HLE: check null and invalid handle in display deferral #531
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!531
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/531/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@pushkarreddyy on GitHub · 2026-11-24 04:32 UTC · original
pushkarreddyy:fix/display-deferral-handle-check→main· +18 −2 · 1 files · 1 commits · closed without mergingMotivation
In
crates/victory-hle/src/modules/display.rs:acquire_deferralonly checkedrequest as isize == -1afterPowerCreateRequest(&context). In the Windows API, handle failure may return null (0) orINVALID_HANDLE_VALUE(-1). Checking both guarantees a null handle is not treated as a successful power request.close_deferralchecked!handle.is_null()but did not guard against pseudo-handle or invalid handle-1, which would invokeCloseHandle(-1).Solution
PowerCreateRequestresult withrequest.is_null() || request as isize == -1.close_deferralwith!handle.is_null() && handle as isize != -1.acquire_deferraland graceful null/invalid handling inclose_deferral.No game files used.
@pushkarreddyy on GitHub · 2026-11-24 04:51 UTC · original
### Technical Verification & Implementation Details
Context & Root Cause
In
crates/victory-hle/src/modules/display.rs:acquire_deferralonly checkedrequest as isize == -1after callingPowerCreateRequest(&context). In the Windows API, handle failure may return null (0) orINVALID_HANDLE_VALUE(-1). Checking both ensures null handles are not treated as valid power requests.close_deferralchecked!handle.is_null()but did not guard against pseudo/invalid handle-1, which would attempt an invalidCloseHandle(-1)call.Changes & Diff
PowerCreateRequestresult withrequest.is_null() || request as isize == -1.close_deferralwith!handle.is_null() && handle as isize != -1.acquire_deferral_rejects_null_outandclose_deferral_handles_null_and_invalid.Git Log Line & Verification
ext 7f0053b HLE: check null and invalid handle in display deferral crates/victory-hle/src/modules/display.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)cargo xtask policy(Rule #1 compliance, zero game assets).rustfmt --edition 2024.@pushkarreddyy on GitHub · 2026-11-24 06:24 UTC · original
### Call for Testing & Maintainer Review
Community members testing game initialization or HLE modules on Windows 10/11: verification and feedback on this PR is warmly welcome!
cargo xtask policypassing).@Marvisak: Ready for maintainer review and merge when convenient!
@pushkarreddyy on GitHub · 2026-11-24 08:20 UTC · original
Thank you @mercuryVM for testing and verifying on Windows 11 / MSVC! Appreciate the confirmation and approval on the handle validation.
@Marvisak on GitHub · 2026-11-25 00:03 UTC · original
Automated triage for the maintainers. Closing because it does not change behaviour the project needs (formatting, guards for cases that cannot occur, or notes and translations that cannot be kept current).
No observable effect: a null request from PowerCreateRequest already fails at PowerSetRequest and returns an error, and -1 is never handed out as a deferral handle. The new tests cover behaviour main already has.
If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
Pull request closed