[PATCH 3/3] shell32/autocomplete: Revamp pwzsRegKeyPath handling so it can deal with arbitrary sizes and make it more robust

Alexandre Julliard julliard at winehq.org
Thu Aug 30 07:44:04 CDT 2018


Gabriel Ivăncescu <gabrielopcode at gmail.com> writes:

> On Thu, Aug 30, 2018 at 2:50 PM, Alexandre Julliard <julliard at winehq.org> wrote:
>> Gabriel Ivăncescu <gabrielopcode at gmail.com> writes:
>>
>> There can still be a race, only you are making the function fail in that
>> case, that's not nice behavior. The right way to do that sort of thing
>> is to allocate a reasonable buffer, get the string (without querying the
>> length first), and on overflow restart the loop with a larger buffer.
>>
>
> Okay, you are right. I'll have it get the length first (because this
> simplifies the case where the value doesn't exist in HKCU but it does
> in HKLM), and start with that buffer size, then use a loop until it
> returns success (or some error other than ERROR_MORE_DATA) or its type
> is not REG_SZ (this should be a failure, right?).

You should never be getting the length first. Just get the data right
away.

>> The Wine implementation replicates the Windows behavior, based on test
>> cases. That's more reliable than MSDN.
>
> Yes you are correct but some hooks (like madCodeHook used in jauntePE)
> might hook the registry APIs to provide virtualized redirections. They
> *might* follow the MSDN instead of test-cases, because that's what
> MSDN claims, I really have no idea if they'll return a non-NUL
> terminated string though.

If anybody is implementing API hooking based only on MSDN descriptions,
they are in for a lot of trouble ;-)

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list