Changeset 73939 in vbox
- Timestamp:
- Aug 29, 2018 7:56:40 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/HostServices/Service.h
r69107 r73939 4 4 5 5 /* 6 * Copyright (C) 2011-201 7Oracle Corporation6 * Copyright (C) 2011-2018 Oracle Corporation 7 7 * 8 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 40 40 { 41 41 42 /** 43 * Message class encapsulating HGCM parameters. 44 */ 42 45 class Message 43 46 { 44 /* Contains a copy of HGCM parameters. */45 47 public: 48 46 49 Message(uint32_t uMsg, uint32_t cParms, VBOXHGCMSVCPARM aParms[]) 47 50 : m_uMsg(0) … … 57 60 } 58 61 59 uint32_t message() const { return m_uMsg; } 60 uint32_t paramsCount() const { return m_cParms; } 61 62 int getData(uint32_t uMsg, uint32_t cParms, VBOXHGCMSVCPARM aParms[]) const 62 /** 63 * Returns the type of this message. 64 * 65 * @returns Message type 66 */ 67 uint32_t GetType(void) const { return m_uMsg; } 68 69 /** 70 * Returns the parameter count of this message. 71 * 72 * @returns Parameter count. 73 */ 74 uint32_t GetParamCount(void) const { return m_cParms; } 75 76 /** 77 * Retrieves the raw HGCM parameter data 78 * 79 * @returns IPRT status code. 80 * @param uMsg Message type to retrieve the parameter data for. Needed for sanity. 81 * @param cParms Size (in parameters) of @a aParms array. 82 * @param aParms Where to store the HGCM parameter data. 83 */ 84 int GetData(uint32_t uMsg, uint32_t cParms, VBOXHGCMSVCPARM aParms[]) const 63 85 { 64 86 if (m_uMsg != uMsg) 65 87 { 66 LogFlowFunc((" Message type does not match (%RU32 (buffer), %RU32 (guest))\n", m_uMsg, uMsg));88 LogFlowFunc(("Stored message type (%RU32) does not match request (%RU32)\n", m_uMsg, uMsg)); 67 89 return VERR_INVALID_PARAMETER; 68 90 } 69 91 if (m_cParms > cParms) 70 92 { 71 LogFlowFunc((" Parameter count does not match (%RU32 (buffer), %RU32 (guest))\n", m_cParms, cParms));93 LogFlowFunc(("Stored parameter count (%RU32) exceeds request buffer (%RU32)\n", m_cParms, cParms)); 72 94 return VERR_INVALID_PARAMETER; 73 95 } … … 76 98 } 77 99 78 int getParmU32Info(uint32_t iParm, uint32_t *pu32Info) const 100 /** 101 * Retrieves a specific parameter value as uint32_t. 102 * 103 * @returns IPRT status code. 104 * @param uParm Index of parameter to retrieve. 105 * @param pu32Info Where to store the parameter value. 106 */ 107 int GetParmU32(uint32_t uParm, uint32_t *pu32Info) const 79 108 { 80 109 AssertPtrNullReturn(pu32Info, VERR_INVALID_PARAMETER); 81 AssertReturn( iParm < m_cParms, VERR_INVALID_PARAMETER);82 AssertReturn(m_paParms[ iParm].type == VBOX_HGCM_SVC_PARM_32BIT, VERR_INVALID_PARAMETER);83 84 *pu32Info = m_paParms[ iParm].u.uint32;110 AssertReturn(uParm < m_cParms, VERR_INVALID_PARAMETER); 111 AssertReturn(m_paParms[uParm].type == VBOX_HGCM_SVC_PARM_32BIT, VERR_INVALID_PARAMETER); 112 113 *pu32Info = m_paParms[uParm].u.uint32; 85 114 86 115 return VINF_SUCCESS; 87 116 } 88 117 89 int getParmU64Info(uint32_t iParm, uint64_t *pu64Info) const 118 /** 119 * Retrieves a specific parameter value as uint64_t. 120 * 121 * @returns IPRT status code. 122 * @param uParm Index of parameter to retrieve. 123 * @param pu32Info Where to store the parameter value. 124 */ 125 int GetParmU64(uint32_t uParm, uint64_t *pu64Info) const 90 126 { 91 127 AssertPtrNullReturn(pu64Info, VERR_INVALID_PARAMETER); 92 AssertReturn( iParm < m_cParms, VERR_INVALID_PARAMETER);93 AssertReturn(m_paParms[ iParm].type == VBOX_HGCM_SVC_PARM_64BIT, VERR_INVALID_PARAMETER);94 95 *pu64Info = m_paParms[ iParm].u.uint64;128 AssertReturn(uParm < m_cParms, VERR_INVALID_PARAMETER); 129 AssertReturn(m_paParms[uParm].type == VBOX_HGCM_SVC_PARM_64BIT, VERR_INVALID_PARAMETER); 130 131 *pu64Info = m_paParms[uParm].u.uint64; 96 132 97 133 return VINF_SUCCESS; 98 134 } 99 135 100 int getParmPtrInfo(uint32_t iParm, void **ppvAddr, uint32_t *pcSize) const 136 /** 137 * Retrieves a specific parameter value as a data address + size. 138 * 139 * @returns IPRT status code. 140 * @param uParm Index of parameter to retrieve. 141 * @param ppvAddr Where to store the data address. 142 * @param pcbSize Where to store the data size (in bytes). 143 * 144 * @remarks Does not copy (store) the actual content of the pointer (deep copy). 145 */ 146 int GetParmPtr(uint32_t uParm, void **ppvAddr, uint32_t *pcbSize) const 101 147 { 102 148 AssertPtrNullReturn(ppvAddr, VERR_INVALID_PARAMETER); 103 AssertPtrNullReturn(pc Size, VERR_INVALID_PARAMETER);104 AssertReturn( iParm < m_cParms, VERR_INVALID_PARAMETER);105 AssertReturn(m_paParms[ iParm].type == VBOX_HGCM_SVC_PARM_PTR, VERR_INVALID_PARAMETER);106 107 *ppvAddr = m_paParms[ iParm].u.pointer.addr;108 *pc Size = m_paParms[iParm].u.pointer.size;149 AssertPtrNullReturn(pcbSize, VERR_INVALID_PARAMETER); 150 AssertReturn(uParm < m_cParms, VERR_INVALID_PARAMETER); 151 AssertReturn(m_paParms[uParm].type == VBOX_HGCM_SVC_PARM_PTR, VERR_INVALID_PARAMETER); 152 153 *ppvAddr = m_paParms[uParm].u.pointer.addr; 154 *pcbSize = m_paParms[uParm].u.pointer.size; 109 155 110 156 return VINF_SUCCESS; 111 }112 113 static int copyParms(PVBOXHGCMSVCPARM paParmsDst, uint32_t cParmsDst, PVBOXHGCMSVCPARM paParmsSrc, uint32_t cParmsSrc)114 {115 return copyParmsInternal(paParmsDst, cParmsDst, paParmsSrc, cParmsSrc, false /* fDeepCopy */);116 157 } 117 158 … … 154 195 } 155 196 197 /** 198 * Copies HGCM parameters from source to destination. 199 * 200 * @returns IPRT status code. 201 * @param paParmsDst Destination array to copy parameters to. 202 * @param cParmsDst Size (in parameters) of destination array. 203 * @param paParmsSrc Source array to copy parameters from. 204 * @param cParmsSrc Size (in parameters) of source array. 205 * @param fDeepCopy Whether to perform a deep copy of pointer parameters or not. 206 * 207 * @remark Static convenience function. 208 */ 156 209 static int copyParmsInternal(PVBOXHGCMSVCPARM paParmsDst, uint32_t cParmsDst, 157 210 PVBOXHGCMSVCPARM paParmsSrc, uint32_t cParmsSrc, … … 234 287 } 235 288 236 void cleanup() 289 /** 290 * Cleans up the message by free'ing all allocated parameters and resetting the rest. 291 */ 292 void cleanup(void) 237 293 { 238 294 if (m_paParms) … … 256 312 }; 257 313 314 /** 315 * Class for keeping and tracking a HGCM client. 316 */ 258 317 class Client 259 318 { 260 319 public: 320 261 321 Client(uint32_t uClientId, VBOXHGCMCALLHANDLE hHandle = NULL, 262 322 uint32_t uMsg = 0, uint32_t cParms = 0, VBOXHGCMSVCPARM aParms[] = NULL) … … 270 330 public: 271 331 272 VBOXHGCMCALLHANDLE handle(void) const { return m_hHandle; }273 uint32_t message(void) const { return m_uMsg; }274 uint32_t clientId(void) const { return m_uClientId; }275 uint32_t protocol(void) const { return m_uProtocol; }332 VBOXHGCMCALLHANDLE GetHandle(void) const { return m_hHandle; } 333 uint32_t GetMsgType(void) const { return m_uMsg; } 334 uint32_t GetClientID(void) const { return m_uClientId; } 335 uint32_t GetProtocolVer(void) const { return m_uProtocol; } 276 336 277 337 public: 278 338 279 int setProtocol(uint32_t uProtocol) { m_uProtocol = uProtocol; return VINF_SUCCESS; }339 int SetProtocolVer(uint32_t uProtocol) { m_uProtocol = uProtocol; return VINF_SUCCESS; } 280 340 281 341 public: … … 297 357 return VERR_INVALID_PARAMETER; 298 358 299 m_paParms[0].setUInt32(pMessage-> message());300 m_paParms[1].setUInt32(pMessage-> paramsCount());359 m_paParms[0].setUInt32(pMessage->GetType()); 360 m_paParms[1].setUInt32(pMessage->GetParamCount()); 301 361 302 362 return VINF_SUCCESS; … … 305 365 { 306 366 AssertPtrReturn(pMessage, VERR_INVALID_POINTER); 307 return pMessage-> getData(m_uMsg, m_cParms, m_paParms);367 return pMessage->GetData(m_uMsg, m_cParms, m_paParms); 308 368 } 309 369 -
trunk/src/VBox/HostServices/DragAndDrop/dndmanager.h
r69500 r73939 59 59 return VERR_NO_DATA; 60 60 61 *puMsg = m_pNextMsg-> message();62 *pcParms = m_pNextMsg-> paramsCount();61 *puMsg = m_pNextMsg->GetType(); 62 *pcParms = m_pNextMsg->GetParamCount(); 63 63 64 64 return VINF_SUCCESS; … … 70 70 if (!m_pNextMsg) 71 71 return VERR_NO_DATA; 72 73 int rc = m_pNextMsg->getData(uMsg, cParms, paParms); 72 int rc = m_pNextMsg->GetData(uMsg, cParms, paParms); 74 73 75 74 clearNextMsg(); -
trunk/src/VBox/HostServices/DragAndDrop/service.cpp
r73511 r73939 474 474 if (rc == VINF_SUCCESS) /* Note: rc might be VINF_HGCM_ASYNC_EXECUTE! */ 475 475 { 476 LogFlowFunc(("Client %RU32: Protocol v%RU32\n", pClient-> clientId(), pClient->protocol()));476 LogFlowFunc(("Client %RU32: Protocol v%RU32\n", pClient->GetClientID(), pClient->GetProtocolVer())); 477 477 478 478 rc = VERR_INVALID_PARAMETER; /* Play safe. */ … … 553 553 rc = paParms[idxProto + 1].getUInt32(&data.uFlags); 554 554 if (RT_SUCCESS(rc)) 555 rc = pClient-> setProtocol(data.uProtocol);556 if (RT_SUCCESS(rc)) 557 { 558 LogFlowFunc(("Client %RU32 is now using protocol v%RU32\n", pClient-> clientId(), pClient->protocol()));555 rc = pClient->SetProtocolVer(data.uProtocol); 556 if (RT_SUCCESS(rc)) 557 { 558 LogFlowFunc(("Client %RU32 is now using protocol v%RU32\n", pClient->GetClientID(), pClient->GetProtocolVer())); 559 559 DO_HOST_CALLBACK(); 560 560 } … … 570 570 data.hdr.uMagic = CB_MAGIC_DND_HG_ACK_OP; 571 571 572 switch (pClient-> protocol())572 switch (pClient->GetProtocolVer()) 573 573 { 574 574 case 3: … … 603 603 data.hdr.uMagic = CB_MAGIC_DND_HG_REQ_DATA; 604 604 605 switch (pClient-> protocol())605 switch (pClient->GetProtocolVer()) 606 606 { 607 607 case 3: … … 638 638 data.hdr.uMagic = CB_MAGIC_DND_HG_EVT_PROGRESS; 639 639 640 switch (pClient-> protocol())640 switch (pClient->GetProtocolVer()) 641 641 { 642 642 case 3: … … 682 682 data.hdr.uMagic = CB_MAGIC_DND_GH_ACK_PENDING; 683 683 684 switch (pClient-> protocol())684 switch (pClient->GetProtocolVer()) 685 685 { 686 686 case 3: … … 761 761 { 762 762 LogFlowFunc(("GUEST_DND_GH_SND_DATA\n")); 763 switch (pClient-> protocol())763 switch (pClient->GetProtocolVer()) 764 764 { 765 765 case 3: … … 810 810 data.hdr.uMagic = CB_MAGIC_DND_GH_SND_DIR; 811 811 812 switch (pClient-> protocol())812 switch (pClient->GetProtocolVer()) 813 813 { 814 814 case 3: … … 877 877 LogFlowFunc(("GUEST_DND_GH_SND_FILE_DATA\n")); 878 878 879 switch (pClient-> protocol())879 switch (pClient->GetProtocolVer()) 880 880 { 881 881 /* Protocol v3 adds (optional) checksums. */ … … 958 958 data.hdr.uMagic = CB_MAGIC_DND_GH_EVT_ERROR; 959 959 960 switch (pClient-> protocol())960 switch (pClient->GetProtocolVer()) 961 961 { 962 962 case 3: … … 1008 1008 data.hdr.uMagic = CB_MAGIC_DND_GH_EVT_ERROR; 1009 1009 1010 switch (pClient-> protocol())1010 switch (pClient->GetProtocolVer()) 1011 1011 { 1012 1012 case 3: … … 1165 1165 int rc2 = pClient->addMessageInfo(HOST_DND_HG_EVT_CANCEL, 1166 1166 /* Protocol v3+ also contains the context ID. */ 1167 pClient-> protocol() >= 3 ? 1 : 0);1167 pClient->GetProtocolVer() >= 3 ? 1 : 0); 1168 1168 pClient->completeDeferred(rc2); 1169 1169 … … 1233 1233 * count. The message itself has to be queued. 1234 1234 */ 1235 uint32_t uMsgClient = pClient-> message();1235 uint32_t uMsgClient = pClient->GetMsgType(); 1236 1236 1237 1237 uint32_t uMsgNext = 0; … … 1265 1265 { 1266 1266 LogFunc(("Client ID=%RU32 in wrong state with uMsg=%RU32 (next message in queue: %RU32), cancelling\n", 1267 pClient-> clientId(), uMsgClient, uMsgNext));1267 pClient->GetClientID(), uMsgClient, uMsgNext)); 1268 1268 1269 1269 pClient->completeDeferred(VERR_CANCELLED);
Note:
See TracChangeset
for help on using the changeset viewer.