ReactOS  0.4.12-dev-75-g00dd17e
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 174 of file wkssvc.c.

177 {
178  switch (fdwReason)
179  {
180  case DLL_PROCESS_ATTACH:
181  DisableThreadLibraryCalls(hinstDLL);
182  break;
183 
184  case DLL_PROCESS_DETACH:
185  break;
186  }
187 
188  return TRUE;
189 }
#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 65 of file wkssvc.c.

Referenced by ServiceMain().

69 {
70  TRACE("ServiceControlHandler() called\n");
71 
72  switch (dwControl)
73  {
75  TRACE(" SERVICE_CONTROL_STOP received\n");
76  /* Stop listening to incoming RPC messages */
79  return ERROR_SUCCESS;
80 
82  TRACE(" SERVICE_CONTROL_PAUSE received\n");
84  return ERROR_SUCCESS;
85 
87  TRACE(" SERVICE_CONTROL_CONTINUE received\n");
89  return ERROR_SUCCESS;
90 
92  TRACE(" SERVICE_CONTROL_INTERROGATE received\n");
94  &ServiceStatus);
95  return ERROR_SUCCESS;
96 
98  TRACE(" SERVICE_CONTROL_SHUTDOWN received\n");
100  return ERROR_SUCCESS;
101 
102  default :
103  TRACE(" Control %lu received\n", dwControl);
105  }
106 }
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: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 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_CONTROL_SHUTDOWN
Definition: winsvc.h:40

◆ ServiceInit()

static DWORD ServiceInit ( VOID  )
static

Definition at line 111 of file wkssvc.c.

Referenced by ServiceMain().

112 {
113  HANDLE hThread;
114 
115  hThread = CreateThread(NULL,
116  0,
118  NULL,
119  0,
120  NULL);
121 
122  if (!hThread)
123  {
124  ERR("Can't create PortThread\n");
125  return GetLastError();
126  }
127  else
128  CloseHandle(hThread);
129 
130  /* Report a running workstation service */
133  TRUE,
134  TRUE);
135 
136  return ERROR_SUCCESS;
137 }
#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:112
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI SetServiceBits(SERVICE_STATUS_HANDLE hServiceStatus, DWORD dwServiceBits, BOOL bSetBitsOn, BOOL bUpdateImmediately)
Definition: sctrl.c:935
#define ERR(fmt,...)
Definition: debug.h:109
HANDLE hThread
Definition: wizard.c:27
static SERVICE_STATUS_HANDLE ServiceStatusHandle
Definition: wkssvc.c:37

◆ ServiceMain()

VOID WINAPI ServiceMain ( DWORD  argc,
LPTSTR argv 
)

Definition at line 141 of file wkssvc.c.

142 {
143  DWORD dwError;
144 
147 
148  TRACE("ServiceMain() called\n");
149 
152  NULL);
153  if (!ServiceStatusHandle)
154  {
155  ERR("RegisterServiceCtrlHandlerExW() failed! (Error %lu)\n", GetLastError());
156  return;
157  }
158 
160 
161  dwError = ServiceInit();
162  if (dwError != ERROR_SUCCESS)
163  {
164  ERR("Service stopped (dwError: %lu\n", dwError);
166  return;
167  }
168 
170 }
static int argc
Definition: ServiceArgs.c:12
static DWORD WINAPI ServiceControlHandler(DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext)
Definition: wkssvc.c:65
#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 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:773
#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:111

◆ UpdateServiceStatus()

static VOID UpdateServiceStatus ( DWORD  dwState)
static

Definition at line 43 of file wkssvc.c.

Referenced by ServiceControlHandler(), and ServiceMain().

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 
61  &ServiceStatus);
62 }
DWORD dwCurrentState
Definition: winsvc.h:100
#define SERVICE_PAUSE_PENDING
Definition: winsvc.h:26
#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: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
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

◆ 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.

◆ ServiceStatusHandle

SERVICE_STATUS_HANDLE ServiceStatusHandle
static

Definition at line 37 of file wkssvc.c.

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