mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-30 22:45:17 -04:00
libstrat: automatically detect+format rawdata structs correctly.
This commit is contained in:
parent
2f7224edce
commit
6ef34d80a0
16 changed files with 147 additions and 76 deletions
22
stratosphere/sm/source/sm_types.hpp
Normal file
22
stratosphere/sm/source/sm_types.hpp
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright (c) 2018 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
struct SmServiceName {
|
||||
char name[sizeof(u64)];
|
||||
};
|
||||
|
||||
static_assert(__alignof__(SmServiceName) == 1, "SmServiceName definition!");
|
|
@ -25,17 +25,17 @@ Result UserService::Initialize(PidDescriptor pid) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
Result UserService::GetService(Out<MovedHandle> out_h, u64 service) {
|
||||
Result UserService::GetService(Out<MovedHandle> out_h, SmServiceName service) {
|
||||
Handle session_h = 0;
|
||||
Result rc = 0x415;
|
||||
|
||||
#ifdef SM_ENABLE_SMHAX
|
||||
if (!this->has_initialized) {
|
||||
rc = Registration::GetServiceForPid(Registration::GetInitialProcessId(), service, &session_h);
|
||||
rc = Registration::GetServiceForPid(Registration::GetInitialProcessId(), smEncodeName(service.name), &session_h);
|
||||
}
|
||||
#endif
|
||||
if (this->has_initialized) {
|
||||
rc = Registration::GetServiceForPid(this->pid, service, &session_h);
|
||||
rc = Registration::GetServiceForPid(this->pid, smEncodeName(service.name), &session_h);
|
||||
}
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
|
@ -44,16 +44,16 @@ Result UserService::GetService(Out<MovedHandle> out_h, u64 service) {
|
|||
return rc;
|
||||
}
|
||||
|
||||
Result UserService::RegisterService(Out<MovedHandle> out_h, u64 service, u8 is_light, u32 max_sessions) {
|
||||
Result UserService::RegisterService(Out<MovedHandle> out_h, SmServiceName service, u32 max_sessions, bool is_light) {
|
||||
Handle service_h = 0;
|
||||
Result rc = 0x415;
|
||||
#ifdef SM_ENABLE_SMHAX
|
||||
if (!this->has_initialized) {
|
||||
rc = Registration::RegisterServiceForPid(Registration::GetInitialProcessId(), service, max_sessions, (is_light & 1) != 0, &service_h);
|
||||
rc = Registration::RegisterServiceForPid(Registration::GetInitialProcessId(), smEncodeName(service.name), max_sessions, (is_light & 1) != 0, &service_h);
|
||||
}
|
||||
#endif
|
||||
if (this->has_initialized) {
|
||||
rc = Registration::RegisterServiceForPid(this->pid, service, max_sessions, (is_light & 1) != 0, &service_h);
|
||||
rc = Registration::RegisterServiceForPid(this->pid, smEncodeName(service.name), max_sessions, (is_light & 1) != 0, &service_h);
|
||||
}
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
|
@ -62,25 +62,25 @@ Result UserService::RegisterService(Out<MovedHandle> out_h, u64 service, u8 is_l
|
|||
return rc;
|
||||
}
|
||||
|
||||
Result UserService::UnregisterService(u64 service) {
|
||||
Result UserService::UnregisterService(SmServiceName service) {
|
||||
Result rc = 0x415;
|
||||
#ifdef SM_ENABLE_SMHAX
|
||||
if (!this->has_initialized) {
|
||||
rc = Registration::UnregisterServiceForPid(Registration::GetInitialProcessId(), service);
|
||||
rc = Registration::UnregisterServiceForPid(Registration::GetInitialProcessId(), smEncodeName(service.name));
|
||||
}
|
||||
#endif
|
||||
if (this->has_initialized) {
|
||||
rc = Registration::UnregisterServiceForPid(this->pid, service);
|
||||
rc = Registration::UnregisterServiceForPid(this->pid, smEncodeName(service.name));
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result UserService::AtmosphereInstallMitm(Out<MovedHandle> srv_h, Out<MovedHandle> qry_h, u64 service) {
|
||||
Result UserService::AtmosphereInstallMitm(Out<MovedHandle> srv_h, Out<MovedHandle> qry_h, SmServiceName service) {
|
||||
Handle service_h = 0;
|
||||
Handle query_h = 0;
|
||||
Result rc = 0x415;
|
||||
if (this->has_initialized) {
|
||||
rc = Registration::InstallMitmForPid(this->pid, service, &service_h, &query_h);
|
||||
rc = Registration::InstallMitmForPid(this->pid, smEncodeName(service.name), &service_h, &query_h);
|
||||
}
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
|
@ -90,10 +90,10 @@ Result UserService::AtmosphereInstallMitm(Out<MovedHandle> srv_h, Out<MovedHandl
|
|||
return rc;
|
||||
}
|
||||
|
||||
Result UserService::AtmosphereUninstallMitm(u64 service) {
|
||||
Result UserService::AtmosphereUninstallMitm(SmServiceName service) {
|
||||
Result rc = 0x415;
|
||||
if (this->has_initialized) {
|
||||
rc = Registration::UninstallMitmForPid(this->pid, service);
|
||||
rc = Registration::UninstallMitmForPid(this->pid, smEncodeName(service.name));
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#pragma once
|
||||
#include <switch.h>
|
||||
#include <stratosphere.hpp>
|
||||
#include "sm_types.hpp"
|
||||
|
||||
enum UserServiceCmd {
|
||||
User_Cmd_Initialize = 0,
|
||||
|
@ -36,13 +37,13 @@ class UserService final : public IServiceObject {
|
|||
|
||||
/* Actual commands. */
|
||||
virtual Result Initialize(PidDescriptor pid);
|
||||
virtual Result GetService(Out<MovedHandle> out_h, u64 service);
|
||||
virtual Result RegisterService(Out<MovedHandle> out_h, u64 service, u8 is_light, u32 max_sessions);
|
||||
virtual Result UnregisterService(u64 service);
|
||||
virtual Result GetService(Out<MovedHandle> out_h, SmServiceName service);
|
||||
virtual Result RegisterService(Out<MovedHandle> out_h, SmServiceName service, u32 max_sessions, bool is_light);
|
||||
virtual Result UnregisterService(SmServiceName service);
|
||||
|
||||
/* Atmosphere commands. */
|
||||
virtual Result AtmosphereInstallMitm(Out<MovedHandle> srv_h, Out<MovedHandle> qry_h, u64 service);
|
||||
virtual Result AtmosphereUninstallMitm(u64 service);
|
||||
virtual Result AtmosphereInstallMitm(Out<MovedHandle> srv_h, Out<MovedHandle> qry_h, SmServiceName service);
|
||||
virtual Result AtmosphereUninstallMitm(SmServiceName service);
|
||||
virtual Result AtmosphereAssociatePidTidForMitm(u64 pid, u64 tid);
|
||||
public:
|
||||
DEFINE_SERVICE_DISPATCH_TABLE {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue