Jacek Caban : gdi32: Avoid using RtlOpenCurrentUser.

Alexandre Julliard julliard at winehq.org
Mon Oct 4 15:42:19 CDT 2021


Module: wine
Branch: master
Commit: 6996627353c9b95ed095c477ca912c525243b0b1
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=6996627353c9b95ed095c477ca912c525243b0b1

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Oct  4 15:03:19 2021 +0100

gdi32: Avoid using RtlOpenCurrentUser.

Based on open_hkcu_key.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/gdi32/font.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c
index 0c08816945a..0b32a94f7fe 100644
--- a/dlls/gdi32/font.c
+++ b/dlls/gdi32/font.c
@@ -6196,6 +6196,28 @@ static void load_registry_fonts(void)
     NtClose( hkey );
 }
 
+static HKEY open_hkcu(void)
+{
+    char buffer[256];
+    WCHAR bufferW[256];
+    DWORD_PTR sid_data[(sizeof(TOKEN_USER) + SECURITY_MAX_SID_SIZE) / sizeof(DWORD_PTR)];
+    DWORD i, len = sizeof(sid_data);
+    SID *sid;
+
+    if (NtQueryInformationToken( GetCurrentThreadEffectiveToken(), TokenUser, sid_data, len, &len ))
+        return 0;
+
+    sid = ((TOKEN_USER *)sid_data)->User.Sid;
+    len = sprintf( buffer, "\\Registry\\User\\S-%u-%u", sid->Revision,
+                 MAKELONG( MAKEWORD( sid->IdentifierAuthority.Value[5], sid->IdentifierAuthority.Value[4] ),
+                           MAKEWORD( sid->IdentifierAuthority.Value[3], sid->IdentifierAuthority.Value[2] )));
+    for (i = 0; i < sid->SubAuthorityCount; i++)
+        len += sprintf( buffer + len, "-%u", sid->SubAuthority[i] );
+    ascii_to_unicode( bufferW, buffer, len + 1 );
+
+    return reg_open_key( NULL, bufferW, len * sizeof(WCHAR) );
+}
+
 /***********************************************************************
  *              font_init
  */
@@ -6214,7 +6236,7 @@ UINT font_init(void)
         {'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\','F','o','n','t','s'};
     static const WCHAR cacheW[] = {'C','a','c','h','e'};
 
-    if (RtlOpenCurrentUser( MAXIMUM_ALLOWED, &hkcu )) return 0;
+    if (!(hkcu = open_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 );
     NtClose( hkcu );




More information about the wine-cvs mailing list