using System;
using System.Runtime.InteropServices;
namespace Keystone
{
internal class NativeInterop
{
[DllImport("keystone", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ks_version" )]
internal static extern uint Version(ref uint major, ref uint minor);
[DllImport("keystone", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ks_open")]
internal static extern KeystoneError Open(Architecture arch, int mode, ref IntPtr ks);
[DllImport("keystone", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ks_close")]
internal static extern KeystoneError Close(IntPtr ks);
[DllImport("keystone", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ks_free")]
internal static extern void Free(IntPtr buffer);
[DllImport("keystone", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ks_strerror")]
internal static extern IntPtr ErrorToString(KeystoneError code);
[DllImport("keystone", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ks_errno")]
internal static extern KeystoneError GetLastKeystoneError(IntPtr ks);
[DllImport("keystone", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ks_arch_supported")]
internal static extern bool IsArchitectureSupported(Architecture arch);
[DllImport("keystone", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ks_option")]
internal static extern KeystoneError SetOption(IntPtr ks, int type, IntPtr value);
[DllImport("keystone", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ks_asm")]
internal static extern int Assemble(IntPtr ks,
[MarshalAs(UnmanagedType.LPStr)] string toEncode,
ulong baseAddress,
out IntPtr encoding,
out uint size,
out uint statements);
}
}