mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-09 22:56:35 +00:00
strat: fix some mitm server management logic
This commit is contained in:
parent
891fa32bf1
commit
7e536f74ae
4 changed files with 19 additions and 4 deletions
|
@ -289,7 +289,7 @@ namespace ams::sf::hipc {
|
||||||
util::TypedStorage<ServerSession> m_session_storages[MaxSessions];
|
util::TypedStorage<ServerSession> m_session_storages[MaxSessions];
|
||||||
bool m_session_allocated[MaxSessions];
|
bool m_session_allocated[MaxSessions];
|
||||||
u8 m_pointer_buffer_storage[0x10 + (MaxSessions * ManagerOptions::PointerBufferSize)];
|
u8 m_pointer_buffer_storage[0x10 + (MaxSessions * ManagerOptions::PointerBufferSize)];
|
||||||
u8 m_saved_message_storage[0x10 + (MaxSessions * (ManagerOptions::CanDeferInvokeRequest ? hipc::TlsMessageBufferSize : 0))];
|
u8 m_saved_message_storage[0x10 + (MaxSessions * ((ManagerOptions::CanDeferInvokeRequest || ManagerOptions::CanManageMitmServers) ? hipc::TlsMessageBufferSize : 0))];
|
||||||
uintptr_t m_pointer_buffers_start;
|
uintptr_t m_pointer_buffers_start;
|
||||||
uintptr_t m_saved_messages_start;
|
uintptr_t m_saved_messages_start;
|
||||||
|
|
||||||
|
@ -403,7 +403,7 @@ namespace ams::sf::hipc {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual cmif::PointerAndSize GetSessionSavedMessageBuffer(const ServerSession *session) const override final {
|
virtual cmif::PointerAndSize GetSessionSavedMessageBuffer(const ServerSession *session) const override final {
|
||||||
if constexpr (ManagerOptions::CanDeferInvokeRequest) {
|
if constexpr (ManagerOptions::CanDeferInvokeRequest || ManagerOptions::CanManageMitmServers) {
|
||||||
return this->GetObjectBySessionIndex(session, m_saved_messages_start, hipc::TlsMessageBufferSize);
|
return this->GetObjectBySessionIndex(session, m_saved_messages_start, hipc::TlsMessageBufferSize);
|
||||||
} else {
|
} else {
|
||||||
return cmif::PointerAndSize();
|
return cmif::PointerAndSize();
|
||||||
|
|
|
@ -69,6 +69,12 @@ namespace ams::sf::hipc {
|
||||||
AMS_ABORT_UNLESS(util::GetReference(m_forward_service) != nullptr);
|
AMS_ABORT_UNLESS(util::GetReference(m_forward_service) != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~ServerSession() {
|
||||||
|
if (m_has_forward_service) {
|
||||||
|
util::DestroyAt(m_forward_service);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ALWAYS_INLINE bool IsMitmSession() const {
|
ALWAYS_INLINE bool IsMitmSession() const {
|
||||||
return m_has_forward_service;
|
return m_has_forward_service;
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,6 +135,13 @@ namespace ams::sf::hipc {
|
||||||
if (!session->m_has_received) {
|
if (!session->m_has_received) {
|
||||||
R_TRY(this->ReceiveRequest(session, tls_message));
|
R_TRY(this->ReceiveRequest(session, tls_message));
|
||||||
session->m_has_received = true;
|
session->m_has_received = true;
|
||||||
|
|
||||||
|
if (this->CanManageMitmServers()) {
|
||||||
|
const cmif::PointerAndSize &saved_message = session->m_saved_message;
|
||||||
|
AMS_ABORT_UNLESS(tls_message.GetSize() == saved_message.GetSize());
|
||||||
|
|
||||||
|
std::memcpy(saved_message.GetPointer(), tls_message.GetPointer(), tls_message.GetSize());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
R_TRY_CATCH(this->ProcessRequest(session, tls_message)) {
|
R_TRY_CATCH(this->ProcessRequest(session, tls_message)) {
|
||||||
|
|
|
@ -624,9 +624,11 @@ namespace ams::sm::impl {
|
||||||
R_TRY(ValidateAccessControl(AccessControlEntry(proc->access_control, proc->access_control_size), service, false, false));
|
R_TRY(ValidateAccessControl(AccessControlEntry(proc->access_control, proc->access_control_size), service, false, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get service info. Check to see if we need to defer this until later. */
|
/* Get service info/mitm info. */
|
||||||
ServiceInfo *service_info = GetServiceInfo(service);
|
ServiceInfo *service_info = GetServiceInfo(service);
|
||||||
MitmInfo *mitm_info = GetMitmInfo(service_info);
|
MitmInfo *mitm_info = service_info != nullptr ? GetMitmInfo(service_info) : nullptr;
|
||||||
|
|
||||||
|
/* Check to see if we need to defer until later. */
|
||||||
R_UNLESS(service_info != nullptr, tipc::ResultRequestDeferred());
|
R_UNLESS(service_info != nullptr, tipc::ResultRequestDeferred());
|
||||||
R_UNLESS(!ShouldDeferForInit(service), tipc::ResultRequestDeferred());
|
R_UNLESS(!ShouldDeferForInit(service), tipc::ResultRequestDeferred());
|
||||||
R_UNLESS(!HasFutureMitmDeclaration(service), tipc::ResultRequestDeferred());
|
R_UNLESS(!HasFutureMitmDeclaration(service), tipc::ResultRequestDeferred());
|
||||||
|
|
Loading…
Reference in a new issue