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>
8 #define KMT_EMULATE_KERNEL
11 START_TEST(RtlException
)
15 /* Access a valid pointer - must not trigger SEH */
17 RtlFillMemory(Buffer
, sizeof(Buffer
), 0x12);
18 KmtEndSeh(STATUS_SUCCESS
);
20 /* Read from a NULL pointer - must cause an access violation */
22 (void)*(volatile CHAR
*)NULL
;
23 KmtEndSeh(STATUS_ACCESS_VIOLATION
);
25 /* Write to a NULL pointer - must cause an access violation */
27 *(volatile CHAR
*)NULL
= 5;
28 KmtEndSeh(STATUS_ACCESS_VIOLATION
);
30 /* TODO: Find where MmBadPointer is defined - gives an unresolved external */
31 #if 0 //def KMT_KERNEL_MODE
32 /* Read from MmBadPointer - must cause an access violation */
34 (void)*(volatile CHAR
*)MmBadPointer
;
35 KmtEndSeh(STATUS_ACCESS_VIOLATION
);
37 /* Write to MmBadPointer - must cause an access violation */
39 *(volatile CHAR
*)MmBadPointer
= 5;
40 KmtEndSeh(STATUS_ACCESS_VIOLATION
);
44 ExRaiseStatus(STATUS_ACCESS_VIOLATION
);
45 KmtEndSeh(STATUS_ACCESS_VIOLATION
);
48 ExRaiseStatus(STATUS_TIMEOUT
);
49 KmtEndSeh(STATUS_TIMEOUT
);
52 ExRaiseStatus(STATUS_STACK_OVERFLOW
);
53 KmtEndSeh(STATUS_STACK_OVERFLOW
);
56 ExRaiseStatus(STATUS_GUARD_PAGE_VIOLATION
);
57 KmtEndSeh(STATUS_GUARD_PAGE_VIOLATION
);
59 /* We cannot test this in kernel mode easily - the stack is just "somewhere"
60 * in system space, and there's no guard page below it */
61 #if CORE_6640_IS_FIXED
63 /* Overflow the stack - must cause a special exception */
65 volatile CHAR
*Pointer
;
69 Pointer
= _alloca(1024);
72 KmtEndSeh(STATUS_STACK_OVERFLOW
);
74 #endif /* CORE_6640_IS_FIXED */