Commit 46b27469 authored by Sebastian Lackner's avatar Sebastian Lackner Committed by Alexandre Julliard

services: Store process id in the process object.

parent c8187d62
...@@ -761,13 +761,7 @@ DWORD __cdecl svcctl_SetServiceStatus( ...@@ -761,13 +761,7 @@ DWORD __cdecl svcctl_SetServiceStatus(
service_lock(service->service_entry); service_lock(service->service_entry);
/* FIXME: be a bit more discriminant about what parts of the status we set /* FIXME: be a bit more discriminant about what parts of the status we set
* and check that fields are valid */ * and check that fields are valid */
service->service_entry->status.dwServiceType = lpServiceStatus->dwServiceType; service->service_entry->status = *lpServiceStatus;
service->service_entry->status.dwCurrentState = lpServiceStatus->dwCurrentState;
service->service_entry->status.dwControlsAccepted = lpServiceStatus->dwControlsAccepted;
service->service_entry->status.dwWin32ExitCode = lpServiceStatus->dwWin32ExitCode;
service->service_entry->status.dwServiceSpecificExitCode = lpServiceStatus->dwServiceSpecificExitCode;
service->service_entry->status.dwCheckPoint = lpServiceStatus->dwCheckPoint;
service->service_entry->status.dwWaitHint = lpServiceStatus->dwWaitHint;
if ((process = service->service_entry->process)) if ((process = service->service_entry->process))
{ {
if (lpServiceStatus->dwCurrentState == SERVICE_STOPPED) if (lpServiceStatus->dwCurrentState == SERVICE_STOPPED)
...@@ -886,6 +880,14 @@ DWORD __cdecl svcctl_QueryServiceConfig2W( SC_RPC_HANDLE hService, DWORD level, ...@@ -886,6 +880,14 @@ DWORD __cdecl svcctl_QueryServiceConfig2W( SC_RPC_HANDLE hService, DWORD level,
return err; return err;
} }
static void fill_status_process(SERVICE_STATUS_PROCESS *status, struct service_entry *service)
{
struct process_entry *process = service->process;
memcpy(status, &service->status, sizeof(service->status));
status->dwProcessId = process ? process->process_id : 0;
status->dwServiceFlags = 0;
}
DWORD __cdecl svcctl_QueryServiceStatusEx( DWORD __cdecl svcctl_QueryServiceStatusEx(
SC_RPC_HANDLE hService, SC_RPC_HANDLE hService,
SC_STATUS_TYPE InfoLevel, SC_STATUS_TYPE InfoLevel,
...@@ -918,17 +920,7 @@ DWORD __cdecl svcctl_QueryServiceStatusEx( ...@@ -918,17 +920,7 @@ DWORD __cdecl svcctl_QueryServiceStatusEx(
} }
service_lock(service->service_entry); service_lock(service->service_entry);
fill_status_process(pSvcStatusData, service->service_entry);
pSvcStatusData->dwServiceType = service->service_entry->status.dwServiceType;
pSvcStatusData->dwCurrentState = service->service_entry->status.dwCurrentState;
pSvcStatusData->dwControlsAccepted = service->service_entry->status.dwControlsAccepted;
pSvcStatusData->dwWin32ExitCode = service->service_entry->status.dwWin32ExitCode;
pSvcStatusData->dwServiceSpecificExitCode = service->service_entry->status.dwServiceSpecificExitCode;
pSvcStatusData->dwCheckPoint = service->service_entry->status.dwCheckPoint;
pSvcStatusData->dwWaitHint = service->service_entry->status.dwWaitHint;
pSvcStatusData->dwProcessId = service->service_entry->status.dwProcessId;
pSvcStatusData->dwServiceFlags = service->service_entry->status.dwServiceFlags;
service_unlock(service->service_entry); service_unlock(service->service_entry);
return ERROR_SUCCESS; return ERROR_SUCCESS;
...@@ -1151,16 +1143,7 @@ DWORD __cdecl svcctl_ControlService( ...@@ -1151,16 +1143,7 @@ DWORD __cdecl svcctl_ControlService(
if (result != ERROR_SUCCESS) if (result != ERROR_SUCCESS)
{ {
if (lpServiceStatus) if (lpServiceStatus) *lpServiceStatus = service->service_entry->status;
{
lpServiceStatus->dwServiceType = service->service_entry->status.dwServiceType;
lpServiceStatus->dwCurrentState = service->service_entry->status.dwCurrentState;
lpServiceStatus->dwControlsAccepted = service->service_entry->status.dwControlsAccepted;
lpServiceStatus->dwWin32ExitCode = service->service_entry->status.dwWin32ExitCode;
lpServiceStatus->dwServiceSpecificExitCode = service->service_entry->status.dwServiceSpecificExitCode;
lpServiceStatus->dwCheckPoint = service->service_entry->status.dwCheckPoint;
lpServiceStatus->dwWaitHint = service->service_entry->status.dwWaitHint;
}
service_unlock(service->service_entry); service_unlock(service->service_entry);
return result; return result;
} }
...@@ -1195,13 +1178,7 @@ DWORD __cdecl svcctl_ControlService( ...@@ -1195,13 +1178,7 @@ DWORD __cdecl svcctl_ControlService(
if (lpServiceStatus) if (lpServiceStatus)
{ {
service_lock(service->service_entry); service_lock(service->service_entry);
lpServiceStatus->dwServiceType = service->service_entry->status.dwServiceType; *lpServiceStatus = service->service_entry->status;
lpServiceStatus->dwCurrentState = service->service_entry->status.dwCurrentState;
lpServiceStatus->dwControlsAccepted = service->service_entry->status.dwControlsAccepted;
lpServiceStatus->dwWin32ExitCode = service->service_entry->status.dwWin32ExitCode;
lpServiceStatus->dwServiceSpecificExitCode = service->service_entry->status.dwServiceSpecificExitCode;
lpServiceStatus->dwCheckPoint = service->service_entry->status.dwCheckPoint;
lpServiceStatus->dwWaitHint = service->service_entry->status.dwWaitHint;
service_unlock(service->service_entry); service_unlock(service->service_entry);
} }
...@@ -1365,7 +1342,7 @@ DWORD __cdecl svcctl_EnumServicesStatusW( ...@@ -1365,7 +1342,7 @@ DWORD __cdecl svcctl_EnumServicesStatusW(
s->lpDisplayName = (WCHAR *)offset; s->lpDisplayName = (WCHAR *)offset;
offset += sz; offset += sz;
} }
memcpy(&s->ServiceStatus, &service->status, sizeof(SERVICE_STATUS)); s->ServiceStatus = service->status;
s++; s++;
} }
} }
...@@ -1490,7 +1467,7 @@ DWORD __cdecl svcctl_EnumServicesStatusExW( ...@@ -1490,7 +1467,7 @@ DWORD __cdecl svcctl_EnumServicesStatusExW(
s->lpDisplayName = (WCHAR *)offset; s->lpDisplayName = (WCHAR *)offset;
offset += sz; offset += sz;
} }
s->ServiceStatusProcess = service->status; fill_status_process(&s->ServiceStatusProcess, service);
s++; s++;
} }
} }
......
...@@ -791,7 +791,7 @@ static DWORD service_start_process(struct service_entry *service_entry, struct p ...@@ -791,7 +791,7 @@ static DWORD service_start_process(struct service_entry *service_entry, struct p
return err; return err;
} }
service_entry->status.dwProcessId = pi.dwProcessId; process->process_id = pi.dwProcessId;
process->process = pi.hProcess; process->process = pi.hProcess;
CloseHandle( pi.hThread ); CloseHandle( pi.hThread );
...@@ -936,7 +936,6 @@ void service_terminate(struct service_entry *service) ...@@ -936,7 +936,6 @@ void service_terminate(struct service_entry *service)
release_process(process); release_process(process);
service->process = NULL; service->process = NULL;
} }
service->status.dwProcessId = 0;
service->status.dwCurrentState = SERVICE_STOPPED; service->status.dwCurrentState = SERVICE_STOPPED;
service_unlock(service); service_unlock(service);
} }
...@@ -951,7 +950,6 @@ void process_terminate(struct process_entry *process) ...@@ -951,7 +950,6 @@ void process_terminate(struct process_entry *process)
LIST_FOR_EACH_ENTRY(service, &db->services, struct service_entry, entry) LIST_FOR_EACH_ENTRY(service, &db->services, struct service_entry, entry)
{ {
if (service->process != process) continue; if (service->process != process) continue;
service->status.dwProcessId = 0;
service->status.dwCurrentState = SERVICE_STOPPED; service->status.dwCurrentState = SERVICE_STOPPED;
service->process = NULL; service->process = NULL;
release_process(process); release_process(process);
......
...@@ -37,6 +37,7 @@ struct process_entry ...@@ -37,6 +37,7 @@ struct process_entry
struct list entry; struct list entry;
struct scmdatabase *db; struct scmdatabase *db;
LONG ref_count; LONG ref_count;
DWORD process_id;
HANDLE process; HANDLE process;
HANDLE control_mutex; HANDLE control_mutex;
HANDLE control_pipe; HANDLE control_pipe;
...@@ -50,7 +51,7 @@ struct service_entry ...@@ -50,7 +51,7 @@ struct service_entry
struct scmdatabase *db; struct scmdatabase *db;
LONG ref_count; /* number of references - if goes to zero and the service is deleted the structure will be freed */ LONG ref_count; /* number of references - if goes to zero and the service is deleted the structure will be freed */
LPWSTR name; LPWSTR name;
SERVICE_STATUS_PROCESS status; SERVICE_STATUS status;
QUERY_SERVICE_CONFIGW config; QUERY_SERVICE_CONFIGW config;
DWORD preshutdown_timeout; DWORD preshutdown_timeout;
LPWSTR description; LPWSTR description;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment