Changeset 65456 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jan 26, 2017 3:14:27 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VBoxBugReport
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxBugReport/VBoxBugReport.cpp
r63735 r65456 327 327 handleRtError(RTStrmOpen(m_szFileName, "r", &m_Strm), 328 328 "Failed to open '%s'", m_szFileName); 329 return m_Strm; 330 } 331 332 333 BugReportCommandTemp::BugReportCommandTemp(const char *pszTitle, const char *pszExec, ...) 334 : BugReportItem(pszTitle), m_Strm(NULL) 335 { 336 handleRtError(RTPathTemp(m_szFileName, RTPATH_MAX), 337 "Failed to obtain path to temporary folder"); 338 handleRtError(RTPathAppend(m_szFileName, RTPATH_MAX, "BugRepXXXXX.tmp"), 339 "Failed to append path"); 340 handleRtError(RTFileCreateTemp(m_szFileName, 0600), 341 "Failed to create temporary file '%s'", m_szFileName); 342 343 unsigned cArgs = 0; 344 m_papszArgs[cArgs++] = RTStrDup(pszExec); 345 346 const char *pszArg; 347 va_list va; 348 va_start(va, pszExec); 349 do 350 { 351 if (cArgs >= RT_ELEMENTS(m_papszArgs) - 1) 352 { 353 va_end(va); 354 throw RTCError(com::Utf8StrFmt("Too many arguments (%u > %u)\n", cArgs+1, RT_ELEMENTS(m_papszArgs))); 355 } 356 pszArg = va_arg(va, const char *); 357 m_papszArgs[cArgs++] = RTStrDup(pszArg ? pszArg : m_szFileName); 358 } while (pszArg); 359 va_end(va); 360 361 m_papszArgs[cArgs++] = NULL; 362 } 363 364 BugReportCommandTemp::~BugReportCommandTemp() 365 { 366 if (m_Strm) 367 RTStrmClose(m_Strm); 368 RTFileDelete(m_szErrFileName); 369 RTFileDelete(m_szFileName); 370 for (size_t i = 0; i < RT_ELEMENTS(m_papszArgs) && m_papszArgs[i]; ++i) 371 RTStrFree(m_papszArgs[i]); 372 } 373 374 PRTSTREAM BugReportCommandTemp::getStream(void) 375 { 376 handleRtError(RTPathTemp(m_szErrFileName, RTPATH_MAX), 377 "Failed to obtain path to temporary folder"); 378 handleRtError(RTPathAppend(m_szErrFileName, RTPATH_MAX, "BugRepErrXXXXX.tmp"), 379 "Failed to append path"); 380 handleRtError(RTFileCreateTemp(m_szErrFileName, 0600), 381 "Failed to create temporary file '%s'", m_szErrFileName); 382 383 RTHANDLE hStdOutErr; 384 hStdOutErr.enmType = RTHANDLETYPE_FILE; 385 handleRtError(RTFileOpen(&hStdOutErr.u.hFile, m_szErrFileName, 386 RTFILE_O_WRITE | RTFILE_O_CREATE_REPLACE | RTFILE_O_DENY_WRITE), 387 "Failed to open temporary file '%s'", m_szErrFileName); 388 389 /* Remove the output file to prevent errors or confirmation prompts */ 390 handleRtError(RTFileDelete(m_szFileName), 391 "Failed to delete temporary file '%s'", m_szFileName); 392 393 RTPROCESS hProcess; 394 handleRtError(RTProcCreateEx(m_papszArgs[0], m_papszArgs, RTENV_DEFAULT, 0, 395 NULL, &hStdOutErr, &hStdOutErr, 396 NULL, NULL, &hProcess), 397 "Failed to create process '%s'", m_papszArgs[0]); 398 RTPROCSTATUS status; 399 handleRtError(RTProcWait(hProcess, RTPROCWAIT_FLAGS_BLOCK, &status), 400 "Process wait failed"); 401 RTFileClose(hStdOutErr.u.hFile); 402 403 if (status.enmReason == RTPROCEXITREASON_NORMAL && status.iStatus == 0) 404 handleRtError(RTStrmOpen(m_szFileName, "r", &m_Strm), "Failed to open '%s'", m_szFileName); 405 else 406 handleRtError(RTStrmOpen(m_szErrFileName, "r", &m_Strm), "Failed to open '%s'", m_szErrFileName); 329 407 return m_Strm; 330 408 } -
trunk/src/VBox/Frontends/VBoxBugReport/VBoxBugReport.h
r59797 r65456 224 224 }; 225 225 226 /* 227 * A base class for item classes that provide temp output file to a command. 228 */ 229 class BugReportCommandTemp : public BugReportItem 230 { 231 public: 232 BugReportCommandTemp(const char *pszTitle, const char *pszExec, ...); 233 virtual ~BugReportCommandTemp(); 234 virtual PRTSTREAM getStream(void); 235 private: 236 PRTSTREAM m_Strm; 237 char m_szFileName[RTPATH_MAX]; 238 char m_szErrFileName[RTPATH_MAX]; 239 char *m_papszArgs[32]; 240 }; 226 241 227 242 /* Platform-specific */ -
trunk/src/VBox/Frontends/VBoxBugReport/VBoxBugReportWin.cpp
r63703 r65456 719 719 report->addItem(new BugReportCommand("DriverServices", PathJoin(WinSysDir.c_str(), "sc.exe"), 720 720 "query", "type=", "driver", "state=", "all", NULL)); 721 report->addItem(new BugReportCommand("DriverStore", PathJoin(WinSysDir.c_str(), "pnputil.exe"), "-e", NULL)); 722 report->addItem(new BugReportCommandTemp("RegDevKeys", PathJoin(WinSysDir.c_str(), "reg.exe"), "export", 723 "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\Root\\NET", NULL)); 724 report->addItem(new BugReportCommandTemp("RegDrvKeys", PathJoin(WinSysDir.c_str(), "reg.exe"), "export", 725 "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}", NULL)); 726 report->addItem(new BugReportCommandTemp("RegNetwork", PathJoin(WinSysDir.c_str(), "reg.exe"), "export", 727 "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}", NULL)); 721 728 report->addItem(new BugReportUsbTreeWin); 722 729 report->addItem(new BugReportDriversWin);
Note:
See TracChangeset
for help on using the changeset viewer.