Improved version of DbgUiConnectToDbg by Mattiwatti

This commit is contained in:
Duncan Ogilvie 2018-11-18 15:43:59 +01:00
parent 250c44388b
commit 7976be4edd
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
1 changed files with 11 additions and 1 deletions

View File

@ -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);