-
Notifications
You must be signed in to change notification settings - Fork 6
/
basic-process-list.rs
50 lines (41 loc) · 1.59 KB
/
basic-process-list.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use isr::cache::{IsrCache, JsonCodec};
use vmi::{
arch::amd64::Amd64, driver::xen::VmiXenDriver, os::windows::WindowsOs, VcpuId, VmiCore,
VmiSession,
};
use xen::XenStore;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let domain_id = 'x: {
for name in &["win7", "win10", "win11", "ubuntu22"] {
if let Some(domain_id) = XenStore::domain_id_from_name(name)? {
break 'x domain_id;
}
}
panic!("Domain not found");
};
// Setup VMI.
let driver = VmiXenDriver::<Amd64>::new(domain_id)?;
let core = VmiCore::new(driver)?;
// Try to find the kernel information.
// This is necessary in order to load the profile.
let kernel_info = {
let _pause_guard = core.pause_guard()?;
let registers = core.registers(VcpuId(0))?;
WindowsOs::find_kernel(&core, ®isters)?.expect("kernel information")
};
// Load the profile.
// The profile contains offsets to kernel functions and data structures.
let isr = IsrCache::<JsonCodec>::new("cache")?;
let entry = isr.entry_from_codeview(kernel_info.codeview)?;
let profile = entry.profile()?;
// Create the VMI session.
tracing::info!("Creating VMI session");
let os = WindowsOs::<VmiXenDriver<Amd64>>::new(&profile)?;
let session = VmiSession::new(&core, &os);
// Get the list of processes and print them.
let _pause_guard = session.pause_guard()?;
let registers = session.registers(VcpuId(0))?;
let processes = session.os().processes(®isters)?;
println!("Processes: {processes:#?}");
Ok(())
}