main
cpp 62 lines 1.66 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 "BextBaseBootstrapperExtensionProc.h"
5
6 static HINSTANCE vhInstance = NULL;
7 static IBootstrapperExtension* vpBootstrapperExtension = NULL;
8
9 // function definitions
10
11 extern "C" BOOL WINAPI DllMain(
12 __in HINSTANCE hInstance,
13 __in DWORD dwReason,
14 __in LPVOID /*pvReserved*/
15 )
16 {
17 switch(dwReason)
18 {
19 case DLL_PROCESS_ATTACH:
20 vhInstance = hInstance;
21 break;
22
23 case DLL_PROCESS_DETACH:
24 vhInstance = NULL;
25 break;
26 }
27
28 return TRUE;
29 }
30
31 extern "C" HRESULT WINAPI BootstrapperExtensionCreate(
32 __in const BOOTSTRAPPER_EXTENSION_CREATE_ARGS* pArgs,
33 __inout BOOTSTRAPPER_EXTENSION_CREATE_RESULTS* pResults
34 )
35 {
36 HRESULT hr = S_OK;
37 IBootstrapperExtensionEngine* pEngine = NULL;
38
39 hr = XmlInitialize();
40 ExitOnFailure(hr, "Failed to initialize XML.");
41
42 hr = BextInitializeFromCreateArgs(pArgs, &pEngine);
43 ExitOnFailure(hr, "Failed to initialize bext");
44
45 hr = NetfxBootstrapperExtensionCreate(vhInstance, pEngine, pArgs, &vpBootstrapperExtension);
46 BextExitOnFailure(hr, "Failed to create WixNetfxBootstrapperExtension");
47
48 pResults->pfnBootstrapperExtensionProc = BextBaseBootstrapperExtensionProc;
49 pResults->pvBootstrapperExtensionProcContext = vpBootstrapperExtension;
50
51 LExit:
52 ReleaseObject(pEngine);
53
54 return hr;
55 }
56
57 extern "C" void WINAPI BootstrapperExtensionDestroy()
58 {
59 BextUninitialize();
60 ReleaseNullObject(vpBootstrapperExtension);
61 XmlUninitialize();
62 }