high6 Posted July 2, 2009 Posted July 2, 2009 Anyone have an example of hooking a kernel32 api with a driver?Also can more than one driver hook an api at a time?Side question: Can you call a drivers functions directly? Or do you have to do the Read/Write file stream?
GamingMasteR Posted July 3, 2009 Posted July 3, 2009 Why you need a driver to hook in user land ? you should use dll instead .
high6 Posted July 3, 2009 Author Posted July 3, 2009 How do you have a dll load in every process without just creating a remote thread in every process?Also I kinda want to do it with a driver that way another dll cannot override the hook.
Loki Posted July 3, 2009 Posted July 3, 2009 You could try this method - http://support.microsoft.com/kb/197571dlls specified in that reg entry are loaded into every process (assuming user32.dll is loaded)
Killboy Posted July 3, 2009 Posted July 3, 2009 Even if another dll overwrites the hook, what it does is overwrite your JMP with another JMP to its own stub.After that it restores the old instruction and calls the API. So it basically restores your own hook again.Even if it copies the instructions it overwrites to its stub, it will still execute the old JMP. (given it can relocate relative jmps/calls)I'm not even sure what a difference a driver would make. It still has to modify userland memory which can still be overwritten by a dll.Unless you monitor and suppress changes to your hook in memory with your driver, it won't give you any extra protection. Let alone the effort of building a stable driver.
high6 Posted July 3, 2009 Author Posted July 3, 2009 Even if another dll overwrites the hook, what it does is overwrite your JMP with another JMP to its own stub.After that it restores the old instruction and calls the API. So it basically restores your own hook again.Even if it copies the instructions it overwrites to its stub, it will still execute the old JMP. (given it can relocate relative jmps/calls)I'm not even sure what a difference a driver would make. It still has to modify userland memory which can still be overwritten by a dll.Unless you monitor and suppress changes to your hook in memory with your driver, it won't give you any extra protection. Let alone the effort of building a stable driver.I guess you are right.But ya, what I want to do is hook an API and block calls to it. That is why I want my dll on top of everything. I guess I could have a thread running in the background that will detect if the hook is tampered with and repair it if it is.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now