2

So this may be a weird question. I'm working with a windows 32-bit executable in IDA that was originally programmed in C/C++ (Mostly likely with Visual Studio .NET 2002). For the virtual function calls, the ABI uses __thiscall, so the callee cleans the stack, and IDA needs to know how many arguments the function takes to account for that in the caller.

The problem is that virtual function calls are done in a way that makes it difficult for IDA to figure out the called function. An example of what the call might look like is this (in Intel syntax, which IDA uses):

mov eax, [ecx]
call dword ptr [eax+4]

with ecx being set to this by the caller. Since there's no easy way to know what dword ptr [eax+4] is referring to, it guesses how many arguments it takes by the variables pushed before the call. The problem is that it often grabs too many push instructions, and keeps including saved registers. This causes it to assume that the function exits with an incorrect stack pointer, and messes up the stack variable references below the call.

I want to tell IDA what the stack change in the call should be to correct this problem, but I can't seem to find the option anywhere. Is this possible? I can't seem to figure this out.

3

You can use Alt-K shortcut to fix the stack pointer. Its documentation is here.

  • This worked great. Thank you so much. I was looking for it in the menu bar, but wasn't finding it. It's apparently in Edit -> Functions -> Change stack pointer... (Found it by looking for the shortcut Alt+K) – LRFLEW Jan 2 '18 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.