Skip to content

Commit

Permalink
removed AMS DRM
Browse files Browse the repository at this point in the history
  • Loading branch information
Reisyukaku committed Jul 29, 2018
1 parent 65be511 commit ec72f51
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 45 deletions.
6 changes: 3 additions & 3 deletions creport/source/creport_crash_report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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);
Expand Down
14 changes: 0 additions & 14 deletions fs_mitm/source/fsmitm_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
20 changes: 10 additions & 10 deletions fs_mitm/source/fsmitm_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down
9 changes: 0 additions & 9 deletions loader/source/ldr_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion loader/source/ldr_npdm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
4 changes: 2 additions & 2 deletions loader/source/ldr_nso.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions loader/source/ldr_patcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions pm/source/pm_boot2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

1 comment on commit ec72f51

@randompea
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure you dont steal atmosphere code

Please sign in to comment.