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