OLD-7084: restore old upstream PR 7084 - pe_inspect: classify system DLLs on Linux through the Wine prefix, bundled names without case #653

Manually merged
github merged 6 commits from gh-pr/653/head into gh-pr/653/base 2026-11-26 09:14:06 +00:00
Owner

@⁠aslan2142 on GitHub · 2026-11-24 11:01 UTC · original
aslan2142:pe-inspect-linux-classes → main · +440 −12 · 5 files · 6 commits · merged 2026-11-25 22:19 UTC

Claimed in the coordination issue as: OLD-7084 #14

Restoration of my original pull request, old upstream PR 7084 in ItsNotRexed/Leonida, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Rebased onto main at 21625bca8c; no changes beyond the rebase.

Depends on: #45 (conflicts only in tests/test_pe_inspect.py, both add tests at the end; keeping both blocks resolves it)

What and why

On a host that isn't Windows, classify_dll in tools/pe_inspect.py marked the C runtime and every system DLL as shim, so the first look's to-do list was wrong there. There were three causes:

  • The bundled check was case-sensitive, so an import of MSVCP140.dll missed the package's msvcp140.dll.
  • System32 does not exist there.
  • The API-set query works only on Windows.

The change:

  • Bundled: the game folder is listed once and names are compared lower-cased, as Windows does.
  • System, off Windows: looked up without case in the Wine prefix's system32 ($WINEPREFIX, else ~/.wine). API sets are resolved through the prefix's apisetschema.dll (version-6 schema), because Wine installs no file for most of them.
  • No prefix: a DLL that is neither bundled nor owned by the runtime's shims is reported as unverified, shown as system (unverified). The shims' DLLs are the SHIM_TABLEs in runtime/shims, less the host DLLs that owns_dll leaves out. scripts/first_look.ps1 lists these DLLs after the to-do and prints a warning.
  • Report: a new system_dlls field, plus a line in the Markdown and stdout summaries, says where system DLLs were checked.
  • Docs: docs/design.md (day one, import table) and README.md (set WINEPREFIX on Linux) describe the above.
  • Windows classification is unchanged.

Tested

Linux, Python 3.14.10, CPU only, synthetic PE images and temporary folders standing in for the game folder and the Wine prefix. No game files.

  • python -I tests/test_pe_inspect.py:
    • main, before the change: 60 tests OK (1 skipped).
    • main with only this pull request's tests: 67 tests, 7 errors (pe_inspect has no IS_WINDOWS).
    • this branch: 67 tests OK (1 skipped, test_system_dll_is_classified_system, which needs Windows).
  • python -I tests/test_text_write_line_endings.py: OK.
  • python -m compileall -q tools tests, git diff --check and python -I scripts/check_no_game_data.py on the five changed files: clean.
  • scripts/first_look.ps1 was not run (no PowerShell or game executable here).

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-24 11:01 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/653) `aslan2142:pe-inspect-linux-classes` → `main` · +440 −12 · 5 files · 6 commits · merged 2026-11-25 22:19 UTC Claimed in the coordination issue as: OLD-7084 https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14 Restoration of my original pull request, old upstream PR 7084 in `ItsNotRexed/Leonida`, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Rebased onto main at 21625bca8c675c62f9dbffc318ce6a59d57faf31; no changes beyond the rebase. Depends on: #45 (conflicts only in `tests/test_pe_inspect.py`, both add tests at the end; keeping both blocks resolves it) ### What and why On a host that isn't Windows, `classify_dll` in `tools/pe_inspect.py` marked the C runtime and every system DLL as `shim`, so the first look's to-do list was wrong there. There were three causes: - The bundled check was case-sensitive, so an import of `MSVCP140.dll` missed the package's `msvcp140.dll`. - System32 does not exist there. - The API-set query works only on Windows. The change: - **Bundled:** the game folder is listed once and names are compared lower-cased, as Windows does. - **System, off Windows:** looked up without case in the Wine prefix's `system32` (`$WINEPREFIX`, else `~/.wine`). API sets are resolved through the prefix's `apisetschema.dll` (version-6 schema), because Wine installs no file for most of them. - **No prefix:** a DLL that is neither bundled nor owned by the runtime's shims is reported as `unverified`, shown as `system (unverified)`. The shims' DLLs are the `SHIM_TABLE`s in `runtime/shims`, less the host DLLs that `owns_dll` leaves out. `scripts/first_look.ps1` lists these DLLs after the to-do and prints a warning. - **Report:** a new `system_dlls` field, plus a line in the Markdown and stdout summaries, says where system DLLs were checked. - **Docs:** `docs/design.md` (day one, import table) and `README.md` (set `WINEPREFIX` on Linux) describe the above. - Windows classification is unchanged. ### Tested Linux, Python 3.14.10, CPU only, synthetic PE images and temporary folders standing in for the game folder and the Wine prefix. No game files. - `python -I tests/test_pe_inspect.py`: - main, before the change: 60 tests OK (1 skipped). - main with only this pull request's tests: 67 tests, 7 errors (`pe_inspect` has no `IS_WINDOWS`). - this branch: 67 tests OK (1 skipped, `test_system_dll_is_classified_system`, which needs Windows). - `python -I tests/test_text_write_line_endings.py`: OK. - `python -m compileall -q tools tests`, `git diff --check` and `python -I scripts/check_no_game_data.py` on the five changed files: clean. - `scripts/first_look.ps1` was not run (no PowerShell or game executable here). GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) AI-assisted (Claude Code, Claude Opus 5.5).
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 <[email protected]>
No conflicts. Brings in main's owns_dll host list with ws2_32.dll and wsock32.dll (the
ws2_offline shim), which the next commit mirrors in pe_inspect.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:14:03 +00:00
github manually merged commit ca9e45dbd1 into gh-pr/653/base 2026-11-26 09:14:06 +00:00
Author
Owner

@⁠Poussistar on GitHub · 2026-11-24 18:09 UTC · original

Verified at head against main 3aa975421d (clean worktree, git apply pull/653.diff): the PR's own test file is red, and it is a real classification bug rather than a too-strict test.

$ python -I tests/test_pe_inspect.py
FAIL: test_runtime_shim_dlls_follow_the_registry
AssertionError: Items in the first set but not the second:
'wsock32.dll'
'ws2_32.dll' : _SHIM_HOST_DLLS is owns_dll's host list
Ran 67 tests in 0.341s
FAILED (failures=1, skipped=1)

Clean main on the same file: Ran 60 tests ... OK (skipped=1), so the red is this PR's own.

Cause: owns_dll gained ws2_32.dll and wsock32.dll in its host[] list (runtime/shims/registry.cpp:497-498; host-owned with a partial override, like kernel32.dll), and runtime/shims/ws2_offline.cpp has a SHIM_TABLE that names both. _SHIM_HOST_DLLS here stops at user32.dll, so:

runtime_shim_dlls() -> 16 names; ws2_32.dll: True, wsock32.dll: True

Those two are then reported as shim off Windows, while the registry does not own them — the same false classification this PR removes for the others.

One-line fix, following the order of owns_dll's table:

_SHIM_HOST_DLLS = frozenset({"kernel32.dll", "kernelbase.dll", "msvcrt.dll", "ucrtbase.dll", "ucrtbased.dll",
                             "vulkan-1.dll", "ntdll.dll", "user32.dll", "ws2_32.dll",
                             "wsock32.dll"})

With it: Ran 67 tests ... OK (skipped=1), runtime_shim_dlls() gives 14 names with ws2_32.dll: False, wsock32.dll: False, and test_text_write_line_endings.py plus test_docs_cli_flags.py / test_docs_links.py still pass. Negative control: the same file without the two names is the failure above.

Linux host, CPython 3.14.7, no game files. AI-assisted.

**@⁠Poussistar** on GitHub · 2026-11-24 18:09 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/653#issuecomment-7140231015) Verified at head against `main` `3aa975421d` (clean worktree, `git apply pull/653.diff`): the PR's own test file is red, and it is a real classification bug rather than a too-strict test. ``` $ python -I tests/test_pe_inspect.py FAIL: test_runtime_shim_dlls_follow_the_registry AssertionError: Items in the first set but not the second: 'wsock32.dll' 'ws2_32.dll' : _SHIM_HOST_DLLS is owns_dll's host list Ran 67 tests in 0.341s FAILED (failures=1, skipped=1) ``` Clean `main` on the same file: `Ran 60 tests ... OK (skipped=1)`, so the red is this PR's own. Cause: `owns_dll` gained `ws2_32.dll` and `wsock32.dll` in its `host[]` list (`runtime/shims/registry.cpp:497-498`; host-owned with a partial override, like `kernel32.dll`), and `runtime/shims/ws2_offline.cpp` has a `SHIM_TABLE` that names both. `_SHIM_HOST_DLLS` here stops at `user32.dll`, so: ``` runtime_shim_dlls() -> 16 names; ws2_32.dll: True, wsock32.dll: True ``` Those two are then reported as `shim` off Windows, while the registry does not own them — the same false classification this PR removes for the others. One-line fix, following the order of `owns_dll`'s table: ```python _SHIM_HOST_DLLS = frozenset({"kernel32.dll", "kernelbase.dll", "msvcrt.dll", "ucrtbase.dll", "ucrtbased.dll", "vulkan-1.dll", "ntdll.dll", "user32.dll", "ws2_32.dll", "wsock32.dll"}) ``` With it: `Ran 67 tests ... OK (skipped=1)`, `runtime_shim_dlls()` gives 14 names with `ws2_32.dll: False, wsock32.dll: False`, and `test_text_write_line_endings.py` plus `test_docs_cli_flags.py` / `test_docs_links.py` still pass. Negative control: the same file without the two names is the failure above. Linux host, CPython 3.14.7, no game files. AI-assisted.
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 00:29 UTC · original

Thanks for running it and finding the cause.

  • Fixed in 4532b5b75: _SHIM_HOST_DLLS now lists ws2_32.dll and wsock32.dll, in the same order as owns_dll's host list in runtime/shims/registry.cpp, so runtime_shim_dlls() no longer reports them as shim off Windows.
  • main is merged in first (70d615b3b, no conflicts), so the branch carries the owns_dll list the test compares with.
  • Tested on Linux, CPython 3.14: python -I tests/test_pe_inspect.py, 67 tests OK (1 skipped), plus test_tool_startup, test_tool_stdout_encoding, the test_docs_* files, test_text_write_line_endings, test_ci_registration and check_no_game_data.py on the changed files.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-25 00:29 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/653#issuecomment-7148561974) Thanks for running it and finding the cause. - Fixed in `4532b5b75`: `_SHIM_HOST_DLLS` now lists `ws2_32.dll` and `wsock32.dll`, in the same order as `owns_dll`'s host list in `runtime/shims/registry.cpp`, so `runtime_shim_dlls()` no longer reports them as `shim` off Windows. - `main` is merged in first (`70d615b3b`, no conflicts), so the branch carries the `owns_dll` list the test compares with. - Tested on Linux, CPython 3.14: `python -I tests/test_pe_inspect.py`, 67 tests OK (1 skipped), plus `test_tool_startup`, `test_tool_stdout_encoding`, the `test_docs_*` files, `test_text_write_line_endings`, `test_ci_registration` and `check_no_game_data.py` on the changed files. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 22:20 UTC · original

Merged: pe_inspect classifies system DLLs on Linux through the Wine prefix.

  • Changed since review: main merged in. main added advapi32.dll to owns_dll's host list in runtime/shims/registry.cpp, which made test_runtime_shim_dlls_follow_the_registry fail. _SHIM_HOST_DLLS now lists it too, in the same order. The earlier ws2_32.dll / wsock32.dll point was fixed in 4532b5b75.
  • Tested: Linux, CPython 3.14. tests/test_pe_inspect.py passes (1 skipped), and so do test_tool_startup, the docs tests, test_ci_registration and test_ctest_registration. test_tool_stdout_encoding fails the same way on main alone, on tools this PR doesn't touch.
  • Checked on main 392dda8f0 + ca9e45dbd: the semantic suite passes (492 files, 6,315 tests, 0 files failed); test_pe_inspect pass; the 15 docs and writer tests pass; check_no_game_data.py is clean on the 5 changed files.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-25 22:20 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/653#issuecomment-7176231209) Merged: `pe_inspect` classifies system DLLs on Linux through the Wine prefix. - **Changed since review:** `main` merged in. `main` added `advapi32.dll` to `owns_dll`'s host list in `runtime/shims/registry.cpp`, which made `test_runtime_shim_dlls_follow_the_registry` fail. `_SHIM_HOST_DLLS` now lists it too, in the same order. The earlier `ws2_32.dll` / `wsock32.dll` point was fixed in `4532b5b75`. - **Tested:** Linux, CPython 3.14. `tests/test_pe_inspect.py` passes (1 skipped), and so do `test_tool_startup`, the docs tests, `test_ci_registration` and `test_ctest_registration`. `test_tool_stdout_encoding` fails the same way on `main` alone, on tools this PR doesn't touch. - **Checked on `main` `392dda8f0` + `ca9e45dbd`:** the semantic suite passes (492 files, 6,315 tests, 0 files failed); `test_pe_inspect` pass; the 15 docs and writer tests pass; `check_no_game_data.py` is clean on the 5 changed files. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.