feat(tools): scan a module's GDK runtime method tables #74

Manually merged
github merged 1 commit from gh-pr/74/head into gh-pr/74/base 2026-11-26 19:17:45 +00:00
Owner

@⁠Dark3581 on GitHub · 2026-11-23 05:39 UTC · original
Dark3581:feat/api-impl-scan → main · +320 −0 · 3 files · 1 commits · merged 2026-11-23 05:42 UTC

What

tools/api_impl_scan.py: a tool to list the GDK runtime method tables a module reaches through QueryApiImpl, so a title's executable can be scanned the first time it's available. It turns the scratch analysis behind #71 and #73 into a tested tool:

  • It finds the QueryApiImpl lookup from the name string, follows the stored pointer to the module's call wrapper, and finds every call to that wrapper, directly or through incremental-link jump stubs.
  • For each thunk it records:
    • the GUID pair passed in rcx/rdx, including the lea rcx,…; mov rdx,rcx form where both are the same;
    • the method slot read from the interface's vtable;
    • the module's real call sites to that thunk; a stub's own jump is not counted;
    • the argument registers and stack slots it passes.
  • The output is grouped by interface: slot range, then for each called slot its call-site count and argument shape. --json writes the same.
  • It uses GNU objdump (--objdump to choose one). Listing parsing and analysis are pure functions.

docs/dev/GAME_TESTING.md gets a "GDK runtime method tables" section: usage, and the rule that a slot is mapped only when its call sites show what it is.

Tested

  • tools/tests/test_api_impl_scan.py (run by ctest as tools_test_api_impl_scan), on a synthetic objdump listing:
    • wrapper discovery from the lookup;
    • only padded jumps count as stubs;
    • a same-GUID thunk reached two times through its stub and one time directly gives 3 callers;
    • a two-GUID thunk with a stack argument and no callers gives 0;
    • the per-interface summary.
  • On two GDK modules bundled with a title package, the tool reproduces the hand analysis from #71 and #73:
    libHttpClient.GDK.dll: wrapper 0x18005e6d0, 404 thunks, 29 interfaces, 15 methods called
    XCurl.dll: wrapper 0x180005144, 16 thunks, 3 interfaces, 16 methods called
    
    The curl module's threading slots 3, 5, 12, 16, 17, 18, 22 and 29 match the call counts and shapes in #73. (libHttpClient counts 29 interfaces here, not the 21 reported before, because this matcher also resolves the same-GUID thunks the earlier pattern missed.)
  • MinGW ctest: 78 of 78. python tools/check_conventions.py: ok.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • python tools/check_conventions.py passes (no comments in code, one declaration per export, Conventional Commit subjects)
  • Unimplemented paths stop (AbxNotImplemented / AbxUnsupported); silent stubs are listed under Silent stubs through a debt fragment
  • Known gaps added, changed or removed through docs/dev/debt/changes/<branch>.md
  • Generic behaviour, not specific to one title
  • No game files, keys, notes or logs added to the repository
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • Source of behaviour: the thunk structure measured in #71 and #73
  • AI-assisted: yes
**@⁠Dark3581** on GitHub · 2026-11-23 05:39 UTC · [original](https://github.com/Dark3581/AnyBox/pull/74) `Dark3581:feat/api-impl-scan` → `main` · +320 −0 · 3 files · 1 commits · merged 2026-11-23 05:42 UTC ### What `tools/api_impl_scan.py`: a tool to list the GDK runtime method tables a module reaches through `QueryApiImpl`, so a title's executable can be scanned the first time it's available. It turns the scratch analysis behind #71 and #73 into a tested tool: - It finds the `QueryApiImpl` lookup from the name string, follows the stored pointer to the module's call wrapper, and finds every call to that wrapper, directly or through incremental-link jump stubs. - For each thunk it records: - the GUID pair passed in `rcx`/`rdx`, including the `lea rcx,…; mov rdx,rcx` form where both are the same; - the method slot read from the interface's vtable; - the module's real call sites to that thunk; a stub's own jump is not counted; - the argument registers and stack slots it passes. - The output is grouped by interface: slot range, then for each called slot its call-site count and argument shape. `--json` writes the same. - It uses GNU `objdump` (`--objdump` to choose one). Listing parsing and analysis are pure functions. `docs/dev/GAME_TESTING.md` gets a "GDK runtime method tables" section: usage, and the rule that a slot is mapped only when its call sites show what it is. ### Tested - `tools/tests/test_api_impl_scan.py` (run by ctest as `tools_test_api_impl_scan`), on a synthetic `objdump` listing: - wrapper discovery from the lookup; - only padded jumps count as stubs; - a same-GUID thunk reached two times through its stub and one time directly gives 3 callers; - a two-GUID thunk with a stack argument and no callers gives 0; - the per-interface summary. - On two GDK modules bundled with a title package, the tool reproduces the hand analysis from #71 and #73: ``` libHttpClient.GDK.dll: wrapper 0x18005e6d0, 404 thunks, 29 interfaces, 15 methods called XCurl.dll: wrapper 0x180005144, 16 thunks, 3 interfaces, 16 methods called ``` The curl module's threading slots 3, 5, 12, 16, 17, 18, 22 and 29 match the call counts and shapes in #73. (libHttpClient counts 29 interfaces here, not the 21 reported before, because this matcher also resolves the same-GUID thunks the earlier pattern missed.) - MinGW `ctest`: 78 of 78. `python tools/check_conventions.py`: ok. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] `python tools/check_conventions.py` passes (no comments in code, one declaration per export, Conventional Commit subjects) - [x] Unimplemented paths stop (`AbxNotImplemented` / `AbxUnsupported`); silent stubs are listed under Silent stubs through a debt fragment - [x] Known gaps added, changed or removed through `docs/dev/debt/changes/<branch>.md` - [x] Generic behaviour, not specific to one title - [x] No game files, keys, notes or logs added to the repository - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] Source of behaviour: the thunk structure measured in #71 and #73 - [x] AI-assisted: yes
api_impl_scan.py finds a module's QueryApiImpl wrapper and lists every thunk's GUID pair and method slot, with the call sites and argument shapes of the ones the module calls, so a title's executable shows which slots to map.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:17:45 +00:00
github manually merged commit e37b35ca2f into gh-pr/74/base 2026-11-26 19:17:45 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.