ReactOS 0.4.15-dev-8235-gcd88a97
hivetest.c File Reference
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include <windows.h>
#include <ndk/ntndk.h>
#include <ndk/rtltypes.h>
Include dependency graph for hivetest.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define NTOS_MODE_USER
 
#define RtlRosInitUnicodeStringFromLiteral(__Name__, __Value__)
 

Functions

void dprintf (char *fmt,...)
 
void do_enumeratekey (PWSTR Name)
 
void CreateKeyTest (void)
 
void DeleteKeyTest (void)
 
void EnumerateKeyTest (void)
 
void SetValueTest1 (void)
 
void SetValueTest2 (void)
 
void DeleteValueTest (void)
 
void EnumerateValueTest (void)
 
void test1 (void)
 
void test3 (void)
 
void test4 (void)
 
void test5 (void)
 
void test6 (void)
 
void test7 (void)
 
void test8 (void)
 
void test9 (void)
 
int main (int argc, char *argv[])
 

Variables

HANDLE OutputHandle
 
HANDLE InputHandle
 

Macro Definition Documentation

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 6 of file hivetest.c.

◆ RtlRosInitUnicodeStringFromLiteral

#define RtlRosInitUnicodeStringFromLiteral (   __Name__,
  __Value__ 
)
Value:
{ \
(__Name__)->Buffer = (__Value__); \
(__Name__)->Length = sizeof(__Value__) - sizeof(WCHAR); \
(__Name__)->MaximumLength = sizeof(__Value__); \
}
Definition: bufpool.h:45
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
_In_ WDFDMATRANSACTION _In_ size_t MaximumLength
__wchar_t WCHAR
Definition: xmlstorage.h:180

Definition at line 10 of file hivetest.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 4 of file hivetest.c.

Function Documentation

◆ CreateKeyTest()

void CreateKeyTest ( void  )

Definition at line 63 of file hivetest.c.

64{
68 UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\Software\\testkey");
69
70 dprintf("Create key '\\Registry\\Machine\\Software\\testkey':\n");
71
73 &KeyName,
75 NULL,
76 NULL);
77 dprintf("NtCreateKey:\n");
81 0,
82 NULL,
84 NULL);
85 dprintf(" Status = %lx\n",Status);
86 if (NT_SUCCESS(Status))
87 {
89 }
90}
LONG NTSTATUS
Definition: precomp.h:26
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
FxAutoRegKey hKey
Status
Definition: gdiplustypes.h:25
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
NTSTATUS NTAPI NtCreateKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG TitleIndex, IN PUNICODE_STRING Class OPTIONAL, IN ULONG CreateOptions, OUT PULONG Disposition OPTIONAL)
Definition: ntapi.c:240
#define L(x)
Definition: ntvdm.h:50
#define dprintf
Definition: regdump.c:33
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699

Referenced by main().

◆ DeleteKeyTest()

void DeleteKeyTest ( void  )

Definition at line 93 of file hivetest.c.

94{
96 UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\Software\\testkey");
99
100 dprintf("Delete key '\\Registry\\Machine\\Software\\testkey':\n");
101
103 &KeyName,
105 NULL,
106 NULL);
107 dprintf("NtOpenKey:\n");
111 dprintf(" Status = %lx\n",Status);
112 if (!NT_SUCCESS(Status))
113 return;
114
115 dprintf("NtDeleteKey:\n");
117 dprintf(" Status = %lx\n",Status);
118 NtClose(hKey);
119}
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
NTSTATUS NTAPI NtDeleteKey(IN HANDLE KeyHandle)
Definition: ntapi.c:408

Referenced by main().

◆ DeleteValueTest()

void DeleteValueTest ( void  )

Definition at line 270 of file hivetest.c.

271{
273 UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\Software\\testkey");
277
278 dprintf("Open key '\\Registry\\Machine\\Software\\testkey':\n");
279
281 &KeyName,
283 NULL,
284 NULL);
288 dprintf(" Status = %lx\n", Status);
289 if (!NT_SUCCESS(Status))
290 return;
291
292 dprintf("Delete value:\n");
293
294
296 &ValueName);
297 dprintf(" Status = %lx\n", Status);
298
299 dprintf("Close key:\n");
301 dprintf(" Status = %lx\n", Status);
302}
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
NTSYSAPI NTSTATUS NTAPI NtDeleteValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName)
Definition: ntapi.c:1014
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243

Referenced by main().

◆ do_enumeratekey()

void do_enumeratekey ( PWSTR  Name)

Definition at line 31 of file hivetest.c.

32{
34 KEY_BASIC_INFORMATION KeyInformation[5];
37 HANDLE hKey1;
39
42 , NULL, NULL);
44 dprintf("NtEnumerateKey : \n");
45 Index=0;
46 while(Status == STATUS_SUCCESS)
47 {
49 ,&KeyInformation[0], sizeof(KeyInformation)
50 ,&Length);
52 {
53 dprintf("\tSubKey Name = ");
54 for (i=0;i<KeyInformation[0].NameLength/2;i++)
55 dprintf("%C",KeyInformation[0].Name[i]);
56 dprintf("\n");
57 }
58 }
59 NtClose(hKey1);
60}
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
@ KeyBasicInformation
Definition: nt_native.h:1131
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI NTSTATUS NTAPI NtEnumerateKey(IN HANDLE KeyHandle, IN ULONG Index, IN KEY_INFORMATION_CLASS KeyInformationClass, IN PVOID KeyInformation, IN ULONG Length, IN PULONG ResultLength)
#define STATUS_SUCCESS
Definition: shellext.h:65
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFCOLLECTION _In_ ULONG Index

◆ dprintf()

void dprintf ( char fmt,
  ... 
)

Definition at line 20 of file hivetest.c.

21{
23 char buffer[255];
24
28 va_end(args);
29}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleA(IN HANDLE hConsoleOutput, IN CONST VOID *lpBuffer, IN DWORD nNumberOfCharsToWrite, OUT LPDWORD lpNumberOfCharsWritten, LPVOID lpReserved)
Definition: readwrite.c:1468
GLuint buffer
Definition: glext.h:5915
HANDLE OutputHandle
Definition: hivetest.c:17
int __cdecl vsprintf(char *_Dest, const char *_Format, va_list _Args)
Definition: sprintf.c:733
#define args
Definition: format.c:66
Definition: match.c:390
Definition: dsound.c:943

◆ EnumerateKeyTest()

void EnumerateKeyTest ( void  )

Definition at line 122 of file hivetest.c.

123{
124 HANDLE hKey = NULL;
127 UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\Software");
128 ULONG Index;
130 ULONG i;
131 KEY_BASIC_INFORMATION KeyInformation[5];
132
133 dprintf("Enumerate key '\\Registry\\Machine\\Software':\n");
134
136 &KeyName,
138 NULL,
139 NULL);
140 dprintf("NtOpenKey:\n");
144 dprintf(" Status = %lx\n", Status);
145 if (!NT_SUCCESS(Status))
146 return;
147
148 dprintf("NtQueryKey:\n");
151 &KeyInformation[0],
152 sizeof(KeyInformation),
153 &Length);
154 dprintf(" Status = %lx\n", Status);
155 if (NT_SUCCESS(Status))
156 {
157 dprintf("\tKey Name = ");
158 for (i = 0; i < KeyInformation[0].NameLength / 2; i++)
159 dprintf("%C", KeyInformation[0].Name[i]);
160 dprintf("\n");
161 }
162
163 dprintf("NtEnumerateKey:\n");
164 Index=0;
165 while(NT_SUCCESS(Status))
166 {
168 Index,
170 &KeyInformation[0],
171 sizeof(KeyInformation),
172 &Length);
173 if (NT_SUCCESS(Status))
174 {
175 dprintf("\tSubKey Name = ");
176 for (i = 0; i < KeyInformation[0].NameLength / 2; i++)
177 dprintf("%C", KeyInformation[0].Name[i]);
178 dprintf("\n");
179 }
180 Index++;
181 }
182
183 dprintf("NtClose:\n");
185 dprintf(" Status = %lx\n", Status);
186}
NTSTATUS NTAPI NtQueryKey(IN HANDLE KeyHandle, IN KEY_INFORMATION_CLASS KeyInformationClass, OUT PVOID KeyInformation, IN ULONG Length, OUT PULONG ResultLength)
Definition: ntapi.c:632

Referenced by main().

◆ EnumerateValueTest()

void EnumerateValueTest ( void  )

Definition at line 305 of file hivetest.c.

306{
307 KEY_VALUE_FULL_INFORMATION KeyValueInformation[5];
309 UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\Software\\testkey");
311 HANDLE hKey = NULL;
313
314 dprintf("Open key '\\Registry\\Machine\\Software\\testkey':\n");
315
317 &KeyName,
319 NULL,
320 NULL);
324 dprintf(" Status = %lx\n", Status);
325 if (!NT_SUCCESS(Status))
326 return;
327
328 dprintf("Enumerate values:\n");
329 Index = 0;
330 while (Status == STATUS_SUCCESS)
331 {
333 Index++,
335 &KeyValueInformation[0],
336 sizeof(KeyValueInformation),
337 &Length);
338 if (Status == STATUS_SUCCESS)
339 {
340 dprintf(" Value:DO=%d, DL=%d, NL=%d, Name = ",
341 KeyValueInformation[0].DataOffset,
342 KeyValueInformation[0].DataLength,
343 KeyValueInformation[0].NameLength);
344 for (i = 0; i < KeyValueInformation[0].NameLength / 2; i++)
345 dprintf("%C", KeyValueInformation[0].Name[i]);
346 dprintf(", Type = %d\n", KeyValueInformation[0].Type);
347
348 if (KeyValueInformation[0].Type == REG_SZ)
349 dprintf(" Value = %S\n",
350 ((char*)&KeyValueInformation[0]+KeyValueInformation[0].DataOffset));
351
352 if (KeyValueInformation[0].Type == REG_DWORD)
353 dprintf(" Value = %X\n",
354 *((DWORD*)((char*)&KeyValueInformation[0]+KeyValueInformation[0].DataOffset)));
355 }
356 }
357
358 dprintf("NtClose:\n");
360 dprintf(" Status = %lx\n", Status);
361}
Type
Definition: Type.h:7
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1444
unsigned long DWORD
Definition: ntddk_ex.h:95
#define REG_SZ
Definition: layer.c:22
@ KeyValueFullInformation
Definition: nt_native.h:1181
NTSTATUS NTAPI NtEnumerateValueKey(IN HANDLE KeyHandle, IN ULONG Index, IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, OUT PVOID KeyValueInformation, IN ULONG Length, OUT PULONG ResultLength)
Definition: ntapi.c:542
#define REG_DWORD
Definition: sdbapi.c:596

Referenced by main().

◆ main()

int main ( int argc  ,
char argv[] 
)

Definition at line 975 of file hivetest.c.

976{
977 char Buffer[10];
979
980 AllocConsole();
983 while(1)
984 {
985 dprintf("choose test :\n");
986 dprintf(" 0 = Exit\n");
987 dprintf(" 1 = Create key\n");
988 dprintf(" 2 = Delete key\n");
989 dprintf(" 3 = Enumerate key\n");
990 dprintf(" 4 = Set value (REG_SZ)\n");
991 dprintf(" 5 = Set value (REG_DWORD)\n");
992 dprintf(" 6 = Delete value\n");
993 dprintf(" 7 = Enumerate value\n");
995 switch (Buffer[0])
996 {
997 case '0':
998 return(0);
999
1000 case '1':
1001 CreateKeyTest();
1002 break;
1003
1004 case '2':
1005 DeleteKeyTest();
1006 break;
1007
1008 case '3':
1010 break;
1011
1012 case '4':
1013 SetValueTest1();
1014 break;
1015
1016 case '5':
1017 SetValueTest2();
1018 break;
1019
1020 case '6':
1022 break;
1023
1024 case '7':
1026 break;
1027 }
1028 }
1029 return(0);
1030}
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:203
BOOL WINAPI AllocConsole(VOID)
Definition: console.c:74
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleA(IN HANDLE hConsoleInput, OUT LPVOID lpBuffer, IN DWORD nNumberOfCharsToRead, OUT LPDWORD lpNumberOfCharsRead, IN PCONSOLE_READCONSOLE_CONTROL pInputControl OPTIONAL)
Definition: readwrite.c:1195
void DeleteValueTest(void)
Definition: hivetest.c:270
HANDLE InputHandle
Definition: hivetest.c:18
void DeleteKeyTest(void)
Definition: hivetest.c:93
void SetValueTest1(void)
Definition: hivetest.c:189
void SetValueTest2(void)
Definition: hivetest.c:230
void EnumerateValueTest(void)
Definition: hivetest.c:305
void EnumerateKeyTest(void)
Definition: hivetest.c:122
void CreateKeyTest(void)
Definition: hivetest.c:63
#define STD_OUTPUT_HANDLE
Definition: winbase.h:268
#define STD_INPUT_HANDLE
Definition: winbase.h:267
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

◆ SetValueTest1()

void SetValueTest1 ( void  )

Definition at line 189 of file hivetest.c.

190{
191 HANDLE hKey;
193 UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\Software\\testkey");
196
197 dprintf("Create key '\\Registry\\Machine\\Software\\testkey':\n");
198
200 &KeyName,
202 NULL,
203 NULL);
204 dprintf("NtCreateKey:\n");
208 0,
209 NULL,
211 NULL);
212 dprintf(" Status = %lx\n",Status);
213 if (!NT_SUCCESS(Status))
214 return;
215
216
217 dprintf("NtSetValueKey:\n");
219 &ValueName,
220 0,
221 REG_SZ,
222 (PVOID)L"TestString",
223 24);
224 dprintf(" Status = %lx\n",Status);
225
226 NtClose(hKey);
227}
#define OBJ_OPENIF
Definition: winternl.h:229
NTSYSAPI NTSTATUS NTAPI NtSetValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN ULONG TitleIndex OPTIONAL, IN ULONG Type, IN PVOID Data, IN ULONG DataSize)
Definition: ntapi.c:859

Referenced by main().

◆ SetValueTest2()

void SetValueTest2 ( void  )

Definition at line 230 of file hivetest.c.

231{
232 HANDLE hKey;
234 UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\Software\\testkey");
237
238 dprintf("Create key '\\Registry\\Machine\\Software\\testkey':\n");
239
241 &KeyName,
243 NULL,
244 NULL);
245 dprintf("NtCreateKey:\n");
249 0,
250 NULL,
252 NULL);
253 dprintf(" Status = %lx\n",Status);
254 if (!NT_SUCCESS(Status))
255 return;
256
257 dprintf("NtSetValueKey:\n");
259 &ValueName,
260 0,
261 REG_DWORD,
262 (PVOID)"reac",
263 4);
264 dprintf(" Status = %lx\n",Status);
265
266 NtClose(hKey);
267}

Referenced by main().

◆ test1()

void test1 ( void  )

Definition at line 366 of file hivetest.c.

367{
368 HANDLE hKey = NULL, hKey1;
371 UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\Software");
373 KEY_BASIC_INFORMATION KeyInformation[5];
374
375#if 0
376 dprintf("NtOpenKey \\Registry : ");
377#endif
378 dprintf("NtOpenKey \\Registry\\Machine\\Software : ");
380 &KeyName,
382 NULL,
383 NULL);
385 dprintf("\t\t\t\tStatus =%x\n",Status);
386 if(Status==0)
387 {
388 dprintf("NtQueryKey : ");
390 ,&KeyInformation[0], sizeof(KeyInformation)
391 ,&Length);
392 dprintf("\t\t\t\t\tStatus =%x\n",Status);
393 if (Status == STATUS_SUCCESS)
394 {
395 dprintf("\tKey Name = ");
396 for (i=0;i<KeyInformation[0].NameLength/2;i++)
397 dprintf("%C",KeyInformation[0].Name[i]);
398 dprintf("\n");
399 }
400 dprintf("NtEnumerateKey : \n");
401 Index=0;
402 while(Status == STATUS_SUCCESS)
403 {
405 ,&KeyInformation[0], sizeof(KeyInformation)
406 ,&Length);
408 {
409 dprintf("\tSubKey Name = ");
410 for (i=0;i<KeyInformation[0].NameLength/2;i++)
411 dprintf("%C",KeyInformation[0].Name[i]);
412 dprintf("\n");
413 }
414 }
415 dprintf("NtClose : ");
416 Status = NtClose( hKey1 );
417 dprintf("\t\t\t\t\tStatus =%x\n",Status);
418 }
419 NtClose(hKey);
420}

◆ test3()

void test3 ( void  )

Definition at line 423 of file hivetest.c.

424{
425 HANDLE hKey;
429 char Buffer[10];
431 dprintf("NtCreateKey non volatile: \n");
432 dprintf(" \\Registry\\Machine\\Software\\test3reactos: ");
433 RtlRosInitUnicodeStringFromLiteral(&KeyName, L"\\Registry\\Machine\\Software\\test3reactos");
435 , NULL, NULL);
438 dprintf("\t\tStatus=%x\n",Status);
439 NtClose(hKey);
440
441 dprintf("delete \\Registry\\Machine\\software\\test3reactos ?");
443 if (Buffer[0] != 'y' && Buffer[0] != 'Y') return;
444
445 dprintf("delete \\Registry\\Machine\\software\\test3reactos ?");
446 RtlRosInitUnicodeStringFromLiteral(&KeyName, L"\\Registry\\Machine\\Software\\test3reactos");
448 &KeyName,
450 NULL,
451 NULL);
452 dprintf("NtOpenKey : ");
454 dprintf("\t\t\t\tStatus =%x\n",Status);
455 dprintf("NtDeleteKey : ");
457 dprintf("\t\t\t\tStatus =%x\n",Status);
458 NtClose(hKey);
459}
#define RtlRosInitUnicodeStringFromLiteral(__Name__, __Value__)
Definition: hivetest.c:10

◆ test4()

void test4 ( void  )

Definition at line 461 of file hivetest.c.

462{
463 HKEY hKey = NULL,hKey1;
464 DWORD dwDisposition;
465 DWORD dwError;
466 DWORD RegDataType, RegDataSize;
467 BOOL GlobalFifoEnable;
468 HKEY hPortKey;
469 DWORD RegDisposition;
470 WCHAR szClass[260];
471 DWORD cchClass;
472 DWORD cSubKeys;
473 DWORD cchMaxSubkey;
474 DWORD cchMaxClass;
475 DWORD cValues;
476 DWORD cchMaxValueName;
477 DWORD cbMaxValueData;
478 DWORD cbSecurityDescriptor;
479 FILETIME ftLastWriteTime;
480 SYSTEMTIME LastWriteTime;
481
482 dprintf ("RegOpenKeyExW HKLM\\System\\Setup: ");
484 L"System\\Setup",
485 0,
487 &hKey1);
488 dprintf("\t\tdwError =%x\n",dwError);
489 if (dwError == ERROR_SUCCESS)
490 {
491 dprintf("RegQueryInfoKeyW: ");
492 cchClass=260;
493 dwError = RegQueryInfoKeyW(hKey1
494 , szClass, &cchClass, NULL, &cSubKeys
495 , &cchMaxSubkey, &cchMaxClass, &cValues, &cchMaxValueName
496 , &cbMaxValueData, &cbSecurityDescriptor, &ftLastWriteTime);
497 dprintf ("\t\t\t\tdwError %x\n", dwError);
498 FileTimeToSystemTime(&ftLastWriteTime,&LastWriteTime);
499 dprintf ("\tnb of subkeys=%d,last write : %d/%d/%d %d:%02.2d'%02.2d''%03.3d\n",cSubKeys
500 ,LastWriteTime.wMonth
501 ,LastWriteTime.wDay
502 ,LastWriteTime.wYear
503 ,LastWriteTime.wHour
504 ,LastWriteTime.wMinute
505 ,LastWriteTime.wSecond
506 ,LastWriteTime.wMilliseconds
507 );
508 }
509
510
511 dprintf ("RegOpenKeyExW: ");
513 L"System\\ControlSet001\\Services\\Serial",
514 0,
516 &hKey);
517 dprintf ("\t\t\t\t\tdwError %x\n", dwError);
518 RegDataSize = sizeof(GlobalFifoEnable);
519 if (dwError == ERROR_SUCCESS)
520 {
521 dprintf ("RegQueryValueExW: ");
522 dwError = RegQueryValueExW(hKey,
523 L"ForceFifoEnable",
524 NULL,
525 &RegDataType,
526 (PBYTE)&GlobalFifoEnable,
527 &RegDataSize);
528 dprintf("\t\t\t\tdwError =%x\n",dwError);
529 if (dwError == 0)
530 {
531 dprintf("\tValue:DT=%d, DS=%d, Value=%d\n"
532 ,RegDataType
533 ,RegDataSize
534 ,GlobalFifoEnable);
535 }
536 }
537 dprintf ("RegCreateKeyExW: ");
538 dwError = RegCreateKeyExW(hKey,
539 L"Parameters\\Serial001",
540 0,
541 NULL,
542 0,
544 NULL,
545 &hPortKey,
546 &RegDisposition
547 );
548 dprintf ("\t\t\t\tdwError %x\n", dwError);
549
550 dprintf ("RegCreateKeyExW: ");
552 L"Software\\test4reactos\\test",
553 0,
554 NULL,
557 NULL,
558 &hKey,
559 &dwDisposition);
560
561 dprintf ("\t\t\t\tdwError %x ", dwError);
562 dprintf ("dwDisposition %x\n", dwDisposition);
563 if (dwError == ERROR_SUCCESS)
564 {
565 dprintf ("RegSetValueExW: ");
566 dwError = RegSetValueExW (hKey,
567 L"TestValue",
568 0,
569 REG_SZ,
570 (BYTE*)L"TestString",
571 20);
572
573 dprintf ("\t\t\t\tdwError %x\n", dwError);
574 dprintf ("RegCloseKey: ");
575 dwError = RegCloseKey (hKey);
576 dprintf ("\t\t\t\t\tdwError %x\n", dwError);
577 }
578 dprintf ("\n\n");
579
580 hKey = NULL;
581
582 dprintf ("RegCreateKeyExW: ");
584 L"software\\Test",
585 0,
586 NULL,
589 NULL,
590 &hKey,
591 &dwDisposition);
592
593 dprintf ("\t\t\t\tdwError %x ", dwError);
594 dprintf ("dwDisposition %x\n", dwDisposition);
595
596
597 if (dwError == ERROR_SUCCESS)
598 {
599 dprintf("RegQueryInfoKeyW: ");
600 cchClass=260;
601 dwError = RegQueryInfoKeyW(hKey
602 , szClass, &cchClass, NULL, &cSubKeys
603 , &cchMaxSubkey, &cchMaxClass, &cValues, &cchMaxValueName
604 , &cbMaxValueData, &cbSecurityDescriptor, &ftLastWriteTime);
605 dprintf ("\t\t\t\tdwError %x\n", dwError);
606 FileTimeToSystemTime(&ftLastWriteTime,&LastWriteTime);
607 dprintf ("\tnb of subkeys=%d,last write : %d/%d/%d %d:%02.2d'%02.2d''%03.3d\n",cSubKeys
608 ,LastWriteTime.wMonth
609 ,LastWriteTime.wDay
610 ,LastWriteTime.wYear
611 ,LastWriteTime.wHour
612 ,LastWriteTime.wMinute
613 ,LastWriteTime.wSecond
614 ,LastWriteTime.wMilliseconds
615 );
616 dprintf ("RegCloseKey: ");
617 dwError = RegCloseKey (hKey);
618 dprintf ("\t\t\t\t\tdwError %x\n", dwError);
619 }
620 dprintf ("\nTests done...\n");
621}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3662
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
unsigned int BOOL
Definition: ntddk_ex.h:94
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1060
BYTE * PBYTE
Definition: pedump.c:66
WORD wYear
Definition: winbase.h:905
WORD wMilliseconds
Definition: winbase.h:912
WORD wMonth
Definition: winbase.h:906
WORD wHour
Definition: winbase.h:909
WORD wSecond
Definition: winbase.h:911
WORD wMinute
Definition: winbase.h:910
WORD wDay
Definition: winbase.h:908
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
unsigned char BYTE
Definition: xxhash.c:193

◆ test5()

void test5 ( void  )

Definition at line 623 of file hivetest.c.

624{
625 HANDLE hKey;
629
630 dprintf("NtOpenKey : \n");
631 dprintf(" \\Registry\\Machine\\Software\\reactos : ");
632 RtlRosInitUnicodeStringFromLiteral(&KeyName,L"\\Registry\\Machine\\Software\\reactos");
634 , NULL, NULL);
636 dprintf("\t\tStatus=%x\n",Status);
637 dprintf("NtFlushKey : \n");
639 dprintf("\t\tStatus=%x\n",Status);
640 dprintf("NtCloseKey : \n");
642 dprintf("\t\tStatus=%x\n",Status);
643}
NTSTATUS NTAPI NtFlushKey(IN HANDLE KeyHandle)
Definition: ntapi.c:1085

◆ test6()

void test6 ( void  )

Definition at line 646 of file hivetest.c.

647{
648 HANDLE hKey;
652 KEY_VALUE_FULL_INFORMATION KeyValueInformation[5];
653 ULONG Length,i;
654
655 dprintf("Create target key\n");
656 dprintf(" Key: \\Registry\\Machine\\SOFTWARE\\Reactos\n");
657 RtlRosInitUnicodeStringFromLiteral(&KeyName, L"\\Registry\\Machine\\SOFTWARE\\Reactos");
659 , NULL, NULL);
662 dprintf(" NtCreateKey() called (Status %lx)\n",Status);
663 if (!NT_SUCCESS(Status))
664 return;
665
666 dprintf("Create target value\n");
667 dprintf(" Value: TestValue = 'Test String'\n");
669 Status=NtSetValueKey(hKey,&ValueName,0,REG_SZ,(PVOID)L"TestString",22);
670 dprintf(" NtSetValueKey() called (Status %lx)\n",Status);
671 if (!NT_SUCCESS(Status))
672 return;
673
674 dprintf("Close target key\n");
675 NtClose(hKey);
676
677
678 dprintf("Create link key\n");
679 dprintf(" Key: \\Registry\\Machine\\SOFTWARE\\Test\n");
680 RtlRosInitUnicodeStringFromLiteral(&KeyName, L"\\Registry\\Machine\\SOFTWARE\\Test");
682 &KeyName,
684 NULL,
685 NULL);
689 0,
690 NULL,
692 NULL);
693 dprintf(" NtCreateKey() called (Status %lx)\n",Status);
694 if (!NT_SUCCESS(Status))
695 return;
696
697 dprintf("Create link value\n");
698 dprintf(" Value: SymbolicLinkValue = '\\Registry\\Machine\\SOFTWARE\\Reactos'\n");
699 RtlRosInitUnicodeStringFromLiteral(&ValueName, L"SymbolicLinkValue");
700 Status=NtSetValueKey(hKey,&ValueName,0,REG_LINK,(PVOID)L"\\Registry\\Machine\\SOFTWARE\\Reactos",68);
701 dprintf(" NtSetValueKey() called (Status %lx)\n",Status);
702 if (!NT_SUCCESS(Status))
703 {
704 dprintf("Creating link value failed! Test failed!\n");
705 NtClose(hKey);
706 return;
707 }
708
709 dprintf("Close link key\n");
710 NtClose(hKey);
711
712 dprintf("Open link key\n");
713 dprintf(" Key: \\Registry\\Machine\\SOFTWARE\\Test\n");
714 RtlRosInitUnicodeStringFromLiteral(&KeyName, L"\\Registry\\Machine\\SOFTWARE\\Test");
716 , NULL, NULL);
719 dprintf(" NtCreateKey() called (Status %lx)\n",Status);
720 if (!NT_SUCCESS(Status))
721 return;
722
723 dprintf("Query value\n");
724 dprintf(" Value: TestValue\n");
727 &ValueName,
729 &KeyValueInformation[0],
730 sizeof(KeyValueInformation),
731 &Length);
732 dprintf(" NtQueryValueKey() called (Status %lx)\n",Status);
733 if (Status == STATUS_SUCCESS)
734 {
735 dprintf(" Value: Type %d DataLength %d NameLength %d Name '",
736 KeyValueInformation[0].Type,
737 KeyValueInformation[0].DataLength,
738 KeyValueInformation[0].NameLength);
739 for (i=0; i < KeyValueInformation[0].NameLength / sizeof(WCHAR); i++)
740 dprintf("%C",KeyValueInformation[0].Name[i]);
741 dprintf("'\n");
742 if (KeyValueInformation[0].Type == REG_SZ)
743 dprintf(" Value '%S'\n",
744 KeyValueInformation[0].Name+1
745 +KeyValueInformation[0].NameLength/2);
746 }
747
748 dprintf("Close link key\n");
749 NtClose(hKey);
750
751 dprintf("Test successful!\n");
752}
#define OBJ_OPENLINK
Definition: winternl.h:230
#define REG_OPTION_CREATE_LINK
Definition: nt_native.h:1063
NTSYSAPI NTSTATUS NTAPI NtQueryValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, IN PVOID KeyValueInformation, IN ULONG Length, IN PULONG ResultLength)
#define REG_LINK
Definition: nt_native.h:1500
#define KEY_CREATE_LINK
Definition: nt_native.h:1021

◆ test7()

void test7 ( void  )

Definition at line 755 of file hivetest.c.

756{
757 HANDLE hKey;
761
762 dprintf("Open link key\n");
763 dprintf(" Key: \\Registry\\Machine\\SOFTWARE\\Test\n");
764 RtlRosInitUnicodeStringFromLiteral(&KeyName, L"\\Registry\\Machine\\SOFTWARE\\Test");
766 &KeyName,
768 NULL,
769 NULL);
773 0,
774 NULL,
776 NULL);
777 dprintf(" NtCreateKey() called (Status %lx)\n",Status);
778 if (!NT_SUCCESS(Status))
779 {
780 dprintf("Could not open the link key. Please run the link create test first!\n");
781 return;
782 }
783
784 dprintf("Delete link value\n");
785 RtlRosInitUnicodeStringFromLiteral(&ValueName, L"SymbolicLinkValue");
787 &ValueName);
788 dprintf(" NtDeleteValueKey() called (Status %lx)\n",Status);
789
790 dprintf("Delete link key\n");
792 dprintf(" NtDeleteKey() called (Status %lx)\n",Status);
793
794 dprintf("Close link key\n");
795 NtClose(hKey);
796}
#define REG_OPTION_OPEN_LINK
Definition: nt_native.h:1070

◆ test8()

void test8 ( void  )

Definition at line 799 of file hivetest.c.

800{
804 LONG dwError;
805 TOKEN_PRIVILEGES NewPrivileges;
807 LUID Luid = {0};
808 BOOLEAN bRes;
811// ,TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&Token);
812 dprintf("\t\t\t\tStatus =%x\n",Status);
813// bRes=LookupPrivilegeValueA(NULL,SE_RESTORE_NAME,&Luid);
814// dprintf("\t\t\t\tbRes =%x\n",bRes);
815 NewPrivileges.PrivilegeCount = 1;
816 NewPrivileges.Privileges[0].Luid = Luid;
817// NewPrivileges.Privileges[0].Luid.u.LowPart=18;
818// NewPrivileges.Privileges[0].Luid.u.HighPart=0;
819 NewPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
820
821// Status = NtAdjustPrivilegesToken(
823 Token,
824 FALSE,
825 &NewPrivileges,
826 0,
827 NULL,
828 NULL
829 );
830 dprintf("\t\t\t\tbRes =%x\n",bRes);
831
832// Status=NtClose(Token);
833// dprintf("\t\t\t\tStatus =%x\n",Status);
834
835
838 , NULL, NULL);
840 dprintf("\t\t\t\tStatus =%x\n",Status);
841 dwError=RegLoadKey(HKEY_LOCAL_MACHINE,"def"
842 ,"test5");
843 dprintf("\t\t\t\tdwError =%x\n",dwError);
844
845 dprintf("NtOpenKey \\Registry\\Machine : ");
846 RtlRosInitUnicodeStringFromLiteral(&KeyName, L"\\Registry\\Machine");
848 &KeyName,
850 NULL,
851 NULL);
853 dprintf("\t\t\tStatus =%x\n",Status);
856 , NULL, NULL);
858 dprintf("\t\t\t\tStatus =%x\n",Status);
859}
unsigned char BOOLEAN
#define FALSE
Definition: types.h:117
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:374
#define GetCurrentProcess()
Definition: compat.h:759
NTSTATUS NTAPI NtLoadKey(IN POBJECT_ATTRIBUTES KeyObjectAttributes, IN POBJECT_ATTRIBUTES FileObjectAttributes)
Definition: ntapi.c:1129
NTSTATUS NTAPI NtOpenProcessToken(IN HANDLE ProcessHandle, IN ACCESS_MASK DesiredAccess, OUT PHANDLE TokenHandle)
Definition: security.c:350
long LONG
Definition: pedump.c:60
$ULONG PrivilegeCount
Definition: setypes.h:1023
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]
Definition: setypes.h:1024
#define RegLoadKey
Definition: winreg.h:515
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:930
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63

◆ test9()

void test9 ( void  )

Definition at line 861 of file hivetest.c.

862{
863 HANDLE hKey = NULL, hKey1;
868 KEY_BASIC_INFORMATION KeyInformation[5];
869 KEY_VALUE_FULL_INFORMATION KeyValueInformation[5];
870
871 dprintf("NtOpenKey \\Registry : ");
873 &KeyName,
875 NULL,
876 NULL);
878 dprintf("\t\t\t\tStatus =%x\n",Status);
879 if (Status == 0) {
880 dprintf("NtQueryKey : ");
881 Status = NtQueryKey(hKey1, KeyBasicInformation, &KeyInformation[0], sizeof(KeyInformation), &Length);
882 dprintf("\t\t\t\t\tStatus =%x\n",Status);
883 if (Status == STATUS_SUCCESS) {
884 dprintf("\tKey Name = ");
885 for (i=0;i<KeyInformation[0].NameLength/2;i++)
886 dprintf("%C",KeyInformation[0].Name[i]);
887 dprintf("\n");
888 }
889
890 dprintf("NtEnumerateKey : \n");
891 Index = 0;
892 while (Status == STATUS_SUCCESS) {
893 Status = NtEnumerateKey(hKey1,Index++,KeyBasicInformation,&KeyInformation[0], sizeof(KeyInformation),&Length);
894 if (Status == STATUS_SUCCESS) {
895 dprintf("\tSubKey Name = ");
896 for (i = 0; i < KeyInformation[0].NameLength / 2; i++)
897 dprintf("%C",KeyInformation[0].Name[i]);
898 dprintf("\n");
899 }
900 }
901 dprintf("NtClose : ");
902 Status = NtClose( hKey1 );
903 dprintf("\t\t\t\t\tStatus =%x\n",Status);
904 }
905 NtClose(hKey); // RobD - hKey unused so-far, should this have been hKey1 ???
906
907 dprintf("NtOpenKey \\Registry\\Machine : ");
908 RtlRosInitUnicodeStringFromLiteral(&KeyName, L"\\Registry\\Machine");
910 &KeyName,
912 NULL,
913 NULL);
915 dprintf("\t\t\tStatus =%x\n",Status);
916
917//Status of c0000001 opening \Registry\Machine\System\CurrentControlSet\Services\Tcpip\Linkage
918
919// dprintf("NtOpenKey System\\CurrentControlSet\\Services\\Tcpip : ");
920// RtlRosInitUnicodeStringFromLiteral(&KeyName, L"System\\CurrentControlSet\\Services\\Tcpip");
921#if 1
922 dprintf("NtOpenKey System\\ControlSet001\\Services\\Tcpip\\Parameters : ");
923 RtlRosInitUnicodeStringFromLiteral(&KeyName, L"System\\ControlSet001\\Services\\Tcpip\\Parameters");
924#else
925 dprintf("NtOpenKey System\\CurrentControlSet\\Services\\Tcpip : ");
926 RtlRosInitUnicodeStringFromLiteral(&KeyName, L"System\\CurrentControlSet\\Services\\Tcpip");
927#endif
930 dprintf("\t\t\tStatus =%x\n",Status);
931 if (Status == 0) {
932 dprintf("NtQueryValueKey : ");
934 Status = NtQueryValueKey(hKey, &KeyName, KeyValueFullInformation, &KeyValueInformation[0], sizeof(KeyValueInformation), &Length);
935 dprintf("\t\t\t\tStatus =%x\n",Status);
936 if (Status == STATUS_SUCCESS) {
937 dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
938 ,KeyValueInformation[0].DataOffset
939 ,KeyValueInformation[0].DataLength
940 ,KeyValueInformation[0].NameLength);
941 for (i = 0; i < 10 && i < KeyValueInformation[0].NameLength / 2; i++)
942 dprintf("%C", KeyValueInformation[0].Name[i]);
943 dprintf("\n");
944 dprintf("\t\tType = %d\n", KeyValueInformation[0].Type);
945 if (KeyValueInformation[0].Type == REG_SZ)
946 //dprintf("\t\tValue = %S\n", KeyValueInformation[0].Name + 1 + KeyValueInformation[0].NameLength / 2);
947 dprintf("\t\tValue = %S\n", KeyValueInformation[0].Name + KeyValueInformation[0].NameLength / 2);
948 }
949 dprintf("NtEnumerateValueKey : \n");
950 Index = 0;
951 while (Status == STATUS_SUCCESS) {
952 Status = NtEnumerateValueKey(hKey, Index++, KeyValueFullInformation, &KeyValueInformation[0], sizeof(KeyValueInformation), &Length);
953 if (Status == STATUS_SUCCESS) {
954 dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
955 ,KeyValueInformation[0].DataOffset
956 ,KeyValueInformation[0].DataLength
957 ,KeyValueInformation[0].NameLength);
958 for (i = 0; i < KeyValueInformation[0].NameLength / 2; i++)
959 dprintf("%C", KeyValueInformation[0].Name[i]);
960 dprintf(", Type = %d\n", KeyValueInformation[0].Type);
961 if (KeyValueInformation[0].Type == REG_SZ)
962 dprintf("\t\tValue = %S\n", ((char*)&KeyValueInformation[0]+KeyValueInformation[0].DataOffset));
963 if (KeyValueInformation[0].Type == REG_DWORD)
964 dprintf("\t\tValue = %X\n", *((DWORD*)((char*)&KeyValueInformation[0]+KeyValueInformation[0].DataOffset)));
965 }
966 }
967 dprintf("NtClose : ");
969 dprintf("\t\t\t\t\tStatus =%x\n", Status);
970 }
971 NtClose(hKey1);
972}
#define KEY_READ
Definition: nt_native.h:1023

Variable Documentation

◆ InputHandle

HANDLE InputHandle

Definition at line 18 of file hivetest.c.

Referenced by main(), and test3().

◆ OutputHandle

HANDLE OutputHandle

Definition at line 17 of file hivetest.c.

Referenced by dprintf(), and main().