From: Michael Müller michael@fds-team.de
This patch allows Process Hacker to show the filename, icon and description of an executable.
Since ProcessImageFileName incorrectly returns a Win32 path, we can simply reuse the existing implementation.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntdll/process.c | 1 + include/winternl.h | 1 + 2 files changed, 2 insertions(+)
diff --git a/dlls/ntdll/process.c b/dlls/ntdll/process.c index 835d7e6..fc75f3e 100644 --- a/dlls/ntdll/process.c +++ b/dlls/ntdll/process.c @@ -517,6 +517,7 @@ NTSTATUS WINAPI NtQueryInformationProcess( case ProcessImageFileName: /* FIXME: this will return a DOS path. Windows returns an NT path. Changing this would require also changing kernel32.QueryFullProcessImageName. * The latter may be harder because of the lack of RtlNtPathNameToDosPathName. */ + case ProcessImageFileNameWin32: SERVER_START_REQ(get_dll_info) { UNICODE_STRING *image_file_name_str = ProcessInformation; diff --git a/include/winternl.h b/include/winternl.h index c3cca80..f72a071 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -853,6 +853,7 @@ typedef enum _PROCESSINFOCLASS { ProcessDebugFlags = 31, ProcessHandleTracing = 32, ProcessExecuteFlags = 34, + ProcessImageFileNameWin32 = 43, MaxProcessInfoClass } PROCESSINFOCLASS, PROCESS_INFORMATION_CLASS;
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntdll/tests/info.c | 28 +++++++++++----------------- dlls/ntdll/tests/ntdll_test.h | 1 + 2 files changed, 12 insertions(+), 17 deletions(-)
diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c index 54321e5..5ea1957 100644 --- a/dlls/ntdll/tests/info.c +++ b/dlls/ntdll/tests/info.c @@ -1416,14 +1416,12 @@ static void test_query_process_handlecount(void)
static void test_query_process_image_file_name(void) { + static const WCHAR deviceW[] = {'\','D','e','v','i','c','e','\'}; NTSTATUS status; ULONG ReturnLength; - UNICODE_STRING image_file_name; - void *buffer; - char *file_nameA; - INT len; + UNICODE_STRING *buffer = NULL;
- status = pNtQueryInformationProcess(NULL, ProcessImageFileName, &image_file_name, sizeof(image_file_name), NULL); + status = pNtQueryInformationProcess(NULL, ProcessImageFileName, buffer, sizeof(*buffer), NULL); if (status == STATUS_INVALID_INFO_CLASS) { win_skip("ProcessImageFileName is not supported\n"); @@ -1431,24 +1429,20 @@ static void test_query_process_image_file_name(void) } ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08x\n", status);
- status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessImageFileName, &image_file_name, 2, &ReturnLength); + status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessImageFileName, buffer, 2, &ReturnLength); ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
- status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessImageFileName, &image_file_name, sizeof(image_file_name), &ReturnLength); + status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessImageFileName, buffer, sizeof(*buffer), &ReturnLength); ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
- buffer = HeapAlloc(GetProcessHeap(), 0, ReturnLength); + buffer = heap_alloc(ReturnLength); status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessImageFileName, buffer, ReturnLength, &ReturnLength); ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status); - memcpy(&image_file_name, buffer, sizeof(image_file_name)); - len = WideCharToMultiByte(CP_ACP, 0, image_file_name.Buffer, image_file_name.Length/sizeof(WCHAR), NULL, 0, NULL, NULL); - file_nameA = HeapAlloc(GetProcessHeap(), 0, len + 1); - WideCharToMultiByte(CP_ACP, 0, image_file_name.Buffer, image_file_name.Length/sizeof(WCHAR), file_nameA, len, NULL, NULL); - file_nameA[len] = '\0'; - HeapFree(GetProcessHeap(), 0, buffer); - trace("process image file name: %s\n", file_nameA); - todo_wine ok(strncmp(file_nameA, "\Device\", 8) == 0, "Process image name should be an NT path beginning with \Device\ (is %s)\n", file_nameA); - HeapFree(GetProcessHeap(), 0, file_nameA); +todo_wine + ok(!memcmp(buffer->Buffer, deviceW, sizeof(deviceW)), + "Expected image name to begin with \Device\, got %s\n", + wine_dbgstr_wn(buffer->Buffer, buffer->Length / sizeof(WCHAR))); + heap_free(buffer); }
static void test_query_process_debug_object_handle(int argc, char **argv) diff --git a/dlls/ntdll/tests/ntdll_test.h b/dlls/ntdll/tests/ntdll_test.h index 167e5ca..a8066c5 100644 --- a/dlls/ntdll/tests/ntdll_test.h +++ b/dlls/ntdll/tests/ntdll_test.h @@ -33,3 +33,4 @@ #include "winternl.h"
#include "wine/test.h" +#include "wine/heap.h"
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at https://testbot.winehq.org/JobDetails.pl?Key=36347
Your paranoid android.
=== w7u (32 bit generated) === TestBot process died unexpectedly
=== wxppro (32 bit info) === info.c:1430: Test failed: Expected STATUS_INVALID_HANDLE, got c0000005 info.c:1433: Test failed: Expected STATUS_INFO_LENGTH_MISMATCH, got c0000005 info.c:1436: Test failed: Expected STATUS_INFO_LENGTH_MISMATCH, got c0000005 The task timed out
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntdll/tests/info.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c index 5ea1957..f6a0d70 100644 --- a/dlls/ntdll/tests/info.c +++ b/dlls/ntdll/tests/info.c @@ -1443,6 +1443,28 @@ todo_wine "Expected image name to begin with \Device\, got %s\n", wine_dbgstr_wn(buffer->Buffer, buffer->Length / sizeof(WCHAR))); heap_free(buffer); + + status = pNtQueryInformationProcess(NULL, ProcessImageFileNameWin32, buffer, sizeof(*buffer), NULL); + if (status == STATUS_INVALID_INFO_CLASS) + { + win_skip("ProcessImageFileName is not supported\n"); + return; + } + ok( status == STATUS_INVALID_HANDLE, "Expected STATUS_INVALID_HANDLE, got %08x\n", status); + + status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessImageFileNameWin32, buffer, 2, &ReturnLength); + ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status); + + status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessImageFileNameWin32, buffer, sizeof(*buffer), &ReturnLength); + ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status); + + buffer = heap_alloc(ReturnLength); + status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessImageFileNameWin32, buffer, ReturnLength, &ReturnLength); + ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status); + ok(memcmp(buffer->Buffer, deviceW, sizeof(deviceW)), + "Expected image name not to begin with \Device\, got %s\n", + wine_dbgstr_wn(buffer->Buffer, buffer->Length / sizeof(WCHAR))); + heap_free(buffer); }
static void test_query_process_debug_object_handle(int argc, char **argv)
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at https://testbot.winehq.org/JobDetails.pl?Key=36348
Your paranoid android.
=== wxppro (32 bit info) === info.c:1430: Test failed: Expected STATUS_INVALID_HANDLE, got c0000005 info.c:1433: Test failed: Expected STATUS_INFO_LENGTH_MISMATCH, got c0000005 info.c:1436: Test failed: Expected STATUS_INFO_LENGTH_MISMATCH, got c0000005 info.c:1453: Test failed: Expected STATUS_INVALID_HANDLE, got c0000005 info.c:1456: Test failed: Expected STATUS_INFO_LENGTH_MISMATCH, got c0000005 info.c:1459: Test failed: Expected STATUS_INFO_LENGTH_MISMATCH, got c0000005 info.c:1463: Test failed: Expected STATUS_SUCCESS, got c0000003
On Thu, Mar 1, 2018 at 4:08 PM, Zebediah Figura z.figura12@gmail.com wrote:
From: Michael Müller michael@fds-team.de
This patch allows Process Hacker to show the filename, icon and description of an executable.
Since ProcessImageFileName incorrectly returns a Win32 path, we can simply reuse the existing implementation.
Signed-off-by: Zebediah Figura z.figura12@gmail.com
dlls/ntdll/process.c | 1 + include/winternl.h | 1 + 2 files changed, 2 insertions(+)
diff --git a/dlls/ntdll/process.c b/dlls/ntdll/process.c index 835d7e6..fc75f3e 100644 --- a/dlls/ntdll/process.c +++ b/dlls/ntdll/process.c @@ -517,6 +517,7 @@ NTSTATUS WINAPI NtQueryInformationProcess( case ProcessImageFileName: /* FIXME: this will return a DOS path. Windows returns an NT path. Changing this would require also changing kernel32.QueryFullProcessImageName. * The latter may be harder because of the lack of RtlNtPathNameToDosPathName. */
It seems that FIXME should be updated/removed then.
On 01/03/18 16:12, Austin English wrote:
On Thu, Mar 1, 2018 at 4:08 PM, Zebediah Figura z.figura12@gmail.com wrote:
From: Michael Müller michael@fds-team.de
This patch allows Process Hacker to show the filename, icon and description of an executable.
Since ProcessImageFileName incorrectly returns a Win32 path, we can simply reuse the existing implementation.
Signed-off-by: Zebediah Figura z.figura12@gmail.com
dlls/ntdll/process.c | 1 + include/winternl.h | 1 + 2 files changed, 2 insertions(+)
diff --git a/dlls/ntdll/process.c b/dlls/ntdll/process.c index 835d7e6..fc75f3e 100644 --- a/dlls/ntdll/process.c +++ b/dlls/ntdll/process.c @@ -517,6 +517,7 @@ NTSTATUS WINAPI NtQueryInformationProcess( case ProcessImageFileName: /* FIXME: this will return a DOS path. Windows returns an NT path. Changing this would require also changing kernel32.QueryFullProcessImageName. * The latter may be harder because of the lack of RtlNtPathNameToDosPathName. */
It seems that FIXME should be updated/removed then.
Fair enough; I'll send an updated patch.