10 void dprintf(char* fmt
, ...)
16 vsprintf(buffer
,fmt
,args
);
17 WriteConsoleA(OutputHandle
, buffer
, strlen(buffer
), NULL
, NULL
);
21 void do_enumeratekey(PWSTR Name
)
24 KEY_BASIC_INFORMATION KeyInformation
[5];
26 OBJECT_ATTRIBUTES ObjectAttributes
;
28 UNICODE_STRING KeyName
;
30 RtlInitUnicodeString(&KeyName
, Name
);
31 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
33 Status
=NtOpenKey( &hKey1
, MAXIMUM_ALLOWED
, &ObjectAttributes
);
34 dprintf("NtEnumerateKey : \n");
36 while(Status
== STATUS_SUCCESS
)
38 Status
=NtEnumerateKey(hKey1
,Index
++,KeyBasicInformation
39 ,&KeyInformation
[0], sizeof(KeyInformation
)
41 if(Status
== STATUS_SUCCESS
)
43 dprintf("\tSubKey Name = ");
44 for (i
=0;i
<KeyInformation
[0].NameLength
/2;i
++)
45 dprintf("%C",KeyInformation
[0].Name
[i
]);
54 HKEY hKey
= NULL
,hKey1
;
55 OBJECT_ATTRIBUTES ObjectAttributes
;
57 UNICODE_STRING KeyName
= UNICODE_STRING_INITIALIZER(L
"\\Registry");
59 KEY_BASIC_INFORMATION KeyInformation
[5];
60 KEY_VALUE_FULL_INFORMATION KeyValueInformation
[5];
62 dprintf("NtOpenKey \\Registry : ");
63 InitializeObjectAttributes(&ObjectAttributes
,
68 Status
=NtOpenKey( &hKey1
, MAXIMUM_ALLOWED
, &ObjectAttributes
);
69 dprintf("\t\t\t\tStatus =%x\n",Status
);
72 dprintf("NtQueryKey : ");
73 Status
=NtQueryKey(hKey1
,KeyBasicInformation
74 ,&KeyInformation
[0], sizeof(KeyInformation
)
76 dprintf("\t\t\t\t\tStatus =%x\n",Status
);
77 if (Status
== STATUS_SUCCESS
)
79 dprintf("\tKey Name = ");
80 for (i
=0;i
<KeyInformation
[0].NameLength
/2;i
++)
81 dprintf("%C",KeyInformation
[0].Name
[i
]);
84 dprintf("NtEnumerateKey : \n");
86 while(Status
== STATUS_SUCCESS
)
88 Status
=NtEnumerateKey(hKey1
,Index
++,KeyBasicInformation
89 ,&KeyInformation
[0], sizeof(KeyInformation
)
91 if(Status
== STATUS_SUCCESS
)
93 dprintf("\tSubKey Name = ");
94 for (i
=0;i
<KeyInformation
[0].NameLength
/2;i
++)
95 dprintf("%C",KeyInformation
[0].Name
[i
]);
99 dprintf("NtClose : ");
100 Status
= NtClose( hKey1
);
101 dprintf("\t\t\t\t\tStatus =%x\n",Status
);
105 dprintf("NtOpenKey \\Registry\\Machine : ");
106 RtlInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine");
107 InitializeObjectAttributes(&ObjectAttributes
,
109 OBJ_CASE_INSENSITIVE
,
112 Status
=NtOpenKey( &hKey1
, MAXIMUM_ALLOWED
, &ObjectAttributes
);
113 dprintf("\t\t\tStatus =%x\n",Status
);
115 dprintf("NtOpenKey System\\Setup : ");
116 RtlInitUnicodeStringFromLiteral(&KeyName
, L
"System\\Setup");
117 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
119 Status
= NtOpenKey ( &hKey
, KEY_READ
, &ObjectAttributes
);
120 dprintf("\t\t\tStatus =%x\n",Status
);
123 dprintf("NtQueryValueKey : ");
124 RtlInitUnicodeStringFromLiteral(&KeyName
, L
"CmdLine");
125 Status
=NtQueryValueKey(hKey
,&KeyName
,KeyValueFullInformation
126 ,&KeyValueInformation
[0], sizeof(KeyValueInformation
)
128 dprintf("\t\t\t\tStatus =%x\n",Status
);
129 if (Status
== STATUS_SUCCESS
)
131 dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
132 ,KeyValueInformation
[0].DataOffset
133 ,KeyValueInformation
[0].DataLength
134 ,KeyValueInformation
[0].NameLength
);
135 for (i
=0;i
<10 && i
<KeyValueInformation
[0].NameLength
/2;i
++)
136 dprintf("%C",KeyValueInformation
[0].Name
[i
]);
138 dprintf("\t\tType = %d\n",KeyValueInformation
[0].Type
);
139 if (KeyValueInformation
[0].Type
== REG_SZ
)
140 dprintf("\t\tValue = %S\n",KeyValueInformation
[0].Name
+1
141 +KeyValueInformation
[0].NameLength
/2);
143 dprintf("NtEnumerateValueKey : \n");
145 while(Status
== STATUS_SUCCESS
)
147 Status
=NtEnumerateValueKey(hKey
,Index
++,KeyValueFullInformation
148 ,&KeyValueInformation
[0], sizeof(KeyValueInformation
)
150 if(Status
== STATUS_SUCCESS
)
152 dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
153 ,KeyValueInformation
[0].DataOffset
154 ,KeyValueInformation
[0].DataLength
155 ,KeyValueInformation
[0].NameLength
);
156 for (i
=0;i
<KeyValueInformation
[0].NameLength
/2;i
++)
157 dprintf("%C",KeyValueInformation
[0].Name
[i
]);
158 dprintf(", Type = %d\n",KeyValueInformation
[0].Type
);
159 if (KeyValueInformation
[0].Type
== REG_SZ
)
160 dprintf("\t\tValue = %S\n",((char*)&KeyValueInformation
[0]
161 +KeyValueInformation
[0].DataOffset
));
164 dprintf("NtClose : ");
165 Status
= NtClose( hKey
);
166 dprintf("\t\t\t\t\tStatus =%x\n",Status
);
175 OBJECT_ATTRIBUTES ObjectAttributes
;
176 UNICODE_STRING KeyName
,ValueName
;
178 KEY_VALUE_FULL_INFORMATION KeyValueInformation
[5];
179 ULONG Index
,Length
,i
;
182 dprintf("NtCreateKey volatile: \n");
183 dprintf(" \\Registry\\Machine\\Software\\test2reactos: ");
184 RtlInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\Software\\test2reactos");
185 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
187 Status
= NtCreateKey ( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
188 ,0,NULL
,REG_OPTION_VOLATILE
,NULL
);
189 dprintf("\t\tStatus=%x\n",Status
);
191 do_enumeratekey(L
"\\Registry\\Machine\\Software");
192 dprintf(" ...\\test2 :");
193 RtlInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\Software\\test2reactos\\test2");
194 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
196 Status
= NtCreateKey ( &hKey1
, KEY_ALL_ACCESS
, &ObjectAttributes
197 ,0,NULL
,REG_OPTION_VOLATILE
,NULL
);
198 dprintf("\t\t\t\t\tStatus=%x\n",Status
);
199 dprintf(" ...\\TestVolatile :");
200 RtlInitUnicodeStringFromLiteral(&KeyName
, L
"TestVolatile");
201 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
203 Status
= NtCreateKey ( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
204 ,0,NULL
,REG_OPTION_VOLATILE
,NULL
);
205 dprintf("\t\t\t\tStatus=%x\n",Status
);
207 RtlInitUnicodeStringFromLiteral(&ValueName
, L
"TestREG_SZ");
208 dprintf("NtSetValueKey reg_sz: ");
209 Status
=NtSetValueKey(hKey
,&ValueName
,0,REG_SZ
,(PVOID
)L
"Test Reg_sz",24);
210 dprintf("\t\t\t\tStatus=%x\n",Status
);
211 RtlInitUnicodeStringFromLiteral(&ValueName
, L
"TestDWORD");
212 dprintf("NtSetValueKey reg_dword: ");
213 Status
=NtSetValueKey(hKey
,&ValueName
,0,REG_DWORD
,(PVOID
)"reac",4);
214 dprintf("\t\t\tStatus=%x\n",Status
);
216 dprintf("NtOpenKey \\Registry\\Machine\\Software\\test2reactos\\test2\\TestVolatile : ");
217 RtlInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\Software\\test2reactos\\test2\\TestVolatile");
218 InitializeObjectAttributes(&ObjectAttributes
,
220 OBJ_CASE_INSENSITIVE
,
223 Status
=NtOpenKey( &hKey
, MAXIMUM_ALLOWED
, &ObjectAttributes
);
224 dprintf("\t\t\t\tStatus =%x\n",Status
);
227 dprintf("NtEnumerateValueKey : \n");
229 while(Status
== STATUS_SUCCESS
)
231 Status
=NtEnumerateValueKey(hKey
,Index
++,KeyValueFullInformation
232 ,&KeyValueInformation
[0], sizeof(KeyValueInformation
)
234 if(Status
== STATUS_SUCCESS
)
236 dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
237 ,KeyValueInformation
[0].DataOffset
238 ,KeyValueInformation
[0].DataLength
239 ,KeyValueInformation
[0].NameLength
);
240 for (i
=0;i
<KeyValueInformation
[0].NameLength
/2;i
++)
241 dprintf("%C",KeyValueInformation
[0].Name
[i
]);
242 dprintf(", Type = %d\n",KeyValueInformation
[0].Type
);
243 if (KeyValueInformation
[0].Type
== REG_SZ
)
244 dprintf("\t\tValue = %S\n",((char*)&KeyValueInformation
[0]
245 +KeyValueInformation
[0].DataOffset
));
250 dprintf("delete \\Registry\\Machine\\software\\test2reactos ?");
251 ReadConsoleA(InputHandle
, Buffer
, 3, &Result
, NULL
) ;
252 if (Buffer
[0] != 'y' && Buffer
[0] != 'Y') return;
253 RtlInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\Software\\test2reactos\\test2\\TestVolatile");
254 InitializeObjectAttributes(&ObjectAttributes
,
256 OBJ_CASE_INSENSITIVE
,
259 dprintf("NtOpenKey : ");
260 Status
=NtOpenKey( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
);
261 dprintf("\t\t\t\tStatus =%x\n",Status
);
262 dprintf("NtDeleteKey : ");
263 Status
=NtDeleteKey(hKey
);
264 dprintf("\t\t\t\tStatus =%x\n",Status
);
266 RtlInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\Software\\test2reactos\\test2");
267 InitializeObjectAttributes(&ObjectAttributes
,
269 OBJ_CASE_INSENSITIVE
,
272 dprintf("NtOpenKey : ");
273 Status
=NtOpenKey( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
);
274 dprintf("\t\t\t\tStatus =%x\n",Status
);
275 dprintf("NtDeleteKey : ");
276 Status
=NtDeleteKey(hKey
);
277 dprintf("\t\t\t\tStatus =%x\n",Status
);
279 RtlInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\Software\\test2reactos");
280 InitializeObjectAttributes(&ObjectAttributes
,
282 OBJ_CASE_INSENSITIVE
,
285 dprintf("NtOpenKey : ");
286 Status
=NtOpenKey( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
);
287 dprintf("\t\t\t\tStatus =%x\n",Status
);
288 dprintf("NtDeleteKey : ");
289 Status
=NtDeleteKey(hKey
);
290 dprintf("\t\t\t\tStatus =%x\n",Status
);
297 OBJECT_ATTRIBUTES ObjectAttributes
;
298 UNICODE_STRING KeyName
,ValueName
;
300 KEY_VALUE_FULL_INFORMATION KeyValueInformation
[5];
301 ULONG Index
,Length
,i
;
304 dprintf("NtCreateKey non volatile: \n");
305 dprintf(" \\Registry\\Machine\\Software\\test3reactos: ");
306 RtlInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\Software\\test3reactos");
307 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
309 Status
= NtCreateKey ( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
310 ,0,NULL
,REG_OPTION_NON_VOLATILE
,NULL
);
311 dprintf("\t\tStatus=%x\n",Status
);
313 do_enumeratekey(L
"\\Registry\\Machine\\Software");
314 dprintf("NtOpenKey: ");
315 Status
=NtOpenKey( &hKey
, MAXIMUM_ALLOWED
, &ObjectAttributes
);
316 dprintf("\t\tStatus=%x\n",Status
);
318 dprintf(" ...\\test3 :");
319 RtlInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\Software\\test3reactos\\test3");
320 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
322 Status
= NtCreateKey ( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
323 ,0,NULL
,REG_OPTION_NON_VOLATILE
,NULL
);
324 dprintf("\t\t\t\t\tStatus=%x\n",Status
);
325 dprintf("NtOpenKey: ");
326 Status
=NtOpenKey( &hKey1
, MAXIMUM_ALLOWED
, &ObjectAttributes
);
327 dprintf("\t\tStatus=%x\n",Status
);
329 dprintf(" ...\\testNonVolatile :");
330 RtlInitUnicodeStringFromLiteral(&KeyName
, L
"TestNonVolatile");
331 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
333 Status
= NtCreateKey ( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
334 ,0,NULL
,REG_OPTION_NON_VOLATILE
,NULL
);
335 dprintf("\t\t\t\tStatus=%x\n",Status
);
337 RtlInitUnicodeStringFromLiteral(&ValueName
, L
"TestREG_SZ");
338 dprintf("NtSetValueKey reg_sz: ");
339 Status
=NtSetValueKey(hKey
,&ValueName
,0,REG_SZ
,(PVOID
)L
"Test Reg_sz",24);
340 dprintf("\t\t\t\tStatus=%x\n",Status
);
341 RtlInitUnicodeStringFromLiteral(&ValueName
, L
"TestDWORD");
342 dprintf("NtSetValueKey reg_dword: ");
343 Status
=NtSetValueKey(hKey
,&ValueName
,0,REG_DWORD
,(PVOID
)"reac",4);
344 dprintf("\t\t\tStatus=%x\n",Status
);
346 dprintf("NtOpenKey \\Registry\\Machine\\Software\\test3reactos\\test3\\testNonVolatile : ");
347 RtlInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\Software\\test3reactos\\test3\\testNonVolatile");
348 InitializeObjectAttributes(&ObjectAttributes
,
350 OBJ_CASE_INSENSITIVE
,
353 Status
=NtOpenKey( &hKey
, MAXIMUM_ALLOWED
, &ObjectAttributes
);
354 dprintf("\t\t\t\tStatus =%x\n",Status
);
357 dprintf("NtEnumerateValueKey : \n");
359 while(Status
== STATUS_SUCCESS
)
361 Status
=NtEnumerateValueKey(hKey
,Index
++,KeyValueFullInformation
362 ,&KeyValueInformation
[0], sizeof(KeyValueInformation
)
364 if(Status
== STATUS_SUCCESS
)
366 dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
367 ,KeyValueInformation
[0].DataOffset
368 ,KeyValueInformation
[0].DataLength
369 ,KeyValueInformation
[0].NameLength
);
370 for (i
=0;i
<KeyValueInformation
[0].NameLength
/2;i
++)
371 dprintf("%C",KeyValueInformation
[0].Name
[i
]);
372 dprintf(", Type = %d\n",KeyValueInformation
[0].Type
);
373 if (KeyValueInformation
[0].Type
== REG_SZ
)
374 dprintf("\t\tValue = %S\n",((char*)&KeyValueInformation
[0]
375 +KeyValueInformation
[0].DataOffset
));
380 dprintf("delete \\Registry\\Machine\\software\\test3reactos ?");
381 ReadConsoleA(InputHandle
, Buffer
, 3, &Result
, NULL
) ;
382 if (Buffer
[0] != 'y' && Buffer
[0] != 'Y') return;
383 RtlInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\Software\\test3reactos\\test3\\testNonvolatile");
384 InitializeObjectAttributes(&ObjectAttributes
,
386 OBJ_CASE_INSENSITIVE
,
389 dprintf("NtOpenKey : ");
390 Status
=NtOpenKey( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
);
391 dprintf("\t\t\t\tStatus =%x\n",Status
);
392 dprintf("NtDeleteKey : ");
393 Status
=NtDeleteKey(hKey
);
394 dprintf("\t\t\t\tStatus =%x\n",Status
);
395 RtlInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\Software\\test3reactos\\test3");
396 InitializeObjectAttributes(&ObjectAttributes
,
398 OBJ_CASE_INSENSITIVE
,
401 dprintf("NtOpenKey : ");
402 Status
=NtOpenKey( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
);
403 dprintf("\t\t\t\tStatus =%x\n",Status
);
404 dprintf("NtDeleteKey : ");
405 Status
=NtDeleteKey(hKey
);
406 dprintf("\t\t\t\tStatus =%x\n",Status
);
408 RtlInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\Software\\test3reactos");
409 InitializeObjectAttributes(&ObjectAttributes
,
411 OBJ_CASE_INSENSITIVE
,
414 dprintf("NtOpenKey : ");
415 Status
=NtOpenKey( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
);
416 dprintf("\t\t\t\tStatus =%x\n",Status
);
417 dprintf("NtDeleteKey : ");
418 Status
=NtDeleteKey(hKey
);
419 dprintf("\t\t\t\tStatus =%x\n",Status
);
425 HKEY hKey
= NULL
,hKey1
;
428 DWORD RegDataType
, RegDataSize
;
429 BOOL GlobalFifoEnable
;
431 DWORD RegDisposition
;
438 DWORD cchMaxValueName
;
439 DWORD cbMaxValueData
;
440 DWORD cbSecurityDescriptor
;
441 FILETIME ftLastWriteTime
;
442 SYSTEMTIME LastWriteTime
;
444 dprintf ("RegOpenKeyExW HKLM\\System\\Setup: ");
445 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
450 dprintf("\t\tdwError =%x\n",dwError
);
451 if (dwError
== ERROR_SUCCESS
)
453 dprintf("RegQueryInfoKeyW: ");
455 dwError
= RegQueryInfoKeyW(hKey1
456 , szClass
, &cchClass
, NULL
, &cSubKeys
457 , &cchMaxSubkey
, &cchMaxClass
, &cValues
, &cchMaxValueName
458 , &cbMaxValueData
, &cbSecurityDescriptor
, &ftLastWriteTime
);
459 dprintf ("\t\t\t\tdwError %x\n", dwError
);
460 FileTimeToSystemTime(&ftLastWriteTime
,&LastWriteTime
);
461 dprintf ("\tnb of subkeys=%d,last write : %d/%d/%d %d:%02.2d'%02.2d''%03.3d\n",cSubKeys
462 ,LastWriteTime
.wMonth
466 ,LastWriteTime
.wMinute
467 ,LastWriteTime
.wSecond
468 ,LastWriteTime
.wMilliseconds
473 dprintf ("RegOpenKeyExW: ");
474 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
475 L
"System\\ControlSet001\\Services\\Serial",
479 dprintf ("\t\t\t\t\tdwError %x\n", dwError
);
480 RegDataSize
= sizeof(GlobalFifoEnable
);
481 if (dwError
== ERROR_SUCCESS
)
483 dprintf ("RegQueryValueExW: ");
484 dwError
= RegQueryValueExW(hKey
,
488 (PBYTE
)&GlobalFifoEnable
,
490 dprintf("\t\t\t\tdwError =%x\n",dwError
);
493 dprintf("\tValue:DT=%d, DS=%d, Value=%d\n"
499 dprintf ("RegCreateKeyExW: ");
500 dwError
= RegCreateKeyExW(hKey
,
501 L
"Parameters\\Serial001",
510 dprintf ("\t\t\t\tdwError %x\n", dwError
);
512 dprintf ("RegCreateKeyExW: ");
513 dwError
= RegCreateKeyExW (HKEY_LOCAL_MACHINE
,
514 L
"Software\\test4reactos\\test",
517 REG_OPTION_NON_VOLATILE
,
523 dprintf ("\t\t\t\tdwError %x ", dwError
);
524 dprintf ("dwDisposition %x\n", dwDisposition
);
525 if (dwError
== ERROR_SUCCESS
)
527 dprintf ("RegSetValueExW: ");
528 dwError
= RegSetValueExW (hKey
,
532 (BYTE
*)L
"TestString",
535 dprintf ("\t\t\t\tdwError %x\n", dwError
);
536 dprintf ("RegCloseKey: ");
537 dwError
= RegCloseKey (hKey
);
538 dprintf ("\t\t\t\t\tdwError %x\n", dwError
);
544 dprintf ("RegCreateKeyExW: ");
545 dwError
= RegCreateKeyExW (HKEY_LOCAL_MACHINE
,
555 dprintf ("\t\t\t\tdwError %x ", dwError
);
556 dprintf ("dwDisposition %x\n", dwDisposition
);
559 if (dwError
== ERROR_SUCCESS
)
561 dprintf("RegQueryInfoKeyW: ");
563 dwError
= RegQueryInfoKeyW(hKey
564 , szClass
, &cchClass
, NULL
, &cSubKeys
565 , &cchMaxSubkey
, &cchMaxClass
, &cValues
, &cchMaxValueName
566 , &cbMaxValueData
, &cbSecurityDescriptor
, &ftLastWriteTime
);
567 dprintf ("\t\t\t\tdwError %x\n", dwError
);
568 FileTimeToSystemTime(&ftLastWriteTime
,&LastWriteTime
);
569 dprintf ("\tnb of subkeys=%d,last write : %d/%d/%d %d:%02.2d'%02.2d''%03.3d\n",cSubKeys
570 ,LastWriteTime
.wMonth
574 ,LastWriteTime
.wMinute
575 ,LastWriteTime
.wSecond
576 ,LastWriteTime
.wMilliseconds
578 dprintf ("RegCloseKey: ");
579 dwError
= RegCloseKey (hKey
);
580 dprintf ("\t\t\t\t\tdwError %x\n", dwError
);
582 dprintf ("\nTests done...\n");
588 OBJECT_ATTRIBUTES ObjectAttributes
;
589 UNICODE_STRING KeyName
,ValueName
;
591 KEY_VALUE_FULL_INFORMATION KeyValueInformation
[5];
592 ULONG Index
,Length
,i
;
596 dprintf("NtOpenKey : \n");
597 dprintf(" \\Registry\\Machine\\Software\\reactos : ");
598 RtlInitUnicodeStringFromLiteral(&KeyName
,L
"\\Registry\\Machine\\Software\\reactos");
599 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
601 Status
=NtOpenKey( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
);
602 dprintf("\t\tStatus=%x\n",Status
);
603 dprintf("NtFlushKey : \n");
604 Status
= NtFlushKey(hKey
);
605 dprintf("\t\tStatus=%x\n",Status
);
606 dprintf("NtCloseKey : \n");
607 Status
=NtClose(hKey
);
608 dprintf("\t\tStatus=%x\n",Status
);
611 /* registry link create test */
615 OBJECT_ATTRIBUTES ObjectAttributes
;
616 UNICODE_STRING KeyName
,ValueName
;
618 KEY_VALUE_FULL_INFORMATION KeyValueInformation
[5];
619 ULONG Index
,Length
,i
;
623 dprintf("Create target key\n");
624 dprintf(" Key: \\Registry\\Machine\\SOFTWARE\\Reactos\n");
625 RtlInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\SOFTWARE\\Reactos");
626 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
628 Status
= NtCreateKey(&hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
629 ,0,NULL
, REG_OPTION_VOLATILE
,NULL
);
630 dprintf(" NtCreateKey() called (Status %lx)\n",Status
);
631 if (!NT_SUCCESS(Status
))
634 dprintf("Create target value\n");
635 dprintf(" Value: TestValue = 'Test String'\n");
636 RtlInitUnicodeStringFromLiteral(&ValueName
, L
"TestValue");
637 Status
=NtSetValueKey(hKey
,&ValueName
,0,REG_SZ
,(PVOID
)L
"TestString",22);
638 dprintf(" NtSetValueKey() called (Status %lx)\n",Status
);
639 if (!NT_SUCCESS(Status
))
642 dprintf("Close target key\n");
646 dprintf("Create link key\n");
647 dprintf(" Key: \\Registry\\Machine\\SOFTWARE\\Test\n");
648 RtlInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\SOFTWARE\\Test");
649 InitializeObjectAttributes(&ObjectAttributes
,
651 OBJ_CASE_INSENSITIVE
| OBJ_OPENLINK
,
654 Status
= NtCreateKey(&hKey
,
655 KEY_ALL_ACCESS
| KEY_CREATE_LINK
,
659 REG_OPTION_VOLATILE
| REG_OPTION_CREATE_LINK
,
661 dprintf(" NtCreateKey() called (Status %lx)\n",Status
);
662 if (!NT_SUCCESS(Status
))
665 dprintf("Create link value\n");
666 dprintf(" Value: SymbolicLinkValue = '\\Registry\\Machine\\SOFTWARE\\Reactos'\n");
667 RtlInitUnicodeStringFromLiteral(&ValueName
, L
"SymbolicLinkValue");
668 Status
=NtSetValueKey(hKey
,&ValueName
,0,REG_LINK
,(PVOID
)L
"\\Registry\\Machine\\SOFTWARE\\Reactos",68);
669 dprintf(" NtSetValueKey() called (Status %lx)\n",Status
);
670 if (!NT_SUCCESS(Status
))
672 dprintf("Creating link value failed! Test failed!\n");
677 dprintf("Close link key\n");
680 dprintf("Open link key\n");
681 dprintf(" Key: \\Registry\\Machine\\SOFTWARE\\Test\n");
682 RtlInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\SOFTWARE\\Test");
683 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
| OBJ_OPENIF
685 Status
= NtCreateKey(&hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
686 ,0,NULL
, REG_OPTION_VOLATILE
, NULL
);
687 dprintf(" NtCreateKey() called (Status %lx)\n",Status
);
688 if (!NT_SUCCESS(Status
))
691 dprintf("Query value\n");
692 dprintf(" Value: TestValue\n");
693 RtlInitUnicodeStringFromLiteral(&ValueName
, L
"TestValue");
694 Status
=NtQueryValueKey(hKey
,
696 KeyValueFullInformation
,
697 &KeyValueInformation
[0],
698 sizeof(KeyValueInformation
),
700 dprintf(" NtQueryValueKey() called (Status %lx)\n",Status
);
701 if (Status
== STATUS_SUCCESS
)
703 dprintf(" Value: Type %d DataLength %d NameLength %d Name '",
704 KeyValueInformation
[0].Type
,
705 KeyValueInformation
[0].DataLength
,
706 KeyValueInformation
[0].NameLength
);
707 for (i
=0; i
< KeyValueInformation
[0].NameLength
/ sizeof(WCHAR
); i
++)
708 dprintf("%C",KeyValueInformation
[0].Name
[i
]);
710 if (KeyValueInformation
[0].Type
== REG_SZ
)
711 dprintf(" Value '%S'\n",
712 KeyValueInformation
[0].Name
+1
713 +KeyValueInformation
[0].NameLength
/2);
716 dprintf("Close link key\n");
719 dprintf("Test successful!\n");
722 /* registry link delete test */
726 OBJECT_ATTRIBUTES ObjectAttributes
;
727 UNICODE_STRING KeyName
,ValueName
;
730 dprintf("Open link key\n");
731 dprintf(" Key: \\Registry\\Machine\\SOFTWARE\\Test\n");
732 RtlInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\SOFTWARE\\Test");
733 InitializeObjectAttributes(&ObjectAttributes
,
735 OBJ_CASE_INSENSITIVE
| OBJ_OPENIF
| OBJ_OPENLINK
,
738 Status
= NtCreateKey(&hKey
,
743 REG_OPTION_VOLATILE
| REG_OPTION_OPEN_LINK
,
745 dprintf(" NtCreateKey() called (Status %lx)\n",Status
);
746 if (!NT_SUCCESS(Status
))
748 dprintf("Could not open the link key. Please run the link create test first!\n");
752 dprintf("Delete link value\n");
753 RtlInitUnicodeStringFromLiteral(&ValueName
, L
"SymbolicLinkValue");
754 Status
= NtDeleteValueKey(hKey
,
756 dprintf(" NtDeleteValueKey() called (Status %lx)\n",Status
);
758 dprintf("Delete link key\n");
759 Status
=NtDeleteKey(hKey
);
760 dprintf(" NtDeleteKey() called (Status %lx)\n",Status
);
762 dprintf("Close link key\n");
769 OBJECT_ATTRIBUTES ObjectAttributes
;
770 UNICODE_STRING KeyName
;
773 TOKEN_PRIVILEGES NewPrivileges
;
777 Status
=NtOpenProcessToken(GetCurrentProcess()
778 ,TOKEN_ADJUST_PRIVILEGES
,&Token
);
779 // ,TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&Token);
780 dprintf("\t\t\t\tStatus =%x\n",Status
);
781 // bRes=LookupPrivilegeValueA(NULL,SE_RESTORE_NAME,&Luid);
782 // dprintf("\t\t\t\tbRes =%x\n",bRes);
783 NewPrivileges
.PrivilegeCount
= 1;
784 NewPrivileges
.Privileges
[0].Luid
= Luid
;
785 // NewPrivileges.Privileges[0].Luid.u.LowPart=18;
786 // NewPrivileges.Privileges[0].Luid.u.HighPart=0;
787 NewPrivileges
.Privileges
[0].Attributes
= SE_PRIVILEGE_ENABLED
;
789 // Status = NtAdjustPrivilegesToken(
790 bRes
= AdjustTokenPrivileges(
798 dprintf("\t\t\t\tbRes =%x\n",bRes
);
800 // Status=NtClose(Token);
801 // dprintf("\t\t\t\tStatus =%x\n",Status);
804 RtlInitUnicodeStringFromLiteral(&KeyName
,L
"test5");
805 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
807 Status
= NtLoadKey(HKEY_LOCAL_MACHINE
,&ObjectAttributes
);
808 dprintf("\t\t\t\tStatus =%x\n",Status
);
809 dwError
=RegLoadKey(HKEY_LOCAL_MACHINE
,"def"
811 dprintf("\t\t\t\tdwError =%x\n",dwError
);
813 dprintf("NtOpenKey \\Registry\\Machine : ");
814 RtlInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine");
815 InitializeObjectAttributes(&ObjectAttributes
,
817 OBJ_CASE_INSENSITIVE
,
820 Status
=NtOpenKey( &hKey
, MAXIMUM_ALLOWED
, &ObjectAttributes
);
821 dprintf("\t\t\tStatus =%x\n",Status
);
822 RtlInitUnicodeStringFromLiteral(&KeyName
,L
"test5");
823 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
825 Status
= NtLoadKey(hKey
,&ObjectAttributes
);
826 dprintf("\t\t\t\tStatus =%x\n",Status
);
829 int main(int argc
, char* argv
[])
835 InputHandle
= GetStdHandle(STD_INPUT_HANDLE
);
836 OutputHandle
= GetStdHandle(STD_OUTPUT_HANDLE
);
839 dprintf("choose test :\n");
840 dprintf(" 0=Exit\n");
841 dprintf(" 1=Ntxxx read functions\n");
842 dprintf(" 2=Ntxxx write functions : volatile keys\n");
843 dprintf(" 3=Ntxxx write functions : non volatile keys\n");
844 dprintf(" 4=Regxxx functions\n");
845 dprintf(" 5=FlushKey \n");
846 dprintf(" 6=Registry link create test\n");
847 dprintf(" 7=Registry link delete test\n");
848 ReadConsoleA(InputHandle
, Buffer
, 3, &Result
, NULL
) ;