goblin::mach::segment

Struct Segment

Source
pub struct Segment<'a> {
    pub cmd: u32,
    pub cmdsize: u32,
    pub segname: [u8; 16],
    pub vmaddr: u64,
    pub vmsize: u64,
    pub fileoff: u64,
    pub filesize: u64,
    pub maxprot: u32,
    pub initprot: u32,
    pub nsects: u32,
    pub flags: u32,
    pub data: &'a [u8],
    /* private fields */
}
Expand description

Generalized 32/64 bit Segment Command

Fields§

§cmd: u32§cmdsize: u32§segname: [u8; 16]§vmaddr: u64§vmsize: u64§fileoff: u64§filesize: u64§maxprot: u32§initprot: u32§nsects: u32§flags: u32§data: &'a [u8]

Implementations§

Source§

impl<'a> Segment<'a>

Source

pub fn new(ctx: Ctx, sections: &'a [u8]) -> Self

Create a new, blank segment, with cmd either LC_SEGMENT_64, or LC_SEGMENT, depending on ctx. NB You are responsible for providing a correctly marshalled byte array as the sections. You should not use this for anything other than writing.

Source

pub fn name(&self) -> Result<&str>

Get the name of this segment

Source

pub fn sections(&self) -> Result<Vec<(Section, SectionData<'a>)>>

Get the sections from this segment, erroring if any section couldn’t be retrieved

Source

pub fn from_32( bytes: &'a [u8], segment: &SegmentCommand32, offset: usize, ctx: Ctx, ) -> Result<Self, Error>

Convert the raw C 32-bit segment command to a generalized version

Source

pub fn from_32_lossy( bytes: &'a [u8], segment: &SegmentCommand32, offset: usize, ctx: Ctx, ) -> Result<Self, Error>

Convert the raw C 32-bit segment command to a generalized version

Source

pub fn from_64( bytes: &'a [u8], segment: &SegmentCommand64, offset: usize, ctx: Ctx, ) -> Result<Self, Error>

Convert the raw C 64-bit segment command to a generalized version

Source

pub fn from_64_lossy( bytes: &'a [u8], segment: &SegmentCommand64, offset: usize, ctx: Ctx, ) -> Result<Self, Error>

Convert the raw C 64-bit segment command to a generalized version

Trait Implementations§

Source§

impl<'a> Debug for Segment<'a>

Source§

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

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

impl<'a> From<Segment<'a>> for SegmentCommand32

Source§

fn from(segment: Segment<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<Segment<'a>> for SegmentCommand64

Source§

fn from(segment: Segment<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> IntoCtx<Ctx> for Segment<'a>

Source§

fn into_ctx(self, bytes: &mut [u8], ctx: Ctx)

Source§

impl<'a, 'b> IntoIterator for &'b Segment<'a>

Source§

type Item = Result<(Section, &'a [u8]), Error>

The type of the elements being iterated over.
Source§

type IntoIter = SectionIterator<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a> SizeWith<Ctx> for Segment<'a>

Source§

impl<'a> TryIntoCtx<Ctx> for Segment<'a>

Source§

type Error = Error

Source§

fn try_into_ctx(self, bytes: &mut [u8], ctx: Ctx) -> Result<usize, Self::Error>

Auto Trait Implementations§

§

impl<'a> Freeze for Segment<'a>

§

impl<'a> RefUnwindSafe for Segment<'a>

§

impl<'a> Send for Segment<'a>

§

impl<'a> Sync for Segment<'a>

§

impl<'a> Unpin for Segment<'a>

§

impl<'a> UnwindSafe for Segment<'a>

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.