From: Paul Gofman pgofman@codeweavers.com
--- dlls/kernelbase/debug.c | 2 +- dlls/psapi/tests/psapi_main.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/dlls/kernelbase/debug.c b/dlls/kernelbase/debug.c index 6a332e971ec..d3f22435f55 100644 --- a/dlls/kernelbase/debug.c +++ b/dlls/kernelbase/debug.c @@ -1555,7 +1555,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetModuleFileNameExW( HANDLE process, HMODULE mod NTSTATUS status;
status = get_process_image_file_name( process, buffer, sizeof(buffer), &dynamic_buffer, &result ); - if (!status) + if (set_ntstatus( status )) { len = result->Length / sizeof(WCHAR); memcpy( name, result->Buffer, min( len, size - 1 ) * sizeof(WCHAR) ); diff --git a/dlls/psapi/tests/psapi_main.c b/dlls/psapi/tests/psapi_main.c index da77e2f0fe9..7bf67d0b331 100644 --- a/dlls/psapi/tests/psapi_main.c +++ b/dlls/psapi/tests/psapi_main.c @@ -1059,6 +1059,16 @@ static void test_GetModuleFileNameEx(void) ret = CreateProcessW(NULL, buffer, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &si, &pi); ok(ret, "CreateProcessW failed: %lu\n", GetLastError());
+ SetLastError(0xdeadbeef); + size = GetModuleFileNameExW((HANDLE)0xdeadbeef, NULL, buffer, ARRAYSIZE(buffer)); + ok(!size, "got %lu.\n", size); + ok(GetLastError() == ERROR_INVALID_HANDLE, "got error %lu.\n", GetLastError()); + + SetLastError(0xdeadbeef); + size = GetModuleFileNameExA((HANDLE)0xdeadbeef, NULL, szModExPath, ARRAYSIZE(szModExPath)); + ok(!size, "got %lu.\n", size); + ok(GetLastError() == ERROR_INVALID_HANDLE, "got error %lu.\n", GetLastError()); + size = GetModuleFileNameExW(pi.hProcess, NULL, buffer, ARRAYSIZE(buffer)); ok(size || broken(GetLastError() == ERROR_INVALID_HANDLE), /* < Win10 */