diff options
author | Kissaki <kissaki@gmx.de> | 2015-05-16 20:53:25 +0300 |
---|---|---|
committer | Kissaki <kissaki@gmx.de> | 2015-05-16 20:53:25 +0300 |
commit | fd223b5b9b37065d2d6b6eb23dc379d4bb453c58 (patch) | |
tree | abbeb919f7fdec521878b6052d1b41201dbd341c | |
parent | 080492d61c026d07a4b086eed4784a20dd19f03e (diff) |
Add function to translate status value to string
-rw-r--r-- | include/MinHook.h | 3 | ||||
-rw-r--r-- | src/hook.c | 27 |
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 @@ -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)"; +} |