[VIDEOPRT] Fix adapter id

This commit is contained in:
Timo Kreuzer 2021-07-03 22:59:30 +02:00 committed by Hervé Poussineau
parent af314557c0
commit 545352c655
4 changed files with 41 additions and 6 deletions

View file

@ -346,6 +346,8 @@ IntVideoPortAddDevice(
Status = IntVideoPortCreateAdapterDeviceObject(DriverObject,
DriverExtension,
PhysicalDeviceObject,
DriverExtension->InitializationData.StartingDeviceNumber,
0,
&DeviceObject);
if (!NT_SUCCESS(Status))
{

View file

@ -21,6 +21,7 @@
#include "videoprt.h"
#include <ndk/obfuncs.h>
#include <stdio.h>
#define NDEBUG
#include <debug.h>
@ -369,6 +370,7 @@ IntCreateNewRegistryPath(
ULONG ResultLength;
USHORT KeyMaxLength;
OBJECT_ATTRIBUTES ObjectAttributes;
PWCHAR InstanceIdBuffer;
/* Open the hardware key: HKLM\System\CurrentControlSet\Enum\... */
Status = IoOpenDeviceRegistryKey(DeviceExtension->PhysicalDeviceObject,
@ -476,9 +478,14 @@ IntCreateNewRegistryPath(
/* Append a the instance path */ /// \todo HACK
RtlAppendUnicodeToString(&DeviceExtension->NewRegistryPath, L"\\");
InstanceIdBuffer = DeviceExtension->NewRegistryPath.Buffer +
DeviceExtension->NewRegistryPath.Length / sizeof(WCHAR);
RtlAppendUnicodeToString(&DeviceExtension->NewRegistryPath, L"0000");
/* Check this key again */
/* Write instance ID */
swprintf(InstanceIdBuffer, L"%04u", DeviceExtension->DisplayNumber);
/* Check if the name exists */
Status = RtlCheckRegistryKey(RTL_REGISTRY_ABSOLUTE,
DeviceExtension->NewRegistryPath.Buffer);
if (Status != STATUS_SUCCESS)
@ -521,8 +528,11 @@ IntCreateNewRegistryPath(
/* Copy the registry data from the legacy key */
Status = IntCopyRegistryKey(SettingsKey, NewKey);
}
/* Close the key handles */
ObCloseHandle(SettingsKey, KernelMode);
ObCloseHandle(NewKey, KernelMode);
}
return Status;
}

View file

@ -153,6 +153,8 @@ IntVideoPortCreateAdapterDeviceObject(
_In_ PDRIVER_OBJECT DriverObject,
_In_ PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
_In_opt_ PDEVICE_OBJECT PhysicalDeviceObject,
_In_ USHORT AdapterNumber,
_In_ USHORT DisplayNumber,
_Out_opt_ PDEVICE_OBJECT *DeviceObject)
{
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
@ -223,12 +225,14 @@ IntVideoPortCreateAdapterDeviceObject(
DeviceExtension->FunctionalDeviceObject = *DeviceObject;
DeviceExtension->DriverExtension = DriverExtension;
DeviceExtension->SessionId = -1;
DeviceExtension->AdapterNumber = AdapterNumber;
DeviceExtension->DisplayNumber = DisplayNumber;
InitializeListHead(&DeviceExtension->ChildDeviceList);
/* Get the registry path associated with this device. */
Status = IntCreateRegistryPath(&DriverExtension->RegistryPath,
DriverExtension->InitializationData.StartingDeviceNumber,
DeviceExtension->AdapterNumber,
&DeviceExtension->RegistryPath);
if (!NT_SUCCESS(Status))
{
@ -299,9 +303,16 @@ IntVideoPortCreateAdapterDeviceObject(
*DeviceObject,
PhysicalDeviceObject);
IntCreateNewRegistryPath(DeviceExtension);
Status = IntCreateNewRegistryPath(DeviceExtension);
if (!NT_SUCCESS(Status))
{
ERR_(VIDEOPRT, "IntCreateNewRegistryPath() failed with status 0x%08x\n", Status);
IoDeleteDevice(*DeviceObject);
*DeviceObject = NULL;
return Status;
}
IntSetupDeviceSettingsKey(DeviceExtension);
DriverExtension->InitializationData.StartingDeviceNumber++;
/* Remove the initailizing flag */
(*DeviceObject)->Flags &= ~DO_DEVICE_INITIALIZING;
@ -316,6 +327,11 @@ IntVideoPortCreateAdapterDeviceObject(
return Status;
}
if (DisplayNumber == 0)
{
DriverExtension->InitializationData.StartingDeviceNumber++;
}
return STATUS_SUCCESS;
}
@ -798,6 +814,8 @@ VideoPortInitialize(
Status = IntVideoPortCreateAdapterDeviceObject(DriverObject,
DriverExtension,
NULL,
DriverExtension->InitializationData.StartingDeviceNumber,
0,
&DeviceObject);
if (!NT_SUCCESS(Status))
{

View file

@ -107,7 +107,10 @@ typedef struct _VIDEO_PORT_DEVICE_EXTENSTION
LIST_ENTRY DmaAdapterList, ChildDeviceList;
LIST_ENTRY HwResetListEntry;
ULONG SessionId;
CHAR MiniPortDeviceExtension[1];
USHORT AdapterNumber;
USHORT DisplayNumber;
ULONG NumberOfSecondaryDisplays;
CHAR POINTER_ALIGNMENT MiniPortDeviceExtension[1];
} VIDEO_PORT_DEVICE_EXTENSION, *PVIDEO_PORT_DEVICE_EXTENSION;
typedef struct _VIDEO_PORT_CHILD_EXTENSION
@ -260,6 +263,8 @@ IntVideoPortCreateAdapterDeviceObject(
_In_ PDRIVER_OBJECT DriverObject,
_In_ PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
_In_opt_ PDEVICE_OBJECT PhysicalDeviceObject,
_In_ USHORT AdapterNumber,
_In_ USHORT DisplayNumber,
_Out_opt_ PDEVICE_OBJECT *DeviceObject);
NTSTATUS NTAPI