** WIP ** DPRINT Investigations for HwFindAdapter and others

This commit is contained in:
Hermès Bélusca-Maïto
2026-01-29 16:26:17 +01:00
parent e24c87021f
commit 640f4d7d9f
2 changed files with 44 additions and 2 deletions

View File

@@ -27,6 +27,14 @@
#define NDEBUG
#include <debug.h>
#undef ERR_
#undef WARN_
#undef INFO_
#undef TRACE_
#define TRACE_(ch, fmt, ...) DPRINT1(fmt, ##__VA_ARGS__)
#define INFO_(ch, fmt, ...) DPRINT1(fmt, ##__VA_ARGS__)
#define WARN_(ch, fmt, ...) DPRINT1(fmt, ##__VA_ARGS__)
#define ERR_(ch, fmt, ...) DPRINT1(fmt, ##__VA_ARGS__)
/* GLOBAL VARIABLES ***********************************************************/
@@ -342,6 +350,8 @@ IntVideoPortAddDevice(
/* Get the initialization data we saved in VideoPortInitialize */
DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
DPRINT1("%s(0x%p, PDO 0x%p, Ext 0x%p)\n", __FUNCTION__, DriverObject, PhysicalDeviceObject, DriverExtension);
/* Create adapter device object */
Status = IntVideoPortCreateAdapterDeviceObject(DriverObject,
DriverExtension,
@@ -376,6 +386,7 @@ IntVideoPortDispatchOpen(
TRACE_(VIDEOPRT, "IntVideoPortDispatchOpen\n");
DPRINT1("%s(0x%p) - CsrProcess 0x%p\n", __FUNCTION__, DeviceObject, CsrProcess);
if (!CsrProcess)
{
/* We know the first open call is from the CSRSS process.
@@ -385,6 +396,7 @@ IntVideoPortDispatchOpen(
ObReferenceObject(CsrProcess);
INFO_(VIDEOPRT, "CsrProcess 0x%p\n", CsrProcess);
DPRINT1("%s: !CsrProcess, calling IntInitializeInt10(CSR);\n", __FUNCTION__);
Status = IntInitializeInt10();
if (!NT_SUCCESS(Status))
{
@@ -400,18 +412,22 @@ IntVideoPortDispatchOpen(
// FIXME: (Re-)initialize INBV only if DeviceObject doesn't belong to a mirror driver.
IntVideoPortInbvInitialize();
DPRINT1("%s: Calling HwInitialize() -->\n", __FUNCTION__);
if (DriverExtension->InitializationData.HwInitialize(&DeviceExtension->MiniPortDeviceExtension))
{
DPRINT1("%s: <-- HwInitialize() returned SUCCESS\n", __FUNCTION__);
Status = STATUS_SUCCESS;
InterlockedIncrement((PLONG)&DeviceExtension->DeviceOpened);
/* Query children, now that device is opened */
DPRINT1("%s: VideoPortEnumerateChildren()\n"); // TODO: I'm not sure this is the correct thing to do!
VideoPortEnumerateChildren(DeviceExtension->MiniPortDeviceExtension, NULL);
}
else
{
DPRINT1("%s: <-- HwInitialize() returned FAILURE\n", __FUNCTION__);
Status = STATUS_UNSUCCESSFUL;
// IoInvalidateDeviceState(DeviceExtension->PhysicalDeviceObject);
}
Irp->IoStatus.Status = Status;
@@ -907,6 +923,8 @@ IntVideoPortPnPStartDevice(
DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
DPRINT1("%s(0x%p, driver 0x%p)\n", __FUNCTION__, DeviceObject, DriverObject);
/* Store some resources in the DeviceExtension */
AllocatedResources = Stack->Parameters.StartDevice.AllocatedResources;
if (AllocatedResources != NULL)
@@ -995,6 +1013,8 @@ IntVideoPortQueryBusRelations(PDEVICE_OBJECT DeviceObject, PIRP Irp)
PLIST_ENTRY CurrentEntry;
NTSTATUS Status;
DPRINT1("%s(0x%p)\n", __FUNCTION__, DeviceObject);
if (InterlockedCompareExchange((PLONG)&DeviceExtension->DeviceOpened, 0, 0) == 0)
{
/* Device not opened. Don't enumerate children yet */
@@ -1203,6 +1223,8 @@ IntVideoPortDispatchPnp(
{
PVIDEO_PORT_COMMON_EXTENSION CommonExtension = DeviceObject->DeviceExtension;
DPRINT1("%s(0x%p, %s)\n", __FUNCTION__, DeviceObject, CommonExtension->Fdo ? "FDO" : "PDO");
if (CommonExtension->Fdo)
return IntVideoPortDispatchFdoPnp(DeviceObject, Irp);
else

View File

@@ -28,6 +28,14 @@
#define NDEBUG
#include <debug.h>
#undef ERR_
#undef WARN_
#undef INFO_
#undef TRACE_
#define TRACE_(ch, fmt, ...) DPRINT1(fmt, ##__VA_ARGS__)
#define INFO_(ch, fmt, ...) DPRINT1(fmt, ##__VA_ARGS__)
#define WARN_(ch, fmt, ...) DPRINT1(fmt, ##__VA_ARGS__)
#define ERR_(ch, fmt, ...) DPRINT1(fmt, ##__VA_ARGS__)
/* GLOBAL VARIABLES ***********************************************************/
@@ -186,6 +194,8 @@ IntVideoPortCreateAdapterDeviceObject(
UNICODE_STRING DeviceName;
PDEVICE_OBJECT DeviceObject_;
DPRINT1("%s(dro 0x%p, ext 0x%p, PDO 0x%p)\n", __FUNCTION__, DriverObject, DriverExtension, PhysicalDeviceObject);
if (DeviceObject == NULL)
DeviceObject = &DeviceObject_;
@@ -444,6 +454,8 @@ IntVideoPortFindAdapter(
UCHAR Again = FALSE;
BOOLEAN VgaResourcesReleased = FALSE;
DPRINT1("%s(0x%p, 0x%p, 0x%p, %s)\n", __FUNCTION__, DriverObject, DriverExtension, DeviceObject, LegacyDetection ? "Legacy" : "Non-legacy");
if (LegacyDetection)
{
ASSERT(DeviceObject == NULL);
@@ -549,13 +561,14 @@ IntVideoPortFindAdapter(
/* FIXME: Need to figure out what string to pass as param 3. */
// FIXME: Handle the 'Again' parameter for legacy detection.
DPRINT1("%s: Legacy: Calling HwFindAdapter() -->\n", __FUNCTION__);
vpStatus = DriverExtension->InitializationData.HwFindAdapter(
&DeviceExtension->MiniPortDeviceExtension,
DriverExtension->HwContext,
NULL,
&ConfigInfo,
&Again);
DPRINT1("%s: <-- Legacy HwFindAdapter() returned\n", __FUNCTION__);
if (vpStatus == ERROR_DEV_NOT_EXIST)
continue;
else
@@ -565,12 +578,14 @@ IntVideoPortFindAdapter(
else
{
/* FIXME: Need to figure out what string to pass as param 3. */
DPRINT1("%s: Non-legacy: Calling HwFindAdapter()\n", __FUNCTION__);
vpStatus = DriverExtension->InitializationData.HwFindAdapter(
&DeviceExtension->MiniPortDeviceExtension,
DriverExtension->HwContext,
NULL,
&ConfigInfo,
&Again);
DPRINT1("%s: <-- Non-legacy HwFindAdapter() returned\n", __FUNCTION__);
}
if (vpStatus != NO_ERROR)
@@ -965,6 +980,7 @@ VideoPortInitialize(
KeInitializeSpinLock(&HwResetAdaptersLock);
IntLoadRegistryParameters();
DPRINT1("%s: 1st initialization, calling IntInitializeInt10(FirstInit);\n", __FUNCTION__);
Status = IntInitializeInt10();
if (!NT_SUCCESS(Status))
{
@@ -1489,6 +1505,8 @@ IntVideoPortEnumerateChildren(
PDEVICE_OBJECT ChildDeviceObject;
PVIDEO_PORT_CHILD_EXTENSION ChildExtension;
DPRINT1("%s(0x%p)\n", __FUNCTION__, DeviceObject);
INFO_(VIDEOPRT, "Starting child device probe\n");
DeviceExtension = DeviceObject->DeviceExtension;
if (DeviceExtension->DriverExtension->InitializationData.HwGetVideoChildDescriptor == NULL)
@@ -1541,6 +1559,7 @@ IntVideoPortEnumerateChildren(
ChildEnumInfo.ChildIndex = ChildExtension->ChildId;
INFO_(VIDEOPRT, "Probing child: %d\n", ChildEnumInfo.ChildIndex);
DPRINT1("%s: Calling HwGetVideoChildDescriptor() -->\n", __FUNCTION__);
Status = DeviceExtension->DriverExtension->InitializationData.HwGetVideoChildDescriptor(
DeviceExtension->MiniPortDeviceExtension,
&ChildEnumInfo,
@@ -1548,6 +1567,7 @@ IntVideoPortEnumerateChildren(
ChildExtension->ChildDescriptor,
&Uid,
&Unused);
DPRINT1("%s: <-- HwGetVideoChildDescriptor() returned 0x%08lx\n", __FUNCTION__, Status);
if (Status == VIDEO_ENUM_MORE_DEVICES)
{
if (ChildExtension->ChildType == Monitor)