Author: tfaber Date: Thu Jun 15 18:32:14 2017 New Revision: 75051
URL: http://svn.reactos.org/svn/reactos?rev=75051&view=rev Log: [NTOS:IO] - Pass the class key handle as a parameter to IopAttachFilterDrivers, since we already opened it in PipCallDriverAddDevice. CORE-13336 #resolve
Modified: trunk/reactos/ntoskrnl/include/internal/io.h trunk/reactos/ntoskrnl/io/iomgr/driver.c trunk/reactos/ntoskrnl/io/pnpmgr/pnpinit.c
Modified: trunk/reactos/ntoskrnl/include/internal/io.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/i... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/io.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/io.h [iso-8859-1] Thu Jun 15 18:32:14 2017 @@ -1115,6 +1115,7 @@ IopAttachFilterDrivers( IN PDEVICE_NODE DeviceNode, IN HANDLE EnumSubKey, + IN HANDLE ClassKey, IN BOOLEAN Lower );
Modified: trunk/reactos/ntoskrnl/io/iomgr/driver.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/driver.c?... ============================================================================== --- trunk/reactos/ntoskrnl/io/iomgr/driver.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/iomgr/driver.c [iso-8859-1] Thu Jun 15 18:32:14 2017 @@ -641,13 +641,10 @@ IopAttachFilterDrivers( PDEVICE_NODE DeviceNode, HANDLE EnumSubKey, + HANDLE ClassKey, BOOLEAN Lower) { RTL_QUERY_REGISTRY_TABLE QueryTable[2] = { { NULL, 0, NULL, NULL, 0, NULL, 0 }, }; - UNICODE_STRING Class; - WCHAR ClassBuffer[40]; - UNICODE_STRING ControlClass = RTL_CONSTANT_STRING(L"\Registry\Machine\System\CurrentControlSet\Control\Class"); - HANDLE ControlKey, ClassKey; NTSTATUS Status;
/* @@ -673,57 +670,6 @@ return Status; }
- /* - * Now get the class GUID - */ - Class.Length = 0; - Class.MaximumLength = 40 * sizeof(WCHAR); - Class.Buffer = ClassBuffer; - QueryTable[0].QueryRoutine = NULL; - QueryTable[0].Name = L"ClassGUID"; - QueryTable[0].EntryContext = &Class; - QueryTable[0].Flags = RTL_QUERY_REGISTRY_REQUIRED | RTL_QUERY_REGISTRY_DIRECT; - - Status = RtlQueryRegistryValues(RTL_REGISTRY_HANDLE, - (PWSTR)EnumSubKey, - QueryTable, - DeviceNode, - NULL); - - /* If there is no class GUID, we're done */ - if (!NT_SUCCESS(Status)) - { - return STATUS_SUCCESS; - } - - /* - * Load the class filter driver - */ - Status = IopOpenRegistryKeyEx(&ControlKey, - NULL, - &ControlClass, - KEY_READ); - if (!NT_SUCCESS(Status)) - { - DPRINT1("IopOpenRegistryKeyEx() failed for '%wZ' with status 0x%lx\n", - &ControlClass, Status); - return STATUS_SUCCESS; - } - - /* Open subkey */ - Status = IopOpenRegistryKeyEx(&ClassKey, - ControlKey, - &Class, - KEY_READ); - if (!NT_SUCCESS(Status)) - { - /* It's okay if there's no class key */ - DPRINT1("IopOpenRegistryKeyEx() failed for '%wZ' with status 0x%lx\n", - &Class, Status); - ZwClose(ControlKey); - return STATUS_SUCCESS; - } - QueryTable[0].QueryRoutine = IopAttachFilterDriversCallback; if (Lower) QueryTable[0].Name = L"LowerFilters"; @@ -733,15 +679,16 @@ QueryTable[0].Flags = 0; QueryTable[0].DefaultType = REG_NONE;
+ if (ClassKey == NULL) + { + return STATUS_SUCCESS; + } + Status = RtlQueryRegistryValues(RTL_REGISTRY_HANDLE, (PWSTR)ClassKey, QueryTable, DeviceNode, NULL); - - /* Clean up */ - ZwClose(ClassKey); - ZwClose(ControlKey);
if (!NT_SUCCESS(Status)) {
Modified: trunk/reactos/ntoskrnl/io/pnpmgr/pnpinit.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/pnpmgr/pnpinit.... ============================================================================== --- trunk/reactos/ntoskrnl/io/pnpmgr/pnpinit.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/pnpmgr/pnpinit.c [iso-8859-1] Thu Jun 15 18:32:14 2017 @@ -253,7 +253,8 @@ IN PDRIVER_OBJECT DriverObject) { NTSTATUS Status; - HANDLE EnumRootKey, SubKey, ControlKey, ClassKey, PropertiesKey; + HANDLE EnumRootKey, SubKey; + HANDLE ControlKey, ClassKey = NULL, PropertiesKey; UNICODE_STRING ClassGuid, Properties; UNICODE_STRING EnumRoot = RTL_CONSTANT_STRING(ENUM_ROOT); UNICODE_STRING ControlClass = @@ -308,7 +309,6 @@ /* No class key */ DPRINT1("IopOpenRegistryKeyEx() failed for '%wZ' with status 0x%lx\n", &ControlClass, Status); - ClassKey = NULL; } else { @@ -323,7 +323,6 @@ /* No class key */ DPRINT1("IopOpenRegistryKeyEx() failed for '%wZ' with status 0x%lx\n", &ClassGuid, Status); - ClassKey = NULL; } }
@@ -336,7 +335,6 @@ ClassKey, &Properties, KEY_READ); - ZwClose(ClassKey); if (!NT_SUCCESS(Status)) { /* No properties */ @@ -355,7 +353,7 @@ }
/* Do ReactOS-style setup */ - Status = IopAttachFilterDrivers(DeviceNode, SubKey, TRUE); + Status = IopAttachFilterDrivers(DeviceNode, SubKey, ClassKey, TRUE); if (!NT_SUCCESS(Status)) { IopRemoveDevice(DeviceNode); @@ -368,7 +366,7 @@ goto Exit; }
- Status = IopAttachFilterDrivers(DeviceNode, SubKey, FALSE); + Status = IopAttachFilterDrivers(DeviceNode, SubKey, ClassKey, FALSE); if (!NT_SUCCESS(Status)) { IopRemoveDevice(DeviceNode); @@ -378,8 +376,12 @@ Status = IopStartDevice(DeviceNode);
Exit: - /* Close key and return status */ + /* Close keys and return status */ ZwClose(SubKey); + if (ClassKey != NULL) + { + ZwClose(ClassKey); + } return Status; }