Mikolaj Zalewski : advapi32: Obtain the process id locally.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Aug 23 07:26:06 CDT 2007
Module: wine
Branch: master
Commit: ec58b4485ade9af278504d74c26f373868d81a3a
URL: http://source.winehq.org/git/wine.git/?a=commit;h=ec58b4485ade9af278504d74c26f373868d81a3a
Author: Mikolaj Zalewski <mikolajz at google.com>
Date: Wed Aug 22 18:10:57 2007 -0700
advapi32: Obtain the process id locally.
---
dlls/advapi32/service.c | 57 ++++------------------------------------------
1 files changed, 5 insertions(+), 52 deletions(-)
diff --git a/dlls/advapi32/service.c b/dlls/advapi32/service.c
index f922e62..fbc888d 100644
--- a/dlls/advapi32/service.c
+++ b/dlls/advapi32/service.c
@@ -69,7 +69,6 @@ typedef struct service_start_info_t
#define WINESERV_STARTINFO 1
#define WINESERV_GETSTATUS 2
#define WINESERV_SENDCONTROL 3
-#define WINESERV_SETPID 4
typedef struct service_data_t
{
@@ -553,41 +552,6 @@ static BOOL service_get_status(HANDLE pipe, LPSERVICE_STATUS_PROCESS status)
}
/******************************************************************************
- * 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
*/
static BOOL service_send_control(HANDLE pipe, DWORD dwControl, DWORD *result)
@@ -772,9 +736,6 @@ static DWORD WINAPI service_control_dispatcher(LPVOID arg)
case WINESERV_SENDCONTROL:
service_handle_control(pipe, service, req[1]);
break;
- case WINESERV_SETPID:
- service_handle_set_processID(pipe, service, req[1]);
- break;
default:
ERR("received invalid command %d length %d\n", req[0], req[1]);
}
@@ -800,15 +761,18 @@ static BOOL service_run_threads(void)
count = list_count( &service_list );
- TRACE("starting %d pipe listener threads\n", count);
+ TRACE("Starting %d pipe listener threads. Services running as process %d\n", count, GetCurrentProcessId());
handles = HeapAlloc(GetProcessHeap(), 0, sizeof(HANDLE) * (count + 1));
handles[n++] = __wine_make_process_system();
LIST_FOR_EACH_ENTRY( service, &service_list, service_data, entry )
+ {
+ service->status.dwProcessId = GetCurrentProcessId();
handles[n++] = CreateThread( NULL, 0, service_control_dispatcher,
service, 0, NULL );
+ }
assert(n == count + 1);
LeaveCriticalSection( &service_cs );
@@ -1741,7 +1705,6 @@ BOOL WINAPI StartServiceW(SC_HANDLE hService, DWORD dwNumServiceArgs,
{
struct sc_service *hsvc;
BOOL r = FALSE;
- DWORD dwResult, dwProcessId = 0;
SC_LOCK hLock;
HANDLE handle = INVALID_HANDLE_VALUE;
@@ -1762,7 +1725,7 @@ BOOL WINAPI StartServiceW(SC_HANDLE hService, DWORD dwNumServiceArgs,
if (handle==INVALID_HANDLE_VALUE)
{
/* start the service process */
- if (service_start_process(hsvc, &dwProcessId))
+ if (service_start_process(hsvc, NULL))
handle = service_open_pipe(hsvc->name);
}
@@ -1772,16 +1735,6 @@ BOOL WINAPI StartServiceW(SC_HANDLE hService, DWORD dwNumServiceArgs,
CloseHandle(handle);
}
- if (r)
- {
- handle = service_open_pipe(hsvc->name);
- if (handle != INVALID_HANDLE_VALUE)
- {
- service_set_processID(handle, dwProcessId, &dwResult);
- CloseHandle(handle);
- }
- }
-
UnlockServiceDatabase( hLock );
TRACE("returning %d\n", r);
More information about the wine-cvs
mailing list