mirror of
https://github.com/reactos/reactos.git
synced 2024-07-30 08:08:56 +00:00
[spoolsv]
- Switch to wine debug macros. Add new debug channel spoolsv. - Update service status when the service receives a control message. svn path=/trunk/; revision=44960
This commit is contained in:
parent
9fb7195e8e
commit
ef88ea7724
|
@ -11,8 +11,10 @@
|
|||
#define WIN32_NO_STATUS
|
||||
#include <windows.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(spoolsv);
|
||||
|
||||
|
||||
/* GLOBALS ******************************************************************/
|
||||
|
||||
|
@ -24,6 +26,35 @@ SERVICE_STATUS ServiceStatus;
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
static VOID
|
||||
UpdateServiceStatus(DWORD dwState)
|
||||
{
|
||||
ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
|
||||
ServiceStatus.dwCurrentState = dwState;
|
||||
|
||||
if (dwState == SERVICE_RUNNING)
|
||||
ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_PAUSE_CONTINUE | SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
|
||||
else if (dwState == SERVICE_PAUSED)
|
||||
ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_PAUSE_CONTINUE;
|
||||
else
|
||||
ServiceStatus.dwControlsAccepted = 0;
|
||||
|
||||
ServiceStatus.dwWin32ExitCode = 0;
|
||||
ServiceStatus.dwServiceSpecificExitCode = 0;
|
||||
ServiceStatus.dwCheckPoint = 0;
|
||||
|
||||
if (dwState == SERVICE_START_PENDING ||
|
||||
dwState == SERVICE_STOP_PENDING ||
|
||||
dwState == SERVICE_PAUSE_PENDING ||
|
||||
dwState == SERVICE_CONTINUE_PENDING)
|
||||
ServiceStatus.dwWaitHint = 10000;
|
||||
else
|
||||
ServiceStatus.dwWaitHint = 0;
|
||||
|
||||
SetServiceStatus(ServiceStatusHandle,
|
||||
&ServiceStatus);
|
||||
}
|
||||
|
||||
|
||||
static DWORD WINAPI
|
||||
ServiceControlHandler(DWORD dwControl,
|
||||
|
@ -31,42 +62,61 @@ ServiceControlHandler(DWORD dwControl,
|
|||
LPVOID lpEventData,
|
||||
LPVOID lpContext)
|
||||
{
|
||||
TRACE("ServiceControlHandler() called\n");
|
||||
|
||||
switch (dwControl)
|
||||
{
|
||||
case SERVICE_CONTROL_STOP:
|
||||
TRACE(" SERVICE_CONTROL_STOP received\n");
|
||||
UpdateServiceStatus(SERVICE_STOPPED);
|
||||
return ERROR_SUCCESS;
|
||||
|
||||
case SERVICE_CONTROL_PAUSE:
|
||||
TRACE(" SERVICE_CONTROL_PAUSE received\n");
|
||||
UpdateServiceStatus(SERVICE_PAUSED);
|
||||
return ERROR_SUCCESS;
|
||||
|
||||
case SERVICE_CONTROL_CONTINUE:
|
||||
TRACE(" SERVICE_CONTROL_CONTINUE received\n");
|
||||
UpdateServiceStatus(SERVICE_RUNNING);
|
||||
return ERROR_SUCCESS;
|
||||
|
||||
case SERVICE_CONTROL_INTERROGATE:
|
||||
TRACE(" SERVICE_CONTROL_INTERROGATE received\n");
|
||||
SetServiceStatus(ServiceStatusHandle,
|
||||
&ServiceStatus);
|
||||
return ERROR_SUCCESS;
|
||||
|
||||
case SERVICE_CONTROL_SHUTDOWN:
|
||||
TRACE(" SERVICE_CONTROL_SHUTDOWN received\n");
|
||||
UpdateServiceStatus(SERVICE_STOPPED);
|
||||
return ERROR_SUCCESS;
|
||||
|
||||
default :
|
||||
TRACE(" Control %lu received\n");
|
||||
return ERROR_CALL_NOT_IMPLEMENTED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static VOID CALLBACK
|
||||
ServiceMain(DWORD argc, LPTSTR *argv)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(argc);
|
||||
UNREFERENCED_PARAMETER(argv);
|
||||
|
||||
DPRINT("ServiceMain() called\n");
|
||||
TRACE("ServiceMain() called\n");
|
||||
|
||||
ServiceStatusHandle = RegisterServiceCtrlHandlerExW(SERVICE_NAME,
|
||||
ServiceControlHandler,
|
||||
NULL);
|
||||
|
||||
/* Service is now running */
|
||||
ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
|
||||
ServiceStatus.dwServiceSpecificExitCode = 0;
|
||||
ServiceStatus.dwWin32ExitCode = NO_ERROR;
|
||||
ServiceStatus.dwWaitHint = 0;
|
||||
ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
|
||||
ServiceStatus.dwCheckPoint = 0;
|
||||
ServiceStatus.dwCurrentState = SERVICE_RUNNING;
|
||||
SetServiceStatus(ServiceStatusHandle, &ServiceStatus);
|
||||
|
||||
DPRINT("ServiceMain() done\n");
|
||||
TRACE("Calling SetServiceStatus()\n");
|
||||
UpdateServiceStatus(SERVICE_RUNNING);
|
||||
TRACE("SetServiceStatus() called\n");
|
||||
|
||||
|
||||
TRACE("ServiceMain() done\n");
|
||||
}
|
||||
|
||||
|
||||
|
@ -82,11 +132,11 @@ wmain(int argc, WCHAR *argv[])
|
|||
UNREFERENCED_PARAMETER(argc);
|
||||
UNREFERENCED_PARAMETER(argv);
|
||||
|
||||
DPRINT("Spoolsv: main() started\n");
|
||||
TRACE("Spoolsv: main() started\n");
|
||||
|
||||
StartServiceCtrlDispatcher(ServiceTable);
|
||||
|
||||
DPRINT("Spoolsv: main() done\n");
|
||||
TRACE("Spoolsv: main() done\n");
|
||||
|
||||
ExitThread(0);
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
|
||||
<module name="spoolsv" type="win32cui" installbase="system32" installname="spoolsv.exe" unicode="yes">
|
||||
<include base="spoolsv">.</include>
|
||||
<library>wine</library>
|
||||
<library>ntdll</library>
|
||||
<library>advapi32</library>
|
||||
<file>spoolsv.c</file>
|
||||
|
|
Loading…
Reference in a new issue