From e879388d96157db6a6e7b2ee79871ef7ebbd3015 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 18 Oct 2020 14:10:20 -0500 Subject: Add CompareVersions engine method. --- .../inc/BootstrapperEngine.h | 14 ++++++++++++++ .../inc/BundleExtension.h | 1 + .../inc/BundleExtensionEngine.h | 14 ++++++++++++++ src/engine/EngineForApplication.cpp | 19 +++++++++++++++++++ src/engine/EngineForExtension.cpp | 19 +++++++++++++++++++ src/engine/burnextension.cpp | 3 ++- src/engine/userexperience.cpp | 2 +- 7 files changed, 70 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h b/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h index a6a87622..13229c29 100644 --- a/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h +++ b/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h @@ -124,6 +124,7 @@ enum BOOTSTRAPPER_ENGINE_MESSAGE BOOTSTRAPPER_ENGINE_MESSAGE_APPLY, BOOTSTRAPPER_ENGINE_MESSAGE_QUIT, BOOTSTRAPPER_ENGINE_MESSAGE_LAUNCHAPPROVEDEXE, + BOOTSTRAPPER_ENGINE_MESSAGE_COMPAREVERSIONS, }; typedef struct _BAENGINE_APPLY_ARGS @@ -147,6 +148,19 @@ typedef struct _BAENGINE_CLOSESPLASHSCREEN_RESULTS DWORD cbSize; } BAENGINE_CLOSESPLASHSCREEN_RESULTS; +typedef struct _BAENGINE_COMPAREVERSIONS_ARGS +{ + DWORD cbSize; + LPCWSTR wzVersion1; + LPCWSTR wzVersion2; +} BAENGINE_COMPAREVERSIONS_ARGS; + +typedef struct _BAENGINE_COMPAREVERSIONS_RESULTS +{ + DWORD cbSize; + int nResult; +} BAENGINE_COMPAREVERSIONS_RESULTS; + typedef struct _BAENGINE_DETECT_ARGS { DWORD cbSize; diff --git a/src/WixToolset.BootstrapperCore.Native/inc/BundleExtension.h b/src/WixToolset.BootstrapperCore.Native/inc/BundleExtension.h index 5c7d1260..be76a1a5 100644 --- a/src/WixToolset.BootstrapperCore.Native/inc/BundleExtension.h +++ b/src/WixToolset.BootstrapperCore.Native/inc/BundleExtension.h @@ -38,6 +38,7 @@ typedef struct _BUNDLE_EXTENSION_CREATE_ARGS LPVOID pvBundleExtensionEngineProcContext; LPCWSTR wzBootstrapperWorkingFolder; LPCWSTR wzBundleExtensionDataPath; + LPCWSTR wzExtensionId; } BUNDLE_EXTENSION_CREATE_ARGS; typedef struct _BUNDLE_EXTENSION_CREATE_RESULTS diff --git a/src/WixToolset.BootstrapperCore.Native/inc/BundleExtensionEngine.h b/src/WixToolset.BootstrapperCore.Native/inc/BundleExtensionEngine.h index adcae1af..becb5be3 100644 --- a/src/WixToolset.BootstrapperCore.Native/inc/BundleExtensionEngine.h +++ b/src/WixToolset.BootstrapperCore.Native/inc/BundleExtensionEngine.h @@ -27,8 +27,22 @@ enum BUNDLE_EXTENSION_ENGINE_MESSAGE BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLENUMERIC, BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLESTRING, BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLEVERSION, + BUNDLE_EXTENSION_ENGINE_MESSAGE_COMPAREVERSIONS, }; +typedef struct _BUNDLE_EXTENSION_ENGINE_COMPAREVERSIONS_ARGS +{ + DWORD cbSize; + LPCWSTR wzVersion1; + LPCWSTR wzVersion2; +} BUNDLE_EXTENSION_ENGINE_COMPAREVERSIONS_ARGS; + +typedef struct _BUNDLE_EXTENSION_ENGINE_COMPAREVERSIONS_RESULTS +{ + DWORD cbSize; + int nResult; +} BUNDLE_EXTENSION_ENGINE_COMPAREVERSIONS_RESULTS; + typedef struct _BUNDLE_EXTENSION_ENGINE_ESCAPESTRING_ARGS { DWORD cbSize; diff --git a/src/engine/EngineForApplication.cpp b/src/engine/EngineForApplication.cpp index d034c2bf..49ffe700 100644 --- a/src/engine/EngineForApplication.cpp +++ b/src/engine/EngineForApplication.cpp @@ -616,6 +616,22 @@ static HRESULT BAEngineCloseSplashScreen( return S_OK; } +static HRESULT BAEngineCompareVersions( + __in BOOTSTRAPPER_ENGINE_CONTEXT* /*pContext*/, + __in const BAENGINE_COMPAREVERSIONS_ARGS* pArgs, + __in BAENGINE_COMPAREVERSIONS_RESULTS* pResults + ) +{ + HRESULT hr = S_OK; + LPCWSTR wzVersion1 = pArgs->wzVersion1; + LPCWSTR wzVersion2 = pArgs->wzVersion2; + int* pnResult = &pResults->nResult; + + hr = VerCompareStringVersions(wzVersion1, wzVersion2, FALSE, pnResult); + + return hr; +} + static HRESULT BAEngineDetect( __in BOOTSTRAPPER_ENGINE_CONTEXT* pContext, __in BAENGINE_DETECT_ARGS* pArgs, @@ -861,6 +877,9 @@ HRESULT WINAPI EngineForApplicationProc( case BOOTSTRAPPER_ENGINE_MESSAGE_LAUNCHAPPROVEDEXE: hr = BAEngineLaunchApprovedExe(pContext, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); break; + case BOOTSTRAPPER_ENGINE_MESSAGE_COMPAREVERSIONS: + hr = BAEngineCompareVersions(pContext, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; default: hr = E_NOTIMPL; break; diff --git a/src/engine/EngineForExtension.cpp b/src/engine/EngineForExtension.cpp index 6ec80a0f..c165e2c2 100644 --- a/src/engine/EngineForExtension.cpp +++ b/src/engine/EngineForExtension.cpp @@ -291,6 +291,22 @@ LExit: return hr; } +static HRESULT BEEngineCompareVersions( + __in BURN_EXTENSION_ENGINE_CONTEXT* /*pContext*/, + __in const BUNDLE_EXTENSION_ENGINE_COMPAREVERSIONS_ARGS* pArgs, + __in BUNDLE_EXTENSION_ENGINE_COMPAREVERSIONS_RESULTS* pResults + ) +{ + HRESULT hr = S_OK; + LPCWSTR wzVersion1 = pArgs->wzVersion1; + LPCWSTR wzVersion2 = pArgs->wzVersion2; + int* pnResult = &pResults->nResult; + + hr = VerCompareStringVersions(wzVersion1, wzVersion2, FALSE, pnResult); + + return hr; +} + HRESULT WINAPI EngineForExtensionProc( __in BUNDLE_EXTENSION_ENGINE_MESSAGE message, __in const LPVOID pvArgs, @@ -338,6 +354,9 @@ HRESULT WINAPI EngineForExtensionProc( case BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLEVERSION: hr = BEEngineSetVariableVersion(pContext, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); break; + case BUNDLE_EXTENSION_ENGINE_MESSAGE_COMPAREVERSIONS: + hr = BEEngineCompareVersions(pContext, reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; default: hr = E_NOTIMPL; break; diff --git a/src/engine/burnextension.cpp b/src/engine/burnextension.cpp index 59f84eca..157b082f 100644 --- a/src/engine/burnextension.cpp +++ b/src/engine/burnextension.cpp @@ -126,9 +126,10 @@ EXTERN_C HRESULT BurnExtensionLoad( args.cbSize = sizeof(BUNDLE_EXTENSION_CREATE_ARGS); args.pfnBundleExtensionEngineProc = EngineForExtensionProc; args.pvBundleExtensionEngineProcContext = pEngineContext; - args.qwEngineAPIVersion = MAKEQWORDVERSION(0, 0, 0, 1); // TODO: need to decide whether to keep this, and if so when to update it. + args.qwEngineAPIVersion = MAKEQWORDVERSION(2020, 8, 31, 0); args.wzBootstrapperWorkingFolder = pEngineContext->pEngineState->userExperience.sczTempDirectory; args.wzBundleExtensionDataPath = sczBundleExtensionDataPath; + args.wzExtensionId = pExtension->sczId; results.cbSize = sizeof(BUNDLE_EXTENSION_CREATE_RESULTS); diff --git a/src/engine/userexperience.cpp b/src/engine/userexperience.cpp index 6ab28cde..5f18cdbc 100644 --- a/src/engine/userexperience.cpp +++ b/src/engine/userexperience.cpp @@ -97,7 +97,7 @@ extern "C" HRESULT UserExperienceLoad( args.pCommand = pCommand; args.pfnBootstrapperEngineProc = EngineForApplicationProc; args.pvBootstrapperEngineProcContext = pEngineContext; - args.qwEngineAPIVersion = MAKEQWORDVERSION(2020, 5, 14, 0); + args.qwEngineAPIVersion = MAKEQWORDVERSION(2020, 8, 31, 0); results.cbSize = sizeof(BOOTSTRAPPER_CREATE_RESULTS); -- cgit v1.2.3-55-g6feb