Author: mjansen
Date: Thu Aug 17 11:42:13 2017
New Revision: 75588
URL:
http://svn.reactos.org/svn/reactos?rev=75588&view=rev
Log:
[NTDLL_APITEST] Test unaligned pointers for NtOpenKey
CORE-13689
Added:
trunk/rostests/apitests/ntdll/NtOpenKey.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…
==============================================================================
--- trunk/rostests/apitests/ntdll/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/rostests/apitests/ntdll/CMakeLists.txt [iso-8859-1] Thu Aug 17 11:42:13 2017
@@ -13,6 +13,7 @@
NtLoadUnloadKey.c
NtMapViewOfSection.c
NtMutant.c
+ NtOpenKey.c
NtOpenProcessToken.c
NtOpenThreadToken.c
NtProtectVirtualMemory.c
Added: trunk/rostests/apitests/ntdll/NtOpenKey.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/NtOpenKey.…
==============================================================================
--- trunk/rostests/apitests/ntdll/NtOpenKey.c (added)
+++ trunk/rostests/apitests/ntdll/NtOpenKey.c [iso-8859-1] Thu Aug 17 11:42:13 2017
@@ -0,0 +1,58 @@
+/*
+ * PROJECT: ReactOS api tests
+ * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
+ * PURPOSE: Test for NtOpenKey data alignment
+ * PROGRAMMER: Mark Jansen (mark.jansen(a)reactos.org)
+ */
+
+#include <apitest.h>
+
+#include <ntndk.h>
+
+
+#define TEST_STR L"\\Registry\\Machine\\SOFTWARE"
+
+
+
+START_TEST(NtOpenKey)
+{
+ OBJECT_ATTRIBUTES Object;
+ UNICODE_STRING String;
+ char GccShouldNotAlignThis[40 * 2];
+ char GccShouldNotAlignThis2[20];
+ PVOID Alias = GccShouldNotAlignThis + 1;
+ PVOID UnalignedKey = GccShouldNotAlignThis2 + 1;
+
+ HANDLE KeyHandle;
+ NTSTATUS Status;
+
+ memcpy(Alias, TEST_STR, sizeof(TEST_STR));
+
+
+ RtlInitUnicodeString(&String, TEST_STR);
+ InitializeObjectAttributes(&Object, &String, OBJ_CASE_INSENSITIVE, NULL,
NULL);
+
+ Status = NtOpenKey(&KeyHandle, KEY_QUERY_VALUE, &Object);
+ ok_ntstatus(Status, STATUS_SUCCESS);
+
+ if (!NT_SUCCESS(Status))
+ return;
+
+ NtClose(KeyHandle);
+
+ String.Buffer = Alias;
+ ok_hex(((ULONG_PTR)String.Buffer) % 2, 1);
+ Status = NtOpenKey(&KeyHandle, KEY_QUERY_VALUE, &Object);
+ ok_ntstatus(Status, STATUS_DATATYPE_MISALIGNMENT); // FIXME: Later
windows versions succeed here.
+ if (NT_SUCCESS(Status))
+ NtClose(KeyHandle);
+
+ RtlInitUnicodeString(&String, TEST_STR);
+ ok_hex(((ULONG_PTR)UnalignedKey) % 2, 1);
+ Status = NtOpenKey(UnalignedKey, KEY_QUERY_VALUE, &Object);
+ ok_ntstatus(Status, STATUS_SUCCESS);
+ if (NT_SUCCESS(Status))
+ {
+ NtClose(*(HANDLE*)(UnalignedKey));
+ }
+}
Propchange: trunk/rostests/apitests/ntdll/NtOpenKey.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…
==============================================================================
--- trunk/rostests/apitests/ntdll/testlist.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/ntdll/testlist.c [iso-8859-1] Thu Aug 17 11:42:13 2017
@@ -16,6 +16,7 @@
extern void func_NtLoadUnloadKey(void);
extern void func_NtMapViewOfSection(void);
extern void func_NtMutant(void);
+extern void func_NtOpenKey(void);
extern void func_NtOpenProcessToken(void);
extern void func_NtOpenThreadToken(void);
extern void func_NtProtectVirtualMemory(void);
@@ -72,6 +73,7 @@
{ "NtLoadUnloadKey", func_NtLoadUnloadKey },
{ "NtMapViewOfSection", func_NtMapViewOfSection },
{ "NtMutant", func_NtMutant },
+ { "NtOpenKey", func_NtOpenKey },
{ "NtOpenProcessToken", func_NtOpenProcessToken },
{ "NtOpenThreadToken", func_NtOpenThreadToken },
{ "NtProtectVirtualMemory", func_NtProtectVirtualMemory },