From a24e330b203a6b37987633ba03fc3b2e1c3a004f Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 28 Jan 2021 11:20:38 +0100 Subject: [PATCH] ntdll: Implement DbgUiConnectToDbg(). Signed-off-by: Alexandre Julliard --- dlls/ntdll/ntdll.spec | 2 +- dlls/ntdll/process.c | 16 ++++++++++++++++ include/winternl.h | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 285b719f2d5..740030f2066 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -34,7 +34,7 @@ @ stub DbgPrompt # @ stub DbgQueryDebugFilterState # @ stub DbgSetDebugFilterState -@ stub DbgUiConnectToDbg +@ stdcall DbgUiConnectToDbg() @ stub DbgUiContinue @ stub DbgUiConvertStateChangeStructure # @ stub DbgUiDebugActiveProcess diff --git a/dlls/ntdll/process.c b/dlls/ntdll/process.c index d8280277418..c52f00d123e 100644 --- a/dlls/ntdll/process.c +++ b/dlls/ntdll/process.c @@ -134,6 +134,22 @@ void WINAPI DbgUiSetThreadDebugObject( HANDLE handle ) NtCurrentTeb()->DbgSsReserved[1] = handle; } +/*********************************************************************** + * DbgUiConnectToDbg (NTDLL.@) + */ +NTSTATUS WINAPI DbgUiConnectToDbg(void) +{ + HANDLE handle; + NTSTATUS status; + OBJECT_ATTRIBUTES attr = { sizeof(attr) }; + + if (DbgUiGetThreadDebugObject()) return STATUS_SUCCESS; /* already connected */ + + status = NtCreateDebugObject( &handle, DEBUG_ALL_ACCESS, &attr, 0 ); + if (!status) DbgUiSetThreadDebugObject( handle ); + return status; +} + /*********************************************************************** * DbgUiRemoteBreakin (NTDLL.@) */ diff --git a/include/winternl.h b/include/winternl.h index ac63567dad3..fc4792a194a 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -3020,6 +3020,7 @@ typedef struct _PS_CREATE_INFO NTSYSAPI void WINAPI DbgBreakPoint(void); NTSYSAPI NTSTATUS WINAPIV DbgPrint(LPCSTR fmt, ...); NTSYSAPI NTSTATUS WINAPIV DbgPrintEx(ULONG iComponentId, ULONG Level, LPCSTR fmt, ...); +NTSYSAPI NTSTATUS WINAPI DbgUiConnectToDbg(void); NTSYSAPI HANDLE WINAPI DbgUiGetThreadDebugObject(void); NTSYSAPI NTSTATUS WINAPI DbgUiIssueRemoteBreakin(HANDLE); NTSYSAPI void WINAPI DbgUiRemoteBreakin(void*);