Changeset 91748 in vbox for trunk/src/VBox/Main/src-client/HGCM.cpp
- Timestamp:
- Oct 14, 2021 9:01:31 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 147506
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/HGCM.cpp
r91100 r91748 213 213 , idxCategory(a_idxCategory) 214 214 , cPendingCalls(0) 215 , m_fGuestAccessible(false) 215 216 { 216 217 Assert(idxCategory < HGCM_CLIENT_CATEGORY_MAX); … … 219 220 220 221 int Init(HGCMService *pSvc); 222 223 /** Lookups a client object by its handle. */ 224 static HGCMClient *ReferenceByHandle(uint32_t idClient) 225 { 226 return (HGCMClient *)hgcmObjReference(idClient, HGCMOBJ_CLIENT); 227 } 228 229 /** Lookups a client object by its handle and makes sure that it's accessible to the guest. */ 230 static HGCMClient *ReferenceByHandleForGuest(uint32_t idClient) 231 { 232 HGCMClient *pClient = (HGCMClient *)hgcmObjReference(idClient, HGCMOBJ_CLIENT); 233 if (pClient) 234 { 235 if (RT_LIKELY(pClient->m_fGuestAccessible)) 236 return pClient; 237 pClient->Dereference(); 238 } 239 return NULL; 240 } 241 242 /** Make the client object accessible to the guest. */ 243 void makeAccessibleToGuest() 244 { 245 ASMAtomicWriteBool(&m_fGuestAccessible, true); 246 } 221 247 222 248 /** Service that the client is connected to. */ … … 235 261 /** Number of pending calls. */ 236 262 uint32_t volatile cPendingCalls; 263 264 protected: 265 /** Set if the client is accessible to the guest, clear if not. */ 266 bool volatile m_fGuestAccessible; 237 267 238 268 private: /* none of this: */ … … 675 705 LogFlowFunc(("SVC_MSG_CONNECT u32ClientId = %d\n", pMsg->u32ClientId)); 676 706 677 HGCMClient *pClient = (HGCMClient *)hgcmObjReference(pMsg->u32ClientId, HGCMOBJ_CLIENT);707 HGCMClient *pClient = HGCMClient::ReferenceByHandle(pMsg->u32ClientId); 678 708 679 709 if (pClient) … … 719 749 pMsg->u32ClientId, pMsg->u32Function, pMsg->cParms, pMsg->paParms)); 720 750 721 HGCMClient *pClient = (HGCMClient *)hgcmObjReference(pMsg->u32ClientId, HGCMOBJ_CLIENT);751 HGCMClient *pClient = HGCMClient::ReferenceByHandleForGuest(pMsg->u32ClientId); 722 752 723 753 if (pClient) … … 741 771 LogFlowFunc(("SVC_MSG_GUESTCANCELLED idClient = %d\n", pMsg->idClient)); 742 772 743 HGCMClient *pClient = (HGCMClient *)hgcmObjReference(pMsg->idClient, HGCMOBJ_CLIENT);773 HGCMClient *pClient = HGCMClient::ReferenceByHandleForGuest(pMsg->idClient); 744 774 745 775 if (pClient) … … 771 801 LogFlowFunc(("SVC_MSG_LOADSTATE\n")); 772 802 773 HGCMClient *pClient = (HGCMClient *)hgcmObjReference(pMsg->u32ClientId, HGCMOBJ_CLIENT);803 HGCMClient *pClient = HGCMClient::ReferenceByHandle(pMsg->u32ClientId); 774 804 775 805 if (pClient) … … 804 834 LogFlowFunc(("SVC_MSG_SAVESTATE\n")); 805 835 806 HGCMClient *pClient = (HGCMClient *)hgcmObjReference(pMsg->u32ClientId, HGCMOBJ_CLIENT);836 HGCMClient *pClient = HGCMClient::ReferenceByHandle(pMsg->u32ClientId); 807 837 808 838 rc = VINF_SUCCESS; … … 940 970 trying to disconnect it. */ 941 971 int rc = VERR_NOT_FOUND; 942 HGCMClient * const pClient = (HGCMClient *)hgcmObjReference(idClient, HGCMOBJ_CLIENT);972 HGCMClient * const pClient = HGCMClient::ReferenceByHandle(idClient); 943 973 if (pClient) 944 974 { … … 1483 1513 { 1484 1514 uint32_t const idClient = pSvc->m_paClientIds[0]; 1485 HGCMClient * const pClient = (HGCMClient *)hgcmObjReference(idClient, HGCMOBJ_CLIENT);1515 HGCMClient * const pClient = HGCMClient::ReferenceByHandle(idClient); 1486 1516 Assert(pClient); 1487 1517 LogFlowFunc(("handle %d/%p\n", pSvc->m_paClientIds[0], pClient)); … … 1789 1819 1790 1820 ReferenceService(); 1821 1822 /* The guest may now use this client object. */ 1823 pClient->makeAccessibleToGuest(); 1791 1824 } 1792 1825 else … … 2316 2349 pMsg->u32ClientId)); 2317 2350 2318 HGCMClient *pClient = (HGCMClient *)hgcmObjReference(pMsg->u32ClientId, HGCMOBJ_CLIENT);2351 HGCMClient *pClient = HGCMClient::ReferenceByHandle(pMsg->u32ClientId); 2319 2352 2320 2353 if (!pClient) … … 2768 2801 2769 2802 /* Resolve the client handle to the client instance pointer. */ 2770 HGCMClient *pClient = (HGCMClient *)hgcmObjReference(u32ClientId, HGCMOBJ_CLIENT);2803 HGCMClient *pClient = HGCMClient::ReferenceByHandleForGuest(u32ClientId); 2771 2804 2772 2805 if (pClient) … … 2798 2831 2799 2832 /* Resolve the client handle to the client instance pointer. */ 2800 HGCMClient *pClient = (HGCMClient *)hgcmObjReference(idClient, HGCMOBJ_CLIENT);2833 HGCMClient *pClient = HGCMClient::ReferenceByHandleForGuest(idClient); 2801 2834 2802 2835 if (pClient)
Note:
See TracChangeset
for help on using the changeset viewer.