server: Fix querying debug port with restricted DACL.

Today, Wine uses NtQueryInformationProcess/ProcessDebugPort to detect
whether the current process is being debugged.  If it is, the process
issues a breakpoint to yield control to the debugger.

Some debuggers (e.g. latest CDB) appear to create debug handles with
restricted DACL, which causes querying debug port to fail with
STATUS_ACCESS_DENIED.  This results in the debuggee erroneously
skipping the initial breakpoint.

Fix this by not requiring DEBUG_ALL_ACCESS when opening the debug port
object.  Instead, use MAXIMUM_ALLOWED for the access mask.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52184
Signed-off-by: Jinoh Kang <jinoh.kang.kr@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jinoh Kang 2021-12-08 00:29:02 +09:00 committed by Alexandre Julliard
parent ee4d38c3b1
commit 3e2f443003
2 changed files with 1 additions and 5 deletions

View File

@ -3518,20 +3518,16 @@ static void test_debuggee_dbgport(int argc, char **argv)
status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessDebugPort,
&debug_port, sizeof(debug_port), NULL );
todo_wine_if(access != DEBUG_ALL_ACCESS && access != GENERIC_ALL)
ok( !status, "NtQueryInformationProcess ProcessDebugPort failed, status %#x.\n", status );
todo_wine_if(access != DEBUG_ALL_ACCESS && access != GENERIC_ALL)
ok( debug_port == ~(DWORD_PTR)0, "Expected port %#lx, got %#lx.\n", ~(DWORD_PTR)0, debug_port );
status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessDebugFlags,
&debug_flags, sizeof(debug_flags), NULL );
todo_wine_if(access != DEBUG_ALL_ACCESS && access != GENERIC_ALL)
ok( !status, "NtQueryInformationProcess ProcessDebugFlags failed, status %#x.\n", status );
expect_status = access ? STATUS_SUCCESS : STATUS_ACCESS_DENIED;
status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessDebugObjectHandle,
&handle, sizeof(handle), NULL );
todo_wine_if(access != DEBUG_ALL_ACCESS && access != GENERIC_ALL)
ok( status == expect_status, "NtQueryInformationProcess ProcessDebugObjectHandle expected status %#x, actual %#x.\n", expect_status, status );
if (SUCCEEDED( status )) NtClose( handle );

View File

@ -1528,7 +1528,7 @@ DECL_HANDLER(get_process_debug_info)
reply->debug_children = process->debug_children;
if (!process->debug_obj) set_error( STATUS_PORT_NOT_SET );
else reply->debug = alloc_handle( current->process, process->debug_obj, DEBUG_ALL_ACCESS, 0 );
else reply->debug = alloc_handle( current->process, process->debug_obj, MAXIMUM_ALLOWED, 0 );
release_object( process );
}