tools/pe_inspect.py carried a private same_output_path (realpath + normcase +
samefile). CONTRIBUTING asks report writers to use
tools/report_paths.same_report_path, which also folds case on a
case-insensitive macOS volume where normcase does not, and samefile cannot see
a report that is not written yet. same_output_path stays as its alias.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014sDZDAAcsauTL6d8ie67Qo
main (273b3bdf9) added advapi32.dll to owns_dll's host list in
runtime/shims/registry.cpp, so test_runtime_shim_dlls_follow_the_registry
failed after merging main. Add it to _SHIM_HOST_DLLS in the same order.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main's runtime/shims/registry.cpp lists both in owns_dll's host list (the ws2_offline shim replaces
only part of them), so runtime_shim_dlls() reported them as shim off Windows and
test_runtime_shim_dlls_follow_the_registry failed. _SHIM_HOST_DLLS now names them in the same order.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On a host that isn't Windows, classify_dll marked the C runtime and every
system DLL `shim`: the bundled check was case-sensitive (an import of
MSVCP140.dll missed the package's msvcp140.dll), System32 doesn't exist and
the API-set query only works on Windows. The first look's to-do list was
wrong there.
- bundled: the game folder is listed once and compared lower-cased.
- elsewhere than Windows, `system` is checked in the Wine prefix's system32
($WINEPREFIX, else ~/.wine), without case, and API sets through the
prefix's apisetschema.dll (version-6 schema; Wine installs no file for
most of them).
- with no prefix, a DLL that is neither bundled nor owned by the runtime's
shims (SHIM_TABLEs in runtime/shims, less owns_dll's host list) is
"unverified", shown as `system (unverified)`; first_look.ps1 lists those
after the to-do and warns.
- the report's new `system_dlls` field and the Markdown/stdout summary say
where system DLLs were checked. Windows classification is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Data directory 2 was never read, so the report said nothing about the version block, the one part of a PE that
names its build. The block's values are free UTF-16 text that can name the title, so the report holds no value:
- resources: the types present with entry and byte counts; named types are counted, not named.
- version: the fixed file info's numbers (file and product version, flags with their names, OS, type, subtype,
date), the translations, and per string table each standard key with its value's length and SHA-256. A key
outside the standard names is listed by its hash.
- problems: a resource tree or version block that is cut short, loops, points outside the file or has a bad
signature is listed (offsets and counts only); the rest of the report is still written.
The Markdown report gets a Resources section and stdout one line per image with a version block. The tests build
a resource tree and a version block by hand, check that the made-up values reach no output, and cover a missing
directory, a cut file, malformed blocks and a loop in the tree.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Clamp PeImage.string_at() and multi-byte table/directory lookups to the
containing header or mapped section span so entries or unterminated
strings cannot read across into an unmapped raw tail or the next section.
- Add PeImage._range() and check full item width in thunk_names(),
_exports(), _export_module_name(), and _tls_callbacks(), while still
raising PeFormatError when a truncated file ends mid-export or mid-TLS
directory.
- Clamp PeImage.string_at() to the mapped byte range of its header or
section.
- Stop masking non-ordinal PE32+ thunk RVAs with 0x7FFFFFFF so invalid
high bits resolve to "?" instead of aliasing low hint/name entries.
- Add synthetic two-section and PE32+ regression tests in
tests/test_pe_inspect.py.
Claim: https://github.com/ItsNotRexed/Leonida/issues/4084#issuecomment-7088230651
AI-assisted: yes (Antigravity)
Eleven tools treated a nonexistent input folder as a failed run (1). They now print one ERROR line and return 2, while real read failures keep exit 1. image_query_probe imports the hardware oracle only for a GPU run, so --help stays prompt. A table-driven subprocess test covers all eleven; existing expectations are updated.
A 4-byte truncated copy that starts with MZ was rejected as "no MZ header",
but the signature is there: the file is just shorter than the 64-byte MS-DOS
header that carries e_lfanew at 0x3c. The same class of wrong cause sat one
check later, where a cut before or inside the PE header said "no PE signature"
even when PE\0\0 was present and only the bytes after it were missing. The
signature and the length are now checked apart, each reporting its real cause.
Tested with the new ShortHeaderTest (hand-built bytes, parser and CLI paths):
4 of its 6 cases fail without the parser change; the suite runs 50 tests, all
passing, 1 Windows-only skip.
AI-assisted: written by Qwen (model qwen3.8-gx10-claude-compatible).
Co-Authored-By: Qwen qwen3.8-gx10-claude-compatible <noreply@qwen.ai>
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, #1384, #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>
A name pointer identifies an export only through its address table index. Check the same slot for named and ordinal-only exports so an empty or out-of-range slot cannot appear in the report.
open(path, "w") without newline= turns each \n into \r\n on Windows, so the same JSON report, manifest or assembly
listing was CRLF there and LF elsewhere. 91 text-mode writes (open, os.fdopen, Path.write_text) under tools/, scripts/,
make_game.py and runtime/test/shaders/ now pass newline="\n". tests/test_text_write_line_endings.py reads the source
with ast and fails for a writer that forgets it; CONTRIBUTING.md names the convention.
AI-assisted (Claude), on behalf of dev-ewann.
On Windows a redirected stdout uses the console's ANSI code page, and python -I ignores PYTHONUTF8 and
PYTHONIOENCODING, so a caller path with a character outside that code page ended a run with
UnicodeEncodeError as soon as a tool printed it. #1406 fixed make_game.py; every CLI tool in tools/ now starts
its __main__ block the same way (stdout errors="replace").
tests/test_tool_stdout_encoding.py checks every tool's __main__ block and reruns two measured crashes
(analyze_4240_full.py, meshlet_page.py) with a private-use-named input. Found by @abilliontokens.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Three places where the report on an image could be wrong, each reproduced with a synthetic image:
- Data directories: all 16 slots were read whatever NumberOfRvaAndSizes said, so stale bytes past the count showed
up as .pdata functions, TLS callbacks or a relocation directory (has_relocs decides whether the image can load
away from its preferred base). A slot past the count is now empty, as in runtime/src/pe_loader.cpp.
- RVA to file offset: a section's span was max(VirtualSize, SizeOfRawData), so a section whose raw data is longer
than the span to the next one answered the next section's RVAs from its own raw tail. The span is VirtualSize
(SizeOfRawData when that is 0), as the loader maps it.
- Names stopped at 512 characters: a longer decorated import name became "?", and a DLL with a longer name lost
its entry. The bound is 4,096 characters.
tests/test_pe_inspect.py: nine new tests, seven of which fail on the old code. No game files; synthetic images only.
_exports() listed every index below NumberOfFunctions that had no name as
#<ordinal>, without reading AddressOfFunctions. A zero RVA there marks an
unused ordinal, so an image with gaps in its ordinals got exports that do
not exist and a count that was too high. Each unnamed slot's RVA is read
now; a zero one, or one the file does not hold, is left out. A forwarder
stays.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Reports were named after the image's stem, so game.exe + game.dll, or a/x.exe +
b/x.exe, in one call wrote the same <out>/<stem>.json/.md and the last one won,
with exit 0. Reports are now named after the full file name (game.exe.json,
game.dll.md); a second image with the same file name from another directory
gets a numbered suffix (x.exe-2.json), compared case-insensitively, and the
name used is printed to stderr. The same path given twice is inspected once.
scripts/first_look.ps1, the only consumer of the report name, reads
<exe file name>.json. Tests cover the exe/dll pair and the two-directory case.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A file cut off inside the optional header, the export directory, the TLS directory or an import lookup table
raised struct.error. main() catches only PeFormatError and OSError, so a run over several images ended in a
traceback at that file and the rest were never inspected. The optional header's fixed fields are now
length-checked, and inspect() turns any remaining struct.error into PeFormatError, which main() reports as
"not a PE image (...)" before moving on.
The two export loops also ran to NumberOfFunctions / NumberOfNames as read from the file, so a corrupt count
near 2^32 kept a run busy indefinitely. They are now capped at MAX_ENTRIES like the import, thunk and TLS
loops, whose comment already says that is what the cap is for.
Tests: TruncatedImageTest in tests/test_pe_inspect.py (each table cut short, a sweep over cut lengths for
PE32 and PE32+, a CLI run that keeps going after a truncated file, and a 0xFFFFFFFF export count).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tools/pe_inspect.py imported pefile at module level, which the contributing rules do not allow, and which kept
the tool out of the standard-library check job: no test imported it, so CI only syntax-checked it while
scripts/first_look.ps1 still ran it on the executable people bring. It now reads the DOS and NT headers, the
section table and the import, delay-import, export, TLS and relocation directories with struct, and writes the
same JSON and Markdown with the same keys.
Delay-import descriptors without dlattrRva store 32-bit virtual addresses, so they are converted with the image
base instead of being read as RVAs. The Markdown shim list no longer tests for a classifier result that is never
produced.
tests/test_pe_inspect.py builds a 64-bit and a 32-bit image byte by byte and covers both descriptor forms,
imports by name and ordinal, an ordinal-only export, .pdata and TLS callback counts, DLL classification, the
CLI's output files and its rejection path.
Shader pipeline (carve, FSSM unpack, gfx1013 disassembly, RDNA2 to SPIR-V),
asset export via rpf9-explorer's Core (submodule), PE loader and shim
skeleton, and make_game.py, which builds from the user's own copy of the game.
No game data, keys or executables are included.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>