From 4082ae7f94346a8db77638ab8f0e06513a53c73a Mon Sep 17 00:00:00 2001
From: Bob Arnson <bob@firegiant.com>
Date: Sat, 4 Jul 2020 19:06:57 -0400
Subject: Add per-platform custom action support.

---
 src/ca/caDecor.h         | 13 +++++++++++++
 src/ca/caSuffix.h        | 11 -----------
 src/ca/iisca.vcxproj     | 46 ++++++++++++++++++++++++++++++++--------------
 src/ca/precomp.h         |  2 +-
 src/ca/scacert.cpp       | 14 +++++++-------
 src/ca/scacertexec.cpp   |  2 +-
 src/ca/scahttpheader.cpp |  2 +-
 src/ca/scaiis.cpp        |  6 +++---
 src/ca/scaiis7.cpp       |  6 +++---
 src/ca/scasched.cpp      |  8 ++++----
 10 files changed, 65 insertions(+), 45 deletions(-)
 create mode 100644 src/ca/caDecor.h
 delete mode 100644 src/ca/caSuffix.h

(limited to 'src/ca')

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/caSuffix.h b/src/ca/caSuffix.h
deleted file mode 100644
index 303a99e9..00000000
--- a/src/ca/caSuffix.h
+++ /dev/null
@@ -1,11 +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 _WIN64
-#define PLATFORM_DECORATION(f) f L"_64"
-#elif defined ARM
-#define PLATFORM_DECORATION(f) f L"_ARM"
-#else
-#define PLATFORM_DECORATION(f) f
-#endif
diff --git a/src/ca/iisca.vcxproj b/src/ca/iisca.vcxproj
index 893130ed..4361b658 100644
--- a/src/ca/iisca.vcxproj
+++ b/src/ca/iisca.vcxproj
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="utf-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. -->
-
 <Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <Import Project="..\..\packages\WixToolset.DUtil.4.0.30\build\WixToolset.DUtil.props" Condition="Exists('..\..\packages\WixToolset.DUtil.4.0.30\build\WixToolset.DUtil.props')" />
   <Import Project="..\..\packages\WixToolset.WcaUtil.4.0.16\build\WixToolset.WcaUtil.props" Condition="Exists('..\..\packages\WixToolset.WcaUtil.4.0.16\build\WixToolset.WcaUtil.props')" />
@@ -14,25 +13,50 @@
       <Configuration>Release</Configuration>
       <Platform>Win32</Platform>
     </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|ARM">
+      <Configuration>Debug</Configuration>
+      <Platform>ARM</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|ARM">
+      <Configuration>Release</Configuration>
+      <Platform>ARM</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|ARM64">
+      <Configuration>Debug</Configuration>
+      <Platform>ARM64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|ARM64">
+      <Configuration>Release</Configuration>
+      <Platform>ARM64</Platform>
+    </ProjectConfiguration>
   </ItemGroup>
 
   <PropertyGroup Label="Globals">
     <ProjectGuid>{CB3FB8C4-14BF-4EA6-9F01-7FB258E5AEF3}</ProjectGuid>
     <ConfigurationType>DynamicLibrary</ConfigurationType>
     <TargetName>iisca</TargetName>
-    <PlatformToolset>v141</PlatformToolset>
+    <PlatformToolset>v142</PlatformToolset>
     <CharacterSet>Unicode</CharacterSet>
     <ProjectModuleDefinitionFile>iisca.def</ProjectModuleDefinitionFile>
     <Description>WiX Toolset Iis CustomAction</Description>
+    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
   </PropertyGroup>
-
+  
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
-
+  
   <PropertyGroup>
     <ProjectAdditionalLinkLibraries>crypt32.lib;msi.lib;Ws2_32.lib</ProjectAdditionalLinkLibraries>
   </PropertyGroup>
-
+  
   <ItemGroup>
     <ClCompile Include="dllmain.cpp">
       <PrecompiledHeader>Create</PrecompiledHeader>
@@ -76,9 +100,6 @@
     <ClCompile Include="scawebprop7.cpp" />
     <ClCompile Include="scawebsvcext.cpp" />
     <ClCompile Include="scawebsvcext7.cpp" />
-  </ItemGroup>
-
-  <ItemGroup>
     <ClInclude Include="caSuffix.h" />
     <ClInclude Include="CustomMsiErrors.h" />
     <ClInclude Include="precomp.h" />
@@ -119,15 +140,12 @@
     <ClInclude Include="scawebprop7.h" />
     <ClInclude Include="scawebsvcext.h" />
     <ClInclude Include="scawebsvcext7.h" />
-  </ItemGroup>
-
-  <ItemGroup>
     <None Include="packages.config" />
     <None Include="iisca.def" />
   </ItemGroup>
-
+  
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-
+  
   <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
     <PropertyGroup>
       <ErrorText>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}.</ErrorText>
@@ -135,4 +153,4 @@
     <Error Condition="!Exists('..\..\packages\WixToolset.DUtil.4.0.30\build\WixToolset.DUtil.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.DUtil.4.0.30\build\WixToolset.DUtil.props'))" />
     <Error Condition="!Exists('..\..\packages\WixToolset.WcaUtil.4.0.16\build\WixToolset.WcaUtil.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.WcaUtil.4.0.16\build\WixToolset.WcaUtil.props'))" />
   </Target>
-</Project>
+</Project>
\ No newline at end of file
diff --git a/src/ca/precomp.h b/src/ca/precomp.h
index c797ce82..85ee0890 100644
--- a/src/ca/precomp.h
+++ b/src/ca/precomp.h
@@ -63,4 +63,4 @@
 #include "scassl7.h"
 #include "scaexecIIS7.h"
 
-#include "caSuffix.h"
+#include "caDecor.h"
diff --git a/src/ca/scacert.cpp b/src/ca/scacert.cpp
index 90db6375..cf979ee7 100644
--- a/src/ca/scacert.cpp
+++ b/src/ca/scacert.cpp
@@ -165,7 +165,7 @@ static HRESULT ConfigureCertificates(
 
     BYTE* pbCertificate = NULL;
     DWORD cbCertificate = 0;
-    DWORD cbPFXPassword = 0;
+    DWORD_PTR cbPFXPassword = 0;
 
     // Bail quickly if the Certificate table isn't around.
     if (S_OK != WcaTableExists(L"Certificate"))
@@ -273,7 +273,7 @@ static HRESULT ConfigureCertificates(
             // Pick the right action to run based on what store we're uninstalling from.
             if (CERT_SYSTEM_STORE_LOCAL_MACHINE == dwStoreLocation)
             {
-                wzAction = L"DeleteMachineCertificate";
+                wzAction = CUSTOM_ACTION_DECORATION(L"DeleteMachineCertificate");
                 if (pbCertificate)
                 {
                     wzRollbackAction = L"RollbackDeleteMachineCertificate";
@@ -281,7 +281,7 @@ static HRESULT ConfigureCertificates(
             }
             else
             {
-                wzAction = L"DeleteUserCertificate";
+                wzAction = CUSTOM_ACTION_DECORATION(L"DeleteUserCertificate");
                 if (pbCertificate)
                 {
                     wzRollbackAction = L"RollbackDeleteUserCertificate";
@@ -304,13 +304,13 @@ static HRESULT ConfigureCertificates(
             // Pick the right action to run based on what store we're installing into.
             if (CERT_SYSTEM_STORE_LOCAL_MACHINE == dwStoreLocation)
             {
-                wzAction = L"AddMachineCertificate";
-                wzRollbackAction = L"RollbackAddMachineCertificate";
+                wzAction = CUSTOM_ACTION_DECORATION(L"AddMachineCertificate");
+                wzRollbackAction = CUSTOM_ACTION_DECORATION(L"RollbackAddMachineCertificate");
             }
             else
             {
-                wzAction = L"AddUserCertificate";
-                wzRollbackAction = L"RollbackAddUserCertificate";
+                wzAction = CUSTOM_ACTION_DECORATION(L"AddUserCertificate");
+                wzRollbackAction = CUSTOM_ACTION_DECORATION(L"RollbackAddUserCertificate");
             }
             dwCost = COST_CERT_ADD;
         }
diff --git a/src/ca/scacertexec.cpp b/src/ca/scacertexec.cpp
index ff87f485..4bb4ef95 100644
--- a/src/ca/scacertexec.cpp
+++ b/src/ca/scacertexec.cpp
@@ -148,7 +148,7 @@ static HRESULT ExecuteCertificateOperation(
     LPWSTR pwzFilePath = NULL;
     BYTE* pbData = NULL;
     DWORD cbData = 0;
-    DWORD cbPFXPassword = 0;
+    DWORD_PTR cbPFXPassword = 0;
 
     BOOL fUserStoreLocation = (CERT_SYSTEM_STORE_CURRENT_USER == dwStoreLocation);
     HCERTSTORE hCertStore = NULL;
diff --git a/src/ca/scahttpheader.cpp b/src/ca/scahttpheader.cpp
index a8fea796..1e134cea 100644
--- a/src/ca/scahttpheader.cpp
+++ b/src/ca/scahttpheader.cpp
@@ -159,7 +159,7 @@ HRESULT ScaWriteHttpHeader(
     LPWSTR pwz = NULL;
     LPWSTR pwzHeaders = NULL;
     LPWSTR pwzNewHeader = NULL;
-    DWORD dwFoundHeaderIndex = 0;
+    DWORD_PTR dwFoundHeaderIndex = 0;
     LPCWSTR wzFoundHeader = NULL;
     BOOL fOldValueFound = FALSE;
 
diff --git a/src/ca/scaiis.cpp b/src/ca/scaiis.cpp
index a29af1db..958051ed 100644
--- a/src/ca/scaiis.cpp
+++ b/src/ca/scaiis.cpp
@@ -12,13 +12,13 @@ HRESULT ScaMetabaseTransaction(__in_z LPCWSTR wzBackup)
 
     // TODO: These functions have been reported to hang IIS (O11:51709).  They may have been fixed in IIS6, but if not, need to be re-written the hard way
 
-    hr = WcaDoDeferredAction(L"StartMetabaseTransaction", wzBackup, COST_IIS_TRANSACTIONS);
+    hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"StartMetabaseTransaction"), wzBackup, COST_IIS_TRANSACTIONS);
     ExitOnFailure(hr, "Failed to schedule StartMetabaseTransaction");
 
-    hr = WcaDoDeferredAction(L"RollbackMetabaseTransaction", wzBackup, 0);   // rollback cost is irrelevant
+    hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"RollbackMetabaseTransaction"), wzBackup, 0);   // rollback cost is irrelevant
     ExitOnFailure(hr, "Failed to schedule RollbackMetabaseTransaction");
 
-    hr = WcaDoDeferredAction(L"CommitMetabaseTransaction", wzBackup, 0);  // commit is free
+    hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"CommitMetabaseTransaction"), wzBackup, 0);  // commit is free
     ExitOnFailure(hr, "Failed to schedule StartMetabaseTransaction");
 
 LExit:
diff --git a/src/ca/scaiis7.cpp b/src/ca/scaiis7.cpp
index f0f4a629..aaf307d7 100644
--- a/src/ca/scaiis7.cpp
+++ b/src/ca/scaiis7.cpp
@@ -8,13 +8,13 @@ HRESULT ScaIIS7ConfigTransaction(LPCWSTR wzBackup)
 {
     HRESULT hr = S_OK;
 
-    hr = WcaDoDeferredAction(L"StartIIS7ConfigTransaction", wzBackup, COST_IIS_TRANSACTIONS);
+    hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"StartIIS7ConfigTransaction"), wzBackup, COST_IIS_TRANSACTIONS);
     ExitOnFailure(hr, "Failed to schedule StartIIS7ConfigTransaction");
 
-    hr = WcaDoDeferredAction(L"RollbackIIS7ConfigTransaction", wzBackup, 0);   // rollback cost is irrelevant
+    hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"RollbackIIS7ConfigTransaction"), wzBackup, 0);   // rollback cost is irrelevant
     ExitOnFailure(hr, "Failed to schedule RollbackIIS7ConfigTransaction");
 
-    hr = WcaDoDeferredAction(L"CommitIIS7ConfigTransaction", wzBackup, 0);  // commit is free
+    hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"CommitIIS7ConfigTransaction"), wzBackup, 0);  // commit is free
     ExitOnFailure(hr, "Failed to schedule StartIIS7ConfigTransaction");
 
 LExit:
diff --git a/src/ca/scasched.cpp b/src/ca/scasched.cpp
index cdece45d..de021275 100644
--- a/src/ca/scasched.cpp
+++ b/src/ca/scasched.cpp
@@ -331,7 +331,7 @@ extern "C" UINT __stdcall ConfigureIIs(
         // This must remain trace only, CA data may contain password
         WcaLog(LOGMSG_TRACEONLY, "Custom Action Data for ConfigureIIS7Exec will be: %ls", pwzCustomActionData);
 
-        hr = WcaDoDeferredAction(L"ConfigureIIs7Exec", pwzCustomActionData, ConfigureIIsCost);
+        hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"ConfigureIIs7Exec"), pwzCustomActionData, ConfigureIIsCost);
         ExitOnFailure(hr, "Failed to schedule ConfigureIIs7Exec custom action");
 
         ReleaseNullStr(pwzCustomActionData);
@@ -340,7 +340,7 @@ extern "C" UINT __stdcall ConfigureIIs(
         hr = WcaWriteStringToCaData(pwzScriptKey, &pwzCustomActionData);
         ExitOnFailure(hr, "Failed to add script key to CustomActionData.");
 
-        hr = WcaDoDeferredAction(L"WriteIIS7ConfigChanges", pwzCustomActionData, WriteIIS7ConfigChangesCost);
+        hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"WriteIIS7ConfigChanges"), pwzCustomActionData, WriteIIS7ConfigChangesCost);
         ExitOnFailure(hr, "Failed to schedule WriteMetabaseChanges custom action");
     }
     else
@@ -348,7 +348,7 @@ extern "C" UINT __stdcall ConfigureIIs(
         // This must remain trace only, CA data may contain password
         WcaLog(LOGMSG_TRACEONLY, "Custom Action Data for ConfigureIISExec will be: %ls", pwzCustomActionData);
 
-        hr = WcaDoDeferredAction(L"ConfigureIIsExec", pwzCustomActionData, ConfigureIIsCost);
+        hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"ConfigureIIsExec"), pwzCustomActionData, ConfigureIIsCost);
         ExitOnFailure(hr, "Failed to schedule ConfigureIISExec custom action");
 
         ReleaseNullStr(pwzCustomActionData);
@@ -357,7 +357,7 @@ extern "C" UINT __stdcall ConfigureIIs(
         hr = WcaWriteStringToCaData(pwzScriptKey, &pwzCustomActionData);
         ExitOnFailure(hr, "Failed to add script key to CustomActionData.");
 
-        hr = WcaDoDeferredAction(L"WriteMetabaseChanges", pwzCustomActionData, WriteMetabaseChangesCost);
+        hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"WriteMetabaseChanges"), pwzCustomActionData, WriteMetabaseChangesCost);
         ExitOnFailure(hr, "Failed to schedule WriteMetabaseChanges custom action");
     }
 
-- 
cgit v1.2.3-55-g6feb