ReactOS 0.4.15-dev-8428-g6910fa6
thmserver.c File Reference
#include <windows.h>
#include <uxtheme.h>
#include <uxundoc.h>
#include <wine/debug.h>
Include dependency graph for thmserver.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shsvcs)
 
BOOL WINAPI ThemeWatchForStart (VOID)
 
static HANDLE GetThemeServiceProcessHandle (VOID)
 
static VOID CALLBACK ThemeStopCallback (PVOID lpParameter, BOOLEAN TimerOrWaitFired)
 
static VOID CALLBACK ThemeServiceDiedCallback (PVOID lpParameter, BOOLEAN TimerOrWaitFired)
 
static VOID CALLBACK ThemeStartCallback (PVOID lpParameter, BOOLEAN TimerOrWaitFired)
 
DWORD WINAPI ThemeWaitForServiceReady (DWORD dwTimeout)
 

Variables

static WCHAR ServiceName [] = L"Themes"
 
HANDLE hThemeStartWaitObject
 
HANDLE hThemeStopWaitObject
 
HANDLE hThemeServiceWaitObject
 
HANDLE hStartEvent
 
HANDLE hStopEvent
 
HANDLE hServiceProcess
 

Function Documentation

◆ GetThemeServiceProcessHandle()

static HANDLE GetThemeServiceProcessHandle ( VOID  )
static

Definition at line 37 of file thmserver.c.

38{
39 SC_HANDLE scm, service;
42 HANDLE ret;
43
44 if (!(scm = OpenSCManagerW( NULL, NULL, 0 )))
45 {
46 ERR( "failed to open service manager\n" );
47 return NULL;
48 }
49 if (!(service = OpenServiceW( scm, ServiceName, SERVICE_QUERY_STATUS )))
50 {
51 ERR( "failed to open themes service\n" );
52 CloseServiceHandle( scm );
53 return NULL;
54 }
55
57 (BYTE *)&status, sizeof(status), &dummy ))
58 {
59 ERR("QueryServiceStatusEx failed\n");
60 CloseServiceHandle( service );
61 CloseServiceHandle( scm );
62 return NULL;
63 }
64
65 ret = OpenProcess(SYNCHRONIZE, FALSE, status.dwProcessId);
66
67 CloseServiceHandle( service );
68 CloseServiceHandle( scm );
69
70 return ret;
71}
#define ERR(fmt,...)
Definition: precomp.h:57
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SYNCHRONIZE
Definition: nt_native.h:61
SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
Definition: scm.c:2068
BOOL WINAPI QueryServiceStatusEx(SC_HANDLE hService, SC_STATUS_TYPE InfoLevel, LPBYTE lpBuffer, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
Definition: scm.c:2887
SC_HANDLE WINAPI OpenServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, DWORD dwDesiredAccess)
Definition: scm.c:2160
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:580
Definition: ps.c:97
static WCHAR ServiceName[]
Definition: thmserver.c:26
int ret
#define SERVICE_QUERY_STATUS
Definition: winsvc.h:55
@ SC_STATUS_PROCESS_INFO
Definition: winsvc.h:119
unsigned char BYTE
Definition: xxhash.c:193

Referenced by ThemeStartCallback().

◆ ThemeServiceDiedCallback()

static VOID CALLBACK ThemeServiceDiedCallback ( PVOID  lpParameter,
BOOLEAN  TimerOrWaitFired 
)
static

Definition at line 88 of file thmserver.c.

89{
90 /* The theme service died and we don't know if it could set its events properly */
93
98}
#define CloseHandle
Definition: compat.h:739
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:714
BOOL WINAPI UnregisterWait(IN HANDLE WaitHandle)
Definition: synch.c:934
BOOL WINAPI ThemeHooksRemove()
Definition: themehooks.c:735
HANDLE hStartEvent
Definition: thmserver.c:29
HANDLE hServiceProcess
Definition: thmserver.c:29
HANDLE hStopEvent
Definition: thmserver.c:29
BOOL WINAPI ThemeWatchForStart(VOID)
Definition: thmserver.c:115
HANDLE hThemeStopWaitObject
Definition: thmserver.c:28

Referenced by ThemeStartCallback().

◆ ThemeStartCallback()

static VOID CALLBACK ThemeStartCallback ( PVOID  lpParameter,
BOOLEAN  TimerOrWaitFired 
)
static

Definition at line 103 of file thmserver.c.

104{
106
109
111}
#define INFINITE
Definition: serial.h:102
BOOL WINAPI RegisterWaitForSingleObject(OUT PHANDLE phNewWaitObject, IN HANDLE hObject, IN WAITORTIMERCALLBACK Callback, IN PVOID Context, IN ULONG dwMilliseconds, IN ULONG dwFlags)
Definition: synch.c:850
BOOL WINAPI ThemeHooksInstall()
Definition: themehooks.c:693
static VOID CALLBACK ThemeServiceDiedCallback(PVOID lpParameter, BOOLEAN TimerOrWaitFired)
Definition: thmserver.c:88
static HANDLE GetThemeServiceProcessHandle(VOID)
Definition: thmserver.c:37
HANDLE hThemeServiceWaitObject
Definition: thmserver.c:28
static VOID CALLBACK ThemeStopCallback(PVOID lpParameter, BOOLEAN TimerOrWaitFired)
Definition: thmserver.c:76
#define WT_EXECUTEONLYONCE
Definition: winnt_old.h:1042

Referenced by ThemeWatchForStart().

◆ ThemeStopCallback()

static VOID CALLBACK ThemeStopCallback ( PVOID  lpParameter,
BOOLEAN  TimerOrWaitFired 
)
static

◆ ThemeWaitForServiceReady()

DWORD WINAPI ThemeWaitForServiceReady ( DWORD  dwTimeout)

Definition at line 127 of file thmserver.c.

128{
129 SC_HANDLE scm, service;
131 BOOL ret = FALSE;
132 DWORD start_time = GetTickCount();
133
134 TRACE("\n");
135
136 if (!(scm = OpenSCManagerW( NULL, NULL, 0 )))
137 {
138 ERR( "failed to open service manager\n" );
139 return FALSE;
140 }
141 if (!(service = OpenServiceW( scm, ServiceName, SERVICE_QUERY_STATUS )))
142 {
143 ERR( "failed to open themes service\n" );
144 CloseServiceHandle( scm );
145 return FALSE;
146 }
147
148 while(TRUE)
149 {
150 DWORD dummy;
151
153 (BYTE *)&status, sizeof(status), &dummy ))
154 break;
155 if (status.dwCurrentState == SERVICE_RUNNING)
156 {
157 ret = TRUE;
158 break;
159 }
160 if (status.dwCurrentState != SERVICE_START_PENDING)
161 {
162 break;
163 }
164
165 if (GetTickCount() - start_time > dwTimeout)
166 {
167 break;
168 }
169 Sleep( 100 );
170 };
171
172 CloseServiceHandle( service );
173 CloseServiceHandle( scm );
174 return ret;
175}
#define TRUE
Definition: types.h:120
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD dwTimeout
Definition: wincrypt.h:6081
#define SERVICE_START_PENDING
Definition: winsvc.h:22
#define SERVICE_RUNNING
Definition: winsvc.h:24

◆ ThemeWatchForStart()

BOOL WINAPI ThemeWatchForStart ( VOID  )

Definition at line 115 of file thmserver.c.

116{
117 hStartEvent = CreateEventW(NULL, TRUE, FALSE, L"Global\\ThemeStartEvent");
118 hStopEvent = CreateEventW(NULL, TRUE, FALSE, L"Global\\ThemeStopEvent");
119
121
122 return TRUE;
123}
#define L(x)
Definition: ntvdm.h:50
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
static VOID CALLBACK ThemeStartCallback(PVOID lpParameter, BOOLEAN TimerOrWaitFired)
Definition: thmserver.c:103
HANDLE hThemeStartWaitObject
Definition: thmserver.c:28

Referenced by ThemeServiceDiedCallback(), and ThemeStopCallback().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shsvcs  )

Variable Documentation

◆ hServiceProcess

HANDLE hServiceProcess

Definition at line 29 of file thmserver.c.

Referenced by ThemeServiceDiedCallback(), ThemeStartCallback(), and ThemeStopCallback().

◆ hStartEvent

HANDLE hStartEvent

Definition at line 29 of file thmserver.c.

Referenced by ThemeServiceDiedCallback(), and ThemeWatchForStart().

◆ hStopEvent

HANDLE hStopEvent

Definition at line 29 of file thmserver.c.

Referenced by ThemeServiceDiedCallback(), ThemeStartCallback(), and ThemeWatchForStart().

◆ hThemeServiceWaitObject

HANDLE hThemeServiceWaitObject

Definition at line 28 of file thmserver.c.

Referenced by ThemeStartCallback(), and ThemeStopCallback().

◆ hThemeStartWaitObject

HANDLE hThemeStartWaitObject

Definition at line 28 of file thmserver.c.

Referenced by ThemeWatchForStart().

◆ hThemeStopWaitObject

HANDLE hThemeStopWaitObject

Definition at line 28 of file thmserver.c.

Referenced by ThemeServiceDiedCallback(), and ThemeStartCallback().

◆ ServiceName

WCHAR ServiceName[] = L"Themes"
static

Definition at line 26 of file thmserver.c.

Referenced by GetThemeServiceProcessHandle(), and ThemeWaitForServiceReady().