From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/sysparams.c | 62 +++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 24 deletions(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 07b9d46d9eb..d1d49d4c1c4 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -1257,40 +1257,26 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param ) ctx->gpu_count++; }
-static void add_adapter( const struct gdi_adapter *adapter, void *param ) +static BOOL write_adapter_to_registry( const struct adapter *adapter, HKEY *adapter_key ) { - struct device_manager_ctx *ctx = param; - unsigned int adapter_index, len; + struct gpu *gpu = adapter->gpu; + unsigned int len, adapter_index = gpu->adapter_count; char name[64], buffer[MAX_PATH]; WCHAR bufferW[MAX_PATH]; HKEY hkey;
- TRACE( "\n" ); - - if (ctx->adapter_key) - { - NtClose( ctx->adapter_key ); - ctx->adapter_key = NULL; - } - - adapter_index = ctx->gpu.adapter_count++; - - memset( &ctx->adapter, 0, sizeof(ctx->adapter) ); - ctx->adapter.gpu = &ctx->gpu; - ctx->adapter.id = ctx->adapter_count++; - - snprintf( buffer, ARRAY_SIZE(buffer), "%s\Video\%s\%04x", control_keyA, ctx->gpu.guid, adapter_index ); + sprintf( buffer, "%s\Video\%s\%04x", control_keyA, gpu->guid, adapter_index ); len = asciiz_to_unicode( bufferW, buffer ) - sizeof(WCHAR);
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", ctx->adapter.id ); + sprintf( name, "\Device\Video%u", adapter->id ); set_reg_ascii_value( video_key, name, buffer );
if (hkey) { - sprintf( buffer, "%s\Class\%s\%04X", control_keyA, guid_devclass_displayA, ctx->gpu.index ); + sprintf( buffer, "%s\Class\%s\%04X", control_keyA, guid_devclass_displayA, gpu->index ); len = asciiz_to_unicode( bufferW, buffer ) - sizeof(WCHAR); set_reg_value( hkey, symbolic_link_valueW, REG_LINK, bufferW, len ); NtClose( hkey ); @@ -1298,12 +1284,40 @@ 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. */ - snprintf( buffer, ARRAY_SIZE(buffer), "System\CurrentControlSet\Control\Video\%s\%04x", ctx->gpu.guid, adapter_index ); - ctx->adapter_key = reg_create_ascii_key( config_key, buffer, REG_OPTION_VOLATILE, NULL ); + sprintf( buffer, "System\CurrentControlSet\Control\Video\%s\%04x", gpu->guid, adapter_index ); + *adapter_key = reg_create_ascii_key( config_key, buffer, REG_OPTION_VOLATILE, NULL );
- set_reg_ascii_value( ctx->adapter_key, "GPUID", ctx->gpu.path ); - set_reg_value( ctx->adapter_key, state_flagsW, REG_DWORD, &adapter->state_flags, + set_reg_ascii_value( *adapter_key, "GPUID", gpu->path ); + set_reg_value( *adapter_key, state_flagsW, REG_DWORD, &adapter->state_flags, sizeof(adapter->state_flags) ); + + return TRUE; +} + +static void add_adapter( const struct gdi_adapter *adapter, void *param ) +{ + struct device_manager_ctx *ctx = param; + + TRACE( "\n" ); + + if (ctx->adapter_key) + { + NtClose( ctx->adapter_key ); + ctx->adapter_key = NULL; + } + + memset( &ctx->adapter, 0, sizeof(ctx->adapter) ); + ctx->adapter.gpu = &ctx->gpu; + ctx->adapter.id = ctx->adapter_count; + ctx->adapter.state_flags = adapter->state_flags; + + if (!write_adapter_to_registry( &ctx->adapter, &ctx->adapter_key )) + WARN( "Failed to write adapter to registry\n" ); + else + { + ctx->gpu.adapter_count++; + ctx->adapter_count++; + } }
static BOOL write_monitor_to_registry( struct monitor *monitor, const BYTE *edid, UINT edid_len )