ReactOS 0.4.15-dev-7907-g95bf896
RtlException.c File Reference
#include <kmt_test.h>
Include dependency graph for RtlException.c:

Go to the source code of this file.

Macros

#define KMT_EMULATE_KERNEL
 

Functions

static VOID PossiblyRaise (_In_ BOOLEAN Raise)
 
static VOID InnerFunction (_Inout_ PULONG State, _In_ BOOLEAN Raise)
 
static VOID OuterFunction (_Inout_ PULONG State, _In_ BOOLEAN Raise)
 
static VOID TestNestedExceptionHandler (VOID)
 
 START_TEST (RtlException)
 

Macro Definition Documentation

◆ KMT_EMULATE_KERNEL

#define KMT_EMULATE_KERNEL

Definition at line 8 of file RtlException.c.

Function Documentation

◆ InnerFunction()

static VOID InnerFunction ( _Inout_ PULONG  State,
_In_ BOOLEAN  Raise 
)
static

Definition at line 24 of file RtlException.c.

27{
28 _SEH2_VOLATILE INT Var = 123;
29 static _SEH2_VOLATILE INT *AddressOfVar;
30
31 AddressOfVar = &Var;
32 ok_eq_ulong(*State, 1);
34 {
35 *State = 2;
36 PossiblyRaise(Raise);
37 ok_eq_ulong(*State, 2);
38 *State = 3;
39 }
41 {
42 ok_eq_int(Var, 123);
43 ok_eq_pointer(&Var, AddressOfVar);
44 if (Raise)
45 ok_eq_ulong(*State, 2);
46 else
47 ok_eq_ulong(*State, 3);
48 *State = 4;
49 }
51
52 ok_eq_int(Var, 123);
53 ok_eq_pointer(&Var, AddressOfVar);
54 ok_eq_ulong(*State, 4);
55 *State = 5;
56}
static VOID PossiblyRaise(_In_ BOOLEAN Raise)
Definition: RtlException.c:13
#define ok_eq_pointer(value, expected)
Definition: apitest.h:59
#define ok_eq_ulong(value, expected)
Definition: apitest.h:63
#define ok_eq_int(value, expected)
Definition: apitest.h:60
#define _SEH2_FINALLY
Definition: filesup.c:21
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
#define _SEH2_VOLATILE
Definition: pseh2_64.h:163
int32_t INT
Definition: typedefs.h:58

Referenced by OuterFunction().

◆ OuterFunction()

static VOID OuterFunction ( _Inout_ PULONG  State,
_In_ BOOLEAN  Raise 
)
static

Definition at line 60 of file RtlException.c.

63{
64 _SEH2_VOLATILE INT Var = 456;
65 static _SEH2_VOLATILE INT *AddressOfVar;
66
67 AddressOfVar = &Var;
68 ok_eq_ulong(*State, 0);
70 {
71 *State = 1;
72 InnerFunction(State, Raise);
73 ok_eq_ulong(*State, 5);
74 *State = 6;
75 }
77 {
78 ok_eq_int(Var, 456);
79 ok_eq_pointer(&Var, AddressOfVar);
80 ok_eq_ulong(*State, 4);
81 *State = 7;
82 }
84
85 ok_eq_int(Var, 456);
86 ok_eq_pointer(&Var, AddressOfVar);
87 if (Raise)
88 ok_eq_ulong(*State, 7);
89 else
90 ok_eq_ulong(*State, 6);
91 *State = 8;
92}
static VOID InnerFunction(_Inout_ PULONG State, _In_ BOOLEAN Raise)
Definition: RtlException.c:24
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34

Referenced by TestNestedExceptionHandler().

◆ PossiblyRaise()

static VOID PossiblyRaise ( _In_ BOOLEAN  Raise)
static

Definition at line 13 of file RtlException.c.

15{
16 if (Raise)
17 {
19 }
20}
#define ExRaiseStatus
Definition: ntoskrnl.h:114
#define STATUS_ASSERTION_FAILURE
Definition: ntstatus.h:960

Referenced by InnerFunction().

◆ START_TEST()

START_TEST ( RtlException  )

Definition at line 109 of file RtlException.c.

110{
111 PCHAR Buffer[128];
112
113 /* Access a valid pointer - must not trigger SEH */
117
118 /* Read from a NULL pointer - must cause an access violation */
120 (void)*(volatile CHAR *)NULL;
122
123 /* Write to a NULL pointer - must cause an access violation */
125 *(volatile CHAR *)NULL = 5;
127
128 /* TODO: Find where MmBadPointer is defined - gives an unresolved external */
129#if 0 //def KMT_KERNEL_MODE
130 /* Read from MmBadPointer - must cause an access violation */
132 (void)*(volatile CHAR *)MmBadPointer;
134
135 /* Write to MmBadPointer - must cause an access violation */
137 *(volatile CHAR *)MmBadPointer = 5;
139#endif
140
144
148
152
156
158
159 /* We cannot test this in kernel mode easily - the stack is just "somewhere"
160 * in system space, and there's no guard page below it */
161#ifdef KMT_USER_MODE
162 /* Overflow the stack - must cause a special exception */
164 volatile CHAR *Pointer;
165
166 while (1)
167 {
168 Pointer = _alloca(1024);
169 *Pointer = 5;
170 }
172#endif
173}
static VOID TestNestedExceptionHandler(VOID)
Definition: RtlException.c:96
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:599
#define KmtStartSeh()
Definition: kmt_test.h:282
#define KmtEndSeh(ExpectedStatus)
Definition: kmt_test.h:288
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
#define STATUS_STACK_OVERFLOW
Definition: ntstatus.h:489
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define STATUS_GUARD_PAGE_VIOLATION
Definition: ntstatus.h:182
#define volatile
Definition: prototyp.h:117
#define STATUS_SUCCESS
Definition: shellext.h:65
char * PCHAR
Definition: typedefs.h:51
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
NTKERNELAPI PVOID MmBadPointer
char CHAR
Definition: xmlstorage.h:175

◆ TestNestedExceptionHandler()

static VOID TestNestedExceptionHandler ( VOID  )
static

Definition at line 96 of file RtlException.c.

97{
99
100 State = 0;
102 ok_eq_ulong(State, 8);
103
104 State = 0;
106 ok_eq_ulong(State, 8);
107}
static VOID OuterFunction(_Inout_ PULONG State, _In_ BOOLEAN Raise)
Definition: RtlException.c:60
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
uint32_t ULONG
Definition: typedefs.h:59

Referenced by START_TEST().