https://git.reactos.org/?p=reactos.git;a=commitdiff;h=26b88af6420f1ed707bd978656624868d428f820

commit 26b88af6420f1ed707bd978656624868d428f820
Author:     Stanislav Motylkov <[email protected]>
AuthorDate: Wed May 25 00:18:10 2022 +0300
Commit:     Stanislav Motylkov <[email protected]>
CommitDate: Mon May 30 15:28:44 2022 +0300

    [WIN32SS] Add missing code parts for monitor handling
    
    - [VIDEOPRT] Add stub for IOCTL_VIDEO_ENUM_MONITOR_PDO.
    
    - [WIN32SS:ENG] Add missing checks and comments.
    
    - [WIN32SS:NTUSER] Add missing monitor handling and comments.
    
    Addendum to 31827c43. CORE-18197 CORE-11715
---
 win32ss/drivers/videoprt/dispatch.c |  5 +++++
 win32ss/gdi/eng/device.c            | 28 ++++++++++++++++++++++++++--
 win32ss/user/ntuser/display.c       | 32 ++++++++++++++++++++++++++------
 3 files changed, 57 insertions(+), 8 deletions(-)

diff --git a/win32ss/drivers/videoprt/dispatch.c 
b/win32ss/drivers/videoprt/dispatch.c
index 1878e797550..79a20481b91 100644
--- a/win32ss/drivers/videoprt/dispatch.c
+++ b/win32ss/drivers/videoprt/dispatch.c
@@ -790,6 +790,11 @@ IntVideoPortDispatchDeviceControl(
             Status = STATUS_NOT_IMPLEMENTED;
             break;
 
+        case IOCTL_VIDEO_ENUM_MONITOR_PDO:
+            WARN_(VIDEOPRT, "- IOCTL_VIDEO_ENUM_MONITOR_PDO is 
UNIMPLEMENTED!\n");
+            Status = STATUS_NOT_IMPLEMENTED;
+            break;
+
         case IOCTL_VIDEO_INIT_WIN32K_CALLBACKS:
             INFO_(VIDEOPRT, "- IOCTL_VIDEO_INIT_WIN32K_CALLBACKS\n");
             Status = VideoPortInitWin32kCallbacks(DeviceObject,
diff --git a/win32ss/gdi/eng/device.c b/win32ss/gdi/eng/device.c
index af6bd3e42aa..3bd3827c9e7 100644
--- a/win32ss/gdi/eng/device.c
+++ b/win32ss/gdi/eng/device.c
@@ -351,6 +351,19 @@ EngpRegisterGraphicsDevice(
     // if (Win32kCallbacks.DualviewFlags & ???)
     pGraphicsDevice->PhysDeviceHandle = Win32kCallbacks.pPhysDeviceObject;
 
+    /* FIXME: Enumerate children monitor devices for this video adapter
+     *
+     * - Force the adapter to re-enumerate its monitors:
+     *   IoSynchronousInvalidateDeviceRelations(pdo, BusRelations)
+     *
+     * - Retrieve all monitor PDOs from VideoPrt:
+     *   EngDeviceIoControl(0x%p, IOCTL_VIDEO_ENUM_MONITOR_PDO)
+     *
+     * - Initialize these fields and structures accordingly:
+     *   pGraphicsDevice->dwMonCnt
+     *   pGraphicsDevice->pvMonDev[0..dwMonCnt-1]
+     */
+
     /* Copy the device name */
     RtlStringCbCopyNW(pGraphicsDevice->szNtDeviceName,
                       sizeof(pGraphicsDevice->szNtDeviceName),
@@ -445,7 +458,7 @@ EngpFindGraphicsDevice(
 
     if (pustrDevice && pustrDevice->Buffer)
     {
-        /* Loop through the list of devices */
+        /* Find specified video adapter by name */
         for (pGraphicsDevice = gpGraphicsDeviceFirst;
              pGraphicsDevice;
              pGraphicsDevice = pGraphicsDevice->pNextGraphicsDevice)
@@ -457,10 +470,21 @@ EngpFindGraphicsDevice(
                 break;
             }
         }
+
+        if (pGraphicsDevice)
+        {
+            /* Validate selected monitor number */
+#if 0
+            if (iDevNum >= pGraphicsDevice->dwMonCnt)
+                pGraphicsDevice = NULL;
+#else
+            /* FIXME: dwMonCnt not initialized, see EngpRegisterGraphicsDevice 
*/
+#endif
+        }
     }
     else
     {
-        /* Loop through the list of devices */
+        /* Select video adapter by device number */
         for (pGraphicsDevice = gpGraphicsDeviceFirst, i = 0;
              pGraphicsDevice && i < iDevNum;
              pGraphicsDevice = pGraphicsDevice->pNextGraphicsDevice, i++);
diff --git a/win32ss/user/ntuser/display.c b/win32ss/user/ntuser/display.c
index 4d14c6552c1..5feb8077db6 100644
--- a/win32ss/user/ntuser/display.c
+++ b/win32ss/user/ntuser/display.c
@@ -237,6 +237,7 @@ UserEnumDisplayDevices(
     DWORD dwFlags)
 {
     PGRAPHICS_DEVICE pGraphicsDevice;
+    PDEVICE_OBJECT pdo;
     PWCHAR pHardwareId;
     ULONG cbSize, dwLength;
     HKEY hkey;
@@ -284,9 +285,19 @@ UserEnumDisplayDevices(
     pdispdev->DeviceID[0] = UNICODE_NULL;
 
     /* Fill in DeviceID */
-    if (pGraphicsDevice->PhysDeviceHandle != NULL)
+    if (!pustrDevice)
+        pdo = pGraphicsDevice->PhysDeviceHandle;
+    else
+#if 0
+        pdo = pGraphicsDevice->pvMonDev[iDevNum].pdo;
+#else
+        /* FIXME: pvMonDev not initialized, see EngpRegisterGraphicsDevice */
+        pdo = NULL;
+#endif
+
+    if (pdo != NULL)
     {
-        Status = IoGetDeviceProperty(pGraphicsDevice->PhysDeviceHandle,
+        Status = IoGetDeviceProperty(pdo,
                                      DevicePropertyHardwareID,
                                      0,
                                      NULL,
@@ -303,7 +314,7 @@ UserEnumDisplayDevices(
                 return STATUS_INSUFFICIENT_RESOURCES;
             }
 
-            Status = IoGetDeviceProperty(pGraphicsDevice->PhysDeviceHandle,
+            Status = IoGetDeviceProperty(pdo,
                                          DevicePropertyHardwareID,
                                          dwLength,
                                          pHardwareId,
@@ -319,10 +330,19 @@ UserEnumDisplayDevices(
                  * which usually is the longest one and unique enough */
                 RtlStringCbCopyW(pdispdev->DeviceID, 
sizeof(pdispdev->DeviceID), pHardwareId);
 
-                /* For monitors it should be the first Hardware ID
-                 * concatenated with the unique driver registry key */
+                if (pustrDevice)
+                {
+                    /* For monitors it should be the first Hardware ID,
+                     * which we already have obtained above,
+                     * concatenated with the unique driver registry key */
+
+                    RtlStringCbCatW(pdispdev->DeviceID, 
sizeof(pdispdev->DeviceID), L"\\");
+
+                    /* FIXME: DevicePropertyDriverKeyName string should be 
appended */
+                    pHardwareId[0] = UNICODE_NULL;
+                    RtlStringCbCatW(pdispdev->DeviceID, 
sizeof(pdispdev->DeviceID), pHardwareId);
+                }
 
-                /* FIXME: Handle monitors! */
                 TRACE("Hardware ID: %ls\n", pdispdev->DeviceID);
             }
 

Reply via email to