Skip to content

Commit 6511d49

Browse files
CsantucciChris Jakeman
authored andcommitted
True 64-bit Launcher to convince ReShade installer that we are running 64 bit
1 parent f806687 commit 6511d49

File tree

5 files changed

+534
-0
lines changed

5 files changed

+534
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{B558F620-3BF7-4371-B7A1-9EE8D828DE21}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>ORTS</RootNamespace>
11+
<AssemblyName>OpenRails64</AssemblyName>
12+
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<ApplicationIcon>..\ORTS.ico</ApplicationIcon>
15+
</PropertyGroup>
16+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>..\..\Program\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
<LangVersion>7.3</LangVersion>
25+
<LangVersion>7.3</LangVersion>
26+
<PlatformTarget>x64</PlatformTarget>
27+
</PropertyGroup>
28+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
29+
<DebugType>pdbonly</DebugType>
30+
<Optimize>true</Optimize>
31+
<OutputPath>..\..\Program\</OutputPath>
32+
<DefineConstants>TRACE</DefineConstants>
33+
<ErrorReport>prompt</ErrorReport>
34+
<WarningLevel>4</WarningLevel>
35+
<DocumentationFile>..\..\Program\OpenRails.xml</DocumentationFile>
36+
<NoWarn>1591</NoWarn>
37+
<LangVersion>7.3</LangVersion>
38+
</PropertyGroup>
39+
<PropertyGroup>
40+
<ApplicationManifest>..\Launcher64\app.manifest</ApplicationManifest>
41+
</PropertyGroup>
42+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
43+
<DebugSymbols>true</DebugSymbols>
44+
<OutputPath>bin\x64\Debug\</OutputPath>
45+
<DefineConstants>DEBUG;TRACE</DefineConstants>
46+
<DebugType>full</DebugType>
47+
<PlatformTarget>x64</PlatformTarget>
48+
<LangVersion>7.3</LangVersion>
49+
<ErrorReport>prompt</ErrorReport>
50+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
51+
</PropertyGroup>
52+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
53+
<OutputPath>bin\x64\Release\</OutputPath>
54+
<DefineConstants>TRACE</DefineConstants>
55+
<DocumentationFile>..\..\Program\OpenRails.xml</DocumentationFile>
56+
<Optimize>true</Optimize>
57+
<NoWarn>1591</NoWarn>
58+
<DebugType>pdbonly</DebugType>
59+
<PlatformTarget>x64</PlatformTarget>
60+
<LangVersion>7.3</LangVersion>
61+
<ErrorReport>prompt</ErrorReport>
62+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
63+
</PropertyGroup>
64+
<ItemGroup>
65+
<Reference Include="System" />
66+
<Reference Include="System.Windows.Forms" />
67+
</ItemGroup>
68+
<ItemGroup>
69+
<Compile Include="Program.cs" />
70+
<Compile Include="Properties\AssemblyInfo.cs" />
71+
</ItemGroup>
72+
<ItemGroup>
73+
<None Include="app.manifest">
74+
<SubType>Designer</SubType>
75+
</None>
76+
</ItemGroup>
77+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
78+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
79+
Other similar extension points exist, see Microsoft.Common.targets.
80+
<Target Name="BeforeBuild">
81+
</Target>
82+
<Target Name="AfterBuild">
83+
</Target>
84+
-->
85+
<PropertyGroup>
86+
<PreBuildEvent>
87+
</PreBuildEvent>
88+
<PostBuildEvent>echo $Revision: 000 $&gt;Revision.txt
89+
date /t&gt;&gt;Revision.txt
90+
time /t&gt;&gt;Revision.txt</PostBuildEvent>
91+
</PropertyGroup>
92+
</Project>

Source/Launcher64/Program.cs

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
// COPYRIGHT 2009, 2010, 2011, 2012, 2013 by the Open Rails project.
2+
//
3+
// This file is part of Open Rails.
4+
//
5+
// Open Rails is free software: you can redistribute it and/or modify
6+
// it under the terms of the GNU General Public License as published by
7+
// the Free Software Foundation, either version 3 of the License, or
8+
// (at your option) any later version.
9+
//
10+
// Open Rails is distributed in the hope that it will be useful,
11+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
// GNU General Public License for more details.
14+
//
15+
// You should have received a copy of the GNU General Public License
16+
// along with Open Rails. If not, see <http://www.gnu.org/licenses/>.
17+
18+
/* ORTS Launcher
19+
*
20+
* This is the program that users execute start ORTS.
21+
* Its purpose is to check for required dependencies
22+
* before launching the rest of the ORTS executables.
23+
*
24+
* This program must be compiled with a minimum of dependencies
25+
* so that it is guaranteed to run.
26+
*/
27+
28+
using Microsoft.Win32;
29+
using System;
30+
using System.Collections.Generic;
31+
using System.Diagnostics;
32+
using System.IO;
33+
using System.Text;
34+
using System.Windows.Forms;
35+
36+
namespace ORTS
37+
{
38+
internal struct DependencyHint
39+
{
40+
public string Name;
41+
public string Url;
42+
public string Text;
43+
}
44+
45+
static class Program
46+
{
47+
/// <summary>
48+
/// The main entry point for the application.
49+
/// </summary>
50+
[STAThread]
51+
static void Main()
52+
{
53+
Application.EnableVisualStyles();
54+
55+
// Check for any missing components.
56+
var path = Path.GetDirectoryName(Application.ExecutablePath);
57+
List<DependencyHint> missingDependencies = new List<DependencyHint>();
58+
59+
CheckNetFx(missingDependencies);
60+
CheckDXRuntime(missingDependencies);
61+
62+
if (missingDependencies.Count > 0)
63+
{
64+
StringBuilder builder = new StringBuilder();
65+
foreach (var item in missingDependencies)
66+
builder.AppendLine(item.Name);
67+
68+
if (MessageBox.Show($"{Application.ProductName} requires the following:\n\n{builder.ToString()}" +
69+
"\nWhen you click OK, we will guide you to download the required software.\n" +
70+
(missingDependencies.Count > 1 ? "If there are multiple items missing, you need to repeat this process until all dependencies are resolved.\n" : string.Empty) +
71+
"Click Cancel to quit.",
72+
Application.ProductName, MessageBoxButtons.OKCancel) == DialogResult.OK)
73+
{
74+
DownloadDependency(missingDependencies[0]);
75+
}
76+
return;
77+
}
78+
79+
List<string> missingORFiles = new List<string>();
80+
CheckOR(missingORFiles, path);
81+
if (missingORFiles.Count > 0)
82+
{
83+
MessageBox.Show($"{Application.ProductName} is missing the following:\n\n{string.Join("\n", missingORFiles.ToArray())}\n\nPlease re-install the software.", Application.ProductName);
84+
return;
85+
}
86+
// Default menu
87+
var process = Process.Start(Path.Combine(path, "Menu.exe"));
88+
process.WaitForInputIdle();
89+
}
90+
91+
private static void DownloadDependency(DependencyHint dependency)
92+
{
93+
Clipboard.SetText(dependency.Url);
94+
MessageBox.Show($"{dependency.Text} \n\nWhen you click OK, we will try to open a browser window pointing to the URL. " +
95+
"You can also open a browser window yourself now and paste the URL from clipboard (Ctrl + V).", dependency.Name);
96+
Process.Start(dependency.Url);
97+
}
98+
99+
static void CheckNetFx(List<DependencyHint> missingDependencies)
100+
{
101+
using (var RK = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\"))
102+
if ((SafeReadKey(RK, "Install", 0) == 1) && (SafeReadKey(RK, "Release", 0) >= 461808)) //https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed#find-net-framework-versions-45-and-later-with-code
103+
return;
104+
105+
missingDependencies.Add(new DependencyHint()
106+
{
107+
Name = ("Microsoft .NET Framework 4.7.2 or later"),
108+
Text = "Please go to\n https://support.microsoft.com/en-us/help/4054530/microsoft-net-framework-4-7-2-offline-installer-for-windows \nto download the installation package " +
109+
"for Microsoft .NET Framework 4.7.2 and install the software.",
110+
Url = "https://support.microsoft.com/en-us/help/4054530/microsoft-net-framework-4-7-2-offline-installer-for-windows"
111+
});
112+
}
113+
114+
static void CheckDXRuntime(List<DependencyHint> missingDependencies)
115+
{
116+
if (File.Exists(Path.Combine(Environment.SystemDirectory, "D3Dcompiler_43.dll"))) //there is a dependency in Monogame requiring the specific version of D3D compiler
117+
return;
118+
119+
missingDependencies.Add(new DependencyHint()
120+
{
121+
Name = "DirectX 9 Runtime",
122+
Text = "Please go to\n https://www.microsoft.com/en-us/download/details.aspx?id=35&nowin10 \nto download the web installer for " +
123+
"DirectX Runtime and install the software. While downloading and installing, you may uncheck the installation of MSN and Bing software.",
124+
Url = "https://www.microsoft.com/en-us/download/details.aspx?id=35&nowin10"
125+
});
126+
}
127+
128+
static void CheckOR(List<string> missingFiles, string path)
129+
{
130+
foreach (var file in new[] {
131+
// Required libraries:
132+
"GNU.Gettext.dll",
133+
"GNU.Gettext.WinForms.dll",
134+
"ICSharpCode.SharpZipLib.dll",
135+
"Ionic.Zip.dll",
136+
"PIEHid32Net.dll",
137+
"PIEHid64Net.dll",
138+
@"Native/X86/OpenAL32.dll",
139+
@"Native/X64/OpenAL32.dll",
140+
// Programs:
141+
"Menu.exe",
142+
"RunActivity.exe",
143+
})
144+
{
145+
if (!File.Exists(Path.Combine(path, file)))
146+
missingFiles.Add($"File '{file}'");
147+
}
148+
}
149+
150+
static int SafeReadKey(RegistryKey key, string name, int defaultValue)
151+
{
152+
try
153+
{
154+
return (int)key.GetValue(name, defaultValue);
155+
}
156+
catch
157+
{
158+
return defaultValue;
159+
}
160+
}
161+
}
162+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("Open Rails")]
9+
[assembly: AssemblyDescription("Open Rails Transport Simulator")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("Open Rails")]
12+
[assembly: AssemblyProduct("Open Rails")]
13+
[assembly: AssemblyCopyright("Copyright © 2009 - 2019")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("631fc5ba-a95a-4bcb-8640-d04f416064fa")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("0.0.*")]
36+

Source/Launcher64/app.manifest

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
3+
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
4+
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
5+
<security>
6+
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
7+
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
8+
</requestedPrivileges>
9+
</security>
10+
</trustInfo>
11+
<application xmlns="urn:schemas-microsoft-com:asm.v3">
12+
<windowsSettings>
13+
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
14+
</windowsSettings>
15+
</application>
16+
</assembly>

0 commit comments

Comments
 (0)