ReactOS  0.4.15-dev-4857-g47842d7
settings.c File Reference
#include <ntddk.h>
#include "mpu401.h"
#include <debug.h>
#include "sbdebug.h"
Include dependency graph for settings.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI EnumDeviceKeys (IN PUNICODE_STRING RegistryPath, IN PWSTR SubKey, IN PREGISTRY_CALLBACK_ROUTINE Callback, IN PVOID Context)
 
NTSTATUS NTAPI LoadSettings (IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, IN ULONG ValueLength, IN PVOID Context, IN PVOID EntryContext)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 16 of file settings.c.

Function Documentation

◆ EnumDeviceKeys()

NTSTATUS NTAPI EnumDeviceKeys ( IN PUNICODE_STRING  RegistryPath,
IN PWSTR  SubKey,
IN PREGISTRY_CALLBACK_ROUTINE  Callback,
IN PVOID  Context 
)

Definition at line 73 of file settings.c.

92 {
93  NTSTATUS s;
95  HANDLE hKey, hSubKey;
97  ULONG i;
98 
99  // Attempt to open the key
100 
103 
104  s = ZwOpenKey(&hKey, KEY_READ, &oa);
105 
106  TEST_STATUS(s); // debugging
107 
108  if (! NT_SUCCESS(s))
109  return s; // Problem
110 
112 
113  DPRINT("Subkey: %wZ\n", &SubkeyName);
114 
117 
118  s = ZwOpenKey(&hSubKey, KEY_ENUMERATE_SUB_KEYS, &oa);
119 
120  ZwClose(hKey);
121 
122  TEST_STATUS(s); // debugging
123 
124  if (! NT_SUCCESS(s))
125  return s;
126 
127 
128  // And now, the enumeration
129 
130  for (i = 0;; i ++)
131  {
134  ULONG ResultLength = 0;
135  ULONG Size = 0;
136  PWSTR Pos;
137  PWSTR Name;
138 
139  // Find the length of the subkey data
140 
141 // Info.NameLength = 0; // TEMPORARY!
142 
143  s = ZwEnumerateKey(hSubKey, i, KeyBasicInformation, &Info,
144  sizeof(Info), &ResultLength);
145 
146  if (s == STATUS_NO_MORE_ENTRIES)
147  break;
148 
149  DPRINT("Found an entry, allocating memory...\n");
150 
151 // Size = Info.NameLength + FIELD_OFFSET(KEY_BASIC_INFORMATION, Name[0]);
153 
154  DPRINT("Size is %d\n", Size);
155 
157 
158  if (pInfo == NULL)
159  {
160  DPRINT("INSUFFICIENT RESOURCES!\n");
162  break;
163  }
164 
165  DPRINT("Re-enumerating...\n");
166 
167  s = ZwEnumerateKey(hSubKey, i, KeyBasicInformation, pInfo, Size,
168  &ResultLength);
169 
170 // TEST_STATUS(s); // debugging
171 
172  if (! NT_SUCCESS(s))
173  {
174  ExFreePool((PVOID) pInfo);
176  break;
177  }
178 
179  DPRINT("Allocating memory for name...\n");
180 
182  RegistryPath->Length + sizeof(WCHAR) +
183  SubkeyName.Length + sizeof(WCHAR) +
184  pInfo->NameLength + sizeof(UNICODE_NULL));
185 
186  if (Name == NULL)
187  {
188  DPRINT("INSUFFICIENT RESOURCES!");
189  ExFreePool((PVOID) pInfo);
191  }
192 
193  // Copy the key name
194  RtlCopyMemory((PVOID)Name, (PVOID)RegistryPath->Buffer, RegistryPath->Length);
195  Pos = Name + (RegistryPath->Length / sizeof(WCHAR));
196  Pos[0] = '\\';
197  Pos++;
198 
199  // Copy the parameters sub key name
200  RtlCopyMemory((PVOID)Pos, (PVOID)SubKey, SubkeyName.Length); //SubkeyName?
201  Pos += SubkeyName.Length / sizeof(WCHAR);
202  Pos[0] = '\\';
203  Pos ++;
204 
205  // Copy the device sub key name
206  RtlCopyMemory((PVOID)Pos, (PVOID)pInfo->Name, pInfo->NameLength);
207  Pos += pInfo->NameLength / sizeof(WCHAR);
208  Pos[0] = UNICODE_NULL;
209 
210  ExFreePool((PVOID)pInfo);
211 
212  DPRINT("Calling callback...\n");
213 
214  s = (*Callback)(Name, Context);
215 
216  if (! NT_SUCCESS(s))
217  { DPRINT("Callback FAILED\n");
218  break;}
219  }
220 
221  ZwClose(hSubKey);
222 
223  DPRINT("%d device registry keys found\n", i);
224 
225  if ((i == 0) && (s == STATUS_NO_MORE_ENTRIES))
227 
229 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:205
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define KEY_READ
Definition: nt_native.h:1023
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
uint16_t * PWSTR
Definition: typedefs.h:56
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:213
ush Pos
Definition: deflate.h:92
enum TestStatus TEST_STATUS
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:683
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:465
#define UNICODE_NULL
struct NameRec_ * Name
Definition: cdprocs.h:459
struct _KEY_BASIC_INFORMATION * PKEY_BASIC_INFORMATION
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
GLdouble s
Definition: gl.h:2039
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
FxAutoRegKey hKey
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define NULL
Definition: types.h:112
_In_opt_ PWSTR SubkeyName
Definition: cdrom.h:960
struct tagContext Context
Definition: acpixf.h:1034
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
#define STATUS_DEVICE_CONFIGURATION_ERROR
Definition: ntstatus.h:619
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019

◆ LoadSettings()

NTSTATUS NTAPI LoadSettings ( IN PWSTR  ValueName,
IN ULONG  ValueType,
IN PVOID  ValueData,
IN ULONG  ValueLength,
IN PVOID  Context,
IN PVOID  EntryContext 
)

Definition at line 233 of file settings.c.

255 {
257 
258  if (ValueType == REG_DWORD)
259  {
261  {
262  DeviceInfo->Port = *(PULONG) ValueData;
263  DPRINT("Registry port = 0x%x\n", DeviceInfo->Port);
264  }
265 
266  // More to come... (config.c)
267  }
268 
269  else
270  {
271  // ?
272  }
273 
274  return STATUS_SUCCESS;
275 }
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG _Out_opt_ PULONG _Out_opt_ PULONG ValueType
Definition: wdfregistry.h:279
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:311
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:240
unsigned int * PULONG
Definition: retypes.h:1
struct tagContext Context
Definition: acpixf.h:1034
#define STATUS_SUCCESS
Definition: shellext.h:65
#define REGISTRY_PORT
Definition: mpu401.h:25
#define DPRINT
Definition: sndvol32.h:71
#define REG_DWORD
Definition: sdbapi.c:596
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)