ReactOS 0.4.15-dev-7887-g64a59a1
service.c File Reference
#include "lsasrv.h"
#include <winsvc.h>
Include dependency graph for service.c:

Go to the source code of this file.

Typedefs

typedef VOID(WINAPIPNETLOGONMAIN) (INT ArgCount, PWSTR *ArgVector)
 

Functions

VOID WINAPI I_ScIsSecurityProcess (VOID)
 
static VOID WINAPI NetlogonServiceMain (DWORD dwArgc, PWSTR *pszArgv)
 
static VOID WINAPI SamSsServiceMain (DWORD dwArgc, PWSTR *pszArgv)
 
static VOID WINAPI NetlogonServiceMain (_In_ DWORD dwArgc, _In_ PWSTR *pszArgv)
 
static VOID WINAPI SamSsControlHandler (_In_ DWORD fdwControl)
 
static VOID WINAPI SamSsServiceMain (_In_ DWORD dwArgc, _In_ PWSTR *pszArgv)
 
static DWORD WINAPI DispatcherThread (_In_ PVOID pParameter)
 
NTSTATUS WINAPI ServiceInit (VOID)
 

Variables

SERVICE_TABLE_ENTRYW ServiceTable []
 

Typedef Documentation

◆ PNETLOGONMAIN

typedef VOID(WINAPI * PNETLOGONMAIN) (INT ArgCount, PWSTR *ArgVector)

Definition at line 14 of file service.c.

Function Documentation

◆ DispatcherThread()

static DWORD WINAPI DispatcherThread ( _In_ PVOID  pParameter)
static

Definition at line 112 of file service.c.

114{
116 DWORD dwError;
117
118 TRACE("DispatcherThread(%p)\n", pParameter);
119
120 /* Create or open the SECURITY_SERVICES_STARTED event */
122 TRUE,
123 FALSE,
124 L"SECURITY_SERVICES_STARTED");
125 if (hEvent == NULL)
126 {
127 dwError = GetLastError();
128 if (dwError != ERROR_ALREADY_EXISTS)
129 return dwError;
130
132 FALSE,
133 L"SECURITY_SERVICES_STARTED");
134 if (hEvent == NULL)
135 return GetLastError();
136 }
137
138 /* Wait for the SECURITY_SERVICES_STARTED event to be signaled */
139 TRACE("Waiting for the SECURITY_SERVICES_STARTED event!\n");
141 TRACE("WaitForSingleObject returned %lu\n", dwError);
142
143 /* Close the event handle */
145
146 /* Fail, if the event was not signaled */
147 if (dwError != WAIT_OBJECT_0)
148 {
149 ERR("Wait failed!\n");
150 return dwError;
151 }
152
153 /* This is the security process */
155
156 /* Start the services */
157 TRACE("Start the security services!\n");
159 return GetLastError();
160
161 TRACE("Done!\n");
162
163 return ERROR_SUCCESS;
164}
#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 FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
SERVICE_TABLE_ENTRYW ServiceTable[]
Definition: service.c:21
VOID WINAPI I_ScIsSecurityProcess(VOID)
Definition: sctrl.c:853
#define INFINITE
Definition: serial.h:102
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
static HANDLE hEvent
Definition: comm.c:54
#define SYNCHRONIZE
Definition: nt_native.h:61
#define L(x)
Definition: ntvdm.h:50
BOOL WINAPI StartServiceCtrlDispatcherW(const SERVICE_TABLE_ENTRYW *lpServiceStartTable)
Definition: sctrl.c:1134
#define TRACE(s)
Definition: solgame.cpp:4
HANDLE WINAPI DECLSPEC_HOTPATCH OpenEventW(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCWSTR lpName)
Definition: synch.c:682
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define WAIT_OBJECT_0
Definition: winbase.h:406

Referenced by ServiceInit().

◆ I_ScIsSecurityProcess()

VOID WINAPI I_ScIsSecurityProcess ( VOID  )

Definition at line 853 of file sctrl.c.

854{
855 TRACE("I_ScIsSecurityProcess()\n");
857}
static BOOL bSecurityServiceProcess
Definition: sctrl.c:63

Referenced by DispatcherThread().

◆ NetlogonServiceMain() [1/2]

static VOID WINAPI NetlogonServiceMain ( _In_ DWORD  dwArgc,
_In_ PWSTR pszArgv 
)
static

Definition at line 34 of file service.c.

37{
38 HINSTANCE hNetlogon = NULL;
39 PNETLOGONMAIN pNetlogonMain = NULL;
40
41 TRACE("NetlogonServiceMain(%lu %p)\n", dwArgc, pszArgv);
42
43 hNetlogon = LoadLibraryW(L"Netlogon.dll");
44 if (hNetlogon == NULL)
45 {
46 ERR("LoadLibrary() failed!\n");
47 return;
48 }
49
50 pNetlogonMain = (PNETLOGONMAIN)GetProcAddress(hNetlogon, "NlNetlogonMain");
51 if (pNetlogonMain == NULL)
52 {
53 ERR("GetProcAddress(NlNetlogonMain) failed!\n");
54 FreeLibrary(hNetlogon);
55 return;
56 }
57
58 TRACE("NlNetlogonMain %p\n", pNetlogonMain);
59
60 pNetlogonMain(dwArgc, pszArgv);
61}
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define LoadLibraryW(x)
Definition: compat.h:747
VOID(WINAPI * PNETLOGONMAIN)(INT ArgCount, PWSTR *ArgVector)
Definition: service.c:14

◆ NetlogonServiceMain() [2/2]

static VOID WINAPI NetlogonServiceMain ( DWORD  dwArgc,
PWSTR pszArgv 
)
static

◆ SamSsControlHandler()

static VOID WINAPI SamSsControlHandler ( _In_ DWORD  fdwControl)
static

Definition at line 67 of file service.c.

69{
70 TRACE("SamSsControlHandler(%lu)\n", fdwControl);
71}

Referenced by SamSsServiceMain().

◆ SamSsServiceMain() [1/2]

static VOID WINAPI SamSsServiceMain ( _In_ DWORD  dwArgc,
_In_ PWSTR pszArgv 
)
static

Definition at line 77 of file service.c.

80{
83
84 TRACE("SamSsServiceMain(%lu %p)\n", dwArgc, pszArgv);
85
88 if (hStatus == NULL)
89 return;
90
98
100
104
106}
static SERVICE_STATUS_HANDLE(WINAPI *pRegisterServiceCtrlHandlerExA)(LPCSTR
static SERVICE_STATUS ServiceStatus
Definition: browser.c:22
static VOID WINAPI SamSsControlHandler(_In_ DWORD fdwControl)
Definition: service.c:67
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerW(LPCWSTR lpServiceName, LPHANDLER_FUNCTION lpHandlerProc)
Definition: sctrl.c:742
BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
Definition: sctrl.c:997
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
SERVICE_STATUS_HANDLE hStatus
Definition: w32time.c:14
#define SERVICE_START_PENDING
Definition: winsvc.h:22
#define SERVICE_RUNNING
Definition: winsvc.h:24
#define SERVICE_WIN32_SHARE_PROCESS
Definition: cmtypes.h:963

◆ SamSsServiceMain() [2/2]

static VOID WINAPI SamSsServiceMain ( DWORD  dwArgc,
PWSTR pszArgv 
)
static

◆ ServiceInit()

NTSTATUS WINAPI ServiceInit ( VOID  )

Definition at line 169 of file service.c.

170{
173
174 TRACE("ServiceInit()\n");
175
177 0,
179 NULL,
180 0,
181 &dwThreadId);
182 if (hThread == NULL)
183 return (NTSTATUS)GetLastError();
184
185 return STATUS_SUCCESS;
186}
LONG NTSTATUS
Definition: precomp.h:26
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
static DWORD WINAPI DispatcherThread(_In_ PVOID pParameter)
Definition: service.c:112
DWORD dwThreadId
Definition: fdebug.c:31
HANDLE hThread
Definition: wizard.c:28
#define STATUS_SUCCESS
Definition: shellext.h:65

Variable Documentation

◆ ServiceTable

SERVICE_TABLE_ENTRYW ServiceTable[]
Initial value:
=
{
{L"NETLOGON", NetlogonServiceMain},
{L"SAMSS", SamSsServiceMain},
}
static VOID WINAPI NetlogonServiceMain(DWORD dwArgc, PWSTR *pszArgv)
static VOID WINAPI SamSsServiceMain(DWORD dwArgc, PWSTR *pszArgv)

Definition at line 21 of file service.c.

Referenced by DispatcherThread(), and START_TEST().