Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IPCFunc::IPCFunc(void* funcPtr, int cPars) {
- this->pFunc = (IntPtr)funcPtr;
- this->cPars = cPars;
- this->parameters = new int[cPars];
- }
- extern "C" int IPCFunc::invoke() {
- // Create function signature based on cArgs
- if (cPars == 0)
- return ((int(*)())pFunc)();
- auto funcPtr = (int(*)())pFunc;
- int returnValue(0);
- int n_stack = cPars * sizeof(int);
- int p_stack = 0;
- __asm {
- sub esp, n_stack;
- push parameters;
- call funcPtr; // call the function
- mov returnValue, eax; // Save the return value from the function return value register
- pop n_stack; // resume normal functionality
- add esp, n_stack;
- }
- return returnValue;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement