| 582 | } |
| 583 | |
| 584 | bool DbgEngAdapter::Attach(std::uint32_t pid) |
| 585 | { |
| 586 | std::atomic_bool ret = false; |
| 587 | std::atomic_bool finished = false; |
| 588 | // Doing the operation on a different thread ensures the same thread starts the session and runs EngineLoop(). |
| 589 | // This is required by DngEng. Although things sometimes work even if it is violated, it can fail randomly. |
| 590 | std::thread([=, &ret, &finished]() { |
| 591 | ret = AttachInternal(pid); |
| 592 | finished = true; |
| 593 | if (ret) |
| 594 | EngineLoop(); |
| 595 | }).detach(); |
| 596 | |
| 597 | while (!finished) |
| 598 | {} |
| 599 | return ret; |
| 600 | } |
| 601 | |
| 602 | bool DbgEngAdapter::Connect(const std::string& server, std::uint32_t port) |
| 603 | { |