ReactOS  0.4.15-dev-4916-gd519b11
seclogon.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Secondary Logon Service
3  * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE: Secondary Logon service RPC server
5  * COPYRIGHT: Eric Kohl 2022 <eric.kohl@reactos.org>
6  */
7 
8 /* INCLUDES *****************************************************************/
9 
10 #include "precomp.h"
11 
13 
14 
15 /* GLOBALS ******************************************************************/
16 
19 
20 static WCHAR ServiceName[] = L"seclogon";
21 
24 
25 
26 /* FUNCTIONS *****************************************************************/
27 
28 static
29 VOID
31  _In_ DWORD dwState)
32 {
34  ServiceStatus.dwCurrentState = dwState;
35 
36  if (dwState == SERVICE_PAUSED || dwState == SERVICE_RUNNING)
40  else
42 
46 
47  if (dwState == SERVICE_START_PENDING ||
48  dwState == SERVICE_STOP_PENDING ||
49  dwState == SERVICE_PAUSE_PENDING ||
50  dwState == SERVICE_CONTINUE_PENDING)
51  ServiceStatus.dwWaitHint = 10000;
52  else
54 
56  &ServiceStatus);
57 }
58 
59 
60 static
61 DWORD
62 WINAPI
64  _In_ DWORD dwControl,
65  _In_ DWORD dwEventType,
66  _In_ LPVOID lpEventData,
67  _In_ LPVOID lpContext)
68 {
69  TRACE("ServiceControlHandlerEx()\n");
70 
71  switch (dwControl)
72  {
74  TRACE(" SERVICE_CONTROL_STOP received\n");
76  StopRpcServer();
77  return ERROR_SUCCESS;
78 
80  TRACE(" SERVICE_CONTROL_PAUSE received\n");
82  StopRpcServer();
84  return ERROR_SUCCESS;
85 
87  TRACE(" SERVICE_CONTROL_CONTINUE received\n");
91  return ERROR_SUCCESS;
92 
94  TRACE(" SERVICE_CONTROL_INTERROGATE received\n");
96  &ServiceStatus);
97  return ERROR_SUCCESS;
98 
100  TRACE(" SERVICE_CONTROL_SHUTDOWN received\n");
102  StopRpcServer();
103  return ERROR_SUCCESS;
104 
105  default :
106  TRACE(" Control %lu received\n", dwControl);
108  }
109 }
110 
111 
112 VOID
113 WINAPI
115  _In_ PSVCHOST_GLOBAL_DATA lpGlobals)
116 {
117  TRACE("SvchostPushServiceGlobals(%p)\n", lpGlobals);
118  lpServiceGlobals = lpGlobals;
119 }
120 
121 
122 VOID
123 WINAPI
125  _In_ INT ArgCount,
126  _In_ PWSTR *ArgVector)
127 {
128  DWORD dwError;
129 
130  UNREFERENCED_PARAMETER(ArgCount);
131  UNREFERENCED_PARAMETER(ArgVector);
132 
133  TRACE("ServiceMain(%d %p)\n", ArgCount, ArgVector);
134 
137  NULL);
138  if (!ServiceStatusHandle)
139  {
140  ERR("RegisterServiceCtrlHandlerExW() failed! (Error %lu)\n", GetLastError());
141  return;
142  }
143 
145 
146  dwError = StartRpcServer();
147  if (dwError != ERROR_SUCCESS)
148  {
149  ERR("Service stopped (dwError: %lu\n", dwError);
151  return;
152  }
153 
155 }
156 
157 
158 BOOL
159 WINAPI
161  _In_ HINSTANCE hinstDLL,
162  _In_ DWORD fdwReason,
164 {
166 
167  switch (fdwReason)
168  {
169  case DLL_PROCESS_ATTACH:
170  DisableThreadLibraryCalls(hinstDLL);
171  hDllInstance = hinstDLL;
172  break;
173 
174  case DLL_PROCESS_DETACH:
175  break;
176  }
177 
178  return TRUE;
179 }
180 
181 /* EOF */
BOOL WINAPI DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ PVOID pvReserved)
Definition: seclogon.c:160
static VOID UpdateServiceStatus(_In_ DWORD dwState)
Definition: seclogon.c:30
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD dwCurrentState
Definition: winsvc.h:100
#define SERVICE_PAUSE_PENDING
Definition: winsvc.h:26
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
uint16_t * PWSTR
Definition: typedefs.h:56
#define SERVICE_PAUSED
Definition: winsvc.h:27
#define SERVICE_ACCEPT_STOP
Definition: winsvc.h:28
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define SERVICE_START_PENDING
Definition: winsvc.h:22
DWORD dwServiceSpecificExitCode
Definition: winsvc.h:103
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
int32_t INT
Definition: typedefs.h:58
BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
Definition: sctrl.c:997
DWORD dwCheckPoint
Definition: winsvc.h:104
#define L(x)
Definition: ntvdm.h:50
#define SERVICE_STOPPED
Definition: winsvc.h:21
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SERVICE_RUNNING
Definition: winsvc.h:24
#define _In_
Definition: ms_sal.h:308
#define SERVICE_CONTROL_INTERROGATE
Definition: winsvc.h:39
VOID WINAPI SvcEntry_Seclogon(_In_ INT ArgCount, _In_ PWSTR *ArgVector)
Definition: seclogon.c:124
static WCHAR ServiceName[]
Definition: seclogon.c:20
#define SERVICE_ACCEPT_PAUSE_CONTINUE
Definition: winsvc.h:29
HINSTANCE hDllInstance
Definition: seclogon.c:17
#define DLL_PROCESS_DETACH
Definition: compat.h:130
static SERVICE_STATUS_HANDLE(WINAPI *pRegisterServiceCtrlHandlerExA)(LPCSTR
#define SERVICE_ACCEPT_SHUTDOWN
Definition: winsvc.h:30
#define TRACE(s)
Definition: solgame.cpp:4
PSVCHOST_GLOBAL_DATA lpServiceGlobals
Definition: seclogon.c:18
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD dwWaitHint
Definition: winsvc.h:105
static LPCSTR DWORD void * pvReserved
Definition: str.c:196
#define WINAPI
Definition: msvc.h:6
DWORD StartRpcServer(VOID)
Definition: rpcserver.c:32
DWORD dwWin32ExitCode
Definition: winsvc.h:102
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dwServiceType
Definition: winsvc.h:99
VOID WINAPI SvchostPushServiceGlobals(_In_ PSVCHOST_GLOBAL_DATA lpGlobals)
Definition: seclogon.c:114
#define SERVICE_WIN32_SHARE_PROCESS
Definition: cmtypes.h:963
#define SERVICE_CONTROL_PAUSE
Definition: winsvc.h:37
DWORD StopRpcServer(VOID)
Definition: rpcserver.c:44
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExW(LPCWSTR lpServiceName, LPHANDLER_FUNCTION_EX lpHandlerProc, LPVOID lpContext)
Definition: sctrl.c:812
#define ERR(fmt,...)
Definition: debug.h:110
DWORD dwControlsAccepted
Definition: winsvc.h:101
#define SERVICE_CONTINUE_PENDING
Definition: winsvc.h:25
#define SERVICE_CONTROL_CONTINUE
Definition: winsvc.h:38
#define NULL
Definition: types.h:112
WINE_DEFAULT_DEBUG_CHANNEL(seclogon)
static DWORD WINAPI ServiceControlHandlerEx(_In_ DWORD dwControl, _In_ DWORD dwEventType, _In_ LPVOID lpEventData, _In_ LPVOID lpContext)
Definition: seclogon.c:63
static SERVICE_STATUS ServiceStatus
Definition: seclogon.c:23
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define SERVICE_CONTROL_STOP
Definition: winsvc.h:36
static SERVICE_STATUS_HANDLE ServiceStatusHandle
Definition: seclogon.c:22
#define SERVICE_STOP_PENDING
Definition: winsvc.h:23
#define SERVICE_CONTROL_SHUTDOWN
Definition: winsvc.h:40