Author: gadamopoulos Date: Tue Feb 4 12:11:51 2014 New Revision: 61978
URL: http://svn.reactos.org/svn/reactos?rev=61978&view=rev Log: [rshell] - Commit rshell.exe that allows explorer_new to run in windows 8
Added: branches/shell-experiments/base/shell/rshell/ (with props) branches/shell-experiments/base/shell/rshell/CDesktopBrowser.cpp - copied, changed from r61883, trunk/reactos/dll/win32/shell32/desktop.cpp branches/shell-experiments/base/shell/rshell/CMakeLists.txt (with props) branches/shell-experiments/base/shell/rshell/CStartMenu.cpp (with props) branches/shell-experiments/base/shell/rshell/misc.cpp (with props) branches/shell-experiments/base/shell/rshell/precomp.h (with props) branches/shell-experiments/base/shell/rshell/rshell.spec (with props) Modified: branches/shell-experiments/base/shell/CMakeLists.txt
Modified: branches/shell-experiments/base/shell/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/CMa... ============================================================================== --- branches/shell-experiments/base/shell/CMakeLists.txt [iso-8859-1] (original) +++ branches/shell-experiments/base/shell/CMakeLists.txt [iso-8859-1] Tue Feb 4 12:11:51 2014 @@ -3,3 +3,4 @@ add_subdirectory(explorer) add_subdirectory(explorer-new) add_subdirectory(filebrowser) +add_subdirectory(rshell)
Propchange: branches/shell-experiments/base/shell/rshell/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Tue Feb 4 12:11:51 2014 @@ -0,0 +1,2 @@ +([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))? +(\d+)
Propchange: branches/shell-experiments/base/shell/rshell/ ------------------------------------------------------------------------------ bugtraq:message = See issue #%BUGID% for more details.
Propchange: branches/shell-experiments/base/shell/rshell/ ------------------------------------------------------------------------------ bugtraq:url = http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Propchange: branches/shell-experiments/base/shell/rshell/ ------------------------------------------------------------------------------ tsvn:logminsize = 10
Copied: branches/shell-experiments/base/shell/rshell/CDesktopBrowser.cpp (from r61883, trunk/reactos/dll/win32/shell32/desktop.cpp) URL: http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rsh... ============================================================================== --- trunk/reactos/dll/win32/shell32/desktop.cpp [iso-8859-1] (original) +++ branches/shell-experiments/base/shell/rshell/CDesktopBrowser.cpp [iso-8859-1] Tue Feb 4 12:11:51 2014 @@ -209,6 +209,12 @@
SetShellWindowEx(hWnd, FindDesktopListView());
+#if 1 + /* A windows 8 specific hack */ + ::ShowWindow(hWndShellView, SW_SHOW); + ::ShowWindow(FindDesktopListView(), SW_SHOW); +#endif + return TRUE; }
@@ -258,6 +264,8 @@ { return S_FALSE; } + +typedef HRESULT (WINAPI *SH_OPEN_NEW_FRAME)(LPITEMIDLIST pidl, IUnknown *paramC, long param10, long param14);
HRESULT STDMETHODCALLTYPE CDesktopBrowser::BrowseObject(LPCITEMIDLIST pidl, UINT wFlags) { @@ -266,7 +274,15 @@ * find an open shell window that shows the requested pidl and activate it */
- return SHOpenNewFrame((LPITEMIDLIST)pidl, NULL, 0, 0); +#if 0 + HMODULE hBrowseui = LoadLibraryW(L"browseui.dll"); + if (hBrowseui) + { + SH_OPEN_NEW_FRAME SHOpenNewFrame = (SH_OPEN_NEW_FRAME)GetProcAddress(hBrowseui, (LPCSTR)103); + return SHOpenNewFrame((LPITEMIDLIST)pidl, NULL, 0, 0); + } +#endif + return E_FAIL; }
HRESULT STDMETHODCALLTYPE CDesktopBrowser::GetViewStateStream(DWORD grfMode, IStream **ppStrm)
Added: branches/shell-experiments/base/shell/rshell/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rsh... ============================================================================== --- branches/shell-experiments/base/shell/rshell/CMakeLists.txt (added) +++ branches/shell-experiments/base/shell/rshell/CMakeLists.txt [iso-8859-1] Tue Feb 4 12:11:51 2014 @@ -0,0 +1,31 @@ +PROJECT(SHELL) + +set_cpp(WITH_RUNTIME) + +include_directories(${REACTOS_SOURCE_DIR}/lib/atl) + +spec2def(rshell.dll rshell.spec ADD_IMPORTLIB) + +list(APPEND SOURCE + CDesktopBrowser.cpp + CStartMenu.cpp + misc.cpp + ${CMAKE_CURRENT_BINARY_DIR}/rshell.def) + +add_library(rshell SHARED ${SOURCE}) + +set_module_type(rshell win32dll UNICODE) + +target_link_libraries(rshell + atlnew + uuid + wine) + +add_importlibs(rshell + shlwapi + shell32 + ole32 + user32 + msvcrt + kernel32 + ntdll)
Propchange: branches/shell-experiments/base/shell/rshell/CMakeLists.txt ------------------------------------------------------------------------------ svn:eol-style = native
Added: branches/shell-experiments/base/shell/rshell/CStartMenu.cpp URL: http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rsh... ============================================================================== --- branches/shell-experiments/base/shell/rshell/CStartMenu.cpp (added) +++ branches/shell-experiments/base/shell/rshell/CStartMenu.cpp [iso-8859-1] Tue Feb 4 12:11:51 2014 @@ -0,0 +1,318 @@ +/* + * ReactOS Explorer + * + * Copyright 2014 Giannis Adamopoulos + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "precomp.h" + +/* NOTE: The following constants may *NOT* be changed because + they're hardcoded and need to be the exact values + in order to get the start menu to work! */ +#define IDM_PROGRAMS 504 +#define IDM_FAVORITES 507 +#define IDM_DOCUMENTS 501 +#define IDM_SETTINGS 508 +#define IDM_CONTROLPANEL 505 +#define IDM_SECURITY 5001 +#define IDM_NETWORKCONNECTIONS 557 +#define IDM_PRINTERSANDFAXES 510 +#define IDM_TASKBARANDSTARTMENU 413 +#define IDM_SEARCH 520 +#define IDM_HELPANDSUPPORT 503 +#define IDM_RUN 401 +#define IDM_SYNCHRONIZE 553 +#define IDM_LOGOFF 402 +#define IDM_DISCONNECT 5000 +#define IDM_UNDOCKCOMPUTER 410 +#define IDM_SHUTDOWN 506 +#define IDM_LASTSTARTMENU_SEPARATOR 450 + +/* + * TODO: + * 1. append the start menu contents from all users + * 2. implement the context menu for start menu entries (programs, control panel, network connetions, printers) + * 3. filter out programs folder from the shell folder part of the start menu + */ + +class CShellMenuCallback : + public CComObjectRootEx<CComMultiThreadModelNoCS>, + public IShellMenuCallback +{ +private: + + HWND m_hwndTray; + CComPtr<IShellMenu> m_pShellMenu; + CComPtr<IBandSite> m_pBandSite; + CComPtr<IDeskBar> m_pDeskBar; + CComPtr<ITrayPriv> m_pTrayPriv; + + HRESULT OnInitMenu() + { + HMENU hmenu; + HRESULT hr; + + if (m_pTrayPriv.p) + return S_OK; + + hr = IUnknown_GetSite(m_pDeskBar, IID_PPV_ARG(ITrayPriv, &m_pTrayPriv)); + hr = IUnknown_GetWindow(m_pTrayPriv, &m_hwndTray); + hr = m_pTrayPriv->AppendMenuW(&hmenu); + hr = m_pShellMenu->SetMenu(hmenu, NULL, SMSET_BOTTOM); + + return hr; + } + + HRESULT OnGetInfo(LPSMDATA psmd, SMINFO *psminfo) + { + int iconIndex = 0; + + switch (psmd->uId) + { + case IDM_PROGRAMS: iconIndex = -20; break; + case IDM_FAVORITES: iconIndex = -173; break; + case IDM_DOCUMENTS: iconIndex = -21; break; + case IDM_SETTINGS: iconIndex = -22; break; + case IDM_CONTROLPANEL: iconIndex = -22; break; + //case IDM_SECURITY: iconIndex = -21; break; + case IDM_NETWORKCONNECTIONS: iconIndex = -257; break; + case IDM_PRINTERSANDFAXES: iconIndex = -138; break; + case IDM_TASKBARANDSTARTMENU: iconIndex = -40; break; + case IDM_SEARCH: iconIndex = -23; break; + case IDM_HELPANDSUPPORT: iconIndex = -24; break; + case IDM_RUN: iconIndex = -25; break; + //case IDM_SYNCHRONIZE: iconIndex = -21; break; + case IDM_LOGOFF: iconIndex = -45; break; + //case IDM_DISCONNECT: iconIndex = -21; break; + //case IDM_UNDOCKCOMPUTER: iconIndex = -21; break; + case IDM_SHUTDOWN: iconIndex = -28; break; + default: + return S_FALSE; + } + + if (iconIndex) + { + psminfo->dwMask = SMIM_ICON; + psminfo->iIcon = Shell_GetCachedImageIndex(L"shell32.dll", iconIndex, FALSE); + } + return S_OK; + } + + HRESULT OnGetSubMenu(LPSMDATA psmd, REFIID iid, void ** pv) + { + HRESULT hr; + int csidl = 0; + IShellMenu *pShellMenu; + + switch (psmd->uId) + { + case IDM_PROGRAMS: csidl = CSIDL_PROGRAMS; break; + case IDM_FAVORITES: csidl = CSIDL_FAVORITES; break; + case IDM_DOCUMENTS: csidl = CSIDL_RECENT; break; + } + + hr = CoCreateInstance(CLSID_MenuBand, + NULL, + CLSCTX_INPROC_SERVER, + IID_PPV_ARG(IShellMenu,&pShellMenu)); + + hr = pShellMenu->Initialize(this, 0, ANCESTORDEFAULT, SMINIT_VERTICAL); + + if (csidl) + { + LPITEMIDLIST pidlStartMenu; + IShellFolder *psfDestop, *psfStartMenu; + + hr = SHGetFolderLocation(NULL, csidl, 0, 0, &pidlStartMenu); + hr = SHGetDesktopFolder(&psfDestop); + hr = psfDestop->BindToObject(pidlStartMenu, NULL, IID_PPV_ARG(IShellFolder, &psfStartMenu)); + + hr = pShellMenu->SetShellFolder(psfStartMenu, NULL, NULL, 0); + } + else + { + MENUITEMINFO mii; + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_SUBMENU; + if (GetMenuItemInfoW( psmd->hmenu, psmd->uId, FALSE, &mii)) + { + hr = pShellMenu->SetMenu(mii.hSubMenu, NULL, SMSET_BOTTOM); + } + } + return pShellMenu->QueryInterface(iid, pv); + } + + HRESULT OnGetContextMenu(LPSMDATA psmd, REFIID iid, void ** pv) + { + if (psmd->uId == IDM_PROGRAMS || + psmd->uId == IDM_CONTROLPANEL || + psmd->uId == IDM_NETWORKCONNECTIONS || + psmd->uId == IDM_PRINTERSANDFAXES) + { + //UNIMPLEMENTED + } + + return S_FALSE; + } + + HRESULT OnGetObject(LPSMDATA psmd, REFIID iid, void ** pv) + { + if (IsEqualIID(iid , IID_IShellMenu)) + return OnGetSubMenu(psmd, iid, pv); + else if (IsEqualIID( iid, IID_IContextMenu)) + return OnGetContextMenu(psmd, iid, pv); + + return S_FALSE; + } + + HRESULT OnExec(LPSMDATA psmd) + { + if(psmd->uId == IDM_CONTROLPANEL) + ShellExecuteW(NULL, L"open", L"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::{21EC2020-3AEA-1069-A2DD-08002B30309D}", NULL,NULL, 1); + else if(psmd->uId == IDM_NETWORKCONNECTIONS) + ShellExecuteW(NULL, L"open", L"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::{21EC2020-3AEA-1069-A2DD-08002B30309D}\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}", NULL,NULL, 1); + else if(psmd->uId == IDM_PRINTERSANDFAXES) + ShellExecuteW(NULL, L"open", L"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::{21EC2020-3AEA-1069-A2DD-08002B30309D}\::{2227A280-3AEA-1069-A2DE-08002B30309D}", NULL,NULL, 1); + else + PostMessageW( m_hwndTray, WM_COMMAND, psmd->uId, 0); + + return S_OK; + } + +public: + + DECLARE_NOT_AGGREGATABLE(CShellMenuCallback) + DECLARE_PROTECT_FINAL_CONSTRUCT() + BEGIN_COM_MAP(CShellMenuCallback) + COM_INTERFACE_ENTRY_IID(IID_IShellMenuCallback, IShellMenuCallback) + END_COM_MAP() + + void Initialize( + IShellMenu* pShellMenu, + IBandSite* pBandSite, + IDeskBar* pDeskBar) + { + m_pShellMenu.Attach(pShellMenu); + m_pBandSite.Attach(pBandSite); + m_pDeskBar.Attach(pDeskBar); + } + + ~CShellMenuCallback() + { + m_pShellMenu.Release(); + m_pBandSite.Release(); + m_pDeskBar.Release(); + } + + HRESULT STDMETHODCALLTYPE CallbackSM( + LPSMDATA psmd, + UINT uMsg, + WPARAM wParam, + LPARAM lParam) + { + switch (uMsg) + { + case SMC_INITMENU: + return OnInitMenu(); + case SMC_GETINFO: + return OnGetInfo(psmd, reinterpret_cast<SMINFO*>(lParam)); + case SMC_GETOBJECT: + return OnGetObject(psmd, *reinterpret_cast<IID *>(wParam), reinterpret_cast<void **>(lParam)); + case SMC_EXEC: + return OnExec(psmd); + case SMC_SFEXEC: + m_pTrayPriv->Execute(psmd->psf, psmd->pidlItem); + break; + } + + return S_FALSE; + } +}; + +extern "C" +HRESULT +CStartMenu_Constructor( + REFIID riid, + void **ppv) +{ + IShellMenu* pShellMenu; + IBandSite* pBandSite; + IDeskBar* pDeskBar; + IShellMenuCallback* callback; + LPITEMIDLIST pidlStartMenu; + + HRESULT hr; + IShellFolder *shellFolder; + IShellFolder *psfStartMenu; + + hr = CoCreateInstance(CLSID_MenuBand, + NULL, + CLSCTX_INPROC_SERVER, + IID_PPV_ARG(IShellMenu, &pShellMenu)); + if (FAILED(hr)) + return NULL; + +#if 1 + hr = CoCreateInstance(CLSID_MenuBandSite, + NULL, + CLSCTX_INPROC_SERVER, + IID_PPV_ARG(IBandSite, &pBandSite)); +#else + hr = CMenuSite_Constructor(IID_PPV_ARG(IBandSite, &pBandSite)); +#endif + if (FAILED(hr)) + return NULL; + + hr = CoCreateInstance(CLSID_MenuDeskBar, + NULL, + CLSCTX_INPROC_SERVER, + IID_PPV_ARG(IDeskBar, &pDeskBar)); + if (FAILED(hr)) + return NULL; + + CComObject<CShellMenuCallback> *pCallback; + hr = CComObject<CShellMenuCallback>::CreateInstance(&pCallback); + if (FAILED(hr)) + return FALSE; + pCallback->AddRef(); // CreateInstance returns object with 0 ref count */ + pCallback->Initialize(pShellMenu, pBandSite, pDeskBar); + callback = pCallback; + + hr = CShellMenuCallback::_CreatorClass::CreateInstance(NULL, IID_PPV_ARG(IShellMenuCallback, &callback)); + if (FAILED(hr)) + return NULL; + + pShellMenu->Initialize(pCallback, -1, 0, SMINIT_TOPLEVEL | SMINIT_VERTICAL); + if (FAILED(hr)) + return NULL; + + hr = SHGetFolderLocation(NULL, CSIDL_STARTMENU, 0, 0, &pidlStartMenu); + hr = SHGetDesktopFolder(&shellFolder); + hr = shellFolder->BindToObject(pidlStartMenu, NULL, IID_IShellFolder, (void**)&psfStartMenu); + + hr = pShellMenu->SetShellFolder(psfStartMenu, NULL, NULL, 0); + + hr = pDeskBar->SetClient(pBandSite); + if (FAILED(hr)) + return NULL; + + hr = pBandSite->AddBand(pShellMenu); + if (FAILED(hr)) + return NULL; + + return pDeskBar->QueryInterface(riid, ppv); +}
Propchange: branches/shell-experiments/base/shell/rshell/CStartMenu.cpp ------------------------------------------------------------------------------ svn:eol-style = native
Added: branches/shell-experiments/base/shell/rshell/misc.cpp URL: http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rsh... ============================================================================== --- branches/shell-experiments/base/shell/rshell/misc.cpp (added) +++ branches/shell-experiments/base/shell/rshell/misc.cpp [iso-8859-1] Tue Feb 4 12:11:51 2014 @@ -0,0 +1,60 @@ +/* + * ReactOS Explorer + * + * Copyright 2014 Giannis Adamopoulos + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "precomp.h" + +DWORD WINAPI WinList_Init(void) +{ + /* do something here (perhaps we may want to add our own implementation fo win8) */ + return 0; +} + +void *operator new (size_t, void *buf) +{ + return buf; +} + +class CRShellModule : public CComModule +{ +public: +}; + +CRShellModule gModule; +CAtlWinModule gWinModule; + +STDAPI_(BOOL) DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID fImpLoad) +{ + if (dwReason == DLL_PROCESS_ATTACH) + { + /* HACK - the global constructors don't run, so I placement new them here */ + new (&gModule) CRShellModule; + new (&gWinModule) CAtlWinModule; + new (&_AtlBaseModule) CAtlBaseModule; + new (&_AtlComModule) CAtlComModule; + + gModule.Init(NULL, hInstance, NULL); + DisableThreadLibraryCalls (hInstance); + } + else if (dwReason == DLL_PROCESS_DETACH) + { + gModule.Term(); + } + return TRUE; +}
Propchange: branches/shell-experiments/base/shell/rshell/misc.cpp ------------------------------------------------------------------------------ svn:eol-style = native
Added: branches/shell-experiments/base/shell/rshell/precomp.h URL: http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rsh... ============================================================================== --- branches/shell-experiments/base/shell/rshell/precomp.h (added) +++ branches/shell-experiments/base/shell/rshell/precomp.h [iso-8859-1] Tue Feb 4 12:11:51 2014 @@ -0,0 +1,55 @@ + +#include <stdio.h> +#include <tchar.h> + +#define WIN32_NO_STATUS +#define _INC_WINDOWS +#define COM_NO_WINDOWS_H + +#define COBJMACROS + +#include <windef.h> +#include <winbase.h> +#include <winreg.h> +#include <wingdi.h> +#include <winnls.h> +#include <wincon.h> +#include <shellapi.h> +#include <shlobj.h> +#include <shlobj_undoc.h> +#include <shlwapi.h> +#include <shlguid_undoc.h> +#include <uxtheme.h> +#include <strsafe.h> + +#include <atlbase.h> +#include <atlcom.h> +#include <wine/debug.h> + +#define shell32_hInstance 0 +#define SMC_EXEC 4 +extern "C" INT WINAPI Shell_GetCachedImageIndex(LPCWSTR szPath, INT nIndex, UINT bSimulateDoc); +extern "C" HRESULT CMenuSite_Constructor(REFIID riid, void **ppv); + +#define INTERFACE IExplorerHostCreator +DECLARE_INTERFACE_(IExplorerHostCreator,IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD_(HRESULT,QueryInterface) (THIS_ REFIID riid, void** ppvObject) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IExplorerHostCreator ***/ + STDMETHOD_(HRESULT,CreateHost)(/*THIS,*/ const GUID* guid) PURE; + STDMETHOD_(HRESULT,RunHost)(THIS) PURE; +}; +#undef INTERFACE + +#if defined(COBJMACROS) +/*** IUnknown methods ***/ +#define IExplorerHostCreator_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IExplorerHostCreator_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IExplorerHostCreator_Release(p) (p)->lpVtbl->Release(p) +/*** IExplorerHostCreator methods ***/ +#define IExplorerHostCreator_CreateHost(p,a) (p)->lpVtbl->CreateHost(p,a) +#define IExplorerHostCreator_RunHost(p) (p)->lpVtbl->RunHost(p) +#endif
Propchange: branches/shell-experiments/base/shell/rshell/precomp.h ------------------------------------------------------------------------------ svn:eol-style = native
Added: branches/shell-experiments/base/shell/rshell/rshell.spec URL: http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rsh... ============================================================================== --- branches/shell-experiments/base/shell/rshell/rshell.spec (added) +++ branches/shell-experiments/base/shell/rshell/rshell.spec [iso-8859-1] Tue Feb 4 12:11:51 2014 @@ -0,0 +1,4 @@ +@ stdcall CStartMenu_Constructor(ptr ptr) +@ stdcall SHDesktopMessageLoop(ptr) +@ stdcall SHCreateDesktop(ptr) +@ stdcall WinList_Init()
Propchange: branches/shell-experiments/base/shell/rshell/rshell.spec ------------------------------------------------------------------------------ svn:eol-style = native