Author: gadamopoulos
Date: Fri Apr 7 13:01:42 2017
New Revision: 74279
URL:
http://svn.reactos.org/svn/reactos?rev=74279&view=rev
Log:
[SHSVCS] -Add the module that should host the theme service. Implement
ThemeWaitForServiceReady and ThemeWatchForStart. These are already called by our msgina
and are responsible for starting themes in the session.
Added:
trunk/reactos/base/services/shsvcs/
trunk/reactos/base/services/shsvcs/CMakeLists.txt (with props)
trunk/reactos/base/services/shsvcs/shsvcs.c (with props)
trunk/reactos/base/services/shsvcs/shsvcs.rc (with props)
trunk/reactos/base/services/shsvcs/shsvcs.spec (with props)
trunk/reactos/base/services/shsvcs/thmserver.c (with props)
trunk/reactos/base/services/shsvcs/thmsvc.c
- copied, changed from r74278, trunk/reactos/base/services/thmsvc/thmsvc.c
Removed:
trunk/reactos/base/services/thmsvc/
Modified:
trunk/reactos/base/services/CMakeLists.txt
trunk/reactos/boot/bootdata/hivesft.inf
trunk/reactos/boot/bootdata/hivesys.inf
Modified: trunk/reactos/base/services/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/CMakeLists.t…
==============================================================================
--- trunk/reactos/base/services/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/base/services/CMakeLists.txt [iso-8859-1] Fri Apr 7 13:01:42 2017
@@ -4,12 +4,12 @@
add_subdirectory(eventlog)
add_subdirectory(rpcss)
add_subdirectory(schedsvc)
+add_subdirectory(shsvcs)
add_subdirectory(srvsvc)
add_subdirectory(svchost)
add_subdirectory(tcpsvcs)
add_subdirectory(telnetd)
#add_subdirectory(tftpd)
-add_subdirectory(thmsvc)
add_subdirectory(umpnpmgr)
add_subdirectory(wkssvc)
add_subdirectory(wlansvc)
Added: trunk/reactos/base/services/shsvcs/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/shsvcs/CMake…
==============================================================================
--- trunk/reactos/base/services/shsvcs/CMakeLists.txt (added)
+++ trunk/reactos/base/services/shsvcs/CMakeLists.txt [iso-8859-1] Fri Apr 7 13:01:42
2017
@@ -0,0 +1,15 @@
+
+spec2def(shsvcs.dll shsvcs.spec ADD_IMPORTLIB)
+
+add_library(shsvcs SHARED
+ shsvcs.c
+ thmsvc.c
+ thmserver.c
+ shsvcs.rc
+ ${CMAKE_CURRENT_BINARY_DIR}/shsvcs_stubs.c
+ ${CMAKE_CURRENT_BINARY_DIR}/shsvcs.def)
+
+set_module_type(shsvcs win32dll UNICODE)
+target_link_libraries(shsvcs wine)
+add_importlibs(shsvcs uxtheme advapi32 msvcrt kernel32 ntdll)
+add_cd_file(TARGET shsvcs DESTINATION reactos/system32 FOR all)
Propchange: trunk/reactos/base/services/shsvcs/CMakeLists.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/base/services/shsvcs/shsvcs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/shsvcs/shsvc…
==============================================================================
--- trunk/reactos/base/services/shsvcs/shsvcs.c (added)
+++ trunk/reactos/base/services/shsvcs/shsvcs.c [iso-8859-1] Fri Apr 7 13:01:42 2017
@@ -0,0 +1,60 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS Shell
+ * FILE: base/services/shsvcs/shsvcs.c
+ * PURPOSE: ReactOS Shell Services
+ * PROGRAMMER: Giannis Adamopoulos
+ */
+
+/* INCLUDES *****************************************************************/
+
+#include <windows.h>
+#include <wine/debug.h>
+
+WINE_DEFAULT_DEBUG_CHANNEL(shsvcs);
+
+/* FUNCTIONS *****************************************************************/
+
+HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline)
+{
+ return S_OK;
+}
+
+HRESULT WINAPI DllRegisterServer()
+{
+ return S_OK;
+}
+
+HRESULT WINAPI DllUnregisterServer()
+{
+ return S_OK;
+}
+
+HRESULT WINAPI DllCanUnloadNow()
+{
+ return S_OK;
+}
+
+HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
+{
+ TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
+ return CLASS_E_CLASSNOTAVAILABLE;
+}
+
+BOOL WINAPI
+DllMain(HINSTANCE hinstDLL,
+ DWORD fdwReason,
+ LPVOID lpvReserved)
+{
+ switch (fdwReason)
+ {
+ case DLL_PROCESS_ATTACH:
+ DisableThreadLibraryCalls(hinstDLL);
+ break;
+
+ case DLL_PROCESS_DETACH:
+ break;
+ }
+
+ return TRUE;
+}
Propchange: trunk/reactos/base/services/shsvcs/shsvcs.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/base/services/shsvcs/shsvcs.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/shsvcs/shsvc…
==============================================================================
--- trunk/reactos/base/services/shsvcs/shsvcs.rc (added)
+++ trunk/reactos/base/services/shsvcs/shsvcs.rc [iso-8859-1] Fri Apr 7 13:01:42 2017
@@ -0,0 +1,5 @@
+#define REACTOS_VERSION_DLL
+#define REACTOS_STR_FILE_DESCRIPTION "Shell Services Dll"
+#define REACTOS_STR_INTERNAL_NAME "shsvcs"
+#define REACTOS_STR_ORIGINAL_FILENAME "shsvcs.dll"
+#include <reactos/version.rc>
Propchange: trunk/reactos/base/services/shsvcs/shsvcs.rc
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/base/services/shsvcs/shsvcs.spec
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/shsvcs/shsvc…
==============================================================================
--- trunk/reactos/base/services/shsvcs/shsvcs.spec (added)
+++ trunk/reactos/base/services/shsvcs/shsvcs.spec [iso-8859-1] Fri Apr 7 13:01:42 2017
@@ -0,0 +1,16 @@
+1 stdcall ThemeWatchForStart()
+2 stdcall ThemeWaitForServiceReady(long)
+#3 stub Stub3
+#4 stub Stub4
+#5 stub Stub5
+#6 stub Stub6
+#7 stub BadApplicationServiceMain
+8 stdcall DllInstall(long wstr)
+9 stdcall DllRegisterServer()
+10 stdcall DllUnregisterServer()
+#11 stub HardwareDetectionServiceMain
+12 stdcall ThemeServiceMain(long ptr)
+#13 stub CreateHardwareEventMoniker
+14 stdcall DllCanUnloadNow()
+15 stdcall DllGetClassObject(ptr ptr ptr)
+#16 stub FUSCompatibilityEntryW
Propchange: trunk/reactos/base/services/shsvcs/shsvcs.spec
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/base/services/shsvcs/thmserver.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/shsvcs/thmse…
==============================================================================
--- trunk/reactos/base/services/shsvcs/thmserver.c (added)
+++ trunk/reactos/base/services/shsvcs/thmserver.c [iso-8859-1] Fri Apr 7 13:01:42 2017
@@ -0,0 +1,177 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * FILE: base/services/thmsvc/thmserver.c
+ * PURPOSE: Themes server
+ * PROGRAMMER: Giannis Adamopoulos
+ */
+
+/*
+ * NOTE:
+ * ThemeWaitForServiceReady and ThemeWatchForStart are called from msgina
+ * so all the functions in this file run in the context of winlogon
+ */
+
+/* INCLUDES *****************************************************************/
+
+#include <windows.h>
+#include <uxtheme.h>
+#include <uxundoc.h>
+#include <wine/debug.h>
+
+WINE_DEFAULT_DEBUG_CHANNEL(shsvcs);
+
+/* GLOBALS ******************************************************************/
+
+static WCHAR ServiceName[] = L"Themes";
+
+HANDLE hThemeStartWaitObject, hThemeStopWaitObject, hThemeServiceWaitObject;
+HANDLE hStartEvent, hStopEvent, hServiceProcess;
+
+BOOL WINAPI ThemeWatchForStart();
+
+/* FUNCTIONS *****************************************************************/
+
+static
+HANDLE
+GetThemeServiceProcessHandle()
+{
+ SC_HANDLE scm, service;
+ SERVICE_STATUS_PROCESS status;
+ DWORD dummy;
+ HANDLE ret;
+
+ if (!(scm = OpenSCManagerW( NULL, NULL, 0 )))
+ {
+ ERR( "failed to open service manager\n" );
+ return NULL;
+ }
+ if (!(service = OpenServiceW( scm, ServiceName, SERVICE_QUERY_STATUS )))
+ {
+ ERR( "failed to open themes service\n" );
+ CloseServiceHandle( scm );
+ return NULL;
+ }
+
+ if (!QueryServiceStatusEx( service, SC_STATUS_PROCESS_INFO,
+ (BYTE *)&status, sizeof(status), &dummy ))
+ {
+ ERR("QueryServiceStatusEx failed\n");
+ CloseServiceHandle( service );
+ CloseServiceHandle( scm );
+ return NULL;
+ }
+
+ ret = OpenProcess(SYNCHRONIZE, FALSE, status.dwProcessId);
+
+ CloseServiceHandle( service );
+ CloseServiceHandle( scm );
+
+ return ret;
+}
+
+static
+VOID
+CALLBACK
+ThemeStopCallback(PVOID lpParameter, BOOLEAN TimerOrWaitFired)
+{
+ CloseHandle(hServiceProcess);
+ UnregisterWait(hThemeStopWaitObject);
+ UnregisterWait(hThemeServiceWaitObject);
+
+ ThemeWatchForStart();
+ ThemeHooksRemove();
+}
+
+static
+VOID
+CALLBACK
+ThemeServiceDiedCallback(PVOID lpParameter, BOOLEAN TimerOrWaitFired)
+{
+ /* The theme service died and we don't know if it could set its events properly
*/
+ ResetEvent(hStartEvent);
+ ResetEvent(hStopEvent);
+
+ ThemeStopCallback(lpParameter, TimerOrWaitFired);
+}
+
+static
+VOID
+CALLBACK
+ThemeStartCallback(PVOID lpParameter, BOOLEAN TimerOrWaitFired)
+{
+ UnregisterWait(hThemeStartWaitObject);
+
+ hServiceProcess = GetThemeServiceProcessHandle();
+
+ RegisterWaitForSingleObject(&hThemeStopWaitObject, hStopEvent, ThemeStopCallback,
NULL, INFINITE, WT_EXECUTEDEFAULT);
+ RegisterWaitForSingleObject(&hThemeServiceWaitObject, hServiceProcess,
ThemeServiceDiedCallback, NULL, INFINITE, WT_EXECUTEDEFAULT);
+
+ ThemeHooksInstall();
+}
+
+BOOL
+WINAPI
+ThemeWatchForStart()
+{
+ hStartEvent = CreateEventW(NULL, TRUE, FALSE, L"Global\\ThemeStartEvent");
+ hStopEvent = CreateEventW(NULL, TRUE, FALSE, L"Global\\ThemeStopEvent");
+
+ RegisterWaitForSingleObject(&hThemeStartWaitObject, hStartEvent,
ThemeStartCallback, NULL, INFINITE, WT_EXECUTEDEFAULT);
+
+ return TRUE;
+}
+
+DWORD
+WINAPI
+ThemeWaitForServiceReady(DWORD dwTimeout)
+{
+ SC_HANDLE scm, service;
+ SERVICE_STATUS_PROCESS status;
+ BOOL ret = FALSE;
+ DWORD start_time = GetTickCount();
+
+ TRACE("\n");
+
+ if (!(scm = OpenSCManagerW( NULL, NULL, 0 )))
+ {
+ ERR( "failed to open service manager\n" );
+ return FALSE;
+ }
+ if (!(service = OpenServiceW( scm, ServiceName, SERVICE_QUERY_STATUS )))
+ {
+ ERR( "failed to open themes service\n" );
+ CloseServiceHandle( scm );
+ return FALSE;
+ }
+
+ while(TRUE)
+ {
+ DWORD dummy;
+
+ if (!QueryServiceStatusEx( service, SC_STATUS_PROCESS_INFO,
+ (BYTE *)&status, sizeof(status), &dummy ))
+ break;
+ if (status.dwCurrentState == SERVICE_RUNNING)
+ {
+ ret = TRUE;
+ break;
+ }
+ if (status.dwCurrentState != SERVICE_START_PENDING)
+ {
+ break;
+ }
+
+ if (GetTickCount() - start_time > dwTimeout)
+ {
+ break;
+ }
+ Sleep( 100 );
+ };
+
+ CloseServiceHandle( service );
+ CloseServiceHandle( scm );
+ return ret;
+}
+
+/* EOF */
Propchange: trunk/reactos/base/services/shsvcs/thmserver.c
------------------------------------------------------------------------------
svn:eol-style = native
Copied: trunk/reactos/base/services/shsvcs/thmsvc.c (from r74278,
trunk/reactos/base/services/thmsvc/thmsvc.c)
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/shsvcs/thmsv…
==============================================================================
--- trunk/reactos/base/services/thmsvc/thmsvc.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/shsvcs/thmsvc.c [iso-8859-1] Fri Apr 7 13:01:42 2017
@@ -1,7 +1,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
- * FILE: base/services/thmsvc/thmsvc.c
+ * FILE: base/services/shsvcs/thmsvc.c
* PURPOSE: Themes service
* PROGRAMMER: Giannis Adamopoulos
*/
@@ -9,28 +9,21 @@
/* INCLUDES *****************************************************************/
#include <windows.h>
-#include <uxtheme.h>
-#include <uxundoc.h>
#include <wine/debug.h>
-WINE_DEFAULT_DEBUG_CHANNEL(thmsvc);
-
+WINE_DEFAULT_DEBUG_CHANNEL(shsvcs);
/* GLOBALS ******************************************************************/
-static VOID CALLBACK ServiceMain(DWORD argc, LPWSTR *argv);
static WCHAR ServiceName[] = L"Themes";
-static SERVICE_TABLE_ENTRYW ServiceTable[] =
-{
- {ServiceName, ServiceMain},
- {NULL, NULL}
-};
SERVICE_STATUS_HANDLE ServiceStatusHandle;
SERVICE_STATUS ServiceStatus;
/* FUNCTIONS *****************************************************************/
+
+HANDLE StartEvent, StopEvent;
static VOID
UpdateServiceStatus(DWORD dwState)
@@ -74,7 +67,10 @@
{
case SERVICE_CONTROL_STOP:
TRACE(" SERVICE_CONTROL_STOP received\n");
- ThemeHooksRemove();
+
+ /* Signal the theme server in winlogon to remove theme hooks */
+ ResetEvent(StartEvent);
+ SetEvent(StopEvent);
UpdateServiceStatus(SERVICE_STOPPED);
return ERROR_SUCCESS;
@@ -105,42 +101,30 @@
}
}
-
-static VOID CALLBACK
-ServiceMain(DWORD argc, LPWSTR *argv)
+VOID
+WINAPI
+ThemeServiceMain(DWORD argc, LPTSTR *argv)
{
UNREFERENCED_PARAMETER(argc);
UNREFERENCED_PARAMETER(argv);
- TRACE("ServiceMain() called\n");
-
ServiceStatusHandle = RegisterServiceCtrlHandlerExW(ServiceName,
ServiceControlHandler,
NULL);
+ if (!ServiceStatusHandle)
+ {
+ ERR("RegisterServiceCtrlHandlerExW() failed! (Error %lu)\n",
GetLastError());
+ return;
+ }
- TRACE("Calling SetServiceStatus()\n");
+ StartEvent = CreateEventW(NULL, TRUE, FALSE, L"Global\\ThemeStartEvent");
+ StopEvent = CreateEventW(NULL, TRUE, FALSE, L"Global\\ThemeStopEvent");
+
UpdateServiceStatus(SERVICE_RUNNING);
- TRACE("SetServiceStatus() called\n");
- ThemeHooksInstall();
-
- TRACE("ServiceMain() done\n");
-}
-
-
-int
-wmain(int argc, WCHAR *argv[])
-{
- UNREFERENCED_PARAMETER(argc);
- UNREFERENCED_PARAMETER(argv);
-
- TRACE("thmsvc: main() started\n");
-
- StartServiceCtrlDispatcher(ServiceTable);
-
- TRACE("thmsvc: main() done\n");
-
- return 0;
+ /* Signal the theme server in winlogon to install theme hooks */
+ ResetEvent(StopEvent);
+ SetEvent(StartEvent);
}
/* EOF */
Modified: trunk/reactos/boot/bootdata/hivesft.inf
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/hivesft.inf?…
==============================================================================
--- trunk/reactos/boot/bootdata/hivesft.inf [iso-8859-1] (original)
+++ trunk/reactos/boot/bootdata/hivesft.inf [iso-8859-1] Fri Apr 7 13:01:42 2017
@@ -1651,7 +1651,7 @@
; SvcHost services
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SvcHost",,0x00000012
HKLM,"SOFTWARE\Microsoft\Windows
NT\CurrentVersion\SvcHost","DcomLaunch",0x00010000,"PlugPlay"
-HKLM,"SOFTWARE\Microsoft\Windows
NT\CurrentVersion\SvcHost","netsvcs",0x00010000,"DHCP","BITS","lanmanserver","lanmanworkstation","Schedule","winmgmt"
+HKLM,"SOFTWARE\Microsoft\Windows
NT\CurrentVersion\SvcHost","netsvcs",0x00010000,"DHCP","BITS","lanmanserver","lanmanworkstation","Schedule","Themes","winmgmt"
; Win32 config
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows",,0x00000012
Modified: trunk/reactos/boot/bootdata/hivesys.inf
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/hivesys.inf?…
==============================================================================
--- trunk/reactos/boot/bootdata/hivesys.inf [iso-8859-1] (original)
+++ trunk/reactos/boot/bootdata/hivesys.inf [iso-8859-1] Fri Apr 7 13:01:42 2017
@@ -1982,10 +1982,12 @@
80,51,01,00,00,00,00,00,00,00,00,00,03,00,00,00,00,00,00,00, \
01,00,00,00,60,ea,00,00,01,00,00,00,60,ea,00,00,00,00,00,00,00,00,00,00
HKLM,"SYSTEM\CurrentControlSet\Services\Themes","Group",0x00000000,"UIGroup"
-HKLM,"SYSTEM\CurrentControlSet\Services\Themes","ImagePath",0x00020000,"%SystemRoot%\system32\thmsvc.exe"
+HKLM,"SYSTEM\CurrentControlSet\Services\Themes","ImagePath",0x00020000,"%SystemRoot%\system32\svchost.exe
-k netsvcs"
HKLM,"SYSTEM\CurrentControlSet\Services\Themes","ObjectName",0x00000000,"LocalSystem"
HKLM,"SYSTEM\CurrentControlSet\Services\Themes","Start",0x00010001,0x00000002
HKLM,"SYSTEM\CurrentControlSet\Services\Themes","Type",0x00010001,0x00000020
+HKLM,"SYSTEM\CurrentControlSet\Services\Themes\Parameters","ServiceDll",0x00020000,"%SystemRoot%\system32\shsvcs.dll"
+HKLM,"SYSTEM\CurrentControlSet\Services\Themes\Parameters","ServiceMain",0x00000000,"ThemeServiceMain"
; ReactOS Installer Service
HKLM,"SYSTEM\CurrentControlSet\Services\MSIServer","DependOnService",0x00010000,"RPCSS"