| 310 | } |
| 311 | |
| 312 | NTSTATUS |
| 313 | DbgkpSetProcessDebugObject( |
| 314 | _In_ PEPROCESS Process, |
| 315 | _In_ PDEBUG_OBJECT DebugObject, |
| 316 | _In_ NTSTATUS MsgStatus, |
| 317 | _In_ PETHREAD LastThread |
| 318 | ) |
| 319 | /*++ |
| 320 | Routine Description: |
| 321 | Attach a debug object to a process. |
| 322 | Arguments: |
| 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. |
| 327 | Return 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 |
no test coverage detected