VirtualBox

Changeset 75757 in vbox


Ignore:
Timestamp:
Nov 27, 2018 4:24:13 AM (6 years ago)
Author:
vboxsync
Message:

GuestControlSvc: Defined 4 new commands that will succeed GUEST_MSG_WAIT - completely untested. [corrections]

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/HostServices/GuestControlSvc.h

    r75755 r75757  
    304304    /** Gets the next message, returning immediately.
    305305     *
    306      * First argument is the message ID returned by the peek and which the caller
    307      * expects to retrieve (holds actual message ID when VERR_MISMATCH is returned).
    308      * Second argument is the parameter count (output only) and exist for
    309      * compatibility with GUEST_MSG_WAIT.  Any subsequent parameters are specific to
    310      * the message being retrieved.
     306     * All parameters are specific to the message being retrieved, however if the
     307     * first one is an integer value it shall be an input parameter holding the
     308     * ID of the message being retrieved.  While it would be nice to add a separate
     309     * parameter for this purpose, this is difficult without breaking GUEST_MSG_WAIT
     310     * compatibility.
    311311     *
    312312     * @retval  VINF_SUCCESS if message retrieved and removed from the pending queue.
  • trunk/src/VBox/HostServices/GuestControl/service.cpp

    r75756 r75757  
    766766                    HGCMSvcSetU32(&mPendingCon.mParms[1], pHostCmd->mParmCount);
    767767                    for (uint32_t i = pHostCmd->mParmCount; i >= 2; i--)
    768                         switch (pHostCmd->mpParms[i].type)
     768                        switch (pHostCmd->mpParms[i - 2].type)
    769769                        {
    770770                            case VBOX_HGCM_SVC_PARM_32BIT: mPendingCon.mParms[i].u.uint32 = ~(uint32_t)sizeof(uint32_t); break;
    771771                            case VBOX_HGCM_SVC_PARM_64BIT: mPendingCon.mParms[i].u.uint32 = ~(uint32_t)sizeof(uint64_t); break;
    772                             case VBOX_HGCM_SVC_PARM_PTR:   mPendingCon.mParms[i].u.uint32 = pHostCmd->mpParms[i].u.pointer.size; break;
     772                            case VBOX_HGCM_SVC_PARM_PTR:   mPendingCon.mParms[i].u.uint32 = pHostCmd->mpParms[i - 2].u.pointer.size; break;
    773773                        }
    774774
     
    12731273        paParms[1].u.uint32 = pFirstCmd->mParmCount;
    12741274        for (uint32_t i = pFirstCmd->mParmCount; i >= 2; i--)
    1275             switch (pFirstCmd->mpParms[i].type)
     1275            switch (pFirstCmd->mpParms[i - 2].type)
    12761276            {
    12771277                case VBOX_HGCM_SVC_PARM_32BIT: paParms[i].u.uint32 = ~(uint32_t)sizeof(uint32_t); break;
    12781278                case VBOX_HGCM_SVC_PARM_64BIT: paParms[i].u.uint32 = ~(uint32_t)sizeof(uint64_t); break;
    1279                 case VBOX_HGCM_SVC_PARM_PTR:   paParms[i].u.uint32 = pFirstCmd->mpParms[i].u.pointer.size; break;
     1279                case VBOX_HGCM_SVC_PARM_PTR:   paParms[i].u.uint32 = pFirstCmd->mpParms[i - 2].u.pointer.size; break;
    12801280            }
    12811281
     
    13301330     * Validate the request.
    13311331     *
    1332      * Note! The 2nd parameter is basically ignored as it's only purpose is
    1333      *       compatibility with GUEST_MSG_WAIT
    1334      */
    1335     ASSERT_GUEST_MSG_RETURN(cParms >= 2, ("cParms=%u!\n", cParms), VERR_INVALID_PARAMETER);
    1336     ASSERT_GUEST_MSG_RETURN(paParms[0].type == VBOX_HGCM_SVC_PARM_32BIT, ("type=%u\n", paParms[0].type), VERR_WRONG_TYPE);
    1337     uint32_t const idMsgExpected  = paParms[0].u.uint32;
    1338     ASSERT_GUEST_MSG_RETURN(paParms[1].type == VBOX_HGCM_SVC_PARM_32BIT, ("type=%u\n", paParms[0].type), VERR_WRONG_TYPE);
     1332     * The weird first parameter logic is due to GUEST_MSG_WAIT compatibility
     1333     * (don't want to rewrite all the message structures).
     1334     */
     1335    uint32_t const idMsgExpected = cParms > 0 && paParms[0].type == VBOX_HGCM_SVC_PARM_32BIT ? paParms[0].u.uint32
     1336                                 : cParms > 0 && paParms[0].type == VBOX_HGCM_SVC_PARM_64BIT ? paParms[0].u.uint64
     1337                                 : UINT32_MAX;
    13391338
    13401339    ClientStateMapIter itClientState = mClientStateMap.find(idClient);
     
    13511350        HostCommand *pFirstCmd = *itFirstCmd;
    13521351
    1353         /* The 'peek' parameters. */
    1354         paParms[0].u.uint32 = pFirstCmd->mMsgType;
    1355         paParms[1].u.uint32 = pFirstCmd->mParmCount;
    1356         ASSERT_GUEST_MSG_RETURN(pFirstCmd->mMsgType == idMsgExpected,
     1352        ASSERT_GUEST_MSG_RETURN(pFirstCmd->mMsgType == idMsgExpected || idMsgExpected == UINT32_MAX,
    13571353                                ("idMsg=%u cParms=%u, caller expected %u and %u\n",
    13581354                                 pFirstCmd->mMsgType, pFirstCmd->mParmCount, idMsgExpected, cParms),
     
    13641360
    13651361        /* Check the parameter types. */
    1366         for (uint32_t i = 2; i < cParms; i++)
     1362        for (uint32_t i = 0; i < cParms; i++)
    13671363            ASSERT_GUEST_MSG_RETURN(pFirstCmd->mpParms[i].type == paParms[i].type,
    13681364                                    ("param #%u: type %u, caller expected %u\n", i, pFirstCmd->mpParms[i].type, paParms[i].type),
     
    13761372         */
    13771373        int rc = VINF_SUCCESS;
    1378         for (uint32_t i = 2; i < cParms; i++)
     1374        for (uint32_t i = 0; i < cParms; i++)
    13791375            switch (pFirstCmd->mpParms[i].type)
    13801376            {
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette