libstrat: fix domain issues. in/out objects now work.

This commit is contained in:
Michael Scire
2019-10-23 00:07:20 -07:00
committed by SciresM
parent 4f455dacf4
commit 15773e4755
23 changed files with 161 additions and 113 deletions

View File

@@ -17,31 +17,31 @@
#include "../service_guard.h"
#include "sm_ams.h"
static Result _smAtmosphereCmdHas(bool *out, u64 service_name, u32 cmd_id) {
static Result _smAtmosphereCmdHas(bool *out, SmServiceName name, u32 cmd_id) {
u8 tmp;
Result rc = serviceDispatchInOut(smGetServiceSession(), cmd_id, service_name, tmp);
Result rc = serviceDispatchInOut(smGetServiceSession(), cmd_id, name, tmp);
if (R_SUCCEEDED(rc) && out) *out = tmp & 1;
return rc;
}
static Result _smAtmosphereCmdInServiceNameNoOut(u64 service_name, Service *srv, u32 cmd_id) {
return serviceDispatchIn(srv, cmd_id, service_name);
static Result _smAtmosphereCmdInServiceNameNoOut(SmServiceName name, Service *srv, u32 cmd_id) {
return serviceDispatchIn(srv, cmd_id, name);
}
Result smAtmosphereHasService(bool *out, const char *name) {
return _smAtmosphereCmdHas(out, smEncodeName(name), 65100);
Result smAtmosphereHasService(bool *out, SmServiceName name) {
return _smAtmosphereCmdHas(out, name, 65100);
}
Result smAtmosphereWaitService(const char *name) {
return _smAtmosphereCmdInServiceNameNoOut(smEncodeName(name), smGetServiceSession(), 65101);
Result smAtmosphereWaitService(SmServiceName name) {
return _smAtmosphereCmdInServiceNameNoOut(name, smGetServiceSession(), 65101);
}
Result smAtmosphereHasMitm(bool *out, const char *name) {
return _smAtmosphereCmdHas(out, smEncodeName(name), 65004);
Result smAtmosphereHasMitm(bool *out, SmServiceName name) {
return _smAtmosphereCmdHas(out, name, 65004);
}
Result smAtmosphereWaitMitm(const char *name) {
return _smAtmosphereCmdInServiceNameNoOut(smEncodeName(name), smGetServiceSession(), 65005);
Result smAtmosphereWaitMitm(SmServiceName name) {
return _smAtmosphereCmdInServiceNameNoOut(name, smGetServiceSession(), 65005);
}
static Service g_smAtmosphereMitmSrv;
@@ -76,10 +76,9 @@ Service* smAtmosphereMitmGetServiceSession(void) {
return &g_smAtmosphereMitmSrv;
}
Result smAtmosphereMitmInstall(Handle *handle_out, Handle *query_out, const char *name) {
const u64 in = smEncodeName(name);
Result smAtmosphereMitmInstall(Handle *handle_out, Handle *query_out, SmServiceName name) {
Handle tmp_handles[2];
Result rc = serviceDispatchIn(&g_smAtmosphereMitmSrv, 65000, in,
Result rc = serviceDispatchIn(&g_smAtmosphereMitmSrv, 65000, name,
.out_handle_attrs = { SfOutHandleAttr_HipcMove, SfOutHandleAttr_HipcMove },
.out_handles = tmp_handles,
);
@@ -92,22 +91,21 @@ Result smAtmosphereMitmInstall(Handle *handle_out, Handle *query_out, const char
return rc;
}
Result smAtmosphereMitmUninstall(const char *name) {
return _smAtmosphereCmdInServiceNameNoOut(smEncodeName(name), &g_smAtmosphereMitmSrv, 65001);
Result smAtmosphereMitmUninstall(SmServiceName name) {
return _smAtmosphereCmdInServiceNameNoOut(name, &g_smAtmosphereMitmSrv, 65001);
}
Result smAtmosphereMitmDeclareFuture(const char *name) {
return _smAtmosphereCmdInServiceNameNoOut(smEncodeName(name), &g_smAtmosphereMitmSrv, 65006);
Result smAtmosphereMitmDeclareFuture(SmServiceName name) {
return _smAtmosphereCmdInServiceNameNoOut(name, &g_smAtmosphereMitmSrv, 65006);
}
Result smAtmosphereMitmAcknowledgeSession(Service *srv_out, u64 *pid_out, u64 *tid_out, const char *name) {
const u64 in = smEncodeName(name);
Result smAtmosphereMitmAcknowledgeSession(Service *srv_out, u64 *pid_out, u64 *tid_out, SmServiceName name) {
struct {
u64 pid;
u64 tid;
} out;
Result rc = serviceDispatchInOut(&g_smAtmosphereMitmSrv, 65003, in, out,
Result rc = serviceDispatchInOut(&g_smAtmosphereMitmSrv, 65003, name, out,
.out_num_objects = 1,
.out_objects = srv_out,
);

View File

@@ -13,19 +13,19 @@
extern "C" {
#endif
Result smAtmosphereHasService(bool *out, const char *name);
Result smAtmosphereWaitService(const char *name);
Result smAtmosphereHasMitm(bool *out, const char *name);
Result smAtmosphereWaitMitm(const char *name);
Result smAtmosphereHasService(bool *out, SmServiceName name);
Result smAtmosphereWaitService(SmServiceName name);
Result smAtmosphereHasMitm(bool *out, SmServiceName name);
Result smAtmosphereWaitMitm(SmServiceName name);
Result smAtmosphereMitmInitialize(void);
void smAtmosphereMitmExit(void);
Service *smAtmosphereMitmGetServiceSession();
Result smAtmosphereMitmInstall(Handle *handle_out, Handle *query_out, const char *name);
Result smAtmosphereMitmUninstall(const char *name);
Result smAtmosphereMitmDeclareFuture(const char *name);
Result smAtmosphereMitmAcknowledgeSession(Service *srv_out, u64 *pid_out, u64 *tid_out, const char *name);
Result smAtmosphereMitmInstall(Handle *handle_out, Handle *query_out, SmServiceName name);
Result smAtmosphereMitmUninstall(SmServiceName name);
Result smAtmosphereMitmDeclareFuture(SmServiceName name);
Result smAtmosphereMitmAcknowledgeSession(Service *srv_out, u64 *pid_out, u64 *tid_out, SmServiceName name);
#ifdef __cplusplus
}

View File

@@ -26,32 +26,32 @@ namespace sts::sm {
/* Ordinary SM API. */
Result GetService(Service *out, ServiceName name) {
return impl::DoWithUserSession([&]() {
return smGetService(out, name.name);
return smGetServiceWrapper(out, impl::ConvertName(name));
});
}
Result RegisterService(Handle *out, ServiceName name, size_t max_sessions, bool is_light) {
return impl::DoWithUserSession([&]() {
return smRegisterService(out, name.name, is_light, static_cast<int>(max_sessions));
return smRegisterService(out, impl::ConvertName(name), is_light, static_cast<int>(max_sessions));
});
}
Result UnregisterService(ServiceName name) {
return impl::DoWithUserSession([&]() {
return smUnregisterService(name.name);
return smUnregisterService(impl::ConvertName(name));
});
}
/* Atmosphere extensions. */
Result HasService(bool *out, ServiceName name) {
return impl::DoWithUserSession([&]() {
return smAtmosphereHasService(out, name.name);
return smAtmosphereHasService(out, impl::ConvertName(name));
});
}
Result WaitService(ServiceName name) {
return impl::DoWithUserSession([&]() {
return smAtmosphereWaitService(name.name);
return smAtmosphereWaitService(impl::ConvertName(name));
});
}

View File

@@ -20,6 +20,7 @@
#include <stratosphere/sm/sm_manager_api.hpp>
#include "smm_ams.h"
#include "sm_utils.hpp"
namespace sts::sm::manager {
@@ -38,7 +39,7 @@ namespace sts::sm::manager {
}
Result HasMitm(bool *out, ServiceName name) {
return smManagerAtmosphereHasMitm(out, name.name);
return smManagerAtmosphereHasMitm(out, impl::ConvertName(name));
}
}

View File

@@ -26,37 +26,37 @@ namespace sts::sm::mitm {
/* Mitm API. */
Result InstallMitm(Handle *out_port, Handle *out_query, ServiceName name) {
return impl::DoWithMitmSession([&]() {
return smAtmosphereMitmInstall(out_port, out_query, name.name);
return smAtmosphereMitmInstall(out_port, out_query, impl::ConvertName(name));
});
}
Result UninstallMitm(ServiceName name) {
return impl::DoWithMitmSession([&]() {
return smAtmosphereMitmUninstall(name.name);
return smAtmosphereMitmUninstall(impl::ConvertName(name));
});
}
Result DeclareFutureMitm(ServiceName name) {
return impl::DoWithMitmSession([&]() {
return smAtmosphereMitmDeclareFuture(name.name);
return smAtmosphereMitmDeclareFuture(impl::ConvertName(name));
});
}
Result AcknowledgeSession(Service *out_service, os::ProcessId *out_pid, ncm::TitleId *out_tid, ServiceName name) {
return impl::DoWithMitmSession([&]() {
return smAtmosphereMitmAcknowledgeSession(out_service, &out_pid->value, &out_tid->value, name.name);
return smAtmosphereMitmAcknowledgeSession(out_service, &out_pid->value, &out_tid->value, impl::ConvertName(name));
});
}
Result HasMitm(bool *out, ServiceName name) {
return impl::DoWithUserSession([&]() {
return smAtmosphereHasMitm(out, name.name);
return smAtmosphereHasMitm(out, impl::ConvertName(name));
});
}
Result WaitMitm(ServiceName name) {
return impl::DoWithUserSession([&]() {
return smAtmosphereWaitMitm(name.name);
return smAtmosphereWaitMitm(impl::ConvertName(name));
});
}

View File

@@ -50,4 +50,11 @@ namespace sts::sm::impl {
}
}
NX_CONSTEXPR SmServiceName ConvertName(sm::ServiceName name) {
static_assert(sizeof(SmServiceName) == sizeof(sm::ServiceName));
SmServiceName ret = {};
__builtin_memcpy(&ret, &name, sizeof(sm::ServiceName));
return ret;
}
}

View File

@@ -36,13 +36,13 @@ Result smManagerAtmosphereRegisterProcess(u64 pid, u64 tid, const void *acid_sac
);
}
static Result _smManagerAtmosphereCmdHas(bool *out, u64 service_name, u32 cmd_id) {
static Result _smManagerAtmosphereCmdHas(bool *out, SmServiceName name, u32 cmd_id) {
u8 tmp;
Result rc = serviceDispatchInOut(smManagerGetServiceSession(), cmd_id, service_name, tmp);
Result rc = serviceDispatchInOut(smManagerGetServiceSession(), cmd_id, name, tmp);
if (R_SUCCEEDED(rc) && out) *out = tmp & 1;
return rc;
}
Result smManagerAtmosphereHasMitm(bool *out, const char* name) {
return _smManagerAtmosphereCmdHas(out, smEncodeName(name), 65001);
Result smManagerAtmosphereHasMitm(bool *out, SmServiceName name) {
return _smManagerAtmosphereCmdHas(out, name, 65001);
}

View File

@@ -13,7 +13,7 @@ extern "C" {
Result smManagerAtmosphereEndInitialDefers(void);
Result smManagerAtmosphereRegisterProcess(u64 pid, u64 tid, const void *acid_sac, size_t acid_sac_size, const void *aci_sac, size_t aci_sac_size);
Result smManagerAtmosphereHasMitm(bool *out, const char* name);
Result smManagerAtmosphereHasMitm(bool *out, SmServiceName name);
#ifdef __cplusplus
}