So, I am currently trying to detour SendPacket for obvious reasons. So far I have been able to get the detour working. The Problem is actually when calling the original SendPacket function ( throws an access_violation error at 0x538 ).
I am assuming that this error is caused by either a wrong argument passed to that function or a false calling convention.
Now the issue I had was that SendPacket has the thiscall convention, meaning that I cannot simply detour it since i cannot declare my function as thiscall as well. So if I understood it right then the thiscall basicly stores the This pointer within ecx but the rest of the parameters (pointer to the CDataStore Object) is passed as usual.
This is why I declared my function as stdcall (basicly default but wth) and just saved the ecx register as you can see.
Now if the DataStore pointer is actually valid (it seems that way) I have to assume that the error is caused by my calling convention. The only way I could think of is declaring my function as declspec(naked) meaning i will have to write my own prolog and epilog.
But before doing that I wanted to ask if someone knows why this is hapenning and whether my thoughts are correct. I am sorry if I broke any rules but as far as I can tell I did alot of research and am just asking a question. Comparing to some of the other threads this seems to be okay to post.
Code:typedef void (__thiscall *SendPacket_t)(void*); void __stdcall My_SendPacket(void*); void* pSendPacket = reinterpret_cast<void*>(Base::Rebase(0x90670)); SendPacket_t Real_SendPacket = (SendPacket_t)DetourFunction((PBYTE)pSendPacket,(PBYTE)My_SendPacket); void __stdcall My_SendPacket(void* Arg1) { DWORD This; __asm mov This, ecx; Real_SendPacket(Arg1); // Access violation __asm mov ecx, This; }