Struct Prefetch

Source
pub struct Prefetch { /* private fields */ }
Expand description

A Prefetch file reader and parser.

§Basic Example

use libprefetch::Prefetch;


let file = std::fs::File::open("assets/WUAUCLT.EXE-399A8E72.pf").unwrap();

let prefetch = Prefetch::new(file).unwrap();

// Or with a path

let prefetch =
     Prefetch::from_path("assets/WUAUCLT.EXE-399A8E72.pf").unwrap();

Implementations§

Source§

impl Prefetch

Source

pub fn version(&self) -> FormatVersion

Returns the version of the Prefetch file.

Source

pub fn size(&self) -> usize

Returns the size of the Prefetch file.

Source

pub fn name(&self) -> &str

Returns the name of the executable.

Source

pub fn hash(&self) -> u32

Returns the prefetch hash of the executable.

Source

pub fn last_execution_time(&self) -> u64

Returns the last execution time, in FILETIME format

Source

pub fn execution_counter(&self) -> usize

Returns the execution counter (how many times the exe was run).

Source

pub fn metrics(&self) -> Result<MetricIterator<'_>, Error>

Returns an Iterator for file metrics.

§Example
use libprefetch::Prefetch;

let prefetch =
    Prefetch::from_path("assets/WUAUCLT.EXE-399A8E72.pf").unwrap();

// Iterate over metrics
for metric in prefetch.metrics().unwrap() {
    println!("Loaded file by the exe: {}", metric.filename());
}
Source

pub fn trace(&self) -> Result<TraceIterator<'_>, Error>

Returns an Iterator for the trace chains.

§Example
use libprefetch::Prefetch;

let prefetch =
    Prefetch::from_path("assets/WUAUCLT.EXE-399A8E72.pf").unwrap();

// Iterate over the chain
for item in prefetch.trace().unwrap() {
    println!("Trace #{}, bytes loaded:: {}", item.id(), item.load_count());
}
Source

pub fn volumes(&self) -> Result<VolumeIterator<'_>, Error>

Returns an Iterator for the volumes.

§Example
use libprefetch::Prefetch;

let prefetch =
    Prefetch::from_path("assets/WUAUCLT.EXE-399A8E72.pf").unwrap();

// Iterates over the volumes
println!(" ===== Volumes ===== ");
for volume in prefetch.volumes().unwrap() {
  println!("Volume #{}:", volume.id());
  println!("    Path: {}", volume.device_path());
  println!("    Creation time: {}", volume.creation_time());
  println!("    Serial number: {}", volume.serial_number());
  println!("    Directories: ");
  for directory in volume.directories().unwrap() {
    println!("        {}", directory);
  }
}
Source

pub fn new<T>(src: T) -> Result<Prefetch, Error>
where T: Read,

Constructs a new Prefetch from a std::io::Read source.

§Example
use libprefetch::Prefetch;

let file = std::fs::File::open("assets/WUAUCLT.EXE-399A8E72.pf").unwrap();

let prefetch = Prefetch::new(file).unwrap();
Source

pub fn from_path(path: &str) -> Result<Prefetch, Error>

Constructs a new Prefetch from a file path.

§Example
use libprefetch::Prefetch;

let prefetch
     = Prefetch::from_path("assets/WUAUCLT.EXE-399A8E72.pf").unwrap();

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.