mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
[NTDLL_APITEST] Test unaligned pointers for NtOpenKey
CORE-13689 svn path=/trunk/; revision=75588
This commit is contained in:
parent
441f8dc306
commit
dd1078cd17
3 changed files with 61 additions and 0 deletions
|
@ -13,6 +13,7 @@ list(APPEND SOURCE
|
|||
NtLoadUnloadKey.c
|
||||
NtMapViewOfSection.c
|
||||
NtMutant.c
|
||||
NtOpenKey.c
|
||||
NtOpenProcessToken.c
|
||||
NtOpenThreadToken.c
|
||||
NtProtectVirtualMemory.c
|
||||
|
|
58
rostests/apitests/ntdll/NtOpenKey.c
Normal file
58
rostests/apitests/ntdll/NtOpenKey.c
Normal file
|
@ -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@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));
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@ extern void func_NtFreeVirtualMemory(void);
|
|||
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 @@ const struct test winetest_testlist[] =
|
|||
{ "NtLoadUnloadKey", func_NtLoadUnloadKey },
|
||||
{ "NtMapViewOfSection", func_NtMapViewOfSection },
|
||||
{ "NtMutant", func_NtMutant },
|
||||
{ "NtOpenKey", func_NtOpenKey },
|
||||
{ "NtOpenProcessToken", func_NtOpenProcessToken },
|
||||
{ "NtOpenThreadToken", func_NtOpenThreadToken },
|
||||
{ "NtProtectVirtualMemory", func_NtProtectVirtualMemory },
|
||||
|
|
Loading…
Reference in a new issue