How do I go about hooking/redirecting a function in a DLL (say, CreateThread
from Kernel32.dll) loaded in the current process?
(I don't have control over which pieces of code call CreateThread
, so it's not like I can just have the code something else instead.)
The language doesn't matter much; I'm guessing C/C++ would be the best choices for this.
Update:
I forgot to mention: I'm not looking for solutions that require the bundling of extra libraries into my program; I was looking for a manual way of doing the hooking (such as by rewriting the address of the function), not for using an external library to do this.
But thanks to those who mentioned an external library; sorry I didn't say this earlier.