diff --git a/win32ss/drivers/videoprt/registry.c b/win32ss/drivers/videoprt/registry.c index 76b3ead08467a..64be360182776 100644 --- a/win32ss/drivers/videoprt/registry.c +++ b/win32ss/drivers/videoprt/registry.c @@ -668,7 +668,12 @@ IntCreateRegistryPath( } } - if (Valid) + if (!VideoPortUseNewKey) + { + INFO_(VIDEOPRT, "Using old registry key as 'UseNewKey' is FALSE\n"); + Valid = FALSE; + } + else if (Valid) { DeviceRegistryPath->MaximumLength = DriverRegistryPath->Length + sizeof(Insert1) + sizeof(Insert2) + DeviceNumberString.Length; diff --git a/win32ss/drivers/videoprt/videoprt.c b/win32ss/drivers/videoprt/videoprt.c index 4398d82e4809d..0348b677c7ba7 100644 --- a/win32ss/drivers/videoprt/videoprt.c +++ b/win32ss/drivers/videoprt/videoprt.c @@ -38,6 +38,7 @@ BOOLEAN VpNoVesa = FALSE; PKPROCESS CsrProcess = NULL; static ULONG VideoPortMaxObjectNumber = -1; +BOOLEAN VideoPortUseNewKey = FALSE; KMUTEX VideoPortInt10Mutex; KSPIN_LOCK HwResetAdaptersLock; RTL_STATIC_LIST_HEAD(HwResetAdaptersList); @@ -58,6 +59,7 @@ NTSTATUS IntVideoPortAddDeviceMapLink( PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension) { + PUNICODE_STRING RegistryPath; WCHAR DeviceBuffer[20]; UNICODE_STRING DeviceName; WCHAR SymlinkBuffer[20]; @@ -69,13 +71,18 @@ IntVideoPortAddDeviceMapLink( DeviceNumber = DeviceExtension->DeviceNumber; swprintf(DeviceBuffer, L"\\Device\\Video%lu", DeviceNumber); + if (VideoPortUseNewKey) + RegistryPath = &DeviceExtension->NewRegistryPath; + else + RegistryPath = &DeviceExtension->RegistryPath; + /* Add entry to DEVICEMAP\VIDEO key in registry. */ Status = RtlWriteRegistryValue(RTL_REGISTRY_DEVICEMAP, L"VIDEO", DeviceBuffer, REG_SZ, - DeviceExtension->NewRegistryPath.Buffer, - DeviceExtension->NewRegistryPath.Length + sizeof(UNICODE_NULL)); + RegistryPath->Buffer, + RegistryPath->Length + sizeof(UNICODE_NULL)); if (!NT_SUCCESS(Status)) { ERR_(VIDEOPRT, "Failed to create DEViCEMAP registry entry: 0x%X\n", Status); @@ -516,12 +523,28 @@ IntLoadRegistryParameters(VOID) { NTSTATUS Status; HANDLE KeyHandle; + UNICODE_STRING UseNewKeyPath = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\GraphicsDrivers\\UseNewKey"); UNICODE_STRING Path = RTL_CONSTANT_STRING(L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Control"); UNICODE_STRING ValueName = RTL_CONSTANT_STRING(L"SystemStartOptions"); OBJECT_ATTRIBUTES ObjectAttributes; PKEY_VALUE_PARTIAL_INFORMATION KeyInfo; ULONG Length, NewLength; + /* Check if we need to use new registry */ + InitializeObjectAttributes(&ObjectAttributes, + &UseNewKeyPath, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, + NULL, + NULL); + Status = ZwOpenKey(&KeyHandle, + GENERIC_READ | GENERIC_WRITE, + &ObjectAttributes); + if (NT_SUCCESS(Status)) + { + VideoPortUseNewKey = TRUE; + ZwClose(KeyHandle); + } + /* Initialize object attributes with the path we want */ InitializeObjectAttributes(&ObjectAttributes, &Path, diff --git a/win32ss/drivers/videoprt/videoprt.h b/win32ss/drivers/videoprt/videoprt.h index bf4290e014dcf..44824dc2bdd15 100644 --- a/win32ss/drivers/videoprt/videoprt.h +++ b/win32ss/drivers/videoprt/videoprt.h @@ -249,6 +249,7 @@ IntVideoPortMapPhysicalMemory( extern PKPROCESS CsrProcess; extern ULONG VideoPortDeviceNumber; +extern BOOLEAN VideoPortUseNewKey; extern KMUTEX VideoPortInt10Mutex; extern KSPIN_LOCK HwResetAdaptersLock; extern LIST_ENTRY HwResetAdaptersList;