• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 960
  • Last Modified:

Kernel API hooking

Hello,
I need to write something like antivirus, but designed to protect a single application. I need to create a system-wide function hook via kernel driver (I'm not interested in methods such as global dll injection etc, as they're not safe enough). Unfortunetely, I'm not able to find anything about it on Google... not even a single example of hooking a single function. My point is to hook functions such as Read/WriteProcessMemory.

I've heard about few methods of hooking via kernel driver. Some of them mean patching the target function in all applications (like we would do using dll injection) and some of them require patching just a single address in Call Table (but I couldn't find any examples for this one). I need a reliable method of hooking which won't miss even a single call, and as far as I know, the 2nd which I've mentioned would be the best.

But well, my knowledge on this subject is horrible and that's why I'm asking. Probably there are better ways to achieve it and I'd be thankful for any directions.

So summarizing, I need some examples (preferably C++) of how to hook functions from kernel driver and some directions, what is the best way to do it :) The support for win 2k is not obligatory, XP and Vista is just fine :)

If something is unclear, feel free to ask :) Thanks in advance for your help.
0
Eriandus
Asked:
Eriandus
  • 2
  • 2
1 Solution
 
jkrCommented:
You'll find some nice articles on this issue along with full source code here

http://www.codeproject.com/KB/system/soviet_direct_hooking.aspx ("Hooking the kernel directly")
http://www.codeproject.com/KB/system/soviet_protector.aspx ("Hooking the native API and controlling process creation on a system-wide basis")
http://www.codeproject.com/KB/system/kernelspying.aspx ("Kernel-mode API spying - an ultimate hack")
0
 
EriandusAuthor Commented:
Thanks, I'll test it soon and award points... but I'm facing a silly problem. What compiler should I use for developing drivers and where can I get it (I don't have MSDN subscriber account and I don't live in USA)? I've heard about the DDK but looks like it now got superceded by WDK, and I'm quite confused...
0
 
jkrCommented:
I don't live in the US either, but any VS version should do nowadays - and the WDK seems to be what you need.
0
 
EriandusAuthor Commented:
Thank you for your help ;)
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now