2010-03-01 16:47:58 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using Specialized = System.Collections.Specialized;
|
|
|
|
|
using Reflection = System.Reflection;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
|
|
namespace GSDumpGUI
|
|
|
|
|
{
|
|
|
|
|
static class Program
|
|
|
|
|
{
|
|
|
|
|
static public GSDumpGUI frmMain;
|
|
|
|
|
|
|
|
|
|
[STAThread]
|
|
|
|
|
static void Main(String[] args)
|
|
|
|
|
{
|
2010-03-04 13:47:36 +00:00
|
|
|
|
if (args.Length == 4)
|
2010-03-01 16:47:58 +00:00
|
|
|
|
{
|
|
|
|
|
Thread thd = new Thread(new ThreadStart(delegate
|
|
|
|
|
{
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
Int32 tmp = NativeMethods.GetAsyncKeyState(0x1b) & 0xf;
|
|
|
|
|
if (tmp != 0)
|
|
|
|
|
Process.GetCurrentProcess().Kill();
|
|
|
|
|
Thread.Sleep(16);
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
thd.IsBackground = true;
|
|
|
|
|
thd.Start();
|
|
|
|
|
|
|
|
|
|
// Retrieve parameters
|
|
|
|
|
String DLLPath = args[0];
|
|
|
|
|
String DumpPath = args[1];
|
|
|
|
|
String Operation = args[2];
|
2010-03-04 13:47:36 +00:00
|
|
|
|
Int32 Renderer = Convert.ToInt32(args[3]);
|
2010-03-01 16:47:58 +00:00
|
|
|
|
|
|
|
|
|
// Try to load the DLL in memory
|
|
|
|
|
IntPtr hmod = NativeMethods.LoadLibrary(DLLPath);
|
|
|
|
|
if (hmod.ToInt64() > 0)
|
|
|
|
|
{
|
|
|
|
|
// Search if the DLL has the requested operation
|
|
|
|
|
IntPtr funcaddr = NativeMethods.GetProcAddress(hmod, Operation);
|
|
|
|
|
if (funcaddr.ToInt64() > 0)
|
|
|
|
|
{
|
|
|
|
|
// Execute the appropriate function pointer by casting it to a delegate.
|
|
|
|
|
if (Operation == "GSReplay")
|
|
|
|
|
{
|
|
|
|
|
GSDXImport.GSReplay dg = (GSDXImport.GSReplay)Marshal.GetDelegateForFunctionPointer(funcaddr, typeof(GSDXImport.GSReplay));
|
2010-03-04 13:47:36 +00:00
|
|
|
|
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);
|
2010-03-01 16:47:58 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GSDXImport.GSConfigure dg = (GSDXImport.GSConfigure)Marshal.GetDelegateForFunctionPointer(funcaddr, typeof(GSDXImport.GSConfigure));
|
|
|
|
|
dg.Invoke();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Unload the library.
|
|
|
|
|
NativeMethods.FreeLibrary(hmod);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Application.EnableVisualStyles();
|
|
|
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
|
|
|
frmMain = new GSDumpGUI();
|
|
|
|
|
Application.Run(frmMain);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|