Changeset 39603 in vbox for trunk/src/VBox/HostServices/SharedOpenGL
- Timestamp:
- Dec 14, 2011 11:12:56 AM (13 years ago)
- Location:
- trunk/src/VBox/HostServices/SharedOpenGL
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedOpenGL/crserver/crservice.cpp
r39507 r39603 939 939 if (cParms == 1 && paParms[0].type == VBOX_HGCM_SVC_PARM_PTR) 940 940 { 941 rc = crVBoxServerCrHgsmiCmd((PVBOXVDMACMD_CHROMIUM_CMD)paParms[0].u.pointer.addr );941 rc = crVBoxServerCrHgsmiCmd((PVBOXVDMACMD_CHROMIUM_CMD)paParms[0].u.pointer.addr, paParms[0].u.pointer.size); 942 942 if (VERR_NOT_SUPPORTED == rc) 943 943 { … … 952 952 Assert(cParms == 1 && paParms[0].type == VBOX_HGCM_SVC_PARM_PTR); 953 953 if (cParms == 1 && paParms[0].type == VBOX_HGCM_SVC_PARM_PTR) 954 rc = crVBoxServerCrHgsmiCtl((PVBOXVDMACMD_CHROMIUM_CTL)paParms[0].u.pointer.addr );954 rc = crVBoxServerCrHgsmiCtl((PVBOXVDMACMD_CHROMIUM_CTL)paParms[0].u.pointer.addr, paParms[0].u.pointer.size); 955 955 else 956 956 rc = VERR_INVALID_PARAMETER; -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server.h
r39288 r39603 20 20 21 21 extern uint8_t* g_pvVRamBase; 22 extern uint32_t g_cbVRam; 22 23 extern HCRHGSMICMDCOMPLETION g_hCrHgsmiCompletion; 23 24 extern PFNCRHGSMICMDCOMPLETION g_pfnCrHgsmiCompletion; 24 25 25 26 #define VBOXCRHGSMI_PTR(_off, _t) ((_t*)(g_pvVRamBase + (_off))) 27 #define VBOXCRHGSMI_PTR_SAFE(_off, _cb, _t) ((_t*)crServerCrHgsmiPtrGet(_off, _cb)) 28 29 DECLINLINE(void*) crServerCrHgsmiPtrGet(VBOXVIDEOOFFSET offBuffer, uint32_t cbBuffer) 30 { 31 return ((offBuffer) + (cbBuffer) <= g_cbVRam ? VBOXCRHGSMI_PTR(offBuffer, void) : NULL); 32 } 26 33 27 34 DECLINLINE(void) crServerCrHgsmiCmdComplete(struct VBOXVDMACMD_CHROMIUM_CMD *pCmd, int cmdProcessingRc) -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c
r39288 r39603 33 33 # include <VBox/HostServices/VBoxCrOpenGLSvc.h> 34 34 uint8_t* g_pvVRamBase = NULL; 35 uint32_t g_cbVRam = 0; 35 36 HCRHGSMICMDCOMPLETION g_hCrHgsmiCompletion = NULL; 36 37 PFNCRHGSMICMDCOMPLETION g_pfnCrHgsmiCompletion = NULL; … … 1353 1354 * NOTE: it is ALWAYS responsibility of the crVBoxServerCrHgsmiCmd to complete the command! 1354 1355 * */ 1355 int32_t crVBoxServerCrHgsmiCmd(struct VBOXVDMACMD_CHROMIUM_CMD *pCmd )1356 int32_t crVBoxServerCrHgsmiCmd(struct VBOXVDMACMD_CHROMIUM_CMD *pCmd, uint32_t cbCmd) 1356 1357 { 1357 1358 int32_t rc; 1358 1359 uint32_t cBuffers = pCmd->cBuffers; 1359 1360 uint32_t cParams; 1361 uint32_t cbHdr; 1360 1362 CRVBOXHGSMIHDR *pHdr; 1361 1363 uint32_t u32Function; … … 1365 1367 if (!g_pvVRamBase) 1366 1368 { 1367 CRASSERT(0);1369 crWarning("g_pvVRamBase is not initialized"); 1368 1370 crServerCrHgsmiCmdComplete(pCmd, VERR_INVALID_STATE); 1369 1371 return VINF_SUCCESS; … … 1372 1374 if (!cBuffers) 1373 1375 { 1374 CRASSERT(0);1376 crWarning("zero buffers passed in!"); 1375 1377 crServerCrHgsmiCmdComplete(pCmd, VERR_INVALID_PARAMETER); 1376 1378 return VINF_SUCCESS; … … 1379 1381 cParams = cBuffers-1; 1380 1382 1381 pHdr = VBOXCRHGSMI_PTR(pCmd->aBuffers[0].offBuffer, CRVBOXHGSMIHDR); 1383 cbHdr = pCmd->aBuffers[0].cbBuffer; 1384 pHdr = VBOXCRHGSMI_PTR_SAFE(pCmd->aBuffers[0].offBuffer, cbHdr, CRVBOXHGSMIHDR); 1385 if (!pHdr) 1386 { 1387 crWarning("invalid header buffer!"); 1388 crServerCrHgsmiCmdComplete(pCmd, VERR_INVALID_PARAMETER); 1389 return VINF_SUCCESS; 1390 } 1391 1392 if (cbHdr < sizeof (*pHdr)) 1393 { 1394 crWarning("invalid header buffer size!"); 1395 crServerCrHgsmiCmdComplete(pCmd, VERR_INVALID_PARAMETER); 1396 return VINF_SUCCESS; 1397 } 1398 1382 1399 u32Function = pHdr->u32Function; 1383 1400 u32ClientID = pHdr->u32ClientID; … … 1395 1412 VBOXVDMACMD_CHROMIUM_BUFFER *pBuf = &pCmd->aBuffers[1]; 1396 1413 /* Fetch parameters. */ 1397 uint8_t *pBuffer = VBOXCRHGSMI_PTR(pBuf->offBuffer, uint8_t);1398 1414 uint32_t cbBuffer = pBuf->cbBuffer; 1399 1400 CRASSERT(pBuffer); 1415 uint8_t *pBuffer = VBOXCRHGSMI_PTR_SAFE(pBuf->offBuffer, cbBuffer, uint8_t); 1416 1417 if (cbHdr < sizeof (*pFnCmd)) 1418 { 1419 crWarning("invalid write cmd buffer size!"); 1420 rc = VERR_INVALID_PARAMETER; 1421 break; 1422 } 1423 1401 1424 CRASSERT(cbBuffer); 1425 if (!pBuffer) 1426 { 1427 crWarning("invalid buffer data received from guest!"); 1428 rc = VERR_INVALID_PARAMETER; 1429 break; 1430 } 1402 1431 1403 1432 rc = crVBoxServerClientGet(u32ClientID, &pClient); … … 1438 1467 uint32_t u32InjectClientID = pFnCmd->u32ClientID; 1439 1468 VBOXVDMACMD_CHROMIUM_BUFFER *pBuf = &pCmd->aBuffers[1]; 1440 uint8_t *pBuffer = VBOXCRHGSMI_PTR(pBuf->offBuffer, uint8_t);1441 1469 uint32_t cbBuffer = pBuf->cbBuffer; 1442 1443 CRASSERT(pBuffer); 1470 uint8_t *pBuffer = VBOXCRHGSMI_PTR_SAFE(pBuf->offBuffer, cbBuffer, uint8_t); 1471 1472 if (cbHdr < sizeof (*pFnCmd)) 1473 { 1474 crWarning("invalid inject cmd buffer size!"); 1475 rc = VERR_INVALID_PARAMETER; 1476 break; 1477 } 1478 1444 1479 CRASSERT(cbBuffer); 1480 if (!pBuffer) 1481 { 1482 crWarning("invalid buffer data received from guest!"); 1483 rc = VERR_INVALID_PARAMETER; 1484 break; 1485 } 1445 1486 1446 1487 rc = crVBoxServerClientGet(u32InjectClientID, &pClient); … … 1477 1518 VBOXVDMACMD_CHROMIUM_BUFFER *pBuf = &pCmd->aBuffers[1]; 1478 1519 /* Fetch parameters. */ 1479 uint8_t *pBuffer = VBOXCRHGSMI_PTR(pBuf->offBuffer, uint8_t);1480 1520 uint32_t cbBuffer = pBuf->cbBuffer; 1521 uint8_t *pBuffer = VBOXCRHGSMI_PTR_SAFE(pBuf->offBuffer, cbBuffer, uint8_t); 1522 1523 if (cbHdr < sizeof (*pFnCmd)) 1524 { 1525 crWarning("invalid read cmd buffer size!"); 1526 rc = VERR_INVALID_PARAMETER; 1527 break; 1528 } 1529 1530 1531 if (!pBuffer) 1532 { 1533 crWarning("invalid buffer data received from guest!"); 1534 rc = VERR_INVALID_PARAMETER; 1535 break; 1536 } 1481 1537 1482 1538 rc = crVBoxServerClientGet(u32ClientID, &pClient); … … 1518 1574 1519 1575 /* Fetch parameters. */ 1520 uint8_t *pBuffer = VBOXCRHGSMI_PTR(pBuf->offBuffer, uint8_t);1521 1576 uint32_t cbBuffer = pBuf->cbBuffer; 1522 1523 uint8_t *pWriteback = VBOXCRHGSMI_PTR(pWbBuf->offBuffer, uint8_t); 1577 uint8_t *pBuffer = VBOXCRHGSMI_PTR_SAFE(pBuf->offBuffer, cbBuffer, uint8_t); 1578 1524 1579 uint32_t cbWriteback = pWbBuf->cbBuffer; 1525 1526 CRASSERT(pBuffer); 1580 uint8_t *pWriteback = VBOXCRHGSMI_PTR_SAFE(pWbBuf->offBuffer, cbWriteback, uint8_t); 1581 1582 if (cbHdr < sizeof (*pFnCmd)) 1583 { 1584 crWarning("invalid write_read cmd buffer size!"); 1585 rc = VERR_INVALID_PARAMETER; 1586 break; 1587 } 1588 1589 1527 1590 CRASSERT(cbBuffer); 1528 1591 if (!pBuffer) 1592 { 1593 crWarning("invalid write buffer data received from guest!"); 1594 rc = VERR_INVALID_PARAMETER; 1595 break; 1596 } 1597 1598 CRASSERT(cbWriteback); 1599 if (!pWriteback) 1600 { 1601 crWarning("invalid writeback buffer data received from guest!"); 1602 rc = VERR_INVALID_PARAMETER; 1603 break; 1604 } 1529 1605 rc = crVBoxServerClientGet(u32ClientID, &pClient); 1530 1606 if (RT_FAILURE(rc)) … … 1582 1658 } 1583 1659 1584 int32_t crVBoxServerCrHgsmiCtl(struct VBOXVDMACMD_CHROMIUM_CTL *pCtl )1660 int32_t crVBoxServerCrHgsmiCtl(struct VBOXVDMACMD_CHROMIUM_CTL *pCtl, uint32_t cbCtl) 1585 1661 { 1586 1662 int rc = VINF_SUCCESS; … … 1591 1667 { 1592 1668 PVBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP pSetup = (PVBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP)pCtl; 1593 g_pvVRamBase = (uint8_t*)pSetup->pvRamBase; 1669 g_pvVRamBase = (uint8_t*)pSetup->pvVRamBase; 1670 g_cbVRam = pSetup->cbVRam; 1594 1671 rc = VINF_SUCCESS; 1595 1672 break;
Note:
See TracChangeset
for help on using the changeset viewer.