2017-08-19 22:40:14 +08:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Runtime.InteropServices;
|
2017-02-13 17:14:22 +08:00
|
|
|
|
|
|
|
|
|
namespace de4dot.Bea
|
|
|
|
|
{
|
2017-08-19 22:40:14 +08:00
|
|
|
|
public static class BeaEngine
|
2017-02-13 17:14:22 +08:00
|
|
|
|
{
|
2017-08-20 21:25:25 +08:00
|
|
|
|
// 'de4dot\bin\de4dot.blocks.dll' -> 'de4dot\bin\'
|
|
|
|
|
private static string _executingPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
|
|
|
|
|
|
2017-08-19 22:40:14 +08:00
|
|
|
|
static BeaEngine()
|
|
|
|
|
{
|
2017-08-20 21:25:25 +08:00
|
|
|
|
if (!File.Exists(Path.Combine(_executingPath, "BeaEngine.dll")))
|
2017-08-19 22:40:14 +08:00
|
|
|
|
{
|
|
|
|
|
throw new FileNotFoundException("BeaEngine.dll missing!");
|
|
|
|
|
}
|
2017-08-20 21:25:25 +08:00
|
|
|
|
|
|
|
|
|
//TODO: Better handle native DLL discovery
|
|
|
|
|
SetDllDirectory(_executingPath);
|
2017-08-19 22:40:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-20 21:25:25 +08:00
|
|
|
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
|
|
|
|
private static extern bool SetDllDirectory(string lpPathName);
|
|
|
|
|
|
2017-02-13 17:14:22 +08:00
|
|
|
|
[DllImport("BeaEngine.dll")]
|
|
|
|
|
public static extern int Disasm([In, Out, MarshalAs(UnmanagedType.LPStruct)] Disasm disasm);
|
|
|
|
|
|
|
|
|
|
[DllImport("BeaEngine.dll")]
|
|
|
|
|
private static extern string BeaEngineVersion();
|
|
|
|
|
|
|
|
|
|
[DllImport("BeaEngine.dll")]
|
|
|
|
|
private static extern string BeaEngineRevision();
|
|
|
|
|
|
|
|
|
|
public static string Version
|
2017-08-20 21:25:25 +08:00
|
|
|
|
{
|
2017-02-13 17:14:22 +08:00
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return BeaEngineVersion();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string Revision
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return BeaEngineRevision();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|