VirtualBox

Ignore:
Timestamp:
Apr 19, 2012 2:25:38 PM (13 years ago)
Author:
vboxsync
Message:

NetCfg/win: disable/enable/update HostOnly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/win/cfg/VBoxNetCfg.cpp

    r38797 r40993  
    448448}
    449449
     450typedef struct VBOXNECTFGWINPROPCHANGE
     451{
     452    VBOXNECTFGWINPROPCHANGE_TYPE enmPcType;
     453    HRESULT hr;
     454} VBOXNECTFGWINPROPCHANGE ,*PVBOXNECTFGWINPROPCHANGE;
     455
     456static BOOL vboxNetCfgWinPropChangeAllNetDevicesOfIdCallback(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pDev, PVOID pContext)
     457{
     458    PVBOXNECTFGWINPROPCHANGE pPc = (PVBOXNECTFGWINPROPCHANGE)pContext;
     459    HRESULT hr = S_OK;
     460    SP_PROPCHANGE_PARAMS PcParams;
     461    memset (&PcParams, 0, sizeof (PcParams));
     462
     463    PcParams.ClassInstallHeader.cbSize = sizeof (SP_CLASSINSTALL_HEADER);
     464    PcParams.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE;
     465    PcParams.Scope = DICS_FLAG_GLOBAL;
     466    PcParams.HwProfile = 0;
     467    switch(pPc->enmPcType)
     468    {
     469        case VBOXNECTFGWINPROPCHANGE_TYPE_DISABLE:
     470            PcParams.StateChange = DICS_DISABLE;
     471            break;
     472        case VBOXNECTFGWINPROPCHANGE_TYPE_ENABLE:
     473            PcParams.StateChange = DICS_ENABLE;
     474            break;
     475        default:
     476            NonStandardLogFlow(("unexpected prop change type: %d\n", pPc->enmPcType));
     477            pPc->hr = E_INVALIDARG;
     478            return FALSE;
     479    }
     480
     481
     482    if (SetupDiSetClassInstallParams(hDevInfo, pDev, &PcParams.ClassInstallHeader, sizeof (PcParams)))
     483    {
     484        if (SetupDiSetSelectedDevice(hDevInfo, pDev))
     485        {
     486            if (SetupDiCallClassInstaller(DIF_PROPERTYCHANGE, hDevInfo, pDev))
     487            {
     488                SP_DEVINSTALL_PARAMS devParams;
     489                devParams.cbSize = sizeof(devParams);
     490                if (SetupDiGetDeviceInstallParams(hDevInfo,pDev,&devParams))
     491                {
     492                    if (devParams.Flags & (DI_NEEDRESTART|DI_NEEDREBOOT))
     493                    {
     494                        hr = S_FALSE;
     495                        NonStandardLogFlow(("PropChange: !!!REBOOT REQUIRED!!!\n"));
     496                    }
     497                }
     498            }
     499            else
     500            {
     501                DWORD dwErr = GetLastError();
     502                NonStandardLogFlow(("SetupDiCallClassInstaller failed with %ld\n", dwErr));
     503                hr = HRESULT_FROM_WIN32(dwErr);
     504            }
     505        }
     506        else
     507        {
     508            DWORD dwErr = GetLastError();
     509            NonStandardLogFlow(("SetupDiSetSelectedDevice failed with %ld\n", dwErr));
     510            hr = HRESULT_FROM_WIN32(dwErr);
     511        }
     512    }
     513    else
     514    {
     515        DWORD dwErr = GetLastError();
     516        NonStandardLogFlow(("SetupDiSetClassInstallParams failed with %ld\n", dwErr));
     517        hr = HRESULT_FROM_WIN32(dwErr);
     518    }
     519
     520    return TRUE;
     521}
     522
    450523typedef BOOL (*VBOXNETCFGWIN_NETENUM_CALLBACK) (HDEVINFO hDevInfo, PSP_DEVINFO_DATA pDev, PVOID pContext);
    451524VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinEnumNetDevices(LPCWSTR pPnPId, VBOXNETCFGWIN_NETENUM_CALLBACK callback, PVOID pContext)
     
    553626{
    554627    return VBoxNetCfgWinEnumNetDevices(lpszPnPId, vboxNetCfgWinRemoveAllNetDevicesOfIdCallback, NULL);
     628}
     629
     630VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinPropChangeAllNetDevicesOfId(IN LPCWSTR lpszPnPId, VBOXNECTFGWINPROPCHANGE_TYPE enmPcType)
     631{
     632    VBOXNECTFGWINPROPCHANGE Pc;
     633    Pc.enmPcType = enmPcType;
     634    Pc.hr = S_OK;
     635    return VBoxNetCfgWinEnumNetDevices(lpszPnPId, vboxNetCfgWinPropChangeAllNetDevicesOfIdCallback, &Pc);
    555636}
    556637
     
    23492430}
    23502431
     2432VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinUpdateHostOnlyNetworkInterface(LPCWSTR pcsxwInf, BOOL *pbRebootRequired)
     2433{
     2434    return VBoxDrvCfgDrvUpdate(DRIVERHWID, pcsxwInf, pbRebootRequired);
     2435}
     2436
    23512437VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinCreateHostOnlyNetworkInterface(IN LPCWSTR pInfPath, IN bool bIsInfPathFile,
    23522438                                                                        OUT GUID *pGuid, OUT BSTR *lppszName, OUT BSTR *pErrMsg)
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