From 638ff7a3f52e031593fc3ef85c20301d9afd2572 Mon Sep 17 00:00:00 2001 From: Ryan Hileman Date: Sat, 5 Dec 2015 11:24:56 -0800 Subject: [PATCH] Go binding: add mem_protect wrapper --- bindings/go/unicorn/unicorn.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bindings/go/unicorn/unicorn.go b/bindings/go/unicorn/unicorn.go index 2cabac74..46802f46 100644 --- a/bindings/go/unicorn/unicorn.go +++ b/bindings/go/unicorn/unicorn.go @@ -28,6 +28,7 @@ func errReturn(err C.uc_err) error { type Unicorn interface { MemMap(addr, size uint64) error MemMapProt(addr, size uint64, prot int) error + MemProtect(addr, size uint64, prot int) error MemUnmap(addr, size uint64) error MemRead(addr, size uint64) ([]byte, error) MemReadInto(dst []byte, addr uint64) error @@ -128,6 +129,10 @@ func (u *uc) MemMap(addr, size uint64) error { return u.MemMapProt(addr, size, PROT_ALL) } +func (u *uc) MemProtect(addr, size uint64, prot int) error { + return errReturn(C.uc_mem_protect(u.handle, C.uint64_t(addr), C.size_t(size), C.uint32_t(prot))) +} + func (u *uc) MemUnmap(addr, size uint64) error { return errReturn(C.uc_mem_unmap(u.handle, C.uint64_t(addr), C.size_t(size))) }