ReactOS  0.4.14-dev-604-gcfdd483
main.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Print Spooler Service
3  * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE: Main functions
5  * COPYRIGHT: Copyright 2015 Colin Finck (colin@reactos.org)
6  */
7 
8 #include "precomp.h"
9 
12 WCHAR wszServiceName[] = L"Spooler";
13 
14 static void
15 _UpdateServiceStatus(DWORD dwNewStatus, DWORD dwCheckPoint)
16 {
17  ServiceStatus.dwCheckPoint = dwCheckPoint;
18  ServiceStatus.dwCurrentState = dwNewStatus;
20 }
21 
22 static DWORD WINAPI
23 _ServiceControlHandlerEx(DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext)
24 {
25  switch (dwControl)
26  {
32  return NO_ERROR;
33 
35  return NO_ERROR;
36 
37  default:
39  }
40 }
41 
42 static VOID WINAPI
43 _ServiceMain(DWORD dwArgc, LPWSTR* lpszArgv)
44 {
46 
47  UNREFERENCED_PARAMETER(dwArgc);
48  UNREFERENCED_PARAMETER(lpszArgv);
49 
50  // Register our service for control
52 
53  // Report initial SERVICE_START_PENDING status
60 
61  // Create a thread for serving RPC requests
63  if (!hThread)
64  {
65  ERR("CreateThread failed with error %u!\n", GetLastError());
67  return;
68  }
69 
70  // We don't need the thread handle. Keeping it open blocks the thread from terminating.
72 
73  // Initialize the routing layer in spoolss.dll
75  {
76  ERR("InitializeRouter failed with error %lu!\n", GetLastError());
78  return;
79  }
80 
81  // We're alive!
83 }
84 
85 int
86 wmain(int argc, WCHAR* argv[])
87 {
89  {
91  {NULL, NULL}
92  };
93 
96 
98 
99  return 0;
100 }
static int argc
Definition: ServiceArgs.c:12
DWORD(WINAPI * LPTHREAD_START_ROUTINE)(LPVOID)
Definition: winbase.h:707
#define CloseHandle
Definition: compat.h:406
RPC_STATUS WINAPI RpcMgmtStopServerListening(RPC_BINDING_HANDLE Binding)
Definition: rpc_server.c:1596
DWORD dwCurrentState
Definition: winsvc.h:100
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define SERVICE_ACCEPT_STOP
Definition: winsvc.h:28
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define SERVICE_START_PENDING
Definition: winsvc.h:22
DWORD dwServiceSpecificExitCode
Definition: winsvc.h:103
#define argv
Definition: mplay32.c:18
WCHAR wszServiceName[]
Definition: main.c:12
#define NO_ERROR
Definition: dderror.h:5
int wmain(int argc, WCHAR *argv[])
Definition: main.c:269
BOOL WINAPI StartServiceCtrlDispatcherW(const SERVICE_TABLE_ENTRYW *lpServiceStartTable)
Definition: sctrl.c:1132
DWORD WINAPI LrpcThreadProc(LPVOID lpParameter)
Definition: rpcserver.c:11
BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
Definition: sctrl.c:995
DWORD dwCheckPoint
Definition: winsvc.h:104
#define SERVICE_STOPPED
Definition: winsvc.h:21
#define SERVICE_RUNNING
Definition: winsvc.h:24
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:136
smooth NULL
Definition: ftsmooth.c:416
#define SERVICE_CONTROL_INTERROGATE
Definition: winsvc.h:39
SERVICE_STATUS ServiceStatus
Definition: main.c:11
#define SERVICE_WIN32_OWN_PROCESS
Definition: cmtypes.h:960
static SERVICE_STATUS_HANDLE(WINAPI *pRegisterServiceCtrlHandlerExA)(LPCSTR
#define SERVICE_ACCEPT_SHUTDOWN
Definition: winsvc.h:30
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD dwWaitHint
Definition: winsvc.h:105
#define WINAPI
Definition: msvc.h:6
DWORD dwWin32ExitCode
Definition: winsvc.h:102
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dwServiceType
Definition: winsvc.h:99
static const WCHAR L[]
Definition: oid.c:1250
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExW(LPCWSTR lpServiceName, LPHANDLER_FUNCTION_EX lpHandlerProc, LPVOID lpContext)
Definition: sctrl.c:810
static void _UpdateServiceStatus(DWORD dwNewStatus, DWORD dwCheckPoint)
Definition: main.c:15
SERVICE_STATUS_HANDLE hServiceStatus
Definition: main.c:10
#define ERR(fmt,...)
Definition: debug.h:109
DWORD dwControlsAccepted
Definition: winsvc.h:101
static DWORD WINAPI _ServiceControlHandlerEx(DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext)
Definition: main.c:23
HANDLE hThread
Definition: wizard.c:27
static VOID WINAPI _ServiceMain(DWORD dwArgc, LPWSTR *lpszArgv)
Definition: main.c:43
BOOL WINAPI InitializeRouter(HANDLE SpoolerStatusHandle)
Definition: main.c:199
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define SERVICE_CONTROL_STOP
Definition: winsvc.h:36
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define SERVICE_STOP_PENDING
Definition: winsvc.h:23
SERVICE_TABLE_ENTRYW ServiceTable[]
Definition: service.c:18
#define SERVICE_CONTROL_SHUTDOWN
Definition: winsvc.h:40