Fix rust formatting

This commit is contained in:
momo5502
2025-04-13 18:00:55 +02:00
committed by Maurice Heumann
parent 4f8c374b01
commit 81f6ce1f47

View File

@@ -153,7 +153,7 @@ impl ExecutionHooks {
}
let mapping = self.address_mapping.get(&address);
if mapping.is_none(){
if mapping.is_none() {
return;
}
@@ -165,7 +165,7 @@ impl ExecutionHooks {
}
}
pub fn execute(&mut self,cpu: &mut icicle_cpu::Cpu, address: u64) {
pub fn execute(&mut self, cpu: &mut icicle_cpu::Cpu, address: u64) {
self.run_hooks(address);
if *self.stop.borrow() {
@@ -188,7 +188,7 @@ impl ExecutionHooks {
}
pub fn remove_generic_hook(&mut self, id: u32) {
self.generic_hooks.remove_hook(id);
self.generic_hooks.remove_hook(id);
}
pub fn remove_specific_hook(&mut self, id: u32) {
@@ -198,7 +198,7 @@ impl ExecutionHooks {
});
self.specific_hooks.remove_hook(id);
}
}
}
pub struct IcicleEmulator {
@@ -377,9 +377,12 @@ impl IcicleEmulator {
let hook_id = self.violation_hooks.add_hook(callback);
return qualify_hook_id(hook_id, HookType::Violation);
}
pub fn add_execution_hook(&mut self, address:u64, callback: Box<dyn Fn(u64)>) -> u32 {
let hook_id = self.execution_hooks.borrow_mut().add_specific_hook(address, callback);
pub fn add_execution_hook(&mut self, address: u64, callback: Box<dyn Fn(u64)>) -> u32 {
let hook_id = self
.execution_hooks
.borrow_mut()
.add_specific_hook(address, callback);
return qualify_hook_id(hook_id, HookType::ExecuteSpecific);
}
@@ -404,7 +407,9 @@ impl IcicleEmulator {
end: u64,
callback: Box<dyn Fn(u64, &[u8])>,
) -> u32 {
let id = self.get_mem().add_read_after_hook(start, end, Box::new(MemoryHook { callback }));
let id = self
.get_mem()
.add_read_after_hook(start, end, Box::new(MemoryHook { callback }));
if id.is_none() {
return 0;
}
@@ -418,7 +423,9 @@ impl IcicleEmulator {
end: u64,
callback: Box<dyn Fn(u64, &[u8])>,
) -> u32 {
let id = self.get_mem().add_write_hook(start, end, Box::new(MemoryHook { callback }));
let id = self
.get_mem()
.add_write_hook(start, end, Box::new(MemoryHook { callback }));
if id.is_none() {
return 0;
}
@@ -433,10 +440,22 @@ impl IcicleEmulator {
HookType::Syscall => self.syscall_hooks.remove_hook(hook_id),
HookType::Violation => self.violation_hooks.remove_hook(hook_id),
HookType::Interrupt => self.interrupt_hooks.remove_hook(hook_id),
HookType::ExecuteGeneric => self.execution_hooks.borrow_mut().remove_generic_hook(hook_id),
HookType::ExecuteSpecific => self.execution_hooks.borrow_mut().remove_specific_hook(hook_id),
HookType::Read => {self.get_mem().remove_read_after_hook(hook_id);()},
HookType::Write => {self.get_mem().remove_write_hook(hook_id);()},
HookType::ExecuteGeneric => self
.execution_hooks
.borrow_mut()
.remove_generic_hook(hook_id),
HookType::ExecuteSpecific => self
.execution_hooks
.borrow_mut()
.remove_specific_hook(hook_id),
HookType::Read => {
self.get_mem().remove_read_after_hook(hook_id);
()
}
HookType::Write => {
self.get_mem().remove_write_hook(hook_id);
()
}
_ => {}
}
}
@@ -543,9 +562,7 @@ impl IcicleEmulator {
return reg_node.size.into();
}
fn read_flags<T>(&mut self, data: &mut [u8]) -> usize
{
fn read_flags<T>(&mut self, data: &mut [u8]) -> usize {
const REAL_SIZE: usize = std::mem::size_of::<u64>();
let limit: usize = std::mem::size_of::<T>();
let size = std::cmp::min(REAL_SIZE, limit);
@@ -567,8 +584,7 @@ impl IcicleEmulator {
}
}
fn write_flags<T>(&mut self, data: &[u8]) -> usize
{
fn write_flags<T>(&mut self, data: &[u8]) -> usize {
const REAL_SIZE: usize = std::mem::size_of::<u64>();
let limit: usize = std::mem::size_of::<T>();
let size = std::cmp::min(REAL_SIZE, limit);