Skip to content

Commit 7976be4

Browse files
committed
Improved version of DbgUiConnectToDbg by Mattiwatti
1 parent 250c443 commit 7976be4

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

TitanEngine/Global.Debugger.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,21 @@ static NTSTATUS NTAPI DbgUiDebugActiveProcess_(IN HANDLE Process)
239239
return Status;
240240
}
241241

242+
static NTSTATUS NTAPI DbgUiConnectToDbg_()
243+
{
244+
if(NtCurrentTeb()->DbgSsReserved[1] != NULL)
245+
return STATUS_SUCCESS;
246+
247+
OBJECT_ATTRIBUTES ObjectAttributes;
248+
InitializeObjectAttributes(&ObjectAttributes, NULL, 0, NULL, NULL);
249+
return NtCreateDebugObject(&NtCurrentTeb()->DbgSsReserved[1], DEBUG_ALL_ACCESS, &ObjectAttributes, 0);
250+
}
251+
242252
// Source: https://github.com/mirror/reactos/blob/c6d2b35ffc91e09f50dfb214ea58237509329d6b/reactos/dll/win32/kernel32/client/debugger.c#L480
243253
BOOL WINAPI DebugActiveProcess_(IN DWORD dwProcessId)
244254
{
245255
/* Connect to the debugger */
246-
NTSTATUS Status = DbgUiConnectToDbg();
256+
NTSTATUS Status = DbgUiConnectToDbg_();
247257
if(!NT_SUCCESS(Status))
248258
{
249259
BaseSetLastNTError(Status);

0 commit comments

Comments
 (0)