Changeset 24332 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Nov 4, 2009 2:08:09 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibMisc.cpp
r24306 r24332 177 177 VBGLR3DECL(int) VbglR3SetGuestCaps(uint32_t fOr, uint32_t fNot) 178 178 { 179 VMMDevReqGuestCapabilities2 vmmreqGuestCaps; 180 int rc; 181 182 vmmdevInitRequest(&vmmreqGuestCaps.header, VMMDevReq_SetGuestCapabilities); 183 vmmreqGuestCaps.u32OrMask = fOr; 184 vmmreqGuestCaps.u32NotMask = fNot; 185 rc = vbglR3GRPerform(&vmmreqGuestCaps.header); 179 VMMDevReqGuestCapabilities2 Req; 180 181 vmmdevInitRequest(&Req.header, VMMDevReq_SetGuestCapabilities); 182 Req.u32OrMask = fOr; 183 Req.u32NotMask = fNot; 184 int rc = vbglR3GRPerform(&Req.header); 186 185 #ifdef DEBUG 187 186 if (RT_SUCCESS(rc)) 188 LogRel(("Successfully changed guest capabilities: or mask 0x%x, not mask 0x%x.\n", 189 fOr, fNot)); 187 LogRel(("Successfully changed guest capabilities: or mask 0x%x, not mask 0x%x.\n", fOr, fNot)); 190 188 else 191 LogRel(("Failed to change guest capabilities: or mask 0x%x, not mask 0x%x. rc = %Rrc.\n", 192 fOr, fNot, rc)); 189 LogRel(("Failed to change guest capabilities: or mask 0x%x, not mask 0x%x. rc=%Rrc.\n", fOr, fNot, rc)); 193 190 #endif 194 191 return rc; … … 197 194 198 195 /** 199 * Retrieves the installed Guest Additions version/revision. 196 * Fallback for vbglR3GetAdditionsVersion. 197 */ 198 static int vbglR3GetAdditionsCompileTimeVersion(char **ppszVer, char **ppszRev) 199 { 200 if (ppszVer) 201 { 202 *ppszVer = RTStrDup(VBOX_VERSION_STRING); 203 if (!*ppszVer) 204 return VERR_NO_STR_MEMORY; 205 } 206 207 if (ppszRev) 208 { 209 char szRev[64]; 210 RTStrPrintf(szRev, sizeof(szRev), "%d", VBOX_SVN_REV); 211 *ppszRev = RTStrDup(szRev); 212 if (!*ppszRev) 213 { 214 if (ppszVer) 215 { 216 RTStrFree(*ppszVer); 217 *ppszVer = NULL; 218 } 219 return VERR_NO_STR_MEMORY; 220 } 221 } 222 223 return VINF_SUCCESS; 224 } 225 226 227 /** 228 * Retrieves the installed Guest Additions version and/or revision. 200 229 * 201 230 * @returns IPRT status value 202 * @param ppszVer Receives pointer of allocated version string. NULL is accepted. 203 * The returned pointer must be freed using RTStrFree(). 204 * @param ppszRev Receives pointer of allocated revision string. NULL is accepted. 205 * The returned pointer must be freed using RTStrFree(). 231 * @param ppszVer Receives pointer of allocated version string. NULL is 232 * accepted. The returned pointer must be freed using 233 * RTStrFree(). 234 * @param ppszRev Receives pointer of allocated revision string. NULL is 235 * accepted. The returned pointer must be freed using 236 * RTStrFree(). 206 237 */ 207 238 VBGLR3DECL(int) VbglR3GetAdditionsVersion(char **ppszVer, char **ppszRev) 208 239 { 240 #ifdef RT_OS_WINDOWS 241 /* 242 * Try get the *installed* version first. 243 */ 209 244 int rc = VINF_SUCCESS; 210 #ifdef RT_OS_WINDOWS211 245 HKEY hKey; 212 246 LONG r; … … 238 272 if (r == ERROR_SUCCESS) 239 273 { 274 /** @todo r=bird: If anything fails here, this code will end up returning 275 * rc=VINF_SUCCESS and uninitialized output pointers. It will also 276 * leak memory in some cases. Iff the value type isn't string, 277 * garbage is returned. 278 * 279 * RTMemAlloc shall be freed by RTMemFree not RTStrFree. Don't ever mix 280 * because it will blow up in an annoying way when using the eletrical 281 * fences and stuff. Use a temporary buffer and RTStrDupEx. 282 */ 240 283 /* Version. */ 241 284 DWORD dwType; … … 264 307 else 265 308 { 266 /* No registry entries found, return the compile-time version string atm. */ 267 /* Version. */ 268 if (ppszVer) 269 rc = RTStrAPrintf(ppszVer, "%s", VBOX_VERSION_STRING); 270 /* Revision. */ 271 if (ppszRev) 272 rc = RTStrAPrintf(ppszRev, "%s", VBOX_SVN_REV); 273 } 274 if (NULL != hKey) 309 /* 310 * No registry entries found, return the version string compiled 311 * into this binary. 312 */ 313 rc = vbglR3GetAdditionsCompileTimeVersion(ppszVer, ppszRev); 314 } 315 if (hKey != NULL) /** @todo r=bird: This looks kind of wrong for the failure case... */ 275 316 RegCloseKey(hKey); 276 # else /* !RT_OS_WINDOWS */ 277 /* On non-Windows platforms just return the compile-time version string atm. */ 278 /* Version. */ 279 if (ppszVer) 280 rc = RTStrAPrintf(ppszVer, "%s", VBOX_VERSION_STRING); 281 /* Revision. */ 282 if (ppszRev) 283 rc = RTStrAPrintf(ppszRev, "%s", VBOX_SVN_REV); 284 # endif /* !RT_OS_WINDOWS */ 285 return rc; 286 } 317 return rc; 318 319 #else /* !RT_OS_WINDOWS */ 320 /* 321 * On non-Windows platforms just return the compile-time version string. 322 */ 323 return vbglR3GetAdditionsCompileTimeVersion(ppszVer, ppszRev); 324 #endif /* !RT_OS_WINDOWS */ 325 }
Note:
See TracChangeset
for help on using the changeset viewer.