2 * PROJECT: ReactOS NetLogon Service
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: NetLogon service RPC server
5 * COPYRIGHT: Eric Kohl 2019 <eric.kohl@reactos.org>
8 /* INCLUDES *****************************************************************/
12 WINE_DEFAULT_DEBUG_CHANNEL(netlogon
);
15 /* GLOBALS ******************************************************************/
17 HINSTANCE hDllInstance
;
19 static WCHAR ServiceName
[] = L
"netlogon";
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
;
128 _In_ PWSTR
*ArgVector
)
132 UNREFERENCED_PARAMETER(ArgCount
);
133 UNREFERENCED_PARAMETER(ArgVector
);
135 TRACE("NlNetlogonMain(%d %p)\n", ArgCount
, ArgVector
);
137 ServiceStatusHandle
= RegisterServiceCtrlHandlerExW(ServiceName
,
138 ServiceControlHandler
,
140 if (!ServiceStatusHandle
)
142 ERR("RegisterServiceCtrlHandlerExW() failed! (Error %lu)\n", GetLastError());
146 UpdateServiceStatus(SERVICE_START_PENDING
);
148 dwError
= ServiceInit();
149 if (dwError
!= ERROR_SUCCESS
)
151 ERR("Service stopped (dwError: %lu\n", dwError
);
152 UpdateServiceStatus(SERVICE_STOPPED
);
156 UpdateServiceStatus(SERVICE_RUNNING
);
163 _In_ HINSTANCE hinstDLL
,
164 _In_ DWORD fdwReason
,
165 _In_ PVOID pvReserved
)
167 UNREFERENCED_PARAMETER(pvReserved
);
171 case DLL_PROCESS_ATTACH
:
172 DisableThreadLibraryCalls(hinstDLL
);
173 hDllInstance
= hinstDLL
;
176 case DLL_PROCESS_DETACH
: