ReactOS 0.4.15-dev-7953-g1f49173
GuardedMemory.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS kernel-mode tests
3 * LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
4 * PURPOSE: Kernel-Mode Test Suite Guarded Memory example test
5 * COPYRIGHT: Copyright 2011-2018 Thomas Faber <thomas.faber@reactos.org>
6 */
7
8#include <kmt_test.h>
9
10#ifdef __GNUC__
11#pragma GCC diagnostic ignored "-Wnonnull"
12#endif /* defined __GNUC__ */
13
14START_TEST(GuardedMemory)
15{
17 SIZE_T Size = 123;
19
20 /* access some invalid memory to test SEH */
23 {
24 RtlFillMemory(NULL, 1, 0);
25 }
27 {
29 } _SEH2_END;
31
32 /* get guarded mem */
34
35 if (skip(Buffer != NULL, "Failed to allocate guarded memory\n"))
36 return;
37
38 /* access to guarded mem should be fine */
41 {
43 }
45 {
47 } _SEH2_END;
49
50 /* access one byte behind guarded mem must cause an access violation! */
53 {
54 RtlFillMemory(Buffer + Size, 1, 0);
55 }
57 {
59 } _SEH2_END;
61
63}
#define ok_eq_hex(value, expected)
Definition: apitest.h:77
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
Status
Definition: gdiplustypes.h:25
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:599
VOID KmtFreeGuarded(PVOID Pointer)
BOOLEAN BOOLEAN VOID VOID BOOLEAN BOOLEAN PVOID KmtAllocateGuarded(SIZE_T SizeRequested)
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:159
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG_PTR SIZE_T
Definition: typedefs.h:80
char * PCHAR
Definition: typedefs.h:51
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533