bindings: Rename dotnet project to UnicornEngine
Add a few more properties to prepare a nuget package
This commit is contained in:
11
bindings/dotnet/UnicornEngine/Binding/BindingFactory.fs
Normal file
11
bindings/dotnet/UnicornEngine/Binding/BindingFactory.fs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace UnicornEngine.Binding
|
||||
|
||||
|
||||
module BindingFactory =
|
||||
let mutable _instance = NativeBinding.instance
|
||||
|
||||
let setDefaultBinding(binding: IBinding) =
|
||||
_instance <- binding
|
||||
|
||||
let getDefault() =
|
||||
_instance
|
||||
28
bindings/dotnet/UnicornEngine/Binding/IBinding.fs
Normal file
28
bindings/dotnet/UnicornEngine/Binding/IBinding.fs
Normal file
@@ -0,0 +1,28 @@
|
||||
namespace UnicornEngine.Binding
|
||||
|
||||
open System
|
||||
|
||||
type IBinding =
|
||||
interface
|
||||
abstract Version : UIntPtr * UIntPtr -> Int32
|
||||
abstract ArchSupported : Int32 -> Boolean
|
||||
abstract UcOpen : UInt32 * UInt32 * UIntPtr array -> Int32
|
||||
abstract Close : UIntPtr -> Int32
|
||||
abstract Strerror : Int32 -> IntPtr
|
||||
abstract Errono : UIntPtr -> Int32
|
||||
abstract RegRead : UIntPtr * Int32 * Byte array -> Int32
|
||||
abstract RegWrite : UIntPtr * Int32 * Byte array -> Int32
|
||||
abstract MemRead : UIntPtr * UInt64 * Byte array * UIntPtr -> Int32
|
||||
abstract MemWrite : UIntPtr * UInt64 * Byte array * UIntPtr -> Int32
|
||||
abstract EmuStart : UIntPtr * UInt64 * UInt64 * UInt64 * UInt64 -> Int32
|
||||
abstract EmuStop : UIntPtr -> Int32
|
||||
abstract HookDel : UIntPtr * UIntPtr -> Int32
|
||||
abstract MemMap : UIntPtr * UInt64 * UIntPtr * UInt32 -> Int32
|
||||
abstract MemMapPtr : UIntPtr * UInt64 * UIntPtr * UInt32 * UIntPtr -> Int32
|
||||
abstract MemUnmap : UIntPtr * UInt64 * UIntPtr -> Int32
|
||||
abstract MemProtect : UIntPtr * UInt64 * UIntPtr * UInt32 -> Int32
|
||||
abstract HookAddNoarg : UIntPtr * UIntPtr * Int32 * UIntPtr * IntPtr * UInt64 * UInt64 -> Int32
|
||||
abstract HookAddArg0 : UIntPtr * UIntPtr * Int32 * UIntPtr * IntPtr * UInt64 * UInt64 * Int32 -> Int32
|
||||
abstract HookAddArg0Arg1 : UIntPtr * UIntPtr * Int32 * UIntPtr * IntPtr * UInt64 * UInt64 * UInt64 * UInt64 -> Int32
|
||||
end
|
||||
|
||||
51
bindings/dotnet/UnicornEngine/Binding/MockBinding.fs
Normal file
51
bindings/dotnet/UnicornEngine/Binding/MockBinding.fs
Normal file
@@ -0,0 +1,51 @@
|
||||
namespace UnicornEngine.Binding
|
||||
|
||||
open System
|
||||
|
||||
module internal MockBinding =
|
||||
// by using a mutables variables it is easier to create testing code
|
||||
let mutable version = fun(major, minor) -> 0
|
||||
let mutable uc_open = fun(arch, mode, uc) -> 0
|
||||
let mutable close = fun(eng) -> 0
|
||||
let mutable mem_map = fun(eng, adress, size, perm) -> 0
|
||||
let mutable mem_map_ptr = fun(eng, address, size, perms, ptr) -> 0
|
||||
let mutable mem_unmap = fun(eng, address, size) -> 0
|
||||
let mutable mem_protect = fun(eng, address, size, perms) -> 0
|
||||
let mutable mem_write = fun(eng, adress, value, size) -> 0
|
||||
let mutable mem_read = fun(eng, adress, value, size) -> 0
|
||||
let mutable reg_write = fun(eng, regId, value) -> 0
|
||||
let mutable reg_read = fun(eng, regId, value) -> 0
|
||||
let mutable emu_start = fun(eng, beginAddr, untilAddr, timeout, count) -> 0
|
||||
let mutable emu_stop = fun(eng) -> 0
|
||||
let mutable hook_del = fun(eng, hook) -> 0
|
||||
let mutable arch_supported = fun(arch) -> true
|
||||
let mutable errno = fun(eng) -> 0
|
||||
let mutable strerror = fun(err) -> new nativeint(0)
|
||||
let mutable hook_add_noarg = fun(eng, hh, callbackType, callback, userData, hookBegin, hookEnd) -> 0
|
||||
let mutable hook_add_arg0 = fun(eng, hh, callbackType, callback, userData, hookBegin, hookEnd, arg0) -> 0
|
||||
let mutable hook_add_arg0_arg1 = fun(eng, hh, callbackType, callback, userData, hookBegin, hookEnd, arg0, arg1) -> 0
|
||||
|
||||
let instance =
|
||||
{new IBinding with
|
||||
member thi.Version(major, minor) = version(major, minor)
|
||||
member thi.UcOpen(arch, mode, uc) = uc_open(arch, mode, uc)
|
||||
member thi.Close(eng) = close(eng)
|
||||
member thi.MemMap(eng, adress, size, perm) = mem_map(eng, adress, size, perm)
|
||||
member thi.MemWrite(eng, adress, value, size) = mem_write(eng, adress, value, size)
|
||||
member thi.MemRead(eng, adress, value, size) = mem_read(eng, adress, value, size)
|
||||
member thi.RegWrite(eng, regId, value) = reg_write(eng, regId, value)
|
||||
member thi.RegRead(eng, regId, value) = reg_read(eng, regId, value)
|
||||
member thi.EmuStart(eng, beginAddr, untilAddr, timeout, count) = emu_start(eng, beginAddr, untilAddr, timeout, count)
|
||||
member thi.EmuStop(eng) = emu_stop(eng)
|
||||
member this.HookDel(eng, hook) = hook_del(eng, hook)
|
||||
member thi.ArchSupported(arch) = arch_supported(arch)
|
||||
member thi.Errono(eng) = errno(eng)
|
||||
member thi.Strerror(err) = strerror(err)
|
||||
member this.MemMapPtr(eng, address, size, perms, ptr) = mem_map_ptr(eng, address, size, perms, ptr)
|
||||
member this.MemUnmap(eng, address, size) = mem_unmap(eng, address, size)
|
||||
member this.MemProtect(eng, address, size, perms) = mem_protect(eng, address, size, perms)
|
||||
member thi.HookAddNoarg(eng, hh, callbackType, callback, userData, hookBegin, hookEnd) = hook_add_noarg(eng, hh, callbackType, callback, userData, hookBegin, hookEnd)
|
||||
member thi.HookAddArg0(eng, hh, callbackType, callback, userData, hookBegin, hookEnd, arg0) = hook_add_arg0(eng, hh, callbackType, callback, userData, hookBegin, hookEnd, arg0)
|
||||
member thi.HookAddArg0Arg1(eng, hh, callbackType, callback, userData, hookBegin, hookEnd, arg0, arg1) = hook_add_arg0_arg1(eng, hh, callbackType, callback, userData, hookBegin, hookEnd, arg0, arg1)
|
||||
}
|
||||
|
||||
93
bindings/dotnet/UnicornEngine/Binding/NativeBinding.fs
Normal file
93
bindings/dotnet/UnicornEngine/Binding/NativeBinding.fs
Normal file
@@ -0,0 +1,93 @@
|
||||
namespace UnicornEngine.Binding
|
||||
|
||||
open System
|
||||
open System.Runtime.InteropServices
|
||||
|
||||
module NativeBinding =
|
||||
|
||||
[<AutoOpen>]
|
||||
module private Imported =
|
||||
|
||||
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl)>]
|
||||
extern Int32 uc_version(UIntPtr major, UIntPtr minor)
|
||||
|
||||
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl)>]
|
||||
extern Int32 uc_open(UInt32 arch, UInt32 mode, UIntPtr[] engine)
|
||||
|
||||
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl)>]
|
||||
extern Int32 uc_close(UIntPtr eng)
|
||||
|
||||
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl)>]
|
||||
extern Int32 uc_mem_map(UIntPtr eng, UInt64 address, UIntPtr size, UInt32 perm)
|
||||
|
||||
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl)>]
|
||||
extern Int32 uc_mem_map_ptr(UIntPtr eng, UInt64 address, UIntPtr size, UInt32 perm, UIntPtr ptr)
|
||||
|
||||
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl)>]
|
||||
extern Int32 uc_mem_unmap(UIntPtr eng, UInt64 address, UIntPtr size)
|
||||
|
||||
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl)>]
|
||||
extern Int32 uc_mem_protect(UIntPtr eng, UInt64 address, UIntPtr size, UInt32 perms)
|
||||
|
||||
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl)>]
|
||||
extern Int32 uc_mem_write(UIntPtr eng, UInt64 address, Byte[] value, UIntPtr size)
|
||||
|
||||
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl)>]
|
||||
extern Int32 uc_mem_read(UIntPtr eng, UInt64 address, Byte[] value, UIntPtr size)
|
||||
|
||||
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl)>]
|
||||
extern Int32 uc_reg_write(UIntPtr eng, Int32 regId, Byte[] value)
|
||||
|
||||
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl)>]
|
||||
extern Int32 uc_reg_read(UIntPtr eng, Int32 regId, Byte[] value)
|
||||
|
||||
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl)>]
|
||||
extern Int32 uc_emu_start(UIntPtr eng, UInt64 beginAddr, UInt64 untilAddr, UInt64 timeout, UInt64 count)
|
||||
|
||||
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl)>]
|
||||
extern Int32 uc_emu_stop(UIntPtr eng)
|
||||
|
||||
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl)>]
|
||||
extern Int32 uc_hook_del(UIntPtr eng, UIntPtr hook)
|
||||
|
||||
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl)>]
|
||||
extern Boolean uc_arch_supported(Int32 arch)
|
||||
|
||||
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl)>]
|
||||
extern Int32 uc_errno(UIntPtr eng)
|
||||
|
||||
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl)>]
|
||||
extern IntPtr uc_strerror(Int32 err)
|
||||
|
||||
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl, EntryPoint = "uc_hook_add")>]
|
||||
extern Int32 uc_hook_add_noarg(UIntPtr eng, UIntPtr hh, Int32 callbackType, UIntPtr callback, IntPtr userData, UInt64 hookbegin, UInt64 hookend)
|
||||
|
||||
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl, EntryPoint = "uc_hook_add")>]
|
||||
extern Int32 uc_hook_add_arg0(UIntPtr eng, UIntPtr hh, Int32 callbackType, UIntPtr callback, IntPtr userData, UInt64 hookbegin, UInt64 hookend, Int32 arg0)
|
||||
|
||||
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl, EntryPoint = "uc_hook_add")>]
|
||||
extern Int32 uc_hook_add_arg0_arg1(UIntPtr eng, UIntPtr hh, Int32 callbackType, UIntPtr callback, IntPtr userData, UInt64 hookbegin, UInt64 hookend, UInt64 arg0, UInt64 arg1)
|
||||
|
||||
let instance =
|
||||
{new IBinding with
|
||||
member thi.Version(major, minor) = uc_version(major, minor)
|
||||
member thi.UcOpen(arch, mode, uc) = uc_open(arch, mode, uc)
|
||||
member thi.Close(eng) = uc_close(eng)
|
||||
member thi.MemMap(eng, adress, size, perm) = uc_mem_map(eng, adress, size, perm)
|
||||
member thi.MemWrite(eng, adress, value, size) = uc_mem_write(eng, adress, value, size)
|
||||
member thi.MemRead(eng, adress, value, size) = uc_mem_read(eng, adress, value, size)
|
||||
member thi.RegWrite(eng, regId, value) = uc_reg_write(eng, regId, value)
|
||||
member thi.RegRead(eng, regId, value) = uc_reg_read(eng, regId, value)
|
||||
member thi.EmuStart(eng, beginAddr, untilAddr, timeout, count) = uc_emu_start(eng, beginAddr, untilAddr, timeout, count)
|
||||
member thi.EmuStop(eng) = uc_emu_stop(eng)
|
||||
member this.HookDel(eng, hook) = uc_hook_del(eng, hook)
|
||||
member thi.ArchSupported(arch) = uc_arch_supported(arch)
|
||||
member thi.Errono(eng) = uc_errno(eng)
|
||||
member thi.Strerror(err) = uc_strerror(err)
|
||||
member this.MemMapPtr(eng, address, size, perms, ptr) = uc_mem_map_ptr(eng, address, size, perms, ptr)
|
||||
member this.MemUnmap(eng, address, size) = uc_mem_unmap(eng, address, size)
|
||||
member this.MemProtect(eng, address, size, perms) = uc_mem_protect(eng, address, size, perms)
|
||||
member thi.HookAddNoarg(eng, hh, callbackType, callback, userData, hookBegin, hookEnd) = uc_hook_add_noarg(eng, hh, callbackType, callback, userData, hookBegin, hookEnd)
|
||||
member thi.HookAddArg0(eng, hh, callbackType, callback, userData, hookBegin, hookEnd, arg0) = uc_hook_add_arg0(eng, hh, callbackType, callback, userData, hookBegin, hookEnd, arg0)
|
||||
member thi.HookAddArg0Arg1(eng, hh, callbackType, callback, userData, hookBegin, hookEnd, arg0, arg1) = uc_hook_add_arg0_arg1(eng, hh, callbackType, callback, userData, hookBegin, hookEnd, arg0, arg1)
|
||||
}
|
||||
Reference in New Issue
Block a user