https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2ae6bd7453766c1069279…
commit 2ae6bd7453766c10692791d397b6a130138a3581
Author: Hervé Poussineau <hpoussin(a)reactos.org>
AuthorDate: Sat May 29 08:29:30 2021 +0200
Commit: Hervé Poussineau <hpoussin(a)reactos.org>
CommitDate: Sat Jun 5 23:38:05 2021 +0200
[VIDEOPRT] Give to each device its own entry in
HKLM\SYSTEM\CurrentControlSet\Services
This is required if you have two graphic cards using the same driver.
---
win32ss/drivers/videoprt/registry.c | 24 +++++++++++++++++++++---
win32ss/drivers/videoprt/videoprt.c | 2 ++
win32ss/drivers/videoprt/videoprt.h | 1 +
3 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/win32ss/drivers/videoprt/registry.c b/win32ss/drivers/videoprt/registry.c
index 362c251d21a..68e3d403353 100644
--- a/win32ss/drivers/videoprt/registry.c
+++ b/win32ss/drivers/videoprt/registry.c
@@ -531,18 +531,33 @@ NTSTATUS
NTAPI
IntCreateRegistryPath(
IN PCUNICODE_STRING DriverRegistryPath,
+ IN ULONG DeviceNumber,
OUT PUNICODE_STRING DeviceRegistryPath)
{
static WCHAR RegistryMachineSystem[] = L"\\REGISTRY\\MACHINE\\SYSTEM\\";
static WCHAR CurrentControlSet[] = L"CURRENTCONTROLSET\\";
static WCHAR ControlSet[] = L"CONTROLSET";
static WCHAR Insert1[] = L"Hardware
Profiles\\Current\\System\\CurrentControlSet\\";
- static WCHAR Insert2[] = L"\\Device0";
+ static WCHAR Insert2[] = L"\\Device";
+ UNICODE_STRING DeviceNumberString;
+ WCHAR DeviceNumberBuffer[20];
BOOLEAN Valid;
UNICODE_STRING AfterControlSet;
+ NTSTATUS Status;
AfterControlSet = *DriverRegistryPath;
+ /* Convert DeviceNumber to string */
+ DeviceNumberString.Length = 0;
+ DeviceNumberString.MaximumLength = sizeof(DeviceNumberBuffer);
+ DeviceNumberString.Buffer = DeviceNumberBuffer;
+ Status = RtlIntegerToUnicodeString(DeviceNumber, 10, &DeviceNumberString);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR_(VIDEOPRT, "RtlIntegerToUnicodeString(%u) returned 0x%08x\n",
DeviceNumber, Status);
+ return Status;
+ }
+
/* Check if path begins with \\REGISTRY\\MACHINE\\SYSTEM\\ */
Valid = (DriverRegistryPath->Length > sizeof(RegistryMachineSystem) &&
0 == _wcsnicmp(DriverRegistryPath->Buffer, RegistryMachineSystem,
@@ -586,7 +601,8 @@ IntCreateRegistryPath(
if (Valid)
{
- DeviceRegistryPath->MaximumLength = DriverRegistryPath->Length +
sizeof(Insert1) + sizeof(Insert2);
+ DeviceRegistryPath->MaximumLength = DriverRegistryPath->Length +
sizeof(Insert1) + sizeof(Insert2)
+ + DeviceNumberString.Length;
DeviceRegistryPath->Buffer = ExAllocatePoolWithTag(PagedPool,
DeviceRegistryPath->MaximumLength,
TAG_VIDEO_PORT);
@@ -600,6 +616,7 @@ IntCreateRegistryPath(
RtlAppendUnicodeToString(DeviceRegistryPath, Insert1);
RtlAppendUnicodeStringToString(DeviceRegistryPath, &AfterControlSet);
RtlAppendUnicodeToString(DeviceRegistryPath, Insert2);
+ RtlAppendUnicodeStringToString(DeviceRegistryPath, &DeviceNumberString);
/* Check if registry key exists */
Valid = NT_SUCCESS(RtlCheckRegistryKey(RTL_REGISTRY_ABSOLUTE,
DeviceRegistryPath->Buffer));
@@ -620,7 +637,7 @@ IntCreateRegistryPath(
/* If path doesn't point to *ControlSet*, use DriverRegistryPath directly */
if (!Valid)
{
- DeviceRegistryPath->MaximumLength = DriverRegistryPath->Length +
sizeof(Insert2);
+ DeviceRegistryPath->MaximumLength = DriverRegistryPath->Length +
sizeof(Insert2) + DeviceNumberString.Length;
DeviceRegistryPath->Buffer = ExAllocatePoolWithTag(NonPagedPool,
DeviceRegistryPath->MaximumLength,
TAG_VIDEO_PORT);
@@ -630,6 +647,7 @@ IntCreateRegistryPath(
RtlCopyUnicodeString(DeviceRegistryPath, DriverRegistryPath);
RtlAppendUnicodeToString(DeviceRegistryPath, Insert2);
+ RtlAppendUnicodeStringToString(DeviceRegistryPath, &DeviceNumberString);
}
DPRINT("Formatted registry key '%wZ' -> '%wZ'\n",
diff --git a/win32ss/drivers/videoprt/videoprt.c b/win32ss/drivers/videoprt/videoprt.c
index 6c54e16fbef..5d4c54a3559 100644
--- a/win32ss/drivers/videoprt/videoprt.c
+++ b/win32ss/drivers/videoprt/videoprt.c
@@ -170,6 +170,7 @@ IntVideoPortCreateAdapterDeviceObject(
/* Get the registry path associated with this device. */
Status = IntCreateRegistryPath(&DriverExtension->RegistryPath,
+
DriverExtension->InitializationData.StartingDeviceNumber,
&DeviceExtension->RegistryPath);
if (!NT_SUCCESS(Status))
{
@@ -242,6 +243,7 @@ IntVideoPortCreateAdapterDeviceObject(
IntCreateNewRegistryPath(DeviceExtension);
IntSetupDeviceSettingsKey(DeviceExtension);
+ DriverExtension->InitializationData.StartingDeviceNumber++;
/* Remove the initailizing flag */
(*DeviceObject)->Flags &= ~DO_DEVICE_INITIALIZING;
diff --git a/win32ss/drivers/videoprt/videoprt.h b/win32ss/drivers/videoprt/videoprt.h
index 7c559def846..408ca0b2b87 100644
--- a/win32ss/drivers/videoprt/videoprt.h
+++ b/win32ss/drivers/videoprt/videoprt.h
@@ -342,6 +342,7 @@ NTSTATUS
NTAPI
IntCreateRegistryPath(
IN PCUNICODE_STRING DriverRegistryPath,
+ IN ULONG DeviceNumber,
OUT PUNICODE_STRING DeviceRegistryPath);