2012-04-27 08:36:58 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS kernel-mode tests
|
|
|
|
* LICENSE: GPLv2+ - See COPYING in the top level directory
|
|
|
|
* PURPOSE: Kernel-Mode Test Suite Exception test
|
2013-10-12 16:05:54 +00:00
|
|
|
* PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
|
2012-04-27 08:36:58 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <kmt_test.h>
|
|
|
|
|
|
|
|
START_TEST(RtlException)
|
|
|
|
{
|
|
|
|
PCHAR Buffer[128];
|
|
|
|
|
|
|
|
/* Access a valid pointer - must not trigger SEH */
|
2012-06-14 17:48:14 +00:00
|
|
|
KmtStartSeh()
|
2012-04-27 08:36:58 +00:00
|
|
|
RtlFillMemory(Buffer, sizeof(Buffer), 0x12);
|
2012-06-14 17:48:14 +00:00
|
|
|
KmtEndSeh(STATUS_SUCCESS);
|
2012-04-27 08:36:58 +00:00
|
|
|
|
|
|
|
/* Read from a NULL pointer - must cause an access violation */
|
2012-06-14 17:48:14 +00:00
|
|
|
KmtStartSeh()
|
2013-07-13 06:31:13 +00:00
|
|
|
(void)*(volatile CHAR *)NULL;
|
2012-06-14 17:48:14 +00:00
|
|
|
KmtEndSeh(STATUS_ACCESS_VIOLATION);
|
2012-04-27 08:36:58 +00:00
|
|
|
|
|
|
|
/* Write to a NULL pointer - must cause an access violation */
|
2012-06-14 17:48:14 +00:00
|
|
|
KmtStartSeh()
|
2012-04-27 08:36:58 +00:00
|
|
|
*(volatile CHAR *)NULL = 5;
|
2012-06-14 17:48:14 +00:00
|
|
|
KmtEndSeh(STATUS_ACCESS_VIOLATION);
|
2012-04-27 08:36:58 +00:00
|
|
|
|
|
|
|
/* TODO: Find where MmBadPointer is defined - gives an unresolved external */
|
|
|
|
#if 0 //def KMT_KERNEL_MODE
|
|
|
|
/* Read from MmBadPointer - must cause an access violation */
|
2012-06-14 17:48:14 +00:00
|
|
|
KmtStartSeh()
|
2013-07-13 06:31:13 +00:00
|
|
|
(void)*(volatile CHAR *)MmBadPointer;
|
2012-06-14 17:48:14 +00:00
|
|
|
KmtEndSeh(STATUS_ACCESS_VIOLATION);
|
2012-04-27 08:36:58 +00:00
|
|
|
|
|
|
|
/* Write to MmBadPointer - must cause an access violation */
|
2012-06-14 17:48:14 +00:00
|
|
|
KmtStartSeh()
|
2012-04-27 08:36:58 +00:00
|
|
|
*(volatile CHAR *)MmBadPointer = 5;
|
2012-06-14 17:48:14 +00:00
|
|
|
KmtEndSeh(STATUS_ACCESS_VIOLATION);
|
2012-04-27 08:36:58 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* We cannot test this in kernel mode easily - the stack is just "somewhere"
|
|
|
|
* in system space, and there's no guard page below it */
|
2012-09-15 19:39:14 +00:00
|
|
|
#if CORE_6640_IS_FIXED
|
2012-04-27 08:36:58 +00:00
|
|
|
#ifdef KMT_USER_MODE
|
|
|
|
/* Overflow the stack - must cause a special exception */
|
2012-06-14 17:48:14 +00:00
|
|
|
KmtStartSeh()
|
2012-04-27 08:36:58 +00:00
|
|
|
PCHAR Pointer;
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
Pointer = _alloca(1024);
|
|
|
|
*Pointer = 5;
|
|
|
|
}
|
2012-06-14 17:48:14 +00:00
|
|
|
KmtEndSeh(STATUS_STACK_OVERFLOW);
|
2012-04-27 08:36:58 +00:00
|
|
|
#endif
|
2012-09-15 19:39:14 +00:00
|
|
|
#endif /* CORE_6640_IS_FIXED */
|
2012-04-27 08:36:58 +00:00
|
|
|
}
|