diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2020-07-10 21:25:44 +1000 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2020-07-10 22:10:26 +1000 |
| commit | f866ab77f8fd0790f4d6628f54dcdf0bd66fccb6 (patch) | |
| tree | b3705d3655e678003d4fce590e7c5cb1c836778e /src/be | |
| parent | af43f098d7d7cc0fe21c7d7b0fe991763e9cae07 (diff) | |
| download | wix-f866ab77f8fd0790f4d6628f54dcdf0bd66fccb6.tar.gz wix-f866ab77f8fd0790f4d6628f54dcdf0bd66fccb6.tar.bz2 wix-f866ab77f8fd0790f4d6628f54dcdf0bd66fccb6.zip | |
Change the DetectSHA2Support element to WindowsFeatureSearch. This will make it easier to add support for other Windows features in the future.
Diffstat (limited to 'src/be')
| -rw-r--r-- | src/be/detectsha2support.cpp | 8 | ||||
| -rw-r--r-- | src/be/detectsha2support.h | 2 | ||||
| -rw-r--r-- | src/be/utilsearch.cpp | 33 | ||||
| -rw-r--r-- | src/be/utilsearch.h | 15 |
4 files changed, 47 insertions, 11 deletions
diff --git a/src/be/detectsha2support.cpp b/src/be/detectsha2support.cpp index f1f3637e..90e349cd 100644 --- a/src/be/detectsha2support.cpp +++ b/src/be/detectsha2support.cpp | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | #include "precomp.h" | 3 | #include "precomp.h" |
| 4 | 4 | ||
| 5 | // https://gist.github.com/navossoc/7572c7d82243e9f818989e2765e7793a | 5 | // https://gist.github.com/navossoc/7572c7d82243e9f818989e2765e7793a |
| 6 | HRESULT DetectSHA2Support( | 6 | HRESULT DetectSHA2CodeSigning( |
| 7 | __out BOOL* pfSupported | 7 | __out BOOL* pfSupported |
| 8 | ) | 8 | ) |
| 9 | { | 9 | { |
| @@ -38,7 +38,7 @@ LExit: | |||
| 38 | return hr; | 38 | return hr; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | HRESULT UtilPerformDetectSHA2Support( | 41 | HRESULT UtilPerformDetectSHA2CodeSigning( |
| 42 | __in LPCWSTR wzVariable, | 42 | __in LPCWSTR wzVariable, |
| 43 | __in UTIL_SEARCH* /*pSearch*/, | 43 | __in UTIL_SEARCH* /*pSearch*/, |
| 44 | __in IBundleExtensionEngine* pEngine | 44 | __in IBundleExtensionEngine* pEngine |
| @@ -47,8 +47,8 @@ HRESULT UtilPerformDetectSHA2Support( | |||
| 47 | HRESULT hr = S_OK; | 47 | HRESULT hr = S_OK; |
| 48 | BOOL fSupported = FALSE; | 48 | BOOL fSupported = FALSE; |
| 49 | 49 | ||
| 50 | hr = DetectSHA2Support(&fSupported); | 50 | hr = DetectSHA2CodeSigning(&fSupported); |
| 51 | ExitOnFailure(hr, "DetectSHA2Support failed."); | 51 | ExitOnFailure(hr, "DetectSHA2CodeSigning failed."); |
| 52 | 52 | ||
| 53 | hr = pEngine->SetVariableNumeric(wzVariable, fSupported ? 1 : 0); | 53 | hr = pEngine->SetVariableNumeric(wzVariable, fSupported ? 1 : 0); |
| 54 | ExitOnFailure(hr, "Failed to set variable '%ls'", wzVariable); | 54 | ExitOnFailure(hr, "Failed to set variable '%ls'", wzVariable); |
diff --git a/src/be/detectsha2support.h b/src/be/detectsha2support.h index 7f1f6031..c38a3d59 100644 --- a/src/be/detectsha2support.h +++ b/src/be/detectsha2support.h | |||
| @@ -1,7 +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 | HRESULT UtilPerformDetectSHA2Support( | 4 | HRESULT UtilPerformDetectSHA2CodeSigning( |
| 5 | __in LPCWSTR wzVariable, | 5 | __in LPCWSTR wzVariable, |
| 6 | __in UTIL_SEARCH* pSearch, | 6 | __in UTIL_SEARCH* pSearch, |
| 7 | __in IBundleExtensionEngine* pEngine | 7 | __in IBundleExtensionEngine* pEngine |
diff --git a/src/be/utilsearch.cpp b/src/be/utilsearch.cpp index 4e9d86a1..7cd2ea09 100644 --- a/src/be/utilsearch.cpp +++ b/src/be/utilsearch.cpp | |||
| @@ -13,9 +13,10 @@ STDMETHODIMP UtilSearchParseFromXml( | |||
| 13 | IXMLDOMNode* pixnNode = NULL; | 13 | IXMLDOMNode* pixnNode = NULL; |
| 14 | DWORD cNodes = 0; | 14 | DWORD cNodes = 0; |
| 15 | BSTR bstrNodeName = NULL; | 15 | BSTR bstrNodeName = NULL; |
| 16 | LPWSTR scz = NULL; | ||
| 16 | 17 | ||
| 17 | // Select Util search nodes. | 18 | // Select Util search nodes. |
| 18 | hr = XmlSelectNodes(pixnBundleExtension, L"WixDetectSHA2Support", &pixnNodes); | 19 | hr = XmlSelectNodes(pixnBundleExtension, L"WixWindowsFeatureSearch", &pixnNodes); |
| 19 | ExitOnFailure(hr, "Failed to select Util search nodes."); | 20 | ExitOnFailure(hr, "Failed to select Util search nodes."); |
| 20 | 21 | ||
| 21 | // Get Util search node count. | 22 | // Get Util search node count. |
| @@ -46,9 +47,23 @@ STDMETHODIMP UtilSearchParseFromXml( | |||
| 46 | ExitOnFailure(hr, "Failed to get @Id."); | 47 | ExitOnFailure(hr, "Failed to get @Id."); |
| 47 | 48 | ||
| 48 | // Read type specific attributes. | 49 | // Read type specific attributes. |
| 49 | if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"WixDetectSHA2Support", -1)) | 50 | if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"WixWindowsFeatureSearch", -1)) |
| 50 | { | 51 | { |
| 51 | pSearch->Type = UTIL_SEARCH_TYPE_DETECT_SHA2_SUPPORT; | 52 | pSearch->Type = UTIL_SEARCH_TYPE_WINDOWS_FEATURE_SEARCH; |
| 53 | |||
| 54 | // @Type | ||
| 55 | hr = XmlGetAttributeEx(pixnNode, L"Type", &scz); | ||
| 56 | ExitOnFailure(hr, "Failed to get @Type."); | ||
| 57 | |||
| 58 | if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"sha2CodeSigning", -1)) | ||
| 59 | { | ||
| 60 | pSearch->WindowsFeatureSearch.type = UTIL_WINDOWS_FEATURE_SEARCH_TYPE_SHA2_CODE_SIGNING; | ||
| 61 | } | ||
| 62 | else | ||
| 63 | { | ||
| 64 | hr = E_INVALIDARG; | ||
| 65 | ExitOnFailure(hr, "Invalid value for @Type: %ls", scz); | ||
| 66 | } | ||
| 52 | } | 67 | } |
| 53 | else | 68 | else |
| 54 | { | 69 | { |
| @@ -62,6 +77,7 @@ STDMETHODIMP UtilSearchParseFromXml( | |||
| 62 | } | 77 | } |
| 63 | 78 | ||
| 64 | LExit: | 79 | LExit: |
| 80 | ReleaseStr(scz); | ||
| 65 | ReleaseBSTR(bstrNodeName); | 81 | ReleaseBSTR(bstrNodeName); |
| 66 | ReleaseObject(pixnNode); | 82 | ReleaseObject(pixnNode); |
| 67 | ReleaseObject(pixnNodes); | 83 | ReleaseObject(pixnNodes); |
| @@ -100,8 +116,15 @@ STDMETHODIMP UtilSearchExecute( | |||
| 100 | 116 | ||
| 101 | switch (pSearch->Type) | 117 | switch (pSearch->Type) |
| 102 | { | 118 | { |
| 103 | case UTIL_SEARCH_TYPE_DETECT_SHA2_SUPPORT: | 119 | case UTIL_SEARCH_TYPE_WINDOWS_FEATURE_SEARCH: |
| 104 | hr = UtilPerformDetectSHA2Support(wzVariable, pSearch, pEngine); | 120 | switch (pSearch->WindowsFeatureSearch.type) |
| 121 | { | ||
| 122 | case UTIL_WINDOWS_FEATURE_SEARCH_TYPE_SHA2_CODE_SIGNING: | ||
| 123 | hr = UtilPerformDetectSHA2CodeSigning(wzVariable, pSearch, pEngine); | ||
| 124 | break; | ||
| 125 | default: | ||
| 126 | hr = E_UNEXPECTED; | ||
| 127 | } | ||
| 105 | break; | 128 | break; |
| 106 | default: | 129 | default: |
| 107 | hr = E_UNEXPECTED; | 130 | hr = E_UNEXPECTED; |
diff --git a/src/be/utilsearch.h b/src/be/utilsearch.h index 1e0ca96d..deeab1f7 100644 --- a/src/be/utilsearch.h +++ b/src/be/utilsearch.h | |||
| @@ -7,7 +7,13 @@ | |||
| 7 | enum UTIL_SEARCH_TYPE | 7 | enum UTIL_SEARCH_TYPE |
| 8 | { | 8 | { |
| 9 | UTIL_SEARCH_TYPE_NONE, | 9 | UTIL_SEARCH_TYPE_NONE, |
| 10 | UTIL_SEARCH_TYPE_DETECT_SHA2_SUPPORT, | 10 | UTIL_SEARCH_TYPE_WINDOWS_FEATURE_SEARCH, |
| 11 | }; | ||
| 12 | |||
| 13 | enum UTIL_WINDOWS_FEATURE_SEARCH_TYPE | ||
| 14 | { | ||
| 15 | UTIL_WINDOWS_FEATURE_SEARCH_TYPE_NONE, | ||
| 16 | UTIL_WINDOWS_FEATURE_SEARCH_TYPE_SHA2_CODE_SIGNING, | ||
| 11 | }; | 17 | }; |
| 12 | 18 | ||
| 13 | 19 | ||
| @@ -18,6 +24,13 @@ typedef struct _UTIL_SEARCH | |||
| 18 | LPWSTR sczId; | 24 | LPWSTR sczId; |
| 19 | 25 | ||
| 20 | UTIL_SEARCH_TYPE Type; | 26 | UTIL_SEARCH_TYPE Type; |
| 27 | union | ||
| 28 | { | ||
| 29 | struct | ||
| 30 | { | ||
| 31 | UTIL_WINDOWS_FEATURE_SEARCH_TYPE type; | ||
| 32 | } WindowsFeatureSearch; | ||
| 33 | }; | ||
| 21 | } UTIL_SEARCH; | 34 | } UTIL_SEARCH; |
| 22 | 35 | ||
| 23 | typedef struct _UTIL_SEARCHES | 36 | typedef struct _UTIL_SEARCHES |
