From fa7efa7843d74216ce684e337a6959668c3013b2 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Tue, 30 Oct 2007 12:05:24 +0000 Subject: [PATCH] - fix a bug in ShellView_DoContextMenu which made shell extensions crash on click - pass the pidl of the parent folder to IShellExtInit function. - shell extension dont run yet due SHGetPathFromIDList[A/W] cant return right information svn path=/trunk/; revision=29977 --- reactos/dll/win32/shell32/shlview.c | 3 +-- reactos/dll/win32/shell32/shv_item_cmenu.c | 19 +++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/reactos/dll/win32/shell32/shlview.c b/reactos/dll/win32/shell32/shlview.c index 5a5b1e33acf..e7693ac8a39 100644 --- a/reactos/dll/win32/shell32/shlview.c +++ b/reactos/dll/win32/shell32/shlview.c @@ -948,7 +948,6 @@ static void ShellView_DoContextMenu(IShellViewImpl * This, WORD x, WORD y, BOOL HMENU hMenu; BOOL fExplore = FALSE; HWND hwndTree = 0; - LPCONTEXTMENU pContextMenu = NULL; CMINVOKECOMMANDINFO cmi; TRACE("(%p)->(0x%08x 0x%08x 0x%08x) stub\n",This, x, y, bDefault); @@ -1011,7 +1010,7 @@ static void ShellView_DoContextMenu(IShellViewImpl * This, WORD x, WORD y, BOOL cmi.cbSize = sizeof(cmi); cmi.hwnd = This->hWndParent; /* this window has to answer CWM_GETISHELLBROWSER */ cmi.lpVerb = (LPCSTR)MAKEINTRESOURCEA(uCommand); - IContextMenu_InvokeCommand(pContextMenu, &cmi); + IContextMenu_InvokeCommand(This->pCM, &cmi); } } DestroyMenu(hMenu); diff --git a/reactos/dll/win32/shell32/shv_item_cmenu.c b/reactos/dll/win32/shell32/shv_item_cmenu.c index 494268c2056..6da34eed144 100644 --- a/reactos/dll/win32/shell32/shv_item_cmenu.c +++ b/reactos/dll/win32/shell32/shv_item_cmenu.c @@ -62,7 +62,7 @@ typedef struct } ItemCmImpl; UINT -SH_EnumerateDynamicContextHandlerForKey(LPWSTR szFileClass, ItemCmImpl *This, IDataObject * pDataObj); +SH_EnumerateDynamicContextHandlerForKey(LPWSTR szFileClass, ItemCmImpl *This, IDataObject * pDataObj, LPITEMIDLIST pidlFolder); static const IContextMenu2Vtbl cmvt; @@ -310,7 +310,7 @@ SH_LoadContextMenuHandlers(ItemCmImpl *This, IDataObject * pDataObj, HMENU hMenu UINT idCmdLast = 0xFFF0; static WCHAR szAny[] = { '*',0}; - SH_EnumerateDynamicContextHandlerForKey(szAny, This, pDataObj); + SH_EnumerateDynamicContextHandlerForKey(szAny, This, pDataObj, This->pidl); for (i = 0; i < This->cidl; i++) { @@ -324,7 +324,7 @@ SH_LoadContextMenuHandlers(ItemCmImpl *This, IDataObject * pDataObj, HMENU hMenu if (hr == S_OK) { memcpy(&buffer[6], pwszCLSID, 38 * sizeof(WCHAR)); - SH_EnumerateDynamicContextHandlerForKey(buffer, This, pDataObj); + SH_EnumerateDynamicContextHandlerForKey(buffer, This, pDataObj, This->pidl); } } @@ -333,7 +333,7 @@ SH_LoadContextMenuHandlers(ItemCmImpl *This, IDataObject * pDataObj, HMENU hMenu ebuf[0] = L'.'; buffer[0] = L'\0'; if (MultiByteToWideChar(CP_ACP, 0, ebuf, -1, buffer, 111)) - SH_EnumerateDynamicContextHandlerForKey(buffer, This, pDataObj); + SH_EnumerateDynamicContextHandlerForKey(buffer, This, pDataObj, This->pidl); } } @@ -778,12 +778,12 @@ static const IContextMenu2Vtbl cmvt = }; HRESULT -SH_LoadDynamicContextMenuHandler(HKEY hKey, const CLSID * szClass, IContextMenu** ppv, IDataObject * pDataObj) +SH_LoadDynamicContextMenuHandler(HKEY hKey, const CLSID * szClass, IContextMenu** ppv, IDataObject * pDataObj, LPITEMIDLIST pidlFolder) { HRESULT hr; IContextMenu * cmobj; IShellExtInit *shext; - + TRACE("SH_LoadDynamicContextMenuHandler entered with %s\n",wine_dbgstr_guid(szClass)); hr = SHCoCreateInstance(NULL, szClass, NULL, &IID_IContextMenu, (void**)&cmobj); @@ -800,8 +800,7 @@ SH_LoadDynamicContextMenuHandler(HKEY hKey, const CLSID * szClass, IContextMenu* cmobj->lpVtbl->Release(cmobj); return FALSE; } - - hr = shext->lpVtbl->Initialize(shext, NULL, pDataObj, hKey); + hr = shext->lpVtbl->Initialize(shext, pidlFolder, pDataObj, hKey); if (hr != S_OK) { TRACE("Failed to initialize shell extension\n"); @@ -817,7 +816,7 @@ SH_LoadDynamicContextMenuHandler(HKEY hKey, const CLSID * szClass, IContextMenu* } UINT -SH_EnumerateDynamicContextHandlerForKey(const LPWSTR szFileClass, ItemCmImpl *This, IDataObject * pDataObj) +SH_EnumerateDynamicContextHandlerForKey(const LPWSTR szFileClass, ItemCmImpl *This, IDataObject * pDataObj, LPITEMIDLIST pidlFolder) { HKEY hKey; WCHAR szKey[MAX_PATH] = {0}; @@ -861,7 +860,7 @@ SH_EnumerateDynamicContextHandlerForKey(const LPWSTR szFileClass, ItemCmImpl *Th TRACE("hResult %x szKey %s name %s\n",hResult, debugstr_w(szKey), debugstr_w(szName)); if (hResult == S_OK) { - hResult = SH_LoadDynamicContextMenuHandler(hKey, &clsid, &cmobj, pDataObj); + hResult = SH_LoadDynamicContextMenuHandler(hKey, &clsid, &cmobj, pDataObj, pidlFolder); } if (hResult == S_OK) {