(ctx: *mut c_void, exit: uc_err)
| 126 | } |
| 127 | |
| 128 | pub unsafe extern "C" fn emu_stop(ctx: *mut c_void, exit: uc_err) -> uc_err { |
| 129 | tracing::debug!("emu_stop({})", fuzzware::uc_error_str(exit)); |
| 130 | let ctx = &mut *ctx.cast::<Context>(); |
| 131 | let vm = unsafe { &mut *ctx.vm }; |
| 132 | |
| 133 | // We might end up with an "uninitalized read" if this stop was requested as part of handling a |
| 134 | // MMIO access, so instead we store the exit code in `fuzzware_exit`. |
| 135 | vm.cpu.exception.code = ExceptionCode::Environment as u32; |
| 136 | vm.cpu.exception.value = 1; |
| 137 | |
| 138 | if vm.env_mut::<FuzzwareEnvironment>().unwrap().fuzzware_exit.is_some() { |
| 139 | // Avoid handling duplicate calls to emu_stop. |
| 140 | return UC_ERR_OK; |
| 141 | } |
| 142 | vm.env_mut::<FuzzwareEnvironment>().unwrap().fuzzware_exit = Some(exit); |
| 143 | |
| 144 | UC_ERR_OK |
| 145 | } |
| 146 | |
| 147 | #[cold] |
| 148 | #[inline(never)] |
nothing calls this directly
no outgoing calls
no test coverage detected