Hooking class methoods (DirectInput)
Hooking class methoods (DirectInput)
I've used MS Detours a bit and I've looked at madcodehook and I was wondering something. I need to hook into DirectInput and I've seen that in madcodehook you can use HookAPI to get the DirectInput8Create() call and then inside there you can use HookCode to hook the CreateDevice() method of the DirectInput8 object created by DirectInput8Create(). Does anyone know if there is a way to do this kind of thing using Detours or does it not have that capability? If so, does anyone have a link or some code so I can see what it would do?
I know this isn't a Detours forum, but I just want to compare the methods and I thought some people here might have some useful info.
Thanks!
I know this isn't a Detours forum, but I just want to compare the methods and I thought some people here might have some useful info.
Thanks!
Last edited by ginsoaked on Tue Oct 19, 2004 12:19 pm, edited 1 time in total.
Sirmabus, have you tried hooking DirectInput (and IDirectInput::CreateDevice()) using MadCodeHook and C++?
Or anyone else, for that matter?
I'm having some trouble with it. I can hook DirectInput8Create() fine, but my CreateDevice() hook never seems to get called.
This is what the HookCode() call looks like:
HookCode(GetInterfaceMethod((IDirectInput8*)DI, 3), DICreateDeviceCallback, (PVOID*) &DICreateDeviceNextHook);
And here's how the functions are defined:
HRESULT (*DICreateDeviceNextHook)(LPVOID Self, REFGUID rguid, LPDIRECTINPUTDEVICE *lplpDirectInputDevice, LPUNKNOWN pUnkOuter);
HRESULT DICreateDeviceCallback(LPVOID Self, REFGUID rguid, LPDIRECTINPUTDEVICE *lplpDirectInputDevice, LPUNKNOWN pUnkOuter);
Is there something special I need to do to hook a class method using HookCode()? (Aside from adding the Self parameter)
Any suggestions or ideas would be appreciated.
Thanks!
Or anyone else, for that matter?
I'm having some trouble with it. I can hook DirectInput8Create() fine, but my CreateDevice() hook never seems to get called.
This is what the HookCode() call looks like:
HookCode(GetInterfaceMethod((IDirectInput8*)DI, 3), DICreateDeviceCallback, (PVOID*) &DICreateDeviceNextHook);
And here's how the functions are defined:
HRESULT (*DICreateDeviceNextHook)(LPVOID Self, REFGUID rguid, LPDIRECTINPUTDEVICE *lplpDirectInputDevice, LPUNKNOWN pUnkOuter);
HRESULT DICreateDeviceCallback(LPVOID Self, REFGUID rguid, LPDIRECTINPUTDEVICE *lplpDirectInputDevice, LPUNKNOWN pUnkOuter);
Is there something special I need to do to hook a class method using HookCode()? (Aside from adding the Self parameter)
Any suggestions or ideas would be appreciated.
Thanks!