Windows Detours To Hook
typedef void(WINAPI *tProcessEvent)(class UFunction*, void*, void*);
void WINAPI xProcessEvent ( class UFunction* Function, void* Parms, void* Result);
tProcessEvent oProcessEvent = NULL;
BOOL APIENTRY DllMain (HMODULE hDll, DWORD reason, PVOID lpReserved) // dll main
{
if( reason == DLL_PROCESS_ATTACH ) // on start of the dll
{
oProcessEvent = (tProcessEvent)DetourFunction((BYTE*)GetProcAddress(GetModuleHandleA("Core.dll"),"?ProcessRemoteFunction@UObject@@UAEHPAVUFunction@@PAXPAUFFrame@@@Z"),(BYTE*)xProcessEvent); // hooking the procevent
}
else if( reason == DLL_PROCESS_DETACH ) // when the dll is detached
{
}
return TRUE;
}
struct Event_Render_Parms
{
class UCanvas* Canvas;
};
void WINAPI xProcessEvent (class UFunction* Function, void* Parms, void* Result=NULL)
{
__asm pushad
if (wcsicmp(Function->GetName(), L"Tick") == 0)
{
(((Event_Render_Parms*)Parms)->Canvas);
}
__asm popad
__asm push Result
__asm push Parms
__asm push Function
__asm call oProcessEvent
}
/*
typedef void(WINAPI *ProcEvent_typedef)(class UFunction*,void*,void*);
ProcEvent_typedef OrgProcessEvent;
struct Event_Render_Parms
{
class UCanvas* Canvas;
};
void xPreRender (class UCanvas* Canvas)
{
}
void xPostRender (class UCanvas* Canvas)
{
}
void WINAPI xProcessEvent (class UFunction* Func, void* Parms, void* Result=NULL)
{
__asm pushad
// GLog->Logf(TEXT("[DEBUG] (Pre-ProcessEvent) Function: %ls"), Function->GetFullName(), *GLog);
if (wcsicmp(Func->GetName(), L"Process_PreRender") == 0)
{
xPreRender(((Event_Render_Parms*)Parms)->Canvas);
}
__asm popad
__asm
{
push Result
push Parms
push Func
call OrgProcessEvent
}
__asm pushad
// GLog->Logf(TEXT("[DEBUG] (Post-ProcessEvent) Function: %ls"), Function->GetFullName(), *GLog);
if (wcsicmp(Func->GetName(), L"Process_PostRender") == 0)
{
xPostRender(((Event_Render_Parms*)Parms)->Canvas);
}
__asm popad
}
void HookFunctions ()
{
HMODULE hCore = GetModuleHandleA("Core.dll");
if (hCore != NULL)
{
void *pProcessEvent = (void*)GetProcAddress(hCore, "?GUglyHackFlags@@3KA");
if (pProcessEvent != NULL)
{
OrgProcessEvent = (ProcEvent_typedef)DetourFunction((PBYTE)pProcessEvent, (PBYTE)xProcessEvent);
}
}
}
BOOL APIENTRY DllMain (HMODULE hDll, DWORD Reason, LPVOID lpReserved)
{
if (Reason == DLL_PROCESS_ATTACH)
{
DisableThreadLibraryCalls(hDll);
HookFunctions();
}
return TRUE;
}
I don't exactly understand how all of this works, and when I try to change
?ProcessRemoteFunction@UObject@@UAEHPAVUFunction@@PAXPAUFFrame@@@Z
it doesnt hook. If I wanted to change where it hooked to, what all must I change? Can someone here give me a good tutorial on Windows Detours? Does anyone know where I can get some good documentation on Windows Detours?

