This commit is contained in:
Boring
2020-02-03 18:01:56 +08:00
parent 8c8b8e2f4d
commit 06023a00e4
10 changed files with 234 additions and 42 deletions
+2 -8
View File
@@ -5,9 +5,6 @@
#include "rtltype.h"
#include "ntstatus.h"
#include <algorithm>
#ifdef DEBUG_OUTPUT
#include <stdio.h>
#endif
#if _MSC_VER
#pragma warning(disable:4055)
@@ -17,10 +14,6 @@
#define inline __inline
#endif
#ifndef IMAGE_SIZEOF_BASE_RELOCATION
#define IMAGE_SIZEOF_BASE_RELOCATION (sizeof(IMAGE_BASE_RELOCATION))
#endif
#ifdef _WIN64
#define HOST_MACHINE IMAGE_FILE_MACHINE_AMD64
#else
@@ -549,7 +542,7 @@ static int _find(const void* a, const void* b) {
FARPROC MemoryGetProcAddress(HMEMORYMODULE mod, LPCSTR name) {
PMEMORYMODULE module = MapMemoryModuleHandle(mod);
unsigned char* codeBase = module->codeBase - module->headers_align;
unsigned char* codeBase = module->codeBase;
DWORD idx = 0;
PIMAGE_EXPORT_DIRECTORY exports;
PIMAGE_NT_HEADERS headers = GetImageNtHeaders(module);
@@ -632,6 +625,7 @@ bool MemoryFreeLibrary(HMEMORYMODULE mod) {
PIMAGE_NT_HEADERS headers = module ? GetImageNtHeaders(module) : nullptr;
if (!module || module->Signature != MEMORY_MODULE_SIGNATURE || !headers) return false;
if (module->loadFromNtLoadDllMemory && !module->underUnload)return false;
if (module->initialized) {
DllEntryProc DllEntry = (DllEntryProc)(LPVOID)(module->codeBase + headers->OptionalHeader.AddressOfEntryPoint);
(*DllEntry)((HINSTANCE)module->codeBase, DLL_PROCESS_DETACH, 0);