mirror of
https://github.com/reactos/reactos.git
synced 2025-01-07 14:51:00 +00:00
[NTDLL_APITEST]
- Show that NtOpenKey and NtCreateKey accept, but ignore, KEY_WOW64_32KEY and KEY_WOW64_64KEY CORE-9691 svn path=/trunk/; revision=72974
This commit is contained in:
parent
9bd7a7db6d
commit
0d36dcef60
3 changed files with 114 additions and 0 deletions
|
@ -5,6 +5,7 @@ list(APPEND SOURCE
|
|||
NtApphelpCacheControl.c
|
||||
NtContinue.c
|
||||
NtCreateFile.c
|
||||
NtCreateKey.c
|
||||
NtCreateThread.c
|
||||
NtDeleteKey.c
|
||||
NtFreeVirtualMemory.c
|
||||
|
|
111
rostests/apitests/ntdll/NtCreateKey.c
Normal file
111
rostests/apitests/ntdll/NtCreateKey.c
Normal file
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
* PROJECT: ReactOS API tests
|
||||
* LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
|
||||
* PURPOSE: Test for NtCreateKey
|
||||
* PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
|
||||
*/
|
||||
|
||||
#include <apitest.h>
|
||||
|
||||
#include <winreg.h>
|
||||
#include <ndk/cmfuncs.h>
|
||||
#include <ndk/obfuncs.h>
|
||||
|
||||
static
|
||||
VOID
|
||||
VerifyAccess_(
|
||||
_In_ HANDLE Handle,
|
||||
_In_ ACCESS_MASK ExpectedAccess,
|
||||
_In_ PCSTR File,
|
||||
_In_ INT Line)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
OBJECT_BASIC_INFORMATION BasicInfo;
|
||||
ULONG Length;
|
||||
|
||||
Status = NtQueryObject(Handle,
|
||||
ObjectBasicInformation,
|
||||
&BasicInfo,
|
||||
sizeof(BasicInfo),
|
||||
&Length);
|
||||
ok_(File, Line)(Status == STATUS_SUCCESS, "NtQueryObject returned 0x%lx\n", Status);
|
||||
ok_(File, Line)(BasicInfo.GrantedAccess == ExpectedAccess,
|
||||
"GrantedAccess is 0x%lx, expected 0x%lx\n",
|
||||
BasicInfo.GrantedAccess, ExpectedAccess);
|
||||
}
|
||||
#define VerifyAccess(h, e) VerifyAccess_(h, e, __FILE__, __LINE__)
|
||||
|
||||
static
|
||||
VOID
|
||||
TestCreateOpen_(
|
||||
_In_ ACCESS_MASK DesiredAccess,
|
||||
_In_ ACCESS_MASK ExpectedAccess,
|
||||
_In_ NTSTATUS ExpectedStatus,
|
||||
_In_ PCSTR File,
|
||||
_In_ INT Line)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
HANDLE KeyHandle;
|
||||
UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\Software");
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&KeyName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
Status = NtCreateKey(&KeyHandle,
|
||||
DesiredAccess,
|
||||
&ObjectAttributes,
|
||||
0,
|
||||
NULL,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
NULL);
|
||||
ok_(File, Line)(Status == ExpectedStatus,
|
||||
"NtCreateKey returned 0x%lx, expected 0x%lx\n",
|
||||
Status, ExpectedStatus);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
VerifyAccess_(KeyHandle, ExpectedAccess, File, Line);
|
||||
Status = NtClose(KeyHandle);
|
||||
ok_(File, Line)(Status == STATUS_SUCCESS,
|
||||
"NtClose from NtCreateKey returned 0x%lx\n",
|
||||
Status);
|
||||
}
|
||||
else if (NT_SUCCESS(ExpectedStatus))
|
||||
{
|
||||
skip_(File, Line)("NtCreateKey failed, skipping\n");
|
||||
}
|
||||
|
||||
Status = NtOpenKey(&KeyHandle,
|
||||
DesiredAccess,
|
||||
&ObjectAttributes);
|
||||
ok_(File, Line)(Status == ExpectedStatus,
|
||||
"NtOpenKey returned 0x%lx, expected 0x%lx\n",
|
||||
Status, ExpectedStatus);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
VerifyAccess_(KeyHandle, ExpectedAccess, File, Line);
|
||||
Status = NtClose(KeyHandle);
|
||||
ok_(File, Line)(Status == STATUS_SUCCESS,
|
||||
"NtClose from NtOpenKey returned 0x%lx\n",
|
||||
Status);
|
||||
}
|
||||
else if (NT_SUCCESS(ExpectedStatus))
|
||||
{
|
||||
skip_(File, Line)("NtOpenKey failed, skipping\n");
|
||||
}
|
||||
}
|
||||
#define TestCreateOpen(d, ea, es) TestCreateOpen_(d, ea, es, __FILE__, __LINE__)
|
||||
|
||||
START_TEST(NtCreateKey)
|
||||
{
|
||||
TestCreateOpen(0, 0, STATUS_ACCESS_DENIED);
|
||||
TestCreateOpen(KEY_WOW64_32KEY, 0, STATUS_ACCESS_DENIED);
|
||||
TestCreateOpen(KEY_WOW64_64KEY, 0, STATUS_ACCESS_DENIED);
|
||||
TestCreateOpen(KEY_WOW64_32KEY | KEY_WOW64_64KEY, 0, STATUS_ACCESS_DENIED); // STATUS_INVALID_PARAMETER on Win7
|
||||
TestCreateOpen(READ_CONTROL, READ_CONTROL, STATUS_SUCCESS);
|
||||
TestCreateOpen(READ_CONTROL | KEY_WOW64_32KEY, READ_CONTROL, STATUS_SUCCESS);
|
||||
TestCreateOpen(READ_CONTROL | KEY_WOW64_64KEY, READ_CONTROL, STATUS_SUCCESS);
|
||||
TestCreateOpen(READ_CONTROL | KEY_WOW64_32KEY | KEY_WOW64_64KEY, READ_CONTROL, STATUS_SUCCESS); // STATUS_INVALID_PARAMETER on Win7
|
||||
}
|
|
@ -8,6 +8,7 @@ extern void func_NtAllocateVirtualMemory(void);
|
|||
extern void func_NtApphelpCacheControl(void);
|
||||
extern void func_NtContinue(void);
|
||||
extern void func_NtCreateFile(void);
|
||||
extern void func_NtCreateKey(void);
|
||||
extern void func_NtCreateThread(void);
|
||||
extern void func_NtDeleteKey(void);
|
||||
extern void func_NtFreeVirtualMemory(void);
|
||||
|
@ -53,6 +54,7 @@ const struct test winetest_testlist[] =
|
|||
{ "NtApphelpCacheControl", func_NtApphelpCacheControl },
|
||||
{ "NtContinue", func_NtContinue },
|
||||
{ "NtCreateFile", func_NtCreateFile },
|
||||
{ "NtCreateKey", func_NtCreateKey },
|
||||
{ "NtCreateThread", func_NtCreateThread },
|
||||
{ "NtDeleteKey", func_NtDeleteKey },
|
||||
{ "NtFreeVirtualMemory", func_NtFreeVirtualMemory },
|
||||
|
|
Loading…
Reference in a new issue