diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ca/directx.cpp | 49 | ||||
| -rw-r--r-- | src/ca/directx.def | 7 | ||||
| -rw-r--r-- | src/ca/directx.vcxproj | 47 | ||||
| -rw-r--r-- | src/ca/dllmain.cpp | 26 | ||||
| -rw-r--r-- | src/ca/precomp.h | 14 | ||||
| -rw-r--r-- | src/wixext/DirectXDecompiler.cs | 70 | ||||
| -rw-r--r-- | src/wixext/DirectXExtensionData.cs | 34 | ||||
| -rw-r--r-- | src/wixext/WixDirectXExtension.csproj | 31 | ||||
| -rw-r--r-- | src/wixlib/DirectXExtension.wixproj | 24 | ||||
| -rw-r--r-- | src/wixlib/DirectXExtension.wxs | 34 |
10 files changed, 336 insertions, 0 deletions
diff --git a/src/ca/directx.cpp b/src/ca/directx.cpp new file mode 100644 index 00000000..21838262 --- /dev/null +++ b/src/ca/directx.cpp | |||
| @@ -0,0 +1,49 @@ | |||
| 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 | |||
| 5 | /******************************************************************** | ||
| 6 | WixQueryDirectXCaps - entry point for WixQueryDirectXCaps CA | ||
| 7 | |||
| 8 | Called as Type 1 custom action (DLL from the Binary table) from | ||
| 9 | Windows Installer to set properties that identify the DirectX | ||
| 10 | capabilities ("caps") of the system. | ||
| 11 | ********************************************************************/ | ||
| 12 | extern "C" UINT __stdcall WixQueryDirectXCaps( | ||
| 13 | __in MSIHANDLE hInstall | ||
| 14 | ) | ||
| 15 | { | ||
| 16 | #if 0 | ||
| 17 | ::MessageBoxA(0, "break into debugger now please", "---->> ATTACH TO ME!", MB_ICONEXCLAMATION); | ||
| 18 | #endif | ||
| 19 | |||
| 20 | HRESULT hr = S_OK; | ||
| 21 | DWORD er = ERROR_SUCCESS; | ||
| 22 | LPDIRECT3D9 pD3D = NULL; | ||
| 23 | |||
| 24 | hr = WcaInitialize(hInstall, "WixQueryDirectXCaps"); | ||
| 25 | ExitOnFailure(hr, "failed to initialize"); | ||
| 26 | |||
| 27 | pD3D = Direct3DCreate9(D3D_SDK_VERSION); | ||
| 28 | ExitOnNull(pD3D, hr, E_FAIL, "Direct3DCreate9 failed"); | ||
| 29 | |||
| 30 | D3DCAPS9 d3dCaps; | ||
| 31 | hr = pD3D->GetDeviceCaps( | ||
| 32 | 0, // first adapter | ||
| 33 | D3DDEVTYPE_HAL, // fail on non-HAL devices | ||
| 34 | &d3dCaps | ||
| 35 | ); | ||
| 36 | ExitOnFailure(hr, "GetDeviceCaps call failed"); | ||
| 37 | |||
| 38 | int iVertexShaderVersion = D3DSHADER_VERSION_MAJOR(d3dCaps.VertexShaderVersion) * 100 + D3DSHADER_VERSION_MINOR(d3dCaps.VertexShaderVersion); | ||
| 39 | WcaSetIntProperty(L"WIX_DIRECTX_VERTEXSHADERVERSION", iVertexShaderVersion); | ||
| 40 | |||
| 41 | int iPixelShaderVersion = D3DSHADER_VERSION_MAJOR(d3dCaps.PixelShaderVersion) * 100 + D3DSHADER_VERSION_MINOR(d3dCaps.PixelShaderVersion); | ||
| 42 | WcaSetIntProperty(L"WIX_DIRECTX_PIXELSHADERVERSION", iPixelShaderVersion); | ||
| 43 | |||
| 44 | LExit: | ||
| 45 | ReleaseObject(pD3D); | ||
| 46 | return WcaFinalize(er = FAILED(hr) ? ERROR_INSTALL_FAILURE : er); | ||
| 47 | } | ||
| 48 | |||
| 49 | |||
diff --git a/src/ca/directx.def b/src/ca/directx.def new file mode 100644 index 00000000..5841db88 --- /dev/null +++ b/src/ca/directx.def | |||
| @@ -0,0 +1,7 @@ | |||
| 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 | |||
| 4 | LIBRARY "directx" | ||
| 5 | |||
| 6 | EXPORTS | ||
| 7 | WixQueryDirectXCaps | ||
diff --git a/src/ca/directx.vcxproj b/src/ca/directx.vcxproj new file mode 100644 index 00000000..e4020bcc --- /dev/null +++ b/src/ca/directx.vcxproj | |||
| @@ -0,0 +1,47 @@ | |||
| 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 | |||
| 5 | <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| 6 | <ItemGroup Label="ProjectConfigurations"> | ||
| 7 | <ProjectConfiguration Include="Debug|Win32"> | ||
| 8 | <Configuration>Debug</Configuration> | ||
| 9 | <Platform>Win32</Platform> | ||
| 10 | </ProjectConfiguration> | ||
| 11 | <ProjectConfiguration Include="Release|Win32"> | ||
| 12 | <Configuration>Release</Configuration> | ||
| 13 | <Platform>Win32</Platform> | ||
| 14 | </ProjectConfiguration> | ||
| 15 | </ItemGroup> | ||
| 16 | |||
| 17 | <PropertyGroup Label="Globals"> | ||
| 18 | <ProjectGuid>{F72D34CA-48DA-4DFD-91A9-A0C78BEF6981}</ProjectGuid> | ||
| 19 | <ConfigurationType>DynamicLibrary</ConfigurationType> | ||
| 20 | <CharacterSet>Unicode</CharacterSet> | ||
| 21 | <TargetName>directx</TargetName> | ||
| 22 | <ProjectModuleDefinitionFile>directx.def</ProjectModuleDefinitionFile> | ||
| 23 | </PropertyGroup> | ||
| 24 | |||
| 25 | <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), wix.proj))\tools\WixBuild.props" /> | ||
| 26 | |||
| 27 | <PropertyGroup> | ||
| 28 | <ProjectAdditionalIncludeDirectories>$(WixRoot)src\libs\dutil\inc;$(WixRoot)src\libs\wcautil</ProjectAdditionalIncludeDirectories> | ||
| 29 | <ProjectAdditionalLinkLibraries>d3d9.lib;msi.lib;dutil.lib;wcautil.lib</ProjectAdditionalLinkLibraries> | ||
| 30 | </PropertyGroup> | ||
| 31 | |||
| 32 | <ItemGroup> | ||
| 33 | <ClCompile Include="directx.cpp" /> | ||
| 34 | <ClCompile Include="dllmain.cpp" /> | ||
| 35 | </ItemGroup> | ||
| 36 | <ItemGroup> | ||
| 37 | <ClInclude Include="precomp.h" /> | ||
| 38 | </ItemGroup> | ||
| 39 | <ItemGroup> | ||
| 40 | <None Include="directx.def" /> | ||
| 41 | </ItemGroup> | ||
| 42 | <ItemGroup> | ||
| 43 | <ResourceCompile Include="directx.rc" /> | ||
| 44 | </ItemGroup> | ||
| 45 | |||
| 46 | <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), wix.proj))\tools\WixBuild.targets" /> | ||
| 47 | </Project> | ||
diff --git a/src/ca/dllmain.cpp b/src/ca/dllmain.cpp new file mode 100644 index 00000000..df53f872 --- /dev/null +++ b/src/ca/dllmain.cpp | |||
| @@ -0,0 +1,26 @@ | |||
| 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 | |||
| 5 | /******************************************************************** | ||
| 6 | DllMain - standard entry point for all WiX CustomActions | ||
| 7 | |||
| 8 | ********************************************************************/ | ||
| 9 | extern "C" BOOL WINAPI DllMain( | ||
| 10 | IN HINSTANCE hInst, | ||
| 11 | IN ULONG ulReason, | ||
| 12 | IN LPVOID) | ||
| 13 | { | ||
| 14 | switch(ulReason) | ||
| 15 | { | ||
| 16 | case DLL_PROCESS_ATTACH: | ||
| 17 | WcaGlobalInitialize(hInst); | ||
| 18 | break; | ||
| 19 | |||
| 20 | case DLL_PROCESS_DETACH: | ||
| 21 | WcaGlobalFinalize(); | ||
| 22 | break; | ||
| 23 | } | ||
| 24 | |||
| 25 | return TRUE; | ||
| 26 | } | ||
diff --git a/src/ca/precomp.h b/src/ca/precomp.h new file mode 100644 index 00000000..8480f2b2 --- /dev/null +++ b/src/ca/precomp.h | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | #pragma once | ||
| 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 | |||
| 5 | #include <windows.h> | ||
| 6 | #include <msidefs.h> | ||
| 7 | #include <msiquery.h> | ||
| 8 | #include <D3D9.h> | ||
| 9 | |||
| 10 | #include "wixstrsafe.h" | ||
| 11 | #include "wcautil.h" | ||
| 12 | #include "strutil.h" | ||
| 13 | |||
| 14 | #include "CustomMsiErrors.h" | ||
diff --git a/src/wixext/DirectXDecompiler.cs b/src/wixext/DirectXDecompiler.cs new file mode 100644 index 00000000..c8056c12 --- /dev/null +++ b/src/wixext/DirectXDecompiler.cs | |||
| @@ -0,0 +1,70 @@ | |||
| 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 | namespace WixToolset.Extensions | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Text; | ||
| 7 | using WixToolset.Data; | ||
| 8 | using WixToolset.Extensibility; | ||
| 9 | using Wix = WixToolset.Data.Serialize; | ||
| 10 | |||
| 11 | /// <summary> | ||
| 12 | /// The WiX Toolset DirectX Extension. | ||
| 13 | /// </summary> | ||
| 14 | public sealed class DirectXDecompiler : DecompilerExtension | ||
| 15 | { | ||
| 16 | /// <summary> | ||
| 17 | /// Get the extensions library to be removed. | ||
| 18 | /// </summary> | ||
| 19 | /// <param name="tableDefinitions">Table definitions for library.</param> | ||
| 20 | /// <returns>Library to remove from decompiled output.</returns> | ||
| 21 | public override Library GetLibraryToRemove(TableDefinitionCollection tableDefinitions) | ||
| 22 | { | ||
| 23 | return DirectXExtensionData.GetExtensionLibrary(tableDefinitions); | ||
| 24 | } | ||
| 25 | |||
| 26 | /// <summary> | ||
| 27 | /// Called at the beginning of the decompilation of a database. | ||
| 28 | /// </summary> | ||
| 29 | /// <param name="tables">The collection of all tables.</param> | ||
| 30 | public override void Initialize(TableIndexedCollection tables) | ||
| 31 | { | ||
| 32 | Table propertyTable = tables["Property"]; | ||
| 33 | |||
| 34 | if (null != propertyTable) | ||
| 35 | { | ||
| 36 | foreach (Row row in propertyTable.Rows) | ||
| 37 | { | ||
| 38 | if ("SecureCustomProperties" == row[0].ToString()) | ||
| 39 | { | ||
| 40 | // if we've referenced any of the DirectX properties, add | ||
| 41 | // a PropertyRef to pick up the CA from the extension and then remove | ||
| 42 | // it from the SecureCustomExtensions property so we don't get duplicates | ||
| 43 | StringBuilder remainingProperties = new StringBuilder(); | ||
| 44 | string[] secureCustomProperties = row[1].ToString().Split(';'); | ||
| 45 | foreach (string property in secureCustomProperties) | ||
| 46 | { | ||
| 47 | if (property.StartsWith("WIX_DIRECTX_")) | ||
| 48 | { | ||
| 49 | Wix.PropertyRef propertyRef = new Wix.PropertyRef(); | ||
| 50 | propertyRef.Id = property; | ||
| 51 | this.Core.RootElement.AddChild(propertyRef); | ||
| 52 | } | ||
| 53 | else | ||
| 54 | { | ||
| 55 | if (0 < remainingProperties.Length) | ||
| 56 | { | ||
| 57 | remainingProperties.Append(";"); | ||
| 58 | } | ||
| 59 | remainingProperties.Append(property); | ||
| 60 | } | ||
| 61 | } | ||
| 62 | |||
| 63 | row[1] = remainingProperties.ToString(); | ||
| 64 | break; | ||
| 65 | } | ||
| 66 | } | ||
| 67 | } | ||
| 68 | } | ||
| 69 | } | ||
| 70 | } | ||
diff --git a/src/wixext/DirectXExtensionData.cs b/src/wixext/DirectXExtensionData.cs new file mode 100644 index 00000000..828b087d --- /dev/null +++ b/src/wixext/DirectXExtensionData.cs | |||
| @@ -0,0 +1,34 @@ | |||
| 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 | namespace WixToolset.Extensions | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Reflection; | ||
| 7 | using WixToolset.Data; | ||
| 8 | using WixToolset.Extensibility; | ||
| 9 | |||
| 10 | /// <summary> | ||
| 11 | /// The WiX Toolset DirectX Extension. | ||
| 12 | /// </summary> | ||
| 13 | public sealed class DirectXExtensionData : ExtensionData | ||
| 14 | { | ||
| 15 | /// <summary> | ||
| 16 | /// Gets the library associated with this extension. | ||
| 17 | /// </summary> | ||
| 18 | /// <param name="tableDefinitions">The table definitions to use while loading the library.</param> | ||
| 19 | /// <returns>The loaded library.</returns> | ||
| 20 | public override Library GetLibrary(TableDefinitionCollection tableDefinitions) | ||
| 21 | { | ||
| 22 | return DirectXExtensionData.GetExtensionLibrary(tableDefinitions); | ||
| 23 | } | ||
| 24 | |||
| 25 | /// <summary> | ||
| 26 | /// Internal mechanism to access the extension's library. | ||
| 27 | /// </summary> | ||
| 28 | /// <returns>Extension's library.</returns> | ||
| 29 | internal static Library GetExtensionLibrary(TableDefinitionCollection tableDefinitions) | ||
| 30 | { | ||
| 31 | return ExtensionData.LoadLibraryHelper(Assembly.GetExecutingAssembly(), "WixToolset.Extensions.Data.DirectX.wixlib", tableDefinitions); | ||
| 32 | } | ||
| 33 | } | ||
| 34 | } | ||
diff --git a/src/wixext/WixDirectXExtension.csproj b/src/wixext/WixDirectXExtension.csproj new file mode 100644 index 00000000..577d36f3 --- /dev/null +++ b/src/wixext/WixDirectXExtension.csproj | |||
| @@ -0,0 +1,31 @@ | |||
| 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 | |||
| 5 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> | ||
| 6 | <PropertyGroup> | ||
| 7 | <ProjectGuid>{6182DBCA-146A-4F37-8406-3139BBE04636}</ProjectGuid> | ||
| 8 | <AssemblyName>WixDirectXExtension</AssemblyName> | ||
| 9 | <OutputType>Library</OutputType> | ||
| 10 | <RootNamespace>WixToolset.Extensions</RootNamespace> | ||
| 11 | </PropertyGroup> | ||
| 12 | <ItemGroup> | ||
| 13 | <Compile Include="AssemblyInfo.cs" /> | ||
| 14 | <Compile Include="DirectXDecompiler.cs" /> | ||
| 15 | <Compile Include="DirectXExtensionData.cs" /> | ||
| 16 | <EmbeddedResource Include="$(OutputPath)\DirectX.wixlib"> | ||
| 17 | <Link>Data\DirectX.wixlib</Link> | ||
| 18 | </EmbeddedResource> | ||
| 19 | </ItemGroup> | ||
| 20 | <ItemGroup> | ||
| 21 | <Reference Include="System" /> | ||
| 22 | <Reference Include="System.Xml" /> | ||
| 23 | <ProjectReference Include="..\..\..\libs\WixToolset.Data\WixToolset.Data.csproj" /> | ||
| 24 | <ProjectReference Include="..\..\..\libs\WixToolset.Extensibility\WixToolset.Extensibility.csproj" /> | ||
| 25 | <ProjectReference Include="..\..\..\tools\wix\Wix.csproj" /> | ||
| 26 | <ProjectReference Include="..\wixlib\DirectXExtension.wixproj"> | ||
| 27 | <ReferenceOutputAssembly>false</ReferenceOutputAssembly> | ||
| 28 | </ProjectReference> | ||
| 29 | </ItemGroup> | ||
| 30 | <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), wix.proj))\tools\WixBuild.targets" /> | ||
| 31 | </Project> | ||
diff --git a/src/wixlib/DirectXExtension.wixproj b/src/wixlib/DirectXExtension.wixproj new file mode 100644 index 00000000..e98970e9 --- /dev/null +++ b/src/wixlib/DirectXExtension.wixproj | |||
| @@ -0,0 +1,24 @@ | |||
| 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 | |||
| 5 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> | ||
| 6 | <PropertyGroup> | ||
| 7 | <ProjectGuid>{4D8DDEC7-AAAC-4A32-87D0-5992FE382ED9}</ProjectGuid> | ||
| 8 | <OutputName>directx</OutputName> | ||
| 9 | <OutputType>Library</OutputType> | ||
| 10 | <BindFiles>true</BindFiles> | ||
| 11 | <Pedantic>true</Pedantic> | ||
| 12 | <Cultures>en-us</Cultures> | ||
| 13 | </PropertyGroup> | ||
| 14 | |||
| 15 | <ItemGroup> | ||
| 16 | <Compile Include="DirectXExtension.wxs" /> | ||
| 17 | </ItemGroup> | ||
| 18 | |||
| 19 | <ItemGroup> | ||
| 20 | <ProjectReference Include="..\ca\directx.vcxproj" /> | ||
| 21 | </ItemGroup> | ||
| 22 | |||
| 23 | <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), wix.proj))\tools\WixBuild.targets" /> | ||
| 24 | </Project> | ||
diff --git a/src/wixlib/DirectXExtension.wxs b/src/wixlib/DirectXExtension.wxs new file mode 100644 index 00000000..022ea5a5 --- /dev/null +++ b/src/wixlib/DirectXExtension.wxs | |||
| @@ -0,0 +1,34 @@ | |||
| 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 | |||
| 5 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
| 6 | <?include caerr.wxi ?> | ||
| 7 | |||
| 8 | <!-- DirectX Custom Action DLL Definitions --> | ||
| 9 | <Fragment> | ||
| 10 | <Binary Id="WixDirectXCA" SourceFile="directx.dll" /> | ||
| 11 | </Fragment> | ||
| 12 | |||
| 13 | <Fragment> | ||
| 14 | <CustomAction Id="WixQueryDirectXCaps" BinaryKey="WixDirectXCA" DllEntry="WixQueryDirectXCaps" Return="ignore" /> | ||
| 15 | |||
| 16 | <InstallUISequence> | ||
| 17 | <Custom Action="WixQueryDirectXCaps" Before="LaunchConditions" Overridable="yes">VersionNT > 400</Custom> | ||
| 18 | </InstallUISequence> | ||
| 19 | |||
| 20 | <InstallExecuteSequence> | ||
| 21 | <Custom Action="WixQueryDirectXCaps" Before="LaunchConditions" Overridable="yes">VersionNT > 400</Custom> | ||
| 22 | </InstallExecuteSequence> | ||
| 23 | </Fragment> | ||
| 24 | |||
| 25 | <Fragment> | ||
| 26 | <Property Id="WIX_DIRECTX_VERTEXSHADERVERSION" Secure="yes" Value="NotSet" /> | ||
| 27 | <CustomActionRef Id="WixQueryDirectXCaps" /> | ||
| 28 | </Fragment> | ||
| 29 | |||
| 30 | <Fragment> | ||
| 31 | <Property Id="WIX_DIRECTX_PIXELSHADERVERSION" Secure="yes" Value="NotSet" /> | ||
| 32 | <CustomActionRef Id="WixQueryDirectXCaps" /> | ||
| 33 | </Fragment> | ||
| 34 | </Wix> | ||
