ReactOS 0.4.16-dev-109-gf4cb10f
dcomlaunch.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS RPC Subsystem Service
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: DCOMLAUNCH service
5 * COPYRIGHT: Copyright 2019 Pierre Schweitzer
6 */
7
8/* INCLUDES *****************************************************************/
9
10#define WIN32_NO_STATUS
11#define _INC_WINDOWS
12#define COM_NO_WINDOWS_H
13#include <stdarg.h>
14#include <windef.h>
15#include <winbase.h>
16#include <winreg.h>
17#include <winsvc.h>
18
19#define NDEBUG
20#include <debug.h>
21
22/* GLOBALS ******************************************************************/
23
24static WCHAR ServiceName[] = L"dcomlaunch";
25
29
30/* FUNCTIONS *****************************************************************/
31
32static VOID
34{
41
42 if (dwState == SERVICE_START_PENDING ||
43 dwState == SERVICE_STOP_PENDING ||
44 dwState == SERVICE_PAUSE_PENDING ||
45 dwState == SERVICE_CONTINUE_PENDING)
47 else
49
52}
53
54static DWORD WINAPI
56 DWORD dwEventType,
57 LPVOID lpEventData,
58 LPVOID lpContext)
59{
60 DPRINT1("ServiceControlHandler() called\n");
61
62 switch (dwControl)
63 {
65 DPRINT1(" SERVICE_CONTROL_STOP received\n");
68 return ERROR_SUCCESS;
69
71 DPRINT1(" SERVICE_CONTROL_PAUSE received\n");
73 return ERROR_SUCCESS;
74
76 DPRINT1(" SERVICE_CONTROL_CONTINUE received\n");
78 return ERROR_SUCCESS;
79
81 DPRINT1(" SERVICE_CONTROL_INTERROGATE received\n");
84 return ERROR_SUCCESS;
85
87 DPRINT1(" SERVICE_CONTROL_SHUTDOWN received\n");
90 return ERROR_SUCCESS;
91
92 default :
93 DPRINT1(" Control %lu received\n", dwControl);
95 }
96}
97
99
102{
105
106 DPRINT("ServiceMain() called\n");
107
110 NULL);
112 {
113 DPRINT1("RegisterServiceCtrlHandlerExW() failed! (Error %lu)\n", GetLastError());
114 return;
115 }
116
118
120
122
125
127}
128
131 DWORD fdwReason,
133{
134 switch (fdwReason)
135 {
138 break;
139
141 break;
142 }
143
144 return TRUE;
145}
static SERVICE_STATUS_HANDLE(WINAPI *pRegisterServiceCtrlHandlerExA)(LPCSTR
static int argc
Definition: ServiceArgs.c:12
#define DPRINT1
Definition: precomp.h:8
static WCHAR ServiceName[]
Definition: dcomlaunch.c:24
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
Definition: dcomlaunch.c:130
static DWORD WINAPI ServiceControlHandler(DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext)
Definition: dcomlaunch.c:55
static VOID UpdateServiceStatus(DWORD dwState)
Definition: dcomlaunch.c:33
static SERVICE_STATUS_HANDLE ServiceStatusHandle
Definition: dcomlaunch.c:26
VOID WINAPI ServiceMain(DWORD argc, LPTSTR *argv)
Definition: dcomlaunch.c:101
static HANDLE ShutdownEvent
Definition: dcomlaunch.c:28
VOID DealWithDeviceEvent()
static SERVICE_STATUS ServiceStatus
Definition: dcomlaunch.c:27
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
#define INFINITE
Definition: serial.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
static IN DWORD IN LPVOID lpvReserved
#define argv
Definition: mplay32.c:18
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define L(x)
Definition: ntvdm.h:50
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExW(LPCWSTR lpServiceName, LPHANDLER_FUNCTION_EX lpHandlerProc, LPVOID lpContext)
Definition: sctrl.c:812
BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
Definition: sctrl.c:997
#define DPRINT
Definition: sndvol32.h:73
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
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define WINAPI
Definition: msvc.h:6
#define SERVICE_STOPPED
Definition: winsvc.h:21
#define SERVICE_STOP_PENDING
Definition: winsvc.h:23
#define SERVICE_CONTROL_SHUTDOWN
Definition: winsvc.h:40
#define SERVICE_PAUSED
Definition: winsvc.h:27
#define SERVICE_START_PENDING
Definition: winsvc.h:22
#define SERVICE_RUNNING
Definition: winsvc.h:24
#define SERVICE_CONTROL_CONTINUE
Definition: winsvc.h:38
#define SERVICE_CONTROL_STOP
Definition: winsvc.h:36
#define SERVICE_PAUSE_PENDING
Definition: winsvc.h:26
#define SERVICE_CONTROL_PAUSE
Definition: winsvc.h:37
#define SERVICE_CONTROL_INTERROGATE
Definition: winsvc.h:39
#define SERVICE_CONTINUE_PENDING
Definition: winsvc.h:25
#define SERVICE_WIN32_OWN_PROCESS
Definition: cmtypes.h:962
__wchar_t WCHAR
Definition: xmlstorage.h:180
CHAR * LPTSTR
Definition: xmlstorage.h:192