mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 12:21:18 +00:00
ro: rename ModuleType to reflect reality
This commit is contained in:
parent
1cccb6efc4
commit
b7d99b732a
10 changed files with 39 additions and 39 deletions
|
@ -27,7 +27,7 @@ namespace ams::ro::impl {
|
|||
AMS_SF_METHOD_INFO(C, H, 2, Result, RegisterModuleInfo, (const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 3, Result, UnregisterModuleInfo, (const sf::ClientProcessId &client_pid, u64 nrr_address)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 4, Result, RegisterProcessHandle, (const sf::ClientProcessId &client_pid, sf::CopyHandle process_h)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 10, Result, RegisterModuleInfoEx, (const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size, sf::CopyHandle process_h), hos::Version_7_0_0)
|
||||
AMS_SF_METHOD_INFO(C, H, 10, Result, RegisterProcessModuleInfo, (const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size, sf::CopyHandle process_h), hos::Version_7_0_0)
|
||||
|
||||
AMS_SF_DEFINE_INTERFACE(IRoInterface, AMS_RO_I_RO_INTERFACE_INTERFACE_INFO)
|
||||
|
||||
|
|
|
@ -20,10 +20,11 @@
|
|||
|
||||
namespace ams::ro {
|
||||
|
||||
enum class ModuleType : u8 {
|
||||
ForSelf = 0,
|
||||
ForOthers = 1,
|
||||
Count
|
||||
enum NrrKind : u8 {
|
||||
NrrKind_User = 0,
|
||||
NrrKind_JitPlugin = 1,
|
||||
|
||||
NrrKind_Count,
|
||||
};
|
||||
|
||||
struct ModuleId {
|
||||
|
@ -54,7 +55,7 @@ namespace ams::ro {
|
|||
u8 signature[0x100];
|
||||
ncm::ProgramId program_id;
|
||||
u32 size;
|
||||
u8 type; /* 7.0.0+ */
|
||||
u8 nrr_kind; /* 7.0.0+ */
|
||||
u8 reserved_33D[3];
|
||||
u32 hashes_offset;
|
||||
u32 num_hashes;
|
||||
|
@ -68,10 +69,10 @@ namespace ams::ro {
|
|||
return (static_cast<u64>(this->program_id) & this->certification.program_id_mask) == this->certification.program_id_pattern;
|
||||
}
|
||||
|
||||
ModuleType GetType() const {
|
||||
const ModuleType type = static_cast<ModuleType>(this->type);
|
||||
AMS_ABORT_UNLESS(type < ModuleType::Count);
|
||||
return type;
|
||||
NrrKind GetNrrKind() const {
|
||||
const NrrKind kind = static_cast<NrrKind>(this->nrr_kind);
|
||||
AMS_ABORT_UNLESS(kind < NrrKind_Count);
|
||||
return kind;
|
||||
}
|
||||
|
||||
ncm::ProgramId GetProgramId() const {
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace ams::ro {
|
|||
R_DEFINE_ERROR_RESULT(TooManyNro, 7);
|
||||
R_DEFINE_ERROR_RESULT(TooManyNrr, 8);
|
||||
R_DEFINE_ERROR_RESULT(NotAuthorized, 9);
|
||||
R_DEFINE_ERROR_RESULT(InvalidNrrType, 10);
|
||||
R_DEFINE_ERROR_RESULT(InvalidNrrKind, 10);
|
||||
|
||||
R_DEFINE_ERROR_RESULT(InternalError, 1023);
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ namespace ams::ro::impl {
|
|||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result ValidateNrr(const NrrHeader *header, u64 size, ncm::ProgramId program_id, ModuleType expected_type, bool enforce_type) {
|
||||
Result ValidateNrr(const NrrHeader *header, u64 size, ncm::ProgramId program_id, NrrKind nrr_kind, bool enforce_nrr_kind) {
|
||||
/* Check magic. */
|
||||
R_UNLESS(header->IsMagicValid(), ResultInvalidNrr());
|
||||
|
||||
|
@ -182,9 +182,9 @@ namespace ams::ro::impl {
|
|||
/* Check program id. */
|
||||
R_UNLESS(header->GetProgramId() == program_id, ResultInvalidNrr());
|
||||
|
||||
/* Check type. */
|
||||
if (hos::GetVersion() >= hos::Version_7_0_0 && enforce_type) {
|
||||
R_UNLESS(header->GetType() == expected_type, ResultInvalidNrrType());
|
||||
/* Check nrr kind. */
|
||||
if (hos::GetVersion() >= hos::Version_7_0_0 && enforce_nrr_kind) {
|
||||
R_UNLESS(header->GetNrrKind() == nrr_kind, ResultInvalidNrrKind());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,7 @@ namespace ams::ro::impl {
|
|||
}
|
||||
|
||||
/* Utilities for working with NRRs. */
|
||||
Result MapAndValidateNrr(NrrHeader **out_header, u64 *out_mapped_code_address, void *out_hash, size_t out_hash_size, Handle process_handle, ncm::ProgramId program_id, u64 nrr_heap_address, u64 nrr_heap_size, ModuleType expected_type, bool enforce_type) {
|
||||
Result MapAndValidateNrr(NrrHeader **out_header, u64 *out_mapped_code_address, void *out_hash, size_t out_hash_size, Handle process_handle, ncm::ProgramId program_id, u64 nrr_heap_address, u64 nrr_heap_size, NrrKind nrr_kind, bool enforce_nrr_kind) {
|
||||
map::MappedCodeMemory nrr_mcm(ResultInternalError{});
|
||||
|
||||
/* First, map the NRR. */
|
||||
|
@ -209,7 +209,7 @@ namespace ams::ro::impl {
|
|||
R_TRY(nrr_map.GetResult());
|
||||
|
||||
NrrHeader *nrr_header = reinterpret_cast<NrrHeader *>(map_address);
|
||||
R_TRY(ValidateNrr(nrr_header, nrr_heap_size, program_id, expected_type, enforce_type));
|
||||
R_TRY(ValidateNrr(nrr_header, nrr_heap_size, program_id, nrr_kind, enforce_nrr_kind));
|
||||
|
||||
/* Invalidation here actually prevents them from unmapping at scope exit. */
|
||||
nrr_map.Invalidate();
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
namespace ams::ro::impl {
|
||||
|
||||
/* Utilities for working with NRRs. */
|
||||
Result MapAndValidateNrr(NrrHeader **out_header, u64 *out_mapped_code_address, void *out_hash, size_t out_hash_size, Handle process_handle, ncm::ProgramId program_id, u64 nrr_heap_address, u64 nrr_heap_size, ModuleType expected_type, bool enforce_type);
|
||||
Result MapAndValidateNrr(NrrHeader **out_header, u64 *out_mapped_code_address, void *out_hash, size_t out_hash_size, Handle process_handle, ncm::ProgramId program_id, u64 nrr_heap_address, u64 nrr_heap_size, NrrKind nrr_kind, bool enforce_nrr_kind);
|
||||
Result UnmapNrr(Handle process_handle, const NrrHeader *header, u64 nrr_heap_address, u64 nrr_heap_size, u64 mapped_code_address);
|
||||
|
||||
bool ValidateNrrHashTableEntry(const void *signed_area, size_t signed_area_size, size_t hashes_offset, size_t num_hashes, const void *nrr_hash, const u8 *hash_table, const void *desired_hash);
|
||||
|
|
|
@ -413,7 +413,7 @@ namespace ams::ro::impl {
|
|||
}
|
||||
|
||||
/* Service implementations. */
|
||||
Result RegisterModuleInfo(size_t context_id, Handle process_h, u64 nrr_address, u64 nrr_size, ModuleType expected_type, bool enforce_type) {
|
||||
Result RegisterModuleInfo(size_t context_id, Handle process_h, u64 nrr_address, u64 nrr_size, NrrKind nrr_kind, bool enforce_nrr_kind) {
|
||||
/* Get context. */
|
||||
ProcessContext *context = GetContextById(context_id);
|
||||
AMS_ABORT_UNLESS(context != nullptr);
|
||||
|
@ -435,7 +435,7 @@ namespace ams::ro::impl {
|
|||
/* Map. */
|
||||
NrrHeader *header = nullptr;
|
||||
u64 mapped_code_address = 0;
|
||||
R_TRY(MapAndValidateNrr(&header, &mapped_code_address, std::addressof(signed_area_hash), sizeof(signed_area_hash), context->process_handle, program_id, nrr_address, nrr_size, expected_type, enforce_type));
|
||||
R_TRY(MapAndValidateNrr(&header, &mapped_code_address, std::addressof(signed_area_hash), sizeof(signed_area_hash), context->process_handle, program_id, nrr_address, nrr_size, nrr_kind, enforce_nrr_kind));
|
||||
|
||||
/* Set NRR info. */
|
||||
context->SetNrrInfoInUse(nrr_info, true);
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace ams::ro::impl {
|
|||
void UnregisterProcess(size_t context_id);
|
||||
|
||||
/* Service implementations. */
|
||||
Result RegisterModuleInfo(size_t context_id, Handle process_h, u64 nrr_address, u64 nrr_size, ModuleType expected_type, bool enforce_type);
|
||||
Result RegisterModuleInfo(size_t context_id, Handle process_h, u64 nrr_address, u64 nrr_size, NrrKind nrr_kind, bool enforce_nrr_kind);
|
||||
Result UnregisterModuleInfo(size_t context_id, u64 nrr_address);
|
||||
Result MapManualLoadModuleMemory(u64 *out_address, size_t context_id, u64 nro_address, u64 nro_size, u64 bss_address, u64 bss_size);
|
||||
Result UnmapManualLoadModuleMemory(size_t context_id, u64 nro_address);
|
||||
|
|
|
@ -95,11 +95,11 @@ namespace {
|
|||
constexpr size_t DebugMonitorMaxSessions = 2;
|
||||
|
||||
/* NOTE: Official code passes 32 for ldr:ro max sessions. We will pass 2, because that's the actual limit. */
|
||||
constexpr sm::ServiceName ForSelfServiceName = sm::ServiceName::Encode("ldr:ro");
|
||||
constexpr size_t ForSelfMaxSessions = 2;
|
||||
constexpr sm::ServiceName UserServiceName = sm::ServiceName::Encode("ldr:ro");
|
||||
constexpr size_t UserMaxSessions = 2;
|
||||
|
||||
constexpr sm::ServiceName ForOthersServiceName = sm::ServiceName::Encode("ro:1");
|
||||
constexpr size_t ForOthersMaxSessions = 2;
|
||||
constexpr sm::ServiceName JitPluginServiceName = sm::ServiceName::Encode("ro:1");
|
||||
constexpr size_t JitPluginMaxSessions = 2;
|
||||
|
||||
}
|
||||
|
||||
|
@ -120,9 +120,9 @@ int main(int argc, char **argv)
|
|||
/* Create services. */
|
||||
R_ABORT_UNLESS((g_server_manager.RegisterServer<ro::impl::IDebugMonitorInterface, ro::DebugMonitorService>(DebugMonitorServiceName, DebugMonitorMaxSessions)));
|
||||
|
||||
R_ABORT_UNLESS((g_server_manager.RegisterServer<ro::impl::IRoInterface, ro::RoServiceForSelf>(ForSelfServiceName, ForSelfMaxSessions)));
|
||||
R_ABORT_UNLESS((g_server_manager.RegisterServer<ro::impl::IRoInterface, ro::RoUserService>(UserServiceName, UserMaxSessions)));
|
||||
if (hos::GetVersion() >= hos::Version_7_0_0) {
|
||||
R_ABORT_UNLESS((g_server_manager.RegisterServer<ro::impl::IRoInterface, ro::RoServiceForOthers>(ForOthersServiceName, ForOthersMaxSessions)));
|
||||
R_ABORT_UNLESS((g_server_manager.RegisterServer<ro::impl::IRoInterface, ro::RoJitPluginService>(JitPluginServiceName, JitPluginMaxSessions)));
|
||||
}
|
||||
|
||||
/* Loop forever, servicing our services. */
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace ams::ro {
|
|||
impl::SetDevelopmentFunctionEnabled(is_development_function_enabled);
|
||||
}
|
||||
|
||||
RoService::RoService(ModuleType t) : context_id(impl::InvalidContextId), type(t) {
|
||||
RoService::RoService(NrrKind k) : context_id(impl::InvalidContextId), nrr_kind(k) {
|
||||
/* ... */
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ namespace ams::ro {
|
|||
|
||||
Result RoService::RegisterModuleInfo(const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size) {
|
||||
R_TRY(impl::ValidateProcess(this->context_id, client_pid.GetValue()));
|
||||
return impl::RegisterModuleInfo(this->context_id, svc::InvalidHandle, nrr_address, nrr_size, ModuleType::ForSelf, true);
|
||||
return impl::RegisterModuleInfo(this->context_id, svc::InvalidHandle, nrr_address, nrr_size, NrrKind_User, true);
|
||||
}
|
||||
|
||||
Result RoService::UnregisterModuleInfo(const sf::ClientProcessId &client_pid, u64 nrr_address) {
|
||||
|
@ -59,9 +59,9 @@ namespace ams::ro {
|
|||
return impl::RegisterProcess(std::addressof(this->context_id), process_h.GetValue(), client_pid.GetValue());
|
||||
}
|
||||
|
||||
Result RoService::RegisterModuleInfoEx(const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size, sf::CopyHandle process_h) {
|
||||
Result RoService::RegisterProcessModuleInfo(const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size, sf::CopyHandle process_h) {
|
||||
R_TRY(impl::ValidateProcess(this->context_id, client_pid.GetValue()));
|
||||
return impl::RegisterModuleInfo(this->context_id, process_h.GetValue(), nrr_address, nrr_size, this->type, this->type == ModuleType::ForOthers);
|
||||
return impl::RegisterModuleInfo(this->context_id, process_h.GetValue(), nrr_address, nrr_size, this->nrr_kind, this->nrr_kind == NrrKind_JitPlugin);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,9 +26,9 @@ namespace ams::ro {
|
|||
class RoService {
|
||||
private:
|
||||
size_t context_id;
|
||||
ModuleType type;
|
||||
NrrKind nrr_kind;
|
||||
protected:
|
||||
explicit RoService(ModuleType t);
|
||||
explicit RoService(NrrKind k);
|
||||
public:
|
||||
virtual ~RoService();
|
||||
public:
|
||||
|
@ -38,19 +38,18 @@ namespace ams::ro {
|
|||
Result RegisterModuleInfo(const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size);
|
||||
Result UnregisterModuleInfo(const sf::ClientProcessId &client_pid, u64 nrr_address);
|
||||
Result RegisterProcessHandle(const sf::ClientProcessId &client_pid, sf::CopyHandle process_h);
|
||||
Result RegisterModuleInfoEx(const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size, sf::CopyHandle process_h);
|
||||
Result RegisterProcessModuleInfo(const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size, sf::CopyHandle process_h);
|
||||
};
|
||||
static_assert(ro::impl::IsIRoInterface<RoService>);
|
||||
|
||||
class RoServiceForSelf final : public RoService {
|
||||
class RoUserService final : public RoService {
|
||||
public:
|
||||
RoServiceForSelf() : RoService(ro::ModuleType::ForSelf) { /* ... */ }
|
||||
RoUserService() : RoService(NrrKind_User) { /* ... */ }
|
||||
};
|
||||
|
||||
/* TODO: This is really JitPlugin... */
|
||||
class RoServiceForOthers final : public RoService {
|
||||
class RoJitPluginService final : public RoService {
|
||||
public:
|
||||
RoServiceForOthers() : RoService(ro::ModuleType::ForOthers) { /* ... */ }
|
||||
RoJitPluginService() : RoService(NrrKind_JitPlugin) { /* ... */ }
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue