runtime/shims: shim PSM app-notification and WER file registration APIs (RT-PSM-APPNOTIFY-WER) #1240

Open
github-bot wants to merge 1 commit from github-bot/gh-1240 into main AGit
Owner

@⁠piyonchu on GitHub · 2026-11-24 20:42 UTC · original
piyonchu:pr/psm-appnotify-wer-shims → main · +412 −2 · 4 files · 1 commits · open

Summary

Claim ID: RT-PSM-APPNOTIFY-WER

Adds runtime/shims/appnotify.cpp and runtime/test/appnotify_test.cpp (wired into runtime/CMakeLists.txt and scripts/build_runtime.ps1):

  • Shims RegisterAppConstrainedChangeNotification and UnregisterAppConstrainedChangeNotification across kernel32.dll, kernelbase.dll, twinapi.appcore.dll, and api-ms-win-core-psm-appnotify-l1-1-0/1.dll, returning distinct tracked registration handles, ignoring nullptr/foreign/already-freed handles cleanly on unregister, and using constant-initialized SRWLOCK + raw lists to avoid MSVC TLS init guards. (RegisterAppStateChangeNotification and UnregisterAppStateChangeNotification are left out so they do not collide with #769.)
  • Shims WerRegisterFile / WerUnregisterFile across kernel32.dll, kernelbase.dll, wer.dll, and api-ms-win-core-windowserrorreporting-l1-1-0/1.dll, tracking normalized GAME:/G:/T: and host paths in-process without mutating host WER state or creating files on disk.
  • Adds unit tests in runtime/test/appnotify_test.cpp executed via rt::shims::find.

Verification

  • Host: Windows 11 (10.0.26100 SDK), MSVC (RelWithDebInfo), rebased onto cont/main (871e4b8b9), commit b607337fd.
  • ctest --test-dir runtime/build -C RelWithDebInfo --output-on-failure: 100% tests passed out of 148 (including #83 appnotify), with 7 game-data tests skipped (LEONIDA_GAME_DIR unset) and 2 gameinput tests disabled (no SDL3).
  • python -I tests/test_build_runtime_fallback.py: passed (10/10).
  • python -I scripts/check_no_game_data.py ... and git diff --check cont/main..HEAD: clean.
  • No game files used; CPU runtime test only (no GPU required). AI-assisted.
**@⁠piyonchu** on GitHub · 2026-11-24 20:42 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1240) `piyonchu:pr/psm-appnotify-wer-shims` → `main` · +412 −2 · 4 files · 1 commits · open ### Summary Claim ID: `RT-PSM-APPNOTIFY-WER` Adds `runtime/shims/appnotify.cpp` and `runtime/test/appnotify_test.cpp` (wired into `runtime/CMakeLists.txt` and `scripts/build_runtime.ps1`): - Shims `RegisterAppConstrainedChangeNotification` and `UnregisterAppConstrainedChangeNotification` across `kernel32.dll`, `kernelbase.dll`, `twinapi.appcore.dll`, and `api-ms-win-core-psm-appnotify-l1-1-0/1.dll`, returning distinct tracked registration handles, ignoring `nullptr`/foreign/already-freed handles cleanly on unregister, and using constant-initialized `SRWLOCK` + raw lists to avoid MSVC TLS init guards. (`RegisterAppStateChangeNotification` and `UnregisterAppStateChangeNotification` are left out so they do not collide with `#769`.) - Shims `WerRegisterFile` / `WerUnregisterFile` across `kernel32.dll`, `kernelbase.dll`, `wer.dll`, and `api-ms-win-core-windowserrorreporting-l1-1-0/1.dll`, tracking normalized `GAME:`/`G:`/`T:` and host paths in-process without mutating host WER state or creating files on disk. - Adds unit tests in `runtime/test/appnotify_test.cpp` executed via `rt::shims::find`. ### Verification - Host: Windows 11 (`10.0.26100` SDK), MSVC (`RelWithDebInfo`), rebased onto `cont/main` (`871e4b8b9`), commit `b607337fd`. - `ctest --test-dir runtime/build -C RelWithDebInfo --output-on-failure`: `100% tests passed out of 148` (including `#83 appnotify`), with 7 game-data tests skipped (`LEONIDA_GAME_DIR` unset) and 2 `gameinput` tests disabled (no SDL3). - `python -I tests/test_build_runtime_fallback.py`: passed (`10/10`). - `python -I scripts/check_no_game_data.py ...` and `git diff --check cont/main..HEAD`: clean. - No game files used; CPU runtime test only (no GPU required). AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:44:08 +00:00
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 01:51 UTC · original

@⁠piyonchu one overlap to sort out before this can go in:

  • The same two functions are shimmed in #769. This PR registers RegisterAppStateChangeNotification and UnregisterAppStateChangeNotification for api-ms-win-core-psm-appnotify-l1-1-0.dll and l1-1-1.dll (runtime/shims/appnotify.cpp, the APPNOTIFY_API table). #769 (RT-GDK-SPEECH-DISPLAY-LIFECYCLE, claimed at 04:11 UTC on 2026-11-24, before this one's 20:42 UTC) registers the same pair on the same two API sets.
  • Why it matters: the shim registry is a map keyed by DLL and name, so with both merged, which of the two implementations the title gets depends on the order of static initialisation, and it could differ between builds.
  • They don't do the same thing: #769 keeps the callbacks and runs them, with quiesced = TRUE, when the title's window is closed, then ends the run; this PR stores the registration and never calls it.
  • The request: please drop the RegisterAppStateChangeNotification / UnregisterAppStateChangeNotification pair from this PR, and keep the rest: the constrained-change pair and the WerRegisterFile shims are not in #769 and are welcome. If a test of yours covers the state-change pair (for example UnregisterAppStateChangeNotification(nullptr)), that case would fit into #769's lifecycle_test instead; say so there if you'd like it added.

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

**@⁠aslan2142** on GitHub · 2026-11-25 01:51 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1240#issuecomment-7150048516) @⁠piyonchu one overlap to sort out before this can go in: - **The same two functions are shimmed in #769.** This PR registers `RegisterAppStateChangeNotification` and `UnregisterAppStateChangeNotification` for `api-ms-win-core-psm-appnotify-l1-1-0.dll` and `l1-1-1.dll` (`runtime/shims/appnotify.cpp`, the `APPNOTIFY_API` table). #769 (`RT-GDK-SPEECH-DISPLAY-LIFECYCLE`, claimed at 04:11 UTC on 2026-11-24, before this one's 20:42 UTC) registers the same pair on the same two API sets. - **Why it matters:** the shim registry is a map keyed by DLL and name, so with both merged, which of the two implementations the title gets depends on the order of static initialisation, and it could differ between builds. - **They don't do the same thing:** #769 keeps the callbacks and runs them, with `quiesced = TRUE`, when the title's window is closed, then ends the run; this PR stores the registration and never calls it. - **The request:** please drop the `RegisterAppStateChangeNotification` / `UnregisterAppStateChangeNotification` pair from this PR, and keep the rest: the constrained-change pair and the `WerRegisterFile` shims are not in #769 and are welcome. If a test of yours covers the state-change pair (for example `UnregisterAppStateChangeNotification(nullptr)`), that case would fit into #769's `lifecycle_test` instead; say so there if you'd like it added. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠piyonchu on GitHub · 2026-11-25 02:08 UTC · original

Thanks for catching the #769 overlap, @⁠aslan2142! Updated #1240 (b607337fd) and rebased cleanly onto main (871e4b8b9):

  • Dropped RegisterAppStateChangeNotification and UnregisterAppStateChangeNotification from runtime/shims/appnotify.cpp and runtime/test/appnotify_test.cpp so there is no SHIM_TABLE registry collision with #769.
  • Kept RegisterAppConstrainedChangeNotification, UnregisterAppConstrainedChangeNotification, WerRegisterFile, and WerUnregisterFile, plus re-tested ctest --test-dir runtime/build -C RelWithDebInfo --output-on-failure (100% passed out of 148, #83 appnotify passed) and python -I tests/test_build_runtime_fallback.py (10/10 passed).

I also left a brief note on #769 with the negative test cases (nullptr registration pointer, null callback zeroing *Registration, nullptr/foreign-handle unregister) in case they are useful for lifecycle_test.

**@⁠piyonchu** on GitHub · 2026-11-25 02:08 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1240#issuecomment-7150361373) Thanks for catching the `#769` overlap, @⁠aslan2142! Updated `#1240` (`b607337fd`) and rebased cleanly onto `main` (`871e4b8b9`): - Dropped `RegisterAppStateChangeNotification` and `UnregisterAppStateChangeNotification` from `runtime/shims/appnotify.cpp` and `runtime/test/appnotify_test.cpp` so there is no `SHIM_TABLE` registry collision with `#769`. - Kept `RegisterAppConstrainedChangeNotification`, `UnregisterAppConstrainedChangeNotification`, `WerRegisterFile`, and `WerUnregisterFile`, plus re-tested `ctest --test-dir runtime/build -C RelWithDebInfo --output-on-failure` (`100% passed out of 148`, `#83 appnotify` passed) and `python -I tests/test_build_runtime_fallback.py` (`10/10` passed). I also left a brief note on `#769` with the negative test cases (`nullptr` registration pointer, null callback zeroing `*Registration`, `nullptr`/foreign-handle unregister) in case they are useful for `lifecycle_test`.
github-bot force-pushed github-bot/gh-1240 from cdee0f8b29 to 677379b018 2026-11-27 00:35:55 +00:00 Compare
Author
Owner

@⁠piyonchu on GitHub · 2026-11-26 21:40 UTC · original

Rebased onto latest main (fac8b4bb9, head commit 677379b01), resolving the scripts/build_runtime.ps1 fallback file list conflict cleanly (shims\xapu_queue.cpp + shims\appnotify.cpp).

Verified locally after rebase:

  • git diff --check cont/main..HEAD
  • python -I scripts/check_no_game_data.py runtime/CMakeLists.txt runtime/shims/appnotify.cpp runtime/test/appnotify_test.cpp scripts/build_runtime.ps1
  • cmake --build runtime/build --config RelWithDebInfo --target gta6rt appnotify_test
  • ctest --test-dir runtime/build -C RelWithDebInfo -R "^appnotify$" --output-on-failure (1/1 passed)
**@⁠piyonchu** on GitHub · 2026-11-26 21:40 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1240#issuecomment-7203956286) Rebased onto latest `main` (`fac8b4bb9`, head commit `677379b01`), resolving the `scripts/build_runtime.ps1` fallback file list conflict cleanly (`shims\xapu_queue.cpp` + `shims\appnotify.cpp`). Verified locally after rebase: - `git diff --check cont/main..HEAD` - `python -I scripts/check_no_game_data.py runtime/CMakeLists.txt runtime/shims/appnotify.cpp runtime/test/appnotify_test.cpp scripts/build_runtime.ps1` - `cmake --build runtime/build --config RelWithDebInfo --target gta6rt appnotify_test` - `ctest --test-dir runtime/build -C RelWithDebInfo -R "^appnotify$" --output-on-failure` (1/1 passed)
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1240/head:github-bot/gh-1240'
git switch 'github-bot/gh-1240'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1240'
git switch 'github-bot/gh-1240'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1240'
git switch 'github-bot/gh-1240'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1240'
git switch 'main'
git merge --squash 'github-bot/gh-1240'
git switch 'main'
git merge --ff-only 'github-bot/gh-1240'
git switch 'main'
git merge 'github-bot/gh-1240'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.