Jump to content
Tuts 4 You

Hook a Kernel32 api with a driver?


high6

Recommended Posts

Posted

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

Why you need a driver to hook in user land ? you should use dll instead .

Posted

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.

Posted

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.

Posted
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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...