Receive a client service handle from advapi32 so we can get a permenant link between the SCM and the service

svn path=/trunk/; revision=29013
This commit is contained in:
Ged Murphy 2007-09-12 08:41:00 +00:00
parent 873c9d539e
commit b29eee1b73
3 changed files with 12 additions and 12 deletions

View file

@ -116,12 +116,12 @@ ScmGetServiceEntryByResumeCount(DWORD dwResumeCount)
PSERVICE
ScmGetServiceEntryByServiceStatusHandle(ULONG Handle)
ScmGetServiceEntryByClientHandle(ULONG Handle)
{
PLIST_ENTRY ServiceEntry;
PSERVICE CurrentService;
DPRINT("ScmGetServiceEntryByServiceStatusHandle() called\n");
DPRINT("ScmGetServiceEntryByClientHandle() called\n");
DPRINT("looking for %lu\n", Handle);
ServiceEntry = ServiceListHead.Flink;
@ -131,7 +131,7 @@ ScmGetServiceEntryByServiceStatusHandle(ULONG Handle)
SERVICE,
ServiceListEntry);
if (CurrentService->hServiceStatus == Handle)
if (CurrentService->hClient == Handle)
{
DPRINT1("Found service: '%S'\n", CurrentService->lpDisplayName);
return CurrentService;
@ -640,13 +640,14 @@ ScmSendStartCommand(PSERVICE Service,
DPRINT("ArgsLength: %ld TotalLength: %ld\n", ArgsLength, TotalLength);
/* Allocate a control packet */
ControlPacket = (SCM_CONTROL_PACKET*) HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
sizeof(SCM_CONTROL_PACKET) + (TotalLength - 1) * sizeof(WCHAR));
ControlPacket = (SCM_CONTROL_PACKET*)HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
sizeof(SCM_CONTROL_PACKET) + (TotalLength - 1) * sizeof(WCHAR));
if (ControlPacket == NULL)
return ERROR_NOT_ENOUGH_MEMORY;
ControlPacket->dwControl = SERVICE_CONTROL_START;
ControlPacket->hClient = Service->hClient;
ControlPacket->dwSize = TotalLength;
Ptr = &ControlPacket->szArguments[0];
wcscpy(Ptr, Service->lpServiceName);
@ -793,7 +794,7 @@ ScmStartUserModeService(PSERVICE Service,
/* Read SERVICE_STATUS_HANDLE from pipe */
if (!ReadFile(Service->ControlPipeHandle,
(LPVOID)&Service->hServiceStatus,
(LPVOID)&Service->hClient,
sizeof(DWORD),
&dwRead,
NULL))
@ -804,8 +805,7 @@ ScmStartUserModeService(PSERVICE Service,
}
else
{
DPRINT("Received service status %lu\n", Service->hServiceStatus);
DPRINT("calling ScmSendStartCommand on %S\n", Service->lpDisplayName);
DPRINT("Received service status %lu\n", Service->hClient);
/* Send start command */
dwError = ScmSendStartCommand(Service, lpArgs);

View file

@ -717,7 +717,7 @@ ScmrSetServiceStatus(handle_t BindingHandle,
if (ScmShutdown)
return ERROR_SHUTDOWN_IN_PROGRESS;
lpService = ScmGetServiceEntryByServiceStatusHandle((ULONG)hServiceStatus);
lpService = ScmGetServiceEntryByClientHandle((ULONG)hServiceStatus);
if (lpService == NULL)
{
DPRINT1("lpService == NULL!\n");

View file

@ -41,7 +41,7 @@ typedef struct _SERVICE
BOOL bDeleted;
DWORD dwResumeCount;
SERVICE_STATUS_HANDLE hServiceStatus;
CLIENT_HANDLE hClient;
SERVICE_STATUS Status;
DWORD dwStartType;
DWORD dwErrorControl;
@ -105,7 +105,7 @@ DWORD ScmStartService(PSERVICE Service,
PSERVICE ScmGetServiceEntryByName(LPWSTR lpServiceName);
PSERVICE ScmGetServiceEntryByDisplayName(LPWSTR lpDisplayName);
PSERVICE ScmGetServiceEntryByResumeCount(DWORD dwResumeCount);
PSERVICE ScmGetServiceEntryByServiceStatusHandle(ULONG ThreadId);
PSERVICE ScmGetServiceEntryByClientHandle(ULONG ThreadId);
DWORD ScmCreateNewServiceRecord(LPWSTR lpServiceName,
PSERVICE *lpServiceRecord);
DWORD ScmMarkServiceForDelete(PSERVICE pService);