Browse Source

implement chainloader

pull/161/head
Lena 10 months ago
parent
commit
e2364ff5e1
No known key found for this signature in database
GPG Key ID: 5A940B96C2DA3683
  1. 5
      ctru-rs/src/services/am.rs
  2. 41
      ctru-rs/src/services/apt.rs

5
ctru-rs/src/services/am.rs

@ -51,6 +51,11 @@ impl<'a> Title<'a> { @@ -51,6 +51,11 @@ impl<'a> Title<'a> {
pub fn version(&self) -> u16 {
self.version
}
/// Returns this title's media type
pub fn media_type(&self) -> MediaType {
self.mediatype
}
}
/// Handle to the Application Manager service.

41
ctru-rs/src/services/apt.rs

@ -132,3 +132,44 @@ impl Drop for Apt { @@ -132,3 +132,44 @@ impl Drop for Apt {
unsafe { ctru_sys::aptExit() };
}
}
pub struct Chainloader<'a> {
_apt: &'a Apt,
}
impl<'a> Chainloader<'a> {
/// Gets a handle to the chainloader
pub fn new(apt: &'a Apt) -> Self {
Self { _apt: apt }
}
/// Checks if the chainloader is set
#[doc(alias = "aptIsChainload")]
pub fn is_set(&mut self) {
//unsafe { ctru_sys::aptIsChainload() }
}
/// Clears the chainloader state.
#[doc(alias = "aptClearChainloader")]
pub fn clear(&mut self) {
unsafe { ctru_sys::aptClearChainloader() }
}
/// Configures the chainloader to launch a specific application.
#[doc(alias = "aptSetChainloader")]
pub fn set_chainloader(&mut self, title: &super::am::Title<'_>) {
unsafe { ctru_sys::aptSetChainloader(title.id(), title.media_type() as u8) }
}
/// Configures the chainloader to launch the previous application.
#[doc(alias = "aptSetChainloaderToCaller")]
pub fn set_chainloader_to_caller(&mut self) {
unsafe { ctru_sys::aptSetChainloaderToCaller() }
}
/// Configures the chainloader to relaunch the current application (i.e. soft-reset)
#[doc(alias = "aptSetChainloaderToSelf")]
pub fn set_chainloader_to_self(&mut self) {
unsafe { ctru_sys::aptSetChainloaderToSelf() }
}
}

Loading…
Cancel
Save