aboutsummaryrefslogtreecommitdiff
path: root/src/libs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/dutil/WixToolset.DUtil/deputil.cpp32
-rw-r--r--src/libs/dutil/WixToolset.DUtil/inc/regutil.h11
-rw-r--r--src/libs/dutil/WixToolset.DUtil/regutil.cpp53
3 files changed, 86 insertions, 10 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/deputil.cpp b/src/libs/dutil/WixToolset.DUtil/deputil.cpp
index 1a480263..4de85199 100644
--- a/src/libs/dutil/WixToolset.DUtil/deputil.cpp
+++ b/src/libs/dutil/WixToolset.DUtil/deputil.cpp
@@ -121,9 +121,10 @@ DAPI_(HRESULT) DepCheckDependency(
121 HRESULT hr = S_OK; 121 HRESULT hr = S_OK;
122 LPWSTR sczKey = NULL; 122 LPWSTR sczKey = NULL;
123 HKEY hkKey = NULL; 123 HKEY hkKey = NULL;
124 DWORD64 dw64Version = 0; 124 VERUTIL_VERSION* pVersion = NULL;
125 DWORD64 dw64MinVersion = 0; 125 VERUTIL_VERSION* pMinVersion = NULL;
126 DWORD64 dw64MaxVersion = 0; 126 VERUTIL_VERSION* pMaxVersion = NULL;
127 int nResult = 0;
127 BOOL fAllowEqual = FALSE; 128 BOOL fAllowEqual = FALSE;
128 LPWSTR sczName = NULL; 129 LPWSTR sczName = NULL;
129 130
@@ -138,7 +139,7 @@ DAPI_(HRESULT) DepCheckDependency(
138 DepExitOnFailure(hr, "Failed to open the registry key for dependency \"%ls\".", wzProviderKey); 139 DepExitOnFailure(hr, "Failed to open the registry key for dependency \"%ls\".", wzProviderKey);
139 140
140 // If there are no registry values, consider the key orphaned and treat it as missing. 141 // If there are no registry values, consider the key orphaned and treat it as missing.
141 hr = RegReadVersion(hkKey, vcszVersionValue, &dw64Version); 142 hr = RegReadWixVersion(hkKey, vcszVersionValue, &pVersion);
142 if (E_FILENOTFOUND != hr) 143 if (E_FILENOTFOUND != hr)
143 { 144 {
144 DepExitOnFailure(hr, "Failed to read the %ls registry value for dependency \"%ls\".", vcszVersionValue, wzProviderKey); 145 DepExitOnFailure(hr, "Failed to read the %ls registry value for dependency \"%ls\".", vcszVersionValue, wzProviderKey);
@@ -171,11 +172,15 @@ DAPI_(HRESULT) DepCheckDependency(
171 { 172 {
172 if (*wzMinVersion) 173 if (*wzMinVersion)
173 { 174 {
174 hr = FileVersionFromStringEx(wzMinVersion, 0, &dw64MinVersion); 175 hr = VerParseVersion(wzMinVersion, 0, FALSE, &pMinVersion);
175 DepExitOnFailure(hr, "Failed to get the 64-bit version number from \"%ls\".", wzMinVersion); 176 DepExitOnFailure(hr, "Failed to get the min version number from \"%ls\".", wzMinVersion);
177
178 hr = VerCompareParsedVersions(pVersion, pMinVersion, &nResult);
179 DepExitOnFailure(hr, "Failed to compare dependency with min version \"%ls\".", wzMinVersion);
176 180
177 fAllowEqual = iAttributes & RequiresAttributesMinVersionInclusive; 181 fAllowEqual = iAttributes & RequiresAttributesMinVersionInclusive;
178 if (!(fAllowEqual && dw64MinVersion <= dw64Version || dw64MinVersion < dw64Version)) 182 // !(fAllowEqual && pMinVersion <= pVersion || pMinVersion < pVersion))
183 if (!(fAllowEqual && 0 <= nResult || 0 < nResult))
179 { 184 {
180 hr = DictKeyExists(sdDependencies, wzProviderKey); 185 hr = DictKeyExists(sdDependencies, wzProviderKey);
181 if (E_NOTFOUND != hr) 186 if (E_NOTFOUND != hr)
@@ -205,11 +210,15 @@ DAPI_(HRESULT) DepCheckDependency(
205 { 210 {
206 if (*wzMaxVersion) 211 if (*wzMaxVersion)
207 { 212 {
208 hr = FileVersionFromStringEx(wzMaxVersion, 0, &dw64MaxVersion); 213 hr = VerParseVersion(wzMaxVersion, 0, FALSE, &pMaxVersion);
209 DepExitOnFailure(hr, "Failed to get the 64-bit version number from \"%ls\".", wzMaxVersion); 214 DepExitOnFailure(hr, "Failed to get the max version number from \"%ls\".", wzMaxVersion);
215
216 hr = VerCompareParsedVersions(pMaxVersion, pVersion, &nResult);
217 DepExitOnFailure(hr, "Failed to compare dependency with max version \"%ls\".", wzMaxVersion);
210 218
211 fAllowEqual = iAttributes & RequiresAttributesMaxVersionInclusive; 219 fAllowEqual = iAttributes & RequiresAttributesMaxVersionInclusive;
212 if (!(fAllowEqual && dw64Version <= dw64MaxVersion || dw64Version < dw64MaxVersion)) 220 // !(fAllowEqual && pVersion <= pMaxVersion || pVersion < pMaxVersion)
221 if (!(fAllowEqual && 0 <= nResult || 0 < nResult))
213 { 222 {
214 hr = DictKeyExists(sdDependencies, wzProviderKey); 223 hr = DictKeyExists(sdDependencies, wzProviderKey);
215 if (E_NOTFOUND != hr) 224 if (E_NOTFOUND != hr)
@@ -235,6 +244,9 @@ DAPI_(HRESULT) DepCheckDependency(
235 } 244 }
236 245
237LExit: 246LExit:
247 ReleaseVerutilVersion(pMaxVersion);
248 ReleaseVerutilVersion(pMinVersion);
249 ReleaseVerutilVersion(pVersion);
238 ReleaseStr(sczName); 250 ReleaseStr(sczName);
239 ReleaseRegKey(hkKey); 251 ReleaseRegKey(hkKey);
240 ReleaseStr(sczKey); 252 ReleaseStr(sczKey);
diff --git a/src/libs/dutil/WixToolset.DUtil/inc/regutil.h b/src/libs/dutil/WixToolset.DUtil/inc/regutil.h
index 3cbb53b0..76d2d7cb 100644
--- a/src/libs/dutil/WixToolset.DUtil/inc/regutil.h
+++ b/src/libs/dutil/WixToolset.DUtil/inc/regutil.h
@@ -1,6 +1,7 @@
1#pragma once 1#pragma once
2// 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. 2// 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.
3 3
4#include "verutil.h"
4 5
5#ifdef __cplusplus 6#ifdef __cplusplus
6extern "C" { 7extern "C" {
@@ -261,6 +262,16 @@ HRESULT DAPI RegReadVersion(
261 ); 262 );
262 263
263/******************************************************************** 264/********************************************************************
265 RegReadWixVersion - reads a registry key value as a WiX version.
266
267*********************************************************************/
268HRESULT DAPI RegReadWixVersion(
269 __in HKEY hk,
270 __in_z_opt LPCWSTR wzName,
271 __out VERUTIL_VERSION** ppVersion
272 );
273
274/********************************************************************
264 RegReadNone - reads a NONE registry key value. 275 RegReadNone - reads a NONE registry key value.
265 276
266*********************************************************************/ 277*********************************************************************/
diff --git a/src/libs/dutil/WixToolset.DUtil/regutil.cpp b/src/libs/dutil/WixToolset.DUtil/regutil.cpp
index 78507ade..64224d42 100644
--- a/src/libs/dutil/WixToolset.DUtil/regutil.cpp
+++ b/src/libs/dutil/WixToolset.DUtil/regutil.cpp
@@ -590,6 +590,7 @@ DAPI_(HRESULT) RegReadVersion(
590 { 590 {
591 ExitFunction1(hr = E_FILENOTFOUND); 591 ExitFunction1(hr = E_FILENOTFOUND);
592 } 592 }
593
593 if (REG_SZ == dwType || REG_EXPAND_SZ == dwType) 594 if (REG_SZ == dwType || REG_EXPAND_SZ == dwType)
594 { 595 {
595 hr = RegReadString(hk, wzName, &sczVersion); 596 hr = RegReadString(hk, wzName, &sczVersion);
@@ -614,6 +615,58 @@ LExit:
614 return hr; 615 return hr;
615} 616}
616 617
618
619DAPI_(HRESULT) RegReadWixVersion(
620 __in HKEY hk,
621 __in_z_opt LPCWSTR wzName,
622 __out VERUTIL_VERSION** ppVersion
623 )
624{
625 HRESULT hr = S_OK;
626 DWORD er = ERROR_SUCCESS;
627 DWORD dwType = 0;
628 DWORD cb = 0;
629 DWORD64 dw64Version = 0;
630 LPWSTR sczVersion = NULL;
631 VERUTIL_VERSION* pVersion = NULL;
632
633 cb = sizeof(DWORD64);
634 er = vpfnRegQueryValueExW(hk, wzName, NULL, &dwType, reinterpret_cast<LPBYTE>(&dw64Version), &cb);
635 if (E_FILENOTFOUND == HRESULT_FROM_WIN32(er))
636 {
637 ExitFunction1(hr = E_FILENOTFOUND);
638 }
639
640 if (REG_SZ == dwType || REG_EXPAND_SZ == dwType)
641 {
642 hr = RegReadString(hk, wzName, &sczVersion);
643 RegExitOnFailure(hr, "Failed to read registry version as string.");
644
645 hr = VerParseVersion(sczVersion, 0, FALSE, &pVersion);
646 RegExitOnFailure(hr, "Failed to convert registry string to version.");
647 }
648 else if (REG_QWORD == dwType)
649 {
650 hr = VerVersionFromQword(dw64Version, &pVersion);
651 RegExitOnFailure(hr, "Failed to convert registry string to version.");
652 }
653 else // unexpected data type
654 {
655 hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATATYPE);
656 RegExitOnRootFailure(hr, "Error reading version registry value due to unexpected data type: %u", dwType);
657 }
658
659 *ppVersion = pVersion;
660 pVersion = NULL;
661
662LExit:
663 ReleaseVerutilVersion(pVersion);
664 ReleaseStr(sczVersion);
665
666 return hr;
667}
668
669
617DAPI_(HRESULT) RegReadNone( 670DAPI_(HRESULT) RegReadNone(
618 __in HKEY hk, 671 __in HKEY hk,
619 __in_z_opt LPCWSTR wzName 672 __in_z_opt LPCWSTR wzName