mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-31 06:48:22 -04:00
strat: use m_ for member variables
This commit is contained in:
parent
ce28591ab2
commit
a595c232b9
425 changed files with 8531 additions and 8484 deletions
|
@ -54,36 +54,36 @@ namespace ams::sf::hipc {
|
|||
NON_COPYABLE(Server);
|
||||
NON_MOVEABLE(Server);
|
||||
private:
|
||||
cmif::ServiceObjectHolder static_object;
|
||||
os::NativeHandle port_handle;
|
||||
sm::ServiceName service_name;
|
||||
int index;
|
||||
bool service_managed;
|
||||
bool is_mitm_server;
|
||||
cmif::ServiceObjectHolder m_static_object;
|
||||
os::NativeHandle m_port_handle;
|
||||
sm::ServiceName m_service_name;
|
||||
int m_index;
|
||||
bool m_service_managed;
|
||||
bool m_is_mitm_server;
|
||||
public:
|
||||
void AcknowledgeMitmSession(std::shared_ptr<::Service> *out_fsrv, sm::MitmProcessInfo *out_client_info) {
|
||||
/* Check mitm server. */
|
||||
AMS_ABORT_UNLESS(this->is_mitm_server);
|
||||
AMS_ABORT_UNLESS(m_is_mitm_server);
|
||||
|
||||
/* Create forward service. */
|
||||
*out_fsrv = ServerSession::CreateForwardService();
|
||||
|
||||
/* Get client info. */
|
||||
R_ABORT_UNLESS(sm::mitm::AcknowledgeSession(out_fsrv->get(), out_client_info, this->service_name));
|
||||
R_ABORT_UNLESS(sm::mitm::AcknowledgeSession(out_fsrv->get(), out_client_info, m_service_name));
|
||||
}
|
||||
};
|
||||
private:
|
||||
/* Multiple wait management. */
|
||||
os::MultiWaitType multi_wait;
|
||||
os::Event request_stop_event;
|
||||
os::MultiWaitHolderType request_stop_event_holder;
|
||||
os::Event notify_event;
|
||||
os::MultiWaitHolderType notify_event_holder;
|
||||
os::MultiWaitType m_multi_wait;
|
||||
os::Event m_request_stop_event;
|
||||
os::MultiWaitHolderType m_request_stop_event_holder;
|
||||
os::Event m_notify_event;
|
||||
os::MultiWaitHolderType m_notify_event_holder;
|
||||
|
||||
os::SdkMutex selection_mutex;
|
||||
os::SdkMutex m_selection_mutex;
|
||||
|
||||
os::SdkMutex deferred_list_mutex;
|
||||
os::MultiWaitType deferred_list;
|
||||
os::SdkMutex m_deferred_list_mutex;
|
||||
os::MultiWaitType m_deferred_list;
|
||||
private:
|
||||
virtual void RegisterServerSessionToWait(ServerSession *session) override final;
|
||||
void LinkToDeferredList(os::MultiWaitHolderType *holder);
|
||||
|
@ -96,10 +96,10 @@ namespace ams::sf::hipc {
|
|||
Result ProcessForSession(os::MultiWaitHolderType *holder);
|
||||
|
||||
void RegisterServerImpl(Server *server, os::NativeHandle port_handle, bool is_mitm_server) {
|
||||
server->port_handle = port_handle;
|
||||
server->m_port_handle = port_handle;
|
||||
hipc::AttachMultiWaitHolderForAccept(server, port_handle);
|
||||
|
||||
server->is_mitm_server = is_mitm_server;
|
||||
server->m_is_mitm_server = is_mitm_server;
|
||||
if (is_mitm_server) {
|
||||
/* Mitm server. */
|
||||
os::SetMultiWaitHolderUserData(server, static_cast<uintptr_t>(UserDataTag::MitmServer));
|
||||
|
@ -108,19 +108,19 @@ namespace ams::sf::hipc {
|
|||
os::SetMultiWaitHolderUserData(server, static_cast<uintptr_t>(UserDataTag::Server));
|
||||
}
|
||||
|
||||
os::LinkMultiWaitHolder(std::addressof(this->multi_wait), server);
|
||||
os::LinkMultiWaitHolder(std::addressof(m_multi_wait), server);
|
||||
}
|
||||
|
||||
void RegisterServerImpl(int index, cmif::ServiceObjectHolder &&static_holder, os::NativeHandle port_handle, bool is_mitm_server) {
|
||||
/* Allocate server memory. */
|
||||
auto *server = this->AllocateServer();
|
||||
AMS_ABORT_UNLESS(server != nullptr);
|
||||
server->service_managed = false;
|
||||
server->m_service_managed = false;
|
||||
|
||||
if (static_holder) {
|
||||
server->static_object = std::move(static_holder);
|
||||
server->m_static_object = std::move(static_holder);
|
||||
} else {
|
||||
server->index = index;
|
||||
server->m_index = index;
|
||||
}
|
||||
|
||||
this->RegisterServerImpl(server, port_handle, is_mitm_server);
|
||||
|
@ -134,13 +134,13 @@ namespace ams::sf::hipc {
|
|||
/* Allocate server memory. */
|
||||
auto *server = this->AllocateServer();
|
||||
AMS_ABORT_UNLESS(server != nullptr);
|
||||
server->service_managed = true;
|
||||
server->service_name = service_name;
|
||||
server->m_service_managed = true;
|
||||
server->m_service_name = service_name;
|
||||
|
||||
if (static_holder) {
|
||||
server->static_object = std::move(static_holder);
|
||||
server->m_static_object = std::move(static_holder);
|
||||
} else {
|
||||
server->index = index;
|
||||
server->m_index = index;
|
||||
}
|
||||
|
||||
this->RegisterServerImpl(server, port_handle, false);
|
||||
|
@ -157,13 +157,13 @@ namespace ams::sf::hipc {
|
|||
/* Allocate server memory. */
|
||||
auto *server = this->AllocateServer();
|
||||
AMS_ABORT_UNLESS(server != nullptr);
|
||||
server->service_managed = true;
|
||||
server->service_name = service_name;
|
||||
server->m_service_managed = true;
|
||||
server->m_service_name = service_name;
|
||||
|
||||
if (static_holder) {
|
||||
server->static_object = std::move(static_holder);
|
||||
server->m_static_object = std::move(static_holder);
|
||||
} else {
|
||||
server->index = index;
|
||||
server->m_index = index;
|
||||
}
|
||||
|
||||
this->RegisterServerImpl(server, port_handle, true);
|
||||
|
@ -182,27 +182,27 @@ namespace ams::sf::hipc {
|
|||
|
||||
template<typename Interface>
|
||||
Result AcceptImpl(Server *server, SharedPointer<Interface> p) {
|
||||
return ServerSessionManager::AcceptSession(server->port_handle, std::move(p));
|
||||
return ServerSessionManager::AcceptSession(server->m_port_handle, std::move(p));
|
||||
}
|
||||
|
||||
template<typename Interface>
|
||||
Result AcceptMitmImpl(Server *server, SharedPointer<Interface> p, std::shared_ptr<::Service> forward_service) {
|
||||
return ServerSessionManager::AcceptMitmSession(server->port_handle, std::move(p), std::move(forward_service));
|
||||
return ServerSessionManager::AcceptMitmSession(server->m_port_handle, std::move(p), std::move(forward_service));
|
||||
}
|
||||
public:
|
||||
ServerManagerBase(DomainEntryStorage *entry_storage, size_t entry_count) :
|
||||
ServerDomainSessionManager(entry_storage, entry_count),
|
||||
request_stop_event(os::EventClearMode_ManualClear), notify_event(os::EventClearMode_ManualClear),
|
||||
selection_mutex(), deferred_list_mutex()
|
||||
m_request_stop_event(os::EventClearMode_ManualClear), m_notify_event(os::EventClearMode_ManualClear),
|
||||
m_selection_mutex(), m_deferred_list_mutex()
|
||||
{
|
||||
/* Link multi-wait holders. */
|
||||
os::InitializeMultiWait(std::addressof(this->multi_wait));
|
||||
os::InitializeMultiWaitHolder(std::addressof(this->request_stop_event_holder), this->request_stop_event.GetBase());
|
||||
os::LinkMultiWaitHolder(std::addressof(this->multi_wait), std::addressof(this->request_stop_event_holder));
|
||||
os::InitializeMultiWaitHolder(std::addressof(this->notify_event_holder), this->notify_event.GetBase());
|
||||
os::LinkMultiWaitHolder(std::addressof(this->multi_wait), std::addressof(this->notify_event_holder));
|
||||
os::InitializeMultiWait(std::addressof(m_multi_wait));
|
||||
os::InitializeMultiWaitHolder(std::addressof(m_request_stop_event_holder), m_request_stop_event.GetBase());
|
||||
os::LinkMultiWaitHolder(std::addressof(m_multi_wait), std::addressof(m_request_stop_event_holder));
|
||||
os::InitializeMultiWaitHolder(std::addressof(m_notify_event_holder), m_notify_event.GetBase());
|
||||
os::LinkMultiWaitHolder(std::addressof(m_multi_wait), std::addressof(m_notify_event_holder));
|
||||
|
||||
os::InitializeMultiWait(std::addressof(this->deferred_list));
|
||||
os::InitializeMultiWait(std::addressof(m_deferred_list));
|
||||
}
|
||||
|
||||
template<typename Interface>
|
||||
|
@ -261,29 +261,29 @@ namespace ams::sf::hipc {
|
|||
using ServerManagerBase::DomainStorage;
|
||||
private:
|
||||
/* Resource storage. */
|
||||
os::SdkMutex resource_mutex;
|
||||
util::TypedStorage<Server> server_storages[MaxServers];
|
||||
bool server_allocated[MaxServers];
|
||||
util::TypedStorage<ServerSession> session_storages[MaxSessions];
|
||||
bool session_allocated[MaxSessions];
|
||||
u8 pointer_buffer_storage[0x10 + (MaxSessions * ManagerOptions::PointerBufferSize)];
|
||||
u8 saved_message_storage[0x10 + (MaxSessions * hipc::TlsMessageBufferSize)];
|
||||
uintptr_t pointer_buffers_start;
|
||||
uintptr_t saved_messages_start;
|
||||
os::SdkMutex m_resource_mutex;
|
||||
util::TypedStorage<Server> m_server_storages[MaxServers];
|
||||
bool m_server_allocated[MaxServers];
|
||||
util::TypedStorage<ServerSession> m_session_storages[MaxSessions];
|
||||
bool m_session_allocated[MaxSessions];
|
||||
u8 m_pointer_buffer_storage[0x10 + (MaxSessions * ManagerOptions::PointerBufferSize)];
|
||||
u8 m_saved_message_storage[0x10 + (MaxSessions * hipc::TlsMessageBufferSize)];
|
||||
uintptr_t m_pointer_buffers_start;
|
||||
uintptr_t m_saved_messages_start;
|
||||
|
||||
/* Domain resources. */
|
||||
DomainStorage domain_storages[ManagerOptions::MaxDomains];
|
||||
bool domain_allocated[ManagerOptions::MaxDomains];
|
||||
DomainEntryStorage domain_entry_storages[ManagerOptions::MaxDomainObjects];
|
||||
DomainStorage m_domain_storages[ManagerOptions::MaxDomains];
|
||||
bool m_domain_allocated[ManagerOptions::MaxDomains];
|
||||
DomainEntryStorage m_domain_entry_storages[ManagerOptions::MaxDomainObjects];
|
||||
private:
|
||||
constexpr inline size_t GetServerIndex(const Server *server) const {
|
||||
const size_t i = server - GetPointer(this->server_storages[0]);
|
||||
const size_t i = server - GetPointer(m_server_storages[0]);
|
||||
AMS_ABORT_UNLESS(i < MaxServers);
|
||||
return i;
|
||||
}
|
||||
|
||||
constexpr inline size_t GetSessionIndex(const ServerSession *session) const {
|
||||
const size_t i = session - GetPointer(this->session_storages[0]);
|
||||
const size_t i = session - GetPointer(m_session_storages[0]);
|
||||
AMS_ABORT_UNLESS(i < MaxSessions);
|
||||
return i;
|
||||
}
|
||||
|
@ -294,12 +294,12 @@ namespace ams::sf::hipc {
|
|||
protected:
|
||||
virtual ServerSession *AllocateSession() override final {
|
||||
if constexpr (MaxSessions > 0) {
|
||||
std::scoped_lock lk(this->resource_mutex);
|
||||
std::scoped_lock lk(m_resource_mutex);
|
||||
|
||||
for (size_t i = 0; i < MaxSessions; i++) {
|
||||
if (!this->session_allocated[i]) {
|
||||
this->session_allocated[i] = true;
|
||||
return GetPointer(this->session_storages[i]);
|
||||
if (!m_session_allocated[i]) {
|
||||
m_session_allocated[i] = true;
|
||||
return GetPointer(m_session_storages[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -308,20 +308,20 @@ namespace ams::sf::hipc {
|
|||
}
|
||||
|
||||
virtual void FreeSession(ServerSession *session) override final {
|
||||
std::scoped_lock lk(this->resource_mutex);
|
||||
std::scoped_lock lk(m_resource_mutex);
|
||||
const size_t index = this->GetSessionIndex(session);
|
||||
AMS_ABORT_UNLESS(this->session_allocated[index]);
|
||||
this->session_allocated[index] = false;
|
||||
AMS_ABORT_UNLESS(m_session_allocated[index]);
|
||||
m_session_allocated[index] = false;
|
||||
}
|
||||
|
||||
virtual Server *AllocateServer() override final {
|
||||
if constexpr (MaxServers > 0) {
|
||||
std::scoped_lock lk(this->resource_mutex);
|
||||
std::scoped_lock lk(m_resource_mutex);
|
||||
|
||||
for (size_t i = 0; i < MaxServers; i++) {
|
||||
if (!this->server_allocated[i]) {
|
||||
this->server_allocated[i] = true;
|
||||
return GetPointer(this->server_storages[i]);
|
||||
if (!m_server_allocated[i]) {
|
||||
m_server_allocated[i] = true;
|
||||
return GetPointer(m_server_storages[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -330,79 +330,79 @@ namespace ams::sf::hipc {
|
|||
}
|
||||
|
||||
virtual void DestroyServer(Server *server) override final {
|
||||
std::scoped_lock lk(this->resource_mutex);
|
||||
std::scoped_lock lk(m_resource_mutex);
|
||||
const size_t index = this->GetServerIndex(server);
|
||||
AMS_ABORT_UNLESS(this->server_allocated[index]);
|
||||
AMS_ABORT_UNLESS(m_server_allocated[index]);
|
||||
{
|
||||
os::UnlinkMultiWaitHolder(server);
|
||||
os::FinalizeMultiWaitHolder(server);
|
||||
if (server->service_managed) {
|
||||
if (server->is_mitm_server) {
|
||||
R_ABORT_UNLESS(sm::mitm::UninstallMitm(server->service_name));
|
||||
if (server->m_service_managed) {
|
||||
if (server->m_is_mitm_server) {
|
||||
R_ABORT_UNLESS(sm::mitm::UninstallMitm(server->m_service_name));
|
||||
} else {
|
||||
R_ABORT_UNLESS(sm::UnregisterService(server->service_name));
|
||||
R_ABORT_UNLESS(sm::UnregisterService(server->m_service_name));
|
||||
}
|
||||
R_ABORT_UNLESS(svc::CloseHandle(server->port_handle));
|
||||
R_ABORT_UNLESS(svc::CloseHandle(server->m_port_handle));
|
||||
}
|
||||
}
|
||||
this->server_allocated[index] = false;
|
||||
m_server_allocated[index] = false;
|
||||
}
|
||||
|
||||
virtual void *AllocateDomain() override final {
|
||||
std::scoped_lock lk(this->resource_mutex);
|
||||
std::scoped_lock lk(m_resource_mutex);
|
||||
for (size_t i = 0; i < ManagerOptions::MaxDomains; i++) {
|
||||
if (!this->domain_allocated[i]) {
|
||||
this->domain_allocated[i] = true;
|
||||
return GetPointer(this->domain_storages[i]);
|
||||
if (!m_domain_allocated[i]) {
|
||||
m_domain_allocated[i] = true;
|
||||
return GetPointer(m_domain_storages[i]);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual void FreeDomain(void *domain) override final {
|
||||
std::scoped_lock lk(this->resource_mutex);
|
||||
std::scoped_lock lk(m_resource_mutex);
|
||||
DomainStorage *ptr = static_cast<DomainStorage *>(domain);
|
||||
const size_t index = ptr - this->domain_storages;
|
||||
const size_t index = ptr - m_domain_storages;
|
||||
AMS_ABORT_UNLESS(index < ManagerOptions::MaxDomains);
|
||||
AMS_ABORT_UNLESS(this->domain_allocated[index]);
|
||||
this->domain_allocated[index] = false;
|
||||
AMS_ABORT_UNLESS(m_domain_allocated[index]);
|
||||
m_domain_allocated[index] = false;
|
||||
}
|
||||
|
||||
virtual cmif::PointerAndSize GetSessionPointerBuffer(const ServerSession *session) const override final {
|
||||
if constexpr (ManagerOptions::PointerBufferSize > 0) {
|
||||
return this->GetObjectBySessionIndex(session, this->pointer_buffers_start, ManagerOptions::PointerBufferSize);
|
||||
return this->GetObjectBySessionIndex(session, m_pointer_buffers_start, ManagerOptions::PointerBufferSize);
|
||||
} else {
|
||||
return cmif::PointerAndSize();
|
||||
}
|
||||
}
|
||||
|
||||
virtual cmif::PointerAndSize GetSessionSavedMessageBuffer(const ServerSession *session) const override final {
|
||||
return this->GetObjectBySessionIndex(session, this->saved_messages_start, hipc::TlsMessageBufferSize);
|
||||
return this->GetObjectBySessionIndex(session, m_saved_messages_start, hipc::TlsMessageBufferSize);
|
||||
}
|
||||
public:
|
||||
ServerManager() : ServerManagerBase(this->domain_entry_storages, ManagerOptions::MaxDomainObjects), resource_mutex() {
|
||||
ServerManager() : ServerManagerBase(m_domain_entry_storages, ManagerOptions::MaxDomainObjects), m_resource_mutex() {
|
||||
/* Clear storages. */
|
||||
#define SF_SM_MEMCLEAR(obj) if constexpr (sizeof(obj) > 0) { std::memset(obj, 0, sizeof(obj)); }
|
||||
SF_SM_MEMCLEAR(this->server_storages);
|
||||
SF_SM_MEMCLEAR(this->server_allocated);
|
||||
SF_SM_MEMCLEAR(this->session_storages);
|
||||
SF_SM_MEMCLEAR(this->session_allocated);
|
||||
SF_SM_MEMCLEAR(this->pointer_buffer_storage);
|
||||
SF_SM_MEMCLEAR(this->saved_message_storage);
|
||||
SF_SM_MEMCLEAR(this->domain_allocated);
|
||||
SF_SM_MEMCLEAR(m_server_storages);
|
||||
SF_SM_MEMCLEAR(m_server_allocated);
|
||||
SF_SM_MEMCLEAR(m_session_storages);
|
||||
SF_SM_MEMCLEAR(m_session_allocated);
|
||||
SF_SM_MEMCLEAR(m_pointer_buffer_storage);
|
||||
SF_SM_MEMCLEAR(m_saved_message_storage);
|
||||
SF_SM_MEMCLEAR(m_domain_allocated);
|
||||
#undef SF_SM_MEMCLEAR
|
||||
|
||||
/* Set resource starts. */
|
||||
this->pointer_buffers_start = util::AlignUp(reinterpret_cast<uintptr_t>(this->pointer_buffer_storage), 0x10);
|
||||
this->saved_messages_start = util::AlignUp(reinterpret_cast<uintptr_t>(this->saved_message_storage), 0x10);
|
||||
m_pointer_buffers_start = util::AlignUp(reinterpret_cast<uintptr_t>(m_pointer_buffer_storage), 0x10);
|
||||
m_saved_messages_start = util::AlignUp(reinterpret_cast<uintptr_t>(m_saved_message_storage), 0x10);
|
||||
}
|
||||
|
||||
~ServerManager() {
|
||||
/* Close all sessions. */
|
||||
if constexpr (MaxSessions > 0) {
|
||||
for (size_t i = 0; i < MaxSessions; i++) {
|
||||
if (this->session_allocated[i]) {
|
||||
this->CloseSessionImpl(GetPointer(this->session_storages[i]));
|
||||
if (m_session_allocated[i]) {
|
||||
this->CloseSessionImpl(GetPointer(m_session_storages[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -410,8 +410,8 @@ namespace ams::sf::hipc {
|
|||
/* Close all servers. */
|
||||
if constexpr (MaxServers > 0) {
|
||||
for (size_t i = 0; i < MaxServers; i++) {
|
||||
if (this->server_allocated[i]) {
|
||||
this->DestroyServer(GetPointer(this->server_storages[i]));
|
||||
if (m_server_allocated[i]) {
|
||||
this->DestroyServer(GetPointer(m_server_storages[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,32 +45,32 @@ namespace ams::sf::hipc {
|
|||
NON_COPYABLE(ServerSession);
|
||||
NON_MOVEABLE(ServerSession);
|
||||
private:
|
||||
cmif::ServiceObjectHolder srv_obj_holder;
|
||||
cmif::PointerAndSize pointer_buffer;
|
||||
cmif::PointerAndSize saved_message;
|
||||
std::shared_ptr<::Service> forward_service;
|
||||
os::NativeHandle session_handle;
|
||||
bool is_closed;
|
||||
bool has_received;
|
||||
cmif::ServiceObjectHolder m_srv_obj_holder;
|
||||
cmif::PointerAndSize m_pointer_buffer;
|
||||
cmif::PointerAndSize m_saved_message;
|
||||
std::shared_ptr<::Service> m_forward_service;
|
||||
os::NativeHandle m_session_handle;
|
||||
bool m_is_closed;
|
||||
bool m_has_received;
|
||||
public:
|
||||
ServerSession(os::NativeHandle h, cmif::ServiceObjectHolder &&obj) : srv_obj_holder(std::move(obj)), session_handle(h) {
|
||||
ServerSession(os::NativeHandle h, cmif::ServiceObjectHolder &&obj) : m_srv_obj_holder(std::move(obj)), m_session_handle(h) {
|
||||
hipc::AttachMultiWaitHolderForReply(this, h);
|
||||
this->is_closed = false;
|
||||
this->has_received = false;
|
||||
this->forward_service = nullptr;
|
||||
m_is_closed = false;
|
||||
m_has_received = false;
|
||||
m_forward_service = nullptr;
|
||||
AMS_ABORT_UNLESS(!this->IsMitmSession());
|
||||
}
|
||||
|
||||
ServerSession(os::NativeHandle h, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv) : srv_obj_holder(std::move(obj)), session_handle(h) {
|
||||
ServerSession(os::NativeHandle h, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv) : m_srv_obj_holder(std::move(obj)), m_session_handle(h) {
|
||||
hipc::AttachMultiWaitHolderForReply(this, h);
|
||||
this->is_closed = false;
|
||||
this->has_received = false;
|
||||
this->forward_service = std::move(fsrv);
|
||||
m_is_closed = false;
|
||||
m_has_received = false;
|
||||
m_forward_service = std::move(fsrv);
|
||||
AMS_ABORT_UNLESS(this->IsMitmSession());
|
||||
}
|
||||
|
||||
bool IsMitmSession() const {
|
||||
return this->forward_service != nullptr;
|
||||
return m_forward_service != nullptr;
|
||||
}
|
||||
|
||||
Result ForwardRequest(const cmif::ServiceDispatchContext &ctx) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue