[NTFS]
[reactos.git] / rostests / kmtests / rtl / RtlException.c
1 /*
2 * PROJECT: ReactOS kernel-mode tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Kernel-Mode Test Suite Exception test
5 * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
6 */
7
8 #include <kmt_test.h>
9
10 START_TEST(RtlException)
11 {
12 PCHAR Buffer[128];
13
14 /* Access a valid pointer - must not trigger SEH */
15 KmtStartSeh()
16 RtlFillMemory(Buffer, sizeof(Buffer), 0x12);
17 KmtEndSeh(STATUS_SUCCESS);
18
19 /* Read from a NULL pointer - must cause an access violation */
20 KmtStartSeh()
21 (void)*(volatile CHAR *)NULL;
22 KmtEndSeh(STATUS_ACCESS_VIOLATION);
23
24 /* Write to a NULL pointer - must cause an access violation */
25 KmtStartSeh()
26 *(volatile CHAR *)NULL = 5;
27 KmtEndSeh(STATUS_ACCESS_VIOLATION);
28
29 /* TODO: Find where MmBadPointer is defined - gives an unresolved external */
30 #if 0 //def KMT_KERNEL_MODE
31 /* Read from MmBadPointer - must cause an access violation */
32 KmtStartSeh()
33 (void)*(volatile CHAR *)MmBadPointer;
34 KmtEndSeh(STATUS_ACCESS_VIOLATION);
35
36 /* Write to MmBadPointer - must cause an access violation */
37 KmtStartSeh()
38 *(volatile CHAR *)MmBadPointer = 5;
39 KmtEndSeh(STATUS_ACCESS_VIOLATION);
40 #endif
41
42 /* We cannot test this in kernel mode easily - the stack is just "somewhere"
43 * in system space, and there's no guard page below it */
44 #if CORE_6640_IS_FIXED
45 #ifdef KMT_USER_MODE
46 /* Overflow the stack - must cause a special exception */
47 KmtStartSeh()
48 PCHAR Pointer;
49
50 while (1)
51 {
52 Pointer = _alloca(1024);
53 *Pointer = 5;
54 }
55 KmtEndSeh(STATUS_STACK_OVERFLOW);
56 #endif
57 #endif /* CORE_6640_IS_FIXED */
58 }