Jump to content
Tuts 4 You

Best way to call local methods?


Recommended Posts

What is the best way in C++ to call a method?

Current I am doing.

const int Method_Addr = 0x1234;

void Method()




call Method_Addr



Any suggestions? Thanks :D .

Link to comment

Best way would be to define a function pointer:

typedef int (__stdcall * ProcPtr)(char * Somestring, int SomeVal);

You can also leave out the var names if you want...

Now define a ProcPtr, assign the address and call it:

ProcPtr Function1;Function1 = (ProcPtr)0x1234;int RetVal = Function1("high6", 666);

Be sure youre using the right calling convention, this is crucial :)

stdcall would be the choice for windows api and most sdk callbacks

sometimes it's fastcall or something totally different (code optimization can affect this a lot)

Edited by Killboy
Link to comment
call dword ptr [variable]

Would be the more "proper" inline method, and in some cases is required. However I do agree with Killboy, the better way would be to use typedefs.

Edited by Atomos
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...