Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

Commit

Permalink
Kernel Inline Hooks stable
Browse files Browse the repository at this point in the history
  • Loading branch information
memN0ps committed Jan 23, 2024
1 parent b380656 commit 4d3d648
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ A lightweight, memory-safe, and blazingly fast Rust-based type-2 research hyperv

- [x] **Extended Page Tables (EPT)**: Support for Memory Type Range Registers (MTRR).
- [x] **VM Exit Handling**: Handling of `ExceptionOrNmi (#GP, #PF, #BP)`, `Cpuid`, `Rdmsr`, `Wrmsr`, `Invd`, `Rdtsc`, `EptViolation`, `EptMisconfiguration`, `Invept`, `Invvpid`, `Xsetbv`.
- [x] **Kernel Inline Hooks (WIP)**: PatchGuard-compatible breakpoint (`int3`) hooks.
- [x] **Kernel Inline Hooks**: PatchGuard-compatible breakpoint (`int3`) hooks.
- [ ] **System Call (Syscall) Hooks (TODO)**: PatchGuard-compatible hooks for System Service Descriptor Table (SSDT) function entries.

## Planned Enhancements
Expand Down
6 changes: 6 additions & 0 deletions hypervisor/src/intel/vmexit/exception.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use {
},
x86::vmx::vmcs,
};
use crate::intel::support::vmwrite;

#[rustfmt::skip]
pub fn handle_exception(_guest_registers: &mut GuestRegisters, vmx: &mut Vmx) -> ExitType {
Expand Down Expand Up @@ -66,14 +67,19 @@ fn handle_breakpoint_exception(guest_registers: &mut GuestRegisters, _vmx: &mut
hook_manager
.find_hook_by_address(guest_registers.rip)
.map(|hook| {
log::info!("Found hook for RIP: {:#x}", guest_registers.rip);
if let HookType::Function { inline_hook } = &hook.hook_type {
log::info!("Getting handler address");
Some(inline_hook.handler_address())
} else {
None
}
})
{
// Call our hook handle function (it will automatically call trampoline).
log::info!("Transferring execution to handler: {:#x}", handler);
guest_registers.rip = handler;
vmwrite(vmcs::guest::RIP, guest_registers.rip);

ExitType::Continue
} else {
Expand Down

0 comments on commit 4d3d648

Please sign in to comment.