Changeset 59571 in vbox for trunk/src/VBox/Main
- Timestamp:
- Feb 3, 2016 2:02:46 PM (9 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/ConsoleImpl.h
r59117 r59571 822 822 /** @} */ 823 823 824 void i_reportDriverVersions(void);825 826 824 bool mSavedStateDataLoaded : 1; 827 825 -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r59087 r59571 364 364 size_t aPlaintextSize, 365 365 size_t aCiphertextSize) const; 366 void i_reportDriverVersions(void); 366 367 367 368 struct Data; // opaque data structure, defined in VirtualBoxImpl.cpp -
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r59341 r59571 746 746 747 747 748 #ifdef RT_OS_WINDOWS749 #include <psapi.h>750 751 /**752 * Report versions of installed drivers to release log.753 */754 void Console::i_reportDriverVersions()755 {756 DWORD err;757 HRESULT hrc;758 LPVOID aDrivers[1024];759 LPVOID *pDrivers = aDrivers;760 UINT cNeeded = 0;761 TCHAR szSystemRoot[MAX_PATH];762 TCHAR *pszSystemRoot = szSystemRoot;763 LPVOID pVerInfo = NULL;764 DWORD cbVerInfo = 0;765 766 do767 {768 cNeeded = GetWindowsDirectory(szSystemRoot, RT_ELEMENTS(szSystemRoot));769 if (cNeeded == 0)770 {771 err = GetLastError();772 hrc = HRESULT_FROM_WIN32(err);773 AssertLogRelMsgFailed(("GetWindowsDirectory failed, hr=%Rhrc (0x%x) err=%u\n",774 hrc, hrc, err));775 break;776 }777 else if (cNeeded > RT_ELEMENTS(szSystemRoot))778 {779 /* The buffer is too small, allocate big one. */780 pszSystemRoot = (TCHAR *)RTMemTmpAlloc(cNeeded * sizeof(_TCHAR));781 if (!pszSystemRoot)782 {783 AssertLogRelMsgFailed(("RTMemTmpAlloc failed to allocate %d bytes\n", cNeeded));784 break;785 }786 if (GetWindowsDirectory(pszSystemRoot, cNeeded) == 0)787 {788 err = GetLastError();789 hrc = HRESULT_FROM_WIN32(err);790 AssertLogRelMsgFailed(("GetWindowsDirectory failed, hr=%Rhrc (0x%x) err=%u\n",791 hrc, hrc, err));792 break;793 }794 }795 796 DWORD cbNeeded = 0;797 if (!EnumDeviceDrivers(aDrivers, sizeof(aDrivers), &cbNeeded) || cbNeeded > sizeof(aDrivers))798 {799 pDrivers = (LPVOID *)RTMemTmpAlloc(cbNeeded);800 if (!EnumDeviceDrivers(pDrivers, cbNeeded, &cbNeeded))801 {802 err = GetLastError();803 hrc = HRESULT_FROM_WIN32(err);804 AssertLogRelMsgFailed(("EnumDeviceDrivers failed, hr=%Rhrc (0x%x) err=%u\n",805 hrc, hrc, err));806 break;807 }808 }809 810 LogRel(("Installed Drivers:\n"));811 812 TCHAR szDriver[1024];813 int cDrivers = cbNeeded / sizeof(pDrivers[0]);814 for (int i = 0; i < cDrivers; i++)815 {816 if (GetDeviceDriverBaseName(pDrivers[i], szDriver, sizeof(szDriver) / sizeof(szDriver[0])))817 {818 if (_tcsnicmp(TEXT("vbox"), szDriver, 4))819 continue;820 }821 else822 continue;823 if (GetDeviceDriverFileName(pDrivers[i], szDriver, sizeof(szDriver) / sizeof(szDriver[0])))824 {825 _TCHAR szTmpDrv[1024];826 _TCHAR *pszDrv = szDriver;827 if (!_tcsncmp(TEXT("\\SystemRoot"), szDriver, 11))828 {829 _tcscpy_s(szTmpDrv, pszSystemRoot);830 _tcsncat_s(szTmpDrv, szDriver + 11, sizeof(szTmpDrv) / sizeof(szTmpDrv[0]) - _tclen(pszSystemRoot));831 pszDrv = szTmpDrv;832 }833 else if (!_tcsncmp(TEXT("\\??\\"), szDriver, 4))834 pszDrv = szDriver + 4;835 836 /* Allocate a buffer for version info. Reuse if large enough. */837 DWORD cbNewVerInfo = GetFileVersionInfoSize(pszDrv, NULL);838 if (cbNewVerInfo > cbVerInfo)839 {840 if (pVerInfo)841 RTMemTmpFree(pVerInfo);842 cbVerInfo = cbNewVerInfo;843 pVerInfo = RTMemTmpAlloc(cbVerInfo);844 if (!pVerInfo)845 {846 AssertLogRelMsgFailed(("RTMemTmpAlloc failed to allocate %d bytes\n", cbVerInfo));847 break;848 }849 }850 851 if (GetFileVersionInfo(pszDrv, NULL, cbVerInfo, pVerInfo))852 {853 UINT cbSize = 0;854 LPBYTE lpBuffer = NULL;855 if (VerQueryValue(pVerInfo, TEXT("\\"), (VOID FAR* FAR*)&lpBuffer, &cbSize))856 {857 if (cbSize)858 {859 VS_FIXEDFILEINFO *pFileInfo = (VS_FIXEDFILEINFO *)lpBuffer;860 if (pFileInfo->dwSignature == 0xfeef04bd)861 {862 LogRel((" %ls (Version: %d.%d.%d.%d)\n", pszDrv,863 (pFileInfo->dwFileVersionMS >> 16) & 0xffff,864 (pFileInfo->dwFileVersionMS >> 0) & 0xffff,865 (pFileInfo->dwFileVersionLS >> 16) & 0xffff,866 (pFileInfo->dwFileVersionLS >> 0) & 0xffff));867 }868 }869 }870 }871 }872 }873 874 }875 while (0);876 877 if (pVerInfo)878 RTMemTmpFree(pVerInfo);879 880 if (pDrivers != aDrivers)881 RTMemTmpFree(pDrivers);882 883 if (pszSystemRoot != szSystemRoot)884 RTMemTmpFree(pszSystemRoot);885 }886 #else /* !RT_OS_WINDOWS */887 void Console::i_reportDriverVersions(void)888 {889 }890 #endif /* !RT_OS_WINDOWS */891 892 893 748 /** 894 749 * Worker for configConstructor. … … 986 841 hrc = systemProperties->GetMaxNetworkAdapters(chipsetType, &maxNetworkAdapters); H(); 987 842 988 i_reportDriverVersions();989 843 /* 990 844 * Get root node first. -
trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp
r59087 r59571 386 386 387 387 LogRel(("Home directory: '%s'\n", m->strHomeDir.c_str())); 388 389 i_reportDriverVersions(); 388 390 389 391 /* compose the VirtualBox.xml file name */ … … 5279 5281 #endif 5280 5282 } 5283 5284 5285 #ifdef RT_OS_WINDOWS 5286 #include <psapi.h> 5287 5288 /** 5289 * Report versions of installed drivers to release log. 5290 */ 5291 void VirtualBox::i_reportDriverVersions() 5292 { 5293 DWORD err; 5294 HRESULT hrc; 5295 LPVOID aDrivers[1024]; 5296 LPVOID *pDrivers = aDrivers; 5297 UINT cNeeded = 0; 5298 TCHAR szSystemRoot[MAX_PATH]; 5299 TCHAR *pszSystemRoot = szSystemRoot; 5300 LPVOID pVerInfo = NULL; 5301 DWORD cbVerInfo = 0; 5302 5303 do 5304 { 5305 cNeeded = GetWindowsDirectory(szSystemRoot, RT_ELEMENTS(szSystemRoot)); 5306 if (cNeeded == 0) 5307 { 5308 err = GetLastError(); 5309 hrc = HRESULT_FROM_WIN32(err); 5310 AssertLogRelMsgFailed(("GetWindowsDirectory failed, hr=%Rhrc (0x%x) err=%u\n", 5311 hrc, hrc, err)); 5312 break; 5313 } 5314 else if (cNeeded > RT_ELEMENTS(szSystemRoot)) 5315 { 5316 /* The buffer is too small, allocate big one. */ 5317 pszSystemRoot = (TCHAR *)RTMemTmpAlloc(cNeeded * sizeof(_TCHAR)); 5318 if (!pszSystemRoot) 5319 { 5320 AssertLogRelMsgFailed(("RTMemTmpAlloc failed to allocate %d bytes\n", cNeeded)); 5321 break; 5322 } 5323 if (GetWindowsDirectory(pszSystemRoot, cNeeded) == 0) 5324 { 5325 err = GetLastError(); 5326 hrc = HRESULT_FROM_WIN32(err); 5327 AssertLogRelMsgFailed(("GetWindowsDirectory failed, hr=%Rhrc (0x%x) err=%u\n", 5328 hrc, hrc, err)); 5329 break; 5330 } 5331 } 5332 5333 DWORD cbNeeded = 0; 5334 if (!EnumDeviceDrivers(aDrivers, sizeof(aDrivers), &cbNeeded) || cbNeeded > sizeof(aDrivers)) 5335 { 5336 pDrivers = (LPVOID *)RTMemTmpAlloc(cbNeeded); 5337 if (!EnumDeviceDrivers(pDrivers, cbNeeded, &cbNeeded)) 5338 { 5339 err = GetLastError(); 5340 hrc = HRESULT_FROM_WIN32(err); 5341 AssertLogRelMsgFailed(("EnumDeviceDrivers failed, hr=%Rhrc (0x%x) err=%u\n", 5342 hrc, hrc, err)); 5343 break; 5344 } 5345 } 5346 5347 LogRel(("Installed Drivers:\n")); 5348 5349 TCHAR szDriver[1024]; 5350 int cDrivers = cbNeeded / sizeof(pDrivers[0]); 5351 for (int i = 0; i < cDrivers; i++) 5352 { 5353 if (GetDeviceDriverBaseName(pDrivers[i], szDriver, sizeof(szDriver) / sizeof(szDriver[0]))) 5354 { 5355 if (_tcsnicmp(TEXT("vbox"), szDriver, 4)) 5356 continue; 5357 } 5358 else 5359 continue; 5360 if (GetDeviceDriverFileName(pDrivers[i], szDriver, sizeof(szDriver) / sizeof(szDriver[0]))) 5361 { 5362 _TCHAR szTmpDrv[1024]; 5363 _TCHAR *pszDrv = szDriver; 5364 if (!_tcsncmp(TEXT("\\SystemRoot"), szDriver, 11)) 5365 { 5366 _tcscpy_s(szTmpDrv, pszSystemRoot); 5367 _tcsncat_s(szTmpDrv, szDriver + 11, sizeof(szTmpDrv) / sizeof(szTmpDrv[0]) - _tclen(pszSystemRoot)); 5368 pszDrv = szTmpDrv; 5369 } 5370 else if (!_tcsncmp(TEXT("\\??\\"), szDriver, 4)) 5371 pszDrv = szDriver + 4; 5372 5373 /* Allocate a buffer for version info. Reuse if large enough. */ 5374 DWORD cbNewVerInfo = GetFileVersionInfoSize(pszDrv, NULL); 5375 if (cbNewVerInfo > cbVerInfo) 5376 { 5377 if (pVerInfo) 5378 RTMemTmpFree(pVerInfo); 5379 cbVerInfo = cbNewVerInfo; 5380 pVerInfo = RTMemTmpAlloc(cbVerInfo); 5381 if (!pVerInfo) 5382 { 5383 AssertLogRelMsgFailed(("RTMemTmpAlloc failed to allocate %d bytes\n", cbVerInfo)); 5384 break; 5385 } 5386 } 5387 5388 if (GetFileVersionInfo(pszDrv, NULL, cbVerInfo, pVerInfo)) 5389 { 5390 UINT cbSize = 0; 5391 LPBYTE lpBuffer = NULL; 5392 if (VerQueryValue(pVerInfo, TEXT("\\"), (VOID FAR* FAR*)&lpBuffer, &cbSize)) 5393 { 5394 if (cbSize) 5395 { 5396 VS_FIXEDFILEINFO *pFileInfo = (VS_FIXEDFILEINFO *)lpBuffer; 5397 if (pFileInfo->dwSignature == 0xfeef04bd) 5398 { 5399 LogRel((" %ls (Version: %d.%d.%d.%d)\n", pszDrv, 5400 (pFileInfo->dwFileVersionMS >> 16) & 0xffff, 5401 (pFileInfo->dwFileVersionMS >> 0) & 0xffff, 5402 (pFileInfo->dwFileVersionLS >> 16) & 0xffff, 5403 (pFileInfo->dwFileVersionLS >> 0) & 0xffff)); 5404 } 5405 } 5406 } 5407 } 5408 } 5409 } 5410 5411 } 5412 while (0); 5413 5414 if (pVerInfo) 5415 RTMemTmpFree(pVerInfo); 5416 5417 if (pDrivers != aDrivers) 5418 RTMemTmpFree(pDrivers); 5419 5420 if (pszSystemRoot != szSystemRoot) 5421 RTMemTmpFree(pszSystemRoot); 5422 } 5423 #else /* !RT_OS_WINDOWS */ 5424 void VirtualBox::i_reportDriverVersions(void) 5425 { 5426 } 5427 #endif /* !RT_OS_WINDOWS */ 5428 5281 5429 /* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note:
See TracChangeset
for help on using the changeset viewer.