ReactOS  0.4.15-dev-448-gd6c4411
settings.c File Reference
#include <ntddk.h>
#include "sndblst.h"
#include "sbdebug.h"
Include dependency graph for settings.c:

Go to the source code of this file.

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)
 

Function Documentation

◆ EnumDeviceKeys()

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

Definition at line 70 of file settings.c.

89 {
90  NTSTATUS s;
92  HANDLE hKey, hSubKey;
94  ULONG i;
95 
96  // Attempt to open the key
97 
100 
101  s = ZwOpenKey(&hKey, KEY_READ, &oa);
102 
103  TEST_STATUS(s); // debugging
104 
105  if (! NT_SUCCESS(s))
106  return s; // Problem
107 
109 
110  DPRINT("Subkey: %wZ\n", &SubkeyName);
111 
113  hKey, (PSECURITY_DESCRIPTOR)NULL);
114 
115  s = ZwOpenKey(&hSubKey, KEY_ENUMERATE_SUB_KEYS, &oa);
116 
117  ZwClose(hKey);
118 
119  TEST_STATUS(s); // debugging
120 
121  if (! NT_SUCCESS(s))
122  return s;
123 
124 
125  // And now, the enumeration
126 
127  for (i = 0;; i ++)
128  {
131  ULONG ResultLength = 0;
132  ULONG Size = 0;
133  PWSTR Pos;
134  PWSTR Name;
135 
136  // Find the length of the subkey data
137 
138 // Info.NameLength = 0; // TEMPORARY!
139 
140  s = ZwEnumerateKey(hSubKey, i, KeyBasicInformation, &Info,
141  sizeof(Info), &ResultLength);
142 
143  if (s == STATUS_NO_MORE_ENTRIES)
144  break;
145 
146  DPRINT("Found an entry, allocating memory...\n");
147 
148 // Size = Info.NameLength + FIELD_OFFSET(KEY_BASIC_INFORMATION, Name[0]);
150 
151  DPRINT("Size is %d\n", Size);
152 
154 
155  if (pInfo == NULL)
156  {
157  DPRINT("INSUFFICIENT RESOURCES!\n");
159  break;
160  }
161 
162  DPRINT("Re-enumerating...\n");
163 
164  s = ZwEnumerateKey(hSubKey, i, KeyBasicInformation, pInfo, Size,
165  &ResultLength);
166 
167 // TEST_STATUS(s); // debugging
168 
169  if (! NT_SUCCESS(s))
170  {
171  ExFreePool((PVOID) pInfo);
173  break;
174  }
175 
176  DPRINT("Allocating memory for name...\n");
177 
179  RegistryPath->Length + sizeof(WCHAR) +
180  SubkeyName.Length + sizeof(WCHAR) +
181  pInfo->NameLength + sizeof(UNICODE_NULL));
182 
183  if (Name == NULL)
184  {
185  DPRINT("INSUFFICIENT RESOURCES!");
186  ExFreePool((PVOID) pInfo);
188  }
189 
190  // Copy the key name
192  Pos = Name + (RegistryPath->Length / sizeof(WCHAR));
193  Pos[0] = '\\';
194  Pos++;
195 
196  // Copy the parameters sub key name
197  RtlCopyMemory((PVOID)Pos, (PVOID)SubKey, SubkeyName.Length); //SubkeyName?
198  Pos += SubkeyName.Length / sizeof(WCHAR);
199  Pos[0] = '\\';
200  Pos ++;
201 
202  // Copy the device sub key name
203  RtlCopyMemory((PVOID)Pos, (PVOID)pInfo->Name, pInfo->NameLength);
204  Pos += pInfo->NameLength / sizeof(WCHAR);
205  Pos[0] = UNICODE_NULL;
206 
207  ExFreePool((PVOID)pInfo);
208 
209  DPRINT("Calling callback...\n");
210 
211  s = (*Callback)(Name, Context);
212 
213  if (! NT_SUCCESS(s))
214  { DPRINT("Callback FAILED\n");
215  break;}
216  }
217 
218  ZwClose(hSubKey);
219 
220  DPRINT("%d device registry keys found\n", i);
221 
222  if ((i == 0) && (s == STATUS_NO_MORE_ENTRIES))
224 
226 }
IN CINT OUT PVOID IN ULONG OUT PULONG ResultLength
Definition: conport.c:47
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:193
#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:55
LONG NTSTATUS
Definition: precomp.h:26
ush Pos
Definition: deflate.h:92
enum TestStatus TEST_STATUS
struct TraceInfo Info
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:451
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
#define UNICODE_NULL
struct NameRec_ * Name
Definition: cdprocs.h:464
struct _KEY_BASIC_INFORMATION * PKEY_BASIC_INFORMATION
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
__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
_In_opt_ PWSTR SubkeyName
Definition: classpnp.h:1209
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
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
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:28
#define STATUS_DEVICE_CONFIGURATION_ERROR
Definition: ntstatus.h:605
return STATUS_SUCCESS
Definition: btrfs.c:3014
#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 230 of file settings.c.

252 {
254 
255  if (ValueType == REG_DWORD)
256  {
258  {
259  DeviceInfo->Port = *(PULONG) ValueData;
260  DPRINT("Registry port = 0x%x\n", DeviceInfo->Port);
261  }
262 
263  // More to come... (config.c)
264  }
265 
266  else
267  {
268  // ?
269  }
270 
271  return STATUS_SUCCESS;
272 }
_In_ PCWSTR _In_z_ PCWSTR _In_ ULONG ValueType
Definition: rtlfuncs.h:4062
_In_ PUNICODE_STRING ValueName
Definition: cmfuncs.h:264
void DPRINT(...)
Definition: polytest.cpp:61
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:311
unsigned int * PULONG
Definition: retypes.h:1
struct tagContext Context
Definition: acpixf.h:1034
#define REGISTRY_PORT
Definition: mpu401.h:25
return STATUS_SUCCESS
Definition: btrfs.c:3014
#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)