Files: CreateFileW and CreateFile2 no longer crash on a null path #2654

Manually merged
github merged 1 commit from github-bot/gh-2654 into gh-pr/2654/base 2026-11-30 14:17:15 +00:00 AGit
Owner

@⁠iBooM72 on GitHub · 2026-11-29 15:36 UTC · original
iBooM72:fix/create-file-null-path → main · +48 −14 · 1 files · 1 commits · merged 2026-11-30 14:12 UTC

What it changes

CreateFileW(NULL, ...) crashes instead of returning an error. Since def7cda6, the code that logs an open's flags reads the path without checking for null. CreateFile2 does the same when its parameter block is 12 to 32 bytes. CreateFileA already checks.

On Windows 11, calling the real functions with a null path returns INVALID_HANDLE_VALUE and error 3 (ERROR_PATH_NOT_FOUND).

Both functions had a copy of the same code. One helper, Wide::shown(), now replaces both and gives an empty string for a null path. The host is still called and returns its own error. Other paths work as before.

Found by reading the code. I have no evidence that the game passes a null path, and this isn't linked to any reported crash.

How it was tested

  • GPU and profile: not applicable. No game run and no release build. Windows 11, debug tests.
  • Before: each new test, run on its own, crashed with null pointer dereference occurred, at files.rs:429 (CreateFileW) and :517 (CreateFile2).
  • After: both pass. They check for the invalid handle and error 3. CreateFile2 is tested with no block and with a 32-byte block.
  • For shader changes, the wave sizes tested: not a shader change.
  • cargo test passed for the crates it touches: no. cargo test -p victory-hle --locked --no-fail-fast: 427 passed, 1 failed, in each of 3 runs. a_read_by_range_waits_only_for_a_remapping_that_meets_it (listed in #2420) also fails on unmodified 829188e9.
  • cargo test --workspace --locked --no-fail-fast: the same 5 tests fail here and on 829188e9. The only difference is the 2 new tests, which pass.
  • Both CI clippy commands fail here and on 829188e9, with no new errors, but stop before victory-hle. cargo clippy -p victory-hle --all-targets --locked (without -D warnings) reports nothing in files.rs. With all features, victory-gpu doesn't compile, so clippy couldn't check victory-hle.
  • cargo xtask policy --staged passed.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #2437 also edits files.rs, but not this code. #831 and #1577 have an older copy of the file, without the code that crashes.

🤖 Generated with Claude Code

**@⁠iBooM72** on GitHub · 2026-11-29 15:36 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2654) `iBooM72:fix/create-file-null-path` → `main` · +48 −14 · 1 files · 1 commits · merged 2026-11-30 14:12 UTC ## What it changes `CreateFileW(NULL, ...)` crashes instead of returning an error. Since def7cda6, the code that logs an open's flags reads the path without checking for null. `CreateFile2` does the same when its parameter block is 12 to 32 bytes. `CreateFileA` already checks. On Windows 11, calling the real functions with a null path returns `INVALID_HANDLE_VALUE` and error 3 (`ERROR_PATH_NOT_FOUND`). Both functions had a copy of the same code. One helper, `Wide::shown()`, now replaces both and gives an empty string for a null path. The host is still called and returns its own error. Other paths work as before. Found by reading the code. I have no evidence that the game passes a null path, and this isn't linked to any reported crash. ## How it was tested - GPU and profile: not applicable. **No game run and no release build.** Windows 11, debug tests. - Before: each new test, run on its own, crashed with `null pointer dereference occurred`, at `files.rs:429` (`CreateFileW`) and `:517` (`CreateFile2`). - After: both pass. They check for the invalid handle and error 3. `CreateFile2` is tested with no block and with a 32-byte block. - For shader changes, the wave sizes tested: not a shader change. - `cargo test` passed for the crates it touches: **no**. `cargo test -p victory-hle --locked --no-fail-fast`: 427 passed, 1 failed, in each of 3 runs. `a_read_by_range_waits_only_for_a_remapping_that_meets_it` (listed in #2420) also fails on unmodified `829188e9`. - `cargo test --workspace --locked --no-fail-fast`: the same 5 tests fail here and on `829188e9`. The only difference is the 2 new tests, which pass. - Both CI clippy commands fail here and on `829188e9`, with no new errors, but stop before `victory-hle`. `cargo clippy -p victory-hle --all-targets --locked` (without `-D warnings`) reports nothing in `files.rs`. With all features, `victory-gpu` doesn't compile, so clippy couldn't check `victory-hle`. - `cargo xtask policy --staged` passed. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #2437 also edits `files.rs`, but not this code. #831 and #1577 have an older copy of the file, without the code that crashes. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Both read the path for the log line that notes an open's flags
(def7cda6), CreateFile2 only for a parameter block it reads flags from.
A null path, which Windows refuses with ERROR_PATH_NOT_FOUND, crashed
there instead. One helper makes the logged path for both, empty for a
null one, and the host is still asked. CreateFileA did this already.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 15:41:36 +00:00
github-bot changed target branch from main to gh-pr/2654/base 2026-11-30 14:17:07 +00:00
github manually merged commit 07a2e8ffb7 into gh-pr/2654/base 2026-11-30 14:17:08 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!2654
No description provided.