Skip to content

Commit e20b9c5

Browse files
committed
Log message for memory block tracking now more descriptive
1 parent 8234e60 commit e20b9c5

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

PackerAttackerHook/UnpackingEngine.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ DWORD UnpackingEngine::getProcessIdIfRemote(HANDLE process)
198198
return (pid == this->processID) ? 0 : pid;
199199
}
200200

201-
ULONG UnpackingEngine::processMemoryBlockFromHook(DWORD address, DWORD size, ULONG newProtection, ULONG oldProtection, bool considerOldProtection)
201+
ULONG UnpackingEngine::processMemoryBlockFromHook(const char* source, DWORD address, DWORD size, ULONG newProtection, ULONG oldProtection, bool considerOldProtection)
202202
{
203203
PVOID _address = (PVOID)address;
204204
DWORD _size = size;
@@ -219,7 +219,7 @@ ULONG UnpackingEngine::processMemoryBlockFromHook(DWORD address, DWORD size, ULO
219219
/* this is a PE section being set to writeable, track it */
220220
this->origNtProtectVirtualMemory(GetCurrentProcess(), &_address, &_size, REMOVE_WRITEABLE_PROT(newProtection), &_oldProtection);
221221
this->writeablePEBlocks.startTracking(address, size, newProtection);
222-
Logger::getInstance()->write("Placed write hook on PE section at 0x%08x", address);
222+
Logger::getInstance()->write("[%s] Placed write hook on PE section at 0x%08x", source, address);
223223
}
224224
else if (IS_EXECUTABLE_PROT(newProtection))
225225
{
@@ -228,7 +228,7 @@ ULONG UnpackingEngine::processMemoryBlockFromHook(DWORD address, DWORD size, ULO
228228
{
229229
this->executableBlocks.startTracking(address, size, (DWORD)newProtection);
230230
this->origNtProtectVirtualMemory(GetCurrentProcess(), &_address, &_size, REMOVE_EXECUTABLE_PROT(newProtection), &_oldProtection);
231-
Logger::getInstance()->write("Placed execution hook on 0x%08x", address);
231+
Logger::getInstance()->write("[%s] Placed execution hook on 0x%08x", source, address);
232232
}
233233
}
234234
else
@@ -238,7 +238,7 @@ ULONG UnpackingEngine::processMemoryBlockFromHook(DWORD address, DWORD size, ULO
238238
if (it != this->executableBlocks.nullMarker())
239239
{
240240
this->executableBlocks.stopTracking(it);
241-
Logger::getInstance()->write("Removed execution hook on 0x%08x", address);
241+
Logger::getInstance()->write("[%s] Removed execution hook on 0x%08x", source, address);
242242
}
243243
}
244244

@@ -263,7 +263,7 @@ NTSTATUS UnpackingEngine::onNtProtectVirtualMemory(HANDLE process, PVOID* baseAd
263263

264264
if (ret == 0 && this->hooksReady && (process == INVALID_HANDLE_VALUE || GetProcessId(process) == this->processID))
265265
{
266-
_oldProtection = this->processMemoryBlockFromHook((DWORD)*baseAddress, (DWORD)*numberOfBytes, newProtection, *OldProtection, true);
266+
_oldProtection = this->processMemoryBlockFromHook("onNtProtectVirtualMemory", (DWORD)*baseAddress, (DWORD)*numberOfBytes, newProtection, *OldProtection, true);
267267
if (OldProtection)
268268
*OldProtection = _oldProtection;
269269
}
@@ -426,7 +426,7 @@ NTSTATUS WINAPI UnpackingEngine::onNtAllocateVirtualMemory(HANDLE ProcessHandle,
426426
this->inAllocationHook = false;
427427

428428
if (ret == 0 && this->hooksReady && (ProcessHandle == INVALID_HANDLE_VALUE || GetProcessId(ProcessHandle) == this->processID))
429-
this->processMemoryBlockFromHook((DWORD)*BaseAddress, (DWORD)*RegionSize, Protect, NULL, false);
429+
this->processMemoryBlockFromHook("onNtAllocateVirtualMemory", (DWORD)*BaseAddress, (DWORD)*RegionSize, Protect, NULL, false);
430430

431431
return ret;
432432
}

PackerAttackerHook/UnpackingEngine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class UnpackingEngine
8080
void dumpMemoryBlock(TrackedMemoryBlock block, DWORD ep);
8181
void dumpMemoryBlock(char* fileName, DWORD size, const unsigned char* data);
8282
DWORD getProcessIdIfRemote(HANDLE process);
83-
ULONG processMemoryBlockFromHook(DWORD address, DWORD size, ULONG newProtection, ULONG oldProtection, bool considerOldProtection);
83+
ULONG processMemoryBlockFromHook(const char* source, DWORD address, DWORD size, ULONG newProtection, ULONG oldProtection, bool considerOldProtection);
8484

8585
/* NtProtectVirtualMemory hook */
8686
HOOK_DEFINE_5(NTSTATUS, NTAPI, NtProtectVirtualMemory, HANDLE, PVOID*, PULONG, ULONG, PULONG);

0 commit comments

Comments
 (0)