https://git.reactos.org/?p=reactos.git;a=commitdiff;h=77e891b8ab93dda5c1a426...
commit 77e891b8ab93dda5c1a4264df4427dc99163ac8a Author: Timo Kreuzer timo.kreuzer@reactos.org AuthorDate: Tue Jul 13 22:24:41 2021 +0200 Commit: Timo Kreuzer timo.kreuzer@reactos.org CommitDate: Thu Jul 15 08:32:46 2021 +0200
[WIN32K] Check if a graphics device already exists before trying to add it
This avoids DPRINTs alleging a failure to open a device. Also improve another DPRINT. --- win32ss/gdi/eng/device.c | 9 +++++++++ win32ss/user/ntuser/display.c | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/win32ss/gdi/eng/device.c b/win32ss/gdi/eng/device.c index deca6e7a9ff..12fbcd0359b 100644 --- a/win32ss/gdi/eng/device.c +++ b/win32ss/gdi/eng/device.c @@ -37,6 +37,7 @@ EngpUpdateGraphicsDeviceList(VOID) { ULONG iDevNum, iVGACompatible = -1, ulMaxObjectNumber = 0; WCHAR awcDeviceName[20]; + UNICODE_STRING ustrDeviceName; WCHAR awcBuffer[256]; NTSTATUS Status; PGRAPHICS_DEVICE pGraphicsDevice; @@ -73,6 +74,14 @@ EngpUpdateGraphicsDeviceList(VOID) { /* Create the adapter's key name */ swprintf(awcDeviceName, L"\Device\Video%lu", iDevNum); + RtlInitUnicodeString(&ustrDeviceName, awcDeviceName); + + /* Check if the device exists already */ + pGraphicsDevice = EngpFindGraphicsDevice(&ustrDeviceName, iDevNum, 0); + if (pGraphicsDevice != NULL) + { + continue; + }
/* Read the reg key name */ cbValue = sizeof(awcBuffer); diff --git a/win32ss/user/ntuser/display.c b/win32ss/user/ntuser/display.c index 676b7d0420c..df00c0e3974 100644 --- a/win32ss/user/ntuser/display.c +++ b/win32ss/user/ntuser/display.c @@ -257,7 +257,7 @@ UserEnumDisplayDevices( if (!pGraphicsDevice) { /* No device found */ - ERR("No GRAPHICS_DEVICE found\n"); + ERR("No GRAPHICS_DEVICE found for '%wZ', iDevNum %lu\n", pustrDevice, iDevNum); return STATUS_UNSUCCESSFUL; }