Skip to content
Permalink
Browse files

removed AMS DRM

  • Loading branch information...
Reisyukaku committed Jul 29, 2018
1 parent 65be511 commit ec72f51531165f78d8d567abd6287a49d91e2800
@@ -204,7 +204,7 @@ bool CrashReport::GetCurrentTime(u64 *out) {

void CrashReport::EnsureReportDirectories() {
char path[FS_MAX_PATH];
strcpy(path, "sdmc:/atmosphere");
strcpy(path, "sdmc:/ReiNX");
mkdir(path, S_IRWXU);
strcat(path, "/crash reports");
mkdir(path, S_IRWXU);
@@ -226,7 +226,7 @@ void CrashReport::SaveReport() {
}

/* Open report file. */
snprintf(report_path, sizeof(report_path) - 1, "sdmc:/atmosphere/crash reports/%011lu_%016lx.log", timestamp, process_info.title_id);
snprintf(report_path, sizeof(report_path) - 1, "sdmc:/ReiNX/crash reports/%011lu_%016lx.log", timestamp, process_info.title_id);
FILE *f_report = fopen(report_path, "w");
if (f_report == NULL) {
return;
@@ -235,7 +235,7 @@ void CrashReport::SaveReport() {
fclose(f_report);

/* Dump threads. */
snprintf(report_path, sizeof(report_path) - 1, "sdmc:/atmosphere/crash reports/dumps/%011lu_%016lx_thread_info.bin", timestamp, process_info.title_id);
snprintf(report_path, sizeof(report_path) - 1, "sdmc:/ReiNX/crash reports/dumps/%011lu_%016lx_thread_info.bin", timestamp, process_info.title_id);
f_report = fopen(report_path, "wb");
this->thread_list.DumpBinary(f_report, this->crashed_thread_info.GetId());
fclose(f_report);
@@ -65,20 +65,6 @@ void __appInit(void) {
if (R_FAILED(rc)) {
fatalSimple(0xCAFE << 4 | 3);
}

/* Check for exosphere API compatibility. */
u64 exosphere_cfg;
if (R_SUCCEEDED(splGetConfig((SplConfigItem)65000, &exosphere_cfg))) {
/* MitM requires Atmosphere API 0.1. */
u16 api_version = (exosphere_cfg >> 16) & 0xFFFF;
if (api_version < 0x0001) {
fatalSimple(0xCAFE << 4 | 0xFE);
}
} else {
fatalSimple(0xCAFE << 4 | 0xFF);
}

//splExit();
}

void __appExit(void) {
@@ -43,15 +43,15 @@ void Utils::InitializeSdThreadFunc(void *args) {

/* Check for MitM flags. */
FsDir titles_dir;
if (R_SUCCEEDED(fsFsOpenDirectory(&g_sd_filesystem, "/atmosphere/titles", FS_DIROPEN_DIRECTORY, &titles_dir))) {
if (R_SUCCEEDED(fsFsOpenDirectory(&g_sd_filesystem, "/ReiNX/titles", FS_DIROPEN_DIRECTORY, &titles_dir))) {
FsDirectoryEntry dir_entry;
FsFile f;
u64 read_entries;
while (R_SUCCEEDED((fsDirRead(&titles_dir, 0, &read_entries, 1, &dir_entry))) && read_entries == 1) {
if (strlen(dir_entry.name) == 0x10 && IsHexadecimal(dir_entry.name)) {
u64 title_id = strtoul(dir_entry.name, NULL, 16);
char title_path[FS_MAX_PATH] = {0};
strcpy(title_path, "/atmosphere/titles/");
strcpy(title_path, "/ReiNX/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))) {
@@ -87,9 +87,9 @@ Result Utils::OpenSdFileForAtmosphere(u64 title_id, const char *fn, int flags, F

char path[FS_MAX_PATH];
if (*fn == '/') {
snprintf(path, sizeof(path), "/atmosphere/titles/%016lx%s", title_id, fn);
snprintf(path, sizeof(path), "/ReiNX/titles/%016lx%s", title_id, fn);
} else {
snprintf(path, sizeof(path), "/atmosphere/titles/%016lx/%s", title_id, fn);
snprintf(path, sizeof(path), "/ReiNX/titles/%016lx/%s", title_id, fn);
}
return fsFsOpenFile(&g_sd_filesystem, path, flags, out);
}
@@ -117,9 +117,9 @@ Result Utils::OpenSdDirForAtmosphere(u64 title_id, const char *path, FsDir *out)

char safe_path[FS_MAX_PATH];
if (*path == '/') {
snprintf(safe_path, sizeof(safe_path), "/atmosphere/titles/%016lx%s", title_id, path);
snprintf(safe_path, sizeof(safe_path), "/ReiNX/titles/%016lx%s", title_id, path);
} else {
snprintf(safe_path, sizeof(safe_path), "/atmosphere/titles/%016lx/%s", title_id, path);
snprintf(safe_path, sizeof(safe_path), "/ReiNX/titles/%016lx/%s", title_id, path);
}
return fsFsOpenDirectory(&g_sd_filesystem, safe_path, FS_DIROPEN_DIRECTORY | FS_DIROPEN_FILE, out);
}
@@ -136,19 +136,19 @@ Result Utils::OpenRomFSSdDir(u64 title_id, const char *path, FsDir *out) {
Result Utils::OpenRomFSFile(FsFileSystem *fs, u64 title_id, const char *fn, int flags, FsFile *out) {
char path[FS_MAX_PATH];
if (*fn == '/') {
snprintf(path, sizeof(path), "/atmosphere/titles/%016lx/romfs%s", title_id, fn);
snprintf(path, sizeof(path), "/ReiNX/titles/%016lx/romfs%s", title_id, fn);
} else {
snprintf(path, sizeof(path), "/atmosphere/titles/%016lx/romfs/%s", title_id, fn);
snprintf(path, sizeof(path), "/ReiNX/titles/%016lx/romfs/%s", title_id, fn);
}
return fsFsOpenFile(fs, path, flags, out);
}

Result Utils::OpenRomFSDir(FsFileSystem *fs, u64 title_id, const char *path, FsDir *out) {
char safe_path[FS_MAX_PATH];
if (*path == '/') {
snprintf(safe_path, sizeof(safe_path), "/atmosphere/titles/%016lx/romfs%s", title_id, path);
snprintf(safe_path, sizeof(safe_path), "/ReiNX/titles/%016lx/romfs%s", title_id, path);
} else {
snprintf(safe_path, sizeof(safe_path), "/atmosphere/titles/%016lx/romfs/%s", title_id, path);
snprintf(safe_path, sizeof(safe_path), "/ReiNX/titles/%016lx/romfs/%s", title_id, path);
}
return fsFsOpenDirectory(fs, safe_path, FS_DIROPEN_DIRECTORY | FS_DIROPEN_FILE, out);
}
@@ -68,15 +68,6 @@ void __appInit(void) {
if (R_FAILED(rc)) {
fatalSimple(0xCAFE << 4 | 3);
}

/* Check for exosphere API compatibility. */
u64 exosphere_cfg;
if (R_FAILED(splGetConfig((SplConfigItem)65000, &exosphere_cfg))) {
//fatalSimple(0xCAFE << 4 | 0xFF);
/* TODO: Does Loader need to know about target firmware/master key revision? If so, extract from exosphere_cfg. */
}

//splExit();
}

void __appExit(void) {
@@ -23,7 +23,7 @@ FILE *NpdmUtils::OpenNpdmFromExeFS() {

FILE *NpdmUtils::OpenNpdmFromSdCard(u64 title_id) {
std::fill(g_npdm_path, g_npdm_path + FS_MAX_PATH, 0);
snprintf(g_npdm_path, FS_MAX_PATH, "sdmc:/atmosphere/titles/%016lx/exefs/main.npdm", title_id);
snprintf(g_npdm_path, FS_MAX_PATH, "sdmc:/ReiNX/titles/%016lx/exefs/main.npdm", title_id);
return fopen(g_npdm_path, "rb");
}

@@ -22,13 +22,13 @@ FILE *NsoUtils::OpenNsoFromExeFS(unsigned int index) {

FILE *NsoUtils::OpenNsoFromSdCard(unsigned int index, u64 title_id) {
std::fill(g_nso_path, g_nso_path + FS_MAX_PATH, 0);
snprintf(g_nso_path, FS_MAX_PATH, "sdmc:/atmosphere/titles/%016lx/exefs/%s", title_id, NsoUtils::GetNsoFileName(index));
snprintf(g_nso_path, FS_MAX_PATH, "sdmc:/ReiNX/titles/%016lx/exefs/%s", title_id, NsoUtils::GetNsoFileName(index));
return fopen(g_nso_path, "rb");
}

bool NsoUtils::CheckNsoStubbed(unsigned int index, u64 title_id) {
std::fill(g_nso_path, g_nso_path + FS_MAX_PATH, 0);
snprintf(g_nso_path, FS_MAX_PATH, "sdmc:/atmosphere/titles/%016lx/exefs/%s.stub", title_id, NsoUtils::GetNsoFileName(index));
snprintf(g_nso_path, FS_MAX_PATH, "sdmc:/ReiNX/titles/%016lx/exefs/%s.stub", title_id, NsoUtils::GetNsoFileName(index));
FILE *f = fopen(g_nso_path, "rb");
bool ret = (f != NULL);
if (ret) {
@@ -127,9 +127,9 @@ static void ApplyIpsPatch(u8 *mapped_nso, size_t mapped_size, bool is_ips32, FIL
}

void PatchUtils::ApplyPatches(const NsoUtils::NsoHeader *header, u8 *mapped_nso, size_t mapped_size) {
/* Inspect all patches from /atmosphere/exefs_patches/<*>/<*>.ips */
/* Inspect all patches from /ReiNX/exefs_patches/<*>/<*>.ips */
char path[FS_MAX_PATH+1] = {0};
snprintf(path, sizeof(path) - 1, "sdmc:/atmosphere/exefs_patches");
snprintf(path, sizeof(path) - 1, "sdmc:/ReiNX/exefs_patches");
DIR *patches_dir = opendir(path);
struct dirent *pdir_ent;
if (patches_dir != NULL) {
@@ -138,7 +138,7 @@ void PatchUtils::ApplyPatches(const NsoUtils::NsoHeader *header, u8 *mapped_nso,
if (strcmp(pdir_ent->d_name, ".") == 0 || strcmp(pdir_ent->d_name, "..") == 0) {
continue;
}
snprintf(path, sizeof(path) - 1, "sdmc:/atmosphere/exefs_patches/%s", pdir_ent->d_name);
snprintf(path, sizeof(path) - 1, "sdmc:/ReiNX/exefs_patches/%s", pdir_ent->d_name);
DIR *patch_dir = opendir(path);
struct dirent *ent;
if (patch_dir != NULL) {
@@ -149,7 +149,7 @@ void PatchUtils::ApplyPatches(const NsoUtils::NsoHeader *header, u8 *mapped_nso,
}
size_t name_len = strlen(ent->d_name);
if ((4 < name_len && name_len <= 0x44) && ((name_len & 1) == 0) && strcmp(ent->d_name + name_len - 4, ".ips") == 0 && MatchesBuildId(ent->d_name, name_len, header->build_id)) {
snprintf(path, sizeof(path) - 1, "sdmc:/atmosphere/exefs_patches/%s/%s", pdir_ent->d_name, ent->d_name);
snprintf(path, sizeof(path) - 1, "sdmc:/ReiNX/exefs_patches/%s/%s", pdir_ent->d_name, ent->d_name);
FILE *f_ips = fopen(path, "rb");
if (f_ips != NULL) {
u8 header[5];
@@ -139,14 +139,14 @@ void EmbeddedBoot2::Main() {
}

/* Allow for user-customizable programs. */
DIR *titles_dir = opendir("sdmc:/atmosphere/titles");
DIR *titles_dir = opendir("sdmc:/ReiNX/titles");
struct dirent *ent;
if (titles_dir != NULL) {
while ((ent = readdir(titles_dir)) != NULL) {
if (strlen(ent->d_name) == 0x10 && IsHexadecimal(ent->d_name)) {
u64 title_id = strtoul(ent->d_name, NULL, 16);
char title_path[FS_MAX_PATH] = {0};
strcpy(title_path, "sdmc:/atmosphere/titles/");
strcpy(title_path, "sdmc:/ReiNX/titles/");
strcat(title_path, ent->d_name);
strcat(title_path, "/boot2.flag");
FILE *f_flag = fopen(title_path, "rb");

0 comments on commit ec72f51

Please sign in to comment.
You can’t perform that action at this time.