aboutsummaryrefslogtreecommitdiff
path: root/src/be
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2020-03-30 19:46:56 +1000
committerSean Hall <r.sean.hall@gmail.com>2020-03-30 21:57:49 +1000
commit0afd76e4c5d46f237591d860e7d445e267522187 (patch)
tree9f3b648da7733464c83ba6e253a65a18d17f5583 /src/be
parentd74e3dd4bcc573d0c4b1fb5c36c8bf0115cc21a1 (diff)
downloadwix-0afd76e4c5d46f237591d860e7d445e267522187.tar.gz
wix-0afd76e4c5d46f237591d860e7d445e267522187.tar.bz2
wix-0afd76e4c5d46f237591d860e7d445e267522187.zip
Add DetectSHA2Support "search".
Diffstat (limited to 'src/be')
-rw-r--r--src/be/UtilBundleExtension.cpp87
-rw-r--r--src/be/UtilBundleExtension.h16
-rw-r--r--src/be/detectsha2support.cpp58
-rw-r--r--src/be/detectsha2support.h8
-rw-r--r--src/be/packages.config1
-rw-r--r--src/be/precomp.h23
-rw-r--r--src/be/utilbe.cpp28
-rw-r--r--src/be/utilbe.vcxproj20
-rw-r--r--src/be/utilsearch.cpp137
-rw-r--r--src/be/utilsearch.h52
10 files changed, 410 insertions, 20 deletions
diff --git a/src/be/UtilBundleExtension.cpp b/src/be/UtilBundleExtension.cpp
new file mode 100644
index 00000000..2ac842a5
--- /dev/null
+++ b/src/be/UtilBundleExtension.cpp
@@ -0,0 +1,87 @@
1// 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
3#include "precomp.h"
4#include "BextBaseBundleExtension.h"
5
6class CWixUtilBundleExtension : public CBextBaseBundleExtension
7{
8public: // IBundleExtension
9 virtual STDMETHODIMP Search(
10 __in LPCWSTR wzId,
11 __in LPCWSTR wzVariable
12 )
13 {
14 HRESULT hr = S_OK;
15
16 hr = UtilSearchExecute(&m_searches, wzId, wzVariable, m_pEngine);
17
18 return hr;
19 }
20
21public: //CBextBaseBundleExtension
22 virtual STDMETHODIMP Initialize(
23 __in const BUNDLE_EXTENSION_CREATE_ARGS* pCreateArgs
24 )
25 {
26 HRESULT hr = S_OK;
27 IXMLDOMDocument* pixdManifest = NULL;
28 IXMLDOMNode* pixnBundleExtension = NULL;
29
30 hr = CBextBaseBundleExtension::Initialize(pCreateArgs);
31 ExitOnFailure(hr, "CBextBaseBundleExtension initialization failed.");
32
33 hr = XmlLoadDocumentFromFile(m_sczBundleExtensionDataPath, &pixdManifest);
34 ExitOnFailure(hr, "Failed to load bundle extension manifest from path: %ls", m_sczBundleExtensionDataPath);
35
36 hr = BextGetBundleExtensionDataNode(pixdManifest, UTIL_BUNDLE_EXTENSION_ID, &pixnBundleExtension);
37 ExitOnFailure(hr, "Failed to get BundleExtension '%ls'", UTIL_BUNDLE_EXTENSION_ID);
38
39 hr = UtilSearchParseFromXml(&m_searches, pixnBundleExtension);
40 ExitOnFailure(hr, "Failed to parse searches from bundle extension manifest.");
41
42 LExit:
43 ReleaseObject(pixnBundleExtension);
44 ReleaseObject(pixdManifest);
45
46 return hr;
47 }
48
49public:
50 CWixUtilBundleExtension(
51 __in IBundleExtensionEngine* pEngine
52 ) : CBextBaseBundleExtension(pEngine)
53 {
54 m_searches = { };
55 }
56
57 ~CWixUtilBundleExtension()
58 {
59 UtilSearchUninitialize(&m_searches);
60 }
61
62private:
63 UTIL_SEARCHES m_searches;
64};
65
66HRESULT UtilBundleExtensionCreate(
67 __in IBundleExtensionEngine* pEngine,
68 __in const BUNDLE_EXTENSION_CREATE_ARGS* pArgs,
69 __out IBundleExtension** ppBundleExtension
70 )
71{
72 HRESULT hr = S_OK;
73 CWixUtilBundleExtension* pExtension = NULL;
74
75 pExtension = new CWixUtilBundleExtension(pEngine);
76 ExitOnNull(pExtension, hr, E_OUTOFMEMORY, "Failed to create new CWixUtilBundleExtension.");
77
78 hr = pExtension->Initialize(pArgs);
79 ExitOnFailure(hr, "CWixUtilBundleExtension initialization failed");
80
81 *ppBundleExtension = pExtension;
82 pExtension = NULL;
83
84LExit:
85 ReleaseObject(pExtension);
86 return hr;
87}
diff --git a/src/be/UtilBundleExtension.h b/src/be/UtilBundleExtension.h
new file mode 100644
index 00000000..16c5b346
--- /dev/null
+++ b/src/be/UtilBundleExtension.h
@@ -0,0 +1,16 @@
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.
3
4
5// constants
6
7#define UTIL_BUNDLE_EXTENSION_ID L"WixUtilBundleExtension"
8
9
10// function declarations
11
12HRESULT UtilBundleExtensionCreate(
13 __in IBundleExtensionEngine* pEngine,
14 __in const BUNDLE_EXTENSION_CREATE_ARGS* pArgs,
15 __out IBundleExtension** ppBundleExtension
16 );
diff --git a/src/be/detectsha2support.cpp b/src/be/detectsha2support.cpp
new file mode 100644
index 00000000..f1f3637e
--- /dev/null
+++ b/src/be/detectsha2support.cpp
@@ -0,0 +1,58 @@
1// 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
3#include "precomp.h"
4
5// https://gist.github.com/navossoc/7572c7d82243e9f818989e2765e7793a
6HRESULT DetectSHA2Support(
7 __out BOOL* pfSupported
8 )
9{
10 HRESULT hr = S_OK;
11 HMODULE hModule = NULL;
12 FARPROC pfn = NULL;
13 DWORD er = ERROR_SUCCESS;
14
15 hr = LoadSystemLibrary(L"wintrust.dll", &hModule);
16 ExitOnFailure(hr, "Failed to load wintrust.dll");
17
18 pfn = ::GetProcAddress(hModule, "CryptCATAdminAcquireContext2");
19 if (pfn)
20 {
21 *pfSupported = TRUE;
22 ExitFunction1(hr = S_OK);
23 }
24
25 er = ::GetLastError();
26 if (er == ERROR_PROC_NOT_FOUND)
27 {
28 *pfSupported = FALSE;
29 ExitFunction1(hr = S_OK);
30 }
31
32 hr = HRESULT_FROM_WIN32(er);
33 ExitOnFailure(hr, "Failed to probe for CryptCATAdminAcquireContext2 in wintrust.dll");
34
35LExit:
36 ::FreeLibrary(hModule);
37
38 return hr;
39}
40
41HRESULT UtilPerformDetectSHA2Support(
42 __in LPCWSTR wzVariable,
43 __in UTIL_SEARCH* /*pSearch*/,
44 __in IBundleExtensionEngine* pEngine
45 )
46{
47 HRESULT hr = S_OK;
48 BOOL fSupported = FALSE;
49
50 hr = DetectSHA2Support(&fSupported);
51 ExitOnFailure(hr, "DetectSHA2Support failed.");
52
53 hr = pEngine->SetVariableNumeric(wzVariable, fSupported ? 1 : 0);
54 ExitOnFailure(hr, "Failed to set variable '%ls'", wzVariable);
55
56LExit:
57 return hr;
58}
diff --git a/src/be/detectsha2support.h b/src/be/detectsha2support.h
new file mode 100644
index 00000000..7f1f6031
--- /dev/null
+++ b/src/be/detectsha2support.h
@@ -0,0 +1,8 @@
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.
3
4HRESULT UtilPerformDetectSHA2Support(
5 __in LPCWSTR wzVariable,
6 __in UTIL_SEARCH* pSearch,
7 __in IBundleExtensionEngine* pEngine
8 ); \ No newline at end of file
diff --git a/src/be/packages.config b/src/be/packages.config
index f05546c5..ca23641f 100644
--- a/src/be/packages.config
+++ b/src/be/packages.config
@@ -1,5 +1,6 @@
1<?xml version="1.0" encoding="utf-8"?> 1<?xml version="1.0" encoding="utf-8"?>
2<packages> 2<packages>
3 <package id="WixToolset.BextUtil" version="4.0.16" targetFramework="native" />
3 <package id="WixToolset.BootstrapperCore.Native" version="4.0.13" targetFramework="native" /> 4 <package id="WixToolset.BootstrapperCore.Native" version="4.0.13" targetFramework="native" />
4 <package id="WixToolset.DUtil" version="4.0.18" targetFramework="native" /> 5 <package id="WixToolset.DUtil" version="4.0.18" targetFramework="native" />
5</packages> \ No newline at end of file 6</packages> \ No newline at end of file
diff --git a/src/be/precomp.h b/src/be/precomp.h
index 9dc3c468..a4ab7abf 100644
--- a/src/be/precomp.h
+++ b/src/be/precomp.h
@@ -17,9 +17,20 @@
17 17
18#define MAXUINT USHRT_MAX 18#define MAXUINT USHRT_MAX
19 19
20#include "dutil.h" 20#include <dutil.h>
21#include "memutil.h" 21#include <memutil.h>
22 22#include <strutil.h>
23#include "BootstrapperEngine.h" 23#include <pathutil.h>
24#include "BundleExtensionEngine.h" 24#include <xmlutil.h>
25#include "BundleExtension.h" 25
26#include <BundleExtensionEngine.h>
27#include <BundleExtension.h>
28
29#include <IBundleExtensionEngine.h>
30#include <IBundleExtension.h>
31#include <bextutil.h>
32#include <BextBundleExtensionEngine.h>
33
34#include "utilsearch.h"
35#include "detectsha2support.h"
36#include "UtilBundleExtension.h"
diff --git a/src/be/utilbe.cpp b/src/be/utilbe.cpp
index 370669dd..d9816dc7 100644
--- a/src/be/utilbe.cpp
+++ b/src/be/utilbe.cpp
@@ -1,19 +1,41 @@
1// 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. 1// 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 2
3#include "precomp.h" 3#include "precomp.h"
4#include "BextBaseBundleExtensionProc.h"
5
6static IBundleExtension* vpBundleExtension = NULL;
4 7
5// function definitions 8// function definitions
6 9
7extern "C" HRESULT WINAPI BundleExtensionCreate( 10extern "C" HRESULT WINAPI BundleExtensionCreate(
8 __in const BUNDLE_EXTENSION_CREATE_ARGS* /*pArgs*/, 11 __in const BUNDLE_EXTENSION_CREATE_ARGS* pArgs,
9 __inout BUNDLE_EXTENSION_CREATE_RESULTS* /*pResults*/ 12 __inout BUNDLE_EXTENSION_CREATE_RESULTS* pResults
10 ) 13 )
11{ 14{
12 HRESULT hr = S_OK; 15 HRESULT hr = S_OK;
16 IBundleExtensionEngine* pEngine = NULL;
17
18 hr = XmlInitialize();
19 ExitOnFailure(hr, "Failed to initialize XML.");
20
21 hr = BextInitializeFromCreateArgs(pArgs, &pEngine);
22 ExitOnFailure(hr, "Failed to initialize bext");
23
24 hr = UtilBundleExtensionCreate(pEngine, pArgs, &vpBundleExtension);
25 BextExitOnFailure(hr, "Failed to create WixUtilBundleExtension");
26
27 pResults->pfnBundleExtensionProc = BextBaseBundleExtensionProc;
28 pResults->pvBundleExtensionProcContext = vpBundleExtension;
29
30LExit:
31 ReleaseObject(pEngine);
13 32
14 return hr; 33 return hr;
15} 34}
16 35
17extern "C" void WINAPI BundleExtensionDestroy() 36extern "C" void WINAPI BundleExtensionDestroy()
18{ 37{
38 BextUninitialize();
39 ReleaseNullObject(vpBundleExtension);
40 XmlUninitialize();
19} \ No newline at end of file 41} \ No newline at end of file
diff --git a/src/be/utilbe.vcxproj b/src/be/utilbe.vcxproj
index 963eac7f..e64d113e 100644
--- a/src/be/utilbe.vcxproj
+++ b/src/be/utilbe.vcxproj
@@ -1,10 +1,9 @@
1<?xml version="1.0" encoding="utf-8"?> 1<?xml version="1.0" encoding="utf-8"?>
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
4<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 3<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
4 <Import Project="..\..\packages\WixToolset.BextUtil.4.0.16\build\WixToolset.BextUtil.props" Condition="Exists('..\..\packages\WixToolset.BextUtil.4.0.16\build\WixToolset.BextUtil.props')" />
5 <Import Project="..\..\packages\WixToolset.BootstrapperCore.Native.4.0.13\build\WixToolset.BootstrapperCore.Native.props" Condition="Exists('..\..\packages\WixToolset.BootstrapperCore.Native.4.0.13\build\WixToolset.BootstrapperCore.Native.props')" /> 5 <Import Project="..\..\packages\WixToolset.BootstrapperCore.Native.4.0.13\build\WixToolset.BootstrapperCore.Native.props" Condition="Exists('..\..\packages\WixToolset.BootstrapperCore.Native.4.0.13\build\WixToolset.BootstrapperCore.Native.props')" />
6 <Import Project="..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props" Condition="Exists('..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props')" /> 6 <Import Project="..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props" Condition="Exists('..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props')" />
7
8 <ItemGroup Label="ProjectConfigurations"> 7 <ItemGroup Label="ProjectConfigurations">
9 <ProjectConfiguration Include="Debug|Win32"> 8 <ProjectConfiguration Include="Debug|Win32">
10 <Configuration>Debug</Configuration> 9 <Configuration>Debug</Configuration>
@@ -15,7 +14,6 @@
15 <Platform>Win32</Platform> 14 <Platform>Win32</Platform>
16 </ProjectConfiguration> 15 </ProjectConfiguration>
17 </ItemGroup> 16 </ItemGroup>
18
19 <PropertyGroup Label="Globals"> 17 <PropertyGroup Label="Globals">
20 <ProjectGuid>{630C1EE7-2517-4A8C-83E3-DA1150308B58}</ProjectGuid> 18 <ProjectGuid>{630C1EE7-2517-4A8C-83E3-DA1150308B58}</ProjectGuid>
21 <ConfigurationType>DynamicLibrary</ConfigurationType> 19 <ConfigurationType>DynamicLibrary</ConfigurationType>
@@ -25,37 +23,37 @@
25 <ProjectModuleDefinitionFile>utilbe.def</ProjectModuleDefinitionFile> 23 <ProjectModuleDefinitionFile>utilbe.def</ProjectModuleDefinitionFile>
26 <Description>WiX Toolset Util BundleExtension</Description> 24 <Description>WiX Toolset Util BundleExtension</Description>
27 </PropertyGroup> 25 </PropertyGroup>
28
29 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> 26 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
30 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> 27 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
31
32 <PropertyGroup> 28 <PropertyGroup>
33 <ProjectAdditionalLinkLibraries>msi.lib</ProjectAdditionalLinkLibraries> 29 <ProjectAdditionalLinkLibraries>msi.lib</ProjectAdditionalLinkLibraries>
34 </PropertyGroup> 30 </PropertyGroup>
35
36 <ItemGroup> 31 <ItemGroup>
32 <ClCompile Include="detectsha2support.cpp" />
37 <ClCompile Include="precomp.cpp"> 33 <ClCompile Include="precomp.cpp">
38 <PrecompiledHeader>Create</PrecompiledHeader> 34 <PrecompiledHeader>Create</PrecompiledHeader>
39 </ClCompile> 35 </ClCompile>
40 <ClCompile Include="utilbe.cpp" /> 36 <ClCompile Include="utilbe.cpp" />
37 <ClCompile Include="UtilBundleExtension.cpp" />
38 <ClCompile Include="utilsearch.cpp" />
41 </ItemGroup> 39 </ItemGroup>
42
43 <ItemGroup> 40 <ItemGroup>
41 <ClInclude Include="detectsha2support.h" />
44 <ClInclude Include="precomp.h" /> 42 <ClInclude Include="precomp.h" />
43 <ClInclude Include="UtilBundleExtension.h" />
44 <ClInclude Include="utilsearch.h" />
45 </ItemGroup> 45 </ItemGroup>
46
47 <ItemGroup> 46 <ItemGroup>
48 <None Include="packages.config" /> 47 <None Include="packages.config" />
49 <None Include="utilbe.def" /> 48 <None Include="utilbe.def" />
50 </ItemGroup> 49 </ItemGroup>
51
52 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> 50 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
53
54 <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> 51 <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
55 <PropertyGroup> 52 <PropertyGroup>
56 <ErrorText>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}.</ErrorText> 53 <ErrorText>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}.</ErrorText>
57 </PropertyGroup> 54 </PropertyGroup>
55 <Error Condition="!Exists('..\..\packages\WixToolset.BextUtil.4.0.16\build\WixToolset.BextUtil.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.BextUtil.4.0.16\build\WixToolset.BextUtil.props'))" />
58 <Error Condition="!Exists('..\..\packages\WixToolset.BootstrapperCore.Native.4.0.13\build\WixToolset.BootstrapperCore.Native.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.BootstrapperCore.Native.4.0.13\build\WixToolset.BootstrapperCore.Native.props'))" /> 56 <Error Condition="!Exists('..\..\packages\WixToolset.BootstrapperCore.Native.4.0.13\build\WixToolset.BootstrapperCore.Native.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.BootstrapperCore.Native.4.0.13\build\WixToolset.BootstrapperCore.Native.props'))" />
59 <Error Condition="!Exists('..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props'))" /> 57 <Error Condition="!Exists('..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props'))" />
60 </Target> 58 </Target>
61</Project> 59</Project> \ No newline at end of file
diff --git a/src/be/utilsearch.cpp b/src/be/utilsearch.cpp
new file mode 100644
index 00000000..4e9d86a1
--- /dev/null
+++ b/src/be/utilsearch.cpp
@@ -0,0 +1,137 @@
1// 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
3#include "precomp.h"
4
5
6STDMETHODIMP UtilSearchParseFromXml(
7 __in UTIL_SEARCHES* pSearches,
8 __in IXMLDOMNode* pixnBundleExtension
9 )
10{
11 HRESULT hr = S_OK;
12 IXMLDOMNodeList* pixnNodes = NULL;
13 IXMLDOMNode* pixnNode = NULL;
14 DWORD cNodes = 0;
15 BSTR bstrNodeName = NULL;
16
17 // Select Util search nodes.
18 hr = XmlSelectNodes(pixnBundleExtension, L"WixDetectSHA2Support", &pixnNodes);
19 ExitOnFailure(hr, "Failed to select Util search nodes.");
20
21 // Get Util search node count.
22 hr = pixnNodes->get_length((long*)&cNodes);
23 ExitOnFailure(hr, "Failed to get Util search node count.");
24
25 if (!cNodes)
26 {
27 ExitFunction();
28 }
29
30 // Allocate memory for searches.
31 pSearches->rgSearches = (UTIL_SEARCH*)MemAlloc(sizeof(UTIL_SEARCH) * cNodes, TRUE);
32 ExitOnNull(pSearches->rgSearches, hr, E_OUTOFMEMORY, "Failed to allocate memory for search structs.");
33
34 pSearches->cSearches = cNodes;
35
36 // Parse search elements.
37 for (DWORD i = 0; i < cNodes; ++i)
38 {
39 UTIL_SEARCH* pSearch = &pSearches->rgSearches[i];
40
41 hr = XmlNextElement(pixnNodes, &pixnNode, &bstrNodeName);
42 ExitOnFailure(hr, "Failed to get next node.");
43
44 // @Id
45 hr = XmlGetAttributeEx(pixnNode, L"Id", &pSearch->sczId);
46 ExitOnFailure(hr, "Failed to get @Id.");
47
48 // Read type specific attributes.
49 if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"WixDetectSHA2Support", -1))
50 {
51 pSearch->Type = UTIL_SEARCH_TYPE_DETECT_SHA2_SUPPORT;
52 }
53 else
54 {
55 hr = E_UNEXPECTED;
56 ExitOnFailure(hr, "Unexpected element name: %ls", bstrNodeName);
57 }
58
59 // prepare next iteration
60 ReleaseNullObject(pixnNode);
61 ReleaseNullBSTR(bstrNodeName);
62 }
63
64LExit:
65 ReleaseBSTR(bstrNodeName);
66 ReleaseObject(pixnNode);
67 ReleaseObject(pixnNodes);
68
69 return hr;
70}
71
72void UtilSearchUninitialize(
73 __in UTIL_SEARCHES* pSearches
74 )
75{
76 if (pSearches->rgSearches)
77 {
78 for (DWORD i = 0; i < pSearches->cSearches; ++i)
79 {
80 UTIL_SEARCH* pSearch = &pSearches->rgSearches[i];
81
82 ReleaseStr(pSearch->sczId);
83 }
84 MemFree(pSearches->rgSearches);
85 }
86}
87
88STDMETHODIMP UtilSearchExecute(
89 __in UTIL_SEARCHES* pSearches,
90 __in LPCWSTR wzSearchId,
91 __in LPCWSTR wzVariable,
92 __in IBundleExtensionEngine* pEngine
93 )
94{
95 HRESULT hr = S_OK;
96 UTIL_SEARCH* pSearch = NULL;
97
98 hr = UtilSearchFindById(pSearches, wzSearchId, &pSearch);
99 ExitOnFailure(hr, "Search id '%ls' is unknown to the util extension.");
100
101 switch (pSearch->Type)
102 {
103 case UTIL_SEARCH_TYPE_DETECT_SHA2_SUPPORT:
104 hr = UtilPerformDetectSHA2Support(wzVariable, pSearch, pEngine);
105 break;
106 default:
107 hr = E_UNEXPECTED;
108 }
109
110LExit:
111 return hr;
112}
113
114STDMETHODIMP UtilSearchFindById(
115 __in UTIL_SEARCHES* pSearches,
116 __in LPCWSTR wzId,
117 __out UTIL_SEARCH** ppSearch
118 )
119{
120 HRESULT hr = S_OK;
121
122 for (DWORD i = 0; i < pSearches->cSearches; ++i)
123 {
124 UTIL_SEARCH* pSearch = &pSearches->rgSearches[i];
125
126 if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, pSearch->sczId, -1, wzId, -1))
127 {
128 *ppSearch = pSearch;
129 ExitFunction1(hr = S_OK);
130 }
131 }
132
133 hr = E_NOTFOUND;
134
135LExit:
136 return hr;
137}
diff --git a/src/be/utilsearch.h b/src/be/utilsearch.h
new file mode 100644
index 00000000..1e0ca96d
--- /dev/null
+++ b/src/be/utilsearch.h
@@ -0,0 +1,52 @@
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.
3
4
5// constants
6
7enum UTIL_SEARCH_TYPE
8{
9 UTIL_SEARCH_TYPE_NONE,
10 UTIL_SEARCH_TYPE_DETECT_SHA2_SUPPORT,
11};
12
13
14// structs
15
16typedef struct _UTIL_SEARCH
17{
18 LPWSTR sczId;
19
20 UTIL_SEARCH_TYPE Type;
21} UTIL_SEARCH;
22
23typedef struct _UTIL_SEARCHES
24{
25 UTIL_SEARCH* rgSearches;
26 DWORD cSearches;
27} UTIL_SEARCHES;
28
29
30// function declarations
31
32STDMETHODIMP UtilSearchParseFromXml(
33 __in UTIL_SEARCHES* pSearches,
34 __in IXMLDOMNode* pixnBundleExtension
35 );
36
37void UtilSearchUninitialize(
38 __in UTIL_SEARCHES* pSearches
39 );
40
41STDMETHODIMP UtilSearchExecute(
42 __in UTIL_SEARCHES* pSearches,
43 __in LPCWSTR wzSearchId,
44 __in LPCWSTR wzVariable,
45 __in IBundleExtensionEngine* pEngine
46 );
47
48STDMETHODIMP UtilSearchFindById(
49 __in UTIL_SEARCHES* pSearches,
50 __in LPCWSTR wzId,
51 __out UTIL_SEARCH** ppSearch
52 );