using System; using System.Runtime.InteropServices; namespace Dbcc { /// /// Imported symbols for interop with dbcc.dll/so. /// internal class NativeInterop { // This shouldn't be needed, even on Windows // /// // /// Taken from: http://stackoverflow.com/questions/10852634/using-a-32bit-or-64bit-dll-in-c-sharp-dllimport // /// // static NativeInterop() // { // var myPath = new Uri(typeof(NativeInterop).Assembly.CodeBase).LocalPath; // var myFolder = Path.GetDirectoryName(myPath); // var is64 = IntPtr.Size == 8; // var subfolder = is64 ? "\\win64\\" : "\\win32\\"; // string dllPosition = myFolder + subfolder + "keystone.dll"; // // If this file exist, load it. // // Otherwise let the marshaller load the appropriate file. // if (File.Exists(dllPosition)) // LoadLibrary(dllPosition); // } // [DllImport("dbcc.dll")] // private static extern IntPtr LoadLibrary(string dllToLoad); [DllImport("dbcc", CallingConvention = CallingConvention.Cdecl, EntryPoint = "version" )] internal static extern uint Version(ref uint major, ref uint minor); [DllImport("dbcc", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SignalProcessor_new")] internal static extern uint Create(ref IntPtr h, [MarshalAs(UnmanagedType.LPStr)] string filePath); [DllImport("dbcc", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SignalProcessor_delete")] internal static extern void Dispose(IntPtr h); [DllImport("dbcc", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SignalProcessor_encode")] internal static extern int Encode(IntPtr h, double pvs, [MarshalAs(UnmanagedType.LPArray)] ref byte[] data, uint length); [DllImport("dbcc", CallingConvention = CallingConvention.Cdecl, EntryPoint = "SignalProcessor_decode")] bool Decode(IntPtr h, uint msgId, [MarshalAs(UnmanagedType.LPArray)] byte[] data, uint length); } }