mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-23 00:43:00 -05:00
dll: FSP_SERVICE
This commit is contained in:
parent
125b612c9f
commit
1017e7fda7
@ -81,17 +81,9 @@ FSP_API NTSTATUS FspServiceCreate(PWSTR ServiceName,
|
|||||||
Service->OnStart = OnStart;
|
Service->OnStart = OnStart;
|
||||||
Service->OnStop = OnStop;
|
Service->OnStop = OnStop;
|
||||||
Service->OnControl = OnControl;
|
Service->OnControl = OnControl;
|
||||||
|
|
||||||
Service->AcceptControl = OnStop ? SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN : 0;
|
Service->AcceptControl = OnStop ? SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN : 0;
|
||||||
|
|
||||||
InitializeCriticalSection(&Service->ServiceStatusGuard);
|
InitializeCriticalSection(&Service->ServiceStatusGuard);
|
||||||
Service->ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
|
|
||||||
Service->ServiceStatus.dwCurrentState = SERVICE_STOPPED;
|
|
||||||
Service->ServiceStatus.dwControlsAccepted = 0;
|
|
||||||
Service->ServiceStatus.dwWin32ExitCode = NO_ERROR;
|
|
||||||
Service->ServiceStatus.dwServiceSpecificExitCode = 0;
|
|
||||||
Service->ServiceStatus.dwCheckPoint = 0;
|
|
||||||
Service->ServiceStatus.dwWaitHint = 0;
|
|
||||||
|
|
||||||
*PService = Service;
|
*PService = Service;
|
||||||
|
|
||||||
@ -185,6 +177,15 @@ FSP_API NTSTATUS FspServiceRun(FSP_SERVICE *Service)
|
|||||||
{
|
{
|
||||||
SERVICE_TABLE_ENTRYW ServiceTable[2];
|
SERVICE_TABLE_ENTRYW ServiceTable[2];
|
||||||
|
|
||||||
|
Service->ExitCode = NO_ERROR;
|
||||||
|
Service->ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
|
||||||
|
Service->ServiceStatus.dwCurrentState = SERVICE_STOPPED;
|
||||||
|
Service->ServiceStatus.dwControlsAccepted = 0;
|
||||||
|
Service->ServiceStatus.dwWin32ExitCode = NO_ERROR;
|
||||||
|
Service->ServiceStatus.dwServiceSpecificExitCode = 0;
|
||||||
|
Service->ServiceStatus.dwCheckPoint = 0;
|
||||||
|
Service->ServiceStatus.dwWaitHint = 0;
|
||||||
|
|
||||||
ServiceTable[0].lpServiceName = Service->ServiceName;
|
ServiceTable[0].lpServiceName = Service->ServiceName;
|
||||||
ServiceTable[0].lpServiceProc = FspServiceEntry;
|
ServiceTable[0].lpServiceProc = FspServiceEntry;
|
||||||
ServiceTable[1].lpServiceName = 0;
|
ServiceTable[1].lpServiceName = 0;
|
||||||
@ -203,10 +204,16 @@ FSP_API NTSTATUS FspServiceRun(FSP_SERVICE *Service)
|
|||||||
|
|
||||||
/* enter INTERACTIVE (DEBUG) mode! */
|
/* enter INTERACTIVE (DEBUG) mode! */
|
||||||
|
|
||||||
Service->InteractiveEvent = CreateEventW(0, TRUE, FALSE, 0);
|
|
||||||
if (0 == Service->InteractiveEvent)
|
if (0 == Service->InteractiveEvent)
|
||||||
return FspNtStatusFromWin32(GetLastError());
|
{
|
||||||
|
Service->InteractiveEvent = CreateEventW(0, TRUE, FALSE, 0);
|
||||||
|
if (0 == Service->InteractiveEvent)
|
||||||
|
return FspNtStatusFromWin32(GetLastError());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ResetEvent(Service->InteractiveEvent);
|
||||||
|
|
||||||
|
/* create a thread to mimic what StartServiceCtrlDispatcherW does */
|
||||||
Thread = CreateThread(0, 0, FspServiceInteractiveThread, Service, 0, 0);
|
Thread = CreateThread(0, 0, FspServiceInteractiveThread, Service, 0, 0);
|
||||||
if (0 == Thread)
|
if (0 == Thread)
|
||||||
return FspNtStatusFromWin32(GetLastError());
|
return FspNtStatusFromWin32(GetLastError());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user