Skip to main content

HiberfilBuilder

Struct HiberfilBuilder 

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

Build a synthetic Windows hibernation file (hiberfil.sys).

Produces a PO_MEMORY_IMAGE header with “hibr” magic, processor state page with CR3, a page table page with PFN entries, and Xpress LZ77 compressed data blocks.

Layout:

  • Page 0 (offset 0x0000): PO_MEMORY_IMAGE header with “hibr” magic at 0x00, LengthSelf at 0x0C (256 = 64-bit), FirstTablePage at 0x68 (value 2).
  • Page 1 (offset 0x1000): Processor state page with CR3 at offset 0x28.
  • Page 2 (offset 0x2000): Page table – array of PFN entries (u64), terminated by 0xFFFF_FFFF_FFFF_FFFF.
  • After header pages: Xpress LZ77 compressed blocks. Block header: sig(8) + num_pages_minus_1(1) + compressed_size_field(3 bytes)
    • padding to 0x20 + compressed data.

Implementations§

Source§

impl HiberfilBuilder

Source

pub fn new() -> Self

Create a new builder with default CR3 (0x1ab000).

Source

pub fn cr3(self, cr3: u64) -> Self

Set the CR3 / DirectoryTableBase value stored in the processor state page.

Source

pub fn add_page(self, pfn: u64, data: &[u8; 4096]) -> Self

Add a physical memory page at the given PFN.

Source

pub fn build(self) -> Vec<u8>

Build the complete hibernation file as a byte vector.

Trait Implementations§

Source§

impl Default for HiberfilBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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.