From d93120a1223af68ba41d2ee1679c80620e3002cd Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 5 Jan 2025 09:58:06 +0100 Subject: [PATCH] Assert correct PE machine type --- src/windows-emulator/module/module_mapping.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/windows-emulator/module/module_mapping.cpp b/src/windows-emulator/module/module_mapping.cpp index 8e486658..31e9d00e 100644 --- a/src/windows-emulator/module/module_mapping.cpp +++ b/src/windows-emulator/module/module_mapping.cpp @@ -202,6 +202,11 @@ mapped_module map_module_from_data(emulator& emu, const std::span const auto nt_headers = buffer.as(nt_headers_offset).get(); auto& optional_header = nt_headers.OptionalHeader; + if (nt_headers.FileHeader.Machine != IMAGE_FILE_MACHINE_AMD64) + { + throw std::runtime_error("Unsupported architecture!"); + } + binary.image_base = optional_header.ImageBase; binary.size_of_image = page_align_up(optional_header.SizeOfImage); // TODO: Sanitize