RtlQueryRegistryValues



I was just reading Doron's latest blog entry where he was talking about strings in the registry not being NULL terminated, and I realized that I have no idea how RtlQueryRegistryValues works when you specify RTL_QUERY_REGISTRY_DIRECT in the QueryTable.

Is this thing just a giant security hole waiting to happen or what?

It doesn't appear that you can specify the type of the value (at least if you also happen to pass RTL_QUERY_REGISTRY_REQUIRED... and I'm not sure that the DefaultValue constrains the DDI even if you don't), so how can you possibly pass in anything in the EntryContext that can hold the result regardless of what type that registry value happens to be?

I mean I suppose if you always passed in an 8 byte buffer where the first DWORD was 8 and the second 0, that it would technically work regardless of whether the value was a REG_SZ (where it would be interpreted as a UNICODE_STRING with a NULL buffer to be allocated, or a raw buffer of length 8, depending on what type the value was)... Is that what you have to do?

I'm perplexed that I can't find any discussion of this problem anywhere that I've looked (maybe that's because I haven't had my coffee this morning, and somehow it's not a problem, but...).

Sure... the correct answer is probably "use KMDF", but still I'm curious (besides, even in our KMDF driver we're still using RtlQueryRegistryValues in some places).
--
Ray
.



Relevant Pages

  • Re: Reading GUID from registry
    ... buffer for the string without space for the NULL. ... Don Burn (MVP, Windows DDK) ... Now I am setting this value in Registry. ...
    (microsoft.public.development.device.drivers)
  • Re: TcpClient buffer size limit?
    ... > Are there any other registry setting that I can set to make the TCP ... socket option or buffer size. ... Take care of your adapter settings, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Entropy sources under WinXP
    ... You cannot directly read this value without risking a buffer overflow on ... Windows version before Windows Vista. ... registry value of unknown size can be read: ...
    (sci.crypt)
  • Re: DefaultPlaybackDevice doesnt reset
    ... device in the registry. ... After I do this I have the code sleep for a ... So the sound is heard on the device that was the default at ... secondary buffer using the device GUID. ...
    (microsoft.public.win32.programmer.directx.audio)
  • Re: Entropy sources under WinXP
    ... There is no jb followed by a race-safe push of ... If the compiled code re-fetches the length value from the registry key ... buffer can't overflow. ...
    (sci.crypt)