Author: gedmurphy
Date: Tue Jul 10 18:49:51 2007
New Revision: 27565
URL:
http://svn.reactos.org/svn/reactos?rev=27565&view=rev
Log:
implement ScmrSetServiceStatus, this goes some way to being able to manually control
services
Modified:
trunk/reactos/base/system/services/database.c
trunk/reactos/base/system/services/rpcserver.c
trunk/reactos/base/system/services/services.h
Modified: trunk/reactos/base/system/services/database.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/datab…
==============================================================================
--- trunk/reactos/base/system/services/database.c (original)
+++ trunk/reactos/base/system/services/database.c Tue Jul 10 18:49:51 2007
@@ -128,6 +128,37 @@
}
+PSERVICE
+ScmGetServiceEntryByThreadId(ULONG ThreadId)
+{
+ PLIST_ENTRY ServiceEntry;
+ PSERVICE CurrentService;
+
+ DPRINT("ScmGetServiceEntryByThreadId() called\n");
+ DPRINT("Finding ThreadId %lu\n", ThreadId);
+
+ ServiceEntry = ServiceListHead.Flink;
+ while (ServiceEntry != &ServiceListHead)
+ {
+ CurrentService = CONTAINING_RECORD(ServiceEntry,
+ SERVICE,
+ ServiceListEntry);
+ DPRINT("Found threadId %lu\n", CurrentService->ThreadId);
+ if (CurrentService->ThreadId == ThreadId)
+ {
+ DPRINT("Found service: '%S'\n",
CurrentService->lpDisplayName);
+ return CurrentService;
+ }
+
+ ServiceEntry = ServiceEntry->Flink;
+ }
+
+ DPRINT("Couldn't find a matching service\n");
+
+ return NULL;
+}
+
+
DWORD
ScmCreateNewServiceRecord(LPWSTR lpServiceName,
PSERVICE *lpServiceRecord)
@@ -542,8 +573,8 @@
DPRINT("ScmControlService() called\n");
ControlPacket = (SCM_CONTROL_PACKET*) HeapAlloc(GetProcessHeap(),
- HEAP_ZERO_MEMORY,
- sizeof(SCM_CONTROL_PACKET));
+ HEAP_ZERO_MEMORY,
+ sizeof(SCM_CONTROL_PACKET));
if (ControlPacket == NULL)
return ERROR_NOT_ENOUGH_MEMORY;
@@ -597,7 +628,7 @@
}
}
TotalLength++;
- DPRINT("ArgsLength: %ld\nTotalLength: %ld\n\n", ArgsLength, TotalLength);
+ DPRINT("ArgsLength: %ld TotalLength: %ld\n", ArgsLength, TotalLength);
/* Allocate a control packet */
ControlPacket = (SCM_CONTROL_PACKET*) HeapAlloc(GetProcessHeap(),
Modified: trunk/reactos/base/system/services/rpcserver.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/rpcse…
==============================================================================
--- trunk/reactos/base/system/services/rpcserver.c (original)
+++ trunk/reactos/base/system/services/rpcserver.c Tue Jul 10 18:49:51 2007
@@ -700,11 +700,31 @@
/* Function 7 */
unsigned long
ScmrSetServiceStatus(handle_t BindingHandle,
- unsigned long hServiceStatus) /* FIXME */
-{
- DPRINT1("ScmrSetServiceStatus() is unimplemented\n");
- /* FIXME */
- return ERROR_CALL_NOT_IMPLEMENTED;
+ unsigned long hServiceStatus,
+ LPSERVICE_STATUS lpServiceStatus)
+{
+ PSERVICE lpService;
+
+ DPRINT("ScmrSetServiceStatus() called\n");
+
+ if (ScmShutdown)
+ return ERROR_SHUTDOWN_IN_PROGRESS;
+
+ lpService = ScmGetServiceEntryByThreadId((ULONG)hServiceStatus);
+ if (lpService == NULL)
+ {
+ DPRINT1("lpService == NULL!\n");
+ return ERROR_INVALID_HANDLE;
+ }
+
+ RtlCopyMemory(&lpService->Status,
+ lpServiceStatus,
+ sizeof(SERVICE_STATUS));
+
+ DPRINT("Set %S to %lu\n", lpService->lpDisplayName,
lpService->Status.dwCurrentState);
+ DPRINT("ScmrSetServiceStatus() done\n");
+
+ return ERROR_SUCCESS;
}
Modified: trunk/reactos/base/system/services/services.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/servi…
==============================================================================
--- trunk/reactos/base/system/services/services.h (original)
+++ trunk/reactos/base/system/services/services.h Tue Jul 10 18:49:51 2007
@@ -102,6 +102,7 @@
PSERVICE ScmGetServiceEntryByName(LPWSTR lpServiceName);
PSERVICE ScmGetServiceEntryByDisplayName(LPWSTR lpDisplayName);
PSERVICE ScmGetServiceEntryByResumeCount(DWORD dwResumeCount);
+PSERVICE ScmGetServiceEntryByThreadId(ULONG ThreadId);
DWORD ScmCreateNewServiceRecord(LPWSTR lpServiceName,
PSERVICE *lpServiceRecord);
DWORD ScmMarkServiceForDelete(PSERVICE pService);