From 25d22ac6fe6c84742dedf45a6b9115b4ba1bbf6c Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sun, 28 May 2017 05:44:38 +0200
Subject: [PATCH] ntdll: Allow to query section names from other processes.
 (v2)

---
 dlls/psapi/tests/psapi_main.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/dlls/psapi/tests/psapi_main.c b/dlls/psapi/tests/psapi_main.c
index b9d8576..af69646 100644
--- a/dlls/psapi/tests/psapi_main.c
+++ b/dlls/psapi/tests/psapi_main.c
@@ -399,6 +399,10 @@ static void test_GetMappedFileName(void)
     char temp_path[MAX_PATH], file_name[MAX_PATH], map_name[MAX_PATH], device_name[MAX_PATH], drive[3];
     WCHAR map_nameW[MAX_PATH], nt_map_name[MAX_PATH];
     HANDLE hfile, hmap;
+    HANDLE current_process;
+
+    DuplicateHandle( GetCurrentProcess(), GetCurrentProcess(),
+                     GetCurrentProcess(), &current_process, 0, 0, DUPLICATE_SAME_ACCESS );
 
     SetLastError(0xdeadbeef);
     ret = GetMappedFileNameA(NULL, hMod, szMapPath, sizeof(szMapPath));
@@ -500,6 +504,20 @@ todo_wine
     }
 
     SetLastError(0xdeadbeef);
+    ret = GetMappedFileNameW(current_process, base, map_nameW, sizeof(map_nameW)/sizeof(map_nameW[0]));
+todo_wine {
+    ok(ret, "GetMappedFileNameW error %d\n", GetLastError());
+    ok(ret > strlen(device_name), "map_name should be longer than device_name\n");
+}
+    if (nt_get_mapped_file_name(current_process, base, nt_map_name, sizeof(nt_map_name)/sizeof(nt_map_name[0])))
+    {
+        ok(memcmp(map_nameW, nt_map_name, lstrlenW(map_nameW)) == 0, "map name does not start with a device name: %s\n", map_name);
+        WideCharToMultiByte(CP_ACP, 0, map_nameW, -1, map_name, MAX_PATH, NULL, NULL);
+todo_wine
+        ok(memcmp(map_name, device_name, strlen(device_name)) == 0, "map name does not start with a device name: %s\n", map_name);
+    }
+
+    SetLastError(0xdeadbeef);
     ret = GetMappedFileNameA(GetCurrentProcess(), base + 0x2000, map_name, sizeof(map_name));
 todo_wine {
     ok(ret, "GetMappedFileName error %d\n", GetLastError());
@@ -544,6 +562,7 @@ todo_wine
 todo_wine
     ok(GetLastError() == ERROR_FILE_INVALID, "expected ERROR_FILE_INVALID, got %d\n", GetLastError());
 
+    CloseHandle(current_process);
     UnmapViewOfFile(base);
     CloseHandle(hmap);
 }
-- 
2.7.4

