mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-12-23 10:52:13 +00:00
fs.mitm: add flag support for writing bis/reading cal0
This commit is contained in:
parent
67ff4fe913
commit
ae4d29a49f
3 changed files with 21 additions and 7 deletions
|
@ -100,11 +100,13 @@ Result FsMitmService::OpenBisStorage(Out<std::shared_ptr<IStorageInterface>> out
|
|||
rc = fsOpenBisStorageFwd(this->forward_service.get(), &bis_storage, bis_partition_id);
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
const bool is_sysmodule = this->title_id < 0x0100000000001000;
|
||||
const bool has_bis_write_flag = Utils::HasFlag(this->title_id, "bis_write");
|
||||
const bool has_cal0_read_flag = Utils::HasFlag(this->title_id, "cal_read");
|
||||
if (bis_partition_id == BisStorageId_Boot0) {
|
||||
storage = std::make_shared<IStorageInterface>(new Boot0Storage(bis_storage, this->title_id));
|
||||
} else if (bis_partition_id == BisStorageId_Prodinfo) {
|
||||
/* PRODINFO should *never* be writable. */
|
||||
if (is_sysmodule) {
|
||||
if (is_sysmodule || has_cal0_read_flag) {
|
||||
storage = std::make_shared<IStorageInterface>(new ROProxyStorage(bis_storage));
|
||||
} else {
|
||||
/* Do not allow non-sysmodules to read *or* write CAL0. */
|
||||
|
@ -112,12 +114,12 @@ Result FsMitmService::OpenBisStorage(Out<std::shared_ptr<IStorageInterface>> out
|
|||
return 0x320002;
|
||||
}
|
||||
} else {
|
||||
if (!is_sysmodule) {
|
||||
/* Non-sysmodules should be allowed to read. */
|
||||
storage = std::make_shared<IStorageInterface>(new ROProxyStorage(bis_storage));
|
||||
} else {
|
||||
if (is_sysmodule || has_bis_write_flag) {
|
||||
/* Sysmodules should still be allowed to read and write. */
|
||||
storage = std::make_shared<IStorageInterface>(new ProxyStorage(bis_storage));
|
||||
} else {
|
||||
/* Non-sysmodules should be allowed to read. */
|
||||
storage = std::make_shared<IStorageInterface>(new ROProxyStorage(bis_storage));
|
||||
}
|
||||
}
|
||||
if (out_storage.IsDomain()) {
|
||||
|
|
|
@ -346,7 +346,7 @@ Result Utils::SaveSdFileForAtmosphere(u64 title_id, const char *fn, void *data,
|
|||
return rc;
|
||||
}
|
||||
|
||||
bool Utils::HasFlag(u64 tid, const char *flag) {
|
||||
bool Utils::HasTitleFlag(u64 tid, const char *flag) {
|
||||
if (IsSdInitialized()) {
|
||||
FsFile f;
|
||||
char flag_path[FS_MAX_PATH];
|
||||
|
@ -381,6 +381,16 @@ bool Utils::HasGlobalFlag(const char *flag) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Utils::HasHblFlag(const char *flag) {
|
||||
char hbl_flag[FS_MAX_PATH] = {0};
|
||||
snprintf(hbl_flag, sizeof(hbl_flag), "hbl_%s", flag);
|
||||
return HasGlobalFlag(hbl_flag);
|
||||
}
|
||||
|
||||
bool Utils::HasFlag(u64 tid, const char *flag) {
|
||||
return HasTitleFlag(tid, flag) || (tid == g_override_hbl_tid && HasHblFlag(flag));
|
||||
}
|
||||
|
||||
bool Utils::HasSdMitMFlag(u64 tid) {
|
||||
if (tid == g_override_hbl_tid) {
|
||||
return true;
|
||||
|
|
|
@ -58,8 +58,10 @@ class Utils {
|
|||
/* SD card Initialization + MitM detection. */
|
||||
static void InitializeSdThreadFunc(void *args);
|
||||
|
||||
static bool HasFlag(u64 tid, const char *flag);
|
||||
static bool HasTitleFlag(u64 tid, const char *flag);
|
||||
static bool HasHblFlag(const char *flag);
|
||||
static bool HasGlobalFlag(const char *flag);
|
||||
static bool HasFlag(u64 tid, const char *flag);
|
||||
|
||||
static bool HasSdMitMFlag(u64 tid);
|
||||
static bool HasSdDisableMitMFlag(u64 tid);
|
||||
|
|
Loading…
Reference in a new issue