Author: gbrunmar
Date: Mon Dec 3 21:24:05 2007
New Revision: 30985
URL:
http://svn.reactos.org/svn/reactos?rev=30985&view=rev
Log:
Fixed some minor things with (yet unused) svchost
Modified:
trunk/reactos/base/services/svchost/svchost.c
Modified: trunk/reactos/base/services/svchost/svchost.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/svchost/svch…
==============================================================================
--- trunk/reactos/base/services/svchost/svchost.c (original)
+++ trunk/reactos/base/services/svchost/svchost.c Mon Dec 3 21:24:05 2007
@@ -102,11 +102,12 @@
HeapFree(GetProcessHeap(), 0, Buffer);
/* Load the service dll */
+ DPRINT1("Trying to load dll\n");
hServiceDll = LoadLibrary(DllPath);
if (NULL == hServiceDll)
{
- DPRINT1("Unable to load ServiceDll: %s\n", DllPath);
+ DPRINT1("Unable to load ServiceDll: %s, ErrorCode: %u\n", DllPath,
GetLastError());
return FALSE;
}
@@ -208,39 +209,47 @@
{
DWORD NrOfServices;
LPSERVICE_TABLE_ENTRY ServiceTable;
- DWORD i;
if (argc < 3)
{
/* MS svchost.exe doesn't seem to print help, should we? */
- return 1;
+ return 0;
}
if (_tcscmp(argv[1], _T("-k")) != 0)
{
/* For now, we only handle "-k" */
- return 1;
+ return 0;
}
NrOfServices = LoadServiceCategory(argv[2]);
+ DPRINT1("NrOfServices: %lu\n", NrOfServices);
if (0 == NrOfServices)
- return 1;
+ return 0;
ServiceTable = HeapAlloc(GetProcessHeap(), 0, sizeof(SERVICE_TABLE_ENTRY) *
(NrOfServices + 1));
if (NULL != ServiceTable)
{
+ DWORD i;
PSERVICE Service = FirstService;
+ /* Fill the service table */
for (i = 0; i < NrOfServices; ++i)
{
+ DPRINT1("Loading service: %s\n", Service->Name);
ServiceTable[i].lpServiceName = Service->Name;
ServiceTable[i].lpServiceProc = Service->ServiceMainFunc;
Service = Service->Next;
}
- StartServiceCtrlDispatcher(ServiceTable);
+ /* Set a NULL entry to end the service table */
+ ServiceTable[i].lpServiceName = NULL;
+ ServiceTable[i].lpServiceProc = NULL;
+
+ if (FALSE == StartServiceCtrlDispatcher(ServiceTable))
+ printf("Failed to start service control dispatcher, ErrorCode: %lu\n",
GetLastError());
HeapFree(GetProcessHeap(), 0, ServiceTable);
}
@@ -249,6 +258,7 @@
DPRINT1("Not enough memory for the service table, trying to allocate %u
bytes\n", sizeof(SERVICE_TABLE_ENTRY) * (NrOfServices + 1));
}
+ DPRINT1("Freeing services...\n");
FreeServices();
return 0;