move patches to pm
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "exheader_info_heap.h"
|
||||
#include "task_runner.h"
|
||||
#include "util.h"
|
||||
#include "luma.h"
|
||||
|
||||
static inline void removeAccessToService(const char *service, char (*serviceAccessList)[8])
|
||||
{
|
||||
@@ -204,6 +205,11 @@ static Result loadWithDependencies(Handle *outDebug, ProcessData **outProcessDat
|
||||
static Result launchTitleImpl(Handle *debug, ProcessData **outProcessData, const FS_ProgramInfo *programInfo,
|
||||
const FS_ProgramInfo *programInfoUpdate, u32 launchFlags, ExHeader_Info *exheaderInfo)
|
||||
{
|
||||
if (isTitleLaunchPrevented(programInfo->programId)) {
|
||||
*debug = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (launchFlags & PMLAUNCHFLAG_NORMAL_APPLICATION) {
|
||||
launchFlags |= PMLAUNCHFLAG_LOAD_DEPENDENCIES;
|
||||
} else {
|
||||
@@ -299,7 +305,7 @@ static Result launchTitleImplWrapper(Handle *outDebug, u32 *outPid, const FS_Pro
|
||||
ProcessData *process;
|
||||
Result res = launchTitleImpl(outDebug, &process, programInfo, programInfoUpdate, launchFlags, exheaderInfo);
|
||||
|
||||
if (outPid != NULL) {
|
||||
if (outPid != NULL && process != NULL) {
|
||||
*outPid = process->pid;
|
||||
}
|
||||
|
||||
|
||||
34
sysmodules/pm/source/luma.c
Normal file
34
sysmodules/pm/source/luma.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <3ds.h>
|
||||
#include <string.h>
|
||||
#include "luma.h"
|
||||
#include "util.h"
|
||||
|
||||
u32 getKExtSize(void)
|
||||
{
|
||||
s64 val;
|
||||
Result res = svcGetSystemInfo(&val, 0x10000, 0x300);
|
||||
return R_FAILED(res) ? 0 : (u32)val;
|
||||
}
|
||||
|
||||
bool isTitleLaunchPrevented(u64 titleId)
|
||||
{
|
||||
s64 numKips = 0;
|
||||
|
||||
svcGetSystemInfo(&numKips, 26, 0);
|
||||
return numKips >= 6 && (titleId & ~N3DS_TID_BIT) == 0x0004003000008A02ULL; // ErrDisp
|
||||
}
|
||||
|
||||
Result fsRegSetupPermissionsForKip(u32 pid, u64 titleId)
|
||||
{
|
||||
FS_ProgramInfo info;
|
||||
|
||||
ExHeader_Arm11StorageInfo storageInfo = {
|
||||
.fs_access_info = FSACCESS_NANDRO_RW | FSACCESS_NANDRW | FSACCESS_SDMC_RW,
|
||||
};
|
||||
|
||||
// Non-dummy TID
|
||||
info.programId = titleId;
|
||||
info.mediaType = MEDIATYPE_NAND;
|
||||
|
||||
return FSREG_Register(pid, 0xFFFF000000000000LL, &info, &storageInfo);;
|
||||
}
|
||||
7
sysmodules/pm/source/luma.h
Normal file
7
sysmodules/pm/source/luma.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <3ds/types.h>
|
||||
|
||||
u32 getKExtSize(void);
|
||||
bool isTitleLaunchPrevented(u64 titleId);
|
||||
Result fsRegSetupPermissionsForKip(u32 pid, u64 titleId);
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "manager.h"
|
||||
#include "reslimit.h"
|
||||
#include "util.h"
|
||||
#include "luma.h"
|
||||
|
||||
Manager g_manager;
|
||||
|
||||
@@ -41,6 +42,13 @@ void Manager_RegisterKips(void)
|
||||
}
|
||||
|
||||
ProcessList_Unlock(&g_manager.processList);
|
||||
|
||||
// Register loader, pm, and rosalina (if applicable)
|
||||
assertSuccess(fsRegSetupPermissionsForKip(1, 0x0004013000001302LL)); // loader
|
||||
assertSuccess(fsRegSetupPermissionsForKip(2, 0x0004013000001202LL)); // pm
|
||||
if (numKips >= 6) {
|
||||
assertSuccess(fsRegSetupPermissionsForKip(5, 0x0004013000006902LL)); // rosalina
|
||||
}
|
||||
}
|
||||
|
||||
Result UnregisterProcess(u64 titleId)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "reslimit.h"
|
||||
#include "util.h"
|
||||
#include "manager.h"
|
||||
#include "luma.h"
|
||||
|
||||
typedef s64 ReslimitValues[10];
|
||||
|
||||
@@ -242,7 +243,7 @@ static ReslimitValues *fixupReslimitValues(void)
|
||||
{
|
||||
// In order: APPLICATION, SYS_APPLET, LIB_APPLET, OTHER
|
||||
// Fixup "commit" reslimit
|
||||
u32 sysmemalloc = SYSMEMALLOC;
|
||||
u32 sysmemalloc = SYSMEMALLOC + getKExtSize();
|
||||
ReslimitValues *values = !IS_N3DS ? g_o3dsReslimitValues : g_n3dsReslimitValues;
|
||||
|
||||
static const u32 minAppletMemAmount = 0x1200000;
|
||||
|
||||
Reference in New Issue
Block a user