From: Rémi Bernon rbernon@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53484 --- dlls/win32u/sysparams.c | 83 +++++------------------------------------ 1 file changed, 10 insertions(+), 73 deletions(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 498ed386386..28e563335b8 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -169,15 +169,6 @@ 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 bits_per_pelW[] = {'B','i','t','s','P','e','r','P','e','l',0}; -static const WCHAR x_resolutionW[] = {'X','R','e','s','o','l','u','t','i','o','n',0}; -static const WCHAR y_resolutionW[] = {'Y','R','e','s','o','l','u','t','i','o','n',0}; -static const WCHAR v_refreshW[] = {'V','R','e','f','r','e','s','h',0}; -static const WCHAR flagsW[] = {'F','l','a','g','s',0}; -static const WCHAR x_panningW[] = {'X','P','a','n','n','i','n','g',0}; -static const WCHAR y_panningW[] = {'Y','P','a','n','n','i','n','g',0}; -static const WCHAR orientationW[] = {'O','r','i','e','n','t','a','t','i','o','n',0}; -static const WCHAR fixed_outputW[] = {'F','i','x','e','d','O','u','t','p','u','t',0}; static const WCHAR mode_countW[] = {'M','o','d','e','C','o','u','n','t',0};
static const char guid_devclass_displayA[] = "{4D36E968-E325-11CE-BFC1-08002BE10318}"; @@ -443,84 +434,30 @@ static void adapter_release( struct adapter *adapter ) } }
+C_ASSERT(sizeof(DEVMODEW) - offsetof(DEVMODEW, dmFields) == 0x94); + static BOOL write_adapter_mode( HKEY adapter_key, DWORD index, const DEVMODEW *mode ) { - WCHAR bufferW[MAX_PATH]; + WCHAR bufferW[MAX_PATH] = {0}; char buffer[MAX_PATH]; - BOOL ret = TRUE; - HKEY hkey;
sprintf( buffer, "Modes\%08X", index ); - reg_delete_tree( adapter_key, bufferW, asciiz_to_unicode( bufferW, buffer ) - sizeof(WCHAR) ); - if (!(hkey = reg_create_key( adapter_key, bufferW, asciiz_to_unicode( bufferW, buffer ) - sizeof(WCHAR), - REG_OPTION_VOLATILE, NULL ))) - return FALSE; - -#define set_mode_field( name, field, flag ) \ - if ((mode->dmFields & (flag)) && \ - !(ret = set_reg_value( hkey, (name), REG_DWORD, &mode->field, \ - sizeof(mode->field) ))) \ - goto done - - set_mode_field( bits_per_pelW, dmBitsPerPel, DM_BITSPERPEL ); - set_mode_field( x_resolutionW, dmPelsWidth, DM_PELSWIDTH ); - set_mode_field( y_resolutionW, dmPelsHeight, DM_PELSHEIGHT ); - set_mode_field( v_refreshW, dmDisplayFrequency, DM_DISPLAYFREQUENCY ); - set_mode_field( flagsW, dmDisplayFlags, DM_DISPLAYFLAGS ); - set_mode_field( orientationW, dmDisplayOrientation, DM_DISPLAYORIENTATION ); - set_mode_field( fixed_outputW, dmDisplayFixedOutput, DM_DISPLAYFIXEDOUTPUT ); - if (index == ENUM_CURRENT_SETTINGS || index == ENUM_REGISTRY_SETTINGS) - { - set_mode_field( x_panningW, dmPosition.x, DM_POSITION ); - set_mode_field( y_panningW, dmPosition.y, DM_POSITION ); - } - -#undef set_mode_field - -done: - NtClose( hkey ); - return ret; + asciiz_to_unicode( bufferW, buffer ); + return set_reg_value( adapter_key, bufferW, REG_BINARY, &mode->dmFields, sizeof(*mode) - offsetof(DEVMODEW, dmFields) ); }
static BOOL read_adapter_mode( HKEY adapter_key, DWORD index, DEVMODEW *mode ) { - char value_buf[offsetof(KEY_VALUE_PARTIAL_INFORMATION, Data[sizeof(DWORD)])]; + char value_buf[offsetof(KEY_VALUE_PARTIAL_INFORMATION, Data[sizeof(*mode)])]; KEY_VALUE_PARTIAL_INFORMATION *value = (void *)value_buf; - WCHAR bufferW[MAX_PATH]; + WCHAR bufferW[MAX_PATH] = {0}; char buffer[MAX_PATH]; - HKEY hkey;
sprintf( buffer, "Modes\%08X", index ); - if (!(hkey = reg_open_key( adapter_key, bufferW, asciiz_to_unicode( bufferW, buffer ) - sizeof(WCHAR) ))) - return FALSE; - -#define query_mode_field( name, field, flag ) \ - do \ - { \ - if (query_reg_value( hkey, (name), value, sizeof(value_buf) ) && \ - value->Type == REG_DWORD) \ - { \ - mode->field = *(const DWORD *)value->Data; \ - mode->dmFields |= (flag); \ - } \ - } while (0) + asciiz_to_unicode( bufferW, buffer ); + if (!query_reg_value( adapter_key, bufferW, value, sizeof(value_buf) )) return FALSE;
- query_mode_field( bits_per_pelW, dmBitsPerPel, DM_BITSPERPEL ); - query_mode_field( x_resolutionW, dmPelsWidth, DM_PELSWIDTH ); - query_mode_field( y_resolutionW, dmPelsHeight, DM_PELSHEIGHT ); - query_mode_field( v_refreshW, dmDisplayFrequency, DM_DISPLAYFREQUENCY ); - query_mode_field( flagsW, dmDisplayFlags, DM_DISPLAYFLAGS ); - query_mode_field( orientationW, dmDisplayOrientation, DM_DISPLAYORIENTATION ); - query_mode_field( fixed_outputW, dmDisplayFixedOutput, DM_DISPLAYFIXEDOUTPUT ); - if (index == ENUM_CURRENT_SETTINGS || index == ENUM_REGISTRY_SETTINGS) - { - query_mode_field( x_panningW, dmPosition.x, DM_POSITION ); - query_mode_field( y_panningW, dmPosition.y, DM_POSITION ); - } - -#undef query_mode_field - - NtClose( hkey ); + memcpy( &mode->dmFields, value->Data, sizeof(*mode) - offsetof(DEVMODEW, dmFields) ); return TRUE; }
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=125185
Your paranoid android.
=== debian11 (build log) ===
Use of uninitialized value $Flaky in addition (+) at /home/testbot/lib/WineTestBot/LogUtils.pm line 720, <$LogFile> line 24727. Use of uninitialized value $Flaky in addition (+) at /home/testbot/lib/WineTestBot/LogUtils.pm line 720, <$LogFile> line 24727. Use of uninitialized value $Flaky in addition (+) at /home/testbot/lib/WineTestBot/LogUtils.pm line 720, <$LogFile> line 24727.
This merge request was approved by Zhiyi Zhang.