From 909de8f972f27eebacd1b071ceb09bc7367282b9 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Mon, 25 Aug 2008 21:02:21 +0000 Subject: [PATCH] - Prevent a crash by checking the applet name if it is empty and does exist - %1 is used for file argument, where %2, %3, %n indicate the index of the passed param, %* is the rest of the command - Directly pass the full filename to ShellExecuteExW from the default context menu - Should fix executing cpl in default shellview svn path=/trunk/; revision=35643 --- reactos/dll/win32/shell32/control.c | 12 ++++++++++-- reactos/dll/win32/shell32/shlexec.c | 6 +++++- reactos/dll/win32/shell32/shv_def_cmenu.c | 17 ++++++++++++++--- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/reactos/dll/win32/shell32/control.c b/reactos/dll/win32/shell32/control.c index 1494df9c49a..baa6d915525 100644 --- a/reactos/dll/win32/shell32/control.c +++ b/reactos/dll/win32/shell32/control.c @@ -427,12 +427,20 @@ static void Control_DoLaunch(CPanel* panel, HWND hWnd, LPCWSTR wszCmd) sp = 0; } - if ((extraPmts)&&(!spSet)) + if ((extraPmts) && extraPmts[0] &&(!spSet)) { while ((lstrcmpiW(extraPmts, applet->info[sp].szName)) && (sp < applet->count)) sp++; - } + if (sp >= applet->count) + { + ReleaseMutex(hMutex); + CloseHandle(hMutex); + Control_UnloadApplet(applet); + HeapFree(GetProcessHeap(), 0, buffer); + return; + } + } if (applet->info[sp].dwSize) { if (!applet->proc(applet->hWnd, CPL_STARTWPARMSA, sp, (LPARAM)extraPmts)) applet->proc(applet->hWnd, CPL_DBLCLK, sp, applet->info[sp].lData); diff --git a/reactos/dll/win32/shell32/shlexec.c b/reactos/dll/win32/shell32/shlexec.c index 72735d72d51..6af52b8cece 100644 --- a/reactos/dll/win32/shell32/shlexec.c +++ b/reactos/dll/win32/shell32/shlexec.c @@ -129,6 +129,7 @@ static BOOL SHELL_ArgifyW(WCHAR* out, int len, const WCHAR* fmt, const WCHAR* lp used++; if (used < len) *res++ = '"'; + break; } else { @@ -146,7 +147,10 @@ static BOOL SHELL_ArgifyW(WCHAR* out, int len, const WCHAR* fmt, const WCHAR* lp } break; } - /* else fall through */ + else + { + break; + } case '1': if (!done || (*fmt == '1')) { diff --git a/reactos/dll/win32/shell32/shv_def_cmenu.c b/reactos/dll/win32/shell32/shv_def_cmenu.c index 3e8c511f8bf..a75d65caa41 100644 --- a/reactos/dll/win32/shell32/shv_def_cmenu.c +++ b/reactos/dll/win32/shell32/shv_def_cmenu.c @@ -1508,6 +1508,8 @@ DoStaticShellExtensions( IDefaultContextMenuImpl *This, LPCMINVOKECOMMANDINFO lpcmi) { + STRRET strFile; + WCHAR szPath[MAX_PATH]; SHELLEXECUTEINFOW sei; PStaticShellEntry pCurrent = This->shead; int verb = LOWORD(lpcmi->lpVerb) - This->iIdSCMFirst; @@ -1520,16 +1522,25 @@ DoStaticShellExtensions( return E_FAIL; + if (IShellFolder2_GetDisplayNameOf(This->dcm.psf, This->dcm.apidl[0], SHGDN_FORPARSING, &strFile) != S_OK) + { + ERR("IShellFolder_GetDisplayNameOf failed for apidl\n"); + return E_FAIL; + } + + if (StrRetToBufW(&strFile, This->dcm.apidl[0], szPath, MAX_PATH) != S_OK) + return E_FAIL; + + ZeroMemory(&sei, sizeof(sei)); sei.cbSize = sizeof(sei); - sei.fMask = SEE_MASK_CLASSNAME | SEE_MASK_IDLIST; + sei.fMask = SEE_MASK_CLASSNAME; sei.lpClass = pCurrent->szClass; sei.hwnd = lpcmi->hwnd; sei.nShow = SW_SHOWNORMAL; sei.lpVerb = pCurrent->szVerb; - sei.lpIDList = ILCombine(This->dcm.pidlFolder, This->dcm.apidl[0]); + sei.lpFile = szPath; ShellExecuteExW(&sei); - SHFree(sei.lpIDList); return S_OK; }