https://git.reactos.org/?p=reactos.git;a=commitdiff;h=545352c65590421198b4a…
commit 545352c65590421198b4aa3a7b4bdf14861fd0bd
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Sat Jul 3 22:59:30 2021 +0200
Commit: Hervé Poussineau <hpoussin(a)reactos.org>
CommitDate: Sat Jul 10 16:27:44 2021 +0200
[VIDEOPRT] Fix adapter id
---
win32ss/drivers/videoprt/dispatch.c | 2 ++
win32ss/drivers/videoprt/registry.c | 14 ++++++++++++--
win32ss/drivers/videoprt/videoprt.c | 24 +++++++++++++++++++++---
win32ss/drivers/videoprt/videoprt.h | 7 ++++++-
4 files changed, 41 insertions(+), 6 deletions(-)
diff --git a/win32ss/drivers/videoprt/dispatch.c b/win32ss/drivers/videoprt/dispatch.c
index 6c01995de5e..77339574f40 100644
--- a/win32ss/drivers/videoprt/dispatch.c
+++ b/win32ss/drivers/videoprt/dispatch.c
@@ -346,6 +346,8 @@ IntVideoPortAddDevice(
Status = IntVideoPortCreateAdapterDeviceObject(DriverObject,
DriverExtension,
PhysicalDeviceObject,
+
DriverExtension->InitializationData.StartingDeviceNumber,
+ 0,
&DeviceObject);
if (!NT_SUCCESS(Status))
{
diff --git a/win32ss/drivers/videoprt/registry.c b/win32ss/drivers/videoprt/registry.c
index 68e3d403353..8d43b32edab 100644
--- a/win32ss/drivers/videoprt/registry.c
+++ b/win32ss/drivers/videoprt/registry.c
@@ -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;
}
diff --git a/win32ss/drivers/videoprt/videoprt.c b/win32ss/drivers/videoprt/videoprt.c
index 31f4efef72a..c8decdcc95d 100644
--- a/win32ss/drivers/videoprt/videoprt.c
+++ b/win32ss/drivers/videoprt/videoprt.c
@@ -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))
{
diff --git a/win32ss/drivers/videoprt/videoprt.h b/win32ss/drivers/videoprt/videoprt.h
index 408ca0b2b87..6ff90e2dd2a 100644
--- a/win32ss/drivers/videoprt/videoprt.h
+++ b/win32ss/drivers/videoprt/videoprt.h
@@ -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