mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-17 17:36:44 +00:00
pm: Only register privileged processes with FS as needed
This commit is contained in:
parent
9898a01d3b
commit
cf510ad9bf
3 changed files with 19 additions and 6 deletions
|
@ -65,6 +65,7 @@
|
|||
"svcReplyAndReceiveWithUserBuffer": "0x44",
|
||||
"svcCreateEvent": "0x45",
|
||||
"svcSetUnsafeLimit": "0x4a",
|
||||
"svcGetProcessList": "0x65",
|
||||
"svcStartProcess": "0x7a",
|
||||
"svcTerminateProcess": "0x7b",
|
||||
"svcGetProcessInfo": "0x7c",
|
||||
|
|
|
@ -65,10 +65,22 @@ void RegisterPrivilegedProcessesWithFs() {
|
|||
const u32 PRIVILEGED_FAH[0x1C/sizeof(u32)] = {0x00000001, 0x00000000, 0x80000000, 0x0000001C, 0x00000000, 0x0000001C, 0x00000000};
|
||||
const u32 PRIVILEGED_FAC[0x2C/sizeof(u32)] = {0x00000001, 0x00000000, 0x80000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF};
|
||||
|
||||
u32 num_pids;
|
||||
u64 pids[PRIVILEGED_PROCESS_MAX+1];
|
||||
if (R_SUCCEEDED(svcGetProcessList(&num_pids, pids, sizeof(pids)/sizeof(pids[0])))) {
|
||||
for (u32 i = 0; i < num_pids; i++) {
|
||||
const u64 pid = pids[i];
|
||||
if (PRIVILEGED_PROCESS_MIN <= pid && pid <= PRIVILEGED_PROCESS_MAX) {
|
||||
fsprUnregisterProgram(pid);
|
||||
fsprRegisterProgram(pid, pid, FsStorageId_NandSystem, PRIVILEGED_FAH, sizeof(PRIVILEGED_FAH), PRIVILEGED_FAC, sizeof(PRIVILEGED_FAC));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (u64 pid = PRIVILEGED_PROCESS_MIN; pid <= PRIVILEGED_PROCESS_MAX; pid++) {
|
||||
fsprUnregisterProgram(pid);
|
||||
fsprRegisterProgram(pid, pid, FsStorageId_NandSystem, PRIVILEGED_FAH, sizeof(PRIVILEGED_FAH), PRIVILEGED_FAC, sizeof(PRIVILEGED_FAC));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void __appInit(void) {
|
||||
|
|
|
@ -292,15 +292,15 @@ void Registration::FinalizeExitedProcess(std::shared_ptr<Registration::Process>
|
|||
bool signal_debug_process_5x = kernelAbove500() && process->flags & PROCESSFLAGS_NOTIFYWHENEXITED;
|
||||
/* Unregister with FS. */
|
||||
if (R_FAILED(fsprUnregisterProgram(process->pid))) {
|
||||
/* TODO: Panic. */
|
||||
std::abort();
|
||||
}
|
||||
/* Unregister with SM. */
|
||||
if (R_FAILED(smManagerUnregisterProcess(process->pid))) {
|
||||
/* TODO: Panic. */
|
||||
std::abort();
|
||||
}
|
||||
/* Unregister with LDR. */
|
||||
if (R_FAILED(ldrPmUnregisterTitle(process->ldr_queue_index))) {
|
||||
/* TODO: Panic. */
|
||||
std::abort();
|
||||
}
|
||||
|
||||
/* Close the process's handle. */
|
||||
|
|
Loading…
Reference in a new issue