mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 22:23:05 +00:00
[KMTESTS] Fixes for 2003, Vista, 7, 8, 10 x86 and x64 (#8175)
Fix several kmtests in preparation for testbots with newer versions of Windows. There's still more kmtests to fix, but this fixes all the kmtests that bugchecked during my testing.
This commit is contained in:
parent
83faff8706
commit
19e8fbb20e
13 changed files with 614 additions and 178 deletions
|
@ -18,6 +18,8 @@
|
||||||
|
|
||||||
#include <kmt_platform.h>
|
#include <kmt_platform.h>
|
||||||
|
|
||||||
|
#define GetNTVersion() ((SharedUserData->NtMajorVersion << 8) | SharedUserData->NtMinorVersion)
|
||||||
|
|
||||||
typedef VOID KMT_TESTFUNC(VOID);
|
typedef VOID KMT_TESTFUNC(VOID);
|
||||||
typedef KMT_TESTFUNC *PKMT_TESTFUNC;
|
typedef KMT_TESTFUNC *PKMT_TESTFUNC;
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@ static PDEVICE_OBJECT MainDeviceObject;
|
||||||
PDRIVER_OBJECT KmtDriverObject = NULL;
|
PDRIVER_OBJECT KmtDriverObject = NULL;
|
||||||
static KMT_USER_WORK_LIST WorkList;
|
static KMT_USER_WORK_LIST WorkList;
|
||||||
static ULONG RequestId = 0;
|
static ULONG RequestId = 0;
|
||||||
|
static const LONGLONG TimeoutDuration = -10LL * (1000 * 1000 * 10); // 10 seconds
|
||||||
|
|
||||||
/* Entry */
|
/* Entry */
|
||||||
/**
|
/**
|
||||||
|
@ -440,13 +441,19 @@ DriverIoControl(
|
||||||
{
|
{
|
||||||
PLIST_ENTRY Entry;
|
PLIST_ENTRY Entry;
|
||||||
PKMT_USER_WORK_ENTRY WorkItem;
|
PKMT_USER_WORK_ENTRY WorkItem;
|
||||||
|
LARGE_INTEGER Timeout;
|
||||||
|
|
||||||
DPRINT("DriverIoControl. IOCTL_KMTEST_USERMODE_AWAIT_REQ, len=%lu\n",
|
DPRINT("DriverIoControl. IOCTL_KMTEST_USERMODE_AWAIT_REQ, len=%lu\n",
|
||||||
IoStackLocation->Parameters.DeviceIoControl.OutputBufferLength);
|
IoStackLocation->Parameters.DeviceIoControl.OutputBufferLength);
|
||||||
|
|
||||||
/* TODO: prevent multiple concurrent invocations */
|
/* TODO: prevent multiple concurrent invocations */
|
||||||
Status = KeWaitForSingleObject(&WorkList.NewWorkEvent, UserRequest, UserMode, FALSE, NULL);
|
Timeout.QuadPart = TimeoutDuration;
|
||||||
if (Status == STATUS_USER_APC || Status == STATUS_KERNEL_APC)
|
Status = KeWaitForSingleObject(&WorkList.NewWorkEvent, UserRequest, UserMode, FALSE, &Timeout);
|
||||||
|
|
||||||
|
if (Status == STATUS_TIMEOUT)
|
||||||
|
DPRINT1("KeWaitForSingleObject timed out!\n");
|
||||||
|
|
||||||
|
if (Status == STATUS_USER_APC || Status == STATUS_KERNEL_APC || Status == STATUS_TIMEOUT)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (IoStackLocation->Parameters.DeviceIoControl.OutputBufferLength < sizeof(KMT_CALLBACK_REQUEST_PACKET))
|
if (IoStackLocation->Parameters.DeviceIoControl.OutputBufferLength < sizeof(KMT_CALLBACK_REQUEST_PACKET))
|
||||||
|
@ -580,7 +587,7 @@ KmtUserModeCallback(
|
||||||
|
|
||||||
KeSetEvent(&WorkList.NewWorkEvent, IO_NO_INCREMENT, FALSE);
|
KeSetEvent(&WorkList.NewWorkEvent, IO_NO_INCREMENT, FALSE);
|
||||||
|
|
||||||
Timeout.QuadPart = -10 * 1000 * 1000 * 10; //wait for 10 seconds
|
Timeout.QuadPart = TimeoutDuration;
|
||||||
Status = KeWaitForSingleObject(&WorkEntry->WorkDoneEvent, Executive, UserMode, FALSE, &Timeout);
|
Status = KeWaitForSingleObject(&WorkEntry->WorkDoneEvent, Executive, UserMode, FALSE, &Timeout);
|
||||||
|
|
||||||
if (Status == STATUS_USER_APC || Status == STATUS_KERNEL_APC || Status == STATUS_TIMEOUT)
|
if (Status == STATUS_USER_APC || Status == STATUS_KERNEL_APC || Status == STATUS_TIMEOUT)
|
||||||
|
|
|
@ -54,10 +54,13 @@ DpcHandler(
|
||||||
ok_eq_pointer(Dpc->SystemArgument2, SystemArgument2);
|
ok_eq_pointer(Dpc->SystemArgument2, SystemArgument2);
|
||||||
ok_eq_pointer(Dpc->DpcData, NULL);
|
ok_eq_pointer(Dpc->DpcData, NULL);
|
||||||
|
|
||||||
|
if (GetNTVersion() == _WIN32_WINNT_WS03)
|
||||||
|
{
|
||||||
ok_eq_uint(Prcb->DpcRoutineActive, 1);
|
ok_eq_uint(Prcb->DpcRoutineActive, 1);
|
||||||
/* this DPC is not in the list anymore, but it was at the head! */
|
/* this DPC is not in the list anymore, but it was at the head! */
|
||||||
ok_eq_pointer(Prcb->DpcData[DPC_NORMAL].DpcListHead.Flink, Dpc->DpcListEntry.Flink);
|
ok_eq_pointer(Prcb->DpcData[DPC_NORMAL].DpcListHead.Flink, Dpc->DpcListEntry.Flink);
|
||||||
ok_eq_pointer(Prcb->DpcData[DPC_NORMAL].DpcListHead.Blink, Dpc->DpcListEntry.Blink);
|
ok_eq_pointer(Prcb->DpcData[DPC_NORMAL].DpcListHead.Blink, Dpc->DpcListEntry.Blink);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
START_TEST(KeDpc)
|
START_TEST(KeDpc)
|
||||||
|
@ -81,6 +84,7 @@ START_TEST(KeDpc)
|
||||||
ok_eq_uint(Dpc.Importance, DpcImportance);
|
ok_eq_uint(Dpc.Importance, DpcImportance);
|
||||||
ok_eq_uint(Dpc.Number, 0);
|
ok_eq_uint(Dpc.Number, 0);
|
||||||
ok_eq_pointer(Dpc.DpcListEntry.Flink, (LIST_ENTRY *)0x5555555555555555LL);
|
ok_eq_pointer(Dpc.DpcListEntry.Flink, (LIST_ENTRY *)0x5555555555555555LL);
|
||||||
|
if (Dpc.DpcListEntry.Blink)
|
||||||
ok_eq_pointer(Dpc.DpcListEntry.Blink, (LIST_ENTRY *)0x5555555555555555LL);
|
ok_eq_pointer(Dpc.DpcListEntry.Blink, (LIST_ENTRY *)0x5555555555555555LL);
|
||||||
ok_eq_pointer(Dpc.DeferredRoutine, DpcHandler);
|
ok_eq_pointer(Dpc.DeferredRoutine, DpcHandler);
|
||||||
ok_eq_pointer(Dpc.DeferredContext, &Dpc);
|
ok_eq_pointer(Dpc.DeferredContext, &Dpc);
|
||||||
|
@ -88,6 +92,10 @@ START_TEST(KeDpc)
|
||||||
ok_eq_pointer(Dpc.SystemArgument2, (PVOID)0x5555555555555555LL);
|
ok_eq_pointer(Dpc.SystemArgument2, (PVOID)0x5555555555555555LL);
|
||||||
ok_eq_pointer(Dpc.DpcData, NULL);
|
ok_eq_pointer(Dpc.DpcData, NULL);
|
||||||
|
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
|
{
|
||||||
|
// Windows 8+ is stricter about misusing DPC, these tests bugcheck there.
|
||||||
|
|
||||||
/* simply run the Dpc a few times */
|
/* simply run the Dpc a few times */
|
||||||
for (i = 0; i < 5; ++i)
|
for (i = 0; i < 5; ++i)
|
||||||
{
|
{
|
||||||
|
@ -143,6 +151,7 @@ START_TEST(KeDpc)
|
||||||
ok_dpccount();
|
ok_dpccount();
|
||||||
}
|
}
|
||||||
KeLowerIrql(Irql);
|
KeLowerIrql(Irql);
|
||||||
|
}
|
||||||
|
|
||||||
/* parameter checks */
|
/* parameter checks */
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
|
@ -153,8 +162,10 @@ START_TEST(KeDpc)
|
||||||
} _SEH2_END;
|
} _SEH2_END;
|
||||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
|
|
||||||
if (!skip(Status == STATUS_SUCCESS, "KeInitializeDpc failed\n"))
|
if (!skip(Status == STATUS_SUCCESS, "KeInitializeDpc failed\n") &&
|
||||||
|
GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
{
|
{
|
||||||
|
// Inserting NULL in a DPC gives a TIMER_OR_DPC_INVALID bugcheck on Windows 8+.
|
||||||
KeRaiseIrql(HIGH_LEVEL, &Irql);
|
KeRaiseIrql(HIGH_LEVEL, &Irql);
|
||||||
Ret = KeInsertQueueDpc(&Dpc, NULL, NULL);
|
Ret = KeInsertQueueDpc(&Dpc, NULL, NULL);
|
||||||
ok_bool_true(Ret, "KeInsertQueueDpc returned");
|
ok_bool_true(Ret, "KeInsertQueueDpc returned");
|
||||||
|
|
|
@ -238,7 +238,9 @@ BOOLEAN TryNoRaise(PKSPIN_LOCK SpinLock, PCHECK_DATA CheckData) {
|
||||||
\
|
\
|
||||||
if ((CheckData)->IsAcquired) \
|
if ((CheckData)->IsAcquired) \
|
||||||
ExpectedIrql = (CheckData)->IrqlWhenAcquired; \
|
ExpectedIrql = (CheckData)->IrqlWhenAcquired; \
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8) \
|
||||||
ok_irql(ExpectedIrql); \
|
ok_irql(ExpectedIrql); \
|
||||||
|
if (GetNTVersion() == _WIN32_WINNT_WS03) \
|
||||||
ok_bool_false(KeAreApcsDisabled(), "KeAreApcsDisabled returned"); \
|
ok_bool_false(KeAreApcsDisabled(), "KeAreApcsDisabled returned"); \
|
||||||
ok_bool_true(KmtAreInterruptsEnabled(), "Interrupts enabled:"); \
|
ok_bool_true(KmtAreInterruptsEnabled(), "Interrupts enabled:"); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
@ -257,9 +259,15 @@ TestSpinLock(
|
||||||
if (SpinLock)
|
if (SpinLock)
|
||||||
ok_eq_ulongptr(*SpinLock, 0);
|
ok_eq_ulongptr(*SpinLock, 0);
|
||||||
CheckData->Acquire(SpinLock, CheckData);
|
CheckData->Acquire(SpinLock, CheckData);
|
||||||
|
#ifdef _M_IX86
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
CheckSpinLock(SpinLock, CheckData, 1);
|
CheckSpinLock(SpinLock, CheckData, 1);
|
||||||
|
#endif
|
||||||
CheckData->Release(SpinLock, CheckData);
|
CheckData->Release(SpinLock, CheckData);
|
||||||
|
#ifdef _M_IX86
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
CheckSpinLock(SpinLock, CheckData, 0);
|
CheckSpinLock(SpinLock, CheckData, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (CheckData->TryAcquire)
|
if (CheckData->TryAcquire)
|
||||||
{
|
{
|
||||||
|
@ -295,19 +303,31 @@ TestSpinLock(
|
||||||
{
|
{
|
||||||
/* acquire/release without irql change */
|
/* acquire/release without irql change */
|
||||||
CheckData->AcquireNoRaise(SpinLock, CheckData);
|
CheckData->AcquireNoRaise(SpinLock, CheckData);
|
||||||
|
#ifdef _M_IX86
|
||||||
|
// Fails on x64 and Windows 8+
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
CheckSpinLock(SpinLock, CheckData, 1);
|
CheckSpinLock(SpinLock, CheckData, 1);
|
||||||
|
#endif
|
||||||
CheckData->ReleaseNoLower(SpinLock, CheckData);
|
CheckData->ReleaseNoLower(SpinLock, CheckData);
|
||||||
CheckSpinLock(SpinLock, CheckData, 0);
|
CheckSpinLock(SpinLock, CheckData, 0);
|
||||||
|
|
||||||
/* acquire without raise, but normal release */
|
/* acquire without raise, but normal release */
|
||||||
CheckData->AcquireNoRaise(SpinLock, CheckData);
|
CheckData->AcquireNoRaise(SpinLock, CheckData);
|
||||||
|
#ifdef _M_IX86
|
||||||
|
// Fails on x64 and Windows 8+
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
CheckSpinLock(SpinLock, CheckData, 1);
|
CheckSpinLock(SpinLock, CheckData, 1);
|
||||||
|
#endif
|
||||||
CheckData->Release(SpinLock, CheckData);
|
CheckData->Release(SpinLock, CheckData);
|
||||||
CheckSpinLock(SpinLock, CheckData, 0);
|
CheckSpinLock(SpinLock, CheckData, 0);
|
||||||
|
|
||||||
/* acquire normally but release without lower */
|
/* acquire normally but release without lower */
|
||||||
CheckData->Acquire(SpinLock, CheckData);
|
CheckData->Acquire(SpinLock, CheckData);
|
||||||
|
#ifdef _M_IX86
|
||||||
|
// Fails on x64 and Windows 8+
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
CheckSpinLock(SpinLock, CheckData, 1);
|
CheckSpinLock(SpinLock, CheckData, 1);
|
||||||
|
#endif
|
||||||
CheckData->ReleaseNoLower(SpinLock, CheckData);
|
CheckData->ReleaseNoLower(SpinLock, CheckData);
|
||||||
CheckSpinLock(SpinLock, CheckData, 0);
|
CheckSpinLock(SpinLock, CheckData, 0);
|
||||||
CheckData->IsAcquired = FALSE;
|
CheckData->IsAcquired = FALSE;
|
||||||
|
@ -349,7 +369,7 @@ START_TEST(KeSpinLock)
|
||||||
PKSPIN_LOCK pSpinLock = &SpinLock;
|
PKSPIN_LOCK pSpinLock = &SpinLock;
|
||||||
KIRQL Irql, SynchIrql = KmtIsMultiProcessorBuild ? IPI_LEVEL - 2 : DISPATCH_LEVEL;
|
KIRQL Irql, SynchIrql = KmtIsMultiProcessorBuild ? IPI_LEVEL - 2 : DISPATCH_LEVEL;
|
||||||
KIRQL OriginalIrqls[] = { PASSIVE_LEVEL, APC_LEVEL, DISPATCH_LEVEL, HIGH_LEVEL };
|
KIRQL OriginalIrqls[] = { PASSIVE_LEVEL, APC_LEVEL, DISPATCH_LEVEL, HIGH_LEVEL };
|
||||||
CHECK_DATA TestData[] =
|
CHECK_DATA TestDataWS03[] =
|
||||||
{
|
{
|
||||||
{ CheckLock, DISPATCH_LEVEL, AcquireNormal, ReleaseNormal, NULL, AcquireNoRaise, ReleaseNoLower, TryNoRaise },
|
{ CheckLock, DISPATCH_LEVEL, AcquireNormal, ReleaseNormal, NULL, AcquireNoRaise, ReleaseNoLower, TryNoRaise },
|
||||||
{ CheckLock, DISPATCH_LEVEL, AcquireExp, ReleaseExp, NULL, AcquireExpNoRaise, ReleaseExpNoLower, NULL },
|
{ CheckLock, DISPATCH_LEVEL, AcquireExp, ReleaseExp, NULL, AcquireExpNoRaise, ReleaseExpNoLower, NULL },
|
||||||
|
@ -363,6 +383,18 @@ START_TEST(KeSpinLock)
|
||||||
{ CheckQueue, DISPATCH_LEVEL, AcquireQueued, ReleaseQueued, TryQueued, NULL, NULL, NULL, LockQueuePfnLock },
|
{ CheckQueue, DISPATCH_LEVEL, AcquireQueued, ReleaseQueued, TryQueued, NULL, NULL, NULL, LockQueuePfnLock },
|
||||||
{ CheckQueue, SynchIrql, AcquireQueuedSynch, ReleaseQueued, TryQueuedSynch, NULL, NULL, NULL, LockQueuePfnLock },
|
{ CheckQueue, SynchIrql, AcquireQueuedSynch, ReleaseQueued, TryQueuedSynch, NULL, NULL, NULL, LockQueuePfnLock },
|
||||||
};
|
};
|
||||||
|
CHECK_DATA TestDataWin7[] =
|
||||||
|
{
|
||||||
|
{ CheckLock, DISPATCH_LEVEL, AcquireNormal, ReleaseNormal, NULL, AcquireNoRaise, ReleaseNoLower, TryNoRaise },
|
||||||
|
{ CheckLock, DISPATCH_LEVEL, AcquireExp, ReleaseExp, NULL, AcquireExpNoRaise, ReleaseExpNoLower, NULL },
|
||||||
|
{ CheckLock, DISPATCH_LEVEL, AcquireNormal, ReleaseNormal, NULL, AcquireInt, ReleaseInt, NULL },
|
||||||
|
{ CheckLock, SynchIrql, AcquireSynch, ReleaseNormal, NULL, NULL, NULL, NULL },
|
||||||
|
{ CheckQueueHandle, DISPATCH_LEVEL, AcquireInStackQueued, ReleaseInStackQueued, NULL, AcquireInStackNoRaise, ReleaseInStackNoRaise, NULL },
|
||||||
|
{ CheckQueueHandle, SynchIrql, AcquireInStackSynch, ReleaseInStackQueued, NULL, NULL, NULL, NULL },
|
||||||
|
{ CheckQueueHandle, DISPATCH_LEVEL, AcquireInStackQueued, ReleaseInStackQueued, NULL, AcquireInStackForDpc, ReleaseInStackForDpc, NULL },
|
||||||
|
};
|
||||||
|
CHECK_DATA *TestData;
|
||||||
|
ULONG TestElements;
|
||||||
int i, iIrql;
|
int i, iIrql;
|
||||||
PKPRCB Prcb;
|
PKPRCB Prcb;
|
||||||
|
|
||||||
|
@ -398,7 +430,30 @@ START_TEST(KeSpinLock)
|
||||||
if (!KmtIsMultiProcessorBuild && !KmtIsCheckedBuild)
|
if (!KmtIsMultiProcessorBuild && !KmtIsCheckedBuild)
|
||||||
pSpinLock = NULL;
|
pSpinLock = NULL;
|
||||||
|
|
||||||
for (i = 0; i < sizeof TestData / sizeof TestData[0]; ++i)
|
switch (GetNTVersion())
|
||||||
|
{
|
||||||
|
case _WIN32_WINNT_VISTA:
|
||||||
|
#ifdef _M_X64
|
||||||
|
skip(FALSE, "This test is broken on Vista x64.\n");
|
||||||
|
goto done;
|
||||||
|
#endif
|
||||||
|
case _WIN32_WINNT_WS03:
|
||||||
|
TestData = TestDataWS03;
|
||||||
|
TestElements = RTL_NUMBER_OF(TestDataWS03);
|
||||||
|
break;
|
||||||
|
case _WIN32_WINNT_WIN7:
|
||||||
|
case _WIN32_WINNT_WIN8:
|
||||||
|
case _WIN32_WINNT_WINBLUE:
|
||||||
|
case _WIN32_WINNT_WIN10:
|
||||||
|
TestData = TestDataWin7;
|
||||||
|
TestElements = RTL_NUMBER_OF(TestDataWin7);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
skip(FALSE, "Unknown NT version (0x%X).\n", GetNTVersion());
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < TestElements; ++i)
|
||||||
{
|
{
|
||||||
memset(&SpinLock, 0x55, sizeof SpinLock);
|
memset(&SpinLock, 0x55, sizeof SpinLock);
|
||||||
KeInitializeSpinLock(&SpinLock);
|
KeInitializeSpinLock(&SpinLock);
|
||||||
|
@ -423,6 +478,6 @@ START_TEST(KeSpinLock)
|
||||||
KeLowerIrql(Irql);
|
KeLowerIrql(Irql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
done:
|
||||||
KmtSetIrql(PASSIVE_LEVEL);
|
KmtSetIrql(PASSIVE_LEVEL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,9 @@ TestMmAllocatePagesForMdl(VOID)
|
||||||
NULL,
|
NULL,
|
||||||
FALSE,
|
FALSE,
|
||||||
NormalPagePriority);
|
NormalPagePriority);
|
||||||
|
#ifdef _M_IX86
|
||||||
ok(SystemVa == NULL, "MmMapLockedPagesSpecifyCache succeeded for 2 GB\n");
|
ok(SystemVa == NULL, "MmMapLockedPagesSpecifyCache succeeded for 2 GB\n");
|
||||||
|
#endif
|
||||||
if (SystemVa != NULL)
|
if (SystemVa != NULL)
|
||||||
MmUnmapLockedPages(SystemVa, Mdl);
|
MmUnmapLockedPages(SystemVa, Mdl);
|
||||||
ok(MmGetMdlByteCount(Mdl) <= 2UL * 1024 * 1024 * 1024, "Byte count: %lu\n", MmGetMdlByteCount(Mdl));
|
ok(MmGetMdlByteCount(Mdl) <= 2UL * 1024 * 1024 * 1024, "Byte count: %lu\n", MmGetMdlByteCount(Mdl));
|
||||||
|
@ -209,9 +211,13 @@ TestMmBuildMdlForNonPagedPool(VOID)
|
||||||
ok((Mdl->MdlFlags & MDL_PAGES_LOCKED) == 0, "MDL locked\n");
|
ok((Mdl->MdlFlags & MDL_PAGES_LOCKED) == 0, "MDL locked\n");
|
||||||
ok((Mdl->MdlFlags & MDL_SOURCE_IS_NONPAGED_POOL) == 0, "MDL from non paged\n");
|
ok((Mdl->MdlFlags & MDL_SOURCE_IS_NONPAGED_POOL) == 0, "MDL from non paged\n");
|
||||||
|
|
||||||
|
// This fails an assertion on Windows 8+ checked and can bugcheck Windows 10+ free.
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
|
{
|
||||||
MmBuildMdlForNonPagedPool(Mdl);
|
MmBuildMdlForNonPagedPool(Mdl);
|
||||||
ok((Mdl->MdlFlags & MDL_PAGES_LOCKED) == 0, "MDL locked\n");
|
ok((Mdl->MdlFlags & MDL_PAGES_LOCKED) == 0, "MDL locked\n");
|
||||||
ok((Mdl->MdlFlags & MDL_SOURCE_IS_NONPAGED_POOL) != 0, "MDL from paged\n");
|
ok((Mdl->MdlFlags & MDL_SOURCE_IS_NONPAGED_POOL) != 0, "MDL from paged\n");
|
||||||
|
}
|
||||||
|
|
||||||
IoFreeMdl(Mdl);
|
IoFreeMdl(Mdl);
|
||||||
ExFreePoolWithTag(Page, 'Test');
|
ExFreePoolWithTag(Page, 'Test');
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include <kmt_test.h>
|
#include <kmt_test.h>
|
||||||
|
|
||||||
static BOOLEAN g_IsPae;
|
static BOOLEAN g_IsPae;
|
||||||
static ULONG g_OsVersion;
|
|
||||||
static BOOLEAN g_IsReactOS;
|
static BOOLEAN g_IsReactOS;
|
||||||
|
|
||||||
#ifdef _M_IX86
|
#ifdef _M_IX86
|
||||||
|
@ -81,6 +80,12 @@ ValidateMapping(
|
||||||
ULONGLONG PteValue, ExpectedValue;
|
ULONGLONG PteValue, ExpectedValue;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
|
|
||||||
|
#ifdef _M_AMD64
|
||||||
|
if (skip(GetNTVersion() < _WIN32_WINNT_WIN10,
|
||||||
|
"Win10 1607+ breaks these next tests.\n"))
|
||||||
|
return Valid;
|
||||||
|
#endif
|
||||||
|
|
||||||
for (i = 0; i < ValidPtes; i++)
|
for (i = 0; i < ValidPtes; i++)
|
||||||
{
|
{
|
||||||
CurrentAddress = (PUCHAR)BaseAddress + i * PAGE_SIZE;
|
CurrentAddress = (PUCHAR)BaseAddress + i * PAGE_SIZE;
|
||||||
|
@ -106,22 +111,42 @@ ValidateMapping(
|
||||||
}
|
}
|
||||||
CurrentAddress = (PUCHAR)BaseAddress - 1 * PAGE_SIZE;
|
CurrentAddress = (PUCHAR)BaseAddress - 1 * PAGE_SIZE;
|
||||||
PteValue = GET_PTE_VALUE(CurrentAddress);
|
PteValue = GET_PTE_VALUE(CurrentAddress);
|
||||||
|
|
||||||
|
if (skip(GetNTVersion() < _WIN32_WINNT_WIN10,
|
||||||
|
"DVRT (Win10 1607+) breaks these next tests.\n"))
|
||||||
|
return Valid;
|
||||||
|
|
||||||
|
#ifdef _M_AMD64
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
ExpectedValue = ((PoolTag & ~1ULL) + 1) << 28;
|
||||||
|
else if (GetNTVersion() >= _WIN32_WINNT_VISTA)
|
||||||
|
#else
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_VISTA)
|
||||||
|
#endif
|
||||||
|
ExpectedValue = ((PoolTag & ~1ULL) + 1) << 32;
|
||||||
|
else
|
||||||
|
ExpectedValue = PoolTag & ~1ULL;
|
||||||
|
|
||||||
Valid = Valid &&
|
Valid = Valid &&
|
||||||
ok(PteValue == (PoolTag & ~1ULL),
|
ok(PteValue == ExpectedValue,
|
||||||
"PTE for %p contains 0x%I64x, expected %x\n",
|
"PTE for %p contains 0x%I64x, expected 0x%I64x\n",
|
||||||
CurrentAddress, PteValue, PoolTag & ~1);
|
CurrentAddress, PteValue, ExpectedValue);
|
||||||
CurrentAddress = (PUCHAR)BaseAddress - 2 * PAGE_SIZE;
|
CurrentAddress = (PUCHAR)BaseAddress - 2 * PAGE_SIZE;
|
||||||
PteValue = GET_PTE_VALUE(CurrentAddress);
|
PteValue = GET_PTE_VALUE(CurrentAddress);
|
||||||
|
|
||||||
if (g_IsReactOS || g_OsVersion >= 0x0600)
|
#ifdef _M_AMD64
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
{
|
||||||
|
ExpectedValue = (TotalPtes + 2) << 28;
|
||||||
|
}
|
||||||
|
else if (g_IsReactOS || GetNTVersion() >= _WIN32_WINNT_VISTA)
|
||||||
|
#else
|
||||||
|
if (g_IsReactOS || GetNTVersion() >= _WIN32_WINNT_VISTA)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
/* On ReactOS and on Vista+ the size is stored in
|
/* On ReactOS and on Vista+ the size is stored in
|
||||||
* the NextEntry field of a MMPTE_LIST structure */
|
* the NextEntry field of a MMPTE_LIST structure */
|
||||||
#ifdef _M_IX86
|
|
||||||
ExpectedValue = (TotalPtes + 2) << 12;
|
|
||||||
#elif defined(_M_AMD64)
|
|
||||||
ExpectedValue = ((ULONG64)TotalPtes + 2) << 32;
|
ExpectedValue = ((ULONG64)TotalPtes + 2) << 32;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -130,7 +155,7 @@ ValidateMapping(
|
||||||
}
|
}
|
||||||
Valid = Valid &&
|
Valid = Valid &&
|
||||||
ok(PteValue == ExpectedValue,
|
ok(PteValue == ExpectedValue,
|
||||||
"PTE for %p contains 0x%I64x, expected %x\n",
|
"PTE for %p contains 0x%I64x, expected 0x%I64x\n",
|
||||||
CurrentAddress, PteValue, ExpectedValue);
|
CurrentAddress, PteValue, ExpectedValue);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -187,6 +212,7 @@ TestMap(
|
||||||
|
|
||||||
KmtStartSeh()
|
KmtStartSeh()
|
||||||
*(volatile ULONG *)BaseAddress = 0x01234567;
|
*(volatile ULONG *)BaseAddress = 0x01234567;
|
||||||
|
ok_eq_ulong(*(volatile ULONG *)BaseAddress, 0x01234567);
|
||||||
KmtEndSeh(STATUS_SUCCESS);
|
KmtEndSeh(STATUS_SUCCESS);
|
||||||
|
|
||||||
MmUnmapReservedMapping(BaseAddress,
|
MmUnmapReservedMapping(BaseAddress,
|
||||||
|
@ -205,6 +231,9 @@ TestMap(
|
||||||
ok(BaseAddress != NULL, "MmMapLockedPagesWithReservedMapping failed\n");
|
ok(BaseAddress != NULL, "MmMapLockedPagesWithReservedMapping failed\n");
|
||||||
if (!skip(BaseAddress != NULL, "Failed to map MDL\n"))
|
if (!skip(BaseAddress != NULL, "Failed to map MDL\n"))
|
||||||
{
|
{
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
ok_eq_pointer(BaseAddress, (PVOID)ALIGN_DOWN_BY((PUCHAR)Mapping + sizeof(ULONG), 16));
|
||||||
|
else
|
||||||
ok_eq_pointer(BaseAddress, (PUCHAR)Mapping + sizeof(ULONG));
|
ok_eq_pointer(BaseAddress, (PUCHAR)Mapping + sizeof(ULONG));
|
||||||
|
|
||||||
ok_bool_true(ValidateMapping(BaseAddress, TotalPtes, PoolTag, 1, MdlPages),
|
ok_bool_true(ValidateMapping(BaseAddress, TotalPtes, PoolTag, 1, MdlPages),
|
||||||
|
@ -212,6 +241,7 @@ TestMap(
|
||||||
|
|
||||||
KmtStartSeh()
|
KmtStartSeh()
|
||||||
*(volatile ULONG *)BaseAddress = 0x01234567;
|
*(volatile ULONG *)BaseAddress = 0x01234567;
|
||||||
|
ok_eq_ulong(*(volatile ULONG *)BaseAddress, 0x01234567);
|
||||||
KmtEndSeh(STATUS_SUCCESS);
|
KmtEndSeh(STATUS_SUCCESS);
|
||||||
|
|
||||||
MmUnmapReservedMapping(BaseAddress,
|
MmUnmapReservedMapping(BaseAddress,
|
||||||
|
@ -223,6 +253,7 @@ TestMap(
|
||||||
}
|
}
|
||||||
|
|
||||||
MmFreePagesFromMdl(Mdl);
|
MmFreePagesFromMdl(Mdl);
|
||||||
|
ExFreePool(Mdl);
|
||||||
|
|
||||||
/* Map all pages */
|
/* Map all pages */
|
||||||
Mdl = pMmAllocatePagesForMdlEx(ZeroPhysical,
|
Mdl = pMmAllocatePagesForMdlEx(ZeroPhysical,
|
||||||
|
@ -253,7 +284,8 @@ TestMap(
|
||||||
for (i = 0; i < TotalPtes; i++)
|
for (i = 0; i < TotalPtes; i++)
|
||||||
{
|
{
|
||||||
KmtStartSeh()
|
KmtStartSeh()
|
||||||
*((volatile ULONG *)BaseAddress + i * PAGE_SIZE / sizeof(ULONG)) = 0x01234567;
|
*((volatile ULONG *)((PUCHAR)BaseAddress + i * PAGE_SIZE)) = 0x01234567 + i;
|
||||||
|
ok_eq_ulong(*((volatile ULONG *)((PUCHAR)BaseAddress + i * PAGE_SIZE)), 0x01234567 + i);
|
||||||
KmtEndSeh(STATUS_SUCCESS);
|
KmtEndSeh(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,6 +298,7 @@ TestMap(
|
||||||
}
|
}
|
||||||
|
|
||||||
MmFreePagesFromMdl(Mdl);
|
MmFreePagesFromMdl(Mdl);
|
||||||
|
ExFreePool(Mdl);
|
||||||
|
|
||||||
/* Try to map more pages than we reserved */
|
/* Try to map more pages than we reserved */
|
||||||
Mdl = pMmAllocatePagesForMdlEx(ZeroPhysical,
|
Mdl = pMmAllocatePagesForMdlEx(ZeroPhysical,
|
||||||
|
@ -292,6 +325,7 @@ TestMap(
|
||||||
}
|
}
|
||||||
|
|
||||||
MmFreePagesFromMdl(Mdl);
|
MmFreePagesFromMdl(Mdl);
|
||||||
|
ExFreePool(Mdl);
|
||||||
}
|
}
|
||||||
|
|
||||||
START_TEST(MmReservedMapping)
|
START_TEST(MmReservedMapping)
|
||||||
|
@ -299,9 +333,9 @@ START_TEST(MmReservedMapping)
|
||||||
PVOID Mapping;
|
PVOID Mapping;
|
||||||
|
|
||||||
g_IsPae = ExIsProcessorFeaturePresent(PF_PAE_ENABLED);
|
g_IsPae = ExIsProcessorFeaturePresent(PF_PAE_ENABLED);
|
||||||
g_OsVersion = SharedUserData->NtMajorVersion << 8 | SharedUserData->NtMinorVersion;
|
|
||||||
g_IsReactOS = *(PULONG)(KI_USER_SHARED_DATA + PAGE_SIZE - sizeof(ULONG)) == 0x8eac705;
|
g_IsReactOS = *(PULONG)(KI_USER_SHARED_DATA + PAGE_SIZE - sizeof(ULONG)) == 0x8eac705;
|
||||||
ok(g_IsReactOS == 1, "Not reactos\n");
|
if (!g_IsReactOS)
|
||||||
|
trace("Not ReactOS\n");
|
||||||
|
|
||||||
pMmAllocatePagesForMdlEx = KmtGetSystemRoutineAddress(L"MmAllocatePagesForMdlEx");
|
pMmAllocatePagesForMdlEx = KmtGetSystemRoutineAddress(L"MmAllocatePagesForMdlEx");
|
||||||
|
|
||||||
|
@ -317,7 +351,7 @@ START_TEST(MmReservedMapping)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 10 pages */
|
/* 10 pages */
|
||||||
Mapping = MmAllocateMappingAddress(10 * PAGE_SIZE, 'MRmK' & ~1);
|
Mapping = MmAllocateMappingAddress(10 * PAGE_SIZE, 'MRmK');
|
||||||
ok(Mapping != NULL, "MmAllocateMappingAddress failed\n");
|
ok(Mapping != NULL, "MmAllocateMappingAddress failed\n");
|
||||||
if (!skip(Mapping != NULL, "No mapping\n"))
|
if (!skip(Mapping != NULL, "No mapping\n"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -96,15 +96,31 @@ TestCreateSection(
|
||||||
IN HANDLE FileHandle2,
|
IN HANDLE FileHandle2,
|
||||||
IN PFILE_OBJECT FileObject2)
|
IN PFILE_OBJECT FileObject2)
|
||||||
{
|
{
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
NTSTATUS Status = STATUS_SUCCESS, ExceptionStatus = STATUS_SUCCESS;
|
||||||
PVOID SectionObject;
|
PVOID SectionObject;
|
||||||
LARGE_INTEGER MaximumSize;
|
LARGE_INTEGER MaximumSize;
|
||||||
ULONG PointerCount1, PointerCount2;
|
ULONG PointerCount1, PointerCount2;
|
||||||
|
|
||||||
KmtStartSeh()
|
_SEH2_TRY
|
||||||
|
{
|
||||||
Status = MmCreateSection(NULL, 0, NULL, NULL, 0, SEC_RESERVE, NULL, NULL);
|
Status = MmCreateSection(NULL, 0, NULL, NULL, 0, SEC_RESERVE, NULL, NULL);
|
||||||
KmtEndSeh(STATUS_SUCCESS);
|
}
|
||||||
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
|
ExceptionStatus = _SEH2_GetExceptionCode();
|
||||||
|
}
|
||||||
|
_SEH2_END;
|
||||||
|
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN10)
|
||||||
|
{
|
||||||
|
ok_eq_hex(ExceptionStatus, STATUS_SUCCESS);
|
||||||
ok_eq_hex(Status, STATUS_INVALID_PAGE_PROTECTION);
|
ok_eq_hex(Status, STATUS_INVALID_PAGE_PROTECTION);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ok_eq_hex(ExceptionStatus, STATUS_ACCESS_VIOLATION);
|
||||||
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
if (!KmtIsCheckedBuild)
|
if (!KmtIsCheckedBuild)
|
||||||
{
|
{
|
||||||
|
@ -119,10 +135,26 @@ TestCreateSection(
|
||||||
}
|
}
|
||||||
|
|
||||||
SectionObject = KmtInvalidPointer;
|
SectionObject = KmtInvalidPointer;
|
||||||
KmtStartSeh()
|
_SEH2_TRY
|
||||||
|
{
|
||||||
Status = MmCreateSection(&SectionObject, 0, NULL, NULL, 0, SEC_RESERVE, NULL, NULL);
|
Status = MmCreateSection(&SectionObject, 0, NULL, NULL, 0, SEC_RESERVE, NULL, NULL);
|
||||||
KmtEndSeh(STATUS_SUCCESS);
|
}
|
||||||
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
|
ExceptionStatus = _SEH2_GetExceptionCode();
|
||||||
|
}
|
||||||
|
_SEH2_END;
|
||||||
|
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN10)
|
||||||
|
{
|
||||||
|
ok_eq_hex(ExceptionStatus, STATUS_SUCCESS);
|
||||||
ok_eq_hex(Status, STATUS_INVALID_PAGE_PROTECTION);
|
ok_eq_hex(Status, STATUS_INVALID_PAGE_PROTECTION);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ok_eq_hex(ExceptionStatus, STATUS_ACCESS_VIOLATION);
|
||||||
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
|
}
|
||||||
ok_eq_pointer(SectionObject, KmtInvalidPointer);
|
ok_eq_pointer(SectionObject, KmtInvalidPointer);
|
||||||
|
|
||||||
if (SectionObject && SectionObject != KmtInvalidPointer)
|
if (SectionObject && SectionObject != KmtInvalidPointer)
|
||||||
|
@ -210,9 +242,22 @@ TestCreateSection(
|
||||||
|
|
||||||
if (!skip(FileHandle1 != NULL && FileObject1 != NULL &&
|
if (!skip(FileHandle1 != NULL && FileObject1 != NULL &&
|
||||||
FileHandle2 != NULL && FileObject2 != NULL, "No file handle or object\n"))
|
FileHandle2 != NULL && FileObject2 != NULL, "No file handle or object\n"))
|
||||||
|
{
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
{
|
{
|
||||||
PointerCount1 = 3;
|
PointerCount1 = 3;
|
||||||
PointerCount2 = 3;
|
PointerCount2 = 3;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#ifdef _M_IX86
|
||||||
|
PointerCount1 = 31;
|
||||||
|
PointerCount2 = 33;
|
||||||
|
#else
|
||||||
|
PointerCount1 = 32767;
|
||||||
|
PointerCount2 = 32769;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
/* image section */
|
/* image section */
|
||||||
CheckObject(FileHandle2, PointerCount2, 1L);
|
CheckObject(FileHandle2, PointerCount2, 1L);
|
||||||
SectionObject = KmtInvalidPointer;
|
SectionObject = KmtInvalidPointer;
|
||||||
|
@ -224,45 +269,64 @@ TestCreateSection(
|
||||||
ok_eq_longlong(MaximumSize.QuadPart, 1LL);
|
ok_eq_longlong(MaximumSize.QuadPart, 1LL);
|
||||||
ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
|
ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
|
||||||
ok(SectionObject != NULL, "Section object pointer NULL\n");
|
ok(SectionObject != NULL, "Section object pointer NULL\n");
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
PointerCount2 -= 2;
|
||||||
CheckObject(FileHandle2, PointerCount2, 1L);
|
CheckObject(FileHandle2, PointerCount2, 1L);
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
CheckSection(SectionObject, SEC_IMAGE);
|
CheckSection(SectionObject, SEC_IMAGE);
|
||||||
TestMapView(SectionObject, FALSE, TRUE);
|
TestMapView(SectionObject, FALSE, TRUE);
|
||||||
|
|
||||||
if (SectionObject && SectionObject != KmtInvalidPointer)
|
if (SectionObject && SectionObject != KmtInvalidPointer)
|
||||||
ObDereferenceObject(SectionObject);
|
ObDereferenceObject(SectionObject);
|
||||||
|
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
PointerCount2--;
|
||||||
CheckObject(FileHandle2, PointerCount2, 1L);
|
CheckObject(FileHandle2, PointerCount2, 1L);
|
||||||
SectionObject = KmtInvalidPointer;
|
SectionObject = KmtInvalidPointer;
|
||||||
MaximumSize.QuadPart = 1;
|
MaximumSize.QuadPart = 1;
|
||||||
KmtStartSeh()
|
KmtStartSeh()
|
||||||
Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, NULL, FileObject2);
|
Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, NULL, FileObject2);
|
||||||
KmtEndSeh(STATUS_SUCCESS);
|
KmtEndSeh(STATUS_SUCCESS);
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
|
else
|
||||||
|
ok_eq_hex(Status, STATUS_INVALID_PARAMETER_6);
|
||||||
ok_eq_longlong(MaximumSize.QuadPart, 1LL);
|
ok_eq_longlong(MaximumSize.QuadPart, 1LL);
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
|
ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
|
||||||
ok(SectionObject != NULL, "Section object pointer NULL\n");
|
ok(SectionObject != NULL, "Section object pointer NULL\n");
|
||||||
//++PointerCount2;
|
if (GetNTVersion() == _WIN32_WINNT_WS03)
|
||||||
|
++PointerCount2;
|
||||||
|
else if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
--PointerCount2;
|
||||||
CheckObject(FileHandle2, PointerCount2, 1L);
|
CheckObject(FileHandle2, PointerCount2, 1L);
|
||||||
CheckSection(SectionObject, SEC_IMAGE);
|
CheckSection(SectionObject, 0);
|
||||||
TestMapView(SectionObject, FALSE, TRUE);
|
TestMapView(SectionObject, TRUE, TRUE);
|
||||||
|
|
||||||
if (SectionObject && SectionObject != KmtInvalidPointer)
|
if (SectionObject && SectionObject != KmtInvalidPointer)
|
||||||
ObDereferenceObject(SectionObject);
|
ObDereferenceObject(SectionObject);
|
||||||
//--PointerCount2; // ????
|
|
||||||
|
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
PointerCount2--;
|
||||||
CheckObject(FileHandle2, PointerCount2, 1L);
|
CheckObject(FileHandle2, PointerCount2, 1L);
|
||||||
SectionObject = KmtInvalidPointer;
|
SectionObject = KmtInvalidPointer;
|
||||||
MaximumSize.QuadPart = 1;
|
MaximumSize.QuadPart = 1;
|
||||||
KmtStartSeh()
|
KmtStartSeh()
|
||||||
Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, FileHandle2, FileObject2);
|
Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, FileHandle2, FileObject2);
|
||||||
KmtEndSeh(STATUS_SUCCESS);
|
KmtEndSeh(STATUS_SUCCESS);
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
|
else
|
||||||
|
ok_eq_hex(Status, STATUS_INVALID_PARAMETER_6);
|
||||||
ok_eq_longlong(MaximumSize.QuadPart, 1LL);
|
ok_eq_longlong(MaximumSize.QuadPart, 1LL);
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
|
ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
|
||||||
ok(SectionObject != NULL, "Section object pointer NULL\n");
|
ok(SectionObject != NULL, "Section object pointer NULL\n");
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
PointerCount2--;
|
||||||
CheckObject(FileHandle2, PointerCount2, 1L);
|
CheckObject(FileHandle2, PointerCount2, 1L);
|
||||||
CheckSection(SectionObject, SEC_IMAGE);
|
CheckSection(SectionObject, 0);
|
||||||
TestMapView(SectionObject, FALSE, TRUE);
|
TestMapView(SectionObject, TRUE, TRUE);
|
||||||
|
|
||||||
if (SectionObject && SectionObject != KmtInvalidPointer)
|
if (SectionObject && SectionObject != KmtInvalidPointer)
|
||||||
ObDereferenceObject(SectionObject);
|
ObDereferenceObject(SectionObject);
|
||||||
|
@ -277,40 +341,58 @@ TestCreateSection(
|
||||||
ok_eq_hex(Status, STATUS_INVALID_IMAGE_NOT_MZ);
|
ok_eq_hex(Status, STATUS_INVALID_IMAGE_NOT_MZ);
|
||||||
ok_eq_longlong(MaximumSize.QuadPart, 1LL);
|
ok_eq_longlong(MaximumSize.QuadPart, 1LL);
|
||||||
ok_eq_pointer(SectionObject, KmtInvalidPointer);
|
ok_eq_pointer(SectionObject, KmtInvalidPointer);
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
PointerCount1 -= 2;
|
||||||
CheckObject(FileHandle1, PointerCount1, 1L);
|
CheckObject(FileHandle1, PointerCount1, 1L);
|
||||||
|
|
||||||
if (SectionObject && SectionObject != KmtInvalidPointer)
|
if (SectionObject && SectionObject != KmtInvalidPointer)
|
||||||
ObDereferenceObject(SectionObject);
|
ObDereferenceObject(SectionObject);
|
||||||
|
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
PointerCount1--;
|
||||||
CheckObject(FileHandle1, PointerCount1, 1L);
|
CheckObject(FileHandle1, PointerCount1, 1L);
|
||||||
SectionObject = KmtInvalidPointer;
|
SectionObject = KmtInvalidPointer;
|
||||||
MaximumSize.QuadPart = 1;
|
MaximumSize.QuadPart = 1;
|
||||||
KmtStartSeh()
|
KmtStartSeh()
|
||||||
Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, NULL, FileObject1);
|
Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, NULL, FileObject1);
|
||||||
KmtEndSeh(STATUS_SUCCESS);
|
KmtEndSeh(STATUS_SUCCESS);
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
|
else
|
||||||
|
ok_eq_hex(Status, STATUS_INVALID_PARAMETER_6);
|
||||||
ok_eq_longlong(MaximumSize.QuadPart, 1LL);
|
ok_eq_longlong(MaximumSize.QuadPart, 1LL);
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
|
ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
|
||||||
ok(SectionObject != NULL, "Section object pointer NULL\n");
|
ok(SectionObject != NULL, "Section object pointer NULL\n");
|
||||||
|
if (GetNTVersion() == _WIN32_WINNT_WS03)
|
||||||
++PointerCount1;
|
++PointerCount1;
|
||||||
|
else if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
--PointerCount1;
|
||||||
CheckObject(FileHandle1, PointerCount1, 1L);
|
CheckObject(FileHandle1, PointerCount1, 1L);
|
||||||
CheckSection(SectionObject, 0);
|
CheckSection(SectionObject, 0);
|
||||||
TestMapView(SectionObject, TRUE, FALSE);
|
TestMapView(SectionObject, TRUE, FALSE);
|
||||||
|
|
||||||
if (SectionObject && SectionObject != KmtInvalidPointer)
|
if (SectionObject && SectionObject != KmtInvalidPointer)
|
||||||
ObDereferenceObject(SectionObject);
|
ObDereferenceObject(SectionObject);
|
||||||
//--PointerCount1; // ????
|
|
||||||
|
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
--PointerCount1;
|
||||||
CheckObject(FileHandle1, PointerCount1, 1L);
|
CheckObject(FileHandle1, PointerCount1, 1L);
|
||||||
SectionObject = KmtInvalidPointer;
|
SectionObject = KmtInvalidPointer;
|
||||||
MaximumSize.QuadPart = 1;
|
MaximumSize.QuadPart = 1;
|
||||||
KmtStartSeh()
|
KmtStartSeh()
|
||||||
Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, FileHandle1, FileObject1);
|
Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, FileHandle1, FileObject1);
|
||||||
KmtEndSeh(STATUS_SUCCESS);
|
KmtEndSeh(STATUS_SUCCESS);
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
|
else
|
||||||
|
ok_eq_hex(Status, STATUS_INVALID_PARAMETER_6);
|
||||||
ok_eq_longlong(MaximumSize.QuadPart, 1LL);
|
ok_eq_longlong(MaximumSize.QuadPart, 1LL);
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
|
ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
|
||||||
ok(SectionObject != NULL, "Section object pointer NULL\n");
|
ok(SectionObject != NULL, "Section object pointer NULL\n");
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
--PointerCount1;
|
||||||
CheckObject(FileHandle1, PointerCount1, 1L);
|
CheckObject(FileHandle1, PointerCount1, 1L);
|
||||||
CheckSection(SectionObject, 0);
|
CheckSection(SectionObject, 0);
|
||||||
TestMapView(SectionObject, TRUE, FALSE);
|
TestMapView(SectionObject, TRUE, FALSE);
|
||||||
|
@ -319,34 +401,56 @@ TestCreateSection(
|
||||||
ObDereferenceObject(SectionObject);
|
ObDereferenceObject(SectionObject);
|
||||||
|
|
||||||
/* image section with two different files */
|
/* image section with two different files */
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
--PointerCount1;
|
||||||
CheckObject(FileHandle1, PointerCount1, 1L);
|
CheckObject(FileHandle1, PointerCount1, 1L);
|
||||||
SectionObject = KmtInvalidPointer;
|
SectionObject = KmtInvalidPointer;
|
||||||
MaximumSize.QuadPart = 1;
|
MaximumSize.QuadPart = 1;
|
||||||
KmtStartSeh()
|
KmtStartSeh()
|
||||||
Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, FileHandle1, FileObject2);
|
Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, FileHandle1, FileObject2);
|
||||||
KmtEndSeh(STATUS_SUCCESS);
|
KmtEndSeh(STATUS_SUCCESS);
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
|
else
|
||||||
|
ok_eq_hex(Status, STATUS_INVALID_PARAMETER_6);
|
||||||
ok_eq_longlong(MaximumSize.QuadPart, 1LL);
|
ok_eq_longlong(MaximumSize.QuadPart, 1LL);
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
|
ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
|
||||||
ok(SectionObject != NULL, "Section object pointer NULL\n");
|
ok(SectionObject != NULL, "Section object pointer NULL\n");
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
{
|
||||||
|
--PointerCount1;
|
||||||
|
--PointerCount2;
|
||||||
|
}
|
||||||
CheckObject(FileHandle1, PointerCount1, 1L);
|
CheckObject(FileHandle1, PointerCount1, 1L);
|
||||||
CheckObject(FileHandle2, PointerCount2, 1L);
|
CheckObject(FileHandle2, PointerCount2, 1L);
|
||||||
CheckSection(SectionObject, SEC_IMAGE);
|
CheckSection(SectionObject, 0);
|
||||||
TestMapView(SectionObject, FALSE, TRUE);
|
TestMapView(SectionObject, TRUE, TRUE);
|
||||||
|
|
||||||
if (SectionObject && SectionObject != KmtInvalidPointer)
|
if (SectionObject && SectionObject != KmtInvalidPointer)
|
||||||
ObDereferenceObject(SectionObject);
|
ObDereferenceObject(SectionObject);
|
||||||
|
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
--PointerCount1;
|
||||||
CheckObject(FileHandle1, PointerCount1, 1L);
|
CheckObject(FileHandle1, PointerCount1, 1L);
|
||||||
SectionObject = KmtInvalidPointer;
|
SectionObject = KmtInvalidPointer;
|
||||||
MaximumSize.QuadPart = 1;
|
MaximumSize.QuadPart = 1;
|
||||||
KmtStartSeh()
|
KmtStartSeh()
|
||||||
Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, FileHandle2, FileObject1);
|
Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_IMAGE, FileHandle2, FileObject1);
|
||||||
KmtEndSeh(STATUS_SUCCESS);
|
KmtEndSeh(STATUS_SUCCESS);
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
|
else
|
||||||
|
ok_eq_hex(Status, STATUS_INVALID_PARAMETER_6);
|
||||||
ok_eq_longlong(MaximumSize.QuadPart, 1LL);
|
ok_eq_longlong(MaximumSize.QuadPart, 1LL);
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
|
ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
|
||||||
ok(SectionObject != NULL, "Section object pointer NULL\n");
|
ok(SectionObject != NULL, "Section object pointer NULL\n");
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
{
|
||||||
|
--PointerCount1;
|
||||||
|
--PointerCount2;
|
||||||
|
}
|
||||||
CheckObject(FileHandle1, PointerCount1, 1L);
|
CheckObject(FileHandle1, PointerCount1, 1L);
|
||||||
CheckObject(FileHandle2, PointerCount2, 1L);
|
CheckObject(FileHandle2, PointerCount2, 1L);
|
||||||
CheckSection(SectionObject, 0);
|
CheckSection(SectionObject, 0);
|
||||||
|
@ -356,6 +460,8 @@ TestCreateSection(
|
||||||
ObDereferenceObject(SectionObject);
|
ObDereferenceObject(SectionObject);
|
||||||
|
|
||||||
/* data file section */
|
/* data file section */
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
--PointerCount1;
|
||||||
CheckObject(FileHandle1, PointerCount1, 1L);
|
CheckObject(FileHandle1, PointerCount1, 1L);
|
||||||
SectionObject = KmtInvalidPointer;
|
SectionObject = KmtInvalidPointer;
|
||||||
MaximumSize.QuadPart = 1;
|
MaximumSize.QuadPart = 1;
|
||||||
|
@ -366,30 +472,39 @@ TestCreateSection(
|
||||||
ok_eq_longlong(MaximumSize.QuadPart, 1LL);
|
ok_eq_longlong(MaximumSize.QuadPart, 1LL);
|
||||||
ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
|
ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
|
||||||
ok(SectionObject != NULL, "Section object pointer NULL\n");
|
ok(SectionObject != NULL, "Section object pointer NULL\n");
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
PointerCount1 -= 2;
|
||||||
CheckObject(FileHandle1, PointerCount1, 1L);
|
CheckObject(FileHandle1, PointerCount1, 1L);
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
CheckSection(SectionObject, 0);
|
CheckSection(SectionObject, 0);
|
||||||
TestMapView(SectionObject, TRUE, FALSE);
|
TestMapView(SectionObject, TRUE, FALSE);
|
||||||
|
|
||||||
if (SectionObject && SectionObject != KmtInvalidPointer)
|
if (SectionObject && SectionObject != KmtInvalidPointer)
|
||||||
ObDereferenceObject(SectionObject);
|
ObDereferenceObject(SectionObject);
|
||||||
|
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
--PointerCount1;
|
||||||
CheckObject(FileHandle1, PointerCount1, 1L);
|
CheckObject(FileHandle1, PointerCount1, 1L);
|
||||||
SectionObject = KmtInvalidPointer;
|
SectionObject = KmtInvalidPointer;
|
||||||
MaximumSize.QuadPart = 1;
|
MaximumSize.QuadPart = 1;
|
||||||
KmtStartSeh()
|
KmtStartSeh()
|
||||||
Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_RESERVE, NULL, FileObject1);
|
Status = MmCreateSection(&SectionObject, 0, NULL, &MaximumSize, PAGE_READONLY, SEC_RESERVE, NULL, FileObject1);
|
||||||
KmtEndSeh(STATUS_SUCCESS);
|
KmtEndSeh(STATUS_SUCCESS);
|
||||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
|
||||||
ok_eq_longlong(MaximumSize.QuadPart, 1LL);
|
ok_eq_longlong(MaximumSize.QuadPart, 1LL);
|
||||||
ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
|
ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
|
||||||
ok(SectionObject != NULL, "Section object pointer NULL\n");
|
ok(SectionObject != NULL, "Section object pointer NULL\n");
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
--PointerCount1;
|
||||||
CheckObject(FileHandle1, PointerCount1, 1L);
|
CheckObject(FileHandle1, PointerCount1, 1L);
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
CheckSection(SectionObject, 0);
|
CheckSection(SectionObject, 0);
|
||||||
TestMapView(SectionObject, TRUE, FALSE);
|
TestMapView(SectionObject, TRUE, FALSE);
|
||||||
|
|
||||||
if (SectionObject && SectionObject != KmtInvalidPointer)
|
if (SectionObject && SectionObject != KmtInvalidPointer)
|
||||||
ObDereferenceObject(SectionObject);
|
ObDereferenceObject(SectionObject);
|
||||||
|
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
--PointerCount1;
|
||||||
CheckObject(FileHandle1, PointerCount1, 1L);
|
CheckObject(FileHandle1, PointerCount1, 1L);
|
||||||
SectionObject = KmtInvalidPointer;
|
SectionObject = KmtInvalidPointer;
|
||||||
MaximumSize.QuadPart = 1;
|
MaximumSize.QuadPart = 1;
|
||||||
|
@ -400,13 +515,18 @@ TestCreateSection(
|
||||||
ok_eq_longlong(MaximumSize.QuadPart, 1LL);
|
ok_eq_longlong(MaximumSize.QuadPart, 1LL);
|
||||||
ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
|
ok(SectionObject != KmtInvalidPointer, "Section object pointer untouched\n");
|
||||||
ok(SectionObject != NULL, "Section object pointer NULL\n");
|
ok(SectionObject != NULL, "Section object pointer NULL\n");
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
--PointerCount1;
|
||||||
CheckObject(FileHandle1, PointerCount1, 1L);
|
CheckObject(FileHandle1, PointerCount1, 1L);
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
CheckSection(SectionObject, 0);
|
CheckSection(SectionObject, 0);
|
||||||
TestMapView(SectionObject, TRUE, FALSE);
|
TestMapView(SectionObject, TRUE, FALSE);
|
||||||
|
|
||||||
if (SectionObject && SectionObject != KmtInvalidPointer)
|
if (SectionObject && SectionObject != KmtInvalidPointer)
|
||||||
ObDereferenceObject(SectionObject);
|
ObDereferenceObject(SectionObject);
|
||||||
|
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
--PointerCount1;
|
||||||
CheckObject(FileHandle1, PointerCount1, 1L);
|
CheckObject(FileHandle1, PointerCount1, 1L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -700,7 +820,10 @@ TestPhysicalMemorySection(VOID)
|
||||||
ViewUnmap,
|
ViewUnmap,
|
||||||
0,
|
0,
|
||||||
PAGE_READWRITE);
|
PAGE_READWRITE);
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN10)
|
||||||
ok_eq_hex(Status, STATUS_INVALID_PARAMETER_6);
|
ok_eq_hex(Status, STATUS_INVALID_PARAMETER_6);
|
||||||
|
else
|
||||||
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
KmtStartSeh()
|
KmtStartSeh()
|
||||||
|
@ -746,7 +869,10 @@ TestPhysicalMemorySection(VOID)
|
||||||
ViewUnmap,
|
ViewUnmap,
|
||||||
0,
|
0,
|
||||||
PAGE_READWRITE);
|
PAGE_READWRITE);
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN10)
|
||||||
ok_eq_hex(Status, STATUS_INVALID_PARAMETER_6);
|
ok_eq_hex(Status, STATUS_INVALID_PARAMETER_6);
|
||||||
|
else
|
||||||
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
KmtStartSeh()
|
KmtStartSeh()
|
||||||
|
@ -788,7 +914,7 @@ TestPhysicalMemorySection(VOID)
|
||||||
ZwClose(SectionHandle);
|
ZwClose(SectionHandle);
|
||||||
|
|
||||||
/* Assertion failure: AllocationAttributes & SEC_IMAGE | SEC_RESERVE | SEC_COMMIT */
|
/* Assertion failure: AllocationAttributes & SEC_IMAGE | SEC_RESERVE | SEC_COMMIT */
|
||||||
if (!KmtIsCheckedBuild)
|
if (!KmtIsCheckedBuild && !(GetNTVersion() >= _WIN32_WINNT_WIN10))
|
||||||
{
|
{
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -808,6 +934,8 @@ TestPhysicalMemorySection(VOID)
|
||||||
ObDereferenceObject(SectionObject);
|
ObDereferenceObject(SectionObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN10)
|
||||||
|
{
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
NULL,
|
NULL,
|
||||||
OBJ_KERNEL_HANDLE,
|
OBJ_KERNEL_HANDLE,
|
||||||
|
@ -824,6 +952,7 @@ TestPhysicalMemorySection(VOID)
|
||||||
ok_eq_hex(Status, STATUS_INVALID_PARAMETER_6);
|
ok_eq_hex(Status, STATUS_INVALID_PARAMETER_6);
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
ObDereferenceObject(SectionObject);
|
ObDereferenceObject(SectionObject);
|
||||||
|
}
|
||||||
|
|
||||||
ExFreePoolWithTag(ZeroPageContents, 'ZPmK');
|
ExFreePoolWithTag(ZeroPageContents, 'ZPmK');
|
||||||
ExFreePoolWithTag(MyPage, 'MPmK');
|
ExFreePoolWithTag(MyPage, 'MPmK');
|
||||||
|
@ -866,7 +995,15 @@ START_TEST(MmSection)
|
||||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
ok_eq_ulongptr(IoStatusBlock.Information, FILE_OPENED);
|
ok_eq_ulongptr(IoStatusBlock.Information, FILE_OPENED);
|
||||||
ok(FileHandle1 != NULL, "FileHandle1 is NULL\n");
|
ok(FileHandle1 != NULL, "FileHandle1 is NULL\n");
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
CheckObject(FileHandle1, 2L, 1L);
|
CheckObject(FileHandle1, 2L, 1L);
|
||||||
|
#ifdef _M_IX86
|
||||||
|
else
|
||||||
|
CheckObject(FileHandle1, 33L, 1L);
|
||||||
|
#else
|
||||||
|
else
|
||||||
|
CheckObject(FileHandle1, 32769L, 1L);
|
||||||
|
#endif
|
||||||
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes, &FileName2, OBJ_CASE_INSENSITIVE, NULL, NULL);
|
InitializeObjectAttributes(&ObjectAttributes, &FileName2, OBJ_CASE_INSENSITIVE, NULL, NULL);
|
||||||
Status = ZwCreateFile(&FileHandle2, GENERIC_READ, &ObjectAttributes, &IoStatusBlock, NULL, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ, FILE_OPEN, FILE_NON_DIRECTORY_FILE, NULL, 0);
|
Status = ZwCreateFile(&FileHandle2, GENERIC_READ, &ObjectAttributes, &IoStatusBlock, NULL, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ, FILE_OPEN, FILE_NON_DIRECTORY_FILE, NULL, 0);
|
||||||
|
@ -879,7 +1016,15 @@ START_TEST(MmSection)
|
||||||
Status = ObReferenceObjectByHandle(FileHandle1, FILE_READ_DATA | FILE_WRITE_DATA, *IoFileObjectType, KernelMode, (PVOID *)&FileObject1, NULL);
|
Status = ObReferenceObjectByHandle(FileHandle1, FILE_READ_DATA | FILE_WRITE_DATA, *IoFileObjectType, KernelMode, (PVOID *)&FileObject1, NULL);
|
||||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
ok(FileObject1 != NULL, "FileObject1 is NULL\n");
|
ok(FileObject1 != NULL, "FileObject1 is NULL\n");
|
||||||
|
if (GetNTVersion() < _WIN32_WINNT_WIN8)
|
||||||
CheckObject(FileHandle1, 3L, 1L);
|
CheckObject(FileHandle1, 3L, 1L);
|
||||||
|
#ifdef _M_IX86
|
||||||
|
else
|
||||||
|
CheckObject(FileHandle1, 32L, 1L);
|
||||||
|
#else
|
||||||
|
else
|
||||||
|
CheckObject(FileHandle1, 32768L, 1L);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!skip(Status == STATUS_SUCCESS && FileHandle2 != NULL, "Failed to open file 2\n"))
|
if (!skip(Status == STATUS_SUCCESS && FileHandle2 != NULL, "Failed to open file 2\n"))
|
||||||
|
|
|
@ -473,6 +473,13 @@ BasicBehaviorChecks(HANDLE FileHandle)
|
||||||
|
|
||||||
Length.QuadPart = TestStringSize;
|
Length.QuadPart = TestStringSize;
|
||||||
CREATE_SECTION(Section, (SECTION_ALL_ACCESS), NULL, Length, PAGE_READONLY, SEC_COMMIT, FileHandle, STATUS_SUCCESS, NO_HANDLE_CLOSE);
|
CREATE_SECTION(Section, (SECTION_ALL_ACCESS), NULL, Length, PAGE_READONLY, SEC_COMMIT, FileHandle, STATUS_SUCCESS, NO_HANDLE_CLOSE);
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
#ifdef _M_IX86
|
||||||
|
CheckObject(Section, 33, 1);
|
||||||
|
#else
|
||||||
|
CheckObject(Section, 32769, 1);
|
||||||
|
#endif
|
||||||
|
else
|
||||||
CheckObject(Section, 2, 1);
|
CheckObject(Section, 2, 1);
|
||||||
CheckSection(Section, SEC_FILE, Length.QuadPart, STATUS_SUCCESS);
|
CheckSection(Section, SEC_FILE, Length.QuadPart, STATUS_SUCCESS);
|
||||||
ZwClose(Section); //manually close it due to NO_HANDLE_CLOSE in CREATE_SECTION
|
ZwClose(Section); //manually close it due to NO_HANDLE_CLOSE in CREATE_SECTION
|
||||||
|
|
|
@ -10,6 +10,10 @@
|
||||||
#define IGNORE -99
|
#define IGNORE -99
|
||||||
#define NEW_CONTENT "NewContent"
|
#define NEW_CONTENT "NewContent"
|
||||||
#define NEW_CONTENT_LEN sizeof(NEW_CONTENT)
|
#define NEW_CONTENT_LEN sizeof(NEW_CONTENT)
|
||||||
|
#define IsInvalidParamStatus(Status) \
|
||||||
|
(Status == STATUS_INVALID_PARAMETER || Status == STATUS_INVALID_PARAMETER_MIX || \
|
||||||
|
(Status >= STATUS_INVALID_PARAMETER_1 && Status <= STATUS_INVALID_PARAMETER_12))
|
||||||
|
#define ok_invalid_parameter(Status) ok(IsInvalidParamStatus(Status), "Invalid status code (0x%X)\n", Status)
|
||||||
|
|
||||||
static UNICODE_STRING FileReadOnlyPath = RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\ntdll.dll");
|
static UNICODE_STRING FileReadOnlyPath = RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\ntdll.dll");
|
||||||
static UNICODE_STRING NtosImgPath = RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\ntoskrnl.exe");
|
static UNICODE_STRING NtosImgPath = RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\ntoskrnl.exe");
|
||||||
|
@ -24,6 +28,9 @@ static OBJECT_ATTRIBUTES NtoskrnlFileObject;
|
||||||
#define TestMapView(SectionHandle, ProcessHandle, BaseAddress2, ZeroBits, CommitSize, SectionOffset, ViewSize2, InheritDisposition, AllocationType, Win32Protect, MapStatus, UnmapStatus) do \
|
#define TestMapView(SectionHandle, ProcessHandle, BaseAddress2, ZeroBits, CommitSize, SectionOffset, ViewSize2, InheritDisposition, AllocationType, Win32Protect, MapStatus, UnmapStatus) do \
|
||||||
{ \
|
{ \
|
||||||
Status = ZwMapViewOfSection(SectionHandle, ProcessHandle, BaseAddress2, ZeroBits, CommitSize, SectionOffset, ViewSize2, InheritDisposition, AllocationType, Win32Protect); \
|
Status = ZwMapViewOfSection(SectionHandle, ProcessHandle, BaseAddress2, ZeroBits, CommitSize, SectionOffset, ViewSize2, InheritDisposition, AllocationType, Win32Protect); \
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN10 && IsInvalidParamStatus(MapStatus)) \
|
||||||
|
ok_invalid_parameter(MapStatus); \
|
||||||
|
else \
|
||||||
ok_eq_hex(Status, MapStatus); \
|
ok_eq_hex(Status, MapStatus); \
|
||||||
if (NT_SUCCESS(Status)) \
|
if (NT_SUCCESS(Status)) \
|
||||||
{ \
|
{ \
|
||||||
|
@ -161,9 +168,15 @@ SimpleErrorChecks(HANDLE FileHandleReadOnly, HANDLE FileHandleWriteOnly, HANDLE
|
||||||
}
|
}
|
||||||
|
|
||||||
//zero bits
|
//zero bits
|
||||||
|
#ifdef _M_IX86
|
||||||
TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 1, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_SUCCESS, STATUS_SUCCESS);
|
TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 1, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_SUCCESS, STATUS_SUCCESS);
|
||||||
TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 5, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_SUCCESS, STATUS_SUCCESS);
|
TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 5, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_SUCCESS, STATUS_SUCCESS);
|
||||||
TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, -1, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_INVALID_PARAMETER_4, IGNORE);
|
TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, -1, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_INVALID_PARAMETER_4, IGNORE);
|
||||||
|
#else
|
||||||
|
TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 1, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, GetNTVersion() >= _WIN32_WINNT_WIN8 ? STATUS_INVALID_PARAMETER_4 : STATUS_SUCCESS, STATUS_SUCCESS);
|
||||||
|
TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 5, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, GetNTVersion() >= _WIN32_WINNT_WIN8 ? STATUS_INVALID_PARAMETER_4 : STATUS_SUCCESS, STATUS_SUCCESS);
|
||||||
|
TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, -1, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_SUCCESS, IGNORE);
|
||||||
|
#endif
|
||||||
TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 20, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_NO_MEMORY, IGNORE);
|
TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 20, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_NO_MEMORY, IGNORE);
|
||||||
TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 21, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_NO_MEMORY, IGNORE);
|
TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 21, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_NO_MEMORY, IGNORE);
|
||||||
TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 22, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_INVALID_PARAMETER_4, IGNORE);
|
TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 22, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_INVALID_PARAMETER_4, IGNORE);
|
||||||
|
@ -207,7 +220,7 @@ SimpleErrorChecks(HANDLE FileHandleReadOnly, HANDLE FileHandleWriteOnly, HANDLE
|
||||||
TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, MEM_RESERVE, PAGE_READWRITE, STATUS_SUCCESS, STATUS_SUCCESS);
|
TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, MEM_RESERVE, PAGE_READWRITE, STATUS_SUCCESS, STATUS_SUCCESS);
|
||||||
TestMapView(PageFileSectionHandle, NtCurrentProcess(), &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, MEM_RESERVE, PAGE_READWRITE, STATUS_INVALID_PARAMETER_9, STATUS_SUCCESS);
|
TestMapView(PageFileSectionHandle, NtCurrentProcess(), &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, MEM_RESERVE, PAGE_READWRITE, STATUS_INVALID_PARAMETER_9, STATUS_SUCCESS);
|
||||||
TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, (MEM_RESERVE | MEM_COMMIT), PAGE_READWRITE, STATUS_INVALID_PARAMETER_9, IGNORE);
|
TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, (MEM_RESERVE | MEM_COMMIT), PAGE_READWRITE, STATUS_INVALID_PARAMETER_9, IGNORE);
|
||||||
TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, (MEM_LARGE_PAGES | MEM_RESERVE), PAGE_READWRITE, STATUS_SUCCESS, STATUS_SUCCESS);
|
TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, (MEM_LARGE_PAGES | MEM_RESERVE), PAGE_READWRITE, (NTSTATUS)(GetNTVersion() >= _WIN32_WINNT_WIN10 ? STATUS_INVALID_PARAMETER : STATUS_SUCCESS), STATUS_SUCCESS);
|
||||||
|
|
||||||
//win32protect
|
//win32protect
|
||||||
TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READONLY, STATUS_SUCCESS, STATUS_SUCCESS);
|
TestMapView(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READONLY, STATUS_SUCCESS, STATUS_SUCCESS);
|
||||||
|
@ -258,7 +271,29 @@ AdvancedErrorChecks(HANDLE FileHandleReadOnly, HANDLE FileHandleWriteOnly)
|
||||||
|
|
||||||
//test first conditional branch
|
//test first conditional branch
|
||||||
ViewSize = -1;
|
ViewSize = -1;
|
||||||
MmTestMapView(SectionObject, PsGetCurrentProcess(), &BaseAddress, 0, TestStringSize, &SectionOffset, &ViewSize, ViewUnmap, MEM_RESERVE, PAGE_READWRITE, STATUS_INVALID_VIEW_SIZE, IGNORE);
|
#ifdef _M_IX86
|
||||||
|
NTSTATUS MapStatus;
|
||||||
|
|
||||||
|
switch (GetNTVersion())
|
||||||
|
{
|
||||||
|
case _WIN32_WINNT_WIN8:
|
||||||
|
case _WIN32_WINNT_WINBLUE:
|
||||||
|
MapStatus = STATUS_INVALID_VIEW_SIZE;
|
||||||
|
break;
|
||||||
|
case _WIN32_WINNT_WIN10:
|
||||||
|
MapStatus = STATUS_CONFLICTING_ADDRESSES;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
MapStatus = STATUS_SUCCESS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
MmTestMapView(SectionObject, PsGetCurrentProcess(), &BaseAddress, 0, TestStringSize,
|
||||||
|
&SectionOffset, &ViewSize, ViewUnmap, MEM_RESERVE, PAGE_READWRITE, MapStatus, IGNORE);
|
||||||
|
#else
|
||||||
|
MmTestMapView(SectionObject, PsGetCurrentProcess(), &BaseAddress, 0, TestStringSize,
|
||||||
|
&SectionOffset, &ViewSize, ViewUnmap, MEM_RESERVE, PAGE_READWRITE, STATUS_INVALID_VIEW_SIZE, IGNORE);
|
||||||
|
#endif
|
||||||
|
|
||||||
//test second conditional branch
|
//test second conditional branch
|
||||||
ViewSize = 1;
|
ViewSize = 1;
|
||||||
|
@ -286,7 +321,7 @@ CompareFileContents(HANDLE FileHandle, ULONG BufferLength, PVOID Buffer)
|
||||||
if (!skip((FileContent != NULL), "Error allocating memory for FileContent\n"))
|
if (!skip((FileContent != NULL), "Error allocating memory for FileContent\n"))
|
||||||
{
|
{
|
||||||
Status = ZwReadFile(FileHandle, NULL, NULL, NULL, &IoStatusBlock, FileContent, BufferLength, &ByteOffset, NULL);
|
Status = ZwReadFile(FileHandle, NULL, NULL, NULL, &IoStatusBlock, FileContent, BufferLength, &ByteOffset, NULL);
|
||||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
ok(Status == STATUS_SUCCESS || Status == STATUS_PENDING, "Unexpected status (0x%X).\n", Status);
|
||||||
ok_eq_ulongptr(IoStatusBlock.Information, BufferLength);
|
ok_eq_ulongptr(IoStatusBlock.Information, BufferLength);
|
||||||
|
|
||||||
Match = 0;
|
Match = 0;
|
||||||
|
@ -310,9 +345,19 @@ SystemProcessWorker(PVOID StartContext)
|
||||||
SIZE_T Match;
|
SIZE_T Match;
|
||||||
LARGE_INTEGER SectionOffset;
|
LARGE_INTEGER SectionOffset;
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
ULONG PtrCnt;
|
||||||
|
|
||||||
UNREFERENCED_PARAMETER(StartContext);
|
UNREFERENCED_PARAMETER(StartContext);
|
||||||
|
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
#ifdef _M_IX86
|
||||||
|
PtrCnt = 64;
|
||||||
|
#else
|
||||||
|
PtrCnt = 65536;
|
||||||
|
#endif
|
||||||
|
else
|
||||||
|
PtrCnt = 4;
|
||||||
|
|
||||||
BaseAddress = NULL;
|
BaseAddress = NULL;
|
||||||
ViewSize = TestStringSize;
|
ViewSize = TestStringSize;
|
||||||
SectionOffset.QuadPart = 0;
|
SectionOffset.QuadPart = 0;
|
||||||
|
@ -321,11 +366,15 @@ SystemProcessWorker(PVOID StartContext)
|
||||||
Status = ZwOpenSection(&SectionHandle, SECTION_ALL_ACCESS, &ObjectAttributes);
|
Status = ZwOpenSection(&SectionHandle, SECTION_ALL_ACCESS, &ObjectAttributes);
|
||||||
if (!skip(NT_SUCCESS(Status), "Error acquiring handle to section. Error = %p\n", Status))
|
if (!skip(NT_SUCCESS(Status), "Error acquiring handle to section. Error = %p\n", Status))
|
||||||
{
|
{
|
||||||
CheckObject(SectionHandle, 4, 2);
|
CheckObject(SectionHandle, PtrCnt, 2);
|
||||||
Status = ZwMapViewOfSection(SectionHandle, NtCurrentProcess(), &BaseAddress, 0, TestStringSize, &SectionOffset, &ViewSize, ViewUnmap, 0, PAGE_READWRITE);
|
Status = ZwMapViewOfSection(SectionHandle, NtCurrentProcess(), &BaseAddress, 0, TestStringSize, &SectionOffset, &ViewSize, ViewUnmap, 0, PAGE_READWRITE);
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
PtrCnt -= 2;
|
||||||
|
|
||||||
//make sure ZwMapViewofSection doesn't touch the section ref counts.
|
//make sure ZwMapViewofSection doesn't touch the section ref counts.
|
||||||
CheckObject(SectionHandle, 4, 2);
|
CheckObject(SectionHandle, PtrCnt, 2);
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
PtrCnt--;
|
||||||
|
|
||||||
if (!skip(NT_SUCCESS(Status), "Error mapping page file view in system process. Error = %p\n", Status))
|
if (!skip(NT_SUCCESS(Status), "Error mapping page file view in system process. Error = %p\n", Status))
|
||||||
{
|
{
|
||||||
|
@ -336,7 +385,7 @@ SystemProcessWorker(PVOID StartContext)
|
||||||
ZwUnmapViewOfSection(NtCurrentProcess(), BaseAddress);
|
ZwUnmapViewOfSection(NtCurrentProcess(), BaseAddress);
|
||||||
|
|
||||||
//make sure ZwMapViewofSection doesn't touch the section ref counts.
|
//make sure ZwMapViewofSection doesn't touch the section ref counts.
|
||||||
CheckObject(SectionHandle, 4, 2);
|
CheckObject(SectionHandle, PtrCnt, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZwClose(SectionHandle);
|
ZwClose(SectionHandle);
|
||||||
|
@ -360,18 +409,30 @@ BehaviorChecks(HANDLE FileHandleReadOnly, HANDLE FileHandleWriteOnly)
|
||||||
LARGE_INTEGER MaximumSize;
|
LARGE_INTEGER MaximumSize;
|
||||||
SIZE_T Match;
|
SIZE_T Match;
|
||||||
SIZE_T ViewSize = 0;
|
SIZE_T ViewSize = 0;
|
||||||
|
ULONG PtrCnt;
|
||||||
|
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
#ifdef _M_IX86
|
||||||
|
PtrCnt = 34;
|
||||||
|
#else
|
||||||
|
PtrCnt = 32770;
|
||||||
|
#endif
|
||||||
|
else
|
||||||
|
PtrCnt = 3;
|
||||||
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes, &SharedSectionName, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL);
|
InitializeObjectAttributes(&ObjectAttributes, &SharedSectionName, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL);
|
||||||
MaximumSize.QuadPart = TestStringSize;
|
MaximumSize.QuadPart = TestStringSize;
|
||||||
SectionOffset.QuadPart = 0;
|
SectionOffset.QuadPart = 0;
|
||||||
|
|
||||||
Status = ZwCreateSection(&WriteSectionHandle, SECTION_ALL_ACCESS, &ObjectAttributes, &MaximumSize, PAGE_READWRITE, SEC_COMMIT, FileHandleWriteOnly);
|
Status = ZwCreateSection(&WriteSectionHandle, SECTION_ALL_ACCESS, &ObjectAttributes, &MaximumSize, PAGE_READWRITE, SEC_COMMIT, FileHandleWriteOnly);
|
||||||
CheckObject(WriteSectionHandle, 3, 1);
|
CheckObject(WriteSectionHandle, PtrCnt, 1);
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
PtrCnt -= 2;
|
||||||
ok(NT_SUCCESS(Status), "Error creating write section from file. Error = %p\n", Status);
|
ok(NT_SUCCESS(Status), "Error creating write section from file. Error = %p\n", Status);
|
||||||
|
|
||||||
//check for section reading/writing by comparing section content to a well-known value.
|
//check for section reading/writing by comparing section content to a well-known value.
|
||||||
Status = ZwMapViewOfSection(WriteSectionHandle, NtCurrentProcess() ,&BaseAddress, 0, 0, &SectionOffset, &ViewSize, ViewUnmap, 0, PAGE_READWRITE);
|
Status = ZwMapViewOfSection(WriteSectionHandle, NtCurrentProcess() ,&BaseAddress, 0, 0, &SectionOffset, &ViewSize, ViewUnmap, 0, PAGE_READWRITE);
|
||||||
CheckObject(WriteSectionHandle, 3, 1);
|
CheckObject(WriteSectionHandle, PtrCnt, 1);
|
||||||
if (!skip(NT_SUCCESS(Status), "Error mapping view with READ/WRITE priv. Error = %p\n", Status))
|
if (!skip(NT_SUCCESS(Status), "Error mapping view with READ/WRITE priv. Error = %p\n", Status))
|
||||||
{
|
{
|
||||||
Match = RtlCompareMemory(BaseAddress, TestString, TestStringSize);
|
Match = RtlCompareMemory(BaseAddress, TestString, TestStringSize);
|
||||||
|
@ -505,6 +566,16 @@ PageFileBehaviorChecks()
|
||||||
SIZE_T Match;
|
SIZE_T Match;
|
||||||
PVOID ThreadObject;
|
PVOID ThreadObject;
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
ULONG PtrCnt;
|
||||||
|
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
#ifdef _M_IX86
|
||||||
|
PtrCnt = 34;
|
||||||
|
#else
|
||||||
|
PtrCnt = 32770;
|
||||||
|
#endif
|
||||||
|
else
|
||||||
|
PtrCnt = 3;
|
||||||
|
|
||||||
MaxSectionSize.QuadPart = TestStringSize;
|
MaxSectionSize.QuadPart = TestStringSize;
|
||||||
SectionOffset.QuadPart = 0;
|
SectionOffset.QuadPart = 0;
|
||||||
|
@ -517,13 +588,15 @@ PageFileBehaviorChecks()
|
||||||
Status = ZwCreateSection(&PageFileSectionHandle, SECTION_ALL_ACCESS, &ObjectAttributes, &MaxSectionSize, PAGE_READWRITE, SEC_COMMIT, NULL);
|
Status = ZwCreateSection(&PageFileSectionHandle, SECTION_ALL_ACCESS, &ObjectAttributes, &MaxSectionSize, PAGE_READWRITE, SEC_COMMIT, NULL);
|
||||||
if (!skip(NT_SUCCESS(Status), "Error creating page file section. Error = %p\n", Status))
|
if (!skip(NT_SUCCESS(Status), "Error creating page file section. Error = %p\n", Status))
|
||||||
{
|
{
|
||||||
CheckObject(PageFileSectionHandle, 3, 1);
|
CheckObject(PageFileSectionHandle, PtrCnt, 1);
|
||||||
Status = ZwMapViewOfSection(PageFileSectionHandle, NtCurrentProcess(), &BaseAddress, 0, TestStringSize, &SectionOffset, &ViewSize, ViewUnmap, 0, PAGE_READWRITE);
|
Status = ZwMapViewOfSection(PageFileSectionHandle, NtCurrentProcess(), &BaseAddress, 0, TestStringSize, &SectionOffset, &ViewSize, ViewUnmap, 0, PAGE_READWRITE);
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
PtrCnt -= 2;
|
||||||
if (!skip(NT_SUCCESS(Status), "Error mapping page file view. Error = %p\n", Status))
|
if (!skip(NT_SUCCESS(Status), "Error mapping page file view. Error = %p\n", Status))
|
||||||
{
|
{
|
||||||
HANDLE SysThreadHandle;
|
HANDLE SysThreadHandle;
|
||||||
|
|
||||||
CheckObject(PageFileSectionHandle, 3, 1);
|
CheckObject(PageFileSectionHandle, PtrCnt, 1);
|
||||||
|
|
||||||
//check also the SEC_COMMIT flag
|
//check also the SEC_COMMIT flag
|
||||||
Test_NtQueryVirtualMemory(BaseAddress, PAGE_SIZE, MEM_COMMIT, PAGE_READWRITE);
|
Test_NtQueryVirtualMemory(BaseAddress, PAGE_SIZE, MEM_COMMIT, PAGE_READWRITE);
|
||||||
|
|
|
@ -34,6 +34,7 @@ TestDuplicate(
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
HANDLE NewHandle;
|
HANDLE NewHandle;
|
||||||
|
ULONG i, PtrCnt1, PtrCnt2;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
ACCESS_MASK DesiredAccess;
|
ACCESS_MASK DesiredAccess;
|
||||||
|
@ -59,10 +60,33 @@ TestDuplicate(
|
||||||
{ DIRECTORY_QUERY, OBJ_INHERIT, DUPLICATE_SAME_ACCESS | DUPLICATE_SAME_ATTRIBUTES,
|
{ DIRECTORY_QUERY, OBJ_INHERIT, DUPLICATE_SAME_ACCESS | DUPLICATE_SAME_ATTRIBUTES,
|
||||||
DIRECTORY_ALL_ACCESS, 0 },
|
DIRECTORY_ALL_ACCESS, 0 },
|
||||||
};
|
};
|
||||||
ULONG i;
|
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
{
|
||||||
|
#ifdef _M_IX86
|
||||||
|
PtrCnt1 = 65UL;
|
||||||
|
PtrCnt2 = 31UL;
|
||||||
|
#else
|
||||||
|
PtrCnt1 = 65537UL;
|
||||||
|
PtrCnt2 = 32767UL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PtrCnt1 = 3UL;
|
||||||
|
PtrCnt2 = 2UL;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < RTL_NUMBER_OF(Tests); i++)
|
for (i = 0; i < RTL_NUMBER_OF(Tests); i++)
|
||||||
{
|
{
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN7 &&
|
||||||
|
Tests[i].RequestedAttributes == OBJ_KERNEL_HANDLE)
|
||||||
|
{
|
||||||
|
skip(FALSE, "Invalid on NT 6.1+\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
trace("Test %lu\n", i);
|
trace("Test %lu\n", i);
|
||||||
Status = ZwDuplicateObject(ZwCurrentProcess(),
|
Status = ZwDuplicateObject(ZwCurrentProcess(),
|
||||||
Handle,
|
Handle,
|
||||||
|
@ -75,12 +99,18 @@ TestDuplicate(
|
||||||
if (!skip(NT_SUCCESS(Status), "DuplicateHandle failed\n"))
|
if (!skip(NT_SUCCESS(Status), "DuplicateHandle failed\n"))
|
||||||
{
|
{
|
||||||
ok(IsUserHandle(NewHandle), "New handle = %p\n", NewHandle);
|
ok(IsUserHandle(NewHandle), "New handle = %p\n", NewHandle);
|
||||||
CheckObject(NewHandle, 3UL, 2UL, Tests[i].ExpectedAttributes, Tests[i].GrantedAccess);
|
CheckObject(NewHandle, PtrCnt1, 2UL, Tests[i].ExpectedAttributes, Tests[i].GrantedAccess);
|
||||||
CheckObject(Handle, 3UL, 2UL, 0UL, DIRECTORY_ALL_ACCESS);
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
PtrCnt1--;
|
||||||
|
CheckObject(Handle, PtrCnt1, 2UL, 0UL, DIRECTORY_ALL_ACCESS);
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
PtrCnt1--;
|
||||||
|
|
||||||
Status = ObCloseHandle(NewHandle, UserMode);
|
Status = ObCloseHandle(NewHandle, UserMode);
|
||||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
CheckObject(Handle, 2UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS);
|
CheckObject(Handle, PtrCnt2, 1UL, 0UL, DIRECTORY_ALL_ACCESS);
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
PtrCnt2 -= 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,19 +126,26 @@ TestDuplicate(
|
||||||
if (!skip(NT_SUCCESS(Status), "DuplicateHandle failed\n"))
|
if (!skip(NT_SUCCESS(Status), "DuplicateHandle failed\n"))
|
||||||
{
|
{
|
||||||
ok(IsKernelHandle(NewHandle), "New handle = %p\n", NewHandle);
|
ok(IsKernelHandle(NewHandle), "New handle = %p\n", NewHandle);
|
||||||
CheckObject(NewHandle, 3UL, 2UL, 0, DIRECTORY_ALL_ACCESS);
|
CheckObject(NewHandle, PtrCnt1, 2UL, 0, DIRECTORY_ALL_ACCESS);
|
||||||
CheckObject(Handle, 3UL, 2UL, 0UL, DIRECTORY_ALL_ACCESS);
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
PtrCnt1--;
|
||||||
|
CheckObject(Handle, PtrCnt1, 2UL, 0UL, DIRECTORY_ALL_ACCESS);
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
PtrCnt1--;
|
||||||
Status = ObCloseHandle(NewHandle, UserMode);
|
Status = ObCloseHandle(NewHandle, UserMode);
|
||||||
ok_eq_hex(Status, STATUS_INVALID_HANDLE);
|
ok_eq_hex(Status, STATUS_INVALID_HANDLE);
|
||||||
CheckObject(NewHandle, 3UL, 2UL, 0, DIRECTORY_ALL_ACCESS);
|
CheckObject(NewHandle, PtrCnt1, 2UL, 0, DIRECTORY_ALL_ACCESS);
|
||||||
CheckObject(Handle, 3UL, 2UL, 0UL, DIRECTORY_ALL_ACCESS);
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
PtrCnt1--;
|
||||||
|
CheckObject(Handle, PtrCnt1, 2UL, 0UL, DIRECTORY_ALL_ACCESS);
|
||||||
|
|
||||||
if (IsKernelHandle(NewHandle))
|
if (IsKernelHandle(NewHandle))
|
||||||
{
|
{
|
||||||
Status = ObCloseHandle(NewHandle, KernelMode);
|
Status = ObCloseHandle(NewHandle, KernelMode);
|
||||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
CheckObject(Handle, 2UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS);
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
PtrCnt2--;
|
||||||
|
CheckObject(Handle, PtrCnt2, 1UL, 0UL, DIRECTORY_ALL_ACCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,6 +182,13 @@ START_TEST(ObHandle)
|
||||||
if (!skip(NT_SUCCESS(Status), "No directory handle\n"))
|
if (!skip(NT_SUCCESS(Status), "No directory handle\n"))
|
||||||
{
|
{
|
||||||
ok(IsUserHandle(UserDirectoryHandle), "User handle = %p\n", UserDirectoryHandle);
|
ok(IsUserHandle(UserDirectoryHandle), "User handle = %p\n", UserDirectoryHandle);
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
#ifdef _M_IX86
|
||||||
|
CheckObject(UserDirectoryHandle, 33UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS);
|
||||||
|
#else
|
||||||
|
CheckObject(UserDirectoryHandle, 32769UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS);
|
||||||
|
#endif
|
||||||
|
else
|
||||||
CheckObject(UserDirectoryHandle, 2UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS);
|
CheckObject(UserDirectoryHandle, 2UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS);
|
||||||
|
|
||||||
TestDuplicate(UserDirectoryHandle);
|
TestDuplicate(UserDirectoryHandle);
|
||||||
|
@ -165,12 +209,26 @@ START_TEST(ObHandle)
|
||||||
if (!skip(NT_SUCCESS(Status), "No directory handle\n"))
|
if (!skip(NT_SUCCESS(Status), "No directory handle\n"))
|
||||||
{
|
{
|
||||||
ok(IsKernelHandle(KernelDirectoryHandle), "Kernel handle = %p\n", KernelDirectoryHandle);
|
ok(IsKernelHandle(KernelDirectoryHandle), "Kernel handle = %p\n", KernelDirectoryHandle);
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
#ifdef _M_IX86
|
||||||
|
CheckObject(KernelDirectoryHandle, 33UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS);
|
||||||
|
#else
|
||||||
|
CheckObject(KernelDirectoryHandle, 32769UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS);
|
||||||
|
#endif
|
||||||
|
else
|
||||||
CheckObject(KernelDirectoryHandle, 2UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS);
|
CheckObject(KernelDirectoryHandle, 2UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS);
|
||||||
|
|
||||||
TestDuplicate(KernelDirectoryHandle);
|
TestDuplicate(KernelDirectoryHandle);
|
||||||
|
|
||||||
Status = ObCloseHandle(KernelDirectoryHandle, UserMode);
|
Status = ObCloseHandle(KernelDirectoryHandle, UserMode);
|
||||||
ok_eq_hex(Status, STATUS_INVALID_HANDLE);
|
ok_eq_hex(Status, STATUS_INVALID_HANDLE);
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
#ifdef _M_IX86
|
||||||
|
CheckObject(KernelDirectoryHandle, 17UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS);
|
||||||
|
#else
|
||||||
|
CheckObject(KernelDirectoryHandle, 32753UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS);
|
||||||
|
#endif
|
||||||
|
else
|
||||||
CheckObject(KernelDirectoryHandle, 2UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS);
|
CheckObject(KernelDirectoryHandle, 2UL, 1UL, 0UL, DIRECTORY_ALL_ACCESS);
|
||||||
|
|
||||||
Status = ObCloseHandle(KernelDirectoryHandle, KernelMode);
|
Status = ObCloseHandle(KernelDirectoryHandle, KernelMode);
|
||||||
|
@ -191,9 +249,15 @@ START_TEST(ObHandle)
|
||||||
ok_eq_hex(Status, STATUS_INVALID_HANDLE);
|
ok_eq_hex(Status, STATUS_INVALID_HANDLE);
|
||||||
DPRINT("Closing -1 kernel handle (NtClose)\n");
|
DPRINT("Closing -1 kernel handle (NtClose)\n");
|
||||||
Status = NtClose(LongToHandle(0xFFFFFFFF));
|
Status = NtClose(LongToHandle(0xFFFFFFFF));
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN10)
|
||||||
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
|
else
|
||||||
ok_eq_hex(Status, STATUS_INVALID_HANDLE);
|
ok_eq_hex(Status, STATUS_INVALID_HANDLE);
|
||||||
DPRINT("Closing 123 handle (NtClose)\n");
|
DPRINT("Closing 123 handle (NtClose)\n");
|
||||||
Status = NtClose(LongToHandle(123));
|
Status = NtClose(LongToHandle(123));
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN8)
|
||||||
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
|
else if (GetNTVersion() != _WIN32_WINNT_WS03)
|
||||||
ok_eq_hex(Status, STATUS_INVALID_HANDLE);
|
ok_eq_hex(Status, STATUS_INVALID_HANDLE);
|
||||||
DPRINT("Closing 123 kernel handle (NtClose)\n");
|
DPRINT("Closing 123 kernel handle (NtClose)\n");
|
||||||
Status = NtClose(LongToHandle(123 | 0x80000000));
|
Status = NtClose(LongToHandle(123 | 0x80000000));
|
||||||
|
@ -211,6 +275,9 @@ START_TEST(ObHandle)
|
||||||
ok_eq_hex(Status, STATUS_INVALID_HANDLE);
|
ok_eq_hex(Status, STATUS_INVALID_HANDLE);
|
||||||
DPRINT("Closing -1 kernel handle (ObCloseHandle, UserMode)\n");
|
DPRINT("Closing -1 kernel handle (ObCloseHandle, UserMode)\n");
|
||||||
Status = ObCloseHandle(LongToHandle(0xFFFFFFFF), UserMode);
|
Status = ObCloseHandle(LongToHandle(0xFFFFFFFF), UserMode);
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN10)
|
||||||
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
|
else
|
||||||
ok_eq_hex(Status, STATUS_INVALID_HANDLE);
|
ok_eq_hex(Status, STATUS_INVALID_HANDLE);
|
||||||
DPRINT("Closing 123 handle (ObCloseHandle, UserMode)\n");
|
DPRINT("Closing 123 handle (ObCloseHandle, UserMode)\n");
|
||||||
Status = ObCloseHandle(LongToHandle(123), UserMode);
|
Status = ObCloseHandle(LongToHandle(123), UserMode);
|
||||||
|
@ -230,6 +297,9 @@ START_TEST(ObHandle)
|
||||||
Status = ZwClose((HANDLE)0x7FFFFFFF);*/
|
Status = ZwClose((HANDLE)0x7FFFFFFF);*/
|
||||||
DPRINT("Closing -1 kernel handle (ZwClose)\n");
|
DPRINT("Closing -1 kernel handle (ZwClose)\n");
|
||||||
Status = ZwClose(LongToHandle(0xFFFFFFFF));
|
Status = ZwClose(LongToHandle(0xFFFFFFFF));
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN10)
|
||||||
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
|
else
|
||||||
ok_eq_hex(Status, STATUS_INVALID_HANDLE);
|
ok_eq_hex(Status, STATUS_INVALID_HANDLE);
|
||||||
/* INVALID_KERNEL_HANDLE, 0x7B, 1, 0, 0
|
/* INVALID_KERNEL_HANDLE, 0x7B, 1, 0, 0
|
||||||
Status = ZwClose(LongToHandle(123));
|
Status = ZwClose(LongToHandle(123));
|
||||||
|
@ -246,6 +316,9 @@ START_TEST(ObHandle)
|
||||||
Status = ObCloseHandle((HANDLE)0x7FFFFFFF, KernelMode);*/
|
Status = ObCloseHandle((HANDLE)0x7FFFFFFF, KernelMode);*/
|
||||||
DPRINT("Closing -1 kernel handle (ObCloseHandle, KernelMode)\n");
|
DPRINT("Closing -1 kernel handle (ObCloseHandle, KernelMode)\n");
|
||||||
Status = ObCloseHandle(LongToHandle(0xFFFFFFFF), KernelMode);
|
Status = ObCloseHandle(LongToHandle(0xFFFFFFFF), KernelMode);
|
||||||
|
if (GetNTVersion() >= _WIN32_WINNT_WIN10)
|
||||||
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
|
else
|
||||||
ok_eq_hex(Status, STATUS_INVALID_HANDLE);
|
ok_eq_hex(Status, STATUS_INVALID_HANDLE);
|
||||||
/* INVALID_KERNEL_HANDLE, 0x7B, 1, 0, 0
|
/* INVALID_KERNEL_HANDLE, 0x7B, 1, 0, 0
|
||||||
Status = ObCloseHandle(LongToHandle(123), KernelMode);
|
Status = ObCloseHandle(LongToHandle(123), KernelMode);
|
||||||
|
|
|
@ -151,7 +151,7 @@ static OB_SECURITY_METHOD SeDefaultObjectMethod;
|
||||||
|
|
||||||
static
|
static
|
||||||
VOID
|
VOID
|
||||||
TestObjectTypes(VOID)
|
TestWin2003ObjectTypes(VOID)
|
||||||
{
|
{
|
||||||
ULONG Index;
|
ULONG Index;
|
||||||
|
|
||||||
|
@ -258,5 +258,13 @@ TestObjectTypes(VOID)
|
||||||
|
|
||||||
START_TEST(ObTypes)
|
START_TEST(ObTypes)
|
||||||
{
|
{
|
||||||
TestObjectTypes();
|
switch (GetNTVersion())
|
||||||
|
{
|
||||||
|
case _WIN32_WINNT_WS03:
|
||||||
|
TestWin2003ObjectTypes();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
skip(FALSE, "FIXME: kmtest:ObTypes is invalid for this NT version (0x%X).\n", GetNTVersion());
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,9 +253,13 @@ START_TEST(RtlMemory)
|
||||||
RtlCopyMemoryNonTemporal(Buffer + 13, Buffer + 62, 95);
|
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");
|
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");
|
||||||
|
|
||||||
|
#ifdef _M_IX86
|
||||||
MakePattern(Buffer, 2, 32, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 192, 0x9A, 0xAB, 0);
|
MakePattern(Buffer, 2, 32, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 192, 0x9A, 0xAB, 0);
|
||||||
RtlCopyMemoryNonTemporal(Buffer + 78, Buffer + 43, 107);
|
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");
|
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");
|
||||||
|
#else
|
||||||
|
skip(FALSE, "FIXME: This part of the test is broken on x64.\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
KeLowerIrql(Irql);
|
KeLowerIrql(Irql);
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
|
|
|
@ -25,6 +25,7 @@ TestStackWalk4(VOID)
|
||||||
ULONG ExpectedHash;
|
ULONG ExpectedHash;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
const ULONG FunctionSizeGuess = 0x1000;
|
const ULONG FunctionSizeGuess = 0x1000;
|
||||||
|
NTSTATUS ExceptionStatus = STATUS_SUCCESS;
|
||||||
|
|
||||||
ReturnAddresses[3] = _ReturnAddress();
|
ReturnAddresses[3] = _ReturnAddress();
|
||||||
|
|
||||||
|
@ -56,9 +57,19 @@ TestStackWalk4(VOID)
|
||||||
ok_eq_pointer(Frames[3], ReturnAddresses[1]);
|
ok_eq_pointer(Frames[3], ReturnAddresses[1]);
|
||||||
ok_eq_pointer(Frames[4], (PVOID)(ULONG_PTR)0x5555555555555555);
|
ok_eq_pointer(Frames[4], (PVOID)(ULONG_PTR)0x5555555555555555);
|
||||||
|
|
||||||
KmtStartSeh()
|
_SEH2_TRY
|
||||||
|
{
|
||||||
RtlCaptureStackBackTrace(0, 5, NULL, NULL);
|
RtlCaptureStackBackTrace(0, 5, NULL, NULL);
|
||||||
KmtEndSeh(STATUS_ACCESS_VIOLATION);
|
}
|
||||||
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
|
ExceptionStatus = _SEH2_GetExceptionCode();
|
||||||
|
}
|
||||||
|
_SEH2_END;
|
||||||
|
if (GetNTVersion() == _WIN32_WINNT_WS03)
|
||||||
|
ok_eq_hex(ExceptionStatus, STATUS_ACCESS_VIOLATION);
|
||||||
|
else
|
||||||
|
ok_eq_hex(ExceptionStatus, STATUS_SUCCESS);
|
||||||
|
|
||||||
RtlFillMemory(Frames, sizeof(Frames), 0x55);
|
RtlFillMemory(Frames, sizeof(Frames), 0x55);
|
||||||
Hash = 0x55555555;
|
Hash = 0x55555555;
|
||||||
|
@ -157,7 +168,7 @@ TestRtlPcToFileHeader(VOID)
|
||||||
#ifdef NTOS_MODE_USER
|
#ifdef NTOS_MODE_USER
|
||||||
Teb = NtCurrentTeb();
|
Teb = NtCurrentTeb();
|
||||||
#else
|
#else
|
||||||
Teb = KeGetCurrentThread()->Teb;
|
Teb = PsGetCurrentThreadTeb();
|
||||||
#endif
|
#endif
|
||||||
ok(Teb != NULL, "Teb is NULL!\n");
|
ok(Teb != NULL, "Teb is NULL!\n");
|
||||||
if (Teb == NULL)
|
if (Teb == NULL)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue