- Copy service status only once after a control packet has been sent to a service.
- Send a reply packet to the service manager after a control packet has been sent to a service.
svn path=/trunk/; revision=45715
DWORD
ScmControlService(PSERVICE Service,
DWORD
ScmControlService(PSERVICE Service,
- DWORD dwControl,
- LPSERVICE_STATUS lpServiceStatus)
{
PSCM_CONTROL_PACKET ControlPacket;
{
PSCM_CONTROL_PACKET ControlPacket;
+ SCM_REPLY_PACKET ReplyPacket;
+
+ DWORD dwWriteCount = 0;
+ DWORD dwReadCount = 0;
+ DWORD dwError = ERROR_SUCCESS;
DPRINT("ScmControlService() called\n");
DPRINT("ScmControlService() called\n");
WriteFile(Service->ControlPipeHandle,
ControlPacket,
sizeof(SCM_CONTROL_PACKET) + (TotalLength * sizeof(WCHAR)),
WriteFile(Service->ControlPipeHandle,
ControlPacket,
sizeof(SCM_CONTROL_PACKET) + (TotalLength * sizeof(WCHAR)),
- /* FIXME: Read the reply */
+ /* Read the reply */
+ ReadFile(Service->ControlPipeHandle,
+ &ReplyPacket,
+ sizeof(SCM_REPLY_PACKET),
+ &dwReadCount,
+ NULL);
/* Release the contol packet */
HeapFree(GetProcessHeap(),
0,
ControlPacket);
/* Release the contol packet */
HeapFree(GetProcessHeap(),
0,
ControlPacket);
- RtlCopyMemory(lpServiceStatus,
- &Service->Status,
- sizeof(SERVICE_STATUS));
+ if (dwReadCount == sizeof(SCM_REPLY_PACKET))
+ {
+ dwError = ReplyPacket.dwError;
+ }
- DPRINT("ScmControlService) done\n");
+ DPRINT("ScmControlService() done\n");
LPWSTR *argv)
{
PSCM_CONTROL_PACKET ControlPacket;
LPWSTR *argv)
{
PSCM_CONTROL_PACKET ControlPacket;
+ SCM_REPLY_PACKET ReplyPacket;
DWORD TotalLength;
DWORD ArgsLength = 0;
DWORD Length;
PWSTR Ptr;
DWORD TotalLength;
DWORD ArgsLength = 0;
DWORD Length;
PWSTR Ptr;
+ DWORD dwWriteCount = 0;
+ DWORD dwReadCount = 0;
+ DWORD dwError = ERROR_SUCCESS;
+ DWORD i;
DPRINT("ScmSendStartCommand() called\n");
DPRINT("ScmSendStartCommand() called\n");
TotalLength = wcslen(Service->lpServiceName) + 1;
if (argc > 0)
{
TotalLength = wcslen(Service->lpServiceName) + 1;
if (argc > 0)
{
- for (Count = 0; Count < argc; Count++)
+ for (i = 0; i < argc; i++)
- DPRINT("Arg: %S\n", argv[Count]);
- Length = wcslen(argv[Count]) + 1;
+ DPRINT("Arg: %S\n", argv[i]);
+ Length = wcslen(argv[i]) + 1;
TotalLength += Length;
ArgsLength += Length;
}
TotalLength += Length;
ArgsLength += Length;
}
WriteFile(Service->ControlPipeHandle,
ControlPacket,
sizeof(SCM_CONTROL_PACKET) + (TotalLength - 1) * sizeof(WCHAR),
WriteFile(Service->ControlPipeHandle,
ControlPacket,
sizeof(SCM_CONTROL_PACKET) + (TotalLength - 1) * sizeof(WCHAR),
- /* FIXME: Read the reply */
+ /* Read the reply */
+ ReadFile(Service->ControlPipeHandle,
+ &ReplyPacket,
+ sizeof(SCM_REPLY_PACKET),
+ &dwReadCount,
+ NULL);
/* Release the contol packet */
HeapFree(GetProcessHeap(),
0,
ControlPacket);
/* Release the contol packet */
HeapFree(GetProcessHeap(),
0,
ControlPacket);
+ if (dwReadCount == sizeof(SCM_REPLY_PACKET))
+ {
+ dwError = ReplyPacket.dwError;
+ }
+
DPRINT("ScmSendStartCommand() done\n");
DPRINT("ScmSendStartCommand() done\n");
{
PLIST_ENTRY ServiceEntry;
PSERVICE CurrentService;
{
PLIST_ENTRY ServiceEntry;
PSERVICE CurrentService;
- SERVICE_STATUS ServiceStatus;
DPRINT("ScmAutoShutdownServices() called\n");
DPRINT("ScmAutoShutdownServices() called\n");
CurrentService->Status.dwCurrentState == SERVICE_START_PENDING)
{
/* shutdown service */
CurrentService->Status.dwCurrentState == SERVICE_START_PENDING)
{
/* shutdown service */
- ScmControlService(CurrentService, SERVICE_CONTROL_STOP, &ServiceStatus);
+ ScmControlService(CurrentService, SERVICE_CONTROL_STOP);
}
ServiceEntry = ServiceEntry->Flink;
}
ServiceEntry = ServiceEntry->Flink;
{
/* Send control code to the service */
dwError = ScmControlService(lpService,
{
/* Send control code to the service */
dwError = ScmControlService(lpService,
- dwControl,
- lpServiceStatus);
+ dwControl);
+
+ /* Return service status information */
+ RtlCopyMemory(lpServiceStatus,
+ &lpService->Status,
+ sizeof(SERVICE_STATUS));
}
if ((dwError == ERROR_SUCCESS) && (pcbBytesNeeded))
}
if ((dwError == ERROR_SUCCESS) && (pcbBytesNeeded))
lpService->ThreadId = 0;
}
lpService->ThreadId = 0;
}
- /* Return service status information */
- RtlCopyMemory(lpServiceStatus,
- &lpService->Status,
- sizeof(SERVICE_STATUS));
DWORD ScmMarkServiceForDelete(PSERVICE pService);
DWORD ScmControlService(PSERVICE Service,
DWORD ScmMarkServiceForDelete(PSERVICE pService);
DWORD ScmControlService(PSERVICE Service,
- DWORD dwControl,
- LPSERVICE_STATUS lpServiceStatus);
BOOL ScmLockDatabaseExclusive(VOID);
BOOL ScmLockDatabaseShared(VOID);
BOOL ScmLockDatabaseExclusive(VOID);
BOOL ScmLockDatabaseShared(VOID);