Changeset 106393 in vbox for trunk/src/VBox/GuestHost
- Timestamp:
- Oct 16, 2024 3:28:46 PM (3 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/installation/VBoxWinDrvCommon.cpp
r106321 r106393 51 51 #endif 52 52 53 #include "VBoxWinDrvCommon.h"53 #include <VBox/GuestHost/VBoxWinDrvCommon.h> 54 54 55 55 … … 252 252 253 253 /** 254 * Queries the "Version" section of an INF file, extended version. 255 * 256 * @returns VBox status code. 257 * @param hInf INF handle to use. 258 * @param uIndex Index of version information to query. Usually 0. 259 * @param pVer Where to return the Version section information on success. 260 */ 261 int VBoxWinDrvInfQuerySectionVerEx(HINF hInf, UINT uIndex, PVBOXWINDRVINFSEC_VERSION pVer) 262 { 263 DWORD dwSize = 0; 264 bool fRc = SetupGetInfInformationW(hInf, INFINFO_INF_SPEC_IS_HINF, NULL, 0, &dwSize); 265 if (!fRc || !dwSize) 266 return VERR_NOT_FOUND; 267 268 int rc = VINF_SUCCESS; 269 270 PSP_INF_INFORMATION pInfo = (PSP_INF_INFORMATION)RTMemAlloc(dwSize); 271 AssertPtrReturn(pInfo, VERR_NO_MEMORY); 272 fRc = SetupGetInfInformationW(hInf, INFINFO_INF_SPEC_IS_HINF, pInfo, dwSize, NULL); 273 if (fRc) 274 { 275 if (pInfo->InfStyle == INF_STYLE_WIN4) 276 { 277 dwSize = 0; 278 fRc = SetupQueryInfVersionInformationW(pInfo, uIndex, NULL /* Key, NULL means all */, 279 NULL, 0, &dwSize); 280 if (fRc) 281 { 282 PRTUTF16 pwszInfo = (PRTUTF16)RTMemAlloc(dwSize * sizeof(RTUTF16)); 283 if (pwszInfo) 284 { 285 fRc = SetupQueryInfVersionInformationW(pInfo, uIndex, NULL /* Key, NULL means all */, 286 pwszInfo, dwSize, NULL); 287 288 /** Macro to find a specific key and assign its value to the given string. */ 289 #define GET_VALUE(a_Key, a_String) \ 290 if (!RTUtf16ICmp(pwsz, a_Key)) \ 291 { \ 292 rc = RTUtf16Printf(a_String, RT_ELEMENTS(a_String), "%ls", pwsz + cch + 1 /* SKip key + terminator */); \ 293 AssertRCBreak(rc); \ 294 } 295 PRTUTF16 pwsz = pwszInfo; 296 while (dwSize) 297 { 298 size_t const cch = RTUtf16Len(pwsz); 299 300 GET_VALUE(L"DriverVer", pVer->wszDriverVer); 301 GET_VALUE(L"Provider", pVer->wszProvider); 302 GET_VALUE(L"CatalogFile", pVer->wszCatalogFile); 303 304 dwSize -= (DWORD)cch + 1; 305 pwsz += cch + 1; 306 } 307 Assert(dwSize == 0); 308 #undef GET_VALUE 309 RTMemFree(pwszInfo); 310 } 311 else 312 rc = VERR_NO_MEMORY; 313 } 314 else 315 rc = RTErrConvertFromWin32(GetLastError()); 316 } 317 else /* Legacy INF files are not supported. */ 318 rc = VERR_NOT_SUPPORTED; 319 } 320 else 321 rc = RTErrConvertFromWin32(GetLastError()); 322 323 RTMemFree(pInfo); 324 return rc; 325 } 326 327 /** 328 * Queries the "Version" section of an INF file. 329 * 330 * @returns VBox status code. 331 * @param hInf INF handle to use. 332 * @param pVer Where to return the Version section information on success. 333 */ 334 int VBoxWinDrvInfQuerySectionVer(HINF hInf, PVBOXWINDRVINFSEC_VERSION pVer) 335 { 336 return VBoxWinDrvInfQuerySectionVerEx(hInf, 0 /* uIndex */, pVer); 337 } 338 339 /** 254 340 * Opens an INF file, extended version. 255 341 *
Note:
See TracChangeset
for help on using the changeset viewer.