Get rid of the old config conversion code.
This commit is contained in:
parent
aa2e3a4f8a
commit
34a9ab04b2
|
@ -56,426 +56,6 @@
|
|||
WINE_DEFAULT_DEBUG_CHANNEL(reg);
|
||||
|
||||
|
||||
/* create symlinks for the DOS drives; helper for create_dos_devices */
|
||||
static int create_drives( int devices_only )
|
||||
{
|
||||
static const WCHAR PathW[] = {'P','a','t','h',0};
|
||||
static const WCHAR DeviceW[] = {'D','e','v','i','c','e',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};
|
||||
const char *config_dir = wine_get_config_dir();
|
||||
OBJECT_ATTRIBUTES attr;
|
||||
UNICODE_STRING nameW;
|
||||
char tmp[1024*sizeof(WCHAR) + sizeof(KEY_VALUE_PARTIAL_INFORMATION)];
|
||||
char dest[1024];
|
||||
char *buffer;
|
||||
WCHAR *p, name[3];
|
||||
HANDLE hkey;
|
||||
DWORD dummy;
|
||||
int i, count = 0;
|
||||
|
||||
attr.Length = sizeof(attr);
|
||||
attr.RootDirectory = 0;
|
||||
attr.ObjectName = &nameW;
|
||||
attr.Attributes = 0;
|
||||
attr.SecurityDescriptor = NULL;
|
||||
attr.SecurityQualityOfService = NULL;
|
||||
|
||||
/* create symlinks for the drive roots */
|
||||
|
||||
if (!devices_only) for (i = 0; i < 26; i++)
|
||||
{
|
||||
RtlInitUnicodeString( &nameW, driveW );
|
||||
nameW.Buffer[(nameW.Length / sizeof(WCHAR)) - 1] = 'A' + i;
|
||||
/* @@ Wine registry key: HKLM\Software\Wine\Wine\Config\Drive A */
|
||||
if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ) != STATUS_SUCCESS) continue;
|
||||
|
||||
RtlInitUnicodeString( &nameW, PathW );
|
||||
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
|
||||
{
|
||||
WCHAR path[1024];
|
||||
WCHAR *data = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
|
||||
ExpandEnvironmentStringsW( data, path, sizeof(path)/sizeof(WCHAR) );
|
||||
|
||||
p = path + strlenW(path) - 1;
|
||||
while ((p > path) && (*p == '/')) *p-- = '\0';
|
||||
|
||||
name[0] = 'a' + i;
|
||||
name[1] = ':';
|
||||
name[2] = 0;
|
||||
|
||||
if (path[0] != '/')
|
||||
{
|
||||
/* relative paths are relative to config dir */
|
||||
memmove( path + 3, path, (strlenW(path) + 1) * sizeof(WCHAR) );
|
||||
path[0] = '.';
|
||||
path[1] = '.';
|
||||
path[2] = '/';
|
||||
}
|
||||
if (DefineDosDeviceW( DDD_RAW_TARGET_PATH, name, path ))
|
||||
{
|
||||
WideCharToMultiByte(CP_UNIXCP, 0, path, -1, dest, sizeof(dest), NULL, NULL);
|
||||
MESSAGE( "Created symlink %s/dosdevices/%c: -> %s\n",
|
||||
wine_get_config_dir(), 'a' + i, dest );
|
||||
count++;
|
||||
}
|
||||
}
|
||||
NtClose( hkey );
|
||||
}
|
||||
|
||||
/* create symlinks for the drive devices */
|
||||
|
||||
buffer = HeapAlloc( GetProcessHeap(), 0,
|
||||
strlen(config_dir) + sizeof("/dosdevices/a::") );
|
||||
strcpy( buffer, config_dir );
|
||||
strcat( buffer, "/dosdevices/a::" );
|
||||
|
||||
for (i = 0; i < 26; i++)
|
||||
{
|
||||
RtlInitUnicodeString( &nameW, driveW );
|
||||
nameW.Buffer[(nameW.Length / sizeof(WCHAR)) - 1] = 'A' + i;
|
||||
/* @@ Wine registry key: HKLM\Software\Wine\Wine\Config\Drive A */
|
||||
if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ) != STATUS_SUCCESS) continue;
|
||||
|
||||
RtlInitUnicodeString( &nameW, DeviceW );
|
||||
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
|
||||
{
|
||||
WCHAR *data = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
|
||||
WideCharToMultiByte(CP_UNIXCP, 0, data, -1, dest, sizeof(dest), NULL, NULL);
|
||||
|
||||
buffer[strlen(buffer) - 3] = 'a' + i;
|
||||
if (!symlink( dest, buffer ))
|
||||
{
|
||||
MESSAGE( "Created symlink %s/dosdevices/%c:: -> %s\n",
|
||||
wine_get_config_dir(), 'a' + i, dest );
|
||||
count++;
|
||||
}
|
||||
}
|
||||
NtClose( hkey );
|
||||
}
|
||||
HeapFree( GetProcessHeap(), 0, buffer );
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/* create the device files for the new device naming scheme */
|
||||
static void create_dos_devices(void)
|
||||
{
|
||||
const char *config_dir = wine_get_config_dir();
|
||||
char *buffer;
|
||||
int i, count = 0;
|
||||
|
||||
if (!(buffer = HeapAlloc( GetProcessHeap(), 0,
|
||||
strlen(config_dir) + sizeof("/dosdevices/a::") )))
|
||||
return;
|
||||
|
||||
strcpy( buffer, config_dir );
|
||||
strcat( buffer, "/dosdevices" );
|
||||
|
||||
if (!mkdir( buffer, 0777 )) /* we created it, so now create the devices */
|
||||
{
|
||||
HANDLE hkey;
|
||||
DWORD dummy;
|
||||
OBJECT_ATTRIBUTES attr;
|
||||
UNICODE_STRING nameW;
|
||||
WCHAR *p, *devnameW;
|
||||
char tmp[128];
|
||||
WCHAR com[5] = {'C','O','M','1',0};
|
||||
WCHAR lpt[5] = {'L','P','T','1',0};
|
||||
|
||||
static const WCHAR serialportsW[] = {'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','\\',
|
||||
'S','e','r','i','a','l','P','o','r','t','s',0};
|
||||
static const WCHAR parallelportsW[] = {'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','\\',
|
||||
'P','a','r','a','l','l','e','l','P','o','r','t','s',0};
|
||||
|
||||
attr.Length = sizeof(attr);
|
||||
attr.RootDirectory = 0;
|
||||
attr.ObjectName = &nameW;
|
||||
attr.Attributes = 0;
|
||||
attr.SecurityDescriptor = NULL;
|
||||
attr.SecurityQualityOfService = NULL;
|
||||
RtlInitUnicodeString( &nameW, serialportsW );
|
||||
|
||||
/* @@ Wine registry key: HKLM\Software\Wine\Wine\Config\SerialPorts */
|
||||
if (!NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ))
|
||||
{
|
||||
RtlInitUnicodeString( &nameW, com );
|
||||
for (i = 1; i <= 9; i++)
|
||||
{
|
||||
com[3] = '0' + i;
|
||||
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation,
|
||||
tmp, sizeof(tmp), &dummy ))
|
||||
{
|
||||
devnameW = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
|
||||
if ((p = strchrW( devnameW, ',' ))) *p = 0;
|
||||
if (DefineDosDeviceW( DDD_RAW_TARGET_PATH, com, devnameW ))
|
||||
{
|
||||
char devname[32];
|
||||
WideCharToMultiByte(CP_UNIXCP, 0, devnameW, -1,
|
||||
devname, sizeof(devname), NULL, NULL);
|
||||
MESSAGE( "Created symlink %s/dosdevices/com%d -> %s\n", config_dir, i, devname );
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
NtClose( hkey );
|
||||
}
|
||||
|
||||
/* @@ Wine registry key: HKLM\Software\Wine\Wine\Config\ParallelPorts */
|
||||
RtlInitUnicodeString( &nameW, parallelportsW );
|
||||
if (!NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ))
|
||||
{
|
||||
RtlInitUnicodeString( &nameW, lpt );
|
||||
for (i = 1; i <= 9; i++)
|
||||
{
|
||||
lpt[3] = '0' + i;
|
||||
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation,
|
||||
tmp, sizeof(tmp), &dummy ))
|
||||
{
|
||||
devnameW = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
|
||||
if ((p = strchrW( devnameW, ',' ))) *p = 0;
|
||||
if (DefineDosDeviceW( DDD_RAW_TARGET_PATH, lpt, devnameW ))
|
||||
{
|
||||
char devname[32];
|
||||
WideCharToMultiByte(CP_UNIXCP, 0, devnameW, -1,
|
||||
devname, sizeof(devname), NULL, NULL);
|
||||
MESSAGE( "Created symlink %s/dosdevices/lpt%d -> %s\n", config_dir, i, devname );
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
NtClose( hkey );
|
||||
}
|
||||
count += create_drives( FALSE );
|
||||
}
|
||||
else
|
||||
{
|
||||
struct stat st;
|
||||
int i;
|
||||
|
||||
/* it is possible that the serial/parallel devices have been created but */
|
||||
/* not the drives; check for at least one drive symlink to catch that case */
|
||||
strcat( buffer, "/a:" );
|
||||
for (i = 0; i < 26; i++)
|
||||
{
|
||||
buffer[strlen(buffer)-2] = 'a' + i;
|
||||
if (!lstat( buffer, &st )) break;
|
||||
}
|
||||
if (i == 26) count += create_drives( FALSE );
|
||||
else
|
||||
{
|
||||
strcat( buffer, ":" );
|
||||
for (i = 0; i < 26; i++)
|
||||
{
|
||||
buffer[strlen(buffer)-3] = 'a' + i;
|
||||
if (!lstat( buffer, &st )) break;
|
||||
}
|
||||
if (i == 26) count += create_drives( TRUE );
|
||||
}
|
||||
}
|
||||
|
||||
if (count)
|
||||
MESSAGE( "\nYou can now remove the [SerialPorts], [ParallelPorts], and [Drive] sections\n"
|
||||
"in your configuration file, they are replaced by the above symlinks.\n\n" );
|
||||
|
||||
HeapFree( GetProcessHeap(), 0, buffer );
|
||||
}
|
||||
|
||||
|
||||
/* convert the drive type entries from the old format to the new one */
|
||||
static void convert_drive_types(void)
|
||||
{
|
||||
static const WCHAR TypeW[] = {'T','y','p','e',0};
|
||||
static const WCHAR drive_types_keyW[] = {'M','a','c','h','i','n','e','\\',
|
||||
'S','o','f','t','w','a','r','e','\\',
|
||||
'W','i','n','e','\\',
|
||||
'D','r','i','v','e','s',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};
|
||||
char tmp[32*sizeof(WCHAR) + sizeof(KEY_VALUE_PARTIAL_INFORMATION)];
|
||||
OBJECT_ATTRIBUTES attr;
|
||||
UNICODE_STRING nameW;
|
||||
DWORD dummy;
|
||||
ULONG disp;
|
||||
HANDLE hkey_old, hkey_new;
|
||||
int i;
|
||||
|
||||
attr.Length = sizeof(attr);
|
||||
attr.RootDirectory = 0;
|
||||
attr.ObjectName = &nameW;
|
||||
attr.Attributes = 0;
|
||||
attr.SecurityDescriptor = NULL;
|
||||
attr.SecurityQualityOfService = NULL;
|
||||
RtlInitUnicodeString( &nameW, drive_types_keyW );
|
||||
|
||||
/* @@ Wine registry key: HKLM\Software\Wine\Drives */
|
||||
if (NtCreateKey( &hkey_new, KEY_ALL_ACCESS, &attr, 0, NULL, 0, &disp )) return;
|
||||
if (disp != REG_CREATED_NEW_KEY)
|
||||
{
|
||||
NtClose( hkey_new );
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < 26; i++)
|
||||
{
|
||||
RtlInitUnicodeString( &nameW, driveW );
|
||||
nameW.Buffer[(nameW.Length / sizeof(WCHAR)) - 1] = 'A' + i;
|
||||
/* @@ Wine registry key: HKLM\Software\Wine\Wine\Config\Drive A */
|
||||
if (NtOpenKey( &hkey_old, KEY_ALL_ACCESS, &attr ) != STATUS_SUCCESS) continue;
|
||||
RtlInitUnicodeString( &nameW, TypeW );
|
||||
if (!NtQueryValueKey( hkey_old, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
|
||||
{
|
||||
WCHAR valueW[] = {'A',':',0};
|
||||
WCHAR *type = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
|
||||
|
||||
valueW[0] = 'A' + i;
|
||||
RtlInitUnicodeString( &nameW, valueW );
|
||||
NtSetValueKey( hkey_new, &nameW, 0, REG_SZ, type, (strlenW(type) + 1) * sizeof(WCHAR) );
|
||||
MESSAGE( "Converted drive type to new entry HKLM\\Software\\Wine\\Drives \"%c:\" = %s\n",
|
||||
'A' + i, debugstr_w(type) );
|
||||
}
|
||||
NtClose( hkey_old );
|
||||
}
|
||||
NtClose( hkey_new );
|
||||
}
|
||||
|
||||
|
||||
/* convert the environment variable entries from the old format to the new one */
|
||||
static void convert_environment( HANDLE hkey_current_user )
|
||||
{
|
||||
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 systemW[] = {'s','y','s','t','e','m',0};
|
||||
static const WCHAR windirW[] = {'w','i','n','d','i','r',0};
|
||||
static const WCHAR systemrootW[] = {'S','y','s','t','e','m','r','o','o','t',0};
|
||||
static const WCHAR winsysdirW[] = {'w','i','n','s','y','s','d','i','r',0};
|
||||
static const WCHAR envW[] = {'E','n','v','i','r','o','n','m','e','n','t',0};
|
||||
static const WCHAR tempW[] = {'T','E','M','P',0};
|
||||
static const WCHAR tmpW[] = {'T','M','P',0};
|
||||
static const WCHAR pathW[] = {'P','A','T','H',0};
|
||||
static const WCHAR profileW[] = {'p','r','o','f','i','l','e',0};
|
||||
static const WCHAR userprofileW[] = {'U','S','E','R','P','R','O','F','I','L','E',0};
|
||||
|
||||
char buffer[1024*sizeof(WCHAR) + sizeof(KEY_VALUE_PARTIAL_INFORMATION)];
|
||||
KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION *)buffer;
|
||||
OBJECT_ATTRIBUTES attr;
|
||||
UNICODE_STRING nameW;
|
||||
DWORD dummy;
|
||||
ULONG disp;
|
||||
HANDLE hkey_old, hkey_env;
|
||||
|
||||
attr.Length = sizeof(attr);
|
||||
attr.RootDirectory = 0;
|
||||
attr.ObjectName = &nameW;
|
||||
attr.Attributes = 0;
|
||||
attr.SecurityDescriptor = NULL;
|
||||
attr.SecurityQualityOfService = NULL;
|
||||
RtlInitUnicodeString( &nameW, wineW );
|
||||
|
||||
/* @@ Wine registry key: HKLM\Software\Wine\Wine\Config\Wine */
|
||||
if (NtOpenKey( &hkey_old, KEY_ALL_ACCESS, &attr ) != STATUS_SUCCESS) return;
|
||||
|
||||
attr.RootDirectory = hkey_current_user;
|
||||
RtlInitUnicodeString( &nameW, envW );
|
||||
if (NtCreateKey( &hkey_env, KEY_ALL_ACCESS, &attr, 0, NULL, 0, &disp ))
|
||||
{
|
||||
NtClose( hkey_old );
|
||||
return;
|
||||
}
|
||||
|
||||
/* Test for existence of TEMP */
|
||||
RtlInitUnicodeString( &nameW, tempW );
|
||||
if (NtQueryValueKey(hkey_env, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
|
||||
{
|
||||
/* convert TEMP */
|
||||
RtlInitUnicodeString( &nameW, tempW );
|
||||
if (!NtQueryValueKey( hkey_old, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
|
||||
{
|
||||
NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength );
|
||||
RtlInitUnicodeString( &nameW, tmpW );
|
||||
NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength );
|
||||
MESSAGE( "Converted temp dir to new entry HKCU\\Environment \"TEMP\" = %s\n",
|
||||
debugstr_w( (WCHAR*)info->Data ) );
|
||||
}
|
||||
}
|
||||
|
||||
/* Test for existence of PATH */
|
||||
RtlInitUnicodeString( &nameW, pathW );
|
||||
if (NtQueryValueKey(hkey_env, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
|
||||
{
|
||||
/* convert PATH */
|
||||
RtlInitUnicodeString( &nameW, pathW );
|
||||
if (!NtQueryValueKey( hkey_old, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
|
||||
{
|
||||
NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength );
|
||||
MESSAGE( "Converted path dir to new entry HKCU\\Environment \"PATH\" = %s\n",
|
||||
debugstr_w( (WCHAR*)info->Data ) );
|
||||
}
|
||||
}
|
||||
|
||||
/* Test for existence of USERPROFILE */
|
||||
RtlInitUnicodeString( &nameW, userprofileW );
|
||||
if (NtQueryValueKey(hkey_env, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
|
||||
{
|
||||
/* convert USERPROFILE */
|
||||
RtlInitUnicodeString( &nameW, profileW );
|
||||
if (!NtQueryValueKey( hkey_old, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
|
||||
{
|
||||
RtlInitUnicodeString( &nameW, userprofileW );
|
||||
NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength );
|
||||
MESSAGE( "Converted profile dir to new entry HKCU\\Environment \"USERPROFILE\" = %s\n",
|
||||
debugstr_w( (WCHAR*)info->Data ) );
|
||||
}
|
||||
}
|
||||
|
||||
/* Test for existence of windir */
|
||||
RtlInitUnicodeString( &nameW, windirW );
|
||||
if (NtQueryValueKey(hkey_env, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
|
||||
{
|
||||
/* convert windir */
|
||||
RtlInitUnicodeString( &nameW, windowsW );
|
||||
if (!NtQueryValueKey( hkey_old, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
|
||||
{
|
||||
RtlInitUnicodeString( &nameW, windirW );
|
||||
NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength );
|
||||
RtlInitUnicodeString( &nameW, systemrootW );
|
||||
NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength );
|
||||
MESSAGE( "Converted windows dir to new entry HKCU\\Environment \"windir\" = %s\n",
|
||||
debugstr_w( (WCHAR*)info->Data ) );
|
||||
}
|
||||
}
|
||||
|
||||
/* Test for existence of winsysdir */
|
||||
RtlInitUnicodeString( &nameW, winsysdirW );
|
||||
if (NtQueryValueKey(hkey_env, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
|
||||
{
|
||||
/* convert winsysdir */
|
||||
RtlInitUnicodeString( &nameW, systemW );
|
||||
if (!NtQueryValueKey( hkey_old, &nameW, KeyValuePartialInformation, buffer, sizeof(buffer), &dummy ))
|
||||
{
|
||||
RtlInitUnicodeString( &nameW, winsysdirW );
|
||||
NtSetValueKey( hkey_env, &nameW, 0, info->Type, info->Data, info->DataLength );
|
||||
MESSAGE( "Converted system dir to new entry HKCU\\Environment \"winsysdir\" = %s\n",
|
||||
debugstr_w( (WCHAR*)info->Data ) );
|
||||
}
|
||||
}
|
||||
NtClose( hkey_old );
|
||||
NtClose( hkey_env );
|
||||
}
|
||||
|
||||
|
||||
/* registry initialisation, allocates some default keys. */
|
||||
static ULONG allocate_default_keys(void)
|
||||
{
|
||||
|
@ -688,11 +268,6 @@ void convert_old_config(void)
|
|||
}
|
||||
SERVER_END_REQ;
|
||||
|
||||
/* convert old configuration */
|
||||
create_dos_devices();
|
||||
convert_drive_types();
|
||||
convert_environment( hkey_current_user );
|
||||
|
||||
/* create some hardware keys (FIXME: should not be done here) */
|
||||
create_hardware_branch();
|
||||
|
||||
|
|
Loading…
Reference in New Issue