|
9 | 9 | #include <Core/source/cli/CliOptions.h> |
10 | 10 | #include <CommonUtilities/log/IdentificationTable.h> |
11 | 11 | #include <CommonUtilities/generated/build_id.h> |
| 12 | +#include <CommonUtilities/win/Utilities.h> |
12 | 13 | #include <PresentMonAPIWrapper/DiagnosticHandler.h> |
13 | 14 | #include <dwmapi.h> |
14 | 15 |
|
| 16 | +#pragma warning(push) |
| 17 | +#pragma warning(disable : 4297) |
| 18 | +#include <boost/process.hpp> |
| 19 | +#pragma warning(pop) |
| 20 | + |
15 | 21 | #pragma comment(lib, "Dwmapi.lib") |
16 | 22 |
|
17 | 23 | using namespace p2c; |
@@ -225,8 +231,27 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi |
225 | 231 | // configure the logging system (partially based on command line options) |
226 | 232 | ConfigureLogging(); |
227 | 233 |
|
228 | | - using namespace client; |
229 | 234 | try { |
| 235 | + // service-as-child handling |
| 236 | + std::optional<boost::process::child> childSvc; |
| 237 | + if (!opt.cefType && opt.svcAsChild) { |
| 238 | + using namespace std::literals; |
| 239 | + namespace bp = boost::process; |
| 240 | + |
| 241 | + childSvc.emplace("PresentMonService.exe"s, |
| 242 | + "--control-pipe"s, *opt.controlPipe, |
| 243 | + "--nsm-prefix"s, "pm-frame-nsm"s, |
| 244 | + "--intro-nsm"s, *opt.shmName, |
| 245 | + "--etw-session-name"s, *opt.etwSessionName); |
| 246 | + |
| 247 | + if (!pmon::util::win::WaitForNamedPipe(*opt.controlPipe, 1500)) { |
| 248 | + pmlog_error(L"timeout waiting for child service control pipe to go online"); |
| 249 | + return -1; |
| 250 | + } |
| 251 | + } |
| 252 | + |
| 253 | + using namespace client; |
| 254 | + // cef process constellation fork control |
230 | 255 | CefMainArgs main_args{ hInstance }; |
231 | 256 | CefRefPtr<ccef::NanoCefProcessHandler> app = new ccef::NanoCefProcessHandler{}; |
232 | 257 |
|
|
0 commit comments