title: Hooking API Calls in Current Process?
body: <p>How do I go about hooking/redirecting a function in a DLL (say, <code>CreateThread</code> from Kernel32.dll) loaded in the <em>current</em> process?</p>
  
  <p>(I don't have control over which pieces of code call <code>CreateThread</code>, so it's not like I can just have the code something else instead.)</p>
  
  <p>The language doesn't matter much; I'm guessing C/C++ would be the best choices for this.</p>
  
  <hr>
  
  <p>Update:</p>
  
  <p>I forgot to mention: I'm <em>not</em> 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.</p>
  
  <p>But thanks to those who mentioned an external library; sorry I didn't say this earlier.</p>