Struct ds_rom::rom::Arm9

source ·
pub struct Arm9<'a> { /* private fields */ }
Expand description

ARM9 program.

Implementations§

source§

impl<'a> Arm9<'a>

source

pub fn new<T: Into<Cow<'a, [u8]>>>( data: T, header_version: HeaderVersion, offsets: Arm9Offsets, ) -> Self

Creates a new ARM9 program from raw data.

source

pub fn with_two_tcms( data: Vec<u8>, itcm: Autoload<'_>, dtcm: Autoload<'_>, header_version: HeaderVersion, offsets: Arm9Offsets, ) -> Result<Self, RawBuildInfoError>

Creates a new ARM9 program with raw data and two autoloads (ITCM and DTCM).

§Errors

See Self::build_info_mut.

source

pub fn is_encrypted(&self) -> bool

Returns whether the secure area is encrypted.

source

pub fn decrypt( &mut self, key: &BlowfishKey, gamecode: u32, ) -> Result<(), Arm9Error>

Decrypts the secure area. Does nothing if already decrypted.

§Errors

This function will return an error if the program is too small to contain a secure area, Blowfish::decrypt fails or “encryObj” was not found.

source

pub fn encrypt( &mut self, key: &BlowfishKey, gamecode: u32, ) -> Result<(), Arm9Error>

Encrypts the secure area. Does nothing if already encrypted.

§Errors

This function will return an error if the program is too small to contain a secure area, or the secure area ID was not found.

source

pub fn encrypted_secure_area( &self, key: &BlowfishKey, gamecode: u32, ) -> [u8; 16384]

Returns an encrypted copy of the secure area.

source

pub fn secure_area_crc(&self, key: &BlowfishKey, gamecode: u32) -> u16

Returns a CRC checksum of the encrypted secure area.

source

pub fn build_info(&self) -> Result<&BuildInfo, RawBuildInfoError>

Returns a reference to the build info.

§Errors

See BuildInfo::borrow_from_slice.

source

pub fn build_info_mut(&mut self) -> Result<&mut BuildInfo, RawBuildInfoError>

Returns a mutable reference to the build info.

§Errors

See BuildInfo::borrow_from_slice_mut.

source

pub fn is_compressed(&self) -> Result<bool, RawBuildInfoError>

Returns whether this ARM9 program is compressed.

§Errors

See Self::build_info.

source

pub fn decompress(&mut self) -> Result<(), Arm9Error>

Decompresses this ARM9 program. Does nothing if already decompressed.

§Errors

See Self::is_compressed and Self::build_info_mut.

source

pub fn compress(&mut self) -> Result<(), Arm9Error>

Compresses this ARM9 program. Does nothing if already compressed.

§Errors

See Self::is_compressed, Lz77::compress and Self::build_info_mut.

source

pub fn autoload_infos(&self) -> Result<&[AutoloadInfo], Arm9AutoloadError>

Returns the autoload infos of this Arm9.

§Errors

This function will return an error if Self::build_info or Self::get_autoload_infos fails or this ARM9 program is compressed.

source

pub fn autoloads(&self) -> Result<Box<[Autoload<'_>]>, Arm9AutoloadError>

Returns the autoloads of this Arm9.

§Errors

This function will return an error if Self::build_info or Self::get_autoload_infos fails or this ARM9 program is compressed.

source

pub fn code(&self) -> Result<&[u8], RawBuildInfoError>

Returns the code of this ARM9 program.

§Errors

See Self::build_info.

source

pub fn full_data(&self) -> &[u8]

Returns a reference to the full data.

source

pub fn base_address(&self) -> u32

Returns the base address.

source

pub fn entry_function(&self) -> u32

Returns the entry function address.

source

pub fn build_info_offset(&self) -> u32

Returns the build info offset.

source

pub fn autoload_callback(&self) -> u32

Returns the autoload callback address.

source

pub fn bss(&self) -> Result<Range<u32>, RawBuildInfoError>

Returns the Range of uninitialized data in this ARM9 program.

§Errors

See Self::build_info.

source

pub fn offsets(&self) -> &Arm9Offsets

Returns a reference to the ARM9 offsets.

Trait Implementations§

source§

impl<'a> AsRef<[u8]> for Arm9<'a>

source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<'a> Clone for Arm9<'a>

source§

fn clone(&self) -> Arm9<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Arm9<'a>

§

impl<'a> RefUnwindSafe for Arm9<'a>

§

impl<'a> Send for Arm9<'a>

§

impl<'a> Sync for Arm9<'a>

§

impl<'a> Unpin for Arm9<'a>

§

impl<'a> UnwindSafe for Arm9<'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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.