6 #include <rosrtl/string.h>
11 void dprintf(char* fmt
, ...)
17 vsprintf(buffer
,fmt
,args
);
18 WriteConsoleA(OutputHandle
, buffer
, strlen(buffer
), NULL
, NULL
);
22 void do_enumeratekey(PWSTR Name
)
25 KEY_BASIC_INFORMATION KeyInformation
[5];
27 OBJECT_ATTRIBUTES ObjectAttributes
;
29 UNICODE_STRING KeyName
;
31 RtlInitUnicodeString(&KeyName
, Name
);
32 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
34 Status
=NtOpenKey( &hKey1
, MAXIMUM_ALLOWED
, &ObjectAttributes
);
35 dprintf("NtEnumerateKey : \n");
37 while(Status
== STATUS_SUCCESS
)
39 Status
=NtEnumerateKey(hKey1
,Index
++,KeyBasicInformation
40 ,&KeyInformation
[0], sizeof(KeyInformation
)
42 if(Status
== STATUS_SUCCESS
)
44 dprintf("\tSubKey Name = ");
45 for (i
=0;i
<KeyInformation
[0].NameLength
/2;i
++)
46 dprintf("%C",KeyInformation
[0].Name
[i
]);
55 HKEY hKey
= NULL
, hKey1
;
56 OBJECT_ATTRIBUTES ObjectAttributes
;
58 UNICODE_STRING KeyName
= ROS_STRING_INITIALIZER(L
"\\Registry");
60 KEY_BASIC_INFORMATION KeyInformation
[5];
61 KEY_VALUE_FULL_INFORMATION KeyValueInformation
[5];
63 dprintf("NtOpenKey \\Registry : ");
64 InitializeObjectAttributes(&ObjectAttributes
,
69 Status
=NtOpenKey( &hKey1
, MAXIMUM_ALLOWED
, &ObjectAttributes
);
70 dprintf("\t\t\t\tStatus =%x\n",Status
);
73 dprintf("NtQueryKey : ");
74 Status
=NtQueryKey(hKey1
,KeyBasicInformation
75 ,&KeyInformation
[0], sizeof(KeyInformation
)
77 dprintf("\t\t\t\t\tStatus =%x\n",Status
);
78 if (Status
== STATUS_SUCCESS
)
80 dprintf("\tKey Name = ");
81 for (i
=0;i
<KeyInformation
[0].NameLength
/2;i
++)
82 dprintf("%C",KeyInformation
[0].Name
[i
]);
85 dprintf("NtEnumerateKey : \n");
87 while(Status
== STATUS_SUCCESS
)
89 Status
=NtEnumerateKey(hKey1
,Index
++,KeyBasicInformation
90 ,&KeyInformation
[0], sizeof(KeyInformation
)
92 if(Status
== STATUS_SUCCESS
)
94 dprintf("\tSubKey Name = ");
95 for (i
=0;i
<KeyInformation
[0].NameLength
/2;i
++)
96 dprintf("%C",KeyInformation
[0].Name
[i
]);
100 dprintf("NtClose : ");
101 Status
= NtClose( hKey1
);
102 dprintf("\t\t\t\t\tStatus =%x\n",Status
);
106 dprintf("NtOpenKey \\Registry\\Machine : ");
107 RtlRosInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine");
108 InitializeObjectAttributes(&ObjectAttributes
,
110 OBJ_CASE_INSENSITIVE
,
113 Status
=NtOpenKey( &hKey1
, MAXIMUM_ALLOWED
, &ObjectAttributes
);
114 dprintf("\t\t\tStatus =%x\n",Status
);
116 dprintf("NtOpenKey System\\Setup : ");
117 RtlRosInitUnicodeStringFromLiteral(&KeyName
, L
"System\\Setup");
118 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
120 Status
= NtOpenKey ( &hKey
, KEY_READ
, &ObjectAttributes
);
121 dprintf("\t\t\tStatus =%x\n",Status
);
124 dprintf("NtQueryValueKey : ");
125 RtlRosInitUnicodeStringFromLiteral(&KeyName
, L
"CmdLine");
126 Status
=NtQueryValueKey(hKey
,&KeyName
,KeyValueFullInformation
127 ,&KeyValueInformation
[0], sizeof(KeyValueInformation
)
129 dprintf("\t\t\t\tStatus =%x\n",Status
);
130 if (Status
== STATUS_SUCCESS
)
132 dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
133 ,KeyValueInformation
[0].DataOffset
134 ,KeyValueInformation
[0].DataLength
135 ,KeyValueInformation
[0].NameLength
);
136 for (i
=0;i
<10 && i
<KeyValueInformation
[0].NameLength
/2;i
++)
137 dprintf("%C",KeyValueInformation
[0].Name
[i
]);
139 dprintf("\t\tType = %d\n",KeyValueInformation
[0].Type
);
140 if (KeyValueInformation
[0].Type
== REG_SZ
)
141 dprintf("\t\tValue = %S\n",
142 (PWCHAR
)((PCHAR
)&KeyValueInformation
[0] + KeyValueInformation
[0].DataOffset
));
144 dprintf("NtEnumerateValueKey : \n");
146 while(Status
== STATUS_SUCCESS
)
148 Status
=NtEnumerateValueKey(hKey
,Index
++,KeyValueFullInformation
149 ,&KeyValueInformation
[0], sizeof(KeyValueInformation
)
151 if(Status
== STATUS_SUCCESS
)
153 dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
154 ,KeyValueInformation
[0].DataOffset
155 ,KeyValueInformation
[0].DataLength
156 ,KeyValueInformation
[0].NameLength
);
157 for (i
=0;i
<KeyValueInformation
[0].NameLength
/2;i
++)
158 dprintf("%C",KeyValueInformation
[0].Name
[i
]);
159 dprintf(", Type = %d\n",KeyValueInformation
[0].Type
);
160 if (KeyValueInformation
[0].Type
== REG_SZ
)
161 dprintf("\t\tValue = %S\n",((char*)&KeyValueInformation
[0]
162 +KeyValueInformation
[0].DataOffset
));
165 dprintf("NtClose : ");
166 Status
= NtClose( hKey
);
167 dprintf("\t\t\t\t\tStatus =%x\n",Status
);
176 OBJECT_ATTRIBUTES ObjectAttributes
;
177 UNICODE_STRING KeyName
,ValueName
;
179 KEY_VALUE_FULL_INFORMATION KeyValueInformation
[5];
180 ULONG Index
,Length
,i
;
183 dprintf("NtCreateKey volatile: \n");
184 dprintf(" \\Registry\\Machine\\Software\\test2reactos: ");
185 RtlRosInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\Software\\test2reactos");
186 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
188 Status
= NtCreateKey ( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
189 ,0,NULL
,REG_OPTION_VOLATILE
,NULL
);
190 dprintf("\t\tStatus=%x\n",Status
);
192 do_enumeratekey(L
"\\Registry\\Machine\\Software");
193 dprintf(" ...\\test2 :");
194 RtlRosInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\Software\\test2reactos\\test2");
195 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
197 Status
= NtCreateKey ( &hKey1
, KEY_ALL_ACCESS
, &ObjectAttributes
198 ,0,NULL
,REG_OPTION_VOLATILE
,NULL
);
199 dprintf("\t\t\t\t\tStatus=%x\n",Status
);
200 dprintf(" ...\\TestVolatile :");
201 RtlRosInitUnicodeStringFromLiteral(&KeyName
, L
"TestVolatile");
202 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
204 Status
= NtCreateKey ( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
205 ,0,NULL
,REG_OPTION_VOLATILE
,NULL
);
206 dprintf("\t\t\t\tStatus=%x\n",Status
);
208 RtlRosInitUnicodeStringFromLiteral(&ValueName
, L
"TestREG_SZ");
209 dprintf("NtSetValueKey reg_sz: ");
210 Status
=NtSetValueKey(hKey
,&ValueName
,0,REG_SZ
,(PVOID
)L
"Test Reg_sz",24);
211 dprintf("\t\t\t\tStatus=%x\n",Status
);
212 RtlRosInitUnicodeStringFromLiteral(&ValueName
, L
"TestDWORD");
213 dprintf("NtSetValueKey reg_dword: ");
214 Status
=NtSetValueKey(hKey
,&ValueName
,0,REG_DWORD
,(PVOID
)"reac",4);
215 dprintf("\t\t\tStatus=%x\n",Status
);
217 dprintf("NtOpenKey \\Registry\\Machine\\Software\\test2reactos\\test2\\TestVolatile : ");
218 RtlRosInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\Software\\test2reactos\\test2\\TestVolatile");
219 InitializeObjectAttributes(&ObjectAttributes
,
221 OBJ_CASE_INSENSITIVE
,
224 Status
=NtOpenKey( &hKey
, MAXIMUM_ALLOWED
, &ObjectAttributes
);
225 dprintf("\t\t\t\tStatus =%x\n",Status
);
228 dprintf("NtEnumerateValueKey : \n");
230 while(Status
== STATUS_SUCCESS
)
232 Status
=NtEnumerateValueKey(hKey
,Index
++,KeyValueFullInformation
233 ,&KeyValueInformation
[0], sizeof(KeyValueInformation
)
235 if(Status
== STATUS_SUCCESS
)
237 dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
238 ,KeyValueInformation
[0].DataOffset
239 ,KeyValueInformation
[0].DataLength
240 ,KeyValueInformation
[0].NameLength
);
241 for (i
=0;i
<KeyValueInformation
[0].NameLength
/2;i
++)
242 dprintf("%C",KeyValueInformation
[0].Name
[i
]);
243 dprintf(", Type = %d\n",KeyValueInformation
[0].Type
);
244 if (KeyValueInformation
[0].Type
== REG_SZ
)
245 dprintf("\t\tValue = %S\n",((char*)&KeyValueInformation
[0]
246 +KeyValueInformation
[0].DataOffset
));
251 dprintf("delete \\Registry\\Machine\\software\\test2reactos ?");
252 ReadConsoleA(InputHandle
, Buffer
, 3, &Result
, NULL
) ;
253 if (Buffer
[0] != 'y' && Buffer
[0] != 'Y') return;
254 RtlRosInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\Software\\test2reactos\\test2\\TestVolatile");
255 InitializeObjectAttributes(&ObjectAttributes
,
257 OBJ_CASE_INSENSITIVE
,
260 dprintf("NtOpenKey : ");
261 Status
=NtOpenKey( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
);
262 dprintf("\t\t\t\tStatus =%x\n",Status
);
263 dprintf("NtDeleteKey : ");
264 Status
=NtDeleteKey(hKey
);
265 dprintf("\t\t\t\tStatus =%x\n",Status
);
267 RtlRosInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\Software\\test2reactos\\test2");
268 InitializeObjectAttributes(&ObjectAttributes
,
270 OBJ_CASE_INSENSITIVE
,
273 dprintf("NtOpenKey : ");
274 Status
=NtOpenKey( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
);
275 dprintf("\t\t\t\tStatus =%x\n",Status
);
276 dprintf("NtDeleteKey : ");
277 Status
=NtDeleteKey(hKey
);
278 dprintf("\t\t\t\tStatus =%x\n",Status
);
280 RtlRosInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\Software\\test2reactos");
281 InitializeObjectAttributes(&ObjectAttributes
,
283 OBJ_CASE_INSENSITIVE
,
286 dprintf("NtOpenKey : ");
287 Status
=NtOpenKey( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
);
288 dprintf("\t\t\t\tStatus =%x\n",Status
);
289 dprintf("NtDeleteKey : ");
290 Status
=NtDeleteKey(hKey
);
291 dprintf("\t\t\t\tStatus =%x\n",Status
);
298 OBJECT_ATTRIBUTES ObjectAttributes
;
299 UNICODE_STRING KeyName
,ValueName
;
301 KEY_VALUE_FULL_INFORMATION KeyValueInformation
[5];
302 ULONG Index
,Length
,i
;
305 dprintf("NtCreateKey non volatile: \n");
306 dprintf(" \\Registry\\Machine\\Software\\test3reactos: ");
307 RtlRosInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\Software\\test3reactos");
308 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
310 Status
= NtCreateKey ( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
311 ,0,NULL
,REG_OPTION_NON_VOLATILE
,NULL
);
312 dprintf("\t\tStatus=%x\n",Status
);
314 do_enumeratekey(L
"\\Registry\\Machine\\Software");
315 dprintf("NtOpenKey: ");
316 Status
=NtOpenKey( &hKey
, MAXIMUM_ALLOWED
, &ObjectAttributes
);
317 dprintf("\t\tStatus=%x\n",Status
);
319 dprintf(" ...\\test3 :");
320 RtlRosInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\Software\\test3reactos\\test3");
321 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
323 Status
= NtCreateKey ( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
324 ,0,NULL
,REG_OPTION_NON_VOLATILE
,NULL
);
325 dprintf("\t\t\t\t\tStatus=%x\n",Status
);
326 dprintf("NtOpenKey: ");
327 Status
=NtOpenKey( &hKey1
, MAXIMUM_ALLOWED
, &ObjectAttributes
);
328 dprintf("\t\tStatus=%x\n",Status
);
330 dprintf(" ...\\testNonVolatile :");
331 RtlRosInitUnicodeStringFromLiteral(&KeyName
, L
"TestNonVolatile");
332 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
334 Status
= NtCreateKey ( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
335 ,0,NULL
,REG_OPTION_NON_VOLATILE
,NULL
);
336 dprintf("\t\t\t\tStatus=%x\n",Status
);
338 RtlRosInitUnicodeStringFromLiteral(&ValueName
, L
"TestREG_SZ");
339 dprintf("NtSetValueKey reg_sz: ");
340 Status
=NtSetValueKey(hKey
,&ValueName
,0,REG_SZ
,(PVOID
)L
"Test Reg_sz",24);
341 dprintf("\t\t\t\tStatus=%x\n",Status
);
342 RtlRosInitUnicodeStringFromLiteral(&ValueName
, L
"TestDWORD");
343 dprintf("NtSetValueKey reg_dword: ");
344 Status
=NtSetValueKey(hKey
,&ValueName
,0,REG_DWORD
,(PVOID
)"reac",4);
345 dprintf("\t\t\tStatus=%x\n",Status
);
347 dprintf("NtOpenKey \\Registry\\Machine\\Software\\test3reactos\\test3\\testNonVolatile : ");
348 RtlRosInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\Software\\test3reactos\\test3\\testNonVolatile");
349 InitializeObjectAttributes(&ObjectAttributes
,
351 OBJ_CASE_INSENSITIVE
,
354 Status
=NtOpenKey( &hKey
, MAXIMUM_ALLOWED
, &ObjectAttributes
);
355 dprintf("\t\t\t\tStatus =%x\n",Status
);
358 dprintf("NtEnumerateValueKey : \n");
360 while(Status
== STATUS_SUCCESS
)
362 Status
=NtEnumerateValueKey(hKey
,Index
++,KeyValueFullInformation
363 ,&KeyValueInformation
[0], sizeof(KeyValueInformation
)
365 if(Status
== STATUS_SUCCESS
)
367 dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
368 ,KeyValueInformation
[0].DataOffset
369 ,KeyValueInformation
[0].DataLength
370 ,KeyValueInformation
[0].NameLength
);
371 for (i
=0;i
<KeyValueInformation
[0].NameLength
/2;i
++)
372 dprintf("%C",KeyValueInformation
[0].Name
[i
]);
373 dprintf(", Type = %d\n",KeyValueInformation
[0].Type
);
374 if (KeyValueInformation
[0].Type
== REG_SZ
)
375 dprintf("\t\tValue = %S\n",((char*)&KeyValueInformation
[0]
376 +KeyValueInformation
[0].DataOffset
));
381 dprintf("delete \\Registry\\Machine\\software\\test3reactos ?");
382 ReadConsoleA(InputHandle
, Buffer
, 3, &Result
, NULL
) ;
383 if (Buffer
[0] != 'y' && Buffer
[0] != 'Y') return;
384 RtlRosInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\Software\\test3reactos\\test3\\testNonvolatile");
385 InitializeObjectAttributes(&ObjectAttributes
,
387 OBJ_CASE_INSENSITIVE
,
390 dprintf("NtOpenKey : ");
391 Status
=NtOpenKey( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
);
392 dprintf("\t\t\t\tStatus =%x\n",Status
);
393 dprintf("NtDeleteKey : ");
394 Status
=NtDeleteKey(hKey
);
395 dprintf("\t\t\t\tStatus =%x\n",Status
);
396 RtlRosInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\Software\\test3reactos\\test3");
397 InitializeObjectAttributes(&ObjectAttributes
,
399 OBJ_CASE_INSENSITIVE
,
402 dprintf("NtOpenKey : ");
403 Status
=NtOpenKey( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
);
404 dprintf("\t\t\t\tStatus =%x\n",Status
);
405 dprintf("NtDeleteKey : ");
406 Status
=NtDeleteKey(hKey
);
407 dprintf("\t\t\t\tStatus =%x\n",Status
);
409 RtlRosInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\Software\\test3reactos");
410 InitializeObjectAttributes(&ObjectAttributes
,
412 OBJ_CASE_INSENSITIVE
,
415 dprintf("NtOpenKey : ");
416 Status
=NtOpenKey( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
);
417 dprintf("\t\t\t\tStatus =%x\n",Status
);
418 dprintf("NtDeleteKey : ");
419 Status
=NtDeleteKey(hKey
);
420 dprintf("\t\t\t\tStatus =%x\n",Status
);
426 HKEY hKey
= NULL
,hKey1
;
429 DWORD RegDataType
, RegDataSize
;
430 BOOL GlobalFifoEnable
;
432 DWORD RegDisposition
;
439 DWORD cchMaxValueName
;
440 DWORD cbMaxValueData
;
441 DWORD cbSecurityDescriptor
;
442 FILETIME ftLastWriteTime
;
443 SYSTEMTIME LastWriteTime
;
445 dprintf ("RegOpenKeyExW HKLM\\System\\Setup: ");
446 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
451 dprintf("\t\tdwError =%x\n",dwError
);
452 if (dwError
== ERROR_SUCCESS
)
454 dprintf("RegQueryInfoKeyW: ");
456 dwError
= RegQueryInfoKeyW(hKey1
457 , szClass
, &cchClass
, NULL
, &cSubKeys
458 , &cchMaxSubkey
, &cchMaxClass
, &cValues
, &cchMaxValueName
459 , &cbMaxValueData
, &cbSecurityDescriptor
, &ftLastWriteTime
);
460 dprintf ("\t\t\t\tdwError %x\n", dwError
);
461 FileTimeToSystemTime(&ftLastWriteTime
,&LastWriteTime
);
462 dprintf ("\tnb of subkeys=%d,last write : %d/%d/%d %d:%02.2d'%02.2d''%03.3d\n",cSubKeys
463 ,LastWriteTime
.wMonth
467 ,LastWriteTime
.wMinute
468 ,LastWriteTime
.wSecond
469 ,LastWriteTime
.wMilliseconds
474 dprintf ("RegOpenKeyExW: ");
475 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
476 L
"System\\ControlSet001\\Services\\Serial",
480 dprintf ("\t\t\t\t\tdwError %x\n", dwError
);
481 RegDataSize
= sizeof(GlobalFifoEnable
);
482 if (dwError
== ERROR_SUCCESS
)
484 dprintf ("RegQueryValueExW: ");
485 dwError
= RegQueryValueExW(hKey
,
489 (PBYTE
)&GlobalFifoEnable
,
491 dprintf("\t\t\t\tdwError =%x\n",dwError
);
494 dprintf("\tValue:DT=%d, DS=%d, Value=%d\n"
500 dprintf ("RegCreateKeyExW: ");
501 dwError
= RegCreateKeyExW(hKey
,
502 L
"Parameters\\Serial001",
511 dprintf ("\t\t\t\tdwError %x\n", dwError
);
513 dprintf ("RegCreateKeyExW: ");
514 dwError
= RegCreateKeyExW (HKEY_LOCAL_MACHINE
,
515 L
"Software\\test4reactos\\test",
518 REG_OPTION_NON_VOLATILE
,
524 dprintf ("\t\t\t\tdwError %x ", dwError
);
525 dprintf ("dwDisposition %x\n", dwDisposition
);
526 if (dwError
== ERROR_SUCCESS
)
528 dprintf ("RegSetValueExW: ");
529 dwError
= RegSetValueExW (hKey
,
533 (BYTE
*)L
"TestString",
536 dprintf ("\t\t\t\tdwError %x\n", dwError
);
537 dprintf ("RegCloseKey: ");
538 dwError
= RegCloseKey (hKey
);
539 dprintf ("\t\t\t\t\tdwError %x\n", dwError
);
545 dprintf ("RegCreateKeyExW: ");
546 dwError
= RegCreateKeyExW (HKEY_LOCAL_MACHINE
,
556 dprintf ("\t\t\t\tdwError %x ", dwError
);
557 dprintf ("dwDisposition %x\n", dwDisposition
);
560 if (dwError
== ERROR_SUCCESS
)
562 dprintf("RegQueryInfoKeyW: ");
564 dwError
= RegQueryInfoKeyW(hKey
565 , szClass
, &cchClass
, NULL
, &cSubKeys
566 , &cchMaxSubkey
, &cchMaxClass
, &cValues
, &cchMaxValueName
567 , &cbMaxValueData
, &cbSecurityDescriptor
, &ftLastWriteTime
);
568 dprintf ("\t\t\t\tdwError %x\n", dwError
);
569 FileTimeToSystemTime(&ftLastWriteTime
,&LastWriteTime
);
570 dprintf ("\tnb of subkeys=%d,last write : %d/%d/%d %d:%02.2d'%02.2d''%03.3d\n",cSubKeys
571 ,LastWriteTime
.wMonth
575 ,LastWriteTime
.wMinute
576 ,LastWriteTime
.wSecond
577 ,LastWriteTime
.wMilliseconds
579 dprintf ("RegCloseKey: ");
580 dwError
= RegCloseKey (hKey
);
581 dprintf ("\t\t\t\t\tdwError %x\n", dwError
);
583 dprintf ("\nTests done...\n");
589 OBJECT_ATTRIBUTES ObjectAttributes
;
590 UNICODE_STRING KeyName
;
593 dprintf("NtOpenKey : \n");
594 dprintf(" \\Registry\\Machine\\Software\\reactos : ");
595 RtlRosInitUnicodeStringFromLiteral(&KeyName
,L
"\\Registry\\Machine\\Software\\reactos");
596 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
598 Status
=NtOpenKey( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
);
599 dprintf("\t\tStatus=%x\n",Status
);
600 dprintf("NtFlushKey : \n");
601 Status
= NtFlushKey(hKey
);
602 dprintf("\t\tStatus=%x\n",Status
);
603 dprintf("NtCloseKey : \n");
604 Status
=NtClose(hKey
);
605 dprintf("\t\tStatus=%x\n",Status
);
608 /* registry link create test */
612 OBJECT_ATTRIBUTES ObjectAttributes
;
613 UNICODE_STRING KeyName
,ValueName
;
615 KEY_VALUE_FULL_INFORMATION KeyValueInformation
[5];
618 dprintf("Create target key\n");
619 dprintf(" Key: \\Registry\\Machine\\SOFTWARE\\Reactos\n");
620 RtlRosInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\SOFTWARE\\Reactos");
621 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
623 Status
= NtCreateKey(&hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
624 ,0,NULL
, REG_OPTION_VOLATILE
,NULL
);
625 dprintf(" NtCreateKey() called (Status %lx)\n",Status
);
626 if (!NT_SUCCESS(Status
))
629 dprintf("Create target value\n");
630 dprintf(" Value: TestValue = 'Test String'\n");
631 RtlRosInitUnicodeStringFromLiteral(&ValueName
, L
"TestValue");
632 Status
=NtSetValueKey(hKey
,&ValueName
,0,REG_SZ
,(PVOID
)L
"TestString",22);
633 dprintf(" NtSetValueKey() called (Status %lx)\n",Status
);
634 if (!NT_SUCCESS(Status
))
637 dprintf("Close target key\n");
641 dprintf("Create link key\n");
642 dprintf(" Key: \\Registry\\Machine\\SOFTWARE\\Test\n");
643 RtlRosInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\SOFTWARE\\Test");
644 InitializeObjectAttributes(&ObjectAttributes
,
646 OBJ_CASE_INSENSITIVE
| OBJ_OPENLINK
,
649 Status
= NtCreateKey(&hKey
,
650 KEY_ALL_ACCESS
| KEY_CREATE_LINK
,
654 REG_OPTION_VOLATILE
| REG_OPTION_CREATE_LINK
,
656 dprintf(" NtCreateKey() called (Status %lx)\n",Status
);
657 if (!NT_SUCCESS(Status
))
660 dprintf("Create link value\n");
661 dprintf(" Value: SymbolicLinkValue = '\\Registry\\Machine\\SOFTWARE\\Reactos'\n");
662 RtlRosInitUnicodeStringFromLiteral(&ValueName
, L
"SymbolicLinkValue");
663 Status
=NtSetValueKey(hKey
,&ValueName
,0,REG_LINK
,(PVOID
)L
"\\Registry\\Machine\\SOFTWARE\\Reactos",68);
664 dprintf(" NtSetValueKey() called (Status %lx)\n",Status
);
665 if (!NT_SUCCESS(Status
))
667 dprintf("Creating link value failed! Test failed!\n");
672 dprintf("Close link key\n");
675 dprintf("Open link key\n");
676 dprintf(" Key: \\Registry\\Machine\\SOFTWARE\\Test\n");
677 RtlRosInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\SOFTWARE\\Test");
678 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
| OBJ_OPENIF
680 Status
= NtCreateKey(&hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
681 ,0,NULL
, REG_OPTION_VOLATILE
, NULL
);
682 dprintf(" NtCreateKey() called (Status %lx)\n",Status
);
683 if (!NT_SUCCESS(Status
))
686 dprintf("Query value\n");
687 dprintf(" Value: TestValue\n");
688 RtlRosInitUnicodeStringFromLiteral(&ValueName
, L
"TestValue");
689 Status
=NtQueryValueKey(hKey
,
691 KeyValueFullInformation
,
692 &KeyValueInformation
[0],
693 sizeof(KeyValueInformation
),
695 dprintf(" NtQueryValueKey() called (Status %lx)\n",Status
);
696 if (Status
== STATUS_SUCCESS
)
698 dprintf(" Value: Type %d DataLength %d NameLength %d Name '",
699 KeyValueInformation
[0].Type
,
700 KeyValueInformation
[0].DataLength
,
701 KeyValueInformation
[0].NameLength
);
702 for (i
=0; i
< KeyValueInformation
[0].NameLength
/ sizeof(WCHAR
); i
++)
703 dprintf("%C",KeyValueInformation
[0].Name
[i
]);
705 if (KeyValueInformation
[0].Type
== REG_SZ
)
706 dprintf(" Value '%S'\n",
707 KeyValueInformation
[0].Name
+1
708 +KeyValueInformation
[0].NameLength
/2);
711 dprintf("Close link key\n");
714 dprintf("Test successful!\n");
717 /* registry link delete test */
721 OBJECT_ATTRIBUTES ObjectAttributes
;
722 UNICODE_STRING KeyName
,ValueName
;
725 dprintf("Open link key\n");
726 dprintf(" Key: \\Registry\\Machine\\SOFTWARE\\Test\n");
727 RtlRosInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine\\SOFTWARE\\Test");
728 InitializeObjectAttributes(&ObjectAttributes
,
730 OBJ_CASE_INSENSITIVE
| OBJ_OPENIF
| OBJ_OPENLINK
,
733 Status
= NtCreateKey(&hKey
,
738 REG_OPTION_VOLATILE
| REG_OPTION_OPEN_LINK
,
740 dprintf(" NtCreateKey() called (Status %lx)\n",Status
);
741 if (!NT_SUCCESS(Status
))
743 dprintf("Could not open the link key. Please run the link create test first!\n");
747 dprintf("Delete link value\n");
748 RtlRosInitUnicodeStringFromLiteral(&ValueName
, L
"SymbolicLinkValue");
749 Status
= NtDeleteValueKey(hKey
,
751 dprintf(" NtDeleteValueKey() called (Status %lx)\n",Status
);
753 dprintf("Delete link key\n");
754 Status
=NtDeleteKey(hKey
);
755 dprintf(" NtDeleteKey() called (Status %lx)\n",Status
);
757 dprintf("Close link key\n");
764 OBJECT_ATTRIBUTES ObjectAttributes
;
765 UNICODE_STRING KeyName
;
768 TOKEN_PRIVILEGES NewPrivileges
;
772 Status
=NtOpenProcessToken(GetCurrentProcess()
773 ,TOKEN_ADJUST_PRIVILEGES
,&Token
);
774 // ,TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&Token);
775 dprintf("\t\t\t\tStatus =%x\n",Status
);
776 // bRes=LookupPrivilegeValueA(NULL,SE_RESTORE_NAME,&Luid);
777 // dprintf("\t\t\t\tbRes =%x\n",bRes);
778 NewPrivileges
.PrivilegeCount
= 1;
779 NewPrivileges
.Privileges
[0].Luid
= Luid
;
780 // NewPrivileges.Privileges[0].Luid.u.LowPart=18;
781 // NewPrivileges.Privileges[0].Luid.u.HighPart=0;
782 NewPrivileges
.Privileges
[0].Attributes
= SE_PRIVILEGE_ENABLED
;
784 // Status = NtAdjustPrivilegesToken(
785 bRes
= AdjustTokenPrivileges(
793 dprintf("\t\t\t\tbRes =%x\n",bRes
);
795 // Status=NtClose(Token);
796 // dprintf("\t\t\t\tStatus =%x\n",Status);
799 RtlRosInitUnicodeStringFromLiteral(&KeyName
,L
"test5");
800 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
802 Status
= NtLoadKey(HKEY_LOCAL_MACHINE
,&ObjectAttributes
);
803 dprintf("\t\t\t\tStatus =%x\n",Status
);
804 dwError
=RegLoadKey(HKEY_LOCAL_MACHINE
,"def"
806 dprintf("\t\t\t\tdwError =%x\n",dwError
);
808 dprintf("NtOpenKey \\Registry\\Machine : ");
809 RtlRosInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine");
810 InitializeObjectAttributes(&ObjectAttributes
,
812 OBJ_CASE_INSENSITIVE
,
815 Status
=NtOpenKey( &hKey
, MAXIMUM_ALLOWED
, &ObjectAttributes
);
816 dprintf("\t\t\tStatus =%x\n",Status
);
817 RtlRosInitUnicodeStringFromLiteral(&KeyName
,L
"test5");
818 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
820 Status
= NtLoadKey(hKey
,&ObjectAttributes
);
821 dprintf("\t\t\t\tStatus =%x\n",Status
);
826 HKEY hKey
= NULL
, hKey1
;
827 OBJECT_ATTRIBUTES ObjectAttributes
;
829 UNICODE_STRING KeyName
= ROS_STRING_INITIALIZER(L
"\\Registry");
830 ULONG Index
,Length
,i
;
831 KEY_BASIC_INFORMATION KeyInformation
[5];
832 KEY_VALUE_FULL_INFORMATION KeyValueInformation
[5];
834 dprintf("NtOpenKey \\Registry : ");
835 InitializeObjectAttributes(&ObjectAttributes
,
837 OBJ_CASE_INSENSITIVE
,
840 Status
=NtOpenKey( &hKey1
, MAXIMUM_ALLOWED
, &ObjectAttributes
);
841 dprintf("\t\t\t\tStatus =%x\n",Status
);
843 dprintf("NtQueryKey : ");
844 Status
= NtQueryKey(hKey1
, KeyBasicInformation
, &KeyInformation
[0], sizeof(KeyInformation
), &Length
);
845 dprintf("\t\t\t\t\tStatus =%x\n",Status
);
846 if (Status
== STATUS_SUCCESS
) {
847 dprintf("\tKey Name = ");
848 for (i
=0;i
<KeyInformation
[0].NameLength
/2;i
++)
849 dprintf("%C",KeyInformation
[0].Name
[i
]);
852 dprintf("NtEnumerateKey : \n");
854 while (Status
== STATUS_SUCCESS
) {
855 Status
= NtEnumerateKey(hKey1
,Index
++,KeyBasicInformation
,&KeyInformation
[0], sizeof(KeyInformation
),&Length
);
856 if (Status
== STATUS_SUCCESS
) {
857 dprintf("\tSubKey Name = ");
858 for (i
= 0; i
< KeyInformation
[0].NameLength
/ 2; i
++)
859 dprintf("%C",KeyInformation
[0].Name
[i
]);
863 dprintf("NtClose : ");
864 Status
= NtClose( hKey1
);
865 dprintf("\t\t\t\t\tStatus =%x\n",Status
);
867 NtClose(hKey
); // RobD - hKey unused so-far, should this have been hKey1 ???
869 dprintf("NtOpenKey \\Registry\\Machine : ");
870 RtlRosInitUnicodeStringFromLiteral(&KeyName
, L
"\\Registry\\Machine");
871 InitializeObjectAttributes(&ObjectAttributes
,
873 OBJ_CASE_INSENSITIVE
,
876 Status
= NtOpenKey(&hKey1
, MAXIMUM_ALLOWED
, &ObjectAttributes
);
877 dprintf("\t\t\tStatus =%x\n",Status
);
879 //Status of c0000001 opening \Registry\Machine\System\CurrentControlSet\Services\Tcpip\Linkage
881 // dprintf("NtOpenKey System\\CurrentControlSet\\Services\\Tcpip : ");
882 // RtlRosInitUnicodeStringFromLiteral(&KeyName, L"System\\CurrentControlSet\\Services\\Tcpip");
884 dprintf("NtOpenKey System\\ControlSet001\\Services\\Tcpip\\Parameters : ");
885 RtlRosInitUnicodeStringFromLiteral(&KeyName
, L
"System\\ControlSet001\\Services\\Tcpip\\Parameters");
887 dprintf("NtOpenKey System\\CurrentControlSet\\Services\\Tcpip : ");
888 RtlRosInitUnicodeStringFromLiteral(&KeyName
, L
"System\\CurrentControlSet\\Services\\Tcpip");
890 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
, hKey1
, NULL
);
891 Status
= NtOpenKey(&hKey
, KEY_READ
, &ObjectAttributes
);
892 dprintf("\t\t\tStatus =%x\n",Status
);
894 dprintf("NtQueryValueKey : ");
895 RtlRosInitUnicodeStringFromLiteral(&KeyName
, L
"NameServer");
896 Status
= NtQueryValueKey(hKey
, &KeyName
, KeyValueFullInformation
, &KeyValueInformation
[0], sizeof(KeyValueInformation
), &Length
);
897 dprintf("\t\t\t\tStatus =%x\n",Status
);
898 if (Status
== STATUS_SUCCESS
) {
899 dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
900 ,KeyValueInformation
[0].DataOffset
901 ,KeyValueInformation
[0].DataLength
902 ,KeyValueInformation
[0].NameLength
);
903 for (i
= 0; i
< 10 && i
< KeyValueInformation
[0].NameLength
/ 2; i
++)
904 dprintf("%C", KeyValueInformation
[0].Name
[i
]);
906 dprintf("\t\tType = %d\n", KeyValueInformation
[0].Type
);
907 if (KeyValueInformation
[0].Type
== REG_SZ
)
908 //dprintf("\t\tValue = %S\n", KeyValueInformation[0].Name + 1 + KeyValueInformation[0].NameLength / 2);
909 dprintf("\t\tValue = %S\n", KeyValueInformation
[0].Name
+ KeyValueInformation
[0].NameLength
/ 2);
911 dprintf("NtEnumerateValueKey : \n");
913 while (Status
== STATUS_SUCCESS
) {
914 Status
= NtEnumerateValueKey(hKey
, Index
++, KeyValueFullInformation
, &KeyValueInformation
[0], sizeof(KeyValueInformation
), &Length
);
915 if (Status
== STATUS_SUCCESS
) {
916 dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
917 ,KeyValueInformation
[0].DataOffset
918 ,KeyValueInformation
[0].DataLength
919 ,KeyValueInformation
[0].NameLength
);
920 for (i
= 0; i
< KeyValueInformation
[0].NameLength
/ 2; i
++)
921 dprintf("%C", KeyValueInformation
[0].Name
[i
]);
922 dprintf(", Type = %d\n", KeyValueInformation
[0].Type
);
923 if (KeyValueInformation
[0].Type
== REG_SZ
)
924 dprintf("\t\tValue = %S\n", ((char*)&KeyValueInformation
[0]+KeyValueInformation
[0].DataOffset
));
925 if (KeyValueInformation
[0].Type
== REG_DWORD
)
926 dprintf("\t\tValue = %X\n", *((DWORD
*)((char*)&KeyValueInformation
[0]+KeyValueInformation
[0].DataOffset
)));
929 dprintf("NtClose : ");
930 Status
= NtClose(hKey
);
931 dprintf("\t\t\t\t\tStatus =%x\n", Status
);
937 int main(int argc
, char* argv
[])
943 InputHandle
= GetStdHandle(STD_INPUT_HANDLE
);
944 OutputHandle
= GetStdHandle(STD_OUTPUT_HANDLE
);
947 dprintf("choose test :\n");
948 dprintf(" 0=Exit\n");
949 dprintf(" 1=Ntxxx read functions\n");
950 dprintf(" 2=Ntxxx write functions : volatile keys\n");
951 dprintf(" 3=Ntxxx write functions : non volatile keys\n");
952 dprintf(" 4=Regxxx functions\n");
953 dprintf(" 5=FlushKey \n");
954 dprintf(" 6=Registry link create test\n");
955 dprintf(" 7=Registry link delete test\n");
956 dprintf(" 8=Not available\n");
957 dprintf(" 9=Ntxx read tcp/ip key test\n");
958 ReadConsoleA(InputHandle
, Buffer
, 3, &Result
, NULL
) ;