UNICODE_STRING EnumRoot = RTL_CONSTANT_STRING(ENUM_ROOT);
UNICODE_STRING ControlClass = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Class");
HANDLE EnumRootKey, SubKey;
+ HANDLE ControlKey, ClassKey;
NTSTATUS Status;
/* Open enumeration root key */
EnumRootKey,
&DeviceNode->InstancePath,
KEY_READ);
+ ZwClose(EnumRootKey);
if (!NT_SUCCESS(Status))
{
DPRINT1("IopOpenRegistryKeyEx() failed for '%wZ' with status 0x%lx\n",
&DeviceNode->InstancePath, Status);
- ZwClose(EnumRootKey);
return Status;
}
DPRINT1("Failed to load device %s filters: %08X\n",
Lower ? "lower" : "upper", Status);
ZwClose(SubKey);
- ZwClose(EnumRootKey);
return Status;
}
DeviceNode,
NULL);
- /* Close handles */
+ /* Close subkey */
ZwClose(SubKey);
- ZwClose(EnumRootKey);
/* If there is no class GUID, we're done */
if (!NT_SUCCESS(Status))
/*
* Load the class filter driver
*/
- Status = IopOpenRegistryKeyEx(&EnumRootKey,
+ Status = IopOpenRegistryKeyEx(&ControlKey,
NULL,
&ControlClass,
KEY_READ);
}
/* Open subkey */
- Status = IopOpenRegistryKeyEx(&SubKey,
- EnumRootKey,
+ 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(EnumRootKey);
+ ZwClose(ControlKey);
return STATUS_SUCCESS;
}
QueryTable[0].DefaultType = REG_NONE;
Status = RtlQueryRegistryValues(RTL_REGISTRY_HANDLE,
- (PWSTR)SubKey,
+ (PWSTR)ClassKey,
QueryTable,
DeviceNode,
NULL);
/* Clean up */
- ZwClose(SubKey);
- ZwClose(EnumRootKey);
+ ZwClose(ClassKey);
+ ZwClose(ControlKey);
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to load class %s filters: %08X\n",
Lower ? "lower" : "upper", Status);
- ZwClose(SubKey);
- ZwClose(EnumRootKey);
return Status;
}