Skip to content

pe_inspect: report run-time load candidates (DLL names held as strings, not imported) - #2456

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
Dom-in:pe-inspect-runtime-loads
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
Dom-in:pe-inspect-runtime-loads

Conversation

@Dom-in

@Dom-in Dom-in commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

What and why

Some modules reach others only through LoadLibrary* at run time:

None of those is in an import table, so tools/pe_inspect.py's report didn't show them. Every one was found by hand from the strings.

The change

pe_inspect now reports run-time load candidates: DLL names the image holds as ASCII or UTF-16LE strings without importing them. It's in the JSON as runtime_load_candidates, each entry with name, encoding (ascii/utf-16/both) and where, using the same bundled/system/shim classification as the imports. The markdown report gets a "Run-time load candidates" section.

  • Names the image imports, and the image's own names (its file name and the export-directory name), are left out.
  • A UTF-16 name must follow a NUL or start the data. Otherwise the tail of an ASCII string followed by a wide one reads as a name: the new test caught "a.dll\0" + L"b.dll" coming out as lb.dll.
  • A string isn't proof of a load, and the report says so; it's where to look.

Tests (tests/test_pe_inspect.py, synthetic images)

  • A UTF-16 XGameRuntime.dll and an ASCII gameplatformservices.dll placed into the fixture are reported, while the imported xmem.dll isn't. The fixture's existing non-imported d3d12_xs.dll string is the baseline.
  • dll_strings covers both encodings ("both"), the image's own name in another case, an imported name, and near misses (x.dllz, a bare .dll).

tests/test_pe_inspect.py: 45 passed.

On the package's DLLs (local run, nothing committed), it lists exactly the loads found by hand:

  • XCurl: gameplatformservices.dll and xgameruntime.dll (UTF-16);
  • libHttpClient: xgameruntime.dll and ntdll.dll;
  • the FidelityFX loader: amd_fidelityfx_upscaler_xbox.dll and amd_fidelityfx_framegeneration_xbox.dll.

Disclosure: written with an AI assistant (Claude Code). I reviewed it and ran the tests above.

🤖 Generated with Claude Code

…s, not imported)

A module can reach another one only through LoadLibrary* at run time:
XCurl.dll and libHttpClient.GDK.dll reach xgameruntime.dll that way, and
XCurl also gameplatformservices.dll (docs/runtime_imports.md, ItsNotRexed#1384, ItsNotRexed#2372).
The import table doesn't show those, so pe_inspect's report didn't either.

It now lists DLL names the image holds as ASCII or UTF-16LE strings without
importing them, each with its encoding and the same bundled/system/shim
classification as the imports, in the JSON (runtime_load_candidates) and a
markdown section. The image's own names (file name and export-directory
name) are left out. A UTF-16 name must follow a NUL, so the tail of an ASCII
string followed by a wide one isn't read as a name (the test caught
"a.dll\0" + L"b.dll" reading as "lb.dll").

On the package's DLLs (local run, nothing committed) it lists exactly the
loads found by hand: XCurl gameplatformservices.dll and xgameruntime.dll
(utf-16), libHttpClient xgameruntime.dll and ntdll.dll, the FidelityFX loader
its upscaler and frame-generation DLLs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ricarmandoagent

Copy link
Copy Markdown

Checked 396ebb0693e7021933b37e7038c918d4c274681b (Linux, Python 3.15.2, no game files).

python3 -m compileall -q make_game.py tools tests        # exit 0
python3 -I tests/test_pe_inspect.py                      # Ran 46 tests, OK (skipped=1)
# skipped: test_system_dll_is_classified_system (needs Windows) -> 45 passed, as the PR says
# same tests with only tools/pe_inspect.py reverted to main:
#   ERROR: test_dll_strings_encodings_own_name_and_near_misses
#   ERROR: test_runtime_load_candidates          (dll_strings missing on main)

dll_strings behaves as described on synthetic bytes: UTF-16LE is only read after a NUL, so
"a.dll\0" + L"b.dll" yields a.dll + b.dll and not lb.dll; a name in both encodings is "both";
the image's own file name and export-directory name and imported names are excluded; x.dllz and
a bare .dll are not matched. The new markdown section renders.

Nit (not blocking): candidate names are lowercased by dll_strings while imports reach
classify_dll with their original case, so on a case-sensitive filesystem a bundled XCurl.dll
would not be found as xcurl.dll — the "same bundled/system/shim classification as the imports"
only holds on Windows. docs/design.md:29's one-line pe_inspect summary also does not mention the
new section.

Verdict: passes.

AI-assisted review.

@ItsNotRexed
ItsNotRexed merged commit b9abeef into ItsNotRexed:main Nov 22, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants