title: How to use DetourAttach() for a pointer to a function in hex?
body: <p>I am trying to make a tutorial using the detour library.</p>
  
  <p>In older version of the detour library v1.5 the function DetourFunction was used to define the address so the DLL knows where to look for the function.</p>
  
  <p>It could for example be used as follows:</p>
  
  <pre><code>         InsertDateTime = (int (__stdcall*)(int))DetourFunction((PBYTE)0x01006F10,       (PBYTE)MyInsertDateTime)
  </code></pre>
  
  <p>see <a href="http://www.moddb.com/groups/ibepex/tutorials/function-hooking" rel="nofollow">http://www.moddb.com/groups/ibepex/tutorials/function-hooking</a></p>
  
  <p>However in newer versions the function is changed to </p>
  
  <pre><code>     LONG DetourAttach(
          PVOID * ppPointer,
          PVOID pDetour
       );
  </code></pre>
  
  <p>where ppPointer is a pointer to the target pointer to which the detour will be attached.</p>
  
  <p>Now since I know the adress of the target function in hex format, 0x01006F10, I want to somehow use that as an argument for ppPointer. I tried to just write:</p>
  
  <pre><code>               InsertDateTime = (int (__stdcall*)(int))DetourAttach((PVOID*)0x01006F10, MyInsertDateTime);
  </code></pre>
  
  <p>and it compiles fine but my program does not work as I thought. It seems that the program never catches the function from that adress.</p>
  
  <p>So basically my question is, did I use the pointer to the hex adress correctly and second, do I have some fundamental mistakes in the way I use DetourAttach()?</p>