mirror of
https://github.com/reactos/reactos.git
synced 2025-05-30 06:28:34 +00:00
- Implement pool corruption tests for testing pool overrun/underrun detectors. Tests invocation is commented out by default.
svn path=/trunk/; revision=43371
This commit is contained in:
parent
4ff9e0a85e
commit
be31446a2e
2 changed files with 54 additions and 0 deletions
|
@ -3,6 +3,7 @@
|
||||||
<include base="ReactOS">include/reactos/drivers</include>
|
<include base="ReactOS">include/reactos/drivers</include>
|
||||||
<library>ntoskrnl</library>
|
<library>ntoskrnl</library>
|
||||||
<library>hal</library>
|
<library>hal</library>
|
||||||
|
<library>pseh</library>
|
||||||
<file>kmtest.c</file>
|
<file>kmtest.c</file>
|
||||||
<file>deviface.c</file>
|
<file>deviface.c</file>
|
||||||
<file>deviface_test.c</file>
|
<file>deviface_test.c</file>
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <ntifs.h>
|
#include <ntifs.h>
|
||||||
#include <ndk/ntndk.h>
|
#include <ndk/ntndk.h>
|
||||||
|
/* SEH support with PSEH */
|
||||||
|
#include <pseh/pseh2.h>
|
||||||
#include "kmtest.h"
|
#include "kmtest.h"
|
||||||
|
|
||||||
//#define NDEBUG
|
//#define NDEBUG
|
||||||
|
@ -125,10 +127,61 @@ PoolsTest()
|
||||||
FinishTest("NTOSKRNL Pools Tests");
|
FinishTest("NTOSKRNL Pools Tests");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
PoolsCorruption()
|
||||||
|
{
|
||||||
|
PULONG Ptr, TestPtr;
|
||||||
|
ULONG AllocSize;
|
||||||
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
|
StartTest();
|
||||||
|
|
||||||
|
// start with non-paged pool
|
||||||
|
AllocSize = 4096 + 0x10;
|
||||||
|
Ptr = ExAllocatePoolWithTag(NonPagedPool, AllocSize, TAG_POOLTEST);
|
||||||
|
|
||||||
|
// touch all bytes, it shouldn't cause an exception
|
||||||
|
RtlZeroMemory(Ptr, AllocSize);
|
||||||
|
|
||||||
|
// test buffer overrun, right after our allocation ends
|
||||||
|
_SEH2_TRY
|
||||||
|
{
|
||||||
|
TestPtr = (PULONG)((PUCHAR)Ptr + AllocSize);
|
||||||
|
//Ptr[4] = 0xd33dbeef;
|
||||||
|
*TestPtr = 0xd33dbeef;
|
||||||
|
}
|
||||||
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
|
/* Get the status */
|
||||||
|
Status = _SEH2_GetExceptionCode();
|
||||||
|
} _SEH2_END;
|
||||||
|
|
||||||
|
ok(Status == STATUS_ACCESS_VIOLATION, "Exception should occur, but got Status 0x%08lX\n", Status);
|
||||||
|
|
||||||
|
// test overrun in a distant byte range, but within 4096KB
|
||||||
|
_SEH2_TRY
|
||||||
|
{
|
||||||
|
Ptr[2020] = 0xdeadb33f;
|
||||||
|
}
|
||||||
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
|
/* Get the status */
|
||||||
|
Status = _SEH2_GetExceptionCode();
|
||||||
|
} _SEH2_END;
|
||||||
|
|
||||||
|
ok(Status == STATUS_ACCESS_VIOLATION, "Exception should occur, but got Status 0x%08lX\n", Status);
|
||||||
|
|
||||||
|
// free the pool
|
||||||
|
ExFreePoolWithTag(Ptr, TAG_POOLTEST);
|
||||||
|
|
||||||
|
FinishTest("NTOSKRNL Pool Corruption");
|
||||||
|
}
|
||||||
|
|
||||||
/* PUBLIC FUNCTIONS ***********************************************************/
|
/* PUBLIC FUNCTIONS ***********************************************************/
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NtoskrnlPoolsTest()
|
NtoskrnlPoolsTest()
|
||||||
{
|
{
|
||||||
PoolsTest();
|
PoolsTest();
|
||||||
|
//PoolsCorruption();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue