我无法打开映射内存。当我使用 OpenFileMappingA() 它返回 NULL 并且 GetLastError() 返回 161 (ERROR_BAD_PATHNAME)。我使用以下代码:
MEMORY_BASIC_INFORMATION mbi = { 0 };
VirtualQuery(image->raw_data, &mbi, sizeof(mbi));
if (mbi.Protect & PAGE_EXECUTE_READWRITE)
ZeroMemory(image->raw_data, sizeof(IMAGE_DOS_HEADER) + sizeof(IMAGE_NT_HEADERS) + sizeof(IMAGE_SECTION_HEADER)* nt_header->FileHeader.NumberOfSections);
else if (mbi.Type & MEM_MAPPED)
{
char buffer[500];
size_t count = GetMappedFileNameA(GetCurrentProcess(), image->raw_data, buffer, sizeof(buffer));
HANDLE hMap = OpenFileMappingA(FILE_MAP_ALL_ACCESS, false, buffer);
std::cout << hMap << std::endl; //0x00000000
std::cout << GetLastError() << std::endl; //161
}