ReactOS  0.4.14-dev-98-gb0d4763
wkssvc.c File Reference
#include "precomp.h"
Include dependency graph for wkssvc.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (wkssvc)
 
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"lanmanworkstation"
 
static SERVICE_STATUS_HANDLE ServiceStatusHandle
 
static SERVICE_STATUS ServiceStatus
 

Function Documentation

◆ DllMain()

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

Definition at line 181 of file wkssvc.c.

184 {
185  switch (fdwReason)
186  {
187  case DLL_PROCESS_ATTACH:
188  DisableThreadLibraryCalls(hinstDLL);
189  break;
190 
191  case DLL_PROCESS_DETACH:
192  break;
193  }
194 
195  return TRUE;
196 }
#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 wkssvc.c.

72 {
73  TRACE("ServiceControlHandler() called\n");
74 
75  switch (dwControl)
76  {
78  TRACE(" SERVICE_CONTROL_STOP received\n");
80  /* Stop listening to incoming RPC messages */
83  return ERROR_SUCCESS;
84 
86  TRACE(" SERVICE_CONTROL_PAUSE received\n");
88  return ERROR_SUCCESS;
89 
91  TRACE(" SERVICE_CONTROL_CONTINUE received\n");
93  return ERROR_SUCCESS;
94 
96  TRACE(" SERVICE_CONTROL_INTERROGATE received\n");
98  &ServiceStatus);
99  return ERROR_SUCCESS;
100 
102  TRACE(" SERVICE_CONTROL_SHUTDOWN received\n");
104  /* Stop listening to incoming RPC messages */
107  return ERROR_SUCCESS;
108 
109  default :
110  TRACE(" Control %lu received\n", dwControl);
112  }
113 }
RPC_STATUS WINAPI RpcMgmtStopServerListening(RPC_BINDING_HANDLE Binding)
Definition: rpc_server.c:1599
#define ERROR_SUCCESS
Definition: deptool.c:10
#define SERVICE_PAUSED
Definition: winsvc.h:27
static SERVICE_STATUS ServiceStatus
Definition: wkssvc.c:38
BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
Definition: sctrl.c:995
#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 VOID UpdateServiceStatus(DWORD dwState)
Definition: wkssvc.c:43
#define SERVICE_CONTROL_CONTINUE
Definition: winsvc.h:38
static SERVICE_STATUS_HANDLE ServiceStatusHandle
Definition: wkssvc.c:37
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define SERVICE_CONTROL_STOP
Definition: winsvc.h:36
#define SERVICE_STOP_PENDING
Definition: winsvc.h:23
#define SERVICE_CONTROL_SHUTDOWN
Definition: winsvc.h:40

Referenced by ServiceMain().

◆ ServiceInit()

static DWORD ServiceInit ( VOID  )
static

Definition at line 118 of file wkssvc.c.

119 {
120  HANDLE hThread;
121 
123  0,
125  NULL,
126  0,
127  NULL);
128 
129  if (!hThread)
130  {
131  ERR("Can't create PortThread\n");
132  return GetLastError();
133  }
134  else
136 
137  /* Report a running workstation service */
140  TRUE,
141  TRUE);
142 
143  return ERROR_SUCCESS;
144 }
#define SV_TYPE_WORKSTATION
Definition: lmserver.h:427
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
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:136
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI SetServiceBits(SERVICE_STATUS_HANDLE hServiceStatus, DWORD dwServiceBits, BOOL bSetBitsOn, BOOL bUpdateImmediately)
Definition: sctrl.c:973
#define ERR(fmt,...)
Definition: debug.h:109
HANDLE hThread
Definition: wizard.c:27
static SERVICE_STATUS_HANDLE ServiceStatusHandle
Definition: wkssvc.c:37

Referenced by ServiceMain().

◆ ServiceMain()

VOID WINAPI ServiceMain ( DWORD  argc,
LPTSTR argv 
)

Definition at line 148 of file wkssvc.c.

149 {
150  DWORD dwError;
151 
154 
155  TRACE("ServiceMain() called\n");
156 
159  NULL);
160  if (!ServiceStatusHandle)
161  {
162  ERR("RegisterServiceCtrlHandlerExW() failed! (Error %lu)\n", GetLastError());
163  return;
164  }
165 
167 
168  dwError = ServiceInit();
169  if (dwError != ERROR_SUCCESS)
170  {
171  ERR("Service stopped (dwError: %lu\n", dwError);
173  return;
174  }
175 
177 }
static int argc
Definition: ServiceArgs.c:12
static DWORD WINAPI ServiceControlHandler(DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext)
Definition: wkssvc.c:68
#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
#define argv
Definition: mplay32.c:18
static WCHAR ServiceName[]
Definition: wkssvc.c:35
#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
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExW(LPCWSTR lpServiceName, LPHANDLER_FUNCTION_EX lpHandlerProc, LPVOID lpContext)
Definition: sctrl.c:810
#define ERR(fmt,...)
Definition: debug.h:109
static VOID UpdateServiceStatus(DWORD dwState)
Definition: wkssvc.c:43
static SERVICE_STATUS_HANDLE ServiceStatusHandle
Definition: wkssvc.c:37
static DWORD ServiceInit(VOID)
Definition: wkssvc.c:118

◆ UpdateServiceStatus()

static VOID UpdateServiceStatus ( DWORD  dwState)
static

Definition at line 43 of file wkssvc.c.

44 {
46  ServiceStatus.dwCurrentState = dwState;
51 
52  if (dwState == SERVICE_START_PENDING ||
53  dwState == SERVICE_STOP_PENDING ||
54  dwState == SERVICE_PAUSE_PENDING ||
55  dwState == SERVICE_CONTINUE_PENDING)
56  ServiceStatus.dwWaitHint = 10000;
57  else
59 
60  if (dwState == SERVICE_RUNNING)
62 
64  &ServiceStatus);
65 }
DWORD dwCurrentState
Definition: winsvc.h:100
#define SERVICE_PAUSE_PENDING
Definition: winsvc.h:26
#define SERVICE_ACCEPT_STOP
Definition: winsvc.h:28
#define SERVICE_START_PENDING
Definition: winsvc.h:22
DWORD dwServiceSpecificExitCode
Definition: winsvc.h:103
static SERVICE_STATUS ServiceStatus
Definition: wkssvc.c:38
BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
Definition: sctrl.c:995
DWORD dwCheckPoint
Definition: winsvc.h:104
#define SERVICE_RUNNING
Definition: winsvc.h:24
#define SERVICE_WIN32_OWN_PROCESS
Definition: cmtypes.h:960
#define SERVICE_ACCEPT_SHUTDOWN
Definition: winsvc.h:30
DWORD dwWaitHint
Definition: winsvc.h:105
DWORD dwWin32ExitCode
Definition: winsvc.h:102
DWORD dwServiceType
Definition: winsvc.h:99
DWORD dwControlsAccepted
Definition: winsvc.h:101
#define SERVICE_CONTINUE_PENDING
Definition: winsvc.h:25
static SERVICE_STATUS_HANDLE ServiceStatusHandle
Definition: wkssvc.c:37
#define SERVICE_STOP_PENDING
Definition: winsvc.h:23

Referenced by ServiceControlHandler(), and ServiceMain().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( wkssvc  )

Variable Documentation

◆ ServiceName

WCHAR ServiceName[] = L"lanmanworkstation"
static

Definition at line 35 of file wkssvc.c.

Referenced by ServiceMain().

◆ ServiceStatus

SERVICE_STATUS ServiceStatus
static

Definition at line 38 of file wkssvc.c.

Referenced by ServiceControlHandler(), and UpdateServiceStatus().

◆ ServiceStatusHandle

SERVICE_STATUS_HANDLE ServiceStatusHandle
static

Definition at line 37 of file wkssvc.c.

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