Esempio n. 1
0
/** @callback_method_impl{FNVBOXEXTPACKREGISTER}  */
extern "C" DECLEXPORT(int) VBoxExtPackRegister(PCVBOXEXTPACKHLP pHlp, PCVBOXEXTPACKREG *ppReg, PRTERRINFO pErrInfo)
{
    /*
     * Check the VirtualBox version.
     */
    if (!VBOXEXTPACK_IS_VER_COMPAT(pHlp->u32Version, VBOXEXTPACKHLP_VERSION))
        return RTErrInfoSetF(pErrInfo, VERR_VERSION_MISMATCH,
                             "Helper version mismatch - expected %#x got %#x",
                             VBOXEXTPACKHLP_VERSION, pHlp->u32Version);
    if (   VBOX_FULL_VERSION_GET_MAJOR(pHlp->uVBoxFullVersion) != VBOX_VERSION_MAJOR
            || VBOX_FULL_VERSION_GET_MINOR(pHlp->uVBoxFullVersion) != VBOX_VERSION_MINOR)
        return RTErrInfoSetF(pErrInfo, VERR_VERSION_MISMATCH,
                             "VirtualBox version mismatch - expected %u.%u got %u.%u",
                             VBOX_VERSION_MAJOR, VBOX_VERSION_MINOR,
                             VBOX_FULL_VERSION_GET_MAJOR(pHlp->uVBoxFullVersion),
                             VBOX_FULL_VERSION_GET_MINOR(pHlp->uVBoxFullVersion));

    /*
     * We're good, save input and return the registration structure.
     */
    g_pHlp = pHlp;
    *ppReg = &g_vboxSkeletonExtPackReg;

    return VINF_SUCCESS;
}
Esempio n. 2
0
/**
 * Sets the Guest Additions version information details.
 *
 * Gets called by vmmdevUpdateGuestInfo2 and vmmdevUpdateGuestInfo (to clear the
 * state).
 *
 * @param   a_uFullVersion          VBoxGuestInfo2::additionsMajor,
 *                                  VBoxGuestInfo2::additionsMinor and
 *                                  VBoxGuestInfo2::additionsBuild combined into
 *                                  one value by VBOX_FULL_VERSION_MAKE.
 *
 *                                  When this is 0, it's vmmdevUpdateGuestInfo
 *                                  calling to reset the state.
 *
 * @param   a_pszName               Build type tag and/or publisher tag, empty
 *                                  string if neiter of those are present.
 * @param   a_uRevision             See VBoxGuestInfo2::additionsRevision.
 * @param   a_fFeatures             See VBoxGuestInfo2::additionsFeatures.
 */
void Guest::setAdditionsInfo2(uint32_t a_uFullVersion, const char *a_pszName, uint32_t a_uRevision, uint32_t a_fFeatures)
{
    AutoCaller autoCaller(this);
    AssertComRCReturnVoid(autoCaller.rc());

    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);

    if (a_uFullVersion)
    {
        mData.mAdditionsVersionNew  = BstrFmt(*a_pszName ? "%u.%u.%u_%s" : "%u.%u.%u",
                                              VBOX_FULL_VERSION_GET_MAJOR(a_uFullVersion),
                                              VBOX_FULL_VERSION_GET_MINOR(a_uFullVersion),
                                              VBOX_FULL_VERSION_GET_BUILD(a_uFullVersion),
                                              a_pszName);
        mData.mAdditionsVersionFull = a_uFullVersion;
        mData.mAdditionsRevision    = a_uRevision;
        mData.mAdditionsFeatures    = a_fFeatures;
    }
    else
    {
        Assert(!a_fFeatures && !a_uRevision && !*a_pszName);
        mData.mAdditionsVersionNew.setNull();
        mData.mAdditionsVersionFull = 0;
        mData.mAdditionsRevision    = 0;
        mData.mAdditionsFeatures    = 0;
    }
}
Esempio n. 3
0
/**
 * Tries to guess the DnD protocol version to use on the guest, based on the
 * installed Guest Additions version + revision.
 *
 * If unable to retrieve the protocol version, VERR_NOT_FOUND is returned along
 * with protocol version 1.
 *
 * @return  IPRT status code.
 * @param   puProto                 Where to store the protocol version.
 */
int GuestDnDBase::getProtocolVersion(uint32_t *puProto)
{
    AssertPtrReturn(puProto, VERR_INVALID_POINTER);

    int rc;

    uint32_t uProto        = 0;
    uint32_t uVerAdditions = 0;
    uint32_t uRevAdditions = 0;
    if (   m_pGuest
        && (uVerAdditions = m_pGuest->i_getAdditionsVersion())  > 0
        && (uRevAdditions = m_pGuest->i_getAdditionsRevision()) > 0)
    {
#ifdef DEBUG
# if 0
        /* Hardcode the to-used protocol version; nice for testing side effects. */
        uProto = 3;
        rc = VINF_SUCCESS;
# endif
#endif
        if (!uProto) /* Protocol not set yet? */
        {
            if (uVerAdditions >= VBOX_FULL_VERSION_MAKE(5, 0, 0))
            {
                if (uRevAdditions >= 103344) /* Since r103344: Protocol v3. */
                {
                    uProto = 3;
                }
                else
                    uProto = 2; /* VBox 5.0.0 - 5.0.8: Protocol v2. */
            }

            LogFlowFunc(("uVerAdditions=%RU32 (%RU32.%RU32.%RU32), r%RU32\n",
                         uVerAdditions, VBOX_FULL_VERSION_GET_MAJOR(uVerAdditions), VBOX_FULL_VERSION_GET_MINOR(uVerAdditions),
                                        VBOX_FULL_VERSION_GET_BUILD(uVerAdditions), uRevAdditions));
            rc = VINF_SUCCESS;
        }
    }
    else
    {
        uProto = 1; /* Fallback. */
        rc = VERR_NOT_FOUND;
    }

    LogRel2(("DnD: Guest is using protocol v%RU32, rc=%Rrc\n", uProto, rc));

    *puProto = uProto;
    return rc;
}
int GuestDnDBase::getProtocolVersion(uint32_t *puVersion)
{
    AssertPtrReturn(puVersion, VERR_INVALID_POINTER);

    int rc;

    uint32_t uVer, uVerAdditions = 0;
    if (   m_pGuest
        && (uVerAdditions = m_pGuest->i_getAdditionsVersion()) > 0)
    {
        uint32_t uVBoxMajor = VBOX_FULL_VERSION_GET_MAJOR(uVerAdditions);
        uint32_t uVBoxMinor = VBOX_FULL_VERSION_GET_MINOR(uVerAdditions);

#if 0 /*def DEBUG_andy*/
        /* Hardcode the to-used protocol version; nice for testing side effects. */
        uVer = 2;
#else
        uVer = (  uVBoxMajor  >= 5)
             ? 2  /* VBox 5.0 and up: Protocol version 2. */
             : 1; /* VBox <= 4.3:     Protocol version 1. */
        /* Build revision is ignored. */
#endif

        LogFlowThisFunc(("uVerAdditions=%RU32 (%RU32.%RU32)\n", uVerAdditions, uVBoxMajor, uVBoxMinor));
        rc = VINF_SUCCESS;
    }
    else
    {
        uVer = 1; /* Fallback. */
        rc = VERR_NOT_FOUND;
    }

    LogFlowThisFunc(("uVer=%RU32, uVerAdditions=%RU32, rc=%Rrc\n", uVer, uVerAdditions, rc));

    *puVersion = uVer;
    return rc;
}