1b38098ebed71db6c22843428199073a5250ef2f
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 <thfabba@gmx.de>
10 #define StartSeh() ExceptionStatus = STATUS_SUCCESS; _SEH2_TRY {
11 #define EndSeh(ExpectedStatus) } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { ExceptionStatus = _SEH2_GetExceptionCode(); } _SEH2_END; ok_eq_hex(ExceptionStatus, ExpectedStatus)
13 START_TEST(RtlException
)
15 NTSTATUS ExceptionStatus
;
19 /* Access a valid pointer - must not trigger SEH */
21 RtlFillMemory(Buffer
, sizeof(Buffer
), 0x12);
22 EndSeh(STATUS_SUCCESS
);
24 /* Read from a NULL pointer - must cause an access violation */
26 Value
= *(volatile CHAR
*)NULL
;
27 EndSeh(STATUS_ACCESS_VIOLATION
);
29 /* Write to a NULL pointer - must cause an access violation */
31 *(volatile CHAR
*)NULL
= 5;
32 EndSeh(STATUS_ACCESS_VIOLATION
);
34 /* TODO: Find where MmBadPointer is defined - gives an unresolved external */
35 #if 0 //def KMT_KERNEL_MODE
36 /* Read from MmBadPointer - must cause an access violation */
38 Value
= *(volatile CHAR
*)MmBadPointer
;
39 EndSeh(STATUS_ACCESS_VIOLATION
);
41 /* Write to MmBadPointer - must cause an access violation */
43 *(volatile CHAR
*)MmBadPointer
= 5;
44 EndSeh(STATUS_ACCESS_VIOLATION
);
47 /* We cannot test this in kernel mode easily - the stack is just "somewhere"
48 * in system space, and there's no guard page below it */
50 /* Overflow the stack - must cause a special exception */
56 Pointer
= _alloca(1024);
59 EndSeh(STATUS_STACK_OVERFLOW
);