mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 16:52:59 +00:00
added test for NtFlushKey
added a loop, allowing to make several tests before exiting. svn path=/trunk/; revision=1437
This commit is contained in:
parent
e53fb528db
commit
c07ef00211
1 changed files with 82 additions and 37 deletions
|
@ -59,10 +59,6 @@ void test1(void)
|
||||||
KEY_BASIC_INFORMATION KeyInformation[5];
|
KEY_BASIC_INFORMATION KeyInformation[5];
|
||||||
KEY_VALUE_FULL_INFORMATION KeyValueInformation[5];
|
KEY_VALUE_FULL_INFORMATION KeyValueInformation[5];
|
||||||
|
|
||||||
AllocConsole();
|
|
||||||
InputHandle = GetStdHandle(STD_INPUT_HANDLE);
|
|
||||||
OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
||||||
|
|
||||||
dprintf("NtOpenKey \\Registry : ");
|
dprintf("NtOpenKey \\Registry : ");
|
||||||
RtlInitUnicodeString(&KeyName, L"\\Registry");
|
RtlInitUnicodeString(&KeyName, L"\\Registry");
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
@ -587,28 +583,54 @@ void test4(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void test5(void)
|
void test5(void)
|
||||||
|
{
|
||||||
|
HKEY hKey,hKey1;
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
UNICODE_STRING KeyName,ValueName;
|
||||||
|
NTSTATUS Status;
|
||||||
|
KEY_VALUE_FULL_INFORMATION KeyValueInformation[5];
|
||||||
|
ULONG Index,Length,i;
|
||||||
|
char Buffer[10];
|
||||||
|
DWORD Result;
|
||||||
|
dprintf("NtOpenKey : \n");
|
||||||
|
dprintf(" \\Registry\\Machine\\Software\\reactos : ");
|
||||||
|
RtlInitUnicodeString(&KeyName,L"\\Registry\\Machine\\Software\\reactos");
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
|
||||||
|
, NULL, NULL);
|
||||||
|
Status=NtOpenKey( &hKey, KEY_ALL_ACCESS, &ObjectAttributes);
|
||||||
|
dprintf("\t\tStatus=%x\n",Status);
|
||||||
|
dprintf("NtFlushKey : \n");
|
||||||
|
Status = NtFlushKey(hKey);
|
||||||
|
dprintf("\t\tStatus=%x\n",Status);
|
||||||
|
dprintf("NtCloseKey : \n");
|
||||||
|
Status=NtClose(hKey);
|
||||||
|
dprintf("\t\tStatus=%x\n",Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test6(void)
|
||||||
{
|
{
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
UNICODE_STRING KeyName;
|
UNICODE_STRING KeyName;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
LONG dwError;
|
LONG dwError;
|
||||||
TOKEN_PRIVILEGES NewPrivileges;
|
TOKEN_PRIVILEGES NewPrivileges;
|
||||||
HANDLE Token;
|
HANDLE Token,hKey;
|
||||||
LUID Luid;
|
LUID Luid;
|
||||||
BOOLEAN bRes;
|
BOOLEAN bRes;
|
||||||
Status=NtOpenProcessToken(GetCurrentProcess()
|
Status=NtOpenProcessToken(GetCurrentProcess()
|
||||||
,TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&Token);
|
,TOKEN_ADJUST_PRIVILEGES,&Token);
|
||||||
|
// ,TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&Token);
|
||||||
dprintf("\t\t\t\tStatus =%x\n",Status);
|
dprintf("\t\t\t\tStatus =%x\n",Status);
|
||||||
/*
|
// bRes=LookupPrivilegeValueA(NULL,SE_RESTORE_NAME,&Luid);
|
||||||
bRes=LookupPrivilegeValueA(NULL,SE_RESTORE_NAME,&Luid);
|
// dprintf("\t\t\t\tbRes =%x\n",bRes);
|
||||||
dprintf("\t\t\t\tbRes =%x\n",bRes);
|
|
||||||
*/
|
|
||||||
NewPrivileges.PrivilegeCount = 1;
|
NewPrivileges.PrivilegeCount = 1;
|
||||||
NewPrivileges.Privileges[0].Luid = Luid;
|
NewPrivileges.Privileges[0].Luid = Luid;
|
||||||
|
// NewPrivileges.Privileges[0].Luid.u.LowPart=18;
|
||||||
|
// NewPrivileges.Privileges[0].Luid.u.HighPart=0;
|
||||||
NewPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
NewPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||||
|
|
||||||
// Status = NtAdjustPrivilegesToken(
|
// Status = NtAdjustPrivilegesToken(
|
||||||
Status = AdjustTokenPrivileges(
|
bRes = AdjustTokenPrivileges(
|
||||||
Token,
|
Token,
|
||||||
FALSE,
|
FALSE,
|
||||||
&NewPrivileges,
|
&NewPrivileges,
|
||||||
|
@ -616,10 +638,10 @@ void test5(void)
|
||||||
NULL,
|
NULL,
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
dprintf("\t\t\t\tStatus =%x\n",Status);
|
dprintf("\t\t\t\tbRes =%x\n",bRes);
|
||||||
|
|
||||||
Status=NtClose(Token);
|
// Status=NtClose(Token);
|
||||||
dprintf("\t\t\t\tStatus =%x\n",Status);
|
// dprintf("\t\t\t\tStatus =%x\n",Status);
|
||||||
|
|
||||||
|
|
||||||
RtlInitUnicodeString(&KeyName,L"test5");
|
RtlInitUnicodeString(&KeyName,L"test5");
|
||||||
|
@ -631,6 +653,20 @@ void test5(void)
|
||||||
,"test5");
|
,"test5");
|
||||||
dprintf("\t\t\t\tdwError =%x\n",dwError);
|
dprintf("\t\t\t\tdwError =%x\n",dwError);
|
||||||
|
|
||||||
|
dprintf("NtOpenKey \\Registry\\Machine : ");
|
||||||
|
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine");
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
&KeyName,
|
||||||
|
OBJ_CASE_INSENSITIVE,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
Status=NtOpenKey( &hKey, MAXIMUM_ALLOWED, &ObjectAttributes);
|
||||||
|
dprintf("\t\t\tStatus =%x\n",Status);
|
||||||
|
RtlInitUnicodeString(&KeyName,L"test5");
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE
|
||||||
|
, NULL, NULL);
|
||||||
|
Status = NtLoadKey(hKey,&ObjectAttributes);
|
||||||
|
dprintf("\t\t\t\tStatus =%x\n",Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
|
@ -641,15 +677,20 @@ int main(int argc, char* argv[])
|
||||||
AllocConsole();
|
AllocConsole();
|
||||||
InputHandle = GetStdHandle(STD_INPUT_HANDLE);
|
InputHandle = GetStdHandle(STD_INPUT_HANDLE);
|
||||||
OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
dprintf("choose test :\n");
|
dprintf("choose test :\n");
|
||||||
|
dprintf(" 0=Exit\n");
|
||||||
dprintf(" 1=Ntxxx read functions\n");
|
dprintf(" 1=Ntxxx read functions\n");
|
||||||
dprintf(" 2=Ntxxx write functions : volatile keys\n");
|
dprintf(" 2=Ntxxx write functions : volatile keys\n");
|
||||||
dprintf(" 3=Ntxxx write functions : non volatile keys\n");
|
dprintf(" 3=Ntxxx write functions : non volatile keys\n");
|
||||||
dprintf(" 4=Regxxx functions\n");
|
dprintf(" 4=Regxxx functions\n");
|
||||||
|
dprintf(" 5=FlushKey \n");
|
||||||
ReadConsoleA(InputHandle, Buffer, 3, &Result, NULL) ;
|
ReadConsoleA(InputHandle, Buffer, 3, &Result, NULL) ;
|
||||||
switch (Buffer[0])
|
switch (Buffer[0])
|
||||||
{
|
{
|
||||||
|
case '0':
|
||||||
|
return(0);
|
||||||
case '1':
|
case '1':
|
||||||
test1();
|
test1();
|
||||||
break;
|
break;
|
||||||
|
@ -665,6 +706,10 @@ int main(int argc, char* argv[])
|
||||||
case '5':
|
case '5':
|
||||||
test5();
|
test5();
|
||||||
break;
|
break;
|
||||||
|
case '6':
|
||||||
|
test6();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue