Jacek Caban : winex11: Directly use ntdll for registry access in X11DRV_GetICMProfile.

Alexandre Julliard julliard at winehq.org
Mon Apr 11 15:54:59 CDT 2022


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri Apr  8 13:29:32 2022 +0200

winex11: Directly use ntdll for registry access in X11DRV_GetICMProfile.

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/winex11.drv/graphics.c    | 32 ++++++++++++++++++++------------
 dlls/winex11.drv/x11drv.h      |  1 +
 dlls/winex11.drv/x11drv_main.c |  2 +-
 3 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/dlls/winex11.drv/graphics.c b/dlls/winex11.drv/graphics.c
index b3df3cafcb1..b07234bbc22 100644
--- a/dlls/winex11.drv/graphics.c
+++ b/dlls/winex11.drv/graphics.c
@@ -1629,12 +1629,14 @@ extern void WINAPI A_SHAUpdate( sha_ctx *, const unsigned char *, unsigned int )
 extern void WINAPI A_SHAFinal( sha_ctx *, unsigned char * );
 
 static const WCHAR mntr_key[] =
-    {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
+    {'\\','R','e','g','i','s','t','r','y','\\','M','a','c','h','i','n','e','\\',
+     'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
      'W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t',
-     'V','e','r','s','i','o','n','\\','I','C','M','\\','m','n','t','r',0};
+     'V','e','r','s','i','o','n','\\','I','C','M','\\','m','n','t','r'};
 
 static const WCHAR color_path[] =
-    {'\\','s','p','o','o','l','\\','d','r','i','v','e','r','s','\\','c','o','l','o','r','\\',0};
+    {'c',':','\\','w','i','n','d','o','w','s','\\','s','y','s','t','e','m','3','2',
+     '\\','s','p','o','o','l','\\','d','r','i','v','e','r','s','\\','c','o','l','o','r','\\'};
 
 /***********************************************************************
  *              GetICMProfile (X11DRV.@)
@@ -1645,22 +1647,27 @@ BOOL CDECL X11DRV_GetICMProfile( PHYSDEV dev, BOOL allow_default, LPDWORD size,
         {'s','R','G','B',' ','C','o','l','o','r',' ','S','p','a','c','e',' ',
          'P','r','o','f','i','l','e','.','i','c','m',0};
     HKEY hkey;
-    DWORD required, len;
-    WCHAR profile[MAX_PATH], fullname[2*MAX_PATH + ARRAY_SIZE( color_path )];
+    DWORD required;
+    char buf[4096];
+    KEY_VALUE_FULL_INFORMATION *info = (void *)buf;
     unsigned char *buffer;
     unsigned long buflen;
+    ULONG full_size;
+    WCHAR profile[MAX_PATH], fullname[MAX_PATH + ARRAY_SIZE( color_path )];
 
     if (!size) return FALSE;
 
-    GetSystemDirectoryW( fullname, MAX_PATH );
-    strcatW( fullname, color_path );
+    memcpy( fullname, color_path, sizeof(color_path) );
+    fullname[ARRAYSIZE(color_path)] = 0;
 
-    len = ARRAY_SIZE( profile );
-    if (!RegCreateKeyExW( HKEY_LOCAL_MACHINE, mntr_key, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL ) &&
-        !RegEnumValueW( hkey, 0, profile, &len, NULL, NULL, NULL, NULL )) /* FIXME handle multiple values */
+    hkey = reg_open_key( NULL, mntr_key, sizeof(mntr_key) );
+
+    if (hkey && !NtEnumerateValueKey( hkey, 0, KeyValueFullInformation,
+                                      info, sizeof(buf), &full_size ))
     {
-        strcatW( fullname, profile );
-        RegCloseKey( hkey );
+        /* FIXME handle multiple values */
+        memcpy( fullname + ARRAYSIZE(color_path), info->Name, info->NameLength );
+        fullname[ARRAYSIZE(color_path) + info->NameLength / sizeof(WCHAR)] = 0;
     }
     else if ((buffer = get_icm_profile( &buflen )))
     {
@@ -1694,6 +1701,7 @@ BOOL CDECL X11DRV_GetICMProfile( PHYSDEV dev, BOOL allow_default, LPDWORD size,
     else if (!allow_default) return FALSE;
     else strcatW( fullname, srgb );
 
+    NtClose( hkey );
     required = strlenW( fullname ) + 1;
     if (*size < required)
     {
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index 1168e0ea7a6..9890fc94c22 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -846,6 +846,7 @@ static inline BOOL is_window_rect_mapped( const RECT *rect )
 extern HKEY open_hkcu_key( const char *name ) DECLSPEC_HIDDEN;
 extern ULONG query_reg_value( HKEY hkey, const WCHAR *name,
                               KEY_VALUE_PARTIAL_INFORMATION *info, ULONG size ) DECLSPEC_HIDDEN;
+extern HKEY reg_open_key( HKEY root, const WCHAR *name, ULONG name_len ) DECLSPEC_HIDDEN;
 
 /* string helpers */
 
diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c
index b6fa5cedc61..539f49197a3 100644
--- a/dlls/winex11.drv/x11drv_main.c
+++ b/dlls/winex11.drv/x11drv_main.c
@@ -336,7 +336,7 @@ static void init_pixmap_formats( Display *display )
 }
 
 
-static HKEY reg_open_key( HKEY root, const WCHAR *name, ULONG name_len )
+HKEY reg_open_key( HKEY root, const WCHAR *name, ULONG name_len )
 {
     UNICODE_STRING nameW = { name_len, name_len, (WCHAR *)name };
     OBJECT_ATTRIBUTES attr;




More information about the wine-cvs mailing list