Changeset 55314 in vbox
- Timestamp:
- Apr 16, 2015 5:13:00 PM (10 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/Makefile.kmk
r55182 r55314 677 677 $(VBOX_LIB_VMM_LAZY) 678 678 VBoxC_LIBS.win += \ 679 $(PATH_SDK_$(VBOX_WINPSDK)_LIB)/psapi.lib \ 679 680 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/delayimp.lib 680 681 ifdef VBOX_WITH_NETFLT -
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r55259 r55314 819 819 820 820 821 #ifdef RT_OS_WINDOWS 822 #include <psapi.h> 823 824 /** 825 * Report versions of installed drivers to release log. 826 */ 827 static void reportDriverVersions(void) 828 { 829 DWORD err; 830 HRESULT hrc; 831 LPVOID aDrivers[1024]; 832 LPVOID *pDrivers = aDrivers; 833 UINT cNeeded = 0; 834 TCHAR szSystemRoot[MAX_PATH]; 835 TCHAR *pszSystemRoot = szSystemRoot; 836 LPVOID pVerInfo = NULL; 837 DWORD cbVerInfo = 0; 838 839 do 840 { 841 cNeeded = GetWindowsDirectory(szSystemRoot, RT_ELEMENTS(szSystemRoot)); 842 if (cNeeded == 0) 843 { 844 err = GetLastError(); 845 hrc = HRESULT_FROM_WIN32(err); 846 AssertLogRelMsgFailed(("GetWindowsDirectory failed, hr=%Rhrc (0x%x) err=%u\n", 847 hrc, hrc, err)); 848 break; 849 } 850 else if (cNeeded > RT_ELEMENTS(szSystemRoot)) 851 { 852 /* The buffer is too small, allocate big one. */ 853 pszSystemRoot = (TCHAR *)RTMemTmpAlloc(cNeeded * sizeof(_TCHAR)); 854 if (!pszSystemRoot) 855 { 856 AssertLogRelMsgFailed(("RTMemTmpAlloc failed to allocate %d bytes\n", cNeeded)); 857 break; 858 } 859 if (GetWindowsDirectory(pszSystemRoot, cNeeded) == 0) 860 { 861 err = GetLastError(); 862 hrc = HRESULT_FROM_WIN32(err); 863 AssertLogRelMsgFailed(("GetWindowsDirectory failed, hr=%Rhrc (0x%x) err=%u\n", 864 hrc, hrc, err)); 865 break; 866 } 867 } 868 869 DWORD cbNeeded = 0; 870 if (!EnumDeviceDrivers(aDrivers, sizeof(aDrivers), &cbNeeded) || cbNeeded > sizeof(aDrivers)) 871 { 872 pDrivers = (LPVOID *)RTMemTmpAlloc(cbNeeded); 873 if (!EnumDeviceDrivers(pDrivers, cbNeeded, &cbNeeded)) 874 { 875 err = GetLastError(); 876 hrc = HRESULT_FROM_WIN32(err); 877 AssertLogRelMsgFailed(("EnumDeviceDrivers failed, hr=%Rhrc (0x%x) err=%u\n", 878 hrc, hrc, err)); 879 break; 880 } 881 } 882 883 LogRel(("Installed Drivers:\n")); 884 885 TCHAR szDriver[1024]; 886 int cDrivers = cbNeeded / sizeof(pDrivers[0]); 887 for (int i = 0; i < cDrivers; i++) 888 { 889 if (GetDeviceDriverBaseName(pDrivers[i], szDriver, sizeof(szDriver) / sizeof(szDriver[0]))) 890 { 891 if (_tcsnicmp(TEXT("vbox"), szDriver, 4)) 892 continue; 893 } 894 else 895 continue; 896 if (GetDeviceDriverFileName(pDrivers[i], szDriver, sizeof(szDriver) / sizeof(szDriver[0]))) 897 { 898 _TCHAR szTmpDrv[1024]; 899 _TCHAR *pszDrv = szDriver; 900 if (!_tcsncmp(TEXT("\\SystemRoot"), szDriver, 11)) 901 { 902 _tcscpy_s(szTmpDrv, pszSystemRoot); 903 _tcsncat_s(szTmpDrv, szDriver + 11, sizeof(szTmpDrv) / sizeof(szTmpDrv[0]) - _tclen(pszSystemRoot)); 904 pszDrv = szTmpDrv; 905 } 906 else if (!_tcsncmp(TEXT("\\??\\"), szDriver, 4)) 907 pszDrv = szDriver + 4; 908 909 /* Allocate a buffer for version info. Reuse if large enough. */ 910 DWORD cbNewVerInfo = GetFileVersionInfoSize(pszDrv, NULL); 911 if (cbNewVerInfo > cbVerInfo) 912 { 913 if (pVerInfo) 914 RTMemTmpFree(pVerInfo); 915 cbVerInfo = cbNewVerInfo; 916 pVerInfo = RTMemTmpAlloc(cbVerInfo); 917 if (!pVerInfo) 918 { 919 AssertLogRelMsgFailed(("RTMemTmpAlloc failed to allocate %d bytes\n", cbVerInfo)); 920 break; 921 } 922 } 923 924 if (GetFileVersionInfo(pszDrv, NULL, cbVerInfo, pVerInfo)) 925 { 926 UINT cbSize = 0; 927 LPBYTE lpBuffer = NULL; 928 if (VerQueryValue(pVerInfo, TEXT("\\"), (VOID FAR* FAR*)&lpBuffer, &cbSize)) 929 { 930 if (cbSize) 931 { 932 VS_FIXEDFILEINFO *pFileInfo = (VS_FIXEDFILEINFO *)lpBuffer; 933 if (pFileInfo->dwSignature == 0xfeef04bd) 934 { 935 LogRel((" %ls (Version: %d.%d.%d.%d)\n", pszDrv, 936 (pFileInfo->dwFileVersionMS >> 16) & 0xffff, 937 (pFileInfo->dwFileVersionMS >> 0) & 0xffff, 938 (pFileInfo->dwFileVersionLS >> 16) & 0xffff, 939 (pFileInfo->dwFileVersionLS >> 0) & 0xffff)); 940 } 941 } 942 } 943 } 944 } 945 } 946 947 } 948 while (0); 949 950 if (pVerInfo) 951 RTMemTmpFree(pVerInfo); 952 953 if (pDrivers != aDrivers) 954 RTMemTmpFree(pDrivers); 955 956 if (pszSystemRoot != szSystemRoot) 957 RTMemTmpFree(pszSystemRoot); 958 } 959 #else /* !RT_OS_WINDOWS */ 960 static void reportDriverVersions(void) 961 { 962 } 963 #endif /* !RT_OS_WINDOWS */ 964 965 821 966 /** 822 967 * Worker for configConstructor. … … 910 1055 ULONG maxNetworkAdapters; 911 1056 hrc = systemProperties->GetMaxNetworkAdapters(chipsetType, &maxNetworkAdapters); H(); 1057 1058 reportDriverVersions(); 912 1059 /* 913 1060 * Get root node first.
Note:
See TracChangeset
for help on using the changeset viewer.