• Advertisement
Sign in to follow this  

Boost.Function __stdcall, __fastcall, etc

This topic is 2857 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I inject my dll into the process space of a game, and Im trying to create a function pointer to a function defined inside the games dll. If I use normal function pointers, it will work:
typedef void(__stdcall *FunctionPtr_t)(void);
FunctionPtr_t myFuncPtr = &SomeFunc;
But if I try to use boost::function, I get compile time errors:
boost::function<void __stdcall(void)> myBoostFuncPtr;
error C2079: 'myBoostFuncPtr' uses undefined class 'boost::function<Signature>'
If I remove the __stdcall it compiles just fine... Any ideas on how to get this to work?

Share this post


Link to post
Share on other sites
Advertisement
Thank you for the reply, I have tried defining BOOST_BIND_ENABLE_STDCALL before including the boost header files, but I still get the same compile error.

Share this post


Link to post
Share on other sites
Try doing it in your project files. I don't know why they imply doing it in a source is workable: In order to get it to work with #defines, you would have to make sure it's before the FIRST #include <boost/bind.hpp> in the entire Translation Unit, which is tantamount to #defining it before EVERY #include <boost/bind.hpp> in your ENTIRE PROJECT/solution/etc.

Share this post


Link to post
Share on other sites
You shouldn't need to make __stdcall part of the boost::function<> type; it should be able to adapt function pointers regardless of the calling convention.

Share this post


Link to post
Share on other sites
Quote:
Original post by SiCrane
You shouldn't need to make __stdcall part of the boost::function<> type; it should be able to adapt function pointers regardless of the calling convention.

When I don't specify a calling convention, and I compile a Debug build, I get the following runtime error:
Quote:
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 with one calling convention with a function pointer declared with a different calling convention.

I have the option of Aborting, Retrying, and Ignoring.
When I click Retry, it works..

If I compile a Release build instead of a Debug build, it works just fine.
I wonder if it is still having a problem, but is silent about it because its not a Debug build...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement