HLE: DualSense device paths keep their NUL (CreateFileW read past the copy) #156

Open
github-bot wants to merge 1 commit from github-bot/gh-156 into main AGit
Owner

@⁠pjanes22 on GitHub · 2026-11-25 17:48 UTC · original
pjanes22:fix/dualsense-path-nul → main · +5 −1 · 1 files · 1 commits · open

device_paths() copied each SetupAPI interface path without its terminating
NUL, and open_pad() passed path.as_ptr() to CreateFileW, which reads up
to a NUL. The reader thread looks for a pad every 2 seconds, so with no
DualSense connected the run stopped at a random moment with an access
violation in ntdll (read past the end of the copy, r11 = STATUS_OBJECT_NAME_NOT_FOUND).

Symbolized stack from a release build: ntdll -> KERNELBASE (CreateFileW) ->
victory_hle::modules::dualsense::open_pad (dualsense.rs:169) ->
dualsense::reader.

Fix: the owned path gets its NUL pushed.

Tested: Windows 11, RTX 5080, Ryzen 9 7950X3D, no DualSense connected; the
crash no longer occurs in several runs of 5-8 minutes.

AI-assisted: analysis and patch written with Claude, run and tested on my machine.

**@⁠pjanes22** on GitHub · 2026-11-25 17:48 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/156) `pjanes22:fix/dualsense-path-nul` → `main` · +5 −1 · 1 files · 1 commits · open `device_paths()` copied each SetupAPI interface path without its terminating NUL, and `open_pad()` passed `path.as_ptr()` to `CreateFileW`, which reads up to a NUL. The reader thread looks for a pad every 2 seconds, so with no DualSense connected the run stopped at a random moment with an access violation in ntdll (read past the end of the copy, r11 = STATUS_OBJECT_NAME_NOT_FOUND). Symbolized stack from a release build: ntdll -> KERNELBASE (CreateFileW) -> `victory_hle::modules::dualsense::open_pad` (dualsense.rs:169) -> `dualsense::reader`. Fix: the owned path gets its NUL pushed. Tested: Windows 11, RTX 5080, Ryzen 9 7950X3D, no DualSense connected; the crash no longer occurs in several runs of 5-8 minutes. AI-assisted: analysis and patch written with Claude, run and tested on my machine.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:36:50 +00:00
Author
Owner

@⁠KernelSmoker on GitHub · 2026-11-25 18:52 UTC · original

Verified PR head 745bc00 (x86_64-pc-windows-gnu, Rust 1.98.1):

  • cargo clippy -p victory-hle --no-deps --all-targets --locked --target x86_64-pc-windows-gnu: no warnings in crates/victory-hle/src/modules/dualsense.rs.
  • modules::dualsense::tests run under GE-Proton 10-34 / Wine 10.0: 6 passed, 0 failed, plus --ignored lists_and_opens_hid_devices passed (enumerated 7 HID interfaces with NUL-terminated paths; no DualSense hardware connected here).
  • Code check: open_pad() is the only caller of device_paths() and passes path.as_ptr() directly to CreateFileW, confirming the missing trailing NUL was an out-of-bounds read.
**@⁠KernelSmoker** on GitHub · 2026-11-25 18:52 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/156#issuecomment-7171519062) Verified PR head `745bc00` (`x86_64-pc-windows-gnu`, Rust 1.98.1): - `cargo clippy -p victory-hle --no-deps --all-targets --locked --target x86_64-pc-windows-gnu`: no warnings in `crates/victory-hle/src/modules/dualsense.rs`. - `modules::dualsense::tests` run under GE-Proton 10-34 / Wine 10.0: **6 passed, 0 failed**, plus `--ignored` `lists_and_opens_hid_devices` passed (enumerated 7 HID interfaces with NUL-terminated paths; no DualSense hardware connected here). - Code check: `open_pad()` is the only caller of `device_paths()` and passes `path.as_ptr()` directly to `CreateFileW`, confirming the missing trailing NUL was an out-of-bounds read.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/156/head:github-bot/gh-156'
git switch 'github-bot/gh-156'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-156'
git switch 'github-bot/gh-156'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-156'
git switch 'github-bot/gh-156'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-156'
git switch 'main'
git merge --squash 'github-bot/gh-156'
git switch 'main'
git merge --ff-only 'github-bot/gh-156'
git switch 'main'
git merge 'github-bot/gh-156'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.