pcsx2/tools/GSDumpGUI/Core/Program.cs
feal87 afde55c1c8 First commit as developer in the team. :P
Committed the first revision of the new GSDX Dump Viewer. At the moment it contains the PThreads dll inside the build process and output to the bin directory of the tools directory till I know for sure I can output the exe directly into pcsx2 bin directory. :P
Report here or on the issue tracker any bug you find. (in this application) :P

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2652 96395faa-99c1-11dd-bbfe-3dabce05a288
2010-03-01 16:47:58 +00:00

73 lines
2.7 KiB
C#

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)
{
if (args.Length == 3)
{
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];
// 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));
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
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
frmMain = new GSDumpGUI();
Application.Run(frmMain);
}
}
}
}