From c05a45e17eda057d8b92ba76feecf3532d8324c1 Mon Sep 17 00:00:00 2001 From: Oleg Dubinskiy Date: Wed, 1 Dec 2021 15:28:45 +0000 Subject: [PATCH] [WIN32K:ENG] Pass correct display name to EngpFindGraphicsDevice (#4128) It actually should look like '\\.\DISPLAY' (since it comes from user mode), which the function expects, and not '\\Device\\Video', like done in the kernel mode. Otherwise, passing wrong name causes a mismatch. Fix the problem with video device access (failure with status 0xc0000022 when trying to open it). Hence, it also fixes the following debug log spam: 'err: Could not open device \Device\Video0, 0xc0000022'. Addendum to 77e891b8. CORE-17719 CORE-17786 --- win32ss/gdi/eng/device.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/win32ss/gdi/eng/device.c b/win32ss/gdi/eng/device.c index 12fbcd0359b..2777143bf9f 100644 --- a/win32ss/gdi/eng/device.c +++ b/win32ss/gdi/eng/device.c @@ -36,7 +36,7 @@ NTSTATUS EngpUpdateGraphicsDeviceList(VOID) { ULONG iDevNum, iVGACompatible = -1, ulMaxObjectNumber = 0; - WCHAR awcDeviceName[20]; + WCHAR awcDeviceName[20], awcWinDeviceName[20]; UNICODE_STRING ustrDeviceName; WCHAR awcBuffer[256]; NTSTATUS Status; @@ -74,7 +74,10 @@ EngpUpdateGraphicsDeviceList(VOID) { /* Create the adapter's key name */ swprintf(awcDeviceName, L"\\Device\\Video%lu", iDevNum); - RtlInitUnicodeString(&ustrDeviceName, awcDeviceName); + + /* Create the display device name */ + swprintf(awcWinDeviceName, L"\\\\.\\DISPLAY%lu", iDevNum + 1); + RtlInitUnicodeString(&ustrDeviceName, awcWinDeviceName); /* Check if the device exists already */ pGraphicsDevice = EngpFindGraphicsDevice(&ustrDeviceName, iDevNum, 0);