aboutsummaryrefslogtreecommitdiff
path: root/src/ext/NetFx/be/NetfxBootstrapperExtension.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ext/NetFx/be/NetfxBootstrapperExtension.cpp')
-rw-r--r--src/ext/NetFx/be/NetfxBootstrapperExtension.cpp102
1 files changed, 102 insertions, 0 deletions
diff --git a/src/ext/NetFx/be/NetfxBootstrapperExtension.cpp b/src/ext/NetFx/be/NetfxBootstrapperExtension.cpp
new file mode 100644
index 00000000..ab30e378
--- /dev/null
+++ b/src/ext/NetFx/be/NetfxBootstrapperExtension.cpp
@@ -0,0 +1,102 @@
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 "BextBaseBootstrapperExtension.h"
5
6class CWixNetfxBootstrapperExtension : public CBextBaseBootstrapperExtension
7{
8public: // IBootstrapperExtension
9 virtual STDMETHODIMP Search(
10 __in LPCWSTR wzId,
11 __in LPCWSTR wzVariable
12 )
13 {
14 HRESULT hr = S_OK;
15
16 hr = NetfxSearchExecute(&m_searches, wzId, wzVariable, m_pEngine, m_sczBaseDirectory);
17
18 return hr;
19 }
20
21public: //CBextBaseBootstrapperExtension
22 virtual STDMETHODIMP Initialize(
23 __in const BOOTSTRAPPER_EXTENSION_CREATE_ARGS* pCreateArgs
24 )
25 {
26 HRESULT hr = S_OK;
27 LPWSTR sczModulePath = NULL;
28 IXMLDOMDocument* pixdManifest = NULL;
29 IXMLDOMNode* pixnBootstrapperExtension = NULL;
30
31 hr = __super::Initialize(pCreateArgs);
32 BextExitOnFailure(hr, "CBextBaseBootstrapperExtension initialization failed.");
33
34 hr = PathForCurrentProcess(&sczModulePath, m_hInstance);
35 BextExitOnFailure(hr, "Failed to get bundle extension path.");
36
37 hr = PathGetDirectory(sczModulePath, &m_sczBaseDirectory);
38 BextExitOnFailure(hr, "Failed to get bundle extension base directory.");
39
40 hr = XmlLoadDocumentFromFile(m_sczBootstrapperExtensionDataPath, &pixdManifest);
41 BextExitOnFailure(hr, "Failed to load bundle extension manifest from path: %ls", m_sczBootstrapperExtensionDataPath);
42
43 hr = BextGetBootstrapperExtensionDataNode(pixdManifest, NETFX_BOOTSTRAPPER_EXTENSION_ID, &pixnBootstrapperExtension);
44 BextExitOnFailure(hr, "Failed to get BootstrapperExtension '%ls'", NETFX_BOOTSTRAPPER_EXTENSION_ID);
45
46 hr = NetfxSearchParseFromXml(&m_searches, pixnBootstrapperExtension);
47 BextExitOnFailure(hr, "Failed to parse searches from bundle extension manifest.");
48
49 LExit:
50 ReleaseObject(pixnBootstrapperExtension);
51 ReleaseObject(pixdManifest);
52 ReleaseStr(sczModulePath);
53
54 return hr;
55 }
56
57public:
58 CWixNetfxBootstrapperExtension(
59 __in HINSTANCE hInstance,
60 __in IBootstrapperExtensionEngine* pEngine
61 ) : CBextBaseBootstrapperExtension(pEngine)
62 {
63 m_searches = { };
64 m_hInstance = hInstance;
65 m_sczBaseDirectory = NULL;
66 }
67
68 ~CWixNetfxBootstrapperExtension()
69 {
70 NetfxSearchUninitialize(&m_searches);
71 ReleaseStr(m_sczBaseDirectory);
72 }
73
74private:
75 NETFX_SEARCHES m_searches;
76 HINSTANCE m_hInstance;
77 LPWSTR m_sczBaseDirectory;
78};
79
80HRESULT NetfxBootstrapperExtensionCreate(
81 __in HINSTANCE hInstance,
82 __in IBootstrapperExtensionEngine* pEngine,
83 __in const BOOTSTRAPPER_EXTENSION_CREATE_ARGS* pArgs,
84 __out IBootstrapperExtension** ppBootstrapperExtension
85 )
86{
87 HRESULT hr = S_OK;
88 CWixNetfxBootstrapperExtension* pExtension = NULL;
89
90 pExtension = new CWixNetfxBootstrapperExtension(hInstance, pEngine);
91 BextExitOnNull(pExtension, hr, E_OUTOFMEMORY, "Failed to create new CWixNetfxBootstrapperExtension.");
92
93 hr = pExtension->Initialize(pArgs);
94 BextExitOnFailure(hr, "CWixNetfxBootstrapperExtension initialization failed.");
95
96 *ppBootstrapperExtension = pExtension;
97 pExtension = NULL;
98
99LExit:
100 ReleaseObject(pExtension);
101 return hr;
102}