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:
authorKissaki <kissaki@gmx.de>2015-05-16 20:53:25 +0300
committerKissaki <kissaki@gmx.de>2015-05-16 20:53:25 +0300
commitfd223b5b9b37065d2d6b6eb23dc379d4bb453c58 (patch)
treeabbeb919f7fdec521878b6052d1b41201dbd341c
parent080492d61c026d07a4b086eed4784a20dd19f03e (diff)
Add function to translate status value to string
-rw-r--r--include/MinHook.h3
-rw-r--r--src/hook.c27
2 files changed, 30 insertions, 0 deletions
diff --git a/include/MinHook.h b/include/MinHook.h
index 31b9d06..aa6763b 100644
--- a/include/MinHook.h
+++ b/include/MinHook.h
@@ -160,6 +160,9 @@ extern "C" {
// Applies all queued changes in one go.
MH_STATUS WINAPI MH_ApplyQueued(VOID);
+ // Translates the MH_STATUS to its name as a string.
+ const char * WINAPI MH_StatusToString(MH_STATUS status);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/hook.c b/src/hook.c
index ae2d01d..d2bbfd0 100644
--- a/src/hook.c
+++ b/src/hook.c
@@ -843,3 +843,30 @@ MH_STATUS WINAPI MH_CreateHookApi(
return MH_CreateHook(pTarget, pDetour, ppOriginal);
}
+
+//-------------------------------------------------------------------------
+const char * WINAPI MH_StatusToString(MH_STATUS status)
+{
+ #define MH_ST2STR(x) \
+ case x: \
+ return #x;
+
+ switch (status) {
+ MH_ST2STR(MH_UNKNOWN)
+ MH_ST2STR(MH_OK)
+ MH_ST2STR(MH_ERROR_ALREADY_INITIALIZED)
+ MH_ST2STR(MH_ERROR_NOT_INITIALIZED)
+ MH_ST2STR(MH_ERROR_ALREADY_CREATED)
+ MH_ST2STR(MH_ERROR_NOT_CREATED)
+ MH_ST2STR(MH_ERROR_ENABLED)
+ MH_ST2STR(MH_ERROR_DISABLED)
+ MH_ST2STR(MH_ERROR_NOT_EXECUTABLE)
+ MH_ST2STR(MH_ERROR_UNSUPPORTED_FUNCTION)
+ MH_ST2STR(MH_ERROR_MEMORY_ALLOC)
+ MH_ST2STR(MH_ERROR_MEMORY_PROTECT)
+ }
+
+#undef MH_ST2STR
+
+ return "(unknown)";
+}