Changeset 55326 in vbox
- Timestamp:
- Apr 17, 2015 12:19:00 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/hgcmsvc.h
r44528 r55326 4 4 5 5 /* 6 * Copyright (C) 2006-201 1Oracle Corporation6 * Copyright (C) 2006-2015 Oracle Corporation 7 7 * 8 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 28 28 29 29 #include <iprt/assert.h> 30 #include <iprt/mem.h> 30 31 #include <iprt/string.h> 31 32 #include <VBox/cdefs.h> … … 88 89 89 90 #define VBOX_HGCM_SVC_PARM_INVALID (0U) 90 #define VBOX_HGCM_SVC_PARM_32BIT (1U)91 #define VBOX_HGCM_SVC_PARM_64BIT (2U)92 #define VBOX_HGCM_SVC_PARM_PTR (3U)91 #define VBOX_HGCM_SVC_PARM_32BIT (1U) 92 #define VBOX_HGCM_SVC_PARM_64BIT (2U) 93 #define VBOX_HGCM_SVC_PARM_PTR (3U) 93 94 94 95 typedef struct VBOXHGCMSVCPARM … … 109 110 #ifdef __cplusplus 110 111 /** Extract a uint32_t value from an HGCM parameter structure */ 111 int getUInt32 112 int getUInt32(uint32_t *u32) 112 113 { 113 114 AssertPtrReturn(u32, VERR_INVALID_POINTER); … … 121 122 122 123 /** Extract a uint64_t value from an HGCM parameter structure */ 123 int getUInt64 124 int getUInt64(uint64_t *u64) 124 125 { 125 126 AssertPtrReturn(u64, VERR_INVALID_POINTER); … … 133 134 134 135 /** Extract a pointer value from an HGCM parameter structure */ 135 int getPointer 136 int getPointer(void **ppv, uint32_t *pcb) 136 137 { 137 138 AssertPtrReturn(ppv, VERR_INVALID_POINTER); … … 148 149 149 150 /** Extract a constant pointer value from an HGCM parameter structure */ 150 int getPointer 151 int getPointer(const void **ppcv, uint32_t *pcb) 151 152 { 152 153 AssertPtrReturn(ppcv, VERR_INVALID_POINTER); … … 160 161 /** Extract a pointer value to a non-empty buffer from an HGCM parameter 161 162 * structure */ 162 int getBuffer 163 int getBuffer(void **ppv, uint32_t *pcb) 163 164 { 164 165 AssertPtrReturn(ppv, VERR_INVALID_POINTER); … … 181 182 /** Extract a pointer value to a non-empty constant buffer from an HGCM 182 183 * parameter structure */ 183 int getBuffer 184 int getBuffer(const void **ppcv, uint32_t *pcb) 184 185 { 185 186 AssertPtrReturn(ppcv, VERR_INVALID_POINTER); … … 192 193 193 194 /** Extract a string value from an HGCM parameter structure */ 194 int getString 195 int getString(char **ppch, uint32_t *pcb) 195 196 { 196 197 uint32_t cb = 0; … … 211 212 212 213 /** Extract a constant string value from an HGCM parameter structure */ 213 int getString 214 int getString(const char **ppch, uint32_t *pcb) 214 215 { 215 216 char *pch = NULL; … … 234 235 235 236 /** Set a pointer value to an HGCM parameter structure */ 236 void setPointer(void *pv, uint32_t cb)237 int setPointer(void *pv, uint32_t cb, bool fDeepCopy = false) 237 238 { 238 239 type = VBOX_HGCM_SVC_PARM_PTR; 239 u.pointer.addr = pv; 240 void *addr = fDeepCopy ? RTMemDup(pv, cb) : pv; 241 if (fDeepCopy && !addr) 242 return VERR_NO_MEMORY; 243 u.pointer.addr = addr; 240 244 u.pointer.size = cb; 241 245 } 242 246 243 247 /** Set a const string value to an HGCM parameter structure */ 244 void setString(const char *psz)248 int setString(const char *psz, bool fDeepCopy = false) 245 249 { 246 250 type = VBOX_HGCM_SVC_PARM_PTR; 247 u.pointer.addr = (void *)psz; 248 u.pointer.size = (uint32_t)strlen(psz) + 1; 251 void *pszaddr = fDeepCopy ? (void *)RTStrDup(psz) : (void *)psz; 252 if (fDeepCopy && !pszaddr) 253 return VERR_NO_MEMORY; 254 u.pointer.addr = pszaddr; 255 u.pointer.size = (uint32_t)strlen((char *)pszaddr) + 1; 249 256 } 250 257 … … 313 320 314 321 VBOXHGCMSVCPARM() : type(VBOX_HGCM_SVC_PARM_INVALID) {} 315 #endif 322 #endif /* __cplusplus */ 316 323 } VBOXHGCMSVCPARM; 317 324
Note:
See TracChangeset
for help on using the changeset viewer.