+/*
+ * PROJECT: ReactOS API Tests
+ * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
+ * PURPOSE: Test for NtMapViewOfSection
+ * PROGRAMMERS: Timo Kreuzer
+ */
#include <apitest.h>
-
+#include <strsafe.h>
#define WIN32_NO_STATUS
#include <ndk/ntndk.h>
-BOOL WINAPI SetInformationJobObject(
- _In_ HANDLE hJob,
- _In_ JOBOBJECTINFOCLASS JobObjectInfoClass,
- _In_ LPVOID lpJobObjectInfo,
- _In_ DWORD cbJobObjectInfoLength
-);
-
-NTSYSAPI
-NTSTATUS
-NTAPI
-NtMapViewOfSection(
- HANDLE SectionHandle,
- HANDLE ProcessHandle,
- PVOID *BaseAddress,
- ULONG_PTR ZeroBits,
- SIZE_T CommitSize,
- PLARGE_INTEGER SectionOffset,
- PSIZE_T ViewSize,
- SECTION_INHERIT InheritDisposition,
- ULONG AllocationType,
- ULONG Protect);
-
void
Test_PageFileSection(void)
{
LARGE_INTEGER MaximumSize, SectionOffset;
PVOID BaseAddress, BaseAddress2;
SIZE_T ViewSize;
- //ULONG OldProtect;
- QUOTA_LIMITS QuotaLimits;
+ ULONG OldProtect;
/* Create a page file backed section with SEC_COMMIT */
MaximumSize.QuadPart = 0x20000;
if (!NT_SUCCESS(Status))
return;
- ok(BaseAddress == UlongToPtr(0x40000000), "Invalid BaseAddress: %p", BaseAddress);
+ ok(BaseAddress == UlongToPtr(0x40000000), "Invalid BaseAddress: %p\n", BaseAddress);
BaseAddress = (PVOID)0x40080000;
SectionOffset.QuadPart = 0x10000;
PAGE_READWRITE);
ok_ntstatus(Status, STATUS_SUCCESS);
- ok(BaseAddress == (PVOID)0x40080000, "Invalid BaseAddress: %p", BaseAddress);
+ ok(BaseAddress == (PVOID)0x40080000, "Invalid BaseAddress: %p\n", BaseAddress);
/* Commit a page in the section */
BaseAddress = (PVOID)0x40000000;
_SEH2_END;
ok_ntstatus(Status, STATUS_SUCCESS);
- ok(*(PULONG)BaseAddress2 == 2, "Value in memory was wrong");
+ ok(*(PULONG)BaseAddress2 == 2, "Value in memory was wrong\n");
/* Close the mapping */
NtUnmapViewOfSection(NtCurrentProcess(), BaseAddress);
NtUnmapViewOfSection(NtCurrentProcess(), (PUCHAR)BaseAddress2 - PAGE_SIZE);
NtClose(SectionHandle);
-#if 0
- {
- HANDLE Job;
- JOBOBJECT_EXTENDED_LIMIT_INFORMATION JobLimitInformation;
-
- Job = CreateJobObject(NULL, NULL);
- ok_ntstatus(Status, STATUS_SUCCESS);
-
- ok(AssignProcessToJobObject(Job, NtCurrentProcess()), "");
-
- RtlZeroMemory(&JobLimitInformation, sizeof(JobLimitInformation));
- JobLimitInformation.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_JOB_MEMORY;
- JobLimitInformation.JobMemoryLimit = 100 * 1024;
- JobLimitInformation.PeakProcessMemoryUsed = JobLimitInformation.JobMemoryLimit;
- JobLimitInformation.PeakJobMemoryUsed = JobLimitInformation.JobMemoryLimit;
-
- ok(SetInformationJobObject(Job,
- JobObjectExtendedLimitInformation,
- &JobLimitInformation,
- sizeof(JobLimitInformation)), "");
- }
-#endif
-
- QuotaLimits.PagedPoolLimit = 0;
- QuotaLimits.NonPagedPoolLimit = 0;
- QuotaLimits.TimeLimit.QuadPart = 0;
- QuotaLimits.PagefileLimit = 0;
- QuotaLimits.MinimumWorkingSetSize = 90000;
- QuotaLimits.MaximumWorkingSetSize = 90000;
- Status = NtSetInformationProcess(NtCurrentProcess(),
- ProcessQuotaLimits,
- &QuotaLimits,
- sizeof(QuotaLimits));
- ok_ntstatus(Status, STATUS_SUCCESS);
-
- QuotaLimits.MinimumWorkingSetSize = 0;
- QuotaLimits.MaximumWorkingSetSize = 0;
- QuotaLimits.PagefileLimit = 1;
- Status = NtSetInformationProcess(NtCurrentProcess(),
- ProcessQuotaLimits,
- &QuotaLimits,
- sizeof(QuotaLimits));
- ok_ntstatus(Status, STATUS_SUCCESS);
-
- /* Try to create a huge page file backed section */
- MaximumSize.QuadPart = 0x800000000;
+ /* Try to create a 512 GB page file backed section with committed pages */
+ MaximumSize.QuadPart = 0x8000000000;
Status = NtCreateSection(&SectionHandle,
SECTION_ALL_ACCESS,
NULL,
NULL);
ok_ntstatus(Status, STATUS_INVALID_PAGE_PROTECTION);
- /* Create a huge page file backed section, but only reserved */
- MaximumSize.QuadPart = 0x8000000000;
+ /* Try to create a very huge page file backed section, but only reserved */
+ MaximumSize.QuadPart = 0x80000000000;
+ Status = NtCreateSection(&SectionHandle,
+ SECTION_ALL_ACCESS,
+ NULL,
+ &MaximumSize,
+ PAGE_READWRITE,
+ SEC_RESERVE,
+ NULL);
+#ifdef _WIN64
+ ok_ntstatus(Status, STATUS_INSUFFICIENT_RESOURCES);
+#else
+ /* WoW64 returns STATUS_INSUFFICIENT_RESOURCES */
+ ok((Status == STATUS_INSUFFICIENT_RESOURCES) || (Status == STATUS_SECTION_TOO_BIG),
+ "got wrong Status: 0x%lx\n", Status);
+#endif
+
+ /* Try to create a even huger page file backed section, but only reserved */
+ MaximumSize.QuadPart = 0x800000000000;
+ Status = NtCreateSection(&SectionHandle,
+ SECTION_ALL_ACCESS,
+ NULL,
+ &MaximumSize,
+ PAGE_READWRITE,
+ SEC_RESERVE,
+ NULL);
+ ok_ntstatus(Status, STATUS_SECTION_TOO_BIG);
+
+ /* Create a 8 GB page file backed section, but only reserved */
+ MaximumSize.QuadPart = 0x200000000;
Status = NtCreateSection(&SectionHandle,
SECTION_ALL_ACCESS,
NULL,
/* Pass a too large region size */
BaseAddress = NULL;
SectionOffset.QuadPart = 0;
- ViewSize = 0x80000000;
+ ViewSize = MAXULONG_PTR;
Status = NtMapViewOfSection(SectionHandle,
NtCurrentProcess(),
&BaseAddress,
ViewShare,
0,
PAGE_READWRITE);
- ok_ntstatus(Status, STATUS_INVALID_PARAMETER_4);
+#ifdef _WIN64
+ ok_ntstatus(Status, STATUS_INVALID_PARAMETER_3);
+#else
+ /* WoW64 returns STATUS_INVALID_PARAMETER_4 */
+ ok((Status == STATUS_INVALID_PARAMETER_4) || (Status == STATUS_INVALID_PARAMETER_3),
+ "got wrong Status: 0x%lx\n", Status);
+#endif
+
+ /* Pass 0 region size */
+ BaseAddress = NULL;
+ SectionOffset.QuadPart = 0;
+ ViewSize = 0;
+ Status = NtMapViewOfSection(SectionHandle,
+ NtCurrentProcess(),
+ &BaseAddress,
+ 0,
+ 0,
+ &SectionOffset,
+ &ViewSize,
+ ViewShare,
+ 0,
+ PAGE_READWRITE);
+#ifdef _WIN64
+ ok_ntstatus(Status, STATUS_SUCCESS);
+ ok(ViewSize == 0x200000000, "wrong ViewSize: 0x%Ix\n", ViewSize);
+#else
+ /* WoW64 returns STATUS_NO_MEMORY */
+ ok((Status == STATUS_NO_MEMORY) || (Status == STATUS_INVALID_VIEW_SIZE),
+ "got wrong Status: 0x%lx\n", Status);
+ ok(ViewSize == 0, "wrong ViewSize: 0x%Ix\n", ViewSize);
+#endif
/* Map with PAGE_NOACCESS */
BaseAddress = NULL;
PAGE_NOACCESS);
ok_ntstatus(Status, STATUS_SUCCESS);
+ /* Try to change protection to read/write */
+ ViewSize = 0x1000;
+ OldProtect = -1;
+ BaseAddress2 = BaseAddress;
+ Status = NtProtectVirtualMemory(NtCurrentProcess(), &BaseAddress2, &ViewSize, PAGE_READWRITE, &OldProtect);
+ ok_ntstatus(Status, STATUS_SECTION_PROTECTION);
+ // Windows 2003 returns bogus
+ //ok(OldProtect == PAGE_READWRITE, "Wrong protection returned: %u\n", OldProtect);
+
+ /* Test read access */
+ Status = STATUS_SUCCESS;
+ _SEH2_TRY
+ {
+ (void)(*(volatile char*)BaseAddress2);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = _SEH2_GetExceptionCode();
+ }
+ _SEH2_END;
+ ok_ntstatus(Status, STATUS_ACCESS_VIOLATION);
+
+ /* Try to change protection to read/write */
+ ViewSize = 0x1000;
+ OldProtect = -1;
+ BaseAddress2 = BaseAddress;
+ Status = NtProtectVirtualMemory(NtCurrentProcess(), &BaseAddress2, &ViewSize, PAGE_READWRITE, &OldProtect);
+ ok_ntstatus(Status, STATUS_SECTION_PROTECTION);
+#ifdef _WIN64
+ ok(OldProtect == 0, "Wrong protection returned: 0x%lx\n", OldProtect);
+#else
+ // Windows 2003 returns bogus
+#endif
+
+ /* Try to change protection to readonly */
+ ViewSize = 0x1000;
+ OldProtect = -1;
+ BaseAddress2 = BaseAddress;
+ Status = NtProtectVirtualMemory(NtCurrentProcess(), &BaseAddress2, &ViewSize, PAGE_READONLY, &OldProtect);
+ ok_ntstatus(Status, STATUS_SECTION_PROTECTION);
+#ifdef _WIN64
+ //ok(OldProtect == 0, "Wrong protection returned: 0x%lx\n", OldProtect);
+#else
+ // Windows 2003 returns bogus
+#endif
+
+ /* Commit a page */
+ ViewSize = 0x1000;
+ BaseAddress2 = BaseAddress;
+ Status = NtAllocateVirtualMemory(NtCurrentProcess(), &BaseAddress2, 0, &ViewSize, MEM_COMMIT, PAGE_READONLY);
+ ok_ntstatus(Status, STATUS_SUCCESS);
+ ok(BaseAddress2 == BaseAddress, "Invalid base address: %p\n", BaseAddress2);
+
+ /* Commit the page again */
+ ViewSize = 0x1000;
+ BaseAddress2 = BaseAddress;
+ Status = NtAllocateVirtualMemory(NtCurrentProcess(), &BaseAddress2, 0, &ViewSize, MEM_COMMIT, PAGE_READONLY);
+ ok_ntstatus(Status, STATUS_SUCCESS);
+ ok(BaseAddress2 == BaseAddress, "Invalid base address: %p\n", BaseAddress2);
+
+ /* Test read access */
+ Status = STATUS_SUCCESS;
+ _SEH2_TRY
+ {
+ (void)(*(volatile char*)BaseAddress2);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = _SEH2_GetExceptionCode();
+ }
+ _SEH2_END;
+ ok_ntstatus(Status, STATUS_SUCCESS);
+
+ /* Test write access */
+ Status = STATUS_SUCCESS;
+ _SEH2_TRY
+ {
+ *(char*)BaseAddress2 = 1;
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = _SEH2_GetExceptionCode();
+ }
+ _SEH2_END;
+ ok_ntstatus(Status, STATUS_ACCESS_VIOLATION);
+
/* Update protection to PAGE_READWRITE */
- ViewSize = 0x20000000;
- Status = NtAllocateVirtualMemory(NtCurrentProcess(), &BaseAddress, 0, &ViewSize, MEM_COMMIT, PAGE_READWRITE);
+ ViewSize = 0x1000;
+ BaseAddress2 = BaseAddress;
+ Status = NtAllocateVirtualMemory(NtCurrentProcess(), &BaseAddress2, 0, &ViewSize, MEM_COMMIT, PAGE_READWRITE);
ok_ntstatus(Status, STATUS_SUCCESS);
- //Status = NtProtectVirtualMemory(NtCurrentProcess(), &BaseAddress, &ViewSize, PAGE_READWRITE, &OldProtect);
- //ok_ntstatus(Status, STATUS_SUCCESS);
- //ok(OldProtect == PAGE_NOACCESS, "Wrong protection returned: %u\n", OldProtect);
+ /* Test write access */
+ Status = STATUS_SUCCESS;
+ _SEH2_TRY
+ {
+ *(char*)BaseAddress2 = 1;
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = _SEH2_GetExceptionCode();
+ }
+ _SEH2_END;
+ ok_ntstatus(Status, STATUS_SUCCESS);
- /* Update protection to PAGE_READWRITE (1 page) */
+ /* Update protection to PAGE_EXECUTE_READWRITE (1 page) */
ViewSize = 0x1000;
- Status = NtAllocateVirtualMemory(NtCurrentProcess(), &BaseAddress, 0, &ViewSize, MEM_COMMIT, PAGE_READWRITE);
+ BaseAddress2 = BaseAddress;
+ Status = NtAllocateVirtualMemory(NtCurrentProcess(), &BaseAddress2, 0, &ViewSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
ok_ntstatus(Status, STATUS_SUCCESS);
}
NTSTATUS Status;
OBJECT_ATTRIBUTES FileObjectAttributes;
IO_STATUS_BLOCK IoStatusBlock;
+ WCHAR TestDllPath[MAX_PATH];
HANDLE FileHandle, DataSectionHandle, ImageSectionHandle;
PVOID DataBase, ImageBase;
SIZE_T ViewSize;
- if (!RtlDosPathNameToNtPathName_U(L"testdata\\test.dll",
+ GetModuleFileNameW(NULL, TestDllPath, RTL_NUMBER_OF(TestDllPath));
+ wcsrchr(TestDllPath, L'\\')[1] = UNICODE_NULL;
+ StringCbCatW(TestDllPath, sizeof(TestDllPath), L"testdata\\test.dll");
+ if (!RtlDosPathNameToNtPathName_U(TestDllPath,
&FileName,
NULL,
NULL))
&IoStatusBlock,
FILE_SHARE_READ,
FILE_SYNCHRONOUS_IO_NONALERT);
- ok(Status == STATUS_SUCCESS, "NtOpenFile failed, Status 0x%lx\n", Status);
+ ok_ntstatus(Status, STATUS_SUCCESS);
+ if (!NT_SUCCESS(Status))
+ {
+ skip("Failed to open file\n");
+ return;
+ }
/* Create a data section with write access */
Status = NtCreateSection(&DataSectionHandle,
PAGE_READWRITE, // SectionPageProtection
SEC_COMMIT, // AllocationAttributes
FileHandle);
- ok(Status == STATUS_SUCCESS, "NtCreateSection failed, Status 0x%lx\n", Status);
+ ok_ntstatus(Status, STATUS_SUCCESS);
+ if (!NT_SUCCESS(Status))
+ {
+ skip("Failed to create data section\n");
+ NtClose(FileHandle);
+ return;
+ }
/* Map the data section as flat mapping */
DataBase = NULL;
ViewShare,
0,
PAGE_READWRITE);
- ok(Status == STATUS_SUCCESS, "NtMapViewOfSection failed, Status 0x%lx\n", Status);
+ ok_ntstatus(Status, STATUS_SUCCESS);
+ //ok(ViewSize == 0x3f95cc48, "ViewSize wrong: 0x%lx\n");
+ if (!NT_SUCCESS(Status))
+ {
+ skip("Failed to map view of data section\n");
+ NtClose(DataSectionHandle);
+ NtClose(FileHandle);
+ return;
+ }
/* Check the original data */
ok(*(ULONG*)DataBase == 0x00905a4d, "Header not ok\n");
PAGE_READWRITE, // SectionPageProtection
SEC_IMAGE, // AllocationAttributes
FileHandle);
- ok(Status == STATUS_INVALID_IMAGE_NOT_MZ, "NtCreateSection failed, Status 0x%lx\n", Status);
+ ok_ntstatus(Status, STATUS_INVALID_IMAGE_NOT_MZ);
+ if (NT_SUCCESS(Status)) NtClose(ImageSectionHandle);
/* Restore the original header */
*(ULONG*)DataBase = 0x00905a4d;
PAGE_READWRITE, // SectionPageProtection
SEC_IMAGE, // AllocationAttributes
FileHandle);
- ok(Status == STATUS_SUCCESS, "NtCreateSection failed, Status 0x%lx\n", Status);
+ ok_ntstatus(Status, STATUS_SUCCESS);
+ if (!NT_SUCCESS(Status))
+ {
+ skip("Failed to create image section\n");
+ NtClose(DataSectionHandle);
+ NtClose(FileHandle);
+ return;
+ }
/* Map the image section */
ImageBase = NULL;
0, // AllocationType
PAGE_READONLY);
#ifdef _M_IX86
- ok(Status == STATUS_SUCCESS, "NtMapViewOfSection failed, Status 0x%lx\n", Status);
+ ok_ntstatus(Status, STATUS_IMAGE_NOT_AT_BASE);
#else
- ok(Status == STATUS_IMAGE_MACHINE_TYPE_MISMATCH, "NtMapViewOfSection failed, Status 0x%lx\n", Status);
+ ok_ntstatus(Status, STATUS_IMAGE_MACHINE_TYPE_MISMATCH);
#endif
+ if (!NT_SUCCESS(Status))
+ {
+ skip("Failed to map view of image section\n");
+ NtClose(ImageSectionHandle);
+ NtClose(DataSectionHandle);
+ NtClose(FileHandle);
+ return;
+ }
/* Check the header */
ok(*(ULONG*)DataBase == 0x00905a4d, "Header not ok\n");
&DataBase,
&ViewSize,
&IoStatusBlock);
- ok(Status == STATUS_SUCCESS, "NtFlushVirtualMemory failed, Status 0x%lx\n", Status);
+ ok_ntstatus(Status, STATUS_SUCCESS);
/* Check the data again */
ok(*(ULONG*)ImageBase == 0x00905a4d, "Data should not be synced!\n");
PAGE_READWRITE, // SectionPageProtection
SEC_IMAGE, // AllocationAttributes
FileHandle);
- ok(Status == STATUS_SUCCESS, "NtCreateSection failed, Status 0x%lx\n", Status);
+ ok_ntstatus(Status, STATUS_SUCCESS);
+ if (!NT_SUCCESS(Status))
+ {
+ skip("Failed to create image section\n");
+ NtClose(DataSectionHandle);
+ NtClose(FileHandle);
+ return;
+ }
/* Map the image section again */
ImageBase = NULL;
0,
PAGE_READONLY);
#ifdef _M_IX86
- ok(Status == STATUS_SUCCESS, "NtMapViewOfSection failed, Status 0x%lx\n", Status);
+ ok_ntstatus(Status, STATUS_IMAGE_NOT_AT_BASE);
#else
- ok(Status == STATUS_IMAGE_MACHINE_TYPE_MISMATCH, "NtMapViewOfSection failed, Status 0x%lx\n", Status);
+ ok_ntstatus(Status, STATUS_IMAGE_MACHINE_TYPE_MISMATCH);
#endif
+ if (!NT_SUCCESS(Status))
+ {
+ skip("Failed to map view of image section\n");
+ NtClose(ImageSectionHandle);
+ NtClose(DataSectionHandle);
+ NtClose(FileHandle);
+ return;
+ }
+ // This one doesn't always work, needs investigation
/* Check the .data section again */
- ok(*(ULONG*)((PUCHAR)ImageBase + 0x80000) == 0xf00dada,
- "Data should be synced: 0x%lx!\n", *(ULONG*)((PUCHAR)ImageBase + 0x80000));
+ //ok(*(ULONG*)((PUCHAR)ImageBase + 0x80000) == 0xf00dada,
+ // "Data should be synced: 0x%lx!\n", *(ULONG*)((PUCHAR)ImageBase + 0x80000));
/* Restore the original data */
*(ULONG*)((PUCHAR)DataBase + 0x800) = 0x12345678;
DataBase = (PUCHAR)ImageBase + 0x20000;
ViewSize = 0x1000;
Status = NtAllocateVirtualMemory(NtCurrentProcess(), &DataBase, 0, &ViewSize, MEM_RESERVE, PAGE_NOACCESS);
- ok(Status == STATUS_CONFLICTING_ADDRESSES, "Wrong Status: 0x%lx\n", Status);
+ ok_ntstatus(Status, STATUS_CONFLICTING_ADDRESSES);
/* Cleanup */
NtClose(FileHandle);
&IoStatusBlock,
FILE_SHARE_READ,
FILE_SYNCHRONOUS_IO_NONALERT);
- ok(Status == STATUS_SUCCESS, "NtOpenFile failed, Status 0x%lx\n", Status);
+ ok_ntstatus(Status, STATUS_SUCCESS);
printf("Opened file with handle %p\n", FileHandle);
/* Create a data section with write access */
PAGE_READWRITE, // SectionPageProtection
SEC_IMAGE, // AllocationAttributes
FileHandle);
- ok(Status == STATUS_SUCCESS, "NtCreateSection failed, Status 0x%lx\n", Status);
+ ok_ntstatus(Status, STATUS_SUCCESS);
printf("Created image section with handle %p\n", ImageSectionHandle);
//system("PAUSE");
ViewShare,
0,
PAGE_READWRITE);
- ok(Status == STATUS_SUCCESS, "NtMapViewOfSection failed, Status 0x%lx\n", Status);
+ ok_ntstatus(Status, STATUS_SUCCESS);
printf("Mapped image section at %p, value in text section: %lx\n",
ImageBase, *((ULONG*)((PCHAR)ImageBase + 0x1196)));
}
+// doesn't work with WoW64!
+void
+Test_BasedSection(void)
+{
+ NTSTATUS Status;
+ HANDLE SectionHandle1, SectionHandle2;
+ LARGE_INTEGER MaximumSize, SectionOffset;
+ PVOID BaseAddress1, BaseAddress2;
+ SIZE_T ViewSize;
+
+ /* Create a based section with SEC_COMMIT */
+ MaximumSize.QuadPart = 0x1000;
+ Status = NtCreateSection(&SectionHandle1,
+ SECTION_ALL_ACCESS,
+ NULL,
+ &MaximumSize,
+ PAGE_READWRITE,
+ SEC_COMMIT | SEC_BASED,
+ NULL);
+ ok_ntstatus(Status, STATUS_SUCCESS);
+
+ /* Map the 1st section */
+ BaseAddress1 = NULL;
+ SectionOffset.QuadPart = 0;
+ ViewSize = 0;
+ Status = NtMapViewOfSection(SectionHandle1,
+ NtCurrentProcess(),
+ &BaseAddress1,
+ 0,
+ 0,
+ &SectionOffset,
+ &ViewSize,
+ ViewShare,
+ 0,
+ PAGE_READWRITE);
+#if 0 // WOW64?
+ ok_ntstatus(Status, STATUS_CONFLICTING_ADDRESSES);
+#else
+ ok_ntstatus(Status, STATUS_SUCCESS);
+#endif
+
+ /* Create a 2nd based section with SEC_COMMIT */
+ MaximumSize.QuadPart = 0x1000;
+ Status = NtCreateSection(&SectionHandle2,
+ SECTION_ALL_ACCESS,
+ NULL,
+ &MaximumSize,
+ PAGE_READWRITE,
+ SEC_COMMIT | SEC_BASED,
+ NULL);
+ ok_ntstatus(Status, STATUS_SUCCESS);//
+
+ /* Map the 2nd section */
+ BaseAddress2 = NULL;
+ SectionOffset.QuadPart = 0;
+ ViewSize = 0;
+ Status = NtMapViewOfSection(SectionHandle2,
+ NtCurrentProcess(),
+ &BaseAddress2,
+ 0,
+ 0,
+ &SectionOffset,
+ &ViewSize,
+ ViewShare,
+ 0,
+ PAGE_READWRITE);
+#if 0 // WOW64?
+ ok_ntstatus(Status, STATUS_CONFLICTING_ADDRESSES);
+#else
+ ok_ntstatus(Status, STATUS_SUCCESS);
+#endif
+
+ ok_ntstatus(Status, STATUS_SUCCESS);
+ ok((ULONG_PTR)BaseAddress2 < (ULONG_PTR)BaseAddress1,
+ "Invalid addresses: BaseAddress1=%p, BaseAddress2=%p\n", BaseAddress1, BaseAddress2);
+ ok(((ULONG_PTR)BaseAddress1 - (ULONG_PTR)BaseAddress2) == 0x10000,
+ "Invalid addresses: BaseAddress1=%p, BaseAddress2=%p\n", BaseAddress1, BaseAddress2);
+
+}
+
START_TEST(NtMapViewOfSection)
{
Test_PageFileSection();
- //Test_ImageSection2();
+ Test_ImageSection();
+ Test_BasedSection();
}
-