[SERVICES]

Implement large parts of RI_ScGetCurrentGroupStateW.

svn path=/trunk/; revision=73417
This commit is contained in:
Eric Kohl 2016-12-03 12:48:44 +00:00
parent 974f97cce5
commit ae1c49c382
3 changed files with 86 additions and 3 deletions

View file

@ -22,6 +22,41 @@ LIST_ENTRY UnknownGroupListHead;
/* FUNCTIONS *****************************************************************/
PSERVICE_GROUP
ScmGetServiceGroupByName(
_In_ LPCWSTR lpGroupName)
{
PLIST_ENTRY GroupEntry;
PSERVICE_GROUP lpGroup;
DPRINT("ScmGetServiceGroupByName(%S)\n", lpGroupName);
GroupEntry = GroupListHead.Flink;
while (GroupEntry != &GroupListHead)
{
lpGroup = CONTAINING_RECORD(GroupEntry, SERVICE_GROUP, GroupListEntry);
if (!_wcsicmp(lpGroup->lpGroupName, lpGroupName))
return lpGroup;
GroupEntry = GroupEntry->Flink;
}
GroupEntry = UnknownGroupListHead.Flink;
while (GroupEntry != &UnknownGroupListHead)
{
lpGroup = CONTAINING_RECORD(GroupEntry, SERVICE_GROUP, GroupListEntry);
if (!_wcsicmp(lpGroup->lpGroupName, lpGroupName))
return lpGroup;
GroupEntry = GroupEntry->Flink;
}
return NULL;
}
DWORD
ScmSetServiceGroup(PSERVICE lpService,
LPCWSTR lpGroupName)

View file

@ -1443,7 +1443,7 @@ DWORD RSetServiceObjectSecurity(
{
PSERVICE_HANDLE hSvc;
PSERVICE lpService;
ACCESS_MASK DesiredAccess = 0;
ULONG DesiredAccess = 0;
HANDLE hToken = NULL;
HKEY hServiceKey = NULL;
BOOL bDatabaseLocked = FALSE;
@ -4580,8 +4580,52 @@ DWORD RI_ScGetCurrentGroupStateW(
LPWSTR lpLoadOrderGroup,
LPDWORD lpState)
{
UNIMPLEMENTED;
return ERROR_CALL_NOT_IMPLEMENTED;
PMANAGER_HANDLE hManager;
PSERVICE_GROUP pServiceGroup;
DWORD dwError = ERROR_SUCCESS;
DPRINT("RI_ScGetCurrentGroupStateW() called\n");
if (ScmShutdown)
return ERROR_SHUTDOWN_IN_PROGRESS;
hManager = ScmGetServiceManagerFromHandle(hSCManager);
if (hManager == NULL)
{
DPRINT1("Invalid service manager handle!\n");
return ERROR_INVALID_HANDLE;
}
/* Check for SC_MANAGER_ENUMERATE_SERVICE access right */
if (!RtlAreAllAccessesGranted(hManager->Handle.DesiredAccess,
SC_MANAGER_ENUMERATE_SERVICE))
{
DPRINT("Insufficient access rights! 0x%lx\n",
hManager->Handle.DesiredAccess);
return ERROR_ACCESS_DENIED;
}
/* Lock the service database shared */
ScmLockDatabaseShared();
/* Get the group list entry */
pServiceGroup = ScmGetServiceGroupByName(lpLoadOrderGroup);
if (pServiceGroup == NULL)
{
dwError = ERROR_SERVICE_DOES_NOT_EXIST;
goto done;
}
/* FIXME: Return the group state */
*lpState = 0;
done:
/* Unlock the service database */
ScmUnlockDatabase();
DPRINT("RI_ScGetCurrentGroupStateW() done (Error %lu)\n", dwError);
return dwError;
}

View file

@ -193,6 +193,10 @@ DWORD ScmControlDriver(PSERVICE lpService,
/* groupdb.c */
PSERVICE_GROUP
ScmGetServiceGroupByName(
_In_ LPCWSTR lpGroupName);
DWORD ScmCreateGroupList(VOID);
DWORD ScmSetServiceGroup(PSERVICE lpService,
LPCWSTR lpGroupName);