mirror of
https://github.com/reactos/reactos.git
synced 2025-01-06 06:20:13 +00:00
[KMTESTS/RTL]
- Remove hacks from RtlSplayTree/RtlAvlTree tests - Extend RtlMemory test svn path=/branches/GSoC_2011/KMTestSuite/; revision=53082
This commit is contained in:
parent
00a70dd864
commit
804d5c4e32
7 changed files with 486 additions and 48 deletions
|
@ -75,6 +75,7 @@ list(APPEND KMTEST_SOURCE
|
|||
|
||||
add_executable(kmtest ${KMTEST_SOURCE})
|
||||
set_module_type(kmtest win32cui)
|
||||
target_link_libraries(kmtest ${PSEH_LIB})
|
||||
add_importlibs(kmtest advapi32 msvcrt kernel32 ntdll)
|
||||
set_property(TARGET kmtest PROPERTY COMPILE_DEFINITIONS KMT_USER_MODE)
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#elif !defined __GNUC__
|
||||
#define KIRQL int
|
||||
#endif /* !defined __GNUC__ */
|
||||
typedef const UCHAR CUCHAR, *PCUCHAR;
|
||||
typedef ULONG LOGICAL, *PLOGICAL;
|
||||
|
||||
#undef KeRaiseIrql
|
||||
#define KeRaiseIrql(new, old)
|
||||
|
@ -39,10 +41,13 @@
|
|||
#define ExAllocatePoolWithTag(type, size, tag) HeapAlloc(GetProcessHeap(), 0, size)
|
||||
#define ExFreePool(p) HeapFree(GetProcessHeap(), 0, p)
|
||||
#define ExFreePoolWithTag(p, tag) HeapFree(GetProcessHeap(), 0, p)
|
||||
#define RtlCopyMemoryNonTemporal(d, s, l)
|
||||
#define RtlPrefetchMemoryNonTemporal(s, l)
|
||||
#endif /* defined KMT_EMULATE_KERNEL */
|
||||
|
||||
#endif /* defined KMT_USER_MODE */
|
||||
|
||||
#include <pseh/pseh2.h>
|
||||
#include <limits.h>
|
||||
|
||||
#endif /* !defined _KMTEST_PLATFORM_H_ */
|
||||
|
|
|
@ -139,6 +139,7 @@ BOOLEAN KmtSkip(INT Condition, PCSTR FileAndLine, PCSTR Format, ...)
|
|||
#define ok_eq_ulong(value, expected) ok_eq_print(value, expected, "%lu")
|
||||
#define ok_eq_longlong(value, expected) ok_eq_print(value, expected, "%I64d")
|
||||
#define ok_eq_ulonglong(value, expected) ok_eq_print(value, expected, "%I64u")
|
||||
#define ok_eq_size(value, expected) ok_eq_ulonglong((ULONGLONG)(value), (ULONGLONG)(expected))
|
||||
#define ok_eq_hex(value, expected) ok_eq_print(value, expected, "0x%08lx")
|
||||
#define ok_bool_true(value, desc) ok((value) == TRUE, desc " FALSE, expected TRUE\n")
|
||||
#define ok_bool_false(value, desc) ok((value) == FALSE, desc " TRUE, expected FALSE\n")
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<include base="kmtest">include</include>
|
||||
<library>advapi32</library>
|
||||
<library>ntdll</library>
|
||||
<library>pseh</library>
|
||||
<define name="KMT_USER_MODE" />
|
||||
<directory name="kmtest">
|
||||
<file>kmtest.c</file>
|
||||
|
|
|
@ -1,34 +1,4 @@
|
|||
/* HACK: broken ntddk.h */
|
||||
#ifdef KMT_KERNEL_MODE
|
||||
typedef struct _RTL_SPLAY_LINKS {
|
||||
struct _RTL_SPLAY_LINKS *Parent;
|
||||
struct _RTL_SPLAY_LINKS *LeftChild;
|
||||
struct _RTL_SPLAY_LINKS *RightChild;
|
||||
} RTL_SPLAY_LINKS, *PRTL_SPLAY_LINKS;
|
||||
#endif
|
||||
|
||||
#define RTL_USE_AVL_TABLES
|
||||
#define KMT_EMULATE_KERNEL
|
||||
#include <kmt_test.h>
|
||||
|
||||
#if defined KMT_USER_MODE
|
||||
/* HACK: missing in rtltypes.h */
|
||||
#undef RTL_GENERIC_TABLE
|
||||
#undef PRTL_GENERIC_TABLE
|
||||
|
||||
#define RTL_GENERIC_TABLE RTL_AVL_TABLE
|
||||
#define PRTL_GENERIC_TABLE PRTL_AVL_TABLE
|
||||
|
||||
/* HACK: missing in rtlfuncs.h */
|
||||
#define RtlInitializeGenericTable RtlInitializeGenericTableAvl
|
||||
#define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl
|
||||
#define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl
|
||||
#define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl
|
||||
#define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl
|
||||
#define RtlGetElementGenericTable RtlGetElementGenericTableAvl
|
||||
#define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl
|
||||
#endif
|
||||
|
||||
/* this is a little hacky, but better than duplicating the code (for now) */
|
||||
#define RTL_USE_AVL_TABLES
|
||||
#define Test_RtlSplayTree Test_RtlAvlTree
|
||||
#include "RtlSplayTree.c"
|
||||
|
|
|
@ -5,23 +5,494 @@
|
|||
* PROGRAMMER: Thomas Faber <thfabba@gmx.de>
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
__declspec(dllimport) void __stdcall RtlMoveMemory(void *, const void *, size_t);
|
||||
__declspec(dllimport) void __stdcall RtlFillMemory(void *, size_t, unsigned char);
|
||||
|
||||
#define KMT_EMULATE_KERNEL
|
||||
#include <kmt_test.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic ignored "-Wnonnull"
|
||||
#endif /* defined __GNUC__ */
|
||||
|
||||
static
|
||||
VOID
|
||||
MakeBuffer(
|
||||
OUT PVOID Buffer,
|
||||
...)
|
||||
{
|
||||
PUCHAR OutBuffer = Buffer;
|
||||
INT Count;
|
||||
INT Value;
|
||||
va_list Arguments;
|
||||
|
||||
va_start(Arguments, Buffer);
|
||||
|
||||
while (1)
|
||||
{
|
||||
Count = va_arg(Arguments, INT);
|
||||
if (!Count)
|
||||
break;
|
||||
ASSERT(Count > 0);
|
||||
|
||||
Value = va_arg(Arguments, INT);
|
||||
while (Count--)
|
||||
*OutBuffer++ = Value;
|
||||
}
|
||||
|
||||
va_end(Arguments);
|
||||
}
|
||||
|
||||
static
|
||||
BOOLEAN
|
||||
CheckBuffer(
|
||||
IN const VOID *Buffer,
|
||||
...)
|
||||
{
|
||||
PCUCHAR OutBuffer = Buffer;
|
||||
INT Count;
|
||||
INT Value;
|
||||
va_list Arguments;
|
||||
|
||||
va_start(Arguments, Buffer);
|
||||
|
||||
while (1)
|
||||
{
|
||||
Count = va_arg(Arguments, INT);
|
||||
if (!Count)
|
||||
break;
|
||||
ASSERT(Count > 0);
|
||||
|
||||
Value = va_arg(Arguments, INT);
|
||||
while (Count--)
|
||||
if (*OutBuffer++ != Value)
|
||||
{
|
||||
--OutBuffer;
|
||||
trace("CheckBuffer failed at offset %d, value %x, expected %x\n", OutBuffer - (PCUCHAR)Buffer, *OutBuffer, Value);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
va_end(Arguments);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static
|
||||
VOID
|
||||
MakePattern(
|
||||
OUT PVOID Buffer,
|
||||
...)
|
||||
{
|
||||
PUCHAR OutBuffer = Buffer;
|
||||
INT Count, Repeat, i;
|
||||
INT Values[16];
|
||||
va_list Arguments;
|
||||
|
||||
va_start(Arguments, Buffer);
|
||||
|
||||
while (1)
|
||||
{
|
||||
Count = va_arg(Arguments, INT);
|
||||
if (!Count)
|
||||
break;
|
||||
ASSERT(Count > 0 && Count < sizeof Values / sizeof Values[0]);
|
||||
|
||||
Repeat = va_arg(Arguments, INT);
|
||||
ASSERT(Repeat > 0);
|
||||
|
||||
for (i = 0; i < Count; ++i)
|
||||
Values[i] = va_arg(Arguments, INT);
|
||||
|
||||
while (Repeat--)
|
||||
for (i = 0; i < Count; ++i)
|
||||
*OutBuffer++ = Values[i];
|
||||
}
|
||||
|
||||
va_end(Arguments);
|
||||
}
|
||||
|
||||
static
|
||||
BOOLEAN
|
||||
CheckPattern(
|
||||
IN const VOID *Buffer,
|
||||
...)
|
||||
{
|
||||
PCUCHAR OutBuffer = Buffer;
|
||||
INT Count, Repeat, i;
|
||||
INT Values[16];
|
||||
va_list Arguments;
|
||||
|
||||
va_start(Arguments, Buffer);
|
||||
|
||||
while (1)
|
||||
{
|
||||
Count = va_arg(Arguments, INT);
|
||||
if (!Count)
|
||||
break;
|
||||
ASSERT(Count > 0 && Count < sizeof Values / sizeof Values[0]);
|
||||
|
||||
Repeat = va_arg(Arguments, INT);
|
||||
ASSERT(Repeat > 0);
|
||||
|
||||
for (i = 0; i < Count; ++i)
|
||||
Values[i] = va_arg(Arguments, INT);
|
||||
|
||||
while (Repeat--)
|
||||
for (i = 0; i < Count; ++i)
|
||||
if (*OutBuffer++ != Values[i])
|
||||
{
|
||||
--OutBuffer;
|
||||
trace("CheckPattern failed at offset %d, value %x, expected %x\n", OutBuffer - (PCUCHAR)Buffer, *OutBuffer, Values[i]);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
va_end(Arguments);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
START_TEST(RtlMemory)
|
||||
{
|
||||
UCHAR Buffer[512];
|
||||
NTSTATUS Status;
|
||||
UCHAR Buffer[513];
|
||||
const INT Size = 512;
|
||||
const INT HalfSize = Size / 2;
|
||||
SIZE_T RetSize;
|
||||
KIRQL Irql;
|
||||
int i;
|
||||
INT i;
|
||||
|
||||
KeRaiseIrql(HIGH_LEVEL, &Irql);
|
||||
/* zero everything behind 'Size'. Tests will check that this wasn't changed.
|
||||
* TODO: use guarded memory for this! */
|
||||
MakeBuffer(Buffer + Size, sizeof Buffer - Size, 0, 0);
|
||||
|
||||
RtlFillMemory(Buffer, sizeof Buffer / 2, 0x55);
|
||||
RtlFillMemory(Buffer + sizeof Buffer / 2, sizeof Buffer / 2, 0xAA);
|
||||
for (i = 0; i < sizeof Buffer / 2; ++i)
|
||||
/* test our helper functions first */
|
||||
MakeBuffer(Buffer, HalfSize, 0x55, HalfSize, 0xAA, 0);
|
||||
for (i = 0; i < HalfSize; ++i)
|
||||
ok_eq_uint(Buffer[i], 0x55);
|
||||
for (i = sizeof Buffer / 2; i < sizeof Buffer; ++i)
|
||||
for (i = HalfSize; i < Size; ++i)
|
||||
ok_eq_uint(Buffer[i], 0xAA);
|
||||
ok_bool_true(CheckBuffer(Buffer, HalfSize, 0x55, HalfSize, 0xAA, 1, 0, 0), "CheckBuffer");
|
||||
|
||||
MakePattern(Buffer, 3, 20, 0x11, 0x22, 0x33, 1, 4, 0x44, 0);
|
||||
for (i = 0; i < 60; i += 3)
|
||||
{
|
||||
ok_eq_uint(Buffer[i+0], 0x11);
|
||||
ok_eq_uint(Buffer[i+1], 0x22);
|
||||
ok_eq_uint(Buffer[i+2], 0x33);
|
||||
}
|
||||
for (i = 60; i < 64; ++i)
|
||||
ok_eq_uint(Buffer[i], 0x44);
|
||||
for (i = 64; i < HalfSize; ++i)
|
||||
ok_eq_uint(Buffer[i], 0x55);
|
||||
for (i = HalfSize; i < Size; ++i)
|
||||
ok_eq_uint(Buffer[i], 0xAA);
|
||||
ok_bool_true(CheckPattern(Buffer, 3, 20, 0x11, 0x22, 0x33, 1, 4, 0x44, 0), "CheckPattern");
|
||||
|
||||
/* RtlMoveMemory */
|
||||
MakePattern(Buffer, 2, 64, 0x12, 0x34, 2, 192, 0x56, 0x78, 0);
|
||||
RtlMoveMemory(Buffer + 13, Buffer + 62, 95);
|
||||
ok_bool_true(CheckPattern(Buffer, 2, 6, 0x12, 0x34, 1, 1, 0x12, 2, 33, 0x12, 0x34, 2, 14, 0x56, 0x78, 1, 1, 0x56, 2, 10, 0x12, 0x34, 2, 192, 0x56, 0x78, 1, 1, 0, 0), "CheckPattern");
|
||||
|
||||
MakePattern(Buffer, 2, 32, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 192, 0x9A, 0xAB, 0);
|
||||
RtlMoveMemory(Buffer + 78, Buffer + 43, 107);
|
||||
ok_bool_true(CheckPattern(Buffer, 2, 32, 0x12, 0x34, 2, 7, 0x56, 0x78, 1, 1, 0x34, 2, 10, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 11, 0x9A, 0xAB, 1, 1, 0xAB, 2, 163, 0x9A, 0xAB, 1, 1, 0, 0), "CheckPattern");
|
||||
|
||||
KeLowerIrql(Irql);
|
||||
Status = STATUS_SUCCESS;
|
||||
_SEH2_TRY {
|
||||
RtlMoveMemory(NULL, NULL, 0);
|
||||
} _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
|
||||
Status = _SEH2_GetExceptionCode();
|
||||
} _SEH2_END;
|
||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||
KeRaiseIrql(HIGH_LEVEL, &Irql);
|
||||
|
||||
#undef RtlMoveMemory
|
||||
/* RtlMoveMemory export */
|
||||
MakePattern(Buffer, 2, 64, 0x12, 0x34, 2, 192, 0x56, 0x78, 0);
|
||||
RtlMoveMemory(Buffer + 13, Buffer + 62, 95);
|
||||
ok_bool_true(CheckPattern(Buffer, 2, 6, 0x12, 0x34, 1, 1, 0x12, 2, 33, 0x12, 0x34, 2, 14, 0x56, 0x78, 1, 1, 0x56, 2, 10, 0x12, 0x34, 2, 192, 0x56, 0x78, 1, 1, 0, 0), "CheckPattern");
|
||||
|
||||
MakePattern(Buffer, 2, 32, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 192, 0x9A, 0xAB, 0);
|
||||
RtlMoveMemory(Buffer + 78, Buffer + 43, 107);
|
||||
ok_bool_true(CheckPattern(Buffer, 2, 32, 0x12, 0x34, 2, 7, 0x56, 0x78, 1, 1, 0x34, 2, 10, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 11, 0x9A, 0xAB, 1, 1, 0xAB, 2, 163, 0x9A, 0xAB, 1, 1, 0, 0), "CheckPattern");
|
||||
|
||||
KeLowerIrql(Irql);
|
||||
Status = STATUS_SUCCESS;
|
||||
_SEH2_TRY {
|
||||
RtlMoveMemory(NULL, NULL, 0);
|
||||
} _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
|
||||
Status = _SEH2_GetExceptionCode();
|
||||
} _SEH2_END;
|
||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||
KeRaiseIrql(HIGH_LEVEL, &Irql);
|
||||
|
||||
/* RtlCopyMemory */
|
||||
MakePattern(Buffer, 2, 64, 0x12, 0x34, 2, 192, 0x56, 0x78, 0);
|
||||
RtlCopyMemory(Buffer + 13, Buffer + 62, 95);
|
||||
ok_bool_true(CheckPattern(Buffer, 2, 6, 0x12, 0x34, 1, 1, 0x12, 2, 33, 0x12, 0x34, 2, 14, 0x56, 0x78, 1, 1, 0x56, 2, 10, 0x12, 0x34, 2, 192, 0x56, 0x78, 1, 1, 0, 0), "CheckPattern");
|
||||
|
||||
MakePattern(Buffer, 2, 32, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 192, 0x9A, 0xAB, 0);
|
||||
RtlCopyMemory(Buffer + 78, Buffer + 43, 107);
|
||||
ok_bool_true(CheckPattern(Buffer, 2, 32, 0x12, 0x34, 2, 7, 0x56, 0x78, 1, 1, 0x34, 2, 10, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 11, 0x9A, 0xAB, 1, 1, 0xAB, 2, 163, 0x9A, 0xAB, 1, 1, 0, 0), "CheckPattern");
|
||||
|
||||
KeLowerIrql(Irql);
|
||||
Status = STATUS_SUCCESS;
|
||||
_SEH2_TRY {
|
||||
RtlCopyMemory(NULL, NULL, 0);
|
||||
} _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
|
||||
Status = _SEH2_GetExceptionCode();
|
||||
} _SEH2_END;
|
||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||
KeRaiseIrql(HIGH_LEVEL, &Irql);
|
||||
|
||||
/* RtlCopyMemoryNonTemporal */
|
||||
MakePattern(Buffer, 2, 64, 0x12, 0x34, 2, 192, 0x56, 0x78, 0);
|
||||
RtlCopyMemoryNonTemporal(Buffer + 13, Buffer + 62, 95);
|
||||
ok_bool_true(CheckPattern(Buffer, 2, 6, 0x12, 0x34, 1, 1, 0x12, 2, 33, 0x12, 0x34, 2, 14, 0x56, 0x78, 1, 1, 0x56, 2, 10, 0x12, 0x34, 2, 192, 0x56, 0x78, 1, 1, 0, 0), "CheckPattern");
|
||||
|
||||
MakePattern(Buffer, 2, 32, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 192, 0x9A, 0xAB, 0);
|
||||
RtlCopyMemoryNonTemporal(Buffer + 78, Buffer + 43, 107);
|
||||
ok_bool_true(CheckPattern(Buffer, 2, 32, 0x12, 0x34, 2, 7, 0x56, 0x78, 1, 1, 0x34, 2, 10, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 11, 0x9A, 0xAB, 1, 1, 0xAB, 2, 163, 0x9A, 0xAB, 1, 1, 0, 0), "CheckPattern");
|
||||
|
||||
KeLowerIrql(Irql);
|
||||
Status = STATUS_SUCCESS;
|
||||
_SEH2_TRY {
|
||||
RtlCopyMemoryNonTemporal(NULL, NULL, 0);
|
||||
} _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
|
||||
Status = _SEH2_GetExceptionCode();
|
||||
} _SEH2_END;
|
||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||
KeRaiseIrql(HIGH_LEVEL, &Irql);
|
||||
|
||||
/* RtlCopyBytes */
|
||||
MakePattern(Buffer, 2, 64, 0x12, 0x34, 2, 192, 0x56, 0x78, 0);
|
||||
RtlCopyBytes(Buffer + 13, Buffer + 62, 95);
|
||||
ok_bool_true(CheckPattern(Buffer, 2, 6, 0x12, 0x34, 1, 1, 0x12, 2, 33, 0x12, 0x34, 2, 14, 0x56, 0x78, 1, 1, 0x56, 2, 10, 0x12, 0x34, 2, 192, 0x56, 0x78, 1, 1, 0, 0), "CheckPattern");
|
||||
|
||||
MakePattern(Buffer, 2, 32, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 192, 0x9A, 0xAB, 0);
|
||||
RtlCopyBytes(Buffer + 78, Buffer + 43, 107);
|
||||
ok_bool_true(CheckPattern(Buffer, 2, 32, 0x12, 0x34, 2, 7, 0x56, 0x78, 1, 1, 0x34, 2, 10, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 11, 0x9A, 0xAB, 1, 1, 0xAB, 2, 163, 0x9A, 0xAB, 1, 1, 0, 0), "CheckPattern");
|
||||
|
||||
KeLowerIrql(Irql);
|
||||
Status = STATUS_SUCCESS;
|
||||
_SEH2_TRY {
|
||||
RtlCopyBytes(NULL, NULL, 0);
|
||||
} _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
|
||||
Status = _SEH2_GetExceptionCode();
|
||||
} _SEH2_END;
|
||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||
KeRaiseIrql(HIGH_LEVEL, &Irql);
|
||||
|
||||
/* RtlEqualMemory */
|
||||
/* TODO: where is memcmp? */
|
||||
|
||||
/* RtlCompareMemory */
|
||||
MakePattern(Buffer, 8, HalfSize / 8 - 1, 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
|
||||
1, 1, 0x12,
|
||||
8, HalfSize / 8, 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
|
||||
1, 7, 0x12, 0);
|
||||
|
||||
RetSize = RtlCompareMemory(Buffer, Buffer + HalfSize - 7, HalfSize - 8);
|
||||
ok_eq_size(RetSize, HalfSize - 8);
|
||||
RetSize = RtlCompareMemory(Buffer, Buffer + HalfSize - 7, HalfSize - 8 + 1);
|
||||
ok_eq_size(RetSize, HalfSize - 8 + 1);
|
||||
RetSize = RtlCompareMemory(Buffer, Buffer + HalfSize - 7, HalfSize - 8 + 2);
|
||||
ok_eq_size(RetSize, HalfSize - 8 + 1);
|
||||
|
||||
KeLowerIrql(Irql);
|
||||
Status = STATUS_SUCCESS;
|
||||
_SEH2_TRY {
|
||||
RetSize = RtlCompareMemory(Buffer, Buffer + HalfSize - 7, SIZE_MAX);
|
||||
ok_eq_size(RetSize, HalfSize - 8 + 1);
|
||||
RetSize = RtlCompareMemory(NULL, NULL, 0);
|
||||
ok_eq_size(RetSize, 0LU);
|
||||
} _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
|
||||
Status = _SEH2_GetExceptionCode();
|
||||
} _SEH2_END;
|
||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||
KeRaiseIrql(HIGH_LEVEL, &Irql);
|
||||
|
||||
/* RtlCompareMemoryUlong */
|
||||
MakeBuffer(Buffer, 8, 0x55, Size - 4, 0, 0);
|
||||
RetSize = RtlCompareMemoryUlong(Buffer, sizeof(ULONG), 0x55555555LU);
|
||||
ok_eq_size(RetSize, 4LU);
|
||||
RetSize = RtlCompareMemoryUlong(Buffer + 1, sizeof(ULONG), 0x55555555LU);
|
||||
ok_eq_size(RetSize, 4LU);
|
||||
RetSize = RtlCompareMemoryUlong(Buffer + 2, sizeof(ULONG), 0x55555555LU);
|
||||
ok_eq_size(RetSize, 4LU);
|
||||
RetSize = RtlCompareMemoryUlong(Buffer + 3, sizeof(ULONG), 0x55555555LU);
|
||||
ok_eq_size(RetSize, 4LU);
|
||||
RetSize = RtlCompareMemoryUlong(Buffer + 5, sizeof(ULONG), 0x55555555LU);
|
||||
ok_eq_size(RetSize, 0LU);
|
||||
RetSize = RtlCompareMemoryUlong(Buffer + 5, sizeof(ULONG), 0x00555555LU);
|
||||
ok_eq_size(RetSize, 4LU);
|
||||
RetSize = RtlCompareMemoryUlong(Buffer, 1, 0x55555555LU);
|
||||
ok_eq_size(RetSize, 0LU);
|
||||
RetSize = RtlCompareMemoryUlong(Buffer, 2, 0x55555555LU);
|
||||
ok_eq_size(RetSize, 0LU);
|
||||
RetSize = RtlCompareMemoryUlong(Buffer, 3, 0x55555555LU);
|
||||
ok_eq_size(RetSize, 0LU);
|
||||
RetSize = RtlCompareMemoryUlong(Buffer, 5, 0x55555555LU);
|
||||
ok_eq_size(RetSize, 4LU);
|
||||
|
||||
KeLowerIrql(Irql);
|
||||
Status = STATUS_SUCCESS;
|
||||
_SEH2_TRY {
|
||||
RetSize = RtlCompareMemoryUlong(NULL, 0, 0x55555555LU);
|
||||
ok_eq_size(RetSize, 0LU);
|
||||
} _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
|
||||
Status = _SEH2_GetExceptionCode();
|
||||
} _SEH2_END;
|
||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||
KeRaiseIrql(HIGH_LEVEL, &Irql);
|
||||
|
||||
/* RtlZeroMemory */
|
||||
MakeBuffer(Buffer, Size, 0x11, 0);
|
||||
RtlZeroMemory(Buffer, 1);
|
||||
ok_bool_true(CheckBuffer(Buffer, 1, 0, Size - 1, 0x11, 1, 0, 0), "CheckBuffer");
|
||||
Buffer[0] = 0x11;
|
||||
RtlZeroMemory(Buffer, Size - 1);
|
||||
ok_bool_true(CheckBuffer(Buffer, Size - 1, 0, 1, 0x11, 1, 0, 0), "CheckBuffer");
|
||||
|
||||
KeLowerIrql(Irql);
|
||||
Status = STATUS_SUCCESS;
|
||||
_SEH2_TRY {
|
||||
RtlZeroMemory(NULL, 0);
|
||||
} _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
|
||||
Status = _SEH2_GetExceptionCode();
|
||||
} _SEH2_END;
|
||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||
KeRaiseIrql(HIGH_LEVEL, &Irql);
|
||||
|
||||
/* RtlSecureZeroMemory */
|
||||
MakeBuffer(Buffer, Size, 0x11, 0);
|
||||
RtlSecureZeroMemory(Buffer, 1);
|
||||
ok_bool_true(CheckBuffer(Buffer, 1, 0, Size - 1, 0x11, 1, 0, 0), "CheckBuffer");
|
||||
Buffer[0] = 0x11;
|
||||
RtlSecureZeroMemory(Buffer, Size - 1);
|
||||
ok_bool_true(CheckBuffer(Buffer, Size - 1, 0, 1, 0x11, 1, 0, 0), "CheckBuffer");
|
||||
|
||||
KeLowerIrql(Irql);
|
||||
Status = STATUS_SUCCESS;
|
||||
_SEH2_TRY {
|
||||
RtlSecureZeroMemory(NULL, 0);
|
||||
} _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
|
||||
Status = _SEH2_GetExceptionCode();
|
||||
} _SEH2_END;
|
||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||
KeRaiseIrql(HIGH_LEVEL, &Irql);
|
||||
|
||||
/* RtlZeroBytes */
|
||||
MakeBuffer(Buffer, Size, 0x11, 0);
|
||||
RtlZeroBytes(Buffer, 1);
|
||||
ok_bool_true(CheckBuffer(Buffer, 1, 0, Size - 1, 0x11, 1, 0, 0), "CheckBuffer");
|
||||
Buffer[0] = 0x11;
|
||||
RtlZeroBytes(Buffer, Size - 1);
|
||||
ok_bool_true(CheckBuffer(Buffer, Size - 1, 0, 1, 0x11, 1, 0, 0), "CheckBuffer");
|
||||
|
||||
KeLowerIrql(Irql);
|
||||
Status = STATUS_SUCCESS;
|
||||
_SEH2_TRY {
|
||||
RtlZeroBytes(NULL, 0);
|
||||
} _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
|
||||
Status = _SEH2_GetExceptionCode();
|
||||
} _SEH2_END;
|
||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||
KeRaiseIrql(HIGH_LEVEL, &Irql);
|
||||
|
||||
/* RtlFillMemory */
|
||||
MakeBuffer(Buffer, Size, 0, 0);
|
||||
RtlFillMemory(Buffer, HalfSize, 0x55);
|
||||
RtlFillMemory(Buffer + HalfSize, HalfSize, 0xAA);
|
||||
ok_bool_true(CheckBuffer(Buffer, HalfSize, 0x55, HalfSize, 0xAA, 1, 0, 0), "CheckBuffer");
|
||||
RtlFillMemory(Buffer + 3, 7, 0x88);
|
||||
ok_bool_true(CheckBuffer(Buffer, 3, 0x55, 7, 0x88, HalfSize - 10, 0x55, HalfSize, 0xAA, 1, 0, 0), "CheckBuffer");
|
||||
|
||||
KeLowerIrql(Irql);
|
||||
Status = STATUS_SUCCESS;
|
||||
_SEH2_TRY {
|
||||
RtlFillMemory(NULL, 0, 0x55);
|
||||
} _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
|
||||
Status = _SEH2_GetExceptionCode();
|
||||
} _SEH2_END;
|
||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||
KeRaiseIrql(HIGH_LEVEL, &Irql);
|
||||
|
||||
#undef RtlFillMemory
|
||||
/* RtlFillMemory export */
|
||||
MakeBuffer(Buffer, Size, 0, 0);
|
||||
RtlFillMemory(Buffer, HalfSize, 0x55);
|
||||
RtlFillMemory(Buffer + HalfSize, HalfSize, 0xAA);
|
||||
ok_bool_true(CheckBuffer(Buffer, HalfSize, 0x55, HalfSize, 0xAA, 1, 0, 0), "CheckBuffer");
|
||||
RtlFillMemory(Buffer + 3, 7, 0x88);
|
||||
ok_bool_true(CheckBuffer(Buffer, 3, 0x55, 7, 0x88, HalfSize - 10, 0x55, HalfSize, 0xAA, 1, 0, 0), "CheckBuffer");
|
||||
|
||||
KeLowerIrql(Irql);
|
||||
Status = STATUS_SUCCESS;
|
||||
_SEH2_TRY {
|
||||
RtlFillMemory(NULL, 0, 0x55);
|
||||
} _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
|
||||
Status = _SEH2_GetExceptionCode();
|
||||
} _SEH2_END;
|
||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||
KeRaiseIrql(HIGH_LEVEL, &Irql);
|
||||
|
||||
/* RtlFillMemoryUlong */
|
||||
MakeBuffer(Buffer, Size, 0, 0);
|
||||
RtlFillMemoryUlong(Buffer, HalfSize, 0x01234567LU);
|
||||
RtlFillMemoryUlong(Buffer + HalfSize, HalfSize, 0x89ABCDEFLU);
|
||||
ok_bool_true(CheckPattern(Buffer, 4, HalfSize / 4, 0x67, 0x45, 0x23, 0x01, 4, HalfSize / 4, 0xEF, 0xCD, 0xAB, 0x89, 1, 1, 0, 0), "CheckPattern");
|
||||
|
||||
KeLowerIrql(Irql);
|
||||
Status = STATUS_SUCCESS;
|
||||
_SEH2_TRY {
|
||||
MakeBuffer(Buffer, Size, 0, 0);
|
||||
RtlFillMemoryUlong(Buffer + 1, sizeof(ULONG), 0xAAAAAAAALU);
|
||||
ok_bool_true(CheckBuffer(Buffer, 1, 0, sizeof(ULONG), 0xAA, Size - sizeof(ULONG) - 1, 0, 1, 0, 0), "CheckBuffer");
|
||||
|
||||
RtlFillMemoryUlong(NULL, 0, 0x55555555LU);
|
||||
} _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
|
||||
Status = _SEH2_GetExceptionCode();
|
||||
} _SEH2_END;
|
||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||
KeRaiseIrql(HIGH_LEVEL, &Irql);
|
||||
|
||||
/* RtlFillMemoryUlonglong */
|
||||
/* TODO: this function doesn't exist in 2k3/x86? wdm.h error? */
|
||||
|
||||
/* RtlFillBytes */
|
||||
MakeBuffer(Buffer, Size, 0, 0);
|
||||
RtlFillBytes(Buffer, HalfSize, 0x55);
|
||||
RtlFillBytes(Buffer + HalfSize, HalfSize, 0xAA);
|
||||
ok_bool_true(CheckBuffer(Buffer, HalfSize, 0x55, HalfSize, 0xAA, 1, 0, 0), "CheckBuffer");
|
||||
RtlFillBytes(Buffer + 3, 7, 0x88);
|
||||
ok_bool_true(CheckBuffer(Buffer, 3, 0x55, 7, 0x88, HalfSize - 10, 0x55, HalfSize, 0xAA, 1, 0, 0), "CheckBuffer");
|
||||
|
||||
KeLowerIrql(Irql);
|
||||
Status = STATUS_SUCCESS;
|
||||
_SEH2_TRY {
|
||||
RtlFillBytes(NULL, 0, 0x55);
|
||||
} _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
|
||||
Status = _SEH2_GetExceptionCode();
|
||||
} _SEH2_END;
|
||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||
KeRaiseIrql(HIGH_LEVEL, &Irql);
|
||||
|
||||
/* RtlPrefetchMemoryNonTemporal */
|
||||
RtlPrefetchMemoryNonTemporal(Buffer, Size);
|
||||
|
||||
KeLowerIrql(Irql);
|
||||
Status = STATUS_SUCCESS;
|
||||
_SEH2_TRY {
|
||||
RtlPrefetchMemoryNonTemporal(NULL, 0);
|
||||
} _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
|
||||
Status = _SEH2_GetExceptionCode();
|
||||
} _SEH2_END;
|
||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||
KeRaiseIrql(HIGH_LEVEL, &Irql);
|
||||
|
||||
KeLowerIrql(Irql);
|
||||
}
|
||||
|
|
|
@ -11,17 +11,6 @@
|
|||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
/* HACK: missing in rtlfuncs.h */
|
||||
#if defined KMT_USER_MODE && !defined RTL_USE_AVL_TABLES
|
||||
NTSYSAPI VOID NTAPI RtlInitializeGenericTable(OUT PRTL_GENERIC_TABLE Table, IN PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine, IN PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine, IN PRTL_GENERIC_FREE_ROUTINE FreeRoutine, IN PVOID TableContext OPTIONAL);
|
||||
NTSYSAPI PVOID NTAPI RtlInsertElementGenericTable(IN PRTL_GENERIC_TABLE Table, IN PVOID Buffer, IN CLONG BufferSize, OUT PBOOLEAN NewElement OPTIONAL);
|
||||
NTSYSAPI BOOLEAN NTAPI RtlDeleteElementGenericTable(IN PRTL_GENERIC_TABLE Table, IN PVOID Buffer);
|
||||
NTSYSAPI PVOID NTAPI RtlLookupElementGenericTable(IN PRTL_GENERIC_TABLE Table, IN PVOID Buffer);
|
||||
NTSYSAPI PVOID NTAPI RtlEnumerateGenericTable(IN PRTL_GENERIC_TABLE Table, IN BOOLEAN Restart);
|
||||
NTSYSAPI PVOID NTAPI RtlGetElementGenericTable(IN PRTL_GENERIC_TABLE Table, IN ULONG I);
|
||||
NTSYSAPI ULONG NTAPI RtlNumberGenericTableElements(IN PRTL_GENERIC_TABLE Table);
|
||||
#endif
|
||||
|
||||
static LIST_ENTRY Allocations;
|
||||
|
||||
static RTL_GENERIC_COMPARE_RESULTS NTAPI
|
||||
|
|
Loading…
Reference in a new issue