Author: mjansen
Date: Thu May 5 12:06:07 2016
New Revision: 71261
URL:
http://svn.reactos.org/svn/reactos?rev=71261&view=rev
Log:
[NTOSKRNL][NTDLL_APITEST] Fix error returned from NtCreateSection when opening an empty
file. CORE-11166
Modified:
trunk/reactos/ntoskrnl/mm/section.c
trunk/rostests/apitests/ntdll/NtMapViewOfSection.c
Modified: trunk/reactos/ntoskrnl/mm/section.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/section.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] Thu May 5 12:06:07 2016
@@ -2993,7 +2993,7 @@
{
ObDereferenceObject(Section);
ObDereferenceObject(FileObject);
- return STATUS_FILE_INVALID;
+ return STATUS_MAPPED_FILE_SIZE_ZERO;
}
}
Modified: trunk/rostests/apitests/ntdll/NtMapViewOfSection.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/NtMapViewO…
==============================================================================
--- trunk/rostests/apitests/ntdll/NtMapViewOfSection.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/ntdll/NtMapViewOfSection.c [iso-8859-1] Thu May 5 12:06:07
2016
@@ -1351,6 +1351,53 @@
DeleteFileW(FileName);
}
+static void
+Test_EmptyFile(VOID)
+{
+ NTSTATUS Status;
+ WCHAR TempPath[MAX_PATH];
+ WCHAR FileName[MAX_PATH];
+ HANDLE Handle;
+ HANDLE SectionHandle;
+ ULONG Length;
+
+ Length = GetTempPathW(MAX_PATH, TempPath);
+ ok(Length != 0, "GetTempPathW failed with %lu\n", GetLastError());
+ Length = GetTempFileNameW(TempPath, L"nta", 0, FileName);
+ ok(Length != 0, "GetTempFileNameW failed with %lu\n", GetLastError());
+ Handle = CreateFileW(FileName,
+ FILE_ALL_ACCESS,
+ 0,
+ NULL,
+ CREATE_ALWAYS,
+ 0,
+ NULL);
+ if (Handle == INVALID_HANDLE_VALUE)
+ {
+ skip("Failed to create temp file %ls, error %lu\n", FileName,
GetLastError());
+ return;
+ }
+
+ Status = NtCreateSection(&SectionHandle,
+ STANDARD_RIGHTS_REQUIRED | SECTION_QUERY |
SECTION_MAP_READ,
+ 0, 0, PAGE_READONLY, SEC_COMMIT, Handle);
+ ok_ntstatus(Status, STATUS_MAPPED_FILE_SIZE_ZERO);
+
+ if (NT_SUCCESS(Status))
+ NtClose(SectionHandle);
+
+ Status = NtCreateSection(&SectionHandle,
+ STANDARD_RIGHTS_REQUIRED | SECTION_QUERY |
SECTION_MAP_READ,
+ 0, 0, PAGE_READONLY, SEC_IMAGE, Handle);
+ ok_ntstatus(Status, STATUS_INVALID_FILE_FOR_SECTION);
+
+ if (NT_SUCCESS(Status))
+ NtClose(SectionHandle);
+
+ CloseHandle(Handle);
+ DeleteFileW(FileName);
+}
+
START_TEST(NtMapViewOfSection)
{
Test_PageFileSection();
@@ -1358,4 +1405,5 @@
Test_BasedSection();
Test_NoLoadSection(FALSE);
Test_NoLoadSection(TRUE);
+ Test_EmptyFile();
}