Author: ekohl
Date: Sat Feb 20 13:59:53 2010
New Revision: 45632
URL:
http://svn.reactos.org/svn/reactos?rev=45632&view=rev
Log:
Make EventLog and Spooler services report their status to the SCM.
Modified:
trunk/reactos/base/services/eventlog/eventlog.c
trunk/reactos/base/services/spoolsv/spoolsv.c
Modified: trunk/reactos/base/services/eventlog/eventlog.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/eventlog/eve…
==============================================================================
--- trunk/reactos/base/services/eventlog/eventlog.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/eventlog/eventlog.c [iso-8859-1] Sat Feb 20 13:59:53 2010
@@ -13,11 +13,11 @@
/* GLOBALS ******************************************************************/
-VOID CALLBACK ServiceMain(DWORD argc, LPTSTR * argv);
-
-SERVICE_TABLE_ENTRY ServiceTable[2] =
-{
- { L"EventLog", (LPSERVICE_MAIN_FUNCTION) ServiceMain },
+static VOID CALLBACK ServiceMain(DWORD, LPWSTR *);
+static WCHAR ServiceName[] = L"EventLog";
+static SERVICE_TABLE_ENTRYW ServiceTable[2] =
+{
+ { ServiceName, ServiceMain },
{ NULL, NULL }
};
@@ -26,7 +26,20 @@
/* FUNCTIONS ****************************************************************/
-VOID CALLBACK ServiceMain(DWORD argc, LPTSTR * argv)
+static DWORD WINAPI
+ServiceControlHandler(DWORD dwControl,
+ DWORD dwEventType,
+ LPVOID lpEventData,
+ LPVOID lpContext)
+{
+ /* FIXME */
+ DPRINT1("ServiceControlHandler() called (control code %lu)\n", dwControl);
+ return ERROR_SUCCESS;
+}
+
+
+static DWORD
+ServiceInit(VOID)
{
HANDLE hThread;
@@ -39,7 +52,10 @@
NULL);
if (!hThread)
+ {
DPRINT("Can't create PortThread\n");
+ return GetLastError();
+ }
else
CloseHandle(hThread);
@@ -52,10 +68,68 @@
NULL);
if (!hThread)
+ {
DPRINT("Can't create RpcThread\n");
+ return GetLastError();
+ }
else
CloseHandle(hThread);
-}
+
+ return ERROR_SUCCESS;
+}
+
+
+static VOID CALLBACK
+ServiceMain(DWORD argc,
+ LPWSTR *argv)
+{
+ SERVICE_STATUS ServiceStatus;
+ SERVICE_STATUS_HANDLE ServiceStatusHandle;
+ DWORD dwError;
+
+ UNREFERENCED_PARAMETER(argc);
+ UNREFERENCED_PARAMETER(argv);
+
+ DPRINT("ServiceMain() called\n");
+
+ ServiceStatusHandle = RegisterServiceCtrlHandlerExW(ServiceName,
+ ServiceControlHandler,
+ NULL);
+ if (!ServiceStatusHandle)
+ {
+ dwError = GetLastError();
+ DPRINT1("RegisterServiceCtrlHandlerW() failed! (Error %lu)\n",
dwError);
+ return;
+ }
+
+ ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
+ ServiceStatus.dwCurrentState = SERVICE_START_PENDING;
+ ServiceStatus.dwControlsAccepted = 0;
+ ServiceStatus.dwWin32ExitCode = NO_ERROR;
+ ServiceStatus.dwServiceSpecificExitCode = 0;
+ ServiceStatus.dwCheckPoint = 0;
+ ServiceStatus.dwWaitHint = 2000;
+
+ SetServiceStatus(ServiceStatusHandle,
+ &ServiceStatus);
+
+ dwError = ServiceInit();
+ if (dwError != ERROR_SUCCESS)
+ {
+ DPRINT1("Service stopped\n");
+ ServiceStatus.dwCurrentState = SERVICE_STOPPED;
+ }
+ else
+ {
+ ServiceStatus.dwCurrentState = SERVICE_RUNNING;
+ }
+
+ SetServiceStatus(ServiceStatusHandle,
+ &ServiceStatus);
+
+ DPRINT("ServiceMain() done\n");
+}
+
BOOL LoadLogFile(HKEY hKey, WCHAR * LogName)
{
Modified: trunk/reactos/base/services/spoolsv/spoolsv.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/spoolsv/spoo…
==============================================================================
--- trunk/reactos/base/services/spoolsv/spoolsv.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/spoolsv/spoolsv.c [iso-8859-1] Sat Feb 20 13:59:53 2010
@@ -18,7 +18,13 @@
/* GLOBALS ******************************************************************/
-#define SERVICE_NAME TEXT("Spooler")
+static VOID CALLBACK ServiceMain(DWORD argc, LPWSTR *argv);
+static WCHAR ServiceName[] = L"Spooler";
+static SERVICE_TABLE_ENTRYW ServiceTable[] =
+{
+ {ServiceName, ServiceMain},
+ {NULL, NULL}
+};
SERVICE_STATUS_HANDLE ServiceStatusHandle;
SERVICE_STATUS ServiceStatus;
@@ -100,14 +106,14 @@
static VOID CALLBACK
-ServiceMain(DWORD argc, LPTSTR *argv)
+ServiceMain(DWORD argc, LPWSTR *argv)
{
UNREFERENCED_PARAMETER(argc);
UNREFERENCED_PARAMETER(argv);
TRACE("ServiceMain() called\n");
- ServiceStatusHandle = RegisterServiceCtrlHandlerExW(SERVICE_NAME,
+ ServiceStatusHandle = RegisterServiceCtrlHandlerExW(ServiceName,
ServiceControlHandler,
NULL);
@@ -123,12 +129,6 @@
int
wmain(int argc, WCHAR *argv[])
{
- SERVICE_TABLE_ENTRY ServiceTable[2] =
- {
- {SERVICE_NAME, ServiceMain},
- {NULL, NULL}
- };
-
UNREFERENCED_PARAMETER(argc);
UNREFERENCED_PARAMETER(argv);
@@ -138,8 +138,6 @@
TRACE("Spoolsv: main() done\n");
- ExitThread(0);
-
return 0;
}