From 6a45cb7687de57056532fe897a708435deec2ea3 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Fri, 9 Sep 2022 21:21:55 -0400 Subject: Update hashes are now hex strings. Fixes https://github.com/wixtoolset/issues/issues/6901. --- .../inc/BootstrapperEngine.h | 3 +-- src/api/burn/WixToolset.Mba.Core/Engine.cs | 4 ++-- src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs | 8 +++----- src/api/burn/WixToolset.Mba.Core/IEngine.cs | 2 +- src/api/burn/balutil/BalBootstrapperEngine.cpp | 6 ++---- src/api/burn/balutil/inc/IBootstrapperEngine.h | 3 +-- src/burn/engine/EngineForApplication.cpp | 2 +- src/burn/engine/externalengine.cpp | 9 ++++----- src/burn/engine/externalengine.h | 5 ++--- src/burn/engine/pseudobundle.cpp | 16 +++++++++++----- src/burn/engine/pseudobundle.h | 5 ++--- 11 files changed, 30 insertions(+), 33 deletions(-) diff --git a/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h b/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h index cdb01330..941e4241 100644 --- a/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h +++ b/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h @@ -381,8 +381,7 @@ typedef struct _BAENGINE_SETUPDATE_ARGS LPCWSTR wzDownloadSource; DWORD64 qwSize; BOOTSTRAPPER_UPDATE_HASH_TYPE hashType; - BYTE* rgbHash; - DWORD cbHash; + LPCWSTR wzHash; } BAENGINE_SETUPDATE_ARGS; typedef struct _BAENGINE_SETUPDATE_RESULTS diff --git a/src/api/burn/WixToolset.Mba.Core/Engine.cs b/src/api/burn/WixToolset.Mba.Core/Engine.cs index 5ebada36..e7ab533b 100644 --- a/src/api/burn/WixToolset.Mba.Core/Engine.cs +++ b/src/api/burn/WixToolset.Mba.Core/Engine.cs @@ -240,9 +240,9 @@ namespace WixToolset.Mba.Core } /// - public void SetUpdate(string localSource, string downloadSource, long size, UpdateHashType hashType, byte[] hash) + public void SetUpdate(string localSource, string downloadSource, long size, UpdateHashType hashType, string hash) { - this.engine.SetUpdate(localSource, downloadSource, size, hashType, hash, null == hash ? 0 : hash.Length); + this.engine.SetUpdate(localSource, downloadSource, size, hashType, hash); } /// diff --git a/src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs b/src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs index fdc9c3f6..408c9955 100644 --- a/src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs +++ b/src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs @@ -123,21 +123,19 @@ namespace WixToolset.Mba.Core ); /// - /// See . + /// See . /// /// /// /// /// - /// - /// + /// void SetUpdate( [MarshalAs(UnmanagedType.LPWStr)] string wzLocalSource, [MarshalAs(UnmanagedType.LPWStr)] string wzDownloadSource, [MarshalAs(UnmanagedType.U8)] long qwValue, [MarshalAs(UnmanagedType.U4)] UpdateHashType hashType, - [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=4)] byte[] rgbHash, - [MarshalAs(UnmanagedType.U4)] int cbHash + [MarshalAs(UnmanagedType.LPWStr)] string wzHash ); /// diff --git a/src/api/burn/WixToolset.Mba.Core/IEngine.cs b/src/api/burn/WixToolset.Mba.Core/IEngine.cs index 3e636961..2b9a90e0 100644 --- a/src/api/burn/WixToolset.Mba.Core/IEngine.cs +++ b/src/api/burn/WixToolset.Mba.Core/IEngine.cs @@ -142,7 +142,7 @@ namespace WixToolset.Mba.Core /// Size of the expected update. /// Type of the hash expected on the update. /// Optional hash expected for the update. - void SetUpdate(string localSource, string downloadSource, long size, UpdateHashType hashType, byte[] hash); + void SetUpdate(string localSource, string downloadSource, long size, UpdateHashType hashType, string hash); /// /// Sets the URL to the update feed. diff --git a/src/api/burn/balutil/BalBootstrapperEngine.cpp b/src/api/burn/balutil/BalBootstrapperEngine.cpp index 301b88a5..898a8a15 100644 --- a/src/api/burn/balutil/BalBootstrapperEngine.cpp +++ b/src/api/burn/balutil/BalBootstrapperEngine.cpp @@ -312,8 +312,7 @@ public: // IBootstrapperEngine __in_z_opt LPCWSTR wzDownloadSource, __in DWORD64 qwSize, __in BOOTSTRAPPER_UPDATE_HASH_TYPE hashType, - __in_bcount_opt(cbHash) BYTE* rgbHash, - __in DWORD cbHash + __in_z_opt LPCWSTR wzHash ) { BAENGINE_SETUPDATE_ARGS args = { }; @@ -324,8 +323,7 @@ public: // IBootstrapperEngine args.wzDownloadSource = wzDownloadSource; args.qwSize = qwSize; args.hashType = hashType; - args.rgbHash = rgbHash; - args.cbHash = cbHash; + args.wzHash = wzHash; results.cbSize = sizeof(results); diff --git a/src/api/burn/balutil/inc/IBootstrapperEngine.h b/src/api/burn/balutil/inc/IBootstrapperEngine.h index ccb07f4f..2a108223 100644 --- a/src/api/burn/balutil/inc/IBootstrapperEngine.h +++ b/src/api/burn/balutil/inc/IBootstrapperEngine.h @@ -65,8 +65,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperEngine, IUnknown, "6480D616-27A0-44D7-905B-8 __in_z_opt LPCWSTR wzDownloadSource, __in DWORD64 qwSize, __in BOOTSTRAPPER_UPDATE_HASH_TYPE hashType, - __in_bcount_opt(cbHash) BYTE* rgbHash, - __in DWORD cbHash + __in_z_opt LPCWSTR wzHash ) = 0; STDMETHOD(SetLocalSource)( diff --git a/src/burn/engine/EngineForApplication.cpp b/src/burn/engine/EngineForApplication.cpp index 83d88ba1..27f815c6 100644 --- a/src/burn/engine/EngineForApplication.cpp +++ b/src/burn/engine/EngineForApplication.cpp @@ -197,7 +197,7 @@ static HRESULT BAEngineSetUpdate( ValidateMessageArgs(hr, pvArgs, BAENGINE_SETUPDATE_ARGS, pArgs); ValidateMessageResults(hr, pvResults, BAENGINE_SETUPDATE_RESULTS, pResults); - hr = ExternalEngineSetUpdate(pContext->pEngineState, pArgs->wzLocalSource, pArgs->wzDownloadSource, pArgs->qwSize, pArgs->hashType, pArgs->rgbHash, pArgs->cbHash); + hr = ExternalEngineSetUpdate(pContext->pEngineState, pArgs->wzLocalSource, pArgs->wzDownloadSource, pArgs->qwSize, pArgs->hashType, pArgs->wzHash); LExit: return hr; diff --git a/src/burn/engine/externalengine.cpp b/src/burn/engine/externalengine.cpp index 16977395..e18b9486 100644 --- a/src/burn/engine/externalengine.cpp +++ b/src/burn/engine/externalengine.cpp @@ -269,8 +269,7 @@ HRESULT ExternalEngineSetUpdate( __in_z_opt LPCWSTR wzDownloadSource, __in const DWORD64 qwSize, __in const BOOTSTRAPPER_UPDATE_HASH_TYPE hashType, - __in_opt const BYTE* rgbHash, - __in const DWORD cbHash + __in_opt LPCWSTR wzHash ) { HRESULT hr = S_OK; @@ -293,11 +292,11 @@ HRESULT ExternalEngineSetUpdate( if (!fRemove) { - if (BOOTSTRAPPER_UPDATE_HASH_TYPE_NONE == hashType && (0 != cbHash || rgbHash)) + if (BOOTSTRAPPER_UPDATE_HASH_TYPE_NONE == hashType && wzHash && *wzHash) { ExitFunction1(hr = E_INVALIDARG); } - else if (BOOTSTRAPPER_UPDATE_HASH_TYPE_SHA512 == hashType && (SHA512_HASH_LEN != cbHash || !rgbHash)) + else if (BOOTSTRAPPER_UPDATE_HASH_TYPE_SHA512 == hashType && (!wzHash || !*wzHash || SHA512_HASH_LEN != lstrlenW(wzHash))) { ExitFunction1(hr = E_INVALIDARG); } @@ -335,7 +334,7 @@ HRESULT ExternalEngineSetUpdate( wzLocalSource = sczFilePath; } - hr = PseudoBundleInitializeUpdateBundle(&pEngineState->update.package, wzGuid, pEngineState->registration.sczId, sczFilePath, wzLocalSource, wzDownloadSource, qwSize, sczCommandline, rgbHash, cbHash); + hr = PseudoBundleInitializeUpdateBundle(&pEngineState->update.package, wzGuid, pEngineState->registration.sczId, sczFilePath, wzLocalSource, wzDownloadSource, qwSize, sczCommandline, wzHash); ExitOnFailure(hr, "Failed to set update bundle."); pEngineState->update.fUpdateAvailable = TRUE; diff --git a/src/burn/engine/externalengine.h b/src/burn/engine/externalengine.h index 2903615d..f28971cd 100644 --- a/src/burn/engine/externalengine.h +++ b/src/burn/engine/externalengine.h @@ -81,9 +81,8 @@ HRESULT ExternalEngineSetUpdate( __in_z_opt LPCWSTR wzDownloadSource, __in const DWORD64 qwSize, __in const BOOTSTRAPPER_UPDATE_HASH_TYPE hashType, - __in_opt const BYTE* rgbHash, - __in const DWORD cbHash - ); + __in_opt LPCWSTR wzHash +); HRESULT ExternalEngineSetLocalSource( __in BURN_ENGINE_STATE* pEngineState, diff --git a/src/burn/engine/pseudobundle.cpp b/src/burn/engine/pseudobundle.cpp index 082c4487..8b30ebfc 100644 --- a/src/burn/engine/pseudobundle.cpp +++ b/src/burn/engine/pseudobundle.cpp @@ -142,9 +142,8 @@ extern "C" HRESULT PseudoBundleInitializeUpdateBundle( __in_z_opt LPCWSTR wzDownloadSource, __in DWORD64 qwSize, __in_z LPCWSTR wzInstallArguments, - __in_opt const BYTE* pbHash, - __in const DWORD cbHash - ) + __in_opt LPCWSTR wzHash +) { HRESULT hr = S_OK; BURN_PAYLOAD* pPayload = NULL; @@ -176,13 +175,20 @@ extern "C" HRESULT PseudoBundleInitializeUpdateBundle( ExitOnFailure(hr, "Failed to copy download source for pseudo bundle."); } - if (pbHash) + if (wzHash && *wzHash) { + BYTE* rgbHash = NULL; + DWORD cbHash = 0; + + hr = StrAllocHexDecode(wzHash, &rgbHash, &cbHash); + ExitOnFailure(hr, "Failed to decode hash string: %ls.", wzHash); + pPayload->pbHash = static_cast(MemAlloc(cbHash, FALSE)); ExitOnNull(pPayload->pbHash, hr, E_OUTOFMEMORY, "Failed to allocate memory for update bundle payload hash."); pPayload->cbHash = cbHash; - memcpy_s(pPayload->pbHash, pPayload->cbHash, pbHash, cbHash); + + memcpy_s(pPayload->pbHash, pPayload->cbHash, rgbHash, cbHash); } pPackage->type = BURN_PACKAGE_TYPE_EXE; diff --git a/src/burn/engine/pseudobundle.h b/src/burn/engine/pseudobundle.h index 78a681df..e55bb951 100644 --- a/src/burn/engine/pseudobundle.h +++ b/src/burn/engine/pseudobundle.h @@ -34,9 +34,8 @@ HRESULT PseudoBundleInitializeUpdateBundle( __in_z_opt LPCWSTR wzDownloadSource, __in DWORD64 qwSize, __in_z LPCWSTR wzInstallArguments, - __in_opt const BYTE* pbHash, - __in const DWORD cbHash - ); + __in_opt LPCWSTR wzHash +); #if defined(__cplusplus) } -- cgit v1.2.3-55-g6feb