Skip to content

fix(windows): skip hybrid GPU hook on single-GPU systems#4938

Open
SeMmyT wants to merge 1 commit intoLizardByte:masterfrom
SeMmyT:fix/skip-hybrid-hook-single-gpu
Open

fix(windows): skip hybrid GPU hook on single-GPU systems#4938
SeMmyT wants to merge 1 commit intoLizardByte:masterfrom
SeMmyT:fix/skip-hybrid-hook-single-gpu

Conversation

@SeMmyT
Copy link
Copy Markdown

@SeMmyT SeMmyT commented Apr 2, 2026

Summary

  • Skip the NtGdiDdDDIGetCachedHybridQueryValue MinHook on single-GPU systems where it's unnecessary
  • Prevents a crash loop (0xc0000005 in dxgi.dll) on Windows 11 24H2 build 29558+
  • Adds proper error handling for MinHook API return values

Problem

The hybrid GPU workaround hook introduced in #3530 causes an access violation in dxgi.dll on recent Windows 11 builds (24H2, build 29558+) with single-GPU systems. The crash is deterministic — always at offset 0x6cb2f in dxgi.dll — and creates an infinite crash loop where the service wrapper restarts sunshine.exe every ~6 seconds.

Crash signature:

Faulting module: dxgi.dll (10.0.29558.1000)
Exception: 0xc0000005 (ACCESS_VIOLATION)
Offset: 0x000000000006cb2f

Root cause: the hook spoofs D3DKMT_GPU_PREFERENCE_STATE_UNSPECIFIED as the return value, but the updated dxgi.dll in build 29558 doesn't handle this state correctly on a code path that only executes when the hook is active.

Fix

Before installing the hook, enumerate DXGI adapters to detect if the system has multiple physical GPUs:

  • Multi-GPU: install the hook as before (needed to prevent output reparenting)
  • Single-GPU: skip the hook entirely (no reparenting issue exists)

Adapters are deduplicated by VendorId + DeviceId since the same physical GPU can appear as multiple DXGI adapters.

Also adds:

  • Error handling for MH_Initialize() and MH_CreateHookApi() return values
  • Logging for hook installation status (success, skip, or failure)

Test Plan

  • Verified on RTX 4070 Ti single-GPU, Windows 11 24H2 build 29558, NVIDIA 591.86
  • Should be tested on multi-GPU/hybrid systems to ensure hook is still applied

🤖 Generated with Claude Code

…xgi.dll crash

The NtGdiDdDDIGetCachedHybridQueryValue hook was introduced in LizardByte#3530 to prevent
DXGI output reparenting on multi-GPU/hybrid systems. On single-GPU systems, this
hook is unnecessary and causes an access violation (0xc0000005) in dxgi.dll at a
consistent offset on Windows 11 24H2 build 29558+.

The crash occurs because dxgi.dll's internal code path doesn't correctly handle
the spoofed D3DKMT_GPU_PREFERENCE_STATE_UNSPECIFIED value on newer Windows builds,
resulting in a crash loop where the service wrapper continuously restarts the process.

This fix:
- Enumerates DXGI adapters before installing the hook to detect single vs multi-GPU
- Deduplicates adapters by VendorId+DeviceId (same physical GPU can appear as
  multiple DXGI adapters due to cross-adapter copies)
- Skips the hook entirely on single-GPU systems where output reparenting is not
  a concern
- Adds error handling for MH_Initialize and MH_CreateHookApi return values
- Adds logging for hook installation status

Tested on: RTX 4070 Ti (single GPU), Windows 11 24H2 build 29558, NVIDIA 591.86

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Guided-By: SeMmy
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 2, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
1 New issue
1 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@ReenigneArcher ReenigneArcher added the ai PR has signs of heavy ai usage (either indicated by user or assumed) label Apr 2, 2026
@ReenigneArcher
Copy link
Copy Markdown
Member

Thank you for the PR submission, but I noticed you didn't use our PR template.

Please update the PR to use the correct template. You can find it at https://github.com/LizardByte/.github/blob/master/.github/pull_request_template.md?plain=1

@ReenigneArcher ReenigneArcher requested a review from cgutman April 2, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai PR has signs of heavy ai usage (either indicated by user or assumed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants