I'm trying to hook this 'recv callback' function and can manage to hook the function. However, when the 'new function' is supposed to return to its caller, it's instead returning to somewhere in stack, causing an access violation while executing opcodes which are actually some data on stack.
I've been trying to debug this for hours but got nowhere. If someone did experience a similar issue and can point me to possible solutions I'd appreciate it very much.
If you've got a clue of what could be the issue and need further information on anything please let me know and I'll try to provide the best I can.
Also need to point that I can call original function(non-hooked) using:
on_recv((char*)buf, ARRAYSIZE(buf), 0, 0x0018F7AC);
Also tried changing myOnRecv to __cdecl and __fastcall but no luck there either.
Upon further debugging I figured that function is returning to whatever was passed as 4th(last) parameter. What could be the reason of this?