I'm trying to figure out the following bit of code.
Based on this code I've created the following class definition.Code:sub_xxxx proc near mov edx, dword_xxxx mov eax, ds:Foo ; << symbol exported from DLL that points to object mov eax, [eax] mov ecx, [eax] push edi push edx push 0Dh push eax mov eax, [ecx+14h] call eax test al, al jnz short loc_xxxx
I call this function using this code.Code:class Foo { public: virtual void func00() = 0; virtual void func04() = 0; virtual void func08() = 0; virtual void func0C() = 0; virtual void func10() = 0; virtual void __cdecl func14(int val) = 0; };
This results in the following code from the compiler.Code:Foo **pFoo = (Foo**)mImports[192]; (*pFoo)->func14(13);
This results in the following runtime error. "Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention."Code:(*pFoo)->func14(13); 00414777 mov esi,esp 00414779 push 0Dh 0041477B mov eax,dword ptr [pFoo] 0041477E mov ecx,dword ptr [eax] 00414780 mov edx,dword ptr [pFoo] 00414783 mov eax,dword ptr [edx] 00414785 mov ecx,dword ptr [ecx] 00414787 push eax 00414788 mov edx,dword ptr [ecx+14h] 0041478B call edx 0041478D add esp,8 00414790 cmp esi,esp 00414792 call @ILT+4925(__RTC_CheckEsp) (412342h)
I verified that my code calls the same function as the client and the function looks like it was executed based on the log output. I'm guessing that I just messed up the function definition. I'm not well versed on the different calling conventions. Would one of you RE gurus kindly point out what I did wrong?
Thanks





Reply With Quote
