diff options
| author | Nolan Cotter <186326284+NolanCotter@users.noreply.github.com> | 2026-11-22 12:46:24 -0700 |
|---|---|---|
| committer | Nolan Cotter <186326284+NolanCotter@users.noreply.github.com> | 2026-11-22 16:41:17 -0700 |
| commit | 7cd6aa7c934268d941c1437dbc507f80080c957d (patch) | |
| tree | 13b71b41129f573ac947119e71b661a22ad7cedf /runtime/test/loader_test.cpp | |
| parent | d2dbb0b69002e6e410119fd690da8d315ef51779 (diff) | |
loader/tools: review fixes for import routing and the inventory
pe_loader: resolve() and resolve_forwarder() key the DLL name with
dll_key() — lower-case, trailing '.' dropped, ".dll" added when there
is no extension — the file-name rule LoadLibrary applies. Without it an
import naming "GameInput" or "gameinput.dll." missed the shim and
owns_dll lookups while LoadLibraryExA still bound a host namesake.
registry: xaudio2_9.dll ordinals 8-10 classify as hresult (host table
measured: XAudio2CreateV2_9 / WithVersionInfo / WithSharedContexts);
the redist's ordinal table is unconfirmed and stays other.
import_inventory: classify parity for the #1 ordinals; the delay-import
directory (entry 13) is read with the loader's checks; the descriptor
table stops at Name == 0 and unreadable names fail like read_string;
host-bound imports report as host instead of unimplemented thunk
(owns_dll ported); thunk tables deduplicate by RVA under a global cap.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Diffstat (limited to 'runtime/test/loader_test.cpp')
| -rw-r--r-- | runtime/test/loader_test.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/runtime/test/loader_test.cpp b/runtime/test/loader_test.cpp index 71a5ede73..58aae185b 100644 --- a/runtime/test/loader_test.cpp +++ b/runtime/test/loader_test.cpp | |||
| @@ -468,6 +468,23 @@ void test_imports() { | |||
| 468 | dir.Size = sizeof(IMAGE_IMPORT_DESCRIPTOR); | 468 | dir.Size = sizeof(IMAGE_IMPORT_DESCRIPTOR); |
| 469 | expect_rejects("an import thunk table that runs past the image", img); | 469 | expect_rejects("an import thunk table that runs past the image", img); |
| 470 | } | 470 | } |
| 471 | for (const char* dll : {"TestShim", "testshim.dll."}) { | ||
| 472 | // LoadLibrary's file-name rule keys these the same as testshim.dll; without that normalisation the | ||
| 473 | // shim lookup misses while a real host namesake would still bind. | ||
| 474 | const std::string what = std::string("an import naming ") + dll + " resolves to testshim.dll's shim"; | ||
| 475 | auto importer = write_image_as(make_import_image(dll, "F"), "importer_key.exe"); | ||
| 476 | try { | ||
| 477 | rt::Loader loader(g_dir); | ||
| 478 | rt::Module& m = loader.load(importer); | ||
| 479 | if (m.imports.size() != 1 || m.imports[0].binding != rt::Binding::Shim) | ||
| 480 | return failed(what.c_str(), "the import did not bind as a shim"); | ||
| 481 | if (*reinterpret_cast<void**>(m.base + 0x1180) != reinterpret_cast<void*>(&test_shim_function)) | ||
| 482 | return failed(what.c_str(), "the address table does not hold the shim function"); | ||
| 483 | pass(what.c_str()); | ||
| 484 | } catch (const std::exception& e) { | ||
| 485 | failed(what.c_str(), e.what()); | ||
| 486 | } | ||
| 487 | } | ||
| 471 | } | 488 | } |
| 472 | 489 | ||
| 473 | void test_import_name_rvas() { | 490 | void test_import_name_rvas() { |