title: C++ function hook inside source code of DLL
body: <p>I have the source code from a C++ DLL. This DLL is part of an applicaton. I want to hook a function loaded in memory by another DLL, so that my hooked function gets called by all other DLL's instead of the original function. I put this code in my code:</p>
  
  <pre><code>#include &lt;windows.h&gt;
  #include "detours.h"
  #pragma comment(lib, "detours.lib")
  
  //Function prototype
  int (__stdcall* OriginalFunction)(); 
  
  //Our hook function
  int FunctionHook()
  {
      //Return the real function
      return OriginalFunction(); 
  }
  
  //On attach set the hooks
  OriginalFunction = (int (__stdcall*)())DetourFunction((PBYTE)0x0100344C, (PBYTE)FunctionHook);
  </code></pre>
  
  <p>The question is: Isn't it wrong if I search in ONE DLL for an offset and patch the function by this offset(I think it's more complicated because I'm in another DLL and want to hook the function for all DLL's)? By the way, does somebody know how I can get the standard(fex. 0x0100344C) offsets in IDA PRO?</p>