From 29b50034559837307dff57cf588c34bfef73f239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Thu, 1 May 2025 13:44:21 +0200 Subject: [PATCH] [VIDEOPRT] Implement IOCTL_VIDEO_ENUM_MONITOR_PDO --- win32ss/drivers/videoprt/dispatch.c | 51 +++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/win32ss/drivers/videoprt/dispatch.c b/win32ss/drivers/videoprt/dispatch.c index 79a20481b91..f07a951eb0d 100644 --- a/win32ss/drivers/videoprt/dispatch.c +++ b/win32ss/drivers/videoprt/dispatch.c @@ -622,6 +622,51 @@ VideoPortUseDeviceInSession( return STATUS_SUCCESS; } +static +NTSTATUS +VideoPortEnumMonitorPdo( + _In_ PDEVICE_OBJECT DeviceObject, + _Inout_ PVIDEO_MONITOR_DEVICE *ppMonitorDevices, + _Out_ PULONG_PTR Information) +{ + PVIDEO_MONITOR_DEVICE pMonitorDevices; + PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension; + PVIDEO_PORT_CHILD_EXTENSION ChildExtension; + ULONG i; + PLIST_ENTRY CurrentEntry; + + /* Count the children */ + i = 0; + CurrentEntry = DeviceExtension->ChildDeviceList.Flink; + while (CurrentEntry != &DeviceExtension->ChildDeviceList) + { + i++; + CurrentEntry = CurrentEntry->Flink; + } + + pMonitorDevices = ExAllocatePoolZero(PagedPool, + sizeof(VIDEO_MONITOR_DEVICE) * (i + 1), + TAG_VIDEO_PORT); + if (!pMonitorDevices) + return STATUS_INSUFFICIENT_RESOURCES; + + /* Add the children */ + i = 0; + CurrentEntry = DeviceExtension->ChildDeviceList.Flink; + while (CurrentEntry != &DeviceExtension->ChildDeviceList) + { + ChildExtension = CONTAINING_RECORD(CurrentEntry, VIDEO_PORT_CHILD_EXTENSION, ListEntry); + + ObReferenceObject(ChildExtension->PhysicalDeviceObject); + pMonitorDevices[i++].pdo = ChildExtension->PhysicalDeviceObject; + CurrentEntry = CurrentEntry->Flink; + } + + *ppMonitorDevices = pMonitorDevices; + *Information = sizeof(pMonitorDevices); + return STATUS_SUCCESS; +} + static NTSTATUS VideoPortInitWin32kCallbacks( @@ -791,8 +836,10 @@ IntVideoPortDispatchDeviceControl( break; case IOCTL_VIDEO_ENUM_MONITOR_PDO: - WARN_(VIDEOPRT, "- IOCTL_VIDEO_ENUM_MONITOR_PDO is UNIMPLEMENTED!\n"); - Status = STATUS_NOT_IMPLEMENTED; + INFO_(VIDEOPRT, "- IOCTL_VIDEO_ENUM_MONITOR_PDO\n"); + Status = VideoPortEnumMonitorPdo(DeviceObject, + Irp->AssociatedIrp.SystemBuffer, + &Irp->IoStatus.Information); break; case IOCTL_VIDEO_INIT_WIN32K_CALLBACKS: