ReactOS  0.4.12-dev-18-gf469aca
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.

Referenced by ThemeStartCallback().

38 {
39  SC_HANDLE scm, service;
41  DWORD dummy;
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 }
BOOL WINAPI QueryServiceStatusEx(SC_HANDLE hService, SC_STATUS_TYPE InfoLevel, LPBYTE lpBuffer, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
Definition: scm.c:2829
static WCHAR ServiceName[]
Definition: thmserver.c:26
SC_HANDLE WINAPI OpenServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, DWORD dwDesiredAccess)
Definition: scm.c:2102
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:576
smooth NULL
Definition: ftsmooth.c:416
#define SERVICE_QUERY_STATUS
Definition: winsvc.h:55
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
Definition: scm.c:2010
#define SYNCHRONIZE
Definition: nt_native.h:61
unsigned char BYTE
Definition: ntddk_ex.h:96
#define ERR(fmt,...)
Definition: debug.h:109
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1257
unsigned char dummy
Definition: maze.c:118
static SERVICE_STATUS status
Definition: service.c:31

◆ ThemeServiceDiedCallback()

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

Definition at line 89 of file thmserver.c.

Referenced by ThemeStartCallback().

90 {
91  /* The theme service died and we don't know if it could set its events properly */
94 
95  ThemeStopCallback(lpParameter, TimerOrWaitFired);
96 }
static VOID CALLBACK ThemeStopCallback(PVOID lpParameter, BOOLEAN TimerOrWaitFired)
Definition: thmserver.c:76
HANDLE hStopEvent
Definition: thmserver.c:29
HANDLE hStartEvent
Definition: thmserver.c:29
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:660

◆ ThemeStartCallback()

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

Definition at line 101 of file thmserver.c.

Referenced by ThemeWatchForStart().

102 {
104 
106 
109 
111 }
BOOL WINAPI ThemeHooksInstall()
Definition: themehooks.c:664
HANDLE hThemeStopWaitObject
Definition: thmserver.c:28
BOOL WINAPI UnregisterWait(IN HANDLE WaitHandle)
Definition: synch.c:880
HANDLE hServiceProcess
Definition: thmserver.c:29
smooth NULL
Definition: ftsmooth.c:416
static VOID CALLBACK ThemeStopCallback(PVOID lpParameter, BOOLEAN TimerOrWaitFired)
Definition: thmserver.c:76
static HANDLE GetThemeServiceProcessHandle(VOID)
Definition: thmserver.c:37
HANDLE hStopEvent
Definition: thmserver.c:29
HANDLE hThemeStartWaitObject
Definition: thmserver.c:28
BOOL WINAPI RegisterWaitForSingleObject(OUT PHANDLE phNewWaitObject, IN HANDLE hObject, IN WAITORTIMERCALLBACK Callback, IN PVOID Context, IN ULONG dwMilliseconds, IN ULONG dwFlags)
Definition: synch.c:796
static VOID CALLBACK ThemeServiceDiedCallback(PVOID lpParameter, BOOLEAN TimerOrWaitFired)
Definition: thmserver.c:89
#define INFINITE
Definition: serial.h:102
#define WT_EXECUTEDEFAULT
Definition: winnt_old.h:1071
HANDLE hThemeServiceWaitObject
Definition: thmserver.c:28

◆ ThemeStopCallback()

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

Definition at line 76 of file thmserver.c.

Referenced by ThemeServiceDiedCallback(), and ThemeStartCallback().

77 {
81 
84 }
#define CloseHandle
Definition: compat.h:398
BOOL WINAPI ThemeHooksRemove()
Definition: themehooks.c:706
HANDLE hThemeStopWaitObject
Definition: thmserver.c:28
BOOL WINAPI UnregisterWait(IN HANDLE WaitHandle)
Definition: synch.c:880
HANDLE hServiceProcess
Definition: thmserver.c:29
BOOL WINAPI ThemeWatchForStart(VOID)
Definition: thmserver.c:115
HANDLE hThemeServiceWaitObject
Definition: thmserver.c:28

◆ 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
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:445
#define SERVICE_START_PENDING
Definition: winsvc.h:22
BOOL WINAPI QueryServiceStatusEx(SC_HANDLE hService, SC_STATUS_TYPE InfoLevel, LPBYTE lpBuffer, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
Definition: scm.c:2829
static WCHAR ServiceName[]
Definition: thmserver.c:26
#define SERVICE_RUNNING
Definition: winsvc.h:24
SC_HANDLE WINAPI OpenServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, DWORD dwDesiredAccess)
Definition: scm.c:2102
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:576
smooth NULL
Definition: ftsmooth.c:416
#define SERVICE_QUERY_STATUS
Definition: winsvc.h:55
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
Definition: scm.c:2010
unsigned char BYTE
Definition: ntddk_ex.h:96
#define ERR(fmt,...)
Definition: debug.h:109
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD dwTimeout
Definition: wincrypt.h:6079
unsigned char dummy
Definition: maze.c:118
static SERVICE_STATUS status
Definition: service.c:31

◆ ThemeWatchForStart()

BOOL WINAPI ThemeWatchForStart ( VOID  )

Definition at line 115 of file thmserver.c.

Referenced by ThemeStopCallback().

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 TRUE
Definition: types.h:120
static VOID CALLBACK ThemeStartCallback(PVOID lpParameter, BOOLEAN TimerOrWaitFired)
Definition: thmserver.c:101
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:597
smooth NULL
Definition: ftsmooth.c:416
HANDLE hStopEvent
Definition: thmserver.c:29
HANDLE hStartEvent
Definition: thmserver.c:29
static const WCHAR L[]
Definition: oid.c:1087
HANDLE hThemeStartWaitObject
Definition: thmserver.c:28
BOOL WINAPI RegisterWaitForSingleObject(OUT PHANDLE phNewWaitObject, IN HANDLE hObject, IN WAITORTIMERCALLBACK Callback, IN PVOID Context, IN ULONG dwMilliseconds, IN ULONG dwFlags)
Definition: synch.c:796
#define INFINITE
Definition: serial.h:102
#define WT_EXECUTEDEFAULT
Definition: winnt_old.h:1071

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shsvcs  )

Variable Documentation

◆ hServiceProcess

HANDLE hServiceProcess

Definition at line 29 of file thmserver.c.

◆ hStartEvent

HANDLE hStartEvent

Definition at line 29 of file thmserver.c.

◆ hStopEvent

HANDLE hStopEvent

Definition at line 29 of file thmserver.c.

◆ hThemeServiceWaitObject

HANDLE hThemeServiceWaitObject

Definition at line 28 of file thmserver.c.

◆ hThemeStartWaitObject

HANDLE hThemeStartWaitObject

Definition at line 28 of file thmserver.c.

◆ hThemeStopWaitObject

HANDLE hThemeStopWaitObject

Definition at line 28 of file thmserver.c.

◆ ServiceName

WCHAR ServiceName[] = L"Themes"
static

Definition at line 26 of file thmserver.c.

Referenced by GetThemeServiceProcessHandle(), and ThemeWaitForServiceReady().