what file(s) do i have to #include for the above code to work? i tried #include <detours.h> and <detoured.h> but pFunction isnt showing up as a proper identifier. also, i read about detourfunctionwithtrampoline and detourfunction. where can i find the header files for those functions?
oh silly me, the function type is __cdecl, not __stdcall
ok, using the signatures i found on this forum, i determined the offset of the engine function R_RenderScene is 0x006DF9D0. IDA tells me it accepts 2 args. (int, int)
so heres the code i have:
#define ADDRESS 0x006DF9D0
//int __stdcall R_RenderScene(int x)
int (__stdcall *R_RenderScene_o)(int x, int y);
int __stdcall R_RenderScene(int x,int y)
MessageBox(NULL, L"hooked", L"hooked", MB_OK);
int WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
R_RenderScene_o = (int (__stdcall *)(int,int))DetourFunction((PBYTE)ADDRESS,(PBYTE)R_RenderScene);
after loading a map, a messagebox shows with the text "hooked", showing the hook is working. but after i click ok, i get this:
Program: ...gram Files\Activision\Call of Duty - Black Ops\patchOpsMP.exe
Module: ...documents\visual studio 2010\projects\detour\debug\detour.dll
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 declared with one calling convention with a function pointer declared with a different calling convention.
i tried the code without the messagebox, same problem
Last edited by gruez; 11-20-2010 at 01:24 PM.
Reason: epic fail :(
I am searching a way to send and execute commands by calling function too. I am a bad C++ coder so I hope someone can post source in here. I still dont know what function is now the right one to call after putting the commands to stack !?
004EFA06 |. E8 95071000 CALL BlackOps.005F01A0
I set BP on both and hoped it breakes when executing a command by typing in manual in consol. but it didnt!
thx for help guys!
Last edited by WhiteLionATX; 11-20-2010 at 05:16 PM.
can you give an example how to use with process memory ? I still dont know which offset I should fill (where put the string (offset)/which offset needs to be filled to set send trigger ?)! can you/someone help ?