pub struct Arm9<'a> { /* private fields */ }Expand description
ARM9 program.
Implementations§
Source§impl<'a> Arm9<'a>
impl<'a> Arm9<'a>
Sourcepub fn new<T: Into<Cow<'a, [u8]>>>(
data: T,
offsets: Arm9Offsets,
) -> Result<Self, RawBuildInfoError>
pub fn new<T: Into<Cow<'a, [u8]>>>( data: T, offsets: Arm9Offsets, ) -> Result<Self, RawBuildInfoError>
Creates a new ARM9 program from raw data.
Sourcepub fn with_two_tcms(
data: Vec<u8>,
itcm: Autoload<'_>,
dtcm: Autoload<'_>,
offsets: Arm9Offsets,
options: Arm9WithTcmsOptions,
) -> Result<Self, RawBuildInfoError>
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.
Sourcepub fn with_autoloads(
data: Vec<u8>,
autoloads: &[Autoload<'_>],
offsets: Arm9Offsets,
options: Arm9WithTcmsOptions,
) -> Result<Self, RawBuildInfoError>
pub fn with_autoloads( data: Vec<u8>, autoloads: &[Autoload<'_>], offsets: Arm9Offsets, options: Arm9WithTcmsOptions, ) -> Result<Self, RawBuildInfoError>
Sourcepub fn is_encrypted(&self) -> bool
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.
Sourcepub fn decrypt(
&mut self,
key: &BlowfishKey,
gamecode: u32,
) -> Result<(), Arm9Error>
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.
Sourcepub fn encrypt(
&mut self,
key: &BlowfishKey,
gamecode: u32,
) -> Result<(), Arm9Error>
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.
Sourcepub fn encrypted_secure_area(
&self,
key: &BlowfishKey,
gamecode: u32,
) -> [u8; 16384]
pub fn encrypted_secure_area( &self, key: &BlowfishKey, gamecode: u32, ) -> [u8; 16384]
Returns an encrypted copy of the secure area.
Sourcepub fn secure_area_crc(&self, key: &BlowfishKey, gamecode: u32) -> u16
pub fn secure_area_crc(&self, key: &BlowfishKey, gamecode: u32) -> u16
Returns a CRC checksum of the encrypted secure area.
Sourcepub fn build_info(&self) -> Result<&BuildInfo, RawBuildInfoError>
pub fn build_info(&self) -> Result<&BuildInfo, RawBuildInfoError>
Sourcepub fn build_info_mut(&mut self) -> Result<&mut BuildInfo, RawBuildInfoError>
pub fn build_info_mut(&mut self) -> Result<&mut BuildInfo, RawBuildInfoError>
Sourcepub fn is_compressed(&self) -> Result<bool, RawBuildInfoError>
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.
Sourcepub fn decompress(&mut self) -> Result<(), Arm9Error>
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.
Sourcepub fn compress(&mut self) -> Result<(), Arm9Error>
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.
Sourcepub fn autoload_infos(&self) -> Result<Vec<AutoloadInfo>, Arm9AutoloadError>
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.
Sourcepub fn autoloads(&self) -> Result<Box<[Autoload<'_>]>, Arm9AutoloadError>
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.
Sourcepub fn num_unknown_autoloads(&self) -> Result<usize, Arm9AutoloadError>
pub fn num_unknown_autoloads(&self) -> Result<usize, Arm9AutoloadError>
Sourcepub fn hmac_sha1_key(&self) -> Result<Option<[u8; 64]>, Arm9HmacSha1KeyError>
pub fn hmac_sha1_key(&self) -> Result<Option<[u8; 64]>, Arm9HmacSha1KeyError>
Returns the HMAC-SHA1 key in this ARM9 program.
Sourcepub fn overlay_table_signature(
&self,
) -> Result<Option<&HmacSha1Signature>, Arm9OverlaySignaturesError>
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.
Sourcepub fn overlay_table_signature_mut(
&mut self,
) -> Result<Option<&mut HmacSha1Signature>, Arm9OverlaySignaturesError>
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.
Sourcepub fn overlay_signatures(
&self,
num_overlays: usize,
) -> Result<Option<&[HmacSha1Signature]>, Arm9OverlaySignaturesError>
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.
Sourcepub fn overlay_signatures_mut(
&mut self,
num_overlays: usize,
) -> Result<Option<&mut [HmacSha1Signature]>, Arm9OverlaySignaturesError>
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.
Sourcepub fn code(&self) -> Result<&[u8], RawBuildInfoError>
pub fn code(&self) -> Result<&[u8], RawBuildInfoError>
Sourcepub fn base_address(&self) -> u32
pub fn base_address(&self) -> u32
Returns the base address.
Sourcepub fn end_address(&self) -> Result<u32, RawBuildInfoError>
pub fn end_address(&self) -> Result<u32, RawBuildInfoError>
Returns the end address.
Sourcepub fn entry_function(&self) -> u32
pub fn entry_function(&self) -> u32
Returns the entry function address.
Sourcepub fn build_info_offset(&self) -> u32
pub fn build_info_offset(&self) -> u32
Returns the build info offset.
Sourcepub fn autoload_callback(&self) -> u32
pub fn autoload_callback(&self) -> u32
Returns the autoload callback address.
Sourcepub fn overlay_signatures_offset(&self) -> u32
pub fn overlay_signatures_offset(&self) -> u32
Returns the offset to the overlay HMAC-SHA1 signature table.
Sourcepub fn offsets(&self) -> &Arm9Offsets
pub fn offsets(&self) -> &Arm9Offsets
Returns a reference to the ARM9 offsets.
Sourcepub fn originally_compressed(&self) -> bool
pub fn originally_compressed(&self) -> bool
Returns whether the ARM9 program was compressed originally. See Self::is_compressed for the current state.
Sourcepub fn originally_encrypted(&self) -> bool
pub fn originally_encrypted(&self) -> bool
Returns whether the ARM9 program was encrypted originally. See Self::is_encrypted for the current state.