Changeset 39440 in vbox
- Timestamp:
- Nov 28, 2011 2:06:19 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/GuestControl/service.cpp
r39427 r39440 281 281 int paramBufferAllocate(PVBOXGUESTCTRPARAMBUFFER pBuf, uint32_t uMsg, uint32_t cParms, VBOXHGCMSVCPARM paParms[]); 282 282 void paramBufferFree(PVBOXGUESTCTRPARAMBUFFER pBuf); 283 int paramBufferAssign( PVBOXGUESTCTRPARAMBUFFER pBuf, uint32_t cParms, VBOXHGCMSVCPARM paParms[]);283 int paramBufferAssign(VBOXHGCMSVCPARM paDstParms[], uint32_t cDstParms, PVBOXGUESTCTRPARAMBUFFER pSrcBuf); 284 284 int prepareExecute(uint32_t cParms, VBOXHGCMSVCPARM paParms[]); 285 285 int clientConnect(uint32_t u32ClientID, void *pvClient); … … 408 408 409 409 /** 410 * Assigns data from a buffered HGCM request to the current HGCM request.410 * Copies data from a buffered HGCM request to the current HGCM request. 411 411 * 412 412 * @return IPRT status code. 413 * @param p Buf Parameter buffer to assign.414 * @param cP armsNumber of parameters the HGCM request can handle.415 * @param p aParms Array of parameters of HGCM request to fill the data into.416 */ 417 int Service::paramBufferAssign( PVBOXGUESTCTRPARAMBUFFER pBuf, uint32_t cParms, VBOXHGCMSVCPARM paParms[])418 { 419 AssertPtr(p Buf);413 * @param paDstParms Array of parameters of HGCM request to fill the data into. 414 * @param cPDstarms Number of parameters the HGCM request can handle. 415 * @param pSrcBuf Parameter buffer to assign. 416 */ 417 int Service::paramBufferAssign(VBOXHGCMSVCPARM paDstParms[], uint32_t cDstParms, PVBOXGUESTCTRPARAMBUFFER pSrcBuf) 418 { 419 AssertPtr(pSrcBuf); 420 420 int rc = VINF_SUCCESS; 421 if (c Parms != pBuf->uParmCount)422 { 423 LogFlowFunc(("Parameter count does not match : %u (host) vs. %u (guest)\n",424 p Buf->uParmCount, cParms));421 if (cDstParms != pSrcBuf->uParmCount) 422 { 423 LogFlowFunc(("Parameter count does not match (got %u, expected %u)\n", 424 pSrcBuf->uParmCount, cDstParms)); 425 425 rc = VERR_INVALID_PARAMETER; 426 426 } 427 427 else 428 428 { 429 /** @todo Add check to verify if the HGCM request is the same *type* as the buffered one! */ 430 for (uint32_t i = 0; i < pBuf->uParmCount; i++) 431 { 432 /** @todo r=bird: Should this CHECK the type instead of overriding 433 * it?? What happens if a guest initializes a PTR param as a 32-bit 434 * or 64-bit value with a non-zero value? You'll crash and burn in 435 * the memcpy below! */ 436 paParms[i].type = pBuf->pParms[i].type; 437 switch (paParms[i].type) 429 for (uint32_t i = 0; i < pSrcBuf->uParmCount; i++) 430 { 431 if (paDstParms[i].type != pSrcBuf->pParms[i].type) 438 432 { 439 case VBOX_HGCM_SVC_PARM_32BIT: 440 paParms[i].u.uint32 = pBuf->pParms[i].u.uint32; 441 break; 442 443 case VBOX_HGCM_SVC_PARM_64BIT: 444 /* Not supported yet. */ 445 /** @todo r=bird: This case needs to fail! */ 446 break; 447 448 case VBOX_HGCM_SVC_PARM_PTR: 449 if (paParms[i].u.pointer.size >= pBuf->pParms[i].u.pointer.size) 433 LogFlowFunc(("Parameter %u type mismatch (got %u, expected %u)\n", 434 i, paDstParms[i].type, pSrcBuf->pParms[i].type)); 435 rc = VERR_INVALID_PARAMETER; 436 } 437 else 438 { 439 switch (pSrcBuf->pParms[i].type) 440 { 441 case VBOX_HGCM_SVC_PARM_32BIT: 442 paDstParms[i].u.uint32 = pSrcBuf->pParms[i].u.uint32; 443 break; 444 445 case VBOX_HGCM_SVC_PARM_PTR: 450 446 { 451 /* Only copy buffer if there actually is something to copy. */ 452 if (pBuf->pParms[i].u.pointer.size) 447 if (!pSrcBuf->pParms[i].u.pointer.size) 448 continue; /* Only copy buffer if there actually is something to copy. */ 449 450 if (!paDstParms[i].u.pointer.addr) 451 rc = VERR_INVALID_PARAMETER; 452 453 if (paDstParms[i].u.pointer.size < pSrcBuf->pParms[i].u.pointer.size) 454 rc = VERR_BUFFER_OVERFLOW; 455 456 if (RT_SUCCESS(rc)) 453 457 { 454 AssertPtr(pBuf->pParms[i].u.pointer.addr); 455 memcpy(paParms[i].u.pointer.addr, 456 pBuf->pParms[i].u.pointer.addr, 457 pBuf->pParms[i].u.pointer.size); 458 memcpy(paDstParms[i].u.pointer.addr, 459 pSrcBuf->pParms[i].u.pointer.addr, 460 pSrcBuf->pParms[i].u.pointer.size); 458 461 } 462 463 break; 459 464 } 460 else 461 rc = VERR_BUFFER_OVERFLOW; 462 break; 463 464 default: 465 /** @todo r=bird: This case needs to fail! */ 466 break; 465 466 case VBOX_HGCM_SVC_PARM_64BIT: 467 /* Fall through is intentional. */ 468 default: 469 LogFlowFunc(("Parameter %u of type %u is not supported yet\n", 470 i, pSrcBuf->pParms[i].type)); 471 rc = VERR_NOT_SUPPORTED; 472 break; 473 } 474 } 475 476 if (RT_FAILURE(rc)) 477 { 478 LogFlowFunc(("Parameter %u invalid (rc=%Rrc), refusing\n", 479 i, rc)); 480 break; 467 481 } 468 482 } … … 621 635 else 622 636 { 623 rc = paramBufferAssign( &pCmd->mParmBuf, cParms, paParms);637 rc = paramBufferAssign(paParms, cParms, &pCmd->mParmBuf); 624 638 } 625 639
Note:
See TracChangeset
for help on using the changeset viewer.