Prev: Windows Phone driver resources?
Next: Get KSPROPERTY_BDA_NODE_DESCRIPTORS in a Filterdriver once
From: John Bond on 12 Mar 2010 16:57 Problem with ZwEnumerateKey Code fragment is run in a KMDF 1.7 driver under Windows 7 //the size of this union works for SmartWORKS subkeys (Bus#Slot#) of Parameters\Devices\MtxBrd union { KEY_BASIC_INFORMATION Basic; KEY_NODE_INFORMATION Node; KEY_FULL_INFORMATION Full; KEY_NAME_INFORMATION Name; WCHAR wcRaw[256]; //provides extra space for Name & Class members (overkill?) } SubKeyInfo; SwrxRegistry *Found = NULL; HANDLE hKey = WdfRegistryWdmGetHandle(Key); findIndex = 0; ULONG RequiredLength; //JBHERE junk test code... NTSTATUS junkStatus = ZwQueryKey(hKey, KeyNameInformation, &SubKeyInfo, sizeof(SubKeyInfo), &RequiredLength); UNICODE_STRING us; RtlInitUnicodeString(&us, SubKeyInfo.Name.Name); TraceEvents(etInfo, DBG_REGISTRY, "ZwQueryKey(0x%p) name=%wZ, %!STATUS!", hKey, &us, junkStatus); junkStatus = ZwQueryKey(hKey, KeyFullInformation, &SubKeyInfo, sizeof(SubKeyInfo), &RequiredLength); TraceEvents(etInfo, DBG_REGISTRY, "ZwQueryKey(0x%p) subkeys=%d %!STATUS!", hKey, SubKeyInfo.Full.SubKeys, junkStatus); findStatus = ZwEnumerateKey(hKey, findIndex++, KeyNameInformation, &SubKeyInfo, sizeof(SubKeyInfo), &RequiredLength); TraceEvents(etError, DBG_REGISTRY, "ZwEnumerateKey handle 0x%p length %d index %d reqsize %d -- %!STATUS!", hKey, SubKeyInfo.Name.NameLength, findIndex-1, RequiredLength, findStatus); The above code reports the correct name of the key and that there are two subkeys... fine, but ZwEnumerateKey returns STATUS_INVALID_PARAMETER... I am perplexed, any ideas? John Bond
From: John Bond on 16 Mar 2010 10:47 Over the last two days, I found out the hard way, that even though “KeyNameInformation” is a valid KEY_INFORMATION_CLASS enum... It is NOT a valid 3rd parameter for ZwEnumerateKey… but the documentation only gives the slightest of hints to this problem. The function returns STATUS_INVALID_PARAMETER, which the doc says is caused by a 3rd parameter which is not of a certain type… but alas, it is a valid KEY_INFORMATION_CLASS enum, but just not valid for this function… (sigh) Could you add a comment saying that KeyNameInformation should not be used, but rather KeyNodeInformation… that is the best way to get the name of a SubKey. This could save someone else two days of wasted time writing a KMDF driver.
From: Doron Holan [MSFT] on 16 Mar 2010 18:50 did you send feedback on the webpage for ZwEnumerateKey with this comment? that feedback goes prety quickly to the doc writers who authored the page d -- This posting is provided "AS IS" with no warranties, and confers no rights. "John Bond" <johnbond(a)newsgroup.nospam> wrote in message news:9DDE589C-E99B-4A80-A2BD-322C7AE834B4(a)microsoft.com... > Over the last two days, I found out the hard way, that even though > “KeyNameInformation” is a valid KEY_INFORMATION_CLASS enum... > It is NOT a valid 3rd parameter for ZwEnumerateKey… but the documentation > only gives the slightest of hints to this problem. The function returns > STATUS_INVALID_PARAMETER, which the doc says is caused by a 3rd parameter > which is not of a certain type… but alas, it is a valid > KEY_INFORMATION_CLASS > enum, but just not valid for this function… (sigh) > Could you add a comment saying that KeyNameInformation should not be used, > but rather KeyNodeInformation… that is the best way to get the name of a > SubKey. > This could save someone else two days of wasted time writing a KMDF > driver. >
|
Pages: 1 Prev: Windows Phone driver resources? Next: Get KSPROPERTY_BDA_NODE_DESCRIPTORS in a Filterdriver once |