pub struct EnhancedChan<'a> { /* private fields */ }
Expand description

Channel for enhanced-RPC transfers.

This can be acquired via BackdoorGuard::open_enhanced_chan.

Implementations§

source§

impl<'a> EnhancedChan<'a>

source

pub fn open(guard: &'a mut BackdoorGuard) -> Result<Self, VmwError>

Open an enhanced-RPC channel.

source

pub fn close(self) -> Result<(), Self>

Close the channel.

On error, this returns back the channel.

source

pub fn get_guestinfo(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>, VmwError>

Retrieve a guestinfo property.

Examples found in repository?
examples/get-guestinfo.rs (line 23)
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
fn main() {
    let key = match env::args().collect::<Vec<_>>().get(1) {
        Some(val) => val.clone(),
        None => panic!("missing argument: key name"),
    };

    let is_vmw = vmw::is_vmware_cpu();
    eprintln!("VMware CPU detected: {}.", is_vmw);
    if !is_vmw {
        panic!("Hypervisor not present");
    }

    let mut backdoor = vmw::probe_backdoor_privileged().unwrap();
    eprintln!("Got backdoor access.");

    let mut erpc = backdoor.open_enhanced_chan().unwrap();
    eprintln!("Got ERPC channel: {:?}.", erpc);

    match erpc.get_guestinfo(key.as_bytes()).unwrap() {
        Some(val) => {
            eprintln!("Got value for key '{}'.", key);
            println!("{}", String::from_utf8_lossy(&val));
        }
        None => panic!("Guestinfo property not found."),
    };
}
source

pub fn log(&mut self, msg: &str) -> Result<(), VmwError>

Log a message.

Examples found in repository?
examples/log.rs (line 23)
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
fn main() {
    let msg = match env::args().collect::<Vec<_>>().get(1) {
        Some(val) => val.clone(),
        None => "Hello world (from vmw_backdoor)".to_string(),
    };

    let is_vmw = vmw::is_vmware_cpu();
    eprintln!("VMware CPU detected: {}.", is_vmw);
    if !is_vmw {
        panic!("Hypervisor not present");
    }

    let mut backdoor = vmw::probe_backdoor_privileged().unwrap();
    eprintln!("Got backdoor access.");

    let mut erpc = backdoor.open_enhanced_chan().unwrap();
    eprintln!("Got ERPC channel: {:?}.", erpc);

    erpc.log(&msg).unwrap();
    eprintln!("Sent log message: {}.", msg);
}
source

pub fn report_agent(&mut self) -> Result<(), VmwError>

Report agent (unmanaged) type.

Examples found in repository?
examples/report-agent.rs (line 17)
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
fn main() {
    let is_vmw = vmw::is_vmware_cpu();
    eprintln!("VMware CPU detected: {}.", is_vmw);
    if !is_vmw {
        panic!("Hypervisor not present");
    }

    let mut backdoor = vmw::probe_backdoor_privileged().unwrap();
    eprintln!("Got backdoor access.");

    let mut erpc = backdoor.open_enhanced_chan().unwrap();
    eprintln!("Got ERPC channel: {:?}.", erpc);

    erpc.report_agent().unwrap();
    eprintln!("Reported agent.");
}

Trait Implementations§

source§

impl<'a> Debug for EnhancedChan<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> Drop for EnhancedChan<'a>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for EnhancedChan<'a>

§

impl<'a> Send for EnhancedChan<'a>

§

impl<'a> Sync for EnhancedChan<'a>

§

impl<'a> Unpin for EnhancedChan<'a>

§

impl<'a> !UnwindSafe for EnhancedChan<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.