VirtualBox

Changeset 68526 in vbox


Ignore:
Timestamp:
Aug 24, 2017 7:11:40 PM (7 years ago)
Author:
vboxsync
Message:

VbglR3GuestCtrlMsgWaitFor: GUEST_MSG_WAIT is really weird.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGuestCtrl.cpp

    r68502 r68526  
    7373 * @returns VBox status code.
    7474 * @param   uClientId       The client ID returned by VbglR3GuestCtrlConnect().
    75  * @param   puMsg           Where to store the message id.
    76  * @param   puNumParms      Where to store the number  of parameters which will be received
    77  *                          in a second call to the host.
    78  */
    79 VBGLR3DECL(int) VbglR3GuestCtrlMsgWaitFor(uint32_t uClientId, uint32_t *puMsg, uint32_t *puNumParms)
    80 {
    81     AssertPtrReturn(puMsg, VERR_INVALID_POINTER);
    82     AssertPtrReturn(puNumParms, VERR_INVALID_POINTER);
     75 * @param   pidMsg          Where to store the message id.
     76 * @param   pcParameters    Where to store the number  of parameters which will
     77 *                          be received in a second call to the host.
     78 */
     79VBGLR3DECL(int) VbglR3GuestCtrlMsgWaitFor(uint32_t uClientId, uint32_t *pidMsg, uint32_t *pcParameters)
     80{
     81    AssertPtrReturn(pidMsg, VERR_INVALID_POINTER);
     82    AssertPtrReturn(pcParameters, VERR_INVALID_POINTER);
    8383
    8484    HGCMMsgCmdWaitFor Msg;
     
    8989    VbglHGCMParmUInt32Set(&Msg.num_parms, 0);
    9090
    91     int rc = VbglR3HGCMCallRaw(&Msg.hdr, sizeof(Msg));
    92     if (RT_SUCCESS(rc))
    93     {
    94         rc = VbglHGCMParmUInt32Get(&Msg.msg, puMsg);
    95         if (RT_SUCCESS(rc))
     91    /*
     92     * We should always get a VERR_TOO_MUCH_DATA response here, see
     93     * guestControl::HostCommand::Peek() and its caller ClientState::SendReply().
     94     * We accept success too here, in case someone decide to make the protocol
     95     * slightly more sane.
     96     *
     97     * Note! A really sane protocol design would have a separate call for getting
     98     *       info about a pending message (returning VINF_SUCCESS), and a separate
     99     *       one for retriving the actual message parameters.  Not this weird
     100     *       stuff, to put it rather bluntly.
     101     */
     102    int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
     103    if (   rc == VERR_TOO_MUCH_DATA
     104        || RT_SUCCESS(rc))
     105    {
     106        int rc2 = VbglHGCMParmUInt32Get(&Msg.msg, pidMsg);
     107        if (RT_SUCCESS(rc2))
    96108        {
    97             rc = VbglHGCMParmUInt32Get(&Msg.num_parms, puNumParms);
    98             if (RT_SUCCESS(rc))
    99                 rc = Msg.hdr.result;
     109            rc2 = VbglHGCMParmUInt32Get(&Msg.num_parms, pcParameters);
     110            if (RT_SUCCESS(rc2))
     111            {
    100112                /* Ok, so now we know what message type and how much parameters there are. */
     113                return rc;
     114            }
    101115        }
    102     }
     116        rc = rc2;
     117    }
     118    *pidMsg       = UINT32_MAX - 1;
     119    *pcParameters = UINT32_MAX - 2;
    103120    return rc;
    104121}
     
    189206    VBGL_HGCM_HDR_INIT(&Msg.hdr, uClientId, GUEST_MSG_SKIP, 1);
    190207    VbglHGCMParmUInt32Set(&Msg.flags, 0 /* Flags, unused */);
    191 
    192     int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
    193     if (RT_SUCCESS(rc))
    194         rc = Msg.hdr.result;
    195 
    196     return rc;
     208    return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
    197209}
    198210
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