fs.mitm: Allow for disabling mitm for a title via flag.

This commit is contained in:
Michael Scire 2018-10-16 20:41:19 -07:00
parent f10ae4d96f
commit 4944986814
3 changed files with 21 additions and 0 deletions

View file

@ -38,6 +38,9 @@ class FsMitMService : public IMitMServiceObject {
} }
static bool should_mitm(u64 pid, u64 tid) { static bool should_mitm(u64 pid, u64 tid) {
if (Utils::HasSdDisableMitMFlag(tid)) {
return false;
}
return (tid >= 0x0100000000010000ULL || Utils::HasSdMitMFlag(tid)) && Utils::HasOverrideButton(tid); return (tid >= 0x0100000000010000ULL || Utils::HasSdMitMFlag(tid)) && Utils::HasOverrideButton(tid);
} }

View file

@ -27,6 +27,7 @@
static FsFileSystem g_sd_filesystem = {0}; static FsFileSystem g_sd_filesystem = {0};
static std::vector<u64> g_mitm_flagged_tids; static std::vector<u64> g_mitm_flagged_tids;
static std::vector<u64> g_disable_mitm_flagged_tids;
static std::atomic_bool g_has_initialized = false; static std::atomic_bool g_has_initialized = false;
static std::atomic_bool g_has_hid_session = false; static std::atomic_bool g_has_hid_session = false;
@ -78,6 +79,15 @@ void Utils::InitializeSdThreadFunc(void *args) {
g_mitm_flagged_tids.push_back(title_id); g_mitm_flagged_tids.push_back(title_id);
fsFileClose(&f); fsFileClose(&f);
} }
memset(title_path, 0, sizeof(title_path));
strcpy(title_path, "/atmosphere/titles/");
strcat(title_path, dir_entry.name);
strcat(title_path, "/fsmitm_disable.flag");
if (R_SUCCEEDED(fsFsOpenFile(&g_sd_filesystem, title_path, FS_OPEN_READ, &f))) {
g_disable_mitm_flagged_tids.push_back(title_id);
fsFileClose(&f);
}
} }
} }
fsDirClose(&titles_dir); fsDirClose(&titles_dir);
@ -217,6 +227,13 @@ bool Utils::HasSdMitMFlag(u64 tid) {
return false; return false;
} }
bool Utils::HasSdDisableMitMFlag(u64 tid) {
if (IsSdInitialized()) {
return std::find(g_disable_mitm_flagged_tids.begin(), g_disable_mitm_flagged_tids.end(), tid) != g_disable_mitm_flagged_tids.end();
}
return false;
}
Result Utils::GetKeysDown(u64 *keys) { Result Utils::GetKeysDown(u64 *keys) {
if (!Utils::IsHidInitialized()) { if (!Utils::IsHidInitialized()) {
return MAKERESULT(Module_Libnx, LibnxError_InitFail_HID); return MAKERESULT(Module_Libnx, LibnxError_InitFail_HID);

View file

@ -37,6 +37,7 @@ class Utils {
/* SD card Initialization + MitM detection. */ /* SD card Initialization + MitM detection. */
static void InitializeSdThreadFunc(void *args); static void InitializeSdThreadFunc(void *args);
static bool HasSdMitMFlag(u64 tid); static bool HasSdMitMFlag(u64 tid);
static bool HasSdDisableMitMFlag(u64 tid);
static bool IsHidInitialized(); static bool IsHidInitialized();