Skip to main content

LoadSession

Struct LoadSession 

Source
pub struct LoadSession {
    pub executable: PathBuf,
    pub root: Option<PathBuf>,
    pub pages: PageLayout,
    pub images: Vec<ProcessImage>,
    /* private fields */
}
Expand description

Configuration and state for loading one guest process image set.

Ownership model: after map, images is the single source of truth for parse / plan / GuestMemory. Before map, the main executable may live in private staging only (no duplicated top-level fields).

Fields§

§executable: PathBuf

Path to the main executable.

§root: Option<PathBuf>

Optional bottle root (KAKEHASHI_ROOT / --root).

§pages: PageLayout

Host/guest page geometry.

§images: Vec<ProcessImage>

Process image set (main at index 0 when mapped). Sole owner after map.

Implementations§

Source§

impl LoadSession

Source

pub fn open( executable: impl Into<PathBuf>, root: Option<PathBuf>, ) -> Result<Self, LoadError>

Starts a session for executable with detected host pages and default guest size.

Source

pub fn open_with_guest( executable: impl Into<PathBuf>, root: Option<PathBuf>, guest: GuestPageSize, ) -> Result<Self, LoadError>

Starts a session with an explicit guest page policy.

Source

pub fn executable(&self) -> &Path

Executable path.

Source

pub fn images(&self) -> &[ProcessImage]

All process images (mapped + skipped), main at index 0 when mapped.

Source

pub fn images_mut(&mut self) -> &mut [ProcessImage]

Mutable view of images (bind / patch prep).

Source

pub fn mapped_memories_mut(&mut self) -> impl Iterator<Item = &mut GuestMemory>

Iterator of mapped GuestMemory mut refs (main then dylibs, map order).

Source

pub fn load_main_image(&mut self) -> Result<&MachOImage, LoadError>

Parses the main executable into staged (or already mapped) state.

Source

pub fn plan_main_image(&mut self) -> Result<&ImagePlan, LoadError>

Parses (if needed) and builds an image plan for the main executable.

Source

pub fn map_main_image(&mut self) -> Result<&GuestMemory, LoadError>

Maps main only into images = [main] (no dependency walk).

Unit tests / simple tooling. Production dry_load and run_micro use Self::map_process.

Source

pub fn map_process(&mut self) -> Result<&[ProcessImage], LoadError>

Map main once, BFS-load allowed dylibs, rebase pointer arrays, bind.

Order matches a minimal dyld load sequence: map → rebase → bind.

Bind prefers chained fixups, then classic opcodes, else nlist → __got. Section rebase is skipped for images that use chained fixups.

Source

pub fn dry_load(&mut self) -> Result<DryLoadReport, LoadError>

Maps the process image set and builds a dry-load report for the CLI.

Source

pub fn memory_mut(&mut self) -> Option<&mut GuestMemory>

Mutable access to main mapped memory (after map).

Source

pub fn entry_va(&self) -> Option<u64>

Guest entry VA after main slide, if known.

Trait Implementations§

Source§

impl Debug for LoadSession

Source§

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

Formats the value using the given formatter. 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more