mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 20:31:14 +00:00
sm: supercede ams extension via DetachClient
This commit is contained in:
parent
4190281b2f
commit
4a82d9bf28
3 changed files with 15 additions and 15 deletions
|
@ -28,6 +28,11 @@ static Result _smAtmosphereCmdInServiceNameNoOut(SmServiceName name, Service *sr
|
||||||
return serviceDispatchIn(srv, cmd_id, name);
|
return serviceDispatchIn(srv, cmd_id, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Result _smAtmosphereDetachClient(Service *srv) {
|
||||||
|
u64 pid_placeholder = 0;
|
||||||
|
return serviceDispatchIn(srv, 4, pid_placeholder, .in_send_pid = true);
|
||||||
|
}
|
||||||
|
|
||||||
Result smAtmosphereHasService(bool *out, SmServiceName name) {
|
Result smAtmosphereHasService(bool *out, SmServiceName name) {
|
||||||
return _smAtmosphereCmdHas(out, name, 65100);
|
return _smAtmosphereCmdHas(out, name, 65100);
|
||||||
}
|
}
|
||||||
|
@ -81,6 +86,10 @@ Result smAtmosphereOpenSession(Service *out) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void smAtmosphereCloseSession(Service *srv) {
|
void smAtmosphereCloseSession(Service *srv) {
|
||||||
|
Result rc = _smAtmosphereDetachClient(srv);
|
||||||
|
if (R_FAILED(rc)) {
|
||||||
|
svcBreak(BreakReason_Panic, (uintptr_t)&rc, sizeof(rc));
|
||||||
|
}
|
||||||
serviceClose(srv);
|
serviceClose(srv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,10 @@ namespace ams::sm::impl {
|
||||||
std::scoped_lock lk(GetUserSessionMutex());
|
std::scoped_lock lk(GetUserSessionMutex());
|
||||||
{
|
{
|
||||||
R_ABORT_UNLESS(smInitialize());
|
R_ABORT_UNLESS(smInitialize());
|
||||||
ON_SCOPE_EXIT { smExit(); };
|
ON_SCOPE_EXIT {
|
||||||
|
R_ABORT_UNLESS(smDetachClient());
|
||||||
|
smExit();
|
||||||
|
};
|
||||||
|
|
||||||
return f();
|
return f();
|
||||||
}
|
}
|
||||||
|
|
|
@ -350,12 +350,6 @@ namespace ams::sm::impl {
|
||||||
return service == InitiallyDeferredServiceName;
|
return service == InitiallyDeferredServiceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShouldCloseOnClientDisconnect(ServiceName service) {
|
|
||||||
/* jit sysmodule is closed and relaunched by am for each application which uses it. */
|
|
||||||
constexpr auto JitU = ServiceName::Encode("jit:u");
|
|
||||||
return service == JitU;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result GetMitmServiceHandleImpl(Handle *out, ServiceInfo *service_info, const MitmProcessInfo &client_info) {
|
Result GetMitmServiceHandleImpl(Handle *out, ServiceInfo *service_info, const MitmProcessInfo &client_info) {
|
||||||
/* Send command to query if we should mitm. */
|
/* Send command to query if we should mitm. */
|
||||||
bool should_mitm;
|
bool should_mitm;
|
||||||
|
@ -438,19 +432,13 @@ namespace ams::sm::impl {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NOTE: Nintendo unregisters all services a process hosted on client close. */
|
/* Unregister all services a client hosts, on attached-client-close. */
|
||||||
/* We do not do this as an atmosphere extension, in order to reduce the number */
|
|
||||||
/* of sessions open at any given time. */
|
|
||||||
/* However, certain system behavior (jit) relies on this occurring. */
|
|
||||||
/* As such, we will special case the system components which rely on the behavior. */
|
|
||||||
for (size_t i = 0; i < ServiceCountMax; i++) {
|
for (size_t i = 0; i < ServiceCountMax; i++) {
|
||||||
if (g_service_list[i].name != InvalidServiceName && g_service_list[i].owner_process_id == process_id) {
|
if (g_service_list[i].name != InvalidServiceName && g_service_list[i].owner_process_id == process_id) {
|
||||||
if (ShouldCloseOnClientDisconnect(g_service_list[i].name)) {
|
|
||||||
g_service_list[i].Free();
|
g_service_list[i].Free();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Process management. */
|
/* Process management. */
|
||||||
Result RegisterProcess(os::ProcessId process_id, ncm::ProgramId program_id, cfg::OverrideStatus override_status, const void *acid_sac, size_t acid_sac_size, const void *aci_sac, size_t aci_sac_size) {
|
Result RegisterProcess(os::ProcessId process_id, ncm::ProgramId program_id, cfg::OverrideStatus override_status, const void *acid_sac, size_t acid_sac_size, const void *aci_sac, size_t aci_sac_size) {
|
||||||
|
|
Loading…
Reference in a new issue