2 * PROJECT: ReactOS Browser Service
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Browser service RPC server
5 * COPYRIGHT: Eric Kohl 2020 <eric.kohl@reactos.org>
8 /* INCLUDES *****************************************************************/
12 WINE_DEFAULT_DEBUG_CHANNEL(browser
);
15 /* GLOBALS ******************************************************************/
17 HINSTANCE hDllInstance
;
19 static WCHAR ServiceName
[] = L
"browser";
21 static SERVICE_STATUS_HANDLE ServiceStatusHandle
;
22 static SERVICE_STATUS ServiceStatus
;
25 /* FUNCTIONS *****************************************************************/
32 ServiceStatus
.dwServiceType
= SERVICE_WIN32_OWN_PROCESS
;
33 ServiceStatus
.dwCurrentState
= dwState
;
34 ServiceStatus
.dwControlsAccepted
= 0;
35 ServiceStatus
.dwWin32ExitCode
= 0;
36 ServiceStatus
.dwServiceSpecificExitCode
= 0;
37 ServiceStatus
.dwCheckPoint
= 0;
39 if (dwState
== SERVICE_START_PENDING
||
40 dwState
== SERVICE_STOP_PENDING
||
41 dwState
== SERVICE_PAUSE_PENDING
||
42 dwState
== SERVICE_CONTINUE_PENDING
)
43 ServiceStatus
.dwWaitHint
= 10000;
45 ServiceStatus
.dwWaitHint
= 0;
47 SetServiceStatus(ServiceStatusHandle
,
55 ServiceControlHandler(
61 TRACE("ServiceControlHandler()\n");
65 case SERVICE_CONTROL_STOP
:
66 TRACE(" SERVICE_CONTROL_STOP received\n");
67 /* Stop listening to incoming RPC messages */
68 RpcMgmtStopServerListening(NULL
);
69 UpdateServiceStatus(SERVICE_STOPPED
);
72 case SERVICE_CONTROL_PAUSE
:
73 TRACE(" SERVICE_CONTROL_PAUSE received\n");
74 UpdateServiceStatus(SERVICE_PAUSED
);
77 case SERVICE_CONTROL_CONTINUE
:
78 TRACE(" SERVICE_CONTROL_CONTINUE received\n");
79 UpdateServiceStatus(SERVICE_RUNNING
);
82 case SERVICE_CONTROL_INTERROGATE
:
83 TRACE(" SERVICE_CONTROL_INTERROGATE received\n");
84 SetServiceStatus(ServiceStatusHandle
,
88 case SERVICE_CONTROL_SHUTDOWN
:
89 TRACE(" SERVICE_CONTROL_SHUTDOWN received\n");
90 UpdateServiceStatus(SERVICE_STOPPED
);
94 TRACE(" Control %lu received\n", dwControl
);
95 return ERROR_CALL_NOT_IMPLEMENTED
;
106 hThread
= CreateThread(NULL
,
108 (LPTHREAD_START_ROUTINE
)RpcThreadRoutine
,
115 ERR("Can't create PortThread\n");
116 return GetLastError();
119 CloseHandle(hThread
);
121 return ERROR_SUCCESS
;
129 _In_ PWSTR
*ArgVector
)
133 UNREFERENCED_PARAMETER(ArgCount
);
134 UNREFERENCED_PARAMETER(ArgVector
);
136 FIXME("ServiceMain(%d %p)\n", ArgCount
, ArgVector
);
138 ServiceStatusHandle
= RegisterServiceCtrlHandlerExW(ServiceName
,
139 ServiceControlHandler
,
141 if (!ServiceStatusHandle
)
143 ERR("RegisterServiceCtrlHandlerExW() failed! (Error %lu)\n", GetLastError());
147 UpdateServiceStatus(SERVICE_START_PENDING
);
149 dwError
= ServiceInit();
150 if (dwError
!= ERROR_SUCCESS
)
152 ERR("Service stopped (dwError: %lu\n", dwError
);
153 UpdateServiceStatus(SERVICE_STOPPED
);
157 UpdateServiceStatus(SERVICE_RUNNING
);
164 _In_ HINSTANCE hinstDLL
,
165 _In_ DWORD fdwReason
,
166 _In_ PVOID pvReserved
)
168 UNREFERENCED_PARAMETER(pvReserved
);
172 case DLL_PROCESS_ATTACH
:
173 DisableThreadLibraryCalls(hinstDLL
);
174 hDllInstance
= hinstDLL
;
177 case DLL_PROCESS_DETACH
: