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