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?

Re: Use of RtlCheckRegistryKey in WDM driver? by Maxim

Maxim
Wed Apr 20 12:52:50 CDT 2005

> 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?

WDM means - "Win9x compatible". If you do not target these OSes - then you can
forget the word "WDM" and only remember the word "NT". Use NTDDK.H in this
case.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com



Re: Use of RtlCheckRegistryKey in WDM driver? by T

T
Thu Apr 21 15:12:30 CDT 2005

Maxim S. Shatskih wrote:
>>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?
>
> WDM means - "Win9x compatible". If you do not target these OSes - then you can
> forget the word "WDM" and only remember the word "NT". Use NTDDK.H in this
> case.

No - I dont need to support the 9X OSes and RtlCheckRegistryKey does
what I need in NT and 2K
Thanks
Tim