revert fsldr change, fix null deref in pm
This commit is contained in:
parent
e688ec9257
commit
ef034a87d4
@ -28,6 +28,26 @@ static u64 g_cached_prog_handle;
|
|||||||
static ExHeader_Info g_exheader;
|
static ExHeader_Info g_exheader;
|
||||||
static char g_ret_buf[1024];
|
static char g_ret_buf[1024];
|
||||||
|
|
||||||
|
// MAKE SURE fsreg has been init before calling this
|
||||||
|
static Result fsldrPatchPermissions(void)
|
||||||
|
{
|
||||||
|
u32 pid;
|
||||||
|
Result res;
|
||||||
|
FS_ProgramInfo info;
|
||||||
|
ExHeader_Arm11StorageInfo storageInfo = {
|
||||||
|
.fs_access_info = FSACCESS_NANDRW | FSACCESS_NANDRO_RO | FSACCESS_SDMC_RW,
|
||||||
|
};
|
||||||
|
|
||||||
|
info.programId = 0x0004013000001302LL; // loader PID
|
||||||
|
info.mediaType = MEDIATYPE_NAND;
|
||||||
|
res = svcGetProcessId(&pid, CUR_PROCESS_HANDLE);
|
||||||
|
if (R_SUCCEEDED(res))
|
||||||
|
{
|
||||||
|
res = FSREG_Register(pid, 0xFFFF000000000000LL, &info, &storageInfo);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
static inline void loadCFWInfo(void)
|
static inline void loadCFWInfo(void)
|
||||||
{
|
{
|
||||||
s64 out;
|
s64 out;
|
||||||
@ -565,10 +585,8 @@ void __appInit()
|
|||||||
svcBreak(USERBREAK_PANIC);
|
svcBreak(USERBREAK_PANIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for pm to call fs:REG Register on us
|
fsRegInit();
|
||||||
bool registered = false;
|
fsldrPatchPermissions();
|
||||||
while (srvIsServiceRegistered(®istered, "pm:app"), registered)
|
|
||||||
svcSleepThread(500 * 1000LL);
|
|
||||||
|
|
||||||
//fsldrInit();
|
//fsldrInit();
|
||||||
res = srvGetServiceHandle(fsGetSessionHandle(), "fs:LDR");
|
res = srvGetServiceHandle(fsGetSessionHandle(), "fs:LDR");
|
||||||
|
@ -205,8 +205,11 @@ static Result loadWithDependencies(Handle *outDebug, ProcessData **outProcessDat
|
|||||||
static Result launchTitleImpl(Handle *debug, ProcessData **outProcessData, const FS_ProgramInfo *programInfo,
|
static Result launchTitleImpl(Handle *debug, ProcessData **outProcessData, const FS_ProgramInfo *programInfo,
|
||||||
const FS_ProgramInfo *programInfoUpdate, u32 launchFlags, ExHeader_Info *exheaderInfo)
|
const FS_ProgramInfo *programInfoUpdate, u32 launchFlags, ExHeader_Info *exheaderInfo)
|
||||||
{
|
{
|
||||||
if (isTitleLaunchPrevented(programInfo->programId)) {
|
if (debug != NULL) {
|
||||||
*debug = 0;
|
*debug = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isTitleLaunchPrevented(programInfo->programId)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,19 +16,4 @@ bool isTitleLaunchPrevented(u64 titleId)
|
|||||||
|
|
||||||
svcGetSystemInfo(&numKips, 26, 0);
|
svcGetSystemInfo(&numKips, 26, 0);
|
||||||
return numKips >= 6 && (titleId & ~N3DS_TID_BIT) == 0x0004003000008A02ULL; // ErrDisp
|
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);;
|
|
||||||
}
|
}
|
@ -3,5 +3,4 @@
|
|||||||
#include <3ds/types.h>
|
#include <3ds/types.h>
|
||||||
|
|
||||||
u32 getKExtSize(void);
|
u32 getKExtSize(void);
|
||||||
bool isTitleLaunchPrevented(u64 titleId);
|
bool isTitleLaunchPrevented(u64 titleId);
|
||||||
Result fsRegSetupPermissionsForKip(u32 pid, u64 titleId);
|
|
@ -42,13 +42,6 @@ void Manager_RegisterKips(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ProcessList_Unlock(&g_manager.processList);
|
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)
|
Result UnregisterProcess(u64 titleId)
|
||||||
|
@ -37,6 +37,39 @@
|
|||||||
#include "menus/miscellaneous.h"
|
#include "menus/miscellaneous.h"
|
||||||
#include "menus/screen_filters.h"
|
#include "menus/screen_filters.h"
|
||||||
|
|
||||||
|
static Result stealFsReg(void)
|
||||||
|
{
|
||||||
|
Result ret = 0;
|
||||||
|
|
||||||
|
ret = svcControlService(SERVICEOP_STEAL_CLIENT_SESSION, fsRegGetSessionHandle(), "fs:REG");
|
||||||
|
while(ret == 0x9401BFE)
|
||||||
|
{
|
||||||
|
svcSleepThread(500 * 1000LL);
|
||||||
|
ret = svcControlService(SERVICEOP_STEAL_CLIENT_SESSION, fsRegGetSessionHandle(), "fs:REG");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Result fsRegSetupPermissions(void)
|
||||||
|
{
|
||||||
|
u32 pid;
|
||||||
|
Result res;
|
||||||
|
FS_ProgramInfo info;
|
||||||
|
|
||||||
|
ExHeader_Arm11StorageInfo storageInfo = {
|
||||||
|
.fs_access_info = FSACCESS_NANDRO_RW | FSACCESS_NANDRW | FSACCESS_SDMC_RW,
|
||||||
|
};
|
||||||
|
|
||||||
|
info.programId = 0x0004013000006902LL; // Rosalina TID
|
||||||
|
info.mediaType = MEDIATYPE_NAND;
|
||||||
|
|
||||||
|
if(R_SUCCEEDED(res = svcGetProcessId(&pid, CUR_PROCESS_HANDLE)))
|
||||||
|
res = FSREG_Register(pid, 0xFFFF000000000000LL, &info, &storageInfo);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
// this is called before main
|
// this is called before main
|
||||||
bool isN3DS;
|
bool isN3DS;
|
||||||
void __appInit()
|
void __appInit()
|
||||||
@ -49,12 +82,7 @@ void __appInit()
|
|||||||
svcBreak(USERBREAK_PANIC);
|
svcBreak(USERBREAK_PANIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for pm to call fs:REG Register on us
|
if (R_FAILED(stealFsReg()) || R_FAILED(fsRegSetupPermissions()) || R_FAILED(fsInit()))
|
||||||
bool registered = false;
|
|
||||||
while (srvIsServiceRegistered(®istered, "pm:app"), registered)
|
|
||||||
svcSleepThread(500 * 1000LL);
|
|
||||||
|
|
||||||
if (R_FAILED(fsInit()))
|
|
||||||
svcBreak(USERBREAK_PANIC);
|
svcBreak(USERBREAK_PANIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user