add offset, size arguments to disasm_iter

This commit is contained in:
Richard Patel 2021-08-19 00:56:39 +02:00
parent e55398cd01
commit 57a317a6b2
1 changed files with 9 additions and 3 deletions

View File

@ -120,10 +120,16 @@ impl PyIterProtocol for DisasmIterator {
}
}
#[pyfunction]
fn disasm_iter(code: &[u8], addr: u32) -> PyResult<DisasmIterator> {
#[pyfunction(code, addr, offset = "0", size = "None")]
fn disasm_iter(code: &[u8], addr: u32, offset: u32, size: Option<u32>) -> PyResult<DisasmIterator> {
let mut bytes = &code[offset as usize..];
if let Some(size) = size {
if (size as usize) < bytes.len() {
bytes = &bytes[..size as usize];
}
}
Ok(DisasmIterator {
bytes: code.to_vec(),
bytes: bytes.to_vec(),
addr,
offset: 0,
})