From: Dmitry Timoshkov <dmitry@baikal.ru> With help from Hans Leidekker. Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru> --- dlls/msi/custom.c | 2 +- dlls/msi/tests/action.c | 67 ++++++++++++++++++++++++++++++++++++++ dlls/msi/tests/custom.c | 16 +++++++++ dlls/msi/tests/custom.spec | 2 ++ 4 files changed, 86 insertions(+), 1 deletion(-) diff --git a/dlls/msi/custom.c b/dlls/msi/custom.c index ab25d1e848c..7b0e9fed87e 100644 --- a/dlls/msi/custom.c +++ b/dlls/msi/custom.c @@ -557,7 +557,7 @@ UINT CDECL __wine_msi_call_dll_function(DWORD client_pid, const GUID *guid) { ERR( "Custom action (%s:%s) caused an exception: %#lx\n", debugstr_w(dll), debugstr_a(proc), GetExceptionCode() ); - r = ERROR_SUCCESS; + r = ERROR_INSTALL_FAILURE; } __ENDTRY; } diff --git a/dlls/msi/tests/action.c b/dlls/msi/tests/action.c index 82d950ce466..1c475aa8e41 100644 --- a/dlls/msi/tests/action.c +++ b/dlls/msi/tests/action.c @@ -1970,6 +1970,24 @@ static const char rep_install_exec_seq_dat[] = "UnpublishFeatures\t\t5300\n" "InstallFinalize\t\t6000\n"; +static const char exception_install_exec_seq_dat[] = + "Action\tCondition\tSequence\n" + "s72\tS255\tI2\n" + "InstallExecuteSequence\tAction\n" + "page_fault\tPAGEFAULT AND NOT REMOVE\t601\n" + "page_fault_ignore\tPAGEFAULT_IGNORE AND NOT REMOVE\t602\n" + "raise_exception\tEXCEPTION AND NOT REMOVE\t603\n" + "raise_exception_ignore\tEXCEPTION_IGNORE AND NOT REMOVE\t604\n"; + +static const char exception_custom_action_dat[] = + "Action\tType\tSource\tTarget\n" + "s72\ti2\tS64\tS0\n" + "CustomAction\tAction\n" + "page_fault\t1\tcustom.dll\tpage_fault\n" + "page_fault_ignore\t65\tcustom.dll\tpage_fault\n" + "raise_exception\t1\tcustom.dll\traise_exception\n" + "raise_exception_ignore\t65\tcustom.dll\traise_exception\n"; + static const msi_table env_tables[] = { ADD_TABLE(component), @@ -2371,6 +2389,19 @@ static const msi_table rep_tables[] = ADD_TABLE(media) }; +static const msi_table exception_tables[] = +{ + ADD_TABLE(component), + ADD_TABLE(directory), + ADD_TABLE(feature), + ADD_TABLE(feature_comp), + ADD_TABLE(file), + ADD_TABLE(exception_install_exec_seq), + ADD_TABLE(exception_custom_action), + ADD_TABLE(media), + ADD_TABLE(property) +}; + /* cabinet definitions */ /* make the max size large so there is only one cab file */ @@ -6541,6 +6572,41 @@ error: DeleteFileA(msifile); } +static void test_custom_action_exception(void) +{ + UINT r; + + if (!is_process_elevated()) + { + skip("Process is limited\n"); + return; + } + + create_database(msifile, exception_tables, ARRAY_SIZE(exception_tables)); + + MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); + + r = MsiInstallProductA(msifile, "PAGEFAULT=1"); + if (r == ERROR_INSTALL_PACKAGE_REJECTED) + { + skip("Not enough rights to perform tests\n"); + goto done; + } + ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r); + + r = MsiInstallProductA(msifile, "PAGEFAULT_IGNORE=1"); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); + + r = MsiInstallProductA(msifile, "EXCEPTION=1"); + ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_SUCCESS, got %u\n", r); + + r = MsiInstallProductA(msifile, "EXCEPTION_IGNORE=1"); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r); + +done: + DeleteFileA(msifile); +} + static HANDLE get_admin_token(void) { TOKEN_ELEVATION_TYPE type; @@ -6647,6 +6713,7 @@ START_TEST(action) test_register_mime_info(); test_publish_assemblies(); test_remove_existing_products(); + test_custom_action_exception(); DeleteFileA(log_file); SetCurrentDirectoryA(prev_path); diff --git a/dlls/msi/tests/custom.c b/dlls/msi/tests/custom.c index 8c5e7e4bbd0..5e4687fa789 100644 --- a/dlls/msi/tests/custom.c +++ b/dlls/msi/tests/custom.c @@ -1411,6 +1411,22 @@ UINT WINAPI async2(MSIHANDLE hinst) return ERROR_SUCCESS; } +UINT WINAPI page_fault(MSIHANDLE hinst) +{ + UINT *p = NULL; + + *(volatile UINT *)p = 0xdeadbeef; + + return ERROR_SUCCESS; +} + +UINT WINAPI raise_exception(MSIHANDLE hinst) +{ + RaiseException(0xdeadbeef, 0, 0, NULL); + + return ERROR_SUCCESS; +} + static BOOL pf_exists(const char *file) { char path[MAX_PATH]; diff --git a/dlls/msi/tests/custom.spec b/dlls/msi/tests/custom.spec index 5d78377a799..4f3f1cb298a 100644 --- a/dlls/msi/tests/custom.spec +++ b/dlls/msi/tests/custom.spec @@ -60,3 +60,5 @@ @ stdcall tl_absent(long) @ stdcall wrv_present(long) @ stdcall wrv_absent(long) +@ stdcall page_fault(long) +@ stdcall raise_exception(long) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11017