diff --git a/RE2REmakeSRT/GameMemory.cs b/RE2REmakeSRT/GameMemory.cs
index 4e22076..0cb4dd1 100644
--- a/RE2REmakeSRT/GameMemory.cs
+++ b/RE2REmakeSRT/GameMemory.cs
@@ -59,11 +59,11 @@ public TimeSpan IGTTimeSpan
///
///
///
- public GameMemory(Process proc)
+ public GameMemory(int pid)
{
- gameVersion = REmake2VersionDetector.GetVersion(proc);
- memoryAccess = new ProcessMemory.ProcessMemory(proc.Id);
- BaseAddress = NativeWrappers.GetProcessBaseAddress(proc.Id, ProcessMemory.PInvoke.ListModules.LIST_MODULES_64BIT).ToInt64(); // Bypass .NET's managed solution for getting this and attempt to get this info ourselves via PInvoke since some users are getting 299 PARTIAL COPY when they seemingly shouldn't. This is built as x64 only and RE2 is x64 only to my knowledge.
+ gameVersion = REmake2VersionDetector.GetVersion(pid);
+ memoryAccess = new ProcessMemory.ProcessMemory(pid);
+ BaseAddress = NativeWrappers.GetProcessBaseAddress(pid, ProcessMemory.PInvoke.ListModules.LIST_MODULES_64BIT).ToInt64(); // Bypass .NET's managed solution for getting this and attempt to get this info ourselves via PInvoke since some users are getting 299 PARTIAL COPY when they seemingly shouldn't. This is built as x64 only and RE2 is x64 only to my knowledge.
//BaseAddress = proc.MainModule.BaseAddress.ToInt64();
// Setup the pointers.
@@ -180,14 +180,38 @@ public void Refresh()
public static void GenerateImages()
{
// Transform the image into a 32-bit PARGB Bitmap.
- inventoryImage = Properties.Resources.ui0100_iam_texout.Clone(new Rectangle(0, 0, Properties.Resources.ui0100_iam_texout.Width, Properties.Resources.ui0100_iam_texout.Height), PixelFormat.Format32bppPArgb);
+ try
+ {
+ inventoryImage = Properties.Resources.ui0100_iam_texout.Clone(new Rectangle(0, 0, Properties.Resources.ui0100_iam_texout.Width, Properties.Resources.ui0100_iam_texout.Height), PixelFormat.Format32bppPArgb);
+ }
+ catch (Exception ex)
+ {
+ Program.FailFast(string.Format("[{0}] An unhandled exception has occurred. Please see below for details.\r\n\r\n[{1}] {2}\r\n{3}.\r\n\r\nPARGB Transform.", Program.srtVersion, ex.GetType().ToString(), ex.Message, ex.StackTrace), ex);
+ }
// Rescales the image down if the scaling factor is not 1.
if (Program.programSpecialOptions.ScalingFactor != 1d)
{
- int sheetWidth = (int)Math.Round(inventoryImage.Width * Program.programSpecialOptions.ScalingFactor, MidpointRounding.AwayFromZero);
- int sheetHeight = (int)Math.Round(inventoryImage.Height * Program.programSpecialOptions.ScalingFactor, MidpointRounding.AwayFromZero);
- inventoryImage = new Bitmap(inventoryImage, sheetWidth, sheetHeight);
+ double sheetWidth = Math.Round(inventoryImage.Width * Program.programSpecialOptions.ScalingFactor, MidpointRounding.AwayFromZero);
+ double sheetHeight = Math.Round(inventoryImage.Height * Program.programSpecialOptions.ScalingFactor, MidpointRounding.AwayFromZero);
+ try
+ {
+ inventoryImage = new Bitmap(inventoryImage, (int)sheetWidth, (int)sheetHeight);
+ }
+ catch (Exception ex)
+ {
+ Program.FailFast(string.Format(@"[{0}] An unhandled exception has occurred. Please see below for details.
+---
+[{1}] {2}
+{3}
+---
+Resizing section.
+sheetWidth: {4} ({7} * {6})
+sheetHeight: {5} ({8} * {6})
+scalingFactor: {6}
+inventoryImage.Width: {7}
+inventoryImage.Height: {8}", Program.srtVersion, ex.GetType().ToString(), ex.Message, ex.StackTrace, sheetWidth.ToString(), sheetHeight.ToString(), Program.programSpecialOptions.ScalingFactor.ToString(), inventoryImage.Width.ToString(), inventoryImage.Height.ToString()), ex);
+ }
}
int itemColumnInc = -1;
diff --git a/RE2REmakeSRT/MainUI.cs b/RE2REmakeSRT/MainUI.cs
index d233776..119bfce 100644
--- a/RE2REmakeSRT/MainUI.cs
+++ b/RE2REmakeSRT/MainUI.cs
@@ -78,6 +78,10 @@ public MainUI()
// Adjust main form width as well.
this.Width = this.statisticsPanel.Width + 24 + this.inventoryPanel.Width;
+
+ // Only adjust form height if its greater than 461. We don't want it to go below this size.
+ if (41 + this.inventoryPanel.Height > 461)
+ this.Height = 41 + this.inventoryPanel.Height;
}
else
{
diff --git a/RE2REmakeSRT/Options.cs b/RE2REmakeSRT/Options.cs
index 9d397ae..476fb26 100644
--- a/RE2REmakeSRT/Options.cs
+++ b/RE2REmakeSRT/Options.cs
@@ -44,6 +44,10 @@ public void GetOptions()
Flags &= ~ProgramFlags.NoInventory;
double.TryParse(RegistryHelper.GetValue(optionsKey, "ScalingFactor", "0.75"), out ScalingFactor);
+
+ // Do not permit ScalingFactor values less than or equal to 0% and greater than 400%.
+ if (ScalingFactor <= 0 || ScalingFactor > 4)
+ ScalingFactor = 0.75d;
}
public void SetOptions()
@@ -81,7 +85,11 @@ public void SetOptions()
else
optionsKey.SetValue("NoInventory", 0, RegistryValueKind.DWord);
- optionsKey.SetValue("ScalingFactor", ScalingFactor.ToString(), RegistryValueKind.String);
+ // Do not permit ScalingFactor values less than or equal to 0% and greater than 400%.
+ if (ScalingFactor <= 0 || ScalingFactor > 4)
+ optionsKey.SetValue("ScalingFactor", "0.75", RegistryValueKind.String);
+ else
+ optionsKey.SetValue("ScalingFactor", ScalingFactor.ToString(), RegistryValueKind.String);
}
}
}
diff --git a/RE2REmakeSRT/Program.cs b/RE2REmakeSRT/Program.cs
index d782bd3..09483d1 100644
--- a/RE2REmakeSRT/Program.cs
+++ b/RE2REmakeSRT/Program.cs
@@ -17,6 +17,7 @@ public static class Program
public static GameMemory gameMem;
public static readonly string srtVersion = string.Format("v{0}", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
+ public static readonly string srtTitle = string.Format("RE2(2019) SRT - {0}", srtVersion);
public static int INV_SLOT_WIDTH;
public static int INV_SLOT_HEIGHT;
@@ -99,17 +100,27 @@ public static void Main(string[] args)
Application.Run(mainContext);
// Attach to the re2.exe process now that we've found it and show the UI.
- using (gameMem = new GameMemory(gameProc))
+ using (gameMem = new GameMemory(gameProc.Id))
using (mainContext = new ApplicationContext(new MainUI()))
Application.Run(mainContext);
}
catch (Exception ex)
{
- string title = "RE2 (2019) SRT - " + srtVersion;
- string exception = string.Format("[{0}] An unhandled exception has occurred. Please see below for details.\r\n\r\n[{1}] {2}\r\n{3}.", srtVersion, ex.GetType().ToString(), ex.Message, ex.StackTrace);
- MessageBox.Show(exception, title, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
- Environment.FailFast(exception, ex);
+ FailFast(string.Format("[{0}] An unhandled exception has occurred. Please see below for details.\r\n\r\n[{1}] {2}\r\n{3}.", srtVersion, ex.GetType().ToString(), ex.Message, ex.StackTrace), ex);
}
}
+
+ public static void FailFast(string message, Exception ex)
+ {
+ ShowError(message);
+ Environment.FailFast(message, ex);
+ }
+
+ public static void ShowError(string message)
+ {
+ MessageBox.Show(message, srtTitle, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
+ }
+
+ public static string GetExceptionMessage(Exception ex) => string.Format("[{0}] An unhandled exception has occurred. Please see below for details.\r\n\r\n[{1}] {2}\r\n{3}.", srtVersion, ex.GetType().ToString(), ex.Message, ex.StackTrace);
}
}
diff --git a/RE2REmakeSRT/Properties/AssemblyInfo.cs b/RE2REmakeSRT/Properties/AssemblyInfo.cs
index c7df9c5..000f6e9 100644
--- a/RE2REmakeSRT/Properties/AssemblyInfo.cs
+++ b/RE2REmakeSRT/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@
// 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.1.8.3")]
-[assembly: AssemblyFileVersion("1.1.8.3")]
+[assembly: AssemblyVersion("1.1.8.4")]
+[assembly: AssemblyFileVersion("1.1.8.4")]
diff --git a/RE2REmakeSRT/REmake2VersionDetector.cs b/RE2REmakeSRT/REmake2VersionDetector.cs
index 345af66..0dc1561 100644
--- a/RE2REmakeSRT/REmake2VersionDetector.cs
+++ b/RE2REmakeSRT/REmake2VersionDetector.cs
@@ -1,4 +1,5 @@
-using System.Diagnostics;
+using ProcessMemory;
+using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
@@ -17,13 +18,13 @@ private static byte[] GetSHA256Checksum(string filePath)
}
}
- public static REmake2VersionEnumeration GetVersion(Process remake2Proc)
+ public static REmake2VersionEnumeration GetVersion(int pid)
{
// If we're skipping the checksum version check, return the latest version we kow about.
if (Program.programSpecialOptions.Flags.HasFlag(ProgramFlags.SkipChecksumCheck))
return REmake2VersionEnumeration.Stock_1p01;
- byte[] processHash = GetSHA256Checksum(remake2Proc.MainModule.FileName);
+ byte[] processHash = GetSHA256Checksum(NativeWrappers.GetProcessPath(pid));
if (processHash.SequenceEqual(GameHashes.Stock_1ShotDemo))
{
diff --git a/RE2REmakeSRT/RegistryHelper.cs b/RE2REmakeSRT/RegistryHelper.cs
index a345f9b..bd48d07 100644
--- a/RE2REmakeSRT/RegistryHelper.cs
+++ b/RE2REmakeSRT/RegistryHelper.cs
@@ -1,10 +1,22 @@
using Microsoft.Win32;
+using System;
namespace RE2REmakeSRT
{
public static class RegistryHelper
{
- public static T GetValue(RegistryKey baseKey, string valueKey, T defaultValue) => (T)baseKey.GetValue(valueKey, defaultValue);
+ public static T GetValue(RegistryKey baseKey, string valueKey, T defaultValue)
+ {
+ try
+ {
+ return (T)baseKey.GetValue(valueKey, defaultValue);
+ }
+ catch (Exception ex)
+ {
+ Program.ShowError(Program.GetExceptionMessage(ex));
+ return defaultValue;
+ }
+ }
public static bool GetBoolValue(RegistryKey baseKey, string valueKey, bool defaultValue)
{