VirtualBox

Changeset 52585 in vbox


Ignore:
Timestamp:
Sep 3, 2014 2:06:48 PM (10 years ago)
Author:
vboxsync
Message:

Storage/VD + Main/ExtPackManager+VirtualBox+SystemProperties: handle unloading of VD plugin from VBoxSVC when extpack is uninstalled, fixes extpack uninstall problems related to VDPluginCrypt.dll on Windows

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vd.h

    r51886 r52585  
    44
    55/*
    6  * Copyright (C) 2006-2013 Oracle Corporation
     6 * Copyright (C) 2006-2014 Oracle Corporation
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    502502
    503503/**
     504 * Unloads a single plugin given by filename.
     505 *
     506 * @returns VBox status code.
     507 * @param   pszFilename     The plugin filename to unload.
     508 */
     509VBOXDDU_DECL(int) VDPluginUnloadFromFilename(const char *pszFilename);
     510
     511/**
     512 * Unload all plugins from a given path.
     513 *
     514 * @returns VBox statuse code.
     515 * @param   pszPath         The path to unload plugins from.
     516 */
     517VBOXDDU_DECL(int) VDPluginUnloadFromPath(const char *pszPath);
     518
     519/**
    504520 * Lists all HDD backends and their capabilities in a caller-provided buffer.
    505521 *
  • trunk/src/VBox/Main/include/SystemPropertiesImpl.h

    r52200 r52585  
    77
    88/*
    9  * Copyright (C) 2006-2013 Oracle Corporation
     9 * Copyright (C) 2006-2014 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    5252    ComObjPtr<MediumFormat> i_mediumFormat(const Utf8Str &aFormat);
    5353    ComObjPtr<MediumFormat> i_mediumFormatFromExtension(const Utf8Str &aExt);
     54
     55    void i_extPackInstallNotify(const char *pszExtPackName);
     56    void i_extPackUninstallNotify(const char *pszExtPackName);
    5457
    5558private:
     
    126129                                               ULONG *aMaxInstances);
    127130
     131    HRESULT i_loadExtPackVDPluginCrypt();
     132    HRESULT i_unloadExtPackVDPluginCrypt();
     133
    128134    HRESULT i_getUserHomeDirectory(Utf8Str &strPath);
    129135    HRESULT i_setDefaultMachineFolder(const Utf8Str &strPath);
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r52095 r52585  
    55
    66/*
    7  * Copyright (C) 2006-2013 Oracle Corporation
     7 * Copyright (C) 2006-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    127127    void i_addProcessToReap(RTPROCESS pid);
    128128    void i_updateClientWatcher();
     129
     130    void i_extPackInstallNotify(const char *pszExtPackName);
     131    void i_extPackUninstallNotify(const char *pszExtPackName);
    129132
    130133    void i_onMachineStateChange(const Guid &aId, MachineState_T aState);
  • trunk/src/VBox/Main/src-all/ExtPackManagerImpl.cpp

    r52267 r52585  
    25302530        {
    25312531            if (pExtPack && a_fReplace)
     2532            {
     2533                m->pVirtualBox->i_extPackUninstallNotify(pStrName->c_str());
    25322534                hrc = pExtPack->i_callUninstallHookAndClose(m->pVirtualBox, false /*a_ForcedRemoval*/);
     2535            }
    25332536            else if (pExtPack)
    25342537                hrc = setError(E_FAIL,
     
    25622565                    pExtPack->i_callInstalledHook(m->pVirtualBox, &autoLock, &ErrInfo.Core);
    25632566                    if (RT_SUCCESS(ErrInfo.Core.rc))
     2567                    {
    25642568                        LogRel(("ExtPackManager: Successfully installed extension pack '%s'.\n", pStrName->c_str()));
     2569                        m->pVirtualBox->i_extPackInstallNotify(pStrName->c_str());
     2570                    }
    25652571                    else
    25662572                    {
     
    26652671                 * Call the uninstall hook and unload the main dll.
    26662672                 */
     2673                m->pVirtualBox->i_extPackUninstallNotify(a_pstrName->c_str());
    26672674                hrc = pExtPack->i_callUninstallHookAndClose(m->pVirtualBox, a_fForcedRemoval);
    26682675                if (SUCCEEDED(hrc))
  • trunk/src/VBox/Main/src-server/SystemPropertiesImpl.cpp

    r52200 r52585  
    55
    66/*
    7  * Copyright (C) 2006-2013 Oracle Corporation
     7 * Copyright (C) 2006-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4444/////////////////////////////////////////////////////////////////////////////
    4545
     46// globals
     47/////////////////////////////////////////////////////////////////////////////
     48static const Utf8Str g_strExtPackPuel("Oracle VM VirtualBox Extension Pack");
     49static const char *g_pszVDPluginCrypt = "VDPluginCrypt";
     50
    4651// constructor / destructor
    4752/////////////////////////////////////////////////////////////////////////////
     
    113118    HRESULT rc = S_OK;
    114119
    115 # ifdef VBOX_WITH_EXTPACK
    116120    /* Load all VD plugins from all extension packs first. */
    117121    /** @todo: Make generic for 4.4 (requires interface changes). */
    118     static const Utf8Str strExtPackPuel("Oracle VM VirtualBox Extension Pack");
    119     static const char *s_pszVDPlugin = "VDPluginCrypt";
    120     if (mParent->i_getExtPackManager()->i_isExtPackUsable(strExtPackPuel.c_str()))
    121     {
    122         Utf8Str strPlugin;
    123         rc = mParent->i_getExtPackManager()->i_getLibraryPathForExtPack(s_pszVDPlugin, &strExtPackPuel, &strPlugin);
    124         if (SUCCEEDED(rc))
    125         {
    126             int vrc = VDPluginLoadFromFilename(strPlugin.c_str());
    127             NOREF(vrc); /** @todo: Don't ignore errors. */
    128         }
    129         else
    130             rc = S_OK; /* ignore errors */
    131     }
    132 # endif
     122    rc = i_loadExtPackVDPluginCrypt();
    133123
    134124    /* Fetch info of all available hd backends. */
     
    11271117}
    11281118
     1119
     1120/**
     1121 * Extension pack install notification
     1122 */
     1123void SystemProperties::i_extPackInstallNotify(const char *pszExtPackName)
     1124{
     1125    if (g_strExtPackPuel.equals(pszExtPackName))
     1126    {
     1127        i_loadExtPackVDPluginCrypt();
     1128    }
     1129}
     1130
     1131/**
     1132 * Extension pack uninstall notification
     1133 */
     1134void SystemProperties::i_extPackUninstallNotify(const char *pszExtPackName)
     1135{
     1136    if (g_strExtPackPuel.equals(pszExtPackName))
     1137    {
     1138        i_unloadExtPackVDPluginCrypt();
     1139    }
     1140}
     1141
     1142HRESULT SystemProperties::i_loadExtPackVDPluginCrypt()
     1143{
     1144    HRESULT rc = S_OK;
     1145#ifdef VBOX_WITH_EXTPACK
     1146    if (mParent->i_getExtPackManager()->i_isExtPackUsable(g_strExtPackPuel.c_str()))
     1147    {
     1148        Utf8Str strPlugin;
     1149        rc = mParent->i_getExtPackManager()->i_getLibraryPathForExtPack(g_pszVDPluginCrypt, &g_strExtPackPuel, &strPlugin);
     1150        if (SUCCEEDED(rc))
     1151        {
     1152            int vrc = VDPluginLoadFromFilename(strPlugin.c_str());
     1153            NOREF(vrc); /** @todo: don't ignore errors. */
     1154        }
     1155        else
     1156            rc = S_OK; /* ignore errors */
     1157    }
     1158# endif
     1159    return rc;
     1160}
     1161
     1162HRESULT SystemProperties::i_unloadExtPackVDPluginCrypt()
     1163{
     1164    HRESULT rc = S_OK;
     1165#ifdef VBOX_WITH_EXTPACK
     1166    Utf8Str strPlugin;
     1167    rc = mParent->i_getExtPackManager()->i_getLibraryPathForExtPack(g_pszVDPluginCrypt, &g_strExtPackPuel, &strPlugin);
     1168    if (SUCCEEDED(rc))
     1169    {
     1170        int vrc = VDPluginUnloadFromFilename(strPlugin.c_str());
     1171        NOREF(vrc); /** @todo: don't ignore errors. */
     1172    }
     1173    else
     1174        rc = S_OK; /* ignore errors */
     1175# endif
     1176    return rc;
     1177}
     1178
    11291179// private methods
    11301180/////////////////////////////////////////////////////////////////////////////
  • trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp

    r52546 r52585  
    26352635};
    26362636
     2637
     2638/**
     2639 * Extpack install notification
     2640 */
     2641void VirtualBox::i_extPackInstallNotify(const char *pszExtPackName)
     2642{
     2643    m->pSystemProperties->i_extPackInstallNotify(pszExtPackName);
     2644}
     2645
     2646/**
     2647 * Extpack uninstall notification
     2648 */
     2649void VirtualBox::i_extPackUninstallNotify(const char *pszExtPackName)
     2650{
     2651    m->pSystemProperties->i_extPackUninstallNotify(pszExtPackName);
     2652}
     2653
     2654
    26372655/**
    26382656 *  @note Doesn't lock any object.
  • trunk/src/VBox/Storage/VD.cpp

    r52359 r52585  
    55
    66/*
    7  * Copyright (C) 2006-2013 Oracle Corporation
     7 * Copyright (C) 2006-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    622622/** Array of pointers to the image backends. */
    623623static PCVBOXHDDBACKEND *g_apBackends = NULL;
     624/** Array of handles to the corresponding plugin. */
     625static RTLDRMOD *g_ahBackendPlugins = NULL;
    624626/** Builtin image backends. */
    625627static PCVBOXHDDBACKEND aStaticBackends[] =
     
    641643/** Array of pointers to the cache backends. */
    642644static PCVDCACHEBACKEND *g_apCacheBackends = NULL;
     645/** Array of handles to the corresponding plugin. */
     646static RTLDRMOD *g_ahCacheBackendPlugins = NULL;
    643647/** Builtin cache backends. */
    644648static PCVDCACHEBACKEND aStaticCacheBackends[] =
     
    651655/** Array of pointers to the filters backends. */
    652656static PCVDFILTERBACKEND *g_apFilterBackends = NULL;
     657/** Array of handles to the corresponding plugin. */
     658static RTLDRMOD *g_ahFilterBackendPlugins = NULL;
    653659
    654660/** Forward declaration of the async discard helper. */
     
    662668 * internal: add several backends.
    663669 */
    664 static int vdAddBackends(PCVBOXHDDBACKEND *ppBackends, unsigned cBackends)
     670static int vdAddBackends(RTLDRMOD hPlugin, PCVBOXHDDBACKEND *ppBackends, unsigned cBackends)
    665671{
    666672    PCVBOXHDDBACKEND *pTmp = (PCVBOXHDDBACKEND*)RTMemRealloc(g_apBackends,
     
    668674    if (RT_UNLIKELY(!pTmp))
    669675        return VERR_NO_MEMORY;
     676    RTLDRMOD *pTmpPlugins = (RTLDRMOD*)RTMemRealloc(g_ahBackendPlugins,
     677           (g_cBackends + cBackends) * sizeof(RTLDRMOD));
     678    if (RT_UNLIKELY(!pTmpPlugins))
     679        return VERR_NO_MEMORY;
    670680    g_apBackends = pTmp;
     681    g_ahBackendPlugins = pTmpPlugins;
    671682    memcpy(&g_apBackends[g_cBackends], ppBackends, cBackends * sizeof(PCVBOXHDDBACKEND));
     683    for (unsigned i = g_cBackends; i < g_cBackends + cBackends; i++)
     684        g_ahBackendPlugins[i] = hPlugin;
    672685    g_cBackends += cBackends;
    673686    return VINF_SUCCESS;
     
    677690 * internal: add single backend.
    678691 */
    679 DECLINLINE(int) vdAddBackend(PCVBOXHDDBACKEND pBackend)
    680 {
    681     return vdAddBackends(&pBackend, 1);
     692DECLINLINE(int) vdAddBackend(RTLDRMOD hPlugin, PCVBOXHDDBACKEND pBackend)
     693{
     694    return vdAddBackends(hPlugin, &pBackend, 1);
    682695}
    683696
     
    685698 * internal: add several cache backends.
    686699 */
    687 static int vdAddCacheBackends(PCVDCACHEBACKEND *ppBackends, unsigned cBackends)
     700static int vdAddCacheBackends(RTLDRMOD hPlugin, PCVDCACHEBACKEND *ppBackends, unsigned cBackends)
    688701{
    689702    PCVDCACHEBACKEND *pTmp = (PCVDCACHEBACKEND*)RTMemRealloc(g_apCacheBackends,
     
    691704    if (RT_UNLIKELY(!pTmp))
    692705        return VERR_NO_MEMORY;
     706    RTLDRMOD *pTmpPlugins = (RTLDRMOD*)RTMemRealloc(g_ahCacheBackendPlugins,
     707           (g_cCacheBackends + cBackends) * sizeof(RTLDRMOD));
     708    if (RT_UNLIKELY(!pTmpPlugins))
     709        return VERR_NO_MEMORY;
    693710    g_apCacheBackends = pTmp;
     711    g_ahCacheBackendPlugins = pTmpPlugins;
    694712    memcpy(&g_apCacheBackends[g_cCacheBackends], ppBackends, cBackends * sizeof(PCVDCACHEBACKEND));
     713    for (unsigned i = g_cCacheBackends; i < g_cCacheBackends + cBackends; i++)
     714        g_ahCacheBackendPlugins[i] = hPlugin;
    695715    g_cCacheBackends += cBackends;
    696716    return VINF_SUCCESS;
     
    700720 * internal: add single cache backend.
    701721 */
    702 DECLINLINE(int) vdAddCacheBackend(PCVDCACHEBACKEND pBackend)
    703 {
    704     return vdAddCacheBackends(&pBackend, 1);
    705 }
    706 
    707 /**
    708  * Add several filter bakends.
     722DECLINLINE(int) vdAddCacheBackend(RTLDRMOD hPlugin, PCVDCACHEBACKEND pBackend)
     723{
     724    return vdAddCacheBackends(hPlugin, &pBackend, 1);
     725}
     726
     727/**
     728 * Add several filter backends.
    709729 *
    710730 * @returns VBox status code.
     731 * @param   hPlugin       Plugin handle to add.
    711732 * @param   ppBackends    Array of filter backends to add.
    712733 * @param   cBackends     Number of backends to add.
    713734 */
    714 static int vdAddFilterBackends(PCVDFILTERBACKEND *ppBackends, unsigned cBackends)
     735static int vdAddFilterBackends(RTLDRMOD hPlugin, PCVDFILTERBACKEND *ppBackends, unsigned cBackends)
    715736{
    716737    PCVDFILTERBACKEND *pTmp = (PCVDFILTERBACKEND *)RTMemRealloc(g_apFilterBackends,
     
    718739    if (RT_UNLIKELY(!pTmp))
    719740        return VERR_NO_MEMORY;
     741    RTLDRMOD *pTmpPlugins = (RTLDRMOD*)RTMemRealloc(g_ahFilterBackendPlugins,
     742           (g_cFilterBackends + cBackends) * sizeof(RTLDRMOD));
     743    if (RT_UNLIKELY(!pTmpPlugins))
     744        return VERR_NO_MEMORY;
    720745    g_apFilterBackends = pTmp;
     746    g_ahFilterBackendPlugins = pTmpPlugins;
    721747    memcpy(&g_apFilterBackends[g_cFilterBackends], ppBackends, cBackends * sizeof(PCVDFILTERBACKEND));
     748    for (unsigned i = g_cFilterBackends; i < g_cFilterBackends + cBackends; i++)
     749        g_ahFilterBackendPlugins[i] = hPlugin;
    722750    g_cFilterBackends += cBackends;
    723751    return VINF_SUCCESS;
     
    728756 *
    729757 * @returns VBox status code.
     758 * @param   hPlugin     Plugin handle to add.
    730759 * @param   pBackend    The backend to add.
    731760 */
    732 DECLINLINE(int) vdAddFilterBackend(PCVDFILTERBACKEND pBackend)
    733 {
    734     return vdAddFilterBackends(&pBackend, 1);
     761DECLINLINE(int) vdAddFilterBackend(RTLDRMOD hPlugin, PCVDFILTERBACKEND pBackend)
     762{
     763    return vdAddFilterBackends(hPlugin, &pBackend, 1);
    735764}
    736765
     
    34923521
    34933522    if (pBackend->cbSize == sizeof(VBOXHDDBACKEND))
    3494         vdAddBackend(pBackend);
     3523        vdAddBackend((RTLDRMOD)pvUser, pBackend);
    34953524    else
    34963525    {
     
    35103539
    35113540    if (pBackend->cbSize == sizeof(VDCACHEBACKEND))
    3512         vdAddCacheBackend(pBackend);
     3541        vdAddCacheBackend((RTLDRMOD)pvUser, pBackend);
    35133542    else
    35143543    {
     
    35283557
    35293558    if (pBackend->cbSize == sizeof(VDFILTERBACKEND))
    3530         vdAddFilterBackend(pBackend);
     3559        vdAddFilterBackend((RTLDRMOD)pvUser, pBackend);
    35313560    else
    35323561    {
     
    35623591 * @returns VBox status code.
    35633592 * @param   hPlugin     Plugin handle to add.
    3564  * @param   pszFilename The associated filename, sued for finding duplicates.
     3593 * @param   pszFilename The associated filename, used for finding duplicates.
    35653594 */
    35663595static int vdAddPlugin(RTLDRMOD hPlugin, const char *pszFilename)
     
    35863615    return rc;
    35873616}
     3617
     3618static int vdRemovePlugin(const char *pszFilename)
     3619{
     3620    /* Find plugin to be removed from the list. */
     3621    PVDPLUGIN pIt = NULL;
     3622    RTListForEach(&g_ListPluginsLoaded, pIt, VDPLUGIN, NodePlugin)
     3623    {
     3624        if (!RTStrCmp(pIt->pszFilename, pszFilename))
     3625            break;
     3626    }
     3627    if (!pIt)
     3628        return VINF_SUCCESS;
     3629
     3630    /** @todo r=klaus: need to add a plugin entry point for unregistering the
     3631     * backends. Only if this doesn't exist (or fails to work) we should fall
     3632     * back to the following uncoordinated backend cleanup. */
     3633    for (unsigned i = 0; i < g_cBackends; i++)
     3634    {
     3635        while (i < g_cBackends && g_ahBackendPlugins[i] == pIt->hPlugin)
     3636        {
     3637            memcpy(&g_apBackends[i], &g_apBackends[i + 1], (g_cBackends - i - 1) * sizeof(PCVBOXHDDBACKEND));
     3638            memcpy(&g_ahBackendPlugins[i], &g_ahBackendPlugins[i + 1], (g_cBackends - i - 1) * sizeof(RTLDRMOD));
     3639            /** @todo for now skip reallocating, doesn't save much */
     3640            g_cBackends--;
     3641        }
     3642    }
     3643    for (unsigned i = 0; i < g_cCacheBackends; i++)
     3644    {
     3645        while (i < g_cCacheBackends && g_ahCacheBackendPlugins[i] == pIt->hPlugin)
     3646        {
     3647            memcpy(&g_apCacheBackends[i], &g_apCacheBackends[i + 1], (g_cCacheBackends - i - 1) * sizeof(PCVBOXHDDBACKEND));
     3648            memcpy(&g_ahCacheBackendPlugins[i], &g_ahCacheBackendPlugins[i + 1], (g_cCacheBackends - i - 1) * sizeof(RTLDRMOD));
     3649            /** @todo for now skip reallocating, doesn't save much */
     3650            g_cCacheBackends--;
     3651        }
     3652    }
     3653    for (unsigned i = 0; i < g_cFilterBackends; i++)
     3654    {
     3655        while (i < g_cFilterBackends && g_ahFilterBackendPlugins[i] == pIt->hPlugin)
     3656        {
     3657            memcpy(&g_apFilterBackends[i], &g_apFilterBackends[i + 1], (g_cFilterBackends - i - 1) * sizeof(PCVBOXHDDBACKEND));
     3658            memcpy(&g_ahFilterBackendPlugins[i], &g_ahFilterBackendPlugins[i + 1], (g_cFilterBackends - i - 1) * sizeof(RTLDRMOD));
     3659            /** @todo for now skip reallocating, doesn't save much */
     3660            g_cFilterBackends--;
     3661        }
     3662    }
     3663
     3664    /* Remove the plugin node now, all traces of it are gone. */
     3665    RTListNodeRemove(&pIt->NodePlugin);
     3666    RTLdrClose(pIt->hPlugin);
     3667    RTStrFree(pIt->pszFilename);
     3668    RTMemFree(pIt);
     3669
     3670    return VINF_SUCCESS;
     3671}
    35883672#endif
    35893673
     
    36243708        {
    36253709            /* Get the function table. */
    3626             rc = pfnVDPluginLoad(NULL, &BackendRegister);
     3710            rc = pfnVDPluginLoad(hPlugin, &BackendRegister);
    36273711        }
    36283712        else
     
    37443828#else
    37453829    return VINF_SUCCESS;
     3830#endif
     3831}
     3832
     3833/**
     3834 * Worker for VDPluginUnloadFromFilename() and vdPluginUnloadFromPath().
     3835 *
     3836 * @returns VBox status code.
     3837 * @param   pszFilename    The plugin filename to unload.
     3838 */
     3839static int vdPluginUnloadFromFilename(const char *pszFilename)
     3840{
     3841#ifndef VBOX_HDD_NO_DYNAMIC_BACKENDS
     3842    return vdRemovePlugin(pszFilename);
     3843#else
     3844    return VERR_NOT_IMPLEMENTED;
     3845#endif
     3846}
     3847
     3848/**
     3849 * Worker for VDPluginUnloadFromPath().
     3850 *
     3851 * @returns VBox status code.
     3852 * @param   pszPath        The path to unload plugins from.
     3853 */
     3854static int vdPluginUnloadFromPath(const char *pszPath)
     3855{
     3856#ifndef VBOX_HDD_NO_DYNAMIC_BACKENDS
     3857    /* To get all entries with VBoxHDD as prefix. */
     3858    char *pszPluginFilter = RTPathJoinA(pszPath, VD_PLUGIN_PREFIX "*");
     3859    if (!pszPluginFilter)
     3860        return VERR_NO_STR_MEMORY;
     3861
     3862    PRTDIRENTRYEX pPluginDirEntry = NULL;
     3863    PRTDIR pPluginDir = NULL;
     3864    size_t cbPluginDirEntry = sizeof(RTDIRENTRYEX);
     3865    int rc = RTDirOpenFiltered(&pPluginDir, pszPluginFilter, RTDIRFILTER_WINNT, 0);
     3866    if (RT_FAILURE(rc))
     3867    {
     3868        /* On Windows the above immediately signals that there are no
     3869         * files matching, while on other platforms enumerating the
     3870         * files below fails. Either way: no plugins. */
     3871        goto out;
     3872    }
     3873
     3874    pPluginDirEntry = (PRTDIRENTRYEX)RTMemAllocZ(sizeof(RTDIRENTRYEX));
     3875    if (!pPluginDirEntry)
     3876    {
     3877        rc = VERR_NO_MEMORY;
     3878        goto out;
     3879    }
     3880
     3881    while ((rc = RTDirReadEx(pPluginDir, pPluginDirEntry, &cbPluginDirEntry, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK)) != VERR_NO_MORE_FILES)
     3882    {
     3883        char *pszPluginPath = NULL;
     3884
     3885        if (rc == VERR_BUFFER_OVERFLOW)
     3886        {
     3887            /* allocate new buffer. */
     3888            RTMemFree(pPluginDirEntry);
     3889            pPluginDirEntry = (PRTDIRENTRYEX)RTMemAllocZ(cbPluginDirEntry);
     3890            if (!pPluginDirEntry)
     3891            {
     3892                rc = VERR_NO_MEMORY;
     3893                break;
     3894            }
     3895            /* Retry. */
     3896            rc = RTDirReadEx(pPluginDir, pPluginDirEntry, &cbPluginDirEntry, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK);
     3897            if (RT_FAILURE(rc))
     3898                break;
     3899        }
     3900        else if (RT_FAILURE(rc))
     3901            break;
     3902
     3903        /* We got the new entry. */
     3904        if (!RTFS_IS_FILE(pPluginDirEntry->Info.Attr.fMode))
     3905            continue;
     3906
     3907        /* Prepend the path to the libraries. */
     3908        pszPluginPath = RTPathJoinA(pszPath, pPluginDirEntry->szName);
     3909        if (!pszPluginPath)
     3910        {
     3911            rc = VERR_NO_STR_MEMORY;
     3912            break;
     3913        }
     3914
     3915        rc = vdPluginUnloadFromFilename(pszPluginPath);
     3916        RTStrFree(pszPluginPath);
     3917    }
     3918out:
     3919    if (rc == VERR_NO_MORE_FILES)
     3920        rc = VINF_SUCCESS;
     3921    RTStrFree(pszPluginFilter);
     3922    if (pPluginDirEntry)
     3923        RTMemFree(pPluginDirEntry);
     3924    if (pPluginDir)
     3925        RTDirClose(pPluginDir);
     3926    return rc;
     3927#else
     3928    return VERR_NOT_IMPLEMENTED;
    37463929#endif
    37473930}
     
    54895672VBOXDDU_DECL(int) VDInit(void)
    54905673{
    5491     int rc = vdAddBackends(aStaticBackends, RT_ELEMENTS(aStaticBackends));
     5674    int rc = vdAddBackends(NIL_RTLDRMOD, aStaticBackends, RT_ELEMENTS(aStaticBackends));
    54925675    if (RT_SUCCESS(rc))
    54935676    {
    5494         rc = vdAddCacheBackends(aStaticCacheBackends, RT_ELEMENTS(aStaticCacheBackends));
     5677        rc = vdAddCacheBackends(NIL_RTLDRMOD, aStaticCacheBackends, RT_ELEMENTS(aStaticCacheBackends));
    54955678        if (RT_SUCCESS(rc))
    54965679        {
     
    55775760
    55785761    return vdPluginLoadFromPath(pszPath);
     5762}
     5763
     5764/**
     5765 * Unloads a single plugin given by filename.
     5766 *
     5767 * @returns VBox status code.
     5768 * @param   pszFilename     The plugin filename to unload.
     5769 */
     5770VBOXDDU_DECL(int) VDPluginUnloadFromFilename(const char *pszFilename)
     5771{
     5772    if (!g_apBackends)
     5773    {
     5774        int rc = VDInit();
     5775        if (RT_FAILURE(rc))
     5776            return rc;
     5777    }
     5778
     5779    return vdPluginUnloadFromFilename(pszFilename);
     5780}
     5781
     5782/**
     5783 * Unload all plugins from a given path.
     5784 *
     5785 * @returns VBox statuse code.
     5786 * @param   pszPath         The path to unload plugins from.
     5787 */
     5788VBOXDDU_DECL(int) VDPluginUnloadFromPath(const char *pszPath)
     5789{
     5790    if (!g_apBackends)
     5791    {
     5792        int rc = VDInit();
     5793        if (RT_FAILURE(rc))
     5794            return rc;
     5795    }
     5796
     5797    return vdPluginUnloadFromPath(pszPath);
    55795798}
    55805799
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