Changeset 75758 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Nov 27, 2018 6:00:54 AM (6 years ago)
- Location:
- trunk/src/VBox/Additions/common
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibGuestCtrl.cpp
r75724 r75758 46 46 47 47 48 /********************************************************************************************************************************* 49 * Global Variables * 50 *********************************************************************************************************************************/ 51 /** Set if GUEST_MSG_PEEK_WAIT and friends are supported. */ 52 static int g_fVbglR3GuestCtrlHavePeekGetCancel = -1; 53 54 48 55 /** 49 56 * Connects to the guest control service. … … 81 88 * be received in a second call to the host. 82 89 */ 83 VBGLR3DECL(int) VbglR3GuestCtrlMsgWaitFor(uint32_t uClientId, uint32_t *pidMsg, uint32_t *pcParameters)90 static int vbglR3GuestCtrlMsgWaitFor(uint32_t uClientId, uint32_t *pidMsg, uint32_t *pcParameters) 84 91 { 85 92 AssertPtrReturn(pidMsg, VERR_INVALID_POINTER); … … 149 156 150 157 /** 158 * Determins the value of g_fVbglR3GuestCtrlHavePeekGetCancel. 159 * 160 * @returns true if supported, false if not. 161 * @param idClient The client ID to use for the testing. 162 */ 163 DECL_NO_INLINE(static, bool) vbglR3GuestCtrlDetectPeekGetCancelSupport(uint32_t idClient) 164 { 165 /* 166 * Seems we get VINF_SUCCESS back from the host if we try unsupported 167 * guest control functions, so we need to supply some random message 168 * parameters and check that they change. 169 */ 170 uint32_t const idDummyMsg = UINT32_C(0x8350bdca); 171 uint32_t const cDummyParmeters = UINT32_C(0x7439604f); 172 uint32_t const cbDummyMask = UINT32_C(0xc0ffe000); 173 Assert(cDummyParmeters > VMMDEV_MAX_HGCM_PARMS); 174 175 int rc; 176 struct 177 { 178 VBGLIOCHGCMCALL Hdr; 179 HGCMFunctionParameter idMsg; 180 HGCMFunctionParameter cParams; 181 HGCMFunctionParameter acbParams[14]; 182 } PeekCall; 183 Assert(RT_ELEMENTS(PeekCall.acbParams) + 2 < VMMDEV_MAX_HGCM_PARMS); 184 185 do 186 { 187 memset(&PeekCall, 0xf6, sizeof(PeekCall)); 188 VBGL_HGCM_HDR_INIT(&PeekCall.Hdr, idClient, GUEST_MSG_PEEK_NOWAIT, 16); 189 VbglHGCMParmUInt32Set(&PeekCall.idMsg, idDummyMsg); 190 VbglHGCMParmUInt32Set(&PeekCall.cParams, cDummyParmeters); 191 for (uint32_t i = 0; i < RT_ELEMENTS(PeekCall.acbParams); i++) 192 VbglHGCMParmUInt32Set(&PeekCall.acbParams[i], i | cbDummyMask); 193 194 rc = VbglR3HGCMCall(&PeekCall.Hdr, sizeof(PeekCall)); 195 } while (rc == VERR_INTERRUPTED); 196 197 LogRel2(("vbglR3GuestCtrlDetectPeekGetCancelSupport: rc=%Rrc %#x %#x %#x %#x %#x %#x %#x %#x %#x %#x %#x %#x %#x %#x %#x %#x\n", 198 rc, PeekCall.idMsg.u.value32, PeekCall.cParams.u.value32, 199 PeekCall.acbParams[ 0].u.value32, PeekCall.acbParams[ 1].u.value32, 200 PeekCall.acbParams[ 2].u.value32, PeekCall.acbParams[ 3].u.value32, 201 PeekCall.acbParams[ 4].u.value32, PeekCall.acbParams[ 5].u.value32, 202 PeekCall.acbParams[ 6].u.value32, PeekCall.acbParams[ 7].u.value32, 203 PeekCall.acbParams[ 8].u.value32, PeekCall.acbParams[ 9].u.value32, 204 PeekCall.acbParams[10].u.value32, PeekCall.acbParams[11].u.value32, 205 PeekCall.acbParams[12].u.value32, PeekCall.acbParams[13].u.value32)); 206 207 #if 0 /* enable after testing. */ 208 /* 209 * VERR_TRY_AGAIN is likely and easy. 210 */ 211 if ( rc == VERR_TRY_AGAIN 212 && PeekCall.idMsg.u.value32 == 0 213 && PeekCall.cParams.u.value32 == 0 214 && PeekCall.acbParams[0].u.value32 == 0 215 && PeekCall.acbParams[1].u.value32 == 0 216 && PeekCall.acbParams[2].u.value32 == 0 217 && PeekCall.acbParams[3].u.value32 == 0) 218 { 219 g_fVbglR3GuestCtrlHavePeekGetCancel = 1; 220 LogRel(("vbglR3GuestCtrlDetectPeekGetCancelSupport: Supported (#1)\n")); 221 return true; 222 } 223 224 /* 225 * VINF_SUCCESS is annoying but with 16 parameters we've got plenty to check. 226 */ 227 if ( rc == VINF_SUCCESS 228 && PeekCall.idMsg.u.value32 != idDummyMsg 229 && PeekCall.idMsg.u.value32 != 0 230 && PeekCall.cParams.u.value32 <= VMMDEV_MAX_HGCM_PARMS) 231 { 232 for (uint32_t i = 0; i < RT_ELEMENTS(PeekCall.acbParams); i++) 233 if (PeekCall.acbParams[i].u.value32 != (i | cbDummyMask)) 234 { 235 g_fVbglR3GuestCtrlHavePeekGetCancel = 0; 236 LogRel(("vbglR3GuestCtrlDetectPeekGetCancelSupport: Not supported (#1)\n")); 237 return false; 238 } 239 g_fVbglR3GuestCtrlHavePeekGetCancel = 1; 240 LogRel(("vbglR3GuestCtrlDetectPeekGetCancelSupport: Supported (#2)\n")); 241 return true; 242 } 243 #endif 244 245 /* 246 * If we get an invalid handle status, we can't really tell. 247 */ 248 if (rc != VERR_INVALID_HANDLE) 249 { 250 LogRel(("vbglR3GuestCtrlDetectPeekGetCancelSupport: Not supported (#3)\n")); 251 g_fVbglR3GuestCtrlHavePeekGetCancel = 0; 252 } 253 else 254 LogRel(("vbglR3GuestCtrlDetectPeekGetCancelSupport: Jury is still out (#4)\n")); 255 return false; 256 } 257 258 259 /** 260 * Reads g_fVbglR3GuestCtrlHavePeekGetCancel and resolved -1. 261 * 262 * @returns true if supported, false if not. 263 * @param idClient The client ID to use for the testing. 264 */ 265 DECLINLINE(bool) vbglR3GuestCtrlSupportsPeekGetCancel(uint32_t idClient) 266 { 267 int fState = g_fVbglR3GuestCtrlHavePeekGetCancel; 268 if (RT_LIKELY(fState != -1)) 269 return fState != 0; 270 return vbglR3GuestCtrlDetectPeekGetCancelSupport(idClient); 271 } 272 273 274 /** 275 * Figures which getter function to use to retrieve the message. 276 */ 277 DECLINLINE(uint32_t) vbglR3GuestCtrlGetMsgFunctionNo(uint32_t idClient) 278 { 279 return vbglR3GuestCtrlSupportsPeekGetCancel(idClient) ? GUEST_MSG_GET : GUEST_MSG_WAIT; 280 } 281 282 283 /** 284 * Peeks at the next host message, waiting for one to turn up. 285 * 286 * @returns VBox status code. 287 * @retval VERR_INTERRUPTED if interrupted. Does the necessary cleanup, so 288 * caller just have to repeat this call. 289 * 290 * @param idClient The client ID returned by VbglR3GuestCtrlConnect(). 291 * @param pidMsg Where to store the message id. 292 * @param pcParameters Where to store the number of parameters which will 293 * be received in a second call to the host. 294 */ 295 VBGLR3DECL(int) VbglR3GuestCtrlMsgPeekWait(uint32_t idClient, uint32_t *pidMsg, uint32_t *pcParameters) 296 { 297 AssertPtrReturn(pidMsg, VERR_INVALID_POINTER); 298 AssertPtrReturn(pcParameters, VERR_INVALID_POINTER); 299 300 int rc; 301 if (vbglR3GuestCtrlSupportsPeekGetCancel(idClient)) 302 { 303 HGCMMsgCmdWaitFor Msg; 304 VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, GUEST_MSG_PEEK_WAIT, 2); 305 VbglHGCMParmUInt32Set(&Msg.msg, 0); 306 VbglHGCMParmUInt32Set(&Msg.num_parms, 0); 307 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 308 if (RT_SUCCESS(rc)) 309 { 310 AssertMsgReturn( Msg.msg.type == VMMDevHGCMParmType_32bit 311 && Msg.num_parms.type == VMMDevHGCMParmType_32bit, 312 ("msg.type=%d num_parms.type=%d\n", Msg.msg.type, Msg.num_parms.type), 313 VERR_INTERNAL_ERROR_3); 314 315 *pidMsg = Msg.msg.u.value32; 316 *pcParameters = Msg.num_parms.u.value32; 317 return rc; 318 } 319 320 /* 321 * If interrupted we must cancel the call so it doesn't prevent us from making another one. 322 */ 323 if (rc == VERR_INTERRUPTED) 324 { 325 VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, GUEST_MSG_CANCEL, 0); 326 int rc2 = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg.hdr)); 327 AssertRC(rc2); 328 } 329 330 *pidMsg = UINT32_MAX - 1; 331 *pcParameters = UINT32_MAX - 2; 332 return rc; 333 } 334 335 /* 336 * Fallback if host < v6.0. 337 */ 338 return vbglR3GuestCtrlMsgWaitFor(idClient, pidMsg, pcParameters); 339 } 340 341 342 /** 151 343 * Asks the host guest control service to set a command filter to this 152 344 * client so that it only will receive certain commands in the future. … … 159 351 * @param uMaskRemove Filter mask to remove. 160 352 */ 161 VBGLR3DECL(int) VbglR3GuestCtrlMsgFilterSet(uint32_t uClientId, uint32_t uValue, 162 uint32_t uMaskAdd, uint32_t uMaskRemove) 353 VBGLR3DECL(int) VbglR3GuestCtrlMsgFilterSet(uint32_t uClientId, uint32_t uValue, uint32_t uMaskAdd, uint32_t uMaskRemove) 163 354 { 164 355 HGCMMsgCmdFilterSet Msg; … … 287 478 288 479 /** 289 * Retrieves the request to create a new guest session. 290 * 291 * @return IPRT status code. 292 ** @todo Docs! 480 * Retrieves a HOST_SESSION_CREATE message. 293 481 */ 294 482 VBGLR3DECL(int) VbglR3GuestCtrlSessionGetOpen(PVBGLR3GUESTCTRLCMDCTX pCtx, … … 308 496 AssertPtrReturn(pfFlags, VERR_INVALID_POINTER); 309 497 310 HGCMMsgSessionOpen Msg;311 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);312 VbglHGCMParmUInt32Set(&Msg.context, 0);313 VbglHGCMParmUInt32Set(&Msg.protocol, 0);314 VbglHGCMParmPtrSet(&Msg.username, pszUser, cbUser);315 VbglHGCMParmPtrSet(&Msg.password, pszPassword, cbPassword);316 VbglHGCMParmPtrSet(&Msg.domain, pszDomain, cbDomain);317 VbglHGCMParmUInt32Set(&Msg.flags, 0);318 319 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));320 if (RT_SUCCESS(rc))321 { 322 Msg.context.GetUInt32(&pCtx->uContextID);323 Msg.protocol.GetUInt32(puProtocol);324 Msg.flags.GetUInt32(pfFlags);325 326 if (pidSession)327 *pidSession = VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pCtx->uContextID);328 } 329 330 return rc;331 }332 333 334 /** 335 * Retrieves the request to terminate an existing guest session. 336 * 337 * @return IPRT status code. 338 * * @todo Docs!498 int rc; 499 do 500 { 501 HGCMMsgSessionOpen Msg; 502 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, vbglR3GuestCtrlGetMsgFunctionNo(pCtx->uClientID), pCtx->uNumParms); 503 VbglHGCMParmUInt32Set(&Msg.context, HOST_SESSION_CREATE); 504 VbglHGCMParmUInt32Set(&Msg.protocol, 0); 505 VbglHGCMParmPtrSet(&Msg.username, pszUser, cbUser); 506 VbglHGCMParmPtrSet(&Msg.password, pszPassword, cbPassword); 507 VbglHGCMParmPtrSet(&Msg.domain, pszDomain, cbDomain); 508 VbglHGCMParmUInt32Set(&Msg.flags, 0); 509 510 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 511 if (RT_SUCCESS(rc)) 512 { 513 Msg.context.GetUInt32(&pCtx->uContextID); 514 Msg.protocol.GetUInt32(puProtocol); 515 Msg.flags.GetUInt32(pfFlags); 516 517 if (pidSession) 518 *pidSession = VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pCtx->uContextID); 519 } 520 } while (rc == VERR_INTERRUPTED && g_fVbglR3GuestCtrlHavePeekGetCancel); 521 return rc; 522 } 523 524 525 /** 526 * Retrieves a HOST_SESSION_CLOSE message. 339 527 */ 340 528 VBGLR3DECL(int) VbglR3GuestCtrlSessionGetClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *pfFlags, uint32_t *pidSession) … … 345 533 AssertPtrReturn(pfFlags, VERR_INVALID_POINTER); 346 534 347 HGCMMsgSessionClose Msg; 348 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms); 349 VbglHGCMParmUInt32Set(&Msg.context, 0); 350 VbglHGCMParmUInt32Set(&Msg.flags, 0); 351 352 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 353 if (RT_SUCCESS(rc)) 354 { 355 Msg.context.GetUInt32(&pCtx->uContextID); 356 Msg.flags.GetUInt32(pfFlags); 357 358 if (pidSession) 359 *pidSession = VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pCtx->uContextID); 360 } 361 362 return rc; 363 } 364 365 535 int rc; 536 do 537 { 538 HGCMMsgSessionClose Msg; 539 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, vbglR3GuestCtrlGetMsgFunctionNo(pCtx->uClientID), pCtx->uNumParms); 540 VbglHGCMParmUInt32Set(&Msg.context, HOST_SESSION_CLOSE); 541 VbglHGCMParmUInt32Set(&Msg.flags, 0); 542 543 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 544 if (RT_SUCCESS(rc)) 545 { 546 Msg.context.GetUInt32(&pCtx->uContextID); 547 Msg.flags.GetUInt32(pfFlags); 548 549 if (pidSession) 550 *pidSession = VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pCtx->uContextID); 551 } 552 } while (rc == VERR_INTERRUPTED && g_fVbglR3GuestCtrlHavePeekGetCancel); 553 return rc; 554 } 555 556 557 /** 558 * Retrieves a HOST_SESSION_CLOSE message. 559 */ 366 560 VBGLR3DECL(int) VbglR3GuestCtrlPathGetRename(PVBGLR3GUESTCTRLCMDCTX pCtx, 367 561 char *pszSource, uint32_t cbSource, … … 378 572 AssertPtrReturn(pfFlags, VERR_INVALID_POINTER); 379 573 380 HGCMMsgPathRename Msg; 381 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms); 382 VbglHGCMParmUInt32Set(&Msg.context, 0); 383 VbglHGCMParmPtrSet(&Msg.source, pszSource, cbSource); 384 VbglHGCMParmPtrSet(&Msg.dest, pszDest, cbDest); 385 VbglHGCMParmUInt32Set(&Msg.flags, 0); 386 387 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 388 if (RT_SUCCESS(rc)) 389 { 390 Msg.context.GetUInt32(&pCtx->uContextID); 391 Msg.flags.GetUInt32(pfFlags); 392 } 393 return rc; 394 } 395 396 574 int rc; 575 do 576 { 577 HGCMMsgPathRename Msg; 578 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, vbglR3GuestCtrlGetMsgFunctionNo(pCtx->uClientID), pCtx->uNumParms); 579 VbglHGCMParmUInt32Set(&Msg.context, HOST_PATH_RENAME); 580 VbglHGCMParmPtrSet(&Msg.source, pszSource, cbSource); 581 VbglHGCMParmPtrSet(&Msg.dest, pszDest, cbDest); 582 VbglHGCMParmUInt32Set(&Msg.flags, 0); 583 584 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 585 if (RT_SUCCESS(rc)) 586 { 587 Msg.context.GetUInt32(&pCtx->uContextID); 588 Msg.flags.GetUInt32(pfFlags); 589 } 590 } while (rc == VERR_INTERRUPTED && g_fVbglR3GuestCtrlHavePeekGetCancel); 591 return rc; 592 } 593 594 595 /** 596 * Retrieves a HOST_PATH_USER_DOCUMENTS message. 597 */ 397 598 VBGLR3DECL(int) VbglR3GuestCtrlPathGetUserDocuments(PVBGLR3GUESTCTRLCMDCTX pCtx) 398 599 { … … 400 601 AssertReturn(pCtx->uNumParms == 1, VERR_INVALID_PARAMETER); 401 602 402 HGCMMsgPathUserDocuments Msg; 403 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms); 404 VbglHGCMParmUInt32Set(&Msg.context, 0); 405 406 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 407 if (RT_SUCCESS(rc)) 408 Msg.context.GetUInt32(&pCtx->uContextID); 409 410 return rc; 411 } 412 413 603 int rc; 604 do 605 { 606 HGCMMsgPathUserDocuments Msg; 607 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, vbglR3GuestCtrlGetMsgFunctionNo(pCtx->uClientID), pCtx->uNumParms); 608 VbglHGCMParmUInt32Set(&Msg.context, HOST_PATH_USER_DOCUMENTS); 609 610 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 611 if (RT_SUCCESS(rc)) 612 Msg.context.GetUInt32(&pCtx->uContextID); 613 } while (rc == VERR_INTERRUPTED && g_fVbglR3GuestCtrlHavePeekGetCancel); 614 return rc; 615 } 616 617 618 /** 619 * Retrieves a HOST_PATH_USER_HOME message. 620 */ 414 621 VBGLR3DECL(int) VbglR3GuestCtrlPathGetUserHome(PVBGLR3GUESTCTRLCMDCTX pCtx) 415 622 { … … 417 624 AssertReturn(pCtx->uNumParms == 1, VERR_INVALID_PARAMETER); 418 625 419 HGCMMsgPathUserHome Msg; 420 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms); 421 VbglHGCMParmUInt32Set(&Msg.context, 0); 422 423 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 424 if (RT_SUCCESS(rc)) 425 Msg.context.GetUInt32(&pCtx->uContextID); 426 427 return rc; 428 } 429 430 431 /** 432 * Allocates and gets host data, based on the message id. 433 * 434 * This will block until data becomes available. 435 * 436 * @returns VBox status code. 437 ** @todo Docs! 438 ** @todo Move the parameters in an own struct! 626 int rc; 627 do 628 { 629 HGCMMsgPathUserHome Msg; 630 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, vbglR3GuestCtrlGetMsgFunctionNo(pCtx->uClientID), pCtx->uNumParms); 631 VbglHGCMParmUInt32Set(&Msg.context, HOST_PATH_USER_HOME); 632 633 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 634 if (RT_SUCCESS(rc)) 635 Msg.context.GetUInt32(&pCtx->uContextID); 636 } while (rc == VERR_INTERRUPTED && g_fVbglR3GuestCtrlHavePeekGetCancel); 637 return rc; 638 } 639 640 641 /** 642 * Retrieves a HOST_EXEC_CMD message. 643 * 644 * @todo Move the parameters in an own struct! 439 645 */ 440 646 VBGLR3DECL(int) VbglR3GuestCtrlProcGetStart(PVBGLR3GUESTCTRLCMDCTX pCtx, … … 460 666 AssertPtrReturn(puTimeoutMS, VERR_INVALID_POINTER); 461 667 462 HGCMMsgProcExec Msg; 463 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms); 464 VbglHGCMParmUInt32Set(&Msg.context, 0); 465 VbglHGCMParmPtrSet(&Msg.cmd, pszCmd, cbCmd); 466 VbglHGCMParmUInt32Set(&Msg.flags, 0); 467 VbglHGCMParmUInt32Set(&Msg.num_args, 0); 468 VbglHGCMParmPtrSet(&Msg.args, pszArgs, cbArgs); 469 VbglHGCMParmUInt32Set(&Msg.num_env, 0); 470 VbglHGCMParmUInt32Set(&Msg.cb_env, 0); 471 VbglHGCMParmPtrSet(&Msg.env, pszEnv, *pcbEnv); 472 if (pCtx->uProtocol < 2) 473 { 474 AssertPtrReturn(pszUser, VERR_INVALID_POINTER); 475 AssertReturn(cbUser, VERR_INVALID_PARAMETER); 476 AssertPtrReturn(pszPassword, VERR_INVALID_POINTER); 477 AssertReturn(pszPassword, VERR_INVALID_PARAMETER); 478 479 VbglHGCMParmPtrSet(&Msg.u.v1.username, pszUser, cbUser); 480 VbglHGCMParmPtrSet(&Msg.u.v1.password, pszPassword, cbPassword); 481 VbglHGCMParmUInt32Set(&Msg.u.v1.timeout, 0); 482 } 483 else 484 { 485 AssertPtrReturn(puAffinity, VERR_INVALID_POINTER); 486 AssertReturn(cbAffinity, VERR_INVALID_PARAMETER); 487 488 VbglHGCMParmUInt32Set(&Msg.u.v2.timeout, 0); 489 VbglHGCMParmUInt32Set(&Msg.u.v2.priority, 0); 490 VbglHGCMParmUInt32Set(&Msg.u.v2.num_affinity, 0); 491 VbglHGCMParmPtrSet(&Msg.u.v2.affinity, puAffinity, cbAffinity); 492 } 493 494 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 495 if (RT_SUCCESS(rc)) 496 { 497 Msg.context.GetUInt32(&pCtx->uContextID); 498 Msg.flags.GetUInt32(pfFlags); 499 Msg.num_args.GetUInt32(pcArgs); 500 Msg.num_env.GetUInt32(pcEnvVars); 501 Msg.cb_env.GetUInt32(pcbEnv); 668 int rc; 669 do 670 { 671 HGCMMsgProcExec Msg; 672 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, vbglR3GuestCtrlGetMsgFunctionNo(pCtx->uClientID), pCtx->uNumParms); 673 VbglHGCMParmUInt32Set(&Msg.context, HOST_EXEC_CMD); 674 VbglHGCMParmPtrSet(&Msg.cmd, pszCmd, cbCmd); 675 VbglHGCMParmUInt32Set(&Msg.flags, 0); 676 VbglHGCMParmUInt32Set(&Msg.num_args, 0); 677 VbglHGCMParmPtrSet(&Msg.args, pszArgs, cbArgs); 678 VbglHGCMParmUInt32Set(&Msg.num_env, 0); 679 VbglHGCMParmUInt32Set(&Msg.cb_env, 0); 680 VbglHGCMParmPtrSet(&Msg.env, pszEnv, *pcbEnv); 502 681 if (pCtx->uProtocol < 2) 503 682 { 504 Msg.u.v1.timeout.GetUInt32(puTimeoutMS); 683 AssertPtrReturn(pszUser, VERR_INVALID_POINTER); 684 AssertReturn(cbUser, VERR_INVALID_PARAMETER); 685 AssertPtrReturn(pszPassword, VERR_INVALID_POINTER); 686 AssertReturn(pszPassword, VERR_INVALID_PARAMETER); 687 688 VbglHGCMParmPtrSet(&Msg.u.v1.username, pszUser, cbUser); 689 VbglHGCMParmPtrSet(&Msg.u.v1.password, pszPassword, cbPassword); 690 VbglHGCMParmUInt32Set(&Msg.u.v1.timeout, 0); 505 691 } 506 692 else 507 693 { 508 Msg.u.v2.timeout.GetUInt32(puTimeoutMS); 509 Msg.u.v2.priority.GetUInt32(puPriority); 510 Msg.u.v2.num_affinity.GetUInt32(pcAffinity); 511 } 512 } 694 AssertPtrReturn(puAffinity, VERR_INVALID_POINTER); 695 AssertReturn(cbAffinity, VERR_INVALID_PARAMETER); 696 697 VbglHGCMParmUInt32Set(&Msg.u.v2.timeout, 0); 698 VbglHGCMParmUInt32Set(&Msg.u.v2.priority, 0); 699 VbglHGCMParmUInt32Set(&Msg.u.v2.num_affinity, 0); 700 VbglHGCMParmPtrSet(&Msg.u.v2.affinity, puAffinity, cbAffinity); 701 } 702 703 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 704 if (RT_SUCCESS(rc)) 705 { 706 Msg.context.GetUInt32(&pCtx->uContextID); 707 Msg.flags.GetUInt32(pfFlags); 708 Msg.num_args.GetUInt32(pcArgs); 709 Msg.num_env.GetUInt32(pcEnvVars); 710 Msg.cb_env.GetUInt32(pcbEnv); 711 if (pCtx->uProtocol < 2) 712 Msg.u.v1.timeout.GetUInt32(puTimeoutMS); 713 else 714 { 715 Msg.u.v2.timeout.GetUInt32(puTimeoutMS); 716 Msg.u.v2.priority.GetUInt32(puPriority); 717 Msg.u.v2.num_affinity.GetUInt32(pcAffinity); 718 } 719 } 720 } while (rc == VERR_INTERRUPTED && g_fVbglR3GuestCtrlHavePeekGetCancel); 513 721 return rc; 514 722 } … … 533 741 AssertPtrReturn(pfFlags, VERR_INVALID_POINTER); 534 742 535 HGCMMsgProcOutput Msg; 536 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms); 537 VbglHGCMParmUInt32Set(&Msg.context, 0); 538 VbglHGCMParmUInt32Set(&Msg.pid, 0); 539 VbglHGCMParmUInt32Set(&Msg.handle, 0); 540 VbglHGCMParmUInt32Set(&Msg.flags, 0); 541 542 int rc = VbglR3HGCMCall(&Msg.hdr, RT_UOFFSETOF(HGCMMsgProcOutput, data)); 543 if (RT_SUCCESS(rc)) 544 { 545 Msg.context.GetUInt32(&pCtx->uContextID); 546 Msg.pid.GetUInt32(puPID); 547 Msg.handle.GetUInt32(puHandle); 548 Msg.flags.GetUInt32(pfFlags); 549 } 550 return rc; 551 } 552 553 554 /** 555 * Retrieves the input data from host which then gets sent to the 556 * started process. 743 int rc; 744 do 745 { 746 HGCMMsgProcOutput Msg; 747 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, vbglR3GuestCtrlGetMsgFunctionNo(pCtx->uClientID), pCtx->uNumParms); 748 VbglHGCMParmUInt32Set(&Msg.context, 0); 749 VbglHGCMParmUInt32Set(&Msg.pid, 0); 750 VbglHGCMParmUInt32Set(&Msg.handle, 0); 751 VbglHGCMParmUInt32Set(&Msg.flags, 0); 752 753 rc = VbglR3HGCMCall(&Msg.hdr, RT_UOFFSETOF(HGCMMsgProcOutput, data)); 754 if (RT_SUCCESS(rc)) 755 { 756 Msg.context.GetUInt32(&pCtx->uContextID); 757 Msg.pid.GetUInt32(puPID); 758 Msg.handle.GetUInt32(puHandle); 759 Msg.flags.GetUInt32(pfFlags); 760 } 761 } while (rc == VERR_INTERRUPTED && g_fVbglR3GuestCtrlHavePeekGetCancel); 762 return rc; 763 } 764 765 766 /** 767 * Retrieves the input data from host which then gets sent to the started 768 * process (HOST_EXEC_SET_INPUT). 557 769 * 558 770 * This will block until data becomes available. 559 *560 * @returns VBox status code.561 ** @todo Docs!562 771 */ 563 772 VBGLR3DECL(int) VbglR3GuestCtrlProcGetInput(PVBGLR3GUESTCTRLCMDCTX pCtx, … … 574 783 AssertPtrReturn(pcbSize, VERR_INVALID_POINTER); 575 784 576 HGCMMsgProcInput Msg; 577 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms); 578 VbglHGCMParmUInt32Set(&Msg.context, 0); 579 VbglHGCMParmUInt32Set(&Msg.pid, 0); 580 VbglHGCMParmUInt32Set(&Msg.flags, 0); 581 VbglHGCMParmPtrSet(&Msg.data, pvData, cbData); 582 VbglHGCMParmUInt32Set(&Msg.size, 0); 583 584 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 585 if (RT_SUCCESS(rc)) 586 { 587 Msg.context.GetUInt32(&pCtx->uContextID); 588 Msg.pid.GetUInt32(puPID); 589 Msg.flags.GetUInt32(pfFlags); 590 Msg.size.GetUInt32(pcbSize); 591 } 592 return rc; 593 } 594 595 785 int rc; 786 do 787 { 788 HGCMMsgProcInput Msg; 789 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, vbglR3GuestCtrlGetMsgFunctionNo(pCtx->uClientID), pCtx->uNumParms); 790 VbglHGCMParmUInt32Set(&Msg.context, HOST_EXEC_SET_INPUT); 791 VbglHGCMParmUInt32Set(&Msg.pid, 0); 792 VbglHGCMParmUInt32Set(&Msg.flags, 0); 793 VbglHGCMParmPtrSet(&Msg.data, pvData, cbData); 794 VbglHGCMParmUInt32Set(&Msg.size, 0); 795 796 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 797 if (RT_SUCCESS(rc)) 798 { 799 Msg.context.GetUInt32(&pCtx->uContextID); 800 Msg.pid.GetUInt32(puPID); 801 Msg.flags.GetUInt32(pfFlags); 802 Msg.size.GetUInt32(pcbSize); 803 } 804 } while (rc == VERR_INTERRUPTED && g_fVbglR3GuestCtrlHavePeekGetCancel); 805 return rc; 806 } 807 808 809 /** 810 * Retrieves a HOST_DIR_REMOVE message. 811 */ 596 812 VBGLR3DECL(int) VbglR3GuestCtrlDirGetRemove(PVBGLR3GUESTCTRLCMDCTX pCtx, 597 813 char *pszPath, uint32_t cbPath, … … 605 821 AssertPtrReturn(pfFlags, VERR_INVALID_POINTER); 606 822 607 HGCMMsgDirRemove Msg; 608 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms); 609 VbglHGCMParmUInt32Set(&Msg.context, 0); 610 VbglHGCMParmPtrSet(&Msg.path, pszPath, cbPath); 611 VbglHGCMParmUInt32Set(&Msg.flags, 0); 612 613 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 614 if (RT_SUCCESS(rc)) 615 { 616 Msg.context.GetUInt32(&pCtx->uContextID); 617 Msg.flags.GetUInt32(pfFlags); 618 } 619 return rc; 620 } 621 622 823 int rc; 824 do 825 { 826 HGCMMsgDirRemove Msg; 827 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, vbglR3GuestCtrlGetMsgFunctionNo(pCtx->uClientID), pCtx->uNumParms); 828 VbglHGCMParmUInt32Set(&Msg.context, HOST_DIR_REMOVE); 829 VbglHGCMParmPtrSet(&Msg.path, pszPath, cbPath); 830 VbglHGCMParmUInt32Set(&Msg.flags, 0); 831 832 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 833 if (RT_SUCCESS(rc)) 834 { 835 Msg.context.GetUInt32(&pCtx->uContextID); 836 Msg.flags.GetUInt32(pfFlags); 837 } 838 } while (rc == VERR_INTERRUPTED && g_fVbglR3GuestCtrlHavePeekGetCancel); 839 return rc; 840 } 841 842 843 /** 844 * Retrieves a HOST_FILE_OPEN message. 845 */ 623 846 VBGLR3DECL(int) VbglR3GuestCtrlFileGetOpen(PVBGLR3GUESTCTRLCMDCTX pCtx, 624 847 char *pszFileName, uint32_t cbFileName, … … 643 866 AssertPtrReturn(poffAt, VERR_INVALID_POINTER); 644 867 645 HGCMMsgFileOpen Msg; 646 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms); 647 VbglHGCMParmUInt32Set(&Msg.context, 0); 648 VbglHGCMParmPtrSet(&Msg.filename, pszFileName, cbFileName); 649 VbglHGCMParmPtrSet(&Msg.openmode, pszAccess, cbAccess); 650 VbglHGCMParmPtrSet(&Msg.disposition, pszDisposition, cbDisposition); 651 VbglHGCMParmPtrSet(&Msg.sharing, pszSharing, cbSharing); 652 VbglHGCMParmUInt32Set(&Msg.creationmode, 0); 653 VbglHGCMParmUInt64Set(&Msg.offset, 0); 654 655 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 656 if (RT_SUCCESS(rc)) 657 { 658 Msg.context.GetUInt32(&pCtx->uContextID); 659 Msg.creationmode.GetUInt32(puCreationMode); 660 Msg.offset.GetUInt64(poffAt); 661 } 662 return rc; 663 } 664 665 868 int rc; 869 do 870 { 871 HGCMMsgFileOpen Msg; 872 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, vbglR3GuestCtrlGetMsgFunctionNo(pCtx->uClientID), pCtx->uNumParms); 873 VbglHGCMParmUInt32Set(&Msg.context, HOST_FILE_OPEN); 874 VbglHGCMParmPtrSet(&Msg.filename, pszFileName, cbFileName); 875 VbglHGCMParmPtrSet(&Msg.openmode, pszAccess, cbAccess); 876 VbglHGCMParmPtrSet(&Msg.disposition, pszDisposition, cbDisposition); 877 VbglHGCMParmPtrSet(&Msg.sharing, pszSharing, cbSharing); 878 VbglHGCMParmUInt32Set(&Msg.creationmode, 0); 879 VbglHGCMParmUInt64Set(&Msg.offset, 0); 880 881 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 882 if (RT_SUCCESS(rc)) 883 { 884 Msg.context.GetUInt32(&pCtx->uContextID); 885 Msg.creationmode.GetUInt32(puCreationMode); 886 Msg.offset.GetUInt64(poffAt); 887 } 888 } while (rc == VERR_INTERRUPTED && g_fVbglR3GuestCtrlHavePeekGetCancel); 889 return rc; 890 } 891 892 893 /** 894 * Retrieves a HOST_FILE_CLOSE message. 895 */ 666 896 VBGLR3DECL(int) VbglR3GuestCtrlFileGetClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle) 667 897 { … … 671 901 AssertPtrReturn(puHandle, VERR_INVALID_POINTER); 672 902 673 HGCMMsgFileClose Msg; 674 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms); 675 VbglHGCMParmUInt32Set(&Msg.context, 0); 676 VbglHGCMParmUInt32Set(&Msg.handle, 0); 677 678 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 679 if (RT_SUCCESS(rc)) 680 { 681 Msg.context.GetUInt32(&pCtx->uContextID); 682 Msg.handle.GetUInt32(puHandle); 683 } 684 return rc; 685 } 686 687 688 VBGLR3DECL(int) VbglR3GuestCtrlFileGetRead(PVBGLR3GUESTCTRLCMDCTX pCtx, 689 uint32_t *puHandle, uint32_t *puToRead) 903 int rc; 904 do 905 { 906 HGCMMsgFileClose Msg; 907 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, vbglR3GuestCtrlGetMsgFunctionNo(pCtx->uClientID), pCtx->uNumParms); 908 VbglHGCMParmUInt32Set(&Msg.context, HOST_FILE_CLOSE); 909 VbglHGCMParmUInt32Set(&Msg.handle, 0); 910 911 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 912 if (RT_SUCCESS(rc)) 913 { 914 Msg.context.GetUInt32(&pCtx->uContextID); 915 Msg.handle.GetUInt32(puHandle); 916 } 917 } while (rc == VERR_INTERRUPTED && g_fVbglR3GuestCtrlHavePeekGetCancel); 918 return rc; 919 } 920 921 922 /** 923 * Retrieves a HOST_FILE_READ message. 924 */ 925 VBGLR3DECL(int) VbglR3GuestCtrlFileGetRead(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle, uint32_t *puToRead) 690 926 { 691 927 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); … … 695 931 AssertPtrReturn(puToRead, VERR_INVALID_POINTER); 696 932 697 HGCMMsgFileRead Msg; 698 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms); 699 VbglHGCMParmUInt32Set(&Msg.context, 0); 700 VbglHGCMParmUInt32Set(&Msg.handle, 0); 701 VbglHGCMParmUInt32Set(&Msg.size, 0); 702 703 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 704 if (RT_SUCCESS(rc)) 705 { 706 Msg.context.GetUInt32(&pCtx->uContextID); 707 Msg.handle.GetUInt32(puHandle); 708 Msg.size.GetUInt32(puToRead); 709 } 710 return rc; 711 } 712 713 933 int rc; 934 do 935 { 936 HGCMMsgFileRead Msg; 937 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, vbglR3GuestCtrlGetMsgFunctionNo(pCtx->uClientID), pCtx->uNumParms); 938 VbglHGCMParmUInt32Set(&Msg.context, HOST_FILE_READ); 939 VbglHGCMParmUInt32Set(&Msg.handle, 0); 940 VbglHGCMParmUInt32Set(&Msg.size, 0); 941 942 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 943 if (RT_SUCCESS(rc)) 944 { 945 Msg.context.GetUInt32(&pCtx->uContextID); 946 Msg.handle.GetUInt32(puHandle); 947 Msg.size.GetUInt32(puToRead); 948 } 949 } while (rc == VERR_INTERRUPTED && g_fVbglR3GuestCtrlHavePeekGetCancel); 950 return rc; 951 } 952 953 954 /** 955 * Retrieves a HOST_FILE_READ_AT message. 956 */ 714 957 VBGLR3DECL(int) VbglR3GuestCtrlFileGetReadAt(PVBGLR3GUESTCTRLCMDCTX pCtx, 715 958 uint32_t *puHandle, uint32_t *puToRead, uint64_t *poffAt) … … 721 964 AssertPtrReturn(puToRead, VERR_INVALID_POINTER); 722 965 723 HGCMMsgFileReadAt Msg; 724 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms); 725 VbglHGCMParmUInt32Set(&Msg.context, 0); 726 VbglHGCMParmUInt32Set(&Msg.handle, 0); 727 VbglHGCMParmUInt32Set(&Msg.offset, 0); 728 VbglHGCMParmUInt32Set(&Msg.size, 0); 729 730 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 731 if (RT_SUCCESS(rc)) 732 { 733 Msg.context.GetUInt32(&pCtx->uContextID); 734 Msg.handle.GetUInt32(puHandle); 735 Msg.offset.GetUInt64(poffAt); 736 Msg.size.GetUInt32(puToRead); 737 } 738 return rc; 739 } 740 741 966 int rc; 967 do 968 { 969 HGCMMsgFileReadAt Msg; 970 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, vbglR3GuestCtrlGetMsgFunctionNo(pCtx->uClientID), pCtx->uNumParms); 971 VbglHGCMParmUInt32Set(&Msg.context, HOST_FILE_READ_AT); 972 VbglHGCMParmUInt32Set(&Msg.handle, 0); 973 VbglHGCMParmUInt32Set(&Msg.offset, 0); 974 VbglHGCMParmUInt32Set(&Msg.size, 0); 975 976 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 977 if (RT_SUCCESS(rc)) 978 { 979 Msg.context.GetUInt32(&pCtx->uContextID); 980 Msg.handle.GetUInt32(puHandle); 981 Msg.offset.GetUInt64(poffAt); 982 Msg.size.GetUInt32(puToRead); 983 } 984 } while (rc == VERR_INTERRUPTED && g_fVbglR3GuestCtrlHavePeekGetCancel); 985 return rc; 986 } 987 988 989 /** 990 * Retrieves a HOST_FILE_WRITE message. 991 */ 742 992 VBGLR3DECL(int) VbglR3GuestCtrlFileGetWrite(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle, 743 993 void *pvData, uint32_t cbData, uint32_t *pcbSize) … … 751 1001 AssertPtrReturn(pcbSize, VERR_INVALID_POINTER); 752 1002 753 HGCMMsgFileWrite Msg; 754 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms); 755 VbglHGCMParmUInt32Set(&Msg.context, 0); 756 VbglHGCMParmUInt32Set(&Msg.handle, 0); 757 VbglHGCMParmPtrSet(&Msg.data, pvData, cbData); 758 VbglHGCMParmUInt32Set(&Msg.size, 0); 759 760 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 761 if (RT_SUCCESS(rc)) 762 { 763 Msg.context.GetUInt32(&pCtx->uContextID); 764 Msg.handle.GetUInt32(puHandle); 765 Msg.size.GetUInt32(pcbSize); 766 } 767 return rc; 768 } 769 770 1003 int rc; 1004 do 1005 { 1006 HGCMMsgFileWrite Msg; 1007 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, vbglR3GuestCtrlGetMsgFunctionNo(pCtx->uClientID), pCtx->uNumParms); 1008 VbglHGCMParmUInt32Set(&Msg.context, HOST_FILE_WRITE); 1009 VbglHGCMParmUInt32Set(&Msg.handle, 0); 1010 VbglHGCMParmPtrSet(&Msg.data, pvData, cbData); 1011 VbglHGCMParmUInt32Set(&Msg.size, 0); 1012 1013 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 1014 if (RT_SUCCESS(rc)) 1015 { 1016 Msg.context.GetUInt32(&pCtx->uContextID); 1017 Msg.handle.GetUInt32(puHandle); 1018 Msg.size.GetUInt32(pcbSize); 1019 } 1020 } while (rc == VERR_INTERRUPTED && g_fVbglR3GuestCtrlHavePeekGetCancel); 1021 return rc; 1022 } 1023 1024 1025 /** 1026 * Retrieves a HOST_FILE_WRITE_AT message. 1027 */ 771 1028 VBGLR3DECL(int) VbglR3GuestCtrlFileGetWriteAt(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle, 772 1029 void *pvData, uint32_t cbData, uint32_t *pcbSize, uint64_t *poffAt) … … 780 1037 AssertPtrReturn(pcbSize, VERR_INVALID_POINTER); 781 1038 782 HGCMMsgFileWriteAt Msg; 783 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms); 784 VbglHGCMParmUInt32Set(&Msg.context, 0); 785 VbglHGCMParmUInt32Set(&Msg.handle, 0); 786 VbglHGCMParmPtrSet(&Msg.data, pvData, cbData); 787 VbglHGCMParmUInt32Set(&Msg.size, 0); 788 VbglHGCMParmUInt32Set(&Msg.offset, 0); 789 790 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 791 if (RT_SUCCESS(rc)) 792 { 793 Msg.context.GetUInt32(&pCtx->uContextID); 794 Msg.handle.GetUInt32(puHandle); 795 Msg.size.GetUInt32(pcbSize); 796 Msg.offset.GetUInt64(poffAt); 797 } 798 return rc; 799 } 800 801 1039 int rc; 1040 do 1041 { 1042 HGCMMsgFileWriteAt Msg; 1043 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, vbglR3GuestCtrlGetMsgFunctionNo(pCtx->uClientID), pCtx->uNumParms); 1044 VbglHGCMParmUInt32Set(&Msg.context, HOST_FILE_WRITE_AT); 1045 VbglHGCMParmUInt32Set(&Msg.handle, 0); 1046 VbglHGCMParmPtrSet(&Msg.data, pvData, cbData); 1047 VbglHGCMParmUInt32Set(&Msg.size, 0); 1048 VbglHGCMParmUInt32Set(&Msg.offset, 0); 1049 1050 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 1051 if (RT_SUCCESS(rc)) 1052 { 1053 Msg.context.GetUInt32(&pCtx->uContextID); 1054 Msg.handle.GetUInt32(puHandle); 1055 Msg.size.GetUInt32(pcbSize); 1056 Msg.offset.GetUInt64(poffAt); 1057 } 1058 } while (rc == VERR_INTERRUPTED && g_fVbglR3GuestCtrlHavePeekGetCancel); 1059 return rc; 1060 } 1061 1062 1063 /** 1064 * Retrieves a HOST_FILE_SEEK message. 1065 */ 802 1066 VBGLR3DECL(int) VbglR3GuestCtrlFileGetSeek(PVBGLR3GUESTCTRLCMDCTX pCtx, 803 1067 uint32_t *puHandle, uint32_t *puSeekMethod, uint64_t *poffAt) … … 810 1074 AssertPtrReturn(poffAt, VERR_INVALID_POINTER); 811 1075 812 HGCMMsgFileSeek Msg; 813 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms); 814 VbglHGCMParmUInt32Set(&Msg.context, 0); 815 VbglHGCMParmUInt32Set(&Msg.handle, 0); 816 VbglHGCMParmUInt32Set(&Msg.method, 0); 817 VbglHGCMParmUInt64Set(&Msg.offset, 0); 818 819 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 820 if (RT_SUCCESS(rc)) 821 { 822 Msg.context.GetUInt32(&pCtx->uContextID); 823 Msg.handle.GetUInt32(puHandle); 824 Msg.method.GetUInt32(puSeekMethod); 825 Msg.offset.GetUInt64(poffAt); 826 } 827 return rc; 828 } 829 830 1076 int rc; 1077 do 1078 { 1079 HGCMMsgFileSeek Msg; 1080 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, vbglR3GuestCtrlGetMsgFunctionNo(pCtx->uClientID), pCtx->uNumParms); 1081 VbglHGCMParmUInt32Set(&Msg.context, HOST_FILE_SEEK); 1082 VbglHGCMParmUInt32Set(&Msg.handle, 0); 1083 VbglHGCMParmUInt32Set(&Msg.method, 0); 1084 VbglHGCMParmUInt64Set(&Msg.offset, 0); 1085 1086 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 1087 if (RT_SUCCESS(rc)) 1088 { 1089 Msg.context.GetUInt32(&pCtx->uContextID); 1090 Msg.handle.GetUInt32(puHandle); 1091 Msg.method.GetUInt32(puSeekMethod); 1092 Msg.offset.GetUInt64(poffAt); 1093 } 1094 } while (rc == VERR_INTERRUPTED && g_fVbglR3GuestCtrlHavePeekGetCancel); 1095 return rc; 1096 } 1097 1098 1099 /** 1100 * Retrieves a HOST_FILE_TELL message. 1101 */ 831 1102 VBGLR3DECL(int) VbglR3GuestCtrlFileGetTell(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle) 832 1103 { … … 836 1107 AssertPtrReturn(puHandle, VERR_INVALID_POINTER); 837 1108 838 HGCMMsgFileTell Msg; 839 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms); 840 VbglHGCMParmUInt32Set(&Msg.context, 0); 841 VbglHGCMParmUInt32Set(&Msg.handle, 0); 842 843 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 844 if (RT_SUCCESS(rc)) 845 { 846 Msg.context.GetUInt32(&pCtx->uContextID); 847 Msg.handle.GetUInt32(puHandle); 848 } 849 return rc; 850 } 851 852 1109 int rc; 1110 do 1111 { 1112 HGCMMsgFileTell Msg; 1113 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, vbglR3GuestCtrlGetMsgFunctionNo(pCtx->uClientID), pCtx->uNumParms); 1114 VbglHGCMParmUInt32Set(&Msg.context, HOST_FILE_TELL); 1115 VbglHGCMParmUInt32Set(&Msg.handle, 0); 1116 1117 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 1118 if (RT_SUCCESS(rc)) 1119 { 1120 Msg.context.GetUInt32(&pCtx->uContextID); 1121 Msg.handle.GetUInt32(puHandle); 1122 } 1123 } while (rc == VERR_INTERRUPTED && g_fVbglR3GuestCtrlHavePeekGetCancel); 1124 return rc; 1125 } 1126 1127 1128 /** 1129 * Retrieves a HOST_EXEC_TERMINATE message. 1130 */ 853 1131 VBGLR3DECL(int) VbglR3GuestCtrlProcGetTerminate(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puPID) 854 1132 { … … 858 1136 AssertPtrReturn(puPID, VERR_INVALID_POINTER); 859 1137 860 HGCMMsgProcTerminate Msg; 861 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms); 862 VbglHGCMParmUInt32Set(&Msg.context, 0); 863 VbglHGCMParmUInt32Set(&Msg.pid, 0); 864 865 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 866 if (RT_SUCCESS(rc)) 867 { 868 Msg.context.GetUInt32(&pCtx->uContextID); 869 Msg.pid.GetUInt32(puPID); 870 } 871 return rc; 872 } 873 874 1138 int rc; 1139 do 1140 { 1141 HGCMMsgProcTerminate Msg; 1142 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, vbglR3GuestCtrlGetMsgFunctionNo(pCtx->uClientID), pCtx->uNumParms); 1143 VbglHGCMParmUInt32Set(&Msg.context, HOST_EXEC_TERMINATE); 1144 VbglHGCMParmUInt32Set(&Msg.pid, 0); 1145 1146 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 1147 if (RT_SUCCESS(rc)) 1148 { 1149 Msg.context.GetUInt32(&pCtx->uContextID); 1150 Msg.pid.GetUInt32(puPID); 1151 } 1152 } while (rc == VERR_INTERRUPTED && g_fVbglR3GuestCtrlHavePeekGetCancel); 1153 return rc; 1154 } 1155 1156 1157 /** 1158 * Retrieves a HOST_EXEC_WAIT_FOR message. 1159 */ 875 1160 VBGLR3DECL(int) VbglR3GuestCtrlProcGetWaitFor(PVBGLR3GUESTCTRLCMDCTX pCtx, 876 1161 uint32_t *puPID, uint32_t *puWaitFlags, uint32_t *puTimeoutMS) … … 881 1166 AssertPtrReturn(puPID, VERR_INVALID_POINTER); 882 1167 883 HGCMMsgProcWaitFor Msg; 884 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms); 885 VbglHGCMParmUInt32Set(&Msg.context, 0); 886 VbglHGCMParmUInt32Set(&Msg.pid, 0); 887 VbglHGCMParmUInt32Set(&Msg.flags, 0); 888 VbglHGCMParmUInt32Set(&Msg.timeout, 0); 889 890 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 891 if (RT_SUCCESS(rc)) 892 { 893 Msg.context.GetUInt32(&pCtx->uContextID); 894 Msg.pid.GetUInt32(puPID); 895 Msg.flags.GetUInt32(puWaitFlags); 896 Msg.timeout.GetUInt32(puTimeoutMS); 897 } 1168 int rc; 1169 do 1170 { 1171 HGCMMsgProcWaitFor Msg; 1172 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, vbglR3GuestCtrlGetMsgFunctionNo(pCtx->uClientID), pCtx->uNumParms); 1173 VbglHGCMParmUInt32Set(&Msg.context, HOST_EXEC_WAIT_FOR); 1174 VbglHGCMParmUInt32Set(&Msg.pid, 0); 1175 VbglHGCMParmUInt32Set(&Msg.flags, 0); 1176 VbglHGCMParmUInt32Set(&Msg.timeout, 0); 1177 1178 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 1179 if (RT_SUCCESS(rc)) 1180 { 1181 Msg.context.GetUInt32(&pCtx->uContextID); 1182 Msg.pid.GetUInt32(puPID); 1183 Msg.flags.GetUInt32(puWaitFlags); 1184 Msg.timeout.GetUInt32(puTimeoutMS); 1185 } 1186 } while (rc == VERR_INTERRUPTED && g_fVbglR3GuestCtrlHavePeekGetCancel); 898 1187 return rc; 899 1188 } -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.cpp
r75722 r75758 251 251 uint32_t uMsg = 0; 252 252 uint32_t cParms = 0; 253 rc = VbglR3GuestCtrlMsg WaitFor(g_uControlSvcClientID, &uMsg, &cParms);253 rc = VbglR3GuestCtrlMsgPeekWait(g_uControlSvcClientID, &uMsg, &cParms); 254 254 if (rc == VERR_TOO_MUCH_DATA) 255 255 { -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp
r75736 r75758 1067 1067 VGSvcVerbose(3, "Unsupported message (uMsg=%RU32, cParms=%RU32) from host, skipping\n", uMsg, pHostCtx->uNumParms); 1068 1068 1069 /** @todo r=bird: Why on earth couldn't you make GUEST_MSG_SKIP do this hacky stuff?!? 1070 * You don't even know if you're replying to a message ment for you (see masking race further down). */ 1071 1069 1072 /* 1070 1073 * !!! HACK ALERT BEGIN !!! … … 1084 1087 HGCMMsgSkip Msg; 1085 1088 VBGL_HGCM_HDR_INIT(&Msg.hdr, pHostCtx->uClientID, GUEST_MSG_WAIT, pHostCtx->uNumParms); 1086 1087 /* Don't want to drag in VbglHGCMParmUInt32Set(). */ /** @todo r=bird: Why don't we? It's an inline function, so little dragging. */ 1088 Msg.context.type = VMMDevHGCMParmType_32bit; 1089 Msg.context.u.value64 = 0; /* init unused bits to 0 */ 1090 Msg.context.u.value32 = 0; 1089 Msg.context.SetUInt32(0); 1091 1090 1092 1091 /* Retrieve the context ID of the message which is not supported and put it in pHostCtx. */ … … 1095 1094 Msg.context.GetUInt32(&pHostCtx->uContextID); 1096 1095 1096 /* Now fake a reply to the message. */ 1097 rc2 = VbglR3GuestCtrlMsgReply(pHostCtx, VERR_NOT_SUPPORTED); 1098 AssertRC(rc2); 1099 1097 1100 /* !!! !!! 1098 1101 * !!! HACK ALERT END !!! 1099 1102 * !!! !!! */ 1100 1101 rc2 = VbglR3GuestCtrlMsgReply(pHostCtx, VERR_NOT_SUPPORTED);1102 AssertRC(rc2);1103 1103 1104 1104 /* Tell the host service to skip the message. */ … … 1333 1333 * 1334 1334 * Note! There was also a fSessionFilter being set on VERR_NOT_SUPPORTED here 1335 * but since it wasn't use , I assume it was just a leftover from some1335 * but since it wasn't used, I assume it was just a leftover from some 1336 1336 * earlier workaround for host behaviour/whatever... 1337 1337 */ 1338 /** @todo r=bird: Unless the host is filtering out everything by default, there 1339 * is a ugly race here between the client masking unwanted messages and the host 1340 * pushing more messages to the clients. We could in theory end up with someone 1341 * elses' messages as the first ones. Too late to require a VbglR3GuestCtrlMsgFilterSet 1342 * call by all clients, which is what would've made sense... I guess 1343 * VbglR3GuestCtrlSessionNotify can't be used as a green-light for sending messages 1344 * either. */ 1338 1345 uint32_t uFilterAdd = VBOX_GUESTCTRL_FILTER_BY_SESSION(pSession->StartupInfo.uSessionID); 1339 1346 rc = VbglR3GuestCtrlMsgFilterSet(idClient, … … 1372 1379 uint32_t uMsg = 0; 1373 1380 uint32_t cParms = 0; 1374 rc = VbglR3GuestCtrlMsg WaitFor(idClient, &uMsg, &cParms);1381 rc = VbglR3GuestCtrlMsgPeekWait(idClient, &uMsg, &cParms); 1375 1382 if ( RT_SUCCESS(rc) 1376 1383 || rc == VERR_TOO_MUCH_DATA)
Note:
See TracChangeset
for help on using the changeset viewer.