runtime: encode the persistent storage root as UTF-8 #1544

Merged
SuperCraft3M merged 2 commits from upstream-pr/1551 into main 2026-11-24 14:36:20 +00:00
SuperCraft3M commented 2026-11-24 13:51:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SuperCraft3M on 2026-11-24T13:51:39Z.


Change

The runtime proxy currently reads X2W_STORAGE_PATH with GetEnvironmentVariableA. On a desktop using a legacy ANSI code page, non-ASCII names are returned in that code page and become damaged when the caller consumes the path as UTF-8. Read the environment in UTF-16 and explicitly encode UTF-8 before appending the separator. The existing bounded buffer and logged fallback remain in use; invalid UTF-16 and UTF-8 expansion beyond capacity are refused without partial output.

This follows the public console encoding contract: https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/overviews/utf-8 . The change is limited to the persistent-storage path answer in the startup runtime proxy, with no dependency on #1549.

Verification

Base: 3c6273ac. Windows 11, MSVC 19.44 Debug.

cmake --build C:/Xbox2Windows-build --target startup_storage_root_check startup_stub_gameinput --parallel 4: passed.

ctest --test-dir C:/Xbox2Windows-build --no-tests=error -R '^startup_storage_root' --output-on-failure: passed 2/2, no skips. The source-built fixture adds 7 UTF-8 cases (ASCII, accent/CJK/supplementary character, empty/null, invalid surrogate, maximum fitting expansion and over-capacity expansion). The existing separator mutation remains an expected failure.

git diff --check: passed.

A local offline diagnostic replay independently changed three storage-directory opens from failure to success with the same non-ASCII root. It still reached a later null-pointer write; this does not establish complete startup or gameplay. Raw traces and local inputs remain private.

Evidence and follow-up

Original source-built tests under MIT; no game files, binaries or raw captures included. The conversion fixture verifies exact UTF-8 bytes and output bounds; it does not model the later crash. Reproduction and byte limits are updated in docs/experiments.md and docs/startup-runtime.md.

AI-assisted (Codex).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6583312128 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1551). Originally posted by [SuperCraft3M](https://github.com/SuperCraft3M) on 2026-11-24T13:51:39Z. --- ## Change The runtime proxy currently reads `X2W_STORAGE_PATH` with `GetEnvironmentVariableA`. On a desktop using a legacy ANSI code page, non-ASCII names are returned in that code page and become damaged when the caller consumes the path as UTF-8. Read the environment in UTF-16 and explicitly encode UTF-8 before appending the separator. The existing bounded buffer and logged fallback remain in use; invalid UTF-16 and UTF-8 expansion beyond capacity are refused without partial output. This follows the public console encoding contract: https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/overviews/utf-8 . The change is limited to the persistent-storage path answer in the startup runtime proxy, with no dependency on #1549. ## Verification Base: 3c6273ac. Windows 11, MSVC 19.44 Debug. `cmake --build C:/Xbox2Windows-build --target startup_storage_root_check startup_stub_gameinput --parallel 4`: passed. `ctest --test-dir C:/Xbox2Windows-build --no-tests=error -R '^startup_storage_root' --output-on-failure`: passed 2/2, no skips. The source-built fixture adds 7 UTF-8 cases (ASCII, accent/CJK/supplementary character, empty/null, invalid surrogate, maximum fitting expansion and over-capacity expansion). The existing separator mutation remains an expected failure. `git diff --check`: passed. A local offline diagnostic replay independently changed three storage-directory opens from failure to success with the same non-ASCII root. It still reached a later null-pointer write; this does not establish complete startup or gameplay. Raw traces and local inputs remain private. ## Evidence and follow-up Original source-built tests under MIT; no game files, binaries or raw captures included. The conversion fixture verifies exact UTF-8 bytes and output bounds; it does not model the later crash. Reproduction and byte limits are updated in `docs/experiments.md` and `docs/startup-runtime.md`. AI-assisted (Codex).
upstream-sync closed this pull request 2026-11-24 15:01:57 +00:00
R0Y00 commented 2026-11-24 15:02:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T14:30:20Z.


Resolved the startup-runtime documentation conflict in b7b17d1f. The offline store-context row from main and the UTF-8 storage path limit are both preserved. Windows Release built startup_stub_gameinput and startup_storage_root_check. Both storage-root tests passed, including the separator control, and the docs check passed 345 links.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7134484111 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1551#issuecomment-7134484111). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T14:30:20Z. --- Resolved the startup-runtime documentation conflict in b7b17d1f. The offline store-context row from main and the UTF-8 storage path limit are both preserved. Windows Release built startup_stub_gameinput and startup_storage_root_check. Both storage-root tests passed, including the separator control, and the docs check passed 345 links.
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
R0Y00/Xbox2Windows!1544
No description provided.