Preserve Win32 errors from DirectStorage OpenFile #1383

Closed
EatCodeSleep2 wants to merge 2 commits from upstream-pr/1383 into main
EatCodeSleep2 commented 2026-11-24 17:40:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by EatCodeSleep2 on 2026-11-24T17:40:07Z.


Addresses VIC-BT-037 in #1249. Capture the host error before decoding the path for the DirectStorage log. Preserve the host thread error around disposal of the translated path in CreateFileW so virtual-drive opens report the same error as direct opens. Keep the documented read access and sharing mode.

Added a factory-vtable test checking the distinct HRESULTs for a missing file and missing parent directory. All 95 victory-hle library tests pass on Windows.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6587818265 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1383). Originally posted by [EatCodeSleep2](https://github.com/EatCodeSleep2) on 2026-11-24T17:40:07Z. --- Addresses VIC-BT-037 in #1249. Capture the host error before decoding the path for the DirectStorage log. Preserve the host thread error around disposal of the translated path in CreateFileW so virtual-drive opens report the same error as direct opens. Keep the documented read access and sharing mode. Added a factory-vtable test checking the distinct HRESULTs for a missing file and missing parent directory. All 95 victory-hle library tests pass on Windows.
catminou4 commented 2026-11-24 21:02:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T20:49:17Z.

Review: COMMENTED


Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows_sys/Win32) — nothing compiles or runs on macOS; this is source review plus the PR's own Windows tests.

Two Win32 error-preservation fixes: dstorage open_file captures last_os_error BEFORE building the lossy path string (which can clobber the thread error), and files.rs CreateFileW saves/restores GetLastError around dropping the translated path. The test asserts the exact HRESULTs for missing file (0x80070002) vs missing directory (0x80070003). Classic last-error hygiene; correct.

<!-- greyfinch-sync:Marvisak/VIctory:review:6047163223 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1383#pullrequestreview-6047163223). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T20:49:17Z. **Review:** COMMENTED --- Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows_sys/Win32) — nothing compiles or runs on macOS; this is source review plus the PR's own Windows tests. Two Win32 error-preservation fixes: dstorage open_file captures last_os_error BEFORE building the lossy path string (which can clobber the thread error), and files.rs CreateFileW saves/restores GetLastError around dropping the translated path. The test asserts the exact HRESULTs for missing file (0x80070002) vs missing directory (0x80070003). Classic last-error hygiene; correct.
Marvisak commented 2026-11-25 03:03:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T02:37:26Z.


Automated triage for the maintainers. Recommended for a maintainer's look: open_file in crates/victory-hle/src/modules/dstorage.rs now captures the last OS error right after CreateFileW, before allocating the path string for the log, and CreateFileW in files.rs saves and restores the thread's last error around dropping the translated virtual-drive path. Win32 does not promise that heap calls leave the last error alone, so reading it first is the correct order; the change is small and uses windows-sys features already enabled. Note that the new test (missing file -> 0x80070002, missing directory -> 0x80070003) most likely passes on main too, so it pins the behaviour rather than reproducing a failure. CI passes.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7150963866 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1383#issuecomment-7150963866). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T02:37:26Z. --- <!-- victory-triage v1 head=a613b9e81b1de2fb8aea8586de05a9948114a7a0 verdict=merge-candidate at=2026-11-25T02:20:29Z --> Automated triage for the maintainers. Recommended for a maintainer's look: `open_file` in `crates/victory-hle/src/modules/dstorage.rs` now captures the last OS error right after `CreateFileW`, before allocating the path string for the log, and `CreateFileW` in `files.rs` saves and restores the thread's last error around dropping the translated virtual-drive path. Win32 does not promise that heap calls leave the last error alone, so reading it first is the correct order; the change is small and uses `windows-sys` features already enabled. Note that the new test (missing file -> 0x80070002, missing directory -> 0x80070003) most likely passes on main too, so it pins the behaviour rather than reproducing a failure. CI passes. --- _Generated by [Claude Code](https://claude.ai/code)_
upstream-sync closed this pull request 2026-11-25 22:02:57 +00:00
Marvisak commented 2026-11-25 22:04:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:00:47Z.


Automated triage for the maintainers, second look (a review against current main, with builds and tests where they could change the verdict).

Closing because it changes no behaviour. Between CreateFileW and the error read there is only a successful heap allocation and free, which do not set the thread's last error, so main already returns the same HRESULT: with both source files put back to main and only the new test kept, open_file_preserves_win32_error still passes.

If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7175824135 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1383#issuecomment-7175824135). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:00:47Z. --- Automated triage for the maintainers, second look (a review against current `main`, with builds and tests where they could change the verdict). Closing because it changes no behaviour. Between `CreateFileW` and the error read there is only a successful heap allocation and free, which do not set the thread's last error, so `main` already returns the same HRESULT: with both source files put back to `main` and only the new test kept, `open_file_preserves_win32_error` still passes. If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

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
Marvisak/VIctory!1383
No description provided.