2

I'm trying to call a function with a function pointer in C++, but I can't find any convention that fits it. Its stack arguments are (right to left):

func(float x, float y, int unk);

...but ecx needs to be pointing to a buffer it can use for output / storage. That would be __thiscall, but the caller cleans up the stack (adds 12 to esp). This is what I have right now:

((void(__thiscall*)(char*,float,float,int))(0x1234567))(a, b, c);

but it causes the application to crash because the stack isn't evened.

How can I call this?

2
  • that sounds more like a fastcall, if ecx points to an integer store Commented May 11, 2016 at 16:02
  • are you sure ecx is used to pass the buffer and not the class instance? please post a fragment of assembly.
    – Igor Skochinsky
    Commented May 24, 2017 at 0:26

1 Answer 1

2

Sounds like you have a variadic __thiscall function (printf-like). Those use ecx for this but the remaining arguments are pushed onto the stack and the caller cleans it up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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