Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are two standard ways I can think of for doing this</p> <ul> <li><p>DLL import table hook.<br> For this you need to parse the PE Header of the DLL, find the import table and write the address of your own function instead of what is already written there. You can save the address of the original function to be able to call it later. The references in the external links of this <a href="http://en.wikipedia.org/wiki/Portable_Executable" rel="noreferrer">wikipedia article</a> should give you all the information you need to be able to do this.</p></li> <li><p>Direct modification of the code. Find the actual code of the function you want to hook and modify the first opcodes of it to jump to your own code. you need to save the opcode which were there so they will eventually get executed. This is simpler than it sounds mostly because it was already implement by no less than Microsoft themselves in the form of the <a href="http://research.microsoft.com/sn/detours/" rel="noreferrer">Detours library</a>.<br> This is a really neat thing to do. with just a couple of lines of code you can for instance replace all calls to GetSystemMetrics() from say outlook.exe and watch the wonders that occur.</p></li> </ul> <p>The advantages of one method are the disadvantages of the other. The first method allows you to add a surgical hook exactly to DLL you want where all other DLLs go by unhooked. The second method allows you the most global kind of hook to intercept all calls do the function.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload