ReactOS 0.4.16-dev-329-g9223134
groupdb.c File Reference
#include "services.h"
#include <debug.h>
Include dependency graph for groupdb.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

PSERVICE_GROUP ScmGetServiceGroupByName (_In_ LPCWSTR lpGroupName)
 
DWORD ScmSetServiceGroup (PSERVICE lpService, LPCWSTR lpGroupName)
 
static NTSTATUS WINAPI CreateGroupOrderListRoutine (PWSTR ValueName, ULONG ValueType, PVOID ValueData, ULONG ValueLength, PVOID Context, PVOID EntryContext)
 
static NTSTATUS WINAPI CreateGroupListRoutine (PWSTR ValueName, ULONG ValueType, PVOID ValueData, ULONG ValueLength, PVOID Context, PVOID EntryContext)
 
DWORD ScmCreateGroupList (VOID)
 

Variables

LIST_ENTRY GroupListHead
 
LIST_ENTRY UnknownGroupListHead
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file groupdb.c.

Function Documentation

◆ CreateGroupListRoutine()

static NTSTATUS WINAPI CreateGroupListRoutine ( PWSTR  ValueName,
ULONG  ValueType,
PVOID  ValueData,
ULONG  ValueLength,
PVOID  Context,
PVOID  EntryContext 
)
static

Definition at line 188 of file groupdb.c.

194{
198
199 if (ValueType == REG_SZ)
200 {
201 DPRINT("Data: '%S'\n", (PWCHAR)ValueData);
202
205 sizeof(SERVICE_GROUP) + ((wcslen((const wchar_t*) ValueData) + 1) * sizeof(WCHAR)));
206 if (Group == NULL)
207 {
209 }
210
211 wcscpy(Group->szGroupName, (const wchar_t*) ValueData);
212 Group->lpGroupName = Group->szGroupName;
213 Group->dwRefCount = (DWORD)-1;
214
218
220 L"GroupOrderList",
222 (PVOID)Group,
223 NULL);
224 DPRINT("%x %lu %S\n", Status, Group->TagCount, (PWSTR)ValueData);
225
227 &Group->GroupListEntry);
228 }
229
230 return STATUS_SUCCESS;
231}
LONG NTSTATUS
Definition: precomp.h:26
struct _SERVICE_GROUP * PSERVICE_GROUP
struct _SERVICE_GROUP SERVICE_GROUP
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define InsertTailList(ListHead, Entry)
Status
Definition: gdiplustypes.h:25
LIST_ENTRY GroupListHead
Definition: groupdb.c:19
static NTSTATUS WINAPI CreateGroupOrderListRoutine(PWSTR ValueName, ULONG ValueType, PVOID ValueData, ULONG ValueLength, PVOID Context, PVOID EntryContext)
Definition: groupdb.c:139
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:312
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
#define REG_SZ
Definition: layer.c:22
_In_opt_ PSID Group
Definition: rtlfuncs.h:1658
_In_ PCWSTR _Inout_ _At_ QueryTable _Pre_unknown_ PRTL_QUERY_REGISTRY_TABLE QueryTable
Definition: rtlfuncs.h:4220
#define RTL_REGISTRY_CONTROL
Definition: nt_native.h:163
#define DWORD
Definition: nt_native.h:44
#define L(x)
Definition: ntvdm.h:50
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine
Definition: nt_native.h:109
uint16_t * PWSTR
Definition: typedefs.h:56
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint16_t * PWCHAR
Definition: typedefs.h:56
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG _Out_opt_ PULONG _Out_opt_ PULONG ValueType
Definition: wdfregistry.h:282
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by ScmCreateGroupList().

◆ CreateGroupOrderListRoutine()

static NTSTATUS WINAPI CreateGroupOrderListRoutine ( PWSTR  ValueName,
ULONG  ValueType,
PVOID  ValueData,
ULONG  ValueLength,
PVOID  Context,
PVOID  EntryContext 
)
static

Definition at line 139 of file groupdb.c.

145{
147
148 DPRINT("CreateGroupOrderListRoutine(%S, %x, %p, %x, %p, %p)\n",
150
151 if (ValueType == REG_BINARY &&
152 ValueData != NULL &&
153 ValueLength >= sizeof(DWORD) &&
154 ValueLength >= (*(PULONG)ValueData + 1) * sizeof(DWORD))
155 {
157 Group->TagCount = ((PULONG)ValueData)[0];
158 if (Group->TagCount > 0)
159 {
160 if (ValueLength >= (Group->TagCount + 1) * sizeof(DWORD))
161 {
162 Group->TagArray = (PULONG)HeapAlloc(GetProcessHeap(),
164 Group->TagCount * sizeof(DWORD));
165 if (Group->TagArray == NULL)
166 {
167 Group->TagCount = 0;
169 }
170
171 RtlCopyMemory(Group->TagArray,
172 (PULONG)ValueData + 1,
173 Group->TagCount * sizeof(DWORD));
174 }
175 else
176 {
177 Group->TagCount = 0;
178 return STATUS_UNSUCCESSFUL;
179 }
180 }
181 }
182
183 return STATUS_SUCCESS;
184}
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ PCWSTR _Inout_ _At_ QueryTable EntryContext
Definition: rtlfuncs.h:4219
#define REG_BINARY
Definition: nt_native.h:1496
uint32_t * PULONG
Definition: typedefs.h:59
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG ValueLength
Definition: wdfregistry.h:275

Referenced by CreateGroupListRoutine().

◆ ScmCreateGroupList()

DWORD ScmCreateGroupList ( VOID  )

Definition at line 235 of file groupdb.c.

236{
239
242
243 /* Build group order list */
245 sizeof(QueryTable));
246
247 QueryTable[0].Name = L"List";
249
251 L"ServiceGroupOrder",
253 NULL,
254 NULL);
255
257}
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
LIST_ENTRY UnknownGroupListHead
Definition: groupdb.c:20
static NTSTATUS WINAPI CreateGroupListRoutine(PWSTR ValueName, ULONG ValueType, PVOID ValueData, ULONG ValueLength, PVOID Context, PVOID EntryContext)
Definition: groupdb.c:188
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)

Referenced by ScmCreateServiceDatabase().

◆ ScmGetServiceGroupByName()

PSERVICE_GROUP ScmGetServiceGroupByName ( _In_ LPCWSTR  lpGroupName)

Definition at line 26 of file groupdb.c.

28{
29 PLIST_ENTRY GroupEntry;
30 PSERVICE_GROUP lpGroup;
31
32 DPRINT("ScmGetServiceGroupByName(%S)\n", lpGroupName);
33
34 GroupEntry = GroupListHead.Flink;
35 while (GroupEntry != &GroupListHead)
36 {
37 lpGroup = CONTAINING_RECORD(GroupEntry, SERVICE_GROUP, GroupListEntry);
38
39 if (!_wcsicmp(lpGroup->lpGroupName, lpGroupName))
40 return lpGroup;
41
42 GroupEntry = GroupEntry->Flink;
43 }
44
45 GroupEntry = UnknownGroupListHead.Flink;
46 while (GroupEntry != &UnknownGroupListHead)
47 {
48 lpGroup = CONTAINING_RECORD(GroupEntry, SERVICE_GROUP, GroupListEntry);
49
50 if (!_wcsicmp(lpGroup->lpGroupName, lpGroupName))
51 return lpGroup;
52
53 GroupEntry = GroupEntry->Flink;
54 }
55
56 return NULL;
57}
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LPWSTR lpGroupName
Definition: services.h:35
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by RI_ScGetCurrentGroupStateW().

◆ ScmSetServiceGroup()

DWORD ScmSetServiceGroup ( PSERVICE  lpService,
LPCWSTR  lpGroupName 
)

Definition at line 61 of file groupdb.c.

63{
64 PLIST_ENTRY GroupEntry;
65 PSERVICE_GROUP lpGroup;
66
67 DPRINT("ScmSetServiceGroup(%S)\n", lpGroupName);
68
69 if (lpService->lpGroup != NULL)
70 {
71 ASSERT(lpService->lpGroup->dwRefCount != 0);
72 ASSERT(lpService->lpGroup->dwRefCount == (DWORD)-1 ||
73 lpService->lpGroup->dwRefCount < 10000);
74 if (lpService->lpGroup->dwRefCount != (DWORD)-1)
75 {
76 lpService->lpGroup->dwRefCount--;
77 if (lpService->lpGroup->dwRefCount == 0)
78 {
79 ASSERT(lpService->lpGroup->TagCount == 0);
80 ASSERT(lpService->lpGroup->TagArray == NULL);
82 HeapFree(GetProcessHeap(), 0, lpService->lpGroup);
83 lpService->lpGroup = NULL;
84 }
85 }
86 }
87
88 if (lpGroupName == NULL)
89 return ERROR_SUCCESS;
90
91 GroupEntry = GroupListHead.Flink;
92 while (GroupEntry != &GroupListHead)
93 {
94 lpGroup = CONTAINING_RECORD(GroupEntry, SERVICE_GROUP, GroupListEntry);
95
96 if (!_wcsicmp(lpGroup->lpGroupName, lpGroupName))
97 {
98 lpService->lpGroup = lpGroup;
99 return ERROR_SUCCESS;
100 }
101
102 GroupEntry = GroupEntry->Flink;
103 }
104
105 GroupEntry = UnknownGroupListHead.Flink;
106 while (GroupEntry != &UnknownGroupListHead)
107 {
108 lpGroup = CONTAINING_RECORD(GroupEntry, SERVICE_GROUP, GroupListEntry);
109
110 if (!_wcsicmp(lpGroup->lpGroupName, lpGroupName))
111 {
112 lpGroup->dwRefCount++;
113 lpService->lpGroup = lpGroup;
114 return ERROR_SUCCESS;
115 }
116
117 GroupEntry = GroupEntry->Flink;
118 }
119
122 sizeof(SERVICE_GROUP) + ((wcslen(lpGroupName) + 1)* sizeof(WCHAR)));
123 if (lpGroup == NULL)
125
126 wcscpy(lpGroup->szGroupName, lpGroupName);
127 lpGroup->lpGroupName = lpGroup->szGroupName;
128 lpGroup->dwRefCount = 1;
129 lpService->lpGroup = lpGroup;
130
132 &lpGroup->GroupListEntry);
133
134 return ERROR_SUCCESS;
135}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HeapFree(x, y, z)
Definition: compat.h:735
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define ASSERT(a)
Definition: mode.c:44
DWORD dwRefCount
Definition: services.h:37
WCHAR szGroupName[1]
Definition: services.h:42
PULONG TagArray
Definition: services.h:40
LIST_ENTRY GroupListEntry
Definition: services.h:34
ULONG TagCount
Definition: services.h:39
PSERVICE_GROUP lpGroup
Definition: services.h:66

Referenced by CreateServiceListEntry(), RChangeServiceConfigW(), RCreateServiceW(), and ScmDeleteServiceRecord().

Variable Documentation

◆ GroupListHead

◆ UnknownGroupListHead

LIST_ENTRY UnknownGroupListHead

Definition at line 20 of file groupdb.c.

Referenced by ScmCreateGroupList(), ScmGetServiceGroupByName(), and ScmSetServiceGroup().