From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/sysparams.c | 60 +++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 38 deletions(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 5dcf42ff7f5..d264120909f 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -200,14 +200,10 @@ static const WCHAR guid_devclass_monitorW[] = {'{','4','D','3','6','E','9','6','E','-','E','3','2','5','-','1','1','C','E','-', 'B','F','C','1','-','0','8','0','0','2','B','E','1','0','3','1','8','}',0};
-static const WCHAR guid_devinterface_display_adapterW[] = - {'{','5','B','4','5','2','0','1','D','-','F','2','F','2','-','4','F','3','B','-', - '8','5','B','B','-','3','0','F','F','1','F','9','5','3','5','9','9','}',0}; - -static const WCHAR guid_display_device_arrivalW[] = - {'{','1','C','A','0','5','1','8','0','-','A','6','9','9','-','4','5','0','A','-', - '9','A','0','C','-','D','E','4','F','B','E','3','D','D','D','8','9','}',0}; +static const char guid_devinterface_display_adapterA[] = "{5B45201D-F2F2-4F3B-85BB-30FF1F953599}"; +static const char guid_display_device_arrivalA[] = "{1CA05180-A699-450A-9A0C-DE4FBE3DDD89}";
+static const char guid_devinterface_monitorA[] = "{E6F07B5F-EE97-4A90-B076-33F57BF4EAA7}"; static const WCHAR guid_devinterface_monitorW[] = {'{','E','6','F','0','7','B','5','F','-','E','E','9','7','-','4','A','9','0','-', 'B','0','7','6','-','3','3','F','5','7','B','F','4','E','A','A','7','}',0}; @@ -1131,7 +1127,7 @@ struct device_manager_ctx unsigned int output_count; unsigned int mode_count; HANDLE mutex; - WCHAR gpuid[128]; + char gpuid[128]; WCHAR gpu_guid[64]; LUID gpu_luid; HKEY adapter_key; @@ -1142,41 +1138,30 @@ struct device_manager_ctx UINT primary_height; };
-static void link_device( const WCHAR *instance, const WCHAR *class ) +static void link_device( const char *instance, const char *class ) { - unsigned int instance_len = lstrlenW( instance ), len; - unsigned int class_len = lstrlenW( class ); - WCHAR buffer[MAX_PATH], *ptr; + char buffer[MAX_PATH], *ptr; + WCHAR bufferW[MAX_PATH]; HKEY hkey, subkey; + unsigned int pos;
static const WCHAR symbolic_linkW[] = {'S','y','m','b','o','l','i','c','L','i','n','k',0}; static const WCHAR hashW[] = {'#'};
- len = asciiz_to_unicode( buffer, "DeviceClasses\" ) / sizeof(WCHAR) - 1; - memcpy( buffer + len, class, class_len * sizeof(WCHAR) ); - len += class_len; - len += asciiz_to_unicode( buffer + len, "\##?#" ) / sizeof(WCHAR) - 1; - memcpy( buffer + len, instance, instance_len * sizeof(WCHAR) ); - for (ptr = buffer + len; *ptr; ptr++) if (*ptr == '\') *ptr = '#'; - len += instance_len; - buffer[len++] = '#'; - memcpy( buffer + len, class, class_len * sizeof(WCHAR) ); - len += class_len; - hkey = reg_create_key( control_key, buffer, len * sizeof(WCHAR), 0, NULL ); + pos = snprintf( buffer, ARRAY_SIZE(buffer), "DeviceClasses\%s\", class ); + snprintf( buffer + pos, ARRAY_SIZE(buffer) - pos, "##?#%s#%s", instance, class ); + for (ptr = buffer + pos; *ptr; ptr++) if (*ptr == '\') *ptr = '#';
- set_reg_value( hkey, device_instanceW, REG_SZ, instance, (instance_len + 1) * sizeof(WCHAR) ); + hkey = reg_create_key( control_key, bufferW, asciiz_to_unicode( bufferW, buffer ) - sizeof(WCHAR), 0, NULL ); + set_reg_value( hkey, device_instanceW, REG_SZ, bufferW, asciiz_to_unicode( bufferW, instance ) );
subkey = reg_create_key( hkey, hashW, sizeof(hashW), REG_OPTION_VOLATILE, NULL ); NtClose( hkey ); hkey = subkey;
- len = asciiz_to_unicode( buffer, "\\?\" ) / sizeof(WCHAR) - 1; - memcpy( buffer + len, instance, (instance_len + 1) * sizeof(WCHAR) ); - len += instance_len; - memcpy( buffer + len, class, (class_len + 1) * sizeof(WCHAR) ); - len += class_len + 1; + snprintf( buffer, ARRAY_SIZE(buffer), "\\?\%s#%s", instance, class ); for (ptr = buffer + 4; *ptr; ptr++) if (*ptr == '\') *ptr = '#'; - set_reg_value( hkey, symbolic_linkW, REG_SZ, buffer, len * sizeof(WCHAR) ); + set_reg_value( hkey, symbolic_linkW, REG_SZ, bufferW, asciiz_to_unicode( bufferW, buffer ) );
if ((subkey = reg_create_key( hkey, controlW, sizeof(controlW), REG_OPTION_VOLATILE, NULL ))) { @@ -1246,10 +1231,10 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param ) prepare_devices(); }
- sprintf( buffer, "PCI\VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%02X\%08X", + sprintf( ctx->gpuid, "PCI\VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%02X\%08X", gpu->vendor_id, gpu->device_id, gpu->subsys_id, gpu->revision_id, gpu_index ); - size = asciiz_to_unicode( ctx->gpuid, buffer ); - if (!(hkey = reg_create_key( enum_key, ctx->gpuid, size - sizeof(WCHAR), 0, NULL ))) return; + size = asciiz_to_unicode( bufferW, ctx->gpuid ); + if (!(hkey = reg_create_key( enum_key, bufferW, size - sizeof(WCHAR), 0, NULL ))) return;
set_reg_value( hkey, classW, REG_SZ, displayW, sizeof(displayW) ); set_reg_value( hkey, class_guidW, REG_SZ, guid_devclass_displayW, @@ -1405,8 +1390,8 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param )
NtClose( hkey );
- link_device( ctx->gpuid, guid_devinterface_display_adapterW ); - link_device( ctx->gpuid, guid_display_device_arrivalW ); + link_device( ctx->gpuid, guid_devinterface_display_adapterA ); + link_device( ctx->gpuid, guid_display_device_arrivalA ); }
static void add_adapter( const struct gdi_adapter *adapter, void *param ) @@ -1465,8 +1450,7 @@ static void add_adapter( const struct gdi_adapter *adapter, void *param ) ctx->adapter_key = reg_create_key( config_key, bufferW, len * sizeof(WCHAR), REG_OPTION_VOLATILE, NULL );
- set_reg_value( ctx->adapter_key, gpu_idW, REG_SZ, ctx->gpuid, - (lstrlenW( ctx->gpuid ) + 1) * sizeof(WCHAR) ); + set_reg_value( ctx->adapter_key, gpu_idW, REG_SZ, bufferW, asciiz_to_unicode( bufferW, ctx->gpuid ) ); set_reg_value( ctx->adapter_key, state_flagsW, REG_DWORD, &adapter->state_flags, sizeof(adapter->state_flags) ); } @@ -1501,7 +1485,7 @@ static void add_monitor( const struct gdi_monitor *monitor, void *param ) 0, NULL ); if (!hkey) return;
- link_device( bufferW, guid_devinterface_monitorW ); + link_device( instance, guid_devinterface_monitorA );
asciiz_to_unicode( bufferW, "Generic Non-PnP Monitor" ); set_reg_value( hkey, device_descW, REG_SZ, bufferW, (lstrlenW( bufferW ) + 1) * sizeof(WCHAR) );
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/sysparams.c | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index d264120909f..e57407b6e79 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -1128,7 +1128,7 @@ struct device_manager_ctx unsigned int mode_count; HANDLE mutex; char gpuid[128]; - WCHAR gpu_guid[64]; + char gpu_guid[39]; LUID gpu_luid; HKEY adapter_key; /* for the virtual desktop settings */ @@ -1178,7 +1178,7 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param ) char buffer[4096]; WCHAR bufferW[512]; KEY_VALUE_PARTIAL_INFORMATION *value = (void *)buffer; - unsigned int gpu_index, size; + unsigned int gpu_index, size, i; HKEY hkey, subkey; LARGE_INTEGER ft; ULONG memory_size; @@ -1290,17 +1290,16 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param ) { GUID guid; uuid_create( &guid ); - sprintf( buffer, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", + sprintf( ctx->gpu_guid, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", (unsigned int)guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7] ); - size = asciiz_to_unicode( ctx->gpu_guid, buffer ); - TRACE( "created guid %s\n", debugstr_w(ctx->gpu_guid) ); - set_reg_value( subkey, video_idW, REG_SZ, ctx->gpu_guid, size ); + TRACE( "created guid %s\n", debugstr_a(ctx->gpu_guid) ); + set_reg_value( subkey, video_idW, REG_SZ, bufferW, asciiz_to_unicode( bufferW, ctx->gpu_guid ) ); } else { - memcpy( ctx->gpu_guid, value->Data, value->DataLength ); - TRACE( "got guid %s\n", debugstr_w(ctx->gpu_guid) ); + for (i = 0; i < sizeof(ctx->gpu_guid); i++) ctx->gpu_guid[i] = value->Data[i]; + TRACE( "got guid %s\n", debugstr_a(ctx->gpu_guid) ); } NtClose( subkey ); } @@ -1415,16 +1414,12 @@ static void add_adapter( const struct gdi_adapter *adapter, void *param ) ctx->monitor_count = 0; ctx->mode_count = 0;
- len = asciiz_to_unicode( bufferW, "\Registry\Machine\System\CurrentControlSet\" - "Control\Video\" ) / sizeof(WCHAR) - 1; - lstrcpyW( bufferW + len, ctx->gpu_guid ); - len += lstrlenW( bufferW + len ); - sprintf( buffer, "\%04x", adapter_index ); - len += asciiz_to_unicode( bufferW + len, buffer ) / sizeof(WCHAR) - 1; - hkey = reg_create_key( NULL, bufferW, len * sizeof(WCHAR), - REG_OPTION_VOLATILE | REG_OPTION_CREATE_LINK, NULL ); - if (!hkey) hkey = reg_create_key( NULL, bufferW, len * sizeof(WCHAR), - REG_OPTION_VOLATILE | REG_OPTION_OPEN_LINK, NULL ); + snprintf( buffer, ARRAY_SIZE(buffer), "\Registry\Machine\System\CurrentControlSet\Control\Video\%s\%04x", + ctx->gpu_guid, adapter_index ); + len = asciiz_to_unicode( bufferW, buffer ) - sizeof(WCHAR); + + hkey = reg_create_key( NULL, bufferW, len, REG_OPTION_VOLATILE | REG_OPTION_CREATE_LINK, NULL ); + if (!hkey) hkey = reg_create_key( NULL, bufferW, len, REG_OPTION_VOLATILE | REG_OPTION_OPEN_LINK, NULL );
sprintf( name, "\Device\Video%u", video_index ); asciiz_to_unicode( nameW, name ); @@ -1441,13 +1436,8 @@ static void add_adapter( const struct gdi_adapter *adapter, void *param ) else ERR( "failed to create link key\n" );
/* Following information is Wine specific, it doesn't really exist on Windows. */ - len = asciiz_to_unicode( bufferW, "System\CurrentControlSet\Control\Video\" ) - / sizeof(WCHAR) - 1; - lstrcpyW( bufferW + len, ctx->gpu_guid ); - len += lstrlenW( bufferW + len ); - sprintf( buffer, "\%04x", adapter_index ); - len += asciiz_to_unicode( bufferW + len, buffer ) / sizeof(WCHAR) - 1; - ctx->adapter_key = reg_create_key( config_key, bufferW, len * sizeof(WCHAR), + snprintf( buffer, ARRAY_SIZE(buffer), "System\CurrentControlSet\Control\Video\%s\%04x", ctx->gpu_guid, adapter_index ); + ctx->adapter_key = reg_create_key( config_key, bufferW, asciiz_to_unicode( bufferW, buffer ) - sizeof(WCHAR), REG_OPTION_VOLATILE, NULL );
set_reg_value( ctx->adapter_key, gpu_idW, REG_SZ, bufferW, asciiz_to_unicode( bufferW, ctx->gpuid ) );
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/sysparams.c | 18 ------------------ 1 file changed, 18 deletions(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index e57407b6e79..bcaa8931873 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -159,14 +159,6 @@ static const WCHAR wine_devpropkey_monitor_rcworkW[] = '\','0','0','0','4' };
-static const WCHAR wine_devpropkey_monitor_adapternameW[] = -{ - 'P','r','o','p','e','r','t','i','e','s','\', - '{','2','3','3','a','9','e','f','3','-','a','f','c','4','-','4','a','b','d', - '-','b','5','6','4','-','c','3','2','f','2','1','f','1','5','3','5','b','}', - '\','0','0','0','5' -}; - static const WCHAR device_instanceW[] = {'D','e','v','i','c','e','I','n','s','t','a','n','c','e',0}; static const WCHAR controlW[] = {'C','o','n','t','r','o','l'}; static const WCHAR device_parametersW[] = @@ -1520,16 +1512,6 @@ static void add_monitor( const struct gdi_monitor *monitor, void *param ) NtClose( subkey ); }
- /* WINE_DEVPROPKEY_MONITOR_ADAPTERNAME */ - if ((subkey = reg_create_key( hkey, wine_devpropkey_monitor_adapternameW, - sizeof(wine_devpropkey_monitor_adapternameW), 0, NULL ))) - { - sprintf( buffer, "\\.\DISPLAY%u", ctx->video_count ); - set_reg_value( subkey, NULL, 0xffff0000 | DEVPROP_TYPE_STRING, bufferW, - asciiz_to_unicode( bufferW, buffer )); - NtClose( subkey ); - } - /* DEVPROPKEY_MONITOR_GPU_LUID */ if ((subkey = reg_create_key( hkey, devpropkey_monitor_gpu_luidW, sizeof(devpropkey_monitor_gpu_luidW), 0, NULL )))
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/sysparams.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index bcaa8931873..42a8d783a2b 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -1342,10 +1342,10 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param )
size = (lstrlenW( desc ) + 1) * sizeof(WCHAR); set_reg_value( hkey, driver_descW, REG_SZ, desc, size ); - set_reg_value( hkey, adapter_stringW, REG_BINARY, desc, size ); - set_reg_value( hkey, bios_stringW, REG_BINARY, desc, size ); - set_reg_value( hkey, chip_typeW, REG_BINARY, desc, size ); - set_reg_value( hkey, dac_typeW, REG_BINARY, ramdacW, sizeof(ramdacW) ); + set_reg_value( hkey, adapter_stringW, REG_SZ, desc, size ); + set_reg_value( hkey, bios_stringW, REG_SZ, desc, size ); + set_reg_value( hkey, chip_typeW, REG_SZ, desc, size ); + set_reg_value( hkey, dac_typeW, REG_SZ, ramdacW, sizeof(ramdacW) );
/* If we failed to retrieve the gpu memory size set a default of 1Gb */ qw_memory_size = gpu->memory_size ? gpu->memory_size : 1073741824;
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/sysparams.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 42a8d783a2b..41f49e28d5f 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -989,10 +989,7 @@ static void prepare_devices(void) continue; }
- size = query_reg_value( device_key, class_guidW, value, sizeof(buffer) ); - if (size == sizeof(guid_devclass_displayW) && - !wcscmp( (const WCHAR *)value->Data, guid_devclass_displayW ) && - (prop_key = reg_create_key( device_key, devpropkey_device_ispresentW, + if ((prop_key = reg_create_key( device_key, devpropkey_device_ispresentW, sizeof(devpropkey_device_ispresentW), 0, NULL ))) { BOOL present = FALSE;
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/sysparams.c | 87 ++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 54 deletions(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 41f49e28d5f..438791a6aa1 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -159,7 +159,6 @@ static const WCHAR wine_devpropkey_monitor_rcworkW[] = '\','0','0','0','4' };
-static const WCHAR device_instanceW[] = {'D','e','v','i','c','e','I','n','s','t','a','n','c','e',0}; static const WCHAR controlW[] = {'C','o','n','t','r','o','l'}; static const WCHAR device_parametersW[] = {'D','e','v','i','c','e',' ','P','a','r','a','m','e','t','e','r','s'}; @@ -167,16 +166,10 @@ static const WCHAR linkedW[] = {'L','i','n','k','e','d',0}; static const WCHAR symbolic_link_valueW[] = {'S','y','m','b','o','l','i','c','L','i','n','k','V','a','l','u','e',0}; static const WCHAR state_flagsW[] = {'S','t','a','t','e','F','l','a','g','s',0}; -static const WCHAR gpu_idW[] = {'G','P','U','I','D',0}; static const WCHAR hardware_idW[] = {'H','a','r','d','w','a','r','e','I','D',0}; static const WCHAR device_descW[] = {'D','e','v','i','c','e','D','e','s','c',0}; static const WCHAR driver_descW[] = {'D','r','i','v','e','r','D','e','s','c',0}; -static const WCHAR driverW[] = {'D','r','i','v','e','r',0}; -static const WCHAR class_guidW[] = {'C','l','a','s','s','G','U','I','D',0}; static const WCHAR pciW[] = {'P','C','I'}; -static const WCHAR classW[] = {'C','l','a','s','s',0}; -static const WCHAR displayW[] = {'D','i','s','p','l','a','y',0}; -static const WCHAR monitorW[] = {'M','o','n','i','t','o','r',0}; static const WCHAR yesW[] = {'Y','e','s',0}; static const WCHAR noW[] = {'N','o',0}; static const WCHAR mode_countW[] = {'M','o','d','e','C','o','u','n','t',0}; @@ -188,9 +181,6 @@ static const WCHAR guid_devclass_displayW[] = 'B','F','C','1','-','0','8','0','0','2','B','E','1','0','3','1','8','}',0};
static const char guid_devclass_monitorA[] = "{4D36E96E-E325-11CE-BFC1-08002BE10318}"; -static const WCHAR guid_devclass_monitorW[] = - {'{','4','D','3','6','E','9','6','E','-','E','3','2','5','-','1','1','C','E','-', - 'B','F','C','1','-','0','8','0','0','2','B','E','1','0','3','1','8','}',0};
static const char guid_devinterface_display_adapterA[] = "{5B45201D-F2F2-4F3B-85BB-30FF1F953599}"; static const char guid_display_device_arrivalA[] = "{1CA05180-A699-450A-9A0C-DE4FBE3DDD89}"; @@ -534,12 +524,10 @@ static BOOL read_adapter_mode( HKEY adapter_key, UINT index, DEVMODEW *mode ) { char value_buf[offsetof(KEY_VALUE_PARTIAL_INFORMATION, Data[sizeof(*mode)])]; KEY_VALUE_PARTIAL_INFORMATION *value = (void *)value_buf; - WCHAR bufferW[MAX_PATH] = {0}; char buffer[MAX_PATH];
sprintf( buffer, "Modes\%08X", index ); - asciiz_to_unicode( bufferW, buffer ); - if (!query_reg_value( adapter_key, bufferW, value, sizeof(value_buf) )) return FALSE; + if (!query_reg_ascii_value( adapter_key, buffer, value, sizeof(value_buf) )) return FALSE;
memcpy( &mode->dmFields, value->Data, sizeof(*mode) - offsetof(DEVMODEW, dmFields) ); return TRUE; @@ -732,7 +720,7 @@ static BOOL read_display_adapter_settings( unsigned int index, struct adapter *i return FALSE;
/* DeviceString */ - if (query_reg_value( hkey, driver_descW, value, sizeof(buffer) ) && value->Type == REG_SZ) + if (query_reg_ascii_value( hkey, "DriverDesc", value, sizeof(buffer) ) && value->Type == REG_SZ) memcpy( info->dev.device_string, value_str, value->DataLength ); NtClose( hkey );
@@ -745,14 +733,14 @@ static BOOL read_display_adapter_settings( unsigned int index, struct adapter *i return FALSE;
/* StateFlags */ - if (query_reg_value( hkey, state_flagsW, value, sizeof(buffer) ) && value->Type == REG_DWORD) + if (query_reg_ascii_value( hkey, "StateFlags", value, sizeof(buffer) ) && value->Type == REG_DWORD) info->dev.state_flags = *(const DWORD *)value->Data;
/* Interface name */ info->dev.interface_name[0] = 0;
/* ModeCount */ - if (query_reg_value( hkey, mode_countW, value, sizeof(buffer) ) && value->Type == REG_DWORD) + if (query_reg_ascii_value( hkey, "ModeCount", value, sizeof(buffer) ) && value->Type == REG_DWORD) info->mode_count = *(const DWORD *)value->Data;
/* Modes, allocate an extra mode for easier iteration */ @@ -770,7 +758,7 @@ static BOOL read_display_adapter_settings( unsigned int index, struct adapter *i }
/* DeviceID */ - size = query_reg_value( hkey, gpu_idW, value, sizeof(buffer) ); + size = query_reg_ascii_value( hkey, "GPUID", value, sizeof(buffer) ); NtClose( hkey ); if (!size || value->Type != REG_SZ || !info->mode_count || !info->modes) return FALSE;
@@ -785,7 +773,7 @@ static BOOL read_display_adapter_settings( unsigned int index, struct adapter *i } memcpy( &info->gpu_luid, value->Data, sizeof(info->gpu_luid) );
- size = query_reg_value( hkey, hardware_idW, value, sizeof(buffer) ); + size = query_reg_ascii_value( hkey, "HardwareID", value, sizeof(buffer) ); NtClose( hkey ); if (!size || (value->Type != REG_SZ && value->Type != REG_MULTI_SZ)) return FALSE; @@ -866,7 +854,7 @@ static BOOL read_monitor_settings( struct adapter *adapter, UINT index, struct m monitor->rc_work = *(const RECT *)value->Data;
/* DeviceString */ - if (!query_reg_value( hkey, device_descW, value, sizeof(buffer) ) || value->Type != REG_SZ) + if (!query_reg_ascii_value( hkey, "DeviceDesc", value, sizeof(buffer) ) || value->Type != REG_SZ) { NtClose( hkey ); return FALSE; @@ -874,7 +862,7 @@ static BOOL read_monitor_settings( struct adapter *adapter, UINT index, struct m memcpy( monitor->dev.device_string, value->Data, value->DataLength );
/* DeviceKey */ - if (!query_reg_value( hkey, driverW, value, sizeof(buffer) ) || value->Type != REG_SZ) + if (!query_reg_ascii_value( hkey, "Driver", value, sizeof(buffer) ) || value->Type != REG_SZ) { NtClose( hkey ); return FALSE; @@ -885,7 +873,7 @@ static BOOL read_monitor_settings( struct adapter *adapter, UINT index, struct m memcpy( device_name, value_str, value->DataLength );
/* DeviceID */ - if (!query_reg_value( hkey, hardware_idW, value, sizeof(buffer) ) || + if (!query_reg_ascii_value( hkey, "HardwareID", value, sizeof(buffer) ) || (value->Type != REG_SZ && value->Type != REG_MULTI_SZ)) { NtClose( hkey ); @@ -899,7 +887,7 @@ static BOOL read_monitor_settings( struct adapter *adapter, UINT index, struct m /* EDID */ if ((subkey = reg_open_key( hkey, device_parametersW, sizeof(device_parametersW) ))) { - if (query_reg_value( subkey, edidW, value, sizeof(buffer) )) + if (query_reg_ascii_value( subkey, "EDID", value, sizeof(buffer) )) get_monitor_info_from_edid( &monitor->edid_info, value->Data, value->DataLength ); NtClose( subkey ); } @@ -956,7 +944,7 @@ static void prepare_devices(void) hkey = reg_create_key( control_key, bufferW, asciiz_to_unicode( bufferW, buffer ) - sizeof(WCHAR), 0, NULL ); reg_empty_key( hkey, NULL ); - set_reg_value( hkey, classW, REG_SZ, monitorW, sizeof(monitorW) ); + set_reg_ascii_value( hkey, "Class", "Monitor" ); NtClose( hkey );
/* delete adapters */ @@ -967,7 +955,7 @@ static void prepare_devices(void) hkey = reg_create_key( control_key, bufferW, asciiz_to_unicode( bufferW, buffer ) - sizeof(WCHAR), 0, NULL ); reg_empty_key( hkey, NULL ); - set_reg_value( hkey, classW, REG_SZ, displayW, sizeof(displayW) ); + set_reg_ascii_value( hkey, "Class", "Display" ); NtClose( hkey );
hkey = reg_open_key( enum_key, pciW, sizeof(pciW) ); @@ -982,7 +970,7 @@ static void prepare_devices(void) while (!NtEnumerateKey( subkey, j++, KeyNodeInformation, key, sizeof(buffer), &size )) { if (!(device_key = reg_open_key( subkey, key->Name, key->NameLength ))) continue; - size = query_reg_value( device_key, class_guidW, value, sizeof(buffer) ); + size = query_reg_ascii_value( device_key, "ClassGUID", value, sizeof(buffer) ); if (size != sizeof(guid_devclass_displayW) || wcscmp( value_str, guid_devclass_displayW )) { NtClose( device_key ); @@ -1033,7 +1021,7 @@ static void cleanup_devices(void) memcpy( bufferW, key->Name, key->NameLength ); bufferW[key->NameLength / sizeof(WCHAR)] = 0;
- size = query_reg_value( device_key, class_guidW, value, sizeof(buffer) ); + size = query_reg_ascii_value( device_key, "ClassGUID", value, sizeof(buffer) ); if (size != sizeof(guid_devclass_displayW) || wcscmp( value_str, guid_devclass_displayW )) { NtClose( device_key ); @@ -1134,7 +1122,6 @@ static void link_device( const char *instance, const char *class ) HKEY hkey, subkey; unsigned int pos;
- static const WCHAR symbolic_linkW[] = {'S','y','m','b','o','l','i','c','L','i','n','k',0}; static const WCHAR hashW[] = {'#'};
pos = snprintf( buffer, ARRAY_SIZE(buffer), "DeviceClasses\%s\", class ); @@ -1142,7 +1129,7 @@ static void link_device( const char *instance, const char *class ) for (ptr = buffer + pos; *ptr; ptr++) if (*ptr == '\') *ptr = '#';
hkey = reg_create_key( control_key, bufferW, asciiz_to_unicode( bufferW, buffer ) - sizeof(WCHAR), 0, NULL ); - set_reg_value( hkey, device_instanceW, REG_SZ, bufferW, asciiz_to_unicode( bufferW, instance ) ); + set_reg_ascii_value( hkey, "DeviceInstance", instance );
subkey = reg_create_key( hkey, hashW, sizeof(hashW), REG_OPTION_VOLATILE, NULL ); NtClose( hkey ); @@ -1150,7 +1137,7 @@ static void link_device( const char *instance, const char *class )
snprintf( buffer, ARRAY_SIZE(buffer), "\\?\%s#%s", instance, class ); for (ptr = buffer + 4; *ptr; ptr++) if (*ptr == '\') *ptr = '#'; - set_reg_value( hkey, symbolic_linkW, REG_SZ, bufferW, asciiz_to_unicode( bufferW, buffer ) ); + set_reg_ascii_value( hkey, "SymbolicLink", buffer );
if ((subkey = reg_create_key( hkey, controlW, sizeof(controlW), REG_OPTION_VOLATILE, NULL ))) { @@ -1175,7 +1162,6 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param )
static const BOOL present = TRUE; static const WCHAR wine_adapterW[] = {'W','i','n','e',' ','A','d','a','p','t','e','r',0}; - static const WCHAR video_idW[] = {'V','i','d','e','o','I','D',0}; static const WCHAR driver_date_dataW[] = {'D','r','i','v','e','r','D','a','t','e','D','a','t','a',0}; static const WCHAR adapter_stringW[] = @@ -1199,8 +1185,6 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param ) static const WCHAR ramdacW[] = {'I','n','t','e','r','g','r','a','t','e','d',' ','R','A','M','D','A','C',0}; static const WCHAR driver_dateW[] = {'D','r','i','v','e','r','D','a','t','e',0}; - static const WCHAR driver_versionW[] = - {'D','r','i','v','e','r','V','e','r','s','i','o','n',0};
TRACE( "%s %04X %04X %08X %02X\n", debugstr_w(gpu->name), gpu->vendor_id, gpu->device_id, gpu->subsys_id, gpu->revision_id ); @@ -1225,11 +1209,10 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param ) size = asciiz_to_unicode( bufferW, ctx->gpuid ); if (!(hkey = reg_create_key( enum_key, bufferW, size - sizeof(WCHAR), 0, NULL ))) return;
- set_reg_value( hkey, classW, REG_SZ, displayW, sizeof(displayW) ); - set_reg_value( hkey, class_guidW, REG_SZ, guid_devclass_displayW, - sizeof(guid_devclass_displayW) ); + set_reg_ascii_value( hkey, "Class", "Display" ); + set_reg_ascii_value( hkey, "ClassGUID", guid_devclass_displayA ); sprintf( buffer, "%s\%04X", guid_devclass_displayA, gpu_index ); - set_reg_value( hkey, driverW, REG_SZ, bufferW, asciiz_to_unicode( bufferW, buffer )); + set_reg_ascii_value( hkey, "Driver", buffer );
sprintf( buffer, "PCI\VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%02X", gpu->vendor_id, gpu->device_id, gpu->subsys_id, gpu->revision_id ); @@ -1275,7 +1258,7 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param )
if ((subkey = reg_create_key( hkey, device_parametersW, sizeof(device_parametersW), 0, NULL ))) { - if (!query_reg_value( subkey, video_idW, value, sizeof(buffer) )) + if (!query_reg_ascii_value( subkey, "VideoID", value, sizeof(buffer) )) { GUID guid; uuid_create( &guid ); @@ -1283,7 +1266,7 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param ) (unsigned int)guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7] ); TRACE( "created guid %s\n", debugstr_a(ctx->gpu_guid) ); - set_reg_value( subkey, video_idW, REG_SZ, bufferW, asciiz_to_unicode( bufferW, ctx->gpu_guid ) ); + set_reg_ascii_value( subkey, "VideoID", ctx->gpu_guid ); } else { @@ -1373,7 +1356,7 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param ) sprintf( buffer, "31.0.10.1000" ); break; } - set_reg_value( hkey, driver_versionW, REG_SZ, bufferW, asciiz_to_unicode( bufferW, buffer ) ); + set_reg_ascii_value( hkey, "DriverVersion", buffer ); }
NtClose( hkey ); @@ -1387,7 +1370,7 @@ static void add_adapter( const struct gdi_adapter *adapter, void *param ) struct device_manager_ctx *ctx = param; unsigned int adapter_index, video_index, len; char name[64], buffer[MAX_PATH]; - WCHAR nameW[64], bufferW[MAX_PATH]; + WCHAR bufferW[MAX_PATH]; HKEY hkey;
TRACE( "\n" ); @@ -1411,8 +1394,7 @@ static void add_adapter( const struct gdi_adapter *adapter, void *param ) if (!hkey) hkey = reg_create_key( NULL, bufferW, len, REG_OPTION_VOLATILE | REG_OPTION_OPEN_LINK, NULL );
sprintf( name, "\Device\Video%u", video_index ); - asciiz_to_unicode( nameW, name ); - set_reg_value( video_key, nameW, REG_SZ, bufferW, (lstrlenW( bufferW ) + 1) * sizeof(WCHAR) ); + set_reg_ascii_value( video_key, name, buffer );
if (hkey) { @@ -1429,7 +1411,7 @@ static void add_adapter( const struct gdi_adapter *adapter, void *param ) ctx->adapter_key = reg_create_key( config_key, bufferW, asciiz_to_unicode( bufferW, buffer ) - sizeof(WCHAR), REG_OPTION_VOLATILE, NULL );
- set_reg_value( ctx->adapter_key, gpu_idW, REG_SZ, bufferW, asciiz_to_unicode( bufferW, ctx->gpuid ) ); + set_reg_ascii_value( ctx->adapter_key, "GPUID", ctx->gpuid ); set_reg_value( ctx->adapter_key, state_flagsW, REG_DWORD, &adapter->state_flags, sizeof(adapter->state_flags) ); } @@ -1466,13 +1448,12 @@ static void add_monitor( const struct gdi_monitor *monitor, void *param )
link_device( instance, guid_devinterface_monitorA );
- asciiz_to_unicode( bufferW, "Generic Non-PnP Monitor" ); - set_reg_value( hkey, device_descW, REG_SZ, bufferW, (lstrlenW( bufferW ) + 1) * sizeof(WCHAR) ); + set_reg_ascii_value( hkey, "DeviceDesc", "Generic Non-PnP Monitor" );
- set_reg_value( hkey, classW, REG_SZ, monitorW, sizeof(monitorW) ); + set_reg_ascii_value( hkey, "Class", "Monitor" ); sprintf( buffer, "%s\%04X", guid_devclass_monitorA, output_index ); set_reg_ascii_value( hkey, "Driver", buffer ); - set_reg_value( hkey, class_guidW, REG_SZ, guid_devclass_monitorW, sizeof(guid_devclass_monitorW) ); + set_reg_ascii_value( hkey, "ClassGUID", guid_devclass_monitorA );
sprintf( buffer, "MONITOR\%s", monitor_id_string ); len = asciiz_to_unicode( bufferW, buffer ); @@ -1732,7 +1713,7 @@ static BOOL update_display_cache_from_registry(void) if (!(gpu_key = reg_open_key( device_key, key2->Name, key2->NameLength ))) continue;
- size = query_reg_value( gpu_key, class_guidW, value, sizeof(buffer) ); + size = query_reg_ascii_value( gpu_key, "ClassGUID", value, sizeof(buffer) ); if (size != sizeof(guid_devclass_displayW) || wcscmp( (WCHAR *)value->Data, guid_devclass_displayW )) { @@ -1862,7 +1843,6 @@ static BOOL parse_size( const WCHAR *size, unsigned int *width, unsigned int *he /* retrieve the default desktop size from the registry */ static BOOL get_default_desktop_size( unsigned int *width, unsigned int *height ) { - static const WCHAR defaultW[] = {'D','e','f','a','u','l','t',0}; WCHAR buffer[4096]; KEY_VALUE_PARTIAL_INFORMATION *value = (void *)buffer; DWORD size; @@ -1871,7 +1851,7 @@ static BOOL get_default_desktop_size( unsigned int *width, unsigned int *height /* @@ Wine registry key: HKCU\Software\Wine\Explorer\Desktops */ if (!(hkey = reg_open_hkcu_key( "Software\Wine\Explorer\Desktops" ))) return FALSE;
- size = query_reg_value( hkey, defaultW, value, sizeof(buffer) ); + size = query_reg_ascii_value( hkey, "Default", value, sizeof(buffer) ); NtClose( hkey ); if (!size || value->Type != REG_SZ) return FALSE;
@@ -4652,7 +4632,7 @@ static DWORD get_config_key( HKEY defkey, HKEY appkey, const char *name,
asciiz_to_unicode( nameW, name );
- if (appkey && query_reg_value( appkey, nameW, info, sizeof(buf) )) + if (appkey && query_reg_ascii_value( appkey, "Name", info, sizeof(buf) )) { size = min( info->DataLength, size - sizeof(WCHAR) ); memcpy( buffer, info->Data, size ); @@ -4660,7 +4640,7 @@ static DWORD get_config_key( HKEY defkey, HKEY appkey, const char *name, return 0; }
- if (defkey && query_reg_value( defkey, nameW, info, sizeof(buf) )) + if (defkey && query_reg_ascii_value( defkey, "Name", info, sizeof(buf) )) { size = min( info->DataLength, size - sizeof(WCHAR) ); memcpy( buffer, info->Data, size ); @@ -4722,7 +4702,6 @@ void sysparams_init(void) get_dword_entry( (union sysparam_all_entry *)&entry_LOGPIXELS, 0, &system_dpi, 0 ); if (!system_dpi) /* check fallback key */ { - static const WCHAR log_pixelsW[] = {'L','o','g','P','i','x','e','l','s',0}; static const WCHAR software_fontsW[] = {'S','o','f','t','w','a','r','e','\','F','o','n','t','s'};
@@ -4731,7 +4710,7 @@ void sysparams_init(void) char buffer[offsetof(KEY_VALUE_PARTIAL_INFORMATION, Data[sizeof(DWORD)])]; KEY_VALUE_PARTIAL_INFORMATION *value = (void *)buffer;
- if (query_reg_value( hkey, log_pixelsW, value, sizeof(buffer) ) && value->Type == REG_DWORD) + if (query_reg_ascii_value( hkey, "LogPixels", value, sizeof(buffer) ) && value->Type == REG_DWORD) system_dpi = *(const DWORD *)value->Data; NtClose( hkey ); }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/font.c | 17 +- dlls/win32u/sysparams.c | 292 ++++++++--------------------------- dlls/win32u/win32u_private.h | 3 + 3 files changed, 86 insertions(+), 226 deletions(-)
diff --git a/dlls/win32u/font.c b/dlls/win32u/font.c index 9ee89f1b5c4..26518d285d9 100644 --- a/dlls/win32u/font.c +++ b/dlls/win32u/font.c @@ -516,6 +516,12 @@ HKEY reg_open_key( HKEY root, const WCHAR *name, ULONG name_len ) return ret; }
+HKEY reg_open_ascii_key( HKEY root, const char *name ) +{ + WCHAR nameW[MAX_PATH]; + return reg_open_key( root, nameW, asciiz_to_unicode( nameW, name ) - sizeof(WCHAR) ); +} + /* wrapper for NtCreateKey that creates the key recursively if necessary */ HKEY reg_create_key( HKEY root, const WCHAR *name, ULONG name_len, DWORD options, DWORD *disposition ) @@ -565,10 +571,17 @@ HKEY reg_create_key( HKEY root, const WCHAR *name, ULONG name_len, return ret; }
+HKEY reg_create_ascii_key( HKEY root, const char *name, DWORD options, + DWORD *disposition ) +{ + WCHAR nameW[MAX_PATH]; + return reg_create_key( root, nameW, asciiz_to_unicode( nameW, name ) - sizeof(WCHAR), + options, disposition ); +} + HKEY reg_open_hkcu_key( const char *name ) { - WCHAR nameW[128]; - return reg_open_key( hkcu_key, nameW, asciiz_to_unicode( nameW, name ) - sizeof(WCHAR) ); + return reg_open_ascii_key( hkcu_key, name ); }
BOOL set_reg_value( HKEY hkey, const WCHAR *name, UINT type, const void *value, DWORD count ) diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 438791a6aa1..206c337264b 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -42,126 +42,22 @@ WINE_DEFAULT_DEBUG_CHANNEL(system);
static HKEY video_key, enum_key, control_key, config_key, volatile_base_key;
-static const WCHAR devicemap_video_keyW[] = -{ - '\','R','e','g','i','s','t','r','y', - '\','M','a','c','h','i','n','e', - '\','H','A','R','D','W','A','R','E', - '\','D','E','V','I','C','E','M','A','P', - '\','V','I','D','E','O' -}; +static const char devicemap_video_keyA[] = "\Registry\Machine\HARDWARE\DEVICEMAP\VIDEO"; +static const char enum_keyA[] = "\Registry\Machine\System\CurrentControlSet\Enum"; +static const char control_keyA[] = "\Registry\Machine\System\CurrentControlSet\Control"; +static const char config_keyA[] = "\Registry\Machine\System\CurrentControlSet\Hardware Profiles\Current"; + +static const char devpropkey_gpu_vulkan_uuidA[] = "Properties\{233A9EF3-AFC4-4ABD-B564-C32F21F1535C}\0002"; +static const char devpropkey_gpu_luidA[] = "Properties\{60B193CB-5276-4D0F-96FC-F173ABAD3EC6}\0002"; +static const char devpkey_device_matching_device_id[] = "Properties\{A8B865DD-2E3D-4094-AD97-E593A70C75D6}\0008"; +static const char devpkey_device_bus_number[] = "Properties\{A45C254E-DF1C-4EFD-8020-67D146A850E0}\0017"; +static const char devpkey_device_removal_policy[] = "Properties\{A45C254E-DF1C-4EFD-8020-67D146A850E0}\0021"; +static const char devpropkey_device_ispresentA[] = "Properties\{540B947E-8B40-45BC-A8A2-6A0B894CBDA2}\0005"; +static const char devpropkey_monitor_gpu_luidA[] = "Properties\{CA085853-16CE-48AA-B114-DE9C72334223}\0001"; +static const char devpropkey_monitor_output_idA[] = "Properties\{CA085853-16CE-48AA-B114-DE9C72334223}\0002"; +static const char wine_devpropkey_monitor_rcmonitorA[] = "Properties\{233a9ef3-afc4-4abd-b564-c32f21f1535b}\0003"; +static const char wine_devpropkey_monitor_rcworkA[] = "Properties\{233a9ef3-afc4-4abd-b564-c32f21f1535b}\0004";
-static const WCHAR enum_keyW[] = -{ - '\','R','e','g','i','s','t','r','y', - '\','M','a','c','h','i','n','e', - '\','S','y','s','t','e','m', - '\','C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t', - '\','E','n','u','m' -}; - -static const WCHAR control_keyW[] = -{ - '\','R','e','g','i','s','t','r','y', - '\','M','a','c','h','i','n','e', - '\','S','y','s','t','e','m', - '\','C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t', - '\','C','o','n','t','r','o','l' -}; - -static const WCHAR config_keyW[] = -{ - '\','R','e','g','i','s','t','r','y', - '\','M','a','c','h','i','n','e', - '\','S','y','s','t','e','m', - '\','C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t', - '\','H','a','r','d','w','a','r','e',' ','P','r','o','f','i','l','e','s', - '\','C','u','r','r','e','n','t' -}; - -static const WCHAR devpropkey_gpu_vulkan_uuidW[] = -{ - 'P','r','o','p','e','r','t','i','e','s', - '\','{','2','3','3','A','9','E','F','3','-','A','F','C','4','-','4','A','B','D', - '-','B','5','6','4','-','C','3','2','F','2','1','F','1','5','3','5','C','}', - '\','0','0','0','2' -}; - -static const WCHAR devpropkey_gpu_luidW[] = -{ - 'P','r','o','p','e','r','t','i','e','s', - '\','{','6','0','B','1','9','3','C','B','-','5','2','7','6','-','4','D','0','F', - '-','9','6','F','C','-','F','1','7','3','A','B','A','D','3','E','C','6','}', - '\','0','0','0','2' -}; - -static const WCHAR devpkey_device_matching_device_id[] = -{ - 'P','r','o','p','e','r','t','i','e','s', - '\','{','A','8','B','8','6','5','D','D','-','2','E','3','D','-','4','0','9','4', - '-','A','D','9','7','-','E','5','9','3','A','7','0','C','7','5','D','6','}', - '\','0','0','0','8' -}; - -static const WCHAR devpkey_device_bus_number[] = -{ - 'P','r','o','p','e','r','t','i','e','s', - '\','{','A','4','5','C','2','5','4','E','-','D','F','1','C','-','4','E','F','D', - '-','8','0','2','0','-','6','7','D','1','4','6','A','8','5','0','E','0','}', - '\','0','0','1','7' -}; - -static const WCHAR devpkey_device_removal_policy[] = -{ - 'P','r','o','p','e','r','t','i','e','s', - '\','{','A','4','5','C','2','5','4','E','-','D','F','1','C','-','4','E','F','D', - '-','8','0','2','0','-','6','7','D','1','4','6','A','8','5','0','E','0','}', - '\','0','0','2','1' -}; - -static const WCHAR devpropkey_device_ispresentW[] = -{ - 'P','r','o','p','e','r','t','i','e','s', - '\','{','5','4','0','B','9','4','7','E','-','8','B','4','0','-','4','5','B','C', - '-','A','8','A','2','-','6','A','0','B','8','9','4','C','B','D','A','2','}', - '\','0','0','0','5' -}; - -static const WCHAR devpropkey_monitor_gpu_luidW[] = -{ - 'P','r','o','p','e','r','t','i','e','s', - '\','{','C','A','0','8','5','8','5','3','-','1','6','C','E','-','4','8','A','A', - '-','B','1','1','4','-','D','E','9','C','7','2','3','3','4','2','2','3','}', - '\','0','0','0','1' -}; - -static const WCHAR devpropkey_monitor_output_idW[] = -{ - 'P','r','o','p','e','r','t','i','e','s', - '\','{','C','A','0','8','5','8','5','3','-','1','6','C','E','-','4','8','A','A', - '-','B','1','1','4','-','D','E','9','C','7','2','3','3','4','2','2','3','}', - '\','0','0','0','2' -}; - -static const WCHAR wine_devpropkey_monitor_rcmonitorW[] = -{ - 'P','r','o','p','e','r','t','i','e','s','\', - '{','2','3','3','a','9','e','f','3','-','a','f','c','4','-','4','a','b','d', - '-','b','5','6','4','-','c','3','2','f','2','1','f','1','5','3','5','b','}', - '\','0','0','0','3' -}; - -static const WCHAR wine_devpropkey_monitor_rcworkW[] = -{ - 'P','r','o','p','e','r','t','i','e','s','\', - '{','2','3','3','a','9','e','f','3','-','a','f','c','4','-','4','a','b','d', - '-','b','5','6','4','-','c','3','2','f','2','1','f','1','5','3','5','b','}', - '\','0','0','0','4' -}; - -static const WCHAR controlW[] = {'C','o','n','t','r','o','l'}; -static const WCHAR device_parametersW[] = - {'D','e','v','i','c','e',' ','P','a','r','a','m','e','t','e','r','s'}; static const WCHAR linkedW[] = {'L','i','n','k','e','d',0}; static const WCHAR symbolic_link_valueW[] = {'S','y','m','b','o','l','i','c','L','i','n','k','V','a','l','u','e',0}; @@ -169,17 +65,14 @@ static const WCHAR state_flagsW[] = {'S','t','a','t','e','F','l','a','g','s',0}; static const WCHAR hardware_idW[] = {'H','a','r','d','w','a','r','e','I','D',0}; static const WCHAR device_descW[] = {'D','e','v','i','c','e','D','e','s','c',0}; static const WCHAR driver_descW[] = {'D','r','i','v','e','r','D','e','s','c',0}; -static const WCHAR pciW[] = {'P','C','I'}; static const WCHAR yesW[] = {'Y','e','s',0}; static const WCHAR noW[] = {'N','o',0}; static const WCHAR mode_countW[] = {'M','o','d','e','C','o','u','n','t',0}; -static const WCHAR edidW[] = {'E','D','I','D',0};
static const char guid_devclass_displayA[] = "{4D36E968-E325-11CE-BFC1-08002BE10318}"; static const WCHAR guid_devclass_displayW[] = {'{','4','D','3','6','E','9','6','8','-','E','3','2','5','-','1','1','C','E','-', 'B','F','C','1','-','0','8','0','0','2','B','E','1','0','3','1','8','}',0}; - static const char guid_devclass_monitorA[] = "{4D36E96E-E325-11CE-BFC1-08002BE10318}";
static const char guid_devinterface_display_adapterA[] = "{5B45201D-F2F2-4F3B-85BB-30FF1F953599}"; @@ -682,12 +575,11 @@ static int mode_compare(const void *p1, const void *p2) return 0; }
-static unsigned int query_reg_subkey_value( HKEY hkey, const WCHAR *name, unsigned int name_size, - KEY_VALUE_PARTIAL_INFORMATION *value, unsigned int size ) +static unsigned int query_reg_subkey_value( HKEY hkey, const char *name, KEY_VALUE_PARTIAL_INFORMATION *value, unsigned int size ) { HKEY subkey;
- if (!(subkey = reg_open_key( hkey, name, name_size ))) return 0; + if (!(subkey = reg_open_ascii_key( hkey, name ))) return 0; size = query_reg_value( subkey, NULL, value, size ); NtClose( subkey ); return size; @@ -702,7 +594,7 @@ static BOOL read_display_adapter_settings( unsigned int index, struct adapter *i DWORD i, size; HKEY hkey;
- if (!enum_key && !(enum_key = reg_open_key( NULL, enum_keyW, sizeof(enum_keyW) ))) + if (!enum_key && !(enum_key = reg_open_ascii_key( NULL, enum_keyA ))) return FALSE;
/* Find adapter */ @@ -765,7 +657,7 @@ static BOOL read_display_adapter_settings( unsigned int index, struct adapter *i if (!(hkey = reg_open_key( enum_key, value_str, value->DataLength - sizeof(WCHAR) ))) return FALSE;
- size = query_reg_subkey_value( hkey, devpropkey_gpu_luidW, sizeof(devpropkey_gpu_luidW), value, sizeof(buffer) ); + size = query_reg_subkey_value( hkey, devpropkey_gpu_luidA, value, sizeof(buffer) ); if (size != sizeof(info->gpu_luid)) { NtClose( hkey ); @@ -821,8 +713,7 @@ static BOOL read_monitor_settings( struct adapter *adapter, UINT index, struct m return FALSE;
/* Output ID */ - size = query_reg_subkey_value( hkey, devpropkey_monitor_output_idW, - sizeof(devpropkey_monitor_output_idW), + size = query_reg_subkey_value( hkey, devpropkey_monitor_output_idA, value, sizeof(buffer) ); if (size != sizeof(monitor->output_id)) { @@ -832,8 +723,7 @@ static BOOL read_monitor_settings( struct adapter *adapter, UINT index, struct m monitor->output_id = *(const unsigned int *)value->Data;
/* rc_monitor, WINE_DEVPROPKEY_MONITOR_RCMONITOR */ - size = query_reg_subkey_value( hkey, wine_devpropkey_monitor_rcmonitorW, - sizeof(wine_devpropkey_monitor_rcmonitorW), + size = query_reg_subkey_value( hkey, wine_devpropkey_monitor_rcmonitorA, value, sizeof(buffer) ); if (size != sizeof(monitor->rc_monitor)) { @@ -843,8 +733,7 @@ static BOOL read_monitor_settings( struct adapter *adapter, UINT index, struct m monitor->rc_monitor = *(const RECT *)value->Data;
/* rc_work, WINE_DEVPROPKEY_MONITOR_RCWORK */ - size = query_reg_subkey_value( hkey, wine_devpropkey_monitor_rcworkW, - sizeof(wine_devpropkey_monitor_rcworkW), + size = query_reg_subkey_value( hkey, wine_devpropkey_monitor_rcworkA, value, sizeof(buffer) ); if (size != sizeof(monitor->rc_work)) { @@ -885,7 +774,7 @@ static BOOL read_monitor_settings( struct adapter *adapter, UINT index, struct m lstrcpyW( monitor->dev.device_id + size, device_name );
/* EDID */ - if ((subkey = reg_open_key( hkey, device_parametersW, sizeof(device_parametersW) ))) + if ((subkey = reg_open_ascii_key( hkey, "Device Parameters" ))) { if (query_reg_ascii_value( subkey, "EDID", value, sizeof(buffer) )) get_monitor_info_from_edid( &monitor->edid_info, value->Data, value->DataLength ); @@ -901,14 +790,8 @@ static void reg_empty_key( HKEY root, const char *key_name ) char buffer[4096]; KEY_NODE_INFORMATION *key = (KEY_NODE_INFORMATION *)buffer; KEY_VALUE_FULL_INFORMATION *value = (KEY_VALUE_FULL_INFORMATION *)buffer; - WCHAR bufferW[512]; DWORD size; - HKEY hkey; - - if (key_name) - hkey = reg_open_key( root, bufferW, asciiz_to_unicode( bufferW, key_name ) - sizeof(WCHAR) ); - else - hkey = root; + HKEY hkey = key_name ? reg_open_ascii_key( root, key_name ) : root;
while (!NtEnumerateKey( hkey, 0, KeyNodeInformation, key, sizeof(buffer), &size )) reg_delete_tree( hkey, key->Name, key->NameLength ); @@ -928,21 +811,18 @@ static void prepare_devices(void) KEY_NODE_INFORMATION *key = (void *)buffer; KEY_VALUE_PARTIAL_INFORMATION *value = (void *)buffer; WCHAR *value_str = (WCHAR *)value->Data; - WCHAR bufferW[128]; unsigned i = 0; DWORD size; HKEY hkey, subkey, device_key, prop_key;
- if (!enum_key) enum_key = reg_create_key( NULL, enum_keyW, sizeof(enum_keyW), 0, NULL ); - if (!control_key) control_key = reg_create_key( NULL, control_keyW, sizeof(control_keyW), 0, NULL ); - if (!video_key) video_key = reg_create_key( NULL, devicemap_video_keyW, sizeof(devicemap_video_keyW), - REG_OPTION_VOLATILE, NULL ); + if (!enum_key) enum_key = reg_create_ascii_key( NULL, enum_keyA, 0, NULL ); + if (!control_key) control_key = reg_create_ascii_key( NULL, control_keyA, 0, NULL ); + if (!video_key) video_key = reg_create_ascii_key( NULL, devicemap_video_keyA, REG_OPTION_VOLATILE, NULL );
/* delete monitors */ reg_empty_key( enum_key, "DISPLAY" ); sprintf( buffer, "Class\%s", guid_devclass_monitorA ); - hkey = reg_create_key( control_key, bufferW, asciiz_to_unicode( bufferW, buffer ) - sizeof(WCHAR), - 0, NULL ); + hkey = reg_create_ascii_key( control_key, buffer, 0, NULL ); reg_empty_key( hkey, NULL ); set_reg_ascii_value( hkey, "Class", "Monitor" ); NtClose( hkey ); @@ -952,13 +832,12 @@ static void prepare_devices(void)
/* clean GPUs */ sprintf( buffer, "Class\%s", guid_devclass_displayA ); - hkey = reg_create_key( control_key, bufferW, asciiz_to_unicode( bufferW, buffer ) - sizeof(WCHAR), - 0, NULL ); + hkey = reg_create_ascii_key( control_key, buffer, 0, NULL ); reg_empty_key( hkey, NULL ); set_reg_ascii_value( hkey, "Class", "Display" ); NtClose( hkey );
- hkey = reg_open_key( enum_key, pciW, sizeof(pciW) ); + hkey = reg_open_ascii_key( enum_key, "PCI" );
/* To preserve GPU GUIDs, mark them as not present and delete them in cleanup_devices if needed. */ while (!NtEnumerateKey( hkey, i++, KeyNodeInformation, key, sizeof(buffer), &size )) @@ -977,8 +856,7 @@ static void prepare_devices(void) continue; }
- if ((prop_key = reg_create_key( device_key, devpropkey_device_ispresentW, - sizeof(devpropkey_device_ispresentW), 0, NULL ))) + if ((prop_key = reg_create_ascii_key( device_key, devpropkey_device_ispresentA, 0, NULL ))) { BOOL present = FALSE; set_reg_value( prop_key, NULL, 0xffff0000 | DEVPROP_TYPE_BOOLEAN, @@ -1005,7 +883,7 @@ static void cleanup_devices(void) DWORD size; HKEY hkey, subkey, device_key, prop_key;
- hkey = reg_open_key( enum_key, pciW, sizeof(pciW) ); + hkey = reg_open_ascii_key( enum_key, "PCI" );
while (!NtEnumerateKey( hkey, i++, KeyNodeInformation, key, sizeof(buffer), &size )) { @@ -1028,8 +906,7 @@ static void cleanup_devices(void) continue; }
- if ((prop_key = reg_open_key( device_key, devpropkey_device_ispresentW, - sizeof(devpropkey_device_ispresentW) ))) + if ((prop_key = reg_open_ascii_key( device_key, devpropkey_device_ispresentA ))) { if (query_reg_value( prop_key, NULL, value, sizeof(buffer) ) == sizeof(BOOL)) present = *(const BOOL *)value->Data; @@ -1118,20 +995,17 @@ struct device_manager_ctx static void link_device( const char *instance, const char *class ) { char buffer[MAX_PATH], *ptr; - WCHAR bufferW[MAX_PATH]; HKEY hkey, subkey; unsigned int pos;
- static const WCHAR hashW[] = {'#'}; - pos = snprintf( buffer, ARRAY_SIZE(buffer), "DeviceClasses\%s\", class ); snprintf( buffer + pos, ARRAY_SIZE(buffer) - pos, "##?#%s#%s", instance, class ); for (ptr = buffer + pos; *ptr; ptr++) if (*ptr == '\') *ptr = '#';
- hkey = reg_create_key( control_key, bufferW, asciiz_to_unicode( bufferW, buffer ) - sizeof(WCHAR), 0, NULL ); + hkey = reg_create_ascii_key( control_key, buffer, 0, NULL ); set_reg_ascii_value( hkey, "DeviceInstance", instance );
- subkey = reg_create_key( hkey, hashW, sizeof(hashW), REG_OPTION_VOLATILE, NULL ); + subkey = reg_create_ascii_key( hkey, "#", REG_OPTION_VOLATILE, NULL ); NtClose( hkey ); hkey = subkey;
@@ -1139,7 +1013,7 @@ static void link_device( const char *instance, const char *class ) for (ptr = buffer + 4; *ptr; ptr++) if (*ptr == '\') *ptr = '#'; set_reg_ascii_value( hkey, "SymbolicLink", buffer );
- if ((subkey = reg_create_key( hkey, controlW, sizeof(controlW), REG_OPTION_VOLATILE, NULL ))) + if ((subkey = reg_create_ascii_key( hkey, "Control", REG_OPTION_VOLATILE, NULL ))) { const DWORD linked = 1; set_reg_value( subkey, linkedW, REG_DWORD, &linked, sizeof(linked) ); @@ -1194,7 +1068,7 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param ) ctx->monitor_count = 0; ctx->mode_count = 0;
- if (!enum_key && !(enum_key = reg_create_key( NULL, enum_keyW, sizeof(enum_keyW), 0, NULL ))) + if (!enum_key && !(enum_key = reg_create_ascii_key( NULL, enum_keyA, 0, NULL ))) return;
if (!ctx->mutex) @@ -1207,7 +1081,7 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param ) sprintf( ctx->gpuid, "PCI\VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%02X\%08X", gpu->vendor_id, gpu->device_id, gpu->subsys_id, gpu->revision_id, gpu_index ); size = asciiz_to_unicode( bufferW, ctx->gpuid ); - if (!(hkey = reg_create_key( enum_key, bufferW, size - sizeof(WCHAR), 0, NULL ))) return; + if (!(hkey = reg_create_ascii_key( enum_key, ctx->gpuid, 0, NULL ))) return;
set_reg_ascii_value( hkey, "Class", "Display" ); set_reg_ascii_value( hkey, "ClassGUID", guid_devclass_displayA ); @@ -1220,8 +1094,7 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param ) bufferW[size / sizeof(WCHAR)] = 0; /* for REG_MULTI_SZ */ set_reg_value( hkey, hardware_idW, REG_MULTI_SZ, bufferW, size + sizeof(WCHAR) );
- if ((subkey = reg_create_key( hkey, devpkey_device_matching_device_id, - sizeof(devpkey_device_matching_device_id), 0, NULL ))) + if ((subkey = reg_create_ascii_key( hkey, devpkey_device_matching_device_id, 0, NULL ))) { if (gpu->vendor_id && gpu->device_id) set_reg_value( subkey, NULL, 0xffff0000 | DEVPROP_TYPE_STRING, bufferW, size ); @@ -1233,8 +1106,7 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param )
if (gpu->vendor_id && gpu->device_id) { - if ((subkey = reg_create_key( hkey, devpkey_device_bus_number, - sizeof(devpkey_device_bus_number), 0, NULL ))) + if ((subkey = reg_create_ascii_key( hkey, devpkey_device_bus_number, 0, NULL ))) { set_reg_value( subkey, NULL, 0xffff0000 | DEVPROP_TYPE_UINT32, &gpu_index, sizeof(gpu_index) ); @@ -1242,8 +1114,7 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param ) } }
- if ((subkey = reg_create_key( hkey, devpkey_device_removal_policy, - sizeof(devpkey_device_removal_policy), 0, NULL ))) + if ((subkey = reg_create_ascii_key( hkey, devpkey_device_removal_policy, 0, NULL ))) { unsigned int removal_policy = CM_REMOVAL_POLICY_EXPECT_NO_REMOVAL;
@@ -1256,7 +1127,7 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param ) if (!desc[0]) desc = wine_adapterW; set_reg_value( hkey, device_descW, REG_SZ, desc, (lstrlenW( desc ) + 1) * sizeof(WCHAR) );
- if ((subkey = reg_create_key( hkey, device_parametersW, sizeof(device_parametersW), 0, NULL ))) + if ((subkey = reg_create_ascii_key( hkey, "Device Parameters", 0, NULL ))) { if (!query_reg_ascii_value( subkey, "VideoID", value, sizeof(buffer) )) { @@ -1276,23 +1147,21 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param ) NtClose( subkey ); }
- if ((subkey = reg_create_key( hkey, devpropkey_gpu_vulkan_uuidW, - sizeof(devpropkey_gpu_vulkan_uuidW), 0, NULL ))) + if ((subkey = reg_create_ascii_key( hkey, devpropkey_gpu_vulkan_uuidA, 0, NULL ))) { set_reg_value( subkey, NULL, 0xffff0000 | DEVPROP_TYPE_GUID, &gpu->vulkan_uuid, sizeof(gpu->vulkan_uuid) ); NtClose( subkey ); }
- if ((subkey = reg_create_key( hkey, devpropkey_device_ispresentW, - sizeof(devpropkey_device_ispresentW), 0, NULL ))) + if ((subkey = reg_create_ascii_key( hkey, devpropkey_device_ispresentA, 0, NULL ))) { set_reg_value( subkey, NULL, 0xffff0000 | DEVPROP_TYPE_BOOLEAN, &present, sizeof(present) ); NtClose( subkey ); }
- if ((subkey = reg_create_key( hkey, devpropkey_gpu_luidW, sizeof(devpropkey_gpu_luidW), 0, NULL ))) + if ((subkey = reg_create_ascii_key( hkey, devpropkey_gpu_luidA, 0, NULL ))) { if (query_reg_value( subkey, NULL, value, sizeof(buffer) ) != sizeof(LUID)) { @@ -1312,8 +1181,7 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param ) NtClose( hkey );
sprintf( buffer, "Class\%s\%04X", guid_devclass_displayA, gpu_index ); - hkey = reg_create_key( control_key, bufferW, - asciiz_to_unicode( bufferW, buffer ) - sizeof(WCHAR), 0, NULL ); + hkey = reg_create_ascii_key( control_key, buffer, 0, NULL );
NtQuerySystemTime( &ft ); set_reg_value( hkey, driver_dateW, REG_SZ, bufferW, format_date( bufferW, ft.QuadPart )); @@ -1390,8 +1258,8 @@ static void add_adapter( const struct gdi_adapter *adapter, void *param ) ctx->gpu_guid, adapter_index ); len = asciiz_to_unicode( bufferW, buffer ) - sizeof(WCHAR);
- hkey = reg_create_key( NULL, bufferW, len, REG_OPTION_VOLATILE | REG_OPTION_CREATE_LINK, NULL ); - if (!hkey) hkey = reg_create_key( NULL, bufferW, len, REG_OPTION_VOLATILE | REG_OPTION_OPEN_LINK, NULL ); + hkey = reg_create_ascii_key( NULL, buffer, REG_OPTION_VOLATILE | REG_OPTION_CREATE_LINK, NULL ); + if (!hkey) hkey = reg_create_ascii_key( NULL, buffer, REG_OPTION_VOLATILE | REG_OPTION_OPEN_LINK, NULL );
sprintf( name, "\Device\Video%u", video_index ); set_reg_ascii_value( video_key, name, buffer ); @@ -1408,8 +1276,7 @@ static void add_adapter( const struct gdi_adapter *adapter, void *param )
/* Following information is Wine specific, it doesn't really exist on Windows. */ snprintf( buffer, ARRAY_SIZE(buffer), "System\CurrentControlSet\Control\Video\%s\%04x", ctx->gpu_guid, adapter_index ); - ctx->adapter_key = reg_create_key( config_key, bufferW, asciiz_to_unicode( bufferW, buffer ) - sizeof(WCHAR), - REG_OPTION_VOLATILE, NULL ); + ctx->adapter_key = reg_create_ascii_key( config_key, buffer, REG_OPTION_VOLATILE, NULL );
set_reg_ascii_value( ctx->adapter_key, "GPUID", ctx->gpuid ); set_reg_value( ctx->adapter_key, state_flagsW, REG_DWORD, &adapter->state_flags, @@ -1442,8 +1309,7 @@ static void add_monitor( const struct gdi_monitor *monitor, void *param ) sprintf( instance, "DISPLAY\%s\%04X&%04X", monitor_id_string, ctx->video_count - 1, monitor_index ); set_reg_ascii_value( ctx->adapter_key, buffer, instance );
- hkey = reg_create_key( enum_key, bufferW, asciiz_to_unicode( bufferW, instance ) - sizeof(WCHAR), - 0, NULL ); + hkey = reg_create_ascii_key( enum_key, instance, 0, NULL ); if (!hkey) return;
link_device( instance, guid_devinterface_monitorA ); @@ -1460,9 +1326,10 @@ static void add_monitor( const struct gdi_monitor *monitor, void *param ) bufferW[len / sizeof(WCHAR)] = 0; set_reg_value( hkey, hardware_idW, REG_MULTI_SZ, bufferW, len + sizeof(WCHAR) );
- if ((subkey = reg_create_key( hkey, device_parametersW, sizeof(device_parametersW), 0, NULL ))) + if ((subkey = reg_create_ascii_key( hkey, "Device Parameters", 0, NULL ))) { static const WCHAR bad_edidW[] = {'B','A','D','_','E','D','I','D',0}; + static const WCHAR edidW[] = {'E','D','I','D',0};
if (monitor->edid_len) set_reg_value( subkey, edidW, REG_BINARY, monitor->edid, monitor->edid_len ); @@ -1472,8 +1339,7 @@ static void add_monitor( const struct gdi_monitor *monitor, void *param ) }
/* WINE_DEVPROPKEY_MONITOR_RCMONITOR */ - if ((subkey = reg_create_key( hkey, wine_devpropkey_monitor_rcmonitorW, - sizeof(wine_devpropkey_monitor_rcmonitorW), 0, NULL ))) + if ((subkey = reg_create_ascii_key( hkey, wine_devpropkey_monitor_rcmonitorA, 0, NULL ))) { set_reg_value( subkey, NULL, 0xffff0000 | DEVPROP_TYPE_BINARY, &monitor->rc_monitor, sizeof(monitor->rc_monitor) ); @@ -1481,8 +1347,7 @@ static void add_monitor( const struct gdi_monitor *monitor, void *param ) }
/* WINE_DEVPROPKEY_MONITOR_RCWORK */ - if ((subkey = reg_create_key( hkey, wine_devpropkey_monitor_rcworkW, - sizeof(wine_devpropkey_monitor_rcworkW), 0, NULL ))) + if ((subkey = reg_create_ascii_key( hkey, wine_devpropkey_monitor_rcworkA, 0, NULL ))) { TRACE( "rc_work %s\n", wine_dbgstr_rect(&monitor->rc_work) ); set_reg_value( subkey, NULL, 0xffff0000 | DEVPROP_TYPE_BINARY, &monitor->rc_work, @@ -1491,8 +1356,7 @@ static void add_monitor( const struct gdi_monitor *monitor, void *param ) }
/* DEVPROPKEY_MONITOR_GPU_LUID */ - if ((subkey = reg_create_key( hkey, devpropkey_monitor_gpu_luidW, - sizeof(devpropkey_monitor_gpu_luidW), 0, NULL ))) + if ((subkey = reg_create_ascii_key( hkey, devpropkey_monitor_gpu_luidA, 0, NULL ))) { set_reg_value( subkey, NULL, 0xffff0000 | DEVPROP_TYPE_INT64, &ctx->gpu_luid, sizeof(ctx->gpu_luid) ); @@ -1500,8 +1364,7 @@ static void add_monitor( const struct gdi_monitor *monitor, void *param ) }
/* DEVPROPKEY_MONITOR_OUTPUT_ID */ - if ((subkey = reg_create_key( hkey, devpropkey_monitor_output_idW, - sizeof(devpropkey_monitor_output_idW), 0, NULL ))) + if ((subkey = reg_create_ascii_key( hkey, devpropkey_monitor_output_idA, 0, NULL ))) { set_reg_value( subkey, NULL, 0xffff0000 | DEVPROP_TYPE_UINT32, &output_index, sizeof(output_index) ); @@ -1511,8 +1374,7 @@ static void add_monitor( const struct gdi_monitor *monitor, void *param ) NtClose( hkey );
sprintf( buffer, "Class\%s\%04X", guid_devclass_monitorA, output_index ); - hkey = reg_create_key( control_key, bufferW, - asciiz_to_unicode( bufferW, buffer ) - sizeof(WCHAR), 0, NULL ); + hkey = reg_create_ascii_key( control_key, buffer, 0, NULL ); if (hkey) NtClose( hkey ); }
@@ -1633,10 +1495,9 @@ static BOOL update_display_cache_from_registry(void) BOOL ret;
/* If user driver did initialize the registry, then exit */ - if (!enum_key && !(enum_key = reg_open_key( NULL, enum_keyW, sizeof(enum_keyW) ))) + if (!enum_key && !(enum_key = reg_open_ascii_key( NULL, enum_keyA ))) return FALSE; - if (!video_key && !(video_key = reg_open_key( NULL, devicemap_video_keyW, - sizeof(devicemap_video_keyW) ))) + if (!video_key && !(video_key = reg_open_ascii_key( NULL, devicemap_video_keyA ))) return FALSE;
status = NtQueryKey( video_key, KeyBasicInformation, &key, @@ -1697,7 +1558,7 @@ static BOOL update_display_cache_from_registry(void) } }
- if ((pci_key = reg_open_key( enum_key, pciW, sizeof(pciW) ))) + if ((pci_key = reg_open_ascii_key( enum_key, "PCI" ))) { unsigned int i = 0;
@@ -1727,8 +1588,7 @@ static BOOL update_display_cache_from_registry(void) continue; }
- if ((prop_key = reg_open_key( gpu_key, devpropkey_gpu_luidW, - sizeof(devpropkey_gpu_luidW) ))) + if ((prop_key = reg_open_ascii_key( gpu_key, devpropkey_gpu_luidA ))) { if (query_reg_value( prop_key, NULL, value, sizeof(buffer) ) == sizeof(LUID)) gpu->luid = *(const LUID *)value->Data; @@ -3660,23 +3520,18 @@ static BOOL get_base_keys( enum parameter_key index, HKEY *base_key, HKEY *volat { static HKEY base_keys[NB_PARAM_KEYS]; static HKEY volatile_keys[NB_PARAM_KEYS]; - WCHAR bufferW[128]; HKEY key;
if (!base_keys[index] && base_key) { - if (!(key = reg_create_key( hkcu_key, bufferW, - asciiz_to_unicode( bufferW, parameter_key_names[index] ) - sizeof(WCHAR), - 0, NULL ))) + if (!(key = reg_create_ascii_key( hkcu_key, parameter_key_names[index], 0, NULL ))) return FALSE; if (InterlockedCompareExchangePointer( (void **)&base_keys[index], key, 0 )) NtClose( key ); } if (!volatile_keys[index] && volatile_key) { - if (!(key = reg_create_key( volatile_base_key, bufferW, - asciiz_to_unicode( bufferW, parameter_key_names[index] ) - sizeof(WCHAR), - REG_OPTION_VOLATILE, NULL ))) + if (!(key = reg_create_ascii_key( volatile_base_key, parameter_key_names[index], REG_OPTION_VOLATILE, NULL ))) return FALSE; if (InterlockedCompareExchangePointer( (void **)&volatile_keys[index], key, 0 )) NtClose( key ); @@ -4660,13 +4515,7 @@ void sysparams_init(void) HKEY hkey, appkey = 0; DWORD len;
- static const WCHAR software_wineW[] = {'S','o','f','t','w','a','r','e','\','W','i','n','e'}; - static const WCHAR temporary_system_parametersW[] = - {'T','e','m','p','o','r','a','r','y',' ','S','y','s','t','e','m',' ', - 'P','a','r','a','m','e','t','e','r','s'}; static const WCHAR oneW[] = {'1',0}; - static const WCHAR kl_preloadW[] = - {'K','e','y','b','o','a','r','d',' ','L','a','y','o','u','t','\','P','r','e','l','o','a','d'}; static const WCHAR x11driverW[] = {'\','X','1','1',' ','D','r','i','v','e','r',0};
pthread_mutexattr_init( &attr ); @@ -4674,7 +4523,7 @@ void sysparams_init(void) pthread_mutex_init( &user_mutex, &attr ); pthread_mutexattr_destroy( &attr );
- if ((hkey = reg_create_key( hkcu_key, kl_preloadW, sizeof(kl_preloadW), 0, NULL ))) + if ((hkey = reg_create_ascii_key( hkcu_key, "Keyboard Layout\Preload", 0, NULL ))) { if (NtUserGetKeyboardLayoutName( layout )) set_reg_value( hkey, oneW, REG_SZ, (const BYTE *)layout, @@ -4683,29 +4532,24 @@ void sysparams_init(void) }
/* this one must be non-volatile */ - if (!(hkey = reg_create_key( hkcu_key, software_wineW, sizeof(software_wineW), 0, NULL ))) + if (!(hkey = reg_create_ascii_key( hkcu_key, "Software\Wine", 0, NULL ))) { ERR("Can't create wine registry branch\n"); return; }
/* @@ Wine registry key: HKCU\Software\Wine\Temporary System Parameters */ - if (!(volatile_base_key = reg_create_key( hkey, temporary_system_parametersW, - sizeof(temporary_system_parametersW), - REG_OPTION_VOLATILE, &dispos ))) + if (!(volatile_base_key = reg_create_ascii_key( hkey, "Temporary System Parameters", REG_OPTION_VOLATILE, &dispos ))) ERR("Can't create non-permanent wine registry branch\n");
NtClose( hkey );
- config_key = reg_create_key( NULL, config_keyW, sizeof(config_keyW), 0, NULL ); + config_key = reg_create_ascii_key( NULL, config_keyA, 0, NULL );
get_dword_entry( (union sysparam_all_entry *)&entry_LOGPIXELS, 0, &system_dpi, 0 ); if (!system_dpi) /* check fallback key */ { - static const WCHAR software_fontsW[] = - {'S','o','f','t','w','a','r','e','\','F','o','n','t','s'}; - - if ((hkey = reg_open_key( config_key, software_fontsW, sizeof(software_fontsW) ))) + if ((hkey = reg_open_ascii_key( config_key, "Software\Fonts" ))) { char buffer[offsetof(KEY_VALUE_PARTIAL_INFORMATION, Data[sizeof(DWORD)])]; KEY_VALUE_PARTIAL_INFORMATION *value = (void *)buffer; diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index d5f010a8249..0e7b84d60a0 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -261,8 +261,11 @@ extern int muldiv( int a, int b, int c );
extern HKEY reg_create_key( HKEY root, const WCHAR *name, ULONG name_len, DWORD options, DWORD *disposition ); +extern HKEY reg_create_ascii_key( HKEY root, const char *name, DWORD options, + DWORD *disposition ); extern HKEY reg_open_hkcu_key( const char *name ); extern HKEY reg_open_key( HKEY root, const WCHAR *name, ULONG name_len ); +extern HKEY reg_open_ascii_key( HKEY root, const char *name ); extern ULONG query_reg_value( HKEY hkey, const WCHAR *name, KEY_VALUE_PARTIAL_INFORMATION *info, ULONG size ); extern ULONG query_reg_ascii_value( HKEY hkey, const char *name,