Changeset 97610 in vbox for trunk/src/VBox
- Timestamp:
- Nov 18, 2022 5:29:35 PM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 154654
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/GuestFileImpl.cpp
r97609 r97610 534 534 case GUEST_FILE_NOTIFYTYPE_READ: 535 535 { 536 if (pSvcCbData->mParms == 4) 536 ASSERT_GUEST_MSG_STMT_BREAK(pSvcCbData->mParms == 4, ("mParms=%u\n", pSvcCbData->mParms), 537 vrc = VERR_WRONG_PARAMETER_COUNT); 538 ASSERT_GUEST_MSG_STMT_BREAK(pSvcCbData->mpaParms[idx].type == VBOX_HGCM_SVC_PARM_PTR, 539 ("type=%u\n", pSvcCbData->mpaParms[idx].type), 540 vrc = VERR_WRONG_PARAMETER_TYPE); 541 542 vrc = HGCMSvcGetPv(&pSvcCbData->mpaParms[idx++], &dataCb.u.read.pvData, &dataCb.u.read.cbData); 543 if (RT_FAILURE(vrc)) 544 break; 545 546 const uint32_t cbRead = dataCb.u.read.cbData; 547 Log3ThisFunc(("cbRead=%RU32\n", cbRead)); 548 549 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 550 mData.mOffCurrent += cbRead; /* Bogus for readAt, which is why we've got GUEST_FILE_NOTIFYTYPE_READ_OFFSET. */ 551 alock.release(); 552 553 try 537 554 { 538 vrc = HGCMSvcGetPv(&pSvcCbData->mpaParms[idx++], &dataCb.u.read.pvData,539 &dataCb.u.read.cbData);540 if (RT_FAILURE(vrc))541 break;542 543 const uint32_t cbRead = dataCb.u.read.cbData;544 545 Log3ThisFunc(("cbRead=%RU32\n", cbRead));546 547 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);548 549 mData.mOffCurrent += cbRead; /* Bogus for readAt, which is why we've got GUEST_FILE_NOTIFYTYPE_READ_OFFSET. */550 551 alock.release();552 553 555 com::SafeArray<BYTE> data((size_t)cbRead); 556 AssertBreakStmt(data.size() == cbRead, vrc = VERR_NO_MEMORY); 554 557 data.initFrom((BYTE *)dataCb.u.read.pvData, cbRead); 555 556 558 ::FireGuestFileReadEvent(mEventSource, mSession, this, mData.mOffCurrent, cbRead, ComSafeArrayAsInParam(data)); 559 } 560 catch (std::bad_alloc &) 561 { 562 vrc = VERR_NO_MEMORY; 557 563 } 558 564 break; … … 567 573 vrc = VERR_WRONG_PARAMETER_TYPE); 568 574 ASSERT_GUEST_MSG_STMT_BREAK(pSvcCbData->mpaParms[idx + 1].type == VBOX_HGCM_SVC_PARM_64BIT, 569 ("type=%u\n", pSvcCbData->mpaParms[idx ].type),575 ("type=%u\n", pSvcCbData->mpaParms[idx + 1].type), 570 576 vrc = VERR_WRONG_PARAMETER_TYPE); 571 577 BYTE const * const pbData = (BYTE const *)pSvcCbData->mpaParms[idx].u.pointer.addr; … … 583 589 { 584 590 com::SafeArray<BYTE> data((size_t)cbRead); 591 AssertBreakStmt(data.size() == cbRead, vrc = VERR_NO_MEMORY); 585 592 data.initFrom(pbData, cbRead); 586 593 ::FireGuestFileReadEvent(mEventSource, mSession, this, offNew, cbRead, ComSafeArrayAsInParam(data)); … … 596 603 case GUEST_FILE_NOTIFYTYPE_WRITE: 597 604 { 598 if (pSvcCbData->mParms == 4) 599 { 600 vrc = HGCMSvcGetU32(&pSvcCbData->mpaParms[idx++], &dataCb.u.write.cbWritten); 601 if (RT_FAILURE(vrc)) 602 break; 603 604 const uint32_t cbWritten = dataCb.u.write.cbWritten; 605 606 Log3ThisFunc(("cbWritten=%RU32\n", cbWritten)); 607 608 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 609 610 mData.mOffCurrent += cbWritten; /* Bogus for writeAt and append mode, thus GUEST_FILE_NOTIFYTYPE_WRITE_OFFSET. */ 611 612 alock.release(); 613 614 ::FireGuestFileWriteEvent(mEventSource, mSession, this, mData.mOffCurrent, cbWritten); 615 } 605 ASSERT_GUEST_MSG_STMT_BREAK(pSvcCbData->mParms == 4, ("mParms=%u\n", pSvcCbData->mParms), 606 vrc = VERR_WRONG_PARAMETER_COUNT); 607 ASSERT_GUEST_MSG_STMT_BREAK(pSvcCbData->mpaParms[idx].type == VBOX_HGCM_SVC_PARM_32BIT, 608 ("type=%u\n", pSvcCbData->mpaParms[idx].type), 609 vrc = VERR_WRONG_PARAMETER_TYPE); 610 611 uint32_t const cbWritten = pSvcCbData->mpaParms[idx].u.uint32; 612 613 Log3ThisFunc(("cbWritten=%RU32\n", cbWritten)); 614 615 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 616 mData.mOffCurrent += cbWritten; /* Bogus for writeAt and append mode, thus GUEST_FILE_NOTIFYTYPE_WRITE_OFFSET. */ 617 alock.release(); 618 619 ::FireGuestFileWriteEvent(mEventSource, mSession, this, mData.mOffCurrent, cbWritten); 616 620 break; 617 621 } … … 644 648 case GUEST_FILE_NOTIFYTYPE_SEEK: 645 649 { 646 if (pSvcCbData->mParms == 4) 647 { 648 vrc = HGCMSvcGetU64(&pSvcCbData->mpaParms[idx++], &dataCb.u.seek.uOffActual); 649 if (RT_FAILURE(vrc)) 650 break; 651 652 Log3ThisFunc(("uOffActual=%RU64\n", dataCb.u.seek.uOffActual)); 653 654 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 655 656 mData.mOffCurrent = dataCb.u.seek.uOffActual; 657 658 alock.release(); 659 660 ::FireGuestFileOffsetChangedEvent(mEventSource, mSession, this, dataCb.u.seek.uOffActual, 0 /* Processed */); 661 } 650 ASSERT_GUEST_MSG_STMT_BREAK(pSvcCbData->mParms == 4, ("mParms=%u\n", pSvcCbData->mParms), 651 vrc = VERR_WRONG_PARAMETER_COUNT); 652 653 vrc = HGCMSvcGetU64(&pSvcCbData->mpaParms[idx++], &dataCb.u.seek.uOffActual); 654 if (RT_FAILURE(vrc)) 655 break; 656 657 Log3ThisFunc(("uOffActual=%RU64\n", dataCb.u.seek.uOffActual)); 658 659 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 660 mData.mOffCurrent = dataCb.u.seek.uOffActual; 661 alock.release(); 662 663 ::FireGuestFileOffsetChangedEvent(mEventSource, mSession, this, dataCb.u.seek.uOffActual, 0 /* Processed */); 662 664 break; 663 665 } … … 685 687 } 686 688 687 if (RT_SUCCESS(vrc))688 { 689 try689 try 690 { 691 if (RT_SUCCESS(vrc)) 690 692 { 691 693 GuestWaitEventPayload payload(dataCb.uType, &dataCb, sizeof(dataCb)); … … 694 696 signalWaitEventInternal(pCbCtx, vrcGuest, &payload); 695 697 } 696 catch (int vrcEx) /* Thrown by GuestWaitEventPayload constructor. */ 697 { 698 vrc = vrcEx; 699 } 698 else /* OOM situation, wrong HGCM parameters or smth. not expected. */ 699 { 700 /* Ignore rc, as the event to signal might not be there (anymore). */ 701 signalWaitEventInternalEx(pCbCtx, vrc, 0 /* guestRc */, NULL /* pPayload */); 702 } 703 } 704 catch (int vrcEx) /* Thrown by GuestWaitEventPayload constructor. */ 705 { 706 /* Also try to signal the waiter, to let it know of the OOM situation. 707 * Ignore rc, as the event to signal might not be there (anymore). */ 708 signalWaitEventInternalEx(pCbCtx, vrcEx, 0 /* guestRc */, NULL /* pPayload */); 709 vrc = vrcEx; 700 710 } 701 711
Note:
See TracChangeset
for help on using the changeset viewer.