From 7976be4edd84e923f24b8e68fc710262a6f3f4b0 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Sun, 18 Nov 2018 15:43:59 +0100 Subject: [PATCH] Improved version of DbgUiConnectToDbg by Mattiwatti --- TitanEngine/Global.Debugger.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/TitanEngine/Global.Debugger.cpp b/TitanEngine/Global.Debugger.cpp index ce0b4da..f5120a5 100644 --- a/TitanEngine/Global.Debugger.cpp +++ b/TitanEngine/Global.Debugger.cpp @@ -239,11 +239,21 @@ static NTSTATUS NTAPI DbgUiDebugActiveProcess_(IN HANDLE Process) return Status; } +static NTSTATUS NTAPI DbgUiConnectToDbg_() +{ + if(NtCurrentTeb()->DbgSsReserved[1] != NULL) + return STATUS_SUCCESS; + + OBJECT_ATTRIBUTES ObjectAttributes; + InitializeObjectAttributes(&ObjectAttributes, NULL, 0, NULL, NULL); + return NtCreateDebugObject(&NtCurrentTeb()->DbgSsReserved[1], DEBUG_ALL_ACCESS, &ObjectAttributes, 0); +} + // Source: https://github.com/mirror/reactos/blob/c6d2b35ffc91e09f50dfb214ea58237509329d6b/reactos/dll/win32/kernel32/client/debugger.c#L480 BOOL WINAPI DebugActiveProcess_(IN DWORD dwProcessId) { /* Connect to the debugger */ - NTSTATUS Status = DbgUiConnectToDbg(); + NTSTATUS Status = DbgUiConnectToDbg_(); if(!NT_SUCCESS(Status)) { BaseSetLastNTError(Status);