ReactOS 0.4.15-dev-7953-g1f49173
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
12WCHAR wszServiceName[] = L"Spooler";
13
14static void
15_UpdateServiceStatus(DWORD dwNewStatus, DWORD dwCheckPoint)
16{
17 ServiceStatus.dwCheckPoint = dwCheckPoint;
18 ServiceStatus.dwCurrentState = dwNewStatus;
20}
21
22static 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
42static VOID WINAPI
43_ServiceMain(DWORD dwArgc, LPWSTR* lpszArgv)
44{
46
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
85int
87{
89 {
91 {NULL, NULL}
92 };
93
96
98
99 return 0;
100}
static SERVICE_STATUS_HANDLE(WINAPI *pRegisterServiceCtrlHandlerExA)(LPCSTR
static int argc
Definition: ServiceArgs.c:12
static SERVICE_TABLE_ENTRYW ServiceTable[2]
Definition: eventlog.c:24
#define ERR(fmt,...)
Definition: debug.h:110
#define NO_ERROR
Definition: dderror.h:5
#define NULL
Definition: types.h:112
#define CloseHandle
Definition: compat.h:739
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
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:137
unsigned long DWORD
Definition: ntddk_ex.h:95
#define argv
Definition: mplay32.c:18
HANDLE hThread
Definition: wizard.c:28
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define L(x)
Definition: ntvdm.h:50
int wmain()
RPC_STATUS WINAPI RpcMgmtStopServerListening(RPC_BINDING_HANDLE Binding)
Definition: rpc_server.c:1596
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExW(LPCWSTR lpServiceName, LPHANDLER_FUNCTION_EX lpHandlerProc, LPVOID lpContext)
Definition: sctrl.c:812
BOOL WINAPI StartServiceCtrlDispatcherW(const SERVICE_TABLE_ENTRYW *lpServiceStartTable)
Definition: sctrl.c:1134
BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
Definition: sctrl.c:997
DWORD dwServiceType
Definition: winsvc.h:99
DWORD dwWin32ExitCode
Definition: winsvc.h:102
DWORD dwControlsAccepted
Definition: winsvc.h:101
DWORD dwWaitHint
Definition: winsvc.h:105
DWORD dwCurrentState
Definition: winsvc.h:100
DWORD dwCheckPoint
Definition: winsvc.h:104
DWORD dwServiceSpecificExitCode
Definition: winsvc.h:103
BOOL WINAPI InitializeRouter(HANDLE SpoolerStatusHandle)
Definition: main.c:199
SERVICE_STATUS_HANDLE hServiceStatus
Definition: main.c:10
static DWORD WINAPI _ServiceControlHandlerEx(DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext)
Definition: main.c:23
static void _UpdateServiceStatus(DWORD dwNewStatus, DWORD dwCheckPoint)
Definition: main.c:15
WCHAR wszServiceName[]
Definition: main.c:12
SERVICE_STATUS ServiceStatus
Definition: main.c:11
static VOID WINAPI _ServiceMain(DWORD dwArgc, LPWSTR *lpszArgv)
Definition: main.c:43
DWORD WINAPI LrpcThreadProc(LPVOID lpParameter)
Definition: rpcserver.c:11
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
DWORD(WINAPI * LPTHREAD_START_ROUTINE)(LPVOID)
Definition: winbase.h:729
#define WINAPI
Definition: msvc.h:6
#define SERVICE_STOPPED
Definition: winsvc.h:21
#define SERVICE_ACCEPT_STOP
Definition: winsvc.h:28
#define SERVICE_STOP_PENDING
Definition: winsvc.h:23
#define SERVICE_CONTROL_SHUTDOWN
Definition: winsvc.h:40
#define SERVICE_START_PENDING
Definition: winsvc.h:22
#define SERVICE_RUNNING
Definition: winsvc.h:24
#define SERVICE_CONTROL_STOP
Definition: winsvc.h:36
#define SERVICE_ACCEPT_SHUTDOWN
Definition: winsvc.h:30
#define SERVICE_CONTROL_INTERROGATE
Definition: winsvc.h:39
#define SERVICE_WIN32_OWN_PROCESS
Definition: cmtypes.h:962
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184