- Timestamp:
- Mar 20, 2013 4:41:00 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 84401
- Location:
- trunk/src/VBox
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGuestCtrl.cpp
r45018 r45109 186 186 187 187 188 VBGLR3DECL(int) VbglR3GuestCtrlSessionNotify( uint32_t uClientId, uint32_t uContext,188 VBGLR3DECL(int) VbglR3GuestCtrlSessionNotify(PVBGLR3GUESTCTRLCMDCTX pCtx, 189 189 uint32_t uType, uint32_t uResult) 190 190 { 191 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 192 191 193 HGCMMsgSessionNotify Msg; 192 194 193 195 Msg.hdr.result = VERR_WRONG_ORDER; 194 Msg.hdr.u32ClientID = uClientId;196 Msg.hdr.u32ClientID = pCtx->uClientID; 195 197 Msg.hdr.u32Function = GUEST_SESSION_NOTIFY; 196 198 Msg.hdr.cParms = 3; 197 199 198 VbglHGCMParmUInt32Set(&Msg.context, uContext);200 VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID); 199 201 VbglHGCMParmUInt32Set(&Msg.type, uType); 200 202 VbglHGCMParmUInt32Set(&Msg.result, uResult); … … 215 217 * 216 218 * @return IPRT status code. 217 * @param p HostCtx Host context.219 * @param pCtx Host context. 218 220 ** @todo Docs! 219 221 */ 220 VBGLR3DECL(int) VbglR3GuestCtrlSessionGetOpen(PVBGLR3GUESTCTRL HOSTCTX pHostCtx,222 VBGLR3DECL(int) VbglR3GuestCtrlSessionGetOpen(PVBGLR3GUESTCTRLCMDCTX pCtx, 221 223 uint32_t *puProtocol, 222 224 char *pszUser, uint32_t cbUser, … … 225 227 uint32_t *puFlags, uint32_t *puSessionID) 226 228 { 227 AssertPtrReturn(p HostCtx, VERR_INVALID_POINTER);228 AssertReturn(p HostCtx->uNumParms == 6, VERR_INVALID_PARAMETER);229 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 230 AssertReturn(pCtx->uNumParms == 6, VERR_INVALID_PARAMETER); 229 231 230 232 AssertPtrReturn(puProtocol, VERR_INVALID_POINTER); … … 237 239 238 240 Msg.hdr.result = VERR_WRONG_ORDER; 239 Msg.hdr.u32ClientID = p HostCtx->uClientID;240 Msg.hdr.u32Function = GUEST_MSG_WAIT; 241 Msg.hdr.cParms = p HostCtx->uNumParms;241 Msg.hdr.u32ClientID = pCtx->uClientID; 242 Msg.hdr.u32Function = GUEST_MSG_WAIT; 243 Msg.hdr.cParms = pCtx->uNumParms; 242 244 243 245 VbglHGCMParmUInt32Set(&Msg.context, 0); … … 258 260 else 259 261 { 260 Msg.context.GetUInt32(&p HostCtx->uContextID);262 Msg.context.GetUInt32(&pCtx->uContextID); 261 263 Msg.protocol.GetUInt32(puProtocol); 262 264 Msg.flags.GetUInt32(puFlags); 263 265 264 266 if (puSessionID) 265 *puSessionID = VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(p HostCtx->uContextID);267 *puSessionID = VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pCtx->uContextID); 266 268 } 267 269 } … … 275 277 * 276 278 * @return IPRT status code. 277 * @param p HostCtx Host context.279 * @param pCtx Host context. 278 280 ** @todo Docs! 279 281 */ 280 VBGLR3DECL(int) VbglR3GuestCtrlSessionGetClose(PVBGLR3GUESTCTRL HOSTCTX pHostCtx, uint32_t *puFlags, uint32_t *puSessionID)281 { 282 AssertPtrReturn(p HostCtx, VERR_INVALID_POINTER);283 AssertReturn(p HostCtx->uNumParms == 2, VERR_INVALID_PARAMETER);282 VBGLR3DECL(int) VbglR3GuestCtrlSessionGetClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puFlags, uint32_t *puSessionID) 283 { 284 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 285 AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER); 284 286 285 287 AssertPtrReturn(puFlags, VERR_INVALID_POINTER); … … 288 290 289 291 Msg.hdr.result = VERR_WRONG_ORDER; 290 Msg.hdr.u32ClientID = p HostCtx->uClientID;291 Msg.hdr.u32Function = GUEST_MSG_WAIT; 292 Msg.hdr.cParms = p HostCtx->uNumParms;292 Msg.hdr.u32ClientID = pCtx->uClientID; 293 Msg.hdr.u32Function = GUEST_MSG_WAIT; 294 Msg.hdr.cParms = pCtx->uNumParms; 293 295 294 296 VbglHGCMParmUInt32Set(&Msg.context, 0); … … 305 307 else 306 308 { 307 Msg.context.GetUInt32(&p HostCtx->uContextID);309 Msg.context.GetUInt32(&pCtx->uContextID); 308 310 Msg.flags.GetUInt32(puFlags); 309 311 310 312 if (puSessionID) 311 *puSessionID = VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(p HostCtx->uContextID);313 *puSessionID = VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pCtx->uContextID); 312 314 } 313 315 } … … 326 328 ** @todo Move the parameters in an own struct! 327 329 */ 328 VBGLR3DECL(int) VbglR3GuestCtrlProcGetStart(PVBGLR3GUESTCTRL HOSTCTX pHostCtx,330 VBGLR3DECL(int) VbglR3GuestCtrlProcGetStart(PVBGLR3GUESTCTRLCMDCTX pCtx, 329 331 char *pszCmd, uint32_t cbCmd, 330 332 uint32_t *puFlags, … … 337 339 uint64_t *puAffinity, uint32_t cbAffinity, uint32_t *pcAffinity) 338 340 { 339 AssertPtrReturn(p HostCtx, VERR_INVALID_POINTER);341 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 340 342 341 343 AssertPtrReturn(pszCmd, VERR_INVALID_POINTER); … … 351 353 352 354 Msg.hdr.result = VERR_WRONG_ORDER; 353 Msg.hdr.u32ClientID = p HostCtx->uClientID;354 Msg.hdr.u32Function = GUEST_MSG_WAIT; 355 Msg.hdr.cParms = p HostCtx->uNumParms;355 Msg.hdr.u32ClientID = pCtx->uClientID; 356 Msg.hdr.u32Function = GUEST_MSG_WAIT; 357 Msg.hdr.cParms = pCtx->uNumParms; 356 358 357 359 VbglHGCMParmUInt32Set(&Msg.context, 0); … … 363 365 VbglHGCMParmUInt32Set(&Msg.cb_env, 0); 364 366 VbglHGCMParmPtrSet(&Msg.env, pszEnv, *pcbEnv); 365 if (p HostCtx->uProtocol < 2)367 if (pCtx->uProtocol < 2) 366 368 { 367 369 AssertPtrReturn(pszUser, VERR_INVALID_POINTER); … … 395 397 else 396 398 { 397 Msg.context.GetUInt32(&p HostCtx->uContextID);399 Msg.context.GetUInt32(&pCtx->uContextID); 398 400 Msg.flags.GetUInt32(puFlags); 399 401 Msg.num_args.GetUInt32(pcArgs); 400 402 Msg.num_env.GetUInt32(pcEnvVars); 401 403 Msg.cb_env.GetUInt32(pcbEnv); 402 if (p HostCtx->uProtocol < 2)404 if (pCtx->uProtocol < 2) 403 405 { 404 406 Msg.u.v1.timeout.GetUInt32(puTimeoutMS); … … 424 426 ** @todo Docs! 425 427 */ 426 VBGLR3DECL(int) VbglR3GuestCtrlProcGetOutput(PVBGLR3GUESTCTRL HOSTCTX pHostCtx,428 VBGLR3DECL(int) VbglR3GuestCtrlProcGetOutput(PVBGLR3GUESTCTRLCMDCTX pCtx, 427 429 uint32_t *puPID, uint32_t *puHandle, uint32_t *puFlags) 428 430 { 429 AssertPtrReturn(p HostCtx, VERR_INVALID_POINTER);430 AssertReturn(p HostCtx->uNumParms == 4, VERR_INVALID_PARAMETER);431 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 432 AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER); 431 433 432 434 AssertPtrReturn(puPID, VERR_INVALID_POINTER); … … 437 439 438 440 Msg.hdr.result = VERR_WRONG_ORDER; 439 Msg.hdr.u32ClientID = p HostCtx->uClientID;440 Msg.hdr.u32Function = GUEST_MSG_WAIT; 441 Msg.hdr.cParms = p HostCtx->uNumParms;441 Msg.hdr.u32ClientID = pCtx->uClientID; 442 Msg.hdr.u32Function = GUEST_MSG_WAIT; 443 Msg.hdr.cParms = pCtx->uNumParms; 442 444 443 445 VbglHGCMParmUInt32Set(&Msg.context, 0); … … 456 458 else 457 459 { 458 Msg.context.GetUInt32(&p HostCtx->uContextID);460 Msg.context.GetUInt32(&pCtx->uContextID); 459 461 Msg.pid.GetUInt32(puPID); 460 462 Msg.handle.GetUInt32(puHandle); … … 475 477 ** @todo Docs! 476 478 */ 477 VBGLR3DECL(int) VbglR3GuestCtrlProcGetInput(PVBGLR3GUESTCTRL HOSTCTX pHostCtx,479 VBGLR3DECL(int) VbglR3GuestCtrlProcGetInput(PVBGLR3GUESTCTRLCMDCTX pCtx, 478 480 uint32_t *puPID, uint32_t *puFlags, 479 481 void *pvData, uint32_t cbData, 480 482 uint32_t *pcbSize) 481 483 { 482 AssertPtrReturn(p HostCtx, VERR_INVALID_POINTER);483 AssertReturn(p HostCtx->uNumParms == 5, VERR_INVALID_PARAMETER);484 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 485 AssertReturn(pCtx->uNumParms == 5, VERR_INVALID_PARAMETER); 484 486 485 487 AssertPtrReturn(puPID, VERR_INVALID_POINTER); … … 491 493 492 494 Msg.hdr.result = VERR_WRONG_ORDER; 493 Msg.hdr.u32ClientID = p HostCtx->uClientID;494 Msg.hdr.u32Function = GUEST_MSG_WAIT; 495 Msg.hdr.cParms = p HostCtx->uNumParms;495 Msg.hdr.u32ClientID = pCtx->uClientID; 496 Msg.hdr.u32Function = GUEST_MSG_WAIT; 497 Msg.hdr.cParms = pCtx->uNumParms; 496 498 497 499 VbglHGCMParmUInt32Set(&Msg.context, 0); … … 511 513 else 512 514 { 513 Msg.context.GetUInt32(&p HostCtx->uContextID);515 Msg.context.GetUInt32(&pCtx->uContextID); 514 516 Msg.pid.GetUInt32(puPID); 515 517 Msg.flags.GetUInt32(puFlags); … … 521 523 522 524 523 VBGLR3DECL(int) VbglR3GuestCtrlFileGetOpen(PVBGLR3GUESTCTRL HOSTCTX pHostCtx,525 VBGLR3DECL(int) VbglR3GuestCtrlFileGetOpen(PVBGLR3GUESTCTRLCMDCTX pCtx, 524 526 char *pszFileName, uint32_t cbFileName, 525 527 char *pszOpenMode, uint32_t cbOpenMode, … … 528 530 uint64_t *puOffset) 529 531 { 530 AssertPtrReturn(p HostCtx, VERR_INVALID_POINTER);531 AssertReturn(p HostCtx->uNumParms == 6, VERR_INVALID_PARAMETER);532 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 533 AssertReturn(pCtx->uNumParms == 6, VERR_INVALID_PARAMETER); 532 534 533 535 AssertPtrReturn(pszFileName, VERR_INVALID_POINTER); … … 543 545 544 546 Msg.hdr.result = VERR_WRONG_ORDER; 545 Msg.hdr.u32ClientID = p HostCtx->uClientID;546 Msg.hdr.u32Function = GUEST_MSG_WAIT; 547 Msg.hdr.cParms = p HostCtx->uNumParms;547 Msg.hdr.u32ClientID = pCtx->uClientID; 548 Msg.hdr.u32Function = GUEST_MSG_WAIT; 549 Msg.hdr.cParms = pCtx->uNumParms; 548 550 549 551 VbglHGCMParmUInt32Set(&Msg.context, 0); … … 564 566 else 565 567 { 566 Msg.context.GetUInt32(&p HostCtx->uContextID);568 Msg.context.GetUInt32(&pCtx->uContextID); 567 569 Msg.creationmode.GetUInt32(puCreationMode); 568 570 Msg.offset.GetUInt64(puOffset); … … 573 575 574 576 575 VBGLR3DECL(int) VbglR3GuestCtrlFileGetClose(PVBGLR3GUESTCTRL HOSTCTX pHostCtx, uint32_t *puHandle)576 { 577 AssertPtrReturn(p HostCtx, VERR_INVALID_POINTER);578 579 AssertReturn(p HostCtx->uNumParms == 2, VERR_INVALID_PARAMETER);577 VBGLR3DECL(int) VbglR3GuestCtrlFileGetClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle) 578 { 579 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 580 581 AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER); 580 582 AssertPtrReturn(puHandle, VERR_INVALID_POINTER); 581 583 … … 583 585 584 586 Msg.hdr.result = VERR_WRONG_ORDER; 585 Msg.hdr.u32ClientID = p HostCtx->uClientID;586 Msg.hdr.u32Function = GUEST_MSG_WAIT; 587 Msg.hdr.cParms = p HostCtx->uNumParms;587 Msg.hdr.u32ClientID = pCtx->uClientID; 588 Msg.hdr.u32Function = GUEST_MSG_WAIT; 589 Msg.hdr.cParms = pCtx->uNumParms; 588 590 589 591 VbglHGCMParmUInt32Set(&Msg.context, 0); … … 600 602 else 601 603 { 602 Msg.context.GetUInt32(&p HostCtx->uContextID);604 Msg.context.GetUInt32(&pCtx->uContextID); 603 605 Msg.handle.GetUInt32(puHandle); 604 606 } … … 608 610 609 611 610 VBGLR3DECL(int) VbglR3GuestCtrlFileGetRead(PVBGLR3GUESTCTRL HOSTCTX pHostCtx,612 VBGLR3DECL(int) VbglR3GuestCtrlFileGetRead(PVBGLR3GUESTCTRLCMDCTX pCtx, 611 613 uint32_t *puHandle, uint32_t *puToRead) 612 614 { 613 AssertPtrReturn(p HostCtx, VERR_INVALID_POINTER);614 615 AssertReturn(p HostCtx->uNumParms == 4, VERR_INVALID_PARAMETER);615 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 616 617 AssertReturn(pCtx->uNumParms == 3, VERR_INVALID_PARAMETER); 616 618 AssertPtrReturn(puHandle, VERR_INVALID_POINTER); 617 619 AssertPtrReturn(puToRead, VERR_INVALID_POINTER); … … 620 622 621 623 Msg.hdr.result = VERR_WRONG_ORDER; 622 Msg.hdr.u32ClientID = p HostCtx->uClientID;623 Msg.hdr.u32Function = GUEST_MSG_WAIT; 624 Msg.hdr.cParms = p HostCtx->uNumParms;624 Msg.hdr.u32ClientID = pCtx->uClientID; 625 Msg.hdr.u32Function = GUEST_MSG_WAIT; 626 Msg.hdr.cParms = pCtx->uNumParms; 625 627 626 628 VbglHGCMParmUInt32Set(&Msg.context, 0); … … 638 640 else 639 641 { 640 Msg.context.GetUInt32(&p HostCtx->uContextID);642 Msg.context.GetUInt32(&pCtx->uContextID); 641 643 Msg.handle.GetUInt32(puHandle); 642 644 Msg.size.GetUInt32(puToRead); … … 647 649 648 650 649 VBGLR3DECL(int) VbglR3GuestCtrlFileGetReadAt(PVBGLR3GUESTCTRL HOSTCTX pHostCtx,651 VBGLR3DECL(int) VbglR3GuestCtrlFileGetReadAt(PVBGLR3GUESTCTRLCMDCTX pCtx, 650 652 uint32_t *puHandle, uint32_t *puToRead, uint64_t *puOffset) 651 653 { 652 AssertPtrReturn(p HostCtx, VERR_INVALID_POINTER);653 654 AssertReturn(p HostCtx->uNumParms == 5, VERR_INVALID_PARAMETER);654 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 655 656 AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER); 655 657 AssertPtrReturn(puHandle, VERR_INVALID_POINTER); 656 658 AssertPtrReturn(puToRead, VERR_INVALID_POINTER); 657 659 658 HGCMMsgFileRead Msg;659 660 Msg.hdr.result = VERR_WRONG_ORDER; 661 Msg.hdr.u32ClientID = p HostCtx->uClientID;662 Msg.hdr.u32Function = GUEST_MSG_WAIT; 663 Msg.hdr.cParms = p HostCtx->uNumParms;660 HGCMMsgFileReadAt Msg; 661 662 Msg.hdr.result = VERR_WRONG_ORDER; 663 Msg.hdr.u32ClientID = pCtx->uClientID; 664 Msg.hdr.u32Function = GUEST_MSG_WAIT; 665 Msg.hdr.cParms = pCtx->uNumParms; 664 666 665 667 VbglHGCMParmUInt32Set(&Msg.context, 0); 666 668 VbglHGCMParmUInt32Set(&Msg.handle, 0); 669 VbglHGCMParmUInt32Set(&Msg.offset, 0); 667 670 VbglHGCMParmUInt32Set(&Msg.size, 0); 668 671 … … 677 680 else 678 681 { 679 Msg.context.GetUInt32(&p HostCtx->uContextID);682 Msg.context.GetUInt32(&pCtx->uContextID); 680 683 Msg.handle.GetUInt32(puHandle); 684 Msg.offset.GetUInt64(puOffset); 681 685 Msg.size.GetUInt32(puToRead); 682 686 } … … 686 690 687 691 688 VBGLR3DECL(int) VbglR3GuestCtrlFileGetWrite(PVBGLR3GUESTCTRL HOSTCTX pHostCtx, uint32_t *puHandle,692 VBGLR3DECL(int) VbglR3GuestCtrlFileGetWrite(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle, 689 693 void *pvData, uint32_t cbData, uint32_t *pcbSize) 690 694 { 691 AssertPtrReturn(p HostCtx, VERR_INVALID_POINTER);692 693 AssertReturn(p HostCtx->uNumParms == 4, VERR_INVALID_PARAMETER);695 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 696 697 AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER); 694 698 AssertPtrReturn(puHandle, VERR_INVALID_POINTER); 695 699 AssertPtrReturn(pvData, VERR_INVALID_POINTER); … … 700 704 701 705 Msg.hdr.result = VERR_WRONG_ORDER; 702 Msg.hdr.u32ClientID = p HostCtx->uClientID;703 Msg.hdr.u32Function = GUEST_MSG_WAIT; 704 Msg.hdr.cParms = p HostCtx->uNumParms;706 Msg.hdr.u32ClientID = pCtx->uClientID; 707 Msg.hdr.u32Function = GUEST_MSG_WAIT; 708 Msg.hdr.cParms = pCtx->uNumParms; 705 709 706 710 VbglHGCMParmUInt32Set(&Msg.context, 0); … … 719 723 else 720 724 { 721 Msg.context.GetUInt32(&p HostCtx->uContextID);725 Msg.context.GetUInt32(&pCtx->uContextID); 722 726 Msg.handle.GetUInt32(puHandle); 723 727 Msg.size.GetUInt32(pcbSize); … … 728 732 729 733 730 VBGLR3DECL(int) VbglR3GuestCtrlFileGetWriteAt(PVBGLR3GUESTCTRL HOSTCTX pHostCtx, uint32_t *puHandle,734 VBGLR3DECL(int) VbglR3GuestCtrlFileGetWriteAt(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle, 731 735 void *pvData, uint32_t cbData, uint32_t *pcbSize, uint64_t *puOffset) 732 736 { 733 AssertPtrReturn(p HostCtx, VERR_INVALID_POINTER);734 735 AssertReturn(p HostCtx->uNumParms == 5, VERR_INVALID_PARAMETER);737 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 738 739 AssertReturn(pCtx->uNumParms == 5, VERR_INVALID_PARAMETER); 736 740 AssertPtrReturn(puHandle, VERR_INVALID_POINTER); 737 741 AssertPtrReturn(pvData, VERR_INVALID_POINTER); … … 742 746 743 747 Msg.hdr.result = VERR_WRONG_ORDER; 744 Msg.hdr.u32ClientID = p HostCtx->uClientID;745 Msg.hdr.u32Function = GUEST_MSG_WAIT; 746 Msg.hdr.cParms = p HostCtx->uNumParms;748 Msg.hdr.u32ClientID = pCtx->uClientID; 749 Msg.hdr.u32Function = GUEST_MSG_WAIT; 750 Msg.hdr.cParms = pCtx->uNumParms; 747 751 748 752 VbglHGCMParmUInt32Set(&Msg.context, 0); … … 762 766 else 763 767 { 764 Msg.context.GetUInt32(&p HostCtx->uContextID);768 Msg.context.GetUInt32(&pCtx->uContextID); 765 769 Msg.handle.GetUInt32(puHandle); 766 770 Msg.size.GetUInt32(pcbSize); … … 771 775 772 776 773 VBGLR3DECL(int) VbglR3GuestCtrlFileGetSeek(PVBGLR3GUESTCTRL HOSTCTX pHostCtx,777 VBGLR3DECL(int) VbglR3GuestCtrlFileGetSeek(PVBGLR3GUESTCTRLCMDCTX pCtx, 774 778 uint32_t *puHandle, uint32_t *puSeekMethod, uint64_t *puOffset) 775 779 { 776 AssertPtrReturn(p HostCtx, VERR_INVALID_POINTER);777 778 AssertReturn(p HostCtx->uNumParms == 4, VERR_INVALID_PARAMETER);780 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 781 782 AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER); 779 783 AssertPtrReturn(puHandle, VERR_INVALID_POINTER); 780 784 AssertPtrReturn(puSeekMethod, VERR_INVALID_POINTER); … … 784 788 785 789 Msg.hdr.result = VERR_WRONG_ORDER; 786 Msg.hdr.u32ClientID = p HostCtx->uClientID;787 Msg.hdr.u32Function = GUEST_MSG_WAIT; 788 Msg.hdr.cParms = p HostCtx->uNumParms;790 Msg.hdr.u32ClientID = pCtx->uClientID; 791 Msg.hdr.u32Function = GUEST_MSG_WAIT; 792 Msg.hdr.cParms = pCtx->uNumParms; 789 793 790 794 VbglHGCMParmUInt32Set(&Msg.context, 0); … … 803 807 else 804 808 { 805 Msg.context.GetUInt32(&p HostCtx->uContextID);809 Msg.context.GetUInt32(&pCtx->uContextID); 806 810 Msg.handle.GetUInt32(puHandle); 807 811 Msg.method.GetUInt32(puSeekMethod); … … 813 817 814 818 815 VBGLR3DECL(int) VbglR3GuestCtrlFileGetTell(PVBGLR3GUESTCTRL HOSTCTX pHostCtx, uint32_t *puHandle)816 { 817 AssertPtrReturn(p HostCtx, VERR_INVALID_POINTER);818 819 AssertReturn(p HostCtx->uNumParms == 2, VERR_INVALID_PARAMETER);819 VBGLR3DECL(int) VbglR3GuestCtrlFileGetTell(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle) 820 { 821 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 822 823 AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER); 820 824 AssertPtrReturn(puHandle, VERR_INVALID_POINTER); 821 825 … … 823 827 824 828 Msg.hdr.result = VERR_WRONG_ORDER; 825 Msg.hdr.u32ClientID = p HostCtx->uClientID;826 Msg.hdr.u32Function = GUEST_MSG_WAIT; 827 Msg.hdr.cParms = p HostCtx->uNumParms;829 Msg.hdr.u32ClientID = pCtx->uClientID; 830 Msg.hdr.u32Function = GUEST_MSG_WAIT; 831 Msg.hdr.cParms = pCtx->uNumParms; 828 832 829 833 VbglHGCMParmUInt32Set(&Msg.context, 0); … … 840 844 else 841 845 { 842 Msg.context.GetUInt32(&p HostCtx->uContextID);846 Msg.context.GetUInt32(&pCtx->uContextID); 843 847 Msg.handle.GetUInt32(puHandle); 844 848 } … … 848 852 849 853 850 VBGLR3DECL(int) VbglR3GuestCtrlProcGetTerminate(PVBGLR3GUESTCTRL HOSTCTX pHostCtx, uint32_t *puPID)851 { 852 AssertPtrReturn(p HostCtx, VERR_INVALID_POINTER);853 854 AssertReturn(p HostCtx->uNumParms == 2, VERR_INVALID_PARAMETER);854 VBGLR3DECL(int) VbglR3GuestCtrlProcGetTerminate(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puPID) 855 { 856 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 857 858 AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER); 855 859 AssertPtrReturn(puPID, VERR_INVALID_POINTER); 856 860 … … 858 862 859 863 Msg.hdr.result = VERR_WRONG_ORDER; 860 Msg.hdr.u32ClientID = p HostCtx->uClientID;861 Msg.hdr.u32Function = GUEST_MSG_WAIT; 862 Msg.hdr.cParms = p HostCtx->uNumParms;864 Msg.hdr.u32ClientID = pCtx->uClientID; 865 Msg.hdr.u32Function = GUEST_MSG_WAIT; 866 Msg.hdr.cParms = pCtx->uNumParms; 863 867 864 868 VbglHGCMParmUInt32Set(&Msg.context, 0); … … 875 879 else 876 880 { 877 Msg.context.GetUInt32(&p HostCtx->uContextID);881 Msg.context.GetUInt32(&pCtx->uContextID); 878 882 Msg.pid.GetUInt32(puPID); 879 883 } … … 883 887 884 888 885 VBGLR3DECL(int) VbglR3GuestCtrlProcGetWaitFor(PVBGLR3GUESTCTRLHOSTCTX pHostCtx, uint32_t *puPID, uint32_t *puWaitFlags, uint32_t *puTimeoutMS) 886 { 887 AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER); 888 889 AssertReturn(pHostCtx->uNumParms == 5, VERR_INVALID_PARAMETER); 889 VBGLR3DECL(int) VbglR3GuestCtrlProcGetWaitFor(PVBGLR3GUESTCTRLCMDCTX pCtx, 890 uint32_t *puPID, uint32_t *puWaitFlags, uint32_t *puTimeoutMS) 891 { 892 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 893 894 AssertReturn(pCtx->uNumParms == 5, VERR_INVALID_PARAMETER); 890 895 AssertPtrReturn(puPID, VERR_INVALID_POINTER); 891 896 … … 893 898 894 899 Msg.hdr.result = VERR_WRONG_ORDER; 895 Msg.hdr.u32ClientID = p HostCtx->uClientID;896 Msg.hdr.u32Function = GUEST_MSG_WAIT; 897 Msg.hdr.cParms = p HostCtx->uNumParms;900 Msg.hdr.u32ClientID = pCtx->uClientID; 901 Msg.hdr.u32Function = GUEST_MSG_WAIT; 902 Msg.hdr.cParms = pCtx->uNumParms; 898 903 899 904 VbglHGCMParmUInt32Set(&Msg.context, 0); … … 912 917 else 913 918 { 914 Msg.context.GetUInt32(&p HostCtx->uContextID);919 Msg.context.GetUInt32(&pCtx->uContextID); 915 920 Msg.pid.GetUInt32(puPID); 916 921 Msg.flags.GetUInt32(puWaitFlags); … … 922 927 923 928 924 VBGLR3DECL(int) VbglR3GuestCtrlFileNotify(uint32_t uClientId, uint32_t uContext, 925 uint32_t uType, 926 void *pvPayload, uint32_t cbPayload) 927 { 928 AssertPtrReturn(pvPayload, VERR_INVALID_POINTER); 929 AssertReturn(cbPayload, VERR_INVALID_PARAMETER); 930 931 HGCMMsgFileNotify Msg; 932 933 Msg.hdr.result = VERR_WRONG_ORDER; 934 Msg.hdr.u32ClientID = uClientId; 935 //Msg.hdr.u32Function = GUEST_FILE_NOTIFY; 929 VBGLR3DECL(int) VbglR3GuestCtrlFileCbOpen(PVBGLR3GUESTCTRLCMDCTX pCtx, 930 uint32_t uRc, uint32_t uFileHandle) 931 { 932 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 933 934 HGCMReplyFileNotify Msg; 935 936 Msg.hdr.result = VERR_WRONG_ORDER; 937 Msg.hdr.u32ClientID = pCtx->uClientID; 938 Msg.hdr.u32Function = GUEST_FILE_NOTIFY; 939 Msg.hdr.cParms = 4; 940 941 VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID); 942 VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_OPEN); 943 VbglHGCMParmUInt32Set(&Msg.rc, uRc); 944 945 VbglHGCMParmUInt32Set(&Msg.u.open.handle, uFileHandle); 946 947 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 948 if (RT_SUCCESS(rc)) 949 { 950 int rc2 = Msg.hdr.result; 951 if (RT_FAILURE(rc2)) 952 rc = rc2; 953 } 954 return rc; 955 } 956 957 958 VBGLR3DECL(int) VbglR3GuestCtrlFileCbClose(PVBGLR3GUESTCTRLCMDCTX pCtx, 959 uint32_t uRc) 960 { 961 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 962 963 HGCMReplyFileNotify Msg; 964 965 Msg.hdr.result = VERR_WRONG_ORDER; 966 Msg.hdr.u32ClientID = pCtx->uClientID; 967 Msg.hdr.u32Function = GUEST_FILE_NOTIFY; 936 968 Msg.hdr.cParms = 3; 937 969 938 VbglHGCMParmUInt32Set(&Msg.context, uContext); 939 VbglHGCMParmUInt32Set(&Msg.type, uType); 940 VbglHGCMParmPtrSet(&Msg.payload, pvPayload, cbPayload); 970 VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID); 971 VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_CLOSE); 972 VbglHGCMParmUInt32Set(&Msg.rc, uRc); 973 974 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 975 if (RT_SUCCESS(rc)) 976 { 977 int rc2 = Msg.hdr.result; 978 if (RT_FAILURE(rc2)) 979 rc = rc2; 980 } 981 return rc; 982 } 983 984 985 VBGLR3DECL(int) VbglR3GuestCtrlFileCbRead(PVBGLR3GUESTCTRLCMDCTX pCtx, 986 uint32_t uRc, 987 void *pvData, uint32_t cbData) 988 { 989 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 990 991 HGCMReplyFileNotify Msg; 992 993 Msg.hdr.result = VERR_WRONG_ORDER; 994 Msg.hdr.u32ClientID = pCtx->uClientID; 995 Msg.hdr.u32Function = GUEST_FILE_NOTIFY; 996 Msg.hdr.cParms = 4; 997 998 VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID); 999 VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_READ); 1000 VbglHGCMParmUInt32Set(&Msg.rc, uRc); 1001 1002 VbglHGCMParmPtrSet(&Msg.u.read.data, pvData, cbData); 1003 1004 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 1005 if (RT_SUCCESS(rc)) 1006 { 1007 int rc2 = Msg.hdr.result; 1008 if (RT_FAILURE(rc2)) 1009 rc = rc2; 1010 } 1011 return rc; 1012 } 1013 1014 1015 VBGLR3DECL(int) VbglR3GuestCtrlFileCbWrite(PVBGLR3GUESTCTRLCMDCTX pCtx, 1016 uint32_t uRc, uint32_t uWritten) 1017 { 1018 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 1019 1020 HGCMReplyFileNotify Msg; 1021 1022 Msg.hdr.result = VERR_WRONG_ORDER; 1023 Msg.hdr.u32ClientID = pCtx->uClientID; 1024 Msg.hdr.u32Function = GUEST_FILE_NOTIFY; 1025 Msg.hdr.cParms = 4; 1026 1027 VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID); 1028 VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_WRITE); 1029 VbglHGCMParmUInt32Set(&Msg.rc, uRc); 1030 1031 VbglHGCMParmUInt32Set(&Msg.u.write.written, uWritten); 1032 1033 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 1034 if (RT_SUCCESS(rc)) 1035 { 1036 int rc2 = Msg.hdr.result; 1037 if (RT_FAILURE(rc2)) 1038 rc = rc2; 1039 } 1040 return rc; 1041 } 1042 1043 1044 VBGLR3DECL(int) VbglR3GuestCtrlFileCbSeek(PVBGLR3GUESTCTRLCMDCTX pCtx, 1045 uint32_t uRc, uint64_t uOffActual) 1046 { 1047 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 1048 1049 HGCMReplyFileNotify Msg; 1050 1051 Msg.hdr.result = VERR_WRONG_ORDER; 1052 Msg.hdr.u32ClientID = pCtx->uClientID; 1053 Msg.hdr.u32Function = GUEST_FILE_NOTIFY; 1054 Msg.hdr.cParms = 4; 1055 1056 VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID); 1057 VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_SEEK); 1058 VbglHGCMParmUInt32Set(&Msg.rc, uRc); 1059 1060 VbglHGCMParmUInt64Set(&Msg.u.seek.offset, uOffActual); 1061 1062 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 1063 if (RT_SUCCESS(rc)) 1064 { 1065 int rc2 = Msg.hdr.result; 1066 if (RT_FAILURE(rc2)) 1067 rc = rc2; 1068 } 1069 return rc; 1070 } 1071 1072 1073 VBGLR3DECL(int) VbglR3GuestCtrlFileCbTell(PVBGLR3GUESTCTRLCMDCTX pCtx, 1074 uint32_t uRc, uint64_t uOffActual) 1075 { 1076 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 1077 1078 HGCMReplyFileNotify Msg; 1079 1080 Msg.hdr.result = VERR_WRONG_ORDER; 1081 Msg.hdr.u32ClientID = pCtx->uClientID; 1082 Msg.hdr.u32Function = GUEST_FILE_NOTIFY; 1083 Msg.hdr.cParms = 4; 1084 1085 VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID); 1086 VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_TELL); 1087 VbglHGCMParmUInt32Set(&Msg.rc, uRc); 1088 1089 VbglHGCMParmUInt64Set(&Msg.u.tell.offset, uOffActual); 941 1090 942 1091 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); … … 957 1106 ** @todo Docs! 958 1107 */ 959 VBGLR3DECL(int) VbglR3GuestCtrlProcCbStatus(uint32_t u32ClientID, 960 uint32_t u32Context, 961 uint32_t u32PID, 962 uint32_t u32Status, 963 uint32_t u32Flags, 964 void *pvData, 965 uint32_t cbData) 966 { 1108 VBGLR3DECL(int) VbglR3GuestCtrlProcCbStatus(PVBGLR3GUESTCTRLCMDCTX pCtx, 1109 uint32_t uPID, uint32_t uStatus, uint32_t uFlags, 1110 void *pvData, uint32_t cbData) 1111 { 1112 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 1113 967 1114 HGCMMsgProcStatus Msg; 968 1115 969 1116 Msg.hdr.result = VERR_WRONG_ORDER; 970 Msg.hdr.u32ClientID = u32ClientID;1117 Msg.hdr.u32ClientID = pCtx->uClientID; 971 1118 Msg.hdr.u32Function = GUEST_EXEC_STATUS; 972 1119 Msg.hdr.cParms = 5; 973 1120 974 VbglHGCMParmUInt32Set(&Msg.context, u32Context);975 VbglHGCMParmUInt32Set(&Msg.pid, u 32PID);976 VbglHGCMParmUInt32Set(&Msg.status, u 32Status);977 VbglHGCMParmUInt32Set(&Msg.flags, u 32Flags);1121 VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID); 1122 VbglHGCMParmUInt32Set(&Msg.pid, uPID); 1123 VbglHGCMParmUInt32Set(&Msg.status, uStatus); 1124 VbglHGCMParmUInt32Set(&Msg.flags, uFlags); 978 1125 VbglHGCMParmPtrSet(&Msg.data, pvData, cbData); 979 1126 … … 995 1142 ** @todo Docs! 996 1143 */ 997 VBGLR3DECL(int) VbglR3GuestCtrlProcCbOutput(uint32_t u32ClientID, 998 uint32_t u32Context, 999 uint32_t u32PID, 1000 uint32_t u32Handle, 1001 uint32_t u32Flags, 1002 void *pvData, 1003 uint32_t cbData) 1004 { 1144 VBGLR3DECL(int) VbglR3GuestCtrlProcCbOutput(PVBGLR3GUESTCTRLCMDCTX pCtx, 1145 uint32_t uPID,uint32_t uHandle, uint32_t uFlags, 1146 void *pvData, uint32_t cbData) 1147 { 1148 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 1149 1005 1150 HGCMMsgProcOutput Msg; 1006 1151 1007 1152 Msg.hdr.result = VERR_WRONG_ORDER; 1008 Msg.hdr.u32ClientID = u32ClientID;1153 Msg.hdr.u32ClientID = pCtx->uClientID; 1009 1154 Msg.hdr.u32Function = GUEST_EXEC_OUTPUT; 1010 1155 Msg.hdr.cParms = 5; 1011 1156 1012 VbglHGCMParmUInt32Set(&Msg.context, u32Context);1013 VbglHGCMParmUInt32Set(&Msg.pid, u 32PID);1014 VbglHGCMParmUInt32Set(&Msg.handle, u 32Handle);1015 VbglHGCMParmUInt32Set(&Msg.flags, u 32Flags);1157 VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID); 1158 VbglHGCMParmUInt32Set(&Msg.pid, uPID); 1159 VbglHGCMParmUInt32Set(&Msg.handle, uHandle); 1160 VbglHGCMParmUInt32Set(&Msg.flags, uFlags); 1016 1161 VbglHGCMParmPtrSet(&Msg.data, pvData, cbData); 1017 1162 … … 1033 1178 ** @todo Docs! 1034 1179 */ 1035 VBGLR3DECL(int) VbglR3GuestCtrlProcCbStatusInput(uint32_t u32ClientID, 1036 uint32_t u32Context, 1037 uint32_t u32PID, 1038 uint32_t u32Status, 1039 uint32_t u32Flags, 1040 uint32_t cbWritten) 1041 { 1180 VBGLR3DECL(int) VbglR3GuestCtrlProcCbStatusInput(PVBGLR3GUESTCTRLCMDCTX pCtx, 1181 uint32_t uPID, uint32_t uStatus, 1182 uint32_t uFlags, uint32_t cbWritten) 1183 { 1184 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 1185 1042 1186 HGCMMsgProcStatusInput Msg; 1043 1187 1044 1188 Msg.hdr.result = VERR_WRONG_ORDER; 1045 Msg.hdr.u32ClientID = u32ClientID;1189 Msg.hdr.u32ClientID = pCtx->uClientID; 1046 1190 Msg.hdr.u32Function = GUEST_EXEC_INPUT_STATUS; 1047 1191 Msg.hdr.cParms = 5; 1048 1192 1049 VbglHGCMParmUInt32Set(&Msg.context, u32Context);1050 VbglHGCMParmUInt32Set(&Msg.pid, u 32PID);1051 VbglHGCMParmUInt32Set(&Msg.status, u 32Status);1052 VbglHGCMParmUInt32Set(&Msg.flags, u 32Flags);1193 VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID); 1194 VbglHGCMParmUInt32Set(&Msg.pid, uPID); 1195 VbglHGCMParmUInt32Set(&Msg.status, uStatus); 1196 VbglHGCMParmUInt32Set(&Msg.flags, uFlags); 1053 1197 VbglHGCMParmUInt32Set(&Msg.written, cbWritten); 1054 1198 -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.cpp
r45010 r45109 68 68 * Internal Functions * 69 69 *******************************************************************************/ 70 static int gstcntlHandleSessionOpen(PVBGLR3GUESTCTRL HOSTCTX pHostCtx);71 static int gstcntlHandleSessionClose(PVBGLR3GUESTCTRL HOSTCTX pHostCtx);70 static int gstcntlHandleSessionOpen(PVBGLR3GUESTCTRLCMDCTX pHostCtx); 71 static int gstcntlHandleSessionClose(PVBGLR3GUESTCTRLCMDCTX pHostCtx); 72 72 static void VBoxServiceControlShutdown(void); 73 73 … … 198 198 AssertPtrReturn(pvScratchBuf, VERR_NO_MEMORY); 199 199 200 VBGLR3GUESTCTRLHOSTCTX ctxHost = { g_uControlSvcClientID, 201 1 /* Default protocol version */ }; 200 VBGLR3GUESTCTRLCMDCTX ctxHost = { g_uControlSvcClientID }; 201 /* Set default protocol version to 1. */ 202 ctxHost.uProtocol = 1; 203 202 204 for (;;) 203 205 { … … 301 303 302 304 303 static int gstcntlHandleSessionOpen(PVBGLR3GUESTCTRL HOSTCTX pHostCtx)305 static int gstcntlHandleSessionOpen(PVBGLR3GUESTCTRLCMDCTX pHostCtx) 304 306 { 305 307 AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER); … … 329 331 /* Report back on failure. On success this will be done 330 332 * by the forked session thread. */ 331 int rc2 = VbglR3GuestCtrlSessionNotify(pHostCtx ->uClientID, pHostCtx->uContextID,333 int rc2 = VbglR3GuestCtrlSessionNotify(pHostCtx, 332 334 GUEST_SESSION_NOTIFYTYPE_ERROR, rc /* uint32_t vs. int */); 333 335 if (RT_FAILURE(rc2)) … … 343 345 344 346 345 static int gstcntlHandleSessionClose(PVBGLR3GUESTCTRL HOSTCTX pHostCtx)347 static int gstcntlHandleSessionClose(PVBGLR3GUESTCTRLCMDCTX pHostCtx) 346 348 { 347 349 AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER); … … 368 370 /* Report back on failure. On success this will be done 369 371 * by the forked session thread. */ 370 int rc2 = VbglR3GuestCtrlSessionNotify(pHostCtx ->uClientID, pHostCtx->uContextID,372 int rc2 = VbglR3GuestCtrlSessionNotify(pHostCtx, 371 373 GUEST_SESSION_NOTIFYTYPE_ERROR, rc); 372 374 if (RT_FAILURE(rc2)) -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.h
r45010 r45109 385 385 extern int GstCntlSessionDestroy(PVBOXSERVICECTRLSESSION pSession); 386 386 extern int GstCntlSessionInit(PVBOXSERVICECTRLSESSION pSession, uint32_t uFlags); 387 extern int GstCntlSessionHandler(PVBOXSERVICECTRLSESSION pSession, uint32_t uMsg, PVBGLR3GUESTCTRL HOSTCTX pHostCtx, void *pvScratchBuf, size_t cbScratchBuf, volatile bool *pfShutdown);387 extern int GstCntlSessionHandler(PVBOXSERVICECTRLSESSION pSession, uint32_t uMsg, PVBGLR3GUESTCTRLCMDCTX pHostCtx, void *pvScratchBuf, size_t cbScratchBuf, volatile bool *pfShutdown); 388 388 extern int GstCntlSessionListSet(PVBOXSERVICECTRLSESSION pSession, PVBOXSERVICECTRLPROCESS pThread, VBOXSERVICECTRLTHREADLISTTYPE enmList); 389 389 extern int GstCntlSessionProcessStartAllowed(const PVBOXSERVICECTRLSESSION pSession, bool *pbAllowed); … … 401 401 extern void GstCntlProcessRequestFree(PVBOXSERVICECTRLREQUEST pReq); 402 402 /* Per-session functions. */ 403 extern int gstcntlHandleFileOpen(uint32_t idClient, uint32_t cParms); 404 extern int gstcntlHandleFileClose(uint32_t idClient, uint32_t cParms); 405 extern int gstcntlHandleFileRead(uint32_t idClient, uint32_t cParms, void *pvScratchBuf, size_t cbScratchBuf); 406 extern int gstcntlHandleFileReadAt(uint32_t idClient, uint32_t cParms, void *pvScratchBuf, size_t cbScratchBuf); 407 extern int gstcntlHandleFileWrite(uint32_t idClient, uint32_t cParms, void *pvScratchBuf, size_t cbScratchBuf); 408 extern int gstcntlHandleFileWriteAt(uint32_t idClient, uint32_t cParms, void *pvScratchBuf, size_t cbScratchBuf); 409 extern int gstcntlHandleFileSeek(uint32_t idClient, uint32_t cParms); 410 extern int gstcntlHandleFileTell(uint32_t idClient, uint32_t cParms); 411 extern int GstCntlSessionHandleProcExec(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLHOSTCTX pHostCtx); 412 extern int GstCntlSessionHandleProcInput(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLHOSTCTX pHostCtx, void *pvScratchBuf, size_t cbScratchBuf); 413 extern int GstCntlSessionHandleProcOutput(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLHOSTCTX pHostCtx); 414 extern int GstCntlSessionHandleProcTerminate(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLHOSTCTX pHostCtx); 415 extern int GstCntlSessionHandleProcWaitFor(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLHOSTCTX pHostCtx); 403 extern int GstCntlSessionHandleProcExec(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx); 404 extern int GstCntlSessionHandleProcInput(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx, void *pvScratchBuf, size_t cbScratchBuf); 405 extern int GstCntlSessionHandleProcOutput(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx); 406 extern int GstCntlSessionHandleProcTerminate(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx); 407 extern int GstCntlSessionHandleProcWaitFor(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx); 416 408 417 409 RT_C_DECLS_END -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlProcess.cpp
r45017 r45109 650 650 VBoxServiceVerbose(2, "[PID %u]: Process \"%s\" started, CID=%u, User=%s\n", 651 651 pThread->uPID, pThread->pszCmd, pThread->uContextID, pThread->pszUser); 652 rc = VbglR3GuestCtrlProcCbStatus(pThread->uClientID, pThread->uContextID, 652 VBGLR3GUESTCTRLCMDCTX ctx = { pThread->uClientID, pThread->uContextID }; 653 rc = VbglR3GuestCtrlProcCbStatus(&ctx, 653 654 pThread->uPID, PROC_STS_STARTED, 0 /* u32Flags */, 654 655 NULL /* pvData */, 0 /* cbData */); … … 925 926 if (!(pThread->uFlags & EXECUTEPROCESSFLAG_WAIT_START)) 926 927 { 927 rc2 = VbglR3GuestCtrlProcCbStatus(pThread->uClientID, pThread->uContextID, 928 VBGLR3GUESTCTRLCMDCTX ctx = { pThread->uClientID, pThread->uContextID }; 929 rc2 = VbglR3GuestCtrlProcCbStatus(&ctx, 928 930 pThread->uPID, uStatus, uFlags, 929 931 NULL /* pvData */, 0 /* cbData */); … … 1746 1748 if (RT_FAILURE(rc)) 1747 1749 { 1748 rc2 = VbglR3GuestCtrlProcCbStatus(pProcess->uClientID, pProcess->uContextID, pProcess->uPID, 1749 PROC_STS_ERROR, rc, 1750 VBGLR3GUESTCTRLCMDCTX ctx = { pProcess->uClientID, pProcess->uContextID }; 1751 rc2 = VbglR3GuestCtrlProcCbStatus(&ctx, 1752 pProcess->uPID, PROC_STS_ERROR, rc, 1750 1753 NULL /* pvData */, 0 /* cbData */); 1751 1754 if (RT_FAILURE(rc2)) -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp
r45076 r45109 55 55 static PVBOXSERVICECTRLFILE gstcntlSessionGetFile(const PVBOXSERVICECTRLSESSION pSession, uint32_t uHandle); 56 56 static int gstcntlSessionGetOutput(const PVBOXSERVICECTRLSESSION pSession, uint32_t uPID, uint32_t uCID, uint32_t uHandleId, uint32_t cMsTimeout, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead); 57 static int gstcntlSessionHandleFileOpen(PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRL HOSTCTX pHostCtx);58 static int gstcntlSessionHandleFileClose(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRL HOSTCTX pHostCtx);59 static int gstcntlSessionHandleFileRead(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRL HOSTCTX pHostCtx);60 static int gstcntlSessionHandleFileWrite(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRL HOSTCTX pHostCtx, void *pvScratchBuf, size_t cbScratchBuf);61 static int gstcntlSessionHandleFileSeek(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRL HOSTCTX pHostCtx);62 static int gstcntlSessionHandleFileTell(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRL HOSTCTX pHostCtx);57 static int gstcntlSessionHandleFileOpen(PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx); 58 static int gstcntlSessionHandleFileClose(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx); 59 static int gstcntlSessionHandleFileRead(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx); 60 static int gstcntlSessionHandleFileWrite(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx, void *pvScratchBuf, size_t cbScratchBuf); 61 static int gstcntlSessionHandleFileSeek(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx); 62 static int gstcntlSessionHandleFileTell(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx); 63 63 static int gstcntlSessionSetInput(const PVBOXSERVICECTRLSESSION pSession, uint32_t uPID, uint32_t uCID, bool fPendingClose, void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten); 64 64 static DECLCALLBACK(int) gstcntlSessionThread(RTTHREAD ThreadSelf, void *pvUser); … … 142 142 143 143 static int gstcntlSessionHandleFileOpen(PVBOXSERVICECTRLSESSION pSession, 144 PVBGLR3GUESTCTRL HOSTCTX pHostCtx)144 PVBGLR3GUESTCTRLCMDCTX pHostCtx) 145 145 { 146 146 AssertPtrReturn(pSession, VERR_INVALID_POINTER); … … 208 208 209 209 /* Report back in any case. */ 210 CALLBACKPAYLOAD_FILE_NOTIFY_OPEN cplOpen = { rc, uHandle }; 211 int rc2 = VbglR3GuestCtrlFileNotify(pHostCtx->uClientID, pHostCtx->uContextID, 212 GUEST_FILE_NOTIFYTYPE_OPEN, &cplOpen, sizeof(cplOpen)); 210 int rc2 = VbglR3GuestCtrlFileCbOpen(pHostCtx, rc, uHandle); 213 211 if (RT_FAILURE(rc2)) 214 212 VBoxServiceError("[File %s]: Failed to report file open status, rc=%Rrc\n", … … 223 221 224 222 static int gstcntlSessionHandleFileClose(const PVBOXSERVICECTRLSESSION pSession, 225 PVBGLR3GUESTCTRL HOSTCTX pHostCtx)223 PVBGLR3GUESTCTRLCMDCTX pHostCtx) 226 224 { 227 225 AssertPtrReturn(pSession, VERR_INVALID_POINTER); … … 242 240 243 241 /* Report back in any case. */ 244 CALLBACKPAYLOAD_FILE_NOTIFY_CLOSE cplClose = { rc }; 245 int rc2 = VbglR3GuestCtrlFileNotify(pHostCtx->uClientID, pHostCtx->uContextID, 246 GUEST_FILE_NOTIFYTYPE_CLOSE, &cplClose, sizeof(cplClose)); 242 int rc2 = VbglR3GuestCtrlFileCbClose(pHostCtx, rc); 247 243 if (RT_FAILURE(rc2)) 248 244 VBoxServiceError("Failed to report file close status, rc=%Rrc\n", rc2); … … 255 251 256 252 static int gstcntlSessionHandleFileRead(const PVBOXSERVICECTRLSESSION pSession, 257 PVBGLR3GUESTCTRL HOSTCTX pHostCtx,253 PVBGLR3GUESTCTRLCMDCTX pHostCtx, 258 254 void *pvScratchBuf, size_t cbScratchBuf) 259 255 { … … 292 288 293 289 /* Report back in any case. */ 294 CALLBACKPAYLOAD_FILE_NOTIFY_READ cplRead = { rc, (uint32_t)cbRead, pvDataRead }; 295 int rc2 = VbglR3GuestCtrlFileNotify(pHostCtx->uClientID, pHostCtx->uContextID, 296 GUEST_FILE_NOTIFYTYPE_READ, &cplRead, sizeof(cplRead)); 290 int rc2 = VbglR3GuestCtrlFileCbRead(pHostCtx, rc, pvDataRead, (uint32_t)cbRead); 297 291 if ( cbToRead > cbScratchBuf 298 292 && pvDataRead) … … 309 303 310 304 static int gstcntlSessionHandleFileReadAt(const PVBOXSERVICECTRLSESSION pSession, 311 PVBGLR3GUESTCTRL HOSTCTX pHostCtx,305 PVBGLR3GUESTCTRLCMDCTX pHostCtx, 312 306 void *pvScratchBuf, size_t cbScratchBuf) 313 307 { … … 347 341 348 342 /* Report back in any case. */ 349 CALLBACKPAYLOAD_FILE_NOTIFY_READ cplRead = { rc, (uint32_t)cbRead, pvDataRead }; 350 int rc2 = VbglR3GuestCtrlFileNotify(pHostCtx->uClientID, pHostCtx->uContextID, 351 GUEST_FILE_NOTIFYTYPE_READ, &cplRead, sizeof(cplRead)); 343 int rc2 = VbglR3GuestCtrlFileCbRead(pHostCtx, rc, pvDataRead, (uint32_t)cbRead); 352 344 if ( cbToRead > cbScratchBuf 353 345 && pvDataRead) … … 364 356 365 357 static int gstcntlSessionHandleFileWrite(const PVBOXSERVICECTRLSESSION pSession, 366 PVBGLR3GUESTCTRL HOSTCTX pHostCtx,358 PVBGLR3GUESTCTRLCMDCTX pHostCtx, 367 359 void *pvScratchBuf, size_t cbScratchBuf) 368 360 { … … 390 382 391 383 /* Report back in any case. */ 392 CALLBACKPAYLOAD_FILE_NOTIFY_WRITE cplWrite = { rc, (uint32_t)cbWritten }; 393 int rc2 = VbglR3GuestCtrlFileNotify(pHostCtx->uClientID, pHostCtx->uContextID, 394 GUEST_FILE_NOTIFYTYPE_WRITE, &cplWrite, sizeof(cplWrite)); 384 int rc2 = VbglR3GuestCtrlFileCbWrite(pHostCtx, rc, (uint32_t)cbWritten); 395 385 if (RT_FAILURE(rc2)) 396 386 VBoxServiceError("Failed to report file write status, rc=%Rrc\n", rc2); … … 403 393 404 394 static int gstcntlSessionHandleFileWriteAt(const PVBOXSERVICECTRLSESSION pSession, 405 PVBGLR3GUESTCTRL HOSTCTX pHostCtx,395 PVBGLR3GUESTCTRLCMDCTX pHostCtx, 406 396 void *pvScratchBuf, size_t cbScratchBuf) 407 397 { … … 430 420 431 421 /* Report back in any case. */ 432 CALLBACKPAYLOAD_FILE_NOTIFY_WRITE cplWrite = { rc, (uint32_t)cbWritten }; 433 int rc2 = VbglR3GuestCtrlFileNotify(pHostCtx->uClientID, pHostCtx->uContextID, 434 GUEST_FILE_NOTIFYTYPE_WRITE, &cplWrite, sizeof(cplWrite)); 422 int rc2 = VbglR3GuestCtrlFileCbWrite(pHostCtx, rc, (uint32_t)cbWritten); 435 423 if (RT_FAILURE(rc2)) 436 424 VBoxServiceError("Failed to report file write status, rc=%Rrc\n", rc2); … … 443 431 444 432 static int gstcntlSessionHandleFileSeek(const PVBOXSERVICECTRLSESSION pSession, 445 PVBGLR3GUESTCTRL HOSTCTX pHostCtx)433 PVBGLR3GUESTCTRLCMDCTX pHostCtx) 446 434 { 447 435 AssertPtrReturn(pSession, VERR_INVALID_POINTER); … … 489 477 490 478 /* Report back in any case. */ 491 CALLBACKPAYLOAD_FILE_NOTFIY_SEEK cplSeek = { rc, uOffsetActual }; 492 int rc2 = VbglR3GuestCtrlFileNotify(pHostCtx->uClientID, pHostCtx->uContextID, 493 GUEST_FILE_NOTIFYTYPE_SEEK, &cplSeek, sizeof(cplSeek)); 479 int rc2 = VbglR3GuestCtrlFileCbSeek(pHostCtx, rc, uOffsetActual); 494 480 if (RT_FAILURE(rc2)) 495 481 VBoxServiceError("Failed to report file seek status, rc=%Rrc\n", rc2); … … 502 488 503 489 static int gstcntlSessionHandleFileTell(const PVBOXSERVICECTRLSESSION pSession, 504 PVBGLR3GUESTCTRL HOSTCTX pHostCtx)490 PVBGLR3GUESTCTRLCMDCTX pHostCtx) 505 491 { 506 492 AssertPtrReturn(pSession, VERR_INVALID_POINTER); … … 522 508 523 509 /* Report back in any case. */ 524 CALLBACKPAYLOAD_FILE_NOTFIY_TELL cplTell = { rc, uOffsetActual }; 525 int rc2 = VbglR3GuestCtrlFileNotify(pHostCtx->uClientID, pHostCtx->uContextID, 526 GUEST_FILE_NOTIFYTYPE_TELL, &cplTell, sizeof(cplTell)); 510 int rc2 = VbglR3GuestCtrlFileCbTell(pHostCtx, rc, uOffsetActual); 527 511 if (RT_FAILURE(rc2)) 528 512 VBoxServiceError("Failed to report file tell status, rc=%Rrc\n", rc2); … … 542 526 */ 543 527 int GstCntlSessionHandleProcExec(PVBOXSERVICECTRLSESSION pSession, 544 PVBGLR3GUESTCTRL HOSTCTX pHostCtx)528 PVBGLR3GUESTCTRLCMDCTX pHostCtx) 545 529 { 546 530 AssertPtrReturn(pSession, VERR_INVALID_POINTER); … … 626 610 * from the host. The host in case has to deal with that! 627 611 */ 628 int rc2 = VbglR3GuestCtrlProcCbStatus(pHostCtx->uClientID, pHostCtx->uContextID, 629 0 /* PID, invalid */, 612 int rc2 = VbglR3GuestCtrlProcCbStatus(pHostCtx, 0 /* PID, invalid */, 630 613 PROC_STS_ERROR, rc, 631 614 NULL /* pvData */, 0 /* cbData */); … … 651 634 */ 652 635 int GstCntlSessionHandleProcInput(PVBOXSERVICECTRLSESSION pSession, 653 PVBGLR3GUESTCTRL HOSTCTX pHostCtx,636 PVBGLR3GUESTCTRLCMDCTX pHostCtx, 654 637 void *pvScratchBuf, size_t cbScratchBuf) 655 638 { … … 732 715 * regardless whether we got data or not! Otherwise the progress object 733 716 * on the host never will get completed! */ 734 rc = VbglR3GuestCtrlProcCbStatusInput(pHostCtx ->uClientID, pHostCtx->uContextID, uPID,717 rc = VbglR3GuestCtrlProcCbStatusInput(pHostCtx, uPID, 735 718 uStatus, uFlags, (uint32_t)cbWritten); 736 719 … … 748 731 */ 749 732 int GstCntlSessionHandleProcOutput(PVBOXSERVICECTRLSESSION pSession, 750 PVBGLR3GUESTCTRL HOSTCTX pHostCtx)733 PVBGLR3GUESTCTRLCMDCTX pHostCtx) 751 734 { 752 735 AssertPtrReturn(pSession, VERR_INVALID_POINTER); … … 800 783 * regardless whether we got data or not! Otherwise the progress object 801 784 * on the host never will get completed! */ 802 int rc2 = VbglR3GuestCtrlProcCbOutput(pHostCtx ->uClientID, pHostCtx->uContextID, uPID, uHandleID, uFlags,785 int rc2 = VbglR3GuestCtrlProcCbOutput(pHostCtx, uPID, uHandleID, uFlags, 803 786 pBuf, cbRead); 804 787 if (RT_SUCCESS(rc)) … … 821 804 822 805 int GstCntlSessionHandleProcTerminate(const PVBOXSERVICECTRLSESSION pSession, 823 PVBGLR3GUESTCTRL HOSTCTX pHostCtx)806 PVBGLR3GUESTCTRLCMDCTX pHostCtx) 824 807 { 825 808 AssertPtrReturn(pSession, VERR_INVALID_POINTER); … … 853 836 854 837 int GstCntlSessionHandleProcWaitFor(const PVBOXSERVICECTRLSESSION pSession, 855 PVBGLR3GUESTCTRL HOSTCTX pHostCtx)838 PVBGLR3GUESTCTRLCMDCTX pHostCtx) 856 839 { 857 840 AssertPtrReturn(pSession, VERR_INVALID_POINTER); … … 888 871 889 872 int GstCntlSessionHandler(PVBOXSERVICECTRLSESSION pSession, 890 uint32_t uMsg, PVBGLR3GUESTCTRL HOSTCTX pHostCtx,873 uint32_t uMsg, PVBGLR3GUESTCTRLCMDCTX pHostCtx, 891 874 void *pvScratchBuf, size_t cbScratchBuf, 892 875 volatile bool *pfShutdown) … … 1136 1119 /* Report final status. */ 1137 1120 Assert(uSessionStatus != GUEST_SESSION_NOTIFYTYPE_UNDEFINED); 1138 rc2 = VbglR3GuestCtrlSessionNotify(uClientID,1139 VBOX_GUESTCTRL_CONTEXTID_MAKE_SESSION(uSessionID),1121 VBGLR3GUESTCTRLCMDCTX ctx = { uClientID, VBOX_GUESTCTRL_CONTEXTID_MAKE_SESSION(uSessionID) }; 1122 rc2 = VbglR3GuestCtrlSessionNotify(&ctx, 1140 1123 uSessionStatus, uSessionRc); 1141 1124 if (RT_FAILURE(rc2)) … … 1187 1170 1188 1171 /* Report started status. */ 1189 int rc2 = VbglR3GuestCtrlSessionNotify(uClientID,1190 VBOX_GUESTCTRL_CONTEXTID_MAKE_SESSION(pSession->StartupInfo.uSessionID),1172 VBGLR3GUESTCTRLCMDCTX ctx = { uClientID, VBOX_GUESTCTRL_CONTEXTID_MAKE_SESSION(pSession->StartupInfo.uSessionID) }; 1173 int rc2 = VbglR3GuestCtrlSessionNotify(&ctx, 1191 1174 GUEST_SESSION_NOTIFYTYPE_STARTED, VINF_SUCCESS); 1192 1175 if (RT_FAILURE(rc2)) … … 1211 1194 bool fShutdown = false; 1212 1195 1213 VBGLR3GUESTCTRL HOSTCTX ctxHost = { uClientID,1214 1196 VBGLR3GUESTCTRLCMDCTX ctxHost = { uClientID, 0 /* Context ID, zeroed */, 1197 pSession->StartupInfo.uProtocol }; 1215 1198 for (;;) 1216 1199 { -
trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h
r45010 r45109 107 107 /** Guest process input notification. */ 108 108 CALLBACKTYPE_PROC_INPUT = 106, 109 /** @todo Docs! */ 110 CALLBACKTYPE_FILE_OPEN = 210, 111 CALLBACKTYPE_FILE_CLOSE = 215, 112 CALLBACKTYPE_FILE_READ = 230, 113 CALLBACKTYPE_FILE_WRITE = 240, 114 CALLBACKTYPE_FILE_SEEK = 250, 115 CALLBACKTYPE_FILE_TELL = 260 109 /** Guest file notification. */ 110 CALLBACKTYPE_FILE_NOTIFY = 210 116 111 }; 117 112 … … 593 588 int bindToSession(Console *pConsole, GuestSession *pSession, uint32_t uObjectID); 594 589 int callbackAdd(GuestCtrlCallback *pCallback, uint32_t *puContextID); 590 void callbackDelete(GuestCtrlCallback *pCallback); 595 591 bool callbackExists(uint32_t uContextID); 596 592 int callbackRemove(uint32_t uContextID); -
trunk/src/VBox/Main/include/GuestFileImpl.h
r44863 r45109 78 78 * @{ */ 79 79 int callbackDispatcher(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb); 80 int closeFile(int *pGuestRc); 80 81 static uint32_t getDispositionFromString(const Utf8Str &strDisposition); 81 82 static uint32_t getOpenModeFromString(const Utf8Str &strOpenMode); 82 int onFileNotify(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, GuestCtrlCallback *pCallback, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData); 83 int onGuestDisconnected(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, GuestCtrlCallback *pCallback, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData); 83 static Utf8Str guestErrorToString(int guestRc); 84 int onFileNotify(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData, GuestCtrlCallback *pCallback); 85 int onGuestDisconnected(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData, GuestCtrlCallback *pCallback); 84 86 int openFile(int *pGuestRc); 87 int readData(uint32_t uSize, uint32_t uTimeoutMS, void *pvData, size_t cbData, size_t *pcbRead, int *pGuestRc); 88 int readDataAt(uint64_t uOffset, uint32_t uSize, uint32_t uTimeoutMS, void *pvData, size_t cbData, size_t *pcbRead, int *pGuestRc); 89 int seekAt(uint64_t uOffset, GUEST_FILE_SEEKTYPE eSeekType, uint32_t uTimeoutMS, int *pGuestRc); 90 int sendFileCommand(uint32_t uFunction, uint32_t uParms, PVBOXHGCMSVCPARM paParms, uint32_t uTimeoutMS, int *pGuestRc, GuestCtrlCallback **ppCallback); 91 static HRESULT setErrorExternal(VirtualBoxBase *pInterface, int guestRc); 92 int writeData(uint32_t uTimeoutMS, void *pvData, size_t cbData, uint32_t *pcbWritten, int *pGuestRc); 93 int writeDataAt(uint64_t uOffset, uint32_t uTimeoutMS, void *pvData, size_t cbData, uint32_t *pcbWritten, int *pGuestRc); 85 94 /** @} */ 86 95 … … 99 108 /** The file's initial size on open. */ 100 109 uint64_t mInitialSize; 110 /** The file's internal ID. */ 111 uint32_t mID; 101 112 /** The file's current offset. */ 102 113 uint64_t mOffCurrent; -
trunk/src/VBox/Main/src-client/GuestCtrlPrivate.cpp
r45076 r45109 189 189 } 190 190 191 case CALLBACKTYPE_FILE_NOTIFY: 192 { 193 pvData = (PCALLBACKDATA_FILE_NOTIFY)RTMemAllocZ(sizeof(CALLBACKDATA_FILE_NOTIFY)); 194 AssertPtrReturn(pvData, VERR_NO_MEMORY); 195 cbData = sizeof(CALLBACKDATA_FILE_NOTIFY); 196 break; 197 } 198 191 199 default: 192 200 AssertMsgFailed(("Unknown callback type specified (%ld)\n", enmType)); … … 220 228 } 221 229 222 case CALLBACKTYPE_FILE_ READ:223 { 224 PCALLBACK PAYLOAD_FILE_NOTIFY_READ pThis = (PCALLBACKPAYLOAD_FILE_NOTIFY_READ)pvData;230 case CALLBACKTYPE_FILE_NOTIFY: 231 { 232 PCALLBACKDATA_FILE_NOTIFY pThis = (PCALLBACKDATA_FILE_NOTIFY)pvData; 225 233 AssertPtr(pThis); 226 if (pThis->pvData) 227 RTMemFree(pThis->pvData); 228 break; 234 switch (pThis->uType) 235 { 236 case GUEST_FILE_NOTIFYTYPE_READ: 237 { 238 if (pThis->u.read.pvData) 239 { 240 RTMemFree(pThis->u.read.pvData); 241 pThis->u.read.pvData = NULL; 242 } 243 244 break; 245 } 246 247 default: 248 break; 249 } 229 250 } 230 251 … … 264 285 Assert(cbCallback == sizeof(CALLBACKDATA_SESSION_NOTIFY)); 265 286 266 pThis->uType = pCB->uType; 267 pThis->uResult = pCB->uResult; 287 memcpy(pThis, pCB, sizeof(CALLBACKDATA_SESSION_NOTIFY)); 268 288 break; 269 289 } … … 275 295 Assert(cbCallback == sizeof(CALLBACKDATA_PROC_STATUS)); 276 296 277 pThis->uFlags = pCB->uFlags; 278 pThis->uPID = pCB->uPID; 279 pThis->uStatus = pCB->uStatus; 297 memcpy(pThis, pCB, sizeof(CALLBACKDATA_PROC_STATUS)); 280 298 break; 281 299 } … … 305 323 Assert(cbCallback == sizeof(CALLBACKDATA_PROC_INPUT)); 306 324 307 pThis->uProcessed = pCB->uProcessed; 308 pThis->uFlags = pCB->uFlags; 309 pThis->uPID = pCB->uPID; 310 pThis->uStatus = pCB->uStatus; 311 break; 312 } 313 325 memcpy(pThis, pCB, sizeof(CALLBACKDATA_PROC_INPUT)); 326 break; 327 } 328 329 case CALLBACKTYPE_FILE_NOTIFY: 330 { 331 PCALLBACKDATA_FILE_NOTIFY pThis = (PCALLBACKDATA_FILE_NOTIFY)pvData; 332 PCALLBACKDATA_FILE_NOTIFY pCB = (PCALLBACKDATA_FILE_NOTIFY)pvCallback; 333 Assert(cbCallback == sizeof(CALLBACKDATA_FILE_NOTIFY)); 334 335 memcpy(pThis, pCB, sizeof(CALLBACKDATA_FILE_NOTIFY)); 336 337 switch (pThis->uType) 338 { 339 case GUEST_FILE_NOTIFYTYPE_READ: 340 { 341 pThis->u.read.pvData = RTMemAlloc(pCB->u.read.cbData); 342 AssertPtrReturn(pThis->u.read.pvData, VERR_NO_MEMORY); 343 memcpy(pThis->u.read.pvData, pCB->u.read.pvData, pCB->u.read.cbData); 344 pThis->u.read.cbData = pCB->u.read.cbData; 345 break; 346 } 347 348 default: 349 break; 350 } 351 break; 352 } 353 354 #if 0 314 355 case CALLBACKTYPE_FILE_OPEN: 315 356 { … … 382 423 break; 383 424 } 384 425 #endif 385 426 default: 386 427 AssertMsgFailed(("Callback type not supported (%ld)\n", mType)); … … 1287 1328 } 1288 1329 1330 void GuestObject::callbackDelete(GuestCtrlCallback *pCallback) 1331 { 1332 if (pCallback) 1333 { 1334 delete pCallback; 1335 pCallback = NULL; 1336 } 1337 } 1338 1289 1339 bool GuestObject::callbackExists(uint32_t uContextID) 1290 1340 { … … 1306 1356 if (it != mObject.mCallbacks.end()) 1307 1357 { 1308 delete it->second;1309 1358 mObject.mCallbacks.erase(it); 1310 1359 -
trunk/src/VBox/Main/src-client/GuestFileImpl.cpp
r44863 r45109 61 61 ///////////////////////////////////////////////////////////////////////////// 62 62 63 /** 64 * Initializes a file object but does *not* open the file on the guest 65 * yet. This is done in the dedidcated openFile call. 66 * 67 * @return IPRT status code. 68 * @param pConsole Pointer to console object. 69 * @param pSession Pointer to session object. 70 * @param uFileID Host-based file ID (part of the context ID). 71 * @param openInfo File opening information. 72 */ 63 73 int GuestFile::init(Console *pConsole, GuestSession *pSession, ULONG uFileID, const GuestFileOpenInfo &openInfo) 64 74 { … … 76 86 if (RT_SUCCESS(vrc)) 77 87 { 88 mData.mID = 0; 78 89 mData.mInitialSize = 0; 79 90 … … 257 268 { 258 269 case GUEST_DISCONNECTED: 259 vrc = onGuestDisconnected(pCbCtx, p Callback, pSvcCb); /* Affects all callbacks. */270 vrc = onGuestDisconnected(pCbCtx, pSvcCb, pCallback); /* Affects all callbacks. */ 260 271 break; 261 272 262 273 case GUEST_FILE_NOTIFY: 263 vrc = onFileNotify(pCbCtx, p Callback, pSvcCb);274 vrc = onFileNotify(pCbCtx, pSvcCb, pCallback); 264 275 break; 265 276 … … 273 284 LogFlowFuncLeaveRC(vrc); 274 285 #endif 286 return vrc; 287 } 288 289 int GuestFile::closeFile(int *pGuestRc) 290 { 291 LogFlowThisFunc(("strFile=%s\n", mData.mOpenInfo.mFileName.c_str())); 292 293 /* Prepare HGCM call. */ 294 VBOXHGCMSVCPARM paParms[4]; 295 int i = 1; /* Context ID will be set in sendFileComannd(). */ 296 paParms[i++].setUInt32(mData.mID /* Guest file ID */); 297 298 int guestRc; 299 int vrc = sendFileCommand(HOST_FILE_CLOSE, i, paParms, 30 * 1000 /* 30s timeout */, 300 &guestRc, NULL /* ppCallback */); 301 if (pGuestRc) 302 *pGuestRc = guestRc; 303 304 LogFlowFuncLeaveRC(vrc); 275 305 return vrc; 276 306 } … … 309 339 } 310 340 311 int GuestFile::onFileNotify(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, GuestCtrlCallback *pCallback, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData) 312 { 313 AssertPtrReturn(pCallback, VERR_INVALID_POINTER); 341 /* static */ 342 Utf8Str GuestFile::guestErrorToString(int guestRc) 343 { 344 Utf8Str strError; 345 346 /** @todo pData->u32Flags: int vs. uint32 -- IPRT errors are *negative* !!! */ 347 switch (guestRc) 348 { 349 case VERR_INVALID_VM_HANDLE: 350 strError += Utf8StrFmt(tr("VMM device is not available (is the VM running?)")); 351 break; 352 353 case VERR_HGCM_SERVICE_NOT_FOUND: 354 strError += Utf8StrFmt(tr("The guest execution service is not available")); 355 break; 356 357 case VERR_TIMEOUT: 358 strError += Utf8StrFmt(tr("The guest did not respond within time")); 359 break; 360 361 case VERR_CANCELLED: 362 strError += Utf8StrFmt(tr("The session operation was canceled")); 363 break; 364 365 case VERR_MAX_PROCS_REACHED: 366 strError += Utf8StrFmt(tr("Maximum number of concurrent guest files has been reached")); 367 break; 368 369 case VERR_NOT_EQUAL: /** @todo Imprecise to the user; can mean anything and all. */ 370 strError += Utf8StrFmt(tr("Unable to retrieve requested information")); 371 break; 372 373 case VERR_NOT_FOUND: 374 strError += Utf8StrFmt(tr("The guest execution service is not ready (yet)")); 375 break; 376 377 default: 378 strError += Utf8StrFmt("%Rrc", guestRc); 379 break; 380 } 381 382 return strError; 383 } 384 385 int GuestFile::onFileNotify(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData, 386 GuestCtrlCallback *pCallback) 387 { 388 AssertPtrReturn(pCbCtx, VERR_INVALID_POINTER); 314 389 AssertPtrReturn(pSvcCbData, VERR_INVALID_POINTER); 390 /* pCallback is optional. */ 315 391 316 392 if (pSvcCbData->mParms < 3) 317 393 return VERR_INVALID_PARAMETER; 318 394 319 uint32_t uType; 320 void *pvData; uint32_t cbData; 395 int vrc = VINF_SUCCESS; 396 397 int idx = 0; /* Current parameter index. */ 398 CALLBACKDATA_FILE_NOTIFY dataCb; 321 399 /* pSvcCb->mpaParms[0] always contains the context ID. */ 322 pSvcCbData->mpaParms[1].getUInt32(&uType); 323 pSvcCbData->mpaParms[2].getPointer(&pvData, &cbData); 324 325 LogFlowThisFunc(("strName=%s, uType=%RU32, pvData=%p, cbData=%RU32, pCallback=%p\n", 326 mData.mOpenInfo.mFileName.c_str(), uType, pvData, cbData, pCallback)); 400 pSvcCbData->mpaParms[idx++].getUInt32(&dataCb.uType); 401 pSvcCbData->mpaParms[idx++].getUInt32(&dataCb.rc); 402 403 switch (dataCb.uType) 404 { 405 case GUEST_FILE_NOTIFYTYPE_ERROR: 406 /* No extra data. */ 407 break; 408 409 case GUEST_FILE_NOTIFYTYPE_OPEN: 410 if (pSvcCbData->mParms == 4) 411 { 412 pSvcCbData->mpaParms[idx++].getUInt32(&dataCb.u.open.uHandle); 413 414 AssertMsg(mData.mID == 0, ("File ID already set to %RU32\n", mData.mID)); 415 mData.mID = dataCb.u.open.uHandle; 416 AssertMsg(mData.mID == VBOX_GUESTCTRL_CONTEXTID_GET_OBJECT(pCbCtx->uContextID), 417 ("File ID %RU32 does not match context ID %RU32\n", mData.mID, 418 VBOX_GUESTCTRL_CONTEXTID_GET_OBJECT(pCbCtx->uContextID))); 419 } 420 else 421 vrc = VERR_NOT_SUPPORTED; 422 break; 423 424 case GUEST_FILE_NOTIFYTYPE_CLOSE: 425 /* No extra data. */ 426 break; 427 428 case GUEST_FILE_NOTIFYTYPE_READ: 429 if (pSvcCbData->mParms == 4) 430 { 431 pSvcCbData->mpaParms[idx++].getPointer(&dataCb.u.read.pvData, 432 &dataCb.u.read.cbData); 433 434 mData.mOffCurrent += dataCb.u.read.cbData; 435 } 436 else 437 vrc = VERR_NOT_SUPPORTED; 438 break; 439 440 case GUEST_FILE_NOTIFYTYPE_WRITE: 441 if (pSvcCbData->mParms == 4) 442 { 443 pSvcCbData->mpaParms[idx++].getUInt32(&dataCb.u.write.cbWritten); 444 445 mData.mOffCurrent += dataCb.u.write.cbWritten; 446 } 447 else 448 vrc = VERR_NOT_SUPPORTED; 449 break; 450 451 case GUEST_FILE_NOTIFYTYPE_SEEK: 452 if (pSvcCbData->mParms == 4) 453 { 454 pSvcCbData->mpaParms[idx++].getUInt64(&dataCb.u.seek.uOffActual); 455 456 mData.mOffCurrent = dataCb.u.seek.uOffActual; 457 } 458 else 459 vrc = VERR_NOT_SUPPORTED; 460 break; 461 462 case GUEST_FILE_NOTIFYTYPE_TELL: 463 if (pSvcCbData->mParms == 4) 464 { 465 pSvcCbData->mpaParms[idx++].getUInt64(&dataCb.u.tell.uOffActual); 466 467 mData.mOffCurrent = dataCb.u.tell.uOffActual; 468 } 469 else 470 vrc = VERR_NOT_SUPPORTED; 471 break; 472 473 default: 474 vrc = VERR_NOT_SUPPORTED; 475 break; 476 } 477 478 LogFlowThisFunc(("strName=%s, uType=%RU32, rc=%Rrc, pCallback=%p\n", 479 mData.mOpenInfo.mFileName.c_str(), dataCb.uType, dataCb.rc, pCallback)); 480 481 int guestRc = (int)dataCb.rc; /* uint32_t vs. int. */ 482 if (RT_SUCCESS(vrc)) 483 { 484 /* Nothing to do here yet. */ 485 } 486 else if (vrc == VERR_NOT_SUPPORTED) 487 { 488 /* Also let the callback know. */ 489 guestRc = VERR_NOT_SUPPORTED; 490 } 327 491 328 492 /* Signal callback in every case (if available). */ 329 int vrc = VINF_SUCCESS;330 493 if (pCallback) 331 494 { 332 vrc = pCallback->SetData(pvData, cbData); 333 334 int rc2 = pCallback->Signal(); 495 int rc2 = pCallback->SetData(&dataCb, sizeof(dataCb)); 335 496 if (RT_SUCCESS(vrc)) 336 497 vrc = rc2; 498 rc2 = pCallback->Signal(guestRc); 499 if (RT_SUCCESS(vrc)) 500 vrc = rc2; 337 501 } 338 502 … … 341 505 } 342 506 343 int GuestFile::onGuestDisconnected(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, GuestCtrlCallback *pCallback, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData) 344 { 345 AssertPtrReturn(pCallback, VERR_INVALID_POINTER); 346 347 LogFlowThisFunc(("strFile=%s, pCallback=%p\n", mData.mOpenInfo.mFileName.c_str(), pCallback)); 507 int GuestFile::onGuestDisconnected(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData, 508 GuestCtrlCallback *pCallback) 509 { 510 AssertPtrReturn(pCbCtx, VERR_INVALID_POINTER); 511 AssertPtrReturn(pSvcCbData, VERR_INVALID_POINTER); 512 /* pCallback is optional. */ 513 514 LogFlowThisFunc(("strFile=%s, pCallback=%p\n", 515 mData.mOpenInfo.mFileName.c_str(), pCallback)); 348 516 349 517 /* First, signal callback in every case. */ … … 364 532 mData.mOpenInfo.mDisposition.c_str(), mData.mOpenInfo.mCreationMode)); 365 533 366 /* Wait until the caller function (if kicked off by a thread) 367 * has returned and continue operation. */ 534 /* Prepare HGCM call. */ 535 VBOXHGCMSVCPARM paParms[8]; 536 int i = 1; /* Context ID will be set in sendFileComannd(). */ 537 paParms[i++].setPointer((void*)mData.mOpenInfo.mFileName.c_str(), 538 (ULONG)mData.mOpenInfo.mFileName.length() + 1); 539 paParms[i++].setPointer((void*)mData.mOpenInfo.mOpenMode.c_str(), 540 (ULONG)mData.mOpenInfo.mOpenMode.length() + 1); 541 paParms[i++].setPointer((void*)mData.mOpenInfo.mDisposition.c_str(), 542 (ULONG)mData.mOpenInfo.mDisposition.length() + 1); 543 paParms[i++].setUInt32(mData.mOpenInfo.mCreationMode); 544 paParms[i++].setUInt64(mData.mOpenInfo.mInitialOffset); 545 546 int vrc = sendFileCommand(HOST_FILE_OPEN, i, paParms, 30 * 1000 /* 30s timeout */, 547 pGuestRc, NULL /* ppCallback */); 548 549 LogFlowFuncLeaveRC(vrc); 550 return vrc; 551 } 552 553 int GuestFile::readData(uint32_t uSize, uint32_t uTimeoutMS, void *pvData, size_t cbData, 554 size_t *pcbRead, int *pGuestRc) 555 { 556 LogFlowThisFunc(("uSize=%RU32, uTimeoutMS=%RU32, pvData=%p, cbData=%zu\n", 557 uSize, uTimeoutMS, pvData, cbData)); 558 559 /* Prepare HGCM call. */ 560 VBOXHGCMSVCPARM paParms[4]; 561 int i = 1; /* Context ID will be set in sendFileComannd(). */ 562 paParms[i++].setUInt32(mData.mID /* File handle */); 563 paParms[i++].setUInt32(uSize /* Size (in bytes) to read */); 564 565 GuestCtrlCallback *pCallback = NULL; int guestRc; 566 int vrc = sendFileCommand(HOST_FILE_READ, i, paParms, uTimeoutMS, 567 &guestRc, &pCallback); 568 569 if (RT_SUCCESS(vrc)) 570 { 571 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 572 573 Assert(pCallback->GetDataSize() == sizeof(CALLBACKDATA_FILE_NOTIFY)); 574 PCALLBACKDATA_FILE_NOTIFY pData = (PCALLBACKDATA_FILE_NOTIFY)pCallback->GetDataRaw(); 575 AssertPtr(pData); 576 Assert(pData->uType == GUEST_FILE_NOTIFYTYPE_READ); 577 578 size_t cbRead = pData->u.read.cbData; 579 if (cbRead) 580 { 581 Assert(cbData >= cbRead); 582 memcpy(pvData, pData->u.read.pvData, cbRead); 583 } 584 585 LogFlowThisFunc(("cbRead=%RU32\n", cbRead)); 586 587 if (pcbRead) 588 *pcbRead = cbRead; 589 } 590 591 callbackDelete(pCallback); 592 593 if (pGuestRc) 594 *pGuestRc = guestRc; 595 596 LogFlowFuncLeaveRC(vrc); 597 return vrc; 598 } 599 600 int GuestFile::readDataAt(uint64_t uOffset, uint32_t uSize, uint32_t uTimeoutMS, 601 void *pvData, size_t cbData, 602 size_t *pcbRead, int *pGuestRc) 603 { 604 LogFlowThisFunc(("uOffset=%RU64, uSize=%RU32, uTimeoutMS=%RU32, pvData=%p, cbData=%zu\n", 605 uOffset, uSize, uTimeoutMS, pvData, cbData)); 606 607 /* Prepare HGCM call. */ 608 VBOXHGCMSVCPARM paParms[4]; 609 int i = 1; /* Context ID will be set in sendFileComannd(). */ 610 paParms[i++].setUInt32(mData.mID /* File handle */); 611 paParms[i++].setUInt64(uOffset /* Offset (in bytes) to start reading */); 612 paParms[i++].setUInt32(uSize /* Size (in bytes) to read */); 613 614 GuestCtrlCallback *pCallback = NULL; int guestRc; 615 int vrc = sendFileCommand(HOST_FILE_READ_AT, i, paParms, uTimeoutMS, 616 &guestRc, &pCallback); 617 618 if (RT_SUCCESS(vrc)) 619 { 620 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 621 622 Assert(pCallback->GetDataSize() == sizeof(CALLBACKDATA_FILE_NOTIFY)); 623 PCALLBACKDATA_FILE_NOTIFY pData = (PCALLBACKDATA_FILE_NOTIFY)pCallback->GetDataRaw(); 624 AssertPtr(pData); 625 Assert(pData->uType == GUEST_FILE_NOTIFYTYPE_READ); 626 627 size_t cbRead = pData->u.read.cbData; 628 if (cbRead) 629 { 630 Assert(cbData >= cbRead); 631 memcpy(pvData, pData->u.read.pvData, cbRead); 632 } 633 634 LogFlowThisFunc(("cbRead=%RU32\n", cbRead)); 635 636 if (pcbRead) 637 *pcbRead = cbRead; 638 } 639 640 callbackDelete(pCallback); 641 642 if (pGuestRc) 643 *pGuestRc = guestRc; 644 645 LogFlowFuncLeaveRC(vrc); 646 return vrc; 647 } 648 649 int GuestFile::seekAt(uint64_t uOffset, GUEST_FILE_SEEKTYPE eSeekType, 650 uint32_t uTimeoutMS, int *pGuestRc) 651 { 652 LogFlowThisFunc(("uOffset=%RU64, uTimeoutMS=%RU32\n", 653 uOffset, uTimeoutMS)); 654 655 /* Prepare HGCM call. */ 656 VBOXHGCMSVCPARM paParms[4]; 657 int i = 1; /* Context ID will be set in sendFileComannd(). */ 658 paParms[i++].setUInt32(mData.mID /* File handle */); 659 paParms[i++].setUInt32(eSeekType /* Seek method */); 660 paParms[i++].setUInt64(uOffset /* Offset (in bytes) to start reading */); 661 662 int guestRc; 663 int vrc = sendFileCommand(HOST_FILE_SEEK, i, paParms, uTimeoutMS, 664 &guestRc, NULL /* ppCallback */); 665 if (pGuestRc) 666 *pGuestRc = guestRc; 667 668 LogFlowFuncLeaveRC(vrc); 669 return vrc; 670 } 671 672 /** 673 * Handles the common parts of sending a file command to the guest. 674 * If ppCallback is returned it must be removed via callbackRemove() 675 * by the caller in any case. 676 * 677 * @return IPRT status code. 678 * @param uFunction HGCM function of command to send. 679 * @param uParms Number of HGCM parameters to send. 680 * At least one parameter must be present. 681 * @param paParms Array of HGCM parameters to send. 682 * Index [0] must not be used and will be 683 * filled out by the function. 684 * @param uTimeoutMS Timeout (in ms). 685 * @param pGuestRc Guest result. Optional. 686 * @param ppCallback Pointer which will receive the callback for 687 * further processing by the caller. Must 688 * be deleted with callbackDelete() when done. Optional. 689 */ 690 int GuestFile::sendFileCommand(uint32_t uFunction, uint32_t uParms, PVBOXHGCMSVCPARM paParms, 691 uint32_t uTimeoutMS, int *pGuestRc, GuestCtrlCallback **ppCallback) 692 { 693 AssertReturn(uParms, VERR_INVALID_PARAMETER); 694 AssertPtrReturn(paParms, VERR_INVALID_POINTER); 695 /** pGuestRc is optional. */ 696 /** ppCallback is optional. */ 697 698 LogFlowThisFunc(("strFile=%s, uFunction=%RU32, uParms=%RU32\n", 699 mData.mOpenInfo.mFileName.c_str(), uFunction, uParms)); 700 368 701 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 369 702 … … 376 709 uint32_t uContextID = 0; 377 710 378 GuestCtrlCallback *pCallback Open;711 GuestCtrlCallback *pCallback; 379 712 try 380 713 { 381 pCallback Open= new GuestCtrlCallback();714 pCallback = new GuestCtrlCallback(); 382 715 } 383 716 catch(std::bad_alloc &) … … 389 722 { 390 723 /* Create callback and add it to the map. */ 391 vrc = pCallback Open->Init(CALLBACKTYPE_FILE_OPEN);724 vrc = pCallback->Init(CALLBACKTYPE_FILE_NOTIFY); 392 725 if (RT_SUCCESS(vrc)) 393 vrc = callbackAdd(pCallback Open, &uContextID);726 vrc = callbackAdd(pCallback, &uContextID); 394 727 } 395 728 396 729 if (RT_SUCCESS(vrc)) 397 730 { 731 /* Assign context ID. */ 732 paParms[0].setUInt32(uContextID); 733 398 734 GuestSession *pSession = mData.mSession; 399 735 AssertPtr(pSession); 400 736 401 const GuestCredentials &sessionCreds = pSession->getCredentials(); 402 403 if (RT_SUCCESS(vrc)) 404 { 405 /* Prepare HGCM call. */ 406 VBOXHGCMSVCPARM paParms[8]; 407 int i = 0; 408 paParms[i++].setUInt32(uContextID); 409 paParms[i++].setPointer((void*)mData.mOpenInfo.mFileName.c_str(), 410 (ULONG)mData.mOpenInfo.mFileName.length() + 1); 411 paParms[i++].setPointer((void*)mData.mOpenInfo.mOpenMode.c_str(), 412 (ULONG)mData.mOpenInfo.mOpenMode.length() + 1); 413 paParms[i++].setPointer((void*)mData.mOpenInfo.mDisposition.c_str(), 414 (ULONG)mData.mOpenInfo.mDisposition.length() + 1); 415 paParms[i++].setUInt32(mData.mOpenInfo.mCreationMode); 416 paParms[i++].setUInt64(mData.mOpenInfo.mInitialOffset); 417 418 /* Note: Don't hold the write lock in here. */ 419 vrc = sendCommand(HOST_FILE_OPEN, i, paParms); 420 } 421 422 /* Drop the write lock again before waiting. */ 423 alock.release(); 737 alock.release(); /* Drop the write lock again. */ 738 739 /* Note: Don't hold the write lock in here. */ 740 vrc = sendCommand(uFunction, uParms, paParms); 424 741 425 742 if (RT_SUCCESS(vrc)) … … 429 746 * Note: Be sure not keeping a AutoRead/WriteLock here. 430 747 */ 431 LogFlowThisFunc(("Waiting for callback (30s) ...\n")); 432 vrc = pCallbackOpen->Wait(30 * 1000 /* Wait 30s max. */); 748 LogFlowThisFunc(("Waiting for callback (%RU32ms) ...\n", 749 uTimeoutMS)); 750 vrc = pCallback->Wait(uTimeoutMS); 433 751 if (RT_SUCCESS(vrc)) /* Wait was successful, check for supplied information. */ 434 752 { 435 int guestRc = pCallback Open->GetResultCode();753 int guestRc = pCallback->GetResultCode(); 436 754 if (RT_SUCCESS(guestRc)) 437 755 { 438 756 /* Nothing to do here yet. */ 439 757 } 758 else 759 vrc = VERR_GSTCTL_GUEST_ERROR; 440 760 441 761 if (pGuestRc) … … 443 763 LogFlowThisFunc(("Callback returned rc=%Rrc\n", guestRc)); 444 764 } 445 else446 vrc = VERR_TIMEOUT;447 765 } 448 766 449 AutoWriteLock awlock(this COMMA_LOCKVAL_SRC_POS);450 451 AssertPtr(pCallback Open);767 alock.acquire(); /* Get write lock again. */ 768 769 AssertPtr(pCallback); 452 770 int rc2 = callbackRemove(uContextID); 453 771 if (RT_SUCCESS(vrc)) 454 772 vrc = rc2; 455 } 773 774 if (ppCallback) 775 { 776 /* Return callback to the caller which then will be 777 * responsible for removing it. Don't forget to lock write 778 * access before using this callback then! */ 779 *ppCallback = pCallback; 780 } 781 else 782 { 783 delete pCallback; 784 } 785 } 786 787 LogFlowFuncLeaveRC(vrc); 788 return vrc; 789 } 790 791 /* static */ 792 HRESULT GuestFile::setErrorExternal(VirtualBoxBase *pInterface, int guestRc) 793 { 794 AssertPtr(pInterface); 795 AssertMsg(RT_FAILURE(guestRc), ("Guest rc does not indicate a failure when setting error\n")); 796 797 return pInterface->setError(VBOX_E_IPRT_ERROR, GuestFile::guestErrorToString(guestRc).c_str()); 798 } 799 800 int GuestFile::writeData(uint32_t uTimeoutMS, void *pvData, size_t cbData, 801 uint32_t *pcbWritten, int *pGuestRc) 802 { 803 AssertPtrReturn(pvData, VERR_INVALID_POINTER); 804 AssertReturn(cbData, VERR_INVALID_PARAMETER); 805 806 LogFlowThisFunc(("uTimeoutMS=%RU32, pvData=%p, cbData=%zu\n", 807 uTimeoutMS, pvData, cbData)); 808 809 /* Prepare HGCM call. */ 810 VBOXHGCMSVCPARM paParms[4]; 811 int i = 1; /* Context ID will be set in sendFileComannd(). */ 812 paParms[i++].setUInt32(mData.mID /* File handle */); 813 paParms[i++].setUInt32(cbData /* Size (in bytes) to write */); 814 paParms[i++].setPointer(pvData, cbData); 815 816 GuestCtrlCallback *pCallback = NULL; int guestRc; 817 int vrc = sendFileCommand(HOST_FILE_WRITE, i, paParms, uTimeoutMS, 818 &guestRc, &pCallback); 819 820 if (RT_SUCCESS(vrc)) 821 { 822 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 823 824 Assert(pCallback->GetDataSize() == sizeof(CALLBACKDATA_FILE_NOTIFY)); 825 PCALLBACKDATA_FILE_NOTIFY pData = (PCALLBACKDATA_FILE_NOTIFY)pCallback->GetDataRaw(); 826 AssertPtr(pData); 827 Assert(pData->uType == GUEST_FILE_NOTIFYTYPE_WRITE); 828 829 size_t cbWritten = pData->u.write.cbWritten; 830 LogFlowThisFunc(("cbWritten=%RU32\n", cbWritten)); 831 832 if (pcbWritten) 833 *pcbWritten = cbWritten; 834 } 835 836 callbackDelete(pCallback); 837 838 if (pGuestRc) 839 *pGuestRc = guestRc; 840 841 LogFlowFuncLeaveRC(vrc); 842 return vrc; 843 } 844 845 int GuestFile::writeDataAt(uint64_t uOffset, uint32_t uTimeoutMS, 846 void *pvData, size_t cbData, 847 uint32_t *pcbWritten, int *pGuestRc) 848 { 849 AssertPtrReturn(pvData, VERR_INVALID_POINTER); 850 AssertReturn(cbData, VERR_INVALID_PARAMETER); 851 852 LogFlowThisFunc(("uOffset=%RU64, uTimeoutMS=%RU32, pvData=%p, cbData=%zu\n", 853 uOffset, uTimeoutMS, pvData, cbData)); 854 855 /* Prepare HGCM call. */ 856 VBOXHGCMSVCPARM paParms[4]; 857 int i = 1; /* Context ID will be set in sendFileComannd(). */ 858 paParms[i++].setUInt32(mData.mID /* File handle */); 859 paParms[i++].setUInt64(uOffset /* Offset where to starting writing */); 860 paParms[i++].setUInt32(cbData /* Size (in bytes) to write */); 861 paParms[i++].setPointer(pvData, cbData); 862 863 GuestCtrlCallback *pCallback = NULL; int guestRc; 864 int vrc = sendFileCommand(HOST_FILE_WRITE_AT, i, paParms, uTimeoutMS, 865 &guestRc, &pCallback); 866 867 if (RT_SUCCESS(vrc)) 868 { 869 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 870 871 Assert(pCallback->GetDataSize() == sizeof(CALLBACKDATA_FILE_NOTIFY)); 872 PCALLBACKDATA_FILE_NOTIFY pData = (PCALLBACKDATA_FILE_NOTIFY)pCallback->GetDataRaw(); 873 AssertPtr(pData); 874 Assert(pData->uType == GUEST_FILE_NOTIFYTYPE_WRITE); 875 876 size_t cbWritten = pData->u.write.cbWritten; 877 LogFlowThisFunc(("cbWritten=%RU32\n", cbWritten)); 878 879 if (pcbWritten) 880 *pcbWritten = cbWritten; 881 } 882 883 callbackDelete(pCallback); 884 885 if (pGuestRc) 886 *pGuestRc = guestRc; 456 887 457 888 LogFlowFuncLeaveRC(vrc); … … 472 903 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 473 904 905 /* Close file on guest. */ 906 int guestRc; 907 int rc = closeFile(&guestRc); 908 /* On failure don't return here, instead do all the cleanup 909 * work first and then return an error. */ 910 474 911 AssertPtr(mData.mSession); 475 int rc = mData.mSession->fileRemoveFromList(this); 912 int rc2 = mData.mSession->fileRemoveFromList(this); 913 if (RT_SUCCESS(rc)) 914 rc = rc2; 476 915 477 916 /* … … 483 922 484 923 LogFlowFuncLeaveRC(rc); 924 if (RT_FAILURE(rc)) 925 { 926 if (rc == VERR_GSTCTL_GUEST_ERROR) 927 return GuestFile::setErrorExternal(this, guestRc); 928 929 return setError(VBOX_E_IPRT_ERROR, 930 tr("Closing guest file failed with %Rrc\n"), rc); 931 } 932 485 933 return S_OK; 486 934 #endif /* VBOX_WITH_GUEST_CONTROL */ … … 504 952 ReturnComNotImplemented(); 505 953 #else 506 AutoCaller autoCaller(this); 507 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 508 509 ReturnComNotImplemented(); 954 if (aToRead == 0) 955 return setError(E_INVALIDARG, tr("The size to read is zero")); 956 CheckComArgOutSafeArrayPointerValid(aData); 957 958 AutoCaller autoCaller(this); 959 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 960 961 com::SafeArray<BYTE> data((size_t)aToRead); 962 Assert(data.size() >= aToRead); 963 964 HRESULT hr = S_OK; 965 966 size_t cbRead; int guestRc; 967 int vrc = readData(aToRead, aTimeoutMS, 968 data.raw(), aToRead, &cbRead, &guestRc); 969 if (RT_SUCCESS(vrc)) 970 { 971 if (data.size() != cbRead) 972 data.resize(cbRead); 973 data.detachTo(ComSafeArrayOutArg(aData)); 974 } 975 else 976 { 977 switch (vrc) 978 { 979 case VERR_GSTCTL_GUEST_ERROR: 980 hr = GuestFile::setErrorExternal(this, guestRc); 981 break; 982 983 default: 984 hr = setError(VBOX_E_IPRT_ERROR, 985 tr("Reading from file \"%s\" failed: %Rrc"), 986 mData.mOpenInfo.mFileName.c_str(), vrc); 987 break; 988 } 989 } 990 991 LogFlowThisFunc(("rc=%Rrc, cbRead=%RU64\n", vrc, cbRead)); 992 993 LogFlowFuncLeaveRC(vrc); 994 return hr; 510 995 #endif /* VBOX_WITH_GUEST_CONTROL */ 511 996 } … … 516 1001 ReturnComNotImplemented(); 517 1002 #else 518 AutoCaller autoCaller(this); 519 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 520 521 ReturnComNotImplemented(); 1003 if (aToRead == 0) 1004 return setError(E_INVALIDARG, tr("The size to read is zero")); 1005 CheckComArgOutSafeArrayPointerValid(aData); 1006 1007 AutoCaller autoCaller(this); 1008 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1009 1010 com::SafeArray<BYTE> data((size_t)aToRead); 1011 Assert(data.size() >= aToRead); 1012 1013 HRESULT hr = S_OK; 1014 1015 size_t cbRead; int guestRc; 1016 int vrc = readDataAt(aOffset, aToRead, aTimeoutMS, 1017 data.raw(), aToRead, &cbRead, &guestRc); 1018 if (RT_SUCCESS(vrc)) 1019 { 1020 if (data.size() != cbRead) 1021 data.resize(cbRead); 1022 data.detachTo(ComSafeArrayOutArg(aData)); 1023 } 1024 else 1025 { 1026 switch (vrc) 1027 { 1028 case VERR_GSTCTL_GUEST_ERROR: 1029 hr = GuestFile::setErrorExternal(this, guestRc); 1030 break; 1031 1032 default: 1033 hr = setError(VBOX_E_IPRT_ERROR, 1034 tr("Reading from file \"%s\" (at offset %RU64) failed: %Rrc"), 1035 mData.mOpenInfo.mFileName.c_str(), aOffset, vrc); 1036 break; 1037 } 1038 } 1039 1040 LogFlowThisFunc(("rc=%Rrc, cbRead=%RU64\n", vrc, cbRead)); 1041 1042 LogFlowFuncLeaveRC(vrc); 1043 return hr; 522 1044 #endif /* VBOX_WITH_GUEST_CONTROL */ 523 1045 } … … 528 1050 ReturnComNotImplemented(); 529 1051 #else 530 AutoCaller autoCaller(this); 531 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 532 533 ReturnComNotImplemented(); 1052 LogFlowThisFuncEnter(); 1053 1054 AutoCaller autoCaller(this); 1055 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1056 1057 HRESULT hr = S_OK; 1058 1059 GUEST_FILE_SEEKTYPE eSeekType; 1060 switch (aType) 1061 { 1062 case FileSeekType_Set: 1063 eSeekType = GUEST_FILE_SEEKTYPE_BEGIN; 1064 break; 1065 1066 case FileSeekType_Current: 1067 eSeekType = GUEST_FILE_SEEKTYPE_CURRENT; 1068 break; 1069 1070 default: 1071 return setError(E_INVALIDARG, tr("Invalid seek type specified")); 1072 break; 1073 } 1074 1075 int guestRc; 1076 int vrc = seekAt(aOffset, eSeekType, 1077 30 * 1000 /* 30s timeout */, &guestRc); 1078 if (RT_FAILURE(vrc)) 1079 { 1080 switch (vrc) 1081 { 1082 case VERR_GSTCTL_GUEST_ERROR: 1083 hr = GuestFile::setErrorExternal(this, guestRc); 1084 break; 1085 1086 default: 1087 hr = setError(VBOX_E_IPRT_ERROR, 1088 tr("Seeking file \"%s\" (to offset %RU64) failed: %Rrc"), 1089 mData.mOpenInfo.mFileName.c_str(), aOffset, vrc); 1090 break; 1091 } 1092 } 1093 1094 LogFlowFuncLeaveRC(vrc); 1095 return hr; 534 1096 #endif /* VBOX_WITH_GUEST_CONTROL */ 535 1097 } … … 552 1114 ReturnComNotImplemented(); 553 1115 #else 554 AutoCaller autoCaller(this); 555 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 556 557 ReturnComNotImplemented(); 1116 LogFlowThisFuncEnter(); 1117 1118 CheckComArgOutPointerValid(aWritten); 1119 1120 AutoCaller autoCaller(this); 1121 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1122 1123 HRESULT hr = S_OK; 1124 1125 com::SafeArray<BYTE> data(ComSafeArrayInArg(aData)); int guestRc; 1126 int vrc = writeData(aTimeoutMS, data.raw(), data.size(), (uint32_t*)aWritten, &guestRc); 1127 if (RT_FAILURE(vrc)) 1128 { 1129 switch (vrc) 1130 { 1131 case VERR_GSTCTL_GUEST_ERROR: 1132 hr = GuestFile::setErrorExternal(this, guestRc); 1133 break; 1134 1135 default: 1136 hr = setError(VBOX_E_IPRT_ERROR, 1137 tr("Writing to file \"%s\" failed: %Rrc"), 1138 mData.mOpenInfo.mFileName.c_str(), vrc); 1139 break; 1140 } 1141 } 1142 1143 LogFlowThisFunc(("rc=%Rrc, aWritten=%RU32\n", vrc, aWritten)); 1144 1145 LogFlowFuncLeaveRC(vrc); 1146 return hr; 558 1147 #endif /* VBOX_WITH_GUEST_CONTROL */ 559 1148 } … … 564 1153 ReturnComNotImplemented(); 565 1154 #else 566 AutoCaller autoCaller(this); 567 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 568 569 ReturnComNotImplemented(); 570 #endif /* VBOX_WITH_GUEST_CONTROL */ 571 } 572 1155 LogFlowThisFuncEnter(); 1156 1157 CheckComArgOutPointerValid(aWritten); 1158 1159 AutoCaller autoCaller(this); 1160 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1161 1162 HRESULT hr = S_OK; 1163 1164 com::SafeArray<BYTE> data(ComSafeArrayInArg(aData)); int guestRc; 1165 int vrc = writeData(aTimeoutMS, data.raw(), data.size(), (uint32_t*)aWritten, &guestRc); 1166 if (RT_FAILURE(vrc)) 1167 { 1168 switch (vrc) 1169 { 1170 case VERR_GSTCTL_GUEST_ERROR: 1171 hr = GuestFile::setErrorExternal(this, guestRc); 1172 break; 1173 1174 default: 1175 hr = setError(VBOX_E_IPRT_ERROR, 1176 tr("Writing to file \"%s\" (at offset %RU64) failed: %Rrc"), 1177 mData.mOpenInfo.mFileName.c_str(), aOffset, vrc); 1178 break; 1179 } 1180 } 1181 1182 LogFlowThisFunc(("rc=%Rrc, aWritten=%RU32\n", vrc, aWritten)); 1183 1184 LogFlowFuncLeaveRC(vrc); 1185 return hr; 1186 #endif /* VBOX_WITH_GUEST_CONTROL */ 1187 } 1188 -
trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp
r45078 r45109 949 949 alock.acquire(); 950 950 951 AssertPtr(pCallbackRead);952 951 int rc2 = callbackRemove(uContextID); 953 952 if (RT_SUCCESS(vrc)) 954 953 vrc = rc2; 954 955 callbackDelete(pCallbackRead); 955 956 956 957 LogFlowFuncLeaveRC(vrc); … … 1015 1016 uint32_t uContextID = 0; 1016 1017 1017 GuestCtrlCallback *pCallbackStart ;1018 GuestCtrlCallback *pCallbackStart = NULL; 1018 1019 try 1019 1020 { … … 1174 1175 AutoWriteLock awlock(this COMMA_LOCKVAL_SRC_POS); 1175 1176 1176 AssertPtr(pCallbackStart);1177 1177 int rc2 = callbackRemove(uContextID); 1178 1178 if (RT_SUCCESS(vrc)) 1179 1179 vrc = rc2; 1180 1180 } 1181 1182 callbackDelete(pCallbackStart); 1181 1183 1182 1184 LogFlowFuncLeaveRC(vrc); … … 1305 1307 alock.acquire(); 1306 1308 1307 AssertPtr(pCallbackTerminate);1308 1309 int rc2 = callbackRemove(uContextID); 1309 1310 if (RT_SUCCESS(vrc)) 1310 1311 vrc = rc2; 1312 1313 callbackDelete(pCallbackTerminate); 1311 1314 1312 1315 LogFlowFuncLeaveRC(vrc); … … 1617 1620 vrc = rc2; 1618 1621 1622 callbackDelete(pCallbackWrite); 1623 1619 1624 LogFlowFuncLeaveRC(vrc); 1620 1625 return vrc; … … 1807 1812 AutoCaller autoCaller(this); 1808 1813 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1809 1810 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);1811 1814 1812 1815 HRESULT hr = S_OK; -
trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp
r45078 r45109 968 968 return rc; 969 969 970 /* Add the created file to our vector. */ 971 mData.mFiles[uNewFileID] = pFile; 972 mData.mNumObjects++; 973 Assert(mData.mNumObjects <= VBOX_GUESTCTRL_MAX_OBJECTS); 974 975 LogFlowFunc(("Added new file \"%s\" (Session: %RU32) (now total %ld files, %ld objects)\n", 976 openInfo.mFileName.c_str(), mData.mSession.mID, mData.mFiles.size(), mData.mNumObjects)); 970 int guestRc; 971 rc = pFile->openFile(&guestRc); 972 if (RT_SUCCESS(rc)) 973 { 974 /* Add the created file to our vector. */ 975 mData.mFiles[uNewFileID] = pFile; 976 mData.mNumObjects++; 977 Assert(mData.mNumObjects <= VBOX_GUESTCTRL_MAX_OBJECTS); 978 979 LogFlowFunc(("Added new file \"%s\" (Session: %RU32) (now total %ld files, %ld objects)\n", 980 openInfo.mFileName.c_str(), mData.mSession.mID, mData.mFiles.size(), mData.mNumObjects)); 981 } 982 983 if (pGuestRc) 984 *pGuestRc = guestRc; 977 985 978 986 LogFlowFuncLeaveRC(rc); … … 1794 1802 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1795 1803 1796 /* Close session on guest session. */1804 /* Close session on guest. */ 1797 1805 int guestRc; 1798 1806 int rc = closeSession(0 /* Flags */, 30 * 1000 /* Timeout */, … … 1816 1824 if (RT_FAILURE(rc)) 1817 1825 { 1818 /** @todo Handle guestRc! */ 1826 if (rc == VERR_GSTCTL_GUEST_ERROR) 1827 return GuestSession::setErrorExternal(this, guestRc); 1828 1819 1829 return setError(VBOX_E_IPRT_ERROR, 1820 1830 tr("Closing guest session failed with %Rrc\n"), rc); … … 2483 2493 { 2484 2494 case VERR_GSTCTL_GUEST_ERROR: 2485 hr = Guest Process::setErrorExternal(this, guestRc);2495 hr = GuestFile::setErrorExternal(this, guestRc); 2486 2496 break; 2487 2497 2488 2498 default: 2489 hr = setError(VBOX_E_IPRT_ERROR, tr("Opening file \"%s\" failed: %Rrc"),2499 hr = setError(VBOX_E_IPRT_ERROR, tr("Opening guest file \"%s\" failed: %Rrc"), 2490 2500 Utf8Str(aPath).c_str(), vrc); 2491 2501 break;
Note:
See TracChangeset
for help on using the changeset viewer.