mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-12-18 08:22:04 +00:00
strat: changes for sm tipc (boots 11.0.1, now)
This commit is contained in:
parent
b1b3914ccf
commit
1118421fa6
12 changed files with 42 additions and 31 deletions
|
@ -19,18 +19,17 @@
|
||||||
|
|
||||||
static Result _smAtmosphereCmdHas(bool *out, SmServiceName name, u32 cmd_id) {
|
static Result _smAtmosphereCmdHas(bool *out, SmServiceName name, u32 cmd_id) {
|
||||||
u8 tmp;
|
u8 tmp;
|
||||||
Result rc = serviceDispatchInOut(smGetServiceSession(), cmd_id, name, tmp);
|
Result rc = tipcDispatchInOut(smGetServiceSessionTipc(), cmd_id, name, tmp);
|
||||||
if (R_SUCCEEDED(rc) && out) *out = tmp & 1;
|
if (R_SUCCEEDED(rc) && out) *out = tmp & 1;
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Result _smAtmosphereCmdInServiceNameNoOut(SmServiceName name, Service *srv, u32 cmd_id) {
|
static Result _smAtmosphereCmdInServiceNameNoOut(SmServiceName name, TipcService *srv, u32 cmd_id) {
|
||||||
return serviceDispatchIn(srv, cmd_id, name);
|
return tipcDispatchIn(srv, cmd_id, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Result _smAtmosphereDetachClient(Service *srv) {
|
static Result _smAtmosphereDetachClient(TipcService *srv) {
|
||||||
u64 pid_placeholder = 0;
|
return tipcDispatch(srv, 4, .in_send_pid = true);
|
||||||
return serviceDispatchIn(srv, 4, pid_placeholder, .in_send_pid = true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result smAtmosphereHasService(bool *out, SmServiceName name) {
|
Result smAtmosphereHasService(bool *out, SmServiceName name) {
|
||||||
|
@ -38,7 +37,7 @@ Result smAtmosphereHasService(bool *out, SmServiceName name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Result smAtmosphereWaitService(SmServiceName name) {
|
Result smAtmosphereWaitService(SmServiceName name) {
|
||||||
return _smAtmosphereCmdInServiceNameNoOut(name, smGetServiceSession(), 65101);
|
return _smAtmosphereCmdInServiceNameNoOut(name, smGetServiceSessionTipc(), 65101);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result smAtmosphereHasMitm(bool *out, SmServiceName name) {
|
Result smAtmosphereHasMitm(bool *out, SmServiceName name) {
|
||||||
|
@ -46,10 +45,10 @@ Result smAtmosphereHasMitm(bool *out, SmServiceName name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Result smAtmosphereWaitMitm(SmServiceName name) {
|
Result smAtmosphereWaitMitm(SmServiceName name) {
|
||||||
return _smAtmosphereCmdInServiceNameNoOut(name, smGetServiceSession(), 65005);
|
return _smAtmosphereCmdInServiceNameNoOut(name, smGetServiceSessionTipc(), 65005);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Service g_smAtmosphereMitmSrv;
|
static TipcService g_smAtmosphereMitmSrv;
|
||||||
|
|
||||||
NX_GENERATE_SERVICE_GUARD(smAtmosphereMitm);
|
NX_GENERATE_SERVICE_GUARD(smAtmosphereMitm);
|
||||||
|
|
||||||
|
@ -61,11 +60,11 @@ void _smAtmosphereMitmCleanup(void) {
|
||||||
smAtmosphereCloseSession(&g_smAtmosphereMitmSrv);
|
smAtmosphereCloseSession(&g_smAtmosphereMitmSrv);
|
||||||
}
|
}
|
||||||
|
|
||||||
Service* smAtmosphereMitmGetServiceSession(void) {
|
TipcService* smAtmosphereMitmGetServiceSession(void) {
|
||||||
return &g_smAtmosphereMitmSrv;
|
return &g_smAtmosphereMitmSrv;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result smAtmosphereOpenSession(Service *out) {
|
Result smAtmosphereOpenSession(TipcService *out) {
|
||||||
Handle sm_handle;
|
Handle sm_handle;
|
||||||
Result rc = svcConnectToNamedPort(&sm_handle, "sm:");
|
Result rc = svcConnectToNamedPort(&sm_handle, "sm:");
|
||||||
while (R_VALUE(rc) == KERNELRESULT(NotFound)) {
|
while (R_VALUE(rc) == KERNELRESULT(NotFound)) {
|
||||||
|
@ -74,28 +73,27 @@ Result smAtmosphereOpenSession(Service *out) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
serviceCreate(out, sm_handle);
|
tipcCreate(out, sm_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
const u64 pid_placeholder = 0;
|
rc = tipcDispatch(out, 0, .in_send_pid = true);
|
||||||
rc = serviceDispatchIn(out, 0, pid_placeholder, .in_send_pid = true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void smAtmosphereCloseSession(Service *srv) {
|
void smAtmosphereCloseSession(TipcService *srv) {
|
||||||
Result rc = _smAtmosphereDetachClient(srv);
|
Result rc = _smAtmosphereDetachClient(srv);
|
||||||
if (R_FAILED(rc)) {
|
if (R_FAILED(rc)) {
|
||||||
svcBreak(BreakReason_Panic, (uintptr_t)&rc, sizeof(rc));
|
svcBreak(BreakReason_Panic, (uintptr_t)&rc, sizeof(rc));
|
||||||
}
|
}
|
||||||
serviceClose(srv);
|
tipcClose(srv);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result smAtmosphereMitmInstall(Service *fwd_srv, Handle *handle_out, Handle *query_out, SmServiceName name) {
|
Result smAtmosphereMitmInstall(TipcService *fwd_srv, Handle *handle_out, Handle *query_out, SmServiceName name) {
|
||||||
Handle tmp_handles[2];
|
Handle tmp_handles[2];
|
||||||
Result rc = serviceDispatchIn(fwd_srv, 65000, name,
|
Result rc = tipcDispatchIn(fwd_srv, 65000, name,
|
||||||
.out_handle_attrs = { SfOutHandleAttr_HipcMove, SfOutHandleAttr_HipcMove },
|
.out_handle_attrs = { SfOutHandleAttr_HipcMove, SfOutHandleAttr_HipcMove },
|
||||||
.out_handles = tmp_handles,
|
.out_handles = tmp_handles,
|
||||||
);
|
);
|
||||||
|
@ -109,15 +107,15 @@ Result smAtmosphereMitmInstall(Service *fwd_srv, Handle *handle_out, Handle *que
|
||||||
}
|
}
|
||||||
|
|
||||||
Result smAtmosphereMitmUninstall(SmServiceName name) {
|
Result smAtmosphereMitmUninstall(SmServiceName name) {
|
||||||
return _smAtmosphereCmdInServiceNameNoOut(name, smGetServiceSession(), 65001);
|
return _smAtmosphereCmdInServiceNameNoOut(name, smGetServiceSessionTipc(), 65001);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result smAtmosphereMitmDeclareFuture(SmServiceName name) {
|
Result smAtmosphereMitmDeclareFuture(SmServiceName name) {
|
||||||
return _smAtmosphereCmdInServiceNameNoOut(name, smGetServiceSession(), 65006);
|
return _smAtmosphereCmdInServiceNameNoOut(name, smGetServiceSessionTipc(), 65006);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result smAtmosphereMitmClearFuture(SmServiceName name) {
|
Result smAtmosphereMitmClearFuture(SmServiceName name) {
|
||||||
return _smAtmosphereCmdInServiceNameNoOut(name, smGetServiceSession(), 65007);
|
return _smAtmosphereCmdInServiceNameNoOut(name, smGetServiceSessionTipc(), 65007);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result smAtmosphereMitmAcknowledgeSession(Service *srv_out, void *_out, SmServiceName name) {
|
Result smAtmosphereMitmAcknowledgeSession(Service *srv_out, void *_out, SmServiceName name) {
|
||||||
|
@ -131,7 +129,7 @@ Result smAtmosphereMitmAcknowledgeSession(Service *srv_out, void *_out, SmServic
|
||||||
|
|
||||||
Handle tmp_handle;
|
Handle tmp_handle;
|
||||||
|
|
||||||
Result rc = serviceDispatchInOut(&g_smAtmosphereMitmSrv, 65003, name, *out,
|
Result rc = tipcDispatchInOut(&g_smAtmosphereMitmSrv, 65003, name, *out,
|
||||||
.out_handle_attrs = { SfOutHandleAttr_HipcMove },
|
.out_handle_attrs = { SfOutHandleAttr_HipcMove },
|
||||||
.out_handles = &tmp_handle,
|
.out_handles = &tmp_handle,
|
||||||
);
|
);
|
||||||
|
|
|
@ -18,12 +18,12 @@ Result smAtmosphereWaitMitm(SmServiceName name);
|
||||||
|
|
||||||
Result smAtmosphereMitmInitialize(void);
|
Result smAtmosphereMitmInitialize(void);
|
||||||
void smAtmosphereMitmExit(void);
|
void smAtmosphereMitmExit(void);
|
||||||
Service *smAtmosphereMitmGetServiceSession();
|
TipcService *smAtmosphereMitmGetServiceSession();
|
||||||
|
|
||||||
Result smAtmosphereOpenSession(Service *out);
|
Result smAtmosphereOpenSession(TipcService *out);
|
||||||
void smAtmosphereCloseSession(Service *srv);
|
void smAtmosphereCloseSession(TipcService *srv);
|
||||||
|
|
||||||
Result smAtmosphereMitmInstall(Service *fwd_srv, Handle *handle_out, Handle *query_out, SmServiceName name);
|
Result smAtmosphereMitmInstall(TipcService *fwd_srv, Handle *handle_out, Handle *query_out, SmServiceName name);
|
||||||
Result smAtmosphereMitmUninstall(SmServiceName name);
|
Result smAtmosphereMitmUninstall(SmServiceName name);
|
||||||
Result smAtmosphereMitmDeclareFuture(SmServiceName name);
|
Result smAtmosphereMitmDeclareFuture(SmServiceName name);
|
||||||
Result smAtmosphereMitmClearFuture(SmServiceName name);
|
Result smAtmosphereMitmClearFuture(SmServiceName name);
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace ams::sm::mitm {
|
||||||
|
|
||||||
/* Mitm API. */
|
/* Mitm API. */
|
||||||
Result InstallMitm(Handle *out_port, Handle *out_query, ServiceName name) {
|
Result InstallMitm(Handle *out_port, Handle *out_query, ServiceName name) {
|
||||||
return impl::DoWithPerThreadSession([&](Service *fwd) {
|
return impl::DoWithPerThreadSession([&](TipcService *fwd) {
|
||||||
return smAtmosphereMitmInstall(fwd, out_port, out_query, impl::ConvertName(name));
|
return smAtmosphereMitmInstall(fwd, out_port, out_query, impl::ConvertName(name));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ namespace ams::sm::impl {
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
Result DoWithPerThreadSession(F f) {
|
Result DoWithPerThreadSession(F f) {
|
||||||
Service srv;
|
TipcService srv;
|
||||||
{
|
{
|
||||||
std::scoped_lock lk(GetPerThreadSessionMutex());
|
std::scoped_lock lk(GetPerThreadSessionMutex());
|
||||||
R_ABORT_UNLESS(smAtmosphereOpenSession(&srv));
|
R_ABORT_UNLESS(smAtmosphereOpenSession(&srv));
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include "smm_ams.h"
|
#include "smm_ams.h"
|
||||||
|
|
||||||
Result smManagerAtmosphereEndInitialDefers(void) {
|
Result smManagerAtmosphereEndInitialDefers(void) {
|
||||||
return serviceDispatch(smManagerGetServiceSession(), 65000);
|
return tipcDispatch(smManagerTipcGetServiceSession(), 65000);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result smManagerAtmosphereRegisterProcess(u64 pid, u64 tid, const CfgOverrideStatus *status, const void *acid_sac, size_t acid_sac_size, const void *aci_sac, size_t aci_sac_size) {
|
Result smManagerAtmosphereRegisterProcess(u64 pid, u64 tid, const CfgOverrideStatus *status, const void *acid_sac, size_t acid_sac_size, const void *aci_sac, size_t aci_sac_size) {
|
||||||
|
@ -25,7 +25,7 @@ Result smManagerAtmosphereRegisterProcess(u64 pid, u64 tid, const CfgOverrideSta
|
||||||
u64 tid;
|
u64 tid;
|
||||||
CfgOverrideStatus status;
|
CfgOverrideStatus status;
|
||||||
} in = { pid, tid, *status };
|
} in = { pid, tid, *status };
|
||||||
return serviceDispatchIn(smManagerGetServiceSession(), 65002, in,
|
return tipcDispatchIn(smManagerTipcGetServiceSession(), 65002, in,
|
||||||
.buffer_attrs = {
|
.buffer_attrs = {
|
||||||
SfBufferAttr_In | SfBufferAttr_HipcMapAlias,
|
SfBufferAttr_In | SfBufferAttr_HipcMapAlias,
|
||||||
SfBufferAttr_In | SfBufferAttr_HipcMapAlias,
|
SfBufferAttr_In | SfBufferAttr_HipcMapAlias,
|
||||||
|
@ -39,7 +39,7 @@ Result smManagerAtmosphereRegisterProcess(u64 pid, u64 tid, const CfgOverrideSta
|
||||||
|
|
||||||
static Result _smManagerAtmosphereCmdHas(bool *out, SmServiceName name, u32 cmd_id) {
|
static Result _smManagerAtmosphereCmdHas(bool *out, SmServiceName name, u32 cmd_id) {
|
||||||
u8 tmp;
|
u8 tmp;
|
||||||
Result rc = serviceDispatchInOut(smManagerGetServiceSession(), cmd_id, name, tmp);
|
Result rc = tipcDispatchInOut(smManagerTipcGetServiceSession(), cmd_id, name, tmp);
|
||||||
if (R_SUCCEEDED(rc) && out) *out = tmp & 1;
|
if (R_SUCCEEDED(rc) && out) *out = tmp & 1;
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
"main_thread_priority": 43,
|
"main_thread_priority": 43,
|
||||||
"default_cpu_id": 3,
|
"default_cpu_id": 3,
|
||||||
"process_category": 1,
|
"process_category": 1,
|
||||||
|
"use_secure_memory": true,
|
||||||
|
"immortal": true,
|
||||||
"kernel_capabilities": [
|
"kernel_capabilities": [
|
||||||
{
|
{
|
||||||
"type": "handle_table_size",
|
"type": "handle_table_size",
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
"default_cpu_id": 3,
|
"default_cpu_id": 3,
|
||||||
"process_category": 1,
|
"process_category": 1,
|
||||||
"use_secure_memory": false,
|
"use_secure_memory": false,
|
||||||
|
"immortal": false,
|
||||||
"kernel_capabilities": [
|
"kernel_capabilities": [
|
||||||
{
|
{
|
||||||
"type": "handle_table_size",
|
"type": "handle_table_size",
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
"main_thread_priority": 49,
|
"main_thread_priority": 49,
|
||||||
"default_cpu_id": 3,
|
"default_cpu_id": 3,
|
||||||
"process_category": 1,
|
"process_category": 1,
|
||||||
|
"use_secure_memory": true,
|
||||||
|
"immortal": true,
|
||||||
"kernel_capabilities": [
|
"kernel_capabilities": [
|
||||||
{
|
{
|
||||||
"type": "handle_table_size",
|
"type": "handle_table_size",
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
"main_thread_priority": 49,
|
"main_thread_priority": 49,
|
||||||
"default_cpu_id": 3,
|
"default_cpu_id": 3,
|
||||||
"process_category": 1,
|
"process_category": 1,
|
||||||
|
"use_secure_memory": true,
|
||||||
|
"immortal": true,
|
||||||
"kernel_capabilities": [
|
"kernel_capabilities": [
|
||||||
{
|
{
|
||||||
"type": "handle_table_size",
|
"type": "handle_table_size",
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
"main_thread_priority": 49,
|
"main_thread_priority": 49,
|
||||||
"default_cpu_id": 3,
|
"default_cpu_id": 3,
|
||||||
"process_category": 1,
|
"process_category": 1,
|
||||||
|
"use_secure_memory": true,
|
||||||
|
"immortal": true,
|
||||||
"kernel_capabilities": [
|
"kernel_capabilities": [
|
||||||
{
|
{
|
||||||
"type": "handle_table_size",
|
"type": "handle_table_size",
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
"main_thread_priority": 27,
|
"main_thread_priority": 27,
|
||||||
"default_cpu_id": 3,
|
"default_cpu_id": 3,
|
||||||
"process_category": 1,
|
"process_category": 1,
|
||||||
|
"use_secure_memory": true,
|
||||||
|
"immortal": true,
|
||||||
"kernel_capabilities": [
|
"kernel_capabilities": [
|
||||||
{
|
{
|
||||||
"type": "handle_table_size",
|
"type": "handle_table_size",
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
"main_thread_priority": 27,
|
"main_thread_priority": 27,
|
||||||
"default_cpu_id": 3,
|
"default_cpu_id": 3,
|
||||||
"process_category": 1,
|
"process_category": 1,
|
||||||
|
"use_secure_memory": true,
|
||||||
|
"immortal": true,
|
||||||
"kernel_capabilities": [{
|
"kernel_capabilities": [{
|
||||||
"type": "handle_table_size",
|
"type": "handle_table_size",
|
||||||
"value": 128
|
"value": 128
|
||||||
|
|
Loading…
Reference in a new issue