Skip to main content
GameDev.net gamedev.net
🔒 Locked

Intercepting DirectInput calls.

Started by Pothead Apr 27, 2003 at 2:48 AM 3 replies 2.1k views
Original Post
Pothead
Pothead
I''m not so pro in win32 programming that I could do this on my own so please help. I want to write a DLL that would intercept all directInput joygetpos(orwhateverthecallis) calls to smooth out all input. here''s the task in very minimal pseudo.. ------------------------------------------------------------------ joypos *buffer i=0 //at load time of dll.. length=4 //this should be configurable function joygetpos() //this is intercepted, not the original { buffer=original joygetpos(); i++; i>=length ? i=0; return (buffer/length); // <-not really like that }
--------------------------------------------------------I'm not crazy, It's the TV that's crazy. Aren't you, TV?--------------------------------------------------------
Corry
Corry
Search on google for apihijack. You are not going to like what you see. It is a tutorial though for doing what you say you want to do. The way it works is it modifies the function tables in the loaded application to point to your function. The other way to do it would be to make your own dinput8.dll. What you''d do there is implement all interfaces, and functions in dinput8.h most of which would be dummy functions which just call the original funtions. Then the function you want to take over, you implement how you see fit, and then decide whether to call the DInput equivilant or not. Other search terms to use to look this up would be like DLL Hooking. There is a small speed hit involved, and unless you have a good understanding of either win32 asm, and/or COM I would NOT reccomend you try this, instead I would look for a way to work with the DirectInput code, or suggest a feature to MS. The only people I can think of who are really skilled at doing this are video game cheat programmers. This is where I learned what I did. I thought about programming an anti-cheat so I looked up DLL Hooking to figure out how to block it since I heard that is what cheats use. Turns out it looks like at least valve figured out a way to do so, probably random interval md5 checksums that the program runs on itself which would detect if the exe image was modified. The other type of hack is th opengl hack which they make their own fake opengl32.dll which does the above mentioned steps, but now that I think about it, They don''t have any D3D hacks like that, so I doubt you can take over dinput8.dll like that. Well that should get you started. If you make it through any of the reading on pages with those search terms you''ll likely learn more about windows than you ever wanted....like the PE File header format....but I digress
Dtag
Dtag
Have a look for Microsofts Detours Library on Google. First Hook the DirectInput8Create Function. Then get the pointer of the function you want to hook and also pass it to detours, in your case you''d want to hook GetDeviceState and GetDeviceData i guess.
Corry
Corry
Interesting, I''ll have to look that up myself!
Corry
Corry
Yup, thats the same thing...but in a nicer format. Rather than having to manually iterate through PE Headers, find the DLL you want, iterate through its PE Header, find the function you want, and repmap it...Didn''t know MS made a library to do that...very cool.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.