MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / DbgkpSetProcessDebugObject

Function DbgkpSetProcessDebugObject

KernelLibrary/kDbgSys.cpp:312–521  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

310}
311
312NTSTATUS
313DbgkpSetProcessDebugObject(
314 _In_ PEPROCESS Process,
315 _In_ PDEBUG_OBJECT DebugObject,
316 _In_ NTSTATUS MsgStatus,
317 _In_ PETHREAD LastThread
318)
319/*++
320Routine Description:
321 Attach a debug object to a process.
322Arguments:
323 Process - Process to be debugged
324 DebugObject - Debug object to attach
325 MsgStatus - Status from queing the messages
326 LastThread - Last thread seen in attach loop.
327Return Value:
328 NTSTATUS - Status of call.
329--*/
330{
331 NTSTATUS status;
332 PETHREAD ThisThread;
333 LIST_ENTRY TempList;
334 PLIST_ENTRY Entry;
335 PDEBUG_EVENT DebugEvent;
336 BOOLEAN First;
337 PETHREAD Thread;
338 BOOLEAN GlobalHeld;
339 PETHREAD FirstThread;
340
341 PAGED_CODE();
342
343 ThisThread = PsGetCurrentThread();
344 InitializeListHead(&TempList);
345
346 First = TRUE;
347 GlobalHeld = FALSE;
348
349 if (!NT_SUCCESS(MsgStatus)) {
350 LastThread = nullptr;
351 status = MsgStatus;
352 }
353 else {
354 status = STATUS_SUCCESS;
355 }
356
357 PDEBUG_OBJECT* pProcessDebugPort = kDbgUtil::GetProcessDebugPort(Process);
358
359 //
360 // Pick up any threads we missed
361 //
362 if (NT_SUCCESS(status)) {
363 while (true) {
364 //
365 // Acquire the debug port mutex so we know that any new threads will
366 // have to wait to behind us.
367 //
368 GlobalHeld = TRUE;
369

Callers 1

NtDebugActiveProcessFunction · 0.85

Calls 4

InitializeListHeadFunction · 0.85
RemoveEntryListFunction · 0.85
InsertTailListFunction · 0.85
IsListEmptyFunction · 0.85

Tested by

no test coverage detected