diff options
author | Tsuda Kageyu <tsuda.kageyu@gmail.com> | 2016-02-22 18:01:17 +0300 |
---|---|---|
committer | Tsuda Kageyu <tsuda.kageyu@gmail.com> | 2016-02-22 18:01:17 +0300 |
commit | d675576d4a2c033f0a3062935bcb19bb824c43cf (patch) | |
tree | 986a947ab204a239e994351ada6e34df1213c498 | |
parent | 8cd8435ffcc1e508bab6e845b9a979aa170f7f66 (diff) |
Add MH_CreateHookApiEx() function.
It's basically the same as MH_CreateHookApi() but can return the pointer to the target function.
-rw-r--r-- | include/MinHook.h | 17 | ||||
-rw-r--r-- | src/hook.c | 11 |
2 files changed, 28 insertions, 0 deletions
diff --git a/include/MinHook.h b/include/MinHook.h index 70879df..8b467f0 100644 --- a/include/MinHook.h +++ b/include/MinHook.h @@ -124,6 +124,23 @@ extern "C" { MH_STATUS WINAPI MH_CreateHookApi( LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal); + // Creates a Hook for the specified API function, in disabled state. + // Parameters: + // pszModule [in] A pointer to the loaded module name which contains the + // target function. + // pszTarget [in] A pointer to the target function name, which will be + // overridden by the detour function. + // pDetour [in] A pointer to the detour function, which will override + // the target function. + // ppOriginal [out] A pointer to the trampoline function, which will be + // used to call the original target function. + // This parameter can be NULL. + // ppTarget [out] A pointer to the target function, which will be used + // with other functions. + // This parameter can be NULL. + MH_STATUS WINAPI MH_CreateHookApiEx( + LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal, LPVOID *ppTarget); + // Removes an already created hook. // Parameters: // pTarget [in] A pointer to the target function. @@ -836,6 +836,14 @@ MH_STATUS WINAPI MH_ApplyQueued(VOID) MH_STATUS WINAPI MH_CreateHookApi( LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal) { + return MH_CreateHookApiEx(pszModule, pszProcName, pDetour, ppOriginal, NULL); +} + +//------------------------------------------------------------------------- +MH_STATUS WINAPI MH_CreateHookApiEx( + LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, + LPVOID *ppOriginal, LPVOID *ppTarget) +{ HMODULE hModule; LPVOID pTarget; @@ -847,6 +855,9 @@ MH_STATUS WINAPI MH_CreateHookApi( if (pTarget == NULL) return MH_ERROR_FUNCTION_NOT_FOUND; + if(ppTarget != NULL) + *ppTarget = pTarget; + return MH_CreateHook(pTarget, pDetour, ppOriginal); } |