services: Add a helper function to send a command to the service.
This commit is contained in:
parent
be57450fee
commit
0c1c1fc20d
|
@ -887,13 +887,38 @@ static BOOL service_accepts_control(const struct service_entry *service, DWORD d
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* service_send_command
|
||||
*/
|
||||
BOOL service_send_command( struct service_entry *service, HANDLE pipe,
|
||||
const void *data, DWORD size, DWORD *result )
|
||||
{
|
||||
DWORD count;
|
||||
BOOL r;
|
||||
|
||||
r = WriteFile(pipe, data, size, &count, NULL);
|
||||
if (!r || count != size)
|
||||
{
|
||||
WINE_ERR("service protocol error - failed to write pipe!\n");
|
||||
return FALSE;
|
||||
}
|
||||
r = ReadFile(pipe, result, sizeof *result, &count, NULL);
|
||||
if (!r || count != sizeof *result)
|
||||
{
|
||||
WINE_ERR("service protocol error - failed to read pipe "
|
||||
"r = %d count = %d!\n", r, count);
|
||||
return FALSE;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* service_send_control
|
||||
*/
|
||||
static BOOL service_send_control(struct service_entry *service, HANDLE pipe, DWORD dwControl, DWORD *result)
|
||||
{
|
||||
service_start_info *ssi;
|
||||
DWORD len, count = 0;
|
||||
DWORD len;
|
||||
BOOL r;
|
||||
|
||||
/* calculate how much space we need to send the startup info */
|
||||
|
@ -906,16 +931,8 @@ static BOOL service_send_control(struct service_entry *service, HANDLE pipe, DWO
|
|||
ssi->name_size = strlenW(service->name) + 1;
|
||||
strcpyW( ssi->data, service->name );
|
||||
|
||||
r = WriteFile(pipe, ssi, ssi->total_size, &count, NULL);
|
||||
if (!r || count != ssi->total_size)
|
||||
{
|
||||
WINE_ERR("service protocol error - failed to write pipe!\n");
|
||||
return r;
|
||||
}
|
||||
r = ReadFile(pipe, result, sizeof *result, &count, NULL);
|
||||
if (!r || count != sizeof *result)
|
||||
WINE_ERR("service protocol error - failed to read pipe "
|
||||
"r = %d count = %d!\n", r, count);
|
||||
r = service_send_command( service, pipe, ssi, ssi->total_size, result );
|
||||
HeapFree( GetProcessHeap(), 0, ssi );
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
@ -671,7 +671,7 @@ static DWORD service_wait_for_startup(struct service_entry *service_entry, HANDL
|
|||
*/
|
||||
static BOOL service_send_start_message(struct service_entry *service, LPCWSTR *argv, DWORD argc)
|
||||
{
|
||||
DWORD i, len, count, result;
|
||||
DWORD i, len, result;
|
||||
service_start_info *ssi;
|
||||
LPWSTR p;
|
||||
BOOL r;
|
||||
|
@ -708,15 +708,11 @@ static BOOL service_send_start_message(struct service_entry *service, LPCWSTR *a
|
|||
}
|
||||
*p=0;
|
||||
|
||||
r = WriteFile(service->control_pipe, ssi, ssi->total_size, &count, NULL);
|
||||
if (r)
|
||||
r = service_send_command( service, service->control_pipe, ssi, ssi->total_size, &result );
|
||||
if (r && result)
|
||||
{
|
||||
r = ReadFile(service->control_pipe, &result, sizeof result, &count, NULL);
|
||||
if (r && result)
|
||||
{
|
||||
SetLastError(result);
|
||||
r = FALSE;
|
||||
}
|
||||
SetLastError(result);
|
||||
r = FALSE;
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(),0,ssi);
|
||||
|
|
|
@ -75,6 +75,8 @@ void service_lock_shared(struct service_entry *service);
|
|||
void service_lock_exclusive(struct service_entry *service);
|
||||
void service_unlock(struct service_entry *service);
|
||||
DWORD service_start(struct service_entry *service, DWORD service_argc, LPCWSTR *service_argv);
|
||||
BOOL service_send_command( struct service_entry *service, HANDLE pipe,
|
||||
const void *data, DWORD size, DWORD *result );
|
||||
|
||||
extern HANDLE g_hStartedEvent;
|
||||
|
||||
|
|
Loading…
Reference in New Issue