https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3904fd6257f97ed9528db0...
commit 3904fd6257f97ed9528db09f097400c35f1229d9 Author: Mark Jansen mark.jansen@reactos.org AuthorDate: Fri Jul 6 21:43:57 2018 +0200 Commit: Mark Jansen mark.jansen@reactos.org CommitDate: Fri Jul 6 21:51:24 2018 +0200
[SHELL32] Ensure OpenAs_RunDLL does not loop to infinity and beyond. This should fix a timeout on the apitests. --- dll/win32/shell32/COpenWithMenu.cpp | 28 +++++++++------------------- dll/win32/shell32/shlexec.cpp | 3 ++- 2 files changed, 11 insertions(+), 20 deletions(-)
diff --git a/dll/win32/shell32/COpenWithMenu.cpp b/dll/win32/shell32/COpenWithMenu.cpp index 3cf5da3b7d..485623fe3a 100644 --- a/dll/win32/shell32/COpenWithMenu.cpp +++ b/dll/win32/shell32/COpenWithMenu.cpp @@ -1035,7 +1035,7 @@ VOID COpenWithDialog::Accept() if (m_pInfo->oaifInFlags & OAIF_EXEC) m_pAppList->Execute(pApp, m_pInfo->pcszFile);
- DestroyWindow(m_hDialog); + EndDialog(m_hDialog, 1); } }
@@ -1066,7 +1066,7 @@ INT_PTR CALLBACK COpenWithDialog::DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wPa return TRUE; } case IDCANCEL: /* cancel */ - DestroyWindow(hwndDlg); + EndDialog(hwndDlg, 0); return TRUE; default: break; @@ -1085,7 +1085,7 @@ INT_PTR CALLBACK COpenWithDialog::DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wPa } break; case WM_CLOSE: - DestroyWindow(hwndDlg); + EndDialog(hwndDlg, 0); return TRUE; default: break; @@ -1427,8 +1427,7 @@ COpenWithMenu::Initialize(LPCITEMIDLIST pidlFolder, HRESULT WINAPI SHOpenWithDialog(HWND hwndParent, const OPENASINFO *poainfo) { - MSG msg; - HWND hwnd; + INT_PTR ret;
TRACE("SHOpenWithDialog hwndParent %p poainfo %p\n", hwndParent, poainfo);
@@ -1439,25 +1438,16 @@ SHOpenWithDialog(HWND hwndParent, const OPENASINFO *poainfo)
COpenWithDialog pDialog(poainfo);
- hwnd = CreateDialogParam(shell32_hInstance, MAKEINTRESOURCE(IDD_OPEN_WITH), hwndParent, COpenWithDialog::DialogProc, (LPARAM)&pDialog); - if (hwnd == NULL) - { - ERR("Failed to create dialog\n"); - return E_FAIL; - } - if (pDialog.IsNoOpen(hwndParent)) return S_OK;
- ShowWindow(hwnd, SW_SHOWNORMAL); + ret = DialogBoxParamW(shell32_hInstance, MAKEINTRESOURCE(IDD_OPEN_WITH), hwndParent, + COpenWithDialog::DialogProc, (LPARAM)&pDialog);
- while (GetMessage(&msg, NULL, 0, 0) && IsWindow(hwnd)) + if (ret == (INT_PTR)-1) { - if (!IsDialogMessage(hwnd, &msg)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } + ERR("Failed to create dialog: %u\n", GetLastError()); + return E_FAIL; }
return S_OK; diff --git a/dll/win32/shell32/shlexec.cpp b/dll/win32/shell32/shlexec.cpp index 67c10f317c..e8885f6fa1 100644 --- a/dll/win32/shell32/shlexec.cpp +++ b/dll/win32/shell32/shlexec.cpp @@ -2314,7 +2314,8 @@ OpenAs_RunDLLA(HWND hwnd, HINSTANCE hinst, LPCSTR cmdline, int cmdshow) LPWSTR pszCmdLineW = NULL; TRACE("%p, %p, %s, %d\n", hwnd, hinst, debugstr_a(cmdline), cmdshow);
- __SHCloneStrAtoW(&pszCmdLineW, cmdline); + if (cmdline) + __SHCloneStrAtoW(&pszCmdLineW, cmdline); OpenAs_RunDLLW(hwnd, hinst, pszCmdLineW, cmdshow); SHFree(pszCmdLineW); }