forked from Mirrors/wine-wine
advapi32: Store process ID into status structure on startup.
parent
1eea906dad
commit
4b7c5097c3
|
@ -3,6 +3,7 @@
|
||||||
*
|
*
|
||||||
* Copyright 1995 Sven Verdoolaege
|
* Copyright 1995 Sven Verdoolaege
|
||||||
* Copyright 2005 Mike McCormack
|
* Copyright 2005 Mike McCormack
|
||||||
|
* Copyright 2007 Rolf Kalbermatter
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -53,6 +54,7 @@ typedef struct service_start_info_t
|
||||||
#define WINESERV_STARTINFO 1
|
#define WINESERV_STARTINFO 1
|
||||||
#define WINESERV_GETSTATUS 2
|
#define WINESERV_GETSTATUS 2
|
||||||
#define WINESERV_SENDCONTROL 3
|
#define WINESERV_SENDCONTROL 3
|
||||||
|
#define WINESERV_SETPID 4
|
||||||
|
|
||||||
typedef struct service_data_t
|
typedef struct service_data_t
|
||||||
{
|
{
|
||||||
|
@ -519,6 +521,41 @@ static BOOL service_get_status(HANDLE pipe, LPSERVICE_STATUS_PROCESS status)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* service_handle_set_processID
|
||||||
|
*/
|
||||||
|
static BOOL service_handle_set_processID(HANDLE pipe, service_data *service, DWORD dwProcessId)
|
||||||
|
{
|
||||||
|
DWORD count, ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
TRACE("received control %d\n", dwProcessId);
|
||||||
|
service->status.dwProcessId = dwProcessId;
|
||||||
|
return WriteFile(pipe, &ret, sizeof ret , &count, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* service_set_processID
|
||||||
|
*/
|
||||||
|
static BOOL service_set_processID(HANDLE pipe, DWORD dwprocessId, LPDWORD dwResult)
|
||||||
|
{
|
||||||
|
DWORD cmd[2], count = 0;
|
||||||
|
BOOL r;
|
||||||
|
|
||||||
|
cmd[0] = WINESERV_SETPID;
|
||||||
|
cmd[1] = dwprocessId;
|
||||||
|
r = WriteFile( pipe, cmd, sizeof cmd, &count, NULL );
|
||||||
|
if (!r || count != sizeof cmd)
|
||||||
|
{
|
||||||
|
ERR("service protocol error - failed to write pipe!\n");
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
r = ReadFile( pipe, dwResult, sizeof *dwResult, &count, NULL );
|
||||||
|
if (!r || count != sizeof *dwResult)
|
||||||
|
ERR("service protocol error - failed to read pipe "
|
||||||
|
"r = %d count = %d!\n", r, count);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* service_send_control
|
* service_send_control
|
||||||
*/
|
*/
|
||||||
|
@ -704,6 +741,9 @@ static DWORD WINAPI service_control_dispatcher(LPVOID arg)
|
||||||
case WINESERV_SENDCONTROL:
|
case WINESERV_SENDCONTROL:
|
||||||
service_handle_control(pipe, service, req[1]);
|
service_handle_control(pipe, service, req[1]);
|
||||||
break;
|
break;
|
||||||
|
case WINESERV_SETPID:
|
||||||
|
service_handle_set_processID(pipe, service, req[1]);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ERR("received invalid command %d length %d\n", req[0], req[1]);
|
ERR("received invalid command %d length %d\n", req[0], req[1]);
|
||||||
}
|
}
|
||||||
|
@ -1523,7 +1563,7 @@ BOOL WINAPI StartServiceW(SC_HANDLE hService, DWORD dwNumServiceArgs,
|
||||||
{
|
{
|
||||||
struct sc_service *hsvc;
|
struct sc_service *hsvc;
|
||||||
BOOL r = FALSE;
|
BOOL r = FALSE;
|
||||||
DWORD pid;
|
DWORD dwResult, dwProcessId = 0;
|
||||||
SC_LOCK hLock;
|
SC_LOCK hLock;
|
||||||
HANDLE handle = INVALID_HANDLE_VALUE;
|
HANDLE handle = INVALID_HANDLE_VALUE;
|
||||||
|
|
||||||
|
@ -1544,15 +1584,15 @@ BOOL WINAPI StartServiceW(SC_HANDLE hService, DWORD dwNumServiceArgs,
|
||||||
if (handle==INVALID_HANDLE_VALUE)
|
if (handle==INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
/* start the service process */
|
/* start the service process */
|
||||||
if (service_start_process(hsvc, &pid))
|
if (service_start_process(hsvc, &dwProcessId))
|
||||||
handle = service_open_pipe(hsvc->name);
|
handle = service_open_pipe(hsvc->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handle != INVALID_HANDLE_VALUE)
|
if (handle != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
service_send_start_message(handle, lpServiceArgVectors, dwNumServiceArgs);
|
if (service_send_start_message(handle, lpServiceArgVectors, dwNumServiceArgs))
|
||||||
|
r = service_set_processID(handle, dwProcessId, &dwResult);
|
||||||
CloseHandle(handle);
|
CloseHandle(handle);
|
||||||
r = TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UnlockServiceDatabase( hLock );
|
UnlockServiceDatabase( hLock );
|
||||||
|
|
Loading…
Reference in New Issue