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