MCPcopy Create free account
hub / github.com/MultiFuzz/MultiFuzz / write

Method write

icicle-cortexm/src/mmio.rs:157–179  ·  view source on GitHub ↗
(&mut self, addr: u64, value: &[u8])

Source from the content-addressed store, hash-verified

155 }
156
157 fn write(&mut self, addr: u64, value: &[u8]) -> MemResult<()> {
158 if self.models.is_empty() || !self.passthrough.is_empty() {
159 return Ok(());
160 }
161
162 let pc = unsafe {
163 let ctx = (*self.uc_ptr).ctx.cast::<crate::unicorn_api::Context>().as_mut().unwrap();
164 let vm = &mut *ctx.vm;
165 vm.cpu.read_pc() as u32
166 };
167
168 if let Some(model) =
169 self.models.iter().find(|x| x.addr == addr as u32 && (x.pc == pc || x.pc == 0xffffffff))
170 {
171 if let ModelKind::Passthrough { id } = model.kind {
172 let len = value.len().min(4);
173 let mut buf = [0; 4];
174 buf[..len].copy_from_slice(&value[..len]);
175 self.passthrough[id] = u32::from_le_bytes(buf);
176 }
177 }
178 Ok(())
179 }
180
181 fn snapshot(&mut self) -> Box<dyn std::any::Any> {
182 Box::new((self.passthrough.clone(), self.source.snapshot()))

Callers

nothing calls this directly

Calls 2

is_emptyMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected