mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-06-06 01:21:18 -04:00
strat: TitleId -> ProgramId, titles->contents
This commit is contained in:
parent
1636668762
commit
ea3ebbaa7d
86 changed files with 1138 additions and 1140 deletions
|
@ -27,8 +27,8 @@ namespace ams::ro::impl {
|
|||
/* TODO: Check PSS fixed-key signature. */
|
||||
R_UNLESS(true, ResultNotAuthorized());
|
||||
|
||||
/* Check TitleID pattern is valid. */
|
||||
R_UNLESS(header->IsTitleIdValid(), ResultNotAuthorized());
|
||||
/* Check ProgramId pattern is valid. */
|
||||
R_UNLESS(header->IsProgramIdValid(), ResultNotAuthorized());
|
||||
|
||||
/* TODO: Check PSS signature over hashes. */
|
||||
R_UNLESS(true, ResultNotAuthorized());
|
||||
|
@ -36,7 +36,7 @@ namespace ams::ro::impl {
|
|||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result ValidateNrr(const NrrHeader *header, u64 size, ncm::TitleId title_id, ModuleType expected_type, bool enforce_type) {
|
||||
Result ValidateNrr(const NrrHeader *header, u64 size, ncm::ProgramId program_id, ModuleType expected_type, bool enforce_type) {
|
||||
/* Check magic. */
|
||||
R_UNLESS(header->IsMagicValid(), ResultInvalidNrr());
|
||||
|
||||
|
@ -49,8 +49,8 @@ namespace ams::ro::impl {
|
|||
/* Check signature. */
|
||||
R_TRY(ValidateNrrSignature(header));
|
||||
|
||||
/* Check title id. */
|
||||
R_UNLESS(header->GetTitleId() == title_id, ResultInvalidNrr());
|
||||
/* Check program id. */
|
||||
R_UNLESS(header->GetProgramId() == program_id, ResultInvalidNrr());
|
||||
|
||||
/* Check type. */
|
||||
if (hos::GetVersion() >= hos::Version_700 && enforce_type) {
|
||||
|
@ -64,7 +64,7 @@ namespace ams::ro::impl {
|
|||
}
|
||||
|
||||
/* Utilities for working with NRRs. */
|
||||
Result MapAndValidateNrr(NrrHeader **out_header, u64 *out_mapped_code_address, Handle process_handle, ncm::TitleId title_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, Handle process_handle, ncm::ProgramId program_id, u64 nrr_heap_address, u64 nrr_heap_size, ModuleType expected_type, bool enforce_type) {
|
||||
map::MappedCodeMemory nrr_mcm(ResultInternalError{});
|
||||
|
||||
/* First, map the NRR. */
|
||||
|
@ -79,7 +79,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, title_id, expected_type, enforce_type));
|
||||
R_TRY(ValidateNrr(nrr_header, nrr_heap_size, program_id, expected_type, enforce_type));
|
||||
|
||||
/* 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, Handle process_handle, ncm::TitleId title_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, Handle process_handle, ncm::ProgramId program_id, u64 nrr_heap_address, u64 nrr_heap_size, ModuleType expected_type, bool enforce_type);
|
||||
Result UnmapNrr(Handle process_handle, const NrrHeader *header, u64 nrr_heap_address, u64 nrr_heap_size, u64 mapped_code_address);
|
||||
|
||||
}
|
|
@ -73,22 +73,22 @@ namespace ams::ro::impl {
|
|||
os::ProcessId process_id;
|
||||
bool in_use;
|
||||
|
||||
ncm::TitleId GetTitleId(Handle other_process_h) const {
|
||||
ncm::ProgramId GetProgramId(Handle other_process_h) const {
|
||||
/* Automatically select a handle, allowing for override. */
|
||||
Handle process_h = this->process_handle;
|
||||
if (other_process_h != INVALID_HANDLE) {
|
||||
process_h = other_process_h;
|
||||
}
|
||||
|
||||
ncm::TitleId title_id = ncm::TitleId::Invalid;
|
||||
ncm::ProgramId program_id = ncm::ProgramId::Invalid;
|
||||
if (hos::GetVersion() >= hos::Version_300) {
|
||||
/* 3.0.0+: Use svcGetInfo. */
|
||||
R_ASSERT(svcGetInfo(&title_id.value, InfoType_TitleId, process_h, 0));
|
||||
R_ASSERT(svcGetInfo(&program_id.value, InfoType_ProgramId, process_h, 0));
|
||||
} else {
|
||||
/* 1.0.0-2.3.0: We're not inside loader, so ask pm. */
|
||||
R_ASSERT(pm::info::GetTitleId(&title_id, os::GetProcessId(process_h)));
|
||||
R_ASSERT(pm::info::GetProgramId(&program_id, os::GetProcessId(process_h)));
|
||||
}
|
||||
return title_id;
|
||||
return program_id;
|
||||
}
|
||||
|
||||
Result GetNrrInfoByAddress(NrrInfo **out, u64 nrr_heap_address) {
|
||||
|
@ -363,8 +363,8 @@ namespace ams::ro::impl {
|
|||
ProcessContext *context = GetContextById(context_id);
|
||||
AMS_ASSERT(context != nullptr);
|
||||
|
||||
/* Get title id. */
|
||||
const ncm::TitleId title_id = context->GetTitleId(process_h);
|
||||
/* Get program id. */
|
||||
const ncm::ProgramId program_id = context->GetProgramId(process_h);
|
||||
|
||||
/* Validate address/size. */
|
||||
R_TRY(ValidateAddressAndSize(nrr_address, nrr_size));
|
||||
|
@ -376,7 +376,7 @@ namespace ams::ro::impl {
|
|||
/* Map. */
|
||||
NrrHeader *header = nullptr;
|
||||
u64 mapped_code_address = 0;
|
||||
R_TRY(MapAndValidateNrr(&header, &mapped_code_address, context->process_handle, title_id, nrr_address, nrr_size, expected_type, enforce_type));
|
||||
R_TRY(MapAndValidateNrr(&header, &mapped_code_address, context->process_handle, program_id, nrr_address, nrr_size, expected_type, enforce_type));
|
||||
|
||||
/* Set NRR info. */
|
||||
nrr_info->in_use = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue