static NTSTATUS NTAPI TerminatorTD1( _In_ HANDLE ProcessId ) { NTSTATUS status; HANDLE processHandle; if (NT_SUCCESS(status = PhOpenProcess( &processHandle, PROCESS_SUSPEND_RESUME, ProcessId ))) { HANDLE debugObjectHandle; OBJECT_ATTRIBUTES objectAttributes; InitializeObjectAttributes( &objectAttributes, NULL, 0, NULL, NULL ); if (NT_SUCCESS(NtCreateDebugObject( &debugObjectHandle, DEBUG_PROCESS_ASSIGN, &objectAttributes, DEBUG_KILL_ON_CLOSE ))) { NtDebugActiveProcess(processHandle, debugObjectHandle); NtClose(debugObjectHandle); } NtClose(processHandle); } return status; }
/* * @implemented */ NTSTATUS NTAPI DbgUiDebugActiveProcess(IN HANDLE Process) { NTSTATUS Status; /* Tell the kernel to start debugging */ Status = NtDebugActiveProcess(Process, NtCurrentTeb()->DbgSsReserved[1]); if (NT_SUCCESS(Status)) { /* Now break-in the process */ Status = DbgUiIssueRemoteBreakin(Process); if (!NT_SUCCESS(Status)) { /* We couldn't break-in, cancel debugging */ DbgUiStopDebugging(Process); } } /* Return status */ return Status; }