mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:55:52 +01:00
[PR #88] [CLOSED] runtime/shims: shim GetLogicalProcessorInformation and GlobalMemoryStatusEx #142
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#142
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/88
Author: @Andretuta
Created: 11/24/2026
Status: ❌ Closed
Base:
main← Head:old-pr/9816📝 Commits (1)
793724fruntime/shims: shim GetLogicalProcessorInformation and GlobalMemoryStatusEx📊 Changes
4 files changed (+489 additions, -2 deletions)
View changed files
📝
runtime/CMakeLists.txt(+14 -0)➕
runtime/shims/sysinfo.cpp(+297 -0)➕
runtime/test/sysinfo_test.cpp(+176 -0)📝
scripts/build_runtime.ps1(+2 -2)📄 Description
Original description (mentions and
#Nreferences are disabled; the numbers refer to the old repository):Clean-room shim for
api-ms-win-core-sysinfo-l1-1-0.dll,kernel32.dll, andkernelbase.dllexportingGetLogicalProcessorInformationandGlobalMemoryStatusEx.Why
Static analysis of the retail executable (
game_scarlett_master.exe, local inspection only — zero game bytes/RVAs included) shows:GetLogicalProcessorInformationis called in a strict two-step pattern:(nullptr, &len)must returnFALSEwithGetLastError() == ERROR_INSUFFICIENT_BUFFERor the caller executesint3, and(buf, &len)must returnTRUEor the caller executesint3; each 32-byteRelationProcessorCorerecord is then walked to count physical cores and__popcnt64(ProcessorMask)for logical processors.GlobalMemoryStatusExqueries physical/available memory and load percentage viaMEMORYSTATUSEX(dwLength == 64).Changes
runtime/shims/sysinfo.cpp:GetLogicalProcessorInformation: forwards to host by default while guarding against hosts/sandboxes that violate theERROR_INSUFFICIENT_BUFFERprobe contract or return an empty record buffer; supports deterministic topology overrides viaLEONIDA_CPU_TOPOLOGY(xbox/scarlett= 8 physical cores / 16 logical SMT threads with per-core L1/L2 + shared 4-core L3 caches + NUMA/package records, or customNxM/Nup to 64 logical CPUs).GlobalMemoryStatusEx: validateslpBuffer != nullptr && dwLength == sizeof(MEMORYSTATUSEX)(ERROR_INVALID_PARAMETERon invalid input), forwards to host by default, and supportsLEONIDA_SYSTEM_MEMORY_MB(xbox/scarlett= 16384 MiB, or explicit MiB) while clamping available memory and recomputing load percentage.0_Init_thread_headersymbols verified viadumpbin /symbols).runtime/test/sysinfo_test.cppcovering validation contracts, host passthrough,"xbox"8c/16t topology + SMT/L3 verification,"6x10"custom core distribution, invalid env fallback, andLEONIDA_SYSTEM_MEMORY_MBoverrides.shims/sysinfo.cppandsysinfo_testintoruntime/CMakeLists.txtandscripts/build_runtime.ps1.Verification
ctest -R '^sysinfo$':PASS (1/1)ona60e5eab5(base only 1 README commit behindmain).ctestsuite (prior base):113/113CPU tests passed (8 skipped/disabled hardware/asset/SDL3 tests).dumpbin /symbolsonsysinfo.obj:0_Init_thread_headersymbols.gta6rt.exe --dry-run game_scarlett_master.exe: resolves bothGetLogicalProcessorInformationandGlobalMemoryStatusExviashim.python scripts/check_no_game_data.py,python tests/test_ctest_registration.py(4/4OK),git diff --check.#9677(https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7116628939).AI-assisted: yes
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.