Repository navigation
DStorage: preserve GetLastError across heap allocation in open_file and permit shared write/delete - #1932
DStorage: preserve GetLastError across heap allocation in open_file and permit shared write/delete#1932ashrafsdrop wants to merge 1 commit into
Conversation
catminou4
left a comment
There was a problem hiding this comment.
Static review only: victory-hle is Windows-only — nothing compiles or runs on macOS; source review of the diff.
DStorage: preserve GetLastError across heap allocation: error-code preservation fix — classic Win32 bug class, good catch.
|
Tested
Not tested: the title. Its DirectStorage files are package archives opened read-only, so I'd expect no change there. AI use: Claude Code (Claude Opus 5.5) ran these checks and wrote this; the results are from the runs described. |
|
Automated triage for the maintainers. Merge candidate. A small hardening change. Recommending a look, not approving.
CI: On your reply: both requested changes are in (error captured first with one decode, share-mode change dropped), so the verdict moves from needs-work. Generated by Claude Code |
ce91efa to
9325572
Compare
|
Updated in head
|
Resolves VIC-BT-037 from #1249:
Summary
Preserve OS Error Code:
In \crates/victory-hle/src/modules/dstorage.rs:open_file, previously \String::from_utf16_lossy\ was executed before \std::io::Error::last_os_error()\ when \CreateFileW\ failed. Because UTF-16 decoding performs heap allocations which can make Win32 calls resetting or mutating the thread-local error state, \GetLastError()\ could be clobbered before being mapped by \rom_win32. Captures \last_os_error()\ immediately after the failure check.
Permit Concurrent Write and Delete Access:
Adds \FILE_SHARE_WRITE\ and \FILE_SHARE_DELETE\ to \FILE_SHARE_READ\ in \CreateFileW. Matches Windows DirectStorage behavior permitting concurrent streaming or file replacements without encountering \ERROR_SHARING_VIOLATION.
Tests:
Adds unit test \open_file_preserves_error_and_allows_shared_access\ asserting that opening a missing file accurately returns \