main
cpp 94 lines 2.36 KB
Raw
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 "BalBaseBAFunctions.h"
5 #include "BalBaseBAFunctionsProc.h"
6
7 class CPrereqBaf : public CBalBaseBAFunctions
8 {
9 public: // IBAFunctions
10
11 public: //IBootstrapperApplication
12 virtual STDMETHODIMP OnCreate(
13 __in IBootstrapperEngine* pEngine,
14 __in BOOTSTRAPPER_COMMAND* pCommand
15 )
16 {
17 HRESULT hr = S_OK;
18
19 hr = __super::OnCreate(pEngine, pCommand);
20 ExitOnFailure(hr, "CPrereqBaf initialization failed.");
21
22 hr = StrAllocString(&m_sczBARuntimeDirectory, pCommand->wzBootstrapperWorkingFolder, 0);
23 ExitOnFailure(hr, "Failed to copy working folder");
24
25 LExit:
26 return hr;
27 }
28
29 virtual STDMETHODIMP OnDetectBegin(
30 __in BOOL /*fCached*/,
31 __in BOOTSTRAPPER_REGISTRATION_TYPE /*registrationType*/,
32 __in DWORD /*cPackages*/,
33 __inout BOOL* /*pfCancel*/
34 )
35 {
36 HRESULT hr = S_OK;
37
38 hr = m_pEngine->SetVariableString(L"BARuntimeDirectory", m_sczBARuntimeDirectory, FALSE);
39 ExitOnFailure(hr, "Failed to set BARuntimeDirectory");
40
41 LExit:
42 return hr;
43 }
44
45 private:
46
47 public:
48 //
49 // Constructor - initialize member variables.
50 //
51 CPrereqBaf(
52 __in HMODULE hModule
53 ) : CBalBaseBAFunctions(hModule)
54 {
55 m_sczBARuntimeDirectory = NULL;
56 }
57
58 //
59 // Destructor - release member variables.
60 //
61 ~CPrereqBaf()
62 {
63 ReleaseNullStr(m_sczBARuntimeDirectory);
64 }
65
66 private:
67 LPWSTR m_sczBARuntimeDirectory;
68 };
69
70
71 HRESULT WINAPI CreateBAFunctions(
72 __in HMODULE hModule,
73 __in const BA_FUNCTIONS_CREATE_ARGS* pArgs,
74 __inout BA_FUNCTIONS_CREATE_RESULTS* pResults
75 )
76 {
77 HRESULT hr = S_OK;
78 CPrereqBaf* pBAFunctions = NULL;
79
80 pBAFunctions = new CPrereqBaf(hModule);
81 ExitOnNull(pBAFunctions, hr, E_OUTOFMEMORY, "Failed to create new CPrereqBaf object.");
82
83 hr = pBAFunctions->OnCreate(pArgs->pEngine, pArgs->pCommand);
84 ExitOnFailure(hr, "Failed to call OnCreate CPrereqBaf.");
85
86 pResults->pfnBAFunctionsProc = BalBaseBAFunctionsProc;
87 pResults->pvBAFunctionsProcContext = pBAFunctions;
88 pBAFunctions = NULL;
89
90 LExit:
91 ReleaseObject(pBAFunctions);
92
93 return hr;
94 }