MCPcopy Create free account
hub / github.com/beefytech/Beef / DoOpenFile

Method DoOpenFile

IDEHelper/WinDebugger.cpp:1350–1500  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1348}
1349
1350bool WinDebugger::DoOpenFile(const StringImpl& fileName, const StringImpl& args, const StringImpl& workingDir, const Array<uint8>& envBlock, DbgOpenFileFlags openFileFlags)
1351{
1352 BP_ZONE("WinDebugger::DoOpenFile");
1353
1354 AutoCrit autoCrit(mDebugManager->mCritSect);
1355 //gDbgPerfManager->StartRecording();
1356
1357 STARTUPINFOW si;
1358 ZeroMemory(&si, sizeof(si));
1359 si.cb = sizeof(si);
1360 ZeroMemory(&mProcessInfo, sizeof(mProcessInfo));
1361
1362 DWORD flags = DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS | CREATE_DEFAULT_ERROR_MODE;
1363 BOOL inheritHandles = false;
1364
1365 // set up the streams
1366 if ((openFileFlags & (DbgOpenFileFlag_RedirectStdInput | DbgOpenFileFlag_RedirectStdOutput | DbgOpenFileFlag_RedirectStdError)) != 0)
1367 {
1368 if ((openFileFlags & DbgOpenFileFlag_RedirectStdInput) != 0)
1369 CreatePipe(mStdInputPipe, si.hStdInput, true);
1370 else if (::GetConsoleWindow() != NULL)
1371 si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
1372 else
1373 si.hStdInput = INVALID_HANDLE_VALUE;
1374
1375 if ((openFileFlags & DbgOpenFileFlag_RedirectStdOutput) != 0)
1376 CreatePipe(mStdOutputPipe, si.hStdOutput, false);
1377 else
1378 si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
1379
1380 if ((openFileFlags & DbgOpenFileFlag_RedirectStdError) != 0)
1381 CreatePipe(mStdErrorPipe, si.hStdError, false);
1382 else
1383 si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
1384 flags |= CREATE_NO_WINDOW;
1385 si.dwFlags = STARTF_USESTDHANDLES;
1386 inheritHandles = true;
1387 }
1388
1389 if (mDbgProcessId != 0)
1390 {
1391 BOOL success = ::DebugActiveProcess(mDbgProcessId);
1392 if (!success)
1393 return false;
1394
1395 mProcessInfo.dwProcessId = mDbgProcessId;
1396 }
1397 else
1398 {
1399 BP_ZONE("DoOpenFile_CreateProcessW");
1400
1401 UTF16String envW;
1402
1403 void* envPtr = NULL;
1404 if (!envBlock.IsEmpty())
1405 {
1406 //UTF16?
1407 if (envBlock[1] == 0)

Callers

nothing calls this directly

Calls 8

CreatePipeFunction · 0.70
IsHandleValidFunction · 0.70
IsEmptyMethod · 0.45
sizeMethod · 0.45
c_strMethod · 0.45
push_backMethod · 0.45
UnlockMethod · 0.45
LockMethod · 0.45

Tested by

no test coverage detected