rosalina/pm: remove fs patch, use pm instead
This commit is contained in:
parent
71cddef78f
commit
a21eee9207
@ -73,7 +73,11 @@ static Result loadWithoutDependencies(Handle *outDebug, ProcessData **outProcess
|
||||
u32 serviceCount;
|
||||
for(serviceCount = 0; serviceCount < 34 && *(u64 *)localcaps->service_access[serviceCount] != 0; serviceCount++);
|
||||
|
||||
TRY(FSREG_Register(pid, programHandle, programInfo, &localcaps->storage_info));
|
||||
// Not in official PM: patch local caps to give access to everything
|
||||
ExHeader_Arm11StorageInfo storageInfo = localcaps->storage_info;
|
||||
storageInfo.fs_access_info = 0xFFFFFFFF;
|
||||
|
||||
TRY(FSREG_Register(pid, programHandle, programInfo, &storageInfo));
|
||||
TRY(SRVPM_RegisterProcess(pid, serviceCount, localcaps->service_access));
|
||||
|
||||
if (localcaps->reslimit_category <= RESLIMIT_CATEGORY_OTHER) {
|
||||
|
@ -7,6 +7,21 @@
|
||||
|
||||
Manager g_manager;
|
||||
|
||||
static void giveAllFsArchiveAccessToKip(u32 pid, u64 tid)
|
||||
{
|
||||
static const ExHeader_Arm11StorageInfo storageInfo = {
|
||||
.fs_access_info = 0xFFFFFFFF,
|
||||
};
|
||||
static const u64 programHandle = 0xFFFF000000000000LL;
|
||||
|
||||
FS_ProgramInfo info = {
|
||||
.programId = tid,
|
||||
.mediaType = MEDIATYPE_NAND,
|
||||
};
|
||||
|
||||
assertSuccess(FSREG_Register(pid, programHandle, &info, &storageInfo));
|
||||
}
|
||||
|
||||
void Manager_Init(void *procBuf, size_t numProc)
|
||||
{
|
||||
memset(&g_manager, 0, sizeof(Manager));
|
||||
@ -34,7 +49,7 @@ void Manager_RegisterKips(void)
|
||||
process->handle = processHandle;
|
||||
process->pid = i;
|
||||
process->refcount = 1;
|
||||
process->titleId = 0x0004000100001000ULL; // note: same TID for all builtins
|
||||
process->titleId = 0x0004000100001000ULL; // note: same internal TID for all builtins
|
||||
process->flags = PROCESSFLAG_KIP;
|
||||
process->terminationStatus = TERMSTATUS_RUNNING;
|
||||
|
||||
@ -43,8 +58,14 @@ void Manager_RegisterKips(void)
|
||||
assertSuccess(svcSetProcessResourceLimits(processHandle, g_manager.reslimits[RESLIMIT_CATEGORY_OTHER]));
|
||||
}
|
||||
}
|
||||
|
||||
ProcessList_Unlock(&g_manager.processList);
|
||||
|
||||
// Give full archive access to us (PM) and Rosalina (real PIDs don't matter, they just have to be unique (?))
|
||||
// Loader doesn't depend on PM and has its own fs:REG handle so it must do it itself.
|
||||
giveAllFsArchiveAccessToKip(2, 0x0004013000001202LL); // PM
|
||||
if (numKips > 5) {
|
||||
giveAllFsArchiveAccessToKip(5, 0x0004013000006902LL); // Rosalina
|
||||
}
|
||||
}
|
||||
|
||||
Result UnregisterProcess(u64 titleId)
|
||||
|
@ -6,30 +6,10 @@
|
||||
#include "exheader_info_heap.h"
|
||||
#include "task_runner.h"
|
||||
|
||||
static Result fsRegSetupPermissions(void)
|
||||
{
|
||||
u32 pid;
|
||||
Result res;
|
||||
FS_ProgramInfo info;
|
||||
|
||||
ExHeader_Arm11StorageInfo storageInfo = {
|
||||
.fs_access_info = FSACCESS_SDMC_RW,
|
||||
};
|
||||
|
||||
info.programId = 0x0004013000001202LL; // PM's TID
|
||||
info.mediaType = MEDIATYPE_NAND;
|
||||
|
||||
if(R_SUCCEEDED(res = svcGetProcessId(&pid, CUR_PROCESS_HANDLE)))
|
||||
res = FSREG_Register(pid, 0xFFFF000000000000LL, &info, &storageInfo);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void forceMountSdCard(void)
|
||||
{
|
||||
FS_Archive sdmcArchive;
|
||||
|
||||
assertSuccess(fsRegSetupPermissions());
|
||||
assertSuccess(fsInit());
|
||||
assertSuccess(FSUSER_OpenArchive(&sdmcArchive, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, "")));
|
||||
// No need to clean up things as we will firmlaunch straight away
|
||||
|
@ -29,4 +29,4 @@
|
||||
#include <3ds/types.h>
|
||||
#include "menu.h"
|
||||
|
||||
void ProcessPatchesMenu_PatchUnpatchFSDirectly(void);
|
||||
Result OpenProcessByName(const char *name, Handle *h);
|
@ -62,5 +62,3 @@ static inline bool isServiceUsable(const char *name)
|
||||
bool r;
|
||||
return R_SUCCEEDED(srvIsServiceRegistered(&r, name)) && r;
|
||||
}
|
||||
|
||||
Result OpenProcessByName(const char *name, Handle *h);
|
||||
|
@ -346,7 +346,7 @@ void HBLDR_HandleCommands(void *ctx)
|
||||
// See the big comment in sysmodules/pm/source/reslimit.c for technical details.
|
||||
localcaps0->reslimits[0] = BIT(7) | 89;
|
||||
|
||||
localcaps0->storage_info.fs_access_info = 0xFFFFFFFF; // Give access to everything
|
||||
//localcaps0->storage_info.fs_access_info = 0xFFFFFFFF; // Give access to everything
|
||||
localcaps0->storage_info.no_romfs = true;
|
||||
localcaps0->storage_info.use_extended_savedata_access = true; // Whatever
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "utils.h" // for makeArmBranch
|
||||
#include "minisoc.h"
|
||||
#include "input_redirection.h"
|
||||
#include "process_patches.h"
|
||||
#include "menus.h"
|
||||
#include "memory.h"
|
||||
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "3dsx.h"
|
||||
#include "utils.h"
|
||||
#include "MyThread.h"
|
||||
#include "menus/process_patches.h"
|
||||
#include "menus/miscellaneous.h"
|
||||
#include "menus/debugger.h"
|
||||
#include "menus/screen_filters.h"
|
||||
@ -47,39 +46,6 @@
|
||||
|
||||
bool isN3DS;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Result __sync_init(void);
|
||||
Result __sync_fini(void);
|
||||
void __libc_init_array(void);
|
||||
@ -124,8 +90,6 @@ void initSystem(void)
|
||||
miscellaneousMenu.items[0].title = HBLDR_3DSX_TID == HBLDR_DEFAULT_3DSX_TID ? "Switch the hb. title to the current app." :
|
||||
"Switch the hb. title to hblauncher_loader";
|
||||
|
||||
ProcessPatchesMenu_PatchUnpatchFSDirectly();
|
||||
|
||||
for(res = 0xD88007FA; res == (Result)0xD88007FA; svcSleepThread(500 * 1000LL))
|
||||
{
|
||||
res = srvInit();
|
||||
@ -133,10 +97,10 @@ void initSystem(void)
|
||||
svcBreak(USERBREAK_PANIC);
|
||||
}
|
||||
|
||||
if (R_FAILED(stealFsReg()) || R_FAILED(fsRegSetupPermissions()) || R_FAILED(fsInit()))
|
||||
if (R_FAILED(pmAppInit()) || R_FAILED(pmDbgInit()))
|
||||
svcBreak(USERBREAK_PANIC);
|
||||
|
||||
if (R_FAILED(pmAppInit()) || R_FAILED(pmDbgInit()))
|
||||
if (R_FAILED(fsInit()))
|
||||
svcBreak(USERBREAK_PANIC);
|
||||
|
||||
// **** DO NOT init services that don't come from KIPs here ****
|
||||
@ -144,14 +108,15 @@ void initSystem(void)
|
||||
|
||||
__libc_init_array();
|
||||
|
||||
// ROSALINA HACKJOB BEGIN
|
||||
// NORMAL APPS SHOULD NOT DO THIS, EVER
|
||||
u32 *tls = (u32 *)getThreadLocalStorage();
|
||||
memset(tls, 0, 0x80);
|
||||
tls[0] = 0x21545624;
|
||||
// ROSALINA HACKJOB END
|
||||
|
||||
// Rosalina specific:
|
||||
u32 *tls = (u32 *)getThreadLocalStorage();
|
||||
memset(tls, 0, 0x80);
|
||||
tls[0] = 0x21545624;
|
||||
|
||||
// ROSALINA HACKJOB BEGIN
|
||||
// NORMAL APPS SHOULD NOT DO THIS, EVER
|
||||
srvSetBlockingPolicy(true); // GetServiceHandle nonblocking if service port is full
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "menu.h"
|
||||
#include "draw.h"
|
||||
#include "menus/process_list.h"
|
||||
#include "menus/process_patches.h"
|
||||
#include "menus/n3ds.h"
|
||||
#include "menus/debugger.h"
|
||||
#include "menus/miscellaneous.h"
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include <3ds.h>
|
||||
#include "menus/process_list.h"
|
||||
#include "process_patches.h"
|
||||
#include "memory.h"
|
||||
#include "csvc.h"
|
||||
#include "draw.h"
|
||||
|
@ -25,48 +25,11 @@
|
||||
*/
|
||||
|
||||
#include <3ds.h>
|
||||
#include <string.h>
|
||||
#include "csvc.h"
|
||||
#include "menus/process_patches.h"
|
||||
#include "memory.h"
|
||||
#include "draw.h"
|
||||
#include "hbloader.h"
|
||||
#include "fmt.h"
|
||||
#include "process_patches.h"
|
||||
#include "utils.h"
|
||||
|
||||
static Result ProcessPatchesMenu_DoPatchUnpatchFS(u32 textTotalRoundedSize)
|
||||
{
|
||||
static bool patched = false;
|
||||
static u16 *off;
|
||||
static u16 origData[2];
|
||||
static const u16 pattern[2] = {
|
||||
0x7401, // strb r1, [r0, #16]
|
||||
0x2000, // movs r0, #0
|
||||
};
|
||||
|
||||
if(patched)
|
||||
{
|
||||
memcpy(off, &origData, sizeof(origData));
|
||||
patched = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
off = (u16 *)memsearch((u8 *)0x00100000, &pattern, textTotalRoundedSize, sizeof(pattern));
|
||||
if(off == NULL)
|
||||
return -1;
|
||||
|
||||
for(; (*off & 0xFF00) != 0xB500; off++); // Find function start
|
||||
|
||||
memcpy(origData, off, 4);
|
||||
off[0] = 0x2001; // mov r0, #1
|
||||
off[1] = 0x4770; // bx lr
|
||||
|
||||
patched = true;
|
||||
}
|
||||
|
||||
//processPatchesMenu.items[1].title = patched ? "Unpatch FS for the archive checks" : "Patch FS for the archive checks";
|
||||
return 0;
|
||||
}
|
||||
|
||||
Result OpenProcessByName(const char *name, Handle *h)
|
||||
{
|
||||
u32 pidList[0x40];
|
||||
@ -96,7 +59,7 @@ Result OpenProcessByName(const char *name, Handle *h)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static u32 ProcessPatchesMenu_PatchUnpatchProcessByName(const char *name, Result (*func)(u32 size))
|
||||
/*static u32 ProcessPatchesMenu_PatchUnpatchProcessByName(const char *name, Result (*func)(u32 size))
|
||||
{
|
||||
Result res;
|
||||
Handle processHandle;
|
||||
@ -112,9 +75,4 @@ static u32 ProcessPatchesMenu_PatchUnpatchProcessByName(const char *name, Result
|
||||
|
||||
svcUnmapProcessMemoryEx(processHandle, 0x00100000, textTotalRoundedSize);
|
||||
return res;
|
||||
}
|
||||
|
||||
void ProcessPatchesMenu_PatchUnpatchFSDirectly(void)
|
||||
{
|
||||
ProcessPatchesMenu_PatchUnpatchProcessByName("fs", &ProcessPatchesMenu_DoPatchUnpatchFS);
|
||||
}
|
||||
}*/
|
Reference in New Issue
Block a user