My WDM driver needs to know if a particular registry key exists
The following code fails with a 3C status even when the reg path exists
UNICODE_STRING uszTemp;
OBJECT_ATTRIBUTES ObjAttrs;
KEY_VALUE_PARTIAL_INFORMATION valueInfo;
UNICODE_STRING uszName;
RtlInitUnicodeString(&uszTemp,"\\Registry\\Machine\\SOFTWARE\\xxx");
InitializeObjectAttributes(&ObjAttrs, &uszTemp,
OBJ_KERNEL_HANDLE|OBJ_CASE_INSENSITIVE, NULL, NULL);
RtlFillMemory(&valueInfo, sizeof(KEY_VALUE_PARTIAL_INFORMATION), 0x0);
RtlInitUnicodeString(&uszName, L"yyy");
status = ZwOpenKey(&KeyHandle, KEY_READ, &ObjAttrs);
By contrast,
RtlCheckRegistryKey(RTL_REGISTRY_ABSOLUTE,L"\\Registry\\Machine\\SOFTWARE\\xxx\\yyy")
returns STATUS_SUCCESS
However RtlCheckRegistryKey only exists in ntddk.h. and does not exists
in wdm.h
This strongly hints that RtlCheckRegistryKey should NOT be used in a wdm
driver. What do other people do? Is there a wdm.h compatible alternative
to RtlCheckRegistryKey or a way of making ZwOpenKey work?