ReactOS  0.4.14-dev-390-g34947ad
service.c
Go to the documentation of this file.
1 /*
2  * PROJECT: Local Security Authority Server DLL
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: dll/win32/lsasrv/service.c
5  * PURPOSE: Security service
6  * COPYRIGHT: Copyright 2016, 2019 Eric Kohl <eric.kohl@reactos.org>
7  */
8 
9 /* INCLUDES ****************************************************************/
10 
11 #include "lsasrv.h"
12 #include <winsvc.h>
13 
15 
16 static VOID WINAPI SamSsServiceMain(DWORD dwArgc, PWSTR *pszArgv);
17 
19 {
20  {L"SAMSS", SamSsServiceMain},
21  {NULL, NULL}
22 };
23 
24 
25 /* FUNCTIONS ***************************************************************/
26 
27 static
28 VOID
29 WINAPI
31  _In_ DWORD fdwControl)
32 {
33  TRACE("SamSsControlHandler(%lu)\n", fdwControl);
34 }
35 
36 
37 static
38 VOID
39 WINAPI
41  _In_ DWORD dwArgc,
42  _In_ PWSTR *pszArgv)
43 {
46 
47  TRACE("SamSsServiceMain(%lu %p)\n", dwArgc, pszArgv);
48 
51  if (hStatus == NULL)
52  return;
53 
60  ServiceStatus.dwWaitHint = 0x7530;
61 
63 
67 
69 }
70 
71 
72 static
73 DWORD
74 WINAPI
76  _In_ PVOID pParameter)
77 {
78  HANDLE hEvent;
79  DWORD dwError;
80 
81  TRACE("DispatcherThread(%p)\n", pParameter);
82 
83  /* Create or open the SECURITY_SERVICES_STARTED event */
85  TRUE,
86  FALSE,
87  L"SECURITY_SERVICES_STARTED");
88  if (hEvent == NULL)
89  {
90  dwError = GetLastError();
91  if (dwError != ERROR_ALREADY_EXISTS)
92  return dwError;
93 
95  FALSE,
96  L"SECURITY_SERVICES_STARTED");
97  if (hEvent == NULL)
98  return GetLastError();
99  }
100 
101  /* Wait for the SECURITY_SERVICES_STARTED event to be signaled */
102  TRACE("Waiting for the SECURITY_SERVICES_STARTED event!\n");
103  dwError = WaitForSingleObject(hEvent, INFINITE);
104  TRACE("WaitForSingleObject returned %lu\n", dwError);
105 
106  /* Close the event handle */
108 
109  /* Fail, if the event was not signaled */
110  if (dwError != WAIT_OBJECT_0)
111  {
112  ERR("Wait failed!\n");
113  return dwError;
114  }
115 
116  /* This is the security process */
118 
119  /* Start the services */
120  TRACE("Start the security services!\n");
122  return GetLastError();
123 
124  TRACE("Done!\n");
125 
126  return ERROR_SUCCESS;
127 }
128 
129 
130 NTSTATUS
131 WINAPI
133 {
134  HANDLE hThread;
136 
137  TRACE("ServiceInit()\n");
138 
140  0,
142  NULL,
143  0,
144  &dwThreadId);
145  if (hThread == NULL)
146  return (NTSTATUS)GetLastError();
147 
148  return STATUS_SUCCESS;
149 }
150 
151 /* EOF */
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:406
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD dwCurrentState
Definition: winsvc.h:100
uint16_t * PWSTR
Definition: typedefs.h:54
LONG NTSTATUS
Definition: precomp.h:26
static SERVICE_STATUS ServiceStatus
Definition: dcomlaunch.c:27
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define SERVICE_START_PENDING
Definition: winsvc.h:22
DWORD dwServiceSpecificExitCode
Definition: winsvc.h:103
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerW(LPCWSTR lpServiceName, LPHANDLER_FUNCTION lpHandlerProc)
Definition: sctrl.c:740
static VOID WINAPI SamSsServiceMain(DWORD dwArgc, PWSTR *pszArgv)
BOOL WINAPI StartServiceCtrlDispatcherW(const SERVICE_TABLE_ENTRYW *lpServiceStartTable)
Definition: sctrl.c:1132
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
HANDLE WINAPI DECLSPEC_HOTPATCH OpenEventW(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCWSTR lpName)
Definition: synch.c:682
static HANDLE hEvent
Definition: comm.c:54
VOID WINAPI I_ScIsSecurityProcess(VOID)
Definition: sctrl.c:851
BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
Definition: sctrl.c:995
SERVICE_STATUS_HANDLE hStatus
Definition: w32time.c:14
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
DWORD dwCheckPoint
Definition: winsvc.h:104
NTSTATUS WINAPI ServiceInit(VOID)
Definition: service.c:132
#define SERVICE_RUNNING
Definition: winsvc.h:24
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:136
smooth NULL
Definition: ftsmooth.c:416
static VOID WINAPI SamSsControlHandler(_In_ DWORD fdwControl)
Definition: service.c:30
#define TRACE(s)
Definition: solgame.cpp:4
#define WAIT_OBJECT_0
Definition: winbase.h:387
DWORD dwWaitHint
Definition: winsvc.h:105
#define WINAPI
Definition: msvc.h:8
DWORD dwWin32ExitCode
Definition: winsvc.h:102
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dwServiceType
Definition: winsvc.h:99
#define SERVICE_WIN32_SHARE_PROCESS
Definition: cmtypes.h:961
DWORD dwThreadId
Definition: fdebug.c:31
static const WCHAR L[]
Definition: oid.c:1250
static DWORD WINAPI DispatcherThread(_In_ PVOID pParameter)
Definition: service.c:75
#define SYNCHRONIZE
Definition: nt_native.h:61
#define ERR(fmt,...)
Definition: debug.h:109
#define _In_
Definition: no_sal2.h:204
DWORD dwControlsAccepted
Definition: winsvc.h:101
HANDLE hThread
Definition: wizard.c:27
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
#define INFINITE
Definition: serial.h:102
return STATUS_SUCCESS
Definition: btrfs.c:2938
static SERVICE_STATUS_HANDLE(WINAPI *pRegisterServiceCtrlHandlerExA)(LPCSTR
SERVICE_TABLE_ENTRYW ServiceTable[]
Definition: service.c:18