From bff5e90eda5c559e9191d9ac7f62e2f95409a868 Mon Sep 17 00:00:00 2001 From: Jason Hood Date: Thu, 26 Oct 2017 12:58:17 +1000 Subject: [PATCH] Add some comments --- injdll.c | 3 ++- proctype.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/injdll.c b/injdll.c index 74a4aeb..e243d3a 100644 --- a/injdll.c +++ b/injdll.c @@ -24,9 +24,10 @@ static PVOID FindMem( HANDLE hProcess, PBYTE base, DWORD len ) if ((minfo.State & MEM_FREE) && minfo.RegionSize >= len) { #ifdef _WIN64 - if ((PBYTE)minfo.BaseAddress - base > 0xFfFfFfFf - len) + if ((PBYTE)minfo.BaseAddress - base > 0xFFFFffff - len) return NULL; #endif + // Round up to the allocation granularity, presumed to be 64Ki. mem = VirtualAllocEx( hProcess, (PVOID) (((DWORD_PTR)minfo.BaseAddress + 0xFFFF) & ~0xFFFF), len, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE ); diff --git a/proctype.c b/proctype.c index 0dca45e..7bb6d43 100644 --- a/proctype.c +++ b/proctype.c @@ -63,8 +63,8 @@ int ProcessType( LPPROCESS_INFORMATION ppi, PBYTE* pBase, BOOL* gui ) && !(nt_header.FileHeader.Characteristics & IMAGE_FILE_DLL)) { // Don't load into ansicon.exe, it wants to do that itself. - if (nt_header.OptionalHeader.MajorImageVersion == 20033 && - nt_header.OptionalHeader.MinorImageVersion == 18771) + if (nt_header.OptionalHeader.MajorImageVersion == 20033 && // 'AN' + nt_header.OptionalHeader.MinorImageVersion == 18771) // 'SI' return -1; *pBase = minfo.BaseAddress;