Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygensettings.c
Go to the documentation of this file.
00001 /* 00002 * 00003 * COPYRIGHT: See COPYING in the top level directory 00004 * PROJECT: ReactOS kernel 00005 * FILE: drivers/dd/sndblst/settings.c 00006 * PURPOSE: MPU-401 MIDI device driver setting management 00007 * PROGRAMMER: Andrew Greenwood 00008 * UPDATE HISTORY: 00009 * Sept 28, 2003: Created 00010 */ 00011 00012 #include <ntddk.h> 00013 #include "sndblst.h" 00014 #include "sbdebug.h" // our own debug helper 00015 00016 00017 #if 0 00018 NTSTATUS 00019 OpenDevicesKey( 00020 IN PWSTR RegistryPath, 00021 OUT PHANDLE Key) 00022 /* 00023 Description: 00024 Create a volatile key under this driver's Services node to contain 00025 the device name list. 00026 00027 Parameters: 00028 RegistryPath The location of the registry entry 00029 Key The key in the registry 00030 00031 Return Value: 00032 NT status STATUS_SUCCESS if successful (duh...) 00033 */ 00034 { 00035 NTSTATUS s; 00036 HANDLE hKey; 00037 OBJECT_ATTRIBUTES oa; 00038 UNICODE_STRING uStr; 00039 00040 // Attempt to open the key 00041 00042 RtlInitUnicodeString(&uStr, RegistryPath); 00043 00044 InitializeObjectAttributes(&oa, &uStr, OBJ_CASE_INSENSITIVE, NULL, 00045 (PSECURITY_DESCRIPTOR)NULL); 00046 00047 s = ZwOpenKey(&hKey, KEY_CREATE_SUB_KEY, &oa); 00048 00049 if (! NT_SUCCESS(s)) 00050 return s; // Problem 00051 00052 00053 // Now create sub key 00054 00055 RtlInitUnicodeString(&uStr, (PWSTR) DEVICE_SUBKEY); 00056 00057 InitializeObjectAttributes(&oa, &uStr, OBJ_CASE_INSENSITIVE, hKey, 00058 (PSECURITY_DESCRIPTOR)NULL); 00059 00060 s = ZwCreateKey(Key, KEY_ALL_ACCESS, &oa, 0, NULL, REG_OPTION_VOLATILE, 00061 NULL); 00062 00063 ZwClose(hKey); 00064 00065 return s; 00066 } 00067 #endif 00068 00069 00070 NTSTATUS NTAPI EnumDeviceKeys( 00071 IN PUNICODE_STRING RegistryPath, 00072 IN PWSTR SubKey, 00073 IN PREGISTRY_CALLBACK_ROUTINE Callback, 00074 IN PVOID Context) 00075 /* 00076 Description: 00077 Enumerate the device subkeys in the driver's registry entry, and 00078 call the specified callback routine for each device. 00079 00080 Parameters: 00081 RegistryPath The location of the registry entry 00082 Subkey The device's subkey 00083 Callback A routine called for each device 00084 Context ??? 00085 00086 Return Value: 00087 NT status STATUS_SUCCESS if successful 00088 */ 00089 { 00090 NTSTATUS s; 00091 OBJECT_ATTRIBUTES oa; 00092 HANDLE hKey, hSubKey; 00093 UNICODE_STRING SubkeyName; 00094 ULONG i; 00095 00096 // Attempt to open the key 00097 00098 InitializeObjectAttributes(&oa, RegistryPath, OBJ_CASE_INSENSITIVE, 00099 NULL, (PSECURITY_DESCRIPTOR)NULL); 00100 00101 s = ZwOpenKey(&hKey, KEY_READ, &oa); 00102 00103 TEST_STATUS(s); // debugging 00104 00105 if (! NT_SUCCESS(s)) 00106 return s; // Problem 00107 00108 RtlInitUnicodeString(&SubkeyName, SubKey); 00109 00110 DPRINT("Subkey: %wZ\n", &SubkeyName); 00111 00112 InitializeObjectAttributes(&oa, &SubkeyName, OBJ_CASE_INSENSITIVE, 00113 hKey, (PSECURITY_DESCRIPTOR)NULL); 00114 00115 s = ZwOpenKey(&hSubKey, KEY_ENUMERATE_SUB_KEYS, &oa); 00116 00117 ZwClose(hKey); 00118 00119 TEST_STATUS(s); // debugging 00120 00121 if (! NT_SUCCESS(s)) 00122 return s; 00123 00124 00125 // And now, the enumeration 00126 00127 for (i = 0;; i ++) 00128 { 00129 KEY_BASIC_INFORMATION Info; 00130 PKEY_BASIC_INFORMATION pInfo; 00131 ULONG ResultLength = 0; 00132 ULONG Size = 0; 00133 PWSTR Pos; 00134 PWSTR Name; 00135 00136 // Find the length of the subkey data 00137 00138 // Info.NameLength = 0; // TEMPORARY! 00139 00140 s = ZwEnumerateKey(hSubKey, i, KeyBasicInformation, &Info, 00141 sizeof(Info), &ResultLength); 00142 00143 if (s == STATUS_NO_MORE_ENTRIES) 00144 break; 00145 00146 DPRINT("Found an entry, allocating memory...\n"); 00147 00148 // Size = Info.NameLength + FIELD_OFFSET(KEY_BASIC_INFORMATION, Name[0]); 00149 Size = ResultLength + FIELD_OFFSET(KEY_BASIC_INFORMATION, Name[0]); 00150 00151 DPRINT("Size is %d\n", Size); 00152 00153 pInfo = (PKEY_BASIC_INFORMATION) ExAllocatePool(PagedPool, Size); 00154 00155 if (pInfo == NULL) 00156 { 00157 DPRINT("INSUFFICIENT RESOURCES!\n"); 00158 s = STATUS_INSUFFICIENT_RESOURCES; 00159 break; 00160 } 00161 00162 DPRINT("Re-enumerating...\n"); 00163 00164 s = ZwEnumerateKey(hSubKey, i, KeyBasicInformation, pInfo, Size, 00165 &ResultLength); 00166 00167 // TEST_STATUS(s); // debugging 00168 00169 if (! NT_SUCCESS(s)) 00170 { 00171 ExFreePool((PVOID) pInfo); 00172 s = STATUS_INTERNAL_ERROR; 00173 break; 00174 } 00175 00176 DPRINT("Allocating memory for name...\n"); 00177 00178 Name = ExAllocatePool(PagedPool, 00179 RegistryPath->Length + sizeof(WCHAR) + 00180 SubkeyName.Length + sizeof(WCHAR) + 00181 pInfo->NameLength + sizeof(UNICODE_NULL)); 00182 00183 if (Name == NULL) 00184 { 00185 DPRINT("INSUFFICIENT RESOURCES!"); 00186 ExFreePool((PVOID) pInfo); 00187 return STATUS_INSUFFICIENT_RESOURCES; 00188 } 00189 00190 // Copy the key name 00191 RtlCopyMemory((PVOID)Name, (PVOID)RegistryPath->Buffer, RegistryPath->Length); 00192 Pos = Name + (RegistryPath->Length / sizeof(WCHAR)); 00193 Pos[0] = '\\'; 00194 Pos++; 00195 00196 // Copy the parameters sub key name 00197 RtlCopyMemory((PVOID)Pos, (PVOID)SubKey, SubkeyName.Length); //SubkeyName? 00198 Pos += SubkeyName.Length / sizeof(WCHAR); 00199 Pos[0] = '\\'; 00200 Pos ++; 00201 00202 // Copy the device sub key name 00203 RtlCopyMemory((PVOID)Pos, (PVOID)pInfo->Name, pInfo->NameLength); 00204 Pos += pInfo->NameLength / sizeof(WCHAR); 00205 Pos[0] = UNICODE_NULL; 00206 00207 ExFreePool((PVOID)pInfo); 00208 00209 DPRINT("Calling callback...\n"); 00210 00211 s = (*Callback)(Name, Context); 00212 00213 if (! NT_SUCCESS(s)) 00214 { DPRINT("Callback FAILED\n"); 00215 break;} 00216 } 00217 00218 ZwClose(hSubKey); 00219 00220 DPRINT("%d device registry keys found\n", i); 00221 00222 if ((i == 0) && (s == STATUS_NO_MORE_ENTRIES)) 00223 return STATUS_DEVICE_CONFIGURATION_ERROR; 00224 00225 return s == STATUS_NO_MORE_ENTRIES ? STATUS_SUCCESS : s; 00226 } 00227 00228 00229 00230 NTSTATUS NTAPI LoadSettings( 00231 IN PWSTR ValueName, 00232 IN ULONG ValueType, 00233 IN PVOID ValueData, 00234 IN ULONG ValueLength, 00235 IN PVOID Context, 00236 IN PVOID EntryContext) 00237 /* 00238 Description: 00239 Read the settings for a particular device 00240 00241 Parameters: 00242 ValueName The value to read from the registry 00243 ValueType ? 00244 ValueData ? 00245 ValueLength ? 00246 Context The configuration structure to write to 00247 EntryContext ? 00248 00249 Return Value: 00250 NT status STATUS_SUCCESS if successful 00251 */ 00252 { 00253 PDEVICE_EXTENSION DeviceInfo = Context; 00254 00255 if (ValueType == REG_DWORD) 00256 { 00257 if (! _wcsicmp(ValueName, REGISTRY_PORT)) 00258 { 00259 DeviceInfo->Port = *(PULONG) ValueData; 00260 DPRINT("Registry port = 0x%x\n", DeviceInfo->Port); 00261 } 00262 00263 // More to come... (config.c) 00264 } 00265 00266 else 00267 { 00268 // ? 00269 } 00270 00271 return STATUS_SUCCESS; 00272 } 00273 00274 00275 #if 0 00276 NTSTATUS SaveSettings( 00277 IN PWSTR RegistryPath, 00278 IN ULONG Port, 00279 IN ULONG IRQ, 00280 IN ULONG DMA) 00281 /* 00282 Description: 00283 Saves the settings for a particular device 00284 00285 Parameters: 00286 RegistryPath Where to save the settings to 00287 Port The device's port number 00288 IRQ The device's interrupt number 00289 DMA The device's DMA channel 00290 00291 Return Value: 00292 NT status STATUS_SUCCESS if successful 00293 */ 00294 { 00295 DPRINT("SaveSettings() unimplemented\n"); 00296 00297 // UNIMPLEMENTED; 00298 00299 return STATUS_SUCCESS; 00300 } 00301 #endif Generated on Sun May 27 2012 04:16:31 for ReactOS by
1.7.6.1
|