[PATCH] gdi32: Create the Software\Wine\Fonts keys one at a time.

Emil Velikov emil.l.velikov at gmail.com
Sat Oct 2 20:15:54 CDT 2021


Hi Gabriel,

Small fly-fy suggestion from a lurker:

On Sat, 2 Oct 2021 at 14:15, Gabriel Ivăncescu <gabrielopcode at gmail.com> wrote:
>
> Fixes a regression introduced by 1cdc74b2d62d1c94005c46f9c8f4b566aa8bdcbd
> when creating new prefixes, as NtCreateKey does not recursively create keys.
>
> Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
> ---
>  dlls/gdi32/font.c | 20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c
> index 98c70a6..31310b1 100644
> --- a/dlls/gdi32/font.c
> +++ b/dlls/gdi32/font.c
> @@ -6209,19 +6209,31 @@ UINT font_init(void)
>      OBJECT_ATTRIBUTES attr = { sizeof(attr) };
>      UNICODE_STRING name;
>      HANDLE mutex, hkcu;
> +    HKEY key, wine_key;
>      DWORD disposition;
>      UINT dpi = 0;
>
>      static WCHAR wine_font_mutexW[] =
>          {'\\','B','a','s','e','N','a','m','e','d','O','b','j','e','c','t','s',
>           '\\','_','_','W','I','N','E','_','F','O','N','T','_','M','U','T','E','X','_','_'};
> -    static const WCHAR wine_fonts_keyW[] =
> -        {'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\','F','o','n','t','s'};
> +    static const WCHAR softwareW[] = {'S','o','f','t','w','a','r','e'};
> +    static const WCHAR wineW[] = {'W','i','n','e'};
> +    static const WCHAR fontsW[] = {'F','o','n','t','s'};
>      static const WCHAR cacheW[] = {'C','a','c','h','e'};
>
>      if (RtlOpenCurrentUser( MAXIMUM_ALLOWED, &hkcu )) return 0;
> -    wine_fonts_key = reg_create_key( hkcu, wine_fonts_keyW, sizeof(wine_fonts_keyW), 0, NULL );
> -    if (wine_fonts_key) dpi = init_font_options( hkcu );
> +    key = reg_create_key( hkcu, softwareW, sizeof(softwareW), 0, NULL );
> +    if (key)
> +    {
> +        wine_key = reg_create_key( key, wineW, sizeof(wineW), 0, NULL );
> +        NtClose( key );
> +        if (wine_key)
> +        {
> +            wine_fonts_key = reg_create_key( wine_key, fontsW, sizeof(fontsW), 0, NULL );
> +            NtClose( wine_key );
> +            if (wine_fonts_key) dpi = init_font_options( hkcu );
> +        }
> +    }

Instead of manually expanding into a series of reg_create_key() calls,
would it make sense to create a helper that does the recursion?
Sure it might be new microseconds slower, since one will need to
parse/tokenize the string. Yet overall it should be less code and
easier on the eyes ;-)

HTH
-Emil



More information about the wine-devel mailing list