* PROGRAMMER: Aleksey Bragin <aleksey@reactos.org>
*/
-/* TODO: PoolsCorruption tests fail because accessing invalid memory doesn't necessarily cause an access violation */
-
#include <kmt_test.h>
#define NDEBUG
static VOID PoolsCorruption(VOID)
{
- PULONG Ptr, TestPtr;
+ PULONG Ptr;
ULONG AllocSize;
- NTSTATUS Status = STATUS_SUCCESS;
// start with non-paged pool
AllocSize = 4096 + 0x10;
// touch all bytes, it shouldn't cause an exception
RtlZeroMemory(Ptr, AllocSize);
+/* TODO: These fail because accessing invalid memory doesn't necessarily
+ cause an access violation */
+#ifdef THIS_DOESNT_WORK
// test buffer overrun, right after our allocation ends
_SEH2_TRY
{
} _SEH2_END;
ok(Status == STATUS_ACCESS_VIOLATION, "Exception should occur, but got Status 0x%08lX\n", Status);
+#endif
// free the pool
ExFreePoolWithTag(Ptr, TAG_POOLTEST);
}
+static
+VOID
+TestPoolTags(VOID)
+{
+ PVOID Memory;
+
+ Memory = ExAllocatePoolWithTag(PagedPool, 8, 'MyTa');
+ ok_eq_tag(KmtGetPoolTag(Memory), 'MyTa');
+ ExFreePoolWithTag(Memory, 'MyTa');
+
+ Memory = ExAllocatePoolWithTag(PagedPool, PAGE_SIZE, 'MyTa');
+ ok_eq_tag(KmtGetPoolTag(Memory), 'TooL');
+ ExFreePoolWithTag(Memory, 'MyTa');
+
+ Memory = ExAllocatePoolWithTag(PagedPool, PAGE_SIZE - 3 * sizeof(PVOID), 'MyTa');
+ ok_eq_tag(KmtGetPoolTag(Memory), 'TooL');
+ ExFreePoolWithTag(Memory, 'MyTa');
+
+ Memory = ExAllocatePoolWithTag(PagedPool, PAGE_SIZE - 4 * sizeof(PVOID) + 1, 'MyTa');
+ ok_eq_tag(KmtGetPoolTag(Memory), 'TooL');
+ ExFreePoolWithTag(Memory, 'MyTa');
+
+ Memory = ExAllocatePoolWithTag(PagedPool, PAGE_SIZE - 4 * sizeof(PVOID), 'MyTa');
+ ok_eq_tag(KmtGetPoolTag(Memory), 'MyTa');
+ ExFreePoolWithTag(Memory, 'MyTa');
+}
+
START_TEST(ExPools)
{
PoolsTest();
PoolsCorruption();
+ TestPoolTags();
}