mirror of https://github.com/PCSX2/pcsx2.git
GSDXGSDumpGUI :
Big optimization, reorganization of the code to be more coherent. Now the Bitmap of "No Image" is created once. Fixed crash on opening the bitmap. Now the program change the GSDX window icon, with its own. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2666 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
85c23ce0a0
commit
b7f3b93ecd
|
@ -6,6 +6,7 @@ using Reflection = System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using GSDumpGUI.Properties;
|
||||||
|
|
||||||
namespace GSDumpGUI
|
namespace GSDumpGUI
|
||||||
{
|
{
|
||||||
|
@ -13,6 +14,8 @@ namespace GSDumpGUI
|
||||||
{
|
{
|
||||||
static public GSDumpGUI frmMain;
|
static public GSDumpGUI frmMain;
|
||||||
|
|
||||||
|
static private Boolean ChangeIcon;
|
||||||
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main(String[] args)
|
static void Main(String[] args)
|
||||||
{
|
{
|
||||||
|
@ -22,6 +25,15 @@ namespace GSDumpGUI
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
if (ChangeIcon)
|
||||||
|
{
|
||||||
|
IntPtr pt = Process.GetCurrentProcess().MainWindowHandle;
|
||||||
|
if (pt.ToInt64() != 0)
|
||||||
|
{
|
||||||
|
NativeMethods.SetClassLong(pt, -14, Resources.AppIcon.Handle.ToInt64());
|
||||||
|
ChangeIcon = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
Int32 tmp = NativeMethods.GetAsyncKeyState(0x1b) & 0xf;
|
Int32 tmp = NativeMethods.GetAsyncKeyState(0x1b) & 0xf;
|
||||||
if (tmp != 0)
|
if (tmp != 0)
|
||||||
Process.GetCurrentProcess().Kill();
|
Process.GetCurrentProcess().Kill();
|
||||||
|
@ -37,32 +49,19 @@ namespace GSDumpGUI
|
||||||
String Operation = args[2];
|
String Operation = args[2];
|
||||||
Int32 Renderer = Convert.ToInt32(args[3]);
|
Int32 Renderer = Convert.ToInt32(args[3]);
|
||||||
|
|
||||||
// Try to load the DLL in memory
|
GSDXWrapper wrap = new GSDXWrapper();
|
||||||
IntPtr hmod = NativeMethods.LoadLibrary(DLLPath);
|
wrap.Load(DLLPath);
|
||||||
if (hmod.ToInt64() > 0)
|
if (Operation == "GSReplay")
|
||||||
{
|
{
|
||||||
// Search if the DLL has the requested operation
|
ChangeIcon = true;
|
||||||
IntPtr funcaddr = NativeMethods.GetProcAddress(hmod, Operation);
|
if (Renderer != -1)
|
||||||
if (funcaddr.ToInt64() > 0)
|
wrap.GSReplayDump(Renderer + " " + DumpPath);
|
||||||
{
|
else
|
||||||
// Execute the appropriate function pointer by casting it to a delegate.
|
wrap.GSReplayDump(DumpPath);
|
||||||
if (Operation == "GSReplay")
|
|
||||||
{
|
|
||||||
GSDXImport.GSReplay dg = (GSDXImport.GSReplay)Marshal.GetDelegateForFunctionPointer(funcaddr, typeof(GSDXImport.GSReplay));
|
|
||||||
if (Renderer != -1)
|
|
||||||
dg.Invoke(new IntPtr(0), new IntPtr(0), Renderer + " " + DumpPath, false);
|
|
||||||
else
|
|
||||||
dg.Invoke(new IntPtr(0), new IntPtr(0), DumpPath, false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GSDXImport.GSConfigure dg = (GSDXImport.GSConfigure)Marshal.GetDelegateForFunctionPointer(funcaddr, typeof(GSDXImport.GSConfigure));
|
|
||||||
dg.Invoke();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Unload the library.
|
|
||||||
NativeMethods.FreeLibrary(hmod);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
wrap.GSConfig();
|
||||||
|
wrap.Unload();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -129,7 +129,6 @@
|
||||||
this.lstGSDX.Name = "lstGSDX";
|
this.lstGSDX.Name = "lstGSDX";
|
||||||
this.lstGSDX.Size = new System.Drawing.Size(301, 225);
|
this.lstGSDX.Size = new System.Drawing.Size(301, 225);
|
||||||
this.lstGSDX.TabIndex = 1;
|
this.lstGSDX.TabIndex = 1;
|
||||||
this.lstGSDX.KeyDown += new System.Windows.Forms.KeyEventHandler(this.lstGSDX_KeyDown);
|
|
||||||
//
|
//
|
||||||
// lstDumps
|
// lstDumps
|
||||||
//
|
//
|
||||||
|
@ -139,7 +138,6 @@
|
||||||
this.lstDumps.Size = new System.Drawing.Size(301, 225);
|
this.lstDumps.Size = new System.Drawing.Size(301, 225);
|
||||||
this.lstDumps.TabIndex = 0;
|
this.lstDumps.TabIndex = 0;
|
||||||
this.lstDumps.SelectedIndexChanged += new System.EventHandler(this.lstDumps_SelectedIndexChanged);
|
this.lstDumps.SelectedIndexChanged += new System.EventHandler(this.lstDumps_SelectedIndexChanged);
|
||||||
this.lstDumps.KeyDown += new System.Windows.Forms.KeyEventHandler(this.lstDumps_KeyDown);
|
|
||||||
//
|
//
|
||||||
// lblDumps
|
// lblDumps
|
||||||
//
|
//
|
||||||
|
@ -229,9 +227,10 @@
|
||||||
this.rdaDX9HW.Name = "rdaDX9HW";
|
this.rdaDX9HW.Name = "rdaDX9HW";
|
||||||
this.rdaDX9HW.Size = new System.Drawing.Size(68, 17);
|
this.rdaDX9HW.Size = new System.Drawing.Size(68, 17);
|
||||||
this.rdaDX9HW.TabIndex = 18;
|
this.rdaDX9HW.TabIndex = 18;
|
||||||
|
this.rdaDX9HW.Tag = "1";
|
||||||
this.rdaDX9HW.Text = "DX9 HW";
|
this.rdaDX9HW.Text = "DX9 HW";
|
||||||
this.rdaDX9HW.UseVisualStyleBackColor = true;
|
this.rdaDX9HW.UseVisualStyleBackColor = true;
|
||||||
this.rdaDX9HW.CheckedChanged += new System.EventHandler(this.rdaDX9HW_CheckedChanged);
|
this.rdaDX9HW.CheckedChanged += new System.EventHandler(this.rda_CheckedChanged);
|
||||||
//
|
//
|
||||||
// rdaDX10HW
|
// rdaDX10HW
|
||||||
//
|
//
|
||||||
|
@ -240,9 +239,10 @@
|
||||||
this.rdaDX10HW.Name = "rdaDX10HW";
|
this.rdaDX10HW.Name = "rdaDX10HW";
|
||||||
this.rdaDX10HW.Size = new System.Drawing.Size(74, 17);
|
this.rdaDX10HW.Size = new System.Drawing.Size(74, 17);
|
||||||
this.rdaDX10HW.TabIndex = 19;
|
this.rdaDX10HW.TabIndex = 19;
|
||||||
|
this.rdaDX10HW.Tag = "2";
|
||||||
this.rdaDX10HW.Text = "DX10 HW";
|
this.rdaDX10HW.Text = "DX10 HW";
|
||||||
this.rdaDX10HW.UseVisualStyleBackColor = true;
|
this.rdaDX10HW.UseVisualStyleBackColor = true;
|
||||||
this.rdaDX10HW.CheckedChanged += new System.EventHandler(this.rdaDX10HW_CheckedChanged);
|
this.rdaDX10HW.CheckedChanged += new System.EventHandler(this.rda_CheckedChanged);
|
||||||
//
|
//
|
||||||
// rdaDX9SW
|
// rdaDX9SW
|
||||||
//
|
//
|
||||||
|
@ -251,9 +251,10 @@
|
||||||
this.rdaDX9SW.Name = "rdaDX9SW";
|
this.rdaDX9SW.Name = "rdaDX9SW";
|
||||||
this.rdaDX9SW.Size = new System.Drawing.Size(67, 17);
|
this.rdaDX9SW.Size = new System.Drawing.Size(67, 17);
|
||||||
this.rdaDX9SW.TabIndex = 20;
|
this.rdaDX9SW.TabIndex = 20;
|
||||||
|
this.rdaDX9SW.Tag = "3";
|
||||||
this.rdaDX9SW.Text = "DX9 SW";
|
this.rdaDX9SW.Text = "DX9 SW";
|
||||||
this.rdaDX9SW.UseVisualStyleBackColor = true;
|
this.rdaDX9SW.UseVisualStyleBackColor = true;
|
||||||
this.rdaDX9SW.CheckedChanged += new System.EventHandler(this.rdaDX9SW_CheckedChanged);
|
this.rdaDX9SW.CheckedChanged += new System.EventHandler(this.rda_CheckedChanged);
|
||||||
//
|
//
|
||||||
// rdaDX10SW
|
// rdaDX10SW
|
||||||
//
|
//
|
||||||
|
@ -262,9 +263,10 @@
|
||||||
this.rdaDX10SW.Name = "rdaDX10SW";
|
this.rdaDX10SW.Name = "rdaDX10SW";
|
||||||
this.rdaDX10SW.Size = new System.Drawing.Size(73, 17);
|
this.rdaDX10SW.Size = new System.Drawing.Size(73, 17);
|
||||||
this.rdaDX10SW.TabIndex = 21;
|
this.rdaDX10SW.TabIndex = 21;
|
||||||
|
this.rdaDX10SW.Tag = "4";
|
||||||
this.rdaDX10SW.Text = "DX10 SW";
|
this.rdaDX10SW.Text = "DX10 SW";
|
||||||
this.rdaDX10SW.UseVisualStyleBackColor = true;
|
this.rdaDX10SW.UseVisualStyleBackColor = true;
|
||||||
this.rdaDX10SW.CheckedChanged += new System.EventHandler(this.rdaDX10SW_CheckedChanged);
|
this.rdaDX10SW.CheckedChanged += new System.EventHandler(this.rda_CheckedChanged);
|
||||||
//
|
//
|
||||||
// lblOverride
|
// lblOverride
|
||||||
//
|
//
|
||||||
|
@ -284,9 +286,10 @@
|
||||||
this.rdaNone.Size = new System.Drawing.Size(51, 17);
|
this.rdaNone.Size = new System.Drawing.Size(51, 17);
|
||||||
this.rdaNone.TabIndex = 23;
|
this.rdaNone.TabIndex = 23;
|
||||||
this.rdaNone.TabStop = true;
|
this.rdaNone.TabStop = true;
|
||||||
|
this.rdaNone.Tag = "0";
|
||||||
this.rdaNone.Text = "None";
|
this.rdaNone.Text = "None";
|
||||||
this.rdaNone.UseVisualStyleBackColor = true;
|
this.rdaNone.UseVisualStyleBackColor = true;
|
||||||
this.rdaNone.CheckedChanged += new System.EventHandler(this.rdaNone_CheckedChanged);
|
this.rdaNone.CheckedChanged += new System.EventHandler(this.rda_CheckedChanged);
|
||||||
//
|
//
|
||||||
// GSDumpGUI
|
// GSDumpGUI
|
||||||
//
|
//
|
||||||
|
|
|
@ -47,10 +47,18 @@ namespace GSDumpGUI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Bitmap NoImage;
|
||||||
|
|
||||||
public GSDumpGUI()
|
public GSDumpGUI()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Processes = new List<Process>();
|
Processes = new List<Process>();
|
||||||
|
|
||||||
|
NoImage = new Bitmap(320, 240, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
|
||||||
|
Graphics g = Graphics.FromImage(NoImage);
|
||||||
|
g.FillRectangle(new SolidBrush(Color.Black), new Rectangle(0, 0, 320, 240));
|
||||||
|
g.DrawString("No Image", new Font(FontFamily.GenericSansSerif, 48, FontStyle.Regular), new SolidBrush(Color.White), new PointF(0, 70));
|
||||||
|
g.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReloadGSDXs()
|
public void ReloadGSDXs()
|
||||||
|
@ -65,36 +73,16 @@ namespace GSDumpGUI
|
||||||
{
|
{
|
||||||
String[] File = Directory.GetFiles(txtGSDXDirectory.Text, "*.dll", SearchOption.TopDirectoryOnly);
|
String[] File = Directory.GetFiles(txtGSDXDirectory.Text, "*.dll", SearchOption.TopDirectoryOnly);
|
||||||
|
|
||||||
NativeMethods.SetErrorMode(0x8007);
|
GSDXWrapper wrap = new GSDXWrapper();
|
||||||
foreach (var itm in File)
|
foreach (var itm in File)
|
||||||
{
|
{
|
||||||
IntPtr hmod = NativeMethods.LoadLibrary(itm);
|
if (GSDXWrapper.IsValidGSDX(itm))
|
||||||
if (hmod.ToInt64() > 0)
|
|
||||||
{
|
{
|
||||||
IntPtr funcaddr = NativeMethods.GetProcAddress(hmod, "GSReplay");
|
wrap.Load(itm);
|
||||||
if (funcaddr.ToInt64() > 0)
|
lstGSDX.Items.Add(Path.GetFileName(itm) + " | " + wrap.PSEGetLibName());
|
||||||
{
|
wrap.Unload();
|
||||||
IntPtr funcaddrN = NativeMethods.GetProcAddress(hmod, "PSEgetLibName");
|
|
||||||
if (funcaddrN.ToInt64() > 0)
|
|
||||||
{
|
|
||||||
GSDXImport.PSEgetLibName ps = (GSDXImport.PSEgetLibName)Marshal.GetDelegateForFunctionPointer(funcaddrN, typeof(GSDXImport.PSEgetLibName));
|
|
||||||
lstGSDX.Items.Add(Path.GetFileName(itm) + " | " + Marshal.PtrToStringAnsi(ps.Invoke()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Int32 id = NativeMethods.GetLastError();
|
|
||||||
System.IO.File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "test.txt", itm + " failed to load. Error " + id + Environment.NewLine);
|
|
||||||
}
|
|
||||||
NativeMethods.FreeLibrary(hmod);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Int32 id = NativeMethods.GetLastError();
|
|
||||||
System.IO.File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "test.txt", itm + " failed to load. Error " + id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NativeMethods.SetErrorMode(0x0000);
|
|
||||||
|
|
||||||
String[] Dumps = Directory.GetFiles(txtDumpsDirectory.Text, "*.gs", SearchOption.TopDirectoryOnly);
|
String[] Dumps = Directory.GetFiles(txtDumpsDirectory.Text, "*.gs", SearchOption.TopDirectoryOnly);
|
||||||
|
|
||||||
|
@ -103,7 +91,7 @@ namespace GSDumpGUI
|
||||||
BinaryReader br = new BinaryReader(System.IO.File.Open(itm, FileMode.Open));
|
BinaryReader br = new BinaryReader(System.IO.File.Open(itm, FileMode.Open));
|
||||||
Int32 CRC = br.ReadInt32();
|
Int32 CRC = br.ReadInt32();
|
||||||
br.Close();
|
br.Close();
|
||||||
lstDumps.Items.Add(Path.GetFileName(itm) + " | CRC : " + CRC.ToString("x"));
|
lstDumps.Items.Add(Path.GetFileName(itm) + " | CRC : " + CRC.ToString("X"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,12 +276,7 @@ namespace GSDumpGUI
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Bitmap bt = new Bitmap(320, 240, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
|
pctBox.Image = NoImage;
|
||||||
Graphics g = Graphics.FromImage(bt);
|
|
||||||
g.FillRectangle(new SolidBrush(Color.Black), new Rectangle(0, 0, 320, 240));
|
|
||||||
g.DrawString("No Image", new Font(FontFamily.GenericSansSerif, 48, FontStyle.Regular), new SolidBrush(Color.White), new PointF(0,70));
|
|
||||||
g.Dispose();
|
|
||||||
pctBox.Image = bt;
|
|
||||||
pctBox.Cursor = Cursors.Default;
|
pctBox.Cursor = Cursors.Default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -303,73 +286,44 @@ namespace GSDumpGUI
|
||||||
{
|
{
|
||||||
if (pctBox.Cursor == Cursors.Hand)
|
if (pctBox.Cursor == Cursors.Hand)
|
||||||
{
|
{
|
||||||
String Filename = Path.GetDirectoryName(Properties.Settings.Default.DumpDir + "\\") + "\\" + Path.GetFileNameWithoutExtension(lstDumps.SelectedItem.ToString()) + ".bmp";
|
String DumpFileName = lstDumps.SelectedItem.ToString().Split(new char[] { '|' })[0];
|
||||||
|
String Filename = Path.GetDirectoryName(Properties.Settings.Default.DumpDir + "\\") +
|
||||||
|
"\\" + Path.GetFileNameWithoutExtension(DumpFileName) + ".bmp";
|
||||||
Process.Start(Filename);
|
Process.Start(Filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void lstDumps_KeyDown(object sender, KeyEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.KeyCode == Keys.Return)
|
|
||||||
cmdStart_Click(sender, e);
|
|
||||||
if (e.KeyCode == Keys.F1)
|
|
||||||
cmdConfigGSDX_Click(sender, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void lstGSDX_KeyDown(object sender, KeyEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.KeyCode == Keys.Return)
|
|
||||||
cmdStart_Click(sender, e);
|
|
||||||
if (e.KeyCode == Keys.F1)
|
|
||||||
cmdConfigGSDX_Click(sender, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void GSDumpGUI_KeyDown(object sender, KeyEventArgs e)
|
private void GSDumpGUI_KeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (e.KeyCode == Keys.Return)
|
||||||
|
cmdStart_Click(sender, e);
|
||||||
|
|
||||||
|
if (e.KeyCode == Keys.F1)
|
||||||
|
cmdConfigGSDX_Click(sender, e);
|
||||||
|
|
||||||
if ((e.KeyCode == Keys.Down))
|
if ((e.KeyCode == Keys.Down))
|
||||||
{
|
{
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
if (lstDumps.Items.Count > lstDumps.SelectedIndex + 1)
|
if (lstDumps.Items.Count > lstDumps.SelectedIndex + 1)
|
||||||
lstDumps.SelectedIndex++;
|
lstDumps.SelectedIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((e.KeyCode == Keys.Up))
|
if ((e.KeyCode == Keys.Up))
|
||||||
{
|
{
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
if (lstDumps.SelectedIndex > 0)
|
if (lstDumps.SelectedIndex > 0)
|
||||||
lstDumps.SelectedIndex--;
|
lstDumps.SelectedIndex--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((e.KeyCode == Keys.F2))
|
if ((e.KeyCode == Keys.F2))
|
||||||
SelectedRad++;
|
SelectedRad++;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rdaDX9HW_CheckedChanged(object sender, EventArgs e)
|
private void rda_CheckedChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (rdaDX9HW.Checked == true)
|
RadioButton itm = ((RadioButton)(sender));
|
||||||
SelectedRad = 1;
|
if (itm.Checked == true)
|
||||||
}
|
SelectedRad = Convert.ToInt32(itm.Tag);
|
||||||
|
|
||||||
private void rdaNone_CheckedChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (rdaNone.Checked == true)
|
|
||||||
SelectedRad = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void rdaDX10HW_CheckedChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (rdaDX10HW.Checked == true)
|
|
||||||
SelectedRad = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void rdaDX9SW_CheckedChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (rdaDX9SW.Checked == true)
|
|
||||||
SelectedRad = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void rdaDX10SW_CheckedChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (rdaDX10SW.Checked == true)
|
|
||||||
SelectedRad = 4;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
<Compile Include="Forms\frmMain.Designer.cs">
|
<Compile Include="Forms\frmMain.Designer.cs">
|
||||||
<DependentUpon>frmMain.cs</DependentUpon>
|
<DependentUpon>frmMain.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Library\GSDXImport.cs" />
|
<Compile Include="Library\GSDXWrapper.cs" />
|
||||||
<Compile Include="Library\NativeMethods.cs" />
|
<Compile Include="Library\NativeMethods.cs" />
|
||||||
<Compile Include="Core\Program.cs" />
|
<Compile Include="Core\Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace GSDumpGUI
|
|
||||||
{
|
|
||||||
static public class GSDXImport
|
|
||||||
{
|
|
||||||
public delegate void GSReplay(IntPtr HWND, IntPtr HInstance, String File, Boolean Show);
|
|
||||||
public delegate void GSConfigure();
|
|
||||||
public delegate IntPtr PSEgetLibName();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,105 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace GSDumpGUI
|
||||||
|
{
|
||||||
|
public class GSDXWrapper
|
||||||
|
{
|
||||||
|
private delegate void GSReplay(IntPtr HWND, IntPtr HInstance, String File, Boolean Show);
|
||||||
|
private delegate void GSConfigure();
|
||||||
|
private delegate IntPtr PSEgetLibName();
|
||||||
|
|
||||||
|
private GSReplay gsReplay;
|
||||||
|
private GSConfigure gsConfigure;
|
||||||
|
private PSEgetLibName PsegetLibName;
|
||||||
|
|
||||||
|
private Boolean Loaded;
|
||||||
|
|
||||||
|
private String DLL;
|
||||||
|
private IntPtr DLLAddr;
|
||||||
|
|
||||||
|
static public Boolean IsValidGSDX(String DLL)
|
||||||
|
{
|
||||||
|
NativeMethods.SetErrorMode(0x8007);
|
||||||
|
Boolean Ris = true;
|
||||||
|
IntPtr hmod = NativeMethods.LoadLibrary(DLL);
|
||||||
|
if (hmod.ToInt64() > 0)
|
||||||
|
{
|
||||||
|
IntPtr funcaddrReplay = NativeMethods.GetProcAddress(hmod, "GSReplay");
|
||||||
|
IntPtr funcaddrLibName = NativeMethods.GetProcAddress(hmod, "PSEgetLibName");
|
||||||
|
IntPtr funcaddrConfig = NativeMethods.GetProcAddress(hmod, "GSconfigure");
|
||||||
|
|
||||||
|
NativeMethods.FreeLibrary(hmod);
|
||||||
|
if (!((funcaddrConfig.ToInt64() > 0) && (funcaddrLibName.ToInt64() > 0) && (funcaddrReplay.ToInt64() > 0)))
|
||||||
|
{
|
||||||
|
Int32 id = NativeMethods.GetLastError();
|
||||||
|
System.IO.File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "test.txt", DLL + " failed to load. Error " + id);
|
||||||
|
Ris = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Int32 id = NativeMethods.GetLastError();
|
||||||
|
System.IO.File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "test.txt", DLL + " failed to load. Error " + id + Environment.NewLine);
|
||||||
|
Ris = false;
|
||||||
|
}
|
||||||
|
NativeMethods.SetErrorMode(0x0000);
|
||||||
|
return Ris;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Load(String DLL)
|
||||||
|
{
|
||||||
|
this.DLL = DLL;
|
||||||
|
NativeMethods.SetErrorMode(0x8007);
|
||||||
|
if (!IsValidGSDX(DLL))
|
||||||
|
throw new Exception("Invalid GSDX DLL");
|
||||||
|
|
||||||
|
if (Loaded)
|
||||||
|
Unload();
|
||||||
|
|
||||||
|
Loaded = true;
|
||||||
|
IntPtr hmod = NativeMethods.LoadLibrary(DLL);
|
||||||
|
if (hmod.ToInt64() > 0)
|
||||||
|
{
|
||||||
|
IntPtr funcaddrReplay = NativeMethods.GetProcAddress(hmod, "GSReplay");
|
||||||
|
IntPtr funcaddrLibName = NativeMethods.GetProcAddress(hmod, "PSEgetLibName");
|
||||||
|
IntPtr funcaddrConfig = NativeMethods.GetProcAddress(hmod, "GSconfigure");
|
||||||
|
|
||||||
|
gsReplay = (GSReplay)Marshal.GetDelegateForFunctionPointer(funcaddrReplay, typeof(GSReplay));
|
||||||
|
gsConfigure = (GSConfigure)Marshal.GetDelegateForFunctionPointer(funcaddrConfig, typeof(GSConfigure));
|
||||||
|
PsegetLibName = (PSEgetLibName)Marshal.GetDelegateForFunctionPointer(funcaddrLibName, typeof(PSEgetLibName));
|
||||||
|
DLLAddr = hmod;
|
||||||
|
}
|
||||||
|
NativeMethods.SetErrorMode(0x0000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Unload()
|
||||||
|
{
|
||||||
|
NativeMethods.FreeLibrary(DLLAddr);
|
||||||
|
Loaded = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GSConfig()
|
||||||
|
{
|
||||||
|
if (!Loaded)
|
||||||
|
throw new Exception("GSDX is not loaded");
|
||||||
|
gsConfigure.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GSReplayDump(String DumpFilename)
|
||||||
|
{
|
||||||
|
if (!Loaded)
|
||||||
|
throw new Exception("GSDX is not loaded");
|
||||||
|
gsReplay.Invoke(new IntPtr(0), new IntPtr(0), DumpFilename, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String PSEGetLibName()
|
||||||
|
{
|
||||||
|
if (!Loaded)
|
||||||
|
throw new Exception("GSDX is not loaded");
|
||||||
|
return Marshal.PtrToStringAnsi(PsegetLibName.Invoke());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,5 +31,9 @@ namespace GSDumpGUI
|
||||||
[SuppressUnmanagedCodeSecurityAttribute]
|
[SuppressUnmanagedCodeSecurityAttribute]
|
||||||
[DllImport("user32", CharSet = CharSet.Ansi)]
|
[DllImport("user32", CharSet = CharSet.Ansi)]
|
||||||
public extern static short GetAsyncKeyState(int key);
|
public extern static short GetAsyncKeyState(int key);
|
||||||
|
|
||||||
|
[SuppressUnmanagedCodeSecurityAttribute]
|
||||||
|
[DllImport("user32", CharSet = CharSet.Ansi)]
|
||||||
|
public extern static int SetClassLong(IntPtr HWND, int index, long newlong);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue