aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Mba.Core
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2019-12-22 10:31:33 +1100
committerSean Hall <r.sean.hall@gmail.com>2019-12-22 13:19:29 +1000
commit24379873f589cff33965f1104041f61c0c4503e0 (patch)
treeb50fb0270d2de706cb6f3a4dea0af77ce2cae9e1 /src/WixToolset.Mba.Core
parentf3c383c2412e376353d64a8b744184fa1cee1c6e (diff)
downloadwix-24379873f589cff33965f1104041f61c0c4503e0.tar.gz
wix-24379873f589cff33965f1104041f61c0c4503e0.tar.bz2
wix-24379873f589cff33965f1104041f61c0c4503e0.zip
Move the responsibility of wrapping the binary interfaces from mbahost to the new mbanative dll of WixToolset.Mba.Core.
Diffstat (limited to 'src/WixToolset.Mba.Core')
-rw-r--r--src/WixToolset.Mba.Core/BalUtil.cs22
-rw-r--r--src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs28
-rw-r--r--src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs14
-rw-r--r--src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs28
-rw-r--r--src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj1
-rw-r--r--src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec4
-rw-r--r--src/WixToolset.Mba.Core/build/net20/WixToolset.Mba.Core.props11
7 files changed, 92 insertions, 16 deletions
diff --git a/src/WixToolset.Mba.Core/BalUtil.cs b/src/WixToolset.Mba.Core/BalUtil.cs
new file mode 100644
index 00000000..f478eca4
--- /dev/null
+++ b/src/WixToolset.Mba.Core/BalUtil.cs
@@ -0,0 +1,22 @@
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
3namespace WixToolset.Mba.Core
4{
5 using System;
6 using System.Runtime.InteropServices;
7
8 internal static class BalUtil
9 {
10 [DllImport("mbanative.dll", ExactSpelling = true, PreserveSig = false)]
11 internal static extern IBootstrapperEngine InitializeFromCreateArgs(
12 IntPtr pArgs,
13 ref Command pCommand
14 );
15
16 [DllImport("mbanative.dll", ExactSpelling = true)]
17 internal static extern void StoreBAInCreateResults(
18 IntPtr pResults,
19 [MarshalAs(UnmanagedType.Interface)] IBootstrapperApplication pBA
20 );
21 }
22}
diff --git a/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs b/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs
index 20151b71..264733ac 100644
--- a/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs
+++ b/src/WixToolset.Mba.Core/BaseBootstrapperApplicationFactory.cs
@@ -2,15 +2,35 @@
2 2
3namespace WixToolset.Mba.Core 3namespace WixToolset.Mba.Core
4{ 4{
5 using System;
6 using System.Runtime.InteropServices;
7
5 public abstract class BaseBootstrapperApplicationFactory : IBootstrapperApplicationFactory 8 public abstract class BaseBootstrapperApplicationFactory : IBootstrapperApplicationFactory
6 { 9 {
7 public IBootstrapperApplication Create(IBootstrapperEngine pEngine, ref Command command) 10 public void Create(IntPtr pArgs, IntPtr pResults)
8 { 11 {
9 IEngine engine = new Engine(pEngine); 12 InitializeFromCreateArgs(pArgs, out var engine, out var bootstrapperCommand);
10 IBootstrapperCommand bootstrapperCommand = command.GetBootstrapperCommand(); 13
11 return this.Create(engine, bootstrapperCommand); 14 var ba = this.Create(engine, bootstrapperCommand);
15 StoreBAInCreateResults(pResults, ba);
12 } 16 }
13 17
14 protected abstract IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand); 18 protected abstract IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand);
19
20 public static void InitializeFromCreateArgs(IntPtr pArgs, out IEngine engine, out IBootstrapperCommand bootstrapperCommand)
21 {
22 Command pCommand = new Command
23 {
24 cbSize = Marshal.SizeOf(typeof(Command))
25 };
26 var pEngine = BalUtil.InitializeFromCreateArgs(pArgs, ref pCommand);
27 engine = new Engine(pEngine);
28 bootstrapperCommand = pCommand.GetBootstrapperCommand();
29 }
30
31 public static void StoreBAInCreateResults(IntPtr pResults, IBootstrapperApplication ba)
32 {
33 BalUtil.StoreBAInCreateResults(pResults, ba);
34 }
15 } 35 }
16} 36}
diff --git a/src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs b/src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs
index 968c6336..55f0e83b 100644
--- a/src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs
+++ b/src/WixToolset.Mba.Core/BootstrapperApplicationFactory.cs
@@ -8,7 +8,7 @@ namespace WixToolset.Mba.Core
8 using System.Runtime.InteropServices; 8 using System.Runtime.InteropServices;
9 9
10 /// <summary> 10 /// <summary>
11 /// Entry point for the MBA host to create and return the IBootstrapperApplication implementation to the engine. 11 /// Entry point for the MBA host to create and return the BA to the engine.
12 /// </summary> 12 /// </summary>
13 [ClassInterface(ClassInterfaceType.None)] 13 [ClassInterface(ClassInterfaceType.None)]
14 public sealed class BootstrapperApplicationFactory : MarshalByRefObject, IBootstrapperApplicationFactory 14 public sealed class BootstrapperApplicationFactory : MarshalByRefObject, IBootstrapperApplicationFactory
@@ -21,14 +21,13 @@ namespace WixToolset.Mba.Core
21 } 21 }
22 22
23 /// <summary> 23 /// <summary>
24 /// Loads the bootstrapper application assembly and creates an instance of the IBootstrapperApplication. 24 /// Loads the bootstrapper application assembly and calls its IBootstrapperApplicationFactory.Create method.
25 /// </summary> 25 /// </summary>
26 /// <param name="pEngine">IBootstrapperEngine provided for the bootstrapper application.</param> 26 /// <param name="pArgs">Pointer to BOOTSTRAPPER_CREATE_ARGS struct.</param>
27 /// <param name="command">Command line for the bootstrapper application.</param> 27 /// <param name="pResults">Pointer to BOOTSTRAPPER_CREATE_RESULTS struct.</param>
28 /// <returns>Bootstrapper application via <see cref="IBootstrapperApplication"/> interface.</returns>
29 /// <exception cref="MissingAttributeException">The bootstrapper application assembly 28 /// <exception cref="MissingAttributeException">The bootstrapper application assembly
30 /// does not define the <see cref="BootstrapperApplicationFactoryAttribute"/>.</exception> 29 /// does not define the <see cref="BootstrapperApplicationFactoryAttribute"/>.</exception>
31 public IBootstrapperApplication Create(IBootstrapperEngine pEngine, ref Command command) 30 public void Create(IntPtr pArgs, IntPtr pResults)
32 { 31 {
33 // Get the wix.boostrapper section group to get the name of the bootstrapper application assembly to host. 32 // Get the wix.boostrapper section group to get the name of the bootstrapper application assembly to host.
34 var section = ConfigurationManager.GetSection("wix.bootstrapper/host") as HostSection; 33 var section = ConfigurationManager.GetSection("wix.bootstrapper/host") as HostSection;
@@ -45,8 +44,7 @@ namespace WixToolset.Mba.Core
45 throw new InvalidBootstrapperApplicationFactoryException(); 44 throw new InvalidBootstrapperApplicationFactoryException();
46 } 45 }
47 46
48 var ba = baFactory.Create(pEngine, ref command); 47 baFactory.Create(pArgs, pResults);
49 return ba;
50 } 48 }
51 49
52 /// <summary> 50 /// <summary>
diff --git a/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs b/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs
index f5d4c705..700f0888 100644
--- a/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs
+++ b/src/WixToolset.Mba.Core/IBootstrapperApplicationFactory.cs
@@ -12,9 +12,9 @@ namespace WixToolset.Mba.Core
12 [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] 12 [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")]
13 public interface IBootstrapperApplicationFactory 13 public interface IBootstrapperApplicationFactory
14 { 14 {
15 IBootstrapperApplication Create( 15 void Create(
16 [MarshalAs(UnmanagedType.Interface)] IBootstrapperEngine pEngine, 16 IntPtr pArgs,
17 ref Command command 17 IntPtr pResults
18 ); 18 );
19 } 19 }
20 20
@@ -23,6 +23,7 @@ namespace WixToolset.Mba.Core
23 [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] 23 [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")]
24 public struct Command 24 public struct Command
25 { 25 {
26 [MarshalAs(UnmanagedType.I4)] internal int cbSize;
26 [MarshalAs(UnmanagedType.U4)] private readonly LaunchAction action; 27 [MarshalAs(UnmanagedType.U4)] private readonly LaunchAction action;
27 [MarshalAs(UnmanagedType.U4)] private readonly Display display; 28 [MarshalAs(UnmanagedType.U4)] private readonly Display display;
28 [MarshalAs(UnmanagedType.U4)] private readonly Restart restart; 29 [MarshalAs(UnmanagedType.U4)] private readonly Restart restart;
@@ -49,4 +50,25 @@ namespace WixToolset.Mba.Core
49 this.wzLayoutDirectory); 50 this.wzLayoutDirectory);
50 } 51 }
51 } 52 }
53
54 [Serializable]
55 [StructLayout(LayoutKind.Sequential)]
56 [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")]
57 public struct BootstrapperCreateArgs
58 {
59 [MarshalAs(UnmanagedType.I4)] public readonly int cbSize;
60 [MarshalAs(UnmanagedType.I8)] public readonly long qwEngineAPIVersion;
61 public readonly IntPtr pfnBootstrapperEngineProc;
62 public readonly IntPtr pvBootstrapperEngineProcContext;
63 public readonly IntPtr pCommand;
64
65 public BootstrapperCreateArgs(long version, IntPtr pEngineProc, IntPtr pEngineContext, IntPtr pCommand)
66 {
67 this.cbSize = Marshal.SizeOf(typeof(BootstrapperCreateArgs));
68 this.qwEngineAPIVersion = version;
69 this.pfnBootstrapperEngineProc = pEngineProc;
70 this.pvBootstrapperEngineProcContext = pEngineContext;
71 this.pCommand = pCommand;
72 }
73 }
52} 74}
diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj
index 05d042c3..4b14a545 100644
--- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj
+++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.csproj
@@ -23,6 +23,7 @@
23 <DefineConstants>$(DefineConstants);TRACE</DefineConstants> 23 <DefineConstants>$(DefineConstants);TRACE</DefineConstants>
24 </PropertyGroup> 24 </PropertyGroup>
25 <ItemGroup> 25 <ItemGroup>
26 <Compile Include="BalUtil.cs" />
26 <Compile Include="BaseBootstrapperApplicationFactory.cs" /> 27 <Compile Include="BaseBootstrapperApplicationFactory.cs" />
27 <Compile Include="BootstrapperApplication.cs" /> 28 <Compile Include="BootstrapperApplication.cs" />
28 <Compile Include="BootstrapperApplicationData.cs" /> 29 <Compile Include="BootstrapperApplicationData.cs" />
diff --git a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec
index 04eee9ec..bbac204f 100644
--- a/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec
+++ b/src/WixToolset.Mba.Core/WixToolset.Mba.Core.nuspec
@@ -7,7 +7,7 @@
7 <owners>WiX Toolset Team</owners> 7 <owners>WiX Toolset Team</owners>
8 <!-- <license type="expression">MS-RL</license> --> 8 <!-- <license type="expression">MS-RL</license> -->
9 <licenseUrl>https://licenses.nuget.org/MS-RL</licenseUrl> 9 <licenseUrl>https://licenses.nuget.org/MS-RL</licenseUrl>
10 <projectUrl>https://github.com/wixtoolset/BootstrapperCore</projectUrl> 10 <projectUrl>https://github.com/wixtoolset/balutil</projectUrl>
11 <requireLicenseAcceptance>false</requireLicenseAcceptance> 11 <requireLicenseAcceptance>false</requireLicenseAcceptance>
12 <description>$description$</description> 12 <description>$description$</description>
13 <copyright>$copyright$</copyright> 13 <copyright>$copyright$</copyright>
@@ -15,6 +15,8 @@
15 15
16 <files> 16 <files>
17 <file src="..\..\build\$configuration$\$id$.config" target="samples" /> 17 <file src="..\..\build\$configuration$\$id$.config" target="samples" />
18 <file src="build\net20\$id$.props" target="build\net20" />
19 <file src="..\..\build\$configuration$\v141_xp\x86\mbanative.dll" target="build\net20\x86" />
18 <file src="..\..\build\$configuration$\$id$.h" target="build\native\include" /> 20 <file src="..\..\build\$configuration$\$id$.h" target="build\native\include" />
19 <file src="..\..\build\$configuration$\$id$.dll" target="lib\net20" /> 21 <file src="..\..\build\$configuration$\$id$.dll" target="lib\net20" />
20 </files> 22 </files>
diff --git a/src/WixToolset.Mba.Core/build/net20/WixToolset.Mba.Core.props b/src/WixToolset.Mba.Core/build/net20/WixToolset.Mba.Core.props
new file mode 100644
index 00000000..c0018e0d
--- /dev/null
+++ b/src/WixToolset.Mba.Core/build/net20/WixToolset.Mba.Core.props
@@ -0,0 +1,11 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- 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. -->
3
4<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
5 <PropertyGroup>
6 <WixToolsetMbaNativePath Condition=" '$(WixToolsetMbaNativePath)' == '' ">$(MSBuildThisFileDirectory)x86\mbanative.dll</WixToolsetMbaNativePath>
7 </PropertyGroup>
8 <ItemGroup>
9 <Content Include="$(WixToolsetMbaNativePath)" CopyToOutputDirectory="Always" />
10 </ItemGroup>
11</Project>