ntdll: Initialize the ShowDotFiles option on the Unix side.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2021-02-25 15:14:41 +01:00
parent 06b729f777
commit 305cb8af27
6 changed files with 54 additions and 56 deletions

View File

@ -40,45 +40,6 @@
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/exception.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.@) * RtlWow64EnableFsRedirection (NTDLL.@)

View File

@ -3999,7 +3999,6 @@ static NTSTATUS process_init(void)
#endif #endif
init_unix_codepage(); init_unix_codepage();
init_directories();
init_user_process_params(); init_user_process_params();
params = peb->ProcessParameters; params = peb->ProcessParameters;

View File

@ -84,8 +84,6 @@ extern const WCHAR syswow64_dir[] DECLSPEC_HIDDEN;
extern void (FASTCALL *pBaseThreadInitThunk)(DWORD,LPTHREAD_START_ROUTINE,void *) DECLSPEC_HIDDEN; extern void (FASTCALL *pBaseThreadInitThunk)(DWORD,LPTHREAD_START_ROUTINE,void *) DECLSPEC_HIDDEN;
extern const struct unix_funcs *unix_funcs 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; extern struct _KUSER_SHARED_DATA *user_shared_data DECLSPEC_HIDDEN;
/* locale */ /* locale */

View File

@ -2726,11 +2726,46 @@ static int get_redirect_path( char *unix_name, int pos, const WCHAR *name, int l
#endif #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 * init_files
*/ */
void init_files(void) void init_files(void)
{ {
HANDLE key;
#ifndef _WIN64 #ifndef _WIN64
if (is_wow64) init_redirects(); if (is_wow64) init_redirects();
#endif #endif
@ -2744,6 +2779,24 @@ void init_files(void)
/* retrieve initial umask */ /* retrieve initial umask */
start_umask = umask( 0777 ); start_umask = umask( 0777 );
umask( start_umask ); 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 * open_unix_file
* *

View File

@ -1718,7 +1718,6 @@ static struct unix_funcs unix_funcs =
get_unix_codepage_data, get_unix_codepage_data,
get_locales, get_locales,
virtual_release_address_space, virtual_release_address_space,
set_show_dot_files,
load_so_dll, load_so_dll,
load_builtin_dll, load_builtin_dll,
unload_builtin_dll, unload_builtin_dll,

View File

@ -26,7 +26,7 @@
struct _DISPATCHER_CONTEXT; struct _DISPATCHER_CONTEXT;
/* increment this when you change the function table */ /* increment this when you change the function table */
#define NTDLL_UNIXLIB_VERSION 112 #define NTDLL_UNIXLIB_VERSION 113
struct unix_funcs struct unix_funcs
{ {
@ -76,9 +76,6 @@ struct unix_funcs
/* virtual memory functions */ /* virtual memory functions */
void (CDECL *virtual_release_address_space)(void); void (CDECL *virtual_release_address_space)(void);
/* file functions */
void (CDECL *set_show_dot_files)( BOOL enable );
/* loader functions */ /* loader functions */
NTSTATUS (CDECL *load_so_dll)( UNICODE_STRING *nt_name, void **module ); NTSTATUS (CDECL *load_so_dll)( UNICODE_STRING *nt_name, void **module );
NTSTATUS (CDECL *load_builtin_dll)( UNICODE_STRING *name, void **module, void **unix_entry, NTSTATUS (CDECL *load_builtin_dll)( UNICODE_STRING *name, void **module, void **unix_entry,