Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Const char #11

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion disasm-lib/disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions mhook-lib/mhook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mhook-lib/mhook.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down
12 changes: 6 additions & 6 deletions mhook-test/mhook-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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));
Expand All @@ -214,15 +214,15 @@ 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
Mhook_Unhook((PVOID*)&TrueHeapAlloc);
}

printf("Testing NtClose.\n");
if (Mhook_SetHook((PVOID*)&TrueNtClose, HookNtClose))
if (Mhook_SetHook((PVOID*)&TrueNtClose, (PVOID) HookNtClose))
{
CloseHandle(NULL);
// Remove the hook
Expand Down