mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-15 14:14:47 +01:00
some more hook.c tweaks
This commit is contained in:
parent
03100ee84b
commit
822b5c5f32
@ -46,6 +46,6 @@ extern BOOL Hook_Active;
|
||||
void Hook_Init();
|
||||
void Hook_PatchIAT(HMODULE hMod, char *moduleName, char *functionName, PROC newFunction);
|
||||
PROC Hook_HotPatch(PROC function, PROC newFunction);
|
||||
void Hook_TryHotPatch(HMODULE hMod, char *moduleName, char *functionName, PROC newFunction, PROC *function);
|
||||
void Hook_TryHotPatch(char *moduleName, char *functionName, PROC newFunction, PROC *function);
|
||||
|
||||
#endif
|
||||
|
88
src/hook.c
88
src/hook.c
@ -111,15 +111,19 @@ PROC Hook_HotPatch(PROC function, PROC newFunction)
|
||||
return result;
|
||||
}
|
||||
|
||||
void Hook_TryHotPatch(HMODULE hMod, char *moduleName, char *functionName, PROC newFunction, PROC *function)
|
||||
void Hook_TryHotPatch(char *moduleName, char *functionName, PROC newFunction, PROC *function)
|
||||
{
|
||||
PROC org = GetProcAddress(GetModuleHandle(moduleName), functionName);
|
||||
if (org)
|
||||
FARPROC org = GetProcAddress(GetModuleHandle(moduleName), functionName);
|
||||
if (ddraw->hotPatch && org)
|
||||
{
|
||||
*function = Hook_HotPatch(org, newFunction);
|
||||
|
||||
if (*function == org) // hotpatch failed...
|
||||
Hook_PatchIAT(hMod, moduleName, functionName, newFunction);
|
||||
Hook_PatchIAT(GetModuleHandle(NULL), moduleName, functionName, newFunction);
|
||||
}
|
||||
else
|
||||
{
|
||||
Hook_PatchIAT(GetModuleHandle(NULL), moduleName, functionName, newFunction);
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,62 +133,24 @@ void Hook_Init()
|
||||
{
|
||||
Hook_Active = TRUE;
|
||||
|
||||
if (ddraw->hotPatch)
|
||||
{
|
||||
Hook_TryHotPatch(
|
||||
GetModuleHandle(NULL), "user32.dll", "GetCursorPos", (PROC)fake_GetCursorPos, (PROC *)&real_GetCursorPos);
|
||||
Hook_TryHotPatch(
|
||||
GetModuleHandle(NULL), "user32.dll", "ClipCursor", (PROC)fake_ClipCursor, (PROC *)&real_ClipCursor);
|
||||
Hook_TryHotPatch(
|
||||
GetModuleHandle(NULL), "user32.dll", "ShowCursor", (PROC)fake_ShowCursor, (PROC *)&real_ShowCursor);
|
||||
Hook_TryHotPatch(
|
||||
GetModuleHandle(NULL), "user32.dll", "SetCursor", (PROC)fake_SetCursor, (PROC *)&real_SetCursor);
|
||||
Hook_TryHotPatch(
|
||||
GetModuleHandle(NULL), "user32.dll", "GetWindowRect", (PROC)fake_GetWindowRect, (PROC *)&real_GetWindowRect);
|
||||
Hook_TryHotPatch(
|
||||
GetModuleHandle(NULL), "user32.dll", "GetClientRect", (PROC)fake_GetClientRect, (PROC *)&real_GetClientRect);
|
||||
Hook_TryHotPatch(
|
||||
GetModuleHandle(NULL), "user32.dll", "ClientToScreen", (PROC)fake_ClientToScreen, (PROC *)&real_ClientToScreen);
|
||||
Hook_TryHotPatch(
|
||||
GetModuleHandle(NULL), "user32.dll", "ScreenToClient", (PROC)fake_ScreenToClient, (PROC *)&real_ScreenToClient);
|
||||
Hook_TryHotPatch(
|
||||
GetModuleHandle(NULL), "user32.dll", "SetCursorPos", (PROC)fake_SetCursorPos, (PROC *)&real_SetCursorPos);
|
||||
Hook_TryHotPatch(
|
||||
GetModuleHandle(NULL), "user32.dll", "GetClipCursor", (PROC)fake_GetClipCursor, (PROC *)&real_GetClipCursor);
|
||||
Hook_TryHotPatch(
|
||||
GetModuleHandle(NULL), "user32.dll", "WindowFromPoint", (PROC)fake_WindowFromPoint, (PROC *)&real_WindowFromPoint);
|
||||
Hook_TryHotPatch(
|
||||
GetModuleHandle(NULL), "user32.dll", "GetCursorInfo", (PROC)fake_GetCursorInfo, (PROC *)&real_GetCursorInfo);
|
||||
Hook_TryHotPatch(
|
||||
GetModuleHandle(NULL), "user32.dll", "GetSystemMetrics", (PROC)fake_GetSystemMetrics, (PROC *)&real_GetSystemMetrics);
|
||||
Hook_TryHotPatch(
|
||||
GetModuleHandle(NULL), "user32.dll", "SetWindowPos", (PROC)fake_SetWindowPos, (PROC *)&real_SetWindowPos);
|
||||
Hook_TryHotPatch(
|
||||
GetModuleHandle(NULL), "user32.dll", "MoveWindow", (PROC)fake_MoveWindow, (PROC *)&real_MoveWindow);
|
||||
Hook_TryHotPatch(
|
||||
GetModuleHandle(NULL), "user32.dll", "SendMessageA", (PROC)fake_SendMessageA, (PROC *)&real_SendMessageA);
|
||||
Hook_TryHotPatch(
|
||||
GetModuleHandle(NULL), "user32.dll", "SetWindowLongA", (PROC)fake_SetWindowLongA, (PROC *)&real_SetWindowLongA);
|
||||
}
|
||||
else
|
||||
{
|
||||
Hook_PatchIAT(GetModuleHandle(NULL), "user32.dll", "GetCursorPos", (PROC)fake_GetCursorPos);
|
||||
Hook_PatchIAT(GetModuleHandle(NULL), "user32.dll", "ClipCursor", (PROC)fake_ClipCursor);
|
||||
Hook_PatchIAT(GetModuleHandle(NULL), "user32.dll", "ShowCursor", (PROC)fake_ShowCursor);
|
||||
Hook_PatchIAT(GetModuleHandle(NULL), "user32.dll", "SetCursor", (PROC)fake_SetCursor);
|
||||
Hook_PatchIAT(GetModuleHandle(NULL), "user32.dll", "GetWindowRect", (PROC)fake_GetWindowRect);
|
||||
Hook_PatchIAT(GetModuleHandle(NULL), "user32.dll", "GetClientRect", (PROC)fake_GetClientRect);
|
||||
Hook_PatchIAT(GetModuleHandle(NULL), "user32.dll", "ClientToScreen", (PROC)fake_ClientToScreen);
|
||||
Hook_PatchIAT(GetModuleHandle(NULL), "user32.dll", "ScreenToClient", (PROC)fake_ScreenToClient);
|
||||
Hook_PatchIAT(GetModuleHandle(NULL), "user32.dll", "SetCursorPos", (PROC)fake_SetCursorPos);
|
||||
Hook_PatchIAT(GetModuleHandle(NULL), "user32.dll", "GetClipCursor", (PROC)fake_GetClipCursor);
|
||||
Hook_PatchIAT(GetModuleHandle(NULL), "user32.dll", "WindowFromPoint", (PROC)fake_WindowFromPoint);
|
||||
Hook_PatchIAT(GetModuleHandle(NULL), "user32.dll", "GetCursorInfo", (PROC)fake_GetCursorInfo);
|
||||
Hook_PatchIAT(GetModuleHandle(NULL), "user32.dll", "GetSystemMetrics", (PROC)fake_GetSystemMetrics);
|
||||
Hook_PatchIAT(GetModuleHandle(NULL), "user32.dll", "SetWindowPos", (PROC)fake_SetWindowPos);
|
||||
Hook_PatchIAT(GetModuleHandle(NULL), "user32.dll", "MoveWindow", (PROC)fake_MoveWindow);
|
||||
Hook_PatchIAT(GetModuleHandle(NULL), "user32.dll", "SendMessageA", (PROC)fake_SendMessageA);
|
||||
Hook_PatchIAT(GetModuleHandle(NULL), "user32.dll", "SetWindowLongA", (PROC)fake_SetWindowLongA);
|
||||
}
|
||||
Hook_TryHotPatch("user32.dll", "GetCursorPos", (PROC)fake_GetCursorPos, (PROC *)&real_GetCursorPos);
|
||||
Hook_TryHotPatch("user32.dll", "ClipCursor", (PROC)fake_ClipCursor, (PROC *)&real_ClipCursor);
|
||||
Hook_TryHotPatch("user32.dll", "ShowCursor", (PROC)fake_ShowCursor, (PROC *)&real_ShowCursor);
|
||||
Hook_TryHotPatch("user32.dll", "SetCursor", (PROC)fake_SetCursor, (PROC *)&real_SetCursor);
|
||||
Hook_TryHotPatch("user32.dll", "GetWindowRect", (PROC)fake_GetWindowRect, (PROC *)&real_GetWindowRect);
|
||||
Hook_TryHotPatch("user32.dll", "GetClientRect", (PROC)fake_GetClientRect, (PROC *)&real_GetClientRect);
|
||||
Hook_TryHotPatch("user32.dll", "ClientToScreen", (PROC)fake_ClientToScreen, (PROC *)&real_ClientToScreen);
|
||||
Hook_TryHotPatch("user32.dll", "ScreenToClient", (PROC)fake_ScreenToClient, (PROC *)&real_ScreenToClient);
|
||||
Hook_TryHotPatch("user32.dll", "SetCursorPos", (PROC)fake_SetCursorPos, (PROC *)&real_SetCursorPos);
|
||||
Hook_TryHotPatch("user32.dll", "GetClipCursor", (PROC)fake_GetClipCursor, (PROC *)&real_GetClipCursor);
|
||||
Hook_TryHotPatch("user32.dll", "WindowFromPoint", (PROC)fake_WindowFromPoint, (PROC *)&real_WindowFromPoint);
|
||||
Hook_TryHotPatch("user32.dll", "GetCursorInfo", (PROC)fake_GetCursorInfo, (PROC *)&real_GetCursorInfo);
|
||||
Hook_TryHotPatch("user32.dll", "GetSystemMetrics", (PROC)fake_GetSystemMetrics, (PROC *)&real_GetSystemMetrics);
|
||||
Hook_TryHotPatch("user32.dll", "SetWindowPos", (PROC)fake_SetWindowPos, (PROC *)&real_SetWindowPos);
|
||||
Hook_TryHotPatch("user32.dll", "MoveWindow", (PROC)fake_MoveWindow, (PROC *)&real_MoveWindow);
|
||||
Hook_TryHotPatch("user32.dll", "SendMessageA", (PROC)fake_SendMessageA, (PROC *)&real_SendMessageA);
|
||||
Hook_TryHotPatch("user32.dll", "SetWindowLongA", (PROC)fake_SetWindowLongA, (PROC *)&real_SetWindowLongA);
|
||||
|
||||
//Hook_PatchIAT(GetModuleHandle(NULL), "user32.dll", "GetCursorPos", (PROC)fake_GetCursorPos);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user