sm: supercede ams extension via DetachClient

This commit is contained in:
Michael Scire 2021-01-27 14:36:15 -08:00
parent efe104b0ea
commit fdd1ccf87a
2 changed files with 13 additions and 1 deletions

View File

@ -28,6 +28,11 @@ static Result _smAtmosphereCmdInServiceNameNoOut(SmServiceName name, Service *sr
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) {
return _smAtmosphereCmdHas(out, name, 65100);
}
@ -81,6 +86,10 @@ Result smAtmosphereOpenSession(Service *out) {
}
void smAtmosphereCloseSession(Service *srv) {
Result rc = _smAtmosphereDetachClient(srv);
if (R_FAILED(rc)) {
svcBreak(BreakReason_Panic, (uintptr_t)&rc, sizeof(rc));
}
serviceClose(srv);
}

View File

@ -30,7 +30,10 @@ namespace ams::sm::impl {
std::scoped_lock lk(GetUserSessionMutex());
{
R_ABORT_UNLESS(smInitialize());
ON_SCOPE_EXIT { smExit(); };
ON_SCOPE_EXIT {
R_ABORT_UNLESS(smDetachClient());
smExit();
};
return f();
}