Replaced remaining calls to PROFILE_GetWineIniString/Bool by direct

registry accesses.
This commit is contained in:
Alexandre Julliard 2003-08-19 03:21:04 +00:00
parent 7c3ab33196
commit e0deb0c627
10 changed files with 419 additions and 284 deletions

View file

@ -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
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 )
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)
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 )
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" );

View file

@ -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"

View file

@ -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
*/ */
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)
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)
} }
/* 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)
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)
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;
} }

View file

@ -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 )
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));
@ -1692,6 +1718,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
*/ */
@ -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;
} }

View file

@ -138,27 +138,23 @@ inline static char *heap_strdup( const char *str )
return p; return p;
} }
#define IS_OPTION_TRUE(ch) ((ch) == 'y' || (ch) == 'Y' || (ch) == 't' || (ch) == 'T' || (ch) == '1')
extern void CDROM_InitRegistry(int dev); extern void CDROM_InitRegistry(int dev);
/*********************************************************************** /***********************************************************************
* DRIVE_GetDriveType * DRIVE_GetDriveType
*/ */
static UINT DRIVE_GetDriveType( LPCWSTR name ) static inline UINT DRIVE_GetDriveType( INT drive, LPCWSTR value )
{ {
WCHAR buffer[20];
int i; int i;
static const WCHAR TypeW[] = {'T','y','p','e',0};
static const WCHAR hdW[] = {'h','d',0};
PROFILE_GetWineIniString( name, TypeW, hdW, buffer, 20 );
if(!buffer[0])
strcpyW(buffer,hdW);
for (i = 0; i < sizeof(DRIVE_Types)/sizeof(DRIVE_Types[0]); i++) for (i = 0; i < sizeof(DRIVE_Types)/sizeof(DRIVE_Types[0]); i++)
{ {
if (!strcmpiW( buffer, DRIVE_Types[i] )) return i; if (!strcmpiW( value, DRIVE_Types[i] )) return i;
} }
MESSAGE("%s: unknown drive type %s, defaulting to 'hd'.\n", MESSAGE("Drive %c: unknown drive type %s, defaulting to 'hd'.\n",
debugstr_w(name), debugstr_w(buffer) ); 'A' + drive, debugstr_w(value) );
return DRIVE_FIXED; return DRIVE_FIXED;
} }
@ -166,14 +162,14 @@ static UINT DRIVE_GetDriveType( LPCWSTR name )
/*********************************************************************** /***********************************************************************
* DRIVE_GetFSFlags * DRIVE_GetFSFlags
*/ */
static UINT DRIVE_GetFSFlags( LPCWSTR name, LPCWSTR value ) static UINT DRIVE_GetFSFlags( INT drive, LPCWSTR value )
{ {
const FS_DESCR *descr; const FS_DESCR *descr;
for (descr = DRIVE_Filesystems; *descr->name; descr++) for (descr = DRIVE_Filesystems; *descr->name; descr++)
if (!strcmpiW( value, descr->name )) return descr->flags; if (!strcmpiW( value, descr->name )) return descr->flags;
MESSAGE("%s: unknown filesystem type %s, defaulting to 'win95'.\n", MESSAGE("Drive %c: unknown filesystem type %s, defaulting to 'win95'.\n",
debugstr_w(name), debugstr_w(value) ); 'A' + drive, debugstr_w(value) );
return DRIVE_CASE_PRESERVING; return DRIVE_CASE_PRESERVING;
} }
@ -184,36 +180,59 @@ static UINT DRIVE_GetFSFlags( LPCWSTR name, LPCWSTR value )
int DRIVE_Init(void) int DRIVE_Init(void)
{ {
int i, len, count = 0; int i, len, count = 0;
WCHAR name[] = {'D','r','i','v','e',' ','A',0}; WCHAR driveW[] = {'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','\\','D','r','i','v','e',' ','A',0};
WCHAR drive_env[] = {'=','A',':',0}; WCHAR drive_env[] = {'=','A',':',0};
WCHAR path[MAX_PATHNAME_LEN]; WCHAR path[MAX_PATHNAME_LEN];
WCHAR buffer[80]; char tmp[MAX_PATHNAME_LEN*sizeof(WCHAR) + sizeof(KEY_VALUE_PARTIAL_INFORMATION)];
struct stat drive_stat_buffer; struct stat drive_stat_buffer;
WCHAR *p; WCHAR *p;
DOSDRIVE *drive; DOSDRIVE *drive;
HKEY hkey;
DWORD dummy;
OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW;
static const WCHAR PathW[] = {'P','a','t','h',0}; static const WCHAR PathW[] = {'P','a','t','h',0};
static const WCHAR empty_strW[] = { 0 };
static const WCHAR CodepageW[] = {'C','o','d','e','p','a','g','e',0}; static const WCHAR CodepageW[] = {'C','o','d','e','p','a','g','e',0};
static const WCHAR LabelW[] = {'L','a','b','e','l',0}; static const WCHAR LabelW[] = {'L','a','b','e','l',0};
static const WCHAR SerialW[] = {'S','e','r','i','a','l',0}; static const WCHAR SerialW[] = {'S','e','r','i','a','l',0};
static const WCHAR zeroW[] = {'0',0}; static const WCHAR TypeW[] = {'T','y','p','e',0};
static const WCHAR def_serialW[] = {'1','2','3','4','5','6','7','8',0};
static const WCHAR FilesystemW[] = {'F','i','l','e','s','y','s','t','e','m',0}; static const WCHAR FilesystemW[] = {'F','i','l','e','s','y','s','t','e','m',0};
static const WCHAR win95W[] = {'w','i','n','9','5',0};
static const WCHAR DeviceW[] = {'D','e','v','i','c','e',0}; static const WCHAR DeviceW[] = {'D','e','v','i','c','e',0};
static const WCHAR ReadVolInfoW[] = {'R','e','a','d','V','o','l','I','n','f','o',0}; static const WCHAR ReadVolInfoW[] = {'R','e','a','d','V','o','l','I','n','f','o',0};
static const WCHAR FailReadOnlyW[] = {'F','a','i','l','R','e','a','d','O','n','l','y',0}; static const WCHAR FailReadOnlyW[] = {'F','a','i','l','R','e','a','d','O','n','l','y',0};
static const WCHAR driveC_labelW[] = {'D','r','i','v','e',' ','C',' ',' ',' ',' ',0}; static const WCHAR driveC_labelW[] = {'D','r','i','v','e',' ','C',' ',' ',' ',' ',0};
for (i = 0, drive = DOSDrives; i < MAX_DOS_DRIVES; i++, name[6]++, drive++)
attr.Length = sizeof(attr);
attr.RootDirectory = 0;
attr.ObjectName = &nameW;
attr.Attributes = 0;
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
for (i = 0, drive = DOSDrives; i < MAX_DOS_DRIVES; i++, drive++)
{ {
PROFILE_GetWineIniString( name, PathW, empty_strW, path, MAX_PATHNAME_LEN ); RtlInitUnicodeString( &nameW, driveW );
if (path[0]) nameW.Buffer[(nameW.Length / sizeof(WCHAR)) - 1] = 'A' + i;
if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ) != STATUS_SUCCESS) continue;
/* Get the code page number */
RtlInitUnicodeString( &nameW, CodepageW );
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
{ {
/* Get the code page number */ WCHAR *data = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
PROFILE_GetWineIniString( name, CodepageW, zeroW, /* 0 == CP_ACP */ drive->codepage = strtolW( data, NULL, 10 );
buffer, 80 ); }
drive->codepage = strtolW( buffer, NULL, 10 );
/* Get the root path */
RtlInitUnicodeString( &nameW, PathW );
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
{
WCHAR *data = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
ExpandEnvironmentStringsW( data, path, sizeof(path)/sizeof(WCHAR) );
p = path + strlenW(path) - 1; p = path + strlenW(path) - 1;
while ((p > path) && (*p == '/')) *p-- = '\0'; while ((p > path) && (*p == '/')) *p-- = '\0';
@ -232,7 +251,8 @@ int DRIVE_Init(void)
len += WideCharToMultiByte(drive->codepage, 0, path, -1, NULL, 0, NULL, NULL) + 2; len += WideCharToMultiByte(drive->codepage, 0, path, -1, NULL, 0, NULL, NULL) + 2;
drive->root = HeapAlloc( GetProcessHeap(), 0, len ); drive->root = HeapAlloc( GetProcessHeap(), 0, len );
len -= sprintf( drive->root, "%s/", config ); len -= sprintf( drive->root, "%s/", config );
WideCharToMultiByte(drive->codepage, 0, path, -1, drive->root + strlen(drive->root), len, NULL, NULL); WideCharToMultiByte(drive->codepage, 0, path, -1,
drive->root + strlen(drive->root), len, NULL, NULL);
} }
if (stat( drive->root, &drive_stat_buffer )) if (stat( drive->root, &drive_stat_buffer ))
@ -241,7 +261,7 @@ int DRIVE_Init(void)
drive->root, strerror(errno), 'A' + i); drive->root, strerror(errno), 'A' + i);
HeapFree( GetProcessHeap(), 0, drive->root ); HeapFree( GetProcessHeap(), 0, drive->root );
drive->root = NULL; drive->root = NULL;
continue; goto next;
} }
if (!S_ISDIR(drive_stat_buffer.st_mode)) if (!S_ISDIR(drive_stat_buffer.st_mode))
{ {
@ -249,19 +269,32 @@ int DRIVE_Init(void)
drive->root, 'A' + i ); drive->root, 'A' + i );
HeapFree( GetProcessHeap(), 0, drive->root ); HeapFree( GetProcessHeap(), 0, drive->root );
drive->root = NULL; drive->root = NULL;
continue; goto next;
} }
drive->dos_cwd = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(drive->dos_cwd[0])); drive->dos_cwd = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(drive->dos_cwd[0]));
drive->unix_cwd = heap_strdup( "" ); drive->unix_cwd = heap_strdup( "" );
drive->type = DRIVE_GetDriveType( name );
drive->device = NULL; drive->device = NULL;
drive->flags = 0; drive->flags = 0;
drive->dev = drive_stat_buffer.st_dev; drive->dev = drive_stat_buffer.st_dev;
drive->ino = drive_stat_buffer.st_ino; drive->ino = drive_stat_buffer.st_ino;
/* Get the drive type */
RtlInitUnicodeString( &nameW, TypeW );
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
{
WCHAR *data = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
drive->type = DRIVE_GetDriveType( i, data );
}
else drive->type = DRIVE_FIXED;
/* Get the drive label */ /* Get the drive label */
PROFILE_GetWineIniString( name, LabelW, empty_strW, drive->label_conf, 12 ); RtlInitUnicodeString( &nameW, LabelW );
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
{
WCHAR *data = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
lstrcpynW( drive->label_conf, data, 12 );
}
if ((len = strlenW(drive->label_conf)) < 11) if ((len = strlenW(drive->label_conf)) < 11)
{ {
/* Pad label with spaces */ /* Pad label with spaces */
@ -270,51 +303,73 @@ int DRIVE_Init(void)
} }
/* Get the serial number */ /* Get the serial number */
PROFILE_GetWineIniString( name, SerialW, def_serialW, buffer, 80 ); RtlInitUnicodeString( &nameW, SerialW );
drive->serial_conf = strtoulW( buffer, NULL, 16 ); if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
{
WCHAR *data = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
drive->serial_conf = strtoulW( data, NULL, 16 );
}
else drive->serial_conf = 12345678;
/* Get the filesystem type */ /* Get the filesystem type */
PROFILE_GetWineIniString( name, FilesystemW, win95W, buffer, 80 ); RtlInitUnicodeString( &nameW, FilesystemW );
drive->flags = DRIVE_GetFSFlags( name, buffer ); if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
{
WCHAR *data = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
drive->flags = DRIVE_GetFSFlags( i, data );
}
else drive->flags = DRIVE_CASE_PRESERVING;
/* Get the device */ /* Get the device */
PROFILE_GetWineIniString( name, DeviceW, empty_strW, buffer, 80 ); RtlInitUnicodeString( &nameW, DeviceW );
if (buffer[0]) if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
{ {
int cd_fd; WCHAR *data = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
len = WideCharToMultiByte(CP_ACP, 0, buffer, -1, NULL, 0, NULL, NULL); len = WideCharToMultiByte(CP_ACP, 0, data, -1, NULL, 0, NULL, NULL);
drive->device = HeapAlloc(GetProcessHeap(), 0, len); drive->device = HeapAlloc(GetProcessHeap(), 0, len);
WideCharToMultiByte(drive->codepage, 0, buffer, -1, drive->device, len, NULL, NULL); WideCharToMultiByte(drive->codepage, 0, data, -1, drive->device, len, NULL, NULL);
if (PROFILE_GetWineIniBool( name, ReadVolInfoW, 1)) RtlInitUnicodeString( &nameW, ReadVolInfoW );
drive->flags |= DRIVE_READ_VOL_INFO; if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
{
WCHAR *data = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
if (IS_OPTION_TRUE(data[0])) drive->flags |= DRIVE_READ_VOL_INFO;
}
else drive->flags |= DRIVE_READ_VOL_INFO;
if (drive->type == DRIVE_CDROM) if (drive->type == DRIVE_CDROM)
{ {
int cd_fd;
if ((cd_fd = open(drive->device, O_RDONLY|O_NONBLOCK)) != -1) if ((cd_fd = open(drive->device, O_RDONLY|O_NONBLOCK)) != -1)
{ {
CDROM_InitRegistry(cd_fd); CDROM_InitRegistry(cd_fd);
close(cd_fd); close(cd_fd);
} }
} }
} }
/* Get the FailReadOnly flag */ /* Get the FailReadOnly flag */
if (PROFILE_GetWineIniBool( name, FailReadOnlyW, 0 )) RtlInitUnicodeString( &nameW, FailReadOnlyW );
drive->flags |= DRIVE_FAIL_READ_ONLY; if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
{
WCHAR *data = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
if (IS_OPTION_TRUE(data[0])) drive->flags |= DRIVE_FAIL_READ_ONLY;
}
/* Make the first hard disk the current drive */ /* Make the first hard disk the current drive */
if ((DRIVE_CurDrive == -1) && (drive->type == DRIVE_FIXED)) if ((DRIVE_CurDrive == -1) && (drive->type == DRIVE_FIXED))
DRIVE_CurDrive = i; DRIVE_CurDrive = i;
count++; count++;
TRACE("%s: path=%s type=%s label=%s serial=%08lx " TRACE("Drive %c: path=%s type=%s label=%s serial=%08lx "
"flags=%08x codepage=%u dev=%x ino=%x\n", "flags=%08x codepage=%u dev=%x ino=%x\n",
debugstr_w(name), drive->root, debugstr_w(DRIVE_Types[drive->type]), 'A' + i, drive->root, debugstr_w(DRIVE_Types[drive->type]),
debugstr_w(drive->label_conf), drive->serial_conf, drive->flags, debugstr_w(drive->label_conf), drive->serial_conf, drive->flags,
drive->codepage, (int)drive->dev, (int)drive->ino ); drive->codepage, (int)drive->dev, (int)drive->ino );
} }
else WARN("%s: not defined\n", debugstr_w(name) );
next:
NtClose( hkey );
} }
if (!count) if (!count)

View 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;
@ -706,6 +708,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
* *
@ -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;
} }

View file

@ -904,133 +904,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
* *

View file

@ -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 );

View file

@ -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
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
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
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
break; break;
} }
if (profile_key) NtClose( profile_key );
} }
/* load home registry files (stored in ~/.wine) [Internal] */ /* load home registry files (stored in ~/.wine) [Internal] */

View file

@ -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)
* 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 "
"RECOMMENDED!!! ***\n");
for (i=0; i < sizeof(port_permissions); i++)
port_permissions[i] |= rw;
} else if (!(!strcmp(temp, "*") || *temp == '\0')) { if (!strcmpiW(str, allW))
len = strlen(temp); {
val = -1; for (i=0; i < sizeof(port_permissions); i++)
val1 = -1; port_permissions[i] |= rw;
for (i = 0; i < len; i++) { }
switch (temp[i]) { else
case '0': {
if (temp[i+1] == 'x' || temp[i+1] == 'X') { val = -1;
sscanf(temp+i, "%x", &val); val1 = -1;
i += 2; while (*str)
} else { {
sscanf(temp+i, "%d", &val); switch(*str)
} {
while (isxdigit(temp[i])) case ',':
i++; case ' ':
i--; case '\t':
break; set_IO_permissions(val1, val, rw);
case ',': val1 = -1;
case ' ': val = -1;
case '\t': str++;
set_IO_permissions(val1, val, rw); break;
val1 = -1; val = -1; case '-':
break; val1 = val;
case '-': if (val1 == -1) val1 = 0;
val1 = val; str++;
if (val1 == -1) val1 = 0; break;
break; default:
default: if (isdigitW(*str))
if (temp[i] >= '0' && temp[i] <= '9') { {
sscanf(temp+i, "%d", &val); val = strtoulW( str, &end, 0 );
while (isdigit(temp[i])) if (end == str)
i++; {
} val = -1;
} str++;
} }
set_IO_permissions(val1, val, rw); else str = end;
} }
break;
}
}
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 )
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};
do_direct_port_access = 0; static const WCHAR portsW[] = {'M','a','c','h','i','n','e','\\',
/* Can we do that? */ 'S','o','f','t','w','a','r','e','\\',
if (!iopl(3)) { 'W','i','n','e','\\','W','i','n','e','\\',
iopl(0); 'C','o','n','f','i','g','\\','P','o','r','t','s',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 ); do_direct_port_access = 0;
WideCharToMultiByte(CP_ACP, 0, tempW, -1, temp, 1024, NULL, NULL); /* Can we do that? */
do_IO_port_init_read_or_write(temp, IO_READ); if (!iopl(3))
PROFILE_GetWineIniString( portsW, writeW, asteriskW, tempW, 1024 ); {
WideCharToMultiByte(CP_ACP, 0, tempW, -1, temp, 1024, NULL, NULL); iopl(0);
do_IO_port_init_read_or_write(temp, IO_WRITE);
} 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();
} }