mirror of
https://github.com/vxcontrol/MemoryModule.git
synced 2026-07-21 14:16:03 -04:00
- debug output disabled by default
- tries to allocate memory at arbitrary address if specified ImageBase is invalid or cannot be allocated
This commit is contained in:
+7
-2
@@ -24,8 +24,6 @@
|
||||
// disable warnings about pointer <-> DWORD conversions
|
||||
#pragma warning( disable : 4311 4312 )
|
||||
|
||||
#define DEBUG_OUTPUT 1
|
||||
|
||||
#include <Windows.h>
|
||||
#include <winnt.h>
|
||||
#ifdef DEBUG_OUTPUT
|
||||
@@ -300,6 +298,13 @@ HMEMORYMODULE MemoryLoadLibrary(const void *data, const size_t size)
|
||||
MEM_RESERVE,
|
||||
PAGE_READWRITE);
|
||||
|
||||
if (code == NULL)
|
||||
// try to allocate memory at arbitrary position
|
||||
code = (unsigned char *)VirtualAlloc(NULL,
|
||||
old_header->OptionalHeader.SizeOfImage,
|
||||
MEM_RESERVE,
|
||||
PAGE_READWRITE);
|
||||
|
||||
if (code == NULL)
|
||||
{
|
||||
#if DEBUG_OUTPUT
|
||||
|
||||
Reference in New Issue
Block a user