diff --git a/App.config b/App.config
new file mode 100644
index 0000000..74ade9d
--- /dev/null
+++ b/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/App.xaml b/App.xaml
new file mode 100644
index 0000000..f736680
--- /dev/null
+++ b/App.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/App.xaml.cs b/App.xaml.cs
new file mode 100644
index 0000000..8a1ef75
--- /dev/null
+++ b/App.xaml.cs
@@ -0,0 +1,11 @@
+using System.Windows;
+
+namespace EonaCatMGSTPF_Resolution_Patcher
+{
+ ///
+ /// Interaction logic for App.xaml
+ ///
+ public partial class App : Application
+ {
+ }
+}
diff --git a/EonaCatMGSTPP_Resolution_Patcher.csproj b/EonaCatMGSTPP_Resolution_Patcher.csproj
new file mode 100644
index 0000000..d1dc229
--- /dev/null
+++ b/EonaCatMGSTPP_Resolution_Patcher.csproj
@@ -0,0 +1,108 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {C0F20CE1-3CB2-4FD3-A6E3-404BCC50C639}
+ WinExe
+ Properties
+ EonaCatMGSTPP_Resolution_Patcher
+ EonaCat MGSTPP Resolution Patcher
+ v4.0
+ 512
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 4
+ true
+
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+ icon.ico
+
+
+
+
+
+
+
+ 4.0
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ App.xaml
+ Code
+
+
+ MainWindow.xaml
+ Code
+
+
+
+
+ Code
+
+
+ True
+ True
+ Resources.resx
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/EonaCatMGSTPP_Resolution_Patcher.sln b/EonaCatMGSTPP_Resolution_Patcher.sln
new file mode 100644
index 0000000..b6fef6c
--- /dev/null
+++ b/EonaCatMGSTPP_Resolution_Patcher.sln
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.23107.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EonaCatMGSTPP Resolution Patcher", "EonaCatMGSTPP_Resolution_Patcher.csproj", "{C0F20CE1-3CB2-4FD3-A6E3-404BCC50C639}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {C0F20CE1-3CB2-4FD3-A6E3-404BCC50C639}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C0F20CE1-3CB2-4FD3-A6E3-404BCC50C639}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C0F20CE1-3CB2-4FD3-A6E3-404BCC50C639}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C0F20CE1-3CB2-4FD3-A6E3-404BCC50C639}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/MainWindow.xaml b/MainWindow.xaml
new file mode 100644
index 0000000..8b10ac9
--- /dev/null
+++ b/MainWindow.xaml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
new file mode 100644
index 0000000..5788215
--- /dev/null
+++ b/MainWindow.xaml.cs
@@ -0,0 +1,259 @@
+using System;
+using System.IO;
+using System.Windows;
+using Microsoft.Win32;
+using System.Management;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Linq;
+using System.Collections.Generic;
+using static EonaCatMGSTPP_Resolution_Patcher.ResolutionDetector;
+
+namespace EonaCatMGSTPP_Resolution_Patcher
+{
+ ///
+ /// Interaction logic for MainWindow.xaml
+ ///
+ public partial class MainWindow : Window
+ {
+ private byte[] _replace;
+ private Dictionary _resolutionsDictionary = new Dictionary();
+
+ public MainWindow()
+ {
+ InitializeComponent();
+ GetAllValidResolutions();
+ FillInKnownResolutions();
+ FillInComboBox();
+ }
+
+ private static byte[] GetBytesArrayFromResolution(int resolutionX, int resolutionY)
+ {
+ var resultX = resolutionX.ToString("X4");
+ var resultY = resolutionY.ToString("X4");
+ var resultXInBytes = StringToByteArray(resultX);
+ var resultYInBytes = StringToByteArray(resultY);
+ return resultXInBytes.Concat(resultYInBytes).ToArray();
+ }
+
+ public static byte[] StringToByteArray(string hex)
+ {
+ return Enumerable.Range(0, hex.Length)
+ .Where(x => x % 2 == 0)
+ .Select(x => Convert.ToByte(hex.Substring(x, 2), 16))
+ .ToArray();
+ }
+
+ private void FillInComboBox()
+ {
+ foreach (var resolution in _resolutionsDictionary.Keys)
+ {
+ comboBox.Items.Add(resolution);
+ }
+ comboBox.SelectedIndex = 0;
+ }
+
+ private void FillInKnownResolutions()
+ {
+ _resolutionsDictionary["1024X768 (4:3)"] = GetBytesArrayFromResolution(1024, 768);
+ _resolutionsDictionary["1280X1024 (5:4)"] = GetBytesArrayFromResolution(1280, 1024);
+ _resolutionsDictionary["1366X768 (16:9)"] = GetBytesArrayFromResolution(1366, 768);
+ _resolutionsDictionary["1440X900 (16:10)"] = GetBytesArrayFromResolution(1440, 900);
+ _resolutionsDictionary["1680X1050 (16:10)"] = GetBytesArrayFromResolution(1680, 1050);
+ _resolutionsDictionary["1600X1200 (16:10)"] = GetBytesArrayFromResolution(1600, 1200);
+ _resolutionsDictionary["1920X1080 (16:9)"] = GetBytesArrayFromResolution(1920, 1080);
+ _resolutionsDictionary["2560X1080 (21:9)"] = GetBytesArrayFromResolution(2560, 1080);
+ _resolutionsDictionary["3440X1440 (21:9)"] = GetBytesArrayFromResolution(3440, 1440);
+ _resolutionsDictionary["5040x1050 (48:10)"] = GetBytesArrayFromResolution(5040, 1050);
+ _resolutionsDictionary["4800X900 (48:9)"] = GetBytesArrayFromResolution(4800, 900);
+ _resolutionsDictionary["7860X1080 (48:9)"] = GetBytesArrayFromResolution(7860, 1080);
+ _resolutionsDictionary["7860X2160 (48:9)"] = GetBytesArrayFromResolution(7860, 2160);
+ }
+
+ /* // Is not used anymore
+ private void OldKnownResolutions()
+ {
+ _resolutionsDictionary["1024X768 (4:3)"] = new byte[] { 0xAB, 0xAA, 0xAA, 0x3F };
+ _resolutionsDictionary["1280X1024 (5:4)"] = new byte[] { 0x00, 0x00, 0x0A, 0x3F };
+ _resolutionsDictionary["1366X768 (16:9)"] = new byte[] { 0xAB, 0xAA, 0xE3, 0x3F };
+ _resolutionsDictionary["1440X900 (16:10)"] = new byte[] { 0xCD, 0xCC, 0xCC, 0x3F };
+ _resolutionsDictionary["1680X1050 (16:10)"] = new byte[] { 0xCD, 0xCC, 0xCC, 0x3F };
+ _resolutionsDictionary["1920X1080 (16:9)"] = new byte[] { 0x39, 0x8E, 0xE3, 0x3F };
+ _resolutionsDictionary["2560X1080 (21:9)"] = new byte[] { 0x26, 0xB4, 0x17, 0x40 };
+ _resolutionsDictionary["3440X1440 (21:9)"] = new byte[] { 0x8E, 0xE3, 0x18, 0x40 };
+ _resolutionsDictionary["5040x1050 (48:10)"] = new byte[] { 0x9A, 0x99, 0x99, 0x40 };
+ _resolutionsDictionary["4800X900 (48:9)"] = new byte[] { 0xBA, 0xAA, 0xAA, 0x40 };
+ _resolutionsDictionary["7860X1080 (48:9)"] = new byte[] { 0xBA, 0xAA, 0xAA, 0x40 };
+ }
+ */
+
+ // Doesnt work yet
+ private void GetAllValidResolutions()
+ {
+ var vDevMode = new DEVMODE();
+ var i = 0;
+ while (EnumDisplaySettings(null, i, ref vDevMode))
+ {
+ Console.WriteLine("Width:{0} Height:{1} Color:{2} Frequency:{3}",
+ vDevMode.dmPelsWidth,
+ vDevMode.dmPelsHeight,
+ 1 << vDevMode.dmBitsPerPel, vDevMode.dmDisplayFrequency
+ );
+ i++;
+ }
+
+ var scope = new ManagementScope();
+
+ var query = new ObjectQuery("SELECT * FROM CIM_VideoControllerResolution");
+
+ using (var searcher = new ManagementObjectSearcher(scope, query))
+ {
+ var results = searcher.Get();
+
+ //previous resolution for checking when new resolution is found
+ var previousResolution = string.Empty;
+ //current resolution
+ var currentResolution = string.Empty;
+
+ foreach (var result in results)
+ {
+ currentResolution = result["HorizontalResolution"] + "x" + result["VerticalResolution"];
+
+ if (currentResolution != previousResolution)
+ {
+ comboBox.Items.Add(currentResolution);
+ previousResolution = currentResolution;
+ }
+ }
+ }
+ }
+
+ private void PatchButton_Click(object sender, RoutedEventArgs e)
+ {
+ if (comboBox.Text.Length > 0)
+ {
+ PatchFile();
+ }
+ else
+ {
+ MessageBox.Show("Please select a resolution!");
+ }
+ }
+
+ private void PatchFile()
+ {
+ var startupFolder = @"I:\Steam\SteamApps\common\MGS_TPP";
+
+ var dialog = new OpenFileDialog
+ {
+ Title = "Select file to patch",
+ DefaultExt = ".exe",
+ Filter = "Exe Files (*.exe) | *.exe"
+ };
+
+ // Set to my own resolution
+ if (Directory.Exists(startupFolder))
+ {
+ dialog.InitialDirectory = startupFolder;
+ _replace = _resolutionsDictionary["2560X1080 (21:9)"];
+ }
+ else
+ {
+ _replace = _resolutionsDictionary[comboBox.Text];
+ }
+
+ var result = dialog.ShowDialog();
+
+ if (result.HasValue && result.Value)
+ {
+ var filename = dialog.FileName;
+ Exception error;
+
+ if (PatchTheFile(filename, out error))
+ {
+ MessageBox.Show("The file was patched successfully");
+ }
+ else
+ {
+ if (error != null)
+ {
+ MessageBox.Show($"The file failed to patch! => '{error.Message}'");
+ }
+ else
+ {
+ MessageBox.Show($"The file failed to patch! => 'Could not find original hexValues, are you sure you are trying to patch an UNPATCHED executable?'");
+ }
+ }
+ MessageBox.Show("Patcher created by EonaCat");
+ }
+ }
+
+ private static void CreateBackup(string filename)
+ {
+ var dirPath = Path.GetDirectoryName(filename);
+ var fileName = Path.GetFileName(filename);
+ var backupExtension = ".backup";
+ var files = Directory.GetFiles(dirPath);
+ var count = files.Count(file => { return file.Contains(fileName + backupExtension); });
+ var newFileName = (count == 0) ? filename + backupExtension : $"{fileName} ({count + 1}){backupExtension}";
+ File.Copy(filename, newFileName);
+ }
+
+ private static readonly byte[] PatchFind = { 0x39, 0x8E, 0xE3, 0x3F };
+ private static readonly byte[] PatchReplace = { 0x26, 0xb4, 0x17, 0x40 };
+
+ private static bool DetectPatch(byte[] sequence, int position)
+ {
+ if (position + PatchFind.Length > sequence.Length) return false;
+ for (int p = 0; p < PatchFind.Length; p++)
+ {
+ if (PatchFind[p] != sequence[position + p]) return false;
+ }
+ return true;
+ }
+
+ private static bool PatchTheFile(string filename, out Exception error)
+ {
+ var foundValueForPatching = false;
+ error = null;
+
+ try
+ {
+ // Ensure target directory exists.
+ var targetDirectory = Path.GetDirectoryName(filename);
+ if (targetDirectory == null) return false;
+ Directory.CreateDirectory(targetDirectory);
+
+ // Read file bytes.
+ var fileContent = File.ReadAllBytes(filename);
+
+ // Detect and patch file.
+ for (int p = 0; p < fileContent.Length; p++)
+ {
+ if (!DetectPatch(fileContent, p)) continue;
+
+ foundValueForPatching = true;
+ for (int w = 0; w < PatchFind.Length; w++)
+ {
+ fileContent[p + w] = PatchReplace[w];
+ }
+ }
+
+ if (foundValueForPatching)
+ {
+ CreateBackup(filename);
+
+ // Save it to another location.
+ File.WriteAllBytes(filename, fileContent);
+ }
+
+ return foundValueForPatching;
+ }
+ catch (Exception exception)
+ {
+ error = exception;
+ return false;
+ }
+ }
+ }
+}
diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..b3133f7
--- /dev/null
+++ b/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("EonaCat Metal Gear Solid The Phantom Pain Resolution Patcher")]
+[assembly: AssemblyDescription("EonaCat Metal Gear Solid The Phantom Pain Resolution Patcher")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("EonaCat")]
+[assembly: AssemblyProduct("EonaCat Metal Gear Solid The Phantom Pain Resolution Patcher")]
+[assembly: AssemblyCopyright("Copyright EonaCat © 2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+//In order to begin building localizable applications, set
+//CultureYouAreCodingWith in your .csproj file
+//inside a . For example, if you are using US english
+//in your source files, set the to en-US. Then uncomment
+//the NeutralResourceLanguage attribute below. Update the "en-US" in
+//the line below to match the UICulture setting in the project file.
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+ //(used if a resource is not found in the page,
+ // or application resource dictionaries)
+ ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+ //(used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
+)]
+
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..5f92c6b
--- /dev/null
+++ b/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace EonaCatMGSTPP_Resolution_Patcher.Properties {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("EonaCatMGSTPP_Resolution_Patcher.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/Properties/Resources.resx b/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/ResolutionDetector.cs b/ResolutionDetector.cs
new file mode 100644
index 0000000..a40b3e2
--- /dev/null
+++ b/ResolutionDetector.cs
@@ -0,0 +1,70 @@
+using System;
+using System.Runtime.InteropServices;
+
+namespace EonaCatMGSTPP_Resolution_Patcher
+{
+ public static class ResolutionDetector
+ {
+ [DllImport("user32.dll")]
+ public static extern bool EnumDisplaySettings(
+ string deviceName, int modeNum, ref DEVMODE devMode);
+ const int ENUM_CURRENT_SETTINGS = -1;
+
+ const int ENUM_REGISTRY_SETTINGS = -2;
+
+ [StructLayout(LayoutKind.Sequential)]
+ public struct DEVMODE
+ {
+
+ private const int CCHDEVICENAME = 0x20;
+ private const int CCHFORMNAME = 0x20;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)]
+ public string dmDeviceName;
+ public short dmSpecVersion;
+ public short dmDriverVersion;
+ public short dmSize;
+ public short dmDriverExtra;
+ public int dmFields;
+ public int dmPositionX;
+ public int dmPositionY;
+ public int dmDisplayFixedOutput;
+ public short dmColor;
+ public short dmDuplex;
+ public short dmYResolution;
+ public short dmTTOption;
+ public short dmCollate;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)]
+ public string dmFormName;
+ public short dmLogPixels;
+ public int dmBitsPerPel;
+ public int dmPelsWidth;
+ public int dmPelsHeight;
+ public int dmDisplayFlags;
+ public int dmDisplayFrequency;
+ public int dmICMMethod;
+ public int dmICMIntent;
+ public int dmMediaType;
+ public int dmDitherType;
+ public int dmReserved1;
+ public int dmReserved2;
+ public int dmPanningWidth;
+ public int dmPanningHeight;
+
+ }
+
+ public static void GetResolutions()
+ {
+ var vDevMode = new DEVMODE();
+ var i = 0;
+ while (EnumDisplaySettings(null, i, ref vDevMode))
+ {
+ Console.WriteLine("Width:{0} Height:{1} Color:{2} Frequency:{3}",
+ vDevMode.dmPelsWidth,
+ vDevMode.dmPelsHeight,
+ 1 << vDevMode.dmBitsPerPel, vDevMode.dmDisplayFrequency
+ );
+ i++;
+ }
+ }
+ }
+}
diff --git a/avatar.png b/avatar.png
new file mode 100644
index 0000000..cf55ef1
Binary files /dev/null and b/avatar.png differ
diff --git a/background.jpg b/background.jpg
new file mode 100644
index 0000000..e1e18ec
Binary files /dev/null and b/background.jpg differ
diff --git a/icon.ico b/icon.ico
new file mode 100644
index 0000000..770f861
Binary files /dev/null and b/icon.ico differ
diff --git a/packages.config b/packages.config
new file mode 100644
index 0000000..6b8deb9
--- /dev/null
+++ b/packages.config
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file