From f207bfab48902be7daa05dc052064e837184e7a3 Mon Sep 17 00:00:00 2001 From: J-D-K Date: Thu, 18 Apr 2019 12:24:12 -0400 Subject: [PATCH] Finally include romfs opening code --- Makefile | 2 +- README.MD | 2 ++ inc/ex.h | 17 +++++++++++++++++ src/ex.c | 38 ++++++++++++++++++++++++++++++++++++++ src/main.cpp | 3 --- src/ui.cpp | 2 +- src/ui/advmode.cpp | 2 ++ src/ui/clsui.cpp | 17 +++++++++++++++++ src/ui/ttlsel.cpp | 1 + 9 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 inc/ex.h create mode 100644 src/ex.c diff --git a/Makefile b/Makefile index f5084e3..5bd16fc 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ INCLUDES := inc EXEFS_SRC := exefs_src APP_TITLE := JKSV APP_AUTHOR := JK -APP_VERSION := 04.17.2019 +APP_VERSION := 04.18.2019 ROMFS := romfs #--------------------------------------------------------------------------------- diff --git a/README.MD b/README.MD index 2c9eb1a..669cdb5 100644 --- a/README.MD +++ b/README.MD @@ -17,6 +17,8 @@ JKSV on Switch started as a small project/port to test some things and get famil * Ability to remove downloaded firmware updates from NAND. * Terminating processes by [ID](https://switchbrew.org/wiki/Title_list#System_Modules). Allowing you to dump normally unopenable system archives. * Mount by System Save [ID](https://switchbrew.org/wiki/Flash_Filesystem#System_Savegames). Normally used when the terminated process makes JKSV unable to rescan titles without the Switch crashing. + * Mount and open RomFS of process the homebrew menu takes over (if launched as NRO) + * Hold R while opening a game or applet with Atmosphere so the homebrew menu loads. Open JKSV and press minus and select **Mount Process RomFS**. The romfs of the app should appear in the browser along with your SD on the right. # Building: 1. Requires [devkitPro](https://devkitpro.org/) and [libnx](https://github.com/switchbrew/libnx) diff --git a/inc/ex.h b/inc/ex.h new file mode 100644 index 0000000..e4c3072 --- /dev/null +++ b/inc/ex.h @@ -0,0 +1,17 @@ +#ifndef EX_H +#define EX_H + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +Result fsOpenDataFileSystemByCurrentProcess(FsFileSystem *out); + +#ifdef __cplusplus +} +#endif + +#endif // EX_H diff --git a/src/ex.c b/src/ex.c new file mode 100644 index 0000000..fa8eaf3 --- /dev/null +++ b/src/ex.c @@ -0,0 +1,38 @@ +#include + +#include "ex.h" + +Result fsOpenDataFileSystemByCurrentProcess(FsFileSystem *out) +{ + Result ret = 0; + + IpcCommand c; + ipcInitialize(&c); + struct + { + uint64_t mag; + uint64_t cmd; + } *raw = serviceIpcPrepareHeader(fsGetServiceSession(), &c, sizeof(*raw)); + raw->mag = SFCI_MAGIC; + raw->cmd = 2; + + ret = serviceIpcDispatch(fsGetServiceSession()); + if(R_SUCCEEDED(ret)) + { + IpcParsedCommand p; + struct + { + uint64_t mag; + uint64_t res; + } *resp; + + serviceIpcParse(fsGetServiceSession(), &p, sizeof(*resp)); + resp = p.Raw; + + ret = resp->res; + if(R_SUCCEEDED(ret)) + serviceCreateSubservice(&out->s, fsGetServiceSession(), &p, 0); + } + + return ret; +} diff --git a/src/main.cpp b/src/main.cpp index 30dee25..0d828c0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,9 +19,6 @@ extern "C" nsInitialize(); setsysInitialize(); accountInitialize(); - - void *add = NULL; - svcSetHeapSize(&add, 0x12000000); } void userAppExit(void) diff --git a/src/ui.cpp b/src/ui.cpp index 8ce8a5e..aee1695 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -11,7 +11,7 @@ #include "util.h" #include "file.h" -#define VER_STRING "v. 04.17.2019" +#define VER_STRING "v. 04.18.2019" //background that can be drawn from "/JKSV/back.jpg" //txtSide and fldSide are to fake alpha blending so the framerate doesn't suffer diff --git a/src/ui/advmode.cpp b/src/ui/advmode.cpp index 78ce02a..b4de22e 100644 --- a/src/ui/advmode.cpp +++ b/src/ui/advmode.cpp @@ -490,6 +490,8 @@ namespace ui { if(prevState == EX_MNU) mstate = EX_MNU; + else if(prevState == TTL_SEL) + mstate = TTL_SEL; else if(ui::clsMode) mstate = CLS_FLD; else diff --git a/src/ui/clsui.cpp b/src/ui/clsui.cpp index 069b28b..ea8dbcd 100644 --- a/src/ui/clsui.cpp +++ b/src/ui/clsui.cpp @@ -9,6 +9,7 @@ #include "data.h" #include "file.h" #include "util.h" +#include "ex.h" static ui::menu userMenu, titleMenu, devMenu; extern ui::menu folderMenu; @@ -253,6 +254,7 @@ namespace ui devMenu.addOpt("Remove Downloaded Update"); devMenu.addOpt("Terminate Process ID"); devMenu.addOpt("Mount System Save ID"); + devMenu.addOpt("Mount Process RomFS"); } void updateExMenu(const uint64_t& down, const uint64_t& held, const touchPosition& p) @@ -467,6 +469,21 @@ namespace ui } } break; + + case 10: + { + fsdevUnmountDevice("sv"); + FsFileSystem tromfs; + Result res = fsOpenDataFileSystemByCurrentProcess(&tromfs); + if(R_SUCCEEDED(res)) + { + fsdevMountDevice("tromfs", tromfs); + advModePrep("tromfs:/", false); + data::curData.setType(FsSaveDataType_SystemSaveData); + ui::mstate = ADV_MDE; + ui::prevState = EX_MNU; + } + } } } else if(down & KEY_B) diff --git a/src/ui/ttlsel.cpp b/src/ui/ttlsel.cpp index 71ce26d..ba6e9f9 100644 --- a/src/ui/ttlsel.cpp +++ b/src/ui/ttlsel.cpp @@ -7,6 +7,7 @@ #include "uiupdate.h" #include "file.h" #include "util.h" +#include "ex.h" extern std::vector ttlNav;