ro: implement rest of LoadNrr/LoadNrrEx

This commit is contained in:
Michael Scire
2019-04-21 05:28:57 -07:00
parent cb88fdfd62
commit 4ba6d8b24c
7 changed files with 589 additions and 32 deletions

View File

@@ -19,10 +19,7 @@
#include <stratosphere.hpp>
enum RoModuleType : u32 {
RoModuleType_ForSelf = 0,
RoModuleType_ForOthers = 1,
};
#include "ro_nrr.hpp"
class Registration {
public:
@@ -31,27 +28,6 @@ class Registration {
static constexpr size_t MaxNrrInfos = 0x40;
static constexpr size_t MaxNroInfos = 0x40;
public:
struct NrrHeader {
u32 magic;
u32 _0x4;
u32 _0x8;
u32 _0xC;
u64 title_id_mask;
u64 title_id_pattern;
u64 _0x20;
u64 _0x28;
u8 modulus[0x100];
u8 fixed_key_signature[0x100];
u8 nrr_signature[0x100];
u64 title_id_min;
u32 nrr_size;
u8 nrr_type; /* 7.0.0+ */
u8 _0x33D[3];
u32 hash_offset;
u32 num_hashes;
u64 _0x348;
};
static_assert(sizeof(NrrHeader) == 0x350, "NrrHeader definition!");
struct NroHeader {
u32 entrypoint_insn;
@@ -105,10 +81,11 @@ class Registration {
bool in_use;
};
private:
static Result MapAndValidateNrr(NrrHeader **out_header, u64 *out_mapped_code_address, Handle process_handle, u64 title_id, u64 nrr_heap_address, u64 nrr_heap_size);
static Result MapAndValidateNrr(NrrHeader **out_header, u64 *out_mapped_code_address, Handle process_handle, u64 title_id, u64 nrr_heap_address, u64 nrr_heap_size, RoModuleType expected_type, bool enforce_type);
static Result UnmapNrr(Handle process_handle, const NrrHeader *header, u64 nrr_heap_address, u64 nrr_heap_size, u64 mapped_code_address);
public:
static void Initialize();
static bool ShouldEaseNroRestriction();
static Result RegisterProcess(RoProcessContext **out_context, Handle process_handle, u64 process_id);
static void UnregisterProcess(RoProcessContext *context);