2019-12-09 11:57:37 +00:00
|
|
|
/*
|
2021-10-04 19:59:10 +00:00
|
|
|
* Copyright (c) Atmosphère-NX
|
2019-12-09 11:57:37 +00:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
2020-05-11 22:02:10 +00:00
|
|
|
#include <stratosphere.hpp>
|
2019-12-09 11:57:37 +00:00
|
|
|
#include "sm_utils.hpp"
|
|
|
|
|
|
|
|
namespace ams::sm::mitm {
|
|
|
|
|
2022-03-06 20:08:20 +00:00
|
|
|
#if defined(ATMOSPHERE_OS_HORIZON)
|
|
|
|
#if AMS_SF_MITM_SUPPORTED
|
2019-12-09 11:57:37 +00:00
|
|
|
/* Mitm API. */
|
2021-10-05 00:12:32 +00:00
|
|
|
Result InstallMitm(os::NativeHandle *out_port, os::NativeHandle *out_query, ServiceName name) {
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(impl::DoWithPerThreadSession([&](TipcService *fwd) {
|
|
|
|
R_RETURN(smAtmosphereMitmInstall(fwd, out_port, out_query, impl::ConvertName(name)));
|
|
|
|
}));
|
2019-12-09 11:57:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Result UninstallMitm(ServiceName name) {
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(smAtmosphereMitmUninstall(impl::ConvertName(name)));
|
2019-12-09 11:57:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Result DeclareFutureMitm(ServiceName name) {
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(smAtmosphereMitmDeclareFuture(impl::ConvertName(name)));
|
2019-12-09 11:57:37 +00:00
|
|
|
}
|
|
|
|
|
2020-09-07 17:40:43 +00:00
|
|
|
Result ClearFutureMitm(ServiceName name) {
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(smAtmosphereMitmClearFuture(impl::ConvertName(name)));
|
2020-09-07 17:40:43 +00:00
|
|
|
}
|
|
|
|
|
2019-12-09 11:57:37 +00:00
|
|
|
Result AcknowledgeSession(Service *out_service, MitmProcessInfo *out_info, ServiceName name) {
|
|
|
|
return impl::DoWithMitmAcknowledgementSession([&]() {
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(smAtmosphereMitmAcknowledgeSession(out_service, reinterpret_cast<void *>(out_info), impl::ConvertName(name)));
|
2019-12-09 11:57:37 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
Result HasMitm(bool *out, ServiceName name) {
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(smAtmosphereHasMitm(out, impl::ConvertName(name)));
|
2019-12-09 11:57:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Result WaitMitm(ServiceName name) {
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(smAtmosphereWaitMitm(impl::ConvertName(name)));
|
2019-12-09 11:57:37 +00:00
|
|
|
}
|
2022-03-06 20:08:20 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2019-12-09 11:57:37 +00:00
|
|
|
|
|
|
|
}
|