ReactOS  0.4.12-dev-36-g472787f
srvsvc.c File Reference
#include "precomp.h"
Include dependency graph for srvsvc.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (srvsvc)
 
static VOID UpdateServiceStatus (DWORD dwState)
 
static DWORD WINAPI ServiceControlHandler (DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext)
 
static DWORD ServiceInit (VOID)
 
VOID WINAPI ServiceMain (DWORD argc, LPTSTR *argv)
 
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 

Variables

static WCHAR ServiceName [] = L"Lanmanserver"
 
static SERVICE_STATUS_HANDLE ServiceStatusHandle
 
static SERVICE_STATUS ServiceStatus
 
DWORD dwServiceBits = 0
 

Function Documentation

◆ DllMain()

BOOL WINAPI DllMain ( HINSTANCE  hinstDLL,
DWORD  fdwReason,
LPVOID  lpvReserved 
)

Definition at line 178 of file srvsvc.c.

181 {
182  switch (fdwReason)
183  {
184  case DLL_PROCESS_ATTACH:
185  DisableThreadLibraryCalls(hinstDLL);
186  break;
187 
188  case DLL_PROCESS_DETACH:
189  break;
190  }
191 
192  return TRUE;
193 }
#define TRUE
Definition: types.h:120
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
#define DLL_PROCESS_DETACH
Definition: compat.h:119

◆ ServiceControlHandler()

static DWORD WINAPI ServiceControlHandler ( DWORD  dwControl,
DWORD  dwEventType,
LPVOID  lpEventData,
LPVOID  lpContext 
)
static

Definition at line 68 of file srvsvc.c.

Referenced by ServiceMain().

72 {
73  TRACE("ServiceControlHandler() called\n");
74 
75  switch (dwControl)
76  {
78  TRACE(" SERVICE_CONTROL_STOP received\n");
79  /* Stop listening to incoming RPC messages */
82  return ERROR_SUCCESS;
83 
85  TRACE(" SERVICE_CONTROL_PAUSE received\n");
87  return ERROR_SUCCESS;
88 
90  TRACE(" SERVICE_CONTROL_CONTINUE received\n");
92  return ERROR_SUCCESS;
93 
95  TRACE(" SERVICE_CONTROL_INTERROGATE received\n");
97  &ServiceStatus);
98  return ERROR_SUCCESS;
99 
101  TRACE(" SERVICE_CONTROL_SHUTDOWN received\n");
103  return ERROR_SUCCESS;
104 
105  default :
106  TRACE(" Control %lu received\n", dwControl);
108  }
109 }
RPC_STATUS WINAPI RpcMgmtStopServerListening(RPC_BINDING_HANDLE Binding)
Definition: rpc_server.c:1599
#define ERROR_SUCCESS
Definition: deptool.c:10
static SERVICE_STATUS ServiceStatus
Definition: srvsvc.c:38
#define SERVICE_PAUSED
Definition: winsvc.h:27
BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
Definition: sctrl.c:957
#define SERVICE_STOPPED
Definition: winsvc.h:21
#define SERVICE_RUNNING
Definition: winsvc.h:24
smooth NULL
Definition: ftsmooth.c:416
#define SERVICE_CONTROL_INTERROGATE
Definition: winsvc.h:39
#define TRACE(s)
Definition: solgame.cpp:4
#define SERVICE_CONTROL_PAUSE
Definition: winsvc.h:37
static SERVICE_STATUS_HANDLE ServiceStatusHandle
Definition: srvsvc.c:37
#define SERVICE_CONTROL_CONTINUE
Definition: winsvc.h:38
static VOID UpdateServiceStatus(DWORD dwState)
Definition: srvsvc.c:46
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define SERVICE_CONTROL_STOP
Definition: winsvc.h:36
#define SERVICE_CONTROL_SHUTDOWN
Definition: winsvc.h:40

◆ ServiceInit()

static DWORD ServiceInit ( VOID  )
static

Definition at line 114 of file srvsvc.c.

Referenced by ServiceMain().

115 {
116  HANDLE hThread;
117 
118  hThread = CreateThread(NULL,
119  0,
121  NULL,
122  0,
123  NULL);
124 
125  if (!hThread)
126  {
127  ERR("Can't create PortThread\n");
128  return GetLastError();
129  }
130  else
131  CloseHandle(hThread);
132 
133  /* Report a running server service */
136  TRUE,
137  TRUE);
138 
139  return ERROR_SUCCESS;
140 }
DWORD(WINAPI * LPTHREAD_START_ROUTINE)(LPVOID)
Definition: winbase.h:707
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
#define ERROR_SUCCESS
Definition: deptool.c:10
#define SV_TYPE_SERVER
Definition: lmserver.h:428
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
DWORD WINAPI RpcThreadRoutine(LPVOID lpParameter)
Definition: rpc.c: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:112
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI SetServiceBits(SERVICE_STATUS_HANDLE hServiceStatus, DWORD dwServiceBits, BOOL bSetBitsOn, BOOL bUpdateImmediately)
Definition: sctrl.c:935
static SERVICE_STATUS_HANDLE ServiceStatusHandle
Definition: srvsvc.c:37
#define ERR(fmt,...)
Definition: debug.h:109
HANDLE hThread
Definition: wizard.c:27

◆ ServiceMain()

VOID WINAPI ServiceMain ( DWORD  argc,
LPTSTR argv 
)

Definition at line 145 of file srvsvc.c.

146 {
147  DWORD dwError;
148 
151 
152  TRACE("ServiceMain() called\n");
153 
156  NULL);
157  if (!ServiceStatusHandle)
158  {
159  ERR("RegisterServiceCtrlHandlerExW() failed! (Error %lu)\n", GetLastError());
160  return;
161  }
162 
164 
165  dwError = ServiceInit();
166  if (dwError != ERROR_SUCCESS)
167  {
168  ERR("Service stopped (dwError: %lu\n", dwError);
170  return;
171  }
172 
174 }
static int argc
Definition: ServiceArgs.c:12
#define ERROR_SUCCESS
Definition: deptool.c:10
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define SERVICE_START_PENDING
Definition: winsvc.h:22
static char ** argv
Definition: ServiceArgs.c:11
static DWORD WINAPI ServiceControlHandler(DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext)
Definition: srvsvc.c:68
#define SERVICE_STOPPED
Definition: winsvc.h:21
#define SERVICE_RUNNING
Definition: winsvc.h:24
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
static SERVICE_STATUS_HANDLE ServiceStatusHandle
Definition: srvsvc.c:37
static WCHAR ServiceName[]
Definition: srvsvc.c:35
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExW(LPCWSTR lpServiceName, LPHANDLER_FUNCTION_EX lpHandlerProc, LPVOID lpContext)
Definition: sctrl.c:773
static DWORD ServiceInit(VOID)
Definition: srvsvc.c:114
#define ERR(fmt,...)
Definition: debug.h:109
static VOID UpdateServiceStatus(DWORD dwState)
Definition: srvsvc.c:46

◆ UpdateServiceStatus()

static VOID UpdateServiceStatus ( DWORD  dwState)
static

Definition at line 46 of file srvsvc.c.

Referenced by ServiceControlHandler(), and ServiceMain().

47 {
49  ServiceStatus.dwCurrentState = dwState;
54 
55  if (dwState == SERVICE_START_PENDING ||
56  dwState == SERVICE_STOP_PENDING ||
57  dwState == SERVICE_PAUSE_PENDING ||
58  dwState == SERVICE_CONTINUE_PENDING)
59  ServiceStatus.dwWaitHint = 10000;
60  else
62 
64  &ServiceStatus);
65 }
DWORD dwCurrentState
Definition: winsvc.h:100
#define SERVICE_PAUSE_PENDING
Definition: winsvc.h:26
static SERVICE_STATUS ServiceStatus
Definition: srvsvc.c:38
#define SERVICE_START_PENDING
Definition: winsvc.h:22
DWORD dwServiceSpecificExitCode
Definition: winsvc.h:103
BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
Definition: sctrl.c:957
DWORD dwCheckPoint
Definition: winsvc.h:104
#define SERVICE_WIN32_OWN_PROCESS
Definition: cmtypes.h:960
DWORD dwWaitHint
Definition: winsvc.h:105
DWORD dwWin32ExitCode
Definition: winsvc.h:102
DWORD dwServiceType
Definition: winsvc.h:99
static SERVICE_STATUS_HANDLE ServiceStatusHandle
Definition: srvsvc.c:37
DWORD dwControlsAccepted
Definition: winsvc.h:101
#define SERVICE_CONTINUE_PENDING
Definition: winsvc.h:25
#define SERVICE_STOP_PENDING
Definition: winsvc.h:23

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( srvsvc  )

Variable Documentation

◆ dwServiceBits

DWORD dwServiceBits = 0

Definition at line 40 of file srvsvc.c.

Referenced by NetrServerGetInfo(), NetrServerSetServiceBits(), and RI_ScSetServiceBitsW().

◆ ServiceName

WCHAR ServiceName[] = L"Lanmanserver"
static

Definition at line 35 of file srvsvc.c.

Referenced by ServiceMain().

◆ ServiceStatus

SERVICE_STATUS ServiceStatus
static

Definition at line 38 of file srvsvc.c.

◆ ServiceStatusHandle

SERVICE_STATUS_HANDLE ServiceStatusHandle
static

Definition at line 37 of file srvsvc.c.

Referenced by ServiceControlHandler(), ServiceInit(), ServiceMain(), and UpdateServiceStatus().