Implemented uc_strerror and minor refactoring

This commit is contained in:
Antonio Parata
2015-10-15 11:24:20 +02:00
parent 03b2fbfbcb
commit c0ba09e0b8
4 changed files with 15 additions and 62 deletions

View File

@@ -55,7 +55,7 @@ and Unicorn(arch: Int32, mode: Int32) =
let mutable _eng = [|UIntPtr.Zero|]
let checkResult(errCode: Int32, errMsg: String) =
if errCode <> Common.UC_ERR_OK then raise(ApplicationException(errMsg + ". Error: " + UcError.toErrorDesc(errCode)))
if errCode <> Common.UC_ERR_OK then raise(ApplicationException(String.Format("{0}. Error: {1}", errMsg, errCode)))
let getId =
let counter = ref 0
@@ -103,9 +103,9 @@ and Unicorn(arch: Int32, mode: Int32) =
member this.ErrNo() =
NativeUnicornEngine.errno(_eng.[0])
member this.StrError() =
// TODO: to be implemented
raise(NotImplementedException())
member this.StrError(errorNo: Int32) =
let errorStringPointer = NativeUnicornEngine.strerror(errorNo)
Marshal.PtrToStringAnsi(errorStringPointer)
member this.AddCodeHook(callback: CodeHook, userData: Object, beginAdd: UInt64, endAddr: UInt64) =
let trampoline(u: IntPtr) (addr: UInt64) (size: Int32) (user: IntPtr) =