From 11c64857c3b5750a456f7ba54e174b586d5598b8 Mon Sep 17 00:00:00 2001 From: Daniel Lehman Date: Mon, 14 Mar 2022 12:27:40 -0700 Subject: [PATCH 2/2] ntdll: Treat INVALID_HANDLE_VALUE as success in CloseHandle. https://bugs.winehq.org/show_bug.cgi?id=51529 Signed-off-by: Daniel Lehman --- visual studio remote debugging hits this exception under wine but not windows this change would also fix the above bug looks like only windows 10 returns success, and then only on 64-bit --- dlls/ntdll/tests/exception.c | 6 ------ dlls/ntdll/unix/server.c | 3 +++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index c065b2d3e4a2..573ff491214c 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c @@ -1246,7 +1246,6 @@ static void test_debugger(DWORD cont_status) } else if (stage == 17) { - todo_wine ok(FALSE, "should not throw exception\n"); continuestatus = DBG_EXCEPTION_NOT_HANDLED; } @@ -3950,7 +3949,6 @@ static void test_debugger(DWORD cont_status) } else if (stage == 17) { - todo_wine ok(FALSE, "should not throw exception\n"); continuestatus = DBG_EXCEPTION_NOT_HANDLED; } @@ -6627,7 +6625,6 @@ static void test_debugger(DWORD cont_status) } else if (stage == 17) { - todo_wine ok(FALSE, "should not throw exception\n"); continuestatus = DBG_EXCEPTION_NOT_HANDLED; } @@ -7881,7 +7878,6 @@ static void test_debugger(DWORD cont_status) } else if (stage == 17) { - todo_wine ok(FALSE, "should not throw exception\n"); continuestatus = DBG_EXCEPTION_NOT_HANDLED; } @@ -8614,13 +8610,11 @@ static void test_closehandle(DWORD numexc, HANDLE handle) invalid_handle_exceptions = 0; CloseHandle(handle); - todo_wine_if(handle == INVALID_HANDLE_VALUE) ok(invalid_handle_exceptions == numexc, "CloseHandle generated %d exceptions, expected %d\n", invalid_handle_exceptions, numexc); invalid_handle_exceptions = 0; pNtClose(handle); - todo_wine_if(handle == INVALID_HANDLE_VALUE) ok(invalid_handle_exceptions == numexc, "NtClose generated %d exceptions, expected %d\n", invalid_handle_exceptions, numexc); diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c index ab9d99c4f474..4ba32c75e219 100644 --- a/dlls/ntdll/unix/server.c +++ b/dlls/ntdll/unix/server.c @@ -1704,6 +1704,9 @@ NTSTATUS WINAPI NtClose( HANDLE handle ) NTSTATUS ret; int fd; + if (handle == INVALID_HANDLE_VALUE) + return STATUS_SUCCESS; + server_enter_uninterrupted_section( &fd_cache_mutex, &sigset ); /* always remove the cached fd; if the server request fails we'll just -- 2.27.0