mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-15 06:04:49 +01:00
move dinput hooks into hook.c
This commit is contained in:
parent
e37aa21ae5
commit
369d3c2b65
@ -13,8 +13,6 @@ typedef HRESULT(WINAPI* DIDGETDEVICEDATAPROC)(IDirectInputDeviceA*, DWORD, LPDID
|
||||
extern DIRECTINPUTCREATEAPROC real_DirectInputCreateA;
|
||||
extern DIRECTINPUT8CREATEPROC real_DirectInput8Create;
|
||||
|
||||
void dinput_hook();
|
||||
void dinput_unhook();
|
||||
HRESULT WINAPI fake_DirectInputCreateA(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA* lplpDirectInput, LPUNKNOWN punkOuter);
|
||||
HRESULT WINAPI fake_DirectInput8Create(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPDIRECTINPUT8* ppvOut, LPUNKNOWN punkOuter);
|
||||
|
||||
|
@ -64,6 +64,7 @@ extern int g_hook_method;
|
||||
extern BOOL g_hook_active;
|
||||
|
||||
void hook_init();
|
||||
void hook_early_init();
|
||||
void hook_exit();
|
||||
void hook_patch_iat(HMODULE hmod, BOOL unhook, char* module_name, char* function_name, PROC new_function);
|
||||
void hook_patch_iat_list(HMODULE hmod, BOOL unhook, hook_list* hooks);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user