mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-26 10:29:23 +01:00
fix GCC build
This commit is contained in:
parent
62d1451885
commit
5c919177d9
16
src/hook.c
16
src/hook.c
@ -42,6 +42,10 @@ void Hook_PatchIAT(HMODULE hMod, char *moduleName, char *functionName, PROC newF
|
|||||||
if (!hMod || hMod == INVALID_HANDLE_VALUE || !newFunction)
|
if (!hMod || hMod == INVALID_HANDLE_VALUE || !newFunction)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
__try
|
||||||
|
{
|
||||||
|
#endif
|
||||||
PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)hMod;
|
PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)hMod;
|
||||||
if (pDosHeader->e_magic != IMAGE_DOS_SIGNATURE)
|
if (pDosHeader->e_magic != IMAGE_DOS_SIGNATURE)
|
||||||
return;
|
return;
|
||||||
@ -94,6 +98,12 @@ void Hook_PatchIAT(HMODULE hMod, char *moduleName, char *functionName, PROC newF
|
|||||||
|
|
||||||
pImportDescriptor++;
|
pImportDescriptor++;
|
||||||
}
|
}
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
}
|
||||||
|
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hook_Create(char *moduleName, char *functionName, PROC newFunction, PROC *function)
|
void Hook_Create(char *moduleName, char *functionName, PROC newFunction, PROC *function)
|
||||||
@ -213,18 +223,20 @@ void Hook_Init()
|
|||||||
{
|
{
|
||||||
if (!Hook_Active || HookingMethod == 3 || HookingMethod == 4)
|
if (!Hook_Active || HookingMethod == 3 || HookingMethod == 4)
|
||||||
{
|
{
|
||||||
|
#ifdef _MSC_VER
|
||||||
if (!Hook_Active && HookingMethod == 3)
|
if (!Hook_Active && HookingMethod == 3)
|
||||||
{
|
{
|
||||||
FARPROC proc = GetProcAddress(GetModuleHandle("kernelbase.dll"), "LoadLibraryExW");
|
FARPROC proc = GetProcAddress(GetModuleHandle("kernelbase.dll"), "LoadLibraryExW");
|
||||||
|
|
||||||
if (proc)
|
if (proc)
|
||||||
real_LoadLibraryExW = proc;
|
real_LoadLibraryExW = (LOADLIBRARYEXWPROC)proc;
|
||||||
|
|
||||||
DetourTransactionBegin();
|
DetourTransactionBegin();
|
||||||
DetourUpdateThread(GetCurrentThread());
|
DetourUpdateThread(GetCurrentThread());
|
||||||
DetourAttach((PVOID*)&real_LoadLibraryExW, (PVOID)fake_LoadLibraryExW);
|
DetourAttach((PVOID*)&real_LoadLibraryExW, (PVOID)fake_LoadLibraryExW);
|
||||||
DetourTransactionCommit();
|
DetourTransactionCommit();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
Hook_Active = TRUE;
|
Hook_Active = TRUE;
|
||||||
|
|
||||||
@ -266,6 +278,7 @@ void Hook_Exit()
|
|||||||
{
|
{
|
||||||
Hook_Active = FALSE;
|
Hook_Active = FALSE;
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
if (HookingMethod == 3)
|
if (HookingMethod == 3)
|
||||||
{
|
{
|
||||||
DetourTransactionBegin();
|
DetourTransactionBegin();
|
||||||
@ -273,6 +286,7 @@ void Hook_Exit()
|
|||||||
DetourDetach((PVOID*)&real_LoadLibraryExW, (PVOID)fake_LoadLibraryExW);
|
DetourDetach((PVOID*)&real_LoadLibraryExW, (PVOID)fake_LoadLibraryExW);
|
||||||
DetourTransactionCommit();
|
DetourTransactionCommit();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
Hook_Revert("user32.dll", "GetCursorPos", (PROC)fake_GetCursorPos, (PROC *)&real_GetCursorPos);
|
Hook_Revert("user32.dll", "GetCursorPos", (PROC)fake_GetCursorPos, (PROC *)&real_GetCursorPos);
|
||||||
Hook_Revert("user32.dll", "ClipCursor", (PROC)fake_ClipCursor, (PROC *)&real_ClipCursor);
|
Hook_Revert("user32.dll", "ClipCursor", (PROC)fake_ClipCursor, (PROC *)&real_ClipCursor);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user