Changeset 36872 in vbox for trunk/src/VBox
- Timestamp:
- Apr 28, 2011 8:53:57 AM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 71449
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/GuestControl/service.cpp
r36743 r36872 309 309 int Service::paramBufferAllocate(PVBOXGUESTCTRPARAMBUFFER pBuf, uint32_t uMsg, uint32_t cParms, VBOXHGCMSVCPARM paParms[]) 310 310 { 311 AssertPtr(pBuf); 312 int rc = VINF_SUCCESS; 311 AssertPtrReturn(pBuf, VERR_INVALID_POINTER); 312 if (cParms) 313 AssertPtrReturn(paParms, VERR_INVALID_POINTER); 313 314 314 315 /* Paranoia. */ 315 316 if (cParms > 256) 316 317 cParms = 256; 318 319 int rc = VINF_SUCCESS; 317 320 318 321 /* … … 321 324 * in an unmodified state. 322 325 */ 323 if (RT_SUCCESS(rc))324 {325 pBuf->uMsg = uMsg;326 pBuf->uParmCount = cParms;326 pBuf->uMsg = uMsg; 327 pBuf->uParmCount = cParms; 328 if (pBuf->uParmCount) 329 { 327 330 pBuf->pParms = (VBOXHGCMSVCPARM*)RTMemAlloc(sizeof(VBOXHGCMSVCPARM) * pBuf->uParmCount); 328 331 if (NULL == pBuf->pParms) 329 {330 332 rc = VERR_NO_MEMORY; 331 } 332 else 333 { 334 for (uint32_t i = 0; i < pBuf->uParmCount; i++) 333 } 334 335 if (RT_SUCCESS(rc)) 336 { 337 for (uint32_t i = 0; i < pBuf->uParmCount; i++) 338 { 339 pBuf->pParms[i].type = paParms[i].type; 340 switch (paParms[i].type) 335 341 { 336 pBuf->pParms[i].type = paParms[i].type;337 switch (paParms[i].type)338 {339 case VBOX_HGCM_SVC_PARM_32BIT: 340 pBuf->pParms[i].u.uint32 = paParms[i].u.uint32;341 break;342 343 case VBOX_HGCM_SVC_PARM_64BIT: 344 /* Not supported yet. */345 break;346 347 case VBOX_HGCM_SVC_PARM_PTR:348 pBuf->pParms[i].u.pointer. size = paParms[i].u.pointer.size;349 if ( pBuf->pParms[i].u.pointer.size > 0)342 case VBOX_HGCM_SVC_PARM_32BIT: 343 pBuf->pParms[i].u.uint32 = paParms[i].u.uint32; 344 break; 345 346 case VBOX_HGCM_SVC_PARM_64BIT: 347 /* Not supported yet. */ 348 break; 349 350 case VBOX_HGCM_SVC_PARM_PTR: 351 pBuf->pParms[i].u.pointer.size = paParms[i].u.pointer.size; 352 if (pBuf->pParms[i].u.pointer.size > 0) 353 { 354 pBuf->pParms[i].u.pointer.addr = RTMemAlloc(pBuf->pParms[i].u.pointer.size); 355 if (NULL == pBuf->pParms[i].u.pointer.addr) 350 356 { 351 pBuf->pParms[i].u.pointer.addr = RTMemAlloc(pBuf->pParms[i].u.pointer.size); 352 if (NULL == pBuf->pParms[i].u.pointer.addr) 353 { 354 rc = VERR_NO_MEMORY; 355 break; 356 } 357 else 358 memcpy(pBuf->pParms[i].u.pointer.addr, 359 paParms[i].u.pointer.addr, 360 pBuf->pParms[i].u.pointer.size); 357 rc = VERR_NO_MEMORY; 358 break; 361 359 } 362 360 else 363 { 364 /* Size is 0 -- make sure we don't have any pointer. */ 365 pBuf->pParms[i].u.pointer.addr = NULL; 366 } 367 break; 368 369 default: 370 break; 371 } 372 if (RT_FAILURE(rc)) 361 memcpy(pBuf->pParms[i].u.pointer.addr, 362 paParms[i].u.pointer.addr, 363 pBuf->pParms[i].u.pointer.size); 364 } 365 else 366 { 367 /* Size is 0 -- make sure we don't have any pointer. */ 368 pBuf->pParms[i].u.pointer.addr = NULL; 369 } 370 break; 371 372 default: 373 373 break; 374 374 } 375 if (RT_FAILURE(rc)) 376 break; 375 377 } 376 378 } … … 785 787 if (mNumClients == 0) 786 788 return VERR_NOT_FOUND; 787 788 789 HostCmd newCmd; 789 790 int rc = paramBufferAllocate(&newCmd.mParmBuf, eFunction, cParms, paParms); 790 if ( RT_SUCCESS(rc) 791 && newCmd.mParmBuf.uParmCount > 0) 791 if (RT_SUCCESS(rc) && cParms) 792 792 { 793 793 /* … … 799 799 } 800 800 801 bool fProcessed = false;802 801 if (RT_SUCCESS(rc)) 803 802 { 803 bool fProcessed = false; 804 804 805 /* Can we wake up a waiting client on guest? */ 805 806 if (!mClientWaiterList.empty()) … … 814 815 mClientWaiterList.pop_front(); 815 816 816 /* If we got VERR_TOO_MUCH_DATA we buffer the host command in the next block 817 * and return success to the host. */ 818 if (rc == VERR_TOO_MUCH_DATA) 817 /* 818 * If we got back an error (like VERR_TOO_MUCH_DATA or VERR_BUFFER_OVERFLOW) 819 * we buffer the host command in the next block and return success to the host. 820 */ 821 if (RT_FAILURE(rc)) 819 822 { 820 823 rc = VINF_SUCCESS; … … 932 935 switch (eFunction) 933 936 { 937 case HOST_CANCEL_PENDING_WAITS: 938 LogFlowFunc(("HOST_CANCEL_PENDING_WAITS\n")); 939 rc = processHostCmd(eFunction, cParms, paParms); 940 break; 941 934 942 /* The host wants to execute something. */ 935 943 case HOST_EXEC_CMD:
Note:
See TracChangeset
for help on using the changeset viewer.