ReactOS 0.4.15-dev-6054-gbddd8b0
browser.c
Go to the documentation of this file.
1/*
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>
6 */
7
8/* INCLUDES *****************************************************************/
9
10#include "precomp.h"
11
13
14
15/* GLOBALS ******************************************************************/
16
18
19static WCHAR ServiceName[] = L"browser";
20
23
24
25/* FUNCTIONS *****************************************************************/
26
27static
28VOID
30 DWORD dwState)
31{
38
39 if (dwState == SERVICE_START_PENDING ||
40 dwState == SERVICE_STOP_PENDING ||
41 dwState == SERVICE_PAUSE_PENDING ||
42 dwState == SERVICE_CONTINUE_PENDING)
44 else
46
49}
50
51
52static
56 DWORD dwControl,
57 DWORD dwEventType,
58 LPVOID lpEventData,
59 LPVOID lpContext)
60{
61 TRACE("ServiceControlHandler()\n");
62
63 switch (dwControl)
64 {
66 TRACE(" SERVICE_CONTROL_STOP received\n");
67 /* Stop listening to incoming RPC messages */
70 return ERROR_SUCCESS;
71
73 TRACE(" SERVICE_CONTROL_PAUSE received\n");
75 return ERROR_SUCCESS;
76
78 TRACE(" SERVICE_CONTROL_CONTINUE received\n");
80 return ERROR_SUCCESS;
81
83 TRACE(" SERVICE_CONTROL_INTERROGATE received\n");
86 return ERROR_SUCCESS;
87
89 TRACE(" SERVICE_CONTROL_SHUTDOWN received\n");
91 return ERROR_SUCCESS;
92
93 default :
94 TRACE(" Control %lu received\n", dwControl);
96 }
97}
98
99
100static
101DWORD
103{
105
107 0,
109 NULL,
110 0,
111 NULL);
112
113 if (!hThread)
114 {
115 ERR("Can't create PortThread\n");
116 return GetLastError();
117 }
118 else
120
121 return ERROR_SUCCESS;
122}
123
124
125VOID
126WINAPI
128 _In_ INT ArgCount,
129 _In_ PWSTR *ArgVector)
130{
131 DWORD dwError;
132
133 UNREFERENCED_PARAMETER(ArgCount);
134 UNREFERENCED_PARAMETER(ArgVector);
135
136 FIXME("ServiceMain(%d %p)\n", ArgCount, ArgVector);
137
140 NULL);
142 {
143 ERR("RegisterServiceCtrlHandlerExW() failed! (Error %lu)\n", GetLastError());
144 return;
145 }
146
148
149 dwError = ServiceInit();
150 if (dwError != ERROR_SUCCESS)
151 {
152 ERR("Service stopped (dwError: %lu\n", dwError);
154 return;
155 }
156
158}
159
160
161BOOL
162WINAPI
164 _In_ HINSTANCE hinstDLL,
165 _In_ DWORD fdwReason,
167{
169
170 switch (fdwReason)
171 {
174 hDllInstance = hinstDLL;
175 break;
176
178 break;
179 }
180
181 return TRUE;
182}
183
184/* EOF */
static SERVICE_STATUS_HANDLE(WINAPI *pRegisterServiceCtrlHandlerExA)(LPCSTR
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
static WCHAR ServiceName[]
Definition: browser.c:19
VOID WINAPI ServiceMain(_In_ INT ArgCount, _In_ PWSTR *ArgVector)
Definition: browser.c:127
static DWORD ServiceInit(VOID)
Definition: browser.c:102
static DWORD WINAPI ServiceControlHandler(DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext)
Definition: browser.c:55
static VOID UpdateServiceStatus(DWORD dwState)
Definition: browser.c:29
static SERVICE_STATUS_HANDLE ServiceStatusHandle
Definition: browser.c:21
BOOL WINAPI DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ PVOID pvReserved)
Definition: browser.c:163
static SERVICE_STATUS ServiceStatus
Definition: browser.c:22
HINSTANCE hDllInstance
Definition: browser.c:17
DWORD WINAPI RpcThreadRoutine(LPVOID lpParameter)
Definition: rpcserver.c:20
#define FIXME(fmt,...)
Definition: debug.h:111
#define ERR(fmt,...)
Definition: debug.h:110
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#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
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 int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
static LPCSTR DWORD void * pvReserved
Definition: str.c:196
#define _In_
Definition: ms_sal.h:308
HANDLE hThread
Definition: wizard.c:28
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define L(x)
Definition: ntvdm.h:50
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 SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
Definition: sctrl.c:997
#define TRACE(s)
Definition: solgame.cpp:4
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
uint16_t * PWSTR
Definition: typedefs.h:56
int32_t INT
Definition: typedefs.h:58
DWORD WINAPI GetLastError(void)
Definition: except.c:1040
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_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