From 1acbf46fcf7747f8e12a81eefd1fbac022dd6cf3 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sat, 14 May 2016 23:46:34 +0200 Subject: [PATCH] Added patch to fix DialogBoxParam return value when control creation fails. --- patches/patchinstall.sh | 21 +++++++ ...t-DialogBoxParam-using-a-dialog-temp.patch | 48 +++++++++++++++ ...Param-should-return-1-when-dialog-co.patch | 61 +++++++++++++++++++ patches/user32-DialogBoxParam/definition | 1 + 4 files changed, 131 insertions(+) create mode 100644 patches/user32-DialogBoxParam/0001-user32-tests-Test-DialogBoxParam-using-a-dialog-temp.patch create mode 100644 patches/user32-DialogBoxParam/0002-user32-DialogBoxParam-should-return-1-when-dialog-co.patch create mode 100644 patches/user32-DialogBoxParam/definition diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index b354fa95..536917aa 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -321,6 +321,7 @@ patch_enable_all () enable_user_exe16_CONTAINING_RECORD="$1" enable_user_exe16_DlgDirList="$1" enable_user32_DeferWindowPos="$1" + enable_user32_DialogBoxParam="$1" enable_user32_Dialog_Paint_Event="$1" enable_user32_DrawTextExW="$1" enable_user32_GetSystemMetrics="$1" @@ -1130,6 +1131,9 @@ patch_enable () user32-DeferWindowPos) enable_user32_DeferWindowPos="$2" ;; + user32-DialogBoxParam) + enable_user32_DialogBoxParam="$2" + ;; user32-Dialog_Paint_Event) enable_user32_Dialog_Paint_Event="$2" ;; @@ -6588,6 +6592,23 @@ if test "$enable_user32_DeferWindowPos" -eq 1; then ) >> "$patchlist" fi +# Patchset user32-DialogBoxParam +# | +# | This patchset fixes the following Wine bugs: +# | * [#40025] DialogBoxParam should return -1 when dialog control creation fails +# | +# | Modified files: +# | * dlls/user32/dialog.c, dlls/user32/tests/dialog.c, dlls/user32/tests/resource.rc +# | +if test "$enable_user32_DialogBoxParam" -eq 1; then + patch_apply user32-DialogBoxParam/0001-user32-tests-Test-DialogBoxParam-using-a-dialog-temp.patch + patch_apply user32-DialogBoxParam/0002-user32-DialogBoxParam-should-return-1-when-dialog-co.patch + ( + echo '+ { "Dmitry Timoshkov", "user32/tests: Test DialogBoxParam using a dialog template with invalid control class.", 1 },'; + echo '+ { "Dmitry Timoshkov", "user32: DialogBoxParam should return -1 when dialog control creation fails.", 1 },'; + ) >> "$patchlist" +fi + # Patchset user32-Dialog_Paint_Event # | # | This patchset fixes the following Wine bugs: diff --git a/patches/user32-DialogBoxParam/0001-user32-tests-Test-DialogBoxParam-using-a-dialog-temp.patch b/patches/user32-DialogBoxParam/0001-user32-tests-Test-DialogBoxParam-using-a-dialog-temp.patch new file mode 100644 index 00000000..cc2a0009 --- /dev/null +++ b/patches/user32-DialogBoxParam/0001-user32-tests-Test-DialogBoxParam-using-a-dialog-temp.patch @@ -0,0 +1,48 @@ +From 2bee693b0105133d7414a6602ce4c0cd155f5cf8 Mon Sep 17 00:00:00 2001 +From: Dmitry Timoshkov +Date: Fri, 13 May 2016 16:13:47 +0800 +Subject: user32/tests: Test DialogBoxParam using a dialog template with + invalid control class. + +--- + dlls/user32/tests/dialog.c | 6 ++++++ + dlls/user32/tests/resource.rc | 6 ++++++ + 2 files changed, 12 insertions(+) + +diff --git a/dlls/user32/tests/dialog.c b/dlls/user32/tests/dialog.c +index a6cd1be..470ffdc 100644 +--- a/dlls/user32/tests/dialog.c ++++ b/dlls/user32/tests/dialog.c +@@ -1222,6 +1222,12 @@ static void test_DialogBoxParamA(void) + "got %d, expected ERROR_RESOURCE_NAME_NOT_FOUND\n",GetLastError()); + + SetLastError(0xdeadbeef); ++ ret = DialogBoxParamA(GetModuleHandleA(NULL), "TEST_DIALOG_INVALID_CLASS", 0, DestroyDlgWinProc, 0); ++todo_wine ++ ok(ret == -1, "DialogBoxParamA returned %ld, expected -1\n", ret); ++ ok(GetLastError() == 0, "got %d\n", GetLastError()); ++ ++ SetLastError(0xdeadbeef); + ret = DefDlgProcA(0, WM_ERASEBKGND, 0, 0); + ok(ret == 0, "DefDlgProcA returned %ld, expected 0\n", ret); + ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || +diff --git a/dlls/user32/tests/resource.rc b/dlls/user32/tests/resource.rc +index f116b85..756e38f 100644 +--- a/dlls/user32/tests/resource.rc ++++ b/dlls/user32/tests/resource.rc +@@ -124,6 +124,12 @@ FONT 8, "MS Shell Dlg" + EDITTEXT 200,4,4,50,14 + } + ++TEST_DIALOG_INVALID_CLASS DIALOG 0, 0, 60, 30 ++STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU ++{ ++ CONTROL "",1,"wine invalid class",WS_CHILD,0,0,40,10 ++} ++ + IDD_DIALOG DIALOG 0, 0, 186, 95 + STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU + CAPTION "Dialog" +-- +2.8.0 + diff --git a/patches/user32-DialogBoxParam/0002-user32-DialogBoxParam-should-return-1-when-dialog-co.patch b/patches/user32-DialogBoxParam/0002-user32-DialogBoxParam-should-return-1-when-dialog-co.patch new file mode 100644 index 00000000..ca53eb69 --- /dev/null +++ b/patches/user32-DialogBoxParam/0002-user32-DialogBoxParam-should-return-1-when-dialog-co.patch @@ -0,0 +1,61 @@ +From 7f3ff2cf69b045541c2ffa6646b8051d78f7e970 Mon Sep 17 00:00:00 2001 +From: Dmitry Timoshkov +Date: Fri, 13 May 2016 16:19:40 +0800 +Subject: user32: DialogBoxParam should return -1 when dialog control creation + fails. + +For bugs #40025 and #40609. +--- + dlls/user32/dialog.c | 8 ++++++-- + dlls/user32/tests/dialog.c | 1 - + 2 files changed, 6 insertions(+), 3 deletions(-) + +diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c +index 9cb4b8d..02b407b 100644 +--- a/dlls/user32/dialog.c ++++ b/dlls/user32/dialog.c +@@ -837,11 +837,13 @@ INT_PTR WINAPI DialogBoxParamA( HINSTANCE hInst, LPCSTR name, + HRSRC hrsrc; + LPCDLGTEMPLATEA ptr; + ++ if (owner && !IsWindow(owner)) return 0; ++ + if (!(hrsrc = FindResourceA( hInst, name, (LPSTR)RT_DIALOG ))) return -1; + if (!(ptr = LoadResource(hInst, hrsrc))) return -1; + hwnd = DIALOG_CreateIndirect( hInst, ptr, owner, dlgProc, param, FALSE, &owner ); + if (hwnd) return DIALOG_DoDialogBox( hwnd, owner ); +- return 0; ++ return -1; + } + + +@@ -855,11 +857,13 @@ INT_PTR WINAPI DialogBoxParamW( HINSTANCE hInst, LPCWSTR name, + HRSRC hrsrc; + LPCDLGTEMPLATEW ptr; + ++ if (owner && !IsWindow(owner)) return 0; ++ + if (!(hrsrc = FindResourceW( hInst, name, (LPWSTR)RT_DIALOG ))) return -1; + if (!(ptr = LoadResource(hInst, hrsrc))) return -1; + hwnd = DIALOG_CreateIndirect( hInst, ptr, owner, dlgProc, param, TRUE, &owner ); + if (hwnd) return DIALOG_DoDialogBox( hwnd, owner ); +- return 0; ++ return -1; + } + + +diff --git a/dlls/user32/tests/dialog.c b/dlls/user32/tests/dialog.c +index 470ffdc..60819c3 100644 +--- a/dlls/user32/tests/dialog.c ++++ b/dlls/user32/tests/dialog.c +@@ -1223,7 +1223,6 @@ static void test_DialogBoxParamA(void) + + SetLastError(0xdeadbeef); + ret = DialogBoxParamA(GetModuleHandleA(NULL), "TEST_DIALOG_INVALID_CLASS", 0, DestroyDlgWinProc, 0); +-todo_wine + ok(ret == -1, "DialogBoxParamA returned %ld, expected -1\n", ret); + ok(GetLastError() == 0, "got %d\n", GetLastError()); + +-- +2.8.0 + diff --git a/patches/user32-DialogBoxParam/definition b/patches/user32-DialogBoxParam/definition new file mode 100644 index 00000000..bcb9efff --- /dev/null +++ b/patches/user32-DialogBoxParam/definition @@ -0,0 +1 @@ +Fixes: [40025] DialogBoxParam should return -1 when dialog control creation fails