| 573 | } |
| 574 | virtual rdcarray<rdcstr> ReplayArgs() { return {"--crash"}; } |
| 575 | virtual int Execute(const CaptureOptions &) |
| 576 | { |
| 577 | CrashGenerationServer *crashServer = NULL; |
| 578 | |
| 579 | wchar_t tempPath[MAX_PATH] = {0}; |
| 580 | GetTempPathW(MAX_PATH - 1, tempPath); |
| 581 | |
| 582 | std::wstring dumpFolder = tempPath; |
| 583 | |
| 584 | // create each parent directory separately, and use \\s |
| 585 | |
| 586 | dumpFolder += L"RenderDoc"; |
| 587 | CreateDirectoryW(dumpFolder.c_str(), NULL); |
| 588 | |
| 589 | dumpFolder += L"\\dumps"; |
| 590 | CreateDirectoryW(dumpFolder.c_str(), NULL); |
| 591 | |
| 592 | crashServer = |
| 593 | new CrashGenerationServer(pipe.c_str(), NULL, OnClientConnected, NULL, OnClientCrashed, |
| 594 | NULL, OnClientExited, NULL, NULL, NULL, true, &dumpFolder); |
| 595 | |
| 596 | if(!crashServer->Start()) |
| 597 | { |
| 598 | delete crashServer; |
| 599 | crashServer = NULL; |
| 600 | return 1; |
| 601 | } |
| 602 | |
| 603 | HANDLE readyEvent = CreateEventA(NULL, TRUE, FALSE, "RENDERDOC_CRASHHANDLE"); |
| 604 | |
| 605 | if(readyEvent != NULL) |
| 606 | { |
| 607 | SetEvent(readyEvent); |
| 608 | |
| 609 | CloseHandle(readyEvent); |
| 610 | } |
| 611 | |
| 612 | const int loopSleep = 100; |
| 613 | int elapsedTime = 0; |
| 614 | |
| 615 | MSG msg; |
| 616 | ZeroMemory(&msg, sizeof(msg)); |
| 617 | while(!exitServer) |
| 618 | { |
| 619 | // Check to see if any messages are waiting in the queue |
| 620 | while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) |
| 621 | { |
| 622 | // Translate the message and dispatch it to WindowProc() |
| 623 | TranslateMessage(&msg); |
| 624 | DispatchMessage(&msg); |
| 625 | } |
| 626 | |
| 627 | // If the message is WM_QUIT, exit the while loop |
| 628 | if(msg.message == WM_QUIT) |
| 629 | break; |
| 630 | |
| 631 | Sleep(loopSleep); |
| 632 | elapsedTime += loopSleep; |