From d80247ef67d126c816b981dbe3be96bfb11382d9 Mon Sep 17 00:00:00 2001 From: Jason Edmeades Date: Wed, 10 Nov 2004 01:31:39 +0000 Subject: [PATCH] - Stub SetServiceObjectSecurity to pretend to work (return true). - Change QueryServiceObjectSecurity so it initializes the ACL with a null DACL, and return as though it worked. - Changed QueryServiceStatus to tell if the service is running by the presence of some named shared storage - copied from StartService when it checks to see if its already running. --- dlls/advapi32/advapi32.spec | 2 +- dlls/advapi32/service.c | 44 ++++++++++++++++++++++++++++++++++--- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/dlls/advapi32/advapi32.spec b/dlls/advapi32/advapi32.spec index 3a7c979a7c1..97011d235f8 100644 --- a/dlls/advapi32/advapi32.spec +++ b/dlls/advapi32/advapi32.spec @@ -282,7 +282,7 @@ @ stdcall SetSecurityDescriptorOwner (ptr ptr long) @ stdcall SetSecurityDescriptorSacl(ptr long ptr long) @ stub SetServiceBits -@ stub SetServiceObjectSecurity +@ stdcall SetServiceObjectSecurity(long long ptr) @ stdcall SetServiceStatus(long long) @ stdcall SetThreadToken (ptr ptr) @ stdcall SetTokenInformation (long long ptr long) diff --git a/dlls/advapi32/service.c b/dlls/advapi32/service.c index c9c0794e683..108b7a2d775 100644 --- a/dlls/advapi32/service.c +++ b/dlls/advapi32/service.c @@ -1097,6 +1097,8 @@ QueryServiceStatus( SC_HANDLE hService, LPSERVICE_STATUS lpservicestatus ) struct sc_handle *hsvc = hService; LONG r; DWORD type, val, size; + WCHAR str[MAX_PATH]; + HANDLE hServiceShmem = NULL; FIXME("(%p,%p) partial\n",hService,lpservicestatus); @@ -1110,8 +1112,25 @@ QueryServiceStatus( SC_HANDLE hService, LPSERVICE_STATUS lpservicestatus ) } lpservicestatus->dwServiceType = val; /* FIXME: how are these determined or read from the registry? */ - /* SERVICE: unavailable=0, stopped=1, starting=2, running=3? */; - lpservicestatus->dwCurrentState = 1; + /* SERVICE: unavailable=0, stopped=1, starting=2, running=3? */ + + /* Determine if currently running via named shared memory */ + snprintfW( str, MAX_PATH, szServiceShmemNameFmtW, hsvc->u.service.name ); + hServiceShmem = CreateFileMappingW( INVALID_HANDLE_VALUE, + NULL, PAGE_READWRITE, 0, size, str ); + if( NULL == hServiceShmem ) + { + lpservicestatus->dwCurrentState = 1; + } else { + if( GetLastError() == ERROR_ALREADY_EXISTS ) + { + lpservicestatus->dwCurrentState = 3; + } else { + lpservicestatus->dwCurrentState = 1; + } + CloseHandle( hServiceShmem ); + } + lpservicestatus->dwControlsAccepted = 0; lpservicestatus->dwWin32ExitCode = NO_ERROR; lpservicestatus->dwServiceSpecificExitCode = 0; @@ -1557,7 +1576,26 @@ BOOL WINAPI QueryServiceObjectSecurity(SC_HANDLE hService, PSECURITY_DESCRIPTOR lpSecurityDescriptor, DWORD cbBufSize, LPDWORD pcbBytesNeeded) { + PACL pACL = NULL; FIXME("%p %ld %p %lu %p\n", hService, dwSecurityInformation, lpSecurityDescriptor, cbBufSize, pcbBytesNeeded); - return ERROR_CALL_NOT_IMPLEMENTED; + + + InitializeSecurityDescriptor(lpSecurityDescriptor, SECURITY_DESCRIPTOR_REVISION); + + pACL = HeapAlloc( GetProcessHeap(), 0, sizeof(ACL) ); + InitializeAcl(pACL, sizeof(ACL), ACL_REVISION); + SetSecurityDescriptorDacl(lpSecurityDescriptor, TRUE, pACL, TRUE); + return TRUE; +} + +/****************************************************************************** + * SetServiceObjectSecurity [ADVAPI32.@] + */ +BOOL WINAPI SetServiceObjectSecurity(SC_HANDLE hService, + SECURITY_INFORMATION dwSecurityInformation, + PSECURITY_DESCRIPTOR lpSecurityDescriptor) +{ + FIXME("%p %ld %p\n", hService, dwSecurityInformation, lpSecurityDescriptor); + return TRUE; }