Author: tfaber
Date: Sat Oct 15 18:33:21 2016
New Revision: 72974

URL: http://svn.reactos.org/svn/reactos?rev=72974&view=rev
Log:
[NTDLL_APITEST]
- Show that NtOpenKey and NtCreateKey accept, but ignore, KEY_WOW64_32KEY and 
KEY_WOW64_64KEY
CORE-9691

Added:
    trunk/rostests/apitests/ntdll/NtCreateKey.c   (with props)
Modified:
    trunk/rostests/apitests/ntdll/CMakeLists.txt
    trunk/rostests/apitests/ntdll/testlist.c

Modified: trunk/rostests/apitests/ntdll/CMakeLists.txt
URL: 
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/CMakeLists.txt?rev=72974&r1=72973&r2=72974&view=diff
==============================================================================
--- trunk/rostests/apitests/ntdll/CMakeLists.txt        [iso-8859-1] (original)
+++ trunk/rostests/apitests/ntdll/CMakeLists.txt        [iso-8859-1] Sat Oct 15 
18:33:21 2016
@@ -5,6 +5,7 @@
     NtApphelpCacheControl.c
     NtContinue.c
     NtCreateFile.c
+    NtCreateKey.c
     NtCreateThread.c
     NtDeleteKey.c
     NtFreeVirtualMemory.c

Added: trunk/rostests/apitests/ntdll/NtCreateKey.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/NtCreateKey.c?rev=72974
==============================================================================
--- trunk/rostests/apitests/ntdll/NtCreateKey.c (added)
+++ trunk/rostests/apitests/ntdll/NtCreateKey.c [iso-8859-1] Sat Oct 15 
18:33:21 2016
@@ -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.fa...@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
+}

Propchange: trunk/rostests/apitests/ntdll/NtCreateKey.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: trunk/rostests/apitests/ntdll/testlist.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/testlist.c?rev=72974&r1=72973&r2=72974&view=diff
==============================================================================
--- trunk/rostests/apitests/ntdll/testlist.c    [iso-8859-1] (original)
+++ trunk/rostests/apitests/ntdll/testlist.c    [iso-8859-1] Sat Oct 15 
18:33:21 2016
@@ -8,6 +8,7 @@
 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 @@
     { "NtApphelpCacheControl",          func_NtApphelpCacheControl },
     { "NtContinue",                     func_NtContinue },
     { "NtCreateFile",                   func_NtCreateFile },
+    { "NtCreateKey",                    func_NtCreateKey },
     { "NtCreateThread",                 func_NtCreateThread },
     { "NtDeleteKey",                    func_NtDeleteKey },
     { "NtFreeVirtualMemory",            func_NtFreeVirtualMemory },


Reply via email to