From 97b80191048b23f2e870c9d6a27e368ebaaf594d Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 2 Jan 2018 23:14:58 -0800 Subject: Initial code commit --- src/Cpp.Build.props | 101 ++ src/Directory.Build.props | 22 + src/FindLocalWix.props | 8 + src/ca/CustomMsiErrors.h | 130 +++ src/ca/cost.h | 5 + src/ca/dllmain.cpp | 26 + src/ca/firewall.cpp | 1067 ++++++++++++++++++++ src/ca/fwca.def | 9 + src/ca/fwca.vcxproj | 72 ++ src/ca/packages.config | 6 + src/ca/precomp.h | 17 + .../FirewallExtensionFixture.cs | 33 + .../TestData/UsingFirewall/Package.en-us.wxl | 11 + .../TestData/UsingFirewall/Package.wxs | 22 + .../TestData/UsingFirewall/PackageComponents.wxs | 14 + .../TestData/UsingFirewall/example.txt | 1 + .../WixToolsetTest.Firewall.csproj | 40 + src/wixext/FirewallCompiler.cs | 356 +++++++ src/wixext/FirewallConstants.cs | 21 + src/wixext/FirewallDecompiler.cs | 169 ++++ src/wixext/FirewallErrors.cs | 42 + src/wixext/FirewallExtensionData.cs | 24 + src/wixext/FirewallExtensionFactory.cs | 18 + .../FirewallWindowsInstallerBackendExtension.cs | 26 + src/wixext/Tuples/FirewallTupleDefinitions.cs | 31 + src/wixext/Tuples/WixFirewallExceptionTuple.cs | 93 ++ src/wixext/WixToolset.Firewall.wixext.csproj | 36 + src/wixext/WixToolset.Firewall.wixext.targets | 11 + src/wixext/firewall.xsd | 211 ++++ src/wixext/tables.xml | 28 + src/wixlib/FirewallExtension.wxs | 12 + src/wixlib/FirewallExtension_Platform.wxi | 41 + src/wixlib/FirewallExtension_x86.wxs | 8 + src/wixlib/caSuffix.wxi | 28 + src/wixlib/caerr.wxi | 96 ++ src/wixlib/en-us.wxl | 14 + src/wixlib/es-es.wxl | 13 + src/wixlib/firewall.wixproj | 44 + src/wixlib/ja-jp.wxl | 14 + src/wixlib/packages.config | 5 + src/wixlib/pl-pl.wxl | 14 + 41 files changed, 2939 insertions(+) create mode 100644 src/Cpp.Build.props create mode 100644 src/Directory.Build.props create mode 100644 src/FindLocalWix.props create mode 100644 src/ca/CustomMsiErrors.h create mode 100644 src/ca/cost.h create mode 100644 src/ca/dllmain.cpp create mode 100644 src/ca/firewall.cpp create mode 100644 src/ca/fwca.def create mode 100644 src/ca/fwca.vcxproj create mode 100644 src/ca/packages.config create mode 100644 src/ca/precomp.h create mode 100644 src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs create mode 100644 src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.en-us.wxl create mode 100644 src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.wxs create mode 100644 src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs create mode 100644 src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/example.txt create mode 100644 src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj create mode 100644 src/wixext/FirewallCompiler.cs create mode 100644 src/wixext/FirewallConstants.cs create mode 100644 src/wixext/FirewallDecompiler.cs create mode 100644 src/wixext/FirewallErrors.cs create mode 100644 src/wixext/FirewallExtensionData.cs create mode 100644 src/wixext/FirewallExtensionFactory.cs create mode 100644 src/wixext/FirewallWindowsInstallerBackendExtension.cs create mode 100644 src/wixext/Tuples/FirewallTupleDefinitions.cs create mode 100644 src/wixext/Tuples/WixFirewallExceptionTuple.cs create mode 100644 src/wixext/WixToolset.Firewall.wixext.csproj create mode 100644 src/wixext/WixToolset.Firewall.wixext.targets create mode 100644 src/wixext/firewall.xsd create mode 100644 src/wixext/tables.xml create mode 100644 src/wixlib/FirewallExtension.wxs create mode 100644 src/wixlib/FirewallExtension_Platform.wxi create mode 100644 src/wixlib/FirewallExtension_x86.wxs create mode 100644 src/wixlib/caSuffix.wxi create mode 100644 src/wixlib/caerr.wxi create mode 100644 src/wixlib/en-us.wxl create mode 100644 src/wixlib/es-es.wxl create mode 100644 src/wixlib/firewall.wixproj create mode 100644 src/wixlib/ja-jp.wxl create mode 100644 src/wixlib/packages.config create mode 100644 src/wixlib/pl-pl.wxl (limited to 'src') diff --git a/src/Cpp.Build.props b/src/Cpp.Build.props new file mode 100644 index 00000000..453aa442 --- /dev/null +++ b/src/Cpp.Build.props @@ -0,0 +1,101 @@ + + + + + + Win32 + $(OutputPath) + $(BaseIntermediateOutputPath)$(Platform)\ + $(OutputPath)$(Platform)\ + + + + + $(DisableSpecificCompilerWarnings) + Level4 + $(ProjectDir)inc;$(MSBuildProjectDirectory);$(IntDir);$(SqlCESdkIncludePath);$(ProjectAdditionalIncludeDirectories);%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;_WIN32_MSI=500;_WIN32_WINNT=0x0501;$(ArmPreprocessorDefinitions);$(UnicodePreprocessorDefinitions);_CRT_STDIO_LEGACY_WIDE_SPECIFIERS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + Use + precomp.h + StdCall + true + false + -YlprecompDefine + /Zc:threadSafeInit- %(AdditionalOptions) + true + + + $(ArmPreprocessorDefinitions);%(PreprocessorDefinitions) + $(ProjectAdditionalResourceIncludeDirectories);%(AdditionalIncludeDirectories) + + + $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ProjectAdditionalLibraryDirectories);%(AdditionalLibraryDirectories) + + + $(ProjectSubSystem) + $(ProjectModuleDefinitionFile) + $(ResourceOnlyDll) + true + $(ProjectAdditionalLinkLibraries);advapi32.lib;comdlg32.lib;user32.lib;oleaut32.lib;gdi32.lib;shell32.lib;ole32.lib;version.lib;%(AdditionalDependencies) + $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ArmLibraryDirectories);$(ProjectAdditionalLinkLibraryDirectories);%(AdditionalLibraryDirectories) + /IGNORE:4099 %(AdditionalOptions) + + + + + + NoExtensions + + + + + CDecl + + + + + OldStyle + true + true + + + + + Disabled + EnableFastChecks + _DEBUG;DEBUG;%(PreprocessorDefinitions) + MultiThreadedDebug + + + + + + MultiThreadedDebugDll + + + + + MinSpace + NDEBUG;%(PreprocessorDefinitions) + true + true + MultiThreaded + + + true + true + + + + + + MultiThreadedDll + + + + + $(LinkKeyFile) + $(LinkDelaySign) + + + diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 00000000..63ad5d6e --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,22 @@ + + + + + + Debug + AnyCPU + $(MSBuildThisFileDirectory)..\build\obj\$(MSBuildProjectName)\ + $(MSBuildThisFileDirectory)..\build\$(Configuration)\ + + WiX Toolset Team + WiX Toolset + Copyright (c) .NET Foundation and contributors. All rights reserved. + + + + $(MSBuildThisFileDirectory)..\..\ + + + + + diff --git a/src/FindLocalWix.props b/src/FindLocalWix.props new file mode 100644 index 00000000..1301b0e5 --- /dev/null +++ b/src/FindLocalWix.props @@ -0,0 +1,8 @@ + + + + + + $(MSBuildThisFileDirectory)..\..\Core\build\Debug\net461\wix.targets + + diff --git a/src/ca/CustomMsiErrors.h b/src/ca/CustomMsiErrors.h new file mode 100644 index 00000000..f149fb31 --- /dev/null +++ b/src/ca/CustomMsiErrors.h @@ -0,0 +1,130 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +#define GLOBAL_ERROR_BASE 25501 + +#define msierrSecureObjectsFailedCreateSD 25520 +#define msierrSecureObjectsFailedSet 25521 +#define msierrSecureObjectsUnknownType 25522 + +#define msierrXmlFileFailedRead 25530 +#define msierrXmlFileFailedOpen 25531 +#define msierrXmlFileFailedSelect 25532 +#define msierrXmlFileFailedSave 25533 + +#define msierrXmlConfigFailedRead 25540 +#define msierrXmlConfigFailedOpen 25541 +#define msierrXmlConfigFailedSelect 25542 +#define msierrXmlConfigFailedSave 25543 + +#define msierrFirewallCannotConnect 25580 + +//--------------------------------------------------------------------------- +// Server CustomAction Errors +// SERVER range: 26001-26100 +#define SERVER_ERROR_BASE 26000 + +#define msierrIISCannotConnect 26001 +#define msierrIISFailedReadWebSite 26002 +#define msierrIISFailedReadWebDirs 26003 +#define msierrIISFailedReadVDirs 26004 +#define msierrIISFailedReadFilters 26005 +#define msierrIISFailedReadAppPool 26006 +#define msierrIISFailedReadMimeMap 26007 +#define msierrIISFailedReadProp 26008 +#define msierrIISFailedReadWebSvcExt 26009 +#define msierrIISFailedReadWebError 26010 +#define msierrIISFailedReadHttpHeader 26011 + +#define msierrIISFailedSchedTransaction 26031 +#define msierrIISFailedSchedInstallWebs 26032 +#define msierrIISFailedSchedInstallWebDirs 26033 +#define msierrIISFailedSchedInstallVDirs 26034 +#define msierrIISFailedSchedInstallFilters 26035 +#define msierrIISFailedSchedInstallAppPool 26036 +#define msierrIISFailedSchedInstallProp 26037 +#define msierrIISFailedSchedInstallWebSvcExt 26038 + +#define msierrIISFailedSchedUninstallWebs 26051 +#define msierrIISFailedSchedUninstallWebDirs 26052 +#define msierrIISFailedSchedUninstallVDirs 26053 +#define msierrIISFailedSchedUninstallFilters 26054 +#define msierrIISFailedSchedUninstallAppPool 26055 +#define msierrIISFailedSchedUninstallProp 26056 +#define msierrIISFailedSchedUninstallWebSvcExt 26057 + +#define msierrIISFailedStartTransaction 26101 +#define msierrIISFailedOpenKey 26102 +#define msierrIISFailedCreateKey 26103 +#define msierrIISFailedWriteData 26104 +#define msierrIISFailedCreateApp 26105 +#define msierrIISFailedDeleteKey 26106 +#define msierrIISFailedDeleteApp 26107 +#define msierrIISFailedDeleteValue 26108 +#define msierrIISFailedCommitInUse 26109 + +#define msierrSQLFailedCreateDatabase 26201 +#define msierrSQLFailedDropDatabase 26202 +#define msierrSQLFailedConnectDatabase 26203 +#define msierrSQLFailedExecString 26204 +#define msierrSQLDatabaseAlreadyExists 26205 + +#define msierrPERFMONFailedRegisterDLL 26251 +#define msierrPERFMONFailedUnregisterDLL 26252 +#define msierrInstallPerfCounterData 26253 +#define msierrUninstallPerfCounterData 26254 + +#define msierrSMBFailedCreate 26301 +#define msierrSMBFailedDrop 26302 + +#define msierrCERTFailedOpen 26351 +#define msierrCERTFailedAdd 26352 + +#define msierrUSRFailedUserCreate 26401 +#define msierrUSRFailedUserCreatePswd 26402 +#define msierrUSRFailedUserGroupAdd 26403 +#define msierrUSRFailedUserCreateExists 26404 +#define msierrUSRFailedGrantLogonAsService 26405 + +#define msierrDependencyMissingDependencies 26451 +#define msierrDependencyHasDependents 26452 + +//-------------------------------------------------------------------------- +// Managed code CustomAction Errors +// MANAGED range: 27000-27100 +#define MANAGED_ERROR_BASE 27000 + +#define msierrDotNetRuntimeRequired 27000 +//--------------------------------------------------------------------------- +// Public CustomAction Errors +// PUBLIC range: 28001-28100 +#define PUBLIC_ERROR_BASE 28000 + +#define msierrComPlusCannotConnect 28001 +#define msierrComPlusPartitionReadFailed 28002 +#define msierrComPlusPartitionRoleReadFailed 28003 +#define msierrComPlusUserInPartitionRoleReadFailed 28004 +#define msierrComPlusPartitionUserReadFailed 28005 +#define msierrComPlusApplicationReadFailed 28006 +#define msierrComPlusApplicationRoleReadFailed 28007 +#define msierrComPlusUserInApplicationRoleReadFailed 28008 +#define msierrComPlusAssembliesReadFailed 28009 +#define msierrComPlusSubscriptionReadFailed 28010 +#define msierrComPlusPartitionDependency 28011 +#define msierrComPlusPartitionNotFound 28012 +#define msierrComPlusPartitionIdConflict 28013 +#define msierrComPlusPartitionNameConflict 28014 +#define msierrComPlusApplicationDependency 28015 +#define msierrComPlusApplicationNotFound 28016 +#define msierrComPlusApplicationIdConflict 28017 +#define msierrComPlusApplicationNameConflict 28018 +#define msierrComPlusApplicationRoleDependency 28019 +#define msierrComPlusApplicationRoleNotFound 28020 +#define msierrComPlusApplicationRoleConflict 28021 +#define msierrComPlusAssemblyDependency 28022 +#define msierrComPlusSubscriptionIdConflict 28023 +#define msierrComPlusSubscriptionNameConflict 28024 +#define msierrComPlusFailedLookupNames 28025 + +#define msierrMsmqCannotConnect 28101 diff --git a/src/ca/cost.h b/src/ca/cost.h new file mode 100644 index 00000000..da68c667 --- /dev/null +++ b/src/ca/cost.h @@ -0,0 +1,5 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +const UINT COST_FIREWALL_EXCEPTION = 2000; diff --git a/src/ca/dllmain.cpp b/src/ca/dllmain.cpp new file mode 100644 index 00000000..df53f872 --- /dev/null +++ b/src/ca/dllmain.cpp @@ -0,0 +1,26 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" + +/******************************************************************** +DllMain - standard entry point for all WiX CustomActions + +********************************************************************/ +extern "C" BOOL WINAPI DllMain( + IN HINSTANCE hInst, + IN ULONG ulReason, + IN LPVOID) +{ + switch(ulReason) + { + case DLL_PROCESS_ATTACH: + WcaGlobalInitialize(hInst); + break; + + case DLL_PROCESS_DETACH: + WcaGlobalFinalize(); + break; + } + + return TRUE; +} diff --git a/src/ca/firewall.cpp b/src/ca/firewall.cpp new file mode 100644 index 00000000..62a5b454 --- /dev/null +++ b/src/ca/firewall.cpp @@ -0,0 +1,1067 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" + +LPCWSTR vcsFirewallExceptionQuery = + L"SELECT `Name`, `RemoteAddresses`, `Port`, `Protocol`, `Program`, `Attributes`, `Profile`, `Component_`, `Description` FROM `WixFirewallException`"; +enum eFirewallExceptionQuery { feqName = 1, feqRemoteAddresses, feqPort, feqProtocol, feqProgram, feqAttributes, feqProfile, feqComponent, feqDescription }; +enum eFirewallExceptionTarget { fetPort = 1, fetApplication, fetUnknown }; +enum eFirewallExceptionAttributes { feaIgnoreFailures = 1 }; + +/****************************************************************** + SchedFirewallExceptions - immediate custom action worker to + register and remove firewall exceptions. + +********************************************************************/ +static UINT SchedFirewallExceptions( + __in MSIHANDLE hInstall, + WCA_TODO todoSched + ) +{ + HRESULT hr = S_OK; + UINT er = ERROR_SUCCESS; + int cFirewallExceptions = 0; + + PMSIHANDLE hView = NULL; + PMSIHANDLE hRec = NULL; + + LPWSTR pwzCustomActionData = NULL; + LPWSTR pwzName = NULL; + LPWSTR pwzRemoteAddresses = NULL; + LPWSTR pwzPort = NULL; + int iProtocol = 0; + int iAttributes = 0; + int iProfile = 0; + LPWSTR pwzProgram = NULL; + LPWSTR pwzComponent = NULL; + LPWSTR pwzFormattedFile = NULL; + LPWSTR pwzDescription = NULL; + + // initialize + hr = WcaInitialize(hInstall, "SchedFirewallExceptions"); + ExitOnFailure(hr, "failed to initialize"); + + // anything to do? + if (S_OK != WcaTableExists(L"WixFirewallException")) + { + WcaLog(LOGMSG_STANDARD, "WixFirewallException table doesn't exist, so there are no firewall exceptions to configure."); + ExitFunction(); + } + + // query and loop through all the firewall exceptions + hr = WcaOpenExecuteView(vcsFirewallExceptionQuery, &hView); + ExitOnFailure(hr, "failed to open view on WixFirewallException table"); + + while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) + { + hr = WcaGetRecordFormattedString(hRec, feqName, &pwzName); + ExitOnFailure(hr, "failed to get firewall exception name"); + + hr = WcaGetRecordFormattedString(hRec, feqRemoteAddresses, &pwzRemoteAddresses); + ExitOnFailure(hr, "failed to get firewall exception remote addresses"); + + hr = WcaGetRecordFormattedString(hRec, feqPort, &pwzPort); + ExitOnFailure(hr, "failed to get firewall exception port"); + + hr = WcaGetRecordInteger(hRec, feqProtocol, &iProtocol); + ExitOnFailure(hr, "failed to get firewall exception protocol"); + + hr = WcaGetRecordFormattedString(hRec, feqProgram, &pwzProgram); + ExitOnFailure(hr, "failed to get firewall exception program"); + + hr = WcaGetRecordInteger(hRec, feqAttributes, &iAttributes); + ExitOnFailure(hr, "failed to get firewall exception attributes"); + + hr = WcaGetRecordInteger(hRec, feqProfile, &iProfile); + ExitOnFailure(hr, "failed to get firewall exception profile"); + + hr = WcaGetRecordString(hRec, feqComponent, &pwzComponent); + ExitOnFailure(hr, "failed to get firewall exception component"); + + hr = WcaGetRecordString(hRec, feqDescription, &pwzDescription); + ExitOnFailure(hr, "failed to get firewall description"); + + // figure out what we're doing for this exception, treating reinstall the same as install + WCA_TODO todoComponent = WcaGetComponentToDo(pwzComponent); + if ((WCA_TODO_REINSTALL == todoComponent ? WCA_TODO_INSTALL : todoComponent) != todoSched) + { + WcaLog(LOGMSG_STANDARD, "Component '%ls' action state (%d) doesn't match request (%d)", pwzComponent, todoComponent, todoSched); + continue; + } + + // action :: name :: profile :: remoteaddresses :: attributes :: target :: {port::protocol | path} + ++cFirewallExceptions; + hr = WcaWriteIntegerToCaData(todoComponent, &pwzCustomActionData); + ExitOnFailure(hr, "failed to write exception action to custom action data"); + + hr = WcaWriteStringToCaData(pwzName, &pwzCustomActionData); + ExitOnFailure(hr, "failed to write exception name to custom action data"); + + hr = WcaWriteIntegerToCaData(iProfile, &pwzCustomActionData); + ExitOnFailure(hr, "failed to write exception profile to custom action data"); + + hr = WcaWriteStringToCaData(pwzRemoteAddresses, &pwzCustomActionData); + ExitOnFailure(hr, "failed to write exception remote addresses to custom action data"); + + hr = WcaWriteIntegerToCaData(iAttributes, &pwzCustomActionData); + ExitOnFailure(hr, "failed to write exception attributes to custom action data"); + + if (*pwzProgram) + { + // If program is defined, we have an application exception. + hr = WcaWriteIntegerToCaData(fetApplication, &pwzCustomActionData); + ExitOnFailure(hr, "failed to write exception target (application) to custom action data"); + + hr = WcaWriteStringToCaData(pwzProgram, &pwzCustomActionData); + ExitOnFailure(hr, "failed to write application path to custom action data"); + } + else + { + // we have a port-only exception + hr = WcaWriteIntegerToCaData(fetPort, &pwzCustomActionData); + ExitOnFailure(hr, "failed to write exception target (port) to custom action data"); + } + + hr = WcaWriteStringToCaData(pwzPort, &pwzCustomActionData); + ExitOnFailure(hr, "failed to write application path to custom action data"); + + hr = WcaWriteIntegerToCaData(iProtocol, &pwzCustomActionData); + ExitOnFailure(hr, "failed to write exception protocol to custom action data"); + + hr = WcaWriteStringToCaData(pwzDescription, &pwzCustomActionData); + ExitOnFailure(hr, "failed to write firewall rule description to custom action data"); + } + + // reaching the end of the list is actually a good thing, not an error + if (E_NOMOREITEMS == hr) + { + hr = S_OK; + } + ExitOnFailure(hr, "failure occured while processing WixFirewallException table"); + + // schedule ExecFirewallExceptions if there's anything to do + if (pwzCustomActionData && *pwzCustomActionData) + { + WcaLog(LOGMSG_STANDARD, "Scheduling firewall exception (%ls)", pwzCustomActionData); + + if (WCA_TODO_INSTALL == todoSched) + { + hr = WcaDoDeferredAction(L"WixRollbackFirewallExceptionsInstall", pwzCustomActionData, cFirewallExceptions * COST_FIREWALL_EXCEPTION); + ExitOnFailure(hr, "failed to schedule firewall install exceptions rollback"); + hr = WcaDoDeferredAction(L"WixExecFirewallExceptionsInstall", pwzCustomActionData, cFirewallExceptions * COST_FIREWALL_EXCEPTION); + ExitOnFailure(hr, "failed to schedule firewall install exceptions execution"); + } + else + { + hr = WcaDoDeferredAction(L"WixRollbackFirewallExceptionsUninstall", pwzCustomActionData, cFirewallExceptions * COST_FIREWALL_EXCEPTION); + ExitOnFailure(hr, "failed to schedule firewall uninstall exceptions rollback"); + hr = WcaDoDeferredAction(L"WixExecFirewallExceptionsUninstall", pwzCustomActionData, cFirewallExceptions * COST_FIREWALL_EXCEPTION); + ExitOnFailure(hr, "failed to schedule firewall uninstall exceptions execution"); + } + } + else + { + WcaLog(LOGMSG_STANDARD, "No firewall exceptions scheduled"); + } + +LExit: + ReleaseStr(pwzCustomActionData); + ReleaseStr(pwzName); + ReleaseStr(pwzRemoteAddresses); + ReleaseStr(pwzPort); + ReleaseStr(pwzProgram); + ReleaseStr(pwzComponent); + ReleaseStr(pwzDescription); + ReleaseStr(pwzFormattedFile); + + return WcaFinalize(er = FAILED(hr) ? ERROR_INSTALL_FAILURE : er); +} + +/****************************************************************** + SchedFirewallExceptionsInstall - immediate custom action entry + point to register firewall exceptions. + +********************************************************************/ +extern "C" UINT __stdcall SchedFirewallExceptionsInstall( + __in MSIHANDLE hInstall + ) +{ + return SchedFirewallExceptions(hInstall, WCA_TODO_INSTALL); +} + +/****************************************************************** + SchedFirewallExceptionsUninstall - immediate custom action entry + point to remove firewall exceptions. + +********************************************************************/ +extern "C" UINT __stdcall SchedFirewallExceptionsUninstall( + __in MSIHANDLE hInstall + ) +{ + return SchedFirewallExceptions(hInstall, WCA_TODO_UNINSTALL); +} + +/****************************************************************** + GetFirewallRules - Get the collection of firewall rules. + +********************************************************************/ +static HRESULT GetFirewallRules( + __in BOOL fIgnoreFailures, + __out INetFwRules** ppNetFwRules + ) +{ + HRESULT hr = S_OK; + INetFwPolicy2* pNetFwPolicy2 = NULL; + INetFwRules* pNetFwRules = NULL; + *ppNetFwRules = NULL; + + do + { + ReleaseNullObject(pNetFwPolicy2); + ReleaseNullObject(pNetFwRules); + + if (SUCCEEDED(hr = ::CoCreateInstance(__uuidof(NetFwPolicy2), NULL, CLSCTX_ALL, __uuidof(INetFwPolicy2), (void**)&pNetFwPolicy2)) && + SUCCEEDED(hr = pNetFwPolicy2->get_Rules(&pNetFwRules))) + { + break; + } + else if (fIgnoreFailures) + { + ExitFunction1(hr = S_FALSE); + } + else + { + WcaLog(LOGMSG_STANDARD, "Failed to connect to Windows Firewall"); + UINT er = WcaErrorMessage(msierrFirewallCannotConnect, hr, INSTALLMESSAGE_ERROR | MB_ABORTRETRYIGNORE, 0); + switch (er) + { + case IDABORT: // exit with the current HRESULT + ExitFunction(); + case IDRETRY: // clean up and retry the loop + hr = S_FALSE; + break; + case IDIGNORE: // pass S_FALSE back to the caller, who knows how to ignore the failure + ExitFunction1(hr = S_FALSE); + default: // No UI, so default is to fail. + ExitFunction(); + } + } + } while (S_FALSE == hr); + + *ppNetFwRules = pNetFwRules; + pNetFwRules = NULL; + +LExit: + ReleaseObject(pNetFwPolicy2); + ReleaseObject(pNetFwRules); + + return hr; +} + +/****************************************************************** + CreateFwRuleObject - CoCreate a firewall rule, and set the common set of properties which are shared + between port and application firewall rules + +********************************************************************/ +static HRESULT CreateFwRuleObject( + __in BSTR bstrName, + __in int iProfile, + __in_opt LPCWSTR wzRemoteAddresses, + __in LPCWSTR wzPort, + __in int iProtocol, + __in LPCWSTR wzDescription, + __out INetFwRule** ppNetFwRule + ) +{ + HRESULT hr = S_OK; + BSTR bstrRemoteAddresses = NULL; + BSTR bstrPort = NULL; + BSTR bstrDescription = NULL; + INetFwRule* pNetFwRule = NULL; + *ppNetFwRule = NULL; + + // convert to BSTRs to make COM happy + bstrRemoteAddresses = ::SysAllocString(wzRemoteAddresses); + ExitOnNull(bstrRemoteAddresses, hr, E_OUTOFMEMORY, "failed SysAllocString for remote addresses"); + bstrPort = ::SysAllocString(wzPort); + ExitOnNull(bstrPort, hr, E_OUTOFMEMORY, "failed SysAllocString for port"); + bstrDescription = ::SysAllocString(wzDescription); + ExitOnNull(bstrDescription, hr, E_OUTOFMEMORY, "failed SysAllocString for description"); + + hr = ::CoCreateInstance(__uuidof(NetFwRule), NULL, CLSCTX_ALL, __uuidof(INetFwRule), (void**)&pNetFwRule); + ExitOnFailure(hr, "failed to create NetFwRule object"); + + hr = pNetFwRule->put_Name(bstrName); + ExitOnFailure(hr, "failed to set exception name"); + + hr = pNetFwRule->put_Profiles(static_cast(iProfile)); + ExitOnFailure(hr, "failed to set exception profile"); + + if (MSI_NULL_INTEGER != iProtocol) + { + hr = pNetFwRule->put_Protocol(static_cast(iProtocol)); + ExitOnFailure(hr, "failed to set exception protocol"); + } + + if (bstrPort && *bstrPort) + { + hr = pNetFwRule->put_LocalPorts(bstrPort); + ExitOnFailure(hr, "failed to set exception port"); + } + + if (bstrRemoteAddresses && *bstrRemoteAddresses) + { + hr = pNetFwRule->put_RemoteAddresses(bstrRemoteAddresses); + ExitOnFailure(hr, "failed to set exception remote addresses '%ls'", bstrRemoteAddresses); + } + + if (bstrDescription && *bstrDescription) + { + hr = pNetFwRule->put_Description(bstrDescription); + ExitOnFailure(hr, "failed to set exception description '%ls'", bstrDescription); + } + + *ppNetFwRule = pNetFwRule; + pNetFwRule = NULL; + +LExit: + ReleaseBSTR(bstrRemoteAddresses); + ReleaseBSTR(bstrPort); + ReleaseBSTR(bstrDescription); + ReleaseObject(pNetFwRule); + + return hr; +} + +/****************************************************************** + FSupportProfiles - Returns true if we support profiles on this machine. + (Only on Vista or later) + +********************************************************************/ +static BOOL FSupportProfiles() +{ + BOOL fSupportProfiles = FALSE; + INetFwRules* pNetFwRules = NULL; + + // We only support profiles if we can co-create an instance of NetFwPolicy2. + // This will not work on pre-vista machines. + if (SUCCEEDED(GetFirewallRules(TRUE, &pNetFwRules)) && pNetFwRules != NULL) + { + fSupportProfiles = TRUE; + ReleaseObject(pNetFwRules); + } + + return fSupportProfiles; +} + +/****************************************************************** + GetCurrentFirewallProfile - get the active firewall profile as an + INetFwProfile, which owns the lists of exceptions we're + updating. + +********************************************************************/ +static HRESULT GetCurrentFirewallProfile( + __in BOOL fIgnoreFailures, + __out INetFwProfile** ppfwProfile + ) +{ + HRESULT hr = S_OK; + INetFwMgr* pfwMgr = NULL; + INetFwPolicy* pfwPolicy = NULL; + INetFwProfile* pfwProfile = NULL; + *ppfwProfile = NULL; + + do + { + ReleaseNullObject(pfwPolicy); + ReleaseNullObject(pfwMgr); + ReleaseNullObject(pfwProfile); + + if (SUCCEEDED(hr = ::CoCreateInstance(__uuidof(NetFwMgr), NULL, CLSCTX_INPROC_SERVER, __uuidof(INetFwMgr), (void**)&pfwMgr)) && + SUCCEEDED(hr = pfwMgr->get_LocalPolicy(&pfwPolicy)) && + SUCCEEDED(hr = pfwPolicy->get_CurrentProfile(&pfwProfile))) + { + break; + } + else if (fIgnoreFailures) + { + ExitFunction1(hr = S_FALSE); + } + else + { + WcaLog(LOGMSG_STANDARD, "Failed to connect to Windows Firewall"); + UINT er = WcaErrorMessage(msierrFirewallCannotConnect, hr, INSTALLMESSAGE_ERROR | MB_ABORTRETRYIGNORE, 0); + switch (er) + { + case IDABORT: // exit with the current HRESULT + ExitFunction(); + case IDRETRY: // clean up and retry the loop + hr = S_FALSE; + break; + case IDIGNORE: // pass S_FALSE back to the caller, who knows how to ignore the failure + ExitFunction1(hr = S_FALSE); + default: // No UI, so default is to fail. + ExitFunction(); + } + } + } while (S_FALSE == hr); + + *ppfwProfile = pfwProfile; + pfwProfile = NULL; + +LExit: + ReleaseObject(pfwPolicy); + ReleaseObject(pfwMgr); + ReleaseObject(pfwProfile); + + return hr; +} + +/****************************************************************** + AddApplicationException + +********************************************************************/ +static HRESULT AddApplicationException( + __in LPCWSTR wzFile, + __in LPCWSTR wzName, + __in int iProfile, + __in_opt LPCWSTR wzRemoteAddresses, + __in BOOL fIgnoreFailures, + __in LPCWSTR wzPort, + __in int iProtocol, + __in LPCWSTR wzDescription + ) +{ + HRESULT hr = S_OK; + BSTR bstrFile = NULL; + BSTR bstrName = NULL; + INetFwRules* pNetFwRules = NULL; + INetFwRule* pNetFwRule = NULL; + + // convert to BSTRs to make COM happy + bstrFile = ::SysAllocString(wzFile); + ExitOnNull(bstrFile, hr, E_OUTOFMEMORY, "failed SysAllocString for path"); + bstrName = ::SysAllocString(wzName); + ExitOnNull(bstrName, hr, E_OUTOFMEMORY, "failed SysAllocString for name"); + + // get the collection of firewall rules + hr = GetFirewallRules(fIgnoreFailures, &pNetFwRules); + ExitOnFailure(hr, "failed to get firewall rules object"); + if (S_FALSE == hr) // user or package author chose to ignore missing firewall + { + ExitFunction(); + } + + // try to find it (i.e., support reinstall) + hr = pNetFwRules->Item(bstrName, &pNetFwRule); + if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr) + { + hr = CreateFwRuleObject(bstrName, iProfile, wzRemoteAddresses, wzPort, iProtocol, wzDescription, &pNetFwRule); + ExitOnFailure(hr, "failed to create FwRule object"); + + // set edge traversal to true + hr = pNetFwRule->put_EdgeTraversal(VARIANT_TRUE); + ExitOnFailure(hr, "failed to set application exception edgetraversal property"); + + // set path + hr = pNetFwRule->put_ApplicationName(bstrFile); + ExitOnFailure(hr, "failed to set application name"); + + // enable it + hr = pNetFwRule->put_Enabled(VARIANT_TRUE); + ExitOnFailure(hr, "failed to to enable application exception"); + + // add it to the list of authorized apps + hr = pNetFwRules->Add(pNetFwRule); + ExitOnFailure(hr, "failed to add app to the authorized apps list"); + } + else + { + // we found an existing app exception (if we succeeded, that is) + ExitOnFailure(hr, "failed trying to find existing app"); + + // enable it (just in case it was disabled) + pNetFwRule->put_Enabled(VARIANT_TRUE); + } + +LExit: + ReleaseBSTR(bstrName); + ReleaseBSTR(bstrFile); + ReleaseObject(pNetFwRules); + ReleaseObject(pNetFwRule); + + return fIgnoreFailures ? S_OK : hr; +} + +/****************************************************************** + AddApplicationExceptionOnCurrentProfile + +********************************************************************/ +static HRESULT AddApplicationExceptionOnCurrentProfile( + __in LPCWSTR wzFile, + __in LPCWSTR wzName, + __in_opt LPCWSTR wzRemoteAddresses, + __in BOOL fIgnoreFailures + ) +{ + HRESULT hr = S_OK; + BSTR bstrFile = NULL; + BSTR bstrName = NULL; + BSTR bstrRemoteAddresses = NULL; + INetFwProfile* pfwProfile = NULL; + INetFwAuthorizedApplications* pfwApps = NULL; + INetFwAuthorizedApplication* pfwApp = NULL; + + // convert to BSTRs to make COM happy + bstrFile = ::SysAllocString(wzFile); + ExitOnNull(bstrFile, hr, E_OUTOFMEMORY, "failed SysAllocString for path"); + bstrName = ::SysAllocString(wzName); + ExitOnNull(bstrName, hr, E_OUTOFMEMORY, "failed SysAllocString for name"); + bstrRemoteAddresses = ::SysAllocString(wzRemoteAddresses); + ExitOnNull(bstrRemoteAddresses, hr, E_OUTOFMEMORY, "failed SysAllocString for remote addresses"); + + // get the firewall profile, which is our entry point for adding exceptions + hr = GetCurrentFirewallProfile(fIgnoreFailures, &pfwProfile); + ExitOnFailure(hr, "failed to get firewall profile"); + if (S_FALSE == hr) // user or package author chose to ignore missing firewall + { + ExitFunction(); + } + + // first, let's see if the app is already on the exception list + hr = pfwProfile->get_AuthorizedApplications(&pfwApps); + ExitOnFailure(hr, "failed to get list of authorized apps"); + + // try to find it (i.e., support reinstall) + hr = pfwApps->Item(bstrFile, &pfwApp); + if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr) + { + // not found, so we get to add it + hr = ::CoCreateInstance(__uuidof(NetFwAuthorizedApplication), NULL, CLSCTX_INPROC_SERVER, __uuidof(INetFwAuthorizedApplication), reinterpret_cast(&pfwApp)); + ExitOnFailure(hr, "failed to create authorized app"); + + // set the display name + hr = pfwApp->put_Name(bstrName); + ExitOnFailure(hr, "failed to set authorized app name"); + + // set path + hr = pfwApp->put_ProcessImageFileName(bstrFile); + ExitOnFailure(hr, "failed to set authorized app path"); + + // set the allowed remote addresses + if (bstrRemoteAddresses && *bstrRemoteAddresses) + { + hr = pfwApp->put_RemoteAddresses(bstrRemoteAddresses); + ExitOnFailure(hr, "failed to set authorized app remote addresses"); + } + + // add it to the list of authorized apps + hr = pfwApps->Add(pfwApp); + ExitOnFailure(hr, "failed to add app to the authorized apps list"); + } + else + { + // we found an existing app exception (if we succeeded, that is) + ExitOnFailure(hr, "failed trying to find existing app"); + + // enable it (just in case it was disabled) + pfwApp->put_Enabled(VARIANT_TRUE); + } + +LExit: + ReleaseBSTR(bstrRemoteAddresses); + ReleaseBSTR(bstrName); + ReleaseBSTR(bstrFile); + ReleaseObject(pfwApp); + ReleaseObject(pfwApps); + ReleaseObject(pfwProfile); + + return fIgnoreFailures ? S_OK : hr; +} + +/****************************************************************** + AddPortException + +********************************************************************/ +static HRESULT AddPortException( + __in LPCWSTR wzName, + __in int iProfile, + __in_opt LPCWSTR wzRemoteAddresses, + __in BOOL fIgnoreFailures, + __in LPCWSTR wzPort, + __in int iProtocol, + __in LPCWSTR wzDescription + ) +{ + HRESULT hr = S_OK; + BSTR bstrName = NULL; + INetFwRules* pNetFwRules = NULL; + INetFwRule* pNetFwRule = NULL; + + // convert to BSTRs to make COM happy + bstrName = ::SysAllocString(wzName); + ExitOnNull(bstrName, hr, E_OUTOFMEMORY, "failed SysAllocString for name"); + + // get the collection of firewall rules + hr = GetFirewallRules(fIgnoreFailures, &pNetFwRules); + ExitOnFailure(hr, "failed to get firewall rules object"); + if (S_FALSE == hr) // user or package author chose to ignore missing firewall + { + ExitFunction(); + } + + // try to find it (i.e., support reinstall) + hr = pNetFwRules->Item(bstrName, &pNetFwRule); + if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr) + { + hr = CreateFwRuleObject(bstrName, iProfile, wzRemoteAddresses, wzPort, iProtocol, wzDescription, &pNetFwRule); + ExitOnFailure(hr, "failed to create FwRule object"); + + // enable it + hr = pNetFwRule->put_Enabled(VARIANT_TRUE); + ExitOnFailure(hr, "failed to to enable port exception"); + + // add it to the list of authorized ports + hr = pNetFwRules->Add(pNetFwRule); + ExitOnFailure(hr, "failed to add app to the authorized ports list"); + } + else + { + // we found an existing port exception (if we succeeded, that is) + ExitOnFailure(hr, "failed trying to find existing port rule"); + + // enable it (just in case it was disabled) + pNetFwRule->put_Enabled(VARIANT_TRUE); + } + +LExit: + ReleaseBSTR(bstrName); + ReleaseObject(pNetFwRules); + ReleaseObject(pNetFwRule); + + return fIgnoreFailures ? S_OK : hr; +} + +/****************************************************************** + AddPortExceptionOnCurrentProfile + +********************************************************************/ +static HRESULT AddPortExceptionOnCurrentProfile( + __in LPCWSTR wzName, + __in_opt LPCWSTR wzRemoteAddresses, + __in BOOL fIgnoreFailures, + __in int iPort, + __in int iProtocol + ) +{ + HRESULT hr = S_OK; + BSTR bstrName = NULL; + BSTR bstrRemoteAddresses = NULL; + INetFwProfile* pfwProfile = NULL; + INetFwOpenPorts* pfwPorts = NULL; + INetFwOpenPort* pfwPort = NULL; + + // convert to BSTRs to make COM happy + bstrName = ::SysAllocString(wzName); + ExitOnNull(bstrName, hr, E_OUTOFMEMORY, "failed SysAllocString for name"); + bstrRemoteAddresses = ::SysAllocString(wzRemoteAddresses); + ExitOnNull(bstrRemoteAddresses, hr, E_OUTOFMEMORY, "failed SysAllocString for remote addresses"); + + // create and initialize a new open port object + hr = ::CoCreateInstance(__uuidof(NetFwOpenPort), NULL, CLSCTX_INPROC_SERVER, __uuidof(INetFwOpenPort), reinterpret_cast(&pfwPort)); + ExitOnFailure(hr, "failed to create new open port"); + + hr = pfwPort->put_Port(iPort); + ExitOnFailure(hr, "failed to set exception port"); + + hr = pfwPort->put_Protocol(static_cast(iProtocol)); + ExitOnFailure(hr, "failed to set exception protocol"); + + if (bstrRemoteAddresses && *bstrRemoteAddresses) + { + hr = pfwPort->put_RemoteAddresses(bstrRemoteAddresses); + ExitOnFailure(hr, "failed to set exception remote addresses '%ls'", bstrRemoteAddresses); + } + + hr = pfwPort->put_Name(bstrName); + ExitOnFailure(hr, "failed to set exception name"); + + // get the firewall profile, its current list of open ports, and add ours + hr = GetCurrentFirewallProfile(fIgnoreFailures, &pfwProfile); + ExitOnFailure(hr, "failed to get firewall profile"); + if (S_FALSE == hr) // user or package author chose to ignore missing firewall + { + ExitFunction(); + } + + hr = pfwProfile->get_GloballyOpenPorts(&pfwPorts); + ExitOnFailure(hr, "failed to get open ports"); + + hr = pfwPorts->Add(pfwPort); + ExitOnFailure(hr, "failed to add exception to global list"); + +LExit: + ReleaseBSTR(bstrRemoteAddresses); + ReleaseBSTR(bstrName); + ReleaseObject(pfwProfile); + ReleaseObject(pfwPorts); + ReleaseObject(pfwPort); + + return fIgnoreFailures ? S_OK : hr; +} + +/****************************************************************** + RemoveException - Removes the exception rule with the given name. + +********************************************************************/ +static HRESULT RemoveException( + __in LPCWSTR wzName, + __in BOOL fIgnoreFailures + ) +{ + HRESULT hr = S_OK;; + INetFwRules* pNetFwRules = NULL; + + // convert to BSTRs to make COM happy + BSTR bstrName = ::SysAllocString(wzName); + ExitOnNull(bstrName, hr, E_OUTOFMEMORY, "failed SysAllocString for path"); + + // get the collection of firewall rules + hr = GetFirewallRules(fIgnoreFailures, &pNetFwRules); + ExitOnFailure(hr, "failed to get firewall rules object"); + if (S_FALSE == hr) // user or package author chose to ignore missing firewall + { + ExitFunction(); + } + + hr = pNetFwRules->Remove(bstrName); + ExitOnFailure(hr, "failed to remove authorized app"); + +LExit: + ReleaseBSTR(bstrName); + ReleaseObject(pNetFwRules); + + return fIgnoreFailures ? S_OK : hr; +} + +/****************************************************************** + RemoveApplicationExceptionFromCurrentProfile + +********************************************************************/ +static HRESULT RemoveApplicationExceptionFromCurrentProfile( + __in LPCWSTR wzFile, + __in BOOL fIgnoreFailures + ) +{ + HRESULT hr = S_OK; + INetFwProfile* pfwProfile = NULL; + INetFwAuthorizedApplications* pfwApps = NULL; + + // convert to BSTRs to make COM happy + BSTR bstrFile = ::SysAllocString(wzFile); + ExitOnNull(bstrFile, hr, E_OUTOFMEMORY, "failed SysAllocString for path"); + + // get the firewall profile, which is our entry point for removing exceptions + hr = GetCurrentFirewallProfile(fIgnoreFailures, &pfwProfile); + ExitOnFailure(hr, "failed to get firewall profile"); + if (S_FALSE == hr) // user or package author chose to ignore missing firewall + { + ExitFunction(); + } + + // now get the list of app exceptions and remove the one + hr = pfwProfile->get_AuthorizedApplications(&pfwApps); + ExitOnFailure(hr, "failed to get list of authorized apps"); + + hr = pfwApps->Remove(bstrFile); + ExitOnFailure(hr, "failed to remove authorized app"); + +LExit: + ReleaseBSTR(bstrFile); + ReleaseObject(pfwApps); + ReleaseObject(pfwProfile); + + return fIgnoreFailures ? S_OK : hr; +} + +/****************************************************************** + RemovePortExceptionFromCurrentProfile + +********************************************************************/ +static HRESULT RemovePortExceptionFromCurrentProfile( + __in int iPort, + __in int iProtocol, + __in BOOL fIgnoreFailures + ) +{ + HRESULT hr = S_OK; + INetFwProfile* pfwProfile = NULL; + INetFwOpenPorts* pfwPorts = NULL; + + // get the firewall profile, which is our entry point for adding exceptions + hr = GetCurrentFirewallProfile(fIgnoreFailures, &pfwProfile); + ExitOnFailure(hr, "failed to get firewall profile"); + if (S_FALSE == hr) // user or package author chose to ignore missing firewall + { + ExitFunction(); + } + + hr = pfwProfile->get_GloballyOpenPorts(&pfwPorts); + ExitOnFailure(hr, "failed to get open ports"); + + hr = pfwPorts->Remove(iPort, static_cast(iProtocol)); + ExitOnFailure(hr, "failed to remove open port %d, protocol %d", iPort, iProtocol); + +LExit: + return fIgnoreFailures ? S_OK : hr; +} + +static HRESULT AddApplicationException( + __in BOOL fSupportProfiles, + __in LPCWSTR wzFile, + __in LPCWSTR wzName, + __in int iProfile, + __in_opt LPCWSTR wzRemoteAddresses, + __in BOOL fIgnoreFailures, + __in LPCWSTR wzPort, + __in int iProtocol, + __in LPCWSTR wzDescription + ) +{ + HRESULT hr = S_OK; + + if (fSupportProfiles) + { + hr = AddApplicationException(wzFile, wzName, iProfile, wzRemoteAddresses, fIgnoreFailures, wzPort, iProtocol, wzDescription); + } + else + { + if (0 != *wzPort || MSI_NULL_INTEGER != iProtocol) + { + // NOTE: This is treated as an error rather than either creating a rule based on just the application (no port), or + // just the port because it is unclear what is the proper fall back. For example, suppose that you have code that + // runs in dllhost.exe. Clearly falling back to opening all of dllhost is wrong. Because the firewall is a security + // feature, it seems better to require the MSI author to indicate the behavior that they want. + WcaLog(LOGMSG_STANDARD, "FirewallExtension: Cannot add firewall rule '%ls', which defines both an application and a port or protocol. Such a rule requires Microsoft Windows Vista or later.", wzName); + return fIgnoreFailures ? S_OK : E_NOTIMPL; + } + + hr = AddApplicationExceptionOnCurrentProfile(wzFile, wzName, wzRemoteAddresses, fIgnoreFailures); + } + + return hr; +} + +static HRESULT AddPortException( + __in BOOL fSupportProfiles, + __in LPCWSTR wzName, + __in int iProfile, + __in_opt LPCWSTR wzRemoteAddresses, + __in BOOL fIgnoreFailures, + __in LPCWSTR wzPort, + __in int iProtocol, + __in LPCWSTR wzDescription + ) +{ + HRESULT hr = S_OK; + + if (fSupportProfiles) + { + hr = AddPortException(wzName, iProfile, wzRemoteAddresses, fIgnoreFailures, wzPort, iProtocol, wzDescription); + } + else + { + hr = AddPortExceptionOnCurrentProfile(wzName, wzRemoteAddresses, fIgnoreFailures, wcstol(wzPort, NULL, 10), iProtocol); + } + + return hr; +} + +static HRESULT RemoveApplicationException( + __in BOOL fSupportProfiles, + __in LPCWSTR wzName, + __in LPCWSTR wzFile, + __in BOOL fIgnoreFailures, + __in LPCWSTR wzPort, + __in int iProtocol + ) +{ + HRESULT hr = S_OK; + + if (fSupportProfiles) + { + hr = RemoveException(wzName, fIgnoreFailures); + } + else + { + if (0 != *wzPort || MSI_NULL_INTEGER != iProtocol) + { + WcaLog(LOGMSG_STANDARD, "FirewallExtension: Cannot remove firewall rule '%ls', which defines both an application and a port or protocol. Such a rule requires Microsoft Windows Vista or later.", wzName); + return S_OK; + } + + hr = RemoveApplicationExceptionFromCurrentProfile(wzFile, fIgnoreFailures); + } + + return hr; +} + +static HRESULT RemovePortException( + __in BOOL fSupportProfiles, + __in LPCWSTR wzName, + __in LPCWSTR wzPort, + __in int iProtocol, + __in BOOL fIgnoreFailures + ) +{ + HRESULT hr = S_OK; + + if (fSupportProfiles) + { + hr = RemoveException(wzName, fIgnoreFailures); + } + else + { + hr = RemovePortExceptionFromCurrentProfile(wcstol(wzPort, NULL, 10), iProtocol, fIgnoreFailures); + } + + return hr; +} + +/****************************************************************** + ExecFirewallExceptions - deferred custom action entry point to + register and remove firewall exceptions. + +********************************************************************/ +extern "C" UINT __stdcall ExecFirewallExceptions( + __in MSIHANDLE hInstall + ) +{ + HRESULT hr = S_OK; + BOOL fSupportProfiles = FALSE; + LPWSTR pwz = NULL; + LPWSTR pwzCustomActionData = NULL; + int iTodo = WCA_TODO_UNKNOWN; + LPWSTR pwzName = NULL; + LPWSTR pwzRemoteAddresses = NULL; + int iAttributes = 0; + int iTarget = fetUnknown; + LPWSTR pwzFile = NULL; + LPWSTR pwzPort = NULL; + LPWSTR pwzDescription = NULL; + int iProtocol = 0; + int iProfile = 0; + + // initialize + hr = WcaInitialize(hInstall, "ExecFirewallExceptions"); + ExitOnFailure(hr, "failed to initialize"); + + hr = WcaGetProperty( L"CustomActionData", &pwzCustomActionData); + ExitOnFailure(hr, "failed to get CustomActionData"); + WcaLog(LOGMSG_TRACEONLY, "CustomActionData: %ls", pwzCustomActionData); + + hr = ::CoInitialize(NULL); + ExitOnFailure(hr, "failed to initialize COM"); + + // Find out if we support profiles (only on Vista or later) + fSupportProfiles = FSupportProfiles(); + + // loop through all the passed in data + pwz = pwzCustomActionData; + while (pwz && *pwz) + { + // extract the custom action data and if rolling back, swap INSTALL and UNINSTALL + hr = WcaReadIntegerFromCaData(&pwz, &iTodo); + ExitOnFailure(hr, "failed to read todo from custom action data"); + if (::MsiGetMode(hInstall, MSIRUNMODE_ROLLBACK)) + { + if (WCA_TODO_INSTALL == iTodo) + { + iTodo = WCA_TODO_UNINSTALL; + } + else if (WCA_TODO_UNINSTALL == iTodo) + { + iTodo = WCA_TODO_INSTALL; + } + } + + hr = WcaReadStringFromCaData(&pwz, &pwzName); + ExitOnFailure(hr, "failed to read name from custom action data"); + + hr = WcaReadIntegerFromCaData(&pwz, &iProfile); + ExitOnFailure(hr, "failed to read profile from custom action data"); + + hr = WcaReadStringFromCaData(&pwz, &pwzRemoteAddresses); + ExitOnFailure(hr, "failed to read remote addresses from custom action data"); + + hr = WcaReadIntegerFromCaData(&pwz, &iAttributes); + ExitOnFailure(hr, "failed to read attributes from custom action data"); + BOOL fIgnoreFailures = feaIgnoreFailures == (iAttributes & feaIgnoreFailures); + + hr = WcaReadIntegerFromCaData(&pwz, &iTarget); + ExitOnFailure(hr, "failed to read target from custom action data"); + + if (iTarget == fetApplication) + { + hr = WcaReadStringFromCaData(&pwz, &pwzFile); + ExitOnFailure(hr, "failed to read file path from custom action data"); + } + + hr = WcaReadStringFromCaData(&pwz, &pwzPort); + ExitOnFailure(hr, "failed to read port from custom action data"); + hr = WcaReadIntegerFromCaData(&pwz, &iProtocol); + ExitOnFailure(hr, "failed to read protocol from custom action data"); + hr = WcaReadStringFromCaData(&pwz, &pwzDescription); + ExitOnFailure(hr, "failed to read protocol from custom action data"); + + switch (iTarget) + { + case fetPort: + switch (iTodo) + { + case WCA_TODO_INSTALL: + case WCA_TODO_REINSTALL: + WcaLog(LOGMSG_STANDARD, "Installing firewall exception2 %ls on port %ls, protocol %d", pwzName, pwzPort, iProtocol); + hr = AddPortException(fSupportProfiles, pwzName, iProfile, pwzRemoteAddresses, fIgnoreFailures, pwzPort, iProtocol, pwzDescription); + ExitOnFailure(hr, "failed to add/update port exception for name '%ls' on port %ls, protocol %d", pwzName, pwzPort, iProtocol); + break; + + case WCA_TODO_UNINSTALL: + WcaLog(LOGMSG_STANDARD, "Uninstalling firewall exception2 %ls on port %ls, protocol %d", pwzName, pwzPort, iProtocol); + hr = RemovePortException(fSupportProfiles, pwzName, pwzPort, iProtocol, fIgnoreFailures); + ExitOnFailure(hr, "failed to remove port exception for name '%ls' on port %ls, protocol %d", pwzName, pwzPort, iProtocol); + break; + } + break; + + case fetApplication: + switch (iTodo) + { + case WCA_TODO_INSTALL: + case WCA_TODO_REINSTALL: + WcaLog(LOGMSG_STANDARD, "Installing firewall exception2 %ls (%ls)", pwzName, pwzFile); + hr = AddApplicationException(fSupportProfiles, pwzFile, pwzName, iProfile, pwzRemoteAddresses, fIgnoreFailures, pwzPort, iProtocol, pwzDescription); + ExitOnFailure(hr, "failed to add/update application exception for name '%ls', file '%ls'", pwzName, pwzFile); + break; + + case WCA_TODO_UNINSTALL: + WcaLog(LOGMSG_STANDARD, "Uninstalling firewall exception2 %ls (%ls)", pwzName, pwzFile); + hr = RemoveApplicationException(fSupportProfiles, pwzName, pwzFile, fIgnoreFailures, pwzPort, iProtocol); + ExitOnFailure(hr, "failed to remove application exception for name '%ls', file '%ls'", pwzName, pwzFile); + break; + } + break; + } + } + +LExit: + ReleaseStr(pwzCustomActionData); + ReleaseStr(pwzName); + ReleaseStr(pwzRemoteAddresses); + ReleaseStr(pwzFile); + ReleaseStr(pwzPort); + ReleaseStr(pwzDescription); + ::CoUninitialize(); + + return WcaFinalize(FAILED(hr) ? ERROR_INSTALL_FAILURE : ERROR_SUCCESS); +} diff --git a/src/ca/fwca.def b/src/ca/fwca.def new file mode 100644 index 00000000..d32c5379 --- /dev/null +++ b/src/ca/fwca.def @@ -0,0 +1,9 @@ +; Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +LIBRARY "fwca" + +EXPORTS + SchedFirewallExceptionsInstall + SchedFirewallExceptionsUninstall + ExecFirewallExceptions diff --git a/src/ca/fwca.vcxproj b/src/ca/fwca.vcxproj new file mode 100644 index 00000000..b6075790 --- /dev/null +++ b/src/ca/fwca.vcxproj @@ -0,0 +1,72 @@ + + + + + + + + + + Debug + Win32 + + + Release + Win32 + + + + + {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981} + DynamicLibrary + fwca + v141 + Unicode + fwca.def + WiX Toolset Firewall CustomAction + + + + + + + + + + + + + + msi.lib + + + + + Create + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + diff --git a/src/ca/packages.config b/src/ca/packages.config new file mode 100644 index 00000000..b74ff5d0 --- /dev/null +++ b/src/ca/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/ca/precomp.h b/src/ca/precomp.h new file mode 100644 index 00000000..a84bacff --- /dev/null +++ b/src/ca/precomp.h @@ -0,0 +1,17 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +#include +#include +#include +#include +#include + +#include "wcautil.h" +#include "fileutil.h" +#include "pathutil.h" +#include "strutil.h" + +#include "CustomMsiErrors.h" +#include "cost.h" diff --git a/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs b/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs new file mode 100644 index 00000000..0d7eb6ad --- /dev/null +++ b/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs @@ -0,0 +1,33 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolsetTest.Firewall +{ + using System.Linq; + using WixBuildTools.TestSupport; + using WixToolset.Core.TestPackage; + using WixToolset.Firewall; + using Xunit; + + public class FirewallExtensionFixture + { + [Fact] + public void CanBuildUsingFileShare() + { + var folder = TestData.Get(@"TestData\UsingFirewall"); + var build = new Builder(folder, typeof(FirewallExtensionFactory), new[] { folder }); + + var results = build.BuildAndQuery(Build, "WixFirewallException"); + Assert.Equal(new[] + { + "WixFirewallException:ExampleFirewall\texample\t*\t42\t6\t\t0\t2147483647\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tAn example firewall", + }, results.OrderBy(s => s).ToArray()); + } + + private static void Build(string[] args) + { + var result = WixRunner.Execute(args, out var messages); + Assert.Equal(0, result); + Assert.Empty(messages); + } + } +} diff --git a/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.en-us.wxl b/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.en-us.wxl @@ -0,0 +1,11 @@ + + + + + + A newer version of [ProductName] is already installed. + MsiPackage + + diff --git a/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.wxs b/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.wxs new file mode 100644 index 00000000..68ff98fd --- /dev/null +++ b/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.wxs @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs b/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs new file mode 100644 index 00000000..910cca2d --- /dev/null +++ b/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs @@ -0,0 +1,14 @@ + + + + + + + + * + + + + + diff --git a/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/example.txt b/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/example.txt new file mode 100644 index 00000000..1b4ffe8a --- /dev/null +++ b/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/example.txt @@ -0,0 +1 @@ +This is example.txt. \ No newline at end of file diff --git a/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj b/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj new file mode 100644 index 00000000..8925cbc7 --- /dev/null +++ b/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj @@ -0,0 +1,40 @@ + + + + + + netcoreapp2.0 + false + + + + NU1701 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/wixext/FirewallCompiler.cs b/src/wixext/FirewallCompiler.cs new file mode 100644 index 00000000..0696b4b1 --- /dev/null +++ b/src/wixext/FirewallCompiler.cs @@ -0,0 +1,356 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Firewall +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Xml.Linq; + using WixToolset.Data; + using WixToolset.Extensibility; + + /// + /// The compiler for the WiX Toolset Firewall Extension. + /// + public sealed class FirewallCompiler : BaseCompilerExtension + { + public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/firewall"; + + /// + /// Processes an element for the Compiler. + /// + /// Source line number for the parent element. + /// Parent element of element to process. + /// Element to process. + /// Extra information about the context in which this element is being parsed. + public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context) + { + switch (parentElement.Name.LocalName) + { + case "File": + string fileId = context["FileId"]; + string fileComponentId = context["ComponentId"]; + + switch (element.Name.LocalName) + { + case "FirewallException": + this.ParseFirewallExceptionElement(intermediate, section, element, fileComponentId, fileId); + break; + default: + this.ParseHelper.UnexpectedElement(parentElement, element); + break; + } + break; + case "Component": + string componentId = context["ComponentId"]; + + switch (element.Name.LocalName) + { + case "FirewallException": + this.ParseFirewallExceptionElement(intermediate, section, element, componentId, null); + break; + default: + this.ParseHelper.UnexpectedElement(parentElement, element); + break; + } + break; + default: + this.ParseHelper.UnexpectedElement(parentElement, element); + break; + } + } + + /// + /// Parses a FirewallException element. + /// + /// The element to parse. + /// Identifier of the component that owns this firewall exception. + /// The file identifier of the parent element (null if nested under Component). + private void ParseFirewallExceptionElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId, string fileId) + { + SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + Identifier id = null; + string name = null; + int attributes = 0; + string file = null; + string program = null; + string port = null; + string protocolValue = null; + int? protocol = null; + string profileValue = null; + int? profile = null; + string scope = null; + string remoteAddresses = null; + string description = null; + + foreach (XAttribute attrib in element.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "Id": + id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Name": + name = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "File": + if (null != fileId) + { + this.Messaging.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, element.Name.LocalName, "File", "File")); + } + else + { + file = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + } + break; + case "IgnoreFailure": + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= 0x1; // feaIgnoreFailures + } + break; + case "Program": + if (null != fileId) + { + this.Messaging.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, element.Name.LocalName, "Program", "File")); + } + else + { + program = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + } + break; + case "Port": + port = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Protocol": + protocolValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + switch (protocolValue) + { + case "tcp": + protocol = FirewallConstants.NET_FW_IP_PROTOCOL_TCP; + break; + case "udp": + protocol = FirewallConstants.NET_FW_IP_PROTOCOL_UDP; + break; + default: + this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, element.Name.LocalName, "Protocol", protocolValue, "tcp", "udp")); + break; + } + break; + case "Scope": + scope = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + switch (scope) + { + case "any": + remoteAddresses = "*"; + break; + case "localSubnet": + remoteAddresses = "LocalSubnet"; + break; + default: + this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, element.Name.LocalName, "Scope", scope, "any", "localSubnet")); + break; + } + break; + case "Profile": + profileValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + switch (profileValue) + { + case "domain": + profile = FirewallConstants.NET_FW_PROFILE2_DOMAIN; + break; + case "private": + profile = FirewallConstants.NET_FW_PROFILE2_PRIVATE; + break; + case "public": + profile = FirewallConstants.NET_FW_PROFILE2_PUBLIC; + break; + case "all": + profile = FirewallConstants.NET_FW_PROFILE2_ALL; + break; + default: + this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, element.Name.LocalName, "Profile", profileValue, "domain", "private", "public", "all")); + break; + } + break; + case "Description": + description = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.ParseHelper.UnexpectedAttribute(element, attrib); + break; + } + } + else + { + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); + } + } + + // parse RemoteAddress children + foreach (XElement child in element.Elements()) + { + if (this.Namespace == child.Name.Namespace) + { + SourceLineNumber childSourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(child); + switch (child.Name.LocalName) + { + case "RemoteAddress": + if (null != scope) + { + this.Messaging.Write(FirewallErrors.IllegalRemoteAddressWithScopeAttribute(sourceLineNumbers)); + } + else + { + this.ParseRemoteAddressElement(intermediate, section, child, ref remoteAddresses); + } + break; + default: + this.ParseHelper.UnexpectedElement(element, child); + break; + } + } + else + { + this.ParseHelper.ParseExtensionElement(this.Context.Extensions, intermediate, section, element, child); + } + } + + // Id and Name are required + if (null == id) + { + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); + } + + if (null == name) + { + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Name")); + } + + // Scope or child RemoteAddress(es) are required + if (null == remoteAddresses) + { + this.Messaging.Write(ErrorMessages.ExpectedAttributeOrElement(sourceLineNumbers, element.Name.LocalName, "Scope", "RemoteAddress")); + } + + // can't have both Program and File + if (null != program && null != file) + { + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, element.Name.LocalName, "File", "Program")); + } + + // must be nested under File, have File or Program attributes, or have Port attribute + if (String.IsNullOrEmpty(fileId) && String.IsNullOrEmpty(file) && String.IsNullOrEmpty(program) && String.IsNullOrEmpty(port)) + { + this.Messaging.Write(FirewallErrors.NoExceptionSpecified(sourceLineNumbers)); + } + + if (!this.Messaging.EncounteredError) + { + // at this point, File attribute and File parent element are treated the same + if (null != file) + { + fileId = file; + } + + var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixFirewallException", id); + row.Set(1, name); + row.Set(2, remoteAddresses); + + if (!String.IsNullOrEmpty(port)) + { + row.Set(3, port); + + if (!protocol.HasValue) + { + // default protocol is "TCP" + protocol = FirewallConstants.NET_FW_IP_PROTOCOL_TCP; + } + } + + if (protocol.HasValue) + { + row.Set(4, protocol); + } + + if (!String.IsNullOrEmpty(fileId)) + { + row.Set(5, $"[#{fileId}]"); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "File", fileId); + } + else if (!String.IsNullOrEmpty(program)) + { + row.Set(5, program); + } + + if (CompilerConstants.IntegerNotSet != attributes) + { + row.Set(6, attributes); + } + + // Default is "all" + row.Set(7, profile ?? FirewallConstants.NET_FW_PROFILE2_ALL); + + row.Set(8, componentId); + + row.Set(9, description); + + if (this.Context.Platform == Platform.ARM) + { + // Ensure ARM version of the CA is referenced + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixSchedFirewallExceptionsInstall_ARM"); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixSchedFirewallExceptionsUninstall_ARM"); + } + else + { + // All other supported platforms use x86 + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixSchedFirewallExceptionsInstall"); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixSchedFirewallExceptionsUninstall"); + } + } + } + + /// + /// Parses a RemoteAddress element + /// + /// The element to parse. + private void ParseRemoteAddressElement(Intermediate intermediate, IntermediateSection section, XElement element, ref string remoteAddresses) + { + SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + + // no attributes + foreach (XAttribute attrib in element.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) + { + this.ParseHelper.UnexpectedAttribute(element, attrib); + } + else + { + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); + } + } + + this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); + + string address = this.ParseHelper.GetTrimmedInnerText(element); + if (String.IsNullOrEmpty(address)) + { + this.Messaging.Write(FirewallErrors.IllegalEmptyRemoteAddress(sourceLineNumbers)); + } + else + { + if (String.IsNullOrEmpty(remoteAddresses)) + { + remoteAddresses = address; + } + else + { + remoteAddresses = String.Concat(remoteAddresses, ",", address); + } + } + } + } +} diff --git a/src/wixext/FirewallConstants.cs b/src/wixext/FirewallConstants.cs new file mode 100644 index 00000000..16caa5b4 --- /dev/null +++ b/src/wixext/FirewallConstants.cs @@ -0,0 +1,21 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Firewall +{ + using System; + using System.Collections.Generic; + using System.Text; + + static class FirewallConstants + { + // from icftypes.h + public const int NET_FW_IP_PROTOCOL_TCP = 6; + public const int NET_FW_IP_PROTOCOL_UDP = 17; + + // from icftypes.h + public const int NET_FW_PROFILE2_DOMAIN = 0x0001; + public const int NET_FW_PROFILE2_PRIVATE = 0x0002; + public const int NET_FW_PROFILE2_PUBLIC = 0x0004; + public const int NET_FW_PROFILE2_ALL = 0x7FFFFFFF; + } +} diff --git a/src/wixext/FirewallDecompiler.cs b/src/wixext/FirewallDecompiler.cs new file mode 100644 index 00000000..b060f8e2 --- /dev/null +++ b/src/wixext/FirewallDecompiler.cs @@ -0,0 +1,169 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Firewall +{ +#if TODO_CONSIDER_DECOMPILER + using System; + using System.Collections; + using System.Diagnostics; + using System.Globalization; + using WixToolset.Data; + using WixToolset.Extensibility; + using Firewall = WixToolset.Extensions.Serialize.Firewall; + using Wix = WixToolset.Data.Serialize; + + /// + /// The decompiler for the WiX Toolset Firewall Extension. + /// + public sealed class FirewallDecompiler : DecompilerExtension + { + /// + /// Creates a decompiler for Firewall Extension. + /// + public FirewallDecompiler() + { + this.TableDefinitions = FirewallExtensionData.GetExtensionTableDefinitions(); + } + + /// + /// Get the extensions library to be removed. + /// + /// Table definitions for library. + /// Library to remove from decompiled output. + public override Library GetLibraryToRemove(TableDefinitionCollection tableDefinitions) + { + return FirewallExtensionData.GetExtensionLibrary(tableDefinitions); + } + + /// + /// Decompiles an extension table. + /// + /// The table to decompile. + public override void DecompileTable(Table table) + { + switch (table.Name) + { + case "WixFirewallException": + this.DecompileWixFirewallExceptionTable(table); + break; + default: + base.DecompileTable(table); + break; + } + } + + /// + /// Decompile the WixFirewallException table. + /// + /// The table to decompile. + private void DecompileWixFirewallExceptionTable(Table table) + { + foreach (Row row in table.Rows) + { + Firewall.FirewallException fire = new Firewall.FirewallException(); + fire.Id = (string)row[0]; + fire.Name = (string)row[1]; + + string[] addresses = ((string)row[2]).Split(','); + if (1 == addresses.Length) + { + // special-case the Scope attribute values + if ("*" == addresses[0]) + { + fire.Scope = Firewall.FirewallException.ScopeType.any; + } + else if ("LocalSubnet" == addresses[0]) + { + fire.Scope = Firewall.FirewallException.ScopeType.localSubnet; + } + else + { + FirewallDecompiler.AddRemoteAddress(fire, addresses[0]); + } + } + else + { + foreach (string address in addresses) + { + FirewallDecompiler.AddRemoteAddress(fire, address); + } + } + + if (!row.IsColumnEmpty(3)) + { + fire.Port = (string)row[3]; + } + + if (!row.IsColumnEmpty(4)) + { + switch (Convert.ToInt32(row[4])) + { + case FirewallConstants.NET_FW_IP_PROTOCOL_TCP: + fire.Protocol = Firewall.FirewallException.ProtocolType.tcp; + break; + case FirewallConstants.NET_FW_IP_PROTOCOL_UDP: + fire.Protocol = Firewall.FirewallException.ProtocolType.udp; + break; + } + } + + if (!row.IsColumnEmpty(5)) + { + fire.Program = (string)row[5]; + } + + if (!row.IsColumnEmpty(6)) + { + int attr = Convert.ToInt32(row[6]); + if (0x1 == (attr & 0x1)) // feaIgnoreFailures + { + fire.IgnoreFailure = Firewall.YesNoType.yes; + } + } + + if (!row.IsColumnEmpty(7)) + { + switch (Convert.ToInt32(row[7])) + { + case FirewallConstants.NET_FW_PROFILE2_DOMAIN: + fire.Profile = Firewall.FirewallException.ProfileType.domain; + break; + case FirewallConstants.NET_FW_PROFILE2_PRIVATE: + fire.Profile = Firewall.FirewallException.ProfileType.@private; + break; + case FirewallConstants.NET_FW_PROFILE2_PUBLIC: + fire.Profile = Firewall.FirewallException.ProfileType.@public; + break; + case FirewallConstants.NET_FW_PROFILE2_ALL: + fire.Profile = Firewall.FirewallException.ProfileType.all; + break; + } + } + + // Description column is new in v3.6 + if (9 < row.Fields.Length && !row.IsColumnEmpty(9)) + { + fire.Description = (string)row[9]; + } + + Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[8]); + if (null != component) + { + component.AddChild(fire); + } + else + { + this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[6], "Component")); + } + } + } + + private static void AddRemoteAddress(Firewall.FirewallException fire, string address) + { + Firewall.RemoteAddress remote = new Firewall.RemoteAddress(); + remote.Content = address; + fire.AddChild(remote); + } + } +#endif +} diff --git a/src/wixext/FirewallErrors.cs b/src/wixext/FirewallErrors.cs new file mode 100644 index 00000000..3fff8c8d --- /dev/null +++ b/src/wixext/FirewallErrors.cs @@ -0,0 +1,42 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Firewall +{ + using System.Resources; + using WixToolset.Data; + + public static class FirewallErrors + { + public static Message IllegalRemoteAddressWithScopeAttribute(SourceLineNumber sourceLineNumbers) + { + return Message(sourceLineNumbers, Ids.IllegalRemoteAddressWithScopeAttribute, "The RemoteAddress element cannot be specified because its parent FirewallException already specified the Scope attribute. To use RemoteAddress elements, omit the Scope attribute."); + } + + public static Message IllegalEmptyRemoteAddress(SourceLineNumber sourceLineNumbers) + { + return Message(sourceLineNumbers, Ids.IllegalEmptyRemoteAddress, "The RemoteAddress element's inner text cannot be an empty string or completely whitespace."); + } + + public static Message NoExceptionSpecified(SourceLineNumber sourceLineNumbers) + { + return Message(sourceLineNumbers, Ids.NoExceptionSpecified, "The FirewallException element doesn't identify the target of the firewall exception. To create an application exception, nest the FirewallException element under a File element or provide a value for the File or Program attributes. To create a port exception, provide a value for the Port attribute."); + } + + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) + { + return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args); + } + + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, ResourceManager resourceManager, string resourceName, params object[] args) + { + return new Message(sourceLineNumber, MessageLevel.Error, (int)id, resourceManager, resourceName, args); + } + + public enum Ids + { + IllegalRemoteAddressWithScopeAttribute = 6401, + IllegalEmptyRemoteAddress = 6402, + NoExceptionSpecified = 6403, + } + } +} diff --git a/src/wixext/FirewallExtensionData.cs b/src/wixext/FirewallExtensionData.cs new file mode 100644 index 00000000..78939c4e --- /dev/null +++ b/src/wixext/FirewallExtensionData.cs @@ -0,0 +1,24 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Firewall +{ + using WixToolset.Data; + using WixToolset.Extensibility; + using WixToolset.Firewall.Tuples; + + public sealed class FirewallExtensionData : BaseExtensionData + { + public override string DefaultCulture => "en-US"; + + public override bool TryGetTupleDefinitionByName(string name, out IntermediateTupleDefinition tupleDefinition) + { + tupleDefinition = (name == FirewallTupleDefinitionNames.WixFirewallException) ? FirewallTupleDefinitions.WixFirewallException : null; + return tupleDefinition != null; + } + + public override Intermediate GetLibrary(ITupleDefinitionCreator tupleDefinitions) + { + return Intermediate.Load(typeof(FirewallExtensionData).Assembly, "WixToolset.Firewall.firewall.wixlib", tupleDefinitions); + } + } +} diff --git a/src/wixext/FirewallExtensionFactory.cs b/src/wixext/FirewallExtensionFactory.cs new file mode 100644 index 00000000..4594419d --- /dev/null +++ b/src/wixext/FirewallExtensionFactory.cs @@ -0,0 +1,18 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Firewall +{ + using System; + using System.Collections.Generic; + using WixToolset.Extensibility; + + public class FirewallExtensionFactory : BaseExtensionFactory + { + protected override IEnumerable ExtensionTypes => new[] + { + typeof(FirewallCompiler), + typeof(FirewallExtensionData), + typeof(FirewallWindowsInstallerBackendExtension), + }; + } +} diff --git a/src/wixext/FirewallWindowsInstallerBackendExtension.cs b/src/wixext/FirewallWindowsInstallerBackendExtension.cs new file mode 100644 index 00000000..a1c78f04 --- /dev/null +++ b/src/wixext/FirewallWindowsInstallerBackendExtension.cs @@ -0,0 +1,26 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Firewall +{ + using System.Linq; + using System.Xml; + using WixToolset.Data.WindowsInstaller; + using WixToolset.Extensibility; + + public class FirewallWindowsInstallerBackendExtension : BaseWindowsInstallerBackendExtension + { + private static readonly TableDefinition[] Tables = LoadTables(); + + protected override TableDefinition[] TableDefinitionsForTuples => Tables; + + private static TableDefinition[] LoadTables() + { + using (var resourceStream = typeof(FirewallWindowsInstallerBackendExtension).Assembly.GetManifestResourceStream("WixToolset.Firewall.tables.xml")) + using (var reader = XmlReader.Create(resourceStream)) + { + var tables = TableDefinitionCollection.Load(reader); + return tables.ToArray(); + } + } + } +} diff --git a/src/wixext/Tuples/FirewallTupleDefinitions.cs b/src/wixext/Tuples/FirewallTupleDefinitions.cs new file mode 100644 index 00000000..79fc28cf --- /dev/null +++ b/src/wixext/Tuples/FirewallTupleDefinitions.cs @@ -0,0 +1,31 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Firewall.Tuples +{ + using WixToolset.Data; + + public static class FirewallTupleDefinitionNames + { + public static string WixFirewallException { get; } = "WixFirewallException"; + } + + public static partial class FirewallTupleDefinitions + { + public static readonly IntermediateTupleDefinition WixFirewallException = new IntermediateTupleDefinition( + FirewallTupleDefinitionNames.WixFirewallException, + new[] + { + new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.WixFirewallException), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Name), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.RemoteAddresses), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Port), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Protocol), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Program), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Attributes), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Profile), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Component_), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Description), IntermediateFieldType.String), + }, + typeof(WixFirewallExceptionTuple)); + } +} diff --git a/src/wixext/Tuples/WixFirewallExceptionTuple.cs b/src/wixext/Tuples/WixFirewallExceptionTuple.cs new file mode 100644 index 00000000..715a4b9b --- /dev/null +++ b/src/wixext/Tuples/WixFirewallExceptionTuple.cs @@ -0,0 +1,93 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Firewall.Tuples +{ + using WixToolset.Data; + + public enum WixFirewallExceptionTupleFields + { + WixFirewallException, + Name, + RemoteAddresses, + Port, + Protocol, + Program, + Attributes, + Profile, + Component_, + Description, + } + + public class WixFirewallExceptionTuple : IntermediateTuple + { + public WixFirewallExceptionTuple() : base(FirewallTupleDefinitions.WixFirewallException, null, null) + { + } + + public WixFirewallExceptionTuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base(FirewallTupleDefinitions.WixFirewallException, sourceLineNumber, id) + { + } + + public IntermediateField this[WixFirewallExceptionTupleFields index] => this.Fields[(int)index]; + + public string WixFirewallException + { + get => this.Fields[(int)WixFirewallExceptionTupleFields.WixFirewallException].AsString(); + set => this.Set((int)WixFirewallExceptionTupleFields.WixFirewallException, value); + } + + public string Name + { + get => this.Fields[(int)WixFirewallExceptionTupleFields.Name].AsString(); + set => this.Set((int)WixFirewallExceptionTupleFields.Name, value); + } + + public string RemoteAddresses + { + get => this.Fields[(int)WixFirewallExceptionTupleFields.RemoteAddresses].AsString(); + set => this.Set((int)WixFirewallExceptionTupleFields.RemoteAddresses, value); + } + + public string Port + { + get => this.Fields[(int)WixFirewallExceptionTupleFields.Port].AsString(); + set => this.Set((int)WixFirewallExceptionTupleFields.Port, value); + } + + public int Protocol + { + get => this.Fields[(int)WixFirewallExceptionTupleFields.Protocol].AsNumber(); + set => this.Set((int)WixFirewallExceptionTupleFields.Protocol, value); + } + + public string Program + { + get => this.Fields[(int)WixFirewallExceptionTupleFields.Program].AsString(); + set => this.Set((int)WixFirewallExceptionTupleFields.Program, value); + } + + public int Attributes + { + get => this.Fields[(int)WixFirewallExceptionTupleFields.Attributes].AsNumber(); + set => this.Set((int)WixFirewallExceptionTupleFields.Attributes, value); + } + + public int Profile + { + get => this.Fields[(int)WixFirewallExceptionTupleFields.Profile].AsNumber(); + set => this.Set((int)WixFirewallExceptionTupleFields.Profile, value); + } + + public string Component_ + { + get => this.Fields[(int)WixFirewallExceptionTupleFields.Component_].AsString(); + set => this.Set((int)WixFirewallExceptionTupleFields.Component_, value); + } + + public string Description + { + get => this.Fields[(int)WixFirewallExceptionTupleFields.Description].AsString(); + set => this.Set((int)WixFirewallExceptionTupleFields.Description, value); + } + } +} \ No newline at end of file diff --git a/src/wixext/WixToolset.Firewall.wixext.csproj b/src/wixext/WixToolset.Firewall.wixext.csproj new file mode 100644 index 00000000..2d89911c --- /dev/null +++ b/src/wixext/WixToolset.Firewall.wixext.csproj @@ -0,0 +1,36 @@ + + + + + + netstandard2.0 + WixToolset.Firewall + WiX Toolset Firewallity Extension + WiX Toolset Firewall Extension + true + build + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/wixext/WixToolset.Firewall.wixext.targets b/src/wixext/WixToolset.Firewall.wixext.targets new file mode 100644 index 00000000..c717450f --- /dev/null +++ b/src/wixext/WixToolset.Firewall.wixext.targets @@ -0,0 +1,11 @@ + + + + + + $(MSBuildThisFileDirectory)..\tools\WixToolset.Firewall.wixext.dll + + + + + diff --git a/src/wixext/firewall.xsd b/src/wixext/firewall.xsd new file mode 100644 index 00000000..d64aafef --- /dev/null +++ b/src/wixext/firewall.xsd @@ -0,0 +1,211 @@ + + + + + + + + The source code schema for the WiX Toolset Firewall Extension. + + + + + + + + + Registers an exception for a program or a specific port and protocol in the Windows Firewall + on Windows XP SP2, Windows Server 2003 SP1, and later. For more information about the Windows + Firewall, see + About Windows Firewall API. + + + + + + + + + + + + Explicitly-listed remote addresses that this exception allows through the + firewall. + + + + + + + + + Unique ID of this firewall exception. + + + + + + + + Name of this firewall exception, visible to the user in the firewall + control panel. + + + + + + + + The scope of this firewall exception, which indicates whether incoming + connections can come from any computer including those on the Internet + or only those on the local network subnet. To more precisely specify + allowed remote address, specify a custom scope using RemoteAddress + child elements. + + + + + + + + + + + + + + Port to allow through the firewall for this exception. + + If you use Port and also File or Program in the same + FirewallException element, the exception will fail to install on + Windows XP and Windows Server 2003. IgnoreFailure="yes" can be used to + ignore the resulting failure, but the exception will not be added. + + + + + + + + IP protocol used for this firewall exception. If Port is defined, + "tcp" is assumed if the protocol is not specified. + + If you use Protocol and also File or Program in the same + FirewallException element, the exception will fail to install on + Windows XP and Windows Server 2003. IgnoreFailure="yes" can be used to + ignore the resulting failure, but the exception will not be added. + + + + + + + + + + + + + + Identifier of a file to be granted access to all incoming ports and + protocols. If you use File, you cannot also use Program. + + If you use File and also Port or Protocol in the same + FirewallException element, the exception will fail to install on + Windows XP and Windows Server 2003. IgnoreFailure="yes" can be used to + ignore the resulting failure, but the exception will not be added. + + + + + + + + Path to a target program to be granted access to all incoming ports and + protocols. Note that this is a formatted field, so you can use [#fileId] + syntax to refer to a file being installed. If you use Program, you cannot + also use File. + + If you use Program and also Port or Protocol in the same + FirewallException element, the exception will fail to install on + Windows XP and Windows Server 2003. IgnoreFailure="yes" can be used to + ignore the resulting failure, but the exception will not be added. + + + + + + + + If "yes," failures to register this firewall exception will be silently + ignored. If "no" (the default), failures will cause rollback. + + + + + + + + Profile type for this firewall exception. Default is "all". + + + + + + + + + + + + + + + Description for this firewall rule displayed in Windows Firewall manager in + Windows Vista and later. + + + + + + + + + + A remote address to which the port or program can listen. Address formats vary + based on the version of Windows and Windows Firewall the program is being installed + on. For Windows XP SP2 and Windows Server 2003 SP1, see + + RemoteAddresses Property. + For Windows Vista and Windows Server 2008, see + + RemoteAddresses Property. + + + + + + + + A remote address. + + + + + + + + + + Values of this type will either be "yes" or "no". + + + + + + + diff --git a/src/wixext/tables.xml b/src/wixext/tables.xml new file mode 100644 index 00000000..5b408b96 --- /dev/null +++ b/src/wixext/tables.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/wixlib/FirewallExtension.wxs b/src/wixlib/FirewallExtension.wxs new file mode 100644 index 00000000..271469e4 --- /dev/null +++ b/src/wixlib/FirewallExtension.wxs @@ -0,0 +1,12 @@ + + + + + + + + + !(loc.msierrFirewallCannotConnect) + + + diff --git a/src/wixlib/FirewallExtension_Platform.wxi b/src/wixlib/FirewallExtension_Platform.wxi new file mode 100644 index 00000000..263651d2 --- /dev/null +++ b/src/wixlib/FirewallExtension_Platform.wxi @@ -0,0 +1,41 @@ + + + + + + + + + !(loc.WixSchedFirewallExceptionsInstall) + !(loc.WixSchedFirewallExceptionsUninstall) + !(loc.WixRollbackFirewallExceptionsInstall) + !(loc.WixExecFirewallExceptionsInstall) + !(loc.WixRollbackFirewallExceptionsUninstall) + !(loc.WixExecFirewallExceptionsUninstall) + + + + + + + + + + + + + = 600 OR (VersionNT >= 501 AND ((MsiNTProductType = 1 AND ServicePackLevel >= 2) OR (MsiNTProductType > 1 AND ServicePackLevel >= 1))) ]]> + + + = 600 OR (VersionNT >= 501 AND ((MsiNTProductType = 1 AND ServicePackLevel >= 2) OR (MsiNTProductType > 1 AND ServicePackLevel >= 1))) ]]> + + + + + + + + + diff --git a/src/wixlib/FirewallExtension_x86.wxs b/src/wixlib/FirewallExtension_x86.wxs new file mode 100644 index 00000000..b43a4c5f --- /dev/null +++ b/src/wixlib/FirewallExtension_x86.wxs @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/wixlib/caSuffix.wxi b/src/wixlib/caSuffix.wxi new file mode 100644 index 00000000..a56a2393 --- /dev/null +++ b/src/wixlib/caSuffix.wxi @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/wixlib/caerr.wxi b/src/wixlib/caerr.wxi new file mode 100644 index 00000000..141942f2 --- /dev/null +++ b/src/wixlib/caerr.wxi @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/wixlib/en-us.wxl b/src/wixlib/en-us.wxl new file mode 100644 index 00000000..7db8a9c2 --- /dev/null +++ b/src/wixlib/en-us.wxl @@ -0,0 +1,14 @@ + + + + + + Cannot connect to Windows Firewall. ([2] [3] [4] [5]) + + Configuring Windows Firewall + Configuring Windows Firewall + Rolling back Windows Firewall configuration + Installing Windows Firewall configuration + Rolling back Windows Firewall configuration + Uninstalling Windows Firewall configuration + diff --git a/src/wixlib/es-es.wxl b/src/wixlib/es-es.wxl new file mode 100644 index 00000000..45d5fd0e --- /dev/null +++ b/src/wixlib/es-es.wxl @@ -0,0 +1,13 @@ + + + + + No se puede conectar al Firewall de Windows. ([2] [3] [4] [5]) + + Configurando el Firewall de Windows + Configurando el Firewall de Windows + Regresando la configuración del Firewall de Windows + Instalando la configuración del Firewall de Windows + Regresando la configuración del Firewall de Windows + Desinstalando la configuración del Firewall de Windows + diff --git a/src/wixlib/firewall.wixproj b/src/wixlib/firewall.wixproj new file mode 100644 index 00000000..fc700d61 --- /dev/null +++ b/src/wixlib/firewall.wixproj @@ -0,0 +1,44 @@ + + + + + + + {1acffefd-505a-41a5-acbf-a02b7b473aa2} + firewall + Library + true + true + en-us + + + + + + + + + + + + + + + fwca + {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981} + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/src/wixlib/ja-jp.wxl b/src/wixlib/ja-jp.wxl new file mode 100644 index 00000000..b6c0b96e --- /dev/null +++ b/src/wixlib/ja-jp.wxl @@ -0,0 +1,14 @@ + + + + + + Windows ファイアウォールへ接続できません。 ([2] [3] [4] [5]) + + Windows ファイアウォールを構成しています + Windows ファイアウォールを構成しています + Windows ファイアウォール構成をロールバックしています + Windows ファイアウォール構成をインストールしています + Windows ファイアウォール構成をロールバックしています + Windows ファイアウォール構成をアンインストールしています + diff --git a/src/wixlib/packages.config b/src/wixlib/packages.config new file mode 100644 index 00000000..4250845c --- /dev/null +++ b/src/wixlib/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/wixlib/pl-pl.wxl b/src/wixlib/pl-pl.wxl new file mode 100644 index 00000000..a685917c --- /dev/null +++ b/src/wixlib/pl-pl.wxl @@ -0,0 +1,14 @@ + + + + + + Nie udało się połączyć z Zaporą systemu Windows. ([2] [3] [4] [5]) + + Dodawanie wyjątków do Zapory systemu Windows + Usuwanie wyjątków z Zapory systemu Windows + Cofanie zmian konfiguracji Zapory systemu Windows + Konfigurowywanie Zapory systemu Windows + Cofanie zmian konfiguracji Zapory systemu Windows + Konfigurowywanie Zapory systemu Windows + -- cgit v1.2.3-55-g6feb From 14b97ae478635b38a48294881b8862bd1d6ff8ad Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Mon, 23 Jul 2018 20:35:41 -0700 Subject: Integrate Core to Tools repro and Extensibility.Data namespace changes --- nuget.config | 1 + src/FindLocalWix.props | 2 +- .../WixToolsetTest.Firewall.csproj | 16 +++++++++------- src/wixext/WixToolset.Firewall.wixext.csproj | 4 ++-- src/wixlib/firewall.wixproj | 12 ++++++------ src/wixlib/packages.config | 4 ++-- 6 files changed, 21 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/nuget.config b/nuget.config index bb8de141..aaee3228 100644 --- a/nuget.config +++ b/nuget.config @@ -9,6 +9,7 @@ + diff --git a/src/FindLocalWix.props b/src/FindLocalWix.props index 1301b0e5..a784e352 100644 --- a/src/FindLocalWix.props +++ b/src/FindLocalWix.props @@ -3,6 +3,6 @@ - $(MSBuildThisFileDirectory)..\..\Core\build\Debug\net461\wix.targets + $(MSBuildThisFileDirectory)..\..\Tools\build\Debug\net461\wix.targets diff --git a/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj b/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj index 8925cbc7..ceb52792 100644 --- a/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj +++ b/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj @@ -1,9 +1,9 @@ - + - netcoreapp2.0 + netcoreapp2.1 false @@ -23,9 +23,11 @@ - - + + + + @@ -33,8 +35,8 @@ - - - + + + diff --git a/src/wixext/WixToolset.Firewall.wixext.csproj b/src/wixext/WixToolset.Firewall.wixext.csproj index 2d89911c..95bedb45 100644 --- a/src/wixext/WixToolset.Firewall.wixext.csproj +++ b/src/wixext/WixToolset.Firewall.wixext.csproj @@ -1,4 +1,4 @@ - + @@ -31,6 +31,6 @@ - + diff --git a/src/wixlib/firewall.wixproj b/src/wixlib/firewall.wixproj index fc700d61..f8857278 100644 --- a/src/wixlib/firewall.wixproj +++ b/src/wixlib/firewall.wixproj @@ -1,7 +1,7 @@ - - + + {1acffefd-505a-41a5-acbf-a02b7b473aa2} @@ -31,14 +31,14 @@ - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + - + \ No newline at end of file diff --git a/src/wixlib/packages.config b/src/wixlib/packages.config index 4250845c..45e5c7b1 100644 --- a/src/wixlib/packages.config +++ b/src/wixlib/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file -- cgit v1.2.3-55-g6feb From 6d4851fe2646a8f13fe04cb005a1ff13de26247c Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Thu, 16 Aug 2018 17:40:11 -0400 Subject: Update to latest MSBuild NuGet package and Windows 10 SDK for CA --- src/ca/fwca.vcxproj | 1 + src/wixlib/firewall.wixproj | 4 ++-- src/wixlib/packages.config | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ca/fwca.vcxproj b/src/ca/fwca.vcxproj index b6075790..3415a4e1 100644 --- a/src/ca/fwca.vcxproj +++ b/src/ca/fwca.vcxproj @@ -24,6 +24,7 @@ Unicode fwca.def WiX Toolset Firewall CustomAction + $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) diff --git a/src/wixlib/firewall.wixproj b/src/wixlib/firewall.wixproj index f8857278..71a17115 100644 --- a/src/wixlib/firewall.wixproj +++ b/src/wixlib/firewall.wixproj @@ -1,7 +1,7 @@ - + {1acffefd-505a-41a5-acbf-a02b7b473aa2} @@ -38,7 +38,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/src/wixlib/packages.config b/src/wixlib/packages.config index 45e5c7b1..f3d424e1 100644 --- a/src/wixlib/packages.config +++ b/src/wixlib/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file -- cgit v1.2.3-55-g6feb From 2116d017c9dd7757c2eb3a201673b22c366d2541 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 2 Oct 2018 15:25:22 -0700 Subject: Enable NCrunch support --- Firewall.wixext.sln | 26 +++++++++++++------------- src/Cpp.Build.props | 5 ++--- src/Directory.Build.props | 15 +++++++++++---- src/ca/fwca.v3.ncrunchproject | 5 +++++ src/wixext/WixToolset.Firewall.wixext.csproj | 2 +- src/wixlib/firewall.v3.ncrunchproject | 5 +++++ 6 files changed, 37 insertions(+), 21 deletions(-) create mode 100644 src/ca/fwca.v3.ncrunchproject create mode 100644 src/wixlib/firewall.v3.ncrunchproject (limited to 'src') diff --git a/Firewall.wixext.sln b/Firewall.wixext.sln index 47e30fcd..59209c88 100644 --- a/Firewall.wixext.sln +++ b/Firewall.wixext.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.27130.2003 MinimumVisualStudioVersion = 15.0.26124.0 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fwca", "src\ca\fwca.vcxproj", "{076018F7-19BD-423A-ABBF-229273DA08D8}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fwca", "src\ca\fwca.vcxproj", "{F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}" EndProject Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "firewall", "src\wixlib\firewall.wixproj", "{1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}" EndProject @@ -21,22 +21,22 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {076018F7-19BD-423A-ABBF-229273DA08D8}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {076018F7-19BD-423A-ABBF-229273DA08D8}.Debug|x64.ActiveCfg = Debug|Win32 - {076018F7-19BD-423A-ABBF-229273DA08D8}.Debug|x86.ActiveCfg = Debug|Win32 - {076018F7-19BD-423A-ABBF-229273DA08D8}.Debug|x86.Build.0 = Debug|Win32 - {076018F7-19BD-423A-ABBF-229273DA08D8}.Release|Any CPU.ActiveCfg = Release|Win32 - {076018F7-19BD-423A-ABBF-229273DA08D8}.Release|x64.ActiveCfg = Release|Win32 - {076018F7-19BD-423A-ABBF-229273DA08D8}.Release|x86.ActiveCfg = Release|Win32 - {076018F7-19BD-423A-ABBF-229273DA08D8}.Release|x86.Build.0 = Release|Win32 + {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Debug|Any CPU.Build.0 = Debug|Win32 + {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Debug|x64.ActiveCfg = Debug|Win32 + {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Debug|x86.ActiveCfg = Debug|Win32 + {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Debug|x86.Build.0 = Debug|Win32 + {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Release|Any CPU.ActiveCfg = Release|Win32 + {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Release|x64.ActiveCfg = Release|Win32 + {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Release|x86.ActiveCfg = Release|Win32 + {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Release|x86.Build.0 = Release|Win32 {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Debug|Any CPU.ActiveCfg = Debug|x86 - {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Debug|x64.ActiveCfg = Debug|x64 - {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Debug|x64.Build.0 = Debug|x64 + {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Debug|Any CPU.Build.0 = Debug|x86 + {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Debug|x64.ActiveCfg = Debug|x86 {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Debug|x86.ActiveCfg = Debug|x86 {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Debug|x86.Build.0 = Debug|x86 {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Release|Any CPU.ActiveCfg = Release|x86 - {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Release|x64.ActiveCfg = Release|x64 - {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Release|x64.Build.0 = Release|x64 + {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Release|x64.ActiveCfg = Release|x86 {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Release|x86.ActiveCfg = Release|x86 {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Release|x86.Build.0 = Release|x86 {6CF033EB-0A39-4AC6-9D41-9BD506352045}.Debug|Any CPU.ActiveCfg = Debug|Any CPU diff --git a/src/Cpp.Build.props b/src/Cpp.Build.props index 453aa442..296b36ca 100644 --- a/src/Cpp.Build.props +++ b/src/Cpp.Build.props @@ -3,9 +3,8 @@ - Win32 - $(OutputPath) - $(BaseIntermediateOutputPath)$(Platform)\ + Win32 + $(BaseIntermediateOutputPath)$(Configuration)\$(Platform)\ $(OutputPath)$(Platform)\ diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 63ad5d6e..9eacf3f5 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,16 +1,23 @@ - + Debug - AnyCPU - $(MSBuildThisFileDirectory)..\build\obj\$(MSBuildProjectName)\ - $(MSBuildThisFileDirectory)..\build\$(Configuration)\ + false + + $(MSBuildProjectName) + $(MSBuildThisFileDirectory)..\build\ + $(BaseOutputPath)obj\$(ProjectName)\ + $(BaseOutputPath)$(Configuration)\ WiX Toolset Team WiX Toolset Copyright (c) .NET Foundation and contributors. All rights reserved. + WiX Toolset diff --git a/src/ca/fwca.v3.ncrunchproject b/src/ca/fwca.v3.ncrunchproject new file mode 100644 index 00000000..319cd523 --- /dev/null +++ b/src/ca/fwca.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/src/wixext/WixToolset.Firewall.wixext.csproj b/src/wixext/WixToolset.Firewall.wixext.csproj index 95bedb45..9982a551 100644 --- a/src/wixext/WixToolset.Firewall.wixext.csproj +++ b/src/wixext/WixToolset.Firewall.wixext.csproj @@ -27,7 +27,7 @@ - + diff --git a/src/wixlib/firewall.v3.ncrunchproject b/src/wixlib/firewall.v3.ncrunchproject new file mode 100644 index 00000000..319cd523 --- /dev/null +++ b/src/wixlib/firewall.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file -- cgit v1.2.3-55-g6feb From cf80d3a0decef4a9208373f7a393b15264d54cef Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 3 Oct 2018 15:49:09 -0700 Subject: Adopt new WixRunner execution --- src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs b/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs index 0d7eb6ad..e3c41181 100644 --- a/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs +++ b/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs @@ -25,9 +25,8 @@ namespace WixToolsetTest.Firewall private static void Build(string[] args) { - var result = WixRunner.Execute(args, out var messages); - Assert.Equal(0, result); - Assert.Empty(messages); + var result = WixRunner.Execute(args) + .AssertSuccess(); } } } -- cgit v1.2.3-55-g6feb From d33819e917476691a13dc82d2aaa9c0c82d0ced6 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Thu, 29 Nov 2018 14:07:07 -0500 Subject: Update extension for latest changes in WixToolset.Extensibility. --- src/wixext/FirewallExtensionFactory.cs | 2 +- src/wixext/FirewallWindowsInstallerBackendExtension.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/wixext/FirewallExtensionFactory.cs b/src/wixext/FirewallExtensionFactory.cs index 4594419d..377ae0ee 100644 --- a/src/wixext/FirewallExtensionFactory.cs +++ b/src/wixext/FirewallExtensionFactory.cs @@ -12,7 +12,7 @@ namespace WixToolset.Firewall { typeof(FirewallCompiler), typeof(FirewallExtensionData), - typeof(FirewallWindowsInstallerBackendExtension), + typeof(FirewallWindowsInstallerBackendBinderExtension), }; } } diff --git a/src/wixext/FirewallWindowsInstallerBackendExtension.cs b/src/wixext/FirewallWindowsInstallerBackendExtension.cs index a1c78f04..a3949e69 100644 --- a/src/wixext/FirewallWindowsInstallerBackendExtension.cs +++ b/src/wixext/FirewallWindowsInstallerBackendExtension.cs @@ -7,7 +7,7 @@ namespace WixToolset.Firewall using WixToolset.Data.WindowsInstaller; using WixToolset.Extensibility; - public class FirewallWindowsInstallerBackendExtension : BaseWindowsInstallerBackendExtension + public class FirewallWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension { private static readonly TableDefinition[] Tables = LoadTables(); @@ -15,7 +15,7 @@ namespace WixToolset.Firewall private static TableDefinition[] LoadTables() { - using (var resourceStream = typeof(FirewallWindowsInstallerBackendExtension).Assembly.GetManifestResourceStream("WixToolset.Firewall.tables.xml")) + using (var resourceStream = typeof(FirewallWindowsInstallerBackendBinderExtension).Assembly.GetManifestResourceStream("WixToolset.Firewall.tables.xml")) using (var reader = XmlReader.Create(resourceStream)) { var tables = TableDefinitionCollection.Load(reader); -- cgit v1.2.3-55-g6feb From 0ff4b0b41f899c0c17f001359598617058af15d3 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 22 Dec 2018 14:45:50 -0800 Subject: Update to latest Home\repo-template --- .editorconfig | 37 +++++++++++ .gitignore | 72 ++++++++++++++++++---- Firewall.wixext.v3.ncrunchsolution | 6 ++ appveyor.yml | 6 ++ src/Directory.Build.props | 9 +-- src/Directory.Build.targets | 48 +++++++++++++++ .../WixToolsetTest.Firewall.csproj | 6 +- src/wixext/WixToolset.Firewall.wixext.csproj | 7 +-- 8 files changed, 162 insertions(+), 29 deletions(-) create mode 100644 .editorconfig create mode 100644 Firewall.wixext.v3.ncrunchsolution create mode 100644 src/Directory.Build.targets (limited to 'src') diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..1d72e683 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,37 @@ +# Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. +# +# Do NOT modify this file. Update the canonical version in Home\repo-template\src\.editorconfig +# then update all of the repos. + +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.{cs,vb}] +dotnet_sort_system_directives_first = true + +[*.cs] +csharp_indent_case_contents = true : error +csharp_indent_switch_labels = true : error +csharp_new_line_before_open_brace = all +csharp_prefer_braces = true : error +csharp_style_expression_bodied_methods = when_on_single_line : suggestion +csharp_style_expression_bodied_constructors = when_on_single_line : suggestion +csharp_style_expression_bodied_operators = when_on_single_line : suggestion +csharp_style_expression_bodied_properties = when_on_single_line : suggestion +csharp_style_expression_bodied_indexers = when_on_single_line : suggestion +csharp_style_expression_bodied_accessors = when_on_single_line : suggestion +csharp_style_var_elsewhere = true : suggestion +csharp_style_var_for_built_in_types = true : suggestion +csharp_style_var_when_type_is_apparent = true : suggestion +dotnet_style_qualification_for_event = true : error +dotnet_style_qualification_for_field = true : error +dotnet_style_qualification_for_method = true : error +dotnet_style_qualification_for_property = true : error + +[*.targets] +indent_size = 2 diff --git a/.gitignore b/.gitignore index 3c6208a8..3e8a1553 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore # User-specific files +*.rsuser *.suo *.user *.userosscache @@ -19,16 +20,21 @@ [Rr]eleases/ x64/ x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ bld/ [Bb]in/ [Oo]bj/ [Ll]og/ -# Visual Studio 2015 cache/options directory +# Visual Studio 2015/2017 cache/options directory .vs/ # Uncomment if you have tasks that create the project's static files in wwwroot #wwwroot/ +# Visual Studio 2017 auto generated files +Generated\ Files/ + # MSTest test Results [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* @@ -49,16 +55,21 @@ BenchmarkDotNet.Artifacts/ project.lock.json project.fragment.lock.json artifacts/ -**/Properties/launchSettings.json +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio *_i.c *_p.c -*_i.h +*_h.h *.ilk *.meta *.obj +*.iobj *.pch *.pdb +*.ipdb *.pgc *.pgd *.rsp @@ -68,6 +79,7 @@ artifacts/ *.tlh *.tmp *.tmp_proj +*_wpftmp.csproj *.log *.vspscc *.vssscc @@ -96,6 +108,9 @@ ipch/ *.vspx *.sap +# Visual Studio Trace Files +*.e2e + # TFS 2012 Local Workspace $tf/ @@ -116,6 +131,10 @@ _TeamCity* # DotCover is a Code Coverage Tool *.dotCover +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + # Visual Studio code coverage results *.coverage *.coveragexml @@ -164,11 +183,11 @@ PublishScripts/ # NuGet Packages *.nupkg # The packages folder can be ignored because of Package Restore -**/packages/* +**/[Pp]ackages/* # except build/, which is used as an MSBuild target. -!**/packages/build/ +!**/[Pp]ackages/build/ # Uncomment if necessary however generally it will be regenerated when needed -#!**/packages/repositories.config +#!**/[Pp]ackages/repositories.config # NuGet v3's project.json files produces more ignorable files *.nuget.props *.nuget.targets @@ -192,7 +211,7 @@ _pkginfo.txt # files ending in .cache can be ignored *.[Cc]ache # but keep track of directories ending in .cache -!*.[Cc]ache/ +!?*.[Cc]ache/ # Others ClientBin/ @@ -205,9 +224,15 @@ ClientBin/ *.publishsettings orleans.codegen.cs +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + # Since there are multiple workflows, uncomment next line to ignore bower_components # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) #bower_components/ +# ASP.NET Core default setup: bower directory is configured as wwwroot/lib/ and bower restore is true +**/wwwroot/lib/ # RIA/Silverlight projects Generated_Code/ @@ -219,6 +244,8 @@ _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak # SQL Server files *.mdf @@ -229,6 +256,7 @@ UpgradeLog*.htm *.rdl.data *.bim.layout *.bim_*.settings +*.rptproj.rsuser # Microsoft Fakes FakesAssemblies/ @@ -240,9 +268,6 @@ FakesAssemblies/ .ntvs_analysis.dat node_modules/ -# Typescript v1 declaration files -typings/ - # Visual Studio 6 build log *.plg @@ -271,8 +296,8 @@ paket-files/ .idea/ *.sln.iml -# CodeRush -.cr/ +# CodeRush personal settings +.cr/personal # Python Tools for Visual Studio (PTVS) __pycache__/ @@ -292,4 +317,25 @@ __pycache__/ *.btp.cs *.btm.cs *.odx.cs -*.xsd.cs \ No newline at end of file +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb diff --git a/Firewall.wixext.v3.ncrunchsolution b/Firewall.wixext.v3.ncrunchsolution new file mode 100644 index 00000000..10420ac9 --- /dev/null +++ b/Firewall.wixext.v3.ncrunchsolution @@ -0,0 +1,6 @@ + + + True + True + + \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 0c74d54b..d55322da 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,3 +1,8 @@ +# Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. +# +# Do NOT modify this file. Update the canonical version in Home\repo-template\src\appveyor.yml +# then update all of the repos. + image: Visual Studio 2017 version: 0.0.0.{build} @@ -17,6 +22,7 @@ pull_requests: nuget: disable_publish_on_pr: true +skip_branch_with_pr: true skip_tags: true artifacts: diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 9eacf3f5..e853e22d 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,7 +1,7 @@ @@ -10,20 +10,17 @@ false $(MSBuildProjectName) - $(MSBuildThisFileDirectory)..\build\ + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\build\)) $(BaseOutputPath)obj\$(ProjectName)\ $(BaseOutputPath)$(Configuration)\ WiX Toolset Team WiX Toolset Copyright (c) .NET Foundation and contributors. All rights reserved. + MS-RL WiX Toolset - - $(MSBuildThisFileDirectory)..\..\ - - diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets new file mode 100644 index 00000000..dac7452a --- /dev/null +++ b/src/Directory.Build.targets @@ -0,0 +1,48 @@ + + + + + + + true + $(SolutionPath) + $(NCrunchOriginalSolutionPath) + + + + + + + $([System.IO.File]::ReadAllText($(TheSolutionPath))) + $([System.IO.Path]::GetDirectoryName( $(TheSolutionPath) )) + (?<="[PackageName]", ")(.*)(?=", ") + + + + + + %(Identity) + $(SolutionFileContent.Contains('\%(Identity).csproj')) + + + + + $(RegexPattern.Replace('[PackageName]','%(PackageName)') ) + $([System.Text.RegularExpressions.Regex]::Match('$(SolutionFileContent)', '%(Pattern)')) + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj b/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj index ceb52792..d9c026f2 100644 --- a/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj +++ b/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj @@ -23,11 +23,7 @@ - - - - - + diff --git a/src/wixext/WixToolset.Firewall.wixext.csproj b/src/wixext/WixToolset.Firewall.wixext.csproj index 9982a551..b0fe04d1 100644 --- a/src/wixext/WixToolset.Firewall.wixext.csproj +++ b/src/wixext/WixToolset.Firewall.wixext.csproj @@ -19,11 +19,8 @@ - - - - - + + -- cgit v1.2.3-55-g6feb From cc153493c432de282ad7297c7e674340829caf7f Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 13 Jan 2019 19:20:11 -0600 Subject: Update to latest Cpp.Build.props for locating latest Win10 SDK. Remove unused Microsoft.VisualStudio.Setup.Configuration.Native package. --- src/Cpp.Build.props | 6 +++++- src/ca/fwca.vcxproj | 9 --------- src/ca/packages.config | 1 - 3 files changed, 5 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/Cpp.Build.props b/src/Cpp.Build.props index 296b36ca..0e00132b 100644 --- a/src/Cpp.Build.props +++ b/src/Cpp.Build.props @@ -8,6 +8,10 @@ $(OutputPath)$(Platform)\ + + $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) + + $(DisableSpecificCompilerWarnings) @@ -16,7 +20,7 @@ WIN32;_WINDOWS;_WIN32_MSI=500;_WIN32_WINNT=0x0501;$(ArmPreprocessorDefinitions);$(UnicodePreprocessorDefinitions);_CRT_STDIO_LEGACY_WIDE_SPECIFIERS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) Use precomp.h - StdCall + StdCall true false -YlprecompDefine diff --git a/src/ca/fwca.vcxproj b/src/ca/fwca.vcxproj index 3415a4e1..a933ed06 100644 --- a/src/ca/fwca.vcxproj +++ b/src/ca/fwca.vcxproj @@ -24,19 +24,11 @@ Unicode fwca.def WiX Toolset Firewall CustomAction - $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) - - - - - - - msi.lib @@ -65,7 +57,6 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - diff --git a/src/ca/packages.config b/src/ca/packages.config index b74ff5d0..b87f9ab4 100644 --- a/src/ca/packages.config +++ b/src/ca/packages.config @@ -1,6 +1,5 @@  - \ No newline at end of file -- cgit v1.2.3-55-g6feb From 7a934bcfb8d460b0cf91a51caa956a8bbff14edf Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Mon, 28 Oct 2019 21:17:09 -0400 Subject: Modernize tuple creation and update dependencies. --- src/ca/fwca.vcxproj | 23 ++++----------- src/ca/packages.config | 4 +-- .../WixToolsetTest.Firewall.csproj | 12 ++++++-- src/wixext/FirewallCompiler.cs | 33 ++++++++++------------ .../FirewallWindowsInstallerBackendExtension.cs | 5 +++- src/wixext/Tuples/FirewallTupleDefinitions.cs | 3 +- src/wixext/Tuples/WixFirewallExceptionTuple.cs | 19 ++++--------- src/wixext/tables.xml | 2 +- src/wixlib/firewall.wixproj | 4 +-- src/wixlib/packages.config | 2 +- 10 files changed, 47 insertions(+), 60 deletions(-) (limited to 'src') diff --git a/src/ca/fwca.vcxproj b/src/ca/fwca.vcxproj index a933ed06..de77df9b 100644 --- a/src/ca/fwca.vcxproj +++ b/src/ca/fwca.vcxproj @@ -1,10 +1,8 @@ - - - - + + Debug @@ -15,7 +13,6 @@ Win32 - {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981} DynamicLibrary @@ -25,40 +22,32 @@ fwca.def WiX Toolset Firewall CustomAction - - msi.lib - Create - - - + - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + - - + \ No newline at end of file diff --git a/src/ca/packages.config b/src/ca/packages.config index b87f9ab4..4e9403bf 100644 --- a/src/ca/packages.config +++ b/src/ca/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file diff --git a/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj b/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj index d9c026f2..306f4b5f 100644 --- a/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj +++ b/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj @@ -23,6 +23,9 @@ + + + @@ -31,8 +34,11 @@ - - - + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/wixext/FirewallCompiler.cs b/src/wixext/FirewallCompiler.cs index 0696b4b1..353afff3 100644 --- a/src/wixext/FirewallCompiler.cs +++ b/src/wixext/FirewallCompiler.cs @@ -4,10 +4,10 @@ namespace WixToolset.Firewall { using System; using System.Collections.Generic; - using System.Globalization; using System.Xml.Linq; using WixToolset.Data; using WixToolset.Extensibility; + using WixToolset.Firewall.Tuples; /// /// The compiler for the WiX Toolset Firewall Extension. @@ -255,13 +255,18 @@ namespace WixToolset.Firewall fileId = file; } - var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixFirewallException", id); - row.Set(1, name); - row.Set(2, remoteAddresses); + var tuple = new WixFirewallExceptionTuple(sourceLineNumbers, id) + { + Name = name, + RemoteAddresses = remoteAddresses, + Profile = profile ?? FirewallConstants.NET_FW_PROFILE2_ALL, + ComponentRef = componentId, + Description = description, + }; if (!String.IsNullOrEmpty(port)) { - row.Set(3, port); + tuple.Port = port; if (!protocol.HasValue) { @@ -270,32 +275,24 @@ namespace WixToolset.Firewall } } - if (protocol.HasValue) - { - row.Set(4, protocol); - } + tuple.Protocol = protocol.Value; if (!String.IsNullOrEmpty(fileId)) { - row.Set(5, $"[#{fileId}]"); + tuple.Program = $"[#{fileId}]"; this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "File", fileId); } else if (!String.IsNullOrEmpty(program)) { - row.Set(5, program); + tuple.Program = program; } if (CompilerConstants.IntegerNotSet != attributes) { - row.Set(6, attributes); + tuple.Attributes = attributes; } - // Default is "all" - row.Set(7, profile ?? FirewallConstants.NET_FW_PROFILE2_ALL); - - row.Set(8, componentId); - - row.Set(9, description); + section.Tuples.Add(tuple); if (this.Context.Platform == Platform.ARM) { diff --git a/src/wixext/FirewallWindowsInstallerBackendExtension.cs b/src/wixext/FirewallWindowsInstallerBackendExtension.cs index a3949e69..47a01ac0 100644 --- a/src/wixext/FirewallWindowsInstallerBackendExtension.cs +++ b/src/wixext/FirewallWindowsInstallerBackendExtension.cs @@ -1,9 +1,10 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. namespace WixToolset.Firewall { using System.Linq; using System.Xml; + using WixToolset.Data; using WixToolset.Data.WindowsInstaller; using WixToolset.Extensibility; @@ -13,6 +14,8 @@ namespace WixToolset.Firewall protected override TableDefinition[] TableDefinitionsForTuples => Tables; + public override bool TryAddTupleToOutput(IntermediateTuple tuple, WindowsInstallerData output) => this.BackendHelper.TryAddTupleToOutputMatchingTableDefinitions(tuple, output, this.TableDefinitionsForTuples, true); + private static TableDefinition[] LoadTables() { using (var resourceStream = typeof(FirewallWindowsInstallerBackendBinderExtension).Assembly.GetManifestResourceStream("WixToolset.Firewall.tables.xml")) diff --git a/src/wixext/Tuples/FirewallTupleDefinitions.cs b/src/wixext/Tuples/FirewallTupleDefinitions.cs index 79fc28cf..df595c18 100644 --- a/src/wixext/Tuples/FirewallTupleDefinitions.cs +++ b/src/wixext/Tuples/FirewallTupleDefinitions.cs @@ -15,7 +15,6 @@ namespace WixToolset.Firewall.Tuples FirewallTupleDefinitionNames.WixFirewallException, new[] { - new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.WixFirewallException), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Name), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.RemoteAddresses), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Port), IntermediateFieldType.String), @@ -23,7 +22,7 @@ namespace WixToolset.Firewall.Tuples new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Program), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Attributes), IntermediateFieldType.Number), new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Profile), IntermediateFieldType.Number), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Component_), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.ComponentRef), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Description), IntermediateFieldType.String), }, typeof(WixFirewallExceptionTuple)); diff --git a/src/wixext/Tuples/WixFirewallExceptionTuple.cs b/src/wixext/Tuples/WixFirewallExceptionTuple.cs index 715a4b9b..3c7cda3a 100644 --- a/src/wixext/Tuples/WixFirewallExceptionTuple.cs +++ b/src/wixext/Tuples/WixFirewallExceptionTuple.cs @@ -6,7 +6,6 @@ namespace WixToolset.Firewall.Tuples public enum WixFirewallExceptionTupleFields { - WixFirewallException, Name, RemoteAddresses, Port, @@ -14,7 +13,7 @@ namespace WixToolset.Firewall.Tuples Program, Attributes, Profile, - Component_, + ComponentRef, Description, } @@ -30,12 +29,6 @@ namespace WixToolset.Firewall.Tuples public IntermediateField this[WixFirewallExceptionTupleFields index] => this.Fields[(int)index]; - public string WixFirewallException - { - get => this.Fields[(int)WixFirewallExceptionTupleFields.WixFirewallException].AsString(); - set => this.Set((int)WixFirewallExceptionTupleFields.WixFirewallException, value); - } - public string Name { get => this.Fields[(int)WixFirewallExceptionTupleFields.Name].AsString(); @@ -54,9 +47,9 @@ namespace WixToolset.Firewall.Tuples set => this.Set((int)WixFirewallExceptionTupleFields.Port, value); } - public int Protocol + public int? Protocol { - get => this.Fields[(int)WixFirewallExceptionTupleFields.Protocol].AsNumber(); + get => this.Fields[(int)WixFirewallExceptionTupleFields.Protocol].AsNullableNumber(); set => this.Set((int)WixFirewallExceptionTupleFields.Protocol, value); } @@ -78,10 +71,10 @@ namespace WixToolset.Firewall.Tuples set => this.Set((int)WixFirewallExceptionTupleFields.Profile, value); } - public string Component_ + public string ComponentRef { - get => this.Fields[(int)WixFirewallExceptionTupleFields.Component_].AsString(); - set => this.Set((int)WixFirewallExceptionTupleFields.Component_, value); + get => this.Fields[(int)WixFirewallExceptionTupleFields.ComponentRef].AsString(); + set => this.Set((int)WixFirewallExceptionTupleFields.ComponentRef, value); } public string Description diff --git a/src/wixext/tables.xml b/src/wixext/tables.xml index 5b408b96..b0c32305 100644 --- a/src/wixext/tables.xml +++ b/src/wixext/tables.xml @@ -17,7 +17,7 @@ + description="Vital=1" /> - + {1acffefd-505a-41a5-acbf-a02b7b473aa2} @@ -38,7 +38,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/src/wixlib/packages.config b/src/wixlib/packages.config index f3d424e1..1ae2b79f 100644 --- a/src/wixlib/packages.config +++ b/src/wixlib/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file -- cgit v1.2.3-55-g6feb From 608f2f6fd9728a630ee5793bb7f24d5b6efeb5d1 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Thu, 9 Apr 2020 08:41:44 +1000 Subject: Update dependencies. --- appveyor.yml | 2 +- src/Cpp.Build.props | 2 +- src/Directory.Build.props | 4 +++- src/FindLocalWix.props | 2 +- src/ca/fwca.vcxproj | 14 ++++++++++++-- .../WixToolsetTest.Firewall.csproj | 17 +++++++---------- src/wixext/FirewallWindowsInstallerBackendExtension.cs | 3 ++- src/wixlib/firewall.wixproj | 4 ++-- src/wixlib/packages.config | 2 +- 9 files changed, 30 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/appveyor.yml b/appveyor.yml index d55322da..bbf880f0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,7 +3,7 @@ # Do NOT modify this file. Update the canonical version in Home\repo-template\src\appveyor.yml # then update all of the repos. -image: Visual Studio 2017 +image: Visual Studio 2019 version: 0.0.0.{build} configuration: Release diff --git a/src/Cpp.Build.props b/src/Cpp.Build.props index 0e00132b..44a042c7 100644 --- a/src/Cpp.Build.props +++ b/src/Cpp.Build.props @@ -8,7 +8,7 @@ $(OutputPath)$(Platform)\ - + $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index e853e22d..a22f4470 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -8,6 +8,7 @@ Debug false + MSB3246 $(MSBuildProjectName) $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\build\)) @@ -21,6 +22,7 @@ WiX Toolset - + + diff --git a/src/FindLocalWix.props b/src/FindLocalWix.props index a784e352..1666e4fe 100644 --- a/src/FindLocalWix.props +++ b/src/FindLocalWix.props @@ -3,6 +3,6 @@ - $(MSBuildThisFileDirectory)..\..\Tools\build\Debug\net461\wix.targets + $(MSBuildThisFileDirectory)..\..\Tools\build\Debug\net461\wix.targets diff --git a/src/ca/fwca.vcxproj b/src/ca/fwca.vcxproj index de77df9b..0172ddbc 100644 --- a/src/ca/fwca.vcxproj +++ b/src/ca/fwca.vcxproj @@ -1,8 +1,10 @@ + - + + Debug @@ -13,6 +15,7 @@ Win32 + {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981} DynamicLibrary @@ -22,27 +25,34 @@ fwca.def WiX Toolset Firewall CustomAction + + msi.lib + Create + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. @@ -50,4 +60,4 @@ - \ No newline at end of file + diff --git a/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj b/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj index 306f4b5f..7727a69b 100644 --- a/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj +++ b/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj @@ -1,9 +1,9 @@ - + - netcoreapp2.1 + netcoreapp3.1 false @@ -23,10 +23,10 @@ - - - - + + + + @@ -36,9 +36,6 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/wixext/FirewallWindowsInstallerBackendExtension.cs b/src/wixext/FirewallWindowsInstallerBackendExtension.cs index 47a01ac0..7b731710 100644 --- a/src/wixext/FirewallWindowsInstallerBackendExtension.cs +++ b/src/wixext/FirewallWindowsInstallerBackendExtension.cs @@ -2,6 +2,7 @@ namespace WixToolset.Firewall { + using System.Collections.Generic; using System.Linq; using System.Xml; using WixToolset.Data; @@ -12,7 +13,7 @@ namespace WixToolset.Firewall { private static readonly TableDefinition[] Tables = LoadTables(); - protected override TableDefinition[] TableDefinitionsForTuples => Tables; + public override IEnumerable TableDefinitions => Tables; public override bool TryAddTupleToOutput(IntermediateTuple tuple, WindowsInstallerData output) => this.BackendHelper.TryAddTupleToOutputMatchingTableDefinitions(tuple, output, this.TableDefinitionsForTuples, true); diff --git a/src/wixlib/firewall.wixproj b/src/wixlib/firewall.wixproj index e14c29ed..b5564fd1 100644 --- a/src/wixlib/firewall.wixproj +++ b/src/wixlib/firewall.wixproj @@ -1,7 +1,7 @@ - + {1acffefd-505a-41a5-acbf-a02b7b473aa2} @@ -38,7 +38,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/src/wixlib/packages.config b/src/wixlib/packages.config index 1ae2b79f..e1b601f6 100644 --- a/src/wixlib/packages.config +++ b/src/wixlib/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file -- cgit v1.2.3-55-g6feb From 2427be20a103957f204b753db45ee89ad636bb08 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Thu, 9 Apr 2020 09:01:29 +1000 Subject: Modernize FirewallCompiler and tuples. --- .../FirewallExtensionFixture.cs | 2 +- src/wixext/FirewallCompiler.cs | 50 +++++++++++----------- src/wixext/FirewallExtensionData.cs | 3 +- src/wixext/FirewallTableDefinitions.cs | 33 ++++++++++++++ .../FirewallWindowsInstallerBackendExtension.cs | 19 +------- src/wixext/Tuples/FirewallTupleDefinitions.cs | 43 +++++++++++-------- src/wixext/Tuples/WixFirewallExceptionTuple.cs | 25 +++++++++++ src/wixext/WixToolset.Firewall.wixext.csproj | 1 - src/wixext/tables.xml | 28 ------------ 9 files changed, 112 insertions(+), 92 deletions(-) create mode 100644 src/wixext/FirewallTableDefinitions.cs delete mode 100644 src/wixext/tables.xml (limited to 'src') diff --git a/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs b/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs index e3c41181..fa64f7d3 100644 --- a/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs +++ b/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs @@ -20,7 +20,7 @@ namespace WixToolsetTest.Firewall Assert.Equal(new[] { "WixFirewallException:ExampleFirewall\texample\t*\t42\t6\t\t0\t2147483647\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tAn example firewall", - }, results.OrderBy(s => s).ToArray()); + }, results); } private static void Build(string[] args) diff --git a/src/wixext/FirewallCompiler.cs b/src/wixext/FirewallCompiler.cs index 353afff3..16136954 100644 --- a/src/wixext/FirewallCompiler.cs +++ b/src/wixext/FirewallCompiler.cs @@ -28,8 +28,8 @@ namespace WixToolset.Firewall switch (parentElement.Name.LocalName) { case "File": - string fileId = context["FileId"]; - string fileComponentId = context["ComponentId"]; + var fileId = context["FileId"]; + var fileComponentId = context["ComponentId"]; switch (element.Name.LocalName) { @@ -42,7 +42,7 @@ namespace WixToolset.Firewall } break; case "Component": - string componentId = context["ComponentId"]; + var componentId = context["ComponentId"]; switch (element.Name.LocalName) { @@ -68,22 +68,20 @@ namespace WixToolset.Firewall /// The file identifier of the parent element (null if nested under Component). private void ParseFirewallExceptionElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId, string fileId) { - SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); Identifier id = null; string name = null; int attributes = 0; string file = null; string program = null; string port = null; - string protocolValue = null; int? protocol = null; - string profileValue = null; int? profile = null; string scope = null; string remoteAddresses = null; string description = null; - foreach (XAttribute attrib in element.Attributes()) + foreach (var attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { @@ -125,7 +123,7 @@ namespace WixToolset.Firewall port = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Protocol": - protocolValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + var protocolValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); switch (protocolValue) { case "tcp": @@ -155,7 +153,7 @@ namespace WixToolset.Firewall } break; case "Profile": - profileValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + var profileValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); switch (profileValue) { case "domain": @@ -190,11 +188,10 @@ namespace WixToolset.Firewall } // parse RemoteAddress children - foreach (XElement child in element.Elements()) + foreach (var child in element.Elements()) { if (this.Namespace == child.Name.Namespace) { - SourceLineNumber childSourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(child); switch (child.Name.LocalName) { case "RemoteAddress": @@ -218,12 +215,12 @@ namespace WixToolset.Firewall } } - // Id and Name are required if (null == id) { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); + id = this.ParseHelper.CreateIdentifier("fex", name, remoteAddresses, componentId); } + // Name is required if (null == name) { this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Name")); @@ -255,14 +252,14 @@ namespace WixToolset.Firewall fileId = file; } - var tuple = new WixFirewallExceptionTuple(sourceLineNumbers, id) + var tuple = section.AddTuple(new WixFirewallExceptionTuple(sourceLineNumbers, id) { Name = name, RemoteAddresses = remoteAddresses, Profile = profile ?? FirewallConstants.NET_FW_PROFILE2_ALL, ComponentRef = componentId, Description = description, - }; + }); if (!String.IsNullOrEmpty(port)) { @@ -275,12 +272,15 @@ namespace WixToolset.Firewall } } - tuple.Protocol = protocol.Value; + if (protocol.HasValue) + { + tuple.Protocol = protocol.Value; + } if (!String.IsNullOrEmpty(fileId)) { tuple.Program = $"[#{fileId}]"; - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "File", fileId); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.File, fileId); } else if (!String.IsNullOrEmpty(program)) { @@ -292,19 +292,17 @@ namespace WixToolset.Firewall tuple.Attributes = attributes; } - section.Tuples.Add(tuple); - if (this.Context.Platform == Platform.ARM) { // Ensure ARM version of the CA is referenced - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixSchedFirewallExceptionsInstall_ARM"); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixSchedFirewallExceptionsUninstall_ARM"); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "WixSchedFirewallExceptionsInstall_ARM"); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "WixSchedFirewallExceptionsUninstall_ARM"); } else { // All other supported platforms use x86 - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixSchedFirewallExceptionsInstall"); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixSchedFirewallExceptionsUninstall"); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "WixSchedFirewallExceptionsInstall"); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "WixSchedFirewallExceptionsUninstall"); } } } @@ -315,10 +313,10 @@ namespace WixToolset.Firewall /// The element to parse. private void ParseRemoteAddressElement(Intermediate intermediate, IntermediateSection section, XElement element, ref string remoteAddresses) { - SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); // no attributes - foreach (XAttribute attrib in element.Attributes()) + foreach (var attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { @@ -332,7 +330,7 @@ namespace WixToolset.Firewall this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); - string address = this.ParseHelper.GetTrimmedInnerText(element); + var address = this.ParseHelper.GetTrimmedInnerText(element); if (String.IsNullOrEmpty(address)) { this.Messaging.Write(FirewallErrors.IllegalEmptyRemoteAddress(sourceLineNumbers)); diff --git a/src/wixext/FirewallExtensionData.cs b/src/wixext/FirewallExtensionData.cs index 78939c4e..44cae0d6 100644 --- a/src/wixext/FirewallExtensionData.cs +++ b/src/wixext/FirewallExtensionData.cs @@ -4,7 +4,6 @@ namespace WixToolset.Firewall { using WixToolset.Data; using WixToolset.Extensibility; - using WixToolset.Firewall.Tuples; public sealed class FirewallExtensionData : BaseExtensionData { @@ -12,7 +11,7 @@ namespace WixToolset.Firewall public override bool TryGetTupleDefinitionByName(string name, out IntermediateTupleDefinition tupleDefinition) { - tupleDefinition = (name == FirewallTupleDefinitionNames.WixFirewallException) ? FirewallTupleDefinitions.WixFirewallException : null; + tupleDefinition = FirewallTupleDefinitions.ByName(name); return tupleDefinition != null; } diff --git a/src/wixext/FirewallTableDefinitions.cs b/src/wixext/FirewallTableDefinitions.cs new file mode 100644 index 00000000..d6e469b8 --- /dev/null +++ b/src/wixext/FirewallTableDefinitions.cs @@ -0,0 +1,33 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Firewall +{ + using WixToolset.Data.WindowsInstaller; + + public static class FirewallTableDefinitions + { + public static readonly TableDefinition WixFirewallException = new TableDefinition( + "WixFirewallException", + new[] + { + new ColumnDefinition("WixFirewallException", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "The primary key, a non-localized token.", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Name", ColumnType.Localized, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Localizable display name.", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("RemoteAddresses", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Remote address to accept incoming connections from.", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("Port", ColumnType.String, 0, primaryKey: false, nullable: true, ColumnCategory.Formatted, minValue: 1, description: "Port number.", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("Protocol", ColumnType.Number, 1, primaryKey: false, nullable: true, ColumnCategory.Integer, minValue: 6, maxValue: 17, description: "Protocol (6=TCP; 17=UDP)."), + new ColumnDefinition("Program", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Exception for a program (formatted path name).", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("Attributes", ColumnType.Number, 4, primaryKey: false, nullable: true, ColumnCategory.Unknown, description: "Vital=1"), + new ColumnDefinition("Profile", ColumnType.Number, 4, primaryKey: false, nullable: false, ColumnCategory.Integer, minValue: 1, maxValue: 2147483647, description: "Profile (1=domain; 2=private; 4=public; 2147483647=all)."), + new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key into the Component table referencing component that controls the firewall configuration.", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Description", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Description displayed in Windows Firewall manager for this firewall rule."), + }, + tupleDefinitionName: FirewallTupleDefinitions.WixFirewallException.Name, + tupleIdIsPrimaryKey: true + ); + + public static readonly TableDefinition[] All = new[] + { + WixFirewallException, + }; + } +} diff --git a/src/wixext/FirewallWindowsInstallerBackendExtension.cs b/src/wixext/FirewallWindowsInstallerBackendExtension.cs index 7b731710..dea355b4 100644 --- a/src/wixext/FirewallWindowsInstallerBackendExtension.cs +++ b/src/wixext/FirewallWindowsInstallerBackendExtension.cs @@ -1,30 +1,15 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. namespace WixToolset.Firewall { using System.Collections.Generic; using System.Linq; using System.Xml; - using WixToolset.Data; using WixToolset.Data.WindowsInstaller; using WixToolset.Extensibility; public class FirewallWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension { - private static readonly TableDefinition[] Tables = LoadTables(); - - public override IEnumerable TableDefinitions => Tables; - - public override bool TryAddTupleToOutput(IntermediateTuple tuple, WindowsInstallerData output) => this.BackendHelper.TryAddTupleToOutputMatchingTableDefinitions(tuple, output, this.TableDefinitionsForTuples, true); - - private static TableDefinition[] LoadTables() - { - using (var resourceStream = typeof(FirewallWindowsInstallerBackendBinderExtension).Assembly.GetManifestResourceStream("WixToolset.Firewall.tables.xml")) - using (var reader = XmlReader.Create(resourceStream)) - { - var tables = TableDefinitionCollection.Load(reader); - return tables.ToArray(); - } - } + public override IEnumerable TableDefinitions => FirewallTableDefinitions.All; } } diff --git a/src/wixext/Tuples/FirewallTupleDefinitions.cs b/src/wixext/Tuples/FirewallTupleDefinitions.cs index df595c18..2710380e 100644 --- a/src/wixext/Tuples/FirewallTupleDefinitions.cs +++ b/src/wixext/Tuples/FirewallTupleDefinitions.cs @@ -1,30 +1,39 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -namespace WixToolset.Firewall.Tuples +namespace WixToolset.Firewall { + using System; using WixToolset.Data; - public static class FirewallTupleDefinitionNames + public enum FirewallTupleDefinitionType { - public static string WixFirewallException { get; } = "WixFirewallException"; + WixFirewallException, } public static partial class FirewallTupleDefinitions { - public static readonly IntermediateTupleDefinition WixFirewallException = new IntermediateTupleDefinition( - FirewallTupleDefinitionNames.WixFirewallException, - new[] + public static readonly Version Version = new Version("4.0.0"); + + public static IntermediateTupleDefinition ByName(string name) + { + if (!Enum.TryParse(name, out FirewallTupleDefinitionType type)) { - new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Name), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.RemoteAddresses), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Port), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Protocol), IntermediateFieldType.Number), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Program), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Attributes), IntermediateFieldType.Number), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Profile), IntermediateFieldType.Number), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.ComponentRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Description), IntermediateFieldType.String), - }, - typeof(WixFirewallExceptionTuple)); + return null; + } + + return ByType(type); + } + + public static IntermediateTupleDefinition ByType(FirewallTupleDefinitionType type) + { + switch (type) + { + case FirewallTupleDefinitionType.WixFirewallException: + return FirewallTupleDefinitions.WixFirewallException; + + default: + throw new ArgumentOutOfRangeException(nameof(type)); + } + } } } diff --git a/src/wixext/Tuples/WixFirewallExceptionTuple.cs b/src/wixext/Tuples/WixFirewallExceptionTuple.cs index 3c7cda3a..d08b9e45 100644 --- a/src/wixext/Tuples/WixFirewallExceptionTuple.cs +++ b/src/wixext/Tuples/WixFirewallExceptionTuple.cs @@ -1,5 +1,30 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. +namespace WixToolset.Firewall +{ + using WixToolset.Data; + using WixToolset.Firewall.Tuples; + + public static partial class FirewallTupleDefinitions + { + public static readonly IntermediateTupleDefinition WixFirewallException = new IntermediateTupleDefinition( + FirewallTupleDefinitionType.WixFirewallException.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Name), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.RemoteAddresses), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Port), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Protocol), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Program), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Attributes), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Profile), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.ComponentRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Description), IntermediateFieldType.String), + }, + typeof(WixFirewallExceptionTuple)); + } +} + namespace WixToolset.Firewall.Tuples { using WixToolset.Data; diff --git a/src/wixext/WixToolset.Firewall.wixext.csproj b/src/wixext/WixToolset.Firewall.wixext.csproj index b0fe04d1..07d5de56 100644 --- a/src/wixext/WixToolset.Firewall.wixext.csproj +++ b/src/wixext/WixToolset.Firewall.wixext.csproj @@ -14,7 +14,6 @@ - diff --git a/src/wixext/tables.xml b/src/wixext/tables.xml deleted file mode 100644 index b0c32305..00000000 --- a/src/wixext/tables.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - -- cgit v1.2.3-55-g6feb From fba81fb720a87075cb78077273b038130c380b8a Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Mon, 13 Apr 2020 19:55:45 +1000 Subject: Update dependencies. --- appveyor.yml | 5 +++++ src/Cpp.Build.props | 18 ------------------ src/wixext/FirewallTableDefinitions.cs | 2 +- src/wixlib/firewall.wixproj | 4 ++-- src/wixlib/packages.config | 2 +- 5 files changed, 9 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/appveyor.yml b/appveyor.yml index bbf880f0..7c686b04 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,6 +3,11 @@ # Do NOT modify this file. Update the canonical version in Home\repo-template\src\appveyor.yml # then update all of the repos. +branches: + only: + - master + - develop + image: Visual Studio 2019 version: 0.0.0.{build} diff --git a/src/Cpp.Build.props b/src/Cpp.Build.props index 44a042c7..9b7a1bb5 100644 --- a/src/Cpp.Build.props +++ b/src/Cpp.Build.props @@ -70,12 +70,6 @@ MultiThreadedDebug - - - - MultiThreadedDebugDll - - MinSpace @@ -89,16 +83,4 @@ true - - - - MultiThreadedDll - - - - - $(LinkKeyFile) - $(LinkDelaySign) - - diff --git a/src/wixext/FirewallTableDefinitions.cs b/src/wixext/FirewallTableDefinitions.cs index d6e469b8..4bae1ef0 100644 --- a/src/wixext/FirewallTableDefinitions.cs +++ b/src/wixext/FirewallTableDefinitions.cs @@ -8,6 +8,7 @@ namespace WixToolset.Firewall { public static readonly TableDefinition WixFirewallException = new TableDefinition( "WixFirewallException", + FirewallTupleDefinitions.WixFirewallException, new[] { new ColumnDefinition("WixFirewallException", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "The primary key, a non-localized token.", modularizeType: ColumnModularizeType.Column), @@ -21,7 +22,6 @@ namespace WixToolset.Firewall new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key into the Component table referencing component that controls the firewall configuration.", modularizeType: ColumnModularizeType.Column), new ColumnDefinition("Description", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Description displayed in Windows Firewall manager for this firewall rule."), }, - tupleDefinitionName: FirewallTupleDefinitions.WixFirewallException.Name, tupleIdIsPrimaryKey: true ); diff --git a/src/wixlib/firewall.wixproj b/src/wixlib/firewall.wixproj index b5564fd1..f9260c88 100644 --- a/src/wixlib/firewall.wixproj +++ b/src/wixlib/firewall.wixproj @@ -1,7 +1,7 @@ - + {1acffefd-505a-41a5-acbf-a02b7b473aa2} @@ -38,7 +38,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/src/wixlib/packages.config b/src/wixlib/packages.config index e1b601f6..1e5a9850 100644 --- a/src/wixlib/packages.config +++ b/src/wixlib/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file -- cgit v1.2.3-55-g6feb From cc083c765e8b7baa239c4d800a372cc729ada9d8 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Sun, 17 May 2020 21:03:28 -0400 Subject: Support ARM64. --- appveyor.cmd | 3 ++ nuget.config | 1 + src/ca/fwca.vcxproj | 37 ++++++++++++++++--- src/ca/packages.config | 4 +- .../FirewallExtensionFixture.cs | 43 ++++++++++++++++++++-- src/wixext/FirewallCompiler.cs | 15 ++------ .../FirewallWindowsInstallerBackendExtension.cs | 4 +- src/wixlib/FirewallExtension_Platform.wxi | 32 ++++++++-------- src/wixlib/FirewallExtension_arm.wxs | 8 ++++ src/wixlib/FirewallExtension_arm64.wxs | 8 ++++ src/wixlib/FirewallExtension_x64.wxs | 8 ++++ src/wixlib/caDecor.wxi | 40 ++++++++++++++++++++ src/wixlib/caSuffix.wxi | 28 -------------- src/wixlib/firewall.wixproj | 39 +++++++++++++++++++- src/wixlib/packages.config | 2 +- 15 files changed, 199 insertions(+), 73 deletions(-) create mode 100644 src/wixlib/FirewallExtension_arm.wxs create mode 100644 src/wixlib/FirewallExtension_arm64.wxs create mode 100644 src/wixlib/FirewallExtension_x64.wxs create mode 100644 src/wixlib/caDecor.wxi delete mode 100644 src/wixlib/caSuffix.wxi (limited to 'src') diff --git a/appveyor.cmd b/appveyor.cmd index 6742048a..f40602b7 100644 --- a/appveyor.cmd +++ b/appveyor.cmd @@ -9,5 +9,8 @@ msbuild -p:Configuration=Release src\test\WixToolsetTest.Firewall\WixToolsetTest msbuild -p:Configuration=Release -t:Pack src\wixext\WixToolset.Firewall.wixext.csproj +msbuild -p:Configuration=Release src\test\WixToolsetTest.Firewall\WixToolsetTest.Firewall.csproj +dotnet test -c Release --no-build src\test\WixToolsetTest.Firewall + @popd @endlocal \ No newline at end of file diff --git a/nuget.config b/nuget.config index aaee3228..d5408d52 100644 --- a/nuget.config +++ b/nuget.config @@ -6,6 +6,7 @@ + diff --git a/src/ca/fwca.vcxproj b/src/ca/fwca.vcxproj index 0172ddbc..c2addf82 100644 --- a/src/ca/fwca.vcxproj +++ b/src/ca/fwca.vcxproj @@ -2,10 +2,37 @@ - - + + + + Debug + ARM + + + Release + ARM + + + + Debug + ARM64 + + + Release + ARM64 + + + + Debug + X64 + + + Release + X64 + + Debug Win32 @@ -20,7 +47,7 @@ {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981} DynamicLibrary fwca - v141 + v142 Unicode fwca.def WiX Toolset Firewall CustomAction @@ -57,7 +84,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + diff --git a/src/ca/packages.config b/src/ca/packages.config index 4e9403bf..97a06c72 100644 --- a/src/ca/packages.config +++ b/src/ca/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file diff --git a/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs b/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs index fa64f7d3..8f8ba44a 100644 --- a/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs +++ b/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs @@ -11,22 +11,57 @@ namespace WixToolsetTest.Firewall public class FirewallExtensionFixture { [Fact] - public void CanBuildUsingFileShare() + public void CanBuildUsingFirewall() { var folder = TestData.Get(@"TestData\UsingFirewall"); var build = new Builder(folder, typeof(FirewallExtensionFactory), new[] { folder }); - var results = build.BuildAndQuery(Build, "WixFirewallException"); + var results = build.BuildAndQuery(Build, "WixFirewallException", "CustomAction"); Assert.Equal(new[] { + "CustomAction:Wix4ExecFirewallExceptionsInstall_X86\t3073\tWix4FWCA_X86\tExecFirewallExceptions\t", + "CustomAction:Wix4ExecFirewallExceptionsUninstall_X86\t3073\tWix4FWCA_X86\tExecFirewallExceptions\t", + "CustomAction:Wix4RollbackFirewallExceptionsInstall_X86\t3329\tWix4FWCA_X86\tExecFirewallExceptions\t", + "CustomAction:Wix4RollbackFirewallExceptionsUninstall_X86\t3329\tWix4FWCA_X86\tExecFirewallExceptions\t", + "CustomAction:Wix4SchedFirewallExceptionsInstall_X86\t1\tWix4FWCA_X86\tSchedFirewallExceptionsInstall\t", + "CustomAction:Wix4SchedFirewallExceptionsUninstall_X86\t1\tWix4FWCA_X86\tSchedFirewallExceptionsUninstall\t", + "WixFirewallException:ExampleFirewall\texample\t*\t42\t6\t\t0\t2147483647\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tAn example firewall", + }, results); + } + + [Fact] + public void CanBuildUsingFirewallARM64() + { + var folder = TestData.Get(@"TestData\UsingFirewall"); + var build = new Builder(folder, typeof(FirewallExtensionFactory), new[] { folder }); + + var results = build.BuildAndQuery(BuildARM64, "WixFirewallException", "CustomAction"); + Assert.Equal(new[] + { + "CustomAction:Wix4ExecFirewallExceptionsInstall_A64\t3073\tWix4FWCA_A64\tExecFirewallExceptions\t", + "CustomAction:Wix4ExecFirewallExceptionsUninstall_A64\t3073\tWix4FWCA_A64\tExecFirewallExceptions\t", + "CustomAction:Wix4RollbackFirewallExceptionsInstall_A64\t3329\tWix4FWCA_A64\tExecFirewallExceptions\t", + "CustomAction:Wix4RollbackFirewallExceptionsUninstall_A64\t3329\tWix4FWCA_A64\tExecFirewallExceptions\t", + "CustomAction:Wix4SchedFirewallExceptionsInstall_A64\t1\tWix4FWCA_A64\tSchedFirewallExceptionsInstall\t", + "CustomAction:Wix4SchedFirewallExceptionsUninstall_A64\t1\tWix4FWCA_A64\tSchedFirewallExceptionsUninstall\t", "WixFirewallException:ExampleFirewall\texample\t*\t42\t6\t\t0\t2147483647\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tAn example firewall", }, results); } private static void Build(string[] args) { - var result = WixRunner.Execute(args) - .AssertSuccess(); + var result = WixRunner.Execute(args); + result.AssertSuccess(); + } + + private static void BuildARM64(string[] args) + { + var newArgs = args.ToList(); + newArgs.Add("-platform"); + newArgs.Add("arm64"); + + var result = WixRunner.Execute(newArgs.ToArray()); + result.AssertSuccess(); } } } diff --git a/src/wixext/FirewallCompiler.cs b/src/wixext/FirewallCompiler.cs index 16136954..1fa80f48 100644 --- a/src/wixext/FirewallCompiler.cs +++ b/src/wixext/FirewallCompiler.cs @@ -7,6 +7,7 @@ namespace WixToolset.Firewall using System.Xml.Linq; using WixToolset.Data; using WixToolset.Extensibility; + using WixToolset.Extensibility.Data; using WixToolset.Firewall.Tuples; /// @@ -292,18 +293,8 @@ namespace WixToolset.Firewall tuple.Attributes = attributes; } - if (this.Context.Platform == Platform.ARM) - { - // Ensure ARM version of the CA is referenced - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "WixSchedFirewallExceptionsInstall_ARM"); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "WixSchedFirewallExceptionsUninstall_ARM"); - } - else - { - // All other supported platforms use x86 - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "WixSchedFirewallExceptionsInstall"); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "WixSchedFirewallExceptionsUninstall"); - } + this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "SchedFirewallExceptionsInstall", this.Context.Platform, CustomActionPlatforms.ARM | CustomActionPlatforms.ARM64 | CustomActionPlatforms.X64 | CustomActionPlatforms.X86); + this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "SchedFirewallExceptionsUninstall", this.Context.Platform, CustomActionPlatforms.ARM | CustomActionPlatforms.ARM64 | CustomActionPlatforms.X64 | CustomActionPlatforms.X86); } } diff --git a/src/wixext/FirewallWindowsInstallerBackendExtension.cs b/src/wixext/FirewallWindowsInstallerBackendExtension.cs index dea355b4..46fdfa77 100644 --- a/src/wixext/FirewallWindowsInstallerBackendExtension.cs +++ b/src/wixext/FirewallWindowsInstallerBackendExtension.cs @@ -1,10 +1,8 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. namespace WixToolset.Firewall { using System.Collections.Generic; - using System.Linq; - using System.Xml; using WixToolset.Data.WindowsInstaller; using WixToolset.Extensibility; diff --git a/src/wixlib/FirewallExtension_Platform.wxi b/src/wixlib/FirewallExtension_Platform.wxi index 263651d2..afd5f20b 100644 --- a/src/wixlib/FirewallExtension_Platform.wxi +++ b/src/wixlib/FirewallExtension_Platform.wxi @@ -2,33 +2,33 @@ - + - !(loc.WixSchedFirewallExceptionsInstall) - !(loc.WixSchedFirewallExceptionsUninstall) - !(loc.WixRollbackFirewallExceptionsInstall) - !(loc.WixExecFirewallExceptionsInstall) - !(loc.WixRollbackFirewallExceptionsUninstall) - !(loc.WixExecFirewallExceptionsUninstall) + !(loc.WixSchedFirewallExceptionsInstall) + !(loc.WixSchedFirewallExceptionsUninstall) + !(loc.WixRollbackFirewallExceptionsInstall) + !(loc.WixExecFirewallExceptionsInstall) + !(loc.WixRollbackFirewallExceptionsUninstall) + !(loc.WixExecFirewallExceptionsUninstall) - - - - - - + + + + + + - + = 600 OR (VersionNT >= 501 AND ((MsiNTProductType = 1 AND ServicePackLevel >= 2) OR (MsiNTProductType > 1 AND ServicePackLevel >= 1))) ]]> - + = 600 OR (VersionNT >= 501 AND ((MsiNTProductType = 1 AND ServicePackLevel >= 2) OR (MsiNTProductType > 1 AND ServicePackLevel >= 1))) ]]> @@ -36,6 +36,6 @@ - + diff --git a/src/wixlib/FirewallExtension_arm.wxs b/src/wixlib/FirewallExtension_arm.wxs new file mode 100644 index 00000000..8afe1589 --- /dev/null +++ b/src/wixlib/FirewallExtension_arm.wxs @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/wixlib/FirewallExtension_arm64.wxs b/src/wixlib/FirewallExtension_arm64.wxs new file mode 100644 index 00000000..4fc16b63 --- /dev/null +++ b/src/wixlib/FirewallExtension_arm64.wxs @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/wixlib/FirewallExtension_x64.wxs b/src/wixlib/FirewallExtension_x64.wxs new file mode 100644 index 00000000..8317c20b --- /dev/null +++ b/src/wixlib/FirewallExtension_x64.wxs @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/wixlib/caDecor.wxi b/src/wixlib/caDecor.wxi new file mode 100644 index 00000000..1d00df8f --- /dev/null +++ b/src/wixlib/caDecor.wxi @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/wixlib/caSuffix.wxi b/src/wixlib/caSuffix.wxi deleted file mode 100644 index a56a2393..00000000 --- a/src/wixlib/caSuffix.wxi +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/wixlib/firewall.wixproj b/src/wixlib/firewall.wixproj index f9260c88..cb273a38 100644 --- a/src/wixlib/firewall.wixproj +++ b/src/wixlib/firewall.wixproj @@ -1,7 +1,7 @@ - + {1acffefd-505a-41a5-acbf-a02b7b473aa2} @@ -13,12 +13,31 @@ + + + + + + + x86 + + + x64 + + + arm + + + arm64 + + + @@ -26,6 +45,22 @@ fwca {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981} + Platform=ARM + + + fwca + {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981} + Platform=ARM64 + + + fwca + {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981} + Platform=x86 + + + fwca + {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981} + Platform=x64 @@ -38,7 +73,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/src/wixlib/packages.config b/src/wixlib/packages.config index 1e5a9850..20afb58c 100644 --- a/src/wixlib/packages.config +++ b/src/wixlib/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file -- cgit v1.2.3-55-g6feb From 5c851a848a6eeb86472e8a1cca814dd0cb1b0483 Mon Sep 17 00:00:00 2001 From: adnan shaheen Date: Mon, 5 Feb 2018 14:01:55 +1000 Subject: WIXFEAT:4009 - Add support for outbound firewall rule --- src/ca/firewall.cpp | 46 +++++++++++++++------- .../FirewallExtensionFixture.cs | 17 +++++++- .../UsingOutboundFirewall/Package.en-us.wxl | 11 ++++++ .../TestData/UsingOutboundFirewall/Package.wxs | 22 +++++++++++ .../UsingOutboundFirewall/PackageComponents.wxs | 14 +++++++ .../TestData/UsingOutboundFirewall/example.txt | 1 + .../WixToolsetTest.Firewall.csproj | 4 ++ src/wixext/FirewallCompiler.cs | 7 ++++ src/wixext/FirewallConstants.cs | 2 + src/wixext/FirewallDecompiler.cs | 13 ++++++ src/wixext/FirewallTableDefinitions.cs | 1 + src/wixext/Tuples/WixFirewallExceptionTuple.cs | 8 ++++ src/wixext/firewall.xsd | 10 ++++- src/wixlib/firewall.wixproj | 4 +- src/wixlib/packages.config | 2 +- 15 files changed, 142 insertions(+), 20 deletions(-) create mode 100644 src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.en-us.wxl create mode 100644 src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.wxs create mode 100644 src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/PackageComponents.wxs create mode 100644 src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/example.txt (limited to 'src') diff --git a/src/ca/firewall.cpp b/src/ca/firewall.cpp index 62a5b454..bf40ce77 100644 --- a/src/ca/firewall.cpp +++ b/src/ca/firewall.cpp @@ -3,7 +3,7 @@ #include "precomp.h" LPCWSTR vcsFirewallExceptionQuery = - L"SELECT `Name`, `RemoteAddresses`, `Port`, `Protocol`, `Program`, `Attributes`, `Profile`, `Component_`, `Description` FROM `WixFirewallException`"; + L"SELECT `Name`, `RemoteAddresses`, `Port`, `Protocol`, `Program`, `Attributes`, `Profile`, `Component_`, `Description`, `Direction` FROM `WixFirewallException`"; enum eFirewallExceptionQuery { feqName = 1, feqRemoteAddresses, feqPort, feqProtocol, feqProgram, feqAttributes, feqProfile, feqComponent, feqDescription }; enum eFirewallExceptionTarget { fetPort = 1, fetApplication, fetUnknown }; enum eFirewallExceptionAttributes { feaIgnoreFailures = 1 }; @@ -36,6 +36,7 @@ static UINT SchedFirewallExceptions( LPWSTR pwzComponent = NULL; LPWSTR pwzFormattedFile = NULL; LPWSTR pwzDescription = NULL; + int iDirection = 0; // initialize hr = WcaInitialize(hInstall, "SchedFirewallExceptions"); @@ -130,6 +131,9 @@ static UINT SchedFirewallExceptions( hr = WcaWriteStringToCaData(pwzDescription, &pwzCustomActionData); ExitOnFailure(hr, "failed to write firewall rule description to custom action data"); + + hr = WcaWriteIntegerToCaData(iDirection, &pwzCustomActionData); + ExitOnFailure(hr, "failed to write firewall rule direction to custom action data"); } // reaching the end of the list is actually a good thing, not an error @@ -270,6 +274,7 @@ static HRESULT CreateFwRuleObject( __in LPCWSTR wzPort, __in int iProtocol, __in LPCWSTR wzDescription, + __in int iDirection, __out INetFwRule** ppNetFwRule ) { @@ -321,6 +326,12 @@ static HRESULT CreateFwRuleObject( ExitOnFailure(hr, "failed to set exception description '%ls'", bstrDescription); } + if (MSI_NULL_INTEGER != iDirection) + { + hr = pNetFwRule->put_Direction(static_cast (iDirection)); + ExitOnFailure(hr, "failed to set exception direction"); + } + *ppNetFwRule = pNetFwRule; pNetFwRule = NULL; @@ -429,7 +440,8 @@ static HRESULT AddApplicationException( __in BOOL fIgnoreFailures, __in LPCWSTR wzPort, __in int iProtocol, - __in LPCWSTR wzDescription + __in LPCWSTR wzDescription, + __in int iDirection ) { HRESULT hr = S_OK; @@ -456,7 +468,7 @@ static HRESULT AddApplicationException( hr = pNetFwRules->Item(bstrName, &pNetFwRule); if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr) { - hr = CreateFwRuleObject(bstrName, iProfile, wzRemoteAddresses, wzPort, iProtocol, wzDescription, &pNetFwRule); + hr = CreateFwRuleObject(bstrName, iProfile, wzRemoteAddresses, wzPort, iProtocol, wzDescription, iDirection, &pNetFwRule); ExitOnFailure(hr, "failed to create FwRule object"); // set edge traversal to true @@ -590,8 +602,9 @@ static HRESULT AddPortException( __in BOOL fIgnoreFailures, __in LPCWSTR wzPort, __in int iProtocol, - __in LPCWSTR wzDescription - ) + __in LPCWSTR wzDescription, + __in int iDirection +) { HRESULT hr = S_OK; BSTR bstrName = NULL; @@ -614,7 +627,7 @@ static HRESULT AddPortException( hr = pNetFwRules->Item(bstrName, &pNetFwRule); if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr) { - hr = CreateFwRuleObject(bstrName, iProfile, wzRemoteAddresses, wzPort, iProtocol, wzDescription, &pNetFwRule); + hr = CreateFwRuleObject(bstrName, iProfile, wzRemoteAddresses, wzPort, iProtocol, wzDescription, iDirection, &pNetFwRule); ExitOnFailure(hr, "failed to create FwRule object"); // enable it @@ -825,14 +838,15 @@ static HRESULT AddApplicationException( __in BOOL fIgnoreFailures, __in LPCWSTR wzPort, __in int iProtocol, - __in LPCWSTR wzDescription - ) + __in LPCWSTR wzDescription, + __in int iDirection +) { HRESULT hr = S_OK; if (fSupportProfiles) { - hr = AddApplicationException(wzFile, wzName, iProfile, wzRemoteAddresses, fIgnoreFailures, wzPort, iProtocol, wzDescription); + hr = AddApplicationException(wzFile, wzName, iProfile, wzRemoteAddresses, fIgnoreFailures, wzPort, iProtocol, wzDescription, iDirection); } else { @@ -860,14 +874,15 @@ static HRESULT AddPortException( __in BOOL fIgnoreFailures, __in LPCWSTR wzPort, __in int iProtocol, - __in LPCWSTR wzDescription - ) + __in LPCWSTR wzDescription, + __in int iDirection +) { HRESULT hr = S_OK; if (fSupportProfiles) { - hr = AddPortException(wzName, iProfile, wzRemoteAddresses, fIgnoreFailures, wzPort, iProtocol, wzDescription); + hr = AddPortException(wzName, iProfile, wzRemoteAddresses, fIgnoreFailures, wzPort, iProtocol, wzDescription, iDirection); } else { @@ -951,6 +966,7 @@ extern "C" UINT __stdcall ExecFirewallExceptions( LPWSTR pwzDescription = NULL; int iProtocol = 0; int iProfile = 0; + int iDirection = 0; // initialize hr = WcaInitialize(hInstall, "ExecFirewallExceptions"); @@ -1013,6 +1029,8 @@ extern "C" UINT __stdcall ExecFirewallExceptions( ExitOnFailure(hr, "failed to read protocol from custom action data"); hr = WcaReadStringFromCaData(&pwz, &pwzDescription); ExitOnFailure(hr, "failed to read protocol from custom action data"); + hr = WcaReadIntegerFromCaData(&pwz, &iDirection); + ExitOnFailure(hr, "failed to read direction from custom action data"); switch (iTarget) { @@ -1022,7 +1040,7 @@ extern "C" UINT __stdcall ExecFirewallExceptions( case WCA_TODO_INSTALL: case WCA_TODO_REINSTALL: WcaLog(LOGMSG_STANDARD, "Installing firewall exception2 %ls on port %ls, protocol %d", pwzName, pwzPort, iProtocol); - hr = AddPortException(fSupportProfiles, pwzName, iProfile, pwzRemoteAddresses, fIgnoreFailures, pwzPort, iProtocol, pwzDescription); + hr = AddPortException(fSupportProfiles, pwzName, iProfile, pwzRemoteAddresses, fIgnoreFailures, pwzPort, iProtocol, pwzDescription, iDirection); ExitOnFailure(hr, "failed to add/update port exception for name '%ls' on port %ls, protocol %d", pwzName, pwzPort, iProtocol); break; @@ -1040,7 +1058,7 @@ extern "C" UINT __stdcall ExecFirewallExceptions( case WCA_TODO_INSTALL: case WCA_TODO_REINSTALL: WcaLog(LOGMSG_STANDARD, "Installing firewall exception2 %ls (%ls)", pwzName, pwzFile); - hr = AddApplicationException(fSupportProfiles, pwzFile, pwzName, iProfile, pwzRemoteAddresses, fIgnoreFailures, pwzPort, iProtocol, pwzDescription); + hr = AddApplicationException(fSupportProfiles, pwzFile, pwzName, iProfile, pwzRemoteAddresses, fIgnoreFailures, pwzPort, iProtocol, pwzDescription, iDirection); ExitOnFailure(hr, "failed to add/update application exception for name '%ls', file '%ls'", pwzName, pwzFile); break; diff --git a/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs b/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs index 8f8ba44a..ceac4f26 100644 --- a/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs +++ b/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs @@ -25,7 +25,7 @@ namespace WixToolsetTest.Firewall "CustomAction:Wix4RollbackFirewallExceptionsUninstall_X86\t3329\tWix4FWCA_X86\tExecFirewallExceptions\t", "CustomAction:Wix4SchedFirewallExceptionsInstall_X86\t1\tWix4FWCA_X86\tSchedFirewallExceptionsInstall\t", "CustomAction:Wix4SchedFirewallExceptionsUninstall_X86\t1\tWix4FWCA_X86\tSchedFirewallExceptionsUninstall\t", - "WixFirewallException:ExampleFirewall\texample\t*\t42\t6\t\t0\t2147483647\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tAn example firewall", + "WixFirewallException:ExampleFirewall\texample\t*\t42\t6\t\t0\t2147483647\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tAn example firewall\t1", }, results); } @@ -44,7 +44,20 @@ namespace WixToolsetTest.Firewall "CustomAction:Wix4RollbackFirewallExceptionsUninstall_A64\t3329\tWix4FWCA_A64\tExecFirewallExceptions\t", "CustomAction:Wix4SchedFirewallExceptionsInstall_A64\t1\tWix4FWCA_A64\tSchedFirewallExceptionsInstall\t", "CustomAction:Wix4SchedFirewallExceptionsUninstall_A64\t1\tWix4FWCA_A64\tSchedFirewallExceptionsUninstall\t", - "WixFirewallException:ExampleFirewall\texample\t*\t42\t6\t\t0\t2147483647\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tAn example firewall", + "WixFirewallException:ExampleFirewall\texample\t*\t42\t6\t\t0\t2147483647\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tAn example firewall\t1", + }, results); + } + + [Fact] + public void CanBuildUsingOutboundFirewall() + { + var folder = TestData.Get(@"TestData\UsingOutboundFirewall"); + var build = new Builder(folder, typeof(FirewallExtensionFactory), new[] { folder }); + + var results = build.BuildAndQuery(Build, "WixFirewallException"); + Assert.Equal(new[] + { + "WixFirewallException:fexPv9RR1kBvP6gMgWyXMVQkVbopOA\texample\t*\t42\t6\t\t0\t2147483647\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tAn example outbound firewall\t2", }, results); } diff --git a/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.en-us.wxl b/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.en-us.wxl @@ -0,0 +1,11 @@ + + + + + + A newer version of [ProductName] is already installed. + MsiPackage + + diff --git a/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.wxs b/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.wxs new file mode 100644 index 00000000..68ff98fd --- /dev/null +++ b/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.wxs @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/PackageComponents.wxs b/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/PackageComponents.wxs new file mode 100644 index 00000000..f8c1e781 --- /dev/null +++ b/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/PackageComponents.wxs @@ -0,0 +1,14 @@ + + + + + + + + * + + + + + diff --git a/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/example.txt b/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/example.txt new file mode 100644 index 00000000..1b4ffe8a --- /dev/null +++ b/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/example.txt @@ -0,0 +1 @@ +This is example.txt. \ No newline at end of file diff --git a/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj b/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj index 7727a69b..d04368c1 100644 --- a/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj +++ b/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj @@ -16,6 +16,10 @@ + + + + diff --git a/src/wixext/FirewallCompiler.cs b/src/wixext/FirewallCompiler.cs index 1fa80f48..900af7aa 100644 --- a/src/wixext/FirewallCompiler.cs +++ b/src/wixext/FirewallCompiler.cs @@ -81,6 +81,7 @@ namespace WixToolset.Firewall string scope = null; string remoteAddresses = null; string description = null; + int? direction = null; foreach (var attrib in element.Attributes()) { @@ -177,6 +178,11 @@ namespace WixToolset.Firewall case "Description": description = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; + case "Outbound": + direction = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib) == YesNoType.Yes + ? FirewallConstants.NET_FW_RULE_DIR_OUT + : FirewallConstants.NET_FW_RULE_DIR_IN; + break; default: this.ParseHelper.UnexpectedAttribute(element, attrib); break; @@ -260,6 +266,7 @@ namespace WixToolset.Firewall Profile = profile ?? FirewallConstants.NET_FW_PROFILE2_ALL, ComponentRef = componentId, Description = description, + Direction = direction ?? FirewallConstants.NET_FW_RULE_DIR_IN, }); if (!String.IsNullOrEmpty(port)) diff --git a/src/wixext/FirewallConstants.cs b/src/wixext/FirewallConstants.cs index 16caa5b4..7bb12ba4 100644 --- a/src/wixext/FirewallConstants.cs +++ b/src/wixext/FirewallConstants.cs @@ -9,6 +9,8 @@ namespace WixToolset.Firewall static class FirewallConstants { // from icftypes.h + public const int NET_FW_RULE_DIR_IN = 1; + public const int NET_FW_RULE_DIR_OUT = 2; public const int NET_FW_IP_PROTOCOL_TCP = 6; public const int NET_FW_IP_PROTOCOL_UDP = 17; diff --git a/src/wixext/FirewallDecompiler.cs b/src/wixext/FirewallDecompiler.cs index b060f8e2..c9478de1 100644 --- a/src/wixext/FirewallDecompiler.cs +++ b/src/wixext/FirewallDecompiler.cs @@ -146,6 +146,19 @@ namespace WixToolset.Firewall fire.Description = (string)row[9]; } + if (!row.IsColumnEmpty(10)) + { + switch (Convert.ToInt32(row[10])) + { + case FirewallConstants.NET_FW_RULE_DIR_IN: + fire.Direction = Firewall.FirewallException.DirectionType.@in; + break; + case FirewallConstants.NET_FW_RULE_DIR_OUT: + fire.Direction = Firewall.FirewallException.DirectionType.@out; + break; + } + } + Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[8]); if (null != component) { diff --git a/src/wixext/FirewallTableDefinitions.cs b/src/wixext/FirewallTableDefinitions.cs index 4bae1ef0..068fe696 100644 --- a/src/wixext/FirewallTableDefinitions.cs +++ b/src/wixext/FirewallTableDefinitions.cs @@ -21,6 +21,7 @@ namespace WixToolset.Firewall new ColumnDefinition("Profile", ColumnType.Number, 4, primaryKey: false, nullable: false, ColumnCategory.Integer, minValue: 1, maxValue: 2147483647, description: "Profile (1=domain; 2=private; 4=public; 2147483647=all)."), new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key into the Component table referencing component that controls the firewall configuration.", modularizeType: ColumnModularizeType.Column), new ColumnDefinition("Description", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Description displayed in Windows Firewall manager for this firewall rule."), + new ColumnDefinition("Direction", ColumnType.Number, 1, primaryKey: false, nullable: true, ColumnCategory.Integer, minValue: 1, maxValue: 2, description: "Direction (1=in; 2=out)"), }, tupleIdIsPrimaryKey: true ); diff --git a/src/wixext/Tuples/WixFirewallExceptionTuple.cs b/src/wixext/Tuples/WixFirewallExceptionTuple.cs index d08b9e45..d34b8207 100644 --- a/src/wixext/Tuples/WixFirewallExceptionTuple.cs +++ b/src/wixext/Tuples/WixFirewallExceptionTuple.cs @@ -20,6 +20,7 @@ namespace WixToolset.Firewall new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Profile), IntermediateFieldType.Number), new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.ComponentRef), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Description), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Direction), IntermediateFieldType.Number), }, typeof(WixFirewallExceptionTuple)); } @@ -40,6 +41,7 @@ namespace WixToolset.Firewall.Tuples Profile, ComponentRef, Description, + Direction, } public class WixFirewallExceptionTuple : IntermediateTuple @@ -107,5 +109,11 @@ namespace WixToolset.Firewall.Tuples get => this.Fields[(int)WixFirewallExceptionTupleFields.Description].AsString(); set => this.Set((int)WixFirewallExceptionTupleFields.Description, value); } + + public int Direction + { + get => this.Fields[(int)WixFirewallExceptionTupleFields.Direction].AsNumber(); + set => this.Set((int)WixFirewallExceptionTupleFields.Direction, value); + } } } \ No newline at end of file diff --git a/src/wixext/firewall.xsd b/src/wixext/firewall.xsd index d64aafef..fec7e37a 100644 --- a/src/wixext/firewall.xsd +++ b/src/wixext/firewall.xsd @@ -141,7 +141,7 @@ - If "yes," failures to register this firewall exception will be silently + If "yes", failures to register this firewall exception will be silently ignored. If "no" (the default), failures will cause rollback. @@ -170,6 +170,14 @@ + + + + + If "yes", registers an outbound firewall rule. + + + diff --git a/src/wixlib/firewall.wixproj b/src/wixlib/firewall.wixproj index cb273a38..c1daa05a 100644 --- a/src/wixlib/firewall.wixproj +++ b/src/wixlib/firewall.wixproj @@ -1,7 +1,7 @@ - + {1acffefd-505a-41a5-acbf-a02b7b473aa2} @@ -73,7 +73,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/src/wixlib/packages.config b/src/wixlib/packages.config index 20afb58c..8db41667 100644 --- a/src/wixlib/packages.config +++ b/src/wixlib/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file -- cgit v1.2.3-55-g6feb From edf4d3aa082d32223f668aff3ddad67d5d7c5bde Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 30 May 2020 15:22:13 -0700 Subject: Add NCrunch configuration --- .../WixToolsetTest.Firewall.v3.ncrunchproject | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.v3.ncrunchproject (limited to 'src') diff --git a/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.v3.ncrunchproject b/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.v3.ncrunchproject new file mode 100644 index 00000000..7b5b2139 --- /dev/null +++ b/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file -- cgit v1.2.3-55-g6feb From 96e0350bc4fc4ca5a7ae61145599f90b7fbf8d9b Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 27 Jun 2020 13:44:44 -0700 Subject: The Great Tuple to Symbol Rename (tm) --- src/wixext/FirewallCompiler.cs | 16 ++--- src/wixext/FirewallExtensionData.cs | 10 ++-- src/wixext/FirewallTableDefinitions.cs | 4 +- src/wixext/Tuples/FirewallTupleDefinitions.cs | 14 ++--- src/wixext/Tuples/WixFirewallExceptionTuple.cs | 82 +++++++++++++------------- 5 files changed, 63 insertions(+), 63 deletions(-) (limited to 'src') diff --git a/src/wixext/FirewallCompiler.cs b/src/wixext/FirewallCompiler.cs index 900af7aa..aefc7f2c 100644 --- a/src/wixext/FirewallCompiler.cs +++ b/src/wixext/FirewallCompiler.cs @@ -8,7 +8,7 @@ namespace WixToolset.Firewall using WixToolset.Data; using WixToolset.Extensibility; using WixToolset.Extensibility.Data; - using WixToolset.Firewall.Tuples; + using WixToolset.Firewall.Symbols; /// /// The compiler for the WiX Toolset Firewall Extension. @@ -259,7 +259,7 @@ namespace WixToolset.Firewall fileId = file; } - var tuple = section.AddTuple(new WixFirewallExceptionTuple(sourceLineNumbers, id) + var symbol = section.AddSymbol(new WixFirewallExceptionSymbol(sourceLineNumbers, id) { Name = name, RemoteAddresses = remoteAddresses, @@ -271,7 +271,7 @@ namespace WixToolset.Firewall if (!String.IsNullOrEmpty(port)) { - tuple.Port = port; + symbol.Port = port; if (!protocol.HasValue) { @@ -282,22 +282,22 @@ namespace WixToolset.Firewall if (protocol.HasValue) { - tuple.Protocol = protocol.Value; + symbol.Protocol = protocol.Value; } if (!String.IsNullOrEmpty(fileId)) { - tuple.Program = $"[#{fileId}]"; - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.File, fileId); + symbol.Program = $"[#{fileId}]"; + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.File, fileId); } else if (!String.IsNullOrEmpty(program)) { - tuple.Program = program; + symbol.Program = program; } if (CompilerConstants.IntegerNotSet != attributes) { - tuple.Attributes = attributes; + symbol.Attributes = attributes; } this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "SchedFirewallExceptionsInstall", this.Context.Platform, CustomActionPlatforms.ARM | CustomActionPlatforms.ARM64 | CustomActionPlatforms.X64 | CustomActionPlatforms.X86); diff --git a/src/wixext/FirewallExtensionData.cs b/src/wixext/FirewallExtensionData.cs index 44cae0d6..7481d993 100644 --- a/src/wixext/FirewallExtensionData.cs +++ b/src/wixext/FirewallExtensionData.cs @@ -9,15 +9,15 @@ namespace WixToolset.Firewall { public override string DefaultCulture => "en-US"; - public override bool TryGetTupleDefinitionByName(string name, out IntermediateTupleDefinition tupleDefinition) + public override bool TryGetSymbolDefinitionByName(string name, out IntermediateSymbolDefinition symbolDefinition) { - tupleDefinition = FirewallTupleDefinitions.ByName(name); - return tupleDefinition != null; + symbolDefinition = FirewallSymbolDefinitions.ByName(name); + return symbolDefinition != null; } - public override Intermediate GetLibrary(ITupleDefinitionCreator tupleDefinitions) + public override Intermediate GetLibrary(ISymbolDefinitionCreator symbolDefinitions) { - return Intermediate.Load(typeof(FirewallExtensionData).Assembly, "WixToolset.Firewall.firewall.wixlib", tupleDefinitions); + return Intermediate.Load(typeof(FirewallExtensionData).Assembly, "WixToolset.Firewall.firewall.wixlib", symbolDefinitions); } } } diff --git a/src/wixext/FirewallTableDefinitions.cs b/src/wixext/FirewallTableDefinitions.cs index 068fe696..eae897d5 100644 --- a/src/wixext/FirewallTableDefinitions.cs +++ b/src/wixext/FirewallTableDefinitions.cs @@ -8,7 +8,7 @@ namespace WixToolset.Firewall { public static readonly TableDefinition WixFirewallException = new TableDefinition( "WixFirewallException", - FirewallTupleDefinitions.WixFirewallException, + FirewallSymbolDefinitions.WixFirewallException, new[] { new ColumnDefinition("WixFirewallException", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "The primary key, a non-localized token.", modularizeType: ColumnModularizeType.Column), @@ -23,7 +23,7 @@ namespace WixToolset.Firewall new ColumnDefinition("Description", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Description displayed in Windows Firewall manager for this firewall rule."), new ColumnDefinition("Direction", ColumnType.Number, 1, primaryKey: false, nullable: true, ColumnCategory.Integer, minValue: 1, maxValue: 2, description: "Direction (1=in; 2=out)"), }, - tupleIdIsPrimaryKey: true + symbolIdIsPrimaryKey: true ); public static readonly TableDefinition[] All = new[] diff --git a/src/wixext/Tuples/FirewallTupleDefinitions.cs b/src/wixext/Tuples/FirewallTupleDefinitions.cs index 2710380e..887893c7 100644 --- a/src/wixext/Tuples/FirewallTupleDefinitions.cs +++ b/src/wixext/Tuples/FirewallTupleDefinitions.cs @@ -5,18 +5,18 @@ namespace WixToolset.Firewall using System; using WixToolset.Data; - public enum FirewallTupleDefinitionType + public enum FirewallSymbolDefinitionType { WixFirewallException, } - public static partial class FirewallTupleDefinitions + public static partial class FirewallSymbolDefinitions { public static readonly Version Version = new Version("4.0.0"); - public static IntermediateTupleDefinition ByName(string name) + public static IntermediateSymbolDefinition ByName(string name) { - if (!Enum.TryParse(name, out FirewallTupleDefinitionType type)) + if (!Enum.TryParse(name, out FirewallSymbolDefinitionType type)) { return null; } @@ -24,12 +24,12 @@ namespace WixToolset.Firewall return ByType(type); } - public static IntermediateTupleDefinition ByType(FirewallTupleDefinitionType type) + public static IntermediateSymbolDefinition ByType(FirewallSymbolDefinitionType type) { switch (type) { - case FirewallTupleDefinitionType.WixFirewallException: - return FirewallTupleDefinitions.WixFirewallException; + case FirewallSymbolDefinitionType.WixFirewallException: + return FirewallSymbolDefinitions.WixFirewallException; default: throw new ArgumentOutOfRangeException(nameof(type)); diff --git a/src/wixext/Tuples/WixFirewallExceptionTuple.cs b/src/wixext/Tuples/WixFirewallExceptionTuple.cs index d34b8207..620de969 100644 --- a/src/wixext/Tuples/WixFirewallExceptionTuple.cs +++ b/src/wixext/Tuples/WixFirewallExceptionTuple.cs @@ -3,34 +3,34 @@ namespace WixToolset.Firewall { using WixToolset.Data; - using WixToolset.Firewall.Tuples; + using WixToolset.Firewall.Symbols; - public static partial class FirewallTupleDefinitions + public static partial class FirewallSymbolDefinitions { - public static readonly IntermediateTupleDefinition WixFirewallException = new IntermediateTupleDefinition( - FirewallTupleDefinitionType.WixFirewallException.ToString(), + public static readonly IntermediateSymbolDefinition WixFirewallException = new IntermediateSymbolDefinition( + FirewallSymbolDefinitionType.WixFirewallException.ToString(), new[] { - new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Name), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.RemoteAddresses), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Port), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Protocol), IntermediateFieldType.Number), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Program), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Attributes), IntermediateFieldType.Number), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Profile), IntermediateFieldType.Number), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.ComponentRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Description), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionTupleFields.Direction), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Name), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.RemoteAddresses), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Port), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Protocol), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Program), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Attributes), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Profile), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.ComponentRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Description), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Direction), IntermediateFieldType.Number), }, - typeof(WixFirewallExceptionTuple)); + typeof(WixFirewallExceptionSymbol)); } } -namespace WixToolset.Firewall.Tuples +namespace WixToolset.Firewall.Symbols { using WixToolset.Data; - public enum WixFirewallExceptionTupleFields + public enum WixFirewallExceptionSymbolFields { Name, RemoteAddresses, @@ -44,76 +44,76 @@ namespace WixToolset.Firewall.Tuples Direction, } - public class WixFirewallExceptionTuple : IntermediateTuple + public class WixFirewallExceptionSymbol : IntermediateSymbol { - public WixFirewallExceptionTuple() : base(FirewallTupleDefinitions.WixFirewallException, null, null) + public WixFirewallExceptionSymbol() : base(FirewallSymbolDefinitions.WixFirewallException, null, null) { } - public WixFirewallExceptionTuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base(FirewallTupleDefinitions.WixFirewallException, sourceLineNumber, id) + public WixFirewallExceptionSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(FirewallSymbolDefinitions.WixFirewallException, sourceLineNumber, id) { } - public IntermediateField this[WixFirewallExceptionTupleFields index] => this.Fields[(int)index]; + public IntermediateField this[WixFirewallExceptionSymbolFields index] => this.Fields[(int)index]; public string Name { - get => this.Fields[(int)WixFirewallExceptionTupleFields.Name].AsString(); - set => this.Set((int)WixFirewallExceptionTupleFields.Name, value); + get => this.Fields[(int)WixFirewallExceptionSymbolFields.Name].AsString(); + set => this.Set((int)WixFirewallExceptionSymbolFields.Name, value); } public string RemoteAddresses { - get => this.Fields[(int)WixFirewallExceptionTupleFields.RemoteAddresses].AsString(); - set => this.Set((int)WixFirewallExceptionTupleFields.RemoteAddresses, value); + get => this.Fields[(int)WixFirewallExceptionSymbolFields.RemoteAddresses].AsString(); + set => this.Set((int)WixFirewallExceptionSymbolFields.RemoteAddresses, value); } public string Port { - get => this.Fields[(int)WixFirewallExceptionTupleFields.Port].AsString(); - set => this.Set((int)WixFirewallExceptionTupleFields.Port, value); + get => this.Fields[(int)WixFirewallExceptionSymbolFields.Port].AsString(); + set => this.Set((int)WixFirewallExceptionSymbolFields.Port, value); } public int? Protocol { - get => this.Fields[(int)WixFirewallExceptionTupleFields.Protocol].AsNullableNumber(); - set => this.Set((int)WixFirewallExceptionTupleFields.Protocol, value); + get => this.Fields[(int)WixFirewallExceptionSymbolFields.Protocol].AsNullableNumber(); + set => this.Set((int)WixFirewallExceptionSymbolFields.Protocol, value); } public string Program { - get => this.Fields[(int)WixFirewallExceptionTupleFields.Program].AsString(); - set => this.Set((int)WixFirewallExceptionTupleFields.Program, value); + get => this.Fields[(int)WixFirewallExceptionSymbolFields.Program].AsString(); + set => this.Set((int)WixFirewallExceptionSymbolFields.Program, value); } public int Attributes { - get => this.Fields[(int)WixFirewallExceptionTupleFields.Attributes].AsNumber(); - set => this.Set((int)WixFirewallExceptionTupleFields.Attributes, value); + get => this.Fields[(int)WixFirewallExceptionSymbolFields.Attributes].AsNumber(); + set => this.Set((int)WixFirewallExceptionSymbolFields.Attributes, value); } public int Profile { - get => this.Fields[(int)WixFirewallExceptionTupleFields.Profile].AsNumber(); - set => this.Set((int)WixFirewallExceptionTupleFields.Profile, value); + get => this.Fields[(int)WixFirewallExceptionSymbolFields.Profile].AsNumber(); + set => this.Set((int)WixFirewallExceptionSymbolFields.Profile, value); } public string ComponentRef { - get => this.Fields[(int)WixFirewallExceptionTupleFields.ComponentRef].AsString(); - set => this.Set((int)WixFirewallExceptionTupleFields.ComponentRef, value); + get => this.Fields[(int)WixFirewallExceptionSymbolFields.ComponentRef].AsString(); + set => this.Set((int)WixFirewallExceptionSymbolFields.ComponentRef, value); } public string Description { - get => this.Fields[(int)WixFirewallExceptionTupleFields.Description].AsString(); - set => this.Set((int)WixFirewallExceptionTupleFields.Description, value); + get => this.Fields[(int)WixFirewallExceptionSymbolFields.Description].AsString(); + set => this.Set((int)WixFirewallExceptionSymbolFields.Description, value); } public int Direction { - get => this.Fields[(int)WixFirewallExceptionTupleFields.Direction].AsNumber(); - set => this.Set((int)WixFirewallExceptionTupleFields.Direction, value); + get => this.Fields[(int)WixFirewallExceptionSymbolFields.Direction].AsNumber(); + set => this.Set((int)WixFirewallExceptionSymbolFields.Direction, value); } } } \ No newline at end of file -- cgit v1.2.3-55-g6feb From f456ade18faf212b6b48719c4801a8eecc55a890 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 27 Jun 2020 13:45:21 -0700 Subject: The Great Tuple to Symbol File Rename (tm) --- src/wixext/Symbols/FirewallSymbolDefinitions.cs | 39 ++++++++ src/wixext/Symbols/WixFirewallExceptionSymbol.cs | 119 +++++++++++++++++++++++ src/wixext/Tuples/FirewallTupleDefinitions.cs | 39 -------- src/wixext/Tuples/WixFirewallExceptionTuple.cs | 119 ----------------------- 4 files changed, 158 insertions(+), 158 deletions(-) create mode 100644 src/wixext/Symbols/FirewallSymbolDefinitions.cs create mode 100644 src/wixext/Symbols/WixFirewallExceptionSymbol.cs delete mode 100644 src/wixext/Tuples/FirewallTupleDefinitions.cs delete mode 100644 src/wixext/Tuples/WixFirewallExceptionTuple.cs (limited to 'src') diff --git a/src/wixext/Symbols/FirewallSymbolDefinitions.cs b/src/wixext/Symbols/FirewallSymbolDefinitions.cs new file mode 100644 index 00000000..887893c7 --- /dev/null +++ b/src/wixext/Symbols/FirewallSymbolDefinitions.cs @@ -0,0 +1,39 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Firewall +{ + using System; + using WixToolset.Data; + + public enum FirewallSymbolDefinitionType + { + WixFirewallException, + } + + public static partial class FirewallSymbolDefinitions + { + public static readonly Version Version = new Version("4.0.0"); + + public static IntermediateSymbolDefinition ByName(string name) + { + if (!Enum.TryParse(name, out FirewallSymbolDefinitionType type)) + { + return null; + } + + return ByType(type); + } + + public static IntermediateSymbolDefinition ByType(FirewallSymbolDefinitionType type) + { + switch (type) + { + case FirewallSymbolDefinitionType.WixFirewallException: + return FirewallSymbolDefinitions.WixFirewallException; + + default: + throw new ArgumentOutOfRangeException(nameof(type)); + } + } + } +} diff --git a/src/wixext/Symbols/WixFirewallExceptionSymbol.cs b/src/wixext/Symbols/WixFirewallExceptionSymbol.cs new file mode 100644 index 00000000..620de969 --- /dev/null +++ b/src/wixext/Symbols/WixFirewallExceptionSymbol.cs @@ -0,0 +1,119 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Firewall +{ + using WixToolset.Data; + using WixToolset.Firewall.Symbols; + + public static partial class FirewallSymbolDefinitions + { + public static readonly IntermediateSymbolDefinition WixFirewallException = new IntermediateSymbolDefinition( + FirewallSymbolDefinitionType.WixFirewallException.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Name), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.RemoteAddresses), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Port), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Protocol), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Program), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Attributes), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Profile), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.ComponentRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Description), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Direction), IntermediateFieldType.Number), + }, + typeof(WixFirewallExceptionSymbol)); + } +} + +namespace WixToolset.Firewall.Symbols +{ + using WixToolset.Data; + + public enum WixFirewallExceptionSymbolFields + { + Name, + RemoteAddresses, + Port, + Protocol, + Program, + Attributes, + Profile, + ComponentRef, + Description, + Direction, + } + + public class WixFirewallExceptionSymbol : IntermediateSymbol + { + public WixFirewallExceptionSymbol() : base(FirewallSymbolDefinitions.WixFirewallException, null, null) + { + } + + public WixFirewallExceptionSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(FirewallSymbolDefinitions.WixFirewallException, sourceLineNumber, id) + { + } + + public IntermediateField this[WixFirewallExceptionSymbolFields index] => this.Fields[(int)index]; + + public string Name + { + get => this.Fields[(int)WixFirewallExceptionSymbolFields.Name].AsString(); + set => this.Set((int)WixFirewallExceptionSymbolFields.Name, value); + } + + public string RemoteAddresses + { + get => this.Fields[(int)WixFirewallExceptionSymbolFields.RemoteAddresses].AsString(); + set => this.Set((int)WixFirewallExceptionSymbolFields.RemoteAddresses, value); + } + + public string Port + { + get => this.Fields[(int)WixFirewallExceptionSymbolFields.Port].AsString(); + set => this.Set((int)WixFirewallExceptionSymbolFields.Port, value); + } + + public int? Protocol + { + get => this.Fields[(int)WixFirewallExceptionSymbolFields.Protocol].AsNullableNumber(); + set => this.Set((int)WixFirewallExceptionSymbolFields.Protocol, value); + } + + public string Program + { + get => this.Fields[(int)WixFirewallExceptionSymbolFields.Program].AsString(); + set => this.Set((int)WixFirewallExceptionSymbolFields.Program, value); + } + + public int Attributes + { + get => this.Fields[(int)WixFirewallExceptionSymbolFields.Attributes].AsNumber(); + set => this.Set((int)WixFirewallExceptionSymbolFields.Attributes, value); + } + + public int Profile + { + get => this.Fields[(int)WixFirewallExceptionSymbolFields.Profile].AsNumber(); + set => this.Set((int)WixFirewallExceptionSymbolFields.Profile, value); + } + + public string ComponentRef + { + get => this.Fields[(int)WixFirewallExceptionSymbolFields.ComponentRef].AsString(); + set => this.Set((int)WixFirewallExceptionSymbolFields.ComponentRef, value); + } + + public string Description + { + get => this.Fields[(int)WixFirewallExceptionSymbolFields.Description].AsString(); + set => this.Set((int)WixFirewallExceptionSymbolFields.Description, value); + } + + public int Direction + { + get => this.Fields[(int)WixFirewallExceptionSymbolFields.Direction].AsNumber(); + set => this.Set((int)WixFirewallExceptionSymbolFields.Direction, value); + } + } +} \ No newline at end of file diff --git a/src/wixext/Tuples/FirewallTupleDefinitions.cs b/src/wixext/Tuples/FirewallTupleDefinitions.cs deleted file mode 100644 index 887893c7..00000000 --- a/src/wixext/Tuples/FirewallTupleDefinitions.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Firewall -{ - using System; - using WixToolset.Data; - - public enum FirewallSymbolDefinitionType - { - WixFirewallException, - } - - public static partial class FirewallSymbolDefinitions - { - public static readonly Version Version = new Version("4.0.0"); - - public static IntermediateSymbolDefinition ByName(string name) - { - if (!Enum.TryParse(name, out FirewallSymbolDefinitionType type)) - { - return null; - } - - return ByType(type); - } - - public static IntermediateSymbolDefinition ByType(FirewallSymbolDefinitionType type) - { - switch (type) - { - case FirewallSymbolDefinitionType.WixFirewallException: - return FirewallSymbolDefinitions.WixFirewallException; - - default: - throw new ArgumentOutOfRangeException(nameof(type)); - } - } - } -} diff --git a/src/wixext/Tuples/WixFirewallExceptionTuple.cs b/src/wixext/Tuples/WixFirewallExceptionTuple.cs deleted file mode 100644 index 620de969..00000000 --- a/src/wixext/Tuples/WixFirewallExceptionTuple.cs +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Firewall -{ - using WixToolset.Data; - using WixToolset.Firewall.Symbols; - - public static partial class FirewallSymbolDefinitions - { - public static readonly IntermediateSymbolDefinition WixFirewallException = new IntermediateSymbolDefinition( - FirewallSymbolDefinitionType.WixFirewallException.ToString(), - new[] - { - new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Name), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.RemoteAddresses), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Port), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Protocol), IntermediateFieldType.Number), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Program), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Attributes), IntermediateFieldType.Number), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Profile), IntermediateFieldType.Number), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.ComponentRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Description), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Direction), IntermediateFieldType.Number), - }, - typeof(WixFirewallExceptionSymbol)); - } -} - -namespace WixToolset.Firewall.Symbols -{ - using WixToolset.Data; - - public enum WixFirewallExceptionSymbolFields - { - Name, - RemoteAddresses, - Port, - Protocol, - Program, - Attributes, - Profile, - ComponentRef, - Description, - Direction, - } - - public class WixFirewallExceptionSymbol : IntermediateSymbol - { - public WixFirewallExceptionSymbol() : base(FirewallSymbolDefinitions.WixFirewallException, null, null) - { - } - - public WixFirewallExceptionSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(FirewallSymbolDefinitions.WixFirewallException, sourceLineNumber, id) - { - } - - public IntermediateField this[WixFirewallExceptionSymbolFields index] => this.Fields[(int)index]; - - public string Name - { - get => this.Fields[(int)WixFirewallExceptionSymbolFields.Name].AsString(); - set => this.Set((int)WixFirewallExceptionSymbolFields.Name, value); - } - - public string RemoteAddresses - { - get => this.Fields[(int)WixFirewallExceptionSymbolFields.RemoteAddresses].AsString(); - set => this.Set((int)WixFirewallExceptionSymbolFields.RemoteAddresses, value); - } - - public string Port - { - get => this.Fields[(int)WixFirewallExceptionSymbolFields.Port].AsString(); - set => this.Set((int)WixFirewallExceptionSymbolFields.Port, value); - } - - public int? Protocol - { - get => this.Fields[(int)WixFirewallExceptionSymbolFields.Protocol].AsNullableNumber(); - set => this.Set((int)WixFirewallExceptionSymbolFields.Protocol, value); - } - - public string Program - { - get => this.Fields[(int)WixFirewallExceptionSymbolFields.Program].AsString(); - set => this.Set((int)WixFirewallExceptionSymbolFields.Program, value); - } - - public int Attributes - { - get => this.Fields[(int)WixFirewallExceptionSymbolFields.Attributes].AsNumber(); - set => this.Set((int)WixFirewallExceptionSymbolFields.Attributes, value); - } - - public int Profile - { - get => this.Fields[(int)WixFirewallExceptionSymbolFields.Profile].AsNumber(); - set => this.Set((int)WixFirewallExceptionSymbolFields.Profile, value); - } - - public string ComponentRef - { - get => this.Fields[(int)WixFirewallExceptionSymbolFields.ComponentRef].AsString(); - set => this.Set((int)WixFirewallExceptionSymbolFields.ComponentRef, value); - } - - public string Description - { - get => this.Fields[(int)WixFirewallExceptionSymbolFields.Description].AsString(); - set => this.Set((int)WixFirewallExceptionSymbolFields.Description, value); - } - - public int Direction - { - get => this.Fields[(int)WixFirewallExceptionSymbolFields.Direction].AsNumber(); - set => this.Set((int)WixFirewallExceptionSymbolFields.Direction, value); - } - } -} \ No newline at end of file -- cgit v1.2.3-55-g6feb From 5b85ba2b9823f4b6db4f5c4bff96a27cd41d39f8 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 27 Jun 2020 13:45:35 -0700 Subject: Build wixlib with WixToolset.Sdk --- global.json | 5 +++ src/FindLocalWix.props | 8 ----- src/wixlib/firewall.wixproj | 76 ++++++--------------------------------------- src/wixlib/packages.config | 5 --- 4 files changed, 14 insertions(+), 80 deletions(-) create mode 100644 global.json delete mode 100644 src/FindLocalWix.props delete mode 100644 src/wixlib/packages.config (limited to 'src') diff --git a/global.json b/global.json new file mode 100644 index 00000000..7a995d0a --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "msbuild-sdks": { + "WixToolset.Sdk": "4.0.0-build-0143" + } +} diff --git a/src/FindLocalWix.props b/src/FindLocalWix.props deleted file mode 100644 index 1666e4fe..00000000 --- a/src/FindLocalWix.props +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - $(MSBuildThisFileDirectory)..\..\Tools\build\Debug\net461\wix.targets - - diff --git a/src/wixlib/firewall.wixproj b/src/wixlib/firewall.wixproj index c1daa05a..7e92bf1a 100644 --- a/src/wixlib/firewall.wixproj +++ b/src/wixlib/firewall.wixproj @@ -1,79 +1,21 @@ - - - - + + - {1acffefd-505a-41a5-acbf-a02b7b473aa2} - firewall Library true - true en-us - - - - - - - - - - - - - x86 - - - x64 - - - arm - - - arm64 - + + + + - + - - - fwca - {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981} - Platform=ARM - - - fwca - {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981} - Platform=ARM64 - - - fwca - {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981} - Platform=x86 - - - fwca - {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981} - Platform=x64 - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - \ No newline at end of file + + diff --git a/src/wixlib/packages.config b/src/wixlib/packages.config deleted file mode 100644 index 8db41667..00000000 --- a/src/wixlib/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file -- cgit v1.2.3-55-g6feb From b38e2bfb0fe419155df164e2bcefbbe34bad6a70 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 27 Jun 2020 13:46:23 -0700 Subject: Update to latest dutil and wcautil --- src/ca/fwca.vcxproj | 8 ++++---- src/ca/packages.config | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ca/fwca.vcxproj b/src/ca/fwca.vcxproj index c2addf82..f35e7177 100644 --- a/src/ca/fwca.vcxproj +++ b/src/ca/fwca.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -84,7 +84,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + diff --git a/src/ca/packages.config b/src/ca/packages.config index 97a06c72..e3dc0e43 100644 --- a/src/ca/packages.config +++ b/src/ca/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file -- cgit v1.2.3-55-g6feb From 8181317ba1b9f718b6e54ce13cba04351e464c01 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 27 Jun 2020 14:06:52 -0700 Subject: Remove use of RemoteAddress inner text --- .../TestData/UsingFirewall/PackageComponents.wxs | 2 +- .../UsingOutboundFirewall/PackageComponents.wxs | 2 +- src/wixext/FirewallCompiler.cs | 11 ++-- src/wixext/FirewallErrors.cs | 6 --- src/wixext/firewall.xsd | 58 +++++++++++----------- 5 files changed, 38 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs b/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs index 910cca2d..53e75427 100644 --- a/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs +++ b/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs @@ -6,7 +6,7 @@ - * + diff --git a/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/PackageComponents.wxs b/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/PackageComponents.wxs index f8c1e781..8084706e 100644 --- a/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/PackageComponents.wxs +++ b/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/PackageComponents.wxs @@ -6,7 +6,7 @@ - * + diff --git a/src/wixext/FirewallCompiler.cs b/src/wixext/FirewallCompiler.cs index aefc7f2c..e3cf201b 100644 --- a/src/wixext/FirewallCompiler.cs +++ b/src/wixext/FirewallCompiler.cs @@ -312,13 +312,19 @@ namespace WixToolset.Firewall private void ParseRemoteAddressElement(Intermediate intermediate, IntermediateSection section, XElement element, ref string remoteAddresses) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + string address = null; // no attributes foreach (var attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { - this.ParseHelper.UnexpectedAttribute(element, attrib); + switch (attrib.Name.LocalName) + { + case "Value": + address = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + } } else { @@ -328,10 +334,9 @@ namespace WixToolset.Firewall this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); - var address = this.ParseHelper.GetTrimmedInnerText(element); if (String.IsNullOrEmpty(address)) { - this.Messaging.Write(FirewallErrors.IllegalEmptyRemoteAddress(sourceLineNumbers)); + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Value")); } else { diff --git a/src/wixext/FirewallErrors.cs b/src/wixext/FirewallErrors.cs index 3fff8c8d..b2dac782 100644 --- a/src/wixext/FirewallErrors.cs +++ b/src/wixext/FirewallErrors.cs @@ -12,11 +12,6 @@ namespace WixToolset.Firewall return Message(sourceLineNumbers, Ids.IllegalRemoteAddressWithScopeAttribute, "The RemoteAddress element cannot be specified because its parent FirewallException already specified the Scope attribute. To use RemoteAddress elements, omit the Scope attribute."); } - public static Message IllegalEmptyRemoteAddress(SourceLineNumber sourceLineNumbers) - { - return Message(sourceLineNumbers, Ids.IllegalEmptyRemoteAddress, "The RemoteAddress element's inner text cannot be an empty string or completely whitespace."); - } - public static Message NoExceptionSpecified(SourceLineNumber sourceLineNumbers) { return Message(sourceLineNumbers, Ids.NoExceptionSpecified, "The FirewallException element doesn't identify the target of the firewall exception. To create an application exception, nest the FirewallException element under a File element or provide a value for the File or Program attributes. To create a port exception, provide a value for the Port attribute."); @@ -35,7 +30,6 @@ namespace WixToolset.Firewall public enum Ids { IllegalRemoteAddressWithScopeAttribute = 6401, - IllegalEmptyRemoteAddress = 6402, NoExceptionSpecified = 6403, } } diff --git a/src/wixext/firewall.xsd b/src/wixext/firewall.xsd index fec7e37a..20ad065f 100644 --- a/src/wixext/firewall.xsd +++ b/src/wixext/firewall.xsd @@ -33,7 +33,7 @@ - Explicitly-listed remote addresses that this exception allows through the + Explicitly-listed remote addresses that this exception allows through the firewall. @@ -51,7 +51,7 @@ - Name of this firewall exception, visible to the user in the firewall + Name of this firewall exception, visible to the user in the firewall control panel. @@ -63,7 +63,7 @@ The scope of this firewall exception, which indicates whether incoming connections can come from any computer including those on the Internet or only those on the local network subnet. To more precisely specify - allowed remote address, specify a custom scope using RemoteAddress + allowed remote address, specify a custom scope using RemoteAddress child elements. @@ -78,10 +78,10 @@ - Port to allow through the firewall for this exception. + Port to allow through the firewall for this exception. - If you use Port and also File or Program in the same - FirewallException element, the exception will fail to install on + If you use Port and also File or Program in the same + FirewallException element, the exception will fail to install on Windows XP and Windows Server 2003. IgnoreFailure="yes" can be used to ignore the resulting failure, but the exception will not be added. @@ -91,11 +91,11 @@ - IP protocol used for this firewall exception. If Port is defined, - "tcp" is assumed if the protocol is not specified. + IP protocol used for this firewall exception. If Port is defined, + "tcp" is assumed if the protocol is not specified. - If you use Protocol and also File or Program in the same - FirewallException element, the exception will fail to install on + If you use Protocol and also File or Program in the same + FirewallException element, the exception will fail to install on Windows XP and Windows Server 2003. IgnoreFailure="yes" can be used to ignore the resulting failure, but the exception will not be added. @@ -111,11 +111,11 @@ - Identifier of a file to be granted access to all incoming ports and + Identifier of a file to be granted access to all incoming ports and protocols. If you use File, you cannot also use Program. - If you use File and also Port or Protocol in the same - FirewallException element, the exception will fail to install on + If you use File and also Port or Protocol in the same + FirewallException element, the exception will fail to install on Windows XP and Windows Server 2003. IgnoreFailure="yes" can be used to ignore the resulting failure, but the exception will not be added. @@ -125,13 +125,13 @@ - Path to a target program to be granted access to all incoming ports and - protocols. Note that this is a formatted field, so you can use [#fileId] - syntax to refer to a file being installed. If you use Program, you cannot + Path to a target program to be granted access to all incoming ports and + protocols. Note that this is a formatted field, so you can use [#fileId] + syntax to refer to a file being installed. If you use Program, you cannot also use File. - If you use Program and also Port or Protocol in the same - FirewallException element, the exception will fail to install on + If you use Program and also Port or Protocol in the same + FirewallException element, the exception will fail to install on Windows XP and Windows Server 2003. IgnoreFailure="yes" can be used to ignore the resulting failure, but the exception will not be added. @@ -141,7 +141,7 @@ - If "yes", failures to register this firewall exception will be silently + If "yes", failures to register this firewall exception will be silently ignored. If "no" (the default), failures will cause rollback. @@ -165,7 +165,7 @@ - Description for this firewall rule displayed in Windows Firewall manager in + Description for this firewall rule displayed in Windows Firewall manager in Windows Vista and later. @@ -184,26 +184,24 @@ - A remote address to which the port or program can listen. Address formats vary + A remote address to which the port or program can listen. Address formats vary based on the version of Windows and Windows Firewall the program is being installed on. For Windows XP SP2 and Windows Server 2003 SP1, see RemoteAddresses Property. For Windows Vista and Windows Server 2008, see - + RemoteAddresses Property. - - - - + + + A remote address. - - - - + + + -- cgit v1.2.3-55-g6feb From e6510bc49ebe47d37790a1930587f6405249def7 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Sat, 4 Jul 2020 18:36:13 -0400 Subject: Fix deferred custom action invocations. --- src/ca/caDecor.h | 13 +++++++++++++ src/ca/firewall.cpp | 8 ++++---- src/ca/precomp.h | 2 ++ 3 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 src/ca/caDecor.h (limited to 'src') diff --git a/src/ca/caDecor.h b/src/ca/caDecor.h new file mode 100644 index 00000000..da274650 --- /dev/null +++ b/src/ca/caDecor.h @@ -0,0 +1,13 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +#if defined(_M_ARM64) +#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_A64" +#elif defined(_M_AMD64) +#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_X64" +#elif defined(_M_ARM) +#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_ARM" +#else +#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_X86" +#endif diff --git a/src/ca/firewall.cpp b/src/ca/firewall.cpp index bf40ce77..038f4ea5 100644 --- a/src/ca/firewall.cpp +++ b/src/ca/firewall.cpp @@ -150,16 +150,16 @@ static UINT SchedFirewallExceptions( if (WCA_TODO_INSTALL == todoSched) { - hr = WcaDoDeferredAction(L"WixRollbackFirewallExceptionsInstall", pwzCustomActionData, cFirewallExceptions * COST_FIREWALL_EXCEPTION); + hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"RollbackFirewallExceptionsInstall"), pwzCustomActionData, cFirewallExceptions * COST_FIREWALL_EXCEPTION); ExitOnFailure(hr, "failed to schedule firewall install exceptions rollback"); - hr = WcaDoDeferredAction(L"WixExecFirewallExceptionsInstall", pwzCustomActionData, cFirewallExceptions * COST_FIREWALL_EXCEPTION); + hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"ExecFirewallExceptionsInstall"), pwzCustomActionData, cFirewallExceptions * COST_FIREWALL_EXCEPTION); ExitOnFailure(hr, "failed to schedule firewall install exceptions execution"); } else { - hr = WcaDoDeferredAction(L"WixRollbackFirewallExceptionsUninstall", pwzCustomActionData, cFirewallExceptions * COST_FIREWALL_EXCEPTION); + hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"RollbackFirewallExceptionsUninstall"), pwzCustomActionData, cFirewallExceptions * COST_FIREWALL_EXCEPTION); ExitOnFailure(hr, "failed to schedule firewall uninstall exceptions rollback"); - hr = WcaDoDeferredAction(L"WixExecFirewallExceptionsUninstall", pwzCustomActionData, cFirewallExceptions * COST_FIREWALL_EXCEPTION); + hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"ExecFirewallExceptionsUninstall"), pwzCustomActionData, cFirewallExceptions * COST_FIREWALL_EXCEPTION); ExitOnFailure(hr, "failed to schedule firewall uninstall exceptions execution"); } } diff --git a/src/ca/precomp.h b/src/ca/precomp.h index a84bacff..03845e1e 100644 --- a/src/ca/precomp.h +++ b/src/ca/precomp.h @@ -15,3 +15,5 @@ #include "CustomMsiErrors.h" #include "cost.h" + +#include "caDecor.h" -- cgit v1.2.3-55-g6feb From 98aec4fbb3a6f8e4f6db7282c9370323d331cf9d Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Wed, 2 Sep 2020 14:30:56 -0400 Subject: Fix Condition authoring. --- .../FirewallExtensionFixture.cs | 2 +- src/wixlib/FirewallExtension_Platform.wxi | 23 +++++++++------------- 2 files changed, 10 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs b/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs index ceac4f26..dd7a4d67 100644 --- a/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs +++ b/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs @@ -57,7 +57,7 @@ namespace WixToolsetTest.Firewall var results = build.BuildAndQuery(Build, "WixFirewallException"); Assert.Equal(new[] { - "WixFirewallException:fexPv9RR1kBvP6gMgWyXMVQkVbopOA\texample\t*\t42\t6\t\t0\t2147483647\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tAn example outbound firewall\t2", + "WixFirewallException:fex.5c8b_4C0THcQTvn8tpwhoRrgck\texample\t*\t42\t6\t\t0\t2147483647\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tAn example outbound firewall\t2", }, results); } diff --git a/src/wixlib/FirewallExtension_Platform.wxi b/src/wixlib/FirewallExtension_Platform.wxi index afd5f20b..4af785bb 100644 --- a/src/wixlib/FirewallExtension_Platform.wxi +++ b/src/wixlib/FirewallExtension_Platform.wxi @@ -1,17 +1,16 @@ - - + - !(loc.WixSchedFirewallExceptionsInstall) - !(loc.WixSchedFirewallExceptionsUninstall) - !(loc.WixRollbackFirewallExceptionsInstall) - !(loc.WixExecFirewallExceptionsInstall) - !(loc.WixRollbackFirewallExceptionsUninstall) - !(loc.WixExecFirewallExceptionsUninstall) + + + + + + @@ -25,12 +24,8 @@ We need the firewall on Windows XP SP2 or later. --> - - = 600 OR (VersionNT >= 501 AND ((MsiNTProductType = 1 AND ServicePackLevel >= 2) OR (MsiNTProductType > 1 AND ServicePackLevel >= 1))) ]]> - - - = 600 OR (VersionNT >= 501 AND ((MsiNTProductType = 1 AND ServicePackLevel >= 2) OR (MsiNTProductType > 1 AND ServicePackLevel >= 1))) ]]> - + + -- cgit v1.2.3-55-g6feb From 4bcd57b4b7a9983b96a6c63522b35747e844cac3 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Sun, 20 Sep 2020 16:58:33 -0400 Subject: Remove 32-bit ARM support. --- global.json | 2 +- src/ca/fwca.vcxproj | 9 --------- src/wixext/FirewallCompiler.cs | 4 ++-- src/wixlib/FirewallExtension.wxs | 5 ++--- src/wixlib/FirewallExtension_Platform.wxi | 12 ++++++------ src/wixlib/FirewallExtension_arm.wxs | 8 -------- src/wixlib/FirewallExtension_arm64.wxs | 3 +-- src/wixlib/FirewallExtension_x64.wxs | 3 +-- src/wixlib/FirewallExtension_x86.wxs | 3 +-- src/wixlib/caDecor.wxi | 21 ++++++++++----------- src/wixlib/caerr.wxi | 2 +- src/wixlib/en-us.wxl | 3 +-- src/wixlib/es-es.wxl | 3 +-- src/wixlib/firewall.wixproj | 7 ++++++- src/wixlib/ja-jp.wxl | 3 +-- src/wixlib/pl-pl.wxl | 3 +-- 16 files changed, 35 insertions(+), 56 deletions(-) delete mode 100644 src/wixlib/FirewallExtension_arm.wxs (limited to 'src') diff --git a/global.json b/global.json index 7a995d0a..4d9df50b 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "msbuild-sdks": { - "WixToolset.Sdk": "4.0.0-build-0143" + "WixToolset.Sdk": "4.0.0-build-0157" } } diff --git a/src/ca/fwca.vcxproj b/src/ca/fwca.vcxproj index f35e7177..6e392b8f 100644 --- a/src/ca/fwca.vcxproj +++ b/src/ca/fwca.vcxproj @@ -6,15 +6,6 @@ - - Debug - ARM - - - Release - ARM - - Debug ARM64 diff --git a/src/wixext/FirewallCompiler.cs b/src/wixext/FirewallCompiler.cs index e3cf201b..8eef2fb2 100644 --- a/src/wixext/FirewallCompiler.cs +++ b/src/wixext/FirewallCompiler.cs @@ -300,8 +300,8 @@ namespace WixToolset.Firewall symbol.Attributes = attributes; } - this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "SchedFirewallExceptionsInstall", this.Context.Platform, CustomActionPlatforms.ARM | CustomActionPlatforms.ARM64 | CustomActionPlatforms.X64 | CustomActionPlatforms.X86); - this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "SchedFirewallExceptionsUninstall", this.Context.Platform, CustomActionPlatforms.ARM | CustomActionPlatforms.ARM64 | CustomActionPlatforms.X64 | CustomActionPlatforms.X86); + this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "SchedFirewallExceptionsInstall", this.Context.Platform, CustomActionPlatforms.ARM64 | CustomActionPlatforms.X64 | CustomActionPlatforms.X86); + this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "SchedFirewallExceptionsUninstall", this.Context.Platform, CustomActionPlatforms.ARM64 | CustomActionPlatforms.X64 | CustomActionPlatforms.X86); } } diff --git a/src/wixlib/FirewallExtension.wxs b/src/wixlib/FirewallExtension.wxs index 271469e4..56ad693e 100644 --- a/src/wixlib/FirewallExtension.wxs +++ b/src/wixlib/FirewallExtension.wxs @@ -1,12 +1,11 @@ - - + - !(loc.msierrFirewallCannotConnect) + diff --git a/src/wixlib/FirewallExtension_Platform.wxi b/src/wixlib/FirewallExtension_Platform.wxi index 4af785bb..3861bd5d 100644 --- a/src/wixlib/FirewallExtension_Platform.wxi +++ b/src/wixlib/FirewallExtension_Platform.wxi @@ -13,12 +13,12 @@ - - - - - - + + + + + + - - - - - - diff --git a/src/wixlib/FirewallExtension_arm64.wxs b/src/wixlib/FirewallExtension_arm64.wxs index 4fc16b63..63cdd1e8 100644 --- a/src/wixlib/FirewallExtension_arm64.wxs +++ b/src/wixlib/FirewallExtension_arm64.wxs @@ -1,5 +1,4 @@ - - + diff --git a/src/wixlib/FirewallExtension_x64.wxs b/src/wixlib/FirewallExtension_x64.wxs index 8317c20b..842aedf1 100644 --- a/src/wixlib/FirewallExtension_x64.wxs +++ b/src/wixlib/FirewallExtension_x64.wxs @@ -1,5 +1,4 @@ - - + diff --git a/src/wixlib/FirewallExtension_x86.wxs b/src/wixlib/FirewallExtension_x86.wxs index b43a4c5f..5867f791 100644 --- a/src/wixlib/FirewallExtension_x86.wxs +++ b/src/wixlib/FirewallExtension_x86.wxs @@ -1,5 +1,4 @@ - - + diff --git a/src/wixlib/caDecor.wxi b/src/wixlib/caDecor.wxi index 1d00df8f..b1711518 100644 --- a/src/wixlib/caDecor.wxi +++ b/src/wixlib/caDecor.wxi @@ -1,40 +1,39 @@ - - + - + - + - + - + - + - + - + - + - + diff --git a/src/wixlib/caerr.wxi b/src/wixlib/caerr.wxi index 141942f2..ff7ec121 100644 --- a/src/wixlib/caerr.wxi +++ b/src/wixlib/caerr.wxi @@ -1,4 +1,4 @@ - + diff --git a/src/wixlib/en-us.wxl b/src/wixlib/en-us.wxl index 7db8a9c2..ab9ce8a0 100644 --- a/src/wixlib/en-us.wxl +++ b/src/wixlib/en-us.wxl @@ -1,5 +1,4 @@ - - + diff --git a/src/wixlib/es-es.wxl b/src/wixlib/es-es.wxl index 45d5fd0e..0631b3a3 100644 --- a/src/wixlib/es-es.wxl +++ b/src/wixlib/es-es.wxl @@ -1,5 +1,4 @@ - - + No se puede conectar al Firewall de Windows. ([2] [3] [4] [5]) diff --git a/src/wixlib/firewall.wixproj b/src/wixlib/firewall.wixproj index 7e92bf1a..049b26b1 100644 --- a/src/wixlib/firewall.wixproj +++ b/src/wixlib/firewall.wixproj @@ -8,7 +8,12 @@ - + + + + + + diff --git a/src/wixlib/ja-jp.wxl b/src/wixlib/ja-jp.wxl index b6c0b96e..a4036c7e 100644 --- a/src/wixlib/ja-jp.wxl +++ b/src/wixlib/ja-jp.wxl @@ -1,5 +1,4 @@ - - + diff --git a/src/wixlib/pl-pl.wxl b/src/wixlib/pl-pl.wxl index a685917c..1b37460e 100644 --- a/src/wixlib/pl-pl.wxl +++ b/src/wixlib/pl-pl.wxl @@ -1,5 +1,4 @@ - - + -- cgit v1.2.3-55-g6feb From 3689bec106a17da7b5bb23d79db10b6214d634fa Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Mon, 26 Oct 2020 21:49:26 -0400 Subject: Update test authoring for Package/SummaryInformation change. --- .../TestData/UsingFirewall/Package.wxs | 11 +++++------ .../TestData/UsingOutboundFirewall/Package.wxs | 11 +++++------ 2 files changed, 10 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.wxs b/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.wxs index 68ff98fd..a79dae6a 100644 --- a/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.wxs +++ b/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.wxs @@ -1,16 +1,15 @@ - - - - + + + - + - + diff --git a/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.wxs b/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.wxs index 68ff98fd..a79dae6a 100644 --- a/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.wxs +++ b/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.wxs @@ -1,16 +1,15 @@ - - - - + + + - + - + -- cgit v1.2.3-55-g6feb From f776ae26df13a194d1b323b99564cbcb76336203 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Sat, 31 Oct 2020 21:45:25 -0400 Subject: Strong-name sign WiX assemblies. --- global.json | 2 +- src/CSharp.Build.props | 11 +++++++++++ src/Directory.Build.props | 1 + src/wix.snk | Bin 0 -> 596 bytes 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/CSharp.Build.props create mode 100644 src/wix.snk (limited to 'src') diff --git a/global.json b/global.json index f94ab6df..10345833 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "msbuild-sdks": { - "WixToolset.Sdk": "4.0.0-build-0162" + "WixToolset.Sdk": "4.0.0-build-0163" } } diff --git a/src/CSharp.Build.props b/src/CSharp.Build.props new file mode 100644 index 00000000..b12f4c6e --- /dev/null +++ b/src/CSharp.Build.props @@ -0,0 +1,11 @@ + + + + + true + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)wix.snk)) + + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index a22f4470..f83cc154 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -22,6 +22,7 @@ WiX Toolset + diff --git a/src/wix.snk b/src/wix.snk new file mode 100644 index 00000000..3908a66a Binary files /dev/null and b/src/wix.snk differ -- cgit v1.2.3-55-g6feb From 0f2fb968a2afdd9e950727250a8069f37bd3d2fc Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 4 Dec 2020 17:23:52 -0600 Subject: xsd got moved to doc repo. Update dependencies. --- global.json | 2 +- src/ca/fwca.vcxproj | 8 +- src/ca/packages.config | 4 +- src/wixext/WixToolset.Firewall.wixext.csproj | 5 +- src/wixext/firewall.xsd | 217 --------------------------- src/wixlib/firewall.wixproj | 2 +- 6 files changed, 10 insertions(+), 228 deletions(-) delete mode 100644 src/wixext/firewall.xsd (limited to 'src') diff --git a/global.json b/global.json index 10345833..77a81322 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "msbuild-sdks": { - "WixToolset.Sdk": "4.0.0-build-0163" + "WixToolset.Sdk": "4.0.0-build-0170" } } diff --git a/src/ca/fwca.vcxproj b/src/ca/fwca.vcxproj index 6e392b8f..5e9a1db6 100644 --- a/src/ca/fwca.vcxproj +++ b/src/ca/fwca.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -75,7 +75,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + diff --git a/src/ca/packages.config b/src/ca/packages.config index e3dc0e43..9d88f529 100644 --- a/src/ca/packages.config +++ b/src/ca/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file diff --git a/src/wixext/WixToolset.Firewall.wixext.csproj b/src/wixext/WixToolset.Firewall.wixext.csproj index 07d5de56..6704dad2 100644 --- a/src/wixext/WixToolset.Firewall.wixext.csproj +++ b/src/wixext/WixToolset.Firewall.wixext.csproj @@ -1,4 +1,4 @@ - + @@ -13,7 +13,6 @@ - @@ -27,6 +26,6 @@ - + diff --git a/src/wixext/firewall.xsd b/src/wixext/firewall.xsd deleted file mode 100644 index 20ad065f..00000000 --- a/src/wixext/firewall.xsd +++ /dev/null @@ -1,217 +0,0 @@ - - - - - - - - The source code schema for the WiX Toolset Firewall Extension. - - - - - - - - - Registers an exception for a program or a specific port and protocol in the Windows Firewall - on Windows XP SP2, Windows Server 2003 SP1, and later. For more information about the Windows - Firewall, see - About Windows Firewall API. - - - - - - - - - - - - Explicitly-listed remote addresses that this exception allows through the - firewall. - - - - - - - - - Unique ID of this firewall exception. - - - - - - - - Name of this firewall exception, visible to the user in the firewall - control panel. - - - - - - - - The scope of this firewall exception, which indicates whether incoming - connections can come from any computer including those on the Internet - or only those on the local network subnet. To more precisely specify - allowed remote address, specify a custom scope using RemoteAddress - child elements. - - - - - - - - - - - - - - Port to allow through the firewall for this exception. - - If you use Port and also File or Program in the same - FirewallException element, the exception will fail to install on - Windows XP and Windows Server 2003. IgnoreFailure="yes" can be used to - ignore the resulting failure, but the exception will not be added. - - - - - - - - IP protocol used for this firewall exception. If Port is defined, - "tcp" is assumed if the protocol is not specified. - - If you use Protocol and also File or Program in the same - FirewallException element, the exception will fail to install on - Windows XP and Windows Server 2003. IgnoreFailure="yes" can be used to - ignore the resulting failure, but the exception will not be added. - - - - - - - - - - - - - - Identifier of a file to be granted access to all incoming ports and - protocols. If you use File, you cannot also use Program. - - If you use File and also Port or Protocol in the same - FirewallException element, the exception will fail to install on - Windows XP and Windows Server 2003. IgnoreFailure="yes" can be used to - ignore the resulting failure, but the exception will not be added. - - - - - - - - Path to a target program to be granted access to all incoming ports and - protocols. Note that this is a formatted field, so you can use [#fileId] - syntax to refer to a file being installed. If you use Program, you cannot - also use File. - - If you use Program and also Port or Protocol in the same - FirewallException element, the exception will fail to install on - Windows XP and Windows Server 2003. IgnoreFailure="yes" can be used to - ignore the resulting failure, but the exception will not be added. - - - - - - - - If "yes", failures to register this firewall exception will be silently - ignored. If "no" (the default), failures will cause rollback. - - - - - - - - Profile type for this firewall exception. Default is "all". - - - - - - - - - - - - - - - Description for this firewall rule displayed in Windows Firewall manager in - Windows Vista and later. - - - - - - - - If "yes", registers an outbound firewall rule. - - - - - - - - - - A remote address to which the port or program can listen. Address formats vary - based on the version of Windows and Windows Firewall the program is being installed - on. For Windows XP SP2 and Windows Server 2003 SP1, see - - RemoteAddresses Property. - For Windows Vista and Windows Server 2008, see - - RemoteAddresses Property. - - - - - - - A remote address. - - - - - - - - - Values of this type will either be "yes" or "no". - - - - - - - diff --git a/src/wixlib/firewall.wixproj b/src/wixlib/firewall.wixproj index 049b26b1..242fa56e 100644 --- a/src/wixlib/firewall.wixproj +++ b/src/wixlib/firewall.wixproj @@ -20,7 +20,7 @@ - + -- cgit v1.2.3-55-g6feb From d7a5afaf95cb942c572074b5c697937ef3e25e38 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Tue, 23 Feb 2021 18:35:00 -0500 Subject: Add custom action prefixes. --- src/wixext/FirewallCompiler.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/wixext/FirewallCompiler.cs b/src/wixext/FirewallCompiler.cs index 8eef2fb2..cbe82d37 100644 --- a/src/wixext/FirewallCompiler.cs +++ b/src/wixext/FirewallCompiler.cs @@ -300,8 +300,8 @@ namespace WixToolset.Firewall symbol.Attributes = attributes; } - this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "SchedFirewallExceptionsInstall", this.Context.Platform, CustomActionPlatforms.ARM64 | CustomActionPlatforms.X64 | CustomActionPlatforms.X86); - this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "SchedFirewallExceptionsUninstall", this.Context.Platform, CustomActionPlatforms.ARM64 | CustomActionPlatforms.X64 | CustomActionPlatforms.X86); + this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4SchedFirewallExceptionsInstall", this.Context.Platform, CustomActionPlatforms.ARM64 | CustomActionPlatforms.X64 | CustomActionPlatforms.X86); + this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4SchedFirewallExceptionsUninstall", this.Context.Platform, CustomActionPlatforms.ARM64 | CustomActionPlatforms.X64 | CustomActionPlatforms.X86); } } -- cgit v1.2.3-55-g6feb From 90864bdc491a74a3688eefc6177e5b93a88a9c9d Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 7 Apr 2021 22:13:39 -0700 Subject: Update dependencies --- global.json | 2 +- .../TestData/UsingFirewall/Package.wxs | 12 +++--------- .../TestData/UsingOutboundFirewall/Package.wxs | 12 +++--------- 3 files changed, 7 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/global.json b/global.json index 77a81322..fc26eb6e 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "msbuild-sdks": { - "WixToolset.Sdk": "4.0.0-build-0170" + "WixToolset.Sdk": "4.0.0-build-0206" } } diff --git a/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.wxs b/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.wxs index a79dae6a..411893bc 100644 --- a/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.wxs +++ b/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.wxs @@ -1,21 +1,15 @@  - - - - - - - - - + + + diff --git a/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.wxs b/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.wxs index a79dae6a..411893bc 100644 --- a/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.wxs +++ b/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.wxs @@ -1,21 +1,15 @@  - - - - - - - - - + + + -- cgit v1.2.3-55-g6feb From e31c6d9643c0578e22db4df1e64d6672248fd0c7 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Sun, 18 Apr 2021 21:06:02 -0400 Subject: Add `Wix4` table prefixes. Per https://github.com/wixtoolset/issues/issues/5933. --- src/ca/firewall.cpp | 10 +++++----- src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs | 12 ++++++------ src/wixext/FirewallTableDefinitions.cs | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/ca/firewall.cpp b/src/ca/firewall.cpp index 038f4ea5..caae21a1 100644 --- a/src/ca/firewall.cpp +++ b/src/ca/firewall.cpp @@ -3,7 +3,7 @@ #include "precomp.h" LPCWSTR vcsFirewallExceptionQuery = - L"SELECT `Name`, `RemoteAddresses`, `Port`, `Protocol`, `Program`, `Attributes`, `Profile`, `Component_`, `Description`, `Direction` FROM `WixFirewallException`"; + L"SELECT `Name`, `RemoteAddresses`, `Port`, `Protocol`, `Program`, `Attributes`, `Profile`, `Component_`, `Description`, `Direction` FROM `Wix4FirewallException`"; enum eFirewallExceptionQuery { feqName = 1, feqRemoteAddresses, feqPort, feqProtocol, feqProgram, feqAttributes, feqProfile, feqComponent, feqDescription }; enum eFirewallExceptionTarget { fetPort = 1, fetApplication, fetUnknown }; enum eFirewallExceptionAttributes { feaIgnoreFailures = 1 }; @@ -43,15 +43,15 @@ static UINT SchedFirewallExceptions( ExitOnFailure(hr, "failed to initialize"); // anything to do? - if (S_OK != WcaTableExists(L"WixFirewallException")) + if (S_OK != WcaTableExists(L"Wix4FirewallException")) { - WcaLog(LOGMSG_STANDARD, "WixFirewallException table doesn't exist, so there are no firewall exceptions to configure."); + WcaLog(LOGMSG_STANDARD, "Wix4FirewallException table doesn't exist, so there are no firewall exceptions to configure."); ExitFunction(); } // query and loop through all the firewall exceptions hr = WcaOpenExecuteView(vcsFirewallExceptionQuery, &hView); - ExitOnFailure(hr, "failed to open view on WixFirewallException table"); + ExitOnFailure(hr, "failed to open view on Wix4FirewallException table"); while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) { @@ -141,7 +141,7 @@ static UINT SchedFirewallExceptions( { hr = S_OK; } - ExitOnFailure(hr, "failure occured while processing WixFirewallException table"); + ExitOnFailure(hr, "failure occured while processing Wix4FirewallException table"); // schedule ExecFirewallExceptions if there's anything to do if (pwzCustomActionData && *pwzCustomActionData) diff --git a/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs b/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs index dd7a4d67..ffdc1326 100644 --- a/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs +++ b/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs @@ -16,7 +16,7 @@ namespace WixToolsetTest.Firewall var folder = TestData.Get(@"TestData\UsingFirewall"); var build = new Builder(folder, typeof(FirewallExtensionFactory), new[] { folder }); - var results = build.BuildAndQuery(Build, "WixFirewallException", "CustomAction"); + var results = build.BuildAndQuery(Build, "Wix4FirewallException", "CustomAction"); Assert.Equal(new[] { "CustomAction:Wix4ExecFirewallExceptionsInstall_X86\t3073\tWix4FWCA_X86\tExecFirewallExceptions\t", @@ -25,7 +25,7 @@ namespace WixToolsetTest.Firewall "CustomAction:Wix4RollbackFirewallExceptionsUninstall_X86\t3329\tWix4FWCA_X86\tExecFirewallExceptions\t", "CustomAction:Wix4SchedFirewallExceptionsInstall_X86\t1\tWix4FWCA_X86\tSchedFirewallExceptionsInstall\t", "CustomAction:Wix4SchedFirewallExceptionsUninstall_X86\t1\tWix4FWCA_X86\tSchedFirewallExceptionsUninstall\t", - "WixFirewallException:ExampleFirewall\texample\t*\t42\t6\t\t0\t2147483647\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tAn example firewall\t1", + "Wix4FirewallException:ExampleFirewall\texample\t*\t42\t6\t\t0\t2147483647\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tAn example firewall\t1", }, results); } @@ -35,7 +35,7 @@ namespace WixToolsetTest.Firewall var folder = TestData.Get(@"TestData\UsingFirewall"); var build = new Builder(folder, typeof(FirewallExtensionFactory), new[] { folder }); - var results = build.BuildAndQuery(BuildARM64, "WixFirewallException", "CustomAction"); + var results = build.BuildAndQuery(BuildARM64, "Wix4FirewallException", "CustomAction"); Assert.Equal(new[] { "CustomAction:Wix4ExecFirewallExceptionsInstall_A64\t3073\tWix4FWCA_A64\tExecFirewallExceptions\t", @@ -44,7 +44,7 @@ namespace WixToolsetTest.Firewall "CustomAction:Wix4RollbackFirewallExceptionsUninstall_A64\t3329\tWix4FWCA_A64\tExecFirewallExceptions\t", "CustomAction:Wix4SchedFirewallExceptionsInstall_A64\t1\tWix4FWCA_A64\tSchedFirewallExceptionsInstall\t", "CustomAction:Wix4SchedFirewallExceptionsUninstall_A64\t1\tWix4FWCA_A64\tSchedFirewallExceptionsUninstall\t", - "WixFirewallException:ExampleFirewall\texample\t*\t42\t6\t\t0\t2147483647\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tAn example firewall\t1", + "Wix4FirewallException:ExampleFirewall\texample\t*\t42\t6\t\t0\t2147483647\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tAn example firewall\t1", }, results); } @@ -54,10 +54,10 @@ namespace WixToolsetTest.Firewall var folder = TestData.Get(@"TestData\UsingOutboundFirewall"); var build = new Builder(folder, typeof(FirewallExtensionFactory), new[] { folder }); - var results = build.BuildAndQuery(Build, "WixFirewallException"); + var results = build.BuildAndQuery(Build, "Wix4FirewallException"); Assert.Equal(new[] { - "WixFirewallException:fex.5c8b_4C0THcQTvn8tpwhoRrgck\texample\t*\t42\t6\t\t0\t2147483647\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tAn example outbound firewall\t2", + "Wix4FirewallException:fex.5c8b_4C0THcQTvn8tpwhoRrgck\texample\t*\t42\t6\t\t0\t2147483647\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tAn example outbound firewall\t2", }, results); } diff --git a/src/wixext/FirewallTableDefinitions.cs b/src/wixext/FirewallTableDefinitions.cs index eae897d5..04918f5f 100644 --- a/src/wixext/FirewallTableDefinitions.cs +++ b/src/wixext/FirewallTableDefinitions.cs @@ -7,11 +7,11 @@ namespace WixToolset.Firewall public static class FirewallTableDefinitions { public static readonly TableDefinition WixFirewallException = new TableDefinition( - "WixFirewallException", + "Wix4FirewallException", FirewallSymbolDefinitions.WixFirewallException, new[] { - new ColumnDefinition("WixFirewallException", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "The primary key, a non-localized token.", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Wix4FirewallException", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "The primary key, a non-localized token.", modularizeType: ColumnModularizeType.Column), new ColumnDefinition("Name", ColumnType.Localized, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Localizable display name.", modularizeType: ColumnModularizeType.Property), new ColumnDefinition("RemoteAddresses", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Remote address to accept incoming connections from.", modularizeType: ColumnModularizeType.Property), new ColumnDefinition("Port", ColumnType.String, 0, primaryKey: false, nullable: true, ColumnCategory.Formatted, minValue: 1, description: "Port number.", modularizeType: ColumnModularizeType.Property), -- cgit v1.2.3-55-g6feb From bfabd9f718af70e59f24ac70046fa3141daf06e8 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 20 Apr 2021 12:46:28 -0700 Subject: Integrate latest tooling --- global.json | 2 +- src/wixext/FirewallExtensionFactory.cs | 2 +- src/wixext/FirewallWindowsInstallerBackendExtension.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/global.json b/global.json index fc26eb6e..23dd3fa6 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "msbuild-sdks": { - "WixToolset.Sdk": "4.0.0-build-0206" + "WixToolset.Sdk": "4.0.0-build-0211" } } diff --git a/src/wixext/FirewallExtensionFactory.cs b/src/wixext/FirewallExtensionFactory.cs index 377ae0ee..279b322a 100644 --- a/src/wixext/FirewallExtensionFactory.cs +++ b/src/wixext/FirewallExtensionFactory.cs @@ -8,7 +8,7 @@ namespace WixToolset.Firewall public class FirewallExtensionFactory : BaseExtensionFactory { - protected override IEnumerable ExtensionTypes => new[] + protected override IReadOnlyCollection ExtensionTypes => new[] { typeof(FirewallCompiler), typeof(FirewallExtensionData), diff --git a/src/wixext/FirewallWindowsInstallerBackendExtension.cs b/src/wixext/FirewallWindowsInstallerBackendExtension.cs index 46fdfa77..b5b97d85 100644 --- a/src/wixext/FirewallWindowsInstallerBackendExtension.cs +++ b/src/wixext/FirewallWindowsInstallerBackendExtension.cs @@ -8,6 +8,6 @@ namespace WixToolset.Firewall public class FirewallWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension { - public override IEnumerable TableDefinitions => FirewallTableDefinitions.All; + public override IReadOnlyCollection TableDefinitions => FirewallTableDefinitions.All; } } -- cgit v1.2.3-55-g6feb From ba00d844a2e2716a6aa07df89dd9318608bd1909 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 4 May 2021 22:46:07 -0700 Subject: Move Firewall.wixext into ext --- .editorconfig | 37 - Firewall.wixext.sln | 73 -- Firewall.wixext.v3.ncrunchsolution | 6 - README.md | 2 - appveyor.cmd | 14 - appveyor.yml | 40 - global.json | 5 - nuget.config | 18 - src/.editorconfig | 37 + src/CSharp.Build.props | 11 - src/Cpp.Build.props | 86 -- src/Directory.Build.props | 29 - src/Directory.Build.targets | 48 - src/ca/CustomMsiErrors.h | 130 --- src/ca/caDecor.h | 13 - src/ca/cost.h | 5 - src/ca/dllmain.cpp | 26 - src/ca/firewall.cpp | 1085 -------------------- src/ca/fwca.def | 9 - src/ca/fwca.v3.ncrunchproject | 5 - src/ca/fwca.vcxproj | 81 -- src/ca/packages.config | 5 - src/ca/precomp.h | 19 - src/ext/Firewall/CSharp.Build.props | 11 + src/ext/Firewall/Cpp.Build.props | 86 ++ src/ext/Firewall/Directory.Build.props | 29 + src/ext/Firewall/Directory.Build.targets | 48 + src/ext/Firewall/Firewall.wixext.sln | 73 ++ .../Firewall/Firewall.wixext.v3.ncrunchsolution | 6 + src/ext/Firewall/README.md | 2 + src/ext/Firewall/appveyor.cmd | 14 + src/ext/Firewall/appveyor.yml | 40 + src/ext/Firewall/ca/CustomMsiErrors.h | 130 +++ src/ext/Firewall/ca/caDecor.h | 13 + src/ext/Firewall/ca/cost.h | 5 + src/ext/Firewall/ca/dllmain.cpp | 26 + src/ext/Firewall/ca/firewall.cpp | 1085 ++++++++++++++++++++ src/ext/Firewall/ca/fwca.def | 9 + src/ext/Firewall/ca/fwca.v3.ncrunchproject | 5 + src/ext/Firewall/ca/fwca.vcxproj | 81 ++ src/ext/Firewall/ca/packages.config | 5 + src/ext/Firewall/ca/precomp.h | 19 + src/ext/Firewall/nuget.config | 18 + .../FirewallExtensionFixture.cs | 80 ++ .../TestData/UsingFirewall/Package.en-us.wxl | 11 + .../TestData/UsingFirewall/Package.wxs | 15 + .../TestData/UsingFirewall/PackageComponents.wxs | 14 + .../TestData/UsingFirewall/example.txt | 1 + .../UsingOutboundFirewall/Package.en-us.wxl | 11 + .../TestData/UsingOutboundFirewall/Package.wxs | 15 + .../UsingOutboundFirewall/PackageComponents.wxs | 14 + .../TestData/UsingOutboundFirewall/example.txt | 1 + .../WixToolsetTest.Firewall.csproj | 45 + .../WixToolsetTest.Firewall.v3.ncrunchproject | 5 + src/ext/Firewall/wix.snk | Bin 0 -> 596 bytes src/ext/Firewall/wixext/FirewallCompiler.cs | 354 +++++++ src/ext/Firewall/wixext/FirewallConstants.cs | 23 + src/ext/Firewall/wixext/FirewallDecompiler.cs | 182 ++++ src/ext/Firewall/wixext/FirewallErrors.cs | 36 + src/ext/Firewall/wixext/FirewallExtensionData.cs | 23 + .../Firewall/wixext/FirewallExtensionFactory.cs | 18 + .../Firewall/wixext/FirewallTableDefinitions.cs | 34 + .../FirewallWindowsInstallerBackendExtension.cs | 13 + .../wixext/Symbols/FirewallSymbolDefinitions.cs | 39 + .../wixext/Symbols/WixFirewallExceptionSymbol.cs | 119 +++ .../wixext/WixToolset.Firewall.wixext.csproj | 31 + .../wixext/WixToolset.Firewall.wixext.targets | 11 + src/ext/Firewall/wixlib/FirewallExtension.wxs | 11 + .../Firewall/wixlib/FirewallExtension_Platform.wxi | 36 + .../Firewall/wixlib/FirewallExtension_arm64.wxs | 7 + src/ext/Firewall/wixlib/FirewallExtension_x64.wxs | 7 + src/ext/Firewall/wixlib/FirewallExtension_x86.wxs | 7 + src/ext/Firewall/wixlib/caDecor.wxi | 39 + src/ext/Firewall/wixlib/caerr.wxi | 96 ++ src/ext/Firewall/wixlib/en-us.wxl | 13 + src/ext/Firewall/wixlib/es-es.wxl | 12 + src/ext/Firewall/wixlib/firewall.v3.ncrunchproject | 5 + src/ext/Firewall/wixlib/firewall.wixproj | 26 + src/ext/Firewall/wixlib/ja-jp.wxl | 13 + src/ext/Firewall/wixlib/pl-pl.wxl | 13 + src/ext/global.json | 5 + .../FirewallExtensionFixture.cs | 80 -- .../TestData/UsingFirewall/Package.en-us.wxl | 11 - .../TestData/UsingFirewall/Package.wxs | 15 - .../TestData/UsingFirewall/PackageComponents.wxs | 14 - .../TestData/UsingFirewall/example.txt | 1 - .../UsingOutboundFirewall/Package.en-us.wxl | 11 - .../TestData/UsingOutboundFirewall/Package.wxs | 15 - .../UsingOutboundFirewall/PackageComponents.wxs | 14 - .../TestData/UsingOutboundFirewall/example.txt | 1 - .../WixToolsetTest.Firewall.csproj | 45 - .../WixToolsetTest.Firewall.v3.ncrunchproject | 5 - src/version.json | 11 + src/wix.snk | Bin 596 -> 0 bytes src/wixext/FirewallCompiler.cs | 354 ------- src/wixext/FirewallConstants.cs | 23 - src/wixext/FirewallDecompiler.cs | 182 ---- src/wixext/FirewallErrors.cs | 36 - src/wixext/FirewallExtensionData.cs | 23 - src/wixext/FirewallExtensionFactory.cs | 18 - src/wixext/FirewallTableDefinitions.cs | 34 - .../FirewallWindowsInstallerBackendExtension.cs | 13 - src/wixext/Symbols/FirewallSymbolDefinitions.cs | 39 - src/wixext/Symbols/WixFirewallExceptionSymbol.cs | 119 --- src/wixext/WixToolset.Firewall.wixext.csproj | 31 - src/wixext/WixToolset.Firewall.wixext.targets | 11 - src/wixlib/FirewallExtension.wxs | 11 - src/wixlib/FirewallExtension_Platform.wxi | 36 - src/wixlib/FirewallExtension_arm64.wxs | 7 - src/wixlib/FirewallExtension_x64.wxs | 7 - src/wixlib/FirewallExtension_x86.wxs | 7 - src/wixlib/caDecor.wxi | 39 - src/wixlib/caerr.wxi | 96 -- src/wixlib/en-us.wxl | 13 - src/wixlib/es-es.wxl | 12 - src/wixlib/firewall.v3.ncrunchproject | 5 - src/wixlib/firewall.wixproj | 26 - src/wixlib/ja-jp.wxl | 13 - src/wixlib/pl-pl.wxl | 13 - version.json | 11 - 120 files changed, 3138 insertions(+), 3138 deletions(-) delete mode 100644 .editorconfig delete mode 100644 Firewall.wixext.sln delete mode 100644 Firewall.wixext.v3.ncrunchsolution delete mode 100644 README.md delete mode 100644 appveyor.cmd delete mode 100644 appveyor.yml delete mode 100644 global.json delete mode 100644 nuget.config create mode 100644 src/.editorconfig delete mode 100644 src/CSharp.Build.props delete mode 100644 src/Cpp.Build.props delete mode 100644 src/Directory.Build.props delete mode 100644 src/Directory.Build.targets delete mode 100644 src/ca/CustomMsiErrors.h delete mode 100644 src/ca/caDecor.h delete mode 100644 src/ca/cost.h delete mode 100644 src/ca/dllmain.cpp delete mode 100644 src/ca/firewall.cpp delete mode 100644 src/ca/fwca.def delete mode 100644 src/ca/fwca.v3.ncrunchproject delete mode 100644 src/ca/fwca.vcxproj delete mode 100644 src/ca/packages.config delete mode 100644 src/ca/precomp.h create mode 100644 src/ext/Firewall/CSharp.Build.props create mode 100644 src/ext/Firewall/Cpp.Build.props create mode 100644 src/ext/Firewall/Directory.Build.props create mode 100644 src/ext/Firewall/Directory.Build.targets create mode 100644 src/ext/Firewall/Firewall.wixext.sln create mode 100644 src/ext/Firewall/Firewall.wixext.v3.ncrunchsolution create mode 100644 src/ext/Firewall/README.md create mode 100644 src/ext/Firewall/appveyor.cmd create mode 100644 src/ext/Firewall/appveyor.yml create mode 100644 src/ext/Firewall/ca/CustomMsiErrors.h create mode 100644 src/ext/Firewall/ca/caDecor.h create mode 100644 src/ext/Firewall/ca/cost.h create mode 100644 src/ext/Firewall/ca/dllmain.cpp create mode 100644 src/ext/Firewall/ca/firewall.cpp create mode 100644 src/ext/Firewall/ca/fwca.def create mode 100644 src/ext/Firewall/ca/fwca.v3.ncrunchproject create mode 100644 src/ext/Firewall/ca/fwca.vcxproj create mode 100644 src/ext/Firewall/ca/packages.config create mode 100644 src/ext/Firewall/ca/precomp.h create mode 100644 src/ext/Firewall/nuget.config create mode 100644 src/ext/Firewall/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs create mode 100644 src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.en-us.wxl create mode 100644 src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.wxs create mode 100644 src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs create mode 100644 src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingFirewall/example.txt create mode 100644 src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.en-us.wxl create mode 100644 src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.wxs create mode 100644 src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/PackageComponents.wxs create mode 100644 src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/example.txt create mode 100644 src/ext/Firewall/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj create mode 100644 src/ext/Firewall/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.v3.ncrunchproject create mode 100644 src/ext/Firewall/wix.snk create mode 100644 src/ext/Firewall/wixext/FirewallCompiler.cs create mode 100644 src/ext/Firewall/wixext/FirewallConstants.cs create mode 100644 src/ext/Firewall/wixext/FirewallDecompiler.cs create mode 100644 src/ext/Firewall/wixext/FirewallErrors.cs create mode 100644 src/ext/Firewall/wixext/FirewallExtensionData.cs create mode 100644 src/ext/Firewall/wixext/FirewallExtensionFactory.cs create mode 100644 src/ext/Firewall/wixext/FirewallTableDefinitions.cs create mode 100644 src/ext/Firewall/wixext/FirewallWindowsInstallerBackendExtension.cs create mode 100644 src/ext/Firewall/wixext/Symbols/FirewallSymbolDefinitions.cs create mode 100644 src/ext/Firewall/wixext/Symbols/WixFirewallExceptionSymbol.cs create mode 100644 src/ext/Firewall/wixext/WixToolset.Firewall.wixext.csproj create mode 100644 src/ext/Firewall/wixext/WixToolset.Firewall.wixext.targets create mode 100644 src/ext/Firewall/wixlib/FirewallExtension.wxs create mode 100644 src/ext/Firewall/wixlib/FirewallExtension_Platform.wxi create mode 100644 src/ext/Firewall/wixlib/FirewallExtension_arm64.wxs create mode 100644 src/ext/Firewall/wixlib/FirewallExtension_x64.wxs create mode 100644 src/ext/Firewall/wixlib/FirewallExtension_x86.wxs create mode 100644 src/ext/Firewall/wixlib/caDecor.wxi create mode 100644 src/ext/Firewall/wixlib/caerr.wxi create mode 100644 src/ext/Firewall/wixlib/en-us.wxl create mode 100644 src/ext/Firewall/wixlib/es-es.wxl create mode 100644 src/ext/Firewall/wixlib/firewall.v3.ncrunchproject create mode 100644 src/ext/Firewall/wixlib/firewall.wixproj create mode 100644 src/ext/Firewall/wixlib/ja-jp.wxl create mode 100644 src/ext/Firewall/wixlib/pl-pl.wxl create mode 100644 src/ext/global.json delete mode 100644 src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs delete mode 100644 src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.en-us.wxl delete mode 100644 src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.wxs delete mode 100644 src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs delete mode 100644 src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/example.txt delete mode 100644 src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.en-us.wxl delete mode 100644 src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.wxs delete mode 100644 src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/PackageComponents.wxs delete mode 100644 src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/example.txt delete mode 100644 src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj delete mode 100644 src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.v3.ncrunchproject create mode 100644 src/version.json delete mode 100644 src/wix.snk delete mode 100644 src/wixext/FirewallCompiler.cs delete mode 100644 src/wixext/FirewallConstants.cs delete mode 100644 src/wixext/FirewallDecompiler.cs delete mode 100644 src/wixext/FirewallErrors.cs delete mode 100644 src/wixext/FirewallExtensionData.cs delete mode 100644 src/wixext/FirewallExtensionFactory.cs delete mode 100644 src/wixext/FirewallTableDefinitions.cs delete mode 100644 src/wixext/FirewallWindowsInstallerBackendExtension.cs delete mode 100644 src/wixext/Symbols/FirewallSymbolDefinitions.cs delete mode 100644 src/wixext/Symbols/WixFirewallExceptionSymbol.cs delete mode 100644 src/wixext/WixToolset.Firewall.wixext.csproj delete mode 100644 src/wixext/WixToolset.Firewall.wixext.targets delete mode 100644 src/wixlib/FirewallExtension.wxs delete mode 100644 src/wixlib/FirewallExtension_Platform.wxi delete mode 100644 src/wixlib/FirewallExtension_arm64.wxs delete mode 100644 src/wixlib/FirewallExtension_x64.wxs delete mode 100644 src/wixlib/FirewallExtension_x86.wxs delete mode 100644 src/wixlib/caDecor.wxi delete mode 100644 src/wixlib/caerr.wxi delete mode 100644 src/wixlib/en-us.wxl delete mode 100644 src/wixlib/es-es.wxl delete mode 100644 src/wixlib/firewall.v3.ncrunchproject delete mode 100644 src/wixlib/firewall.wixproj delete mode 100644 src/wixlib/ja-jp.wxl delete mode 100644 src/wixlib/pl-pl.wxl delete mode 100644 version.json (limited to 'src') diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 1d72e683..00000000 --- a/.editorconfig +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -# -# Do NOT modify this file. Update the canonical version in Home\repo-template\src\.editorconfig -# then update all of the repos. - -root = true - -[*] -charset = utf-8 -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true - -[*.{cs,vb}] -dotnet_sort_system_directives_first = true - -[*.cs] -csharp_indent_case_contents = true : error -csharp_indent_switch_labels = true : error -csharp_new_line_before_open_brace = all -csharp_prefer_braces = true : error -csharp_style_expression_bodied_methods = when_on_single_line : suggestion -csharp_style_expression_bodied_constructors = when_on_single_line : suggestion -csharp_style_expression_bodied_operators = when_on_single_line : suggestion -csharp_style_expression_bodied_properties = when_on_single_line : suggestion -csharp_style_expression_bodied_indexers = when_on_single_line : suggestion -csharp_style_expression_bodied_accessors = when_on_single_line : suggestion -csharp_style_var_elsewhere = true : suggestion -csharp_style_var_for_built_in_types = true : suggestion -csharp_style_var_when_type_is_apparent = true : suggestion -dotnet_style_qualification_for_event = true : error -dotnet_style_qualification_for_field = true : error -dotnet_style_qualification_for_method = true : error -dotnet_style_qualification_for_property = true : error - -[*.targets] -indent_size = 2 diff --git a/Firewall.wixext.sln b/Firewall.wixext.sln deleted file mode 100644 index 59209c88..00000000 --- a/Firewall.wixext.sln +++ /dev/null @@ -1,73 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27130.2003 -MinimumVisualStudioVersion = 15.0.26124.0 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fwca", "src\ca\fwca.vcxproj", "{F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}" -EndProject -Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "firewall", "src\wixlib\firewall.wixproj", "{1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.Firewall.wixext", "src\wixext\WixToolset.Firewall.wixext.csproj", "{6CF033EB-0A39-4AC6-9D41-9BD506352045}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolsetTest.Firewall", "src\test\WixToolsetTest.Firewall\WixToolsetTest.Firewall.csproj", "{D5D34EC4-AF91-4B11-AC0A-FA5242AE924B}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Debug|Any CPU.Build.0 = Debug|Win32 - {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Debug|x64.ActiveCfg = Debug|Win32 - {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Debug|x86.ActiveCfg = Debug|Win32 - {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Debug|x86.Build.0 = Debug|Win32 - {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Release|Any CPU.ActiveCfg = Release|Win32 - {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Release|x64.ActiveCfg = Release|Win32 - {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Release|x86.ActiveCfg = Release|Win32 - {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Release|x86.Build.0 = Release|Win32 - {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Debug|Any CPU.ActiveCfg = Debug|x86 - {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Debug|Any CPU.Build.0 = Debug|x86 - {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Debug|x64.ActiveCfg = Debug|x86 - {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Debug|x86.ActiveCfg = Debug|x86 - {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Debug|x86.Build.0 = Debug|x86 - {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Release|Any CPU.ActiveCfg = Release|x86 - {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Release|x64.ActiveCfg = Release|x86 - {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Release|x86.ActiveCfg = Release|x86 - {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Release|x86.Build.0 = Release|x86 - {6CF033EB-0A39-4AC6-9D41-9BD506352045}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6CF033EB-0A39-4AC6-9D41-9BD506352045}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6CF033EB-0A39-4AC6-9D41-9BD506352045}.Debug|x64.ActiveCfg = Debug|Any CPU - {6CF033EB-0A39-4AC6-9D41-9BD506352045}.Debug|x64.Build.0 = Debug|Any CPU - {6CF033EB-0A39-4AC6-9D41-9BD506352045}.Debug|x86.ActiveCfg = Debug|Any CPU - {6CF033EB-0A39-4AC6-9D41-9BD506352045}.Debug|x86.Build.0 = Debug|Any CPU - {6CF033EB-0A39-4AC6-9D41-9BD506352045}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6CF033EB-0A39-4AC6-9D41-9BD506352045}.Release|Any CPU.Build.0 = Release|Any CPU - {6CF033EB-0A39-4AC6-9D41-9BD506352045}.Release|x64.ActiveCfg = Release|Any CPU - {6CF033EB-0A39-4AC6-9D41-9BD506352045}.Release|x64.Build.0 = Release|Any CPU - {6CF033EB-0A39-4AC6-9D41-9BD506352045}.Release|x86.ActiveCfg = Release|Any CPU - {6CF033EB-0A39-4AC6-9D41-9BD506352045}.Release|x86.Build.0 = Release|Any CPU - {D5D34EC4-AF91-4B11-AC0A-FA5242AE924B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D5D34EC4-AF91-4B11-AC0A-FA5242AE924B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D5D34EC4-AF91-4B11-AC0A-FA5242AE924B}.Debug|x64.ActiveCfg = Debug|Any CPU - {D5D34EC4-AF91-4B11-AC0A-FA5242AE924B}.Debug|x64.Build.0 = Debug|Any CPU - {D5D34EC4-AF91-4B11-AC0A-FA5242AE924B}.Debug|x86.ActiveCfg = Debug|Any CPU - {D5D34EC4-AF91-4B11-AC0A-FA5242AE924B}.Debug|x86.Build.0 = Debug|Any CPU - {D5D34EC4-AF91-4B11-AC0A-FA5242AE924B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D5D34EC4-AF91-4B11-AC0A-FA5242AE924B}.Release|Any CPU.Build.0 = Release|Any CPU - {D5D34EC4-AF91-4B11-AC0A-FA5242AE924B}.Release|x64.ActiveCfg = Release|Any CPU - {D5D34EC4-AF91-4B11-AC0A-FA5242AE924B}.Release|x64.Build.0 = Release|Any CPU - {D5D34EC4-AF91-4B11-AC0A-FA5242AE924B}.Release|x86.ActiveCfg = Release|Any CPU - {D5D34EC4-AF91-4B11-AC0A-FA5242AE924B}.Release|x86.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {E4566A6B-47D0-4EA0-989A-D763AC39105D} - EndGlobalSection -EndGlobal diff --git a/Firewall.wixext.v3.ncrunchsolution b/Firewall.wixext.v3.ncrunchsolution deleted file mode 100644 index 10420ac9..00000000 --- a/Firewall.wixext.v3.ncrunchsolution +++ /dev/null @@ -1,6 +0,0 @@ - - - True - True - - \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index be5801da..00000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# Firewall.wixext -WixToolset.Firewall.wixext - Firewall WiX Toolset Extension diff --git a/appveyor.cmd b/appveyor.cmd deleted file mode 100644 index 79c24cc1..00000000 --- a/appveyor.cmd +++ /dev/null @@ -1,14 +0,0 @@ -@setlocal -@pushd %~dp0 - -nuget restore || exit /b - -msbuild -p:Configuration=Release -t:Restore || exit /b - -msbuild -p:Configuration=Release src\test\WixToolsetTest.Firewall\WixToolsetTest.Firewall.csproj || exit /b -dotnet test -c Release --no-build src\test\WixToolsetTest.Firewall || exit /b - -msbuild -p:Configuration=Release -t:Pack src\wixext\WixToolset.Firewall.wixext.csproj || exit /b - -@popd -@endlocal \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 7c686b04..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -# -# Do NOT modify this file. Update the canonical version in Home\repo-template\src\appveyor.yml -# then update all of the repos. - -branches: - only: - - master - - develop - -image: Visual Studio 2019 - -version: 0.0.0.{build} -configuration: Release - -environment: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - DOTNET_CLI_TELEMETRY_OPTOUT: 1 - NUGET_XMLDOC_MODE: skip - -build_script: - - appveyor.cmd - -pull_requests: - do_not_increment_build_number: true - -nuget: - disable_publish_on_pr: true - -skip_branch_with_pr: true -skip_tags: true - -artifacts: -- path: build\Release\**\*.nupkg - name: nuget - -notifications: -- provider: Slack - incoming_webhook: - secure: p5xuu+4x2JHfwGDMDe5KcG1k7gZxqYc4jWVwvyNZv5cvkubPD2waJs5yXMAXZNN7Z63/3PWHb7q4KoY/99AjauYa1nZ4c5qYqRPFRBKTHfA= diff --git a/global.json b/global.json deleted file mode 100644 index 23dd3fa6..00000000 --- a/global.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "msbuild-sdks": { - "WixToolset.Sdk": "4.0.0-build-0211" - } -} diff --git a/nuget.config b/nuget.config deleted file mode 100644 index aaf36562..00000000 --- a/nuget.config +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/.editorconfig b/src/.editorconfig new file mode 100644 index 00000000..1d72e683 --- /dev/null +++ b/src/.editorconfig @@ -0,0 +1,37 @@ +# Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. +# +# Do NOT modify this file. Update the canonical version in Home\repo-template\src\.editorconfig +# then update all of the repos. + +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.{cs,vb}] +dotnet_sort_system_directives_first = true + +[*.cs] +csharp_indent_case_contents = true : error +csharp_indent_switch_labels = true : error +csharp_new_line_before_open_brace = all +csharp_prefer_braces = true : error +csharp_style_expression_bodied_methods = when_on_single_line : suggestion +csharp_style_expression_bodied_constructors = when_on_single_line : suggestion +csharp_style_expression_bodied_operators = when_on_single_line : suggestion +csharp_style_expression_bodied_properties = when_on_single_line : suggestion +csharp_style_expression_bodied_indexers = when_on_single_line : suggestion +csharp_style_expression_bodied_accessors = when_on_single_line : suggestion +csharp_style_var_elsewhere = true : suggestion +csharp_style_var_for_built_in_types = true : suggestion +csharp_style_var_when_type_is_apparent = true : suggestion +dotnet_style_qualification_for_event = true : error +dotnet_style_qualification_for_field = true : error +dotnet_style_qualification_for_method = true : error +dotnet_style_qualification_for_property = true : error + +[*.targets] +indent_size = 2 diff --git a/src/CSharp.Build.props b/src/CSharp.Build.props deleted file mode 100644 index b12f4c6e..00000000 --- a/src/CSharp.Build.props +++ /dev/null @@ -1,11 +0,0 @@ - - - - - true - $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)wix.snk)) - - diff --git a/src/Cpp.Build.props b/src/Cpp.Build.props deleted file mode 100644 index 9b7a1bb5..00000000 --- a/src/Cpp.Build.props +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - Win32 - $(BaseIntermediateOutputPath)$(Configuration)\$(Platform)\ - $(OutputPath)$(Platform)\ - - - - $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) - - - - - $(DisableSpecificCompilerWarnings) - Level4 - $(ProjectDir)inc;$(MSBuildProjectDirectory);$(IntDir);$(SqlCESdkIncludePath);$(ProjectAdditionalIncludeDirectories);%(AdditionalIncludeDirectories) - WIN32;_WINDOWS;_WIN32_MSI=500;_WIN32_WINNT=0x0501;$(ArmPreprocessorDefinitions);$(UnicodePreprocessorDefinitions);_CRT_STDIO_LEGACY_WIDE_SPECIFIERS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) - Use - precomp.h - StdCall - true - false - -YlprecompDefine - /Zc:threadSafeInit- %(AdditionalOptions) - true - - - $(ArmPreprocessorDefinitions);%(PreprocessorDefinitions) - $(ProjectAdditionalResourceIncludeDirectories);%(AdditionalIncludeDirectories) - - - $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ProjectAdditionalLibraryDirectories);%(AdditionalLibraryDirectories) - - - $(ProjectSubSystem) - $(ProjectModuleDefinitionFile) - $(ResourceOnlyDll) - true - $(ProjectAdditionalLinkLibraries);advapi32.lib;comdlg32.lib;user32.lib;oleaut32.lib;gdi32.lib;shell32.lib;ole32.lib;version.lib;%(AdditionalDependencies) - $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ArmLibraryDirectories);$(ProjectAdditionalLinkLibraryDirectories);%(AdditionalLibraryDirectories) - /IGNORE:4099 %(AdditionalOptions) - - - - - - NoExtensions - - - - - CDecl - - - - - OldStyle - true - true - - - - - Disabled - EnableFastChecks - _DEBUG;DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebug - - - - - MinSpace - NDEBUG;%(PreprocessorDefinitions) - true - true - MultiThreaded - - - true - true - - - diff --git a/src/Directory.Build.props b/src/Directory.Build.props deleted file mode 100644 index f83cc154..00000000 --- a/src/Directory.Build.props +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - Debug - false - MSB3246 - - $(MSBuildProjectName) - $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\build\)) - $(BaseOutputPath)obj\$(ProjectName)\ - $(BaseOutputPath)$(Configuration)\ - - WiX Toolset Team - WiX Toolset - Copyright (c) .NET Foundation and contributors. All rights reserved. - MS-RL - WiX Toolset - - - - - - - diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets deleted file mode 100644 index dac7452a..00000000 --- a/src/Directory.Build.targets +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - true - $(SolutionPath) - $(NCrunchOriginalSolutionPath) - - - - - - - $([System.IO.File]::ReadAllText($(TheSolutionPath))) - $([System.IO.Path]::GetDirectoryName( $(TheSolutionPath) )) - (?<="[PackageName]", ")(.*)(?=", ") - - - - - - %(Identity) - $(SolutionFileContent.Contains('\%(Identity).csproj')) - - - - - $(RegexPattern.Replace('[PackageName]','%(PackageName)') ) - $([System.Text.RegularExpressions.Regex]::Match('$(SolutionFileContent)', '%(Pattern)')) - - - - - - - - - - - diff --git a/src/ca/CustomMsiErrors.h b/src/ca/CustomMsiErrors.h deleted file mode 100644 index f149fb31..00000000 --- a/src/ca/CustomMsiErrors.h +++ /dev/null @@ -1,130 +0,0 @@ -#pragma once -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - - -#define GLOBAL_ERROR_BASE 25501 - -#define msierrSecureObjectsFailedCreateSD 25520 -#define msierrSecureObjectsFailedSet 25521 -#define msierrSecureObjectsUnknownType 25522 - -#define msierrXmlFileFailedRead 25530 -#define msierrXmlFileFailedOpen 25531 -#define msierrXmlFileFailedSelect 25532 -#define msierrXmlFileFailedSave 25533 - -#define msierrXmlConfigFailedRead 25540 -#define msierrXmlConfigFailedOpen 25541 -#define msierrXmlConfigFailedSelect 25542 -#define msierrXmlConfigFailedSave 25543 - -#define msierrFirewallCannotConnect 25580 - -//--------------------------------------------------------------------------- -// Server CustomAction Errors -// SERVER range: 26001-26100 -#define SERVER_ERROR_BASE 26000 - -#define msierrIISCannotConnect 26001 -#define msierrIISFailedReadWebSite 26002 -#define msierrIISFailedReadWebDirs 26003 -#define msierrIISFailedReadVDirs 26004 -#define msierrIISFailedReadFilters 26005 -#define msierrIISFailedReadAppPool 26006 -#define msierrIISFailedReadMimeMap 26007 -#define msierrIISFailedReadProp 26008 -#define msierrIISFailedReadWebSvcExt 26009 -#define msierrIISFailedReadWebError 26010 -#define msierrIISFailedReadHttpHeader 26011 - -#define msierrIISFailedSchedTransaction 26031 -#define msierrIISFailedSchedInstallWebs 26032 -#define msierrIISFailedSchedInstallWebDirs 26033 -#define msierrIISFailedSchedInstallVDirs 26034 -#define msierrIISFailedSchedInstallFilters 26035 -#define msierrIISFailedSchedInstallAppPool 26036 -#define msierrIISFailedSchedInstallProp 26037 -#define msierrIISFailedSchedInstallWebSvcExt 26038 - -#define msierrIISFailedSchedUninstallWebs 26051 -#define msierrIISFailedSchedUninstallWebDirs 26052 -#define msierrIISFailedSchedUninstallVDirs 26053 -#define msierrIISFailedSchedUninstallFilters 26054 -#define msierrIISFailedSchedUninstallAppPool 26055 -#define msierrIISFailedSchedUninstallProp 26056 -#define msierrIISFailedSchedUninstallWebSvcExt 26057 - -#define msierrIISFailedStartTransaction 26101 -#define msierrIISFailedOpenKey 26102 -#define msierrIISFailedCreateKey 26103 -#define msierrIISFailedWriteData 26104 -#define msierrIISFailedCreateApp 26105 -#define msierrIISFailedDeleteKey 26106 -#define msierrIISFailedDeleteApp 26107 -#define msierrIISFailedDeleteValue 26108 -#define msierrIISFailedCommitInUse 26109 - -#define msierrSQLFailedCreateDatabase 26201 -#define msierrSQLFailedDropDatabase 26202 -#define msierrSQLFailedConnectDatabase 26203 -#define msierrSQLFailedExecString 26204 -#define msierrSQLDatabaseAlreadyExists 26205 - -#define msierrPERFMONFailedRegisterDLL 26251 -#define msierrPERFMONFailedUnregisterDLL 26252 -#define msierrInstallPerfCounterData 26253 -#define msierrUninstallPerfCounterData 26254 - -#define msierrSMBFailedCreate 26301 -#define msierrSMBFailedDrop 26302 - -#define msierrCERTFailedOpen 26351 -#define msierrCERTFailedAdd 26352 - -#define msierrUSRFailedUserCreate 26401 -#define msierrUSRFailedUserCreatePswd 26402 -#define msierrUSRFailedUserGroupAdd 26403 -#define msierrUSRFailedUserCreateExists 26404 -#define msierrUSRFailedGrantLogonAsService 26405 - -#define msierrDependencyMissingDependencies 26451 -#define msierrDependencyHasDependents 26452 - -//-------------------------------------------------------------------------- -// Managed code CustomAction Errors -// MANAGED range: 27000-27100 -#define MANAGED_ERROR_BASE 27000 - -#define msierrDotNetRuntimeRequired 27000 -//--------------------------------------------------------------------------- -// Public CustomAction Errors -// PUBLIC range: 28001-28100 -#define PUBLIC_ERROR_BASE 28000 - -#define msierrComPlusCannotConnect 28001 -#define msierrComPlusPartitionReadFailed 28002 -#define msierrComPlusPartitionRoleReadFailed 28003 -#define msierrComPlusUserInPartitionRoleReadFailed 28004 -#define msierrComPlusPartitionUserReadFailed 28005 -#define msierrComPlusApplicationReadFailed 28006 -#define msierrComPlusApplicationRoleReadFailed 28007 -#define msierrComPlusUserInApplicationRoleReadFailed 28008 -#define msierrComPlusAssembliesReadFailed 28009 -#define msierrComPlusSubscriptionReadFailed 28010 -#define msierrComPlusPartitionDependency 28011 -#define msierrComPlusPartitionNotFound 28012 -#define msierrComPlusPartitionIdConflict 28013 -#define msierrComPlusPartitionNameConflict 28014 -#define msierrComPlusApplicationDependency 28015 -#define msierrComPlusApplicationNotFound 28016 -#define msierrComPlusApplicationIdConflict 28017 -#define msierrComPlusApplicationNameConflict 28018 -#define msierrComPlusApplicationRoleDependency 28019 -#define msierrComPlusApplicationRoleNotFound 28020 -#define msierrComPlusApplicationRoleConflict 28021 -#define msierrComPlusAssemblyDependency 28022 -#define msierrComPlusSubscriptionIdConflict 28023 -#define msierrComPlusSubscriptionNameConflict 28024 -#define msierrComPlusFailedLookupNames 28025 - -#define msierrMsmqCannotConnect 28101 diff --git a/src/ca/caDecor.h b/src/ca/caDecor.h deleted file mode 100644 index da274650..00000000 --- a/src/ca/caDecor.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - - -#if defined(_M_ARM64) -#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_A64" -#elif defined(_M_AMD64) -#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_X64" -#elif defined(_M_ARM) -#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_ARM" -#else -#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_X86" -#endif diff --git a/src/ca/cost.h b/src/ca/cost.h deleted file mode 100644 index da68c667..00000000 --- a/src/ca/cost.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - - -const UINT COST_FIREWALL_EXCEPTION = 2000; diff --git a/src/ca/dllmain.cpp b/src/ca/dllmain.cpp deleted file mode 100644 index df53f872..00000000 --- a/src/ca/dllmain.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -#include "precomp.h" - -/******************************************************************** -DllMain - standard entry point for all WiX CustomActions - -********************************************************************/ -extern "C" BOOL WINAPI DllMain( - IN HINSTANCE hInst, - IN ULONG ulReason, - IN LPVOID) -{ - switch(ulReason) - { - case DLL_PROCESS_ATTACH: - WcaGlobalInitialize(hInst); - break; - - case DLL_PROCESS_DETACH: - WcaGlobalFinalize(); - break; - } - - return TRUE; -} diff --git a/src/ca/firewall.cpp b/src/ca/firewall.cpp deleted file mode 100644 index caae21a1..00000000 --- a/src/ca/firewall.cpp +++ /dev/null @@ -1,1085 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -#include "precomp.h" - -LPCWSTR vcsFirewallExceptionQuery = - L"SELECT `Name`, `RemoteAddresses`, `Port`, `Protocol`, `Program`, `Attributes`, `Profile`, `Component_`, `Description`, `Direction` FROM `Wix4FirewallException`"; -enum eFirewallExceptionQuery { feqName = 1, feqRemoteAddresses, feqPort, feqProtocol, feqProgram, feqAttributes, feqProfile, feqComponent, feqDescription }; -enum eFirewallExceptionTarget { fetPort = 1, fetApplication, fetUnknown }; -enum eFirewallExceptionAttributes { feaIgnoreFailures = 1 }; - -/****************************************************************** - SchedFirewallExceptions - immediate custom action worker to - register and remove firewall exceptions. - -********************************************************************/ -static UINT SchedFirewallExceptions( - __in MSIHANDLE hInstall, - WCA_TODO todoSched - ) -{ - HRESULT hr = S_OK; - UINT er = ERROR_SUCCESS; - int cFirewallExceptions = 0; - - PMSIHANDLE hView = NULL; - PMSIHANDLE hRec = NULL; - - LPWSTR pwzCustomActionData = NULL; - LPWSTR pwzName = NULL; - LPWSTR pwzRemoteAddresses = NULL; - LPWSTR pwzPort = NULL; - int iProtocol = 0; - int iAttributes = 0; - int iProfile = 0; - LPWSTR pwzProgram = NULL; - LPWSTR pwzComponent = NULL; - LPWSTR pwzFormattedFile = NULL; - LPWSTR pwzDescription = NULL; - int iDirection = 0; - - // initialize - hr = WcaInitialize(hInstall, "SchedFirewallExceptions"); - ExitOnFailure(hr, "failed to initialize"); - - // anything to do? - if (S_OK != WcaTableExists(L"Wix4FirewallException")) - { - WcaLog(LOGMSG_STANDARD, "Wix4FirewallException table doesn't exist, so there are no firewall exceptions to configure."); - ExitFunction(); - } - - // query and loop through all the firewall exceptions - hr = WcaOpenExecuteView(vcsFirewallExceptionQuery, &hView); - ExitOnFailure(hr, "failed to open view on Wix4FirewallException table"); - - while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) - { - hr = WcaGetRecordFormattedString(hRec, feqName, &pwzName); - ExitOnFailure(hr, "failed to get firewall exception name"); - - hr = WcaGetRecordFormattedString(hRec, feqRemoteAddresses, &pwzRemoteAddresses); - ExitOnFailure(hr, "failed to get firewall exception remote addresses"); - - hr = WcaGetRecordFormattedString(hRec, feqPort, &pwzPort); - ExitOnFailure(hr, "failed to get firewall exception port"); - - hr = WcaGetRecordInteger(hRec, feqProtocol, &iProtocol); - ExitOnFailure(hr, "failed to get firewall exception protocol"); - - hr = WcaGetRecordFormattedString(hRec, feqProgram, &pwzProgram); - ExitOnFailure(hr, "failed to get firewall exception program"); - - hr = WcaGetRecordInteger(hRec, feqAttributes, &iAttributes); - ExitOnFailure(hr, "failed to get firewall exception attributes"); - - hr = WcaGetRecordInteger(hRec, feqProfile, &iProfile); - ExitOnFailure(hr, "failed to get firewall exception profile"); - - hr = WcaGetRecordString(hRec, feqComponent, &pwzComponent); - ExitOnFailure(hr, "failed to get firewall exception component"); - - hr = WcaGetRecordString(hRec, feqDescription, &pwzDescription); - ExitOnFailure(hr, "failed to get firewall description"); - - // figure out what we're doing for this exception, treating reinstall the same as install - WCA_TODO todoComponent = WcaGetComponentToDo(pwzComponent); - if ((WCA_TODO_REINSTALL == todoComponent ? WCA_TODO_INSTALL : todoComponent) != todoSched) - { - WcaLog(LOGMSG_STANDARD, "Component '%ls' action state (%d) doesn't match request (%d)", pwzComponent, todoComponent, todoSched); - continue; - } - - // action :: name :: profile :: remoteaddresses :: attributes :: target :: {port::protocol | path} - ++cFirewallExceptions; - hr = WcaWriteIntegerToCaData(todoComponent, &pwzCustomActionData); - ExitOnFailure(hr, "failed to write exception action to custom action data"); - - hr = WcaWriteStringToCaData(pwzName, &pwzCustomActionData); - ExitOnFailure(hr, "failed to write exception name to custom action data"); - - hr = WcaWriteIntegerToCaData(iProfile, &pwzCustomActionData); - ExitOnFailure(hr, "failed to write exception profile to custom action data"); - - hr = WcaWriteStringToCaData(pwzRemoteAddresses, &pwzCustomActionData); - ExitOnFailure(hr, "failed to write exception remote addresses to custom action data"); - - hr = WcaWriteIntegerToCaData(iAttributes, &pwzCustomActionData); - ExitOnFailure(hr, "failed to write exception attributes to custom action data"); - - if (*pwzProgram) - { - // If program is defined, we have an application exception. - hr = WcaWriteIntegerToCaData(fetApplication, &pwzCustomActionData); - ExitOnFailure(hr, "failed to write exception target (application) to custom action data"); - - hr = WcaWriteStringToCaData(pwzProgram, &pwzCustomActionData); - ExitOnFailure(hr, "failed to write application path to custom action data"); - } - else - { - // we have a port-only exception - hr = WcaWriteIntegerToCaData(fetPort, &pwzCustomActionData); - ExitOnFailure(hr, "failed to write exception target (port) to custom action data"); - } - - hr = WcaWriteStringToCaData(pwzPort, &pwzCustomActionData); - ExitOnFailure(hr, "failed to write application path to custom action data"); - - hr = WcaWriteIntegerToCaData(iProtocol, &pwzCustomActionData); - ExitOnFailure(hr, "failed to write exception protocol to custom action data"); - - hr = WcaWriteStringToCaData(pwzDescription, &pwzCustomActionData); - ExitOnFailure(hr, "failed to write firewall rule description to custom action data"); - - hr = WcaWriteIntegerToCaData(iDirection, &pwzCustomActionData); - ExitOnFailure(hr, "failed to write firewall rule direction to custom action data"); - } - - // reaching the end of the list is actually a good thing, not an error - if (E_NOMOREITEMS == hr) - { - hr = S_OK; - } - ExitOnFailure(hr, "failure occured while processing Wix4FirewallException table"); - - // schedule ExecFirewallExceptions if there's anything to do - if (pwzCustomActionData && *pwzCustomActionData) - { - WcaLog(LOGMSG_STANDARD, "Scheduling firewall exception (%ls)", pwzCustomActionData); - - if (WCA_TODO_INSTALL == todoSched) - { - hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"RollbackFirewallExceptionsInstall"), pwzCustomActionData, cFirewallExceptions * COST_FIREWALL_EXCEPTION); - ExitOnFailure(hr, "failed to schedule firewall install exceptions rollback"); - hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"ExecFirewallExceptionsInstall"), pwzCustomActionData, cFirewallExceptions * COST_FIREWALL_EXCEPTION); - ExitOnFailure(hr, "failed to schedule firewall install exceptions execution"); - } - else - { - hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"RollbackFirewallExceptionsUninstall"), pwzCustomActionData, cFirewallExceptions * COST_FIREWALL_EXCEPTION); - ExitOnFailure(hr, "failed to schedule firewall uninstall exceptions rollback"); - hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"ExecFirewallExceptionsUninstall"), pwzCustomActionData, cFirewallExceptions * COST_FIREWALL_EXCEPTION); - ExitOnFailure(hr, "failed to schedule firewall uninstall exceptions execution"); - } - } - else - { - WcaLog(LOGMSG_STANDARD, "No firewall exceptions scheduled"); - } - -LExit: - ReleaseStr(pwzCustomActionData); - ReleaseStr(pwzName); - ReleaseStr(pwzRemoteAddresses); - ReleaseStr(pwzPort); - ReleaseStr(pwzProgram); - ReleaseStr(pwzComponent); - ReleaseStr(pwzDescription); - ReleaseStr(pwzFormattedFile); - - return WcaFinalize(er = FAILED(hr) ? ERROR_INSTALL_FAILURE : er); -} - -/****************************************************************** - SchedFirewallExceptionsInstall - immediate custom action entry - point to register firewall exceptions. - -********************************************************************/ -extern "C" UINT __stdcall SchedFirewallExceptionsInstall( - __in MSIHANDLE hInstall - ) -{ - return SchedFirewallExceptions(hInstall, WCA_TODO_INSTALL); -} - -/****************************************************************** - SchedFirewallExceptionsUninstall - immediate custom action entry - point to remove firewall exceptions. - -********************************************************************/ -extern "C" UINT __stdcall SchedFirewallExceptionsUninstall( - __in MSIHANDLE hInstall - ) -{ - return SchedFirewallExceptions(hInstall, WCA_TODO_UNINSTALL); -} - -/****************************************************************** - GetFirewallRules - Get the collection of firewall rules. - -********************************************************************/ -static HRESULT GetFirewallRules( - __in BOOL fIgnoreFailures, - __out INetFwRules** ppNetFwRules - ) -{ - HRESULT hr = S_OK; - INetFwPolicy2* pNetFwPolicy2 = NULL; - INetFwRules* pNetFwRules = NULL; - *ppNetFwRules = NULL; - - do - { - ReleaseNullObject(pNetFwPolicy2); - ReleaseNullObject(pNetFwRules); - - if (SUCCEEDED(hr = ::CoCreateInstance(__uuidof(NetFwPolicy2), NULL, CLSCTX_ALL, __uuidof(INetFwPolicy2), (void**)&pNetFwPolicy2)) && - SUCCEEDED(hr = pNetFwPolicy2->get_Rules(&pNetFwRules))) - { - break; - } - else if (fIgnoreFailures) - { - ExitFunction1(hr = S_FALSE); - } - else - { - WcaLog(LOGMSG_STANDARD, "Failed to connect to Windows Firewall"); - UINT er = WcaErrorMessage(msierrFirewallCannotConnect, hr, INSTALLMESSAGE_ERROR | MB_ABORTRETRYIGNORE, 0); - switch (er) - { - case IDABORT: // exit with the current HRESULT - ExitFunction(); - case IDRETRY: // clean up and retry the loop - hr = S_FALSE; - break; - case IDIGNORE: // pass S_FALSE back to the caller, who knows how to ignore the failure - ExitFunction1(hr = S_FALSE); - default: // No UI, so default is to fail. - ExitFunction(); - } - } - } while (S_FALSE == hr); - - *ppNetFwRules = pNetFwRules; - pNetFwRules = NULL; - -LExit: - ReleaseObject(pNetFwPolicy2); - ReleaseObject(pNetFwRules); - - return hr; -} - -/****************************************************************** - CreateFwRuleObject - CoCreate a firewall rule, and set the common set of properties which are shared - between port and application firewall rules - -********************************************************************/ -static HRESULT CreateFwRuleObject( - __in BSTR bstrName, - __in int iProfile, - __in_opt LPCWSTR wzRemoteAddresses, - __in LPCWSTR wzPort, - __in int iProtocol, - __in LPCWSTR wzDescription, - __in int iDirection, - __out INetFwRule** ppNetFwRule - ) -{ - HRESULT hr = S_OK; - BSTR bstrRemoteAddresses = NULL; - BSTR bstrPort = NULL; - BSTR bstrDescription = NULL; - INetFwRule* pNetFwRule = NULL; - *ppNetFwRule = NULL; - - // convert to BSTRs to make COM happy - bstrRemoteAddresses = ::SysAllocString(wzRemoteAddresses); - ExitOnNull(bstrRemoteAddresses, hr, E_OUTOFMEMORY, "failed SysAllocString for remote addresses"); - bstrPort = ::SysAllocString(wzPort); - ExitOnNull(bstrPort, hr, E_OUTOFMEMORY, "failed SysAllocString for port"); - bstrDescription = ::SysAllocString(wzDescription); - ExitOnNull(bstrDescription, hr, E_OUTOFMEMORY, "failed SysAllocString for description"); - - hr = ::CoCreateInstance(__uuidof(NetFwRule), NULL, CLSCTX_ALL, __uuidof(INetFwRule), (void**)&pNetFwRule); - ExitOnFailure(hr, "failed to create NetFwRule object"); - - hr = pNetFwRule->put_Name(bstrName); - ExitOnFailure(hr, "failed to set exception name"); - - hr = pNetFwRule->put_Profiles(static_cast(iProfile)); - ExitOnFailure(hr, "failed to set exception profile"); - - if (MSI_NULL_INTEGER != iProtocol) - { - hr = pNetFwRule->put_Protocol(static_cast(iProtocol)); - ExitOnFailure(hr, "failed to set exception protocol"); - } - - if (bstrPort && *bstrPort) - { - hr = pNetFwRule->put_LocalPorts(bstrPort); - ExitOnFailure(hr, "failed to set exception port"); - } - - if (bstrRemoteAddresses && *bstrRemoteAddresses) - { - hr = pNetFwRule->put_RemoteAddresses(bstrRemoteAddresses); - ExitOnFailure(hr, "failed to set exception remote addresses '%ls'", bstrRemoteAddresses); - } - - if (bstrDescription && *bstrDescription) - { - hr = pNetFwRule->put_Description(bstrDescription); - ExitOnFailure(hr, "failed to set exception description '%ls'", bstrDescription); - } - - if (MSI_NULL_INTEGER != iDirection) - { - hr = pNetFwRule->put_Direction(static_cast (iDirection)); - ExitOnFailure(hr, "failed to set exception direction"); - } - - *ppNetFwRule = pNetFwRule; - pNetFwRule = NULL; - -LExit: - ReleaseBSTR(bstrRemoteAddresses); - ReleaseBSTR(bstrPort); - ReleaseBSTR(bstrDescription); - ReleaseObject(pNetFwRule); - - return hr; -} - -/****************************************************************** - FSupportProfiles - Returns true if we support profiles on this machine. - (Only on Vista or later) - -********************************************************************/ -static BOOL FSupportProfiles() -{ - BOOL fSupportProfiles = FALSE; - INetFwRules* pNetFwRules = NULL; - - // We only support profiles if we can co-create an instance of NetFwPolicy2. - // This will not work on pre-vista machines. - if (SUCCEEDED(GetFirewallRules(TRUE, &pNetFwRules)) && pNetFwRules != NULL) - { - fSupportProfiles = TRUE; - ReleaseObject(pNetFwRules); - } - - return fSupportProfiles; -} - -/****************************************************************** - GetCurrentFirewallProfile - get the active firewall profile as an - INetFwProfile, which owns the lists of exceptions we're - updating. - -********************************************************************/ -static HRESULT GetCurrentFirewallProfile( - __in BOOL fIgnoreFailures, - __out INetFwProfile** ppfwProfile - ) -{ - HRESULT hr = S_OK; - INetFwMgr* pfwMgr = NULL; - INetFwPolicy* pfwPolicy = NULL; - INetFwProfile* pfwProfile = NULL; - *ppfwProfile = NULL; - - do - { - ReleaseNullObject(pfwPolicy); - ReleaseNullObject(pfwMgr); - ReleaseNullObject(pfwProfile); - - if (SUCCEEDED(hr = ::CoCreateInstance(__uuidof(NetFwMgr), NULL, CLSCTX_INPROC_SERVER, __uuidof(INetFwMgr), (void**)&pfwMgr)) && - SUCCEEDED(hr = pfwMgr->get_LocalPolicy(&pfwPolicy)) && - SUCCEEDED(hr = pfwPolicy->get_CurrentProfile(&pfwProfile))) - { - break; - } - else if (fIgnoreFailures) - { - ExitFunction1(hr = S_FALSE); - } - else - { - WcaLog(LOGMSG_STANDARD, "Failed to connect to Windows Firewall"); - UINT er = WcaErrorMessage(msierrFirewallCannotConnect, hr, INSTALLMESSAGE_ERROR | MB_ABORTRETRYIGNORE, 0); - switch (er) - { - case IDABORT: // exit with the current HRESULT - ExitFunction(); - case IDRETRY: // clean up and retry the loop - hr = S_FALSE; - break; - case IDIGNORE: // pass S_FALSE back to the caller, who knows how to ignore the failure - ExitFunction1(hr = S_FALSE); - default: // No UI, so default is to fail. - ExitFunction(); - } - } - } while (S_FALSE == hr); - - *ppfwProfile = pfwProfile; - pfwProfile = NULL; - -LExit: - ReleaseObject(pfwPolicy); - ReleaseObject(pfwMgr); - ReleaseObject(pfwProfile); - - return hr; -} - -/****************************************************************** - AddApplicationException - -********************************************************************/ -static HRESULT AddApplicationException( - __in LPCWSTR wzFile, - __in LPCWSTR wzName, - __in int iProfile, - __in_opt LPCWSTR wzRemoteAddresses, - __in BOOL fIgnoreFailures, - __in LPCWSTR wzPort, - __in int iProtocol, - __in LPCWSTR wzDescription, - __in int iDirection - ) -{ - HRESULT hr = S_OK; - BSTR bstrFile = NULL; - BSTR bstrName = NULL; - INetFwRules* pNetFwRules = NULL; - INetFwRule* pNetFwRule = NULL; - - // convert to BSTRs to make COM happy - bstrFile = ::SysAllocString(wzFile); - ExitOnNull(bstrFile, hr, E_OUTOFMEMORY, "failed SysAllocString for path"); - bstrName = ::SysAllocString(wzName); - ExitOnNull(bstrName, hr, E_OUTOFMEMORY, "failed SysAllocString for name"); - - // get the collection of firewall rules - hr = GetFirewallRules(fIgnoreFailures, &pNetFwRules); - ExitOnFailure(hr, "failed to get firewall rules object"); - if (S_FALSE == hr) // user or package author chose to ignore missing firewall - { - ExitFunction(); - } - - // try to find it (i.e., support reinstall) - hr = pNetFwRules->Item(bstrName, &pNetFwRule); - if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr) - { - hr = CreateFwRuleObject(bstrName, iProfile, wzRemoteAddresses, wzPort, iProtocol, wzDescription, iDirection, &pNetFwRule); - ExitOnFailure(hr, "failed to create FwRule object"); - - // set edge traversal to true - hr = pNetFwRule->put_EdgeTraversal(VARIANT_TRUE); - ExitOnFailure(hr, "failed to set application exception edgetraversal property"); - - // set path - hr = pNetFwRule->put_ApplicationName(bstrFile); - ExitOnFailure(hr, "failed to set application name"); - - // enable it - hr = pNetFwRule->put_Enabled(VARIANT_TRUE); - ExitOnFailure(hr, "failed to to enable application exception"); - - // add it to the list of authorized apps - hr = pNetFwRules->Add(pNetFwRule); - ExitOnFailure(hr, "failed to add app to the authorized apps list"); - } - else - { - // we found an existing app exception (if we succeeded, that is) - ExitOnFailure(hr, "failed trying to find existing app"); - - // enable it (just in case it was disabled) - pNetFwRule->put_Enabled(VARIANT_TRUE); - } - -LExit: - ReleaseBSTR(bstrName); - ReleaseBSTR(bstrFile); - ReleaseObject(pNetFwRules); - ReleaseObject(pNetFwRule); - - return fIgnoreFailures ? S_OK : hr; -} - -/****************************************************************** - AddApplicationExceptionOnCurrentProfile - -********************************************************************/ -static HRESULT AddApplicationExceptionOnCurrentProfile( - __in LPCWSTR wzFile, - __in LPCWSTR wzName, - __in_opt LPCWSTR wzRemoteAddresses, - __in BOOL fIgnoreFailures - ) -{ - HRESULT hr = S_OK; - BSTR bstrFile = NULL; - BSTR bstrName = NULL; - BSTR bstrRemoteAddresses = NULL; - INetFwProfile* pfwProfile = NULL; - INetFwAuthorizedApplications* pfwApps = NULL; - INetFwAuthorizedApplication* pfwApp = NULL; - - // convert to BSTRs to make COM happy - bstrFile = ::SysAllocString(wzFile); - ExitOnNull(bstrFile, hr, E_OUTOFMEMORY, "failed SysAllocString for path"); - bstrName = ::SysAllocString(wzName); - ExitOnNull(bstrName, hr, E_OUTOFMEMORY, "failed SysAllocString for name"); - bstrRemoteAddresses = ::SysAllocString(wzRemoteAddresses); - ExitOnNull(bstrRemoteAddresses, hr, E_OUTOFMEMORY, "failed SysAllocString for remote addresses"); - - // get the firewall profile, which is our entry point for adding exceptions - hr = GetCurrentFirewallProfile(fIgnoreFailures, &pfwProfile); - ExitOnFailure(hr, "failed to get firewall profile"); - if (S_FALSE == hr) // user or package author chose to ignore missing firewall - { - ExitFunction(); - } - - // first, let's see if the app is already on the exception list - hr = pfwProfile->get_AuthorizedApplications(&pfwApps); - ExitOnFailure(hr, "failed to get list of authorized apps"); - - // try to find it (i.e., support reinstall) - hr = pfwApps->Item(bstrFile, &pfwApp); - if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr) - { - // not found, so we get to add it - hr = ::CoCreateInstance(__uuidof(NetFwAuthorizedApplication), NULL, CLSCTX_INPROC_SERVER, __uuidof(INetFwAuthorizedApplication), reinterpret_cast(&pfwApp)); - ExitOnFailure(hr, "failed to create authorized app"); - - // set the display name - hr = pfwApp->put_Name(bstrName); - ExitOnFailure(hr, "failed to set authorized app name"); - - // set path - hr = pfwApp->put_ProcessImageFileName(bstrFile); - ExitOnFailure(hr, "failed to set authorized app path"); - - // set the allowed remote addresses - if (bstrRemoteAddresses && *bstrRemoteAddresses) - { - hr = pfwApp->put_RemoteAddresses(bstrRemoteAddresses); - ExitOnFailure(hr, "failed to set authorized app remote addresses"); - } - - // add it to the list of authorized apps - hr = pfwApps->Add(pfwApp); - ExitOnFailure(hr, "failed to add app to the authorized apps list"); - } - else - { - // we found an existing app exception (if we succeeded, that is) - ExitOnFailure(hr, "failed trying to find existing app"); - - // enable it (just in case it was disabled) - pfwApp->put_Enabled(VARIANT_TRUE); - } - -LExit: - ReleaseBSTR(bstrRemoteAddresses); - ReleaseBSTR(bstrName); - ReleaseBSTR(bstrFile); - ReleaseObject(pfwApp); - ReleaseObject(pfwApps); - ReleaseObject(pfwProfile); - - return fIgnoreFailures ? S_OK : hr; -} - -/****************************************************************** - AddPortException - -********************************************************************/ -static HRESULT AddPortException( - __in LPCWSTR wzName, - __in int iProfile, - __in_opt LPCWSTR wzRemoteAddresses, - __in BOOL fIgnoreFailures, - __in LPCWSTR wzPort, - __in int iProtocol, - __in LPCWSTR wzDescription, - __in int iDirection -) -{ - HRESULT hr = S_OK; - BSTR bstrName = NULL; - INetFwRules* pNetFwRules = NULL; - INetFwRule* pNetFwRule = NULL; - - // convert to BSTRs to make COM happy - bstrName = ::SysAllocString(wzName); - ExitOnNull(bstrName, hr, E_OUTOFMEMORY, "failed SysAllocString for name"); - - // get the collection of firewall rules - hr = GetFirewallRules(fIgnoreFailures, &pNetFwRules); - ExitOnFailure(hr, "failed to get firewall rules object"); - if (S_FALSE == hr) // user or package author chose to ignore missing firewall - { - ExitFunction(); - } - - // try to find it (i.e., support reinstall) - hr = pNetFwRules->Item(bstrName, &pNetFwRule); - if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr) - { - hr = CreateFwRuleObject(bstrName, iProfile, wzRemoteAddresses, wzPort, iProtocol, wzDescription, iDirection, &pNetFwRule); - ExitOnFailure(hr, "failed to create FwRule object"); - - // enable it - hr = pNetFwRule->put_Enabled(VARIANT_TRUE); - ExitOnFailure(hr, "failed to to enable port exception"); - - // add it to the list of authorized ports - hr = pNetFwRules->Add(pNetFwRule); - ExitOnFailure(hr, "failed to add app to the authorized ports list"); - } - else - { - // we found an existing port exception (if we succeeded, that is) - ExitOnFailure(hr, "failed trying to find existing port rule"); - - // enable it (just in case it was disabled) - pNetFwRule->put_Enabled(VARIANT_TRUE); - } - -LExit: - ReleaseBSTR(bstrName); - ReleaseObject(pNetFwRules); - ReleaseObject(pNetFwRule); - - return fIgnoreFailures ? S_OK : hr; -} - -/****************************************************************** - AddPortExceptionOnCurrentProfile - -********************************************************************/ -static HRESULT AddPortExceptionOnCurrentProfile( - __in LPCWSTR wzName, - __in_opt LPCWSTR wzRemoteAddresses, - __in BOOL fIgnoreFailures, - __in int iPort, - __in int iProtocol - ) -{ - HRESULT hr = S_OK; - BSTR bstrName = NULL; - BSTR bstrRemoteAddresses = NULL; - INetFwProfile* pfwProfile = NULL; - INetFwOpenPorts* pfwPorts = NULL; - INetFwOpenPort* pfwPort = NULL; - - // convert to BSTRs to make COM happy - bstrName = ::SysAllocString(wzName); - ExitOnNull(bstrName, hr, E_OUTOFMEMORY, "failed SysAllocString for name"); - bstrRemoteAddresses = ::SysAllocString(wzRemoteAddresses); - ExitOnNull(bstrRemoteAddresses, hr, E_OUTOFMEMORY, "failed SysAllocString for remote addresses"); - - // create and initialize a new open port object - hr = ::CoCreateInstance(__uuidof(NetFwOpenPort), NULL, CLSCTX_INPROC_SERVER, __uuidof(INetFwOpenPort), reinterpret_cast(&pfwPort)); - ExitOnFailure(hr, "failed to create new open port"); - - hr = pfwPort->put_Port(iPort); - ExitOnFailure(hr, "failed to set exception port"); - - hr = pfwPort->put_Protocol(static_cast(iProtocol)); - ExitOnFailure(hr, "failed to set exception protocol"); - - if (bstrRemoteAddresses && *bstrRemoteAddresses) - { - hr = pfwPort->put_RemoteAddresses(bstrRemoteAddresses); - ExitOnFailure(hr, "failed to set exception remote addresses '%ls'", bstrRemoteAddresses); - } - - hr = pfwPort->put_Name(bstrName); - ExitOnFailure(hr, "failed to set exception name"); - - // get the firewall profile, its current list of open ports, and add ours - hr = GetCurrentFirewallProfile(fIgnoreFailures, &pfwProfile); - ExitOnFailure(hr, "failed to get firewall profile"); - if (S_FALSE == hr) // user or package author chose to ignore missing firewall - { - ExitFunction(); - } - - hr = pfwProfile->get_GloballyOpenPorts(&pfwPorts); - ExitOnFailure(hr, "failed to get open ports"); - - hr = pfwPorts->Add(pfwPort); - ExitOnFailure(hr, "failed to add exception to global list"); - -LExit: - ReleaseBSTR(bstrRemoteAddresses); - ReleaseBSTR(bstrName); - ReleaseObject(pfwProfile); - ReleaseObject(pfwPorts); - ReleaseObject(pfwPort); - - return fIgnoreFailures ? S_OK : hr; -} - -/****************************************************************** - RemoveException - Removes the exception rule with the given name. - -********************************************************************/ -static HRESULT RemoveException( - __in LPCWSTR wzName, - __in BOOL fIgnoreFailures - ) -{ - HRESULT hr = S_OK;; - INetFwRules* pNetFwRules = NULL; - - // convert to BSTRs to make COM happy - BSTR bstrName = ::SysAllocString(wzName); - ExitOnNull(bstrName, hr, E_OUTOFMEMORY, "failed SysAllocString for path"); - - // get the collection of firewall rules - hr = GetFirewallRules(fIgnoreFailures, &pNetFwRules); - ExitOnFailure(hr, "failed to get firewall rules object"); - if (S_FALSE == hr) // user or package author chose to ignore missing firewall - { - ExitFunction(); - } - - hr = pNetFwRules->Remove(bstrName); - ExitOnFailure(hr, "failed to remove authorized app"); - -LExit: - ReleaseBSTR(bstrName); - ReleaseObject(pNetFwRules); - - return fIgnoreFailures ? S_OK : hr; -} - -/****************************************************************** - RemoveApplicationExceptionFromCurrentProfile - -********************************************************************/ -static HRESULT RemoveApplicationExceptionFromCurrentProfile( - __in LPCWSTR wzFile, - __in BOOL fIgnoreFailures - ) -{ - HRESULT hr = S_OK; - INetFwProfile* pfwProfile = NULL; - INetFwAuthorizedApplications* pfwApps = NULL; - - // convert to BSTRs to make COM happy - BSTR bstrFile = ::SysAllocString(wzFile); - ExitOnNull(bstrFile, hr, E_OUTOFMEMORY, "failed SysAllocString for path"); - - // get the firewall profile, which is our entry point for removing exceptions - hr = GetCurrentFirewallProfile(fIgnoreFailures, &pfwProfile); - ExitOnFailure(hr, "failed to get firewall profile"); - if (S_FALSE == hr) // user or package author chose to ignore missing firewall - { - ExitFunction(); - } - - // now get the list of app exceptions and remove the one - hr = pfwProfile->get_AuthorizedApplications(&pfwApps); - ExitOnFailure(hr, "failed to get list of authorized apps"); - - hr = pfwApps->Remove(bstrFile); - ExitOnFailure(hr, "failed to remove authorized app"); - -LExit: - ReleaseBSTR(bstrFile); - ReleaseObject(pfwApps); - ReleaseObject(pfwProfile); - - return fIgnoreFailures ? S_OK : hr; -} - -/****************************************************************** - RemovePortExceptionFromCurrentProfile - -********************************************************************/ -static HRESULT RemovePortExceptionFromCurrentProfile( - __in int iPort, - __in int iProtocol, - __in BOOL fIgnoreFailures - ) -{ - HRESULT hr = S_OK; - INetFwProfile* pfwProfile = NULL; - INetFwOpenPorts* pfwPorts = NULL; - - // get the firewall profile, which is our entry point for adding exceptions - hr = GetCurrentFirewallProfile(fIgnoreFailures, &pfwProfile); - ExitOnFailure(hr, "failed to get firewall profile"); - if (S_FALSE == hr) // user or package author chose to ignore missing firewall - { - ExitFunction(); - } - - hr = pfwProfile->get_GloballyOpenPorts(&pfwPorts); - ExitOnFailure(hr, "failed to get open ports"); - - hr = pfwPorts->Remove(iPort, static_cast(iProtocol)); - ExitOnFailure(hr, "failed to remove open port %d, protocol %d", iPort, iProtocol); - -LExit: - return fIgnoreFailures ? S_OK : hr; -} - -static HRESULT AddApplicationException( - __in BOOL fSupportProfiles, - __in LPCWSTR wzFile, - __in LPCWSTR wzName, - __in int iProfile, - __in_opt LPCWSTR wzRemoteAddresses, - __in BOOL fIgnoreFailures, - __in LPCWSTR wzPort, - __in int iProtocol, - __in LPCWSTR wzDescription, - __in int iDirection -) -{ - HRESULT hr = S_OK; - - if (fSupportProfiles) - { - hr = AddApplicationException(wzFile, wzName, iProfile, wzRemoteAddresses, fIgnoreFailures, wzPort, iProtocol, wzDescription, iDirection); - } - else - { - if (0 != *wzPort || MSI_NULL_INTEGER != iProtocol) - { - // NOTE: This is treated as an error rather than either creating a rule based on just the application (no port), or - // just the port because it is unclear what is the proper fall back. For example, suppose that you have code that - // runs in dllhost.exe. Clearly falling back to opening all of dllhost is wrong. Because the firewall is a security - // feature, it seems better to require the MSI author to indicate the behavior that they want. - WcaLog(LOGMSG_STANDARD, "FirewallExtension: Cannot add firewall rule '%ls', which defines both an application and a port or protocol. Such a rule requires Microsoft Windows Vista or later.", wzName); - return fIgnoreFailures ? S_OK : E_NOTIMPL; - } - - hr = AddApplicationExceptionOnCurrentProfile(wzFile, wzName, wzRemoteAddresses, fIgnoreFailures); - } - - return hr; -} - -static HRESULT AddPortException( - __in BOOL fSupportProfiles, - __in LPCWSTR wzName, - __in int iProfile, - __in_opt LPCWSTR wzRemoteAddresses, - __in BOOL fIgnoreFailures, - __in LPCWSTR wzPort, - __in int iProtocol, - __in LPCWSTR wzDescription, - __in int iDirection -) -{ - HRESULT hr = S_OK; - - if (fSupportProfiles) - { - hr = AddPortException(wzName, iProfile, wzRemoteAddresses, fIgnoreFailures, wzPort, iProtocol, wzDescription, iDirection); - } - else - { - hr = AddPortExceptionOnCurrentProfile(wzName, wzRemoteAddresses, fIgnoreFailures, wcstol(wzPort, NULL, 10), iProtocol); - } - - return hr; -} - -static HRESULT RemoveApplicationException( - __in BOOL fSupportProfiles, - __in LPCWSTR wzName, - __in LPCWSTR wzFile, - __in BOOL fIgnoreFailures, - __in LPCWSTR wzPort, - __in int iProtocol - ) -{ - HRESULT hr = S_OK; - - if (fSupportProfiles) - { - hr = RemoveException(wzName, fIgnoreFailures); - } - else - { - if (0 != *wzPort || MSI_NULL_INTEGER != iProtocol) - { - WcaLog(LOGMSG_STANDARD, "FirewallExtension: Cannot remove firewall rule '%ls', which defines both an application and a port or protocol. Such a rule requires Microsoft Windows Vista or later.", wzName); - return S_OK; - } - - hr = RemoveApplicationExceptionFromCurrentProfile(wzFile, fIgnoreFailures); - } - - return hr; -} - -static HRESULT RemovePortException( - __in BOOL fSupportProfiles, - __in LPCWSTR wzName, - __in LPCWSTR wzPort, - __in int iProtocol, - __in BOOL fIgnoreFailures - ) -{ - HRESULT hr = S_OK; - - if (fSupportProfiles) - { - hr = RemoveException(wzName, fIgnoreFailures); - } - else - { - hr = RemovePortExceptionFromCurrentProfile(wcstol(wzPort, NULL, 10), iProtocol, fIgnoreFailures); - } - - return hr; -} - -/****************************************************************** - ExecFirewallExceptions - deferred custom action entry point to - register and remove firewall exceptions. - -********************************************************************/ -extern "C" UINT __stdcall ExecFirewallExceptions( - __in MSIHANDLE hInstall - ) -{ - HRESULT hr = S_OK; - BOOL fSupportProfiles = FALSE; - LPWSTR pwz = NULL; - LPWSTR pwzCustomActionData = NULL; - int iTodo = WCA_TODO_UNKNOWN; - LPWSTR pwzName = NULL; - LPWSTR pwzRemoteAddresses = NULL; - int iAttributes = 0; - int iTarget = fetUnknown; - LPWSTR pwzFile = NULL; - LPWSTR pwzPort = NULL; - LPWSTR pwzDescription = NULL; - int iProtocol = 0; - int iProfile = 0; - int iDirection = 0; - - // initialize - hr = WcaInitialize(hInstall, "ExecFirewallExceptions"); - ExitOnFailure(hr, "failed to initialize"); - - hr = WcaGetProperty( L"CustomActionData", &pwzCustomActionData); - ExitOnFailure(hr, "failed to get CustomActionData"); - WcaLog(LOGMSG_TRACEONLY, "CustomActionData: %ls", pwzCustomActionData); - - hr = ::CoInitialize(NULL); - ExitOnFailure(hr, "failed to initialize COM"); - - // Find out if we support profiles (only on Vista or later) - fSupportProfiles = FSupportProfiles(); - - // loop through all the passed in data - pwz = pwzCustomActionData; - while (pwz && *pwz) - { - // extract the custom action data and if rolling back, swap INSTALL and UNINSTALL - hr = WcaReadIntegerFromCaData(&pwz, &iTodo); - ExitOnFailure(hr, "failed to read todo from custom action data"); - if (::MsiGetMode(hInstall, MSIRUNMODE_ROLLBACK)) - { - if (WCA_TODO_INSTALL == iTodo) - { - iTodo = WCA_TODO_UNINSTALL; - } - else if (WCA_TODO_UNINSTALL == iTodo) - { - iTodo = WCA_TODO_INSTALL; - } - } - - hr = WcaReadStringFromCaData(&pwz, &pwzName); - ExitOnFailure(hr, "failed to read name from custom action data"); - - hr = WcaReadIntegerFromCaData(&pwz, &iProfile); - ExitOnFailure(hr, "failed to read profile from custom action data"); - - hr = WcaReadStringFromCaData(&pwz, &pwzRemoteAddresses); - ExitOnFailure(hr, "failed to read remote addresses from custom action data"); - - hr = WcaReadIntegerFromCaData(&pwz, &iAttributes); - ExitOnFailure(hr, "failed to read attributes from custom action data"); - BOOL fIgnoreFailures = feaIgnoreFailures == (iAttributes & feaIgnoreFailures); - - hr = WcaReadIntegerFromCaData(&pwz, &iTarget); - ExitOnFailure(hr, "failed to read target from custom action data"); - - if (iTarget == fetApplication) - { - hr = WcaReadStringFromCaData(&pwz, &pwzFile); - ExitOnFailure(hr, "failed to read file path from custom action data"); - } - - hr = WcaReadStringFromCaData(&pwz, &pwzPort); - ExitOnFailure(hr, "failed to read port from custom action data"); - hr = WcaReadIntegerFromCaData(&pwz, &iProtocol); - ExitOnFailure(hr, "failed to read protocol from custom action data"); - hr = WcaReadStringFromCaData(&pwz, &pwzDescription); - ExitOnFailure(hr, "failed to read protocol from custom action data"); - hr = WcaReadIntegerFromCaData(&pwz, &iDirection); - ExitOnFailure(hr, "failed to read direction from custom action data"); - - switch (iTarget) - { - case fetPort: - switch (iTodo) - { - case WCA_TODO_INSTALL: - case WCA_TODO_REINSTALL: - WcaLog(LOGMSG_STANDARD, "Installing firewall exception2 %ls on port %ls, protocol %d", pwzName, pwzPort, iProtocol); - hr = AddPortException(fSupportProfiles, pwzName, iProfile, pwzRemoteAddresses, fIgnoreFailures, pwzPort, iProtocol, pwzDescription, iDirection); - ExitOnFailure(hr, "failed to add/update port exception for name '%ls' on port %ls, protocol %d", pwzName, pwzPort, iProtocol); - break; - - case WCA_TODO_UNINSTALL: - WcaLog(LOGMSG_STANDARD, "Uninstalling firewall exception2 %ls on port %ls, protocol %d", pwzName, pwzPort, iProtocol); - hr = RemovePortException(fSupportProfiles, pwzName, pwzPort, iProtocol, fIgnoreFailures); - ExitOnFailure(hr, "failed to remove port exception for name '%ls' on port %ls, protocol %d", pwzName, pwzPort, iProtocol); - break; - } - break; - - case fetApplication: - switch (iTodo) - { - case WCA_TODO_INSTALL: - case WCA_TODO_REINSTALL: - WcaLog(LOGMSG_STANDARD, "Installing firewall exception2 %ls (%ls)", pwzName, pwzFile); - hr = AddApplicationException(fSupportProfiles, pwzFile, pwzName, iProfile, pwzRemoteAddresses, fIgnoreFailures, pwzPort, iProtocol, pwzDescription, iDirection); - ExitOnFailure(hr, "failed to add/update application exception for name '%ls', file '%ls'", pwzName, pwzFile); - break; - - case WCA_TODO_UNINSTALL: - WcaLog(LOGMSG_STANDARD, "Uninstalling firewall exception2 %ls (%ls)", pwzName, pwzFile); - hr = RemoveApplicationException(fSupportProfiles, pwzName, pwzFile, fIgnoreFailures, pwzPort, iProtocol); - ExitOnFailure(hr, "failed to remove application exception for name '%ls', file '%ls'", pwzName, pwzFile); - break; - } - break; - } - } - -LExit: - ReleaseStr(pwzCustomActionData); - ReleaseStr(pwzName); - ReleaseStr(pwzRemoteAddresses); - ReleaseStr(pwzFile); - ReleaseStr(pwzPort); - ReleaseStr(pwzDescription); - ::CoUninitialize(); - - return WcaFinalize(FAILED(hr) ? ERROR_INSTALL_FAILURE : ERROR_SUCCESS); -} diff --git a/src/ca/fwca.def b/src/ca/fwca.def deleted file mode 100644 index d32c5379..00000000 --- a/src/ca/fwca.def +++ /dev/null @@ -1,9 +0,0 @@ -; Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - - -LIBRARY "fwca" - -EXPORTS - SchedFirewallExceptionsInstall - SchedFirewallExceptionsUninstall - ExecFirewallExceptions diff --git a/src/ca/fwca.v3.ncrunchproject b/src/ca/fwca.v3.ncrunchproject deleted file mode 100644 index 319cd523..00000000 --- a/src/ca/fwca.v3.ncrunchproject +++ /dev/null @@ -1,5 +0,0 @@ - - - True - - \ No newline at end of file diff --git a/src/ca/fwca.vcxproj b/src/ca/fwca.vcxproj deleted file mode 100644 index 5e9a1db6..00000000 --- a/src/ca/fwca.vcxproj +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - Debug - ARM64 - - - Release - ARM64 - - - - Debug - X64 - - - Release - X64 - - - - Debug - Win32 - - - Release - Win32 - - - - - {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981} - DynamicLibrary - fwca - v142 - Unicode - fwca.def - WiX Toolset Firewall CustomAction - - - - - - - msi.lib - - - - - Create - - - - - - - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - diff --git a/src/ca/packages.config b/src/ca/packages.config deleted file mode 100644 index 9d88f529..00000000 --- a/src/ca/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/ca/precomp.h b/src/ca/precomp.h deleted file mode 100644 index 03845e1e..00000000 --- a/src/ca/precomp.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - - -#include -#include -#include -#include -#include - -#include "wcautil.h" -#include "fileutil.h" -#include "pathutil.h" -#include "strutil.h" - -#include "CustomMsiErrors.h" -#include "cost.h" - -#include "caDecor.h" diff --git a/src/ext/Firewall/CSharp.Build.props b/src/ext/Firewall/CSharp.Build.props new file mode 100644 index 00000000..b12f4c6e --- /dev/null +++ b/src/ext/Firewall/CSharp.Build.props @@ -0,0 +1,11 @@ + + + + + true + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)wix.snk)) + + diff --git a/src/ext/Firewall/Cpp.Build.props b/src/ext/Firewall/Cpp.Build.props new file mode 100644 index 00000000..9b7a1bb5 --- /dev/null +++ b/src/ext/Firewall/Cpp.Build.props @@ -0,0 +1,86 @@ + + + + + + Win32 + $(BaseIntermediateOutputPath)$(Configuration)\$(Platform)\ + $(OutputPath)$(Platform)\ + + + + $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) + + + + + $(DisableSpecificCompilerWarnings) + Level4 + $(ProjectDir)inc;$(MSBuildProjectDirectory);$(IntDir);$(SqlCESdkIncludePath);$(ProjectAdditionalIncludeDirectories);%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;_WIN32_MSI=500;_WIN32_WINNT=0x0501;$(ArmPreprocessorDefinitions);$(UnicodePreprocessorDefinitions);_CRT_STDIO_LEGACY_WIDE_SPECIFIERS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + Use + precomp.h + StdCall + true + false + -YlprecompDefine + /Zc:threadSafeInit- %(AdditionalOptions) + true + + + $(ArmPreprocessorDefinitions);%(PreprocessorDefinitions) + $(ProjectAdditionalResourceIncludeDirectories);%(AdditionalIncludeDirectories) + + + $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ProjectAdditionalLibraryDirectories);%(AdditionalLibraryDirectories) + + + $(ProjectSubSystem) + $(ProjectModuleDefinitionFile) + $(ResourceOnlyDll) + true + $(ProjectAdditionalLinkLibraries);advapi32.lib;comdlg32.lib;user32.lib;oleaut32.lib;gdi32.lib;shell32.lib;ole32.lib;version.lib;%(AdditionalDependencies) + $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ArmLibraryDirectories);$(ProjectAdditionalLinkLibraryDirectories);%(AdditionalLibraryDirectories) + /IGNORE:4099 %(AdditionalOptions) + + + + + + NoExtensions + + + + + CDecl + + + + + OldStyle + true + true + + + + + Disabled + EnableFastChecks + _DEBUG;DEBUG;%(PreprocessorDefinitions) + MultiThreadedDebug + + + + + MinSpace + NDEBUG;%(PreprocessorDefinitions) + true + true + MultiThreaded + + + true + true + + + diff --git a/src/ext/Firewall/Directory.Build.props b/src/ext/Firewall/Directory.Build.props new file mode 100644 index 00000000..f83cc154 --- /dev/null +++ b/src/ext/Firewall/Directory.Build.props @@ -0,0 +1,29 @@ + + + + + + Debug + false + MSB3246 + + $(MSBuildProjectName) + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\build\)) + $(BaseOutputPath)obj\$(ProjectName)\ + $(BaseOutputPath)$(Configuration)\ + + WiX Toolset Team + WiX Toolset + Copyright (c) .NET Foundation and contributors. All rights reserved. + MS-RL + WiX Toolset + + + + + + + diff --git a/src/ext/Firewall/Directory.Build.targets b/src/ext/Firewall/Directory.Build.targets new file mode 100644 index 00000000..dac7452a --- /dev/null +++ b/src/ext/Firewall/Directory.Build.targets @@ -0,0 +1,48 @@ + + + + + + + true + $(SolutionPath) + $(NCrunchOriginalSolutionPath) + + + + + + + $([System.IO.File]::ReadAllText($(TheSolutionPath))) + $([System.IO.Path]::GetDirectoryName( $(TheSolutionPath) )) + (?<="[PackageName]", ")(.*)(?=", ") + + + + + + %(Identity) + $(SolutionFileContent.Contains('\%(Identity).csproj')) + + + + + $(RegexPattern.Replace('[PackageName]','%(PackageName)') ) + $([System.Text.RegularExpressions.Regex]::Match('$(SolutionFileContent)', '%(Pattern)')) + + + + + + + + + + + diff --git a/src/ext/Firewall/Firewall.wixext.sln b/src/ext/Firewall/Firewall.wixext.sln new file mode 100644 index 00000000..59209c88 --- /dev/null +++ b/src/ext/Firewall/Firewall.wixext.sln @@ -0,0 +1,73 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27130.2003 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fwca", "src\ca\fwca.vcxproj", "{F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}" +EndProject +Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "firewall", "src\wixlib\firewall.wixproj", "{1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.Firewall.wixext", "src\wixext\WixToolset.Firewall.wixext.csproj", "{6CF033EB-0A39-4AC6-9D41-9BD506352045}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolsetTest.Firewall", "src\test\WixToolsetTest.Firewall\WixToolsetTest.Firewall.csproj", "{D5D34EC4-AF91-4B11-AC0A-FA5242AE924B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Debug|Any CPU.Build.0 = Debug|Win32 + {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Debug|x64.ActiveCfg = Debug|Win32 + {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Debug|x86.ActiveCfg = Debug|Win32 + {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Debug|x86.Build.0 = Debug|Win32 + {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Release|Any CPU.ActiveCfg = Release|Win32 + {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Release|x64.ActiveCfg = Release|Win32 + {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Release|x86.ActiveCfg = Release|Win32 + {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}.Release|x86.Build.0 = Release|Win32 + {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Debug|Any CPU.ActiveCfg = Debug|x86 + {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Debug|Any CPU.Build.0 = Debug|x86 + {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Debug|x64.ActiveCfg = Debug|x86 + {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Debug|x86.ActiveCfg = Debug|x86 + {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Debug|x86.Build.0 = Debug|x86 + {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Release|Any CPU.ActiveCfg = Release|x86 + {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Release|x64.ActiveCfg = Release|x86 + {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Release|x86.ActiveCfg = Release|x86 + {1ACFFEFD-505A-41A5-ACBF-A02B7B473AA2}.Release|x86.Build.0 = Release|x86 + {6CF033EB-0A39-4AC6-9D41-9BD506352045}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6CF033EB-0A39-4AC6-9D41-9BD506352045}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6CF033EB-0A39-4AC6-9D41-9BD506352045}.Debug|x64.ActiveCfg = Debug|Any CPU + {6CF033EB-0A39-4AC6-9D41-9BD506352045}.Debug|x64.Build.0 = Debug|Any CPU + {6CF033EB-0A39-4AC6-9D41-9BD506352045}.Debug|x86.ActiveCfg = Debug|Any CPU + {6CF033EB-0A39-4AC6-9D41-9BD506352045}.Debug|x86.Build.0 = Debug|Any CPU + {6CF033EB-0A39-4AC6-9D41-9BD506352045}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6CF033EB-0A39-4AC6-9D41-9BD506352045}.Release|Any CPU.Build.0 = Release|Any CPU + {6CF033EB-0A39-4AC6-9D41-9BD506352045}.Release|x64.ActiveCfg = Release|Any CPU + {6CF033EB-0A39-4AC6-9D41-9BD506352045}.Release|x64.Build.0 = Release|Any CPU + {6CF033EB-0A39-4AC6-9D41-9BD506352045}.Release|x86.ActiveCfg = Release|Any CPU + {6CF033EB-0A39-4AC6-9D41-9BD506352045}.Release|x86.Build.0 = Release|Any CPU + {D5D34EC4-AF91-4B11-AC0A-FA5242AE924B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D5D34EC4-AF91-4B11-AC0A-FA5242AE924B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D5D34EC4-AF91-4B11-AC0A-FA5242AE924B}.Debug|x64.ActiveCfg = Debug|Any CPU + {D5D34EC4-AF91-4B11-AC0A-FA5242AE924B}.Debug|x64.Build.0 = Debug|Any CPU + {D5D34EC4-AF91-4B11-AC0A-FA5242AE924B}.Debug|x86.ActiveCfg = Debug|Any CPU + {D5D34EC4-AF91-4B11-AC0A-FA5242AE924B}.Debug|x86.Build.0 = Debug|Any CPU + {D5D34EC4-AF91-4B11-AC0A-FA5242AE924B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D5D34EC4-AF91-4B11-AC0A-FA5242AE924B}.Release|Any CPU.Build.0 = Release|Any CPU + {D5D34EC4-AF91-4B11-AC0A-FA5242AE924B}.Release|x64.ActiveCfg = Release|Any CPU + {D5D34EC4-AF91-4B11-AC0A-FA5242AE924B}.Release|x64.Build.0 = Release|Any CPU + {D5D34EC4-AF91-4B11-AC0A-FA5242AE924B}.Release|x86.ActiveCfg = Release|Any CPU + {D5D34EC4-AF91-4B11-AC0A-FA5242AE924B}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E4566A6B-47D0-4EA0-989A-D763AC39105D} + EndGlobalSection +EndGlobal diff --git a/src/ext/Firewall/Firewall.wixext.v3.ncrunchsolution b/src/ext/Firewall/Firewall.wixext.v3.ncrunchsolution new file mode 100644 index 00000000..10420ac9 --- /dev/null +++ b/src/ext/Firewall/Firewall.wixext.v3.ncrunchsolution @@ -0,0 +1,6 @@ + + + True + True + + \ No newline at end of file diff --git a/src/ext/Firewall/README.md b/src/ext/Firewall/README.md new file mode 100644 index 00000000..be5801da --- /dev/null +++ b/src/ext/Firewall/README.md @@ -0,0 +1,2 @@ +# Firewall.wixext +WixToolset.Firewall.wixext - Firewall WiX Toolset Extension diff --git a/src/ext/Firewall/appveyor.cmd b/src/ext/Firewall/appveyor.cmd new file mode 100644 index 00000000..79c24cc1 --- /dev/null +++ b/src/ext/Firewall/appveyor.cmd @@ -0,0 +1,14 @@ +@setlocal +@pushd %~dp0 + +nuget restore || exit /b + +msbuild -p:Configuration=Release -t:Restore || exit /b + +msbuild -p:Configuration=Release src\test\WixToolsetTest.Firewall\WixToolsetTest.Firewall.csproj || exit /b +dotnet test -c Release --no-build src\test\WixToolsetTest.Firewall || exit /b + +msbuild -p:Configuration=Release -t:Pack src\wixext\WixToolset.Firewall.wixext.csproj || exit /b + +@popd +@endlocal \ No newline at end of file diff --git a/src/ext/Firewall/appveyor.yml b/src/ext/Firewall/appveyor.yml new file mode 100644 index 00000000..7c686b04 --- /dev/null +++ b/src/ext/Firewall/appveyor.yml @@ -0,0 +1,40 @@ +# Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. +# +# Do NOT modify this file. Update the canonical version in Home\repo-template\src\appveyor.yml +# then update all of the repos. + +branches: + only: + - master + - develop + +image: Visual Studio 2019 + +version: 0.0.0.{build} +configuration: Release + +environment: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + NUGET_XMLDOC_MODE: skip + +build_script: + - appveyor.cmd + +pull_requests: + do_not_increment_build_number: true + +nuget: + disable_publish_on_pr: true + +skip_branch_with_pr: true +skip_tags: true + +artifacts: +- path: build\Release\**\*.nupkg + name: nuget + +notifications: +- provider: Slack + incoming_webhook: + secure: p5xuu+4x2JHfwGDMDe5KcG1k7gZxqYc4jWVwvyNZv5cvkubPD2waJs5yXMAXZNN7Z63/3PWHb7q4KoY/99AjauYa1nZ4c5qYqRPFRBKTHfA= diff --git a/src/ext/Firewall/ca/CustomMsiErrors.h b/src/ext/Firewall/ca/CustomMsiErrors.h new file mode 100644 index 00000000..f149fb31 --- /dev/null +++ b/src/ext/Firewall/ca/CustomMsiErrors.h @@ -0,0 +1,130 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +#define GLOBAL_ERROR_BASE 25501 + +#define msierrSecureObjectsFailedCreateSD 25520 +#define msierrSecureObjectsFailedSet 25521 +#define msierrSecureObjectsUnknownType 25522 + +#define msierrXmlFileFailedRead 25530 +#define msierrXmlFileFailedOpen 25531 +#define msierrXmlFileFailedSelect 25532 +#define msierrXmlFileFailedSave 25533 + +#define msierrXmlConfigFailedRead 25540 +#define msierrXmlConfigFailedOpen 25541 +#define msierrXmlConfigFailedSelect 25542 +#define msierrXmlConfigFailedSave 25543 + +#define msierrFirewallCannotConnect 25580 + +//--------------------------------------------------------------------------- +// Server CustomAction Errors +// SERVER range: 26001-26100 +#define SERVER_ERROR_BASE 26000 + +#define msierrIISCannotConnect 26001 +#define msierrIISFailedReadWebSite 26002 +#define msierrIISFailedReadWebDirs 26003 +#define msierrIISFailedReadVDirs 26004 +#define msierrIISFailedReadFilters 26005 +#define msierrIISFailedReadAppPool 26006 +#define msierrIISFailedReadMimeMap 26007 +#define msierrIISFailedReadProp 26008 +#define msierrIISFailedReadWebSvcExt 26009 +#define msierrIISFailedReadWebError 26010 +#define msierrIISFailedReadHttpHeader 26011 + +#define msierrIISFailedSchedTransaction 26031 +#define msierrIISFailedSchedInstallWebs 26032 +#define msierrIISFailedSchedInstallWebDirs 26033 +#define msierrIISFailedSchedInstallVDirs 26034 +#define msierrIISFailedSchedInstallFilters 26035 +#define msierrIISFailedSchedInstallAppPool 26036 +#define msierrIISFailedSchedInstallProp 26037 +#define msierrIISFailedSchedInstallWebSvcExt 26038 + +#define msierrIISFailedSchedUninstallWebs 26051 +#define msierrIISFailedSchedUninstallWebDirs 26052 +#define msierrIISFailedSchedUninstallVDirs 26053 +#define msierrIISFailedSchedUninstallFilters 26054 +#define msierrIISFailedSchedUninstallAppPool 26055 +#define msierrIISFailedSchedUninstallProp 26056 +#define msierrIISFailedSchedUninstallWebSvcExt 26057 + +#define msierrIISFailedStartTransaction 26101 +#define msierrIISFailedOpenKey 26102 +#define msierrIISFailedCreateKey 26103 +#define msierrIISFailedWriteData 26104 +#define msierrIISFailedCreateApp 26105 +#define msierrIISFailedDeleteKey 26106 +#define msierrIISFailedDeleteApp 26107 +#define msierrIISFailedDeleteValue 26108 +#define msierrIISFailedCommitInUse 26109 + +#define msierrSQLFailedCreateDatabase 26201 +#define msierrSQLFailedDropDatabase 26202 +#define msierrSQLFailedConnectDatabase 26203 +#define msierrSQLFailedExecString 26204 +#define msierrSQLDatabaseAlreadyExists 26205 + +#define msierrPERFMONFailedRegisterDLL 26251 +#define msierrPERFMONFailedUnregisterDLL 26252 +#define msierrInstallPerfCounterData 26253 +#define msierrUninstallPerfCounterData 26254 + +#define msierrSMBFailedCreate 26301 +#define msierrSMBFailedDrop 26302 + +#define msierrCERTFailedOpen 26351 +#define msierrCERTFailedAdd 26352 + +#define msierrUSRFailedUserCreate 26401 +#define msierrUSRFailedUserCreatePswd 26402 +#define msierrUSRFailedUserGroupAdd 26403 +#define msierrUSRFailedUserCreateExists 26404 +#define msierrUSRFailedGrantLogonAsService 26405 + +#define msierrDependencyMissingDependencies 26451 +#define msierrDependencyHasDependents 26452 + +//-------------------------------------------------------------------------- +// Managed code CustomAction Errors +// MANAGED range: 27000-27100 +#define MANAGED_ERROR_BASE 27000 + +#define msierrDotNetRuntimeRequired 27000 +//--------------------------------------------------------------------------- +// Public CustomAction Errors +// PUBLIC range: 28001-28100 +#define PUBLIC_ERROR_BASE 28000 + +#define msierrComPlusCannotConnect 28001 +#define msierrComPlusPartitionReadFailed 28002 +#define msierrComPlusPartitionRoleReadFailed 28003 +#define msierrComPlusUserInPartitionRoleReadFailed 28004 +#define msierrComPlusPartitionUserReadFailed 28005 +#define msierrComPlusApplicationReadFailed 28006 +#define msierrComPlusApplicationRoleReadFailed 28007 +#define msierrComPlusUserInApplicationRoleReadFailed 28008 +#define msierrComPlusAssembliesReadFailed 28009 +#define msierrComPlusSubscriptionReadFailed 28010 +#define msierrComPlusPartitionDependency 28011 +#define msierrComPlusPartitionNotFound 28012 +#define msierrComPlusPartitionIdConflict 28013 +#define msierrComPlusPartitionNameConflict 28014 +#define msierrComPlusApplicationDependency 28015 +#define msierrComPlusApplicationNotFound 28016 +#define msierrComPlusApplicationIdConflict 28017 +#define msierrComPlusApplicationNameConflict 28018 +#define msierrComPlusApplicationRoleDependency 28019 +#define msierrComPlusApplicationRoleNotFound 28020 +#define msierrComPlusApplicationRoleConflict 28021 +#define msierrComPlusAssemblyDependency 28022 +#define msierrComPlusSubscriptionIdConflict 28023 +#define msierrComPlusSubscriptionNameConflict 28024 +#define msierrComPlusFailedLookupNames 28025 + +#define msierrMsmqCannotConnect 28101 diff --git a/src/ext/Firewall/ca/caDecor.h b/src/ext/Firewall/ca/caDecor.h new file mode 100644 index 00000000..da274650 --- /dev/null +++ b/src/ext/Firewall/ca/caDecor.h @@ -0,0 +1,13 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +#if defined(_M_ARM64) +#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_A64" +#elif defined(_M_AMD64) +#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_X64" +#elif defined(_M_ARM) +#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_ARM" +#else +#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_X86" +#endif diff --git a/src/ext/Firewall/ca/cost.h b/src/ext/Firewall/ca/cost.h new file mode 100644 index 00000000..da68c667 --- /dev/null +++ b/src/ext/Firewall/ca/cost.h @@ -0,0 +1,5 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +const UINT COST_FIREWALL_EXCEPTION = 2000; diff --git a/src/ext/Firewall/ca/dllmain.cpp b/src/ext/Firewall/ca/dllmain.cpp new file mode 100644 index 00000000..df53f872 --- /dev/null +++ b/src/ext/Firewall/ca/dllmain.cpp @@ -0,0 +1,26 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" + +/******************************************************************** +DllMain - standard entry point for all WiX CustomActions + +********************************************************************/ +extern "C" BOOL WINAPI DllMain( + IN HINSTANCE hInst, + IN ULONG ulReason, + IN LPVOID) +{ + switch(ulReason) + { + case DLL_PROCESS_ATTACH: + WcaGlobalInitialize(hInst); + break; + + case DLL_PROCESS_DETACH: + WcaGlobalFinalize(); + break; + } + + return TRUE; +} diff --git a/src/ext/Firewall/ca/firewall.cpp b/src/ext/Firewall/ca/firewall.cpp new file mode 100644 index 00000000..caae21a1 --- /dev/null +++ b/src/ext/Firewall/ca/firewall.cpp @@ -0,0 +1,1085 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" + +LPCWSTR vcsFirewallExceptionQuery = + L"SELECT `Name`, `RemoteAddresses`, `Port`, `Protocol`, `Program`, `Attributes`, `Profile`, `Component_`, `Description`, `Direction` FROM `Wix4FirewallException`"; +enum eFirewallExceptionQuery { feqName = 1, feqRemoteAddresses, feqPort, feqProtocol, feqProgram, feqAttributes, feqProfile, feqComponent, feqDescription }; +enum eFirewallExceptionTarget { fetPort = 1, fetApplication, fetUnknown }; +enum eFirewallExceptionAttributes { feaIgnoreFailures = 1 }; + +/****************************************************************** + SchedFirewallExceptions - immediate custom action worker to + register and remove firewall exceptions. + +********************************************************************/ +static UINT SchedFirewallExceptions( + __in MSIHANDLE hInstall, + WCA_TODO todoSched + ) +{ + HRESULT hr = S_OK; + UINT er = ERROR_SUCCESS; + int cFirewallExceptions = 0; + + PMSIHANDLE hView = NULL; + PMSIHANDLE hRec = NULL; + + LPWSTR pwzCustomActionData = NULL; + LPWSTR pwzName = NULL; + LPWSTR pwzRemoteAddresses = NULL; + LPWSTR pwzPort = NULL; + int iProtocol = 0; + int iAttributes = 0; + int iProfile = 0; + LPWSTR pwzProgram = NULL; + LPWSTR pwzComponent = NULL; + LPWSTR pwzFormattedFile = NULL; + LPWSTR pwzDescription = NULL; + int iDirection = 0; + + // initialize + hr = WcaInitialize(hInstall, "SchedFirewallExceptions"); + ExitOnFailure(hr, "failed to initialize"); + + // anything to do? + if (S_OK != WcaTableExists(L"Wix4FirewallException")) + { + WcaLog(LOGMSG_STANDARD, "Wix4FirewallException table doesn't exist, so there are no firewall exceptions to configure."); + ExitFunction(); + } + + // query and loop through all the firewall exceptions + hr = WcaOpenExecuteView(vcsFirewallExceptionQuery, &hView); + ExitOnFailure(hr, "failed to open view on Wix4FirewallException table"); + + while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) + { + hr = WcaGetRecordFormattedString(hRec, feqName, &pwzName); + ExitOnFailure(hr, "failed to get firewall exception name"); + + hr = WcaGetRecordFormattedString(hRec, feqRemoteAddresses, &pwzRemoteAddresses); + ExitOnFailure(hr, "failed to get firewall exception remote addresses"); + + hr = WcaGetRecordFormattedString(hRec, feqPort, &pwzPort); + ExitOnFailure(hr, "failed to get firewall exception port"); + + hr = WcaGetRecordInteger(hRec, feqProtocol, &iProtocol); + ExitOnFailure(hr, "failed to get firewall exception protocol"); + + hr = WcaGetRecordFormattedString(hRec, feqProgram, &pwzProgram); + ExitOnFailure(hr, "failed to get firewall exception program"); + + hr = WcaGetRecordInteger(hRec, feqAttributes, &iAttributes); + ExitOnFailure(hr, "failed to get firewall exception attributes"); + + hr = WcaGetRecordInteger(hRec, feqProfile, &iProfile); + ExitOnFailure(hr, "failed to get firewall exception profile"); + + hr = WcaGetRecordString(hRec, feqComponent, &pwzComponent); + ExitOnFailure(hr, "failed to get firewall exception component"); + + hr = WcaGetRecordString(hRec, feqDescription, &pwzDescription); + ExitOnFailure(hr, "failed to get firewall description"); + + // figure out what we're doing for this exception, treating reinstall the same as install + WCA_TODO todoComponent = WcaGetComponentToDo(pwzComponent); + if ((WCA_TODO_REINSTALL == todoComponent ? WCA_TODO_INSTALL : todoComponent) != todoSched) + { + WcaLog(LOGMSG_STANDARD, "Component '%ls' action state (%d) doesn't match request (%d)", pwzComponent, todoComponent, todoSched); + continue; + } + + // action :: name :: profile :: remoteaddresses :: attributes :: target :: {port::protocol | path} + ++cFirewallExceptions; + hr = WcaWriteIntegerToCaData(todoComponent, &pwzCustomActionData); + ExitOnFailure(hr, "failed to write exception action to custom action data"); + + hr = WcaWriteStringToCaData(pwzName, &pwzCustomActionData); + ExitOnFailure(hr, "failed to write exception name to custom action data"); + + hr = WcaWriteIntegerToCaData(iProfile, &pwzCustomActionData); + ExitOnFailure(hr, "failed to write exception profile to custom action data"); + + hr = WcaWriteStringToCaData(pwzRemoteAddresses, &pwzCustomActionData); + ExitOnFailure(hr, "failed to write exception remote addresses to custom action data"); + + hr = WcaWriteIntegerToCaData(iAttributes, &pwzCustomActionData); + ExitOnFailure(hr, "failed to write exception attributes to custom action data"); + + if (*pwzProgram) + { + // If program is defined, we have an application exception. + hr = WcaWriteIntegerToCaData(fetApplication, &pwzCustomActionData); + ExitOnFailure(hr, "failed to write exception target (application) to custom action data"); + + hr = WcaWriteStringToCaData(pwzProgram, &pwzCustomActionData); + ExitOnFailure(hr, "failed to write application path to custom action data"); + } + else + { + // we have a port-only exception + hr = WcaWriteIntegerToCaData(fetPort, &pwzCustomActionData); + ExitOnFailure(hr, "failed to write exception target (port) to custom action data"); + } + + hr = WcaWriteStringToCaData(pwzPort, &pwzCustomActionData); + ExitOnFailure(hr, "failed to write application path to custom action data"); + + hr = WcaWriteIntegerToCaData(iProtocol, &pwzCustomActionData); + ExitOnFailure(hr, "failed to write exception protocol to custom action data"); + + hr = WcaWriteStringToCaData(pwzDescription, &pwzCustomActionData); + ExitOnFailure(hr, "failed to write firewall rule description to custom action data"); + + hr = WcaWriteIntegerToCaData(iDirection, &pwzCustomActionData); + ExitOnFailure(hr, "failed to write firewall rule direction to custom action data"); + } + + // reaching the end of the list is actually a good thing, not an error + if (E_NOMOREITEMS == hr) + { + hr = S_OK; + } + ExitOnFailure(hr, "failure occured while processing Wix4FirewallException table"); + + // schedule ExecFirewallExceptions if there's anything to do + if (pwzCustomActionData && *pwzCustomActionData) + { + WcaLog(LOGMSG_STANDARD, "Scheduling firewall exception (%ls)", pwzCustomActionData); + + if (WCA_TODO_INSTALL == todoSched) + { + hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"RollbackFirewallExceptionsInstall"), pwzCustomActionData, cFirewallExceptions * COST_FIREWALL_EXCEPTION); + ExitOnFailure(hr, "failed to schedule firewall install exceptions rollback"); + hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"ExecFirewallExceptionsInstall"), pwzCustomActionData, cFirewallExceptions * COST_FIREWALL_EXCEPTION); + ExitOnFailure(hr, "failed to schedule firewall install exceptions execution"); + } + else + { + hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"RollbackFirewallExceptionsUninstall"), pwzCustomActionData, cFirewallExceptions * COST_FIREWALL_EXCEPTION); + ExitOnFailure(hr, "failed to schedule firewall uninstall exceptions rollback"); + hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"ExecFirewallExceptionsUninstall"), pwzCustomActionData, cFirewallExceptions * COST_FIREWALL_EXCEPTION); + ExitOnFailure(hr, "failed to schedule firewall uninstall exceptions execution"); + } + } + else + { + WcaLog(LOGMSG_STANDARD, "No firewall exceptions scheduled"); + } + +LExit: + ReleaseStr(pwzCustomActionData); + ReleaseStr(pwzName); + ReleaseStr(pwzRemoteAddresses); + ReleaseStr(pwzPort); + ReleaseStr(pwzProgram); + ReleaseStr(pwzComponent); + ReleaseStr(pwzDescription); + ReleaseStr(pwzFormattedFile); + + return WcaFinalize(er = FAILED(hr) ? ERROR_INSTALL_FAILURE : er); +} + +/****************************************************************** + SchedFirewallExceptionsInstall - immediate custom action entry + point to register firewall exceptions. + +********************************************************************/ +extern "C" UINT __stdcall SchedFirewallExceptionsInstall( + __in MSIHANDLE hInstall + ) +{ + return SchedFirewallExceptions(hInstall, WCA_TODO_INSTALL); +} + +/****************************************************************** + SchedFirewallExceptionsUninstall - immediate custom action entry + point to remove firewall exceptions. + +********************************************************************/ +extern "C" UINT __stdcall SchedFirewallExceptionsUninstall( + __in MSIHANDLE hInstall + ) +{ + return SchedFirewallExceptions(hInstall, WCA_TODO_UNINSTALL); +} + +/****************************************************************** + GetFirewallRules - Get the collection of firewall rules. + +********************************************************************/ +static HRESULT GetFirewallRules( + __in BOOL fIgnoreFailures, + __out INetFwRules** ppNetFwRules + ) +{ + HRESULT hr = S_OK; + INetFwPolicy2* pNetFwPolicy2 = NULL; + INetFwRules* pNetFwRules = NULL; + *ppNetFwRules = NULL; + + do + { + ReleaseNullObject(pNetFwPolicy2); + ReleaseNullObject(pNetFwRules); + + if (SUCCEEDED(hr = ::CoCreateInstance(__uuidof(NetFwPolicy2), NULL, CLSCTX_ALL, __uuidof(INetFwPolicy2), (void**)&pNetFwPolicy2)) && + SUCCEEDED(hr = pNetFwPolicy2->get_Rules(&pNetFwRules))) + { + break; + } + else if (fIgnoreFailures) + { + ExitFunction1(hr = S_FALSE); + } + else + { + WcaLog(LOGMSG_STANDARD, "Failed to connect to Windows Firewall"); + UINT er = WcaErrorMessage(msierrFirewallCannotConnect, hr, INSTALLMESSAGE_ERROR | MB_ABORTRETRYIGNORE, 0); + switch (er) + { + case IDABORT: // exit with the current HRESULT + ExitFunction(); + case IDRETRY: // clean up and retry the loop + hr = S_FALSE; + break; + case IDIGNORE: // pass S_FALSE back to the caller, who knows how to ignore the failure + ExitFunction1(hr = S_FALSE); + default: // No UI, so default is to fail. + ExitFunction(); + } + } + } while (S_FALSE == hr); + + *ppNetFwRules = pNetFwRules; + pNetFwRules = NULL; + +LExit: + ReleaseObject(pNetFwPolicy2); + ReleaseObject(pNetFwRules); + + return hr; +} + +/****************************************************************** + CreateFwRuleObject - CoCreate a firewall rule, and set the common set of properties which are shared + between port and application firewall rules + +********************************************************************/ +static HRESULT CreateFwRuleObject( + __in BSTR bstrName, + __in int iProfile, + __in_opt LPCWSTR wzRemoteAddresses, + __in LPCWSTR wzPort, + __in int iProtocol, + __in LPCWSTR wzDescription, + __in int iDirection, + __out INetFwRule** ppNetFwRule + ) +{ + HRESULT hr = S_OK; + BSTR bstrRemoteAddresses = NULL; + BSTR bstrPort = NULL; + BSTR bstrDescription = NULL; + INetFwRule* pNetFwRule = NULL; + *ppNetFwRule = NULL; + + // convert to BSTRs to make COM happy + bstrRemoteAddresses = ::SysAllocString(wzRemoteAddresses); + ExitOnNull(bstrRemoteAddresses, hr, E_OUTOFMEMORY, "failed SysAllocString for remote addresses"); + bstrPort = ::SysAllocString(wzPort); + ExitOnNull(bstrPort, hr, E_OUTOFMEMORY, "failed SysAllocString for port"); + bstrDescription = ::SysAllocString(wzDescription); + ExitOnNull(bstrDescription, hr, E_OUTOFMEMORY, "failed SysAllocString for description"); + + hr = ::CoCreateInstance(__uuidof(NetFwRule), NULL, CLSCTX_ALL, __uuidof(INetFwRule), (void**)&pNetFwRule); + ExitOnFailure(hr, "failed to create NetFwRule object"); + + hr = pNetFwRule->put_Name(bstrName); + ExitOnFailure(hr, "failed to set exception name"); + + hr = pNetFwRule->put_Profiles(static_cast(iProfile)); + ExitOnFailure(hr, "failed to set exception profile"); + + if (MSI_NULL_INTEGER != iProtocol) + { + hr = pNetFwRule->put_Protocol(static_cast(iProtocol)); + ExitOnFailure(hr, "failed to set exception protocol"); + } + + if (bstrPort && *bstrPort) + { + hr = pNetFwRule->put_LocalPorts(bstrPort); + ExitOnFailure(hr, "failed to set exception port"); + } + + if (bstrRemoteAddresses && *bstrRemoteAddresses) + { + hr = pNetFwRule->put_RemoteAddresses(bstrRemoteAddresses); + ExitOnFailure(hr, "failed to set exception remote addresses '%ls'", bstrRemoteAddresses); + } + + if (bstrDescription && *bstrDescription) + { + hr = pNetFwRule->put_Description(bstrDescription); + ExitOnFailure(hr, "failed to set exception description '%ls'", bstrDescription); + } + + if (MSI_NULL_INTEGER != iDirection) + { + hr = pNetFwRule->put_Direction(static_cast (iDirection)); + ExitOnFailure(hr, "failed to set exception direction"); + } + + *ppNetFwRule = pNetFwRule; + pNetFwRule = NULL; + +LExit: + ReleaseBSTR(bstrRemoteAddresses); + ReleaseBSTR(bstrPort); + ReleaseBSTR(bstrDescription); + ReleaseObject(pNetFwRule); + + return hr; +} + +/****************************************************************** + FSupportProfiles - Returns true if we support profiles on this machine. + (Only on Vista or later) + +********************************************************************/ +static BOOL FSupportProfiles() +{ + BOOL fSupportProfiles = FALSE; + INetFwRules* pNetFwRules = NULL; + + // We only support profiles if we can co-create an instance of NetFwPolicy2. + // This will not work on pre-vista machines. + if (SUCCEEDED(GetFirewallRules(TRUE, &pNetFwRules)) && pNetFwRules != NULL) + { + fSupportProfiles = TRUE; + ReleaseObject(pNetFwRules); + } + + return fSupportProfiles; +} + +/****************************************************************** + GetCurrentFirewallProfile - get the active firewall profile as an + INetFwProfile, which owns the lists of exceptions we're + updating. + +********************************************************************/ +static HRESULT GetCurrentFirewallProfile( + __in BOOL fIgnoreFailures, + __out INetFwProfile** ppfwProfile + ) +{ + HRESULT hr = S_OK; + INetFwMgr* pfwMgr = NULL; + INetFwPolicy* pfwPolicy = NULL; + INetFwProfile* pfwProfile = NULL; + *ppfwProfile = NULL; + + do + { + ReleaseNullObject(pfwPolicy); + ReleaseNullObject(pfwMgr); + ReleaseNullObject(pfwProfile); + + if (SUCCEEDED(hr = ::CoCreateInstance(__uuidof(NetFwMgr), NULL, CLSCTX_INPROC_SERVER, __uuidof(INetFwMgr), (void**)&pfwMgr)) && + SUCCEEDED(hr = pfwMgr->get_LocalPolicy(&pfwPolicy)) && + SUCCEEDED(hr = pfwPolicy->get_CurrentProfile(&pfwProfile))) + { + break; + } + else if (fIgnoreFailures) + { + ExitFunction1(hr = S_FALSE); + } + else + { + WcaLog(LOGMSG_STANDARD, "Failed to connect to Windows Firewall"); + UINT er = WcaErrorMessage(msierrFirewallCannotConnect, hr, INSTALLMESSAGE_ERROR | MB_ABORTRETRYIGNORE, 0); + switch (er) + { + case IDABORT: // exit with the current HRESULT + ExitFunction(); + case IDRETRY: // clean up and retry the loop + hr = S_FALSE; + break; + case IDIGNORE: // pass S_FALSE back to the caller, who knows how to ignore the failure + ExitFunction1(hr = S_FALSE); + default: // No UI, so default is to fail. + ExitFunction(); + } + } + } while (S_FALSE == hr); + + *ppfwProfile = pfwProfile; + pfwProfile = NULL; + +LExit: + ReleaseObject(pfwPolicy); + ReleaseObject(pfwMgr); + ReleaseObject(pfwProfile); + + return hr; +} + +/****************************************************************** + AddApplicationException + +********************************************************************/ +static HRESULT AddApplicationException( + __in LPCWSTR wzFile, + __in LPCWSTR wzName, + __in int iProfile, + __in_opt LPCWSTR wzRemoteAddresses, + __in BOOL fIgnoreFailures, + __in LPCWSTR wzPort, + __in int iProtocol, + __in LPCWSTR wzDescription, + __in int iDirection + ) +{ + HRESULT hr = S_OK; + BSTR bstrFile = NULL; + BSTR bstrName = NULL; + INetFwRules* pNetFwRules = NULL; + INetFwRule* pNetFwRule = NULL; + + // convert to BSTRs to make COM happy + bstrFile = ::SysAllocString(wzFile); + ExitOnNull(bstrFile, hr, E_OUTOFMEMORY, "failed SysAllocString for path"); + bstrName = ::SysAllocString(wzName); + ExitOnNull(bstrName, hr, E_OUTOFMEMORY, "failed SysAllocString for name"); + + // get the collection of firewall rules + hr = GetFirewallRules(fIgnoreFailures, &pNetFwRules); + ExitOnFailure(hr, "failed to get firewall rules object"); + if (S_FALSE == hr) // user or package author chose to ignore missing firewall + { + ExitFunction(); + } + + // try to find it (i.e., support reinstall) + hr = pNetFwRules->Item(bstrName, &pNetFwRule); + if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr) + { + hr = CreateFwRuleObject(bstrName, iProfile, wzRemoteAddresses, wzPort, iProtocol, wzDescription, iDirection, &pNetFwRule); + ExitOnFailure(hr, "failed to create FwRule object"); + + // set edge traversal to true + hr = pNetFwRule->put_EdgeTraversal(VARIANT_TRUE); + ExitOnFailure(hr, "failed to set application exception edgetraversal property"); + + // set path + hr = pNetFwRule->put_ApplicationName(bstrFile); + ExitOnFailure(hr, "failed to set application name"); + + // enable it + hr = pNetFwRule->put_Enabled(VARIANT_TRUE); + ExitOnFailure(hr, "failed to to enable application exception"); + + // add it to the list of authorized apps + hr = pNetFwRules->Add(pNetFwRule); + ExitOnFailure(hr, "failed to add app to the authorized apps list"); + } + else + { + // we found an existing app exception (if we succeeded, that is) + ExitOnFailure(hr, "failed trying to find existing app"); + + // enable it (just in case it was disabled) + pNetFwRule->put_Enabled(VARIANT_TRUE); + } + +LExit: + ReleaseBSTR(bstrName); + ReleaseBSTR(bstrFile); + ReleaseObject(pNetFwRules); + ReleaseObject(pNetFwRule); + + return fIgnoreFailures ? S_OK : hr; +} + +/****************************************************************** + AddApplicationExceptionOnCurrentProfile + +********************************************************************/ +static HRESULT AddApplicationExceptionOnCurrentProfile( + __in LPCWSTR wzFile, + __in LPCWSTR wzName, + __in_opt LPCWSTR wzRemoteAddresses, + __in BOOL fIgnoreFailures + ) +{ + HRESULT hr = S_OK; + BSTR bstrFile = NULL; + BSTR bstrName = NULL; + BSTR bstrRemoteAddresses = NULL; + INetFwProfile* pfwProfile = NULL; + INetFwAuthorizedApplications* pfwApps = NULL; + INetFwAuthorizedApplication* pfwApp = NULL; + + // convert to BSTRs to make COM happy + bstrFile = ::SysAllocString(wzFile); + ExitOnNull(bstrFile, hr, E_OUTOFMEMORY, "failed SysAllocString for path"); + bstrName = ::SysAllocString(wzName); + ExitOnNull(bstrName, hr, E_OUTOFMEMORY, "failed SysAllocString for name"); + bstrRemoteAddresses = ::SysAllocString(wzRemoteAddresses); + ExitOnNull(bstrRemoteAddresses, hr, E_OUTOFMEMORY, "failed SysAllocString for remote addresses"); + + // get the firewall profile, which is our entry point for adding exceptions + hr = GetCurrentFirewallProfile(fIgnoreFailures, &pfwProfile); + ExitOnFailure(hr, "failed to get firewall profile"); + if (S_FALSE == hr) // user or package author chose to ignore missing firewall + { + ExitFunction(); + } + + // first, let's see if the app is already on the exception list + hr = pfwProfile->get_AuthorizedApplications(&pfwApps); + ExitOnFailure(hr, "failed to get list of authorized apps"); + + // try to find it (i.e., support reinstall) + hr = pfwApps->Item(bstrFile, &pfwApp); + if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr) + { + // not found, so we get to add it + hr = ::CoCreateInstance(__uuidof(NetFwAuthorizedApplication), NULL, CLSCTX_INPROC_SERVER, __uuidof(INetFwAuthorizedApplication), reinterpret_cast(&pfwApp)); + ExitOnFailure(hr, "failed to create authorized app"); + + // set the display name + hr = pfwApp->put_Name(bstrName); + ExitOnFailure(hr, "failed to set authorized app name"); + + // set path + hr = pfwApp->put_ProcessImageFileName(bstrFile); + ExitOnFailure(hr, "failed to set authorized app path"); + + // set the allowed remote addresses + if (bstrRemoteAddresses && *bstrRemoteAddresses) + { + hr = pfwApp->put_RemoteAddresses(bstrRemoteAddresses); + ExitOnFailure(hr, "failed to set authorized app remote addresses"); + } + + // add it to the list of authorized apps + hr = pfwApps->Add(pfwApp); + ExitOnFailure(hr, "failed to add app to the authorized apps list"); + } + else + { + // we found an existing app exception (if we succeeded, that is) + ExitOnFailure(hr, "failed trying to find existing app"); + + // enable it (just in case it was disabled) + pfwApp->put_Enabled(VARIANT_TRUE); + } + +LExit: + ReleaseBSTR(bstrRemoteAddresses); + ReleaseBSTR(bstrName); + ReleaseBSTR(bstrFile); + ReleaseObject(pfwApp); + ReleaseObject(pfwApps); + ReleaseObject(pfwProfile); + + return fIgnoreFailures ? S_OK : hr; +} + +/****************************************************************** + AddPortException + +********************************************************************/ +static HRESULT AddPortException( + __in LPCWSTR wzName, + __in int iProfile, + __in_opt LPCWSTR wzRemoteAddresses, + __in BOOL fIgnoreFailures, + __in LPCWSTR wzPort, + __in int iProtocol, + __in LPCWSTR wzDescription, + __in int iDirection +) +{ + HRESULT hr = S_OK; + BSTR bstrName = NULL; + INetFwRules* pNetFwRules = NULL; + INetFwRule* pNetFwRule = NULL; + + // convert to BSTRs to make COM happy + bstrName = ::SysAllocString(wzName); + ExitOnNull(bstrName, hr, E_OUTOFMEMORY, "failed SysAllocString for name"); + + // get the collection of firewall rules + hr = GetFirewallRules(fIgnoreFailures, &pNetFwRules); + ExitOnFailure(hr, "failed to get firewall rules object"); + if (S_FALSE == hr) // user or package author chose to ignore missing firewall + { + ExitFunction(); + } + + // try to find it (i.e., support reinstall) + hr = pNetFwRules->Item(bstrName, &pNetFwRule); + if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr) + { + hr = CreateFwRuleObject(bstrName, iProfile, wzRemoteAddresses, wzPort, iProtocol, wzDescription, iDirection, &pNetFwRule); + ExitOnFailure(hr, "failed to create FwRule object"); + + // enable it + hr = pNetFwRule->put_Enabled(VARIANT_TRUE); + ExitOnFailure(hr, "failed to to enable port exception"); + + // add it to the list of authorized ports + hr = pNetFwRules->Add(pNetFwRule); + ExitOnFailure(hr, "failed to add app to the authorized ports list"); + } + else + { + // we found an existing port exception (if we succeeded, that is) + ExitOnFailure(hr, "failed trying to find existing port rule"); + + // enable it (just in case it was disabled) + pNetFwRule->put_Enabled(VARIANT_TRUE); + } + +LExit: + ReleaseBSTR(bstrName); + ReleaseObject(pNetFwRules); + ReleaseObject(pNetFwRule); + + return fIgnoreFailures ? S_OK : hr; +} + +/****************************************************************** + AddPortExceptionOnCurrentProfile + +********************************************************************/ +static HRESULT AddPortExceptionOnCurrentProfile( + __in LPCWSTR wzName, + __in_opt LPCWSTR wzRemoteAddresses, + __in BOOL fIgnoreFailures, + __in int iPort, + __in int iProtocol + ) +{ + HRESULT hr = S_OK; + BSTR bstrName = NULL; + BSTR bstrRemoteAddresses = NULL; + INetFwProfile* pfwProfile = NULL; + INetFwOpenPorts* pfwPorts = NULL; + INetFwOpenPort* pfwPort = NULL; + + // convert to BSTRs to make COM happy + bstrName = ::SysAllocString(wzName); + ExitOnNull(bstrName, hr, E_OUTOFMEMORY, "failed SysAllocString for name"); + bstrRemoteAddresses = ::SysAllocString(wzRemoteAddresses); + ExitOnNull(bstrRemoteAddresses, hr, E_OUTOFMEMORY, "failed SysAllocString for remote addresses"); + + // create and initialize a new open port object + hr = ::CoCreateInstance(__uuidof(NetFwOpenPort), NULL, CLSCTX_INPROC_SERVER, __uuidof(INetFwOpenPort), reinterpret_cast(&pfwPort)); + ExitOnFailure(hr, "failed to create new open port"); + + hr = pfwPort->put_Port(iPort); + ExitOnFailure(hr, "failed to set exception port"); + + hr = pfwPort->put_Protocol(static_cast(iProtocol)); + ExitOnFailure(hr, "failed to set exception protocol"); + + if (bstrRemoteAddresses && *bstrRemoteAddresses) + { + hr = pfwPort->put_RemoteAddresses(bstrRemoteAddresses); + ExitOnFailure(hr, "failed to set exception remote addresses '%ls'", bstrRemoteAddresses); + } + + hr = pfwPort->put_Name(bstrName); + ExitOnFailure(hr, "failed to set exception name"); + + // get the firewall profile, its current list of open ports, and add ours + hr = GetCurrentFirewallProfile(fIgnoreFailures, &pfwProfile); + ExitOnFailure(hr, "failed to get firewall profile"); + if (S_FALSE == hr) // user or package author chose to ignore missing firewall + { + ExitFunction(); + } + + hr = pfwProfile->get_GloballyOpenPorts(&pfwPorts); + ExitOnFailure(hr, "failed to get open ports"); + + hr = pfwPorts->Add(pfwPort); + ExitOnFailure(hr, "failed to add exception to global list"); + +LExit: + ReleaseBSTR(bstrRemoteAddresses); + ReleaseBSTR(bstrName); + ReleaseObject(pfwProfile); + ReleaseObject(pfwPorts); + ReleaseObject(pfwPort); + + return fIgnoreFailures ? S_OK : hr; +} + +/****************************************************************** + RemoveException - Removes the exception rule with the given name. + +********************************************************************/ +static HRESULT RemoveException( + __in LPCWSTR wzName, + __in BOOL fIgnoreFailures + ) +{ + HRESULT hr = S_OK;; + INetFwRules* pNetFwRules = NULL; + + // convert to BSTRs to make COM happy + BSTR bstrName = ::SysAllocString(wzName); + ExitOnNull(bstrName, hr, E_OUTOFMEMORY, "failed SysAllocString for path"); + + // get the collection of firewall rules + hr = GetFirewallRules(fIgnoreFailures, &pNetFwRules); + ExitOnFailure(hr, "failed to get firewall rules object"); + if (S_FALSE == hr) // user or package author chose to ignore missing firewall + { + ExitFunction(); + } + + hr = pNetFwRules->Remove(bstrName); + ExitOnFailure(hr, "failed to remove authorized app"); + +LExit: + ReleaseBSTR(bstrName); + ReleaseObject(pNetFwRules); + + return fIgnoreFailures ? S_OK : hr; +} + +/****************************************************************** + RemoveApplicationExceptionFromCurrentProfile + +********************************************************************/ +static HRESULT RemoveApplicationExceptionFromCurrentProfile( + __in LPCWSTR wzFile, + __in BOOL fIgnoreFailures + ) +{ + HRESULT hr = S_OK; + INetFwProfile* pfwProfile = NULL; + INetFwAuthorizedApplications* pfwApps = NULL; + + // convert to BSTRs to make COM happy + BSTR bstrFile = ::SysAllocString(wzFile); + ExitOnNull(bstrFile, hr, E_OUTOFMEMORY, "failed SysAllocString for path"); + + // get the firewall profile, which is our entry point for removing exceptions + hr = GetCurrentFirewallProfile(fIgnoreFailures, &pfwProfile); + ExitOnFailure(hr, "failed to get firewall profile"); + if (S_FALSE == hr) // user or package author chose to ignore missing firewall + { + ExitFunction(); + } + + // now get the list of app exceptions and remove the one + hr = pfwProfile->get_AuthorizedApplications(&pfwApps); + ExitOnFailure(hr, "failed to get list of authorized apps"); + + hr = pfwApps->Remove(bstrFile); + ExitOnFailure(hr, "failed to remove authorized app"); + +LExit: + ReleaseBSTR(bstrFile); + ReleaseObject(pfwApps); + ReleaseObject(pfwProfile); + + return fIgnoreFailures ? S_OK : hr; +} + +/****************************************************************** + RemovePortExceptionFromCurrentProfile + +********************************************************************/ +static HRESULT RemovePortExceptionFromCurrentProfile( + __in int iPort, + __in int iProtocol, + __in BOOL fIgnoreFailures + ) +{ + HRESULT hr = S_OK; + INetFwProfile* pfwProfile = NULL; + INetFwOpenPorts* pfwPorts = NULL; + + // get the firewall profile, which is our entry point for adding exceptions + hr = GetCurrentFirewallProfile(fIgnoreFailures, &pfwProfile); + ExitOnFailure(hr, "failed to get firewall profile"); + if (S_FALSE == hr) // user or package author chose to ignore missing firewall + { + ExitFunction(); + } + + hr = pfwProfile->get_GloballyOpenPorts(&pfwPorts); + ExitOnFailure(hr, "failed to get open ports"); + + hr = pfwPorts->Remove(iPort, static_cast(iProtocol)); + ExitOnFailure(hr, "failed to remove open port %d, protocol %d", iPort, iProtocol); + +LExit: + return fIgnoreFailures ? S_OK : hr; +} + +static HRESULT AddApplicationException( + __in BOOL fSupportProfiles, + __in LPCWSTR wzFile, + __in LPCWSTR wzName, + __in int iProfile, + __in_opt LPCWSTR wzRemoteAddresses, + __in BOOL fIgnoreFailures, + __in LPCWSTR wzPort, + __in int iProtocol, + __in LPCWSTR wzDescription, + __in int iDirection +) +{ + HRESULT hr = S_OK; + + if (fSupportProfiles) + { + hr = AddApplicationException(wzFile, wzName, iProfile, wzRemoteAddresses, fIgnoreFailures, wzPort, iProtocol, wzDescription, iDirection); + } + else + { + if (0 != *wzPort || MSI_NULL_INTEGER != iProtocol) + { + // NOTE: This is treated as an error rather than either creating a rule based on just the application (no port), or + // just the port because it is unclear what is the proper fall back. For example, suppose that you have code that + // runs in dllhost.exe. Clearly falling back to opening all of dllhost is wrong. Because the firewall is a security + // feature, it seems better to require the MSI author to indicate the behavior that they want. + WcaLog(LOGMSG_STANDARD, "FirewallExtension: Cannot add firewall rule '%ls', which defines both an application and a port or protocol. Such a rule requires Microsoft Windows Vista or later.", wzName); + return fIgnoreFailures ? S_OK : E_NOTIMPL; + } + + hr = AddApplicationExceptionOnCurrentProfile(wzFile, wzName, wzRemoteAddresses, fIgnoreFailures); + } + + return hr; +} + +static HRESULT AddPortException( + __in BOOL fSupportProfiles, + __in LPCWSTR wzName, + __in int iProfile, + __in_opt LPCWSTR wzRemoteAddresses, + __in BOOL fIgnoreFailures, + __in LPCWSTR wzPort, + __in int iProtocol, + __in LPCWSTR wzDescription, + __in int iDirection +) +{ + HRESULT hr = S_OK; + + if (fSupportProfiles) + { + hr = AddPortException(wzName, iProfile, wzRemoteAddresses, fIgnoreFailures, wzPort, iProtocol, wzDescription, iDirection); + } + else + { + hr = AddPortExceptionOnCurrentProfile(wzName, wzRemoteAddresses, fIgnoreFailures, wcstol(wzPort, NULL, 10), iProtocol); + } + + return hr; +} + +static HRESULT RemoveApplicationException( + __in BOOL fSupportProfiles, + __in LPCWSTR wzName, + __in LPCWSTR wzFile, + __in BOOL fIgnoreFailures, + __in LPCWSTR wzPort, + __in int iProtocol + ) +{ + HRESULT hr = S_OK; + + if (fSupportProfiles) + { + hr = RemoveException(wzName, fIgnoreFailures); + } + else + { + if (0 != *wzPort || MSI_NULL_INTEGER != iProtocol) + { + WcaLog(LOGMSG_STANDARD, "FirewallExtension: Cannot remove firewall rule '%ls', which defines both an application and a port or protocol. Such a rule requires Microsoft Windows Vista or later.", wzName); + return S_OK; + } + + hr = RemoveApplicationExceptionFromCurrentProfile(wzFile, fIgnoreFailures); + } + + return hr; +} + +static HRESULT RemovePortException( + __in BOOL fSupportProfiles, + __in LPCWSTR wzName, + __in LPCWSTR wzPort, + __in int iProtocol, + __in BOOL fIgnoreFailures + ) +{ + HRESULT hr = S_OK; + + if (fSupportProfiles) + { + hr = RemoveException(wzName, fIgnoreFailures); + } + else + { + hr = RemovePortExceptionFromCurrentProfile(wcstol(wzPort, NULL, 10), iProtocol, fIgnoreFailures); + } + + return hr; +} + +/****************************************************************** + ExecFirewallExceptions - deferred custom action entry point to + register and remove firewall exceptions. + +********************************************************************/ +extern "C" UINT __stdcall ExecFirewallExceptions( + __in MSIHANDLE hInstall + ) +{ + HRESULT hr = S_OK; + BOOL fSupportProfiles = FALSE; + LPWSTR pwz = NULL; + LPWSTR pwzCustomActionData = NULL; + int iTodo = WCA_TODO_UNKNOWN; + LPWSTR pwzName = NULL; + LPWSTR pwzRemoteAddresses = NULL; + int iAttributes = 0; + int iTarget = fetUnknown; + LPWSTR pwzFile = NULL; + LPWSTR pwzPort = NULL; + LPWSTR pwzDescription = NULL; + int iProtocol = 0; + int iProfile = 0; + int iDirection = 0; + + // initialize + hr = WcaInitialize(hInstall, "ExecFirewallExceptions"); + ExitOnFailure(hr, "failed to initialize"); + + hr = WcaGetProperty( L"CustomActionData", &pwzCustomActionData); + ExitOnFailure(hr, "failed to get CustomActionData"); + WcaLog(LOGMSG_TRACEONLY, "CustomActionData: %ls", pwzCustomActionData); + + hr = ::CoInitialize(NULL); + ExitOnFailure(hr, "failed to initialize COM"); + + // Find out if we support profiles (only on Vista or later) + fSupportProfiles = FSupportProfiles(); + + // loop through all the passed in data + pwz = pwzCustomActionData; + while (pwz && *pwz) + { + // extract the custom action data and if rolling back, swap INSTALL and UNINSTALL + hr = WcaReadIntegerFromCaData(&pwz, &iTodo); + ExitOnFailure(hr, "failed to read todo from custom action data"); + if (::MsiGetMode(hInstall, MSIRUNMODE_ROLLBACK)) + { + if (WCA_TODO_INSTALL == iTodo) + { + iTodo = WCA_TODO_UNINSTALL; + } + else if (WCA_TODO_UNINSTALL == iTodo) + { + iTodo = WCA_TODO_INSTALL; + } + } + + hr = WcaReadStringFromCaData(&pwz, &pwzName); + ExitOnFailure(hr, "failed to read name from custom action data"); + + hr = WcaReadIntegerFromCaData(&pwz, &iProfile); + ExitOnFailure(hr, "failed to read profile from custom action data"); + + hr = WcaReadStringFromCaData(&pwz, &pwzRemoteAddresses); + ExitOnFailure(hr, "failed to read remote addresses from custom action data"); + + hr = WcaReadIntegerFromCaData(&pwz, &iAttributes); + ExitOnFailure(hr, "failed to read attributes from custom action data"); + BOOL fIgnoreFailures = feaIgnoreFailures == (iAttributes & feaIgnoreFailures); + + hr = WcaReadIntegerFromCaData(&pwz, &iTarget); + ExitOnFailure(hr, "failed to read target from custom action data"); + + if (iTarget == fetApplication) + { + hr = WcaReadStringFromCaData(&pwz, &pwzFile); + ExitOnFailure(hr, "failed to read file path from custom action data"); + } + + hr = WcaReadStringFromCaData(&pwz, &pwzPort); + ExitOnFailure(hr, "failed to read port from custom action data"); + hr = WcaReadIntegerFromCaData(&pwz, &iProtocol); + ExitOnFailure(hr, "failed to read protocol from custom action data"); + hr = WcaReadStringFromCaData(&pwz, &pwzDescription); + ExitOnFailure(hr, "failed to read protocol from custom action data"); + hr = WcaReadIntegerFromCaData(&pwz, &iDirection); + ExitOnFailure(hr, "failed to read direction from custom action data"); + + switch (iTarget) + { + case fetPort: + switch (iTodo) + { + case WCA_TODO_INSTALL: + case WCA_TODO_REINSTALL: + WcaLog(LOGMSG_STANDARD, "Installing firewall exception2 %ls on port %ls, protocol %d", pwzName, pwzPort, iProtocol); + hr = AddPortException(fSupportProfiles, pwzName, iProfile, pwzRemoteAddresses, fIgnoreFailures, pwzPort, iProtocol, pwzDescription, iDirection); + ExitOnFailure(hr, "failed to add/update port exception for name '%ls' on port %ls, protocol %d", pwzName, pwzPort, iProtocol); + break; + + case WCA_TODO_UNINSTALL: + WcaLog(LOGMSG_STANDARD, "Uninstalling firewall exception2 %ls on port %ls, protocol %d", pwzName, pwzPort, iProtocol); + hr = RemovePortException(fSupportProfiles, pwzName, pwzPort, iProtocol, fIgnoreFailures); + ExitOnFailure(hr, "failed to remove port exception for name '%ls' on port %ls, protocol %d", pwzName, pwzPort, iProtocol); + break; + } + break; + + case fetApplication: + switch (iTodo) + { + case WCA_TODO_INSTALL: + case WCA_TODO_REINSTALL: + WcaLog(LOGMSG_STANDARD, "Installing firewall exception2 %ls (%ls)", pwzName, pwzFile); + hr = AddApplicationException(fSupportProfiles, pwzFile, pwzName, iProfile, pwzRemoteAddresses, fIgnoreFailures, pwzPort, iProtocol, pwzDescription, iDirection); + ExitOnFailure(hr, "failed to add/update application exception for name '%ls', file '%ls'", pwzName, pwzFile); + break; + + case WCA_TODO_UNINSTALL: + WcaLog(LOGMSG_STANDARD, "Uninstalling firewall exception2 %ls (%ls)", pwzName, pwzFile); + hr = RemoveApplicationException(fSupportProfiles, pwzName, pwzFile, fIgnoreFailures, pwzPort, iProtocol); + ExitOnFailure(hr, "failed to remove application exception for name '%ls', file '%ls'", pwzName, pwzFile); + break; + } + break; + } + } + +LExit: + ReleaseStr(pwzCustomActionData); + ReleaseStr(pwzName); + ReleaseStr(pwzRemoteAddresses); + ReleaseStr(pwzFile); + ReleaseStr(pwzPort); + ReleaseStr(pwzDescription); + ::CoUninitialize(); + + return WcaFinalize(FAILED(hr) ? ERROR_INSTALL_FAILURE : ERROR_SUCCESS); +} diff --git a/src/ext/Firewall/ca/fwca.def b/src/ext/Firewall/ca/fwca.def new file mode 100644 index 00000000..d32c5379 --- /dev/null +++ b/src/ext/Firewall/ca/fwca.def @@ -0,0 +1,9 @@ +; Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +LIBRARY "fwca" + +EXPORTS + SchedFirewallExceptionsInstall + SchedFirewallExceptionsUninstall + ExecFirewallExceptions diff --git a/src/ext/Firewall/ca/fwca.v3.ncrunchproject b/src/ext/Firewall/ca/fwca.v3.ncrunchproject new file mode 100644 index 00000000..319cd523 --- /dev/null +++ b/src/ext/Firewall/ca/fwca.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/src/ext/Firewall/ca/fwca.vcxproj b/src/ext/Firewall/ca/fwca.vcxproj new file mode 100644 index 00000000..5e9a1db6 --- /dev/null +++ b/src/ext/Firewall/ca/fwca.vcxproj @@ -0,0 +1,81 @@ + + + + + + + + + + Debug + ARM64 + + + Release + ARM64 + + + + Debug + X64 + + + Release + X64 + + + + Debug + Win32 + + + Release + Win32 + + + + + {F72D34CA-48DA-4DFD-91A9-A0C78BEF6981} + DynamicLibrary + fwca + v142 + Unicode + fwca.def + WiX Toolset Firewall CustomAction + + + + + + + msi.lib + + + + + Create + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + diff --git a/src/ext/Firewall/ca/packages.config b/src/ext/Firewall/ca/packages.config new file mode 100644 index 00000000..9d88f529 --- /dev/null +++ b/src/ext/Firewall/ca/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/ext/Firewall/ca/precomp.h b/src/ext/Firewall/ca/precomp.h new file mode 100644 index 00000000..03845e1e --- /dev/null +++ b/src/ext/Firewall/ca/precomp.h @@ -0,0 +1,19 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +#include +#include +#include +#include +#include + +#include "wcautil.h" +#include "fileutil.h" +#include "pathutil.h" +#include "strutil.h" + +#include "CustomMsiErrors.h" +#include "cost.h" + +#include "caDecor.h" diff --git a/src/ext/Firewall/nuget.config b/src/ext/Firewall/nuget.config new file mode 100644 index 00000000..aaf36562 --- /dev/null +++ b/src/ext/Firewall/nuget.config @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/ext/Firewall/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs b/src/ext/Firewall/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs new file mode 100644 index 00000000..ffdc1326 --- /dev/null +++ b/src/ext/Firewall/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs @@ -0,0 +1,80 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolsetTest.Firewall +{ + using System.Linq; + using WixBuildTools.TestSupport; + using WixToolset.Core.TestPackage; + using WixToolset.Firewall; + using Xunit; + + public class FirewallExtensionFixture + { + [Fact] + public void CanBuildUsingFirewall() + { + var folder = TestData.Get(@"TestData\UsingFirewall"); + var build = new Builder(folder, typeof(FirewallExtensionFactory), new[] { folder }); + + var results = build.BuildAndQuery(Build, "Wix4FirewallException", "CustomAction"); + Assert.Equal(new[] + { + "CustomAction:Wix4ExecFirewallExceptionsInstall_X86\t3073\tWix4FWCA_X86\tExecFirewallExceptions\t", + "CustomAction:Wix4ExecFirewallExceptionsUninstall_X86\t3073\tWix4FWCA_X86\tExecFirewallExceptions\t", + "CustomAction:Wix4RollbackFirewallExceptionsInstall_X86\t3329\tWix4FWCA_X86\tExecFirewallExceptions\t", + "CustomAction:Wix4RollbackFirewallExceptionsUninstall_X86\t3329\tWix4FWCA_X86\tExecFirewallExceptions\t", + "CustomAction:Wix4SchedFirewallExceptionsInstall_X86\t1\tWix4FWCA_X86\tSchedFirewallExceptionsInstall\t", + "CustomAction:Wix4SchedFirewallExceptionsUninstall_X86\t1\tWix4FWCA_X86\tSchedFirewallExceptionsUninstall\t", + "Wix4FirewallException:ExampleFirewall\texample\t*\t42\t6\t\t0\t2147483647\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tAn example firewall\t1", + }, results); + } + + [Fact] + public void CanBuildUsingFirewallARM64() + { + var folder = TestData.Get(@"TestData\UsingFirewall"); + var build = new Builder(folder, typeof(FirewallExtensionFactory), new[] { folder }); + + var results = build.BuildAndQuery(BuildARM64, "Wix4FirewallException", "CustomAction"); + Assert.Equal(new[] + { + "CustomAction:Wix4ExecFirewallExceptionsInstall_A64\t3073\tWix4FWCA_A64\tExecFirewallExceptions\t", + "CustomAction:Wix4ExecFirewallExceptionsUninstall_A64\t3073\tWix4FWCA_A64\tExecFirewallExceptions\t", + "CustomAction:Wix4RollbackFirewallExceptionsInstall_A64\t3329\tWix4FWCA_A64\tExecFirewallExceptions\t", + "CustomAction:Wix4RollbackFirewallExceptionsUninstall_A64\t3329\tWix4FWCA_A64\tExecFirewallExceptions\t", + "CustomAction:Wix4SchedFirewallExceptionsInstall_A64\t1\tWix4FWCA_A64\tSchedFirewallExceptionsInstall\t", + "CustomAction:Wix4SchedFirewallExceptionsUninstall_A64\t1\tWix4FWCA_A64\tSchedFirewallExceptionsUninstall\t", + "Wix4FirewallException:ExampleFirewall\texample\t*\t42\t6\t\t0\t2147483647\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tAn example firewall\t1", + }, results); + } + + [Fact] + public void CanBuildUsingOutboundFirewall() + { + var folder = TestData.Get(@"TestData\UsingOutboundFirewall"); + var build = new Builder(folder, typeof(FirewallExtensionFactory), new[] { folder }); + + var results = build.BuildAndQuery(Build, "Wix4FirewallException"); + Assert.Equal(new[] + { + "Wix4FirewallException:fex.5c8b_4C0THcQTvn8tpwhoRrgck\texample\t*\t42\t6\t\t0\t2147483647\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tAn example outbound firewall\t2", + }, results); + } + + private static void Build(string[] args) + { + var result = WixRunner.Execute(args); + result.AssertSuccess(); + } + + private static void BuildARM64(string[] args) + { + var newArgs = args.ToList(); + newArgs.Add("-platform"); + newArgs.Add("arm64"); + + var result = WixRunner.Execute(newArgs.ToArray()); + result.AssertSuccess(); + } + } +} diff --git a/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.en-us.wxl b/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.en-us.wxl @@ -0,0 +1,11 @@ + + + + + + A newer version of [ProductName] is already installed. + MsiPackage + + diff --git a/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.wxs b/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.wxs new file mode 100644 index 00000000..411893bc --- /dev/null +++ b/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.wxs @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs b/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs new file mode 100644 index 00000000..53e75427 --- /dev/null +++ b/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs @@ -0,0 +1,14 @@ + + + + + + + + + + + + + diff --git a/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingFirewall/example.txt b/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingFirewall/example.txt new file mode 100644 index 00000000..1b4ffe8a --- /dev/null +++ b/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingFirewall/example.txt @@ -0,0 +1 @@ +This is example.txt. \ No newline at end of file diff --git a/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.en-us.wxl b/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.en-us.wxl @@ -0,0 +1,11 @@ + + + + + + A newer version of [ProductName] is already installed. + MsiPackage + + diff --git a/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.wxs b/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.wxs new file mode 100644 index 00000000..411893bc --- /dev/null +++ b/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.wxs @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/PackageComponents.wxs b/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/PackageComponents.wxs new file mode 100644 index 00000000..8084706e --- /dev/null +++ b/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/PackageComponents.wxs @@ -0,0 +1,14 @@ + + + + + + + + + + + + + diff --git a/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/example.txt b/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/example.txt new file mode 100644 index 00000000..1b4ffe8a --- /dev/null +++ b/src/ext/Firewall/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/example.txt @@ -0,0 +1 @@ +This is example.txt. \ No newline at end of file diff --git a/src/ext/Firewall/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj b/src/ext/Firewall/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj new file mode 100644 index 00000000..d04368c1 --- /dev/null +++ b/src/ext/Firewall/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj @@ -0,0 +1,45 @@ + + + + + + netcoreapp3.1 + false + + + + NU1701 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ext/Firewall/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.v3.ncrunchproject b/src/ext/Firewall/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.v3.ncrunchproject new file mode 100644 index 00000000..7b5b2139 --- /dev/null +++ b/src/ext/Firewall/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/src/ext/Firewall/wix.snk b/src/ext/Firewall/wix.snk new file mode 100644 index 00000000..3908a66a Binary files /dev/null and b/src/ext/Firewall/wix.snk differ diff --git a/src/ext/Firewall/wixext/FirewallCompiler.cs b/src/ext/Firewall/wixext/FirewallCompiler.cs new file mode 100644 index 00000000..cbe82d37 --- /dev/null +++ b/src/ext/Firewall/wixext/FirewallCompiler.cs @@ -0,0 +1,354 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Firewall +{ + using System; + using System.Collections.Generic; + using System.Xml.Linq; + using WixToolset.Data; + using WixToolset.Extensibility; + using WixToolset.Extensibility.Data; + using WixToolset.Firewall.Symbols; + + /// + /// The compiler for the WiX Toolset Firewall Extension. + /// + public sealed class FirewallCompiler : BaseCompilerExtension + { + public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/firewall"; + + /// + /// Processes an element for the Compiler. + /// + /// Source line number for the parent element. + /// Parent element of element to process. + /// Element to process. + /// Extra information about the context in which this element is being parsed. + public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context) + { + switch (parentElement.Name.LocalName) + { + case "File": + var fileId = context["FileId"]; + var fileComponentId = context["ComponentId"]; + + switch (element.Name.LocalName) + { + case "FirewallException": + this.ParseFirewallExceptionElement(intermediate, section, element, fileComponentId, fileId); + break; + default: + this.ParseHelper.UnexpectedElement(parentElement, element); + break; + } + break; + case "Component": + var componentId = context["ComponentId"]; + + switch (element.Name.LocalName) + { + case "FirewallException": + this.ParseFirewallExceptionElement(intermediate, section, element, componentId, null); + break; + default: + this.ParseHelper.UnexpectedElement(parentElement, element); + break; + } + break; + default: + this.ParseHelper.UnexpectedElement(parentElement, element); + break; + } + } + + /// + /// Parses a FirewallException element. + /// + /// The element to parse. + /// Identifier of the component that owns this firewall exception. + /// The file identifier of the parent element (null if nested under Component). + private void ParseFirewallExceptionElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId, string fileId) + { + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + Identifier id = null; + string name = null; + int attributes = 0; + string file = null; + string program = null; + string port = null; + int? protocol = null; + int? profile = null; + string scope = null; + string remoteAddresses = null; + string description = null; + int? direction = null; + + foreach (var attrib in element.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "Id": + id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Name": + name = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "File": + if (null != fileId) + { + this.Messaging.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, element.Name.LocalName, "File", "File")); + } + else + { + file = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + } + break; + case "IgnoreFailure": + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= 0x1; // feaIgnoreFailures + } + break; + case "Program": + if (null != fileId) + { + this.Messaging.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, element.Name.LocalName, "Program", "File")); + } + else + { + program = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + } + break; + case "Port": + port = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Protocol": + var protocolValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + switch (protocolValue) + { + case "tcp": + protocol = FirewallConstants.NET_FW_IP_PROTOCOL_TCP; + break; + case "udp": + protocol = FirewallConstants.NET_FW_IP_PROTOCOL_UDP; + break; + default: + this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, element.Name.LocalName, "Protocol", protocolValue, "tcp", "udp")); + break; + } + break; + case "Scope": + scope = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + switch (scope) + { + case "any": + remoteAddresses = "*"; + break; + case "localSubnet": + remoteAddresses = "LocalSubnet"; + break; + default: + this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, element.Name.LocalName, "Scope", scope, "any", "localSubnet")); + break; + } + break; + case "Profile": + var profileValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + switch (profileValue) + { + case "domain": + profile = FirewallConstants.NET_FW_PROFILE2_DOMAIN; + break; + case "private": + profile = FirewallConstants.NET_FW_PROFILE2_PRIVATE; + break; + case "public": + profile = FirewallConstants.NET_FW_PROFILE2_PUBLIC; + break; + case "all": + profile = FirewallConstants.NET_FW_PROFILE2_ALL; + break; + default: + this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, element.Name.LocalName, "Profile", profileValue, "domain", "private", "public", "all")); + break; + } + break; + case "Description": + description = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Outbound": + direction = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib) == YesNoType.Yes + ? FirewallConstants.NET_FW_RULE_DIR_OUT + : FirewallConstants.NET_FW_RULE_DIR_IN; + break; + default: + this.ParseHelper.UnexpectedAttribute(element, attrib); + break; + } + } + else + { + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); + } + } + + // parse RemoteAddress children + foreach (var child in element.Elements()) + { + if (this.Namespace == child.Name.Namespace) + { + switch (child.Name.LocalName) + { + case "RemoteAddress": + if (null != scope) + { + this.Messaging.Write(FirewallErrors.IllegalRemoteAddressWithScopeAttribute(sourceLineNumbers)); + } + else + { + this.ParseRemoteAddressElement(intermediate, section, child, ref remoteAddresses); + } + break; + default: + this.ParseHelper.UnexpectedElement(element, child); + break; + } + } + else + { + this.ParseHelper.ParseExtensionElement(this.Context.Extensions, intermediate, section, element, child); + } + } + + if (null == id) + { + id = this.ParseHelper.CreateIdentifier("fex", name, remoteAddresses, componentId); + } + + // Name is required + if (null == name) + { + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Name")); + } + + // Scope or child RemoteAddress(es) are required + if (null == remoteAddresses) + { + this.Messaging.Write(ErrorMessages.ExpectedAttributeOrElement(sourceLineNumbers, element.Name.LocalName, "Scope", "RemoteAddress")); + } + + // can't have both Program and File + if (null != program && null != file) + { + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, element.Name.LocalName, "File", "Program")); + } + + // must be nested under File, have File or Program attributes, or have Port attribute + if (String.IsNullOrEmpty(fileId) && String.IsNullOrEmpty(file) && String.IsNullOrEmpty(program) && String.IsNullOrEmpty(port)) + { + this.Messaging.Write(FirewallErrors.NoExceptionSpecified(sourceLineNumbers)); + } + + if (!this.Messaging.EncounteredError) + { + // at this point, File attribute and File parent element are treated the same + if (null != file) + { + fileId = file; + } + + var symbol = section.AddSymbol(new WixFirewallExceptionSymbol(sourceLineNumbers, id) + { + Name = name, + RemoteAddresses = remoteAddresses, + Profile = profile ?? FirewallConstants.NET_FW_PROFILE2_ALL, + ComponentRef = componentId, + Description = description, + Direction = direction ?? FirewallConstants.NET_FW_RULE_DIR_IN, + }); + + if (!String.IsNullOrEmpty(port)) + { + symbol.Port = port; + + if (!protocol.HasValue) + { + // default protocol is "TCP" + protocol = FirewallConstants.NET_FW_IP_PROTOCOL_TCP; + } + } + + if (protocol.HasValue) + { + symbol.Protocol = protocol.Value; + } + + if (!String.IsNullOrEmpty(fileId)) + { + symbol.Program = $"[#{fileId}]"; + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.File, fileId); + } + else if (!String.IsNullOrEmpty(program)) + { + symbol.Program = program; + } + + if (CompilerConstants.IntegerNotSet != attributes) + { + symbol.Attributes = attributes; + } + + this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4SchedFirewallExceptionsInstall", this.Context.Platform, CustomActionPlatforms.ARM64 | CustomActionPlatforms.X64 | CustomActionPlatforms.X86); + this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4SchedFirewallExceptionsUninstall", this.Context.Platform, CustomActionPlatforms.ARM64 | CustomActionPlatforms.X64 | CustomActionPlatforms.X86); + } + } + + /// + /// Parses a RemoteAddress element + /// + /// The element to parse. + private void ParseRemoteAddressElement(Intermediate intermediate, IntermediateSection section, XElement element, ref string remoteAddresses) + { + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + string address = null; + + // no attributes + foreach (var attrib in element.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "Value": + address = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + } + } + else + { + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); + } + } + + this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); + + if (String.IsNullOrEmpty(address)) + { + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Value")); + } + else + { + if (String.IsNullOrEmpty(remoteAddresses)) + { + remoteAddresses = address; + } + else + { + remoteAddresses = String.Concat(remoteAddresses, ",", address); + } + } + } + } +} diff --git a/src/ext/Firewall/wixext/FirewallConstants.cs b/src/ext/Firewall/wixext/FirewallConstants.cs new file mode 100644 index 00000000..7bb12ba4 --- /dev/null +++ b/src/ext/Firewall/wixext/FirewallConstants.cs @@ -0,0 +1,23 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Firewall +{ + using System; + using System.Collections.Generic; + using System.Text; + + static class FirewallConstants + { + // from icftypes.h + public const int NET_FW_RULE_DIR_IN = 1; + public const int NET_FW_RULE_DIR_OUT = 2; + public const int NET_FW_IP_PROTOCOL_TCP = 6; + public const int NET_FW_IP_PROTOCOL_UDP = 17; + + // from icftypes.h + public const int NET_FW_PROFILE2_DOMAIN = 0x0001; + public const int NET_FW_PROFILE2_PRIVATE = 0x0002; + public const int NET_FW_PROFILE2_PUBLIC = 0x0004; + public const int NET_FW_PROFILE2_ALL = 0x7FFFFFFF; + } +} diff --git a/src/ext/Firewall/wixext/FirewallDecompiler.cs b/src/ext/Firewall/wixext/FirewallDecompiler.cs new file mode 100644 index 00000000..c9478de1 --- /dev/null +++ b/src/ext/Firewall/wixext/FirewallDecompiler.cs @@ -0,0 +1,182 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Firewall +{ +#if TODO_CONSIDER_DECOMPILER + using System; + using System.Collections; + using System.Diagnostics; + using System.Globalization; + using WixToolset.Data; + using WixToolset.Extensibility; + using Firewall = WixToolset.Extensions.Serialize.Firewall; + using Wix = WixToolset.Data.Serialize; + + /// + /// The decompiler for the WiX Toolset Firewall Extension. + /// + public sealed class FirewallDecompiler : DecompilerExtension + { + /// + /// Creates a decompiler for Firewall Extension. + /// + public FirewallDecompiler() + { + this.TableDefinitions = FirewallExtensionData.GetExtensionTableDefinitions(); + } + + /// + /// Get the extensions library to be removed. + /// + /// Table definitions for library. + /// Library to remove from decompiled output. + public override Library GetLibraryToRemove(TableDefinitionCollection tableDefinitions) + { + return FirewallExtensionData.GetExtensionLibrary(tableDefinitions); + } + + /// + /// Decompiles an extension table. + /// + /// The table to decompile. + public override void DecompileTable(Table table) + { + switch (table.Name) + { + case "WixFirewallException": + this.DecompileWixFirewallExceptionTable(table); + break; + default: + base.DecompileTable(table); + break; + } + } + + /// + /// Decompile the WixFirewallException table. + /// + /// The table to decompile. + private void DecompileWixFirewallExceptionTable(Table table) + { + foreach (Row row in table.Rows) + { + Firewall.FirewallException fire = new Firewall.FirewallException(); + fire.Id = (string)row[0]; + fire.Name = (string)row[1]; + + string[] addresses = ((string)row[2]).Split(','); + if (1 == addresses.Length) + { + // special-case the Scope attribute values + if ("*" == addresses[0]) + { + fire.Scope = Firewall.FirewallException.ScopeType.any; + } + else if ("LocalSubnet" == addresses[0]) + { + fire.Scope = Firewall.FirewallException.ScopeType.localSubnet; + } + else + { + FirewallDecompiler.AddRemoteAddress(fire, addresses[0]); + } + } + else + { + foreach (string address in addresses) + { + FirewallDecompiler.AddRemoteAddress(fire, address); + } + } + + if (!row.IsColumnEmpty(3)) + { + fire.Port = (string)row[3]; + } + + if (!row.IsColumnEmpty(4)) + { + switch (Convert.ToInt32(row[4])) + { + case FirewallConstants.NET_FW_IP_PROTOCOL_TCP: + fire.Protocol = Firewall.FirewallException.ProtocolType.tcp; + break; + case FirewallConstants.NET_FW_IP_PROTOCOL_UDP: + fire.Protocol = Firewall.FirewallException.ProtocolType.udp; + break; + } + } + + if (!row.IsColumnEmpty(5)) + { + fire.Program = (string)row[5]; + } + + if (!row.IsColumnEmpty(6)) + { + int attr = Convert.ToInt32(row[6]); + if (0x1 == (attr & 0x1)) // feaIgnoreFailures + { + fire.IgnoreFailure = Firewall.YesNoType.yes; + } + } + + if (!row.IsColumnEmpty(7)) + { + switch (Convert.ToInt32(row[7])) + { + case FirewallConstants.NET_FW_PROFILE2_DOMAIN: + fire.Profile = Firewall.FirewallException.ProfileType.domain; + break; + case FirewallConstants.NET_FW_PROFILE2_PRIVATE: + fire.Profile = Firewall.FirewallException.ProfileType.@private; + break; + case FirewallConstants.NET_FW_PROFILE2_PUBLIC: + fire.Profile = Firewall.FirewallException.ProfileType.@public; + break; + case FirewallConstants.NET_FW_PROFILE2_ALL: + fire.Profile = Firewall.FirewallException.ProfileType.all; + break; + } + } + + // Description column is new in v3.6 + if (9 < row.Fields.Length && !row.IsColumnEmpty(9)) + { + fire.Description = (string)row[9]; + } + + if (!row.IsColumnEmpty(10)) + { + switch (Convert.ToInt32(row[10])) + { + case FirewallConstants.NET_FW_RULE_DIR_IN: + fire.Direction = Firewall.FirewallException.DirectionType.@in; + break; + case FirewallConstants.NET_FW_RULE_DIR_OUT: + fire.Direction = Firewall.FirewallException.DirectionType.@out; + break; + } + } + + Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[8]); + if (null != component) + { + component.AddChild(fire); + } + else + { + this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[6], "Component")); + } + } + } + + private static void AddRemoteAddress(Firewall.FirewallException fire, string address) + { + Firewall.RemoteAddress remote = new Firewall.RemoteAddress(); + remote.Content = address; + fire.AddChild(remote); + } + } +#endif +} diff --git a/src/ext/Firewall/wixext/FirewallErrors.cs b/src/ext/Firewall/wixext/FirewallErrors.cs new file mode 100644 index 00000000..b2dac782 --- /dev/null +++ b/src/ext/Firewall/wixext/FirewallErrors.cs @@ -0,0 +1,36 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Firewall +{ + using System.Resources; + using WixToolset.Data; + + public static class FirewallErrors + { + public static Message IllegalRemoteAddressWithScopeAttribute(SourceLineNumber sourceLineNumbers) + { + return Message(sourceLineNumbers, Ids.IllegalRemoteAddressWithScopeAttribute, "The RemoteAddress element cannot be specified because its parent FirewallException already specified the Scope attribute. To use RemoteAddress elements, omit the Scope attribute."); + } + + public static Message NoExceptionSpecified(SourceLineNumber sourceLineNumbers) + { + return Message(sourceLineNumbers, Ids.NoExceptionSpecified, "The FirewallException element doesn't identify the target of the firewall exception. To create an application exception, nest the FirewallException element under a File element or provide a value for the File or Program attributes. To create a port exception, provide a value for the Port attribute."); + } + + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) + { + return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args); + } + + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, ResourceManager resourceManager, string resourceName, params object[] args) + { + return new Message(sourceLineNumber, MessageLevel.Error, (int)id, resourceManager, resourceName, args); + } + + public enum Ids + { + IllegalRemoteAddressWithScopeAttribute = 6401, + NoExceptionSpecified = 6403, + } + } +} diff --git a/src/ext/Firewall/wixext/FirewallExtensionData.cs b/src/ext/Firewall/wixext/FirewallExtensionData.cs new file mode 100644 index 00000000..7481d993 --- /dev/null +++ b/src/ext/Firewall/wixext/FirewallExtensionData.cs @@ -0,0 +1,23 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Firewall +{ + using WixToolset.Data; + using WixToolset.Extensibility; + + public sealed class FirewallExtensionData : BaseExtensionData + { + public override string DefaultCulture => "en-US"; + + public override bool TryGetSymbolDefinitionByName(string name, out IntermediateSymbolDefinition symbolDefinition) + { + symbolDefinition = FirewallSymbolDefinitions.ByName(name); + return symbolDefinition != null; + } + + public override Intermediate GetLibrary(ISymbolDefinitionCreator symbolDefinitions) + { + return Intermediate.Load(typeof(FirewallExtensionData).Assembly, "WixToolset.Firewall.firewall.wixlib", symbolDefinitions); + } + } +} diff --git a/src/ext/Firewall/wixext/FirewallExtensionFactory.cs b/src/ext/Firewall/wixext/FirewallExtensionFactory.cs new file mode 100644 index 00000000..279b322a --- /dev/null +++ b/src/ext/Firewall/wixext/FirewallExtensionFactory.cs @@ -0,0 +1,18 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Firewall +{ + using System; + using System.Collections.Generic; + using WixToolset.Extensibility; + + public class FirewallExtensionFactory : BaseExtensionFactory + { + protected override IReadOnlyCollection ExtensionTypes => new[] + { + typeof(FirewallCompiler), + typeof(FirewallExtensionData), + typeof(FirewallWindowsInstallerBackendBinderExtension), + }; + } +} diff --git a/src/ext/Firewall/wixext/FirewallTableDefinitions.cs b/src/ext/Firewall/wixext/FirewallTableDefinitions.cs new file mode 100644 index 00000000..04918f5f --- /dev/null +++ b/src/ext/Firewall/wixext/FirewallTableDefinitions.cs @@ -0,0 +1,34 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Firewall +{ + using WixToolset.Data.WindowsInstaller; + + public static class FirewallTableDefinitions + { + public static readonly TableDefinition WixFirewallException = new TableDefinition( + "Wix4FirewallException", + FirewallSymbolDefinitions.WixFirewallException, + new[] + { + new ColumnDefinition("Wix4FirewallException", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "The primary key, a non-localized token.", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Name", ColumnType.Localized, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Localizable display name.", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("RemoteAddresses", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Remote address to accept incoming connections from.", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("Port", ColumnType.String, 0, primaryKey: false, nullable: true, ColumnCategory.Formatted, minValue: 1, description: "Port number.", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("Protocol", ColumnType.Number, 1, primaryKey: false, nullable: true, ColumnCategory.Integer, minValue: 6, maxValue: 17, description: "Protocol (6=TCP; 17=UDP)."), + new ColumnDefinition("Program", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Exception for a program (formatted path name).", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("Attributes", ColumnType.Number, 4, primaryKey: false, nullable: true, ColumnCategory.Unknown, description: "Vital=1"), + new ColumnDefinition("Profile", ColumnType.Number, 4, primaryKey: false, nullable: false, ColumnCategory.Integer, minValue: 1, maxValue: 2147483647, description: "Profile (1=domain; 2=private; 4=public; 2147483647=all)."), + new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key into the Component table referencing component that controls the firewall configuration.", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Description", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Description displayed in Windows Firewall manager for this firewall rule."), + new ColumnDefinition("Direction", ColumnType.Number, 1, primaryKey: false, nullable: true, ColumnCategory.Integer, minValue: 1, maxValue: 2, description: "Direction (1=in; 2=out)"), + }, + symbolIdIsPrimaryKey: true + ); + + public static readonly TableDefinition[] All = new[] + { + WixFirewallException, + }; + } +} diff --git a/src/ext/Firewall/wixext/FirewallWindowsInstallerBackendExtension.cs b/src/ext/Firewall/wixext/FirewallWindowsInstallerBackendExtension.cs new file mode 100644 index 00000000..b5b97d85 --- /dev/null +++ b/src/ext/Firewall/wixext/FirewallWindowsInstallerBackendExtension.cs @@ -0,0 +1,13 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Firewall +{ + using System.Collections.Generic; + using WixToolset.Data.WindowsInstaller; + using WixToolset.Extensibility; + + public class FirewallWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension + { + public override IReadOnlyCollection TableDefinitions => FirewallTableDefinitions.All; + } +} diff --git a/src/ext/Firewall/wixext/Symbols/FirewallSymbolDefinitions.cs b/src/ext/Firewall/wixext/Symbols/FirewallSymbolDefinitions.cs new file mode 100644 index 00000000..887893c7 --- /dev/null +++ b/src/ext/Firewall/wixext/Symbols/FirewallSymbolDefinitions.cs @@ -0,0 +1,39 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Firewall +{ + using System; + using WixToolset.Data; + + public enum FirewallSymbolDefinitionType + { + WixFirewallException, + } + + public static partial class FirewallSymbolDefinitions + { + public static readonly Version Version = new Version("4.0.0"); + + public static IntermediateSymbolDefinition ByName(string name) + { + if (!Enum.TryParse(name, out FirewallSymbolDefinitionType type)) + { + return null; + } + + return ByType(type); + } + + public static IntermediateSymbolDefinition ByType(FirewallSymbolDefinitionType type) + { + switch (type) + { + case FirewallSymbolDefinitionType.WixFirewallException: + return FirewallSymbolDefinitions.WixFirewallException; + + default: + throw new ArgumentOutOfRangeException(nameof(type)); + } + } + } +} diff --git a/src/ext/Firewall/wixext/Symbols/WixFirewallExceptionSymbol.cs b/src/ext/Firewall/wixext/Symbols/WixFirewallExceptionSymbol.cs new file mode 100644 index 00000000..620de969 --- /dev/null +++ b/src/ext/Firewall/wixext/Symbols/WixFirewallExceptionSymbol.cs @@ -0,0 +1,119 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Firewall +{ + using WixToolset.Data; + using WixToolset.Firewall.Symbols; + + public static partial class FirewallSymbolDefinitions + { + public static readonly IntermediateSymbolDefinition WixFirewallException = new IntermediateSymbolDefinition( + FirewallSymbolDefinitionType.WixFirewallException.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Name), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.RemoteAddresses), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Port), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Protocol), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Program), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Attributes), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Profile), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.ComponentRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Description), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Direction), IntermediateFieldType.Number), + }, + typeof(WixFirewallExceptionSymbol)); + } +} + +namespace WixToolset.Firewall.Symbols +{ + using WixToolset.Data; + + public enum WixFirewallExceptionSymbolFields + { + Name, + RemoteAddresses, + Port, + Protocol, + Program, + Attributes, + Profile, + ComponentRef, + Description, + Direction, + } + + public class WixFirewallExceptionSymbol : IntermediateSymbol + { + public WixFirewallExceptionSymbol() : base(FirewallSymbolDefinitions.WixFirewallException, null, null) + { + } + + public WixFirewallExceptionSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(FirewallSymbolDefinitions.WixFirewallException, sourceLineNumber, id) + { + } + + public IntermediateField this[WixFirewallExceptionSymbolFields index] => this.Fields[(int)index]; + + public string Name + { + get => this.Fields[(int)WixFirewallExceptionSymbolFields.Name].AsString(); + set => this.Set((int)WixFirewallExceptionSymbolFields.Name, value); + } + + public string RemoteAddresses + { + get => this.Fields[(int)WixFirewallExceptionSymbolFields.RemoteAddresses].AsString(); + set => this.Set((int)WixFirewallExceptionSymbolFields.RemoteAddresses, value); + } + + public string Port + { + get => this.Fields[(int)WixFirewallExceptionSymbolFields.Port].AsString(); + set => this.Set((int)WixFirewallExceptionSymbolFields.Port, value); + } + + public int? Protocol + { + get => this.Fields[(int)WixFirewallExceptionSymbolFields.Protocol].AsNullableNumber(); + set => this.Set((int)WixFirewallExceptionSymbolFields.Protocol, value); + } + + public string Program + { + get => this.Fields[(int)WixFirewallExceptionSymbolFields.Program].AsString(); + set => this.Set((int)WixFirewallExceptionSymbolFields.Program, value); + } + + public int Attributes + { + get => this.Fields[(int)WixFirewallExceptionSymbolFields.Attributes].AsNumber(); + set => this.Set((int)WixFirewallExceptionSymbolFields.Attributes, value); + } + + public int Profile + { + get => this.Fields[(int)WixFirewallExceptionSymbolFields.Profile].AsNumber(); + set => this.Set((int)WixFirewallExceptionSymbolFields.Profile, value); + } + + public string ComponentRef + { + get => this.Fields[(int)WixFirewallExceptionSymbolFields.ComponentRef].AsString(); + set => this.Set((int)WixFirewallExceptionSymbolFields.ComponentRef, value); + } + + public string Description + { + get => this.Fields[(int)WixFirewallExceptionSymbolFields.Description].AsString(); + set => this.Set((int)WixFirewallExceptionSymbolFields.Description, value); + } + + public int Direction + { + get => this.Fields[(int)WixFirewallExceptionSymbolFields.Direction].AsNumber(); + set => this.Set((int)WixFirewallExceptionSymbolFields.Direction, value); + } + } +} \ No newline at end of file diff --git a/src/ext/Firewall/wixext/WixToolset.Firewall.wixext.csproj b/src/ext/Firewall/wixext/WixToolset.Firewall.wixext.csproj new file mode 100644 index 00000000..6704dad2 --- /dev/null +++ b/src/ext/Firewall/wixext/WixToolset.Firewall.wixext.csproj @@ -0,0 +1,31 @@ + + + + + + netstandard2.0 + WixToolset.Firewall + WiX Toolset Firewallity Extension + WiX Toolset Firewall Extension + true + build + + + + + + + + + + + + + + + + + + + + diff --git a/src/ext/Firewall/wixext/WixToolset.Firewall.wixext.targets b/src/ext/Firewall/wixext/WixToolset.Firewall.wixext.targets new file mode 100644 index 00000000..c717450f --- /dev/null +++ b/src/ext/Firewall/wixext/WixToolset.Firewall.wixext.targets @@ -0,0 +1,11 @@ + + + + + + $(MSBuildThisFileDirectory)..\tools\WixToolset.Firewall.wixext.dll + + + + + diff --git a/src/ext/Firewall/wixlib/FirewallExtension.wxs b/src/ext/Firewall/wixlib/FirewallExtension.wxs new file mode 100644 index 00000000..56ad693e --- /dev/null +++ b/src/ext/Firewall/wixlib/FirewallExtension.wxs @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/ext/Firewall/wixlib/FirewallExtension_Platform.wxi b/src/ext/Firewall/wixlib/FirewallExtension_Platform.wxi new file mode 100644 index 00000000..3861bd5d --- /dev/null +++ b/src/ext/Firewall/wixlib/FirewallExtension_Platform.wxi @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ext/Firewall/wixlib/FirewallExtension_arm64.wxs b/src/ext/Firewall/wixlib/FirewallExtension_arm64.wxs new file mode 100644 index 00000000..63cdd1e8 --- /dev/null +++ b/src/ext/Firewall/wixlib/FirewallExtension_arm64.wxs @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/ext/Firewall/wixlib/FirewallExtension_x64.wxs b/src/ext/Firewall/wixlib/FirewallExtension_x64.wxs new file mode 100644 index 00000000..842aedf1 --- /dev/null +++ b/src/ext/Firewall/wixlib/FirewallExtension_x64.wxs @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/ext/Firewall/wixlib/FirewallExtension_x86.wxs b/src/ext/Firewall/wixlib/FirewallExtension_x86.wxs new file mode 100644 index 00000000..5867f791 --- /dev/null +++ b/src/ext/Firewall/wixlib/FirewallExtension_x86.wxs @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/ext/Firewall/wixlib/caDecor.wxi b/src/ext/Firewall/wixlib/caDecor.wxi new file mode 100644 index 00000000..b1711518 --- /dev/null +++ b/src/ext/Firewall/wixlib/caDecor.wxi @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ext/Firewall/wixlib/caerr.wxi b/src/ext/Firewall/wixlib/caerr.wxi new file mode 100644 index 00000000..ff7ec121 --- /dev/null +++ b/src/ext/Firewall/wixlib/caerr.wxi @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/ext/Firewall/wixlib/en-us.wxl b/src/ext/Firewall/wixlib/en-us.wxl new file mode 100644 index 00000000..ab9ce8a0 --- /dev/null +++ b/src/ext/Firewall/wixlib/en-us.wxl @@ -0,0 +1,13 @@ + + + + + Cannot connect to Windows Firewall. ([2] [3] [4] [5]) + + Configuring Windows Firewall + Configuring Windows Firewall + Rolling back Windows Firewall configuration + Installing Windows Firewall configuration + Rolling back Windows Firewall configuration + Uninstalling Windows Firewall configuration + diff --git a/src/ext/Firewall/wixlib/es-es.wxl b/src/ext/Firewall/wixlib/es-es.wxl new file mode 100644 index 00000000..0631b3a3 --- /dev/null +++ b/src/ext/Firewall/wixlib/es-es.wxl @@ -0,0 +1,12 @@ + + + + No se puede conectar al Firewall de Windows. ([2] [3] [4] [5]) + + Configurando el Firewall de Windows + Configurando el Firewall de Windows + Regresando la configuración del Firewall de Windows + Instalando la configuración del Firewall de Windows + Regresando la configuración del Firewall de Windows + Desinstalando la configuración del Firewall de Windows + diff --git a/src/ext/Firewall/wixlib/firewall.v3.ncrunchproject b/src/ext/Firewall/wixlib/firewall.v3.ncrunchproject new file mode 100644 index 00000000..319cd523 --- /dev/null +++ b/src/ext/Firewall/wixlib/firewall.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/src/ext/Firewall/wixlib/firewall.wixproj b/src/ext/Firewall/wixlib/firewall.wixproj new file mode 100644 index 00000000..242fa56e --- /dev/null +++ b/src/ext/Firewall/wixlib/firewall.wixproj @@ -0,0 +1,26 @@ + + + + + Library + true + en-us + + + + + + + + + + + + + + + + + + + diff --git a/src/ext/Firewall/wixlib/ja-jp.wxl b/src/ext/Firewall/wixlib/ja-jp.wxl new file mode 100644 index 00000000..a4036c7e --- /dev/null +++ b/src/ext/Firewall/wixlib/ja-jp.wxl @@ -0,0 +1,13 @@ + + + + + Windows ファイアウォールへ接続できません。 ([2] [3] [4] [5]) + + Windows ファイアウォールを構成しています + Windows ファイアウォールを構成しています + Windows ファイアウォール構成をロールバックしています + Windows ファイアウォール構成をインストールしています + Windows ファイアウォール構成をロールバックしています + Windows ファイアウォール構成をアンインストールしています + diff --git a/src/ext/Firewall/wixlib/pl-pl.wxl b/src/ext/Firewall/wixlib/pl-pl.wxl new file mode 100644 index 00000000..1b37460e --- /dev/null +++ b/src/ext/Firewall/wixlib/pl-pl.wxl @@ -0,0 +1,13 @@ + + + + + Nie udało się połączyć z Zaporą systemu Windows. ([2] [3] [4] [5]) + + Dodawanie wyjątków do Zapory systemu Windows + Usuwanie wyjątków z Zapory systemu Windows + Cofanie zmian konfiguracji Zapory systemu Windows + Konfigurowywanie Zapory systemu Windows + Cofanie zmian konfiguracji Zapory systemu Windows + Konfigurowywanie Zapory systemu Windows + diff --git a/src/ext/global.json b/src/ext/global.json new file mode 100644 index 00000000..23dd3fa6 --- /dev/null +++ b/src/ext/global.json @@ -0,0 +1,5 @@ +{ + "msbuild-sdks": { + "WixToolset.Sdk": "4.0.0-build-0211" + } +} diff --git a/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs b/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs deleted file mode 100644 index ffdc1326..00000000 --- a/src/test/WixToolsetTest.Firewall/FirewallExtensionFixture.cs +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolsetTest.Firewall -{ - using System.Linq; - using WixBuildTools.TestSupport; - using WixToolset.Core.TestPackage; - using WixToolset.Firewall; - using Xunit; - - public class FirewallExtensionFixture - { - [Fact] - public void CanBuildUsingFirewall() - { - var folder = TestData.Get(@"TestData\UsingFirewall"); - var build = new Builder(folder, typeof(FirewallExtensionFactory), new[] { folder }); - - var results = build.BuildAndQuery(Build, "Wix4FirewallException", "CustomAction"); - Assert.Equal(new[] - { - "CustomAction:Wix4ExecFirewallExceptionsInstall_X86\t3073\tWix4FWCA_X86\tExecFirewallExceptions\t", - "CustomAction:Wix4ExecFirewallExceptionsUninstall_X86\t3073\tWix4FWCA_X86\tExecFirewallExceptions\t", - "CustomAction:Wix4RollbackFirewallExceptionsInstall_X86\t3329\tWix4FWCA_X86\tExecFirewallExceptions\t", - "CustomAction:Wix4RollbackFirewallExceptionsUninstall_X86\t3329\tWix4FWCA_X86\tExecFirewallExceptions\t", - "CustomAction:Wix4SchedFirewallExceptionsInstall_X86\t1\tWix4FWCA_X86\tSchedFirewallExceptionsInstall\t", - "CustomAction:Wix4SchedFirewallExceptionsUninstall_X86\t1\tWix4FWCA_X86\tSchedFirewallExceptionsUninstall\t", - "Wix4FirewallException:ExampleFirewall\texample\t*\t42\t6\t\t0\t2147483647\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tAn example firewall\t1", - }, results); - } - - [Fact] - public void CanBuildUsingFirewallARM64() - { - var folder = TestData.Get(@"TestData\UsingFirewall"); - var build = new Builder(folder, typeof(FirewallExtensionFactory), new[] { folder }); - - var results = build.BuildAndQuery(BuildARM64, "Wix4FirewallException", "CustomAction"); - Assert.Equal(new[] - { - "CustomAction:Wix4ExecFirewallExceptionsInstall_A64\t3073\tWix4FWCA_A64\tExecFirewallExceptions\t", - "CustomAction:Wix4ExecFirewallExceptionsUninstall_A64\t3073\tWix4FWCA_A64\tExecFirewallExceptions\t", - "CustomAction:Wix4RollbackFirewallExceptionsInstall_A64\t3329\tWix4FWCA_A64\tExecFirewallExceptions\t", - "CustomAction:Wix4RollbackFirewallExceptionsUninstall_A64\t3329\tWix4FWCA_A64\tExecFirewallExceptions\t", - "CustomAction:Wix4SchedFirewallExceptionsInstall_A64\t1\tWix4FWCA_A64\tSchedFirewallExceptionsInstall\t", - "CustomAction:Wix4SchedFirewallExceptionsUninstall_A64\t1\tWix4FWCA_A64\tSchedFirewallExceptionsUninstall\t", - "Wix4FirewallException:ExampleFirewall\texample\t*\t42\t6\t\t0\t2147483647\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tAn example firewall\t1", - }, results); - } - - [Fact] - public void CanBuildUsingOutboundFirewall() - { - var folder = TestData.Get(@"TestData\UsingOutboundFirewall"); - var build = new Builder(folder, typeof(FirewallExtensionFactory), new[] { folder }); - - var results = build.BuildAndQuery(Build, "Wix4FirewallException"); - Assert.Equal(new[] - { - "Wix4FirewallException:fex.5c8b_4C0THcQTvn8tpwhoRrgck\texample\t*\t42\t6\t\t0\t2147483647\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tAn example outbound firewall\t2", - }, results); - } - - private static void Build(string[] args) - { - var result = WixRunner.Execute(args); - result.AssertSuccess(); - } - - private static void BuildARM64(string[] args) - { - var newArgs = args.ToList(); - newArgs.Add("-platform"); - newArgs.Add("arm64"); - - var result = WixRunner.Execute(newArgs.ToArray()); - result.AssertSuccess(); - } - } -} diff --git a/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.en-us.wxl b/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.en-us.wxl deleted file mode 100644 index 38c12ac1..00000000 --- a/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.en-us.wxl +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - A newer version of [ProductName] is already installed. - MsiPackage - - diff --git a/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.wxs b/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.wxs deleted file mode 100644 index 411893bc..00000000 --- a/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/Package.wxs +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs b/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs deleted file mode 100644 index 53e75427..00000000 --- a/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - diff --git a/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/example.txt b/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/example.txt deleted file mode 100644 index 1b4ffe8a..00000000 --- a/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/example.txt +++ /dev/null @@ -1 +0,0 @@ -This is example.txt. \ No newline at end of file diff --git a/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.en-us.wxl b/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.en-us.wxl deleted file mode 100644 index 38c12ac1..00000000 --- a/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.en-us.wxl +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - A newer version of [ProductName] is already installed. - MsiPackage - - diff --git a/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.wxs b/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.wxs deleted file mode 100644 index 411893bc..00000000 --- a/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/Package.wxs +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/PackageComponents.wxs b/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/PackageComponents.wxs deleted file mode 100644 index 8084706e..00000000 --- a/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/PackageComponents.wxs +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - diff --git a/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/example.txt b/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/example.txt deleted file mode 100644 index 1b4ffe8a..00000000 --- a/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/example.txt +++ /dev/null @@ -1 +0,0 @@ -This is example.txt. \ No newline at end of file diff --git a/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj b/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj deleted file mode 100644 index d04368c1..00000000 --- a/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.csproj +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - netcoreapp3.1 - false - - - - NU1701 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.v3.ncrunchproject b/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.v3.ncrunchproject deleted file mode 100644 index 7b5b2139..00000000 --- a/src/test/WixToolsetTest.Firewall/WixToolsetTest.Firewall.v3.ncrunchproject +++ /dev/null @@ -1,5 +0,0 @@ - - - True - - \ No newline at end of file diff --git a/src/version.json b/src/version.json new file mode 100644 index 00000000..5f857771 --- /dev/null +++ b/src/version.json @@ -0,0 +1,11 @@ +{ + "version": "4.0", + "publicReleaseRefSpec": [ + "^refs/heads/master$" + ], + "cloudBuild": { + "buildNumber": { + "enabled": true + } + } +} diff --git a/src/wix.snk b/src/wix.snk deleted file mode 100644 index 3908a66a..00000000 Binary files a/src/wix.snk and /dev/null differ diff --git a/src/wixext/FirewallCompiler.cs b/src/wixext/FirewallCompiler.cs deleted file mode 100644 index cbe82d37..00000000 --- a/src/wixext/FirewallCompiler.cs +++ /dev/null @@ -1,354 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Firewall -{ - using System; - using System.Collections.Generic; - using System.Xml.Linq; - using WixToolset.Data; - using WixToolset.Extensibility; - using WixToolset.Extensibility.Data; - using WixToolset.Firewall.Symbols; - - /// - /// The compiler for the WiX Toolset Firewall Extension. - /// - public sealed class FirewallCompiler : BaseCompilerExtension - { - public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/firewall"; - - /// - /// Processes an element for the Compiler. - /// - /// Source line number for the parent element. - /// Parent element of element to process. - /// Element to process. - /// Extra information about the context in which this element is being parsed. - public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context) - { - switch (parentElement.Name.LocalName) - { - case "File": - var fileId = context["FileId"]; - var fileComponentId = context["ComponentId"]; - - switch (element.Name.LocalName) - { - case "FirewallException": - this.ParseFirewallExceptionElement(intermediate, section, element, fileComponentId, fileId); - break; - default: - this.ParseHelper.UnexpectedElement(parentElement, element); - break; - } - break; - case "Component": - var componentId = context["ComponentId"]; - - switch (element.Name.LocalName) - { - case "FirewallException": - this.ParseFirewallExceptionElement(intermediate, section, element, componentId, null); - break; - default: - this.ParseHelper.UnexpectedElement(parentElement, element); - break; - } - break; - default: - this.ParseHelper.UnexpectedElement(parentElement, element); - break; - } - } - - /// - /// Parses a FirewallException element. - /// - /// The element to parse. - /// Identifier of the component that owns this firewall exception. - /// The file identifier of the parent element (null if nested under Component). - private void ParseFirewallExceptionElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId, string fileId) - { - var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); - Identifier id = null; - string name = null; - int attributes = 0; - string file = null; - string program = null; - string port = null; - int? protocol = null; - int? profile = null; - string scope = null; - string remoteAddresses = null; - string description = null; - int? direction = null; - - foreach (var attrib in element.Attributes()) - { - if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) - { - switch (attrib.Name.LocalName) - { - case "Id": - id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Name": - name = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "File": - if (null != fileId) - { - this.Messaging.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, element.Name.LocalName, "File", "File")); - } - else - { - file = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - } - break; - case "IgnoreFailure": - if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= 0x1; // feaIgnoreFailures - } - break; - case "Program": - if (null != fileId) - { - this.Messaging.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, element.Name.LocalName, "Program", "File")); - } - else - { - program = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - } - break; - case "Port": - port = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Protocol": - var protocolValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - switch (protocolValue) - { - case "tcp": - protocol = FirewallConstants.NET_FW_IP_PROTOCOL_TCP; - break; - case "udp": - protocol = FirewallConstants.NET_FW_IP_PROTOCOL_UDP; - break; - default: - this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, element.Name.LocalName, "Protocol", protocolValue, "tcp", "udp")); - break; - } - break; - case "Scope": - scope = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - switch (scope) - { - case "any": - remoteAddresses = "*"; - break; - case "localSubnet": - remoteAddresses = "LocalSubnet"; - break; - default: - this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, element.Name.LocalName, "Scope", scope, "any", "localSubnet")); - break; - } - break; - case "Profile": - var profileValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - switch (profileValue) - { - case "domain": - profile = FirewallConstants.NET_FW_PROFILE2_DOMAIN; - break; - case "private": - profile = FirewallConstants.NET_FW_PROFILE2_PRIVATE; - break; - case "public": - profile = FirewallConstants.NET_FW_PROFILE2_PUBLIC; - break; - case "all": - profile = FirewallConstants.NET_FW_PROFILE2_ALL; - break; - default: - this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, element.Name.LocalName, "Profile", profileValue, "domain", "private", "public", "all")); - break; - } - break; - case "Description": - description = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Outbound": - direction = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib) == YesNoType.Yes - ? FirewallConstants.NET_FW_RULE_DIR_OUT - : FirewallConstants.NET_FW_RULE_DIR_IN; - break; - default: - this.ParseHelper.UnexpectedAttribute(element, attrib); - break; - } - } - else - { - this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); - } - } - - // parse RemoteAddress children - foreach (var child in element.Elements()) - { - if (this.Namespace == child.Name.Namespace) - { - switch (child.Name.LocalName) - { - case "RemoteAddress": - if (null != scope) - { - this.Messaging.Write(FirewallErrors.IllegalRemoteAddressWithScopeAttribute(sourceLineNumbers)); - } - else - { - this.ParseRemoteAddressElement(intermediate, section, child, ref remoteAddresses); - } - break; - default: - this.ParseHelper.UnexpectedElement(element, child); - break; - } - } - else - { - this.ParseHelper.ParseExtensionElement(this.Context.Extensions, intermediate, section, element, child); - } - } - - if (null == id) - { - id = this.ParseHelper.CreateIdentifier("fex", name, remoteAddresses, componentId); - } - - // Name is required - if (null == name) - { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Name")); - } - - // Scope or child RemoteAddress(es) are required - if (null == remoteAddresses) - { - this.Messaging.Write(ErrorMessages.ExpectedAttributeOrElement(sourceLineNumbers, element.Name.LocalName, "Scope", "RemoteAddress")); - } - - // can't have both Program and File - if (null != program && null != file) - { - this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, element.Name.LocalName, "File", "Program")); - } - - // must be nested under File, have File or Program attributes, or have Port attribute - if (String.IsNullOrEmpty(fileId) && String.IsNullOrEmpty(file) && String.IsNullOrEmpty(program) && String.IsNullOrEmpty(port)) - { - this.Messaging.Write(FirewallErrors.NoExceptionSpecified(sourceLineNumbers)); - } - - if (!this.Messaging.EncounteredError) - { - // at this point, File attribute and File parent element are treated the same - if (null != file) - { - fileId = file; - } - - var symbol = section.AddSymbol(new WixFirewallExceptionSymbol(sourceLineNumbers, id) - { - Name = name, - RemoteAddresses = remoteAddresses, - Profile = profile ?? FirewallConstants.NET_FW_PROFILE2_ALL, - ComponentRef = componentId, - Description = description, - Direction = direction ?? FirewallConstants.NET_FW_RULE_DIR_IN, - }); - - if (!String.IsNullOrEmpty(port)) - { - symbol.Port = port; - - if (!protocol.HasValue) - { - // default protocol is "TCP" - protocol = FirewallConstants.NET_FW_IP_PROTOCOL_TCP; - } - } - - if (protocol.HasValue) - { - symbol.Protocol = protocol.Value; - } - - if (!String.IsNullOrEmpty(fileId)) - { - symbol.Program = $"[#{fileId}]"; - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.File, fileId); - } - else if (!String.IsNullOrEmpty(program)) - { - symbol.Program = program; - } - - if (CompilerConstants.IntegerNotSet != attributes) - { - symbol.Attributes = attributes; - } - - this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4SchedFirewallExceptionsInstall", this.Context.Platform, CustomActionPlatforms.ARM64 | CustomActionPlatforms.X64 | CustomActionPlatforms.X86); - this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4SchedFirewallExceptionsUninstall", this.Context.Platform, CustomActionPlatforms.ARM64 | CustomActionPlatforms.X64 | CustomActionPlatforms.X86); - } - } - - /// - /// Parses a RemoteAddress element - /// - /// The element to parse. - private void ParseRemoteAddressElement(Intermediate intermediate, IntermediateSection section, XElement element, ref string remoteAddresses) - { - var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); - string address = null; - - // no attributes - foreach (var attrib in element.Attributes()) - { - if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) - { - switch (attrib.Name.LocalName) - { - case "Value": - address = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - } - } - else - { - this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); - } - } - - this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); - - if (String.IsNullOrEmpty(address)) - { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Value")); - } - else - { - if (String.IsNullOrEmpty(remoteAddresses)) - { - remoteAddresses = address; - } - else - { - remoteAddresses = String.Concat(remoteAddresses, ",", address); - } - } - } - } -} diff --git a/src/wixext/FirewallConstants.cs b/src/wixext/FirewallConstants.cs deleted file mode 100644 index 7bb12ba4..00000000 --- a/src/wixext/FirewallConstants.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Firewall -{ - using System; - using System.Collections.Generic; - using System.Text; - - static class FirewallConstants - { - // from icftypes.h - public const int NET_FW_RULE_DIR_IN = 1; - public const int NET_FW_RULE_DIR_OUT = 2; - public const int NET_FW_IP_PROTOCOL_TCP = 6; - public const int NET_FW_IP_PROTOCOL_UDP = 17; - - // from icftypes.h - public const int NET_FW_PROFILE2_DOMAIN = 0x0001; - public const int NET_FW_PROFILE2_PRIVATE = 0x0002; - public const int NET_FW_PROFILE2_PUBLIC = 0x0004; - public const int NET_FW_PROFILE2_ALL = 0x7FFFFFFF; - } -} diff --git a/src/wixext/FirewallDecompiler.cs b/src/wixext/FirewallDecompiler.cs deleted file mode 100644 index c9478de1..00000000 --- a/src/wixext/FirewallDecompiler.cs +++ /dev/null @@ -1,182 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Firewall -{ -#if TODO_CONSIDER_DECOMPILER - using System; - using System.Collections; - using System.Diagnostics; - using System.Globalization; - using WixToolset.Data; - using WixToolset.Extensibility; - using Firewall = WixToolset.Extensions.Serialize.Firewall; - using Wix = WixToolset.Data.Serialize; - - /// - /// The decompiler for the WiX Toolset Firewall Extension. - /// - public sealed class FirewallDecompiler : DecompilerExtension - { - /// - /// Creates a decompiler for Firewall Extension. - /// - public FirewallDecompiler() - { - this.TableDefinitions = FirewallExtensionData.GetExtensionTableDefinitions(); - } - - /// - /// Get the extensions library to be removed. - /// - /// Table definitions for library. - /// Library to remove from decompiled output. - public override Library GetLibraryToRemove(TableDefinitionCollection tableDefinitions) - { - return FirewallExtensionData.GetExtensionLibrary(tableDefinitions); - } - - /// - /// Decompiles an extension table. - /// - /// The table to decompile. - public override void DecompileTable(Table table) - { - switch (table.Name) - { - case "WixFirewallException": - this.DecompileWixFirewallExceptionTable(table); - break; - default: - base.DecompileTable(table); - break; - } - } - - /// - /// Decompile the WixFirewallException table. - /// - /// The table to decompile. - private void DecompileWixFirewallExceptionTable(Table table) - { - foreach (Row row in table.Rows) - { - Firewall.FirewallException fire = new Firewall.FirewallException(); - fire.Id = (string)row[0]; - fire.Name = (string)row[1]; - - string[] addresses = ((string)row[2]).Split(','); - if (1 == addresses.Length) - { - // special-case the Scope attribute values - if ("*" == addresses[0]) - { - fire.Scope = Firewall.FirewallException.ScopeType.any; - } - else if ("LocalSubnet" == addresses[0]) - { - fire.Scope = Firewall.FirewallException.ScopeType.localSubnet; - } - else - { - FirewallDecompiler.AddRemoteAddress(fire, addresses[0]); - } - } - else - { - foreach (string address in addresses) - { - FirewallDecompiler.AddRemoteAddress(fire, address); - } - } - - if (!row.IsColumnEmpty(3)) - { - fire.Port = (string)row[3]; - } - - if (!row.IsColumnEmpty(4)) - { - switch (Convert.ToInt32(row[4])) - { - case FirewallConstants.NET_FW_IP_PROTOCOL_TCP: - fire.Protocol = Firewall.FirewallException.ProtocolType.tcp; - break; - case FirewallConstants.NET_FW_IP_PROTOCOL_UDP: - fire.Protocol = Firewall.FirewallException.ProtocolType.udp; - break; - } - } - - if (!row.IsColumnEmpty(5)) - { - fire.Program = (string)row[5]; - } - - if (!row.IsColumnEmpty(6)) - { - int attr = Convert.ToInt32(row[6]); - if (0x1 == (attr & 0x1)) // feaIgnoreFailures - { - fire.IgnoreFailure = Firewall.YesNoType.yes; - } - } - - if (!row.IsColumnEmpty(7)) - { - switch (Convert.ToInt32(row[7])) - { - case FirewallConstants.NET_FW_PROFILE2_DOMAIN: - fire.Profile = Firewall.FirewallException.ProfileType.domain; - break; - case FirewallConstants.NET_FW_PROFILE2_PRIVATE: - fire.Profile = Firewall.FirewallException.ProfileType.@private; - break; - case FirewallConstants.NET_FW_PROFILE2_PUBLIC: - fire.Profile = Firewall.FirewallException.ProfileType.@public; - break; - case FirewallConstants.NET_FW_PROFILE2_ALL: - fire.Profile = Firewall.FirewallException.ProfileType.all; - break; - } - } - - // Description column is new in v3.6 - if (9 < row.Fields.Length && !row.IsColumnEmpty(9)) - { - fire.Description = (string)row[9]; - } - - if (!row.IsColumnEmpty(10)) - { - switch (Convert.ToInt32(row[10])) - { - case FirewallConstants.NET_FW_RULE_DIR_IN: - fire.Direction = Firewall.FirewallException.DirectionType.@in; - break; - case FirewallConstants.NET_FW_RULE_DIR_OUT: - fire.Direction = Firewall.FirewallException.DirectionType.@out; - break; - } - } - - Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[8]); - if (null != component) - { - component.AddChild(fire); - } - else - { - this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[6], "Component")); - } - } - } - - private static void AddRemoteAddress(Firewall.FirewallException fire, string address) - { - Firewall.RemoteAddress remote = new Firewall.RemoteAddress(); - remote.Content = address; - fire.AddChild(remote); - } - } -#endif -} diff --git a/src/wixext/FirewallErrors.cs b/src/wixext/FirewallErrors.cs deleted file mode 100644 index b2dac782..00000000 --- a/src/wixext/FirewallErrors.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Firewall -{ - using System.Resources; - using WixToolset.Data; - - public static class FirewallErrors - { - public static Message IllegalRemoteAddressWithScopeAttribute(SourceLineNumber sourceLineNumbers) - { - return Message(sourceLineNumbers, Ids.IllegalRemoteAddressWithScopeAttribute, "The RemoteAddress element cannot be specified because its parent FirewallException already specified the Scope attribute. To use RemoteAddress elements, omit the Scope attribute."); - } - - public static Message NoExceptionSpecified(SourceLineNumber sourceLineNumbers) - { - return Message(sourceLineNumbers, Ids.NoExceptionSpecified, "The FirewallException element doesn't identify the target of the firewall exception. To create an application exception, nest the FirewallException element under a File element or provide a value for the File or Program attributes. To create a port exception, provide a value for the Port attribute."); - } - - private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) - { - return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args); - } - - private static Message Message(SourceLineNumber sourceLineNumber, Ids id, ResourceManager resourceManager, string resourceName, params object[] args) - { - return new Message(sourceLineNumber, MessageLevel.Error, (int)id, resourceManager, resourceName, args); - } - - public enum Ids - { - IllegalRemoteAddressWithScopeAttribute = 6401, - NoExceptionSpecified = 6403, - } - } -} diff --git a/src/wixext/FirewallExtensionData.cs b/src/wixext/FirewallExtensionData.cs deleted file mode 100644 index 7481d993..00000000 --- a/src/wixext/FirewallExtensionData.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Firewall -{ - using WixToolset.Data; - using WixToolset.Extensibility; - - public sealed class FirewallExtensionData : BaseExtensionData - { - public override string DefaultCulture => "en-US"; - - public override bool TryGetSymbolDefinitionByName(string name, out IntermediateSymbolDefinition symbolDefinition) - { - symbolDefinition = FirewallSymbolDefinitions.ByName(name); - return symbolDefinition != null; - } - - public override Intermediate GetLibrary(ISymbolDefinitionCreator symbolDefinitions) - { - return Intermediate.Load(typeof(FirewallExtensionData).Assembly, "WixToolset.Firewall.firewall.wixlib", symbolDefinitions); - } - } -} diff --git a/src/wixext/FirewallExtensionFactory.cs b/src/wixext/FirewallExtensionFactory.cs deleted file mode 100644 index 279b322a..00000000 --- a/src/wixext/FirewallExtensionFactory.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Firewall -{ - using System; - using System.Collections.Generic; - using WixToolset.Extensibility; - - public class FirewallExtensionFactory : BaseExtensionFactory - { - protected override IReadOnlyCollection ExtensionTypes => new[] - { - typeof(FirewallCompiler), - typeof(FirewallExtensionData), - typeof(FirewallWindowsInstallerBackendBinderExtension), - }; - } -} diff --git a/src/wixext/FirewallTableDefinitions.cs b/src/wixext/FirewallTableDefinitions.cs deleted file mode 100644 index 04918f5f..00000000 --- a/src/wixext/FirewallTableDefinitions.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Firewall -{ - using WixToolset.Data.WindowsInstaller; - - public static class FirewallTableDefinitions - { - public static readonly TableDefinition WixFirewallException = new TableDefinition( - "Wix4FirewallException", - FirewallSymbolDefinitions.WixFirewallException, - new[] - { - new ColumnDefinition("Wix4FirewallException", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "The primary key, a non-localized token.", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("Name", ColumnType.Localized, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Localizable display name.", modularizeType: ColumnModularizeType.Property), - new ColumnDefinition("RemoteAddresses", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Remote address to accept incoming connections from.", modularizeType: ColumnModularizeType.Property), - new ColumnDefinition("Port", ColumnType.String, 0, primaryKey: false, nullable: true, ColumnCategory.Formatted, minValue: 1, description: "Port number.", modularizeType: ColumnModularizeType.Property), - new ColumnDefinition("Protocol", ColumnType.Number, 1, primaryKey: false, nullable: true, ColumnCategory.Integer, minValue: 6, maxValue: 17, description: "Protocol (6=TCP; 17=UDP)."), - new ColumnDefinition("Program", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Exception for a program (formatted path name).", modularizeType: ColumnModularizeType.Property), - new ColumnDefinition("Attributes", ColumnType.Number, 4, primaryKey: false, nullable: true, ColumnCategory.Unknown, description: "Vital=1"), - new ColumnDefinition("Profile", ColumnType.Number, 4, primaryKey: false, nullable: false, ColumnCategory.Integer, minValue: 1, maxValue: 2147483647, description: "Profile (1=domain; 2=private; 4=public; 2147483647=all)."), - new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key into the Component table referencing component that controls the firewall configuration.", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("Description", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Description displayed in Windows Firewall manager for this firewall rule."), - new ColumnDefinition("Direction", ColumnType.Number, 1, primaryKey: false, nullable: true, ColumnCategory.Integer, minValue: 1, maxValue: 2, description: "Direction (1=in; 2=out)"), - }, - symbolIdIsPrimaryKey: true - ); - - public static readonly TableDefinition[] All = new[] - { - WixFirewallException, - }; - } -} diff --git a/src/wixext/FirewallWindowsInstallerBackendExtension.cs b/src/wixext/FirewallWindowsInstallerBackendExtension.cs deleted file mode 100644 index b5b97d85..00000000 --- a/src/wixext/FirewallWindowsInstallerBackendExtension.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Firewall -{ - using System.Collections.Generic; - using WixToolset.Data.WindowsInstaller; - using WixToolset.Extensibility; - - public class FirewallWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension - { - public override IReadOnlyCollection TableDefinitions => FirewallTableDefinitions.All; - } -} diff --git a/src/wixext/Symbols/FirewallSymbolDefinitions.cs b/src/wixext/Symbols/FirewallSymbolDefinitions.cs deleted file mode 100644 index 887893c7..00000000 --- a/src/wixext/Symbols/FirewallSymbolDefinitions.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Firewall -{ - using System; - using WixToolset.Data; - - public enum FirewallSymbolDefinitionType - { - WixFirewallException, - } - - public static partial class FirewallSymbolDefinitions - { - public static readonly Version Version = new Version("4.0.0"); - - public static IntermediateSymbolDefinition ByName(string name) - { - if (!Enum.TryParse(name, out FirewallSymbolDefinitionType type)) - { - return null; - } - - return ByType(type); - } - - public static IntermediateSymbolDefinition ByType(FirewallSymbolDefinitionType type) - { - switch (type) - { - case FirewallSymbolDefinitionType.WixFirewallException: - return FirewallSymbolDefinitions.WixFirewallException; - - default: - throw new ArgumentOutOfRangeException(nameof(type)); - } - } - } -} diff --git a/src/wixext/Symbols/WixFirewallExceptionSymbol.cs b/src/wixext/Symbols/WixFirewallExceptionSymbol.cs deleted file mode 100644 index 620de969..00000000 --- a/src/wixext/Symbols/WixFirewallExceptionSymbol.cs +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Firewall -{ - using WixToolset.Data; - using WixToolset.Firewall.Symbols; - - public static partial class FirewallSymbolDefinitions - { - public static readonly IntermediateSymbolDefinition WixFirewallException = new IntermediateSymbolDefinition( - FirewallSymbolDefinitionType.WixFirewallException.ToString(), - new[] - { - new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Name), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.RemoteAddresses), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Port), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Protocol), IntermediateFieldType.Number), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Program), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Attributes), IntermediateFieldType.Number), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Profile), IntermediateFieldType.Number), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.ComponentRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Description), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixFirewallExceptionSymbolFields.Direction), IntermediateFieldType.Number), - }, - typeof(WixFirewallExceptionSymbol)); - } -} - -namespace WixToolset.Firewall.Symbols -{ - using WixToolset.Data; - - public enum WixFirewallExceptionSymbolFields - { - Name, - RemoteAddresses, - Port, - Protocol, - Program, - Attributes, - Profile, - ComponentRef, - Description, - Direction, - } - - public class WixFirewallExceptionSymbol : IntermediateSymbol - { - public WixFirewallExceptionSymbol() : base(FirewallSymbolDefinitions.WixFirewallException, null, null) - { - } - - public WixFirewallExceptionSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(FirewallSymbolDefinitions.WixFirewallException, sourceLineNumber, id) - { - } - - public IntermediateField this[WixFirewallExceptionSymbolFields index] => this.Fields[(int)index]; - - public string Name - { - get => this.Fields[(int)WixFirewallExceptionSymbolFields.Name].AsString(); - set => this.Set((int)WixFirewallExceptionSymbolFields.Name, value); - } - - public string RemoteAddresses - { - get => this.Fields[(int)WixFirewallExceptionSymbolFields.RemoteAddresses].AsString(); - set => this.Set((int)WixFirewallExceptionSymbolFields.RemoteAddresses, value); - } - - public string Port - { - get => this.Fields[(int)WixFirewallExceptionSymbolFields.Port].AsString(); - set => this.Set((int)WixFirewallExceptionSymbolFields.Port, value); - } - - public int? Protocol - { - get => this.Fields[(int)WixFirewallExceptionSymbolFields.Protocol].AsNullableNumber(); - set => this.Set((int)WixFirewallExceptionSymbolFields.Protocol, value); - } - - public string Program - { - get => this.Fields[(int)WixFirewallExceptionSymbolFields.Program].AsString(); - set => this.Set((int)WixFirewallExceptionSymbolFields.Program, value); - } - - public int Attributes - { - get => this.Fields[(int)WixFirewallExceptionSymbolFields.Attributes].AsNumber(); - set => this.Set((int)WixFirewallExceptionSymbolFields.Attributes, value); - } - - public int Profile - { - get => this.Fields[(int)WixFirewallExceptionSymbolFields.Profile].AsNumber(); - set => this.Set((int)WixFirewallExceptionSymbolFields.Profile, value); - } - - public string ComponentRef - { - get => this.Fields[(int)WixFirewallExceptionSymbolFields.ComponentRef].AsString(); - set => this.Set((int)WixFirewallExceptionSymbolFields.ComponentRef, value); - } - - public string Description - { - get => this.Fields[(int)WixFirewallExceptionSymbolFields.Description].AsString(); - set => this.Set((int)WixFirewallExceptionSymbolFields.Description, value); - } - - public int Direction - { - get => this.Fields[(int)WixFirewallExceptionSymbolFields.Direction].AsNumber(); - set => this.Set((int)WixFirewallExceptionSymbolFields.Direction, value); - } - } -} \ No newline at end of file diff --git a/src/wixext/WixToolset.Firewall.wixext.csproj b/src/wixext/WixToolset.Firewall.wixext.csproj deleted file mode 100644 index 6704dad2..00000000 --- a/src/wixext/WixToolset.Firewall.wixext.csproj +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - netstandard2.0 - WixToolset.Firewall - WiX Toolset Firewallity Extension - WiX Toolset Firewall Extension - true - build - - - - - - - - - - - - - - - - - - - - diff --git a/src/wixext/WixToolset.Firewall.wixext.targets b/src/wixext/WixToolset.Firewall.wixext.targets deleted file mode 100644 index c717450f..00000000 --- a/src/wixext/WixToolset.Firewall.wixext.targets +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - $(MSBuildThisFileDirectory)..\tools\WixToolset.Firewall.wixext.dll - - - - - diff --git a/src/wixlib/FirewallExtension.wxs b/src/wixlib/FirewallExtension.wxs deleted file mode 100644 index 56ad693e..00000000 --- a/src/wixlib/FirewallExtension.wxs +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/src/wixlib/FirewallExtension_Platform.wxi b/src/wixlib/FirewallExtension_Platform.wxi deleted file mode 100644 index 3861bd5d..00000000 --- a/src/wixlib/FirewallExtension_Platform.wxi +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/wixlib/FirewallExtension_arm64.wxs b/src/wixlib/FirewallExtension_arm64.wxs deleted file mode 100644 index 63cdd1e8..00000000 --- a/src/wixlib/FirewallExtension_arm64.wxs +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/wixlib/FirewallExtension_x64.wxs b/src/wixlib/FirewallExtension_x64.wxs deleted file mode 100644 index 842aedf1..00000000 --- a/src/wixlib/FirewallExtension_x64.wxs +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/wixlib/FirewallExtension_x86.wxs b/src/wixlib/FirewallExtension_x86.wxs deleted file mode 100644 index 5867f791..00000000 --- a/src/wixlib/FirewallExtension_x86.wxs +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/wixlib/caDecor.wxi b/src/wixlib/caDecor.wxi deleted file mode 100644 index b1711518..00000000 --- a/src/wixlib/caDecor.wxi +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/wixlib/caerr.wxi b/src/wixlib/caerr.wxi deleted file mode 100644 index ff7ec121..00000000 --- a/src/wixlib/caerr.wxi +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/wixlib/en-us.wxl b/src/wixlib/en-us.wxl deleted file mode 100644 index ab9ce8a0..00000000 --- a/src/wixlib/en-us.wxl +++ /dev/null @@ -1,13 +0,0 @@ - - - - - Cannot connect to Windows Firewall. ([2] [3] [4] [5]) - - Configuring Windows Firewall - Configuring Windows Firewall - Rolling back Windows Firewall configuration - Installing Windows Firewall configuration - Rolling back Windows Firewall configuration - Uninstalling Windows Firewall configuration - diff --git a/src/wixlib/es-es.wxl b/src/wixlib/es-es.wxl deleted file mode 100644 index 0631b3a3..00000000 --- a/src/wixlib/es-es.wxl +++ /dev/null @@ -1,12 +0,0 @@ - - - - No se puede conectar al Firewall de Windows. ([2] [3] [4] [5]) - - Configurando el Firewall de Windows - Configurando el Firewall de Windows - Regresando la configuración del Firewall de Windows - Instalando la configuración del Firewall de Windows - Regresando la configuración del Firewall de Windows - Desinstalando la configuración del Firewall de Windows - diff --git a/src/wixlib/firewall.v3.ncrunchproject b/src/wixlib/firewall.v3.ncrunchproject deleted file mode 100644 index 319cd523..00000000 --- a/src/wixlib/firewall.v3.ncrunchproject +++ /dev/null @@ -1,5 +0,0 @@ - - - True - - \ No newline at end of file diff --git a/src/wixlib/firewall.wixproj b/src/wixlib/firewall.wixproj deleted file mode 100644 index 242fa56e..00000000 --- a/src/wixlib/firewall.wixproj +++ /dev/null @@ -1,26 +0,0 @@ - - - - - Library - true - en-us - - - - - - - - - - - - - - - - - - - diff --git a/src/wixlib/ja-jp.wxl b/src/wixlib/ja-jp.wxl deleted file mode 100644 index a4036c7e..00000000 --- a/src/wixlib/ja-jp.wxl +++ /dev/null @@ -1,13 +0,0 @@ - - - - - Windows ファイアウォールへ接続できません。 ([2] [3] [4] [5]) - - Windows ファイアウォールを構成しています - Windows ファイアウォールを構成しています - Windows ファイアウォール構成をロールバックしています - Windows ファイアウォール構成をインストールしています - Windows ファイアウォール構成をロールバックしています - Windows ファイアウォール構成をアンインストールしています - diff --git a/src/wixlib/pl-pl.wxl b/src/wixlib/pl-pl.wxl deleted file mode 100644 index 1b37460e..00000000 --- a/src/wixlib/pl-pl.wxl +++ /dev/null @@ -1,13 +0,0 @@ - - - - - Nie udało się połączyć z Zaporą systemu Windows. ([2] [3] [4] [5]) - - Dodawanie wyjątków do Zapory systemu Windows - Usuwanie wyjątków z Zapory systemu Windows - Cofanie zmian konfiguracji Zapory systemu Windows - Konfigurowywanie Zapory systemu Windows - Cofanie zmian konfiguracji Zapory systemu Windows - Konfigurowywanie Zapory systemu Windows - diff --git a/version.json b/version.json deleted file mode 100644 index 5f857771..00000000 --- a/version.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": "4.0", - "publicReleaseRefSpec": [ - "^refs/heads/master$" - ], - "cloudBuild": { - "buildNumber": { - "enabled": true - } - } -} -- cgit v1.2.3-55-g6feb