runtime/shims: shim GetLogicalProcessorInformation and GlobalMemoryStatusEx (OLD-9816) #1104

Closed
ambroseautomation wants to merge 1 commit from upstream-pr/1104 into main
ambroseautomation commented 2026-11-24 18:33:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ambroseautomation on 2026-11-24T18:33:31Z.


Claimed in the coordination issue as: OLD-9816 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7140741518)

What and why

Carries forward old-pr/9816 (draft #88, original commit author piyonchu preserved; indexed in #17), rebased cleanly onto current main (71f99e224) without the stray UTF-8 BOM in scripts/build_runtime.ps1.

Shims GetLogicalProcessorInformation and GlobalMemoryStatusEx across kernel32.dll, kernelbase.dll, and api-ms-win-core-sysinfo-l1-1-0.dll in runtime/shims/sysinfo.cpp:

  • Preserves the two-step GetLogicalProcessorInformation size-probe contract (FALSE + ERROR_INSUFFICIENT_BUFFER with required byte count) and falls back to a synthesized topology if the host fails or returns an empty buffer.
  • Supports deterministic console parity overrides via LEONIDA_CPU_TOPOLOGY (xbox/scarlett for 8c/16t with SMT + L1/L2/L3/NUMA/package records, NxM, N, or host) and LEONIDA_SYSTEM_MEMORY_MB (xbox/scarlett for 16384 MiB, or explicit MiB clamped to [256, 1048576]).
  • Keeps owns_dll false for kernel32.dll, kernelbase.dll, and api-ms-win-core-sysinfo-l1-1-0.dll.
  • Registers sysinfo_test in runtime/CMakeLists.txt and adds shims\sysinfo.cpp to scripts/build_runtime.ps1.

Tested

  • Compiled and ran sysinfo_test.exe natively on Windows 11 with MSVC (/std:c++20 /EHsc /W4 /permissive- /utf-8 /O2): sysinfo_test: PASS (0 failures), zero compiler warnings.
  • Built runtime/build/gta6rt.exe via .\scripts\build_runtime.ps1 -jobs 8: succeeded cleanly with shims\sysinfo.cpp linked.
  • python -I tests/test_build_runtime_fallback.py: 10 tests, OK.
  • python -I tests/test_text_write_line_endings.py: 3 tests, OK.
  • python -I scripts/check_no_game_data.py runtime/CMakeLists.txt runtime/shims/sysinfo.cpp runtime/test/sysinfo_test.cpp scripts/build_runtime.ps1: exit 0 (no game data).

GPUs tested: n/a (CPU/OS runtime shim; built and tested on Windows 11 Pro 64-bit, MSVC VS 18)

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 — runtime shim)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5478072121 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1104). Originally posted by [ambroseautomation](https://github.com/ambroseautomation) on 2026-11-24T18:33:31Z. --- Claimed in the coordination issue as: OLD-9816 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7140741518) ### What and why Carries forward `old-pr/9816` (draft #88, original commit author `piyonchu` preserved; indexed in #17), rebased cleanly onto current `main` (`71f99e224`) without the stray UTF-8 BOM in `scripts/build_runtime.ps1`. Shims `GetLogicalProcessorInformation` and `GlobalMemoryStatusEx` across `kernel32.dll`, `kernelbase.dll`, and `api-ms-win-core-sysinfo-l1-1-0.dll` in `runtime/shims/sysinfo.cpp`: - Preserves the two-step `GetLogicalProcessorInformation` size-probe contract (`FALSE` + `ERROR_INSUFFICIENT_BUFFER` with required byte count) and falls back to a synthesized topology if the host fails or returns an empty buffer. - Supports deterministic console parity overrides via `LEONIDA_CPU_TOPOLOGY` (`xbox`/`scarlett` for 8c/16t with SMT + L1/L2/L3/NUMA/package records, `NxM`, `N`, or `host`) and `LEONIDA_SYSTEM_MEMORY_MB` (`xbox`/`scarlett` for 16384 MiB, or explicit MiB clamped to `[256, 1048576]`). - Keeps `owns_dll` false for `kernel32.dll`, `kernelbase.dll`, and `api-ms-win-core-sysinfo-l1-1-0.dll`. - Registers `sysinfo_test` in `runtime/CMakeLists.txt` and adds `shims\sysinfo.cpp` to `scripts/build_runtime.ps1`. ### Tested - Compiled and ran `sysinfo_test.exe` natively on Windows 11 with MSVC (`/std:c++20 /EHsc /W4 /permissive- /utf-8 /O2`): `sysinfo_test: PASS (0 failures)`, zero compiler warnings. - Built `runtime/build/gta6rt.exe` via `.\scripts\build_runtime.ps1 -jobs 8`: succeeded cleanly with `shims\sysinfo.cpp` linked. - `python -I tests/test_build_runtime_fallback.py`: 10 tests, OK. - `python -I tests/test_text_write_line_endings.py`: 3 tests, OK. - `python -I scripts/check_no_game_data.py runtime/CMakeLists.txt runtime/shims/sysinfo.cpp runtime/test/sysinfo_test.cpp scripts/build_runtime.ps1`: exit 0 (no game data). GPUs tested: n/a (CPU/OS runtime shim; built and tested on Windows 11 Pro 64-bit, MSVC VS 18) 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 — runtime shim)
abnalstlll-byte commented 2026-11-24 18:39:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T18:39:31Z.

Review: APPROVED


Audited and verified. Shims GetLogicalProcessorInformation and GlobalMemoryStatusEx in
untime/shims/sysinfo.cpp with support for LEONIDA_CPU_TOPOLOGY (8c/16t Xbox topology) and LEONIDA_SYSTEM_MEMORY_MB, strictly preserving the two-step Win32 buffer probe contract (ERROR_INSUFFICIENT_BUFFER) required by the retail boot sequence. Tests in
untime/test/sysinfo_test.cpp pass cleanly. Approved.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6045197752 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1104#pullrequestreview-6045197752). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T18:39:31Z. **Review:** APPROVED --- Audited and verified. Shims GetLogicalProcessorInformation and GlobalMemoryStatusEx in untime/shims/sysinfo.cpp with support for LEONIDA_CPU_TOPOLOGY (8c/16t Xbox topology) and LEONIDA_SYSTEM_MEMORY_MB, strictly preserving the two-step Win32 buffer probe contract (ERROR_INSUFFICIENT_BUFFER) required by the retail boot sequence. Tests in untime/test/sysinfo_test.cpp pass cleanly. Approved.
abnalstlll-byte commented 2026-11-24 18:52:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T18:52:53Z.

Review: APPROVED


Clean-Room Audit — PR #1104 (OLD-9816 SysInfo Shims)

Clean carry-forward of runtime/shims/sysinfo.cpp shimming GetLogicalProcessorInformation and GlobalMemoryStatusEx with LEONIDA_CPU_TOPOLOGY and LEONIDA_SYSTEM_MEMORY_MB configuration plus runtime/test/sysinfo_test.cpp coverage. CMake/build integration clean; 0 game data.

Verdict: APPROVED

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6045382534 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1104#pullrequestreview-6045382534). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T18:52:53Z. **Review:** APPROVED --- ### Clean-Room Audit — PR #1104 (`OLD-9816` SysInfo Shims) Clean carry-forward of `runtime/shims/sysinfo.cpp` shimming `GetLogicalProcessorInformation` and `GlobalMemoryStatusEx` with `LEONIDA_CPU_TOPOLOGY` and `LEONIDA_SYSTEM_MEMORY_MB` configuration plus `runtime/test/sysinfo_test.cpp` coverage. CMake/build integration clean; 0 game data. **Verdict: APPROVED**
madhyn commented 2026-11-24 19:36:00 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by madhyn on 2026-11-24T19:36:00Z.


Tested 4dc12a4c3 on Arch Linux + Wine 11.22 (clang-cl + xwin cross-build):

  • ctest --test-dir runtime/build/win -R "^sysinfo$" --output-on-failure: Passed (5.32 s)

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7142327406 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1104#issuecomment-7142327406). Originally posted by [madhyn](https://github.com/madhyn) on 2026-11-24T19:36:00Z. --- Tested `4dc12a4c3` on Arch Linux + Wine 11.22 (clang-cl + xwin cross-build): - `ctest --test-dir runtime/build/win -R "^sysinfo$" --output-on-failure`: **Passed** (5.32 s) AI-assisted: yes
Deedlyy commented 2026-11-24 20:17:30 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Deedlyy on 2026-11-24T20:17:30Z.


Recommendation: [MERGE]

Reasoning: Carries #88: shims GetLogicalProcessorInformation and GlobalMemoryStatusEx across kernel32/kernelbase/api-set with the size-probe contract preserved, plus a 176-line test; also drops the stray BOM from build_runtime.ps1. Self-contained new shim file. Verified on Arch + Wine (sysinfo passes). CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main. Merge once the queued checks are green.

Impact level: 4/10

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7143315037 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1104#issuecomment-7143315037). Originally posted by [Deedlyy](https://github.com/Deedlyy) on 2026-11-24T20:17:30Z. --- **Recommendation:** [MERGE] **Reasoning:** Carries #88: shims `GetLogicalProcessorInformation` and `GlobalMemoryStatusEx` across kernel32/kernelbase/api-set with the size-probe contract preserved, plus a 176-line test; also drops the stray BOM from `build_runtime.ps1`. Self-contained new shim file. Verified on Arch + Wine (`sysinfo` passes). CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with `main`. Merge once the queued checks are green. **Impact level:** 4/10

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!1104
No description provided.