Finally include romfs opening code

This commit is contained in:
J-D-K 2019-04-18 12:24:12 -04:00
parent 512889a1a5
commit f207bfab48
9 changed files with 79 additions and 5 deletions

View File

@ -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
#---------------------------------------------------------------------------------

View File

@ -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)

17
inc/ex.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef EX_H
#define EX_H
#include <switch.h>
#ifdef __cplusplus
extern "C"
{
#endif
Result fsOpenDataFileSystemByCurrentProcess(FsFileSystem *out);
#ifdef __cplusplus
}
#endif
#endif // EX_H

38
src/ex.c Normal file
View File

@ -0,0 +1,38 @@
#include <switch.h>
#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;
}

View File

@ -19,9 +19,6 @@ extern "C"
nsInitialize();
setsysInitialize();
accountInitialize();
void *add = NULL;
svcSetHeapSize(&add, 0x12000000);
}
void userAppExit(void)

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -7,6 +7,7 @@
#include "uiupdate.h"
#include "file.h"
#include "util.h"
#include "ex.h"
extern std::vector<ui::button> ttlNav;