diff --git a/src/ipc/server.rs b/src/ipc/server.rs index a504f73a..1e886d48 100755 --- a/src/ipc/server.rs +++ b/src/ipc/server.rs @@ -511,18 +511,24 @@ impl ServerHolder { #[cfg(feature = "services")] { let mut sm = service::new_named_port_object::()?; - match (self.is_mitm_service, self.handle_type) { - (true, WaitHandleType::Server) => { + + if self.handle_type == WaitHandleType::Server { + if self.is_mitm_service { debug_assert!( self.info.owns_handle, "MitM server objects should always own their handles." ); sm.atmosphere_uninstall_mitm(self.service_name)?; - sf::Session::from(self.mitm_forward_info).close(); } - (false, _) => sm.unregister_service(self.service_name)?, - _ => {} - }; + else { + sm.unregister_service(self.service_name)?; + } + } + + if self.is_mitm_service { + sf::Session::from(self.mitm_forward_info).close(); + } + sm.detach_client(sf::ProcessId::new())?; } } @@ -698,7 +704,7 @@ impl ServerManager

{ let mut handles_index: usize = 0; for server_holder in &mut self.server_holders { let server_info = server_holder.info; - if server_info.handle != 0 { + if server_info.handle != svc::INVALID_HANDLE { self.wait_handles[handles_index] = server_info.handle; handles_index += 1; } diff --git a/src/ipc/sf.rs b/src/ipc/sf.rs index 83965277..d926a2cb 100755 --- a/src/ipc/sf.rs +++ b/src/ipc/sf.rs @@ -333,7 +333,6 @@ impl< } impl< - const IN: bool, const MAP_ALIAS: bool, const POINTER: bool, const FIXED_SIZE: bool, @@ -344,7 +343,7 @@ impl< > Buffer< '_, - IN, + true, true, MAP_ALIAS, POINTER, diff --git a/src/ipc/sf/nfp.rs b/src/ipc/sf/nfp.rs index 1c154a76..18a0e481 100755 --- a/src/ipc/sf/nfp.rs +++ b/src/ipc/sf/nfp.rs @@ -27,14 +27,14 @@ pub struct DeviceHandle { } const_assert!(core::mem::size_of::() == 0x8); -#[derive(Request, Response, Copy, Clone, PartialEq, Eq)] +#[derive(Request, Response, Copy, Clone, PartialEq, Eq, Debug)] #[repr(u32)] pub enum State { NonInitialized = 0, Initialized = 1, } -#[derive(Request, Response, Copy, Clone, PartialEq, Eq)] +#[derive(Request, Response, Copy, Clone, PartialEq, Eq, Debug)] #[repr(u32)] pub enum DeviceState { Initialized = 0, diff --git a/src/svc.rs b/src/svc.rs index 5f046d84..e0e3422e 100755 --- a/src/svc.rs +++ b/src/svc.rs @@ -828,7 +828,7 @@ pub fn send_sync_request_light(handle: Handle) -> Result<()> { } } -/// Sends an IPC synchronization request to a session. +/// Sends a synchronous IPC request to a session. #[inline(always)] pub fn send_sync_request(handle: Handle) -> Result<()> { unsafe { @@ -837,7 +837,7 @@ pub fn send_sync_request(handle: Handle) -> Result<()> { } } -/// Sends an IPC synchronization request to a session from an user allocated buffer. +/// Sends a synchronous IPC request to a session from an user allocated buffer. /// /// The buffer size must be a multiple of the system page size (0x1000). #[inline(always)] @@ -848,7 +848,7 @@ pub unsafe fn send_sync_request_with_user_data(buffer: &mut [u8], handle: Handle } } -/// Sends an IPC synchronization request to a session from an user allocated buffer (asynchronous version). +/// Sends an asynchronous IPC request to a session from an user allocated buffer . /// /// The buffer size must be a multiple of the system page size (0x1000). #[inline(always)]