Changeset 73939 in vbox for trunk/include/VBox/HostServices
- Timestamp:
- Aug 29, 2018 7:56:40 AM (6 years ago)
- File:
-
- 1 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
Note:
See TracChangeset
for help on using the changeset viewer.