Alexandre Julliard : ntdll: Initialize the ShowDotFiles option on the Unix side.

Alexandre Julliard julliard at winehq.org
Thu Feb 25 16:45:37 CST 2021


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Feb 25 15:14:41 2021 +0100

ntdll: Initialize the ShowDotFiles option on the Unix side.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/directory.c   | 39 ------------------------------
 dlls/ntdll/loader.c      |  1 -
 dlls/ntdll/ntdll_misc.h  |  2 --
 dlls/ntdll/unix/file.c   | 62 +++++++++++++++++++++++++++++++++++++++++-------
 dlls/ntdll/unix/loader.c |  1 -
 dlls/ntdll/unixlib.h     |  5 +---
 6 files changed, 54 insertions(+), 56 deletions(-)

diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index fb2f25d35bc..4125170b509 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -40,45 +40,6 @@
 #include "wine/debug.h"
 #include "wine/exception.h"
 
-#define IS_OPTION_TRUE(ch) ((ch) == 'y' || (ch) == 'Y' || (ch) == 't' || (ch) == 'T' || (ch) == '1')
-
-static BOOL show_dot_files;
-
-/***********************************************************************
- *           init_directories
- */
-void init_directories(void)
-{
-    char tmp[80];
-    HANDLE root, hkey;
-    DWORD dummy;
-    OBJECT_ATTRIBUTES attr;
-    UNICODE_STRING nameW;
-
-    RtlOpenCurrentUser( KEY_ALL_ACCESS, &root );
-    attr.Length = sizeof(attr);
-    attr.RootDirectory = root;
-    attr.ObjectName = &nameW;
-    attr.Attributes = 0;
-    attr.SecurityDescriptor = NULL;
-    attr.SecurityQualityOfService = NULL;
-    RtlInitUnicodeString( &nameW, L"Software\\Wine" );
-
-    /* @@ Wine registry key: HKCU\Software\Wine */
-    if (!NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ))
-    {
-        RtlInitUnicodeString( &nameW, L"ShowDotFiles" );
-        if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
-        {
-            WCHAR *str = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
-            show_dot_files = IS_OPTION_TRUE( str[0] );
-        }
-        NtClose( hkey );
-    }
-    NtClose( root );
-    unix_funcs->set_show_dot_files( show_dot_files );
-}
-
 
 /******************************************************************
  *		RtlWow64EnableFsRedirection   (NTDLL.@)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index e609a0f77d4..8dbbb14f05d 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -3999,7 +3999,6 @@ static NTSTATUS process_init(void)
 #endif
 
     init_unix_codepage();
-    init_directories();
     init_user_process_params();
     params = peb->ProcessParameters;
 
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index 67696f80db3..aebea12e6ba 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -84,8 +84,6 @@ extern const WCHAR syswow64_dir[] DECLSPEC_HIDDEN;
 extern void (FASTCALL *pBaseThreadInitThunk)(DWORD,LPTHREAD_START_ROUTINE,void *) DECLSPEC_HIDDEN;
 extern const struct unix_funcs *unix_funcs DECLSPEC_HIDDEN;
 
-extern void init_directories(void) DECLSPEC_HIDDEN;
-
 extern struct _KUSER_SHARED_DATA *user_shared_data DECLSPEC_HIDDEN;
 
 /* locale */
diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c
index 00ca2005f92..381805c0f04 100644
--- a/dlls/ntdll/unix/file.c
+++ b/dlls/ntdll/unix/file.c
@@ -2726,11 +2726,46 @@ static int get_redirect_path( char *unix_name, int pos, const WCHAR *name, int l
 
 #endif
 
+#define IS_OPTION_TRUE(ch) ((ch) == 'y' || (ch) == 'Y' || (ch) == 't' || (ch) == 'T' || (ch) == '1')
+
+static NTSTATUS open_hkcu_key( const char *path, HANDLE *key )
+{
+    NTSTATUS status;
+    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;
+    UNICODE_STRING name;
+    OBJECT_ATTRIBUTES attr;
+
+    status = NtQueryInformationToken( GetCurrentThreadEffectiveToken(), TokenUser, sid_data, len, &len );
+    if (status) return status;
+
+    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] );
+    len += sprintf( buffer + len, "\\%s", path );
+
+    name.Buffer = bufferW;
+    name.Length = len * sizeof(WCHAR);
+    name.MaximumLength = name.Length + sizeof(WCHAR);
+    ascii_to_unicode( bufferW, buffer, len + 1 );
+    InitializeObjectAttributes( &attr, &name, OBJ_CASE_INSENSITIVE, 0, NULL );
+    return NtCreateKey( key, KEY_ALL_ACCESS, &attr, 0, NULL, 0, NULL );
+}
+
+
 /***********************************************************************
  *           init_files
  */
 void init_files(void)
 {
+    HANDLE key;
+
 #ifndef _WIN64
     if (is_wow64) init_redirects();
 #endif
@@ -2744,6 +2779,24 @@ void init_files(void)
     /* retrieve initial umask */
     start_umask = umask( 0777 );
     umask( start_umask );
+
+    if (!open_hkcu_key( "Software\\Wine", &key ))
+    {
+        static WCHAR showdotfilesW[] = {'S','h','o','w','D','o','t','F','i','l','e','s',0};
+        char tmp[80];
+        DWORD dummy;
+        UNICODE_STRING nameW;
+
+        nameW.MaximumLength = sizeof(showdotfilesW);
+        nameW.Length = nameW.MaximumLength - sizeof(WCHAR);
+        nameW.Buffer = showdotfilesW;
+        if (!NtQueryValueKey( key, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
+        {
+            WCHAR *str = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
+            show_dot_files = IS_OPTION_TRUE( str[0] );
+        }
+        NtClose( key );
+    }
 }
 
 
@@ -3522,15 +3575,6 @@ static NTSTATUS unmount_device( HANDLE handle )
 }
 
 
-/***********************************************************************
- *           set_show_dot_files
- */
-void CDECL set_show_dot_files( BOOL enable )
-{
-    show_dot_files = enable;
-}
-
-
 /******************************************************************************
  *              open_unix_file
  *
diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c
index d03034f35fc..df8d99ce489 100644
--- a/dlls/ntdll/unix/loader.c
+++ b/dlls/ntdll/unix/loader.c
@@ -1718,7 +1718,6 @@ static struct unix_funcs unix_funcs =
     get_unix_codepage_data,
     get_locales,
     virtual_release_address_space,
-    set_show_dot_files,
     load_so_dll,
     load_builtin_dll,
     unload_builtin_dll,
diff --git a/dlls/ntdll/unixlib.h b/dlls/ntdll/unixlib.h
index c317784a3ea..bd2512030c2 100644
--- a/dlls/ntdll/unixlib.h
+++ b/dlls/ntdll/unixlib.h
@@ -26,7 +26,7 @@
 struct _DISPATCHER_CONTEXT;
 
 /* increment this when you change the function table */
-#define NTDLL_UNIXLIB_VERSION 112
+#define NTDLL_UNIXLIB_VERSION 113
 
 struct unix_funcs
 {
@@ -76,9 +76,6 @@ struct unix_funcs
     /* virtual memory functions */
     void          (CDECL *virtual_release_address_space)(void);
 
-    /* file functions */
-    void          (CDECL *set_show_dot_files)( BOOL enable );
-
     /* loader functions */
     NTSTATUS      (CDECL *load_so_dll)( UNICODE_STRING *nt_name, void **module );
     NTSTATUS      (CDECL *load_builtin_dll)( UNICODE_STRING *name, void **module, void **unix_entry,




More information about the wine-cvs mailing list