Jump to content

  • Log In with Google      Sign In   
  • Create Account


[C++] DirectInput Hooking component and sample


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Muhammad Haggag   Moderators   -  Reputation: 1357

Like
0Likes
Like

Posted 21 January 2006 - 10:11 PM

This sample demonstrates using DirectInput hooking to send key-presses to DirectInput-based applications, mostly games. It is actually more like a component in that it can readily be used as is, you'll just have to write client applications. The main component is DirectInput-Hook.dll. This DLL exports 2 functions, InstallHook and RemoveHook. The first instructs the DLL to start inspecting the names of all processes loaded afterwards in search for a specific process, and then injecting code into that process to override DirectInput8Create. The process name is specified in a registry key, HKEY_CURRENT_USER\Software\Dinput-Hook. The DLL component intercepts requests to create GUID_SysKeyboard devices and returns a special keyboard device instead. This special keyboard device, on initialization, creates a pipe named "DInput-Pipe". Whenever IDirectInputDevice8::GetDeviceState is called to retrieve the state of the keyboard in immediate mode, the keyboard checks the pipe for any pending messages, reads them, parses them to determine what key-presses to simulate, and returns a keyboard state containing the simulated key-presses. Message format is straight-forward: Strings containing space-seperated lists of integral scan-codes; the values for DIK_* constants. Nothing is done with buffered input. You're free to modify the code if you like, you'll find a couple of hints in the comments. Important things to keep in mind: 1. You must keep the DLL loaded while the target application hasn't stopped using DirectInput. Otherwise, our DirectInput interface implementor objects will be unloaded and the target application will crash. 2. Put the target process name in the registry, and call InstallHook before launching the target process. A sample client application is provided - all it does is hook "Keyboard.exe", one of the DirectInput samples included in the SDK, and sends it 4 key-presses all the time: Escape, 1, 2 and 3. As always, my code is public domain. APIHijack, the hooking library, is not. Contact its author for license details. 2003 and 2005 solutions are included.

Sponsor:

#2 jollyjeffers   Crossbones+   -  Reputation: 1542

Like
0Likes
Like

Posted 22 January 2006 - 12:26 AM

Looks good to me, will see about having a proper look when I've got a bit more free time! I presume this is the final results of what you mentioned in this thread: Help Needed - DirectX and SendKeys?

I'll sticky this for a while so that it gets the attention it deserves [smile]

(Although, that means I'll have to tidy things up around here...)

Keep up the good work!
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

#3 JezzaP   Members   -  Reputation: 113

Like
0Likes
Like

Posted 03 January 2012 - 08:00 AM

does anyone have a local copy of this sample? I really would like to see it but the link is dead.
[href]http://whileboredblog.blogspot.com/[/href] - My Development Blog

#4 badboy3000   Members   -  Reputation: 105

Like
0Likes
Like

Posted 08 June 2012 - 12:29 AM

Who can upload this sample?




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS