mirror of
https://github.com/reactos/reactos.git
synced 2024-08-08 12:18:13 +00:00
fix SetServiceStatus to now call ScmrSetServiceStatus to set the service data
svn path=/trunk/; revision=27566
This commit is contained in:
parent
f8ab7f007a
commit
e9982e936f
|
@ -1829,6 +1829,69 @@ QueryServiceObjectSecurity(SC_HANDLE hService,
|
||||||
return TRUE;
|
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
|
* QueryServiceStatus
|
||||||
|
@ -1896,67 +1959,35 @@ QueryServiceStatusEx(SC_HANDLE hService,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* SetServiceObjectSecurity
|
* SetServiceStatus
|
||||||
*
|
*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
BOOL STDCALL
|
BOOL STDCALL
|
||||||
SetServiceObjectSecurity(SC_HANDLE hService,
|
SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus,
|
||||||
SECURITY_INFORMATION dwSecurityInformation,
|
LPSERVICE_STATUS lpServiceStatus)
|
||||||
PSECURITY_DESCRIPTOR lpSecurityDescriptor)
|
|
||||||
{
|
{
|
||||||
PSECURITY_DESCRIPTOR SelfRelativeSD = NULL;
|
|
||||||
ULONG Length;
|
|
||||||
NTSTATUS Status;
|
|
||||||
DWORD dwError;
|
DWORD dwError;
|
||||||
|
|
||||||
Length = 0;
|
DPRINT("SetServiceStatus() called\n");
|
||||||
Status = RtlMakeSelfRelativeSD(lpSecurityDescriptor,
|
DPRINT("ThreadId %lu, data addr %p called\n", hServiceStatus, lpServiceStatus);
|
||||||
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();
|
HandleBind();
|
||||||
|
|
||||||
/* Call to services.exe using RPC */
|
/* Call to services.exe using RPC */
|
||||||
dwError = ScmrSetServiceObjectSecurity(BindingHandle,
|
dwError = ScmrSetServiceStatus(BindingHandle,
|
||||||
(unsigned int)hService,
|
(unsigned long)hServiceStatus,
|
||||||
dwSecurityInformation,
|
lpServiceStatus);
|
||||||
(unsigned char *)SelfRelativeSD,
|
|
||||||
Length);
|
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, SelfRelativeSD);
|
|
||||||
|
|
||||||
if (dwError != ERROR_SUCCESS)
|
if (dwError != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
DPRINT1("ScmrServiceObjectSecurity() failed (Error %lu)\n", dwError);
|
DPRINT1("ScmrSetServiceStatus() failed (Error %lu)\n", dwError);
|
||||||
SetLastError(dwError);
|
SetLastError(dwError);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DPRINT("SetServiceStatus() done (ret %lu\n", dwError);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ ScLookupServiceByServiceName(LPCWSTR lpServiceName)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
static PACTIVE_SERVICE
|
static PACTIVE_SERVICE
|
||||||
ScLookupServiceByThreadId(DWORD ThreadId)
|
ScLookupServiceByThreadId(DWORD ThreadId)
|
||||||
{
|
{
|
||||||
|
@ -82,7 +82,7 @@ ScLookupServiceByThreadId(DWORD ThreadId)
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
static DWORD WINAPI
|
static DWORD WINAPI
|
||||||
ScServiceMainStub(LPVOID Context)
|
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
|
* StartServiceCtrlDispatcherA
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue