Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/minhook.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTsuda Kageyu <tsuda.kageyu@gmail.com>2016-02-22 18:01:17 +0300
committerTsuda Kageyu <tsuda.kageyu@gmail.com>2016-02-22 18:01:17 +0300
commitd675576d4a2c033f0a3062935bcb19bb824c43cf (patch)
tree986a947ab204a239e994351ada6e34df1213c498
parent8cd8435ffcc1e508bab6e845b9a979aa170f7f66 (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.h17
-rw-r--r--src/hook.c11
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.
diff --git a/src/hook.c b/src/hook.c
index ca06216..96ebac2 100644
--- a/src/hook.c
+++ b/src/hook.c
@@ -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);
}