diff options
Diffstat (limited to 'src/api/burn/bextutil/inc/BextBaseBootstrapperExtension.h')
-rw-r--r-- | src/api/burn/bextutil/inc/BextBaseBootstrapperExtension.h | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/src/api/burn/bextutil/inc/BextBaseBootstrapperExtension.h b/src/api/burn/bextutil/inc/BextBaseBootstrapperExtension.h new file mode 100644 index 00000000..83ba23a6 --- /dev/null +++ b/src/api/burn/bextutil/inc/BextBaseBootstrapperExtension.h | |||
@@ -0,0 +1,115 @@ | |||
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 <windows.h> | ||
4 | |||
5 | #include "bextutil.h" | ||
6 | |||
7 | class CBextBaseBootstrapperExtension : public IBootstrapperExtension | ||
8 | { | ||
9 | public: // IUnknown | ||
10 | virtual STDMETHODIMP QueryInterface( | ||
11 | __in REFIID riid, | ||
12 | __out LPVOID *ppvObject | ||
13 | ) | ||
14 | { | ||
15 | if (!ppvObject) | ||
16 | { | ||
17 | return E_INVALIDARG; | ||
18 | } | ||
19 | |||
20 | *ppvObject = NULL; | ||
21 | |||
22 | if (::IsEqualIID(__uuidof(IBootstrapperExtension), riid)) | ||
23 | { | ||
24 | *ppvObject = static_cast<IBootstrapperExtension*>(this); | ||
25 | } | ||
26 | else if (::IsEqualIID(IID_IUnknown, riid)) | ||
27 | { | ||
28 | *ppvObject = static_cast<IUnknown*>(this); | ||
29 | } | ||
30 | else // no interface for requested iid | ||
31 | { | ||
32 | return E_NOINTERFACE; | ||
33 | } | ||
34 | |||
35 | AddRef(); | ||
36 | return S_OK; | ||
37 | } | ||
38 | |||
39 | virtual STDMETHODIMP_(ULONG) AddRef() | ||
40 | { | ||
41 | return ::InterlockedIncrement(&this->m_cReferences); | ||
42 | } | ||
43 | |||
44 | virtual STDMETHODIMP_(ULONG) Release() | ||
45 | { | ||
46 | long l = ::InterlockedDecrement(&this->m_cReferences); | ||
47 | if (0 < l) | ||
48 | { | ||
49 | return l; | ||
50 | } | ||
51 | |||
52 | delete this; | ||
53 | return 0; | ||
54 | } | ||
55 | |||
56 | public: // IBootstrapperExtension | ||
57 | virtual STDMETHODIMP Search( | ||
58 | __in LPCWSTR /*wzId*/, | ||
59 | __in LPCWSTR /*wzVariable*/ | ||
60 | ) | ||
61 | { | ||
62 | return E_NOTIMPL; | ||
63 | } | ||
64 | |||
65 | virtual STDMETHODIMP BootstrapperExtensionProc( | ||
66 | __in BOOTSTRAPPER_EXTENSION_MESSAGE /*message*/, | ||
67 | __in const LPVOID /*pvArgs*/, | ||
68 | __inout LPVOID /*pvResults*/, | ||
69 | __in_opt LPVOID /*pvContext*/ | ||
70 | ) | ||
71 | { | ||
72 | return E_NOTIMPL; | ||
73 | } | ||
74 | |||
75 | public: //CBextBaseBootstrapperExtension | ||
76 | virtual STDMETHODIMP Initialize( | ||
77 | __in const BOOTSTRAPPER_EXTENSION_CREATE_ARGS* pCreateArgs | ||
78 | ) | ||
79 | { | ||
80 | HRESULT hr = S_OK; | ||
81 | |||
82 | hr = StrAllocString(&m_sczBootstrapperExtensionDataPath, pCreateArgs->wzBootstrapperExtensionDataPath, 0); | ||
83 | ExitOnFailure(hr, "Failed to copy BootstrapperExtensionDataPath."); | ||
84 | |||
85 | LExit: | ||
86 | return hr; | ||
87 | } | ||
88 | |||
89 | protected: | ||
90 | |||
91 | CBextBaseBootstrapperExtension( | ||
92 | __in IBootstrapperExtensionEngine* pEngine | ||
93 | ) | ||
94 | { | ||
95 | m_cReferences = 1; | ||
96 | |||
97 | pEngine->AddRef(); | ||
98 | m_pEngine = pEngine; | ||
99 | |||
100 | m_sczBootstrapperExtensionDataPath = NULL; | ||
101 | } | ||
102 | |||
103 | virtual ~CBextBaseBootstrapperExtension() | ||
104 | { | ||
105 | ReleaseNullObject(m_pEngine); | ||
106 | ReleaseStr(m_sczBootstrapperExtensionDataPath); | ||
107 | } | ||
108 | |||
109 | protected: | ||
110 | IBootstrapperExtensionEngine* m_pEngine; | ||
111 | LPWSTR m_sczBootstrapperExtensionDataPath; | ||
112 | |||
113 | private: | ||
114 | long m_cReferences; | ||
115 | }; | ||