mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 23:22:57 +00:00
Merge ScmControlService() and ScmSendStartCommand() into ScmSendServiceCommand().
svn path=/trunk/; revision=49366
This commit is contained in:
parent
d4bd38df22
commit
1917d1c595
3 changed files with 31 additions and 75 deletions
|
@ -678,66 +678,10 @@ ScmGetBootAndSystemDriverState(VOID)
|
||||||
|
|
||||||
|
|
||||||
DWORD
|
DWORD
|
||||||
ScmControlService(PSERVICE Service,
|
ScmSendServiceCommand(PSERVICE Service,
|
||||||
DWORD dwControl)
|
DWORD dwControl,
|
||||||
{
|
DWORD argc,
|
||||||
PSCM_CONTROL_PACKET ControlPacket;
|
LPWSTR *argv)
|
||||||
SCM_REPLY_PACKET ReplyPacket;
|
|
||||||
|
|
||||||
DWORD dwWriteCount = 0;
|
|
||||||
DWORD dwReadCount = 0;
|
|
||||||
DWORD TotalLength;
|
|
||||||
DWORD dwError = ERROR_SUCCESS;
|
|
||||||
|
|
||||||
DPRINT("ScmControlService() called\n");
|
|
||||||
|
|
||||||
TotalLength = wcslen(Service->lpServiceName) + 1;
|
|
||||||
|
|
||||||
ControlPacket = (SCM_CONTROL_PACKET*)HeapAlloc(GetProcessHeap(),
|
|
||||||
HEAP_ZERO_MEMORY,
|
|
||||||
sizeof(SCM_CONTROL_PACKET) + (TotalLength * sizeof(WCHAR)));
|
|
||||||
if (ControlPacket == NULL)
|
|
||||||
return ERROR_NOT_ENOUGH_MEMORY;
|
|
||||||
|
|
||||||
ControlPacket->dwControl = dwControl;
|
|
||||||
ControlPacket->dwSize = TotalLength;
|
|
||||||
ControlPacket->hServiceStatus = (SERVICE_STATUS_HANDLE)Service;
|
|
||||||
wcscpy(&ControlPacket->szArguments[0], Service->lpServiceName);
|
|
||||||
|
|
||||||
/* Send the control packet */
|
|
||||||
WriteFile(Service->ControlPipeHandle,
|
|
||||||
ControlPacket,
|
|
||||||
sizeof(SCM_CONTROL_PACKET) + (TotalLength * sizeof(WCHAR)),
|
|
||||||
&dwWriteCount,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
/* Read the reply */
|
|
||||||
ReadFile(Service->ControlPipeHandle,
|
|
||||||
&ReplyPacket,
|
|
||||||
sizeof(SCM_REPLY_PACKET),
|
|
||||||
&dwReadCount,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
/* Release the contol packet */
|
|
||||||
HeapFree(GetProcessHeap(),
|
|
||||||
0,
|
|
||||||
ControlPacket);
|
|
||||||
|
|
||||||
if (dwReadCount == sizeof(SCM_REPLY_PACKET))
|
|
||||||
{
|
|
||||||
dwError = ReplyPacket.dwError;
|
|
||||||
}
|
|
||||||
|
|
||||||
DPRINT("ScmControlService() done\n");
|
|
||||||
|
|
||||||
return dwError;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static DWORD
|
|
||||||
ScmSendStartCommand(PSERVICE Service,
|
|
||||||
DWORD argc,
|
|
||||||
LPWSTR *argv)
|
|
||||||
{
|
{
|
||||||
PSCM_CONTROL_PACKET ControlPacket;
|
PSCM_CONTROL_PACKET ControlPacket;
|
||||||
SCM_REPLY_PACKET ReplyPacket;
|
SCM_REPLY_PACKET ReplyPacket;
|
||||||
|
@ -750,7 +694,7 @@ ScmSendStartCommand(PSERVICE Service,
|
||||||
DWORD dwError = ERROR_SUCCESS;
|
DWORD dwError = ERROR_SUCCESS;
|
||||||
DWORD i;
|
DWORD i;
|
||||||
|
|
||||||
DPRINT("ScmSendStartCommand() called\n");
|
DPRINT("ScmSendServiceCommand() called\n");
|
||||||
|
|
||||||
/* Calculate the total length of the start command line */
|
/* Calculate the total length of the start command line */
|
||||||
TotalLength = wcslen(Service->lpServiceName) + 1;
|
TotalLength = wcslen(Service->lpServiceName) + 1;
|
||||||
|
@ -774,7 +718,7 @@ ScmSendStartCommand(PSERVICE Service,
|
||||||
if (ControlPacket == NULL)
|
if (ControlPacket == NULL)
|
||||||
return ERROR_NOT_ENOUGH_MEMORY;
|
return ERROR_NOT_ENOUGH_MEMORY;
|
||||||
|
|
||||||
ControlPacket->dwControl = SERVICE_CONTROL_START;
|
ControlPacket->dwControl = dwControl;
|
||||||
ControlPacket->hServiceStatus = (SERVICE_STATUS_HANDLE)Service;
|
ControlPacket->hServiceStatus = (SERVICE_STATUS_HANDLE)Service;
|
||||||
ControlPacket->dwSize = TotalLength;
|
ControlPacket->dwSize = TotalLength;
|
||||||
Ptr = &ControlPacket->szArguments[0];
|
Ptr = &ControlPacket->szArguments[0];
|
||||||
|
@ -819,7 +763,7 @@ ScmSendStartCommand(PSERVICE Service,
|
||||||
dwError = ReplyPacket.dwError;
|
dwError = ReplyPacket.dwError;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("ScmSendStartCommand() done\n");
|
DPRINT("ScmSendServiceCommand() done\n");
|
||||||
|
|
||||||
return dwError;
|
return dwError;
|
||||||
}
|
}
|
||||||
|
@ -998,7 +942,10 @@ ScmStartUserModeService(PSERVICE Service,
|
||||||
DPRINT("Received service process ID %lu\n", dwProcessId);
|
DPRINT("Received service process ID %lu\n", dwProcessId);
|
||||||
|
|
||||||
/* Send start command */
|
/* Send start command */
|
||||||
dwError = ScmSendStartCommand(Service, argc, argv);
|
dwError = ScmSendServiceCommand(Service,
|
||||||
|
SERVICE_CONTROL_START,
|
||||||
|
argc,
|
||||||
|
argv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1227,7 +1174,10 @@ ScmAutoShutdownServices(VOID)
|
||||||
CurrentService->Status.dwCurrentState == SERVICE_START_PENDING)
|
CurrentService->Status.dwCurrentState == SERVICE_START_PENDING)
|
||||||
{
|
{
|
||||||
/* shutdown service */
|
/* shutdown service */
|
||||||
ScmControlService(CurrentService, SERVICE_CONTROL_STOP);
|
ScmSendServiceCommand(CurrentService,
|
||||||
|
SERVICE_CONTROL_STOP,
|
||||||
|
0,
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceEntry = ServiceEntry->Flink;
|
ServiceEntry = ServiceEntry->Flink;
|
||||||
|
|
|
@ -699,8 +699,10 @@ DWORD RControlService(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send control code to the service */
|
/* Send control code to the service */
|
||||||
dwError = ScmControlService(lpService,
|
dwError = ScmSendServiceCommand(lpService,
|
||||||
dwControl);
|
dwControl,
|
||||||
|
0,
|
||||||
|
NULL);
|
||||||
|
|
||||||
/* Return service status information */
|
/* Return service status information */
|
||||||
RtlCopyMemory(lpServiceStatus,
|
RtlCopyMemory(lpServiceStatus,
|
||||||
|
@ -2864,7 +2866,10 @@ DWORD RStartServiceW(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Start the service */
|
/* Start the service */
|
||||||
dwError = ScmStartService(lpService, argc, (LPWSTR *)argv);
|
dwError = ScmSendServiceCommand(lpService,
|
||||||
|
SERVICE_CONTROL_START,
|
||||||
|
argc,
|
||||||
|
(LPWSTR *)argv);
|
||||||
|
|
||||||
return dwError;
|
return dwError;
|
||||||
}
|
}
|
||||||
|
@ -4072,7 +4077,10 @@ DWORD RStartServiceA(
|
||||||
/* FIXME: Convert argument vector to Unicode */
|
/* FIXME: Convert argument vector to Unicode */
|
||||||
|
|
||||||
/* Start the service */
|
/* Start the service */
|
||||||
dwError = ScmStartService(lpService, 0, NULL);
|
dwError = ScmSendServiceCommand(lpService,
|
||||||
|
SERVICE_CONTROL_START,
|
||||||
|
0,
|
||||||
|
NULL);
|
||||||
|
|
||||||
/* FIXME: Free argument vector */
|
/* FIXME: Free argument vector */
|
||||||
|
|
||||||
|
|
|
@ -104,9 +104,10 @@ VOID ScmShutdownServiceDatabase(VOID);
|
||||||
VOID ScmGetBootAndSystemDriverState(VOID);
|
VOID ScmGetBootAndSystemDriverState(VOID);
|
||||||
VOID ScmAutoStartServices(VOID);
|
VOID ScmAutoStartServices(VOID);
|
||||||
VOID ScmAutoShutdownServices(VOID);
|
VOID ScmAutoShutdownServices(VOID);
|
||||||
DWORD ScmStartService(PSERVICE Service,
|
DWORD ScmSendServiceCommand(PSERVICE Service,
|
||||||
DWORD argc,
|
DWORD dwControl,
|
||||||
LPWSTR *argv);
|
DWORD argc,
|
||||||
|
LPWSTR *argv);
|
||||||
|
|
||||||
PSERVICE ScmGetServiceEntryByName(LPCWSTR lpServiceName);
|
PSERVICE ScmGetServiceEntryByName(LPCWSTR lpServiceName);
|
||||||
PSERVICE ScmGetServiceEntryByDisplayName(LPCWSTR lpDisplayName);
|
PSERVICE ScmGetServiceEntryByDisplayName(LPCWSTR lpDisplayName);
|
||||||
|
@ -116,9 +117,6 @@ DWORD ScmCreateNewServiceRecord(LPCWSTR lpServiceName,
|
||||||
VOID ScmDeleteServiceRecord(PSERVICE lpService);
|
VOID ScmDeleteServiceRecord(PSERVICE lpService);
|
||||||
DWORD ScmMarkServiceForDelete(PSERVICE pService);
|
DWORD ScmMarkServiceForDelete(PSERVICE pService);
|
||||||
|
|
||||||
DWORD ScmControlService(PSERVICE Service,
|
|
||||||
DWORD dwControl);
|
|
||||||
|
|
||||||
BOOL ScmLockDatabaseExclusive(VOID);
|
BOOL ScmLockDatabaseExclusive(VOID);
|
||||||
BOOL ScmLockDatabaseShared(VOID);
|
BOOL ScmLockDatabaseShared(VOID);
|
||||||
VOID ScmUnlockDatabase(VOID);
|
VOID ScmUnlockDatabase(VOID);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue