Author: dquintana Date: Wed Jul 23 18:00:36 2014 New Revision: 63732
URL: http://svn.reactos.org/svn/reactos?rev=63732&view=rev Log: [STOBJECT] * Create skeleton for the SysTray shell service object DLL. No tray icons are created yet. * Tranks Robert Naumann for providing the icon resources, and some file templates.
Added: branches/shell-experiments/dll/win32/stobject/ (with props) branches/shell-experiments/dll/win32/stobject/CMakeLists.txt (with props) branches/shell-experiments/dll/win32/stobject/lang/ (with props) branches/shell-experiments/dll/win32/stobject/lang/de-DE.rc (with props) branches/shell-experiments/dll/win32/stobject/lang/en-US.rc (with props) branches/shell-experiments/dll/win32/stobject/precomp.h (with props) branches/shell-experiments/dll/win32/stobject/resource.h (with props) branches/shell-experiments/dll/win32/stobject/resources/ (with props) branches/shell-experiments/dll/win32/stobject/resources/1.ico (with props) branches/shell-experiments/dll/win32/stobject/resources/2.ico (with props) branches/shell-experiments/dll/win32/stobject/resources/3.ico (with props) branches/shell-experiments/dll/win32/stobject/resources/4.ico (with props) branches/shell-experiments/dll/win32/stobject/resources/rgs/ (with props) branches/shell-experiments/dll/win32/stobject/resources/rgs/systray.rgs (with props) branches/shell-experiments/dll/win32/stobject/stobject.cpp (with props) branches/shell-experiments/dll/win32/stobject/stobject.rc (with props) branches/shell-experiments/dll/win32/stobject/stobject.spec (with props) Modified: branches/shell-experiments/base/shell/rshell/CStartMenu.cpp branches/shell-experiments/dll/win32/CMakeLists.txt
Modified: 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 [iso-8859-1] (original) +++ branches/shell-experiments/base/shell/rshell/CStartMenu.cpp [iso-8859-1] Wed Jul 23 18:00:36 2014 @@ -412,6 +412,8 @@ return hr;
hr = SHGetSpecialFolderLocation(NULL, CSIDL_PROGRAMS, &pidlProgramsAbsolute); + if (FAILED_UNEXPECTEDLY(hr)) + return hr;
pidlPrograms = ILClone(ILFindLastID(pidlProgramsAbsolute)); ILFree(pidlProgramsAbsolute);
Modified: branches/shell-experiments/dll/win32/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/CMak... ============================================================================== --- branches/shell-experiments/dll/win32/CMakeLists.txt [iso-8859-1] (original) +++ branches/shell-experiments/dll/win32/CMakeLists.txt [iso-8859-1] Wed Jul 23 18:00:36 2014 @@ -193,6 +193,7 @@ add_subdirectory(stdole2.tlb) add_subdirectory(stdole32.tlb) add_subdirectory(sti) +add_subdirectory(stobject) add_subdirectory(sxs) add_subdirectory(syssetup) add_subdirectory(t2embed)
Propchange: branches/shell-experiments/dll/win32/stobject/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Wed Jul 23 18:00:36 2014 @@ -0,0 +1,2 @@ +([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))? +(\d+)
Propchange: branches/shell-experiments/dll/win32/stobject/ ------------------------------------------------------------------------------ bugtraq:message = See issue #%BUGID% for more details.
Propchange: branches/shell-experiments/dll/win32/stobject/ ------------------------------------------------------------------------------ bugtraq:url = http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Propchange: branches/shell-experiments/dll/win32/stobject/ ------------------------------------------------------------------------------ tsvn:logminsize = 10
Added: branches/shell-experiments/dll/win32/stobject/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/stob... ============================================================================== --- branches/shell-experiments/dll/win32/stobject/CMakeLists.txt (added) +++ branches/shell-experiments/dll/win32/stobject/CMakeLists.txt [iso-8859-1] Wed Jul 23 18:00:36 2014 @@ -0,0 +1,36 @@ + +project(SHELL) + +set_cpp(WITH_RUNTIME) + +if(NOT MSVC) + # HACK: this should be enabled globally! + add_compile_flags_language("-std=c++11" "CXX") +endif() + +include_directories( + ${REACTOS_SOURCE_DIR}/lib/atl + ${REACTOS_SOURCE_DIR}) + +spec2def(stobject.dll stobject.spec) + +add_library(stobject SHARED + stobject.cpp + stobject.rc + ${CMAKE_CURRENT_BINARY_DIR}/stobject.def) + +set_module_type(stobject win32dll UNICODE) +target_link_libraries(stobject uuid wine atlnew) + +add_importlibs(stobject + advapi32 + ole32 + gdi32 + user32 + comctl32 + shlwapi + msvcrt + kernel32 + ntdll) + +add_cd_file(TARGET stobject DESTINATION reactos/system32 FOR all)
Propchange: branches/shell-experiments/dll/win32/stobject/CMakeLists.txt ------------------------------------------------------------------------------ svn:eol-style = native
Propchange: branches/shell-experiments/dll/win32/stobject/lang/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Wed Jul 23 18:00:36 2014 @@ -0,0 +1,2 @@ +([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))? +(\d+)
Propchange: branches/shell-experiments/dll/win32/stobject/lang/ ------------------------------------------------------------------------------ bugtraq:message = See issue #%BUGID% for more details.
Propchange: branches/shell-experiments/dll/win32/stobject/lang/ ------------------------------------------------------------------------------ bugtraq:url = http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Propchange: branches/shell-experiments/dll/win32/stobject/lang/ ------------------------------------------------------------------------------ tsvn:logminsize = 10
Added: branches/shell-experiments/dll/win32/stobject/lang/de-DE.rc URL: http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/stob... ============================================================================== --- branches/shell-experiments/dll/win32/stobject/lang/de-DE.rc (added) +++ branches/shell-experiments/dll/win32/stobject/lang/de-DE.rc [iso-8859-1] Wed Jul 23 18:00:36 2014 @@ -0,0 +1,2 @@ +LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL +
Propchange: branches/shell-experiments/dll/win32/stobject/lang/de-DE.rc ------------------------------------------------------------------------------ svn:eol-style = native
Added: branches/shell-experiments/dll/win32/stobject/lang/en-US.rc URL: http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/stob... ============================================================================== --- branches/shell-experiments/dll/win32/stobject/lang/en-US.rc (added) +++ branches/shell-experiments/dll/win32/stobject/lang/en-US.rc [iso-8859-1] Wed Jul 23 18:00:36 2014 @@ -0,0 +1 @@ +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
Propchange: branches/shell-experiments/dll/win32/stobject/lang/en-US.rc ------------------------------------------------------------------------------ svn:eol-style = native
Added: branches/shell-experiments/dll/win32/stobject/precomp.h URL: http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/stob... ============================================================================== --- branches/shell-experiments/dll/win32/stobject/precomp.h (added) +++ branches/shell-experiments/dll/win32/stobject/precomp.h [iso-8859-1] Wed Jul 23 18:00:36 2014 @@ -0,0 +1,75 @@ +#pragma once + +#define WIN32_NO_STATUS +#include <stdarg.h> +#include <tchar.h> + +#define COBJMACROS +#define WIN32_NO_STATUS +#define _INC_WINDOWS +#define COM_NO_WINDOWS_H +#define NTOS_MODE_USER + +#include <windef.h> +#include <winbase.h> +#include <winreg.h> +#include <winuser.h> +#include <wincon.h> +#include <ddeml.h> +#include <shlguid_undoc.h> +#include <shlwapi.h> +#include <shlobj.h> +#include <shlobj_undoc.h> +#include <shlwapi_undoc.h> +#include <tchar.h> +#include <strsafe.h> +#include <atlbase.h> +#include <atlcom.h> + +#include <wine/debug.h> +#include <wine/unicode.h> + +extern const GUID CLSID_SysTray; + +#include "resource.h" + +static __inline ULONG +Win32DbgPrint(const char *filename, int line, const char *lpFormat, ...) +{ + char szMsg[512]; + char *szMsgStart; + const char *fname; + va_list vl; + ULONG uRet; + + fname = strrchr(filename, '\'); + if (fname == NULL) + { + fname = strrchr(filename, '/'); + } + + if (fname == NULL) + fname = filename; + else + fname++; + + szMsgStart = szMsg + sprintf(szMsg, "[%10lu] %s:%d: ", GetTickCount(), fname, line); + + va_start(vl, lpFormat); + uRet = (ULONG) vsprintf(szMsgStart, lpFormat, vl); + va_end(vl); + + OutputDebugStringA(szMsg); + + return uRet; +} + +#define DbgPrint(fmt, ...) \ + Win32DbgPrint(__FILE__, __LINE__, fmt, ##__VA_ARGS__) + +#if 1 +#define FAILED_UNEXPECTEDLY(hr) (FAILED(hr) && (DbgPrint("Unexpected failure %08x.\n", hr), TRUE)) +#else +#define FAILED_UNEXPECTEDLY(hr) FAILED(hr) +#endif +
Propchange: branches/shell-experiments/dll/win32/stobject/precomp.h ------------------------------------------------------------------------------ svn:eol-style = native
Added: branches/shell-experiments/dll/win32/stobject/resource.h URL: http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/stob... ============================================================================== --- branches/shell-experiments/dll/win32/stobject/resource.h (added) +++ branches/shell-experiments/dll/win32/stobject/resource.h [iso-8859-1] Wed Jul 23 18:00:36 2014 @@ -0,0 +1,8 @@ +#pragma once + +#define IDI_ICON1 200 +#define IDI_ICON2 210 +#define IDI_ICON3 230 +#define IDI_ICON4 231 + +#define IDR_SYSTRAY 11001
Propchange: branches/shell-experiments/dll/win32/stobject/resource.h ------------------------------------------------------------------------------ svn:eol-style = native
Propchange: branches/shell-experiments/dll/win32/stobject/resources/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Wed Jul 23 18:00:36 2014 @@ -0,0 +1,2 @@ +([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))? +(\d+)
Propchange: branches/shell-experiments/dll/win32/stobject/resources/ ------------------------------------------------------------------------------ bugtraq:message = See issue #%BUGID% for more details.
Propchange: branches/shell-experiments/dll/win32/stobject/resources/ ------------------------------------------------------------------------------ bugtraq:url = http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Propchange: branches/shell-experiments/dll/win32/stobject/resources/ ------------------------------------------------------------------------------ tsvn:logminsize = 10
Added: branches/shell-experiments/dll/win32/stobject/resources/1.ico URL: http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/stob... ============================================================================== Binary file - no diff available.
Propchange: branches/shell-experiments/dll/win32/stobject/resources/1.ico ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream
Added: branches/shell-experiments/dll/win32/stobject/resources/2.ico URL: http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/stob... ============================================================================== Binary file - no diff available.
Propchange: branches/shell-experiments/dll/win32/stobject/resources/2.ico ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream
Added: branches/shell-experiments/dll/win32/stobject/resources/3.ico URL: http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/stob... ============================================================================== Binary file - no diff available.
Propchange: branches/shell-experiments/dll/win32/stobject/resources/3.ico ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream
Added: branches/shell-experiments/dll/win32/stobject/resources/4.ico URL: http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/stob... ============================================================================== Binary file - no diff available.
Propchange: branches/shell-experiments/dll/win32/stobject/resources/4.ico ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream
Propchange: branches/shell-experiments/dll/win32/stobject/resources/rgs/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Wed Jul 23 18:00:36 2014 @@ -0,0 +1,2 @@ +([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))? +(\d+)
Propchange: branches/shell-experiments/dll/win32/stobject/resources/rgs/ ------------------------------------------------------------------------------ bugtraq:message = See issue #%BUGID% for more details.
Propchange: branches/shell-experiments/dll/win32/stobject/resources/rgs/ ------------------------------------------------------------------------------ bugtraq:url = http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Propchange: branches/shell-experiments/dll/win32/stobject/resources/rgs/ ------------------------------------------------------------------------------ tsvn:logminsize = 10
Added: branches/shell-experiments/dll/win32/stobject/resources/rgs/systray.rgs URL: http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/stob... ============================================================================== --- branches/shell-experiments/dll/win32/stobject/resources/rgs/systray.rgs (added) +++ branches/shell-experiments/dll/win32/stobject/resources/rgs/systray.rgs [iso-8859-1] Wed Jul 23 18:00:36 2014 @@ -0,0 +1,13 @@ +HKCR +{ + NoRemove CLSID + { + ForceRemove {35CEC8A3-2BE6-11D2-8773-92E220524153} = s 'SysTray' + { + InprocServer32 = s '%MODULE%' + { + val ThreadingModel = s 'Both' + } + } + } +}
Propchange: branches/shell-experiments/dll/win32/stobject/resources/rgs/systray.rgs ------------------------------------------------------------------------------ svn:eol-style = native
Added: branches/shell-experiments/dll/win32/stobject/stobject.cpp URL: http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/stob... ============================================================================== --- branches/shell-experiments/dll/win32/stobject/stobject.cpp (added) +++ branches/shell-experiments/dll/win32/stobject/stobject.cpp [iso-8859-1] Wed Jul 23 18:00:36 2014 @@ -0,0 +1,165 @@ +/* + * PROJECT: ReactOS system libraries + * LICENSE: GPL - See COPYING in the top level directory + * FILE: dll\win32\stobject\stobject.c + * PURPOSE: Systray shell service object + * PROGRAMMERS: Copyright 2014 Robert Naumann + */ + +#include "precomp.h" + +#include <olectl.h> + +WINE_DEFAULT_DEBUG_CHANNEL(stobject); + +const GUID CLSID_SysTray = { 0x35CEC8A3, 0x2BE6, 0x11D2, { 0x87, 0x73, 0x92, 0xE2, 0x20, 0x52, 0x41, 0x53 } }; + +class CShellTrayModule : public CComModule +{ +public: +}; + +class CSysTray : + public CComCoClass<CSysTray, &CLSID_SysTray>, + public CComObjectRootEx<CComMultiThreadModelNoCS>, + public IOleCommandTarget +{ + // TODO: keep icon handlers here + +public: + CSysTray() {} + virtual ~CSysTray() {} + + // *** IOleCommandTarget methods *** + virtual HRESULT STDMETHODCALLTYPE QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds [], OLECMDTEXT *pCmdText) + { + UNIMPLEMENTED; + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) + { + if (!IsEqualGUID(*pguidCmdGroup, CGID_ShellServiceObject)) + return E_FAIL; + + switch (nCmdID) + { + case OLECMDID_NEW: // init + DbgPrint("CSysTray Init TODO: Initialize tray icon handlers.\n"); + break; + case OLECMDID_SAVE: // shutdown + DbgPrint("CSysTray Shutdown TODO: Shutdown.\n"); + break; + } + return S_OK; + } + + DECLARE_REGISTRY_RESOURCEID(IDR_SYSTRAY) + DECLARE_NOT_AGGREGATABLE(CSysTray) + DECLARE_PROTECT_FINAL_CONSTRUCT() + + BEGIN_COM_MAP(CSysTray) + COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget, IOleCommandTarget) + END_COM_MAP() +}; + + +BEGIN_OBJECT_MAP(ObjectMap) + OBJECT_ENTRY(CLSID_SysTray, CSysTray) +END_OBJECT_MAP() + +CShellTrayModule gModule; + +HINSTANCE g_hInstance; + +HRESULT RegisterShellServiceObject(REFGUID guidClass, LPCWSTR lpName, BOOL bRegister) +{ + const LPCWSTR strRegistryLocation = L"Software\Microsoft\Windows\CurrentVersion\ShellServiceObjectDelayLoad"; + + OLECHAR strGuid[128]; // shouldn't need so much! + LSTATUS ret = 0; + HKEY hKey = 0; + if (StringFromGUID2(guidClass, strGuid, 128)) + { + if (!RegOpenKeyExW(HKEY_LOCAL_MACHINE, strRegistryLocation, 0, KEY_WRITE, &hKey)) + { + if (bRegister) + { + LONG cbGuid = (lstrlenW(strGuid) + 1) * 2; + ret = RegSetValueExW(hKey, lpName, 0, REG_SZ, (const BYTE *) strGuid, cbGuid); + } + else + { + ret = RegDeleteValueW(hKey, lpName); + } + } + } + if (hKey) + RegCloseKey(hKey); + return /*HRESULT_FROM_NT*/(ret); // regsvr32 considers anything != S_OK to be an error + +} + +void *operator new (size_t, void *buf) +{ + return buf; +} + +BOOL +WINAPI +DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad) +{ + if (fdwReason == DLL_PROCESS_ATTACH) + { + /* HACK - the global constructors don't run, so I placement new them here */ + new (&gModule) CShellTrayModule; + new (&_AtlWinModule) CAtlWinModule; + new (&_AtlBaseModule) CAtlBaseModule; + new (&_AtlComModule) CAtlComModule; + + g_hInstance = hinstDLL; + DisableThreadLibraryCalls(g_hInstance); + + gModule.Init(ObjectMap, g_hInstance, NULL); + } + else if (fdwReason == DLL_PROCESS_DETACH) + { + g_hInstance = NULL; + gModule.Term(); + } + return TRUE; +} + +HRESULT +WINAPI +DllCanUnloadNow(void) +{ + return gModule.DllCanUnloadNow(); +} + +STDAPI +DllRegisterServer(void) +{ + HRESULT hr = gModule.DllRegisterServer(FALSE); + if (FAILED(hr)) + return hr; + + return RegisterShellServiceObject(CLSID_SysTray, L"SysTray", TRUE); +} + +STDAPI +DllUnregisterServer(void) +{ + RegisterShellServiceObject(CLSID_SysTray, L"SysTray", FALSE); + + return gModule.DllUnregisterServer(FALSE); +} + +STDAPI +DllGetClassObject( + REFCLSID rclsid, + REFIID riid, + LPVOID *ppv) +{ + return gModule.DllGetClassObject(rclsid, riid, ppv); +}
Propchange: branches/shell-experiments/dll/win32/stobject/stobject.cpp ------------------------------------------------------------------------------ svn:eol-style = native
Added: branches/shell-experiments/dll/win32/stobject/stobject.rc URL: http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/stob... ============================================================================== --- branches/shell-experiments/dll/win32/stobject/stobject.rc (added) +++ branches/shell-experiments/dll/win32/stobject/stobject.rc [iso-8859-1] Wed Jul 23 18:00:36 2014 @@ -0,0 +1,26 @@ +#include <windef.h> +#include <winuser.h> +#include <commctrl.h> + +#include "resource.h" + +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL + +IDI_ICON1 ICON "resources/1.ico" +IDI_ICON2 ICON "resources/2.ico" +IDI_ICON3 ICON "resources/3.ico" +IDI_ICON4 ICON "resources/4.ico" + +IDR_SYSTRAY REGISTRY "resources/rgs/systray.rgs" + +/* UTF-8 */ +#pragma code_page(65001) + +#if 0 +#ifdef LANGUAGE_DE_DE + #include "lang/de-DE.rc" +#endif +#ifdef LANGUAGE_EN_US + #include "lang/en-US.rc" +#endif +#endif
Propchange: branches/shell-experiments/dll/win32/stobject/stobject.rc ------------------------------------------------------------------------------ svn:eol-style = native
Added: branches/shell-experiments/dll/win32/stobject/stobject.spec URL: http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/stob... ============================================================================== --- branches/shell-experiments/dll/win32/stobject/stobject.spec (added) +++ branches/shell-experiments/dll/win32/stobject/stobject.spec [iso-8859-1] Wed Jul 23 18:00:36 2014 @@ -0,0 +1,4 @@ +@ stdcall -private DllCanUnloadNow() +@ stdcall -private DllGetClassObject(ptr ptr ptr) +@ stdcall -private DllRegisterServer() +@ stdcall -private DllUnregisterServer()
Propchange: branches/shell-experiments/dll/win32/stobject/stobject.spec ------------------------------------------------------------------------------ svn:eol-style = native