aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Arnson <bob@firegiant.com>2022-08-31 16:07:08 -0400
committerBob Arnson <github@bobs.org>2022-08-31 19:59:16 -0400
commit914a92d16d7a0245f3cf0b42cc5e320c34d23d30 (patch)
treef145e999fc4ccefa2e92466a45b602f080a32440
parentf6c86c939af9f8b0036f4b197512f06e861e5fd3 (diff)
downloadwix-914a92d16d7a0245f3cf0b42cc5e320c34d23d30.tar.gz
wix-914a92d16d7a0245f3cf0b42cc5e320c34d23d30.tar.bz2
wix-914a92d16d7a0245f3cf0b42cc5e320c34d23d30.zip
Supply hashes to BA if present in update feed.
Fixes https://github.com/wixtoolset/issues/issues/6353.
-rw-r--r--src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h2
-rw-r--r--src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs4
-rw-r--r--src/api/burn/WixToolset.Mba.Core/EventArgs.cs15
-rw-r--r--src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs4
-rw-r--r--src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs4
-rw-r--r--src/api/burn/balutil/inc/BalBaseBAFunctions.h2
-rw-r--r--src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h2
-rw-r--r--src/api/burn/balutil/inc/BalBaseBootstrapperApplicationProc.h2
-rw-r--r--src/api/burn/balutil/inc/IBootstrapperApplication.h2
-rw-r--r--src/burn/engine/detect.cpp24
-rw-r--r--src/burn/engine/userexperience.cpp5
-rw-r--r--src/burn/engine/userexperience.h2
12 files changed, 58 insertions, 10 deletions
diff --git a/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h b/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h
index ad3ef8a3..c65ca86b 100644
--- a/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h
+++ b/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h
@@ -870,6 +870,8 @@ struct BA_ONDETECTUPDATE_ARGS
870 DWORD cbSize; 870 DWORD cbSize;
871 LPCWSTR wzUpdateLocation; 871 LPCWSTR wzUpdateLocation;
872 DWORD64 dw64Size; 872 DWORD64 dw64Size;
873 LPCWSTR wzHash;
874 BOOTSTRAPPER_UPDATE_HASH_TYPE hashAlgorithm;
873 LPCWSTR wzVersion; 875 LPCWSTR wzVersion;
874 LPCWSTR wzTitle; 876 LPCWSTR wzTitle;
875 LPCWSTR wzSummary; 877 LPCWSTR wzSummary;
diff --git a/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs
index fe9322ce..ecc99069 100644
--- a/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs
+++ b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs
@@ -1451,9 +1451,9 @@ namespace WixToolset.Mba.Core
1451 return args.HResult; 1451 return args.HResult;
1452 } 1452 }
1453 1453
1454 int IBootstrapperApplication.OnDetectUpdate(string wzUpdateLocation, long dw64Size, string wzVersion, string wzTitle, string wzSummary, string wzContentType, string wzContent, ref bool fCancel, ref bool fStopProcessingUpdates) 1454 int IBootstrapperApplication.OnDetectUpdate(string wzUpdateLocation, long dw64Size, string wzHash, UpdateHashType hashAlgorithm, string wzVersion, string wzTitle, string wzSummary, string wzContentType, string wzContent, ref bool fCancel, ref bool fStopProcessingUpdates)
1455 { 1455 {
1456 DetectUpdateEventArgs args = new DetectUpdateEventArgs(wzUpdateLocation, dw64Size, wzVersion, wzTitle, wzSummary, wzContentType, wzContent, fCancel, fStopProcessingUpdates); 1456 DetectUpdateEventArgs args = new DetectUpdateEventArgs(wzUpdateLocation, dw64Size, wzHash, hashAlgorithm, wzVersion, wzTitle, wzSummary, wzContentType, wzContent, fCancel, fStopProcessingUpdates);
1457 this.OnDetectUpdate(args); 1457 this.OnDetectUpdate(args);
1458 1458
1459 fCancel = args.Cancel; 1459 fCancel = args.Cancel;
diff --git a/src/api/burn/WixToolset.Mba.Core/EventArgs.cs b/src/api/burn/WixToolset.Mba.Core/EventArgs.cs
index 2b414d91..48850fd7 100644
--- a/src/api/burn/WixToolset.Mba.Core/EventArgs.cs
+++ b/src/api/burn/WixToolset.Mba.Core/EventArgs.cs
@@ -5,6 +5,7 @@ namespace WixToolset.Mba.Core
5 using System; 5 using System;
6 using System.Collections.Generic; 6 using System.Collections.Generic;
7 using System.Collections.ObjectModel; 7 using System.Collections.ObjectModel;
8 using System.Runtime.InteropServices;
8 9
9 /// <summary> 10 /// <summary>
10 /// Base class for BA <see cref="EventArgs"/> classes. 11 /// Base class for BA <see cref="EventArgs"/> classes.
@@ -328,11 +329,13 @@ namespace WixToolset.Mba.Core
328 public class DetectUpdateEventArgs : CancellableHResultEventArgs 329 public class DetectUpdateEventArgs : CancellableHResultEventArgs
329 { 330 {
330 /// <summary /> 331 /// <summary />
331 public DetectUpdateEventArgs(string updateLocation, long size, string version, string title, string summary, string contentType, string content, bool cancelRecommendation, bool stopRecommendation) 332 public DetectUpdateEventArgs(string updateLocation, long size, string hash, UpdateHashType hashAlgorithm, string version, string title, string summary, string contentType, string content, bool cancelRecommendation, bool stopRecommendation)
332 : base(cancelRecommendation) 333 : base(cancelRecommendation)
333 { 334 {
334 this.UpdateLocation = updateLocation; 335 this.UpdateLocation = updateLocation;
335 this.Size = size; 336 this.Size = size;
337 this.Hash = hash;
338 this.HashAlgorithm = hashAlgorithm;
336 this.Version = version; 339 this.Version = version;
337 this.Title = title; 340 this.Title = title;
338 this.Summary = summary; 341 this.Summary = summary;
@@ -352,6 +355,16 @@ namespace WixToolset.Mba.Core
352 public long Size { get; private set; } 355 public long Size { get; private set; }
353 356
354 /// <summary> 357 /// <summary>
358 /// File hash of the updated bundle.
359 /// </summary>
360 public string Hash { get; }
361
362 /// <summary>
363 /// The algorithm of the updated bundle's hash.
364 /// </summary>
365 public UpdateHashType HashAlgorithm { get; }
366
367 /// <summary>
355 /// Gets the version of the updated bundle. 368 /// Gets the version of the updated bundle.
356 /// </summary> 369 /// </summary>
357 public string Version { get; private set; } 370 public string Version { get; private set; }
diff --git a/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs
index 87da2191..daa95e17 100644
--- a/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs
+++ b/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs
@@ -106,6 +106,8 @@ namespace WixToolset.Mba.Core
106 /// <param name="wzUpdateLocation"></param> 106 /// <param name="wzUpdateLocation"></param>
107 /// <param name="dw64Size"></param> 107 /// <param name="dw64Size"></param>
108 /// <param name="wzVersion"></param> 108 /// <param name="wzVersion"></param>
109 /// <param name="wzHash"></param>
110 /// <param name="hashAlgorithm"></param>
109 /// <param name="wzTitle"></param> 111 /// <param name="wzTitle"></param>
110 /// <param name="wzSummary"></param> 112 /// <param name="wzSummary"></param>
111 /// <param name="wzContentType"></param> 113 /// <param name="wzContentType"></param>
@@ -118,6 +120,8 @@ namespace WixToolset.Mba.Core
118 int OnDetectUpdate( 120 int OnDetectUpdate(
119 [MarshalAs(UnmanagedType.LPWStr)] string wzUpdateLocation, 121 [MarshalAs(UnmanagedType.LPWStr)] string wzUpdateLocation,
120 [MarshalAs(UnmanagedType.U8)] long dw64Size, 122 [MarshalAs(UnmanagedType.U8)] long dw64Size,
123 [MarshalAs(UnmanagedType.LPWStr)] string wzHash,
124 [MarshalAs(UnmanagedType.U4)] UpdateHashType hashAlgorithm,
121 [MarshalAs(UnmanagedType.LPWStr)] string wzVersion, 125 [MarshalAs(UnmanagedType.LPWStr)] string wzVersion,
122 [MarshalAs(UnmanagedType.LPWStr)] string wzTitle, 126 [MarshalAs(UnmanagedType.LPWStr)] string wzTitle,
123 [MarshalAs(UnmanagedType.LPWStr)] string wzSummary, 127 [MarshalAs(UnmanagedType.LPWStr)] string wzSummary,
diff --git a/src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs b/src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs
index ebea6c4f..fdc9c3f6 100644
--- a/src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs
+++ b/src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs
@@ -421,9 +421,9 @@ namespace WixToolset.Mba.Core
421 None, 421 None,
422 422
423 /// <summary> 423 /// <summary>
424 /// SHA-1 based hash provided. 424 /// SHA-512 based hash provided.
425 /// </summary> 425 /// </summary>
426 Sha1, 426 Sha512,
427 } 427 }
428 428
429 /// <summary> 429 /// <summary>
diff --git a/src/api/burn/balutil/inc/BalBaseBAFunctions.h b/src/api/burn/balutil/inc/BalBaseBAFunctions.h
index 3f99673d..9a8ac87e 100644
--- a/src/api/burn/balutil/inc/BalBaseBAFunctions.h
+++ b/src/api/burn/balutil/inc/BalBaseBAFunctions.h
@@ -133,6 +133,8 @@ public: // IBootstrapperApplication
133 virtual STDMETHODIMP OnDetectUpdate( 133 virtual STDMETHODIMP OnDetectUpdate(
134 __in_z LPCWSTR /*wzUpdateLocation*/, 134 __in_z LPCWSTR /*wzUpdateLocation*/,
135 __in DWORD64 /*dw64Size*/, 135 __in DWORD64 /*dw64Size*/,
136 __in_z_opt LPCWSTR /*wzHash*/,
137 __in BOOTSTRAPPER_UPDATE_HASH_TYPE /*hashAlgorithm*/,
136 __in LPCWSTR /*wzVersion*/, 138 __in LPCWSTR /*wzVersion*/,
137 __in_z LPCWSTR /*wzTitle*/, 139 __in_z LPCWSTR /*wzTitle*/,
138 __in_z LPCWSTR /*wzSummary*/, 140 __in_z LPCWSTR /*wzSummary*/,
diff --git a/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h b/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h
index c3223bee..58cc0673 100644
--- a/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h
+++ b/src/api/burn/balutil/inc/BalBaseBootstrapperApplication.h
@@ -132,6 +132,8 @@ public: // IBootstrapperApplication
132 virtual STDMETHODIMP OnDetectUpdate( 132 virtual STDMETHODIMP OnDetectUpdate(
133 __in_z LPCWSTR /*wzUpdateLocation*/, 133 __in_z LPCWSTR /*wzUpdateLocation*/,
134 __in DWORD64 /*dw64Size*/, 134 __in DWORD64 /*dw64Size*/,
135 __in_z_opt LPCWSTR /*wzHash*/,
136 __in BOOTSTRAPPER_UPDATE_HASH_TYPE /*hashAlgorithm*/,
135 __in LPCWSTR /*wzVersion*/, 137 __in LPCWSTR /*wzVersion*/,
136 __in_z LPCWSTR /*wzTitle*/, 138 __in_z LPCWSTR /*wzTitle*/,
137 __in_z LPCWSTR /*wzSummary*/, 139 __in_z LPCWSTR /*wzSummary*/,
diff --git a/src/api/burn/balutil/inc/BalBaseBootstrapperApplicationProc.h b/src/api/burn/balutil/inc/BalBaseBootstrapperApplicationProc.h
index 3054731f..62cb85bc 100644
--- a/src/api/burn/balutil/inc/BalBaseBootstrapperApplicationProc.h
+++ b/src/api/burn/balutil/inc/BalBaseBootstrapperApplicationProc.h
@@ -87,7 +87,7 @@ static HRESULT BalBaseBAProcOnDetectUpdate(
87 __inout BA_ONDETECTUPDATE_RESULTS* pResults 87 __inout BA_ONDETECTUPDATE_RESULTS* pResults
88 ) 88 )
89{ 89{
90 return pBA->OnDetectUpdate(pArgs->wzUpdateLocation, pArgs->dw64Size, pArgs->wzVersion, pArgs->wzTitle, pArgs->wzSummary, pArgs->wzContentType, pArgs->wzContent, &pResults->fCancel, &pResults->fStopProcessingUpdates); 90 return pBA->OnDetectUpdate(pArgs->wzUpdateLocation, pArgs->dw64Size, pArgs->wzHash, pArgs->hashAlgorithm, pArgs->wzVersion, pArgs->wzTitle, pArgs->wzSummary, pArgs->wzContentType, pArgs->wzContent, &pResults->fCancel, &pResults->fStopProcessingUpdates);
91} 91}
92 92
93static HRESULT BalBaseBAProcOnDetectUpdateComplete( 93static HRESULT BalBaseBAProcOnDetectUpdateComplete(
diff --git a/src/api/burn/balutil/inc/IBootstrapperApplication.h b/src/api/burn/balutil/inc/IBootstrapperApplication.h
index 0362e171..fba919ea 100644
--- a/src/api/burn/balutil/inc/IBootstrapperApplication.h
+++ b/src/api/burn/balutil/inc/IBootstrapperApplication.h
@@ -63,6 +63,8 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A
63 STDMETHOD(OnDetectUpdate)( 63 STDMETHOD(OnDetectUpdate)(
64 __in_z_opt LPCWSTR wzUpdateLocation, 64 __in_z_opt LPCWSTR wzUpdateLocation,
65 __in DWORD64 dw64Size, 65 __in DWORD64 dw64Size,
66 __in_z_opt LPCWSTR wzHash,
67 __in BOOTSTRAPPER_UPDATE_HASH_TYPE hashAlgorithm,
66 __in_z LPCWSTR wzVersion, 68 __in_z LPCWSTR wzVersion,
67 __in_z_opt LPCWSTR wzTitle, 69 __in_z_opt LPCWSTR wzTitle,
68 __in_z_opt LPCWSTR wzSummary, 70 __in_z_opt LPCWSTR wzSummary,
diff --git a/src/burn/engine/detect.cpp b/src/burn/engine/detect.cpp
index 7628b26a..25d184c1 100644
--- a/src/burn/engine/detect.cpp
+++ b/src/burn/engine/detect.cpp
@@ -379,6 +379,7 @@ static HRESULT DetectAtomFeedUpdate(
379 ATOM_FEED* pAtomFeed = NULL; 379 ATOM_FEED* pAtomFeed = NULL;
380 APPLICATION_UPDATE_CHAIN* pApupChain = NULL; 380 APPLICATION_UPDATE_CHAIN* pApupChain = NULL;
381 BOOL fStopProcessingUpdates = FALSE; 381 BOOL fStopProcessingUpdates = FALSE;
382 LPWSTR sczHash = NULL;
382 383
383 hr = AtomInitialize(); 384 hr = AtomInitialize();
384 ExitOnFailure(hr, "Failed to initialize Atom."); 385 ExitOnFailure(hr, "Failed to initialize Atom.");
@@ -397,11 +398,25 @@ static HRESULT DetectAtomFeedUpdate(
397 for (DWORD i = 0; i < pApupChain->cEntries; ++i) 398 for (DWORD i = 0; i < pApupChain->cEntries; ++i)
398 { 399 {
399 APPLICATION_UPDATE_ENTRY* pAppUpdateEntry = &pApupChain->rgEntries[i]; 400 APPLICATION_UPDATE_ENTRY* pAppUpdateEntry = &pApupChain->rgEntries[i];
401 APPLICATION_UPDATE_ENCLOSURE* pEnclosure = pAppUpdateEntry->rgEnclosures;
400 402
401 hr = UserExperienceOnDetectUpdate(pUX, pAppUpdateEntry->rgEnclosures ? pAppUpdateEntry->rgEnclosures->wzUrl : NULL, 403 if (pEnclosure)
402 pAppUpdateEntry->rgEnclosures ? pAppUpdateEntry->rgEnclosures->dw64Size : 0, 404 {
403 pAppUpdateEntry->pVersion, pAppUpdateEntry->wzTitle, 405 hr = StrAllocHexEncode(pEnclosure->rgbDigest, pEnclosure->cbDigest, &sczHash);
404 pAppUpdateEntry->wzSummary, pAppUpdateEntry->wzContentType, pAppUpdateEntry->wzContent, &fStopProcessingUpdates); 406 ExitOnFailure(hr, "Failed to encode hash as string.");
407 }
408
409 hr = UserExperienceOnDetectUpdate(pUX,
410 pEnclosure ? pEnclosure->wzUrl : NULL,
411 pEnclosure ? pEnclosure->dw64Size : 0,
412 sczHash ? sczHash : L"",
413 pEnclosure ? pEnclosure->digestAlgorithm == APUP_HASH_ALGORITHM_SHA512 ? BOOTSTRAPPER_UPDATE_HASH_TYPE_SHA512 : BOOTSTRAPPER_UPDATE_HASH_TYPE_NONE : BOOTSTRAPPER_UPDATE_HASH_TYPE_NONE,
414 pAppUpdateEntry->pVersion,
415 pAppUpdateEntry->wzTitle,
416 pAppUpdateEntry->wzSummary,
417 pAppUpdateEntry->wzContentType,
418 pAppUpdateEntry->wzContent,
419 &fStopProcessingUpdates);
405 ExitOnRootFailure(hr, "BA aborted detect update."); 420 ExitOnRootFailure(hr, "BA aborted detect update.");
406 421
407 if (fStopProcessingUpdates) 422 if (fStopProcessingUpdates)
@@ -420,6 +435,7 @@ LExit:
420 ApupFreeChain(pApupChain); 435 ApupFreeChain(pApupChain);
421 AtomFreeFeed(pAtomFeed); 436 AtomFreeFeed(pAtomFeed);
422 ReleaseStr(sczUpdateFeedTempFile); 437 ReleaseStr(sczUpdateFeedTempFile);
438 ReleaseStr(sczHash);
423 AtomUninitialize(); 439 AtomUninitialize();
424 440
425 return hr; 441 return hr;
diff --git a/src/burn/engine/userexperience.cpp b/src/burn/engine/userexperience.cpp
index 6f84caba..28429394 100644
--- a/src/burn/engine/userexperience.cpp
+++ b/src/burn/engine/userexperience.cpp
@@ -1395,6 +1395,8 @@ EXTERN_C BAAPI UserExperienceOnDetectUpdate(
1395 __in BURN_USER_EXPERIENCE* pUserExperience, 1395 __in BURN_USER_EXPERIENCE* pUserExperience,
1396 __in_z_opt LPCWSTR wzUpdateLocation, 1396 __in_z_opt LPCWSTR wzUpdateLocation,
1397 __in DWORD64 dw64Size, 1397 __in DWORD64 dw64Size,
1398 __in_z_opt LPCWSTR wzHash,
1399 __in BOOTSTRAPPER_UPDATE_HASH_TYPE hashAlgorithm,
1398 __in VERUTIL_VERSION* pVersion, 1400 __in VERUTIL_VERSION* pVersion,
1399 __in_z_opt LPCWSTR wzTitle, 1401 __in_z_opt LPCWSTR wzTitle,
1400 __in_z_opt LPCWSTR wzSummary, 1402 __in_z_opt LPCWSTR wzSummary,
@@ -1410,6 +1412,8 @@ EXTERN_C BAAPI UserExperienceOnDetectUpdate(
1410 args.cbSize = sizeof(args); 1412 args.cbSize = sizeof(args);
1411 args.wzUpdateLocation = wzUpdateLocation; 1413 args.wzUpdateLocation = wzUpdateLocation;
1412 args.dw64Size = dw64Size; 1414 args.dw64Size = dw64Size;
1415 args.wzHash = wzHash;
1416 args.hashAlgorithm = hashAlgorithm;
1413 args.wzVersion = pVersion->sczVersion; 1417 args.wzVersion = pVersion->sczVersion;
1414 args.wzTitle = wzTitle; 1418 args.wzTitle = wzTitle;
1415 args.wzSummary = wzSummary; 1419 args.wzSummary = wzSummary;
@@ -1426,6 +1430,7 @@ EXTERN_C BAAPI UserExperienceOnDetectUpdate(
1426 { 1430 {
1427 hr = HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT); 1431 hr = HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT);
1428 } 1432 }
1433
1429 *pfStopProcessingUpdates = results.fStopProcessingUpdates; 1434 *pfStopProcessingUpdates = results.fStopProcessingUpdates;
1430 1435
1431LExit: 1436LExit:
diff --git a/src/burn/engine/userexperience.h b/src/burn/engine/userexperience.h
index 9f183208..e342da03 100644
--- a/src/burn/engine/userexperience.h
+++ b/src/burn/engine/userexperience.h
@@ -332,6 +332,8 @@ BAAPI UserExperienceOnDetectUpdate(
332 __in BURN_USER_EXPERIENCE* pUserExperience, 332 __in BURN_USER_EXPERIENCE* pUserExperience,
333 __in_z_opt LPCWSTR wzUpdateLocation, 333 __in_z_opt LPCWSTR wzUpdateLocation,
334 __in DWORD64 dw64Size, 334 __in DWORD64 dw64Size,
335 __in_z_opt LPCWSTR wzHash,
336 __in BOOTSTRAPPER_UPDATE_HASH_TYPE hashAlgorithm,
335 __in VERUTIL_VERSION* pVersion, 337 __in VERUTIL_VERSION* pVersion,
336 __in_z_opt LPCWSTR wzTitle, 338 __in_z_opt LPCWSTR wzTitle,
337 __in_z_opt LPCWSTR wzSummary, 339 __in_z_opt LPCWSTR wzSummary,