1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-05 19:51:45 +00:00

fs.mitm: match any_app override semantics

This commit is contained in:
Michael Scire 2019-01-09 12:50:01 -08:00
parent da0d22f05a
commit a899a61f80
2 changed files with 17 additions and 5 deletions

View file

@ -33,6 +33,7 @@ static std::atomic_bool g_has_hid_session = false;
static u64 g_override_key_combination = KEY_R;
static u64 g_override_hbl_tid = 0x010000000000100DULL;
static bool g_override_any_app = false;
static bool g_override_by_default = true;
/* Static buffer for loader.ini contents at runtime. */
@ -348,6 +349,10 @@ Result Utils::SaveSdFileForAtmosphere(u64 title_id, const char *fn, void *data,
return rc;
}
bool Utils::IsHblTid(u64 tid) {
return (g_override_any_app && tid >= 0x0100000000010000ULL) || (!g_override_any_app && tid == g_override_hbl_tid);
}
bool Utils::HasTitleFlag(u64 tid, const char *flag) {
if (IsSdInitialized()) {
FsFile f;
@ -390,11 +395,11 @@ bool Utils::HasHblFlag(const char *flag) {
}
bool Utils::HasFlag(u64 tid, const char *flag) {
return HasTitleFlag(tid, flag) || (tid == g_override_hbl_tid && HasHblFlag(flag));
return HasTitleFlag(tid, flag) || (IsHblTid(tid) && HasHblFlag(flag));
}
bool Utils::HasSdMitMFlag(u64 tid) {
if (tid == g_override_hbl_tid) {
if (IsHblTid(tid)) {
return true;
}
@ -441,10 +446,15 @@ static int FsMitMIniHandler(void *user, const char *section, const char *name, c
/* Taken and modified, with love, from Rajkosto's implementation. */
if (strcasecmp(section, "config") == 0) {
if (strcasecmp(name, "hbl_tid") == 0) {
if (strcasecmp(value, "app") == 0) {
g_override_any_app = true;
}
else {
u64 override_tid = strtoul(value, NULL, 16);
if (override_tid != 0) {
g_override_hbl_tid = override_tid;
}
}
} else if (strcasecmp(name, "override_key") == 0) {
if (value[0] == '!') {
g_override_by_default = true;

View file

@ -58,6 +58,8 @@ class Utils {
/* SD card Initialization + MitM detection. */
static void InitializeSdThreadFunc(void *args);
static bool IsHblTid(u64 tid);
static bool HasTitleFlag(u64 tid, const char *flag);
static bool HasHblFlag(const char *flag);
static bool HasGlobalFlag(const char *flag);