mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-14 00:56:35 +00:00
all: Change flagging location. Support (but deprecate) old location.
This commit is contained in:
parent
05187502b3
commit
420361597e
4 changed files with 86 additions and 5 deletions
3
Makefile
3
Makefile
|
@ -46,7 +46,8 @@ dist: all
|
||||||
cp common/defaults/loader.ini atmosphere-$(AMSVER)/atmosphere/loader.ini
|
cp common/defaults/loader.ini atmosphere-$(AMSVER)/atmosphere/loader.ini
|
||||||
cp stratosphere/creport/creport.nsp atmosphere-$(AMSVER)/atmosphere/titles/0100000000000036/exefs.nsp
|
cp stratosphere/creport/creport.nsp atmosphere-$(AMSVER)/atmosphere/titles/0100000000000036/exefs.nsp
|
||||||
cp stratosphere/set_mitm/set_mitm.nsp atmosphere-$(AMSVER)/atmosphere/titles/0100000000000032/exefs.nsp
|
cp stratosphere/set_mitm/set_mitm.nsp atmosphere-$(AMSVER)/atmosphere/titles/0100000000000032/exefs.nsp
|
||||||
touch atmosphere-$(AMSVER)/atmosphere/titles/0100000000000032/boot2.flag
|
mkdir -p atmosphere-$(AMSVER)/atmosphere/titles/0100000000000032/flags
|
||||||
|
touch atmosphere-$(AMSVER)/atmosphere/titles/0100000000000032/flags/boot2.flag
|
||||||
cd atmosphere-$(AMSVER); zip -r ../atmosphere-$(AMSVER).zip ./*; cd ../;
|
cd atmosphere-$(AMSVER); zip -r ../atmosphere-$(AMSVER).zip ./*; cd ../;
|
||||||
rm -r atmosphere-$(AMSVER)
|
rm -r atmosphere-$(AMSVER)
|
||||||
mkdir out
|
mkdir out
|
||||||
|
|
|
@ -31,6 +31,7 @@ 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;
|
||||||
|
|
||||||
static u64 g_override_key_combination = KEY_R;
|
static u64 g_override_key_combination = KEY_R;
|
||||||
|
static u64 g_override_hbl_tid = 0x010000000000100DULL;
|
||||||
static bool g_override_by_default = true;
|
static bool g_override_by_default = true;
|
||||||
|
|
||||||
/* Static buffer for loader.ini contents at runtime. */
|
/* Static buffer for loader.ini contents at runtime. */
|
||||||
|
@ -76,19 +77,39 @@ void Utils::InitializeSdThreadFunc(void *args) {
|
||||||
char title_path[FS_MAX_PATH] = {0};
|
char title_path[FS_MAX_PATH] = {0};
|
||||||
strcpy(title_path, "/atmosphere/titles/");
|
strcpy(title_path, "/atmosphere/titles/");
|
||||||
strcat(title_path, dir_entry.name);
|
strcat(title_path, dir_entry.name);
|
||||||
strcat(title_path, "/fsmitm.flag");
|
strcat(title_path, "/flags/fsmitm.flag");
|
||||||
if (R_SUCCEEDED(fsFsOpenFile(&g_sd_filesystem, title_path, FS_OPEN_READ, &f))) {
|
if (R_SUCCEEDED(fsFsOpenFile(&g_sd_filesystem, title_path, FS_OPEN_READ, &f))) {
|
||||||
g_mitm_flagged_tids.push_back(title_id);
|
g_mitm_flagged_tids.push_back(title_id);
|
||||||
fsFileClose(&f);
|
fsFileClose(&f);
|
||||||
|
} else {
|
||||||
|
/* TODO: Deprecate. */
|
||||||
|
memset(title_path, 0, sizeof(title_path));
|
||||||
|
strcpy(title_path, "/atmosphere/titles/");
|
||||||
|
strcat(title_path, dir_entry.name);
|
||||||
|
strcat(title_path, "/fsmitm.flag");
|
||||||
|
if (R_SUCCEEDED(fsFsOpenFile(&g_sd_filesystem, title_path, FS_OPEN_READ, &f))) {
|
||||||
|
g_mitm_flagged_tids.push_back(title_id);
|
||||||
|
fsFileClose(&f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(title_path, 0, sizeof(title_path));
|
memset(title_path, 0, sizeof(title_path));
|
||||||
strcpy(title_path, "/atmosphere/titles/");
|
strcpy(title_path, "/atmosphere/titles/");
|
||||||
strcat(title_path, dir_entry.name);
|
strcat(title_path, dir_entry.name);
|
||||||
strcat(title_path, "/fsmitm_disable.flag");
|
strcat(title_path, "/flags/fsmitm_disable.flag");
|
||||||
if (R_SUCCEEDED(fsFsOpenFile(&g_sd_filesystem, title_path, FS_OPEN_READ, &f))) {
|
if (R_SUCCEEDED(fsFsOpenFile(&g_sd_filesystem, title_path, FS_OPEN_READ, &f))) {
|
||||||
g_disable_mitm_flagged_tids.push_back(title_id);
|
g_disable_mitm_flagged_tids.push_back(title_id);
|
||||||
fsFileClose(&f);
|
fsFileClose(&f);
|
||||||
|
} else {
|
||||||
|
/* TODO: Deprecate. */
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -264,7 +285,46 @@ Result Utils::SaveSdFileForAtmosphere(u64 title_id, const char *fn, void *data,
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Utils::HasFlag(u64 tid, const char *flag) {
|
||||||
|
if (IsSdInitialized()) {
|
||||||
|
FsFile f;
|
||||||
|
char flag_path[FS_MAX_PATH];
|
||||||
|
|
||||||
|
memset(flag_path, 0, sizeof(flag_path));
|
||||||
|
snprintf(flag_path, sizeof(flag_path) - 1, "flags/%s.flag", flag);
|
||||||
|
if (OpenSdFileForAtmosphere(tid, flag_path, FS_OPEN_READ, &f)) {
|
||||||
|
fsFileClose(&f);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* TODO: Deprecate. */
|
||||||
|
snprintf(flag_path, sizeof(flag_path) - 1, "%s.flag", flag);
|
||||||
|
if (OpenSdFileForAtmosphere(tid, flag_path, FS_OPEN_READ, &f)) {
|
||||||
|
fsFileClose(&f);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Utils::HasGlobalFlag(u64 tid, const char *flag) {
|
||||||
|
if (IsSdInitialized()) {
|
||||||
|
FsFile f;
|
||||||
|
char flag_path[FS_MAX_PATH] = {0};
|
||||||
|
snprintf(flag_path, sizeof(flag_path), "/atmosphere/flags/%s.flag", flag);
|
||||||
|
if (fsFsOpenFile(&g_sd_filesystem, flag_path, FS_OPEN_READ, &f)) {
|
||||||
|
fsFileClose(&f);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool Utils::HasSdMitMFlag(u64 tid) {
|
bool Utils::HasSdMitMFlag(u64 tid) {
|
||||||
|
if (tid == g_override_hbl_tid) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (IsSdInitialized()) {
|
if (IsSdInitialized()) {
|
||||||
return std::find(g_mitm_flagged_tids.begin(), g_mitm_flagged_tids.end(), tid) != g_mitm_flagged_tids.end();
|
return std::find(g_mitm_flagged_tids.begin(), g_mitm_flagged_tids.end(), tid) != g_mitm_flagged_tids.end();
|
||||||
}
|
}
|
||||||
|
@ -306,7 +366,12 @@ bool Utils::HasOverrideButton(u64 tid) {
|
||||||
static int FsMitMIniHandler(void *user, const char *section, const char *name, const char *value) {
|
static int FsMitMIniHandler(void *user, const char *section, const char *name, const char *value) {
|
||||||
/* Taken and modified, with love, from Rajkosto's implementation. */
|
/* Taken and modified, with love, from Rajkosto's implementation. */
|
||||||
if (strcasecmp(section, "config") == 0) {
|
if (strcasecmp(section, "config") == 0) {
|
||||||
if (strcasecmp(name, "override_key") == 0) {
|
if (strcasecmp(name, "hbl_tid") == 0) {
|
||||||
|
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] == '!') {
|
if (value[0] == '!') {
|
||||||
g_override_by_default = true;
|
g_override_by_default = true;
|
||||||
value++;
|
value++;
|
||||||
|
|
|
@ -38,6 +38,10 @@ class Utils {
|
||||||
|
|
||||||
/* SD card Initialization + MitM detection. */
|
/* SD card Initialization + MitM detection. */
|
||||||
static void InitializeSdThreadFunc(void *args);
|
static void InitializeSdThreadFunc(void *args);
|
||||||
|
|
||||||
|
static bool HasFlag(u64 tid, const char *flag);
|
||||||
|
static bool HasGlobalFlag(const char *flag);
|
||||||
|
|
||||||
static bool HasSdMitMFlag(u64 tid);
|
static bool HasSdMitMFlag(u64 tid);
|
||||||
static bool HasSdDisableMitMFlag(u64 tid);
|
static bool HasSdDisableMitMFlag(u64 tid);
|
||||||
|
|
||||||
|
|
|
@ -163,11 +163,22 @@ void EmbeddedBoot2::Main() {
|
||||||
char title_path[FS_MAX_PATH] = {0};
|
char title_path[FS_MAX_PATH] = {0};
|
||||||
strcpy(title_path, "sdmc:/atmosphere/titles/");
|
strcpy(title_path, "sdmc:/atmosphere/titles/");
|
||||||
strcat(title_path, ent->d_name);
|
strcat(title_path, ent->d_name);
|
||||||
strcat(title_path, "/boot2.flag");
|
strcat(title_path, "/flags/boot2.flag");
|
||||||
FILE *f_flag = fopen(title_path, "rb");
|
FILE *f_flag = fopen(title_path, "rb");
|
||||||
if (f_flag != NULL) {
|
if (f_flag != NULL) {
|
||||||
fclose(f_flag);
|
fclose(f_flag);
|
||||||
LaunchTitle((Boot2KnownTitleId)title_id, FsStorageId_None, 0, NULL);
|
LaunchTitle((Boot2KnownTitleId)title_id, FsStorageId_None, 0, NULL);
|
||||||
|
} else {
|
||||||
|
/* TODO: Deprecate this in the future. */
|
||||||
|
memset(title_path, 0, FS_MAX_PATH);
|
||||||
|
strcpy(title_path, "sdmc:/atmosphere/titles/");
|
||||||
|
strcat(title_path, ent->d_name);
|
||||||
|
strcat(title_path, "/boot2.flag");
|
||||||
|
f_flag = fopen(title_path, "rb");
|
||||||
|
if (f_flag != NULL) {
|
||||||
|
fclose(f_flag);
|
||||||
|
LaunchTitle((Boot2KnownTitleId)title_id, FsStorageId_None, 0, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue