From 5d91d52417f94e41427bd3ecc7239c31d726d8ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Fri, 2 Nov 2018 18:26:52 +0100 Subject: [PATCH] [KMTESTS/MM] Enable again accessing forbidden memory. Also adda test case for the PAGE_GUARD case ROSTESTS-110 --- .../kmtests/ntos_mm/ZwMapViewOfSection.c | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/modules/rostests/kmtests/ntos_mm/ZwMapViewOfSection.c b/modules/rostests/kmtests/ntos_mm/ZwMapViewOfSection.c index b6e6146536b..aa8e1459545 100644 --- a/modules/rostests/kmtests/ntos_mm/ZwMapViewOfSection.c +++ b/modules/rostests/kmtests/ntos_mm/ZwMapViewOfSection.c @@ -433,8 +433,6 @@ BehaviorChecks(HANDLE FileHandleReadOnly, HANDLE FileHandleWriteOnly) ZwUnmapViewOfSection(NtCurrentProcess(), BaseAddress); } -/* FIXME: Crash. See ROSTESTS-110 */ -#ifdef ROSTESTS_110_FIXED //try to access forbidden memory BaseAddress = NULL; ViewSize = 0; @@ -448,7 +446,24 @@ BehaviorChecks(HANDLE FileHandleReadOnly, HANDLE FileHandleWriteOnly) ZwUnmapViewOfSection(NtCurrentProcess(), BaseAddress); } -#endif /* ROSTESTS_110_FIXED */ + + //try to access guarded memory + BaseAddress = NULL; + ViewSize = 0; + SectionOffset.QuadPart = 0; + Status = ZwMapViewOfSection(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 0, 0, &SectionOffset, &ViewSize, ViewUnmap, 0, PAGE_GUARD | PAGE_READWRITE); + if (!skip(NT_SUCCESS(Status), "Error mapping view with PAGE_NOACCESS priv. Error = %p\n", Status)) + { + KmtStartSeh() + RtlCompareMemory(BaseAddress, TestString, TestStringSize); + KmtEndSeh(STATUS_GUARD_PAGE_VIOLATION); + + KmtStartSeh() + RtlCompareMemory(BaseAddress, TestString, TestStringSize); + KmtEndSeh(STATUS_SUCCESS); + + ZwUnmapViewOfSection(NtCurrentProcess(), BaseAddress); + } ZwClose(WriteSectionHandle);