validate nt-header signature

This commit is contained in:
otavepto 2024-05-06 23:29:17 +03:00
parent 6fbc37630b
commit 47d48829a9

View File

@ -28,7 +28,12 @@ PIMAGE_NT_HEADERS pe_helpers::get_nt_header(HMODULE hModule)
return nullptr;
}
LONG newExeHeaderOffset = dosHeader->e_lfanew;
return (PIMAGE_NT_HEADERS)((char*)hModule + newExeHeaderOffset);
PIMAGE_NT_HEADERS ntHeader = (PIMAGE_NT_HEADERS)((char*)hModule + newExeHeaderOffset);
if (!ntHeader || ntHeader->Signature != 0x00004550) { // "PE\0\0"
return nullptr;
}
return ntHeader;
}
PIMAGE_FILE_HEADER pe_helpers::get_file_header(HMODULE hModule)