From 77f52cf04d83333b96b313ac32aa662ebf909f97 Mon Sep 17 00:00:00 2001 From: KrossX Date: Fri, 2 Aug 2019 19:05:57 -0300 Subject: [PATCH] GSDumpGUI: Some changes based on willkuer's review. --- tools/GSDumpGUI/Forms/frmMain.cs | 58 +++++++++++++----------- tools/GSDumpGUI/Library/GSDXWrapper.cs | 43 +++++++++--------- tools/GSDumpGUI/Library/GSDump/GSDump.cs | 4 +- tools/GSDumpGUI/Library/NativeMethods.cs | 2 +- 4 files changed, 56 insertions(+), 51 deletions(-) diff --git a/tools/GSDumpGUI/Forms/frmMain.cs b/tools/GSDumpGUI/Forms/frmMain.cs index 68441b5eea..a43c2a801f 100644 --- a/tools/GSDumpGUI/Forms/frmMain.cs +++ b/tools/GSDumpGUI/Forms/frmMain.cs @@ -116,7 +116,7 @@ namespace GSDumpGUI _availableGsDumps.OnIndexUpdatedEvent += UpdatePreviewImage; - this.Text += " " + (IntPtr.Size * 8).ToString() + "bits"; + this.Text += Environment.Is64BitProcess ? " 64bits" : " 32bits"; if (String.IsNullOrEmpty(Settings.GSDXDir) || !Directory.Exists(Settings.GSDXDir)) Settings.GSDXDir = AppDomain.CurrentDomain.BaseDirectory; @@ -217,7 +217,7 @@ namespace GSDumpGUI _dllWatcher.Clear(); - for (int i = 0; i < 4; i++) + for (int i = 0; i < paths.Length; i++) { try { @@ -256,7 +256,7 @@ namespace GSDumpGUI _dumpWatcher.Clear(); - for (int i = 0; i < 3; i++) + for (int i = 0; i < paths.Length; i++) { try { @@ -294,7 +294,7 @@ namespace GSDumpGUI if(ofd.ShowDialog() == DialogResult.OK) { string newpath = Path.GetDirectoryName(ofd.FileName); - if (!Settings.GSDXDir.ToLower().Equals(newpath.ToLower())) + if (!Settings.GSDXDir.Equals(newpath, StringComparison.OrdinalIgnoreCase)) { txtGSDXDirectory.Text = newpath; Settings.GSDXDir = newpath; @@ -317,7 +317,7 @@ namespace GSDumpGUI if (ofd.ShowDialog() == DialogResult.OK) { string newpath = Path.GetDirectoryName(ofd.FileName); - if (!Settings.DumpDir.ToLower().Equals(newpath.ToLower())) + if (!Settings.DumpDir.Equals(newpath, StringComparison.OrdinalIgnoreCase)) { txtDumpsDirectory.Text = newpath; Settings.DumpDir = newpath; @@ -524,46 +524,50 @@ namespace GSDumpGUI private void txtGSDXDirectory_Leave(object sender, EventArgs e) { string newpath = txtGSDXDirectory.Text; - if (!_gsdxPathOld.ToLower().Equals(newpath.ToLower())) + if (!_gsdxPathOld.Equals(newpath, StringComparison.OrdinalIgnoreCase)) txtGSDXDirectory.Text = _gsdxPathOld; } private void txtDumpsDirectory_Leave(object sender, EventArgs e) { string newpath = txtDumpsDirectory.Text; - if(!_dumpPathOld.ToLower().Equals(newpath.ToLower())) + if(!_dumpPathOld.Equals(newpath, StringComparison.OrdinalIgnoreCase)) txtDumpsDirectory.Text = _dumpPathOld; } private void txtGSDXDirectory_KeyDown(object sender, KeyEventArgs e) { - if (e.KeyCode != Keys.Return) return; - - string newpath = txtGSDXDirectory.Text; - if (!String.IsNullOrEmpty(newpath) && - !_gsdxPathOld.ToLower().Equals(newpath.ToLower()) && - Directory.Exists(newpath)) + if (e.KeyCode == Keys.Return) { - Settings.GSDXDir = newpath; - Settings.Save(); - ReloadGsdxDlls(); - _availableGsDlls.Selected = _availableGsDlls.Files.FirstOrDefault(); + string newpath = txtGSDXDirectory.Text; + if (!String.IsNullOrEmpty(newpath) && + !_gsdxPathOld.Equals(newpath, StringComparison.OrdinalIgnoreCase) && + Directory.Exists(newpath)) + { + _gsdxPathOld = newpath; + Settings.GSDXDir = newpath; + Settings.Save(); + ReloadGsdxDlls(); + _availableGsDlls.Selected = _availableGsDlls.Files.FirstOrDefault(); + } } } private void txtDumpsDirectory_KeyDown(object sender, KeyEventArgs e) { - if (e.KeyCode != Keys.Return) return; - - string newpath = txtDumpsDirectory.Text; - if (!String.IsNullOrEmpty(newpath) && - !_dumpPathOld.ToLower().Equals(newpath.ToLower()) && - Directory.Exists(newpath)) + if (e.KeyCode == Keys.Return) { - Settings.DumpDir = newpath; - Settings.Save(); - ReloadGsdxDumps(); - _availableGsDumps.Selected = _availableGsDumps.Files.FirstOrDefault(); + string newpath = txtDumpsDirectory.Text; + if (!String.IsNullOrEmpty(newpath) && + !_dumpPathOld.Equals(newpath, StringComparison.OrdinalIgnoreCase) && + Directory.Exists(newpath)) + { + _dumpPathOld = newpath; + Settings.DumpDir = newpath; + Settings.Save(); + ReloadGsdxDumps(); + _availableGsDumps.Selected = _availableGsDumps.Files.FirstOrDefault(); + } } } diff --git a/tools/GSDumpGUI/Library/GSDXWrapper.cs b/tools/GSDumpGUI/Library/GSDXWrapper.cs index 61f6596ce1..5c8e9c6824 100644 --- a/tools/GSDumpGUI/Library/GSDXWrapper.cs +++ b/tools/GSDumpGUI/Library/GSDXWrapper.cs @@ -31,22 +31,22 @@ using System.Threading; namespace GSDumpGUI { - public delegate void GSgifTransfer(IntPtr data, int size); - public delegate void GSgifTransfer1(IntPtr data, int size); - public delegate void GSgifTransfer2(IntPtr data, int size); - public delegate void GSgifTransfer3(IntPtr data, int size); - public delegate void GSVSync(byte field); - public delegate void GSreset(); - public delegate void GSreadFIFO2(IntPtr data, int size); - public delegate void GSsetGameCRC(int crc, int options); - public delegate int GSfreeze(int mode, IntPtr data); - public delegate int GSopen(IntPtr hwnd, String Title, int renderer); - public delegate void GSclose(); - public delegate void GSshutdown(); - public delegate void GSConfigure(); - public delegate void GSsetBaseMem(IntPtr data); + public delegate void GSgifTransfer(IntPtr data, int size); + public delegate void GSgifTransfer1(IntPtr data, int size); + public delegate void GSgifTransfer2(IntPtr data, int size); + public delegate void GSgifTransfer3(IntPtr data, int size); + public delegate void GSVSync(byte field); + public delegate void GSreset(); + public delegate void GSreadFIFO2(IntPtr data, int size); + public delegate void GSsetGameCRC(int crc, int options); + public delegate int GSfreeze(int mode, IntPtr data); + public delegate int GSopen(IntPtr hwnd, String Title, int renderer); + public delegate void GSclose(); + public delegate void GSshutdown(); + public delegate void GSConfigure(); + public delegate void GSsetBaseMem(IntPtr data); public delegate IntPtr PSEgetLibName(); - public delegate void GSinit(); + public delegate void GSinit(); public delegate UInt32 GSmakeSnapshot(string path); public class InvalidGSPlugin : Exception @@ -105,7 +105,6 @@ namespace GSDumpGUI if (dir == null) return; Directory.SetCurrentDirectory(dir); - System.Diagnostics.Trace.WriteLine("LoadLibrary: " + DLL); IntPtr hmod = NativeMethods.LoadLibrary(DLL); if (hmod != IntPtr.Zero) { @@ -174,7 +173,6 @@ namespace GSDumpGUI public void Unload() { - System.Diagnostics.Trace.WriteLine("FreeLibrary: " + DLL); NativeMethods.FreeLibrary(DLLAddr); Loaded = false; } @@ -218,7 +216,7 @@ namespace GSDumpGUI { byte[] GSFreez; - if (IntPtr.Size > 4) + if (Environment.Is64BitProcess) { GSFreez = new byte[16]; Array.Copy(BitConverter.GetBytes((Int64)dump.StateData.Length), 0, GSFreez, 0, 8); @@ -281,15 +279,18 @@ namespace GSDumpGUI switch (Mess.MessageType) { case MessageType.Step: - if (debug_idx >= dump.Data.Count) debug_idx = 0; + if (debug_idx >= dump.Data.Count) + debug_idx = 0; RunTo = debug_idx; break; case MessageType.RunToCursor: RunTo = (int)Mess.Parameters[0]; - if(debug_idx > RunTo) debug_idx = 0; + if(debug_idx > RunTo) + debug_idx = 0; break; case MessageType.RunToNextVSync: - if (debug_idx >= dump.Data.Count) debug_idx = 1; + if (debug_idx >= dump.Data.Count) + debug_idx = 1; RunTo = dump.Data.FindIndex(debug_idx, a => a.id == GSType.VSync); break; default: diff --git a/tools/GSDumpGUI/Library/GSDump/GSDump.cs b/tools/GSDumpGUI/Library/GSDump/GSDump.cs index 09b218987d..142584670a 100644 --- a/tools/GSDumpGUI/Library/GSDump/GSDump.cs +++ b/tools/GSDumpGUI/Library/GSDump/GSDump.cs @@ -101,8 +101,8 @@ namespace GSDumpGUI dmp.CRC = br.ReadInt32(); Int32 ss = br.ReadInt32(); - dmp.StateData = br.ReadBytes(ss); - + dmp.StateData = br.ReadBytes(ss); + dmp.Registers = br.ReadBytes(8192); while (br.PeekChar() != -1) diff --git a/tools/GSDumpGUI/Library/NativeMethods.cs b/tools/GSDumpGUI/Library/NativeMethods.cs index ecea1c5c2a..4d8e287f92 100644 --- a/tools/GSDumpGUI/Library/NativeMethods.cs +++ b/tools/GSDumpGUI/Library/NativeMethods.cs @@ -90,7 +90,7 @@ namespace GSDumpGUI public static UIntPtr SetClassLong(IntPtr hWnd, Int32 index, IntPtr dwNewLong) { - if (IntPtr.Size > 4) return SetClassLong64(hWnd, index, dwNewLong); + if (Environment.Is64BitProcess) return SetClassLong64(hWnd, index, dwNewLong); else return new UIntPtr(SetClassLong32(hWnd, index, dwNewLong.ToInt32())); } }