Changeset 107901 in vbox
- Timestamp:
- Jan 22, 2025 10:21:48 PM (2 weeks ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/GuestHost/VBoxWinDrvDefs.h
r107076 r107901 1 1 /* $Id$ */ 2 2 /** @file 3 * VBoxWinDrvDefs - Common definitions for Windows driver functions.3 * VBoxWinDrvDefs - Common definitions for Windows driver installation functions. 4 4 */ 5 5 … … 85 85 * Structure for keeping INF Version section information. 86 86 */ 87 typedef struct _VBOXWINDRVINFSEC_VERSION87 typedef struct VBOXWINDRVINFSECVERSION 88 88 { 89 89 /** Catalog (.cat) file. */ … … 93 93 /** Provider name. */ 94 94 RTUTF16 wszProvider[VBOXWINDRVINF_MAX_PROVIDER_NAME_LEN]; 95 } VBOXWINDRVINFSEC _VERSION;95 } VBOXWINDRVINFSECVERSION; 96 96 /** Pointer to structure for keeping INF Version section information. */ 97 typedef VBOXWINDRVINFSEC _VERSION *PVBOXWINDRVINFSEC_VERSION;97 typedef VBOXWINDRVINFSECVERSION *PVBOXWINDRVINFSECVERSION; 98 98 99 99 #endif /* !VBOX_INCLUDED_GuestHost_VBoxWinDrvDefs_h */ -
trunk/include/VBox/GuestHost/VBoxWinDrvStore.h
r106395 r107901 57 57 * Structure for keeping a generic Windows driver store list. 58 58 */ 59 typedef struct _VBOXWINDRVSTORELIST59 typedef struct VBOXWINDRVSTORELIST 60 60 { 61 61 /** List node. */ … … 70 70 * Structure for keeping a Windows driver store entry. 71 71 */ 72 typedef struct _VBOXWINDRVSTOREENTRY72 typedef struct VBOXWINDRVSTOREENTRY 73 73 { 74 74 RTLISTNODE Node; 75 75 /** Version section information. */ 76 VBOXWINDRVINFSEC _VERSIONVer;76 VBOXWINDRVINFSECVERSION Ver; 77 77 /** Full path to the oemXXX.inf file within the driver store. */ 78 78 RTUTF16 wszInfFile[RTPATH_MAX]; … … 90 90 typedef VBOXWINDRVSTOREENTRY *PVBOXWINDRVSTOREENTRY; 91 91 92 struct _VBOXWINDRVSTORE;92 struct VBOXWINDRVSTORE; 93 93 /** Pointer to Windows driver store instance data. */ 94 typedef struct _VBOXWINDRVSTORE *PVBOXWINDRVSTORE;94 typedef struct VBOXWINDRVSTORE *PVBOXWINDRVSTORE; 95 95 96 96 /** 97 97 * Interface for a Windows driver store implementation. 98 98 */ 99 typedef struct _VBOXWINDRVSTOREIFACE99 typedef struct VBOXWINDRVSTOREIFACE 100 100 { 101 101 /** … … 133 133 * Enumeration for a driver store backend. 134 134 */ 135 typedef enum _VBOXWINDRVSTOREBACKENDTYPE135 typedef enum VBOXWINDRVSTOREBACKENDTYPE 136 136 { 137 137 /** Invalid. */ … … 146 146 * Currently only the (local) file system backend is supported. 147 147 */ 148 typedef struct _VBOXWINDRVSTOREBACKEND148 typedef struct VBOXWINDRVSTOREBACKEND 149 149 { 150 150 VBOXWINDRVSTOREBACKENDTYPE enmType; … … 165 165 * Structure for keeping Windows driver store instance data. 166 166 */ 167 typedef struct _VBOXWINDRVSTORE167 typedef struct VBOXWINDRVSTORE 168 168 { 169 169 /** The current list of drivers. */ -
trunk/src/VBox/GuestHost/installation/VBoxWinDrvCommon.cpp
r107395 r107901 1 1 /* $Id$ */ 2 2 /** @file 3 * VBoxWinDrvCommon - Common Windows driver functions.3 * VBoxWinDrvCommon - Common Windows driver installation functions. 4 4 */ 5 5 … … 52 52 53 53 /********************************************************************************************************************************* 54 * Defines *55 *********************************************************************************************************************************/56 57 58 /*********************************************************************************************************************************59 * Defined Constants And Macros *60 *********************************************************************************************************************************/61 62 63 /*********************************************************************************************************************************64 54 * Prototypes * 65 55 *********************************************************************************************************************************/ … … 77 67 VBOXWINDRVINFTYPE VBoxWinDrvInfGetTypeEx(HINF hInf, PRTUTF16 *ppwszSection) 78 68 { 69 if (ppwszSection) 70 *ppwszSection = NULL; 71 79 72 /* 80 73 * Regular driver? … … 133 126 if ( pwszManufacturerSection 134 127 && pwszPrimitiveSection) 135 {136 128 return VBOXWINDRVINFTYPE_INVALID; 137 } 138 else if (pwszManufacturerSection) 129 if (pwszManufacturerSection) 139 130 { 140 131 if (ppwszSection) 141 132 *ppwszSection = RTUtf16Dup(pwszManufacturerSection); 142 143 133 return VBOXWINDRVINFTYPE_NORMAL; 144 134 } 145 elseif (pwszPrimitiveSection)135 if (pwszPrimitiveSection) 146 136 { 147 137 if (ppwszSection) 148 138 *ppwszSection = RTUtf16Dup(pwszPrimitiveSection); 149 150 139 return VBOXWINDRVINFTYPE_PRIMITIVE; 151 140 } … … 189 178 * @param iValue Index to query. 190 179 * @param ppwszValue Where to return the value on success. 191 * @param pcwcValue Where to return the number of characters for \a ppwszValue. Optional an can be NULL. 180 * @param pcwcValue Where to return the number of characters in the 181 * string returned via \a ppwszValue, including the 182 * zero terminator. Optional and can be NULL. 192 183 */ 193 184 int VBoxWinDrvInfQueryKeyValue(PINFCONTEXT pCtx, DWORD iValue, PRTUTF16 *ppwszValue, PDWORD pcwcValue) … … 231 222 * Currently only the first model (index 0) is supported. 232 223 * @param ppwszValue Where to return the model name on success. 233 * @param pcwcValue Where to return the number of characters for \a ppwszValue. Optional an can be NULL. 224 * @param pcwcValue Where to return the number of characters in the 225 * string returned via \a ppwszValue, including the 226 * zero terminator. Optional and can be NULL. 234 227 */ 235 228 int VBoxWinDrvInfQueryModelEx(HINF hInf, PCRTUTF16 pwszSection, unsigned uIndex, PRTUTF16 *ppwszValue, PDWORD pcwcValue) 236 229 { 237 AssertPtrReturn(pwszSection, VERR_INVALID_POINTER);238 AssertReturn(uIndex == 0, VERR_INVALID_PARAMETER);239 240 230 *ppwszValue = NULL; 241 231 if (pcwcValue) 242 232 *pcwcValue = 0; 243 244 int rc = VINF_SUCCESS;233 AssertPtrReturn(pwszSection, VERR_INVALID_POINTER); 234 AssertReturn(uIndex == 0, VERR_INVALID_PARAMETER); 245 235 246 236 INFCONTEXT InfCtx; 247 rc = vboxWinDrvInfQueryContext(hInf, pwszSection, NULL, &InfCtx);237 int rc = vboxWinDrvInfQueryContext(hInf, pwszSection, NULL, &InfCtx); 248 238 if (RT_FAILURE(rc)) 249 239 return rc; … … 255 245 return rc; 256 246 257 PRTUTF16 pwszResult = NULL;258 DWORD cwcResult = 0;259 260 247 PRTUTF16 pwszPlatform = NULL; 261 248 DWORD cwcPlatform; … … 270 257 { 271 258 RTUTF16 wszSection[VBOXWINDRVINF_MAX_SECTION_NAME_LEN]; 272 rc = RTUtf16Copy(wszSection, sizeof(wszSection), pwszModel);259 rc = RTUtf16Copy(wszSection, RT_ELEMENTS(wszSection), pwszModel); 273 260 if (RT_SUCCESS(rc)) 274 261 { 275 rc = RTUtf16Cat(wszSection, sizeof(wszSection), VBOXWINDRVINF_DECORATION_SEP_UTF16_STR);262 rc = RTUtf16Cat(wszSection, RT_ELEMENTS(wszSection), VBOXWINDRVINF_DECORATION_SEP_UTF16_STR); 276 263 if (RT_SUCCESS(rc)) 277 264 { 278 rc = RTUtf16Cat(wszSection, sizeof(wszSection), pwszPlatform);265 rc = RTUtf16Cat(wszSection, RT_ELEMENTS(wszSection), pwszPlatform); 279 266 if (RT_SUCCESS(rc)) 280 267 { 281 pwszResult = RTUtf16Dup(wszSection); 268 /** @todo r=bird: Mixing RTMemAlloc and RTUtf16Dup/RTUtf16Alloc is not 269 * allowed because of RTMEM_WRAP_TO_EF_APIS and other reasons! */ 270 PRTUTF16 pwszResult = RTUtf16Dup(wszSection); 282 271 if (pwszResult) 283 272 { 284 cwcResult = (DWORD)RTUtf16Len(wszSection); 273 *ppwszValue = pwszResult; 274 if (pcwcValue) 275 *pcwcValue = (DWORD)(RTUtf16Len(wszSection) + 1); 285 276 } 286 277 else … … 292 283 else 293 284 rc = VERR_PLATFORM_ARCH_NOT_SUPPORTED; 294 } 295 else /* Model w/o platform. */ 296 { 297 pwszResult = pwszModel; 298 cwcResult = cwcModels; 299 pwszModel = NULL; 300 285 RTMemFree(pwszPlatform); 286 RTMemFree(pwszModel); 287 } 288 else 289 { 290 /* Model without platform - just return the pwszModel string. */ 291 *ppwszValue = pwszModel; 292 if (pcwcValue) 293 *pcwcValue = cwcModels; 301 294 rc = VINF_SUCCESS; 302 }303 304 RTMemFree(pwszModel);305 RTMemFree(pwszPlatform);306 307 if (RT_SUCCESS(rc))308 {309 *ppwszValue = pwszResult;310 if (pcwcValue)311 *pcwcValue = cwcResult;312 295 } 313 296 … … 338 321 * @param pVer Where to return the Version section information on success. 339 322 */ 340 int VBoxWinDrvInfQuerySectionVerEx(HINF hInf, UINT uIndex, PVBOXWINDRVINFSEC _VERSION pVer)323 int VBoxWinDrvInfQuerySectionVerEx(HINF hInf, UINT uIndex, PVBOXWINDRVINFSECVERSION pVer) 341 324 { 342 325 DWORD dwSize = 0; … … 345 328 return VERR_NOT_FOUND; 346 329 347 int rc = VINF_SUCCESS;348 349 PSP_INF_INFORMATION pInfo = (PSP_INF_INFORMATION)RTMemAlloc (dwSize);330 int rc; 331 332 PSP_INF_INFORMATION pInfo = (PSP_INF_INFORMATION)RTMemAllocZ(dwSize); 350 333 AssertPtrReturn(pInfo, VERR_NO_MEMORY); 351 334 fRc = SetupGetInfInformationW(hInf, INFINFO_INF_SPEC_IS_HINF, pInfo, dwSize, NULL); … … 354 337 if (pInfo->InfStyle == INF_STYLE_WIN4) 355 338 { 339 /* 340 * We query all the keys and values for the given index. 341 */ 356 342 dwSize = 0; 357 343 fRc = SetupQueryInfVersionInformationW(pInfo, uIndex, NULL /* Key, NULL means all */, … … 359 345 if (fRc) 360 346 { 361 PRTUTF16 pwsz Info = (PRTUTF16)RTMemAlloc(dwSize * sizeof(RTUTF16));362 if (pwsz Info)347 PRTUTF16 pwszzInfo = (PRTUTF16)RTMemAllocZ(dwSize * sizeof(RTUTF16)); 348 if (pwszzInfo) 363 349 { 364 350 fRc = SetupQueryInfVersionInformationW(pInfo, uIndex, NULL /* Key, NULL means all */, 365 pwszInfo, dwSize, NULL); 351 pwszzInfo, dwSize, NULL); 352 if (fRc) 353 { 354 /* 355 * Parse the block of "key1\0value1\0\key2\0\value2\0....\0\0" strings, 356 * snapping up stuff we know. 357 */ 358 rc = VINF_SUCCESS; 359 size_t off = 0; 360 while (off < dwSize) 361 { 362 PRTUTF16 const pwszKey = &pwszzInfo[off]; 363 size_t const cwcKey = RTUtf16NLen(pwszKey, dwSize - off); 364 off += cwcKey + 1; 365 if (off >= dwSize) 366 break; 367 PRTUTF16 const pwszValue = &pwszzInfo[off]; 368 size_t const cwcValue = RTUtf16NLen(pwszValue, dwSize - off); 369 off += cwcValue + 1; 366 370 367 371 /** Macro to find a specific key and assign its value to the given string. */ 368 #define GET_VALUE(a_ Key, a_String) \369 if (!RTUtf16ICmp(pwsz , a_Key)) \372 #define GET_VALUE(a_wszKey, a_wszDst) \ 373 if (!RTUtf16ICmp(pwszKey, a_wszKey)) \ 370 374 { \ 371 rc = RTUtf16 Printf(a_String, RT_ELEMENTS(a_String), "%ls", pwsz + cch + 1 /* SKip key + terminator */); \375 rc = RTUtf16CopyEx(a_wszDst, RT_ELEMENTS(a_wszDst), pwszValue, cwcValue); \ 372 376 AssertRCBreak(rc); \ 373 377 } 374 PRTUTF16 pwsz = pwszInfo; 375 while (dwSize) 376 { 377 size_t const cch = RTUtf16Len(pwsz); 378 379 GET_VALUE(L"DriverVer", pVer->wszDriverVer); 380 GET_VALUE(L"Provider", pVer->wszProvider); 381 GET_VALUE(L"CatalogFile", pVer->wszCatalogFile); 382 383 dwSize -= (DWORD)cch + 1; 384 pwsz += cch + 1; 378 GET_VALUE(L"DriverVer", pVer->wszDriverVer); 379 GET_VALUE(L"Provider", pVer->wszProvider); 380 GET_VALUE(L"CatalogFile", pVer->wszCatalogFile); 381 #undef GET_VALUE 382 } 383 Assert(off == dwSize); 385 384 } 386 Assert(dwSize == 0);387 #undef GET_VALUE 388 RTMemFree(pwsz Info);385 else 386 rc = VBoxWinDrvInstErrorFromWin32(GetLastError()); 387 RTMemFree(pwszzInfo); 389 388 } 390 389 else … … 411 410 * @param pVer Where to return the Version section information on success. 412 411 */ 413 int VBoxWinDrvInfQuerySectionVer(HINF hInf, PVBOXWINDRVINFSEC _VERSION pVer)412 int VBoxWinDrvInfQuerySectionVer(HINF hInf, PVBOXWINDRVINFSECVERSION pVer) 414 413 { 415 414 return VBoxWinDrvInfQuerySectionVerEx(hInf, 0 /* uIndex */, pVer); … … 427 426 { 428 427 HINF hInf = SetupOpenInfFileW(pwszInfFile, pwszClassName, INF_STYLE_WIN4, NULL /*__in PUINT ErrorLine */); 429 if (hInf == INVALID_HANDLE_VALUE) 428 *phInf = hInf; 429 if (hInf != INVALID_HANDLE_VALUE) 430 430 return VBoxWinDrvInstErrorFromWin32(GetLastError()); 431 432 *phInf = hInf;433 434 431 return VINF_SUCCESS; 435 432 } … … 446 443 int VBoxWinDrvInfOpen(PCRTUTF16 pwszInfFile, HINF *phInf) 447 444 { 448 int rc; 449 445 int rc; 450 446 GUID guid = {}; 451 RTUTF16 pwszClassName[MAX_CLASS_NAME_LEN] = { }; 452 if (SetupDiGetINFClassW(pwszInfFile, &guid, &(pwszClassName[0]), sizeof(pwszClassName), NULL)) 453 { 454 rc = VBoxWinDrvInfOpenEx(pwszInfFile, pwszClassName, phInf); 455 } 447 RTUTF16 wszClassName[MAX_CLASS_NAME_LEN] = {}; 448 if (SetupDiGetINFClassW(pwszInfFile, &guid, wszClassName, RT_ELEMENTS(wszClassName), NULL)) 449 rc = VBoxWinDrvInfOpenEx(pwszInfFile, wszClassName, phInf); 456 450 else 457 451 rc = VBoxWinDrvInstErrorFromWin32(GetLastError()); 458 459 452 return rc; 460 453 } -
trunk/src/VBox/GuestHost/installation/VBoxWinDrvCommon.h
r106890 r107901 68 68 int VBoxWinDrvInfQueryInstallSectionEx(HINF hInf, PCRTUTF16 pwszModel, PRTUTF16 *ppwszValue, PDWORD pcwcValue); 69 69 int VBoxWinDrvInfQueryInstallSection(HINF hInf, PCRTUTF16 pwszModel, PRTUTF16 *ppwszValue); 70 int VBoxWinDrvInfQuerySectionVerEx(HINF hInf, UINT uIndex, PVBOXWINDRVINFSEC _VERSION pVer);71 int VBoxWinDrvInfQuerySectionVer(HINF hInf, PVBOXWINDRVINFSEC _VERSION pVer);70 int VBoxWinDrvInfQuerySectionVerEx(HINF hInf, UINT uIndex, PVBOXWINDRVINFSECVERSION pVer); 71 int VBoxWinDrvInfQuerySectionVer(HINF hInf, PVBOXWINDRVINFSECVERSION pVer); 72 72 73 73 const char *VBoxWinDrvSetupApiErrToStr(const DWORD dwErr);
Note:
See TracChangeset
for help on using the changeset viewer.