[NTOS:IO]

- Pass the class key handle as a parameter to IopAttachFilterDrivers, since we already opened it in PipCallDriverAddDevice.
CORE-13336 #resolve

svn path=/trunk/; revision=75051
This commit is contained in:
Thomas Faber
2017-06-15 18:32:14 +00:00
parent 56c393d8f4
commit 830b3fc070
3 changed files with 16 additions and 66 deletions
+1
View File
@@ -1115,6 +1115,7 @@ FASTCALL
IopAttachFilterDrivers(
IN PDEVICE_NODE DeviceNode,
IN HANDLE EnumSubKey,
IN HANDLE ClassKey,
IN BOOLEAN Lower
);
+6 -59
View File
@@ -641,13 +641,10 @@ FASTCALL
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 @@ IopAttachFilterDrivers(
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,16 +679,17 @@ IopAttachFilterDrivers(
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))
{
DPRINT1("Failed to load class %s filters: %08X\n",
+9 -7
View File
@@ -253,7 +253,8 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode,
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 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode,
/* No class key */
DPRINT1("IopOpenRegistryKeyEx() failed for '%wZ' with status 0x%lx\n",
&ControlClass, Status);
ClassKey = NULL;
}
else
{
@@ -323,7 +323,6 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode,
/* No class key */
DPRINT1("IopOpenRegistryKeyEx() failed for '%wZ' with status 0x%lx\n",
&ClassGuid, Status);
ClassKey = NULL;
}
}
@@ -336,7 +335,6 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode,
ClassKey,
&Properties,
KEY_READ);
ZwClose(ClassKey);
if (!NT_SUCCESS(Status))
{
/* No properties */
@@ -355,7 +353,7 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode,
}
/* 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 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode,
goto Exit;
}
Status = IopAttachFilterDrivers(DeviceNode, SubKey, FALSE);
Status = IopAttachFilterDrivers(DeviceNode, SubKey, ClassKey, FALSE);
if (!NT_SUCCESS(Status))
{
IopRemoveDevice(DeviceNode);
@@ -378,8 +376,12 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode,
Status = IopStartDevice(DeviceNode);
Exit:
/* Close key and return status */
/* Close keys and return status */
ZwClose(SubKey);
if (ClassKey != NULL)
{
ZwClose(ClassKey);
}
return Status;
}