ReactOS  0.4.14-dev-358-gbef841c
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 }
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
#define TEST_STR
Definition: NtOpenKey.c:10
LONG NTSTATUS
Definition: precomp.h:26
static WCHAR String[]
Definition: stringtable.c:55
#define ok_hex(expression, result)
Definition: atltest.h:94
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static IUnknown Object
Definition: main.c:512
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
START_TEST(NtOpenKey)
Definition: NtOpenKey.c:12
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Status
Definition: gdiplustypes.h:24
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
#define ok_ntstatus(status, expected)
Definition: atltest.h:135
#define STATUS_DATATYPE_MISALIGNMENT
Definition: ntstatus.h:171
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
return STATUS_SUCCESS
Definition: btrfs.c:2938