Commit e0deb0c6 authored by Alexandre Julliard's avatar Alexandre Julliard

Replaced remaining calls to PROFILE_GetWineIniString/Bool by direct

registry accesses.
parent 7c3ab331
...@@ -40,14 +40,9 @@ ...@@ -40,14 +40,9 @@
#include "wine/exception.h" #include "wine/exception.h"
#include "excpt.h" #include "excpt.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "file.h"
WINE_DEFAULT_DEBUG_CHANNEL(computername); WINE_DEFAULT_DEBUG_CHANNEL(computername);
/* Wine config options */
static const WCHAR NetworkW[] = {'N','e','t','w','o','r','k',0};
static const WCHAR UseDNSW[] = {'U','s','e','D','n','s','C','o','m','p','u','t','e','r','N','a','m','e',0};
/* Registry key and value names */ /* Registry key and value names */
static const WCHAR ComputerW[] = {'M','a','c','h','i','n','e','\\', static const WCHAR ComputerW[] = {'M','a','c','h','i','n','e','\\',
'S','y','s','t','e','m','\\', 'S','y','s','t','e','m','\\',
...@@ -59,6 +54,8 @@ static const WCHAR ComputerNameW[] = {'C','o','m','p','u','t','e','r','N','a','m ...@@ -59,6 +54,8 @@ static const WCHAR ComputerNameW[] = {'C','o','m','p','u','t','e','r','N','a','m
static const char default_ComputerName[] = "WINE"; static const char default_ComputerName[] = "WINE";
#define IS_OPTION_TRUE(ch) ((ch) == 'y' || (ch) == 'Y' || (ch) == 't' || (ch) == 'T' || (ch) == '1')
/* filter for page-fault exceptions */ /* filter for page-fault exceptions */
static WINE_EXCEPTION_FILTER(page_fault) static WINE_EXCEPTION_FILTER(page_fault)
{ {
...@@ -189,6 +186,41 @@ inline static void _init_attr ( OBJECT_ATTRIBUTES *attr, UNICODE_STRING *name ) ...@@ -189,6 +186,41 @@ inline static void _init_attr ( OBJECT_ATTRIBUTES *attr, UNICODE_STRING *name )
attr->SecurityQualityOfService = NULL; attr->SecurityQualityOfService = NULL;
} }
/***********************************************************************
* get_use_dns_option
*/
static BOOL get_use_dns_option(void)
{
static const WCHAR NetworkW[] = {'M','a','c','h','i','n','e','\\',
'S','o','f','t','w','a','r','e','\\',
'W','i','n','e','\\','W','i','n','e','\\',
'C','o','n','f','i','g','\\','N','e','t','w','o','r','k',0};
static const WCHAR UseDNSW[] = {'U','s','e','D','n','s','C','o','m','p','u','t','e','r','N','a','m','e',0};
char tmp[80];
HKEY hkey;
DWORD dummy;
OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW;
BOOL ret = TRUE;
_init_attr( &attr, &nameW );
RtlInitUnicodeString( &nameW, NetworkW );
if (!NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ))
{
RtlInitUnicodeString( &nameW, UseDNSW );
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
{
WCHAR *str = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
ret = IS_OPTION_TRUE( str[0] );
}
NtClose( hkey );
}
return ret;
}
/*********************************************************************** /***********************************************************************
* COMPUTERNAME_Init (INTERNAL) * COMPUTERNAME_Init (INTERNAL)
*/ */
...@@ -216,8 +248,7 @@ void COMPUTERNAME_Init (void) ...@@ -216,8 +248,7 @@ void COMPUTERNAME_Init (void)
st = NtQueryValueKey( hsubkey, &nameW, KeyValuePartialInformation, buf, len, &len ); st = NtQueryValueKey( hsubkey, &nameW, KeyValuePartialInformation, buf, len, &len );
if ( st == STATUS_OBJECT_NAME_NOT_FOUND || if ( st == STATUS_OBJECT_NAME_NOT_FOUND || ( st == STATUS_SUCCESS && get_use_dns_option()))
( st == STATUS_SUCCESS && PROFILE_GetWineIniBool( NetworkW, UseDNSW, 1 ) ) )
{ {
char hbuf[256]; char hbuf[256];
int hlen = sizeof (hbuf); int hlen = sizeof (hbuf);
...@@ -539,7 +570,7 @@ BOOL WINAPI SetComputerNameW( LPCWSTR lpComputerName ) ...@@ -539,7 +570,7 @@ BOOL WINAPI SetComputerNameW( LPCWSTR lpComputerName )
int i; int i;
NTSTATUS st = STATUS_INTERNAL_ERROR; NTSTATUS st = STATUS_INTERNAL_ERROR;
if ( PROFILE_GetWineIniBool ( NetworkW, UseDNSW, 1 ) ) if (get_use_dns_option())
{ {
/* This check isn't necessary, but may help debugging problems. */ /* This check isn't necessary, but may help debugging problems. */
WARN( "Disabled by Wine Configuration.\n" ); WARN( "Disabled by Wine Configuration.\n" );
......
...@@ -51,7 +51,7 @@ WINE REGISTRY Version 2 ...@@ -51,7 +51,7 @@ WINE REGISTRY Version 2
"Filesystem" = "win95" "Filesystem" = "win95"
[Drive F] [Drive F]
"Path" = "${HOME}" "Path" = "%HOME%"
"Type" = "network" "Type" = "network"
"Label" = "Home" "Label" = "Home"
"Filesystem" = "win95" "Filesystem" = "win95"
......
...@@ -69,14 +69,19 @@ inline static int FILE_contains_pathW (LPCWSTR name) ...@@ -69,14 +69,19 @@ inline static int FILE_contains_pathW (LPCWSTR name)
* *
* Get a path name from the wine.ini file and make sure it is valid. * Get a path name from the wine.ini file and make sure it is valid.
*/ */
static int DIR_GetPath( LPCWSTR keyname, LPCWSTR defval, DOS_FULL_NAME *full_name, static int DIR_GetPath( HKEY hkey, LPCWSTR keyname, LPCWSTR defval, DOS_FULL_NAME *full_name,
LPWSTR longname, INT longname_len, BOOL warn ) LPWSTR longname, INT longname_len, BOOL warn )
{ {
WCHAR path[MAX_PATHNAME_LEN]; UNICODE_STRING nameW;
DWORD dummy;
WCHAR tmp[MAX_PATHNAME_LEN];
BY_HANDLE_FILE_INFORMATION info; BY_HANDLE_FILE_INFORMATION info;
const WCHAR *path = defval;
const char *mess = "does not exist"; const char *mess = "does not exist";
PROFILE_GetWineIniString( wineW, keyname, defval, path, MAX_PATHNAME_LEN ); RtlInitUnicodeString( &nameW, keyname );
if (hkey && !NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
path = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
if (!DOSFS_GetFullName( path, TRUE, full_name ) || if (!DOSFS_GetFullName( path, TRUE, full_name ) ||
(!FILE_Stat( full_name->long_name, &info, NULL ) && (mess=strerror(errno)))|| (!FILE_Stat( full_name->long_name, &info, NULL ) && (mess=strerror(errno)))||
...@@ -97,11 +102,18 @@ static int DIR_GetPath( LPCWSTR keyname, LPCWSTR defval, DOS_FULL_NAME *full_nam ...@@ -97,11 +102,18 @@ static int DIR_GetPath( LPCWSTR keyname, LPCWSTR defval, DOS_FULL_NAME *full_nam
*/ */
int DIR_Init(void) int DIR_Init(void)
{ {
OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW;
HKEY hkey;
char path[MAX_PATHNAME_LEN]; char path[MAX_PATHNAME_LEN];
WCHAR longpath[MAX_PATHNAME_LEN]; WCHAR longpath[MAX_PATHNAME_LEN];
DOS_FULL_NAME tmp_dir, profile_dir; DOS_FULL_NAME tmp_dir, profile_dir;
int drive; int drive;
const char *cwd; const char *cwd;
static const WCHAR wineW[] = {'M','a','c','h','i','n','e','\\',
'S','o','f','t','w','a','r','e','\\',
'W','i','n','e','\\','W','i','n','e','\\',
'C','o','n','f','i','g','\\','W','i','n','e',0};
static const WCHAR windowsW[] = {'w','i','n','d','o','w','s',0}; static const WCHAR windowsW[] = {'w','i','n','d','o','w','s',0};
static const WCHAR systemW[] = {'s','y','s','t','e','m',0}; static const WCHAR systemW[] = {'s','y','s','t','e','m',0};
static const WCHAR tempW[] = {'t','e','m','p',0}; static const WCHAR tempW[] = {'t','e','m','p',0};
...@@ -144,11 +156,22 @@ int DIR_Init(void) ...@@ -144,11 +156,22 @@ int DIR_Init(void)
chdir("/"); /* change to root directory so as not to lock cdroms */ chdir("/"); /* change to root directory so as not to lock cdroms */
} }
if (!(DIR_GetPath( windowsW, windows_dirW, &DIR_Windows, longpath, MAX_PATHNAME_LEN, TRUE )) || attr.Length = sizeof(attr);
!(DIR_GetPath( systemW, system_dirW, &DIR_System, longpath, MAX_PATHNAME_LEN, TRUE )) || attr.RootDirectory = 0;
!(DIR_GetPath( tempW, windows_dirW, &tmp_dir, longpath, MAX_PATHNAME_LEN, TRUE ))) attr.ObjectName = &nameW;
attr.Attributes = 0;
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
RtlInitUnicodeString( &nameW, wineW );
if (NtCreateKey( &hkey, KEY_ALL_ACCESS, &attr, 0, NULL, 0, NULL )) hkey = 0;
if (!(DIR_GetPath( hkey, windowsW, windows_dirW, &DIR_Windows, longpath, MAX_PATHNAME_LEN, TRUE )) ||
!(DIR_GetPath( hkey, systemW, system_dirW, &DIR_System, longpath, MAX_PATHNAME_LEN, TRUE )) ||
!(DIR_GetPath( hkey, tempW, windows_dirW, &tmp_dir, longpath, MAX_PATHNAME_LEN, TRUE )))
{ {
PROFILE_UsageWineIni(); PROFILE_UsageWineIni();
if (hkey) NtClose( hkey );
return 0; return 0;
} }
if (-1 == access( tmp_dir.long_name, W_OK )) if (-1 == access( tmp_dir.long_name, W_OK ))
...@@ -181,16 +204,27 @@ int DIR_Init(void) ...@@ -181,16 +204,27 @@ int DIR_Init(void)
} }
/* set PATH only if not set already */ /* set PATH only if not set already */
if (!GetEnvironmentVariableW( path_capsW, longpath, MAX_PATHNAME_LEN )) if (!GetEnvironmentVariableW( path_capsW, NULL, 0 ))
{ {
PROFILE_GetWineIniString(wineW, pathW, path_dirW, longpath, MAX_PATHNAME_LEN); WCHAR tmp[MAX_PATHNAME_LEN];
if (strchrW(longpath, '/')) DWORD dummy;
const WCHAR *path = path_dirW;
RtlInitUnicodeString( &nameW, pathW );
if (hkey && !NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation,
tmp, sizeof(tmp), &dummy ))
{
path = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
}
if (strchrW(path, '/'))
{ {
MESSAGE("Fix your wine config to use DOS drive syntax in [wine] 'Path=' statement! (no '/' allowed)\n"); MESSAGE("Fix your wine config to use DOS drive syntax in [wine] 'Path=' statement! (no '/' allowed)\n");
PROFILE_UsageWineIni(); PROFILE_UsageWineIni();
ExitProcess(1); ExitProcess(1);
} }
SetEnvironmentVariableW( path_capsW, longpath ); SetEnvironmentVariableW( path_capsW, path );
TRACE("Path = %s\n", debugstr_w(path) );
} }
SetEnvironmentVariableW( temp_capsW, tmp_dir.short_name ); SetEnvironmentVariableW( temp_capsW, tmp_dir.short_name );
...@@ -204,11 +238,10 @@ int DIR_Init(void) ...@@ -204,11 +238,10 @@ int DIR_Init(void)
debugstr_w(DIR_System.short_name), DIR_System.long_name ); debugstr_w(DIR_System.short_name), DIR_System.long_name );
TRACE("TempDir = %s (%s)\n", TRACE("TempDir = %s (%s)\n",
debugstr_w(tmp_dir.short_name), tmp_dir.long_name ); debugstr_w(tmp_dir.short_name), tmp_dir.long_name );
TRACE("Path = %s\n", debugstr_w(longpath) );
TRACE("Cwd = %c:\\%s\n", TRACE("Cwd = %c:\\%s\n",
'A' + drive, debugstr_w(DRIVE_GetDosCwd(drive)) ); 'A' + drive, debugstr_w(DRIVE_GetDosCwd(drive)) );
if (DIR_GetPath( profileW, empty_strW, &profile_dir, longpath, MAX_PATHNAME_LEN, FALSE )) if (DIR_GetPath( hkey, profileW, empty_strW, &profile_dir, longpath, MAX_PATHNAME_LEN, FALSE ))
{ {
TRACE("USERPROFILE= %s\n", debugstr_w(longpath) ); TRACE("USERPROFILE= %s\n", debugstr_w(longpath) );
SetEnvironmentVariableW( userprofileW, longpath ); SetEnvironmentVariableW( userprofileW, longpath );
...@@ -216,6 +249,7 @@ int DIR_Init(void) ...@@ -216,6 +249,7 @@ int DIR_Init(void)
TRACE("SYSTEMROOT = %s\n", debugstr_w(DIR_Windows.short_name) ); TRACE("SYSTEMROOT = %s\n", debugstr_w(DIR_Windows.short_name) );
SetEnvironmentVariableW( systemrootW, DIR_Windows.short_name ); SetEnvironmentVariableW( systemrootW, DIR_Windows.short_name );
if (hkey) NtClose( hkey );
return 1; return 1;
} }
......
...@@ -84,6 +84,8 @@ typedef struct ...@@ -84,6 +84,8 @@ typedef struct
#undef VFAT_IOCTL_READDIR_BOTH /* just in case... */ #undef VFAT_IOCTL_READDIR_BOTH /* just in case... */
#endif /* linux */ #endif /* linux */
#define IS_OPTION_TRUE(ch) ((ch) == 'y' || (ch) == 'Y' || (ch) == 't' || (ch) == 'T' || (ch) == '1')
/* Chars we don't want to see in DOS file names */ /* Chars we don't want to see in DOS file names */
#define INVALID_DOS_CHARS "*?<>|\"+=,;[] \345" #define INVALID_DOS_CHARS "*?<>|\"+=,;[] \345"
...@@ -854,17 +856,41 @@ const DOS_DEVICE *DOSFS_GetDeviceByHandle( HANDLE hFile ) ...@@ -854,17 +856,41 @@ const DOS_DEVICE *DOSFS_GetDeviceByHandle( HANDLE hFile )
static HANDLE DOSFS_CreateCommPort(LPCWSTR name, DWORD access, DWORD attributes, LPSECURITY_ATTRIBUTES sa) static HANDLE DOSFS_CreateCommPort(LPCWSTR name, DWORD access, DWORD attributes, LPSECURITY_ATTRIBUTES sa)
{ {
HANDLE ret; HANDLE ret;
HKEY hkey;
DWORD dummy;
OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW;
WCHAR *devnameW;
char tmp[128];
char devname[40]; char devname[40];
WCHAR devnameW[40];
static const WCHAR serialportsW[] = {'s','e','r','i','a','l','p','o','r','t','s',0}; static const WCHAR serialportsW[] = {'M','a','c','h','i','n','e','\\',
static const WCHAR empty_strW[] = { 0 }; 'S','o','f','t','w','a','r','e','\\',
'W','i','n','e','\\','W','i','n','e','\\',
'C','o','n','f','i','g','\\',
'S','e','r','i','a','l','P','o','r','t','s',0};
TRACE_(file)("%s %lx %lx\n", debugstr_w(name), access, attributes); TRACE_(file)("%s %lx %lx\n", debugstr_w(name), access, attributes);
PROFILE_GetWineIniString(serialportsW, name, empty_strW, devnameW, 40); attr.Length = sizeof(attr);
if(!devnameW[0]) attr.RootDirectory = 0;
return 0; attr.ObjectName = &nameW;
attr.Attributes = 0;
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
RtlInitUnicodeString( &nameW, serialportsW );
if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr )) return 0;
RtlInitUnicodeString( &nameW, name );
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
devnameW = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
else
devnameW = NULL;
NtClose( hkey );
if (!devnameW) return 0;
WideCharToMultiByte(CP_ACP, 0, devnameW, -1, devname, sizeof(devname), NULL, NULL); WideCharToMultiByte(CP_ACP, 0, devnameW, -1, devname, sizeof(devname), NULL, NULL);
TRACE("opening %s as %s\n", devname, debugstr_w(name)); TRACE("opening %s as %s\n", devname, debugstr_w(name));
...@@ -1693,6 +1719,46 @@ BOOL WINAPI wine_get_unix_file_name( LPCSTR dos, LPSTR buffer, DWORD len ) ...@@ -1693,6 +1719,46 @@ BOOL WINAPI wine_get_unix_file_name( LPCSTR dos, LPSTR buffer, DWORD len )
/*********************************************************************** /***********************************************************************
* get_show_dir_symlinks_option
*/
static BOOL get_show_dir_symlinks_option(void)
{
static const WCHAR WineW[] = {'M','a','c','h','i','n','e','\\',
'S','o','f','t','w','a','r','e','\\',
'W','i','n','e','\\','W','i','n','e','\\',
'C','o','n','f','i','g','\\','W','i','n','e',0};
static const WCHAR ShowDirSymlinksW[] = {'S','h','o','w','D','i','r','S','y','m','l','i','n','k','s',0};
char tmp[80];
HKEY hkey;
DWORD dummy;
OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW;
BOOL ret = FALSE;
attr.Length = sizeof(attr);
attr.RootDirectory = 0;
attr.ObjectName = &nameW;
attr.Attributes = 0;
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
RtlInitUnicodeString( &nameW, WineW );
if (!NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ))
{
RtlInitUnicodeString( &nameW, ShowDirSymlinksW );
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
{
WCHAR *str = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
ret = IS_OPTION_TRUE( str[0] );
}
NtClose( hkey );
}
return ret;
}
/***********************************************************************
* DOSFS_FindNextEx * DOSFS_FindNextEx
*/ */
static int DOSFS_FindNextEx( FIND_FIRST_INFO *info, WIN32_FIND_DATAW *entry ) static int DOSFS_FindNextEx( FIND_FIRST_INFO *info, WIN32_FIND_DATAW *entry )
...@@ -1774,11 +1840,9 @@ static int DOSFS_FindNextEx( FIND_FIRST_INFO *info, WIN32_FIND_DATAW *entry ) ...@@ -1774,11 +1840,9 @@ static int DOSFS_FindNextEx( FIND_FIRST_INFO *info, WIN32_FIND_DATAW *entry )
} }
if (is_symlink && (fileinfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) if (is_symlink && (fileinfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{ {
static const WCHAR wineW[] = {'w','i','n','e',0};
static const WCHAR ShowDirSymlinksW[] = {'S','h','o','w','D','i','r','S','y','m','l','i','n','k','s',0};
static int show_dir_symlinks = -1; static int show_dir_symlinks = -1;
if (show_dir_symlinks == -1) if (show_dir_symlinks == -1)
show_dir_symlinks = PROFILE_GetWineIniBool(wineW, ShowDirSymlinksW, 0); show_dir_symlinks = get_show_dir_symlinks_option();
if (!show_dir_symlinks) continue; if (!show_dir_symlinks) continue;
} }
......
...@@ -81,6 +81,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(file); ...@@ -81,6 +81,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(file);
#define MAP_ANON MAP_ANONYMOUS #define MAP_ANON MAP_ANONYMOUS
#endif #endif
#define IS_OPTION_TRUE(ch) ((ch) == 'y' || (ch) == 'Y' || (ch) == 't' || (ch) == 'T' || (ch) == '1')
HANDLE dos_handles[DOS_TABLE_SIZE]; HANDLE dos_handles[DOS_TABLE_SIZE];
mode_t FILE_umask; mode_t FILE_umask;
...@@ -707,6 +709,46 @@ static void FILE_FillInfo( struct stat *st, BY_HANDLE_FILE_INFORMATION *info ) ...@@ -707,6 +709,46 @@ static void FILE_FillInfo( struct stat *st, BY_HANDLE_FILE_INFORMATION *info )
/*********************************************************************** /***********************************************************************
* get_show_dot_files_option
*/
static BOOL get_show_dot_files_option(void)
{
static const WCHAR WineW[] = {'M','a','c','h','i','n','e','\\',
'S','o','f','t','w','a','r','e','\\',
'W','i','n','e','\\','W','i','n','e','\\',
'C','o','n','f','i','g','\\','W','i','n','e',0};
static const WCHAR ShowDotFilesW[] = {'S','h','o','w','D','o','t','F','i','l','e','s',0};
char tmp[80];
HKEY hkey;
DWORD dummy;
OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW;
BOOL ret = FALSE;
attr.Length = sizeof(attr);
attr.RootDirectory = 0;
attr.ObjectName = &nameW;
attr.Attributes = 0;
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
RtlInitUnicodeString( &nameW, WineW );
if (!NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ))
{
RtlInitUnicodeString( &nameW, ShowDotFilesW );
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
{
WCHAR *str = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
ret = IS_OPTION_TRUE( str[0] );
}
NtClose( hkey );
}
return ret;
}
/***********************************************************************
* FILE_Stat * FILE_Stat
* *
* Stat a Unix path name. Return TRUE if OK. * Stat a Unix path name. Return TRUE if OK.
...@@ -742,11 +784,9 @@ BOOL FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info, BOOL *is_syml ...@@ -742,11 +784,9 @@ BOOL FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info, BOOL *is_syml
p = p ? p + 1 : unixName; p = p ? p + 1 : unixName;
if (*p == '.' && *(p+1) && (*(p+1) != '.' || *(p+2))) if (*p == '.' && *(p+1) && (*(p+1) != '.' || *(p+2)))
{ {
static const WCHAR wineW[] = {'w','i','n','e',0};
static const WCHAR ShowDotFilesW[] = {'S','h','o','w','D','o','t','F','i','l','e','s',0};
static int show_dot_files = -1; static int show_dot_files = -1;
if (show_dot_files == -1) if (show_dot_files == -1)
show_dot_files = PROFILE_GetWineIniBool(wineW, ShowDotFilesW, 0); show_dot_files = get_show_dot_files_option();
if (!show_dot_files) if (!show_dot_files)
info->dwFileAttributes |= FILE_ATTRIBUTE_HIDDEN; info->dwFileAttributes |= FILE_ATTRIBUTE_HIDDEN;
} }
......
...@@ -905,133 +905,6 @@ static BOOL PROFILE_SetString( LPCWSTR section_name, LPCWSTR key_name, ...@@ -905,133 +905,6 @@ static BOOL PROFILE_SetString( LPCWSTR section_name, LPCWSTR key_name,
/*********************************************************************** /***********************************************************************
* get_profile_key
*/
static HKEY get_profile_key(void)
{
static HKEY profile_key;
if (!profile_key)
{
OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW;
HKEY hkey;
attr.Length = sizeof(attr);
attr.RootDirectory = 0;
attr.ObjectName = &nameW;
attr.Attributes = 0;
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
if (!RtlCreateUnicodeStringFromAsciiz( &nameW, "Machine\\Software\\Wine\\Wine\\Config" ) ||
NtCreateKey( &hkey, KEY_ALL_ACCESS, &attr, 0, NULL, REG_OPTION_VOLATILE, NULL ))
{
ERR("Cannot create config registry key\n" );
ExitProcess( 1 );
}
RtlFreeUnicodeString( &nameW );
if (InterlockedCompareExchangePointer( (void **)&profile_key, hkey, 0 ))
NtClose( hkey ); /* somebody beat us to it */
}
return profile_key;
}
/***********************************************************************
* PROFILE_GetWineIniString
*
* Get a config string from the wine.ini file.
*/
int PROFILE_GetWineIniString( LPCWSTR section, LPCWSTR key_name,
LPCWSTR def, LPWSTR buffer, int len )
{
HKEY hkey;
NTSTATUS err;
OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW;
attr.Length = sizeof(attr);
attr.RootDirectory = get_profile_key();
attr.ObjectName = &nameW;
attr.Attributes = 0;
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
RtlInitUnicodeString( &nameW, section );
if (!(err = NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr )))
{
char tmp[PROFILE_MAX_LINE_LEN*sizeof(WCHAR) + sizeof(KEY_VALUE_PARTIAL_INFORMATION)];
DWORD count;
RtlInitUnicodeString( &nameW, key_name );
if (!(err = NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation,
tmp, sizeof(tmp), &count )))
{
WCHAR *str = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
PROFILE_CopyEntry( buffer, str, len, TRUE, TRUE );
}
NtClose( hkey );
}
if (err) PROFILE_CopyEntry( buffer, def, len, TRUE, TRUE );
TRACE( "(%s,%s,%s): returning %s\n", debugstr_w(section),
debugstr_w(key_name), debugstr_w(def), debugstr_w(buffer) );
return strlenW(buffer);
}
/******************************************************************************
*
* PROFILE_GetWineIniBool
*
* Reads a boolean value from the wine.ini file. This function attempts to
* be user-friendly by accepting 'n', 'N' (no), 'f', 'F' (false), or '0'
* (zero) for false, 'y', 'Y' (yes), 't', 'T' (true), or '1' (one) for
* true. Anything else results in the return of the default value.
*
* This function uses 1 to indicate true, and 0 for false. You can check
* for existence by setting def to something other than 0 or 1 and
* examining the return value.
*/
int PROFILE_GetWineIniBool( LPCWSTR section, LPCWSTR key_name, int def )
{
static const WCHAR def_valueW[] = {'~',0};
WCHAR key_value[2];
int retval;
PROFILE_GetWineIniString(section, key_name, def_valueW, key_value, 2);
switch(key_value[0]) {
case 'n':
case 'N':
case 'f':
case 'F':
case '0':
retval = 0;
break;
case 'y':
case 'Y':
case 't':
case 'T':
case '1':
retval = 1;
break;
default:
retval = def;
}
TRACE("(%s, %s, %s), [%c], ret %s\n", debugstr_w(section), debugstr_w(key_name),
def ? "TRUE" : "FALSE", key_value[0],
retval ? "TRUE" : "FALSE");
return retval;
}
/***********************************************************************
* PROFILE_UsageWineIni * PROFILE_UsageWineIni
* *
* Explain the wine.ini file to those who don't read documentation. * Explain the wine.ini file to those who don't read documentation.
......
...@@ -111,9 +111,6 @@ extern int DOSFS_FindNext( const char *path, const char *short_mask, ...@@ -111,9 +111,6 @@ extern int DOSFS_FindNext( const char *path, const char *short_mask,
/* profile.c */ /* profile.c */
extern void PROFILE_UsageWineIni(void); extern void PROFILE_UsageWineIni(void);
extern int PROFILE_GetWineIniString( LPCWSTR section, LPCWSTR key_name,
LPCWSTR def, LPWSTR buffer, int len );
extern int PROFILE_GetWineIniBool( LPCWSTR section, LPCWSTR key_name, int def );
/* win32/device.c */ /* win32/device.c */
extern HANDLE DEVICE_Open( LPCWSTR filename, DWORD access, LPSECURITY_ATTRIBUTES sa ); extern HANDLE DEVICE_Open( LPCWSTR filename, DWORD access, LPSECURITY_ATTRIBUTES sa );
......
...@@ -1406,11 +1406,15 @@ static void _load_windows_registry( HKEY hkey_local_machine, HKEY hkey_current_u ...@@ -1406,11 +1406,15 @@ static void _load_windows_registry( HKEY hkey_local_machine, HKEY hkey_current_u
WCHAR path[MAX_PATHNAME_LEN]; WCHAR path[MAX_PATHNAME_LEN];
OBJECT_ATTRIBUTES attr; OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW; UNICODE_STRING nameW;
HKEY hkey; HKEY hkey, profile_key;
char tmp[1024];
DWORD dummy;
static const WCHAR WineW[] = {'W','i','n','e',0}; static const WCHAR WineW[] = {'M','a','c','h','i','n','e','\\',
'S','o','f','t','w','a','r','e','\\',
'W','i','n','e','\\','W','i','n','e','\\',
'C','o','n','f','i','g','\\','W','i','n','e',0};
static const WCHAR ProfileW[] = {'P','r','o','f','i','l','e',0}; static const WCHAR ProfileW[] = {'P','r','o','f','i','l','e',0};
static const WCHAR empty_strW[] = { 0 };
static const WCHAR System[] = {'M','a','c','h','i','n','e','\\','S','y','s','t','e','m',0}; static const WCHAR System[] = {'M','a','c','h','i','n','e','\\','S','y','s','t','e','m',0};
static const WCHAR Software[] = {'M','a','c','h','i','n','e','\\','S','o','f','t','w','a','r','e',0}; static const WCHAR Software[] = {'M','a','c','h','i','n','e','\\','S','o','f','t','w','a','r','e',0};
static const WCHAR Clone[] = {'M','a','c','h','i','n','e','\\', static const WCHAR Clone[] = {'M','a','c','h','i','n','e','\\',
...@@ -1424,12 +1428,14 @@ static void _load_windows_registry( HKEY hkey_local_machine, HKEY hkey_current_u ...@@ -1424,12 +1428,14 @@ static void _load_windows_registry( HKEY hkey_local_machine, HKEY hkey_current_u
attr.SecurityDescriptor = NULL; attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL; attr.SecurityQualityOfService = NULL;
RtlInitUnicodeString( &nameW, WineW );
if (NtCreateKey( &profile_key, KEY_ALL_ACCESS, &attr, 0, NULL, 0, NULL )) profile_key = 0;
GetWindowsDirectoryW(windir, MAX_PATHNAME_LEN); GetWindowsDirectoryW(windir, MAX_PATHNAME_LEN);
reg_type = _get_reg_type(); reg_type = _get_reg_type();
switch (reg_type) { switch (reg_type) {
case REG_WINNT: { case REG_WINNT: {
HKEY hkey;
static const WCHAR ntuser_datW[] = {'\\','n','t','u','s','e','r','.','d','a','t',0}; static const WCHAR ntuser_datW[] = {'\\','n','t','u','s','e','r','.','d','a','t',0};
static const WCHAR defaultW[] = {'\\','s','y','s','t','e','m','3','2','\\','c','o','n','f','i','g','\\','d','e','f','a','u','l','t',0}; static const WCHAR defaultW[] = {'\\','s','y','s','t','e','m','3','2','\\','c','o','n','f','i','g','\\','d','e','f','a','u','l','t',0};
static const WCHAR systemW[] = {'\\','s','y','s','t','e','m','3','2','\\','c','o','n','f','i','g','\\','s','y','s','t','e','m',0}; static const WCHAR systemW[] = {'\\','s','y','s','t','e','m','3','2','\\','c','o','n','f','i','g','\\','s','y','s','t','e','m',0};
...@@ -1438,7 +1444,11 @@ static void _load_windows_registry( HKEY hkey_local_machine, HKEY hkey_current_u ...@@ -1438,7 +1444,11 @@ static void _load_windows_registry( HKEY hkey_local_machine, HKEY hkey_current_u
static const WCHAR securityW[] = {'\\','s','y','s','t','e','m','3','2','\\','c','o','n','f','i','g','\\','s','e','c','u','r','i','t','y',0}; static const WCHAR securityW[] = {'\\','s','y','s','t','e','m','3','2','\\','c','o','n','f','i','g','\\','s','e','c','u','r','i','t','y',0};
/* user specific ntuser.dat */ /* user specific ntuser.dat */
if (PROFILE_GetWineIniString( WineW, ProfileW, empty_strW, path, MAX_PATHNAME_LEN )) { RtlInitUnicodeString( &nameW, ProfileW );
if (profile_key && !NtQueryValueKey( profile_key, &nameW, KeyValuePartialInformation,
tmp, sizeof(tmp), &dummy ))
{
strcpyW(path, (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data);
strcatW(path, ntuser_datW); strcatW(path, ntuser_datW);
_convert_and_load_native_registry(path,hkey_current_user,REG_WINNT,1); _convert_and_load_native_registry(path,hkey_current_user,REG_WINNT,1);
} }
...@@ -1514,9 +1524,13 @@ static void _load_windows_registry( HKEY hkey_local_machine, HKEY hkey_current_u ...@@ -1514,9 +1524,13 @@ static void _load_windows_registry( HKEY hkey_local_machine, HKEY hkey_current_u
NtClose( hkey ); NtClose( hkey );
} }
if (PROFILE_GetWineIniString(WineW, ProfileW, empty_strW, path, MAX_PATHNAME_LEN)) { RtlInitUnicodeString( &nameW, ProfileW );
/* user specific user.dat */ if (profile_key && !NtQueryValueKey( profile_key, &nameW, KeyValuePartialInformation,
strcatW(path, user_datW); tmp, sizeof(tmp), &dummy ))
{
/* user specific user.dat */
strcpyW(path, (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data);
strcatW(path, user_datW);
_convert_and_load_native_registry(path,hkey_current_user,REG_WIN95,1); _convert_and_load_native_registry(path,hkey_current_user,REG_WIN95,1);
/* default user.dat */ /* default user.dat */
...@@ -1547,6 +1561,7 @@ static void _load_windows_registry( HKEY hkey_local_machine, HKEY hkey_current_u ...@@ -1547,6 +1561,7 @@ static void _load_windows_registry( HKEY hkey_local_machine, HKEY hkey_current_u
break; break;
} }
if (profile_key) NtClose( profile_key );
} }
/* load home registry files (stored in ~/.wine) [Internal] */ /* load home registry files (stored in ~/.wine) [Internal] */
......
...@@ -38,9 +38,10 @@ ...@@ -38,9 +38,10 @@
#endif #endif
#include "windef.h" #include "windef.h"
#include "winnls.h" #include "winnls.h"
#include "winternl.h"
#include "callback.h" #include "callback.h"
#include "file.h"
#include "miscemu.h" #include "miscemu.h"
#include "wine/unicode.h"
#include "wine/debug.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(int); WINE_DEFAULT_DEBUG_CHANNEL(int);
...@@ -162,54 +163,54 @@ static void set_IO_permissions(int val1, int val, char rw) ...@@ -162,54 +163,54 @@ static void set_IO_permissions(int val1, int val, char rw)
* Helper function for IO_port_init * Helper function for IO_port_init
*/ */
static void do_IO_port_init_read_or_write(char* temp, char rw) static void do_IO_port_init_read_or_write(const WCHAR *str, char rw)
{ {
int val, val1, i, len; int val, val1, i;
if (!strcasecmp(temp, "all")) { WCHAR *end;
MESSAGE("Warning!!! Granting FULL IO port access to" static const WCHAR allW[] = {'a','l','l',0};
" windoze programs!\nWarning!!! "
"*** THIS IS NOT AT ALL " if (!strcmpiW(str, allW))
"RECOMMENDED!!! ***\n"); {
for (i=0; i < sizeof(port_permissions); i++) for (i=0; i < sizeof(port_permissions); i++)
port_permissions[i] |= rw; port_permissions[i] |= rw;
}
} else if (!(!strcmp(temp, "*") || *temp == '\0')) { else
len = strlen(temp); {
val = -1; val = -1;
val1 = -1; val1 = -1;
for (i = 0; i < len; i++) { while (*str)
switch (temp[i]) { {
case '0': switch(*str)
if (temp[i+1] == 'x' || temp[i+1] == 'X') { {
sscanf(temp+i, "%x", &val); case ',':
i += 2; case ' ':
} else { case '\t':
sscanf(temp+i, "%d", &val); set_IO_permissions(val1, val, rw);
} val1 = -1;
while (isxdigit(temp[i])) val = -1;
i++; str++;
i--; break;
break; case '-':
case ',': val1 = val;
case ' ': if (val1 == -1) val1 = 0;
case '\t': str++;
set_IO_permissions(val1, val, rw); break;
val1 = -1; val = -1; default:
break; if (isdigitW(*str))
case '-': {
val1 = val; val = strtoulW( str, &end, 0 );
if (val1 == -1) val1 = 0; if (end == str)
break; {
default: val = -1;
if (temp[i] >= '0' && temp[i] <= '9') { str++;
sscanf(temp+i, "%d", &val); }
while (isdigit(temp[i])) else str = end;
i++; }
} break;
} }
} }
set_IO_permissions(val1, val, rw); set_IO_permissions(val1, val, rw);
} }
} }
static inline BYTE inb( WORD port ) static inline BYTE inb( WORD port )
...@@ -250,25 +251,50 @@ static inline void outl( DWORD value, WORD port ) ...@@ -250,25 +251,50 @@ static inline void outl( DWORD value, WORD port )
static void IO_port_init(void) static void IO_port_init(void)
{ {
char temp[1024]; char tmp[1024];
WCHAR tempW[1024]; HKEY hkey;
static const WCHAR portsW[] = {'p','o','r','t','s',0}; DWORD dummy;
static const WCHAR readW[] = {'r','e','a','d',0}; OBJECT_ATTRIBUTES attr;
static const WCHAR writeW[] = {'w','r','i','t','e',0}; UNICODE_STRING nameW;
static const WCHAR asteriskW[] = {'*',0};
static const WCHAR portsW[] = {'M','a','c','h','i','n','e','\\',
do_direct_port_access = 0; 'S','o','f','t','w','a','r','e','\\',
/* Can we do that? */ 'W','i','n','e','\\','W','i','n','e','\\',
if (!iopl(3)) { 'C','o','n','f','i','g','\\','P','o','r','t','s',0};
iopl(0); static const WCHAR readW[] = {'r','e','a','d',0};
static const WCHAR writeW[] = {'w','r','i','t','e',0};
PROFILE_GetWineIniString( portsW, readW, asteriskW, tempW, 1024 );
WideCharToMultiByte(CP_ACP, 0, tempW, -1, temp, 1024, NULL, NULL); do_direct_port_access = 0;
do_IO_port_init_read_or_write(temp, IO_READ); /* Can we do that? */
PROFILE_GetWineIniString( portsW, writeW, asteriskW, tempW, 1024 ); if (!iopl(3))
WideCharToMultiByte(CP_ACP, 0, tempW, -1, temp, 1024, NULL, NULL); {
do_IO_port_init_read_or_write(temp, IO_WRITE); iopl(0);
}
attr.Length = sizeof(attr);
attr.RootDirectory = 0;
attr.ObjectName = &nameW;
attr.Attributes = 0;
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
RtlInitUnicodeString( &nameW, portsW );
if (!NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ))
{
RtlInitUnicodeString( &nameW, readW );
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
{
WCHAR *str = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
do_IO_port_init_read_or_write(str, IO_READ);
}
RtlInitUnicodeString( &nameW, writeW );
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
{
WCHAR *str = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
do_IO_port_init_read_or_write(str, IO_WRITE);
}
NtClose( hkey );
}
}
IO_FixCMOSCheckSum(); IO_FixCMOSCheckSum();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment