Skip to content

RT-418: Honor OEM mode in narrow filename inputs - #5548

Open
Hiiva wants to merge 1 commit into
ItsNotRexed:mainfrom
Hiiva:fix/file-api-oem
Open

Hiiva wants to merge 1 commit into
ItsNotRexed:mainfrom
Hiiva:fix/file-api-oem

Conversation

@Hiiva

@Hiiva Hiiva commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Problem

After SetFileApisToOEM(), the narrow file shims still decode filename inputs with CP_ACP. A valid OEM filename can fail with ERROR_FILE_NOT_FOUND, or a create can succeed under the wrong filename. Native Windows accepts the same inputs.

Change

widen_ansi() now snapshots AreFileApisANSI() and selects CP_ACP or CP_OEMCP for both conversion calls. This fixes the existing narrow filename input paths without changing CRT arguments or wide APIs.

Enumeration output stays ANSI. Native FindFirstFileA, FindFirstFileExA, FindNextFileA, and GetCurrentDirectoryA on Windows 11 build 26200 still return ANSI bytes in OEM input mode; the native comparisons preserve that distinction.

Claimed as RT-418: #5361 (comment)

Depends on: none.

Validation

  • New file_api_codepage CTest exercises all 15 existing narrow file APIs through the production registry, against native Windows, using separate synthetic host and console fixtures in ANSI, OEM, and restored ANSI mode. It selects a character that round-trips differently on the detected code pages and restores process mode and current-directory state.
  • Final test against unchanged main 3faac557: 557 checks, 52 failures. With the fix: 557 checks, 0 failures. The native controls succeed in both runs.
  • file_api_codepage and existing file_system: 2/2 CTests pass; the existing suite reports 159 checks, 0 failures.
  • Isolated source integration with the already combined RT-389: Support console current directories and relative file paths #5187, RT-392: Copy writable console sources into the overlay #5234, and RT-406: Reject copies to the same logical console file #5354 changes: 557 new checks, 67 additional native/current-directory/self-copy/preflight checks, and 1,889 existing combined filesystem checks all pass. The current-directory output remains ANSI; OEM input reaches the intended logical directory; rejected self-copies and writable-source preflight failures create no overlay copy or parent.
  • Documentation links: 6 tests pass. Text encoding: 2 tests pass. git diff --check passes. Independent source review completed.

Integration heads checked: #5187 97278af44e6672356eb4ce0585d8551eacc6902f, #5234 29dc0a03c2740e6b08ee3ca4b327411c553505ee, #5354 9c343265c89b6075a6d4aa5d5a6d69166ea3756b. The fix passes independently on main; these integration checks do not add those PRs to this patch.

Windows 11 x64 build 26200, MSVC 19.44.35228, Windows SDK 10.0.26100.0. Detected ACP 1252 / OEM 437; selected regression character U+00A0. CPU only, no GPU or game execution, no game files accessed.

Primary references: SetFileApisToOEM, AreFileApisANSI. Output behavior above is measured directly against the native APIs.

AI-assisted: yes.

@thehollowedone

Copy link
Copy Markdown

Independent Windows check of d4fbd45c on 3faac557. Windows 11 build 26300, MSVC 19.44.35230, ACP 1252 / OEM 437.

The stock file_api_codepage CTest passed all 557 checks. All 15 narrow APIs matched native Windows for the synthetic host and console fixtures through ANSI → OEM → ANSI. With only file_system.cpp restored to base, the same fixture reported 52 failures, all in OEM mode. The native controls passed in both runs. CPU only, synthetic files. AI-assisted.

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed head d4fbd45.

  • Configured runtime (Ninja, RelWithDebInfo, BUILD_TESTING=ON, LEONIDA_BUILD_WINDOWS_RUNTIME=ON, Vulkan 1.4.363) and built file_api_codepage_test + file_system_test.
  • file_api_codepage_test.exe -> INFO ACP=1252 OEM=437 character=U+00A0, 557 checks, 0 failures. It exercises ANSI, OEM and restored-ANSI input modes on host and GAME: paths, with the native Windows API as the oracle for both results and returned filename bytes.
  • file_system_test.exe -> 159 checks, 0 failures.
  • git diff --check clean.

Default behaviour is unchanged (AreFileApisANSI() true -> CP_ACP); only widen_ansi reads the mode, and enumeration output intentionally stays ANSI (native confirms that here). Skip 77 when ACP==OEMCP is wired to CTest. No blockers. Coverage note: only the 1252/437 pair was exercised on this machine.

@mrloic

mrloic commented Nov 23, 2026

Copy link
Copy Markdown

Tested d4fbd45c (base 3faac557) on Windows 11 Pro 26300, Russian locale: ACP 1251 / OEM 866, MSVC 19.44 (VS 2022 Build Tools 17.14), Windows SDK 10.0.26100: pass. As far as I can see, the earlier runs were all ACP 1252 / OEM 437, so this is the first check on a Cyrillic code-page pair.

  • ctest -R "file_api_codepage|file_system": 2/2 passed. file_api_codepage printed INFO ACP=1251 OEM=866 character=U+00A0 and 557 checks, 0 failures; file_system 159 checks, 0 failures.
  • Negative control: with only runtime/shims/file_system.cpp restored to 3faac557 and file_api_codepage_test rebuilt: 557 checks, 52 failures, all 52 in OEM mode ([OEM host pass 1] mapped CreateFileA read, GetFileAttributesA matches native, ...). That's the same count as on 1252/437, and the native controls pass.
  • Full ctest: 177 of 178 passed (gameinput not built: no SDL3). The one failure is d3d12_fence_timing (SegFault), and it's intermittent: with --repeat until-fail:20 it passed once, then segfaulted. It isn't this change: the rebuild with the fix restored recompiled file_system.cpp only into file_system_test, file_api_codepage_test, the xgameruntime* tests and gta6rt. d3d12_fence_timing_test links gta6rt_d3d12_com d3d12 dxgi and wasn't rebuilt. Same binary as main, NVIDIA RTX 4060, driver 617.42. I'll file it separately as a finding.

AI-assisted (Claude Code).

@mrloic

mrloic commented Nov 23, 2026

Copy link
Copy Markdown

Follow-up on the d3d12_fence_timing SegFault above: I'm not filing it as a finding. On 3faac557 it was 2 of 20 standalone runs (0xC0000005, during device teardown, after the GPU address arena line). On current main 561b65a8, built the same way on the same RTX 4060 / 617.42, it's 0 of 40. main has fence-lifetime fixes since 3faac557 (df99c8916 "make fence cancel wait for in-flight callbacks", 8728339f9, dea6c3835), so it looks already fixed and unrelated to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants