On Wed, Jun 19, 2019 at 02:01:24PM +0200, Rémi Bernon wrote:
+static void test_MapViewOfSection(void)
Let's keep its name as test_NtMapViewofSection, since that's what we're testing.
+{ + static const char testfile[] = "testfile.xxx"; + static const char data[] = "test data for NtMapViewOfSection"; + char buffer[sizeof(data)]; + HANDLE file, mapping, process; + void *ptr, *ptr2; + BOOL is_wow64, ret; + DWORD status, written; + SIZE_T size, result; + LARGE_INTEGER offset; + ULONG zero_bits; + + file = CreateFileA(testfile, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0); + ok(file != INVALID_HANDLE_VALUE, "Failed to create test file\n"); + WriteFile(file, data, sizeof(data), &written, NULL); + SetFilePointer(file, 4096, NULL, FILE_BEGIN); + SetEndOfFile(file); + + /* read/write mapping */ + + mapping = CreateFileMappingA(file, NULL, PAGE_READWRITE, 0, 4096, NULL); + ok(mapping != 0, "CreateFileMapping failed\n"); + + process = create_target_process("sleep"); + ok(process != NULL, "Can't start process\n"); + + ptr = NULL; + size = 0; + offset.QuadPart = 0; + status = NtMapViewOfSection(mapping, process, &ptr, 0, 0, &offset, &size, 1, 0, PAGE_READWRITE); + ok(status == STATUS_SUCCESS, "NtMapViewOfSection returned %08x\n", status); + ok(!((ULONG_PTR)ptr & 0xffff), "returned memory %p is not aligned to 64k\n", ptr); + + ret = ReadProcessMemory(process, ptr, buffer, sizeof(buffer), &result); + ok(ret, "ReadProcessMemory failed\n"); + ok(result == sizeof(buffer), "ReadProcessMemory didn't read all data (%lx)\n", result); + ok(!memcmp(buffer, data, sizeof(buffer) ), "Wrong data read\n"); + + /* for some unknown reason NtMapViewOfSection fails with STATUS_NO_MEMORY when zero_bits != 0 ? */ + ptr2 = NULL; + size = 0; + offset.QuadPart = 0; + status = NtMapViewOfSection(mapping, process, &ptr2, 12, 0, &offset, &size, 1, 0, PAGE_READWRITE);
This is not the same as the code you've removed from kernel32. I suggest you regenerate this patch by gonig the cut-and-paste again. Huw.