From c9d14eb51e4b8458fd5e2738fcc7d1c1129ad22e Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 18 Oct 2020 22:37:12 -0500 Subject: WIXFEAT:6210 Change data type of versions to strings. --- src/WixToolset.Mba.Core/BootstrapperApplication.cs | 24 +++--- src/WixToolset.Mba.Core/Engine.cs | 86 +++++++++++++++++++--- src/WixToolset.Mba.Core/EventArgs.cs | 36 ++++----- .../IBootstrapperApplication.cs | 12 +-- src/WixToolset.Mba.Core/IBootstrapperEngine.cs | 5 +- src/WixToolset.Mba.Core/IEngine.cs | 19 ++--- src/WixToolset.Mba.Core/PackageInfo.cs | 4 +- src/balutil/BalBootstrapperEngine.cpp | 14 ++-- src/balutil/balutil.vcxproj | 8 +- src/balutil/inc/BalBaseBAFunctions.h | 12 +-- src/balutil/inc/BalBaseBootstrapperApplication.h | 12 +-- .../inc/BalBaseBootstrapperApplicationProc.h | 12 +-- src/balutil/inc/IBootstrapperApplication.h | 12 +-- src/balutil/inc/IBootstrapperEngine.h | 5 +- src/balutil/packages.config | 4 +- src/bextutil/BextBundleExtensionEngine.cpp | 14 ++-- src/bextutil/bextutil.vcxproj | 8 +- src/bextutil/inc/IBundleExtensionEngine.h | 5 +- src/bextutil/packages.config | 4 +- src/mbanative/mbanative.vcxproj | 8 +- src/mbanative/packages.config | 4 +- 21 files changed, 185 insertions(+), 123 deletions(-) diff --git a/src/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/WixToolset.Mba.Core/BootstrapperApplication.cs index 9ee909dc..472c553a 100644 --- a/src/WixToolset.Mba.Core/BootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/BootstrapperApplication.cs @@ -1130,9 +1130,9 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnDetectForwardCompatibleBundle(string wzBundleId, RelationType relationType, string wzBundleTag, bool fPerMachine, long version, ref bool fCancel, ref bool fIgnoreBundle) + int IBootstrapperApplication.OnDetectForwardCompatibleBundle(string wzBundleId, RelationType relationType, string wzBundleTag, bool fPerMachine, string wzVersion, ref bool fCancel, ref bool fIgnoreBundle) { - DetectForwardCompatibleBundleEventArgs args = new DetectForwardCompatibleBundleEventArgs(wzBundleId, relationType, wzBundleTag, fPerMachine, version, fCancel, fIgnoreBundle); + DetectForwardCompatibleBundleEventArgs args = new DetectForwardCompatibleBundleEventArgs(wzBundleId, relationType, wzBundleTag, fPerMachine, wzVersion, fCancel, fIgnoreBundle); this.OnDetectForwardCompatibleBundle(args); fCancel = args.Cancel; @@ -1150,9 +1150,9 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnDetectUpdate(string wzUpdateLocation, long dw64Size, long dw64Version, string wzTitle, string wzSummary, string wzContentType, string wzContent, ref bool fCancel, ref bool fStopProcessingUpdates) + int IBootstrapperApplication.OnDetectUpdate(string wzUpdateLocation, long dw64Size, string wzVersion, string wzTitle, string wzSummary, string wzContentType, string wzContent, ref bool fCancel, ref bool fStopProcessingUpdates) { - DetectUpdateEventArgs args = new DetectUpdateEventArgs(wzUpdateLocation, dw64Size, dw64Version, wzTitle, wzSummary, wzContentType, wzContent, fCancel, fStopProcessingUpdates); + DetectUpdateEventArgs args = new DetectUpdateEventArgs(wzUpdateLocation, dw64Size, wzVersion, wzTitle, wzSummary, wzContentType, wzContent, fCancel, fStopProcessingUpdates); this.OnDetectUpdate(args); fCancel = args.Cancel; @@ -1169,9 +1169,9 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnDetectRelatedBundle(string wzProductCode, RelationType relationType, string wzBundleTag, bool fPerMachine, long version, RelatedOperation operation, ref bool fCancel) + int IBootstrapperApplication.OnDetectRelatedBundle(string wzProductCode, RelationType relationType, string wzBundleTag, bool fPerMachine, string wzVersion, RelatedOperation operation, ref bool fCancel) { - DetectRelatedBundleEventArgs args = new DetectRelatedBundleEventArgs(wzProductCode, relationType, wzBundleTag, fPerMachine, version, operation, fCancel); + DetectRelatedBundleEventArgs args = new DetectRelatedBundleEventArgs(wzProductCode, relationType, wzBundleTag, fPerMachine, wzVersion, operation, fCancel); this.OnDetectRelatedBundle(args); fCancel = args.Cancel; @@ -1187,18 +1187,18 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnDetectCompatibleMsiPackage(string wzPackageId, string wzCompatiblePackageId, long dw64CompatiblePackageVersion, ref bool fCancel) + int IBootstrapperApplication.OnDetectCompatibleMsiPackage(string wzPackageId, string wzCompatiblePackageId, string wzCompatiblePackageVersion, ref bool fCancel) { - DetectCompatibleMsiPackageEventArgs args = new DetectCompatibleMsiPackageEventArgs(wzPackageId, wzCompatiblePackageId, dw64CompatiblePackageVersion, fCancel); + DetectCompatibleMsiPackageEventArgs args = new DetectCompatibleMsiPackageEventArgs(wzPackageId, wzCompatiblePackageId, wzCompatiblePackageVersion, fCancel); this.OnDetectCompatibleMsiPackage(args); fCancel = args.Cancel; return args.HResult; } - int IBootstrapperApplication.OnDetectRelatedMsiPackage(string wzPackageId, string wzUpgradeCode, string wzProductCode, bool fPerMachine, long version, RelatedOperation operation, ref bool fCancel) + int IBootstrapperApplication.OnDetectRelatedMsiPackage(string wzPackageId, string wzUpgradeCode, string wzProductCode, bool fPerMachine, string wzVersion, RelatedOperation operation, ref bool fCancel) { - DetectRelatedMsiPackageEventArgs args = new DetectRelatedMsiPackageEventArgs(wzPackageId, wzUpgradeCode, wzProductCode, fPerMachine, version, operation, fCancel); + DetectRelatedMsiPackageEventArgs args = new DetectRelatedMsiPackageEventArgs(wzPackageId, wzUpgradeCode, wzProductCode, fPerMachine, wzVersion, operation, fCancel); this.OnDetectRelatedMsiPackage(args); fCancel = args.Cancel; @@ -1268,9 +1268,9 @@ namespace WixToolset.Mba.Core return args.HResult; } - int IBootstrapperApplication.OnPlanCompatibleMsiPackageBegin(string wzPackageId, string wzCompatiblePackageId, long dw64CompatiblePackageVersion, RequestState recommendedState, ref RequestState pRequestedState, ref bool fCancel) + int IBootstrapperApplication.OnPlanCompatibleMsiPackageBegin(string wzPackageId, string wzCompatiblePackageId, string wzCompatiblePackageVersion, RequestState recommendedState, ref RequestState pRequestedState, ref bool fCancel) { - PlanCompatibleMsiPackageBeginEventArgs args = new PlanCompatibleMsiPackageBeginEventArgs(wzPackageId, wzCompatiblePackageId, dw64CompatiblePackageVersion, recommendedState, pRequestedState, fCancel); + PlanCompatibleMsiPackageBeginEventArgs args = new PlanCompatibleMsiPackageBeginEventArgs(wzPackageId, wzCompatiblePackageId, wzCompatiblePackageVersion, recommendedState, pRequestedState, fCancel); this.OnPlanCompatibleMsiPackageBegin(args); pRequestedState = args.State; diff --git a/src/WixToolset.Mba.Core/Engine.cs b/src/WixToolset.Mba.Core/Engine.cs index 98427cfa..e3ad097a 100644 --- a/src/WixToolset.Mba.Core/Engine.cs +++ b/src/WixToolset.Mba.Core/Engine.cs @@ -178,15 +178,21 @@ namespace WixToolset.Mba.Core } } - public Version GetVariableVersion(string name) + public string GetVariableVersion(string name) { - int ret = this.engine.GetVariableVersion(name, out long value); - if (NativeMethods.S_OK != ret) + int length; + IntPtr pUniString = this.getVersionVariable(name, out length); + try { - throw new Win32Exception(ret); + return Marshal.PtrToStringUni(pUniString, length); + } + finally + { + if (IntPtr.Zero != pUniString) + { + Marshal.FreeCoTaskMem(pUniString); + } } - - return LongToVersion(value); } public void LaunchApprovedExe(IntPtr hwndParent, string approvedExeForElevationId, string arguments) @@ -224,12 +230,12 @@ namespace WixToolset.Mba.Core this.engine.SetDownloadSource(packageOrContainerId, payloadId, url, user, password); } - public void SetVariable(string name, long value) + public void SetVariableNumeric(string name, long value) { this.engine.SetVariableNumeric(name, value); } - public void SetVariable(string name, SecureString value, bool formatted) + public void SetVariableString(string name, SecureString value, bool formatted) { IntPtr pValue = Marshal.SecureStringToCoTaskMemUnicode(value); try @@ -242,7 +248,7 @@ namespace WixToolset.Mba.Core } } - public void SetVariable(string name, string value, bool formatted) + public void SetVariableString(string name, string value, bool formatted) { IntPtr pValue = Marshal.StringToCoTaskMemUni(value); try @@ -255,10 +261,17 @@ namespace WixToolset.Mba.Core } } - public void SetVariable(string name, Version value) + public void SetVariableVersion(string name, string value) { - long version = VersionToLong(value); - this.engine.SetVariableVersion(name, version); + IntPtr pValue = Marshal.StringToCoTaskMemUni(value); + try + { + this.engine.SetVariableVersion(name, pValue); + } + finally + { + Marshal.FreeCoTaskMem(pValue); + } } public int SendEmbeddedError(int errorCode, string message, int uiHint) @@ -329,6 +342,55 @@ namespace WixToolset.Mba.Core } } + /// + /// Gets the variable given by as a version string. + /// + /// The name of the variable to get. + /// The length of the Unicode string. + /// The value by a pointer to a Unicode string. Must be freed by Marshal.FreeCoTaskMem. + /// An error occurred getting the variable. + internal IntPtr getVersionVariable(string name, out int length) + { + int capacity = InitialBufferSize; + bool success = false; + IntPtr pValue = Marshal.AllocCoTaskMem(capacity * UnicodeEncoding.CharSize); + try + { + // Get the size of the buffer. + int ret = this.engine.GetVariableVersion(name, pValue, ref capacity); + if (NativeMethods.E_INSUFFICIENT_BUFFER == ret || NativeMethods.E_MOREDATA == ret) + { + // Don't need to add 1 for the null terminator, the engine already includes that. + pValue = Marshal.ReAllocCoTaskMem(pValue, capacity * UnicodeEncoding.CharSize); + ret = this.engine.GetVariableVersion(name, pValue, ref capacity); + } + + if (NativeMethods.S_OK != ret) + { + throw Marshal.GetExceptionForHR(ret); + } + + // The engine only returns the exact length of the string if the buffer was too small, so calculate it ourselves. + for (length = 0; length < capacity; ++length) + { + if (0 == Marshal.ReadInt16(pValue, length * UnicodeEncoding.CharSize)) + { + break; + } + } + + success = true; + return pValue; + } + finally + { + if (!success && IntPtr.Zero != pValue) + { + Marshal.FreeCoTaskMem(pValue); + } + } + } + /// /// Initialize a SecureString with the given Unicode string. /// diff --git a/src/WixToolset.Mba.Core/EventArgs.cs b/src/WixToolset.Mba.Core/EventArgs.cs index e739a853..71bd15e1 100644 --- a/src/WixToolset.Mba.Core/EventArgs.cs +++ b/src/WixToolset.Mba.Core/EventArgs.cs @@ -241,14 +241,14 @@ namespace WixToolset.Mba.Core /// The version of the forward compatible bundle detected. /// The cancel recommendation from the engine. /// The ignore recommendation from the engine. - public DetectForwardCompatibleBundleEventArgs(string bundleId, RelationType relationType, string bundleTag, bool perMachine, long version, bool cancelRecommendation, bool ignoreBundleRecommendation) + public DetectForwardCompatibleBundleEventArgs(string bundleId, RelationType relationType, string bundleTag, bool perMachine, string version, bool cancelRecommendation, bool ignoreBundleRecommendation) : base(cancelRecommendation) { this.BundleId = bundleId; this.RelationType = relationType; this.BundleTag = bundleTag; this.PerMachine = perMachine; - this.Version = Engine.LongToVersion(version); + this.Version = version; this.IgnoreBundle = ignoreBundleRecommendation; } @@ -275,7 +275,7 @@ namespace WixToolset.Mba.Core /// /// Gets the version of the forward compatible bundle detected. /// - public Version Version { get; private set; } + public string Version { get; private set; } /// /// Instructs the engine whether to use the forward compatible bundle. @@ -330,12 +330,12 @@ namespace WixToolset.Mba.Core /// The content of the updated bundle. /// The recommendation from the engine. /// The recommendation from the engine. - public DetectUpdateEventArgs(string updateLocation, long size, long version, string title, string summary, string contentType, string content, bool cancelRecommendation, bool stopRecommendation) + public DetectUpdateEventArgs(string updateLocation, long size, string version, string title, string summary, string contentType, string content, bool cancelRecommendation, bool stopRecommendation) : base(cancelRecommendation) { this.UpdateLocation = updateLocation; this.Size = size; - this.Version = Engine.LongToVersion(version); + this.Version = version; this.Title = title; this.Summary = summary; this.ContentType = contentType; @@ -356,7 +356,7 @@ namespace WixToolset.Mba.Core /// /// Gets the version of the updated bundle. /// - public Version Version { get; private set; } + public string Version { get; private set; } /// /// Gets the title of the the updated bundle. @@ -423,14 +423,14 @@ namespace WixToolset.Mba.Core /// The version of the related bundle detected. /// The operation that will be taken on the detected bundle. /// The recommendation from the engine. - public DetectRelatedBundleEventArgs(string productCode, RelationType relationType, string bundleTag, bool perMachine, long version, RelatedOperation operation, bool cancelRecommendation) + public DetectRelatedBundleEventArgs(string productCode, RelationType relationType, string bundleTag, bool perMachine, string version, RelatedOperation operation, bool cancelRecommendation) : base(cancelRecommendation) { this.ProductCode = productCode; this.RelationType = relationType; this.BundleTag = bundleTag; this.PerMachine = perMachine; - this.Version = Engine.LongToVersion(version); + this.Version = version; this.Operation = operation; } @@ -457,7 +457,7 @@ namespace WixToolset.Mba.Core /// /// Gets the version of the related bundle detected. /// - public Version Version { get; private set; } + public string Version { get; private set; } /// /// Gets the operation that will be taken on the detected bundle. @@ -501,12 +501,12 @@ namespace WixToolset.Mba.Core /// The identity of the compatible package that was detected. /// The version of the compatible package that was detected. /// The recommendation from the engine. - public DetectCompatibleMsiPackageEventArgs(string packageId, string compatiblePackageId, long compatiblePackageVersion, bool cancelRecommendation) + public DetectCompatibleMsiPackageEventArgs(string packageId, string compatiblePackageId, string compatiblePackageVersion, bool cancelRecommendation) : base(cancelRecommendation) { this.PackageId = packageId; this.CompatiblePackageId = compatiblePackageId; - this.CompatiblePackageVersion = Engine.LongToVersion(compatiblePackageVersion); + this.CompatiblePackageVersion = compatiblePackageVersion; } /// @@ -522,7 +522,7 @@ namespace WixToolset.Mba.Core /// /// Gets the version of the compatible package that was detected. /// - public Version CompatiblePackageVersion { get; private set; } + public string CompatiblePackageVersion { get; private set; } } /// @@ -541,14 +541,14 @@ namespace WixToolset.Mba.Core /// The version of the related package detected. /// The operation that will be taken on the detected package. /// The recommendation from the engine. - public DetectRelatedMsiPackageEventArgs(string packageId, string upgradeCode, string productCode, bool perMachine, long version, RelatedOperation operation, bool cancelRecommendation) + public DetectRelatedMsiPackageEventArgs(string packageId, string upgradeCode, string productCode, bool perMachine, string version, RelatedOperation operation, bool cancelRecommendation) : base(cancelRecommendation) { this.PackageId = packageId; this.UpgradeCode = upgradeCode; this.ProductCode = productCode; this.PerMachine = perMachine; - this.Version = Engine.LongToVersion(version); + this.Version = version; this.Operation = operation; } @@ -575,7 +575,7 @@ namespace WixToolset.Mba.Core /// /// Gets the version of the related package detected. /// - public Version Version { get; private set; } + public string Version { get; private set; } /// /// Gets the operation that will be taken on the detected package. @@ -813,12 +813,12 @@ namespace WixToolset.Mba.Core /// The recommended request state for the compatible package. /// The requested state for the compatible package. /// The recommendation from the engine. - public PlanCompatibleMsiPackageBeginEventArgs(string packageId, string compatiblePackageId, long compatiblePackageVersion, RequestState recommendedState, RequestState state, bool cancelRecommendation) + public PlanCompatibleMsiPackageBeginEventArgs(string packageId, string compatiblePackageId, string compatiblePackageVersion, RequestState recommendedState, RequestState state, bool cancelRecommendation) : base(cancelRecommendation) { this.PackageId = packageId; this.CompatiblePackageId = compatiblePackageId; - this.CompatiblePackageVersion = Engine.LongToVersion(compatiblePackageVersion); + this.CompatiblePackageVersion = compatiblePackageVersion; this.RecommendedState = recommendedState; this.State = state; } @@ -836,7 +836,7 @@ namespace WixToolset.Mba.Core /// /// Gets the version of the compatible package detected. /// - public Version CompatiblePackageVersion { get; private set; } + public string CompatiblePackageVersion { get; private set; } /// /// Gets the recommended state to use for the compatible package for planning. diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs index fa655282..0d79122d 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperApplication.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperApplication.cs @@ -45,7 +45,7 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.U4)] RelationType relationType, [MarshalAs(UnmanagedType.LPWStr)] string wzBundleTag, [MarshalAs(UnmanagedType.Bool)] bool fPerMachine, - [MarshalAs(UnmanagedType.U8)] long dw64Version, + [MarshalAs(UnmanagedType.LPWStr)] string wzVersion, [MarshalAs(UnmanagedType.Bool)] ref bool fCancel, [MarshalAs(UnmanagedType.Bool)] ref bool fIgnoreBundle ); @@ -63,7 +63,7 @@ namespace WixToolset.Mba.Core int OnDetectUpdate( [MarshalAs(UnmanagedType.LPWStr)] string wzUpdateLocation, [MarshalAs(UnmanagedType.U8)] long dw64Size, - [MarshalAs(UnmanagedType.U8)] long dw64Version, + [MarshalAs(UnmanagedType.LPWStr)] string wzVersion, [MarshalAs(UnmanagedType.LPWStr)] string wzTitle, [MarshalAs(UnmanagedType.LPWStr)] string wzSummary, [MarshalAs(UnmanagedType.LPWStr)] string wzContentType, @@ -86,7 +86,7 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.U4)] RelationType relationType, [MarshalAs(UnmanagedType.LPWStr)] string wzBundleTag, [MarshalAs(UnmanagedType.Bool)] bool fPerMachine, - [MarshalAs(UnmanagedType.U8)] long dw64Version, + [MarshalAs(UnmanagedType.LPWStr)] string wzVersion, [MarshalAs(UnmanagedType.U4)] RelatedOperation operation, [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); @@ -103,7 +103,7 @@ namespace WixToolset.Mba.Core int OnDetectCompatibleMsiPackage( [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, [MarshalAs(UnmanagedType.LPWStr)] string wzCompatiblePackageId, - [MarshalAs(UnmanagedType.U8)] long dw64CompatiblePackageVersion, + [MarshalAs(UnmanagedType.LPWStr)] string wzCompatiblePackageVersion, [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); @@ -114,7 +114,7 @@ namespace WixToolset.Mba.Core [MarshalAs(UnmanagedType.LPWStr)] string wzUpgradeCode, [MarshalAs(UnmanagedType.LPWStr)] string wzProductCode, [MarshalAs(UnmanagedType.Bool)] bool fPerMachine, - [MarshalAs(UnmanagedType.U8)] long dw64Version, + [MarshalAs(UnmanagedType.LPWStr)] string wzVersion, [MarshalAs(UnmanagedType.U4)] RelatedOperation operation, [MarshalAs(UnmanagedType.Bool)] ref bool fCancel ); @@ -181,7 +181,7 @@ namespace WixToolset.Mba.Core int OnPlanCompatibleMsiPackageBegin( [MarshalAs(UnmanagedType.LPWStr)] string wzPackageId, [MarshalAs(UnmanagedType.LPWStr)] string wzCompatiblePackageId, - [MarshalAs(UnmanagedType.U8)] long dw64CompatiblePackageVersion, + [MarshalAs(UnmanagedType.LPWStr)] string wzCompatiblePackageVersion, [MarshalAs(UnmanagedType.U4)] RequestState recommendedState, [MarshalAs(UnmanagedType.U4)] ref RequestState pRequestedState, [MarshalAs(UnmanagedType.Bool)] ref bool fCancel diff --git a/src/WixToolset.Mba.Core/IBootstrapperEngine.cs b/src/WixToolset.Mba.Core/IBootstrapperEngine.cs index 85ca8693..584e0f6d 100644 --- a/src/WixToolset.Mba.Core/IBootstrapperEngine.cs +++ b/src/WixToolset.Mba.Core/IBootstrapperEngine.cs @@ -36,7 +36,8 @@ namespace WixToolset.Mba.Core [PreserveSig] int GetVariableVersion( [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, - [MarshalAs(UnmanagedType.U8)] out long pqwValue + IntPtr wzValue, + [MarshalAs(UnmanagedType.U4)] ref int pcchValue ); [PreserveSig] @@ -112,7 +113,7 @@ namespace WixToolset.Mba.Core void SetVariableVersion( [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, - [MarshalAs(UnmanagedType.U8)] long qwValue + IntPtr wzValue ); void CloseSplashScreen(); diff --git a/src/WixToolset.Mba.Core/IEngine.cs b/src/WixToolset.Mba.Core/IEngine.cs index 84d93bb0..b486e51d 100644 --- a/src/WixToolset.Mba.Core/IEngine.cs +++ b/src/WixToolset.Mba.Core/IEngine.cs @@ -96,7 +96,7 @@ namespace WixToolset.Mba.Core /// Gets variables for the engine. /// /// The name of the variable. - Version GetVariableVersion(string name); + string GetVariableVersion(string name); /// /// Launches a preapproved executable elevated. As long as the engine already elevated, there will be no UAC prompt. @@ -161,7 +161,7 @@ namespace WixToolset.Mba.Core /// /// The name of the variable. /// The value to set. - void SetVariable(string name, long value); + void SetVariableNumeric(string name, long value); /// /// Sets string variables for the engine using SecureStrings. @@ -169,7 +169,7 @@ namespace WixToolset.Mba.Core /// The name of the variable. /// The value to set. /// False if the value is a literal string. - void SetVariable(string name, SecureString value, bool formatted); + void SetVariableString(string name, SecureString value, bool formatted); /// /// Sets string variables for the engine. @@ -177,21 +177,14 @@ namespace WixToolset.Mba.Core /// The name of the variable. /// The value to set. /// False if the value is a literal string. - void SetVariable(string name, string value, bool formatted); + void SetVariableString(string name, string value, bool formatted); /// - /// Sets variables for the engine. - /// - /// The class can keep track of when the build and revision fields are undefined, but the engine can't. - /// Therefore, the build and revision fields must be defined when setting a variable. - /// Use the NormalizeVersion method to make sure the engine can accept the Version. - /// - /// To keep track of versions without build or revision fields, use StringVariables instead. + /// Sets version variables for the engine. /// /// The name of the variable. /// The value to set. - /// The given was invalid. - void SetVariable(string name, Version value); + void SetVariableVersion(string name, string value); /// /// Sends error message when embedded. diff --git a/src/WixToolset.Mba.Core/PackageInfo.cs b/src/WixToolset.Mba.Core/PackageInfo.cs index d3199c08..d54438f5 100644 --- a/src/WixToolset.Mba.Core/PackageInfo.cs +++ b/src/WixToolset.Mba.Core/PackageInfo.cs @@ -159,11 +159,11 @@ namespace WixToolset.Mba.Core } } - public static IPackageInfo GetRelatedBundleAsPackage(string id, RelationType relationType, bool perMachine, Version version) + public static IPackageInfo GetRelatedBundleAsPackage(string id, RelationType relationType, bool perMachine, string version) { PackageInfo package = new PackageInfo(); package.Id = id; - package.Version = version.ToString(); + package.Version = version; switch (relationType) { diff --git a/src/balutil/BalBootstrapperEngine.cpp b/src/balutil/BalBootstrapperEngine.cpp index 6a0c66d6..b68ea7c2 100644 --- a/src/balutil/BalBootstrapperEngine.cpp +++ b/src/balutil/BalBootstrapperEngine.cpp @@ -133,26 +133,28 @@ public: // IBootstrapperEngine virtual STDMETHODIMP GetVariableVersion( __in_z LPCWSTR wzVariable, - __out DWORD64* pqwValue + __out_ecount_opt(*pcchValue) LPWSTR wzValue, + __inout DWORD* pcchValue ) { HRESULT hr = S_OK; BAENGINE_GETVARIABLEVERSION_ARGS args = { }; BAENGINE_GETVARIABLEVERSION_RESULTS results = { }; - ExitOnNull(pqwValue, hr, E_INVALIDARG, "pqwValue is required"); + ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required"); args.cbSize = sizeof(args); args.wzVariable = wzVariable; results.cbSize = sizeof(results); + results.wzValue = wzValue; + results.cchValue = *pcchValue; hr = m_pfnBAEngineProc(BOOTSTRAPPER_ENGINE_MESSAGE_GETVARIABLEVERSION, &args, &results, m_pvBAEngineProcContext); - *pqwValue = results.qwValue; + *pcchValue = results.cchValue; LExit: - SecureZeroMemory(&results, sizeof(results)); return hr; } @@ -410,7 +412,7 @@ public: // IBootstrapperEngine virtual STDMETHODIMP SetVariableVersion( __in_z LPCWSTR wzVariable, - __in DWORD64 qwValue + __in_z_opt LPCWSTR wzValue ) { BAENGINE_SETVARIABLEVERSION_ARGS args = { }; @@ -418,7 +420,7 @@ public: // IBootstrapperEngine args.cbSize = sizeof(args); args.wzVariable = wzVariable; - args.qwValue = qwValue; + args.wzValue = wzValue; results.cbSize = sizeof(results); diff --git a/src/balutil/balutil.vcxproj b/src/balutil/balutil.vcxproj index 8697b5ab..7373040a 100644 --- a/src/balutil/balutil.vcxproj +++ b/src/balutil/balutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -98,8 +98,8 @@ 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/balutil/inc/BalBaseBAFunctions.h b/src/balutil/inc/BalBaseBAFunctions.h index 4e095fb8..72edadd5 100644 --- a/src/balutil/inc/BalBaseBAFunctions.h +++ b/src/balutil/inc/BalBaseBAFunctions.h @@ -103,7 +103,7 @@ public: // IBootstrapperApplication __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, __in_z LPCWSTR /*wzBundleTag*/, __in BOOL /*fPerMachine*/, - __in DWORD64 /*dw64Version*/, + __in LPCWSTR /*wzVersion*/, __inout BOOL* /*pfCancel*/, __inout BOOL* /*pfIgnoreBundle*/ ) @@ -123,7 +123,7 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnDetectUpdate( __in_z LPCWSTR /*wzUpdateLocation*/, __in DWORD64 /*dw64Size*/, - __in DWORD64 /*dw64Version*/, + __in LPCWSTR /*wzVersion*/, __in_z LPCWSTR /*wzTitle*/, __in_z LPCWSTR /*wzSummary*/, __in_z LPCWSTR /*wzContentType*/, @@ -148,7 +148,7 @@ public: // IBootstrapperApplication __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, __in_z LPCWSTR /*wzBundleTag*/, __in BOOL /*fPerMachine*/, - __in DWORD64 /*dw64Version*/, + __in LPCWSTR /*wzVersion*/, __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/, __inout BOOL* /*pfCancel*/ ) @@ -167,7 +167,7 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnDetectCompatibleMsiPackage( __in_z LPCWSTR /*wzPackageId*/, __in_z LPCWSTR /*wzCompatiblePackageId*/, - __in DWORD64 /*dw64CompatiblePackageVersion*/, + __in LPCWSTR /*wzCompatiblePackageVersion*/, __inout BOOL* /*pfCancel*/ ) { @@ -179,7 +179,7 @@ public: // IBootstrapperApplication __in_z LPCWSTR /*wzUpgradeCode*/, __in_z LPCWSTR /*wzProductCode*/, __in BOOL /*fPerMachine*/, - __in DWORD64 /*dw64Version*/, + __in LPCWSTR /*wzVersion*/, __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/, __inout BOOL* /*pfCancel*/ ) @@ -254,7 +254,7 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnPlanCompatibleMsiPackageBegin( __in_z LPCWSTR /*wzPackageId*/, __in_z LPCWSTR /*wzCompatiblePackageId*/, - __in DWORD64 /*dw64CompatiblePackageVersion*/, + __in LPCWSTR /*wzCompatiblePackageVersion*/, __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/, __inout BOOL* /*pfCancel*/ diff --git a/src/balutil/inc/BalBaseBootstrapperApplication.h b/src/balutil/inc/BalBaseBootstrapperApplication.h index 1d014419..612faf54 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplication.h +++ b/src/balutil/inc/BalBaseBootstrapperApplication.h @@ -101,7 +101,7 @@ public: // IBootstrapperApplication __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, __in_z LPCWSTR /*wzBundleTag*/, __in BOOL /*fPerMachine*/, - __in DWORD64 /*dw64Version*/, + __in LPCWSTR /*wzVersion*/, __inout BOOL* pfCancel, __inout BOOL* /*pfIgnoreBundle*/ ) @@ -123,7 +123,7 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnDetectUpdate( __in_z LPCWSTR /*wzUpdateLocation*/, __in DWORD64 /*dw64Size*/, - __in DWORD64 /*dw64Version*/, + __in LPCWSTR /*wzVersion*/, __in_z LPCWSTR /*wzTitle*/, __in_z LPCWSTR /*wzSummary*/, __in_z LPCWSTR /*wzContentType*/, @@ -149,7 +149,7 @@ public: // IBootstrapperApplication __in BOOTSTRAPPER_RELATION_TYPE /*relationType*/, __in_z LPCWSTR /*wzBundleTag*/, __in BOOL /*fPerMachine*/, - __in DWORD64 /*dw64Version*/, + __in LPCWSTR /*wzVersion*/, __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/, __inout BOOL* pfCancel ) @@ -170,7 +170,7 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnDetectCompatibleMsiPackage( __in_z LPCWSTR /*wzPackageId*/, __in_z LPCWSTR /*wzCompatiblePackageId*/, - __in DWORD64 /*dw64CompatiblePackageVersion*/, + __in LPCWSTR /*wzCompatiblePackageVersion*/, __inout BOOL* pfCancel ) { @@ -183,7 +183,7 @@ public: // IBootstrapperApplication __in_z LPCWSTR /*wzUpgradeCode*/, __in_z LPCWSTR /*wzProductCode*/, __in BOOL /*fPerMachine*/, - __in DWORD64 /*dw64Version*/, + __in LPCWSTR /*wzVersion*/, __in BOOTSTRAPPER_RELATED_OPERATION /*operation*/, __inout BOOL* pfCancel ) @@ -264,7 +264,7 @@ public: // IBootstrapperApplication virtual STDMETHODIMP OnPlanCompatibleMsiPackageBegin( __in_z LPCWSTR /*wzPackageId*/, __in_z LPCWSTR /*wzCompatiblePackageId*/, - __in DWORD64 /*dw64CompatiblePackageVersion*/, + __in LPCWSTR /*wzCompatiblePackageVersion*/, __in BOOTSTRAPPER_REQUEST_STATE /*recommendedState*/, __inout BOOTSTRAPPER_REQUEST_STATE* /*pRequestedState*/, __inout BOOL* pfCancel diff --git a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h index d25af1f7..7d5de8e4 100644 --- a/src/balutil/inc/BalBaseBootstrapperApplicationProc.h +++ b/src/balutil/inc/BalBaseBootstrapperApplicationProc.h @@ -78,7 +78,7 @@ static HRESULT BalBaseBAProcOnDetectForwardCompatibleBundle( __inout BA_ONDETECTFORWARDCOMPATIBLEBUNDLE_RESULTS* pResults ) { - return pBA->OnDetectForwardCompatibleBundle(pArgs->wzBundleId, pArgs->relationType, pArgs->wzBundleTag, pArgs->fPerMachine, pArgs->dw64Version, &pResults->fCancel, &pResults->fIgnoreBundle); + return pBA->OnDetectForwardCompatibleBundle(pArgs->wzBundleId, pArgs->relationType, pArgs->wzBundleTag, pArgs->fPerMachine, pArgs->wzVersion, &pResults->fCancel, &pResults->fIgnoreBundle); } static HRESULT BalBaseBAProcOnDetectUpdateBegin( @@ -96,7 +96,7 @@ static HRESULT BalBaseBAProcOnDetectUpdate( __inout BA_ONDETECTUPDATE_RESULTS* pResults ) { - return pBA->OnDetectUpdate(pArgs->wzUpdateLocation, pArgs->dw64Size, pArgs->dw64Version, pArgs->wzTitle, pArgs->wzSummary, pArgs->wzContentType, pArgs->wzContent, &pResults->fCancel, &pResults->fStopProcessingUpdates); + return pBA->OnDetectUpdate(pArgs->wzUpdateLocation, pArgs->dw64Size, pArgs->wzVersion, pArgs->wzTitle, pArgs->wzSummary, pArgs->wzContentType, pArgs->wzContent, &pResults->fCancel, &pResults->fStopProcessingUpdates); } static HRESULT BalBaseBAProcOnDetectUpdateComplete( @@ -114,7 +114,7 @@ static HRESULT BalBaseBAProcOnDetectRelatedBundle( __inout BA_ONDETECTRELATEDBUNDLE_RESULTS* pResults ) { - return pBA->OnDetectRelatedBundle(pArgs->wzBundleId, pArgs->relationType, pArgs->wzBundleTag, pArgs->fPerMachine, pArgs->dw64Version, pArgs->operation, &pResults->fCancel); + return pBA->OnDetectRelatedBundle(pArgs->wzBundleId, pArgs->relationType, pArgs->wzBundleTag, pArgs->fPerMachine, pArgs->wzVersion, pArgs->operation, &pResults->fCancel); } static HRESULT BalBaseBAProcOnDetectPackageBegin( @@ -132,7 +132,7 @@ static HRESULT BalBaseBAProcOnDetectCompatiblePackage( __inout BA_ONDETECTCOMPATIBLEMSIPACKAGE_RESULTS* pResults ) { - return pBA->OnDetectCompatibleMsiPackage(pArgs->wzPackageId, pArgs->wzCompatiblePackageId, pArgs->dw64CompatiblePackageVersion, &pResults->fCancel); + return pBA->OnDetectCompatibleMsiPackage(pArgs->wzPackageId, pArgs->wzCompatiblePackageId, pArgs->wzCompatiblePackageVersion, &pResults->fCancel); } static HRESULT BalBaseBAProcOnDetectRelatedMsiPackage( @@ -141,7 +141,7 @@ static HRESULT BalBaseBAProcOnDetectRelatedMsiPackage( __inout BA_ONDETECTRELATEDMSIPACKAGE_RESULTS* pResults ) { - return pBA->OnDetectRelatedMsiPackage(pArgs->wzPackageId, pArgs->wzUpgradeCode, pArgs->wzProductCode, pArgs->fPerMachine, pArgs->dw64Version, pArgs->operation, &pResults->fCancel); + return pBA->OnDetectRelatedMsiPackage(pArgs->wzPackageId, pArgs->wzUpgradeCode, pArgs->wzProductCode, pArgs->fPerMachine, pArgs->wzVersion, pArgs->operation, &pResults->fCancel); } static HRESULT BalBaseBAProcOnDetectTargetMsiPackage( @@ -195,7 +195,7 @@ static HRESULT BalBaseBAProcOnPlanCompatibleMsiPackageBegin( __inout BA_ONPLANCOMPATIBLEMSIPACKAGEBEGIN_RESULTS* pResults ) { - return pBA->OnPlanCompatibleMsiPackageBegin(pArgs->wzPackageId, pArgs->wzCompatiblePackageId, pArgs->dw64CompatiblePackageVersion, pArgs->recommendedState, &pResults->requestedState, &pResults->fCancel); + return pBA->OnPlanCompatibleMsiPackageBegin(pArgs->wzPackageId, pArgs->wzCompatiblePackageId, pArgs->wzCompatiblePackageVersion, pArgs->recommendedState, &pResults->requestedState, &pResults->fCancel); } static HRESULT BalBaseBAProcOnPlanCompatibleMsiPackageComplete( diff --git a/src/balutil/inc/IBootstrapperApplication.h b/src/balutil/inc/IBootstrapperApplication.h index e17d2589..9cc19120 100644 --- a/src/balutil/inc/IBootstrapperApplication.h +++ b/src/balutil/inc/IBootstrapperApplication.h @@ -32,7 +32,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __in BOOTSTRAPPER_RELATION_TYPE relationType, __in_z LPCWSTR wzBundleTag, __in BOOL fPerMachine, - __in DWORD64 dw64Version, + __in_z LPCWSTR wzVersion, __inout BOOL* pfCancel, __inout BOOL* pfIgnoreBundle ) = 0; @@ -48,7 +48,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A STDMETHOD(OnDetectUpdate)( __in_z_opt LPCWSTR wzUpdateLocation, __in DWORD64 dw64Size, - __in DWORD64 dw64Version, + __in_z LPCWSTR wzVersion, __in_z_opt LPCWSTR wzTitle, __in_z_opt LPCWSTR wzSummary, __in_z_opt LPCWSTR wzContentType, @@ -69,7 +69,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __in BOOTSTRAPPER_RELATION_TYPE relationType, __in_z LPCWSTR wzBundleTag, __in BOOL fPerMachine, - __in DWORD64 dw64Version, + __in_z LPCWSTR wzVersion, __in BOOTSTRAPPER_RELATED_OPERATION operation, __inout BOOL* pfCancel ) = 0; @@ -84,7 +84,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A STDMETHOD(OnDetectCompatibleMsiPackage)( __in_z LPCWSTR wzPackageId, __in_z LPCWSTR wzCompatiblePackageId, - __in DWORD64 dw64CompatiblePackageVersion, + __in_z LPCWSTR wzCompatiblePackageVersion, __inout BOOL* pfCancel ) = 0; @@ -94,7 +94,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A __in_z LPCWSTR wzUpgradeCode, __in_z LPCWSTR wzProductCode, __in BOOL fPerMachine, - __in DWORD64 dw64Version, + __in_z LPCWSTR wzVersion, __in BOOTSTRAPPER_RELATED_OPERATION operation, __inout BOOL* pfCancel ) = 0; @@ -156,7 +156,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperApplication, IUnknown, "53C31D56-49C0-426B-A STDMETHOD(OnPlanCompatibleMsiPackageBegin)( __in_z LPCWSTR wzPackageId, __in_z LPCWSTR wzCompatiblePackageId, - __in DWORD64 dw64CompatiblePackageVersion, + __in_z LPCWSTR wzCompatiblePackageVersion, __in BOOTSTRAPPER_REQUEST_STATE recommendedState, __inout BOOTSTRAPPER_REQUEST_STATE* pRequestedState, __inout BOOL* pfCancel diff --git a/src/balutil/inc/IBootstrapperEngine.h b/src/balutil/inc/IBootstrapperEngine.h index 3b648df1..cf055102 100644 --- a/src/balutil/inc/IBootstrapperEngine.h +++ b/src/balutil/inc/IBootstrapperEngine.h @@ -21,7 +21,8 @@ DECLARE_INTERFACE_IID_(IBootstrapperEngine, IUnknown, "6480D616-27A0-44D7-905B-8 STDMETHOD(GetVariableVersion)( __in_z LPCWSTR wzVariable, - __out DWORD64* pqwValue + __out_ecount_opt(*pcchValue) LPWSTR wzValue, + __inout DWORD* pcchValue ) = 0; STDMETHOD(FormatString)( @@ -95,7 +96,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperEngine, IUnknown, "6480D616-27A0-44D7-905B-8 STDMETHOD(SetVariableVersion)( __in_z LPCWSTR wzVariable, - __in DWORD64 qwValue + __in_z_opt LPCWSTR wzValue ) = 0; STDMETHOD(CloseSplashScreen)() = 0; diff --git a/src/balutil/packages.config b/src/balutil/packages.config index 4db0b6a7..be1bf8e2 100644 --- a/src/balutil/packages.config +++ b/src/balutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/bextutil/BextBundleExtensionEngine.cpp b/src/bextutil/BextBundleExtensionEngine.cpp index a78b3130..983782a9 100644 --- a/src/bextutil/BextBundleExtensionEngine.cpp +++ b/src/bextutil/BextBundleExtensionEngine.cpp @@ -185,26 +185,28 @@ public: // IBundleExtensionEngine virtual STDMETHODIMP GetVariableVersion( __in_z LPCWSTR wzVariable, - __out DWORD64* pqwValue + __out_ecount_opt(*pcchValue) LPWSTR wzValue, + __inout DWORD* pcchValue ) { HRESULT hr = S_OK; BUNDLE_EXTENSION_ENGINE_GETVARIABLEVERSION_ARGS args = { }; BUNDLE_EXTENSION_ENGINE_GETVARIABLEVERSION_RESULTS results = { }; - ExitOnNull(pqwValue, hr, E_INVALIDARG, "pqwValue is required"); + ExitOnNull(pcchValue, hr, E_INVALIDARG, "pcchValue is required"); args.cbSize = sizeof(args); args.wzVariable = wzVariable; results.cbSize = sizeof(results); + results.wzValue = wzValue; + results.cchValue = *pcchValue; hr = m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_GETVARIABLEVERSION, &args, &results, m_pvBundleExtensionEngineProcContext); - *pqwValue = results.qwValue; + *pcchValue = results.cchValue; LExit: - SecureZeroMemory(&results, sizeof(results)); return hr; } @@ -263,7 +265,7 @@ public: // IBundleExtensionEngine virtual STDMETHODIMP SetVariableVersion( __in_z LPCWSTR wzVariable, - __in DWORD64 qwValue + __in_z_opt LPCWSTR wzValue ) { BUNDLE_EXTENSION_ENGINE_SETVARIABLEVERSION_ARGS args = { }; @@ -271,7 +273,7 @@ public: // IBundleExtensionEngine args.cbSize = sizeof(args); args.wzVariable = wzVariable; - args.qwValue = qwValue; + args.wzValue = wzValue; results.cbSize = sizeof(results); diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj index c27d8aee..00478a6e 100644 --- a/src/bextutil/bextutil.vcxproj +++ b/src/bextutil/bextutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -87,8 +87,8 @@ 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/bextutil/inc/IBundleExtensionEngine.h b/src/bextutil/inc/IBundleExtensionEngine.h index 7772b016..77ea2770 100644 --- a/src/bextutil/inc/IBundleExtensionEngine.h +++ b/src/bextutil/inc/IBundleExtensionEngine.h @@ -34,7 +34,8 @@ DECLARE_INTERFACE_IID_(IBundleExtensionEngine, IUnknown, "9D027A39-F6B6-42CC-973 STDMETHOD(GetVariableVersion)( __in_z LPCWSTR wzVariable, - __out DWORD64* pqwValue + __out_ecount_opt(*pcchValue) LPWSTR wzValue, + __inout DWORD* pcchValue ) = 0; STDMETHOD(Log)( @@ -55,6 +56,6 @@ DECLARE_INTERFACE_IID_(IBundleExtensionEngine, IUnknown, "9D027A39-F6B6-42CC-973 STDMETHOD(SetVariableVersion)( __in_z LPCWSTR wzVariable, - __in DWORD64 qwValue + __in_z_opt LPCWSTR wzValue ) = 0; }; diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config index 4db0b6a7..be1bf8e2 100644 --- a/src/bextutil/packages.config +++ b/src/bextutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/mbanative/mbanative.vcxproj b/src/mbanative/mbanative.vcxproj index 3fe9ef6b..3e1de28f 100644 --- a/src/mbanative/mbanative.vcxproj +++ b/src/mbanative/mbanative.vcxproj @@ -5,8 +5,8 @@ - - + + @@ -94,7 +94,7 @@ - - + + \ No newline at end of file diff --git a/src/mbanative/packages.config b/src/mbanative/packages.config index 443e0094..3faa75d5 100644 --- a/src/mbanative/packages.config +++ b/src/mbanative/packages.config @@ -4,6 +4,6 @@ - - + + \ No newline at end of file -- cgit v1.2.3-55-g6feb