ReactOS  0.4.15-dev-3453-gff89651
services.c File Reference
#include "audiosrv.h"
Include dependency graph for services.c:

Go to the source code of this file.

Functions

BOOL WaitForService (SC_HANDLE hService, ULONG RetryCount)
 
BOOL StartAudioService (SC_HANDLE hSCManager, LPWSTR ServiceName, ULONG RetryCount)
 
BOOL StartSystemAudioServices (VOID)
 

Function Documentation

◆ StartAudioService()

BOOL StartAudioService ( SC_HANDLE  hSCManager,
LPWSTR  ServiceName,
ULONG  RetryCount 
)

Definition at line 41 of file services.c.

45 {
46  SC_HANDLE hService;
47  BOOL ret;
48 
50  if (!hService)
51  {
52  logmsg("Failed to open service %S %x\n", ServiceName, GetLastError());
53  return FALSE;
54  }
55 
56  if (!StartService(hService, 0, NULL))
57  {
58  logmsg("Failed to start service %S %x\n", ServiceName, GetLastError());
59  CloseServiceHandle(hService);
60  return FALSE;
61  }
62 
63  ret = WaitForService(hService, RetryCount);
64 
65  CloseServiceHandle(hService);
66  return ret;
67 }
#define StartService
Definition: winsvc.h:585
BOOL WaitForService(SC_HANDLE hService, ULONG RetryCount)
Definition: services.c:12
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define SERVICE_ALL_ACCESS
Definition: winsvc.h:62
#define OpenService
Definition: winsvc.h:576
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:580
LPTSTR ServiceName
Definition: ServiceMain.c:15
int ret
void logmsg(char *string,...)
Definition: debug.c:10
SC_HANDLE hSCManager
Definition: sc.c:12
#define NULL
Definition: types.h:112

Referenced by StartSystemAudioServices().

◆ StartSystemAudioServices()

BOOL StartSystemAudioServices ( VOID  )

Definition at line 70 of file services.c.

71 {
72  SC_HANDLE hSCManager;
73 
74  logmsg("Starting system audio services\n");
75 
77  if (!hSCManager)
78  {
79  logmsg("Failed to open service manager %x\n", GetLastError());
80  return FALSE;
81  }
82 
83  logmsg("Starting sysaudio service\n");
84  StartAudioService(hSCManager, L"sysaudio", 20);
85  logmsg("Starting wdmaud service\n");
86  StartAudioService(hSCManager, L"wdmaud", 20);
87 
89  return TRUE;
90 }
#define SC_MANAGER_CONNECT
Definition: winsvc.h:14
#define TRUE
Definition: types.h:120
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define L(x)
Definition: ntvdm.h:50
BOOL StartAudioService(SC_HANDLE hSCManager, LPWSTR ServiceName, ULONG RetryCount)
Definition: services.c:41
#define FALSE
Definition: types.h:117
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:580
#define OpenSCManager
Definition: winsvc.h:575
void logmsg(char *string,...)
Definition: debug.c:10
SC_HANDLE hSCManager
Definition: sc.c:12
#define NULL
Definition: types.h:112

Referenced by ServiceMain().

◆ WaitForService()

BOOL WaitForService ( SC_HANDLE  hService,
ULONG  RetryCount 
)

Definition at line 12 of file services.c.

15 {
16  ULONG Index = 0;
17  DWORD dwSize;
19 
20  do
21  {
23  {
24  logmsg("QueryServiceStatusEx failed %x\n", GetLastError());
25  break;
26  }
27 
28  if (Info.dwCurrentState == SERVICE_RUNNING)
29  return TRUE;
30 
31  Sleep(1000);
32 
33  } while (Index++ < RetryCount);
34 
35  logmsg("Timeout while waiting for service to become ready %p\n", hService);
36 
37  return FALSE;
38 }
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
#define TRUE
Definition: types.h:120
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
BOOL WINAPI QueryServiceStatusEx(SC_HANDLE hService, SC_STATUS_TYPE InfoLevel, LPBYTE lpBuffer, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
Definition: scm.c:2835
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:683
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
#define SERVICE_RUNNING
Definition: winsvc.h:24
_In_ WDFCOLLECTION _In_ ULONG Index
unsigned long DWORD
Definition: ntddk_ex.h:95
void logmsg(char *string,...)
Definition: debug.c:10
unsigned int ULONG
Definition: retypes.h:1
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56

Referenced by StartAudioService().