ReactOS  0.4.15-dev-2720-g5ee0925
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 {
115  HANDLE hEvent;
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");
140  dwError = WaitForSingleObject(hEvent, INFINITE);
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 CloseHandle
Definition: compat.h:598
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
BOOL WINAPI StartServiceCtrlDispatcherW(const SERVICE_TABLE_ENTRYW *lpServiceStartTable)
Definition: sctrl.c:1134
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:853
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
#define WAIT_OBJECT_0
Definition: winbase.h:403
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define SYNCHRONIZE
Definition: nt_native.h:61
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
#define INFINITE
Definition: serial.h:102
SERVICE_TABLE_ENTRYW ServiceTable[]
Definition: service.c:21

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 }
#define TRUE
Definition: types.h:120
static BOOL bSecurityServiceProcess
Definition: sctrl.c:63
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by DispatcherThread().

◆ NetlogonServiceMain() [1/2]

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

◆ NetlogonServiceMain() [2/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 }
VOID(WINAPI * PNETLOGONMAIN)(INT ArgCount, PWSTR *ArgVector)
Definition: service.c:14
#define LoadLibraryW(x)
Definition: compat.h:606
#define TRACE(s)
Definition: solgame.cpp:4
#define FreeLibrary(x)
Definition: compat.h:607
static const WCHAR L[]
Definition: oid.c:1250
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
#define GetProcAddress(x, y)
Definition: compat.h:612

◆ 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 }
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by SamSsServiceMain().

◆ SamSsServiceMain() [1/2]

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

◆ SamSsServiceMain() [2/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 
97  ServiceStatus.dwWaitHint = 0x7530;
98 
100 
104 
106 }
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD dwCurrentState
Definition: winsvc.h:100
#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:742
BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
Definition: sctrl.c:997
SERVICE_STATUS_HANDLE hStatus
Definition: w32time.c:14
DWORD dwCheckPoint
Definition: winsvc.h:104
#define SERVICE_RUNNING
Definition: winsvc.h:24
static VOID WINAPI SamSsControlHandler(_In_ DWORD fdwControl)
Definition: service.c:67
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwWaitHint
Definition: winsvc.h:105
static SERVICE_STATUS ServiceStatus
Definition: browser.c:22
DWORD dwWin32ExitCode
Definition: winsvc.h:102
DWORD dwServiceType
Definition: winsvc.h:99
#define SERVICE_WIN32_SHARE_PROCESS
Definition: cmtypes.h:963
static const WCHAR L[]
Definition: oid.c:1250
DWORD dwControlsAccepted
Definition: winsvc.h:101
#define NULL
Definition: types.h:112
static SERVICE_STATUS_HANDLE(WINAPI *pRegisterServiceCtrlHandlerExA)(LPCSTR

◆ ServiceInit()

NTSTATUS WINAPI ServiceInit ( VOID  )

Definition at line 169 of file service.c.

170 {
171  HANDLE hThread;
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
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
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
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dwThreadId
Definition: fdebug.c:31
static DWORD WINAPI DispatcherThread(_In_ PVOID pParameter)
Definition: service.c:112
#define NULL
Definition: types.h:112
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 SamSsServiceMain(DWORD dwArgc, PWSTR *pszArgv)
static const WCHAR L[]
Definition: oid.c:1250
#define NULL
Definition: types.h:112
static VOID WINAPI NetlogonServiceMain(DWORD dwArgc, PWSTR *pszArgv)

Definition at line 21 of file service.c.

Referenced by _tmain(), DispatcherThread(), KiSystemService(), START_TEST(), and wmain().