Skip to main content

Arm9

Struct 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, offsets: Arm9Offsets, ) -> Result<Self, RawBuildInfoError>

Creates a new ARM9 program from raw data.

Source

pub fn with_two_tcms( data: Vec<u8>, itcm: Autoload<'_>, dtcm: Autoload<'_>, offsets: Arm9Offsets, options: Arm9WithTcmsOptions, ) -> 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 with_autoloads( data: Vec<u8>, autoloads: &[Autoload<'_>], offsets: Arm9Offsets, options: Arm9WithTcmsOptions, ) -> Result<Self, RawBuildInfoError>

Creates a new ARM9 program with raw data and a list of autoloads.

§Errors

See Self::build_info_mut.

Source

pub fn is_encrypted(&self) -> bool

Returns whether the secure area is encrypted. See Self::originally_encrypted for whether the secure area was encrypted originally.

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 libraries(&self) -> Result<Box<[LibraryEntry<'_>]>, Utf8Error>

Returns the library version strings in this Arm9.

§Errors

This function will return an error if a library string is not valid UTF-8.

Source

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

Returns whether this ARM9 program is compressed. See Self::originally_compressed for whether the program was compressed originally.

§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<Vec<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 num_unknown_autoloads(&self) -> Result<usize, Arm9AutoloadError>

Returns the number of unknown autoloads of this Arm9.

§Errors

See Self::autoloads.

Source

pub fn hmac_sha1_key(&self) -> Result<Option<[u8; 64]>, Arm9HmacSha1KeyError>

Returns the HMAC-SHA1 key in this ARM9 program.

Source

pub fn overlay_table_signature( &self, ) -> Result<Option<&HmacSha1Signature>, Arm9OverlaySignaturesError>

Returns the ARM9 overlay table signature.

§Errors

This function will return an error if the ARM9 program is compressed or if HmacSha1Signature::borrow_from_slice fails.

Source

pub fn overlay_table_signature_mut( &mut self, ) -> Result<Option<&mut HmacSha1Signature>, Arm9OverlaySignaturesError>

Returns a mutable reference to the ARM9 overlay table signature.

§Errors

This function will return an error if the ARM9 program is compressed or if HmacSha1Signature::borrow_from_slice_mut fails.

Source

pub fn overlay_signatures( &self, num_overlays: usize, ) -> Result<Option<&[HmacSha1Signature]>, Arm9OverlaySignaturesError>

Returns the ARM9 overlay signature table.

§Errors

This function will return an error if the ARM9 program is compressed or if HmacSha1Signature::borrow_from_slice fails.

Source

pub fn overlay_signatures_mut( &mut self, num_overlays: usize, ) -> Result<Option<&mut [HmacSha1Signature]>, Arm9OverlaySignaturesError>

Returns a mutable reference to the ARM9 overlay signature table.

§Errors

This function will return an error if the ARM9 program is compressed or if HmacSha1Signature::borrow_from_slice_mut fails.

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 end_address(&self) -> Result<u32, RawBuildInfoError>

Returns the end 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 overlay_signatures_offset(&self) -> u32

Returns the offset to the overlay HMAC-SHA1 signature table.

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.

Source

pub fn originally_compressed(&self) -> bool

Returns whether the ARM9 program was compressed originally. See Self::is_compressed for the current state.

Source

pub fn originally_encrypted(&self) -> bool

Returns whether the ARM9 program was encrypted originally. See Self::is_encrypted for the current state.

Trait Implementations§

Source§

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

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 duplicate 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> UnsafeUnpin 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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> 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.