Changeset 37141 in vbox for trunk/src/VBox/Additions
- Timestamp:
- May 18, 2011 3:14:59 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibAdditions.cpp
r37019 r37141 37 37 38 38 /** 39 * Fallback for vbglR3GetAdditionsVersion.39 * Fallback for VbglR3GetAdditionsVersion. 40 40 */ 41 41 static int vbglR3GetAdditionsCompileTimeVersion(char **ppszVer, char **ppszVerEx, char **ppszRev) 42 42 { 43 /* Raw version string: major.minor.build. */43 int rc = VINF_SUCCESS; 44 44 if (ppszVer) 45 { 46 *ppszVer = RTStrDup(VBOX_VERSION_STRING_RAW); 47 if (!*ppszVer) 48 return VERR_NO_STR_MEMORY; 49 } 50 51 /* Extended version string: major.minor.build (+ vendor [suffix(es)]). */ 52 if (ppszVerEx) 53 { 54 *ppszVerEx = RTStrDup(VBOX_VERSION_STRING); 55 if (!*ppszVerEx) 56 return VERR_NO_STR_MEMORY; 57 } 58 59 if (ppszRev) 60 { 61 char szRev[64]; 62 RTStrPrintf(szRev, sizeof(szRev), "%d", VBOX_SVN_REV); 63 *ppszRev = RTStrDup(szRev); 64 if (!*ppszRev) 65 { 66 if (ppszVer) 67 { 68 RTStrFree(*ppszVer); 69 *ppszVer = NULL; 70 } 71 return VERR_NO_STR_MEMORY; 72 } 73 } 74 75 return VINF_SUCCESS; 45 rc = RTStrDupEx(ppszVer, VBOX_VERSION_STRING_RAW); 46 if (RT_SUCCESS(rc)) 47 { 48 if (ppszVerEx) 49 rc = RTStrDupEx(ppszVerEx, VBOX_VERSION_STRING); 50 if (RT_SUCCESS(rc)) 51 { 52 if (ppszRev) 53 { 54 #if 0 55 char szRev[64]; 56 RTStrPrintf(szRev, sizeof(szRev), "%d", VBOX_SVN_REV); 57 rc = RTStrDupEx(ppszRev, szRev); 58 #else 59 rc = RTStrDupEx(ppszRev, RT_XSTR(VBOX_SVN_REV)); 60 #endif 61 } 62 if (RT_SUCCESS(rc)) 63 return VINF_SUCCESS; 64 65 /* bail out: */ 66 } 67 if (ppszVerEx) 68 { 69 RTStrFree(*ppszVerEx); 70 *ppszVerEx = NULL; 71 } 72 } 73 if (ppszVer) 74 { 75 RTStrFree(*ppszVer); 76 *ppszVer = NULL; 77 } 78 return rc; 76 79 } 77 80 78 81 #ifdef RT_OS_WINDOWS 82 79 83 /** 80 84 * Looks up the storage path handle (registry). … … 85 89 * vbglR3CloseAdditionsWinStoragePath(). 86 90 */ 87 static int vbglR3 GetAdditionsWinStoragePath(PHKEY phKey)91 static int vbglR3QueryAdditionsWinStoragePath(PHKEY phKey) 88 92 { 89 93 /* … … 139 143 * @returns IPRT status value 140 144 * @param hKey Handle to close, retrieved by 141 * vbglR3 GetAdditionsWinStoragePath().145 * vbglR3QueryAdditionsWinStoragePath(). 142 146 */ 143 147 static int vbglR3CloseAdditionsWinStoragePath(HKEY hKey) … … 173 177 return rc; 174 178 } 179 175 180 176 181 /** … … 191 196 VBGLR3DECL(int) VbglR3GetAdditionsVersion(char **ppszVer, char **ppszVerEx, char **ppszRev) 192 197 { 198 /* 199 * Zap the return value up front. 200 */ 201 if (ppszVer) 202 *ppszVer = NULL; 203 if (ppszVerEx) 204 *ppszVerEx = NULL; 205 if (ppszRev) 206 *ppszRev = NULL; 207 208 193 209 #ifdef RT_OS_WINDOWS 194 210 HKEY hKey; 195 int rc = vbglR3 GetAdditionsWinStoragePath(&hKey);211 int rc = vbglR3QueryAdditionsWinStoragePath(&hKey); 196 212 if (RT_SUCCESS(rc)) 197 213 { 198 /* Version. */ 214 /* 215 * Version. 216 */ 217 /** @todo r=bird: This code has broken error handling: 1. Errors are 218 * overwritten and hidden, leaving return values undefined. 219 * 2. On error, memory could be leaked. 220 * Also, just use a static 32-byte buffer instead of allocating 221 * three! In fact, why not just factor out the string value query? */ 199 222 LONG l; 200 223 DWORD dwType; … … 246 269 rc = VERR_NO_MEMORY; 247 270 } 248 /* Revision. */ 271 272 /* 273 * Revision. 274 */ 249 275 if (ppszRev) 250 276 { … … 310 336 #ifdef RT_OS_WINDOWS 311 337 HKEY hKey; 312 rc = vbglR3 GetAdditionsWinStoragePath(&hKey);338 rc = vbglR3QueryAdditionsWinStoragePath(&hKey); 313 339 if (RT_SUCCESS(rc)) 314 340 {
Note:
See TracChangeset
for help on using the changeset viewer.