HowTo Add a New Hook

Hooks are implemented based on Microsoft's Detours library, in ABPAEngine DLL To add a hook to a new function, do the following:
  1. In DetouredFunctions.h: add a new typedef for the prototype of the function you want to hook (see some examples for naming conventions).
  2. In same file: OriginalAPI class: add a new static member based on the type you've defined.
  3. In same file: declare a Hook### function, accepting same arguments as original one.
  4. In DetouredFunctions.cpp: implement the Hook### function, use OriginalAPI static functions to call the original version of the function.
  5. In HooksInstaller.cpp: at the beginning of the file, initialize the new static member of OriginalAPI by providing a pointer to real API function.
  6. In InstallHooks function: add DetourAttach call for new function.
  7. In RestoreHooks function: add DetourDetach.

Last edited Jun 1, 2008 at 8:29 AM by migo, version 1

Comments

No comments yet.