mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 13:56:56 +00:00
[SERVICES]
- 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
This commit is contained in:
parent
420940d94d
commit
38e5930305
3 changed files with 48 additions and 27 deletions
|
@ -679,12 +679,15 @@ ScmGetBootAndSystemDriverState(VOID)
|
||||||
|
|
||||||
DWORD
|
DWORD
|
||||||
ScmControlService(PSERVICE Service,
|
ScmControlService(PSERVICE Service,
|
||||||
DWORD dwControl,
|
DWORD dwControl)
|
||||||
LPSERVICE_STATUS lpServiceStatus)
|
|
||||||
{
|
{
|
||||||
PSCM_CONTROL_PACKET ControlPacket;
|
PSCM_CONTROL_PACKET ControlPacket;
|
||||||
DWORD Count;
|
SCM_REPLY_PACKET ReplyPacket;
|
||||||
|
|
||||||
|
DWORD dwWriteCount = 0;
|
||||||
|
DWORD dwReadCount = 0;
|
||||||
DWORD TotalLength;
|
DWORD TotalLength;
|
||||||
|
DWORD dwError = ERROR_SUCCESS;
|
||||||
|
|
||||||
DPRINT("ScmControlService() called\n");
|
DPRINT("ScmControlService() called\n");
|
||||||
|
|
||||||
|
@ -705,23 +708,29 @@ ScmControlService(PSERVICE Service,
|
||||||
WriteFile(Service->ControlPipeHandle,
|
WriteFile(Service->ControlPipeHandle,
|
||||||
ControlPacket,
|
ControlPacket,
|
||||||
sizeof(SCM_CONTROL_PACKET) + (TotalLength * sizeof(WCHAR)),
|
sizeof(SCM_CONTROL_PACKET) + (TotalLength * sizeof(WCHAR)),
|
||||||
&Count,
|
&dwWriteCount,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
/* FIXME: Read the reply */
|
/* Read the reply */
|
||||||
|
ReadFile(Service->ControlPipeHandle,
|
||||||
|
&ReplyPacket,
|
||||||
|
sizeof(SCM_REPLY_PACKET),
|
||||||
|
&dwReadCount,
|
||||||
|
NULL);
|
||||||
|
|
||||||
/* Release the contol packet */
|
/* Release the contol packet */
|
||||||
HeapFree(GetProcessHeap(),
|
HeapFree(GetProcessHeap(),
|
||||||
0,
|
0,
|
||||||
ControlPacket);
|
ControlPacket);
|
||||||
|
|
||||||
RtlCopyMemory(lpServiceStatus,
|
if (dwReadCount == sizeof(SCM_REPLY_PACKET))
|
||||||
&Service->Status,
|
{
|
||||||
sizeof(SERVICE_STATUS));
|
dwError = ReplyPacket.dwError;
|
||||||
|
}
|
||||||
|
|
||||||
DPRINT("ScmControlService) done\n");
|
DPRINT("ScmControlService() done\n");
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return dwError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -731,11 +740,15 @@ ScmSendStartCommand(PSERVICE Service,
|
||||||
LPWSTR *argv)
|
LPWSTR *argv)
|
||||||
{
|
{
|
||||||
PSCM_CONTROL_PACKET ControlPacket;
|
PSCM_CONTROL_PACKET ControlPacket;
|
||||||
|
SCM_REPLY_PACKET ReplyPacket;
|
||||||
DWORD TotalLength;
|
DWORD TotalLength;
|
||||||
DWORD ArgsLength = 0;
|
DWORD ArgsLength = 0;
|
||||||
DWORD Length;
|
DWORD Length;
|
||||||
PWSTR Ptr;
|
PWSTR Ptr;
|
||||||
DWORD Count;
|
DWORD dwWriteCount = 0;
|
||||||
|
DWORD dwReadCount = 0;
|
||||||
|
DWORD dwError = ERROR_SUCCESS;
|
||||||
|
DWORD i;
|
||||||
|
|
||||||
DPRINT("ScmSendStartCommand() called\n");
|
DPRINT("ScmSendStartCommand() called\n");
|
||||||
|
|
||||||
|
@ -743,10 +756,10 @@ ScmSendStartCommand(PSERVICE Service,
|
||||||
TotalLength = wcslen(Service->lpServiceName) + 1;
|
TotalLength = wcslen(Service->lpServiceName) + 1;
|
||||||
if (argc > 0)
|
if (argc > 0)
|
||||||
{
|
{
|
||||||
for (Count = 0; Count < argc; Count++)
|
for (i = 0; i < argc; i++)
|
||||||
{
|
{
|
||||||
DPRINT("Arg: %S\n", argv[Count]);
|
DPRINT("Arg: %S\n", argv[i]);
|
||||||
Length = wcslen(argv[Count]) + 1;
|
Length = wcslen(argv[i]) + 1;
|
||||||
TotalLength += Length;
|
TotalLength += Length;
|
||||||
ArgsLength += Length;
|
ArgsLength += Length;
|
||||||
}
|
}
|
||||||
|
@ -786,19 +799,29 @@ ScmSendStartCommand(PSERVICE Service,
|
||||||
WriteFile(Service->ControlPipeHandle,
|
WriteFile(Service->ControlPipeHandle,
|
||||||
ControlPacket,
|
ControlPacket,
|
||||||
sizeof(SCM_CONTROL_PACKET) + (TotalLength - 1) * sizeof(WCHAR),
|
sizeof(SCM_CONTROL_PACKET) + (TotalLength - 1) * sizeof(WCHAR),
|
||||||
&Count,
|
&dwWriteCount,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
/* FIXME: Read the reply */
|
/* Read the reply */
|
||||||
|
ReadFile(Service->ControlPipeHandle,
|
||||||
|
&ReplyPacket,
|
||||||
|
sizeof(SCM_REPLY_PACKET),
|
||||||
|
&dwReadCount,
|
||||||
|
NULL);
|
||||||
|
|
||||||
/* Release the contol packet */
|
/* Release the contol packet */
|
||||||
HeapFree(GetProcessHeap(),
|
HeapFree(GetProcessHeap(),
|
||||||
0,
|
0,
|
||||||
ControlPacket);
|
ControlPacket);
|
||||||
|
|
||||||
|
if (dwReadCount == sizeof(SCM_REPLY_PACKET))
|
||||||
|
{
|
||||||
|
dwError = ReplyPacket.dwError;
|
||||||
|
}
|
||||||
|
|
||||||
DPRINT("ScmSendStartCommand() done\n");
|
DPRINT("ScmSendStartCommand() done\n");
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return dwError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1192,7 +1215,6 @@ ScmAutoShutdownServices(VOID)
|
||||||
{
|
{
|
||||||
PLIST_ENTRY ServiceEntry;
|
PLIST_ENTRY ServiceEntry;
|
||||||
PSERVICE CurrentService;
|
PSERVICE CurrentService;
|
||||||
SERVICE_STATUS ServiceStatus;
|
|
||||||
|
|
||||||
DPRINT("ScmAutoShutdownServices() called\n");
|
DPRINT("ScmAutoShutdownServices() called\n");
|
||||||
|
|
||||||
|
@ -1205,7 +1227,7 @@ ScmAutoShutdownServices(VOID)
|
||||||
CurrentService->Status.dwCurrentState == SERVICE_START_PENDING)
|
CurrentService->Status.dwCurrentState == SERVICE_START_PENDING)
|
||||||
{
|
{
|
||||||
/* shutdown service */
|
/* shutdown service */
|
||||||
ScmControlService(CurrentService, SERVICE_CONTROL_STOP, &ServiceStatus);
|
ScmControlService(CurrentService, SERVICE_CONTROL_STOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceEntry = ServiceEntry->Flink;
|
ServiceEntry = ServiceEntry->Flink;
|
||||||
|
|
|
@ -637,8 +637,12 @@ DWORD RControlService(
|
||||||
{
|
{
|
||||||
/* Send control code to the service */
|
/* Send control code to the service */
|
||||||
dwError = ScmControlService(lpService,
|
dwError = ScmControlService(lpService,
|
||||||
dwControl,
|
dwControl);
|
||||||
lpServiceStatus);
|
|
||||||
|
/* Return service status information */
|
||||||
|
RtlCopyMemory(lpServiceStatus,
|
||||||
|
&lpService->Status,
|
||||||
|
sizeof(SERVICE_STATUS));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((dwError == ERROR_SUCCESS) && (pcbBytesNeeded))
|
if ((dwError == ERROR_SUCCESS) && (pcbBytesNeeded))
|
||||||
|
@ -652,10 +656,6 @@ DWORD RControlService(
|
||||||
lpService->ThreadId = 0;
|
lpService->ThreadId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return service status information */
|
|
||||||
RtlCopyMemory(lpServiceStatus,
|
|
||||||
&lpService->Status,
|
|
||||||
sizeof(SERVICE_STATUS));
|
|
||||||
|
|
||||||
return dwError;
|
return dwError;
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,8 +117,7 @@ VOID ScmDeleteServiceRecord(PSERVICE lpService);
|
||||||
DWORD ScmMarkServiceForDelete(PSERVICE pService);
|
DWORD ScmMarkServiceForDelete(PSERVICE pService);
|
||||||
|
|
||||||
DWORD ScmControlService(PSERVICE Service,
|
DWORD ScmControlService(PSERVICE Service,
|
||||||
DWORD dwControl,
|
DWORD dwControl);
|
||||||
LPSERVICE_STATUS lpServiceStatus);
|
|
||||||
|
|
||||||
BOOL ScmLockDatabaseExclusive(VOID);
|
BOOL ScmLockDatabaseExclusive(VOID);
|
||||||
BOOL ScmLockDatabaseShared(VOID);
|
BOOL ScmLockDatabaseShared(VOID);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue