DexReader

Struct DexReader 

Source
pub struct DexReader {
    pub bytes: Cursor<Vec<u8>>,
    pub bytes_len: u64,
    pub endianness: DexEndianness,
}
Expand description

A reader for a DEX file

Fields§

§bytes: Cursor<Vec<u8>>

A cursor over the bytes of the DEX file

§bytes_len: u64

Number of bytes in the DEX file

§endianness: DexEndianness

Endianness of the DEX file

Implementations§

Source§

impl DexReader

Source

pub fn build_from_file(filepath: &str) -> Result<Vec<DexReader>, DexError>

Open the file at the given path and create reader(s)

Each APK can contain multiple DEX files. This function extracts them all, create a reader from each, and returns a vector of readers.

Source

pub fn build(raw_dex: Vec<u8>) -> Result<Self, DexError>

Read a DEX file and create a reader from it

Source

pub fn check_endianness(bytes: &[u8]) -> Result<DexEndianness, DexError>

Check the endianness of a DEX file

Source

pub fn align_cursor(&mut self) -> Result<(), DexError>

Check if the cursor is on an even-numbered bytecode offsets and, if not, consume data until it is

Source

pub fn read_u8(&mut self) -> Result<u8, DexError>

Read an unsigned 8 bits integer from the reader

Source

pub fn read_u16(&mut self) -> Result<u16, DexError>

Read an unsigned 16 bits integer from the reader

Source

pub fn read_u32(&mut self) -> Result<u32, DexError>

Read an unsigned 32 bits integer from the reader

Source

pub fn read_i32(&mut self) -> Result<i32, DexError>

Read a signed 32 bits integer from the reader

Source

pub fn read_uleb128(&mut self) -> Result<(u32, usize), DexError>

Read an unsigned LEB128 value from the reader

Source

pub fn read_sleb128(&mut self) -> Result<(i32, usize), DexError>

Read a signed LEB128 value from the reader

Source

pub fn read_uleb128p1(&mut self) -> Result<(i32, usize), DexError>

Read a signed LEB128p1 value from the reader

Trait Implementations§

Source§

impl Debug for DexReader

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, 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> Same for T

Source§

type Output = T

Should always be Self
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.