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
;
59 KEY_BASIC_INFORMATION KeyInformation
[5];
60 KEY_VALUE_FULL_INFORMATION KeyValueInformation
[5];
63 InputHandle
= GetStdHandle(STD_INPUT_HANDLE
);
64 OutputHandle
= GetStdHandle(STD_OUTPUT_HANDLE
);
66 dprintf("NtOpenKey \\Registry : ");
67 RtlInitUnicodeString(&KeyName
, L
"\\Registry");
68 InitializeObjectAttributes(&ObjectAttributes
,
73 Status
=NtOpenKey( &hKey1
, MAXIMUM_ALLOWED
, &ObjectAttributes
);
74 dprintf("\t\t\t\tStatus =%x\n",Status
);
77 dprintf("NtQueryKey : ");
78 Status
=NtQueryKey(hKey1
,KeyBasicInformation
79 ,&KeyInformation
[0], sizeof(KeyInformation
)
81 dprintf("\t\t\t\t\tStatus =%x\n",Status
);
82 if (Status
== STATUS_SUCCESS
)
84 dprintf("\tKey Name = ");
85 for (i
=0;i
<KeyInformation
[0].NameLength
/2;i
++)
86 dprintf("%C",KeyInformation
[0].Name
[i
]);
89 dprintf("NtEnumerateKey : \n");
91 while(Status
== STATUS_SUCCESS
)
93 Status
=NtEnumerateKey(hKey1
,Index
++,KeyBasicInformation
94 ,&KeyInformation
[0], sizeof(KeyInformation
)
96 if(Status
== STATUS_SUCCESS
)
98 dprintf("\tSubKey Name = ");
99 for (i
=0;i
<KeyInformation
[0].NameLength
/2;i
++)
100 dprintf("%C",KeyInformation
[0].Name
[i
]);
104 dprintf("NtClose : ");
105 Status
= NtClose( hKey1
);
106 dprintf("\t\t\t\t\tStatus =%x\n",Status
);
110 dprintf("NtOpenKey \\Registry\\Machine : ");
111 RtlInitUnicodeString(&KeyName
, L
"\\Registry\\Machine");
112 InitializeObjectAttributes(&ObjectAttributes
,
114 OBJ_CASE_INSENSITIVE
,
117 Status
=NtOpenKey( &hKey1
, MAXIMUM_ALLOWED
, &ObjectAttributes
);
118 dprintf("\t\t\tStatus =%x\n",Status
);
120 dprintf("NtOpenKey System\\Setup : ");
121 RtlInitUnicodeString(&KeyName
, L
"System\\Setup");
122 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
124 Status
= NtOpenKey ( &hKey
, KEY_READ
, &ObjectAttributes
);
125 dprintf("\t\t\tStatus =%x\n",Status
);
128 dprintf("NtQueryValueKey : ");
129 RtlInitUnicodeString(&KeyName
, L
"CmdLine");
130 Status
=NtQueryValueKey(hKey
,&KeyName
,KeyValueFullInformation
131 ,&KeyValueInformation
[0], sizeof(KeyValueInformation
)
133 dprintf("\t\t\t\tStatus =%x\n",Status
);
134 if (Status
== STATUS_SUCCESS
)
136 dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
137 ,KeyValueInformation
[0].DataOffset
138 ,KeyValueInformation
[0].DataLength
139 ,KeyValueInformation
[0].NameLength
);
140 for (i
=0;i
<10 && i
<KeyValueInformation
[0].NameLength
/2;i
++)
141 dprintf("%C",KeyValueInformation
[0].Name
[i
]);
143 dprintf("\t\tType = %d\n",KeyValueInformation
[0].Type
);
144 if (KeyValueInformation
[0].Type
== REG_SZ
)
145 dprintf("\t\tValue = %S\n",KeyValueInformation
[0].Name
+1
146 +KeyValueInformation
[0].NameLength
/2);
148 dprintf("NtEnumerateValueKey : \n");
150 while(Status
== STATUS_SUCCESS
)
152 Status
=NtEnumerateValueKey(hKey
,Index
++,KeyValueFullInformation
153 ,&KeyValueInformation
[0], sizeof(KeyValueInformation
)
155 if(Status
== STATUS_SUCCESS
)
157 dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
158 ,KeyValueInformation
[0].DataOffset
159 ,KeyValueInformation
[0].DataLength
160 ,KeyValueInformation
[0].NameLength
);
161 for (i
=0;i
<KeyValueInformation
[0].NameLength
/2;i
++)
162 dprintf("%C",KeyValueInformation
[0].Name
[i
]);
163 dprintf(", Type = %d\n",KeyValueInformation
[0].Type
);
164 if (KeyValueInformation
[0].Type
== REG_SZ
)
165 dprintf("\t\tValue = %S\n",((char*)&KeyValueInformation
[0]
166 +KeyValueInformation
[0].DataOffset
));
169 dprintf("NtClose : ");
170 Status
= NtClose( hKey
);
171 dprintf("\t\t\t\t\tStatus =%x\n",Status
);
179 OBJECT_ATTRIBUTES ObjectAttributes
;
180 UNICODE_STRING KeyName
,ValueName
;
182 KEY_VALUE_FULL_INFORMATION KeyValueInformation
[5];
183 ULONG Index
,Length
,i
;
186 dprintf("NtCreateKey volatile: \n");
187 dprintf(" \\Registry\\Machine\\Software\\test2reactos: ");
188 RtlInitUnicodeString(&KeyName
, L
"\\Registry\\Machine\\Software\\test2reactos");
189 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
191 Status
= NtCreateKey ( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
192 ,0,NULL
,REG_OPTION_VOLATILE
,NULL
);
193 dprintf("\t\tStatus=%x\n",Status
);
195 do_enumeratekey(L
"\\Registry\\Machine\\Software");
196 dprintf(" ...\\test2 :");
197 RtlInitUnicodeString(&KeyName
, L
"\\Registry\\Machine\\Software\\test2reactos\\test2");
198 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
200 Status
= NtCreateKey ( &hKey1
, KEY_ALL_ACCESS
, &ObjectAttributes
201 ,0,NULL
,REG_OPTION_VOLATILE
,NULL
);
202 dprintf("\t\t\t\t\tStatus=%x\n",Status
);
203 dprintf(" ...\\TestVolatile :");
204 RtlInitUnicodeString(&KeyName
, L
"TestVolatile");
205 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
207 Status
= NtCreateKey ( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
208 ,0,NULL
,REG_OPTION_VOLATILE
,NULL
);
209 dprintf("\t\t\t\tStatus=%x\n",Status
);
211 RtlInitUnicodeString(&ValueName
, L
"TestREG_SZ");
212 dprintf("NtSetValueKey reg_sz: ");
213 Status
=NtSetValueKey(hKey
,&ValueName
,0,REG_SZ
,(PVOID
)L
"Test Reg_sz",24);
214 dprintf("\t\t\t\tStatus=%x\n",Status
);
215 RtlInitUnicodeString(&ValueName
, L
"TestDWORD");
216 dprintf("NtSetValueKey reg_dword: ");
217 Status
=NtSetValueKey(hKey
,&ValueName
,0,REG_DWORD
,(PVOID
)"reac",4);
218 dprintf("\t\t\tStatus=%x\n",Status
);
220 dprintf("NtOpenKey \\Registry\\Machine\\Software\\test2reactos\\test2\\TestVolatile : ");
221 RtlInitUnicodeString(&KeyName
, L
"\\Registry\\Machine\\Software\\test2reactos\\test2\\TestVolatile");
222 InitializeObjectAttributes(&ObjectAttributes
,
224 OBJ_CASE_INSENSITIVE
,
227 Status
=NtOpenKey( &hKey
, MAXIMUM_ALLOWED
, &ObjectAttributes
);
228 dprintf("\t\t\t\tStatus =%x\n",Status
);
231 dprintf("NtEnumerateValueKey : \n");
233 while(Status
== STATUS_SUCCESS
)
235 Status
=NtEnumerateValueKey(hKey
,Index
++,KeyValueFullInformation
236 ,&KeyValueInformation
[0], sizeof(KeyValueInformation
)
238 if(Status
== STATUS_SUCCESS
)
240 dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
241 ,KeyValueInformation
[0].DataOffset
242 ,KeyValueInformation
[0].DataLength
243 ,KeyValueInformation
[0].NameLength
);
244 for (i
=0;i
<KeyValueInformation
[0].NameLength
/2;i
++)
245 dprintf("%C",KeyValueInformation
[0].Name
[i
]);
246 dprintf(", Type = %d\n",KeyValueInformation
[0].Type
);
247 if (KeyValueInformation
[0].Type
== REG_SZ
)
248 dprintf("\t\tValue = %S\n",((char*)&KeyValueInformation
[0]
249 +KeyValueInformation
[0].DataOffset
));
254 dprintf("delete \\Registry\\Machine\\software\\test2reactos ?");
255 ReadConsoleA(InputHandle
, Buffer
, 3, &Result
, NULL
) ;
256 if (Buffer
[0] != 'y' && Buffer
[0] != 'Y') return;
257 RtlInitUnicodeString(&KeyName
, L
"\\Registry\\Machine\\Software\\test2reactos\\test2\\TestVolatile");
258 InitializeObjectAttributes(&ObjectAttributes
,
260 OBJ_CASE_INSENSITIVE
,
263 dprintf("NtOpenKey : ");
264 Status
=NtOpenKey( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
);
265 dprintf("\t\t\t\tStatus =%x\n",Status
);
266 dprintf("NtDeleteKey : ");
267 Status
=NtDeleteKey(hKey
);
268 dprintf("\t\t\t\tStatus =%x\n",Status
);
270 RtlInitUnicodeString(&KeyName
, L
"\\Registry\\Machine\\Software\\test2reactos\\test2");
271 InitializeObjectAttributes(&ObjectAttributes
,
273 OBJ_CASE_INSENSITIVE
,
276 dprintf("NtOpenKey : ");
277 Status
=NtOpenKey( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
);
278 dprintf("\t\t\t\tStatus =%x\n",Status
);
279 dprintf("NtDeleteKey : ");
280 Status
=NtDeleteKey(hKey
);
281 dprintf("\t\t\t\tStatus =%x\n",Status
);
283 RtlInitUnicodeString(&KeyName
, L
"\\Registry\\Machine\\Software\\test2reactos");
284 InitializeObjectAttributes(&ObjectAttributes
,
286 OBJ_CASE_INSENSITIVE
,
289 dprintf("NtOpenKey : ");
290 Status
=NtOpenKey( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
);
291 dprintf("\t\t\t\tStatus =%x\n",Status
);
292 dprintf("NtDeleteKey : ");
293 Status
=NtDeleteKey(hKey
);
294 dprintf("\t\t\t\tStatus =%x\n",Status
);
301 OBJECT_ATTRIBUTES ObjectAttributes
;
302 UNICODE_STRING KeyName
,ValueName
;
304 KEY_VALUE_FULL_INFORMATION KeyValueInformation
[5];
305 ULONG Index
,Length
,i
;
308 dprintf("NtCreateKey non volatile: \n");
309 dprintf(" \\Registry\\Machine\\Software\\test3reactos: ");
310 RtlInitUnicodeString(&KeyName
, L
"\\Registry\\Machine\\Software\\test3reactos");
311 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
313 Status
= NtCreateKey ( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
314 ,0,NULL
,REG_OPTION_NON_VOLATILE
,NULL
);
315 dprintf("\t\tStatus=%x\n",Status
);
317 do_enumeratekey(L
"\\Registry\\Machine\\Software");
318 dprintf("NtOpenKey: ");
319 Status
=NtOpenKey( &hKey
, MAXIMUM_ALLOWED
, &ObjectAttributes
);
320 dprintf("\t\tStatus=%x\n",Status
);
322 dprintf(" ...\\test3 :");
323 RtlInitUnicodeString(&KeyName
, L
"\\Registry\\Machine\\Software\\test3reactos\\test3");
324 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
326 Status
= NtCreateKey ( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
327 ,0,NULL
,REG_OPTION_NON_VOLATILE
,NULL
);
328 dprintf("\t\t\t\t\tStatus=%x\n",Status
);
329 dprintf("NtOpenKey: ");
330 Status
=NtOpenKey( &hKey1
, MAXIMUM_ALLOWED
, &ObjectAttributes
);
331 dprintf("\t\tStatus=%x\n",Status
);
333 dprintf(" ...\\testNonVolatile :");
334 RtlInitUnicodeString(&KeyName
, L
"TestNonVolatile");
335 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
337 Status
= NtCreateKey ( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
338 ,0,NULL
,REG_OPTION_NON_VOLATILE
,NULL
);
339 dprintf("\t\t\t\tStatus=%x\n",Status
);
341 RtlInitUnicodeString(&ValueName
, L
"TestREG_SZ");
342 dprintf("NtSetValueKey reg_sz: ");
343 Status
=NtSetValueKey(hKey
,&ValueName
,0,REG_SZ
,(PVOID
)L
"Test Reg_sz",24);
344 dprintf("\t\t\t\tStatus=%x\n",Status
);
345 RtlInitUnicodeString(&ValueName
, L
"TestDWORD");
346 dprintf("NtSetValueKey reg_dword: ");
347 Status
=NtSetValueKey(hKey
,&ValueName
,0,REG_DWORD
,(PVOID
)"reac",4);
348 dprintf("\t\t\tStatus=%x\n",Status
);
350 dprintf("NtOpenKey \\Registry\\Machine\\Software\\test3reactos\\test3\\testNonVolatile : ");
351 RtlInitUnicodeString(&KeyName
, L
"\\Registry\\Machine\\Software\\test3reactos\\test3\\testNonVolatile");
352 InitializeObjectAttributes(&ObjectAttributes
,
354 OBJ_CASE_INSENSITIVE
,
357 Status
=NtOpenKey( &hKey
, MAXIMUM_ALLOWED
, &ObjectAttributes
);
358 dprintf("\t\t\t\tStatus =%x\n",Status
);
361 dprintf("NtEnumerateValueKey : \n");
363 while(Status
== STATUS_SUCCESS
)
365 Status
=NtEnumerateValueKey(hKey
,Index
++,KeyValueFullInformation
366 ,&KeyValueInformation
[0], sizeof(KeyValueInformation
)
368 if(Status
== STATUS_SUCCESS
)
370 dprintf("\tValue:DO=%d, DL=%d, NL=%d, Name = "
371 ,KeyValueInformation
[0].DataOffset
372 ,KeyValueInformation
[0].DataLength
373 ,KeyValueInformation
[0].NameLength
);
374 for (i
=0;i
<KeyValueInformation
[0].NameLength
/2;i
++)
375 dprintf("%C",KeyValueInformation
[0].Name
[i
]);
376 dprintf(", Type = %d\n",KeyValueInformation
[0].Type
);
377 if (KeyValueInformation
[0].Type
== REG_SZ
)
378 dprintf("\t\tValue = %S\n",((char*)&KeyValueInformation
[0]
379 +KeyValueInformation
[0].DataOffset
));
384 dprintf("delete \\Registry\\Machine\\software\\test3reactos ?");
385 ReadConsoleA(InputHandle
, Buffer
, 3, &Result
, NULL
) ;
386 if (Buffer
[0] != 'y' && Buffer
[0] != 'Y') return;
387 RtlInitUnicodeString(&KeyName
, L
"\\Registry\\Machine\\Software\\test3reactos\\test3\\testNonvolatile");
388 InitializeObjectAttributes(&ObjectAttributes
,
390 OBJ_CASE_INSENSITIVE
,
393 dprintf("NtOpenKey : ");
394 Status
=NtOpenKey( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
);
395 dprintf("\t\t\t\tStatus =%x\n",Status
);
396 dprintf("NtDeleteKey : ");
397 Status
=NtDeleteKey(hKey
);
398 dprintf("\t\t\t\tStatus =%x\n",Status
);
399 RtlInitUnicodeString(&KeyName
, L
"\\Registry\\Machine\\Software\\test3reactos\\test3");
400 InitializeObjectAttributes(&ObjectAttributes
,
402 OBJ_CASE_INSENSITIVE
,
405 dprintf("NtOpenKey : ");
406 Status
=NtOpenKey( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
);
407 dprintf("\t\t\t\tStatus =%x\n",Status
);
408 dprintf("NtDeleteKey : ");
409 Status
=NtDeleteKey(hKey
);
410 dprintf("\t\t\t\tStatus =%x\n",Status
);
412 RtlInitUnicodeString(&KeyName
, L
"\\Registry\\Machine\\Software\\test3reactos");
413 InitializeObjectAttributes(&ObjectAttributes
,
415 OBJ_CASE_INSENSITIVE
,
418 dprintf("NtOpenKey : ");
419 Status
=NtOpenKey( &hKey
, KEY_ALL_ACCESS
, &ObjectAttributes
);
420 dprintf("\t\t\t\tStatus =%x\n",Status
);
421 dprintf("NtDeleteKey : ");
422 Status
=NtDeleteKey(hKey
);
423 dprintf("\t\t\t\tStatus =%x\n",Status
);
429 HKEY hKey
= NULL
,hKey1
;
432 DWORD RegDataType
, RegDataSize
;
433 BOOL GlobalFifoEnable
;
435 DWORD RegDisposition
;
442 DWORD cchMaxValueName
;
443 DWORD cbMaxValueData
;
444 DWORD cbSecurityDescriptor
;
445 FILETIME ftLastWriteTime
;
446 SYSTEMTIME LastWriteTime
;
448 dprintf ("RegOpenKeyExW HKLM\\System\\Setup: ");
449 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
454 dprintf("\t\tdwError =%x\n",dwError
);
455 if (dwError
== ERROR_SUCCESS
)
457 dprintf("RegQueryInfoKeyW: ");
459 dwError
= RegQueryInfoKeyW(hKey1
460 , szClass
, &cchClass
, NULL
, &cSubKeys
461 , &cchMaxSubkey
, &cchMaxClass
, &cValues
, &cchMaxValueName
462 , &cbMaxValueData
, &cbSecurityDescriptor
, &ftLastWriteTime
);
463 dprintf ("\t\t\t\tdwError %x\n", dwError
);
464 FileTimeToSystemTime(&ftLastWriteTime
,&LastWriteTime
);
465 dprintf ("\tnb of subkeys=%d,last write : %d/%d/%d %d:%02.2d'%02.2d''%03.3d\n",cSubKeys
466 ,LastWriteTime
.wMonth
470 ,LastWriteTime
.wMinute
471 ,LastWriteTime
.wSecond
472 ,LastWriteTime
.wMilliseconds
477 dprintf ("RegOpenKeyExW: ");
478 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
479 L
"System\\ControlSet001\\Services\\Serial",
483 dprintf ("\t\t\t\t\tdwError %x\n", dwError
);
484 RegDataSize
= sizeof(GlobalFifoEnable
);
485 if (dwError
== ERROR_SUCCESS
)
487 dprintf ("RegQueryValueExW: ");
488 dwError
= RegQueryValueExW(hKey
,
492 (PBYTE
)&GlobalFifoEnable
,
494 dprintf("\t\t\t\tdwError =%x\n",dwError
);
497 dprintf("\tValue:DT=%d, DS=%d, Value=%d\n"
503 dprintf ("RegCreateKeyExW: ");
504 dwError
= RegCreateKeyExW(hKey
,
505 L
"Parameters\\Serial001",
514 dprintf ("\t\t\t\tdwError %x\n", dwError
);
516 dprintf ("RegCreateKeyExW: ");
517 dwError
= RegCreateKeyExW (HKEY_LOCAL_MACHINE
,
518 L
"Software\\test4reactos\\test",
521 REG_OPTION_NON_VOLATILE
,
527 dprintf ("\t\t\t\tdwError %x ", dwError
);
528 dprintf ("dwDisposition %x\n", dwDisposition
);
529 if (dwError
== ERROR_SUCCESS
)
531 dprintf ("RegSetValueExW: ");
532 dwError
= RegSetValueExW (hKey
,
536 (BYTE
*)L
"TestString",
539 dprintf ("\t\t\t\tdwError %x\n", dwError
);
540 dprintf ("RegCloseKey: ");
541 dwError
= RegCloseKey (hKey
);
542 dprintf ("\t\t\t\t\tdwError %x\n", dwError
);
548 dprintf ("RegCreateKeyExW: ");
549 dwError
= RegCreateKeyExW (HKEY_LOCAL_MACHINE
,
559 dprintf ("\t\t\t\tdwError %x ", dwError
);
560 dprintf ("dwDisposition %x\n", dwDisposition
);
563 if (dwError
== ERROR_SUCCESS
)
565 dprintf("RegQueryInfoKeyW: ");
567 dwError
= RegQueryInfoKeyW(hKey
568 , szClass
, &cchClass
, NULL
, &cSubKeys
569 , &cchMaxSubkey
, &cchMaxClass
, &cValues
, &cchMaxValueName
570 , &cbMaxValueData
, &cbSecurityDescriptor
, &ftLastWriteTime
);
571 dprintf ("\t\t\t\tdwError %x\n", dwError
);
572 FileTimeToSystemTime(&ftLastWriteTime
,&LastWriteTime
);
573 dprintf ("\tnb of subkeys=%d,last write : %d/%d/%d %d:%02.2d'%02.2d''%03.3d\n",cSubKeys
574 ,LastWriteTime
.wMonth
578 ,LastWriteTime
.wMinute
579 ,LastWriteTime
.wSecond
580 ,LastWriteTime
.wMilliseconds
582 dprintf ("RegCloseKey: ");
583 dwError
= RegCloseKey (hKey
);
584 dprintf ("\t\t\t\t\tdwError %x\n", dwError
);
586 dprintf ("\nTests done...\n");
591 OBJECT_ATTRIBUTES ObjectAttributes
;
592 UNICODE_STRING KeyName
;
595 TOKEN_PRIVILEGES NewPrivileges
;
599 Status
=NtOpenProcessToken(GetCurrentProcess()
600 ,TOKEN_ADJUST_PRIVILEGES
|TOKEN_QUERY
,&Token
);
601 dprintf("\t\t\t\tStatus =%x\n",Status
);
603 bRes=LookupPrivilegeValueA(NULL,SE_RESTORE_NAME,&Luid);
604 dprintf("\t\t\t\tbRes =%x\n",bRes);
606 NewPrivileges
.PrivilegeCount
= 1;
607 NewPrivileges
.Privileges
[0].Luid
= Luid
;
608 NewPrivileges
.Privileges
[0].Attributes
= SE_PRIVILEGE_ENABLED
;
610 // Status = NtAdjustPrivilegesToken(
611 Status
= AdjustTokenPrivileges(
619 dprintf("\t\t\t\tStatus =%x\n",Status
);
621 Status
=NtClose(Token
);
622 dprintf("\t\t\t\tStatus =%x\n",Status
);
625 RtlInitUnicodeString(&KeyName
,L
"test5");
626 InitializeObjectAttributes(&ObjectAttributes
, &KeyName
, OBJ_CASE_INSENSITIVE
628 Status
= NtLoadKey(HKEY_LOCAL_MACHINE
,&ObjectAttributes
);
629 dprintf("\t\t\t\tStatus =%x\n",Status
);
630 dwError
=RegLoadKey(HKEY_LOCAL_MACHINE
,"def"
632 dprintf("\t\t\t\tdwError =%x\n",dwError
);
636 int main(int argc
, char* argv
[])
642 InputHandle
= GetStdHandle(STD_INPUT_HANDLE
);
643 OutputHandle
= GetStdHandle(STD_OUTPUT_HANDLE
);
645 dprintf("choose test :\n");
646 dprintf(" 1=Ntxxx read functions\n");
647 dprintf(" 2=Ntxxx write functions : volatile keys\n");
648 dprintf(" 3=Ntxxx write functions : non volatile keys\n");
649 dprintf(" 4=Regxxx functions\n");
650 ReadConsoleA(InputHandle
, Buffer
, 3, &Result
, NULL
) ;