fix SetServiceStatus to now call ScmrSetServiceStatus to set the service data

svn path=/trunk/; revision=27566
This commit is contained in:
Ged Murphy 2007-07-10 14:54:30 +00:00
parent f8ab7f007a
commit e9982e936f
2 changed files with 76 additions and 71 deletions

View file

@ -1829,6 +1829,69 @@ QueryServiceObjectSecurity(SC_HANDLE hService,
return TRUE;
}
/**********************************************************************
* SetServiceObjectSecurity
*
* @implemented
*/
BOOL STDCALL
SetServiceObjectSecurity(SC_HANDLE hService,
SECURITY_INFORMATION dwSecurityInformation,
PSECURITY_DESCRIPTOR lpSecurityDescriptor)
{
PSECURITY_DESCRIPTOR SelfRelativeSD = NULL;
ULONG Length;
NTSTATUS Status;
DWORD dwError;
Length = 0;
Status = RtlMakeSelfRelativeSD(lpSecurityDescriptor,
SelfRelativeSD,
&Length);
if (Status != STATUS_BUFFER_TOO_SMALL)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
SelfRelativeSD = HeapAlloc(GetProcessHeap(), 0, Length);
if (SelfRelativeSD == NULL)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
Status = RtlMakeSelfRelativeSD(lpSecurityDescriptor,
SelfRelativeSD,
&Length);
if (!NT_SUCCESS(Status))
{
HeapFree(GetProcessHeap(), 0, SelfRelativeSD);
SetLastError(RtlNtStatusToDosError(Status));
return FALSE;
}
HandleBind();
/* Call to services.exe using RPC */
dwError = ScmrSetServiceObjectSecurity(BindingHandle,
(unsigned int)hService,
dwSecurityInformation,
(unsigned char *)SelfRelativeSD,
Length);
HeapFree(GetProcessHeap(), 0, SelfRelativeSD);
if (dwError != ERROR_SUCCESS)
{
DPRINT1("ScmrServiceObjectSecurity() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
return TRUE;
}
/**********************************************************************
* QueryServiceStatus
@ -1896,67 +1959,35 @@ QueryServiceStatusEx(SC_HANDLE hService,
return TRUE;
}
/**********************************************************************
* SetServiceObjectSecurity
* SetServiceStatus
*
* @implemented
*/
BOOL STDCALL
SetServiceObjectSecurity(SC_HANDLE hService,
SECURITY_INFORMATION dwSecurityInformation,
PSECURITY_DESCRIPTOR lpSecurityDescriptor)
SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus,
LPSERVICE_STATUS lpServiceStatus)
{
PSECURITY_DESCRIPTOR SelfRelativeSD = NULL;
ULONG Length;
NTSTATUS Status;
DWORD dwError;
Length = 0;
Status = RtlMakeSelfRelativeSD(lpSecurityDescriptor,
SelfRelativeSD,
&Length);
if (Status != STATUS_BUFFER_TOO_SMALL)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
SelfRelativeSD = HeapAlloc(GetProcessHeap(), 0, Length);
if (SelfRelativeSD == NULL)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
Status = RtlMakeSelfRelativeSD(lpSecurityDescriptor,
SelfRelativeSD,
&Length);
if (!NT_SUCCESS(Status))
{
HeapFree(GetProcessHeap(), 0, SelfRelativeSD);
SetLastError(RtlNtStatusToDosError(Status));
return FALSE;
}
DPRINT("SetServiceStatus() called\n");
DPRINT("ThreadId %lu, data addr %p called\n", hServiceStatus, lpServiceStatus);
HandleBind();
/* Call to services.exe using RPC */
dwError = ScmrSetServiceObjectSecurity(BindingHandle,
(unsigned int)hService,
dwSecurityInformation,
(unsigned char *)SelfRelativeSD,
Length);
HeapFree(GetProcessHeap(), 0, SelfRelativeSD);
dwError = ScmrSetServiceStatus(BindingHandle,
(unsigned long)hServiceStatus,
lpServiceStatus);
if (dwError != ERROR_SUCCESS)
{
DPRINT1("ScmrServiceObjectSecurity() failed (Error %lu)\n", dwError);
DPRINT1("ScmrSetServiceStatus() failed (Error %lu)\n", dwError);
SetLastError(dwError);
return FALSE;
}
DPRINT("SetServiceStatus() done (ret %lu\n", dwError);
return TRUE;
}

View file

@ -64,7 +64,7 @@ ScLookupServiceByServiceName(LPCWSTR lpServiceName)
return NULL;
}
/*
static PACTIVE_SERVICE
ScLookupServiceByThreadId(DWORD ThreadId)
{
@ -82,7 +82,7 @@ ScLookupServiceByThreadId(DWORD ThreadId)
return NULL;
}
*/
static DWORD WINAPI
ScServiceMainStub(LPVOID Context)
@ -486,32 +486,6 @@ SetServiceBits(SERVICE_STATUS_HANDLE hServiceStatus,
}
/**********************************************************************
* SetServiceStatus
*
* @implemented
*/
BOOL STDCALL
SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus,
LPSERVICE_STATUS lpServiceStatus)
{
PACTIVE_SERVICE Service;
Service = ScLookupServiceByThreadId((DWORD)hServiceStatus);
if (!Service)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
RtlCopyMemory(&Service->ServiceStatus,
lpServiceStatus,
sizeof(SERVICE_STATUS));
return TRUE;
}
/**********************************************************************
* StartServiceCtrlDispatcherA
*