Click to See Complete Forum and Search --> : API Hooking question


olin
April 24th, 2005, 07:15 PM
I want to hook some APIs. I has some questions when reading the article on codeguru website
http://www.codeguru.com/Cpp/W-P/dll...ticle.php/c127/

The sample in that article is to hook DirectDrawCreate function in DDRAW.dll, and change it with his own function in his own dll. I am just wondering why he set a global WH_CBT hook but with a callback function doing nothing (just do CallNextHookEx).

When I made some mouse hook or keyborad hook, I always did my work in the callback function, so I am confused that why we changed when do API hooking.

Thanks in advance!

msg555
April 24th, 2005, 09:34 PM
That link didn't take me anywhere so I'm guessing.

He probably create a WH_CBT hook to create an instance of his dll in every process. This would be nessisary if you were trying to hook every call to an api

olin
April 25th, 2005, 09:12 AM
Sorry about the link. it is:

<a href=http://www.codeguru.com/Cpp/W-P/dll/hooking/article.php/c127/>api hooking </a>

I think you are right. So to use WH_CBT hook is just make a chance to create the dll instance for very processes. the hook itself is not essential, and I might use some other types of global hook such as WH_GETMESSAGE hook to do the same job. Am I right? Thank you!

msg555
April 25th, 2005, 02:47 PM
From the link

This code is intended to be included in a DLL inserted through a global Windows Hook (CBT hook for example).
looks like I guessed right