Go binding: add mem_protect wrapper

This commit is contained in:
Ryan Hileman 2015-12-05 11:24:56 -08:00
parent c37b2582d7
commit 638ff7a3f5

View file

@ -28,6 +28,7 @@ func errReturn(err C.uc_err) error {
type Unicorn interface { type Unicorn interface {
MemMap(addr, size uint64) error MemMap(addr, size uint64) error
MemMapProt(addr, size uint64, prot int) error MemMapProt(addr, size uint64, prot int) error
MemProtect(addr, size uint64, prot int) error
MemUnmap(addr, size uint64) error MemUnmap(addr, size uint64) error
MemRead(addr, size uint64) ([]byte, error) MemRead(addr, size uint64) ([]byte, error)
MemReadInto(dst []byte, addr uint64) 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) 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 { func (u *uc) MemUnmap(addr, size uint64) error {
return errReturn(C.uc_mem_unmap(u.handle, C.uint64_t(addr), C.size_t(size))) return errReturn(C.uc_mem_unmap(u.handle, C.uint64_t(addr), C.size_t(size)))
} }