From e4b71d31f94f7e496f139e03fae619a8e6436c9e Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Sat, 18 Feb 2017 14:22:44 +0000 Subject: [PATCH] [KMTESTS:MM] - Add some stricter checks and improved error handling in NtCreateSection_user svn path=/trunk/; revision=73827 --- .../kmtests/ntos_mm/NtCreateSection_user.c | 80 +++++++++++++------ 1 file changed, 54 insertions(+), 26 deletions(-) diff --git a/rostests/kmtests/ntos_mm/NtCreateSection_user.c b/rostests/kmtests/ntos_mm/NtCreateSection_user.c index ce21f47475a..6c68c451bd6 100644 --- a/rostests/kmtests/ntos_mm/NtCreateSection_user.c +++ b/rostests/kmtests/ntos_mm/NtCreateSection_user.c @@ -33,7 +33,9 @@ START_TEST(NtCreateSection) Status = NtCreateSection(&SectionHandle, SECTION_ALL_ACCESS, 0, &MaxFileSize, PAGE_READWRITE, SEC_COMMIT, Handle); ok_eq_hex(Status, STATUS_INVALID_FILE_FOR_SECTION); - NtClose(Handle); + if (NT_SUCCESS(Status)) NtClose(SectionHandle); + Status = NtClose(Handle); + ok_eq_hex(Status, STATUS_SUCCESS); /* Test 1 */ InitializeObjectAttributes(&ObjectAttributes, &InitOnCreate, OBJ_CASE_INSENSITIVE, NULL, NULL); @@ -57,9 +59,12 @@ START_TEST(NtCreateSection) memset(Buffer, 0xBA, 512); KmtEndSeh(STATUS_SUCCESS); - NtUnmapViewOfSection(NtCurrentProcess(), Buffer); - NtClose(SectionHandle); - NtClose(Handle); + Status = NtUnmapViewOfSection(NtCurrentProcess(), Buffer); + ok_eq_hex(Status, STATUS_SUCCESS); + Status = NtClose(SectionHandle); + ok_eq_hex(Status, STATUS_SUCCESS); + Status = NtClose(Handle); + ok_eq_hex(Status, STATUS_SUCCESS); /* Test 2 */ InitializeObjectAttributes(&ObjectAttributes, &InitOnCreate, OBJ_CASE_INSENSITIVE, NULL, NULL); @@ -83,9 +88,12 @@ START_TEST(NtCreateSection) memset(Buffer, 0xBA, 4096); KmtEndSeh(STATUS_SUCCESS); - NtUnmapViewOfSection(NtCurrentProcess(), Buffer); - NtClose(SectionHandle); - NtClose(Handle); + Status = NtUnmapViewOfSection(NtCurrentProcess(), Buffer); + ok_eq_hex(Status, STATUS_SUCCESS); + Status = NtClose(SectionHandle); + ok_eq_hex(Status, STATUS_SUCCESS); + Status = NtClose(Handle); + ok_eq_hex(Status, STATUS_SUCCESS); /* Test 3 */ InitializeObjectAttributes(&ObjectAttributes, &InitOnRW, OBJ_CASE_INSENSITIVE, NULL, NULL); @@ -109,9 +117,12 @@ START_TEST(NtCreateSection) memset(Buffer, 0xBA, 512); KmtEndSeh(STATUS_SUCCESS); - NtUnmapViewOfSection(NtCurrentProcess(), Buffer); - NtClose(SectionHandle); - NtClose(Handle); + Status = NtUnmapViewOfSection(NtCurrentProcess(), Buffer); + ok_eq_hex(Status, STATUS_SUCCESS); + Status = NtClose(SectionHandle); + ok_eq_hex(Status, STATUS_SUCCESS); + Status = NtClose(Handle); + ok_eq_hex(Status, STATUS_SUCCESS); /* Test 4 */ InitializeObjectAttributes(&ObjectAttributes, &InitOnRW, OBJ_CASE_INSENSITIVE, NULL, NULL); @@ -135,9 +146,12 @@ START_TEST(NtCreateSection) memset(Buffer, 0xBA, 4096); KmtEndSeh(STATUS_SUCCESS); - NtUnmapViewOfSection(NtCurrentProcess(), Buffer); - NtClose(SectionHandle); - NtClose(Handle); + Status = NtUnmapViewOfSection(NtCurrentProcess(), Buffer); + ok_eq_hex(Status, STATUS_SUCCESS); + Status = NtClose(SectionHandle); + ok_eq_hex(Status, STATUS_SUCCESS); + Status = NtClose(Handle); + ok_eq_hex(Status, STATUS_SUCCESS); /* Test 10 */ InitializeObjectAttributes(&ObjectAttributes, &InvalidInit, OBJ_CASE_INSENSITIVE, NULL, NULL); @@ -149,7 +163,9 @@ START_TEST(NtCreateSection) Status = NtCreateSection(&SectionHandle, SECTION_ALL_ACCESS, 0, &MaxFileSize, PAGE_READWRITE, SEC_COMMIT, Handle); ok_eq_hex(Status, STATUS_INVALID_FILE_FOR_SECTION); - NtClose(Handle); + if (NT_SUCCESS(Status)) NtClose(SectionHandle); + Status = NtClose(Handle); + ok_eq_hex(Status, STATUS_SUCCESS); /* Test 11 */ InitializeObjectAttributes(&ObjectAttributes, &InitOnCreate, OBJ_CASE_INSENSITIVE, NULL, NULL); @@ -173,9 +189,12 @@ START_TEST(NtCreateSection) memset(Buffer, 0xBA, 512); KmtEndSeh(STATUS_SUCCESS); - NtUnmapViewOfSection(NtCurrentProcess(), Buffer); - NtClose(SectionHandle); - NtClose(Handle); + Status = NtUnmapViewOfSection(NtCurrentProcess(), Buffer); + ok_eq_hex(Status, STATUS_SUCCESS); + Status = NtClose(SectionHandle); + ok_eq_hex(Status, STATUS_SUCCESS); + Status = NtClose(Handle); + ok_eq_hex(Status, STATUS_SUCCESS); /* Test 12 */ InitializeObjectAttributes(&ObjectAttributes, &InitOnCreate, OBJ_CASE_INSENSITIVE, NULL, NULL); @@ -199,9 +218,12 @@ START_TEST(NtCreateSection) memset(Buffer, 0xBA, 4096); KmtEndSeh(STATUS_SUCCESS); - NtUnmapViewOfSection(NtCurrentProcess(), Buffer); - NtClose(SectionHandle); - NtClose(Handle); + Status = NtUnmapViewOfSection(NtCurrentProcess(), Buffer); + ok_eq_hex(Status, STATUS_SUCCESS); + Status = NtClose(SectionHandle); + ok_eq_hex(Status, STATUS_SUCCESS); + Status = NtClose(Handle); + ok_eq_hex(Status, STATUS_SUCCESS); /* Test 13 */ InitializeObjectAttributes(&ObjectAttributes, &InitOnRW, OBJ_CASE_INSENSITIVE, NULL, NULL); @@ -225,9 +247,12 @@ START_TEST(NtCreateSection) memset(Buffer, 0xBA, 512); KmtEndSeh(STATUS_SUCCESS); - NtUnmapViewOfSection(NtCurrentProcess(), Buffer); - NtClose(SectionHandle); - NtClose(Handle); + Status = NtUnmapViewOfSection(NtCurrentProcess(), Buffer); + ok_eq_hex(Status, STATUS_SUCCESS); + Status = NtClose(SectionHandle); + ok_eq_hex(Status, STATUS_SUCCESS); + Status = NtClose(Handle); + ok_eq_hex(Status, STATUS_SUCCESS); /* Test 14 */ InitializeObjectAttributes(&ObjectAttributes, &InitOnRW, OBJ_CASE_INSENSITIVE, NULL, NULL); @@ -251,9 +276,12 @@ START_TEST(NtCreateSection) memset(Buffer, 0xBA, 4096); KmtEndSeh(STATUS_SUCCESS); - NtUnmapViewOfSection(NtCurrentProcess(), Buffer); - NtClose(SectionHandle); - NtClose(Handle); + Status = NtUnmapViewOfSection(NtCurrentProcess(), Buffer); + ok_eq_hex(Status, STATUS_SUCCESS); + Status = NtClose(SectionHandle); + ok_eq_hex(Status, STATUS_SUCCESS); + Status = NtClose(Handle); + ok_eq_hex(Status, STATUS_SUCCESS); KmtCloseDriver(); KmtUnloadDriver(); -- 2.17.1