Struct goblin::mach::segment::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>

§

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

The type of the elements being iterated over.
§

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>

§

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>,

§

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>,

§

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.