upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/pe_loader.cpp
diff options
context:
space:
mode:
authorDea7hsmiles <188018312+dea7hsmiless@users.noreply.github.com>2026-11-21 13:46:21 -0800
committerDea7hsmiles <188018312+dea7hsmiless@users.noreply.github.com>2026-11-21 15:51:43 -0800
commitf6b3d3a24c533d213178c9a927014abe1fadfc1f (patch)
tree7b917dbb0e351085b6eb56568f12cae2748c3d2f /runtime/src/pe_loader.cpp
parent4abd54571b6efa02d97eda4711792fa00b455dc3 (diff)
Loader: reject a delay-import descriptor with no name table
An IAT without an INT still holds delay thunks, not name RVAs, so eager binding has no symbol to resolve. Reject the form with a clear error. A scan of the installed x64 System32 tree found 4,620 DLLs and 17,558 delay descriptors, none with a missing INT or without dlattrRva. The test now expects the rejection.
Diffstat (limited to 'runtime/src/pe_loader.cpp')
-rw-r--r--runtime/src/pe_loader.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/runtime/src/pe_loader.cpp b/runtime/src/pe_loader.cpp
index ca12273b2..9ac97239f 100644
--- a/runtime/src/pe_loader.cpp
+++ b/runtime/src/pe_loader.cpp
@@ -592,9 +592,12 @@ void Loader::bind_imports(Module& m) {
592 if (!d->ImportAddressTableRVA) 592 if (!d->ImportAddressTableRVA)
593 throw std::runtime_error(m.name + ": a delay-import descriptor has no address table"); 593 throw std::runtime_error(m.name + ": a delay-import descriptor has no address table");
594 std::string dll = read_string(m.name, m.base, m.size, d->DllNameRVA, "a delay-imported DLL name"); 594 std::string dll = read_string(m.name, m.base, m.size, d->DllNameRVA, "a delay-imported DLL name");
595 // The name table is optional: without it, entries are read back through the address table itself. 595 // Without a name table the IAT still holds delay thunks, not import names, so there is no symbol to bind
596 bind_thunks(dll, d->ImportNameTableRVA ? d->ImportNameTableRVA : d->ImportAddressTableRVA, 596 // eagerly. Every MSVC delay descriptor and every System32 DLL has one; reject the form instead of reading
597 d->ImportAddressTableRVA); 597 // thunk addresses as name RVAs.
598 if (!d->ImportNameTableRVA)
599 throw std::runtime_error(m.name + ": a delay-import descriptor has no name table");
600 bind_thunks(dll, d->ImportNameTableRVA, d->ImportAddressTableRVA);
598 } 601 }
599 } 602 }
600} 603}