- Timestamp:
- Nov 7, 2024 9:40:41 AM (3 weeks ago)
- Location:
- trunk/src/VBox/GuestHost/installation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/installation/VBoxWinDrvCommon.cpp
r106839 r106869 37 37 #include <iprt/assert.h> 38 38 #include <iprt/dir.h> 39 #include <iprt/errcore.h>40 39 #include <iprt/ldr.h> 41 40 #include <iprt/list.h> … … 47 46 #include <iprt/utf16.h> 48 47 49 #ifdef DEBUG 50 # include <iprt/stream.h> 51 #endif 48 #include <VBox/err.h> /* For VERR_PLATFORM_ARCH_NOT_SUPPORTED.*/ 52 49 53 50 #include "VBoxWinDrvCommon.h" … … 136 133 137 134 /** 138 * Queries for the model name inan INF file.135 * Queries a model name from an INF file. 139 136 * 140 137 * @returns VBox status code. 141 138 * @retval VERR_NOT_FOUND if no model has been found. 142 139 * @param hInf INF handle to use. 140 * @param uIndex Index of model to query. 141 * Currently only the first model (index 0) is supported. 143 142 * @param ppwszValue Where to return the model name on success. 144 143 * @param pcwcValue Where to return the number of characters for \a ppwszValue. Optional an can be NULL. … … 146 145 * @note Only for non-"primitive" drivers. 147 146 */ 148 int VBoxWinDrvInfQueryModelsSectionName(HINF hInf, PRTUTF16 *ppwszValue, PDWORD pcwcValue) 149 { 147 int VBoxWinDrvInfQueryModel(HINF hInf, unsigned uIndex, PRTUTF16 *ppwszValue, PDWORD pcwcValue) 148 { 149 AssertReturn(uIndex == 0, VERR_INVALID_PARAMETER); 150 150 151 *ppwszValue = NULL; 151 152 if (pcwcValue) … … 176 177 return rc; 177 178 178 LPWSTR pwszModels;179 DWORD cwcModels;180 rc = VBoxWinDrvInfQueryKeyValue(&InfCtx, 1, &pwszModel s, &cwcModels);179 PRTUTF16 pwszModel; 180 DWORD cwcModels; 181 rc = VBoxWinDrvInfQueryKeyValue(&InfCtx, 1, &pwszModel, &cwcModels); 181 182 if (RT_FAILURE(rc)) 182 183 return rc; 183 184 184 LPWSTR pwszPlatform = NULL; 185 DWORD cwcPlatform = 0; 186 bool fArch = false; 187 bool fNt = false; 188 189 LPWSTR pwszPlatformCur; 190 DWORD cwcPlatformCur; 191 for (DWORD i = 2; (rc = VBoxWinDrvInfQueryKeyValue(&InfCtx, i, &pwszPlatformCur, &cwcPlatformCur)) == VINF_SUCCESS; ++i) 192 { 193 if (RTUtf16ICmpAscii(pwszPlatformCur, "NT" VBOXWINDRVINF_NATIVE_ARCH_STR) == 0) 194 fArch = true; 195 else 185 PRTUTF16 pwszResult = NULL; 186 DWORD cwcResult = 0; 187 188 PRTUTF16 pwszPlatform = NULL; 189 DWORD cwcPlatform; 190 rc = VBoxWinDrvInfQueryKeyValue(&InfCtx, 2, &pwszPlatform, &cwcPlatform); 191 if (RT_SUCCESS(rc)) /* Platform is optional. */ 192 { 193 /* Note! The platform can be more specific, e.g. "NTAMD64.6.0". */ 194 if (RTUtf16FindAscii(pwszPlatform, VBOXWINDRVINF_NT_NATIVE_ARCH_STR) == 0) 196 195 { 197 if ( fNt 198 || RTUtf16ICmpAscii(pwszPlatformCur, "NT") != 0) 196 RTUTF16 wszSection[VBOXWINDRVINF_MAX_INF_SECTION_NAME]; 197 rc = RTUtf16Copy(wszSection, sizeof(wszSection), pwszModel); 198 if (RT_SUCCESS(rc)) 199 199 { 200 RTMemFree(pwszPlatformCur); 201 pwszPlatformCur = NULL; 202 continue; 200 rc = RTUtf16Cat(wszSection, sizeof(wszSection), VBOXWINDRVINF_DECORATION_SEP_UTF16_STR); 201 if (RT_SUCCESS(rc)) 202 { 203 rc = RTUtf16Cat(wszSection, sizeof(wszSection), pwszPlatform); 204 if (RT_SUCCESS(rc)) 205 { 206 pwszResult = RTUtf16Dup(wszSection); 207 if (pwszResult) 208 { 209 cwcResult = (DWORD)RTUtf16Len(wszSection); 210 } 211 else 212 rc = VERR_NO_MEMORY; 213 } 214 } 203 215 } 204 fNt = true;205 }206 207 cwcPlatform = cwcPlatformCur;208 if (pwszPlatform)209 RTMemFree(pwszPlatform);210 pwszPlatform = pwszPlatformCur;211 pwszPlatformCur = NULL;212 }213 214 rc = VINF_SUCCESS;215 216 LPWSTR pwszResult = NULL;217 DWORD cwcResult = 0;218 if (pwszPlatform)219 {220 pwszResult = (LPWSTR)RTMemAlloc((cwcModels + cwcPlatform) * sizeof(pwszResult[0]));221 if (pwszResult)222 {223 memcpy(pwszResult, pwszModels, (cwcModels - 1) * sizeof(pwszResult[0]));224 pwszResult[cwcModels - 1] = L'.';225 memcpy(&pwszResult[cwcModels], pwszPlatform, cwcPlatform * sizeof(pwszResult[0]));226 cwcResult = cwcModels + cwcPlatform;227 216 } 228 217 else 229 rc = VERR_ NO_MEMORY;230 } 231 else 232 { 233 pwszResult = pwszModel s;218 rc = VERR_PLATFORM_ARCH_NOT_SUPPORTED; 219 } 220 else /* Model w/o platform. */ 221 { 222 pwszResult = pwszModel; 234 223 cwcResult = cwcModels; 235 pwszModel s= NULL;236 } 237 238 if (pwszModels)239 RTMemFree(pwszModels); 240 if (pwszPlatform)241 224 pwszModel = NULL; 225 226 rc = VINF_SUCCESS; 227 } 228 229 RTMemFree(pwszModel); 230 RTMemFree(pwszPlatform); 242 231 243 232 if (RT_SUCCESS(rc)) … … 249 238 250 239 return rc; 240 } 241 242 int VBoxWinDrvInfQueryInstallSectionEx(HINF hInf, PCRTUTF16 pwszModel, PRTUTF16 *ppwszValue, PDWORD pcwcValue) 243 { 244 INFCONTEXT InfCtx; 245 int rc = VBoxWinDrvInfQueryContext(hInf, pwszModel, NULL, &InfCtx); 246 if (RT_FAILURE(rc)) 247 return rc; 248 249 return VBoxWinDrvInfQueryKeyValue(&InfCtx, 1, ppwszValue, pcwcValue); 250 } 251 252 int VBoxWinDrvInfQueryInstallSection(HINF hInf, PCRTUTF16 pwszModel, PRTUTF16 *ppwszValue) 253 { 254 return VBoxWinDrvInfQueryInstallSectionEx(hInf, pwszModel, ppwszValue, NULL); 251 255 } 252 256 … … 430 434 *ppwszModel = NULL; 431 435 432 return VBoxWinDrvInfQueryModel sSectionName(hInf, ppwszModel, NULL);436 return VBoxWinDrvInfQueryModel(hInf, 0 /* Index */, ppwszModel, NULL); 433 437 } 434 438 -
trunk/src/VBox/GuestHost/installation/VBoxWinDrvCommon.h
r106397 r106869 46 46 int VBoxWinDrvInfQueryFirstPnPId(HINF hInf, PRTUTF16 pwszModel, PRTUTF16 *ppwszPnPId); 47 47 int VBoxWinDrvInfQueryKeyValue(PINFCONTEXT pCtx, DWORD iValue, PRTUTF16 *ppwszValue, PDWORD pcwcValue); 48 int VBoxWinDrvInfQueryModelsSectionName(HINF hInf, PRTUTF16 *ppwszValue, PDWORD pcwcValue); 48 int VBoxWinDrvInfQueryModel(HINF hInf, PRTUTF16 *ppwszValue, PDWORD pcwcValue); 49 int VBoxWinDrvInfQueryInstallSectionEx(HINF hInf, PCRTUTF16 pwszModel, PRTUTF16 *ppwszValue, PDWORD pcwcValue); 50 int VBoxWinDrvInfQueryInstallSection(HINF hInf, PCRTUTF16 pwszModel, PRTUTF16 *ppwszValue); 49 51 int VBoxWinDrvInfQuerySectionVerEx(HINF hInf, UINT uIndex, PVBOXWINDRVINFSEC_VERSION pVer); 50 52 int VBoxWinDrvInfQuerySectionVer(HINF hInf, PVBOXWINDRVINFSEC_VERSION pVer);
Note:
See TracChangeset
for help on using the changeset viewer.