Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygengroupdb.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS Service Control Manager 00003 * LICENSE: GPL - See COPYING in the top level directory 00004 * FILE: base/system/services/groupdb.c 00005 * PURPOSE: Service group control interface 00006 * COPYRIGHT: Copyright 2005 Eric Kohl 00007 * 00008 */ 00009 00010 /* INCLUDES *****************************************************************/ 00011 00012 #include "services.h" 00013 00014 #define NDEBUG 00015 #include <debug.h> 00016 00017 00018 /* GLOBALS *******************************************************************/ 00019 00020 LIST_ENTRY GroupListHead; 00021 LIST_ENTRY UnknownGroupListHead; 00022 00023 00024 /* FUNCTIONS *****************************************************************/ 00025 00026 DWORD 00027 ScmSetServiceGroup(PSERVICE lpService, 00028 LPCWSTR lpGroupName) 00029 { 00030 PLIST_ENTRY GroupEntry; 00031 PSERVICE_GROUP lpGroup; 00032 00033 DPRINT("ScmSetServiceGroup(%S)\n", lpGroupName); 00034 00035 if (lpService->lpGroup != NULL) 00036 { 00037 lpService->lpGroup->dwRefCount--; 00038 00039 /* FIXME: What do we have to do when dwRefCount is 0? */ 00040 } 00041 00042 GroupEntry = GroupListHead.Flink; 00043 while (GroupEntry != &GroupListHead) 00044 { 00045 lpGroup = CONTAINING_RECORD(GroupEntry, SERVICE_GROUP, GroupListEntry); 00046 00047 if (!_wcsicmp(lpGroup->lpGroupName, lpGroupName)) 00048 { 00049 lpService->lpGroup = lpGroup; 00050 return ERROR_SUCCESS; 00051 } 00052 00053 GroupEntry = GroupEntry->Flink; 00054 } 00055 00056 GroupEntry = UnknownGroupListHead.Flink; 00057 while (GroupEntry != &UnknownGroupListHead) 00058 { 00059 lpGroup = CONTAINING_RECORD(GroupEntry, SERVICE_GROUP, GroupListEntry); 00060 00061 if (!_wcsicmp(lpGroup->lpGroupName, lpGroupName)) 00062 { 00063 lpGroup->dwRefCount++; 00064 lpService->lpGroup = lpGroup; 00065 return ERROR_SUCCESS; 00066 } 00067 00068 GroupEntry = GroupEntry->Flink; 00069 } 00070 00071 lpGroup = (PSERVICE_GROUP)HeapAlloc(GetProcessHeap(), 00072 HEAP_ZERO_MEMORY, 00073 sizeof(SERVICE_GROUP) + ((wcslen(lpGroupName) + 1)* sizeof(WCHAR))); 00074 if (lpGroup == NULL) 00075 return ERROR_NOT_ENOUGH_MEMORY; 00076 00077 wcscpy(lpGroup->szGroupName, lpGroupName); 00078 lpGroup->lpGroupName = lpGroup->szGroupName; 00079 lpGroup->dwRefCount = 1; 00080 lpService->lpGroup = lpGroup; 00081 00082 InsertTailList(&UnknownGroupListHead, 00083 &lpGroup->GroupListEntry); 00084 00085 return ERROR_SUCCESS; 00086 } 00087 00088 00089 static NTSTATUS WINAPI 00090 CreateGroupOrderListRoutine(PWSTR ValueName, 00091 ULONG ValueType, 00092 PVOID ValueData, 00093 ULONG ValueLength, 00094 PVOID Context, 00095 PVOID EntryContext) 00096 { 00097 PSERVICE_GROUP Group; 00098 00099 DPRINT("CreateGroupOrderListRoutine(%S, %x, %x, %x, %x, %x)\n", 00100 ValueName, ValueType, ValueData, ValueLength, Context, EntryContext); 00101 00102 if (ValueType == REG_BINARY && 00103 ValueData != NULL && 00104 ValueLength >= sizeof(DWORD) && 00105 ValueLength >= (*(PULONG)ValueData + 1) * sizeof(DWORD)) 00106 { 00107 Group = (PSERVICE_GROUP)Context; 00108 Group->TagCount = ((PULONG)ValueData)[0]; 00109 if (Group->TagCount > 0) 00110 { 00111 if (ValueLength >= (Group->TagCount + 1) * sizeof(DWORD)) 00112 { 00113 Group->TagArray = (PULONG)HeapAlloc(GetProcessHeap(), 00114 HEAP_ZERO_MEMORY, 00115 Group->TagCount * sizeof(DWORD)); 00116 if (Group->TagArray == NULL) 00117 { 00118 Group->TagCount = 0; 00119 return STATUS_INSUFFICIENT_RESOURCES; 00120 } 00121 00122 RtlCopyMemory(Group->TagArray, 00123 (PULONG)ValueData + 1, 00124 Group->TagCount * sizeof(DWORD)); 00125 } 00126 else 00127 { 00128 Group->TagCount = 0; 00129 return STATUS_UNSUCCESSFUL; 00130 } 00131 } 00132 } 00133 00134 return STATUS_SUCCESS; 00135 } 00136 00137 00138 static NTSTATUS WINAPI 00139 CreateGroupListRoutine(PWSTR ValueName, 00140 ULONG ValueType, 00141 PVOID ValueData, 00142 ULONG ValueLength, 00143 PVOID Context, 00144 PVOID EntryContext) 00145 { 00146 PSERVICE_GROUP Group; 00147 RTL_QUERY_REGISTRY_TABLE QueryTable[2]; 00148 NTSTATUS Status; 00149 00150 if (ValueType == REG_SZ) 00151 { 00152 DPRINT("Data: '%S'\n", (PWCHAR)ValueData); 00153 00154 Group = (PSERVICE_GROUP)HeapAlloc(GetProcessHeap(), 00155 HEAP_ZERO_MEMORY, 00156 sizeof(SERVICE_GROUP) + ((wcslen((const wchar_t*) ValueData) + 1) * sizeof(WCHAR))); 00157 if (Group == NULL) 00158 { 00159 return STATUS_INSUFFICIENT_RESOURCES; 00160 } 00161 00162 wcscpy(Group->szGroupName, (const wchar_t*) ValueData); 00163 Group->lpGroupName = Group->szGroupName; 00164 Group->dwRefCount = (DWORD)-1; 00165 00166 RtlZeroMemory(&QueryTable, sizeof(QueryTable)); 00167 QueryTable[0].Name = (PWSTR)ValueData; 00168 QueryTable[0].QueryRoutine = CreateGroupOrderListRoutine; 00169 00170 Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL, 00171 L"GroupOrderList", 00172 QueryTable, 00173 (PVOID)Group, 00174 NULL); 00175 DPRINT("%x %d %S\n", Status, Group->TagCount, (PWSTR)ValueData); 00176 00177 InsertTailList(&GroupListHead, 00178 &Group->GroupListEntry); 00179 } 00180 00181 return STATUS_SUCCESS; 00182 } 00183 00184 00185 DWORD 00186 ScmCreateGroupList(VOID) 00187 { 00188 RTL_QUERY_REGISTRY_TABLE QueryTable[2]; 00189 NTSTATUS Status; 00190 00191 InitializeListHead(&GroupListHead); 00192 InitializeListHead(&UnknownGroupListHead); 00193 00194 /* Build group order list */ 00195 RtlZeroMemory(&QueryTable, 00196 sizeof(QueryTable)); 00197 00198 QueryTable[0].Name = L"List"; 00199 QueryTable[0].QueryRoutine = CreateGroupListRoutine; 00200 00201 Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL, 00202 L"ServiceGroupOrder", 00203 QueryTable, 00204 NULL, 00205 NULL); 00206 00207 return RtlNtStatusToDosError(Status); 00208 } 00209 00210 /* EOF */ Generated on Sun May 27 2012 04:18:52 for ReactOS by
1.7.6.1
|