ReactOS 0.4.16-dev-320-g3bd9ddc
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 ServiceInit (VOID)
 
static VOID ServiceShutdown (VOID)
 
static DWORD WINAPI ServiceControlHandler (DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext)
 
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
 
OSVERSIONINFOW VersionInfo
 
HANDLE LsaHandle = NULL
 
ULONG LsaAuthenticationPackage = 0
 

Function Documentation

◆ DllMain()

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

Definition at line 235 of file wkssvc.c.

238{
239 switch (fdwReason)
240 {
243 break;
244
246 break;
247 }
248
249 return TRUE;
250}
#define TRUE
Definition: types.h:120
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85

◆ ServiceControlHandler()

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

Definition at line 151 of file wkssvc.c.

155{
156 TRACE("ServiceControlHandler() called\n");
157
158 switch (dwControl)
159 {
161 TRACE(" SERVICE_CONTROL_STOP received\n");
163 /* Stop listening to incoming RPC messages */
167 return ERROR_SUCCESS;
168
170 TRACE(" SERVICE_CONTROL_PAUSE received\n");
172 return ERROR_SUCCESS;
173
175 TRACE(" SERVICE_CONTROL_CONTINUE received\n");
177 return ERROR_SUCCESS;
178
180 TRACE(" SERVICE_CONTROL_INTERROGATE received\n");
183 return ERROR_SUCCESS;
184
186 TRACE(" SERVICE_CONTROL_SHUTDOWN received\n");
188 /* Stop listening to incoming RPC messages */
192 return ERROR_SUCCESS;
193
194 default :
195 TRACE(" Control %lu received\n", dwControl);
197 }
198}
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
RPC_STATUS WINAPI RpcMgmtStopServerListening(RPC_BINDING_HANDLE Binding)
Definition: rpc_server.c:1596
BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
Definition: sctrl.c:997
#define TRACE(s)
Definition: solgame.cpp:4
#define SERVICE_STOPPED
Definition: winsvc.h:21
#define SERVICE_STOP_PENDING
Definition: winsvc.h:23
#define SERVICE_CONTROL_SHUTDOWN
Definition: winsvc.h:40
#define SERVICE_PAUSED
Definition: winsvc.h:27
#define SERVICE_RUNNING
Definition: winsvc.h:24
#define SERVICE_CONTROL_CONTINUE
Definition: winsvc.h:38
#define SERVICE_CONTROL_STOP
Definition: winsvc.h:36
#define SERVICE_CONTROL_PAUSE
Definition: winsvc.h:37
#define SERVICE_CONTROL_INTERROGATE
Definition: winsvc.h:39
static VOID ServiceShutdown(VOID)
Definition: wkssvc.c:135
static VOID UpdateServiceStatus(DWORD dwState)
Definition: wkssvc.c:47
static SERVICE_STATUS_HANDLE ServiceStatusHandle
Definition: wkssvc.c:37
static SERVICE_STATUS ServiceStatus
Definition: wkssvc.c:38

Referenced by ServiceMain().

◆ ServiceInit()

static DWORD ServiceInit ( VOID  )
static

Definition at line 74 of file wkssvc.c.

75{
76 LSA_STRING ProcessName = RTL_CONSTANT_STRING("Workstation");
81
82 ERR("ServiceInit()\n");
83
84 /* Get the OS version */
87
89
90 Status = LsaRegisterLogonProcess(&ProcessName,
91 &LsaHandle,
92 &Mode);
93 if (!NT_SUCCESS(Status))
94 {
95 ERR("LsaRegisterLogonProcess() failed! (Status 0x%08lx)\n", Status);
96 return 1;
97 }
98
100 &PackageName,
102 if (!NT_SUCCESS(Status))
103 {
104 ERR("LsaLookupAuthenticationPackage() failed! (Status 0x%08lx)\n", Status);
105 return 1;
106 }
107
109 0,
111 NULL,
112 0,
113 NULL);
114
115 if (!hThread)
116 {
117 ERR("Can't create PortThread\n");
118 return GetLastError();
119 }
120 else
122
123 /* Report a running workstation service */
126 TRUE,
127 TRUE);
128
129 return ERROR_SUCCESS;
130}
LONG NTSTATUS
Definition: precomp.h:26
DWORD WINAPI RpcThreadRoutine(LPVOID lpParameter)
Definition: rpcserver.c:20
VOID InitWorkstationInfo(VOID)
Definition: info.c:23
#define ERR(fmt,...)
Definition: precomp.h:57
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define CloseHandle
Definition: compat.h:739
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
BOOL WINAPI GetVersionExW(IN LPOSVERSIONINFOW lpVersionInformation)
Definition: version.c:37
Status
Definition: gdiplustypes.h:25
_In_ ULONG Mode
Definition: hubbusif.h:303
#define SV_TYPE_WORKSTATION
Definition: lmserver.h:427
HANDLE hThread
Definition: wizard.c:28
NTSTATUS NTAPI LsaLookupAuthenticationPackage(HANDLE, PLSA_STRING, PULONG)
#define MSV1_0_PACKAGE_NAME
Definition: ntsecapi.h:42
ULONG LSA_OPERATIONAL_MODE
Definition: ntsecapi.h:367
NTSTATUS NTAPI LsaRegisterLogonProcess(PLSA_STRING, PHANDLE, PLSA_OPERATIONAL_MODE)
BOOL WINAPI SetServiceBits(SERVICE_STATUS_HANDLE hServiceStatus, DWORD dwServiceBits, BOOL bSetBitsOn, BOOL bUpdateImmediately)
Definition: sctrl.c:975
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:246
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
DWORD(WINAPI * LPTHREAD_START_ROUTINE)(LPVOID)
Definition: winbase.h:754
HANDLE LsaHandle
Definition: wkssvc.c:41
OSVERSIONINFOW VersionInfo
Definition: wkssvc.c:40
ULONG LsaAuthenticationPackage
Definition: wkssvc.c:42

Referenced by ServiceMain().

◆ ServiceMain()

VOID WINAPI ServiceMain ( DWORD  argc,
LPTSTR argv 
)

Definition at line 202 of file wkssvc.c.

203{
204 DWORD dwError;
205
208
209 TRACE("ServiceMain() called\n");
210
213 NULL);
215 {
216 ERR("RegisterServiceCtrlHandlerExW() failed! (Error %lu)\n", GetLastError());
217 return;
218 }
219
221
222 dwError = ServiceInit();
223 if (dwError != ERROR_SUCCESS)
224 {
225 ERR("Service stopped (dwError: %lu\n", dwError);
227 return;
228 }
229
231}
static int argc
Definition: ServiceArgs.c:12
unsigned long DWORD
Definition: ntddk_ex.h:95
#define argv
Definition: mplay32.c:18
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExW(LPCWSTR lpServiceName, LPHANDLER_FUNCTION_EX lpHandlerProc, LPVOID lpContext)
Definition: sctrl.c:812
#define SERVICE_START_PENDING
Definition: winsvc.h:22
static WCHAR ServiceName[]
Definition: wkssvc.c:35
static DWORD ServiceInit(VOID)
Definition: wkssvc.c:74
static DWORD WINAPI ServiceControlHandler(DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext)
Definition: wkssvc.c:151

◆ ServiceShutdown()

static VOID ServiceShutdown ( VOID  )
static

Definition at line 135 of file wkssvc.c.

136{
138
139 ERR("ServiceShutdown()\n");
140
142 if (!NT_SUCCESS(Status))
143 {
144 ERR("LsaDeRegisterLogonProcess() failed! (Status 0x%08lx)\n", Status);
145 return;
146 }
147}
NTSTATUS NTAPI LsaDeregisterLogonProcess(HANDLE)

Referenced by ServiceControlHandler().

◆ UpdateServiceStatus()

static VOID UpdateServiceStatus ( DWORD  dwState)
static

Definition at line 47 of file wkssvc.c.

48{
55
56 if (dwState == SERVICE_START_PENDING ||
57 dwState == SERVICE_STOP_PENDING ||
58 dwState == SERVICE_PAUSE_PENDING ||
59 dwState == SERVICE_CONTINUE_PENDING)
61 else
63
64 if (dwState == SERVICE_RUNNING)
66
69}
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
#define SERVICE_ACCEPT_STOP
Definition: winsvc.h:28
#define SERVICE_ACCEPT_SHUTDOWN
Definition: winsvc.h:30
#define SERVICE_PAUSE_PENDING
Definition: winsvc.h:26
#define SERVICE_CONTINUE_PENDING
Definition: winsvc.h:25
#define SERVICE_WIN32_SHARE_PROCESS
Definition: cmtypes.h:963

Referenced by ServiceControlHandler(), and ServiceMain().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( wkssvc  )

Variable Documentation

◆ LsaAuthenticationPackage

ULONG LsaAuthenticationPackage = 0

Definition at line 42 of file wkssvc.c.

Referenced by ServiceInit().

◆ LsaHandle

HANDLE LsaHandle = NULL

Definition at line 41 of file wkssvc.c.

Referenced by ServiceInit(), and ServiceShutdown().

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

◆ VersionInfo