pub struct Interrupt {
pub vector: ExceptionVector,
pub typ: InterruptType,
pub error_code: u32,
pub instruction_length: u8,
pub extra: u64,
}Available on crate feature
arch-amd64 only.Expand description
Information about an interrupt or exception.
Fields§
§vector: ExceptionVectorVector number of the interrupt.
typ: InterruptTypeType of interrupt.
error_code: u32Error code associated with the interrupt.
instruction_length: u8Length of the instruction that caused the interrupt.
extra: u64Extra information about the interrupt.
For page faults, this is the virtual address that caused the fault
(i.e., CR2).
Implementations§
Source§impl Interrupt
impl Interrupt
Sourcepub fn breakpoint(instruction_length: u8) -> Interrupt
pub fn breakpoint(instruction_length: u8) -> Interrupt
Creates a new software breakpoint exception.
Sourcepub fn page_fault(va: Va, error_code: u32) -> Interrupt
pub fn page_fault(va: Va, error_code: u32) -> Interrupt
Creates a new page fault exception.
Examples found in repository?
examples/windows-breakpoint-manager.rs (line 522)
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527
fn dispatch(
&mut self,
vmi: &VmiContext<'_, Driver, WindowsOs<Driver>>,
) -> Result<VmiEventResponse<Amd64>, VmiError> {
let event = vmi.event();
let result = match event.reason() {
EventReason::MemoryAccess(_) => self.memory_access(vmi),
EventReason::Interrupt(_) => self.interrupt(vmi),
EventReason::Singlestep(_) => self.singlestep(vmi),
_ => panic!("Unhandled event: {:?}", event.reason()),
};
// If VMI tries to read from a page that is not present, it will return
// a page fault error. In this case, we inject a page fault interrupt
// to the guest.
//
// Once the guest handles the page fault, it will try to retry the
// instruction that caused the page fault.
if let Err(VmiError::PageFault(pfs)) = result {
tracing::warn!(?pfs, "Page fault, injecting");
vmi.inject_interrupt(event.vcpu_id(), Interrupt::page_fault(pfs[0].address, 0))?;
return Ok(VmiEventResponse::default());
}
result
}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Interrupt
impl RefUnwindSafe for Interrupt
impl Send for Interrupt
impl Sync for Interrupt
impl Unpin for Interrupt
impl UnwindSafe for Interrupt
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)