diff --git a/disasm-lib/disasm.c b/disasm-lib/disasm.c index 03076b1..14899dc 100644 --- a/disasm-lib/disasm.c +++ b/disasm-lib/disasm.c @@ -37,7 +37,7 @@ typedef struct _DISASM_ARG_INFO ////////////////////////////////////////////////////////////////////// BOOL InitInstruction(INSTRUCTION *Instruction, DISASSEMBLER *Disassembler); -struct _ARCHITECTURE_FORMAT *GetArchitectureFormat(ARCHITECTURE_TYPE Type); +static struct _ARCHITECTURE_FORMAT *GetArchitectureFormat(ARCHITECTURE_TYPE Type); ////////////////////////////////////////////////////////////////////// // Disassembler setup diff --git a/mhook-lib/mhook.cpp b/mhook-lib/mhook.cpp index d87615c..a66ec38 100644 --- a/mhook-lib/mhook.cpp +++ b/mhook-lib/mhook.cpp @@ -463,7 +463,7 @@ static MHOOKS_TRAMPOLINE* BlockAlloc(PBYTE pSystemFunction, PBYTE pbLower, PBYTE ::GetSystemInfo(&sSysInfo); // Always allocate in bulk, in case the system actually has a smaller allocation granularity than MINALLOCSIZE. - const ptrdiff_t cAllocSize = max(sSysInfo.dwAllocationGranularity, MHOOK_MINALLOCSIZE); + const ptrdiff_t cAllocSize = MAX(sSysInfo.dwAllocationGranularity, MHOOK_MINALLOCSIZE); MHOOKS_TRAMPOLINE* pRetVal = NULL; PBYTE pModuleGuess = (PBYTE) RoundDown((size_t)pSystemFunction, cAllocSize); @@ -1216,7 +1216,7 @@ int Mhook_SetHookEx(HOOK_INFO* hooks, int hookCount) for (int idx = 0; idx < hookCount; idx++) { - hookCtx[idx].pSystemFunction = *hooks[idx].ppSystemFunction; + hookCtx[idx].pSystemFunction = hooks[idx].pSystemFunction; hookCtx[idx].pHookFunction = hooks[idx].pHookFunction; hookCtx[idx].pTrampoline = NULL; hookCtx[idx].dwInstructionLength = 0; @@ -1365,7 +1365,7 @@ int Mhook_SetHookEx(HOOK_INFO* hooks, int hookCount) { // this is what the application will use as the entry point // to the "original" unhooked function. - *hooks[i].ppSystemFunction = hookCtx[i].pTrampoline->codeTrampoline; + hooks[i].pSystemFunction = hookCtx[i].pTrampoline->codeTrampoline; } // flush instruction cache and restore original protection diff --git a/mhook-lib/mhook.h b/mhook-lib/mhook.h index 5332e17..77f6264 100644 --- a/mhook-lib/mhook.h +++ b/mhook-lib/mhook.h @@ -26,7 +26,7 @@ struct HOOK_INFO { - PVOID *ppSystemFunction; // pointer to pointer to function to be hooked + PVOID pSystemFunction; // pointer to function to be hooked PVOID pHookFunction; // hook function }; diff --git a/mhook-test/mhook-test.cpp b/mhook-test/mhook-test.cpp index 06c0b2d..84dd524 100644 --- a/mhook-test/mhook-test.cpp +++ b/mhook-test/mhook-test.cpp @@ -127,7 +127,7 @@ int wmain(int argc, WCHAR* argv[]) HANDLE hProc = NULL; // Set the hook - if (Mhook_SetHook((PVOID*)&TrueNtOpenProcess, HookNtOpenProcess)) + if (Mhook_SetHook((PVOID*)&TrueNtOpenProcess, (PVOID) HookNtOpenProcess)) { // Now call OpenProcess and observe NtOpenProcess being redirected // under the hood. @@ -165,7 +165,7 @@ int wmain(int argc, WCHAR* argv[]) // extra work under the hood to make things work properly. This really // is more of a test case rather than a demo.) printf("Testing SelectObject.\n"); - if (Mhook_SetHook((PVOID*)&TrueSelectObject, HookSelectobject)) + if (Mhook_SetHook((PVOID*)&TrueSelectObject, (PVOID) HookSelectobject)) { // error checking omitted for brevity. doesn't matter much // in this context anyway. @@ -182,13 +182,13 @@ int wmain(int argc, WCHAR* argv[]) } printf("Testing getaddrinfo.\n"); - if (Mhook_SetHook((PVOID*)&Truegetaddrinfo, Hookgetaddrinfo)) + if (Mhook_SetHook((PVOID*)&Truegetaddrinfo, (PVOID) Hookgetaddrinfo)) { // error checking omitted for brevity. doesn't matter much // in this context anyway. WSADATA wd = {0}; WSAStartup(MAKEWORD(2, 2), &wd); - char* ip = "localhost"; + const char* ip = "localhost"; struct addrinfo aiHints; struct addrinfo *res = NULL; memset(&aiHints, 0, sizeof(aiHints)); @@ -214,7 +214,7 @@ int wmain(int argc, WCHAR* argv[]) } printf("Testing HeapAlloc.\n"); - if (Mhook_SetHook((PVOID*)&TrueHeapAlloc, HookHeapAlloc)) + if (Mhook_SetHook((PVOID*)&TrueHeapAlloc, (PVOID) HookHeapAlloc)) { free(malloc(10)); // Remove the hook @@ -222,7 +222,7 @@ int wmain(int argc, WCHAR* argv[]) } printf("Testing NtClose.\n"); - if (Mhook_SetHook((PVOID*)&TrueNtClose, HookNtClose)) + if (Mhook_SetHook((PVOID*)&TrueNtClose, (PVOID) HookNtClose)) { CloseHandle(NULL); // Remove the hook