Changeset 102654 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Dec 20, 2023 4:10:26 PM (13 months ago)
- Location:
- trunk/src/VBox/Additions/common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibGuestCtrl.cpp
r99395 r102654 1175 1175 /** 1176 1176 * Retrieves a HOST_PATH_RENAME message. 1177 * 1178 * @returns VBox status code. 1179 * @param pCtx Guest control command context to use. 1180 * @param pszSource Where to return the source path. 1181 * @param cbSource Size (in bytes) of \a pszSource. 1182 * @param pszDest Where to return the destination path. 1183 * @param cbDest Size (in bytes) of \a pszDest. 1184 * @param pfFlags Where to return the rename flags. 1177 1185 */ 1178 1186 VBGLR3DECL(int) VbglR3GuestCtrlPathGetRename(PVBGLR3GUESTCTRLCMDCTX pCtx, … … 1214 1222 /** 1215 1223 * Retrieves a HOST_PATH_USER_DOCUMENTS message. 1224 * 1225 * @param pCtx Guest control command context to use. 1216 1226 */ 1217 1227 VBGLR3DECL(int) VbglR3GuestCtrlPathGetUserDocuments(PVBGLR3GUESTCTRLCMDCTX pCtx) … … 1237 1247 /** 1238 1248 * Retrieves a HOST_PATH_USER_HOME message. 1249 * 1250 * @param pCtx Guest control command context to use. 1239 1251 */ 1240 1252 VBGLR3DECL(int) VbglR3GuestCtrlPathGetUserHome(PVBGLR3GUESTCTRLCMDCTX pCtx) … … 1249 1261 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, vbglR3GuestCtrlGetMsgFunctionNo(pCtx->uClientID), pCtx->uNumParms); 1250 1262 VbglHGCMParmUInt32Set(&Msg.context, HOST_MSG_PATH_USER_HOME); 1263 1264 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 1265 if (RT_SUCCESS(rc)) 1266 Msg.context.GetUInt32(&pCtx->uContextID); 1267 } while (rc == VERR_INTERRUPTED && g_fVbglR3GuestCtrlHavePeekGetCancel); 1268 return rc; 1269 } 1270 1271 1272 /** 1273 * Retrieves a HOST_MSG_MOUNT_POINTS message. 1274 * 1275 * @param pCtx Guest control command context to use. 1276 */ 1277 VBGLR3DECL(int) VbglR3GuestCtrlGetMountPoints(PVBGLR3GUESTCTRLCMDCTX pCtx) 1278 { 1279 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 1280 AssertReturn(pCtx->uNumParms == 1, VERR_INVALID_PARAMETER); 1281 1282 int rc; 1283 do 1284 { 1285 HGCMMsgPathUserHome Msg; 1286 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, vbglR3GuestCtrlGetMsgFunctionNo(pCtx->uClientID), pCtx->uNumParms); 1287 VbglHGCMParmUInt32Set(&Msg.context, HOST_MSG_MOUNT_POINTS); 1251 1288 1252 1289 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp
r99262 r102654 1707 1707 1708 1708 /** 1709 * Structure for keeping a mount point enumeration context. 1710 */ 1711 typedef struct VGSVCMOUNTPOINTENUMCTX 1712 { 1713 /** Mount points as strings, delimited with a string terminator ('\0'). 1714 * List ends with an additional string terminator. Might get re-allocated, so don't rely on this pointer! */ 1715 char *psz; 1716 /** Current size of \a psz in bytes. Includes ending terminator. */ 1717 size_t cb; 1718 /** Total allocation Size of \a psz in bytes. */ 1719 size_t cbAlloc; 1720 } VGSVCMOUNTPOINTENUMCTX; 1721 /** Pointer to a structure for keeping a mount point enumeration context. */ 1722 typedef VGSVCMOUNTPOINTENUMCTX *PVGSVCMOUNTPOINTENUMCTX; 1723 1724 /** 1725 * Enumeration callback for storing the mount points. 1726 * 1727 * @returns VBox status code. 1728 * @param pszMountpoint Mount point to handle. 1729 * @param pvUser Pointer of type PVGSVCMOUNTPOINTENUMCTX. 1730 */ 1731 DECLCALLBACK(int) vgsvcGstCtrlSessionHandleMountPointsEnumCallback(const char *pszMountpoint, void *pvUser) 1732 { 1733 PVGSVCMOUNTPOINTENUMCTX pCtx = (PVGSVCMOUNTPOINTENUMCTX)pvUser; 1734 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 1735 1736 size_t const cch = strlen(pszMountpoint) + 1 /* Entry terminator */; 1737 AssertReturn(cch < RTPATH_MAX, VERR_INVALID_PARAMETER); /* Paranoia. */ 1738 if (cch > pCtx->cbAlloc - pCtx->cb - 1 /* Ending terminator */) 1739 { 1740 char *pszNew; 1741 int rc2 = RTStrRealloc(&pszNew, pCtx->cbAlloc + RT_MAX(_4K, cch)); 1742 AssertRCReturn(rc2, rc2); 1743 pCtx->psz = pszNew; 1744 } 1745 1746 memcpy(&pCtx->psz[pCtx->cb], pszMountpoint, cch); 1747 pCtx->cb += cch; 1748 AssertReturn(pCtx->cb <= pCtx->cbAlloc, VERR_BUFFER_OVERFLOW); /* Paranoia. */ 1749 1750 return VINF_SUCCESS; 1751 } 1752 1753 /** 1754 * Handles getting the current mount points. 1755 * 1756 * @returns VBox status code. 1757 * @param pSession Guest session. 1758 * @param pHostCtx Host context. 1759 */ 1760 static int vgsvcGstCtrlSessionHandleMountPoints(PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx) 1761 { 1762 AssertPtrReturn(pSession, VERR_INVALID_POINTER); 1763 AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER); 1764 1765 /* 1766 * Retrieve the request. 1767 */ 1768 int rc = VbglR3GuestCtrlGetMountPoints(pHostCtx); 1769 if (RT_SUCCESS(rc)) 1770 { 1771 VGSVCMOUNTPOINTENUMCTX Ctx; 1772 Ctx.cb = 0; 1773 Ctx.cbAlloc = _4K; /* Start with something sensible. */ 1774 Ctx.psz = RTStrAlloc(Ctx.cbAlloc); 1775 if (!Ctx.psz) 1776 rc = VERR_NO_MEMORY; 1777 1778 if (RT_SUCCESS(rc)) 1779 rc = RTFsMountpointsEnum(vgsvcGstCtrlSessionHandleMountPointsEnumCallback, &Ctx); 1780 1781 /* Report back in any case. */ 1782 int rc2 = VbglR3GuestCtrlMsgReplyEx(pHostCtx, rc, 0 /* Type */, Ctx.psz, 1783 RT_SUCCESS(rc) ? (uint32_t)Ctx.cb : 0); 1784 if (RT_FAILURE(rc2)) 1785 { 1786 VGSvcError("Failed to report mount points, rc=%Rrc\n", rc2); 1787 if (RT_SUCCESS(rc)) 1788 rc = rc2; 1789 } 1790 1791 RTStrFree(Ctx.psz); 1792 Ctx.psz = NULL; 1793 } 1794 else 1795 { 1796 VGSvcError("Error fetching parameters for getting mount points request: %Rrc\n", rc); 1797 VbglR3GuestCtrlMsgSkip(pHostCtx->uClientID, rc, UINT32_MAX); 1798 } 1799 return rc; 1800 } 1801 1802 1803 /** 1709 1804 * Handles starting a guest processes. 1710 1805 * … … 2450 2545 if (fImpersonated) 2451 2546 rc = vgsvcGstCtrlSessionHandlePathUserHome(pSession, pHostCtx); 2547 break; 2548 2549 case HOST_MSG_MOUNT_POINTS: 2550 if (fImpersonated) 2551 rc = vgsvcGstCtrlSessionHandleMountPoints(pSession, pHostCtx); 2452 2552 break; 2453 2553
Note:
See TracChangeset
for help on using the changeset viewer.