Changeset 63703 in vbox for trunk/src/VBox/Frontends/VBoxBugReport
- Timestamp:
- Sep 2, 2016 3:00:26 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VBoxBugReport
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxBugReport/Makefile.kmk
r59797 r63703 25 25 # VBoxBugReport_DEFS += \ 26 26 VBOX_WATCHDOG_GLOBAL_PERFCOL VBOX_BUILD_TARGET=\"$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)\" 27 VBoxBugReport_DEFS.win = _WIN32_WINNT=0x0501 27 VBoxBugReport_DEFS.win = _WIN32_WINNT=0x0501 PSAPI_VERSION=1 28 VBoxBugReport_LIBS.win = psapi.lib 28 29 VBoxBugReport_SOURCES = \ 29 30 VBoxBugReport.cpp -
trunk/src/VBox/Frontends/VBoxBugReport/VBoxBugReport.cpp
r63384 r63703 117 117 118 118 119 class VBRDir 120 { 121 public: 122 VBRDir(const char *pcszPath) 123 { 124 int rc = RTDirOpenFiltered(&m_pDir, pcszPath, RTDIRFILTER_WINNT, 0); 125 if (RT_FAILURE(rc)) 126 throw RTCError(com::Utf8StrFmt("Failed to open directory '%s'\n", pcszPath)); 127 }; 128 ~VBRDir() 129 { 130 int rc = RTDirClose(m_pDir); 131 if (RT_FAILURE(rc)) 132 throw RTCError("Failed to close directory\n"); 133 }; 134 const char *next(void) 135 { 136 int rc = RTDirRead(m_pDir, &m_DirEntry, NULL); 137 if (RT_SUCCESS(rc)) 138 return m_DirEntry.szName; 139 else if (rc == VERR_NO_MORE_FILES) 140 return NULL; 141 throw RTCError("Failed to read directory element\n"); 142 }; 143 144 private: 145 PRTDIR m_pDir; 146 RTDIRENTRY m_DirEntry; 147 }; 148 119 149 /* 120 150 * An abstract class serving as the root of the bug report item tree. … … 461 491 void createBugReport(BugReport* report, const char *pszHome, MachineInfoList& machines) 462 492 { 463 report->addItem(new BugReportFile(PathJoin(pszHome, "VBoxSVC.log"), "VBoxSVC.log")); 464 report->addItem(new BugReportFile(PathJoin(pszHome, "VBoxSVC.log.1"), "VBoxSVC.log.1")); 493 /* Collect all log files from VBoxSVC */ 494 VBRDir HomeDir(PathJoin(pszHome, "VBoxSVC.log*")); 495 const char *pcszSvcLogFile = HomeDir.next(); 496 while (pcszSvcLogFile) 497 { 498 report->addItem(new BugReportFile(PathJoin(pszHome, pcszSvcLogFile), pcszSvcLogFile)); 499 pcszSvcLogFile = HomeDir.next(); 500 } 501 465 502 report->addItem(new BugReportFile(PathJoin(pszHome, "VirtualBox.xml"), "VirtualBox.xml")); 466 503 report->addItem(new BugReportCommand("HostUsbDevices", g_pszVBoxManage, "list", "usbhost", NULL)); … … 468 505 for (MachineInfoList::iterator it = machines.begin(); it != machines.end(); ++it) 469 506 { 470 report->addItem(new BugReportFile(PathJoin((*it)->getLogPath(), "VBox.log"), 471 PathJoin((*it)->getName(), "VBox.log"))); 507 VBRDir VmDir(PathJoin((*it)->getLogPath(), "VBox.log*")); 508 const char *pcszVmLogFile = HomeDir.next(); 509 while (pcszVmLogFile) 510 { 511 report->addItem(new BugReportFile(PathJoin((*it)->getLogPath(), pcszVmLogFile), 512 PathJoin((*it)->getName(), pcszVmLogFile))); 513 pcszVmLogFile = HomeDir.next(); 514 } 472 515 report->addItem(new BugReportFile((*it)->getSettingsFile(), 473 516 PathJoin((*it)->getName(), RTPathFilename((*it)->getSettingsFile())))); -
trunk/src/VBox/Frontends/VBoxBugReport/VBoxBugReportWin.cpp
r63295 r63703 29 29 #include <usbiodef.h> 30 30 #include <usbioctl.h> 31 #include <psapi.h> 31 32 32 33 #define ReleaseAndReset(obj) \ … … 561 562 } 562 563 564 class BugReportDriversWin : public BugReportStream 565 { 566 public: 567 BugReportDriversWin(); 568 virtual ~BugReportDriversWin(); 569 virtual PRTSTREAM getStream(void) { enumerateDrivers(); return BugReportStream::getStream(); } 570 private: 571 void enumerateDrivers(void); 572 573 WCHAR *m_pwszSystemRoot; 574 UINT m_cSystemRoot; 575 LPVOID *m_pDrivers; 576 DWORD m_cDrivers; 577 LPVOID m_pVerInfo; 578 DWORD m_cbVerInfo; 579 }; 580 581 BugReportDriversWin::BugReportDriversWin() : BugReportStream("DriverVersions") 582 { 583 m_cSystemRoot = MAX_PATH; 584 m_pwszSystemRoot = new WCHAR[MAX_PATH]; 585 m_cDrivers = 1024; 586 m_pDrivers = new LPVOID[m_cDrivers]; 587 m_pVerInfo = NULL; 588 m_cbVerInfo = 0; 589 } 590 591 BugReportDriversWin::~BugReportDriversWin() 592 { 593 if (m_pVerInfo) 594 RTMemTmpFree(m_pVerInfo); 595 delete[] m_pDrivers; 596 delete[] m_pwszSystemRoot; 597 } 598 599 void BugReportDriversWin::enumerateDrivers() 600 { 601 UINT cNeeded = GetWindowsDirectory(m_pwszSystemRoot, m_cSystemRoot); 602 if (cNeeded > m_cSystemRoot) 603 { 604 /* Re-allocate and try again */ 605 m_cSystemRoot = cNeeded; 606 delete[] m_pwszSystemRoot; 607 m_pwszSystemRoot = new WCHAR[m_cSystemRoot]; 608 cNeeded = GetWindowsDirectory(m_pwszSystemRoot, m_cSystemRoot); 609 } 610 if (cNeeded == 0) 611 handleWinError(GetLastError(), "GetWindowsDirectory failed"); 612 613 DWORD cbNeeded = 0; 614 if ( !EnumDeviceDrivers(m_pDrivers, m_cDrivers * sizeof(m_pDrivers[0]), &cbNeeded) 615 || cbNeeded > m_cDrivers * sizeof(m_pDrivers[0])) 616 { 617 /* Re-allocate and try again */ 618 m_cDrivers = cbNeeded / sizeof(m_pDrivers[0]); 619 delete[] m_pDrivers; 620 m_pDrivers = new LPVOID[m_cDrivers]; 621 if (!EnumDeviceDrivers(m_pDrivers, cbNeeded, &cbNeeded)) 622 handleWinError(GetLastError(), "EnumDeviceDrivers failed (%p, %u)", m_pDrivers, cbNeeded); 623 } 624 625 WCHAR wszDriver[1024]; 626 for (unsigned i = 0; i < m_cDrivers; i++) 627 { 628 if (GetDeviceDriverBaseName(m_pDrivers[i], wszDriver, RT_ELEMENTS(wszDriver))) 629 { 630 if (_wcsnicmp(L"vbox", wszDriver, 4)) 631 continue; 632 } 633 else 634 continue; 635 if (GetDeviceDriverFileName(m_pDrivers[i], wszDriver, RT_ELEMENTS(wszDriver))) 636 { 637 WCHAR wszTmpDrv[1024]; 638 WCHAR *pwszDrv = wszDriver; 639 if (!wcsncmp(L"\\SystemRoot", wszDriver, 11)) 640 { 641 wcsncpy_s(wszTmpDrv, m_pwszSystemRoot, m_cSystemRoot); 642 wcsncat_s(wszTmpDrv, wszDriver + 11, RT_ELEMENTS(wszTmpDrv) - m_cSystemRoot); 643 pwszDrv = wszTmpDrv; 644 } 645 else if (!wcsncmp(L"\\??\\", wszDriver, 4)) 646 pwszDrv = wszDriver + 4; 647 648 649 /* Allocate a buffer for version info. Reuse if large enough. */ 650 DWORD cbNewVerInfo = GetFileVersionInfoSize(pwszDrv, NULL); 651 if (cbNewVerInfo > m_cbVerInfo) 652 { 653 if (m_pVerInfo) 654 RTMemTmpFree(m_pVerInfo); 655 m_cbVerInfo = cbNewVerInfo; 656 m_pVerInfo = RTMemTmpAlloc(m_cbVerInfo); 657 if (!m_pVerInfo) 658 throw RTCError(RTCStringFmt("Failed to allocate %u bytes", m_cbVerInfo).c_str()); 659 } 660 661 if (GetFileVersionInfo(pwszDrv, NULL, m_cbVerInfo, m_pVerInfo)) 662 { 663 UINT cbSize = 0; 664 LPBYTE lpBuffer = NULL; 665 if (VerQueryValue(m_pVerInfo, L"\\", (VOID FAR* FAR*)&lpBuffer, &cbSize)) 666 { 667 if (cbSize) 668 { 669 VS_FIXEDFILEINFO *pFileInfo = (VS_FIXEDFILEINFO *)lpBuffer; 670 if (pFileInfo->dwSignature == 0xfeef04bd) 671 { 672 printf("%ls (Version: %d.%d.%d.%d)\n", pwszDrv, 673 (pFileInfo->dwFileVersionMS >> 16) & 0xffff, 674 (pFileInfo->dwFileVersionMS >> 0) & 0xffff, 675 (pFileInfo->dwFileVersionLS >> 16) & 0xffff, 676 (pFileInfo->dwFileVersionLS >> 0) & 0xffff); 677 } 678 else 679 printf("%ls - invalid signature\n", pwszDrv); 680 } 681 else 682 printf("%ls - version info size is 0\n", pwszDrv); 683 } 684 else 685 printf("%ls - failed to query version info size\n", pwszDrv); 686 } 687 else 688 printf("%ls - failed to get version info with 0x%x\n", pwszDrv, GetLastError()); 689 } 690 else 691 printf("%ls - GetDeviceDriverFileName failed with 0x%x\n", wszDriver, GetLastError()); 692 } 693 } 694 695 563 696 564 697 void createBugReportOsSpecific(BugReport* report, const char *pszHome) … … 587 720 "query", "type=", "driver", "state=", "all", NULL)); 588 721 report->addItem(new BugReportUsbTreeWin); 589 } 722 report->addItem(new BugReportDriversWin); 723 }
Note:
See TracChangeset
for help on using the changeset viewer.