VirtualBox

Ignore:
Timestamp:
Mar 18, 2024 11:46:55 AM (11 months ago)
Author:
vboxsync
Message:

Installer/Windows/InstallHelper: Cleaned up #ifdef hell for VBOX_WITH_NETADP and VBOX_WITH_NETFLT to make it actually compile if not defined. Made some functions static which weren't before. Better would be having most of that code in a separate module; something for later. Needed as a prerequisite for a new testcase which doesn't need all of this VBOX_WITH_NETXXX code.

Location:
trunk/src/VBox/Installer/win/InstallHelper
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Installer/win/InstallHelper/Makefile.kmk

    r98429 r103889  
    3434VBoxInstallHelper_SDKS     = ReorderCompilerIncs $(VBOX_WINPSDK) $(VBOX_WINDDK)
    3535VBoxInstallHelper_DEFS     = _WIN32_WINNT=0x0501 _UNICODE UNICODE VBOX_SVN_REV=$(VBOX_SVN_REV)
    36 ifdef VBOX_WITH_NETFLT
     36if defined(VBOX_WITH_NETFLT) || defined(VBOX_WITH_NETADP)
    3737 VBoxInstallHelper_SDKS   += VBoxWinNewDevLib
    38  VBoxInstallHelper_DEFS   += VBOX_WITH_NETFLT=1
     38 VBoxInstallHelper_DEFS   += \
     39        $(if $(VBOX_WITH_NETFLT),VBOX_WITH_NETFLT,) \
     40        $(if $(VBOX_WITH_NETADP),VBOX_WITH_NETADP,)
     41 VBoxInstallHelper_LIBS   += \
     42        $(PATH_STAGE_LIB)/WinNetConfigSharedStatic.lib \
     43        $(PATH_STAGE_LIB)/VBoxDrvCfgSharedStatic.lib \
     44        $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/comsupp.lib \
     45        $(PATH_SDK_$(VBOX_WINPSDK)_LIB)/WbemUuid.Lib
    3946endif
    4047VBoxInstallHelper_DEPS     = $(VBOX_SVN_REV_KMK)
     
    4855        internal/VBoxSerial.cpp
    4956endif
    50 VBoxInstallHelper_LIBS    = \
     57VBoxInstallHelper_LIBS += \
    5158        $(PATH_SDK_$(VBOX_WINPSDK)_LIB)/Msi.lib
    52 ifdef VBOX_WITH_NETFLT
    53  VBoxInstallHelper_LIBS   += \
    54         $(PATH_STAGE_LIB)/WinNetConfigSharedStatic.lib \
    55         $(PATH_STAGE_LIB)/VBoxDrvCfgSharedStatic.lib \
    56         $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/comsupp.lib \
    57         $(PATH_SDK_$(VBOX_WINPSDK)_LIB)/WbemUuid.Lib
    58 endif
    5959
    6060if "$(KBUILD_TARGET)" == "win" && defined(VBOX_WITH_TESTCASES) && !defined(VBOX_OSE)
  • trunk/src/VBox/Installer/win/InstallHelper/VBoxInstallHelper.cpp

    r103328 r103889  
    3030*   Header Files                                                                                                                 *
    3131*********************************************************************************************************************************/
    32 #ifdef VBOX_WITH_NETFLT
     32#if defined(VBOX_WITH_NETFLT) || defined(VBOX_WITH_NETADP)
    3333# include "VBox/VBoxNetCfg-win.h"
    3434# include "VBox/VBoxDrvCfg-win.h"
    3535#endif
    3636
     37#define _WIN32_DCOM
     38#include <iprt/win/windows.h>
     39
    3740#include <msi.h>
    3841#include <msiquery.h>
    39 
    40 #define _WIN32_DCOM
    41 #include <iprt/win/windows.h>
    4242
    4343#include <shellapi.h>
     
    874874}
    875875
    876 #ifdef VBOX_WITH_NETFLT
     876#if defined(VBOX_WITH_NETFLT) || defined(VBOX_WITH_NETADP)
    877877
    878878/** @todo should use some real VBox app name */
     
    10561056    return uErr;
    10571057}
    1058 
     1058#endif /* defined(VBOX_WITH_NETFLT) || defined(VBOX_WITH_NETADP) */
     1059
     1060#ifdef VBOX_WITH_NETFLT
    10591061static UINT vboxNetFltQueryInfArray(MSIHANDLE hModule, OUT LPWSTR pwszPtInf, DWORD cwcPtInf,
    10601062                                    OUT LPWSTR pwszMpInf, DWORD cwcMpInf)
     
    10871089}
    10881090
    1089 #endif /*VBOX_WITH_NETFLT*/
    1090 
    1091 /*static*/ UINT _uninstallNetFlt(MSIHANDLE hModule)
    1092 {
    1093 #ifdef VBOX_WITH_NETFLT
     1091static UINT _uninstallNetFlt(MSIHANDLE hModule)
     1092{
    10941093    INetCfg *pNetCfg;
    10951094    UINT uErr;
     
    11281127        netCfgLoggerDisable();
    11291128    }
     1129
     1130    /* Never fail the uninstall even if we did not succeed. */
     1131    return ERROR_SUCCESS;
     1132}
    11301133#endif /* VBOX_WITH_NETFLT */
    11311134
    1132     /* Never fail the uninstall even if we did not succeed. */
    1133     return ERROR_SUCCESS;
    1134 }
    1135 
    11361135UINT __stdcall UninstallNetFlt(MSIHANDLE hModule)
    11371136{
    1138     (void)_uninstallNetLwf(hModule);
     1137#ifdef VBOX_WITH_NETFLT
     1138    _uninstallNetLwf(hModule);
    11391139    return _uninstallNetFlt(hModule);
    1140 }
    1141 
     1140#else
     1141    RT_NOREF(hModule);
     1142    return ERROR_SUCCESS;
     1143#endif
     1144}
     1145
     1146#ifdef VBOX_WITH_NETFLT
    11421147static UINT _installNetFlt(MSIHANDLE hModule)
    11431148{
    1144 #ifdef VBOX_WITH_NETFLT
    11451149    UINT uErr;
    11461150    INetCfg *pNetCfg;
     
    11891193        netCfgLoggerDisable();
    11901194    }
     1195
     1196    /* Never fail the install even if we did not succeed. */
     1197    return ERROR_SUCCESS;
     1198}
    11911199#endif /* VBOX_WITH_NETFLT */
    11921200
    1193     /* Never fail the install even if we did not succeed. */
    1194     return ERROR_SUCCESS;
    1195 }
    1196 
    11971201UINT __stdcall InstallNetFlt(MSIHANDLE hModule)
    11981202{
    1199     (void)_uninstallNetLwf(hModule);
     1203#ifdef VBOX_WITH_NETFLT
     1204    _uninstallNetLwf(hModule);
    12001205    return _installNetFlt(hModule);
    1201 }
    1202 
    1203 
    1204 /*static*/ UINT _uninstallNetLwf(MSIHANDLE hModule)
    1205 {
     1206#else
     1207    RT_NOREF(hModule);
     1208    return ERROR_SUCCESS;
     1209#endif
     1210}
     1211
    12061212#ifdef VBOX_WITH_NETFLT
     1213static UINT _uninstallNetLwf(MSIHANDLE hModule)
     1214{
    12071215    INetCfg *pNetCfg;
    12081216    UINT uErr;
     
    12411249        netCfgLoggerDisable();
    12421250    }
     1251
     1252    /* Never fail the uninstall even if we did not succeed. */
     1253    return ERROR_SUCCESS;
     1254}
    12431255#endif /* VBOX_WITH_NETFLT */
    12441256
    1245     /* Never fail the uninstall even if we did not succeed. */
    1246     return ERROR_SUCCESS;
    1247 }
    1248 
    12491257UINT __stdcall UninstallNetLwf(MSIHANDLE hModule)
    12501258{
    1251     (void)_uninstallNetFlt(hModule);
     1259#ifdef VBOX_WITH_NETFLT
     1260    _uninstallNetFlt(hModule);
    12521261    return _uninstallNetLwf(hModule);
    1253 }
    1254 
     1262#else
     1263    RT_NOREF(hModule);
     1264    return ERROR_SUCCESS;
     1265#endif
     1266}
     1267
     1268#ifdef VBOX_WITH_NETFLT
    12551269static UINT _installNetLwf(MSIHANDLE hModule)
    12561270{
    1257 #ifdef VBOX_WITH_NETFLT
    12581271    UINT uErr;
    12591272    INetCfg *pNetCfg;
     
    13181331        netCfgLoggerDisable();
    13191332    }
     1333
     1334    /* Never fail the install even if we did not succeed. */
     1335    return ERROR_SUCCESS;
     1336}
    13201337#endif /* VBOX_WITH_NETFLT */
    13211338
    1322     /* Never fail the install even if we did not succeed. */
    1323     return ERROR_SUCCESS;
    1324 }
    1325 
    13261339UINT __stdcall InstallNetLwf(MSIHANDLE hModule)
    13271340{
    1328     (void)_uninstallNetFlt(hModule);
     1341#ifdef VBOX_WITH_NETFLT
     1342    _uninstallNetFlt(hModule);
    13291343    return _installNetLwf(hModule);
    1330 }
    1331 
    1332 
    1333 #if 0
     1344#else
     1345    RT_NOREF(hModule);
     1346    return ERROR_SUCCESS;
     1347#endif
     1348}
     1349
     1350
     1351#if 0 /** @todo r=andy Remove this? */
    13341352static BOOL RenameHostOnlyConnectionsCallback(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pDev, PVOID pContext)
    13351353{
     
    13871405    return TRUE;
    13881406}
    1389 #endif
    1390 
     1407#endif /* 0 */
     1408
     1409#ifdef VBOX_WITH_NETADP
    13911410static UINT _createHostOnlyInterface(MSIHANDLE hModule, LPCWSTR pwszId, LPCWSTR pwszInfName)
    13921411{
    1393 #ifdef VBOX_WITH_NETFLT
    13941412    netCfgLoggerEnable(hModule);
    13951413
     
    14601478            logStringF(hModule, "CreateHostOnlyInterface: VBoxNetCfgWinUpdateHostOnlyNetworkInterface failed, hr = %#x", hr);
    14611479            logStringF(hModule, "CreateHostOnlyInterface: calling VBoxNetCfgWinCreateHostOnlyNetworkInterface");
    1462 #ifdef VBOXNETCFG_DELAYEDRENAME
     1480# ifdef VBOXNETCFG_DELAYEDRENAME
    14631481            BSTR devId;
    14641482            hr = VBoxNetCfgWinCreateHostOnlyNetworkInterface(pwszInfPath, fIsFile, NULL, &guid, &devId, NULL);
    1465 #else /* !VBOXNETCFG_DELAYEDRENAME */
     1483# else /* !VBOXNETCFG_DELAYEDRENAME */
    14661484            hr = VBoxNetCfgWinCreateHostOnlyNetworkInterface(pwszInfPath, fIsFile, NULL, &guid, NULL, NULL);
    1467 #endif /* !VBOXNETCFG_DELAYEDRENAME */
     1485# endif /* !VBOXNETCFG_DELAYEDRENAME */
    14681486            logStringF(hModule, "CreateHostOnlyInterface: VBoxNetCfgWinCreateHostOnlyNetworkInterface returns %#x", hr);
    14691487            if (SUCCEEDED(hr))
     
    14761494                if (FAILED(hr))
    14771495                    logStringF(hModule, "CreateHostOnlyInterface: VBoxNetCfgWinEnableStaticIpConfig failed, error = %#x", hr);
    1478 #ifdef VBOXNETCFG_DELAYEDRENAME
     1496# ifdef VBOXNETCFG_DELAYEDRENAME
    14791497                hr = VBoxNetCfgWinRenameHostOnlyConnection(&guid, devId, NULL);
    14801498                if (FAILED(hr))
    14811499                    logStringF(hModule, "CreateHostOnlyInterface: VBoxNetCfgWinRenameHostOnlyConnection failed, error = %#x", hr);
    14821500                SysFreeString(devId);
    1483 #endif /* VBOXNETCFG_DELAYEDRENAME */
     1501# endif /* VBOXNETCFG_DELAYEDRENAME */
    14841502            }
    14851503            else
     
    14981516    netCfgLoggerDisable();
    14991517
    1500 #endif /* VBOX_WITH_NETFLT */
    1501 
    15021518    logStringF(hModule, "CreateHostOnlyInterface: Returns success (ignoring all failures)");
    15031519    /* Never fail the install even if we did not succeed. */
    15041520    return ERROR_SUCCESS;
    15051521}
     1522#endif /* VBOX_WITH_NETADP */
    15061523
    15071524UINT __stdcall CreateHostOnlyInterface(MSIHANDLE hModule)
    15081525{
     1526#ifdef VBOX_WITH_NETADP
    15091527    return _createHostOnlyInterface(hModule, NETADP_ID, L"VBoxNetAdp.inf");
     1528#else
     1529    RT_NOREF(hModule);
     1530    return ERROR_SUCCESS;
     1531#endif
    15101532}
    15111533
    15121534UINT __stdcall Ndis6CreateHostOnlyInterface(MSIHANDLE hModule)
    15131535{
    1514 #if 0 /* Trick for allowing the debugger to be attached. */
     1536#ifdef VBOX_WITH_NETADP
     1537# if 0 /* Trick for allowing the debugger to be attached. */
    15151538    for (unsigned i = 0; i < 128 && !IsDebuggerPresent(); i++)
    15161539    {
     
    15201543    Sleep(1002);
    15211544    __debugbreak();
     1545# endif
     1546    return _createHostOnlyInterface(hModule, NETADP_ID, L"VBoxNetAdp6.inf");
     1547#else /* !VBOX_WITH_NETADP */
     1548    RT_NOREF(hModule);
     1549    return ERROR_SUCCESS;
    15221550#endif
    1523     return _createHostOnlyInterface(hModule, NETADP_ID, L"VBoxNetAdp6.inf");
    1524 }
    1525 
     1551}
     1552
     1553#ifdef VBOX_WITH_NETADP
    15261554static UINT _removeHostOnlyInterfaces(MSIHANDLE hModule, LPCWSTR pwszId)
    15271555{
    1528 #ifdef VBOX_WITH_NETFLT
    15291556    netCfgLoggerEnable(hModule);
    15301557
     
    15501577
    15511578    netCfgLoggerDisable();
    1552 #endif /* VBOX_WITH_NETFLT */
    15531579
    15541580    /* Never fail the uninstall even if we did not succeed. */
    15551581    return ERROR_SUCCESS;
    15561582}
     1583#endif /* VBOX_WITH_NETADP */
    15571584
    15581585UINT __stdcall RemoveHostOnlyInterfaces(MSIHANDLE hModule)
    15591586{
     1587#ifdef VBOX_WITH_NETADP
    15601588    return _removeHostOnlyInterfaces(hModule, NETADP_ID);
    1561 }
    1562 
     1589#else
     1590    RT_NOREF(hModule);
     1591    return ERROR_SUCCESS;
     1592#endif
     1593}
     1594
     1595#ifdef VBOX_WITH_NETADP
    15631596static UINT _stopHostOnlyInterfaces(MSIHANDLE hModule, LPCWSTR pwszId)
    15641597{
    1565 #ifdef VBOX_WITH_NETFLT
    15661598    netCfgLoggerEnable(hModule);
    15671599
     
    15811613
    15821614    netCfgLoggerDisable();
    1583 #endif /* VBOX_WITH_NETFLT */
    15841615
    15851616    /* Never fail the uninstall even if we did not succeed. */
    15861617    return ERROR_SUCCESS;
    15871618}
     1619#endif /* VBOX_WITH_NETADP */
    15881620
    15891621UINT __stdcall StopHostOnlyInterfaces(MSIHANDLE hModule)
    15901622{
     1623#ifdef VBOX_WITH_NETADP
    15911624    return _stopHostOnlyInterfaces(hModule, NETADP_ID);
    1592 }
    1593 
     1625#else
     1626    RT_NOREF(hModule);
     1627    return ERROR_SUCCESS;
     1628#endif
     1629}
     1630
     1631#ifdef VBOX_WITH_NETADP
    15941632static UINT _updateHostOnlyInterfaces(MSIHANDLE hModule, LPCWSTR pwszInfName, LPCWSTR pwszId)
    15951633{
    1596 #ifdef VBOX_WITH_NETFLT
    15971634    netCfgLoggerEnable(hModule);
    15981635
     
    16611698
    16621699    netCfgLoggerDisable();
    1663 #endif /* VBOX_WITH_NETFLT */
    16641700
    16651701    /* Never fail the update even if we did not succeed. */
    16661702    return ERROR_SUCCESS;
    16671703}
     1704#endif /* VBOX_WITH_NETADP */
    16681705
    16691706UINT __stdcall UpdateHostOnlyInterfaces(MSIHANDLE hModule)
    16701707{
     1708#ifdef VBOX_WITH_NETADP
    16711709    return _updateHostOnlyInterfaces(hModule, L"VBoxNetAdp.inf", NETADP_ID);
     1710#else
     1711    RT_NOREF(hModule);
     1712    return ERROR_SUCCESS;
     1713#endif
    16721714}
    16731715
    16741716UINT __stdcall Ndis6UpdateHostOnlyInterfaces(MSIHANDLE hModule)
    16751717{
     1718#ifdef VBOX_WITH_NETADP
    16761719    return _updateHostOnlyInterfaces(hModule, L"VBoxNetAdp6.inf", NETADP_ID);
    1677 }
    1678 
     1720#else
     1721    RT_NOREF(hModule);
     1722    return ERROR_SUCCESS;
     1723#endif
     1724}
     1725
     1726#ifdef VBOX_WITH_NETADP
    16791727static UINT _uninstallNetAdp(MSIHANDLE hModule, LPCWSTR pwszId)
    16801728{
    1681 #ifdef VBOX_WITH_NETFLT
    16821729    INetCfg *pNetCfg;
    16831730    UINT uErr;
     
    17161763        netCfgLoggerDisable();
    17171764    }
    1718 #endif /* VBOX_WITH_NETFLT */
    17191765
    17201766    /* Never fail the uninstall even if we did not succeed. */
    17211767    return ERROR_SUCCESS;
    17221768}
     1769#endif /* VBOX_WITH_NETADP */
    17231770
    17241771UINT __stdcall UninstallNetAdp(MSIHANDLE hModule)
    17251772{
     1773#ifdef VBOX_WITH_NETADP
    17261774    return _uninstallNetAdp(hModule, NETADP_ID);
     1775#else
     1776    RT_NOREF(hModule);
     1777    return ERROR_SUCCESS;
     1778#endif
    17271779}
    17281780
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