fs.mitm: WIP LayeredFS impl (NOTE: UNUSABLE ATM)
Also greatly refactors libstratosphere, and does a lot of other things. There is a lot of code in this one.
This commit is contained in:
@@ -18,6 +18,10 @@ class DebugMonitorService final : public IServiceObject {
|
||||
return 0;
|
||||
}
|
||||
|
||||
DebugMonitorService *clone() override {
|
||||
return new DebugMonitorService();
|
||||
}
|
||||
|
||||
private:
|
||||
/* Actual commands. */
|
||||
std::tuple<Result> add_title_to_launch_queue(u64 tid, InPointer<char> args);
|
||||
|
||||
@@ -186,6 +186,9 @@ Result ProcessCreation::CreateProcess(Handle *out_process_h, u64 index, char *nc
|
||||
}
|
||||
}
|
||||
|
||||
/* Send the pid/tid pair to anyone interested in man-in-the-middle-attacking it. */
|
||||
Registration::AssociatePidTidForMitM(index);
|
||||
|
||||
rc = 0;
|
||||
CREATE_PROCESS_END:
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
|
||||
@@ -35,6 +35,10 @@ class ProcessManagerService final : public IServiceObject {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ProcessManagerService *clone() override {
|
||||
return new ProcessManagerService();
|
||||
}
|
||||
|
||||
private:
|
||||
/* Actual commands. */
|
||||
std::tuple<Result, MovedHandle> create_process(u64 flags, u64 index, CopiedHandle reslimit_h);
|
||||
|
||||
@@ -266,3 +266,65 @@ Result Registration::GetNsoInfosForProcessId(Registration::NsoInfo *out, u32 max
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Registration::AssociatePidTidForMitM(u64 index) {
|
||||
Registration::Process *target_process = GetProcess(index);
|
||||
if (target_process == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
Handle sm_hnd;
|
||||
Result rc = svcConnectToNamedPort(&sm_hnd, "sm:");
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
/* Initialize. */
|
||||
{
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
ipcSendPid(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
u64 zero;
|
||||
u64 reserved[2];
|
||||
} *raw = (decltype(raw))ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 0;
|
||||
raw->zero = 0;
|
||||
|
||||
rc = ipcDispatch(sm_hnd);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = (decltype(resp))r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
}
|
||||
}
|
||||
/* Associate. */
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
u64 process_id;
|
||||
u64 title_id;
|
||||
} *raw = (decltype(raw))ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 65002;
|
||||
raw->process_id = target_process->process_id;
|
||||
raw->title_id = target_process->tid_sid.title_id;
|
||||
|
||||
ipcDispatch(sm_hnd);
|
||||
}
|
||||
svcCloseHandle(sm_hnd);
|
||||
}
|
||||
}
|
||||
@@ -76,4 +76,7 @@ class Registration {
|
||||
static void AddNroToProcess(u64 index, MappedCodeMemory *nro, MappedCodeMemory *bss, u32 text_size, u32 ro_size, u32 rw_size, u8 *build_id);
|
||||
static Result RemoveNroInfo(u64 index, Handle process_h, u64 base_address);
|
||||
static Result GetNsoInfosForProcessId(NsoInfo *out, u32 max_out, u64 process_id, u32 *num_written);
|
||||
|
||||
/* Atmosphere MitM Extension. */
|
||||
static void AssociatePidTidForMitM(u64 index);
|
||||
};
|
||||
|
||||
@@ -30,6 +30,10 @@ class RelocatableObjectsService final : public IServiceObject {
|
||||
return 0;
|
||||
}
|
||||
|
||||
RelocatableObjectsService *clone() override {
|
||||
return new RelocatableObjectsService(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
/* Actual commands. */
|
||||
std::tuple<Result, u64> load_nro(PidDescriptor pid_desc, u64 nro_address, u64 nro_size, u64 bss_address, u64 bss_size);
|
||||
|
||||
@@ -15,6 +15,10 @@ class ShellService final : public IServiceObject {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ShellService *clone() override {
|
||||
return new ShellService();
|
||||
}
|
||||
|
||||
private:
|
||||
/* Actual commands. */
|
||||
std::tuple<Result> add_title_to_launch_queue(u64 tid, InPointer<char> args);
|
||||
|
||||
Reference in New Issue
Block a user