https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2538583dbe13560676ac9…
commit 2538583dbe13560676ac9bb3dc0911b8a070c1a1
Author: Hervé Poussineau <hpoussin(a)reactos.org>
AuthorDate: Sun Jan 2 21:31:29 2022 +0100
Commit: Hervé Poussineau <hpoussin(a)reactos.org>
CommitDate: Thu Jan 6 22:02:07 2022 +0100
[VIDEOPRT] Query children only when device has been opened
HwGetVideoChildDescriptor callback must be called only after HwInitialize.
CORE-17979
---
win32ss/drivers/videoprt/dispatch.c | 15 ++++++++++++++
win32ss/drivers/videoprt/videoprt.c | 41 ++++++++++++++++++++++++-------------
win32ss/drivers/videoprt/videoprt.h | 5 +++++
3 files changed, 47 insertions(+), 14 deletions(-)
diff --git a/win32ss/drivers/videoprt/dispatch.c b/win32ss/drivers/videoprt/dispatch.c
index 6ab73148530..ac5e5b880d7 100644
--- a/win32ss/drivers/videoprt/dispatch.c
+++ b/win32ss/drivers/videoprt/dispatch.c
@@ -407,6 +407,9 @@ IntVideoPortDispatchOpen(
{
Status = STATUS_SUCCESS;
InterlockedIncrement((PLONG)&DeviceExtension->DeviceOpened);
+
+ /* Query children, now that device is opened */
+ VideoPortEnumerateChildren(DeviceExtension->MiniPortDeviceExtension, NULL);
}
else
{
@@ -938,6 +941,18 @@ IntVideoPortQueryBusRelations(PDEVICE_OBJECT DeviceObject, PIRP Irp)
PVIDEO_PORT_CHILD_EXTENSION ChildExtension;
ULONG i;
PLIST_ENTRY CurrentEntry;
+ NTSTATUS Status;
+
+ if (InterlockedCompareExchange((PLONG)&DeviceExtension->DeviceOpened, 0, 0) ==
0)
+ {
+ /* Device not opened. Don't enumerate children yet */
+ WARN_(VIDEOPRT, "Skipping child enumeration because device is not
opened");
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+ /* Query children of the device. */
+ Status = IntVideoPortEnumerateChildren(DeviceObject, Irp);
+ if (!NT_SUCCESS(Status))
+ return Status;
/* Count the children */
i = 0;
diff --git a/win32ss/drivers/videoprt/videoprt.c b/win32ss/drivers/videoprt/videoprt.c
index 6f94d2a788d..4398d82e480 100644
--- a/win32ss/drivers/videoprt/videoprt.c
+++ b/win32ss/drivers/videoprt/videoprt.c
@@ -474,9 +474,6 @@ IntVideoPortFindAdapter(
&HwResetAdaptersLock);
}
- /* Query children of the device. */
- VideoPortEnumerateChildren(&DeviceExtension->MiniPortDeviceExtension, NULL);
-
INFO_(VIDEOPRT, "STATUS_SUCCESS\n");
return STATUS_SUCCESS;
@@ -1170,11 +1167,10 @@ VideoPortSynchronizeExecution(
/*
* @implemented
*/
-VP_STATUS
-NTAPI
-VideoPortEnumerateChildren(
- IN PVOID HwDeviceExtension,
- IN PVOID Reserved)
+NTSTATUS NTAPI
+IntVideoPortEnumerateChildren(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
{
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
ULONG Status;
@@ -1187,17 +1183,17 @@ VideoPortEnumerateChildren(
PVIDEO_PORT_CHILD_EXTENSION ChildExtension;
INFO_(VIDEOPRT, "Starting child device probe\n");
- DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
+ DeviceExtension = DeviceObject->DeviceExtension;
if
(DeviceExtension->DriverExtension->InitializationData.HwGetVideoChildDescriptor ==
NULL)
{
WARN_(VIDEOPRT, "Miniport's HwGetVideoChildDescriptor is
NULL!\n");
- return NO_ERROR;
+ return STATUS_SUCCESS;
}
if (!IsListEmpty(&DeviceExtension->ChildDeviceList))
{
ERR_(VIDEOPRT, "FIXME: Support calling VideoPortEnumerateChildren
again!\n");
- return NO_ERROR;
+ return STATUS_SUCCESS;
}
/* Enumerate the children */
@@ -1239,7 +1235,7 @@ VideoPortEnumerateChildren(
INFO_(VIDEOPRT, "Probing child: %d\n", ChildEnumInfo.ChildIndex);
Status =
DeviceExtension->DriverExtension->InitializationData.HwGetVideoChildDescriptor(
- HwDeviceExtension,
+ DeviceExtension->MiniPortDeviceExtension,
&ChildEnumInfo,
&ChildExtension->ChildType,
ChildExtension->ChildDescriptor,
@@ -1331,8 +1327,25 @@ VideoPortEnumerateChildren(
&ChildExtension->ListEntry);
}
- /* Trigger reenumeration by the PnP manager */
- IoInvalidateDeviceRelations(DeviceExtension->PhysicalDeviceObject, BusRelations);
+ return STATUS_SUCCESS;
+}
+
+VP_STATUS
+NTAPI
+VideoPortEnumerateChildren(
+ IN PVOID HwDeviceExtension,
+ IN PVOID Reserved)
+{
+ PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
+
+ DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
+ ASSERT(DeviceExtension);
+
+ if (DeviceExtension->PhysicalDeviceObject)
+ {
+ /* Trigger reenumeration by the PnP manager */
+ IoInvalidateDeviceRelations(DeviceExtension->PhysicalDeviceObject,
BusRelations);
+ }
return NO_ERROR;
}
diff --git a/win32ss/drivers/videoprt/videoprt.h b/win32ss/drivers/videoprt/videoprt.h
index 61363fafadc..bf4290e014d 100644
--- a/win32ss/drivers/videoprt/videoprt.h
+++ b/win32ss/drivers/videoprt/videoprt.h
@@ -279,6 +279,11 @@ IntVideoPortGetProcAddress(
IN PVOID HwDeviceExtension,
IN PUCHAR FunctionName);
+NTSTATUS NTAPI
+IntVideoPortEnumerateChildren(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp);
+
/* int10.c */
NTSTATUS