Changeset 21485 in vbox for trunk/include
- Timestamp:
- Jul 10, 2009 4:33:50 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 49929
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/shflsvc.h
r21227 r21485 141 141 #define SHFL_MAX_MAPPINGS (64) 142 142 143 /** Shared Folders strings. They can be either UTF8 or Unicode. 144 * @{ 145 */ 146 143 /** @name Shared Folders strings. They can be either UTF-8 or UTF-16. 144 * @{ 145 */ 146 147 /** 148 * Shared folder string buffer structure. 149 */ 147 150 typedef struct _SHFLSTRING 148 151 { 149 /** Size of string String buffer in bytes. */152 /** Size of the String member in bytes. */ 150 153 uint16_t u16Size; 151 154 … … 153 156 uint16_t u16Length; 154 157 155 /** UTF 8 or Unicode16 string. Nul terminated. */158 /** UTF-8 or UTF-16 string. Nul terminated. */ 156 159 union 157 160 { … … 161 164 } SHFLSTRING; 162 165 166 /** Pointer to a shared folder string buffer. */ 163 167 typedef SHFLSTRING *PSHFLSTRING; 168 /** Pointer to a const shared folder string buffer. */ 169 typedef const SHFLSTRING *PCSHFLSTRING; 164 170 165 171 /** Calculate size of the string. */ 166 DECLINLINE(uint32_t) ShflStringSizeOfBuffer (P SHFLSTRING pString)172 DECLINLINE(uint32_t) ShflStringSizeOfBuffer (PCSHFLSTRING pString) 167 173 { 168 174 return pString? sizeof (SHFLSTRING) - sizeof (pString->String) + pString->u16Size: 0; 169 175 } 170 176 171 DECLINLINE(uint32_t) ShflStringLength (P SHFLSTRING pString)177 DECLINLINE(uint32_t) ShflStringLength (PCSHFLSTRING pString) 172 178 { 173 179 return pString? pString->u16Length: 0; … … 191 197 192 198 return pString; 199 } 200 201 /** 202 * Validates a HGCM string parameter. 203 * 204 * @returns true if valid, false if not. 205 * 206 * @param pString The string buffer pointer. 207 * @param cbBuf The buffer size from the parameter. 208 */ 209 DECLINLINE(bool) ShflStringIsValid(PCSHFLSTRING pString, uint32_t cbBuf) 210 { 211 if (RT_UNLIKELY(cbBuf <= RT_UOFFSETOF(SHFLSTRING, String))) 212 return false; 213 if (RT_UNLIKELY((uint32_t)pString->u16Size + RT_UOFFSETOF(SHFLSTRING, String) > cbBuf)) 214 return false; 215 if (RT_UNLIKELY(pString->u16Length >= pString->u16Size)) 216 return false; 217 return true; 218 } 219 220 /** 221 * Validates an optional HGCM string parameter. 222 * 223 * @returns true if valid, false if not. 224 * 225 * @param pString The string buffer pointer. Can be NULL. 226 * @param cbBuf The buffer size from the parameter. 227 */ 228 DECLINLINE(bool) ShflStringIsValidOrNull(PCSHFLSTRING pString, uint32_t cbBuf) 229 { 230 if (pString) 231 return ShflStringIsValid(pString, cbBuf); 232 if (RT_UNLIKELY(cbBuf > 0)) 233 return false; 234 return true; 193 235 } 194 236
Note:
See TracChangeset
for help on using the changeset viewer.