diff options
Diffstat (limited to 'miasm2/os_dep/common.py')
| -rw-r--r-- | miasm2/os_dep/common.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/miasm2/os_dep/common.py b/miasm2/os_dep/common.py index 7f8caed1..d70cdccf 100644 --- a/miasm2/os_dep/common.py +++ b/miasm2/os_dep/common.py @@ -55,14 +55,23 @@ class heap(object): self.addr &= self.mask ^ (self.align - 1) return ret - def alloc(self, jitter, size): + def alloc(self, jitter, size, perm=PAGE_READ|PAGE_WRITE): """ @jitter: a jitter instance @size: the size to allocate + @perm: permission flags (see vm_alloc doc) """ + return self.vm_alloc(jitter.vm, size, perm) + def vm_alloc(self, vm, size, perm=PAGE_READ|PAGE_WRITE): + """ + @vm: a VmMngr instance + @size: the size to allocate + @perm: permission flags (PAGE_READ, PAGE_WRITE, PAGE_EXEC or any `|` + combination of them); default is PAGE_READ|PAGE_WRITE + """ addr = self.next_addr(size) - jitter.vm.add_memory_page(addr, PAGE_READ | PAGE_WRITE, "\x00" * size) + vm.add_memory_page(addr, perm, "\x00" * size) return addr |