ReactOS 0.4.16-dev-306-g647d351
NtOpenKey.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
4 * PURPOSE: Test for NtOpenKey data alignment
5 * PROGRAMMER: Mark Jansen (mark.jansen@reactos.org)
6 */
7
8#include "precomp.h"
9
10#define TEST_STR L"\\Registry\\Machine\\SOFTWARE"
11
13{
16 char GccShouldNotAlignThis[40 * 2];
17 char GccShouldNotAlignThis2[20];
18 PVOID Alias = GccShouldNotAlignThis + 1;
19 PVOID UnalignedKey = GccShouldNotAlignThis2 + 1;
20
23
24 memcpy(Alias, TEST_STR, sizeof(TEST_STR));
25
26
29
32
33 if (!NT_SUCCESS(Status))
34 return;
35
37
38 String.Buffer = Alias;
39 ok_hex(((ULONG_PTR)String.Buffer) % 2, 1);
41 ok_ntstatus(Status, STATUS_DATATYPE_MISALIGNMENT); // FIXME: Later windows versions succeed here.
42 if (NT_SUCCESS(Status))
44
46 ok_hex(((ULONG_PTR)UnalignedKey) % 2, 1);
47 Status = NtOpenKey(UnalignedKey, KEY_QUERY_VALUE, &Object);
49 if (NT_SUCCESS(Status))
50 {
51 NtClose(*(HANDLE*)(UnalignedKey));
52 }
53}
#define TEST_STR
Definition: NtOpenKey.c:10
#define ok_hex(expression, result)
Definition: atltest.h:94
#define ok_ntstatus(status, expected)
Definition: atltest.h:135
#define START_TEST(x)
Definition: atltest.h:75
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:25
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define STATUS_DATATYPE_MISALIGNMENT
Definition: ntstatus.h:183
#define STATUS_SUCCESS
Definition: shellext.h:65
uint32_t ULONG_PTR
Definition: typedefs.h:65
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433