From e88d386127b751d17b9005b2e374150473f42729 Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Fri, 26 Apr 2024 18:22:11 -0400 Subject: Fill out int_arg_registers and float_arg_registers in the Rust API --- rust/src/callingconvention.rs | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'rust/src') diff --git a/rust/src/callingconvention.rs b/rust/src/callingconvention.rs index 815f4d42..57f76a11 100644 --- a/rust/src/callingconvention.rs +++ b/rust/src/callingconvention.rs @@ -569,11 +569,43 @@ impl CallingConventionBase for CallingConvention { } fn int_arg_registers(&self) -> Vec { - Vec::new() + unsafe { + let mut count = 0; + let regs = BNGetIntegerArgumentRegisters(self.handle, &mut count); + let arch = self.arch_handle.borrow(); + + let res = slice::from_raw_parts(regs, count) + .iter() + .map(|&r| { + arch.register_from_id(r) + .expect("bad reg id from CallingConvention") + }) + .collect(); + + BNFreeRegisterList(regs); + + res + } } fn float_arg_registers(&self) -> Vec { - Vec::new() + unsafe { + let mut count = 0; + let regs = BNGetFloatArgumentRegisters(self.handle, &mut count); + let arch = self.arch_handle.borrow(); + + let res = slice::from_raw_parts(regs, count) + .iter() + .map(|&r| { + arch.register_from_id(r) + .expect("bad reg id from CallingConvention") + }) + .collect(); + + BNFreeRegisterList(regs); + + res + } } fn arg_registers_shared_index(&self) -> bool { -- cgit v1.3.1