diff options
| author | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 13:17:26 -0500 |
|---|---|---|
| committer | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 13:17:26 -0500 |
| commit | 89d191af095053ce7f0df639aa4c70021df91039 (patch) | |
| tree | 12df01bf9520bb314b36bf4ac0c2b72e7475c200 /runtime/src/pe_loader.cpp | |
| parent | f8175dc5014379966530e3169440ec1508bc4787 (diff) | |
| parent | 585143544e76954905535335ab98e7ab2ea7c23c (diff) | |
Merge pull request #2734 from admin
Diffstat (limited to 'runtime/src/pe_loader.cpp')
| -rw-r--r-- | runtime/src/pe_loader.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/runtime/src/pe_loader.cpp b/runtime/src/pe_loader.cpp index 054598c6e..f2c62ec91 100644 --- a/runtime/src/pe_loader.cpp +++ b/runtime/src/pe_loader.cpp | |||
| @@ -697,7 +697,6 @@ void Loader::initialise(Module& m) { | |||
| 697 | // Only a DLL gets DllMain. An EXE's entry point has a different signature and is the caller's to run. | 697 | // Only a DLL gets DllMain. An EXE's entry point has a different signature and is the caller's to run. |
| 698 | auto* nt = at<IMAGE_NT_HEADERS64>(m.base, reinterpret_cast<IMAGE_DOS_HEADER*>(m.base)->e_lfanew); | 698 | auto* nt = at<IMAGE_NT_HEADERS64>(m.base, reinterpret_cast<IMAGE_DOS_HEADER*>(m.base)->e_lfanew); |
| 699 | if ((nt->FileHeader.Characteristics & IMAGE_FILE_DLL) && m.entry_rva) { | 699 | if ((nt->FileHeader.Characteristics & IMAGE_FILE_DLL) && m.entry_rva) { |
| 700 | if (m.entry_rva >= m.size) throw std::runtime_error(m.name + ": the entry point is outside the image"); | ||
| 701 | auto entry = reinterpret_cast<BOOL(NTAPI*)(void*, DWORD, void*)>(m.base + m.entry_rva); | 700 | auto entry = reinterpret_cast<BOOL(NTAPI*)(void*, DWORD, void*)>(m.base + m.entry_rva); |
| 702 | const BOOL ok = entry(m.base, DLL_PROCESS_ATTACH, nullptr); | 701 | const BOOL ok = entry(m.base, DLL_PROCESS_ATTACH, nullptr); |
| 703 | if (startup_trace::enabled()) | 702 | if (startup_trace::enabled()) |
| @@ -742,6 +741,8 @@ Module& Loader::map_image(const std::filesystem::path& path) { | |||
| 742 | if (!oh.SizeOfImage || oh.SizeOfHeaders < headers_end || oh.SizeOfHeaders > oh.SizeOfImage || | 741 | if (!oh.SizeOfImage || oh.SizeOfHeaders < headers_end || oh.SizeOfHeaders > oh.SizeOfImage || |
| 743 | oh.SizeOfHeaders > file.size()) | 742 | oh.SizeOfHeaders > file.size()) |
| 744 | throw std::runtime_error(name + ": SizeOfHeaders and SizeOfImage don't fit the headers and file"); | 743 | throw std::runtime_error(name + ": SizeOfHeaders and SizeOfImage don't fit the headers and file"); |
| 744 | if (oh.AddressOfEntryPoint && oh.AddressOfEntryPoint >= oh.SizeOfImage) | ||
| 745 | throw std::runtime_error(name + ": the entry point is outside the image"); | ||
| 745 | 746 | ||
| 746 | auto* m = new Module; | 747 | auto* m = new Module; |
| 747 | m->name = name; | 748 | m->name = name; |