From d694ea725efa855edfca0863cf462b1c0f26c156 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sat, 2 Feb 2019 15:13:20 -0600 Subject: Import code from old v4 repo --- src/wixext/DifxAppCompiler.cs | 148 ++++++++++++++++++++++++++++++++++ src/wixext/DifxAppDecompiler.cs | 96 ++++++++++++++++++++++ src/wixext/DifxAppExtensionData.cs | 43 ++++++++++ src/wixext/WixDifxAppExtension.csproj | 47 +++++++++++ src/wixext/difxapp.xsd | 108 +++++++++++++++++++++++++ src/wixext/tables.xml | 14 ++++ src/wixlib/DIFxAppExtension.wixproj | 30 +++++++ src/wixlib/DIFxAppExtension.wxs | 21 +++++ src/wixlib/x64/DIFxApp.dll | Bin 0 -> 153080 bytes src/wixlib/x64/DIFxAppA.dll | Bin 0 -> 707464 bytes src/wixlib/x86/DIFxApp.dll | Bin 0 -> 122248 bytes src/wixlib/x86/DIFxAppA.dll | Bin 0 -> 364424 bytes 12 files changed, 507 insertions(+) create mode 100644 src/wixext/DifxAppCompiler.cs create mode 100644 src/wixext/DifxAppDecompiler.cs create mode 100644 src/wixext/DifxAppExtensionData.cs create mode 100644 src/wixext/WixDifxAppExtension.csproj create mode 100644 src/wixext/difxapp.xsd create mode 100644 src/wixext/tables.xml create mode 100644 src/wixlib/DIFxAppExtension.wixproj create mode 100644 src/wixlib/DIFxAppExtension.wxs create mode 100644 src/wixlib/x64/DIFxApp.dll create mode 100644 src/wixlib/x64/DIFxAppA.dll create mode 100644 src/wixlib/x86/DIFxApp.dll create mode 100644 src/wixlib/x86/DIFxAppA.dll diff --git a/src/wixext/DifxAppCompiler.cs b/src/wixext/DifxAppCompiler.cs new file mode 100644 index 00000000..63396932 --- /dev/null +++ b/src/wixext/DifxAppCompiler.cs @@ -0,0 +1,148 @@ +// 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. + +namespace WixToolset.Extensions +{ + using System; + using System.Collections.Generic; + using System.Xml.Linq; + using WixToolset.Data; + using WixToolset.Extensibility; + + /// + /// The compiler for the WiX Toolset Driver Install Frameworks for Applications Extension. + /// + public sealed class DifxAppCompiler : CompilerExtension + { + private HashSet components; + + /// + /// Instantiate a new DifxAppCompiler. + /// + public DifxAppCompiler() + { + this.Namespace = "http://wixtoolset.org/schemas/v4/wxs/difxapp"; + this.components = new HashSet(); + } + + /// + /// Processes an element for the Compiler. + /// + /// Source line number for the parent element. + /// Parent element of element to process. + /// Element to process. + /// Extra information about the context in which this element is being parsed. + public override void ParseElement(XElement parentElement, XElement element, IDictionary context) + { + switch (parentElement.Name.LocalName) + { + case "Component": + string componentId = context["ComponentId"]; + string directoryId = context["DirectoryId"]; + + switch (element.Name.LocalName) + { + case "Driver": + this.ParseDriverElement(element, componentId); + break; + default: + this.Core.UnexpectedElement(parentElement, element); + break; + } + break; + default: + this.Core.UnexpectedElement(parentElement, element); + break; + } + } + + /// + /// Parses a Driver element. + /// + /// Element to parse. + /// Identifier for parent component. + private void ParseDriverElement(XElement node, string componentId) + { + SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + int attributes = 0; + int sequence = CompilerConstants.IntegerNotSet; + + // check the number of times a Driver element has been nested under this Component element + if (null != componentId) + { + if (this.components.Contains(componentId)) + { + this.Core.OnMessage(WixErrors.TooManyElements(sourceLineNumbers, "Component", node.Name.LocalName, 1)); + } + else + { + this.components.Add(componentId); + } + } + + foreach (XAttribute attrib in node.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "AddRemovePrograms": + if (YesNoType.No == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= 0x4; + } + break; + case "DeleteFiles": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= 0x10; + } + break; + case "ForceInstall": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= 0x1; + } + break; + case "Legacy": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= 0x8; + } + break; + case "PlugAndPlayPrompt": + if (YesNoType.No == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= 0x2; + } + break; + case "Sequence": + sequence = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, int.MaxValue); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; + } + } + else + { + this.Core.ParseExtensionAttribute(node, attrib); + } + } + + this.Core.ParseForExtensionElements(node); + + if (!this.Core.EncounteredError) + { + Row row = this.Core.CreateRow(sourceLineNumbers, "MsiDriverPackages"); + row[0] = componentId; + row[1] = attributes; + if (CompilerConstants.IntegerNotSet != sequence) + { + row[2] = sequence; + } + + this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "MsiProcessDrivers"); + } + } + } +} diff --git a/src/wixext/DifxAppDecompiler.cs b/src/wixext/DifxAppDecompiler.cs new file mode 100644 index 00000000..db42b3d0 --- /dev/null +++ b/src/wixext/DifxAppDecompiler.cs @@ -0,0 +1,96 @@ +// 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. + +namespace WixToolset.Extensions +{ + using System; + using System.Collections; + using System.Globalization; + using WixToolset.Data; + using WixToolset.Extensibility; + using DifxApp = WixToolset.Extensions.Serialize.DifxApp; + using Wix = WixToolset.Data.Serialize; + + /// + /// The decompiler for the WiX Toolset Driver Install Frameworks for Applications Extension. + /// + public sealed class DifxAppDecompiler : DecompilerExtension + { + /// + /// Creates a decompiler for Gaming Extension. + /// + public DifxAppDecompiler() + { + this.TableDefinitions = DifxAppExtensionData.GetExtensionTableDefinitions(); + } + + /// + /// Decompiles an extension table. + /// + /// The table to decompile. + public override void DecompileTable(Table table) + { + switch (table.Name) + { + case "MsiDriverPackages": + this.DecompileMsiDriverPackagesTable(table); + break; + default: + base.DecompileTable(table); + break; + } + } + + /// + /// Decompile the MsiDriverPackages table. + /// + /// The table to decompile. + private void DecompileMsiDriverPackagesTable(Table table) + { + foreach (Row row in table.Rows) + { + DifxApp.Driver driver = new DifxApp.Driver(); + + int attributes = (int)row[1]; + if (0x1 == (attributes & 0x1)) + { + driver.ForceInstall = DifxApp.YesNoType.yes; + } + + if (0x2 == (attributes & 0x2)) + { + driver.PlugAndPlayPrompt = DifxApp.YesNoType.no; + } + + if (0x4 == (attributes & 0x4)) + { + driver.AddRemovePrograms = DifxApp.YesNoType.no; + } + + if (0x8 == (attributes & 0x8)) + { + driver.Legacy = DifxApp.YesNoType.yes; + } + + if (0x10 == (attributes & 0x10)) + { + driver.DeleteFiles = DifxApp.YesNoType.yes; + } + + if (null != row[2]) + { + driver.Sequence = (int)row[2]; + } + + Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[0]); + if (null != component) + { + component.AddChild(driver); + } + else + { + this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component", (string)row[0], "Component")); + } + } + } + } +} diff --git a/src/wixext/DifxAppExtensionData.cs b/src/wixext/DifxAppExtensionData.cs new file mode 100644 index 00000000..266f5ee4 --- /dev/null +++ b/src/wixext/DifxAppExtensionData.cs @@ -0,0 +1,43 @@ +// 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. + +namespace WixToolset.Extensions +{ + using System; + using System.Reflection; + using WixToolset.Data; + using WixToolset.Extensibility; + + /// + /// The WiX Toolset Driver Install Frameworks for Applications Extension. + /// + public sealed class DifxAppExtensionData : ExtensionData + { + private static TableDefinitionCollection tableDefinitions; + + /// + /// Gets the optional table definitions for this extension. + /// + /// The optional table definitions for this extension. + public override TableDefinitionCollection TableDefinitions + { + get + { + return DifxAppExtensionData.GetExtensionTableDefinitions(); + } + } + + /// + /// Internal mechanism to access the extension's table definitions. + /// + /// Extension's table definitions. + internal static TableDefinitionCollection GetExtensionTableDefinitions() + { + if (null == DifxAppExtensionData.tableDefinitions) + { + DifxAppExtensionData.tableDefinitions = ExtensionData.LoadTableDefinitionHelper(Assembly.GetExecutingAssembly(), "WixToolset.Extensions.Data.tables.xml"); + } + + return DifxAppExtensionData.tableDefinitions; + } + } +} diff --git a/src/wixext/WixDifxAppExtension.csproj b/src/wixext/WixDifxAppExtension.csproj new file mode 100644 index 00000000..5e85c675 --- /dev/null +++ b/src/wixext/WixDifxAppExtension.csproj @@ -0,0 +1,47 @@ + + + + + + + {2256EFD7-E678-4485-818D-986D590068BE} + WixDifxAppExtension + Library + WixToolset.Extensions + + + + + + + + $(RootNamespace).Data.tables.xml + + + $(RootNamespace).Xsd.difxapp.xsd + PreserveNewest + + + Designer + WixToolset.Data.Serialize + WixToolset.Extensions.Serialize.DifxApp + + + + + + + + + + + Platform=x86 + false + + + Platform=x64 + false + + + + diff --git a/src/wixext/difxapp.xsd b/src/wixext/difxapp.xsd new file mode 100644 index 00000000..e665d034 --- /dev/null +++ b/src/wixext/difxapp.xsd @@ -0,0 +1,108 @@ + + + + + + + + The source code schema for the WiX Toolset Driver Install Frameworks for Applications Extension. + + + + + + + + + + + + Installs a driver. To use this element, you need to reference the WixDifxAppExtension extension and add the + .wixlib appropriate for the target platform (difxapp_x86.wixlib or difxapp_x64.wixlib) + to your project. + + + + + + + Specifies that the DIFxApp CustomActions should add an entry in the Add/Remove Programs Control + Panel applet. The default is 'yes'. + + + + + + + If set to "yes", configures DIFxApp to delete binary files that were copied to the system from the driver + store when a driver package was installed. If this attribute is set to "no" or not present, DIFxApp does not + remove these files from a system. Note that configuring DIFxApp to delete these files is controlled by the + Flags entry value of the component that represents the driver package in the MsiDriverPackages custom table. + Setting DeleteFiles to "yes" sets the corresponding bit in the Flags entry value. Setting DeleteFiles to "no" + clears the corresponding bit in the Flags entry value. If this attribute is not present, DIFxApp uses a + default value of "no". + + + + + + + Specifies that the DIFxApp CustomActions should force the installation of a new Plug and Play driver + on a device, even if the currently installed driver on the device is a better match than the new driver. + Specifying 'no' is an excellent way to ensure the DIFxApp CustomActions recognize the Component contains + a driver for installation. The default is null which means the Component does not install a driver via + DIFxApp CustomActions. See http://www.microsoft.com/whdc/driver/install/difxtools.mspx + for more information. + + + + + + + If set to "yes", configures DIFxApp to install unsigned driver packages and driver packages with missing + files. For more information, see "Installing Unsigned Driver Packages in Legacy Mode" earlier in this paper. + If this attribute is set to "no" or not present, DIFxApp will install only signed driver packages. Note + that configuring DIFxApp to install unsigned drivers is controlled by the Flags entry value of the component + that represents the driver package in the MsiDriverPackages custom table. Setting Legacy to "yes" sets + the corresponding bit in the Flags entry value. Setting Legacy to "no" clears the bit in the Flags + entry value that configures DIFxApp to install unsigned driver packages. If this attribute is not present, + DIFxApp uses a default value of "no". + + + + + + + Specifies that the DIFxApp CustomActions should prompt the user to connect the Plug and Play + device if it is not connected. The default is 'yes'. + + + + + + + Specifies an optional installation sequence number. DIFxApp CustomActions install the driver packages in + an installation package in the order of increasing sequence numbers. The same sequence number can be used + for more than one driver; however, the order in which packages with the same sequence number are actually + installed cannot be determined. + + + + + + + + + Values of this type will either be "yes" or "no". + + + + + + + diff --git a/src/wixext/tables.xml b/src/wixext/tables.xml new file mode 100644 index 00000000..c328f875 --- /dev/null +++ b/src/wixext/tables.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + diff --git a/src/wixlib/DIFxAppExtension.wixproj b/src/wixlib/DIFxAppExtension.wixproj new file mode 100644 index 00000000..f4a7eb74 --- /dev/null +++ b/src/wixlib/DIFxAppExtension.wixproj @@ -0,0 +1,30 @@ + + + + + + + {5066EB93-D8F7-4FAE-B687-024D7A81BD95} + difxapp_$(Platform) + Library + true + true + en-us + + + + + + + $(DefineConstants); + DIFxAppDll=$(ProjectDir)$(Platform)\DIFxApp.dll; + DIFxAppADll=$(ProjectDir)$(Platform)\DIFxAppA.dll; + + + + + + + + + diff --git a/src/wixlib/DIFxAppExtension.wxs b/src/wixlib/DIFxAppExtension.wxs new file mode 100644 index 00000000..44b0ce2c --- /dev/null +++ b/src/wixlib/DIFxAppExtension.wxs @@ -0,0 +1,21 @@ + + + + + + + + VersionNT > 400 + VersionNT > 400 + + + + + + + + + + + + diff --git a/src/wixlib/x64/DIFxApp.dll b/src/wixlib/x64/DIFxApp.dll new file mode 100644 index 00000000..69a44cc8 Binary files /dev/null and b/src/wixlib/x64/DIFxApp.dll differ diff --git a/src/wixlib/x64/DIFxAppA.dll b/src/wixlib/x64/DIFxAppA.dll new file mode 100644 index 00000000..99458040 Binary files /dev/null and b/src/wixlib/x64/DIFxAppA.dll differ diff --git a/src/wixlib/x86/DIFxApp.dll b/src/wixlib/x86/DIFxApp.dll new file mode 100644 index 00000000..678a9d95 Binary files /dev/null and b/src/wixlib/x86/DIFxApp.dll differ diff --git a/src/wixlib/x86/DIFxAppA.dll b/src/wixlib/x86/DIFxAppA.dll new file mode 100644 index 00000000..3ac0838d Binary files /dev/null and b/src/wixlib/x86/DIFxAppA.dll differ -- cgit v1.2.3-55-g6feb