move dinput hooks into hook.c

This commit is contained in:
FunkyFr3sh 2021-05-14 01:24:46 +02:00
parent e37aa21ae5
commit 369d3c2b65
5 changed files with 11 additions and 17 deletions

View file

@ -111,15 +111,3 @@ HRESULT WINAPI fake_DirectInput8Create(HINSTANCE hinst, DWORD dwVersion, REFIID
return result;
}
void dinput_hook()
{
hook_patch_iat(GetModuleHandle(NULL), FALSE, "dinput.dll", "DirectInputCreateA", (PROC)fake_DirectInputCreateA);
hook_patch_iat(GetModuleHandle(NULL), FALSE, "dinput8.dll", "DirectInput8Create", (PROC)fake_DirectInput8Create);
}
void dinput_unhook()
{
hook_patch_iat(GetModuleHandle(NULL), TRUE, "dinput.dll", "DirectInputCreateA", (PROC)fake_DirectInputCreateA);
hook_patch_iat(GetModuleHandle(NULL), TRUE, "dinput8.dll", "DirectInput8Create", (PROC)fake_DirectInput8Create);
}

View file

@ -7,7 +7,6 @@
#include "ddclipper.h"
#include "debug.h"
#include "config.h"
#include "directinput.h"
#include "hook.h"
@ -96,7 +95,7 @@ BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
}
timeBeginPeriod(1);
dinput_hook();
hook_early_init();
break;
}
case DLL_PROCESS_DETACH:
@ -107,7 +106,6 @@ BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
timeEndPeriod(1);
hook_exit();
dinput_unhook();
break;
}
}

View file

@ -407,6 +407,12 @@ void hook_init()
}
}
void hook_early_init()
{
hook_patch_iat(GetModuleHandle(NULL), FALSE, "dinput.dll", "DirectInputCreateA", (PROC)fake_DirectInputCreateA);
hook_patch_iat(GetModuleHandle(NULL), FALSE, "dinput8.dll", "DirectInput8Create", (PROC)fake_DirectInput8Create);
}
void hook_exit()
{
if (g_hook_active)
@ -436,4 +442,7 @@ void hook_exit()
hook_revert((hook_list*)&g_hooks);
}
hook_patch_iat(GetModuleHandle(NULL), TRUE, "dinput.dll", "DirectInputCreateA", (PROC)fake_DirectInputCreateA);
hook_patch_iat(GetModuleHandle(NULL), TRUE, "dinput8.dll", "DirectInput8Create", (PROC)fake_DirectInput8Create);
}