Hello,
i just started playing around with detours. Hooking Winapi functions works fine, but i have trouble with detouring e.g. a notepad function.
My Code is :
Code:
#include <windows.h>
#include <detours.h>
#pragma comment(lib, "detours.lib")
int (__stdcall* InsertDateTime)(int x);
int MyInsertDateTime(int x)
{
MessageBoxA( NULL, "A", "a", MB_OK);
return InsertDateTime(x);
}
INT APIENTRY DllMain(HMODULE hDLL, DWORD Reason, LPVOID Reserved)
{
if(DLL_PROCESS_ATTACH == Reason)
{
InsertDateTime = (int (__stdcall*)(int))DetourFunction((PBYTE)0x0100978A, (PBYTE)MyInsertDateTime);
}
return TRUE;
}
It looks right for me, but Winject won't inject the compiled .dll. I always get an error. The error seems to be here , but it is the right address.