Changeset 95857 in vbox for trunk/src/VBox
- Timestamp:
- Jul 26, 2022 11:54:38 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceUtils.cpp
r93115 r95857 167 167 * @returns Success indicator. 168 168 */ 169 static bool vgsvcUtilGetFileVersionOwn(LPSTR pVerData, PDWORD pdwMajor, PDWORD pdwMinor, PDWORD pdwBuildNumber,170 PDWORD pdwRevisionNumber)169 static bool vgsvcUtilGetFileVersionOwn(LPSTR pVerData, uint32_t *puMajor, uint32_t *puMinor, 170 uint32_t *puBuildNumber, uint32_t *puRevisionNumber) 171 171 { 172 172 UINT cchStrValue = 0; … … 175 175 return false; 176 176 177 /** @todo r=bird: get rid of this. Avoid sscanf like the plague! */ 178 if (sscanf(pStrValue, "%ld.%ld.%ld.%ld", pdwMajor, pdwMinor, pdwBuildNumber, pdwRevisionNumber) != 4) 179 return false; 177 char *pszNext = pStrValue; 178 int rc = RTStrToUInt32Ex(pszNext, &pszNext, 0, puMajor); 179 AssertReturn(rc == VWRN_TRAILING_CHARS, false); 180 AssertReturn(*pszNext == '.', false); 181 182 rc = RTStrToUInt32Ex(pszNext + 1, &pszNext, 0, puMinor); 183 AssertReturn(rc == VWRN_TRAILING_CHARS, false); 184 AssertReturn(*pszNext == '.', false); 185 186 rc = RTStrToUInt32Ex(pszNext + 1, &pszNext, 0, puBuildNumber); 187 AssertReturn(rc == VWRN_TRAILING_CHARS, false); 188 AssertReturn(*pszNext == '.', false); 189 190 rc = RTStrToUInt32Ex(pszNext + 1, &pszNext, 0, puRevisionNumber); 191 AssertReturn(rc == VINF_SUCCESS || rc == VWRN_TRAILING_CHARS /*??*/, false); 180 192 181 193 return true; … … 188 200 * @returns VBox status code. 189 201 * @param pszFilename ASCII & ANSI & UTF-8 compliant name. 190 * @param p dwMajorWhere to return the major version number.191 * @param p dwMinorWhere to return the minor version number.192 * @param p dwBuildNumberWhere to return the build number.193 * @param p dwRevisionNumberWhere to return the revision number.194 */ 195 static int vgsvcUtilGetFileVersion(const char *pszFilename, PDWORD pdwMajor, PDWORD pdwMinor, PDWORD pdwBuildNumber,196 PDWORD pdwRevisionNumber)202 * @param puMajor Where to return the major version number. 203 * @param puMinor Where to return the minor version number. 204 * @param puBuildNumber Where to return the build number. 205 * @param puRevisionNumber Where to return the revision number. 206 */ 207 static int vgsvcUtilGetFileVersion(const char *pszFilename, uint32_t *puMajor, uint32_t *puMinor, uint32_t *puBuildNumber, 208 uint32_t *puRevisionNumber) 197 209 { 198 210 int rc; 199 211 200 *p dwMajor = *pdwMinor = *pdwBuildNumber = *pdwRevisionNumber = 0;212 *puMajor = *puMinor = *puBuildNumber = *puRevisionNumber = 0; 201 213 202 214 /* … … 217 229 * it goes beyond the range of an uint16_t / WORD. 218 230 */ 219 if (vgsvcUtilGetFileVersionOwn(pVerData, p dwMajor, pdwMinor, pdwBuildNumber, pdwRevisionNumber))231 if (vgsvcUtilGetFileVersionOwn(pVerData, puMajor, puMinor, puBuildNumber, puRevisionNumber)) 220 232 rc = VINF_SUCCESS; 221 233 else … … 226 238 if (VerQueryValue(pVerData, "\\", (LPVOID *)&pFileInfo, &cbFileInfoIgnored)) 227 239 { 228 *p dwMajor = HIWORD(pFileInfo->dwFileVersionMS);229 *p dwMinor = LOWORD(pFileInfo->dwFileVersionMS);230 *p dwBuildNumber = HIWORD(pFileInfo->dwFileVersionLS);231 *p dwRevisionNumber = LOWORD(pFileInfo->dwFileVersionLS);240 *puMajor = HIWORD(pFileInfo->dwFileVersionMS); 241 *puMinor = LOWORD(pFileInfo->dwFileVersionMS); 242 *puBuildNumber = HIWORD(pFileInfo->dwFileVersionLS); 243 *puRevisionNumber = LOWORD(pFileInfo->dwFileVersionLS); 232 244 rc = VINF_SUCCESS; 233 245 } … … 291 303 if (RT_SUCCESS(rc)) 292 304 { 293 DWORD dwMajor, dwMinor, dwBuild, dwRev;294 rc = vgsvcUtilGetFileVersion(szFullPath, & dwMajor, &dwMinor, &dwBuild, &dwRev);305 uint32_t uMajor, uMinor, uBuild, uRev; 306 rc = vgsvcUtilGetFileVersion(szFullPath, &uMajor, &uMinor, &uBuild, &uRev); 295 307 if (RT_SUCCESS(rc)) 296 RTStrPrintf(pszVersion, cbVersion, "%u.%u.%ur%u", dwMajor, dwMinor, dwBuild, dwRev);308 RTStrPrintf(pszVersion, cbVersion, "%u.%u.%ur%u", uMajor, uMinor, uBuild, uRev); 297 309 } 298 310 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.