Loader: Change ips patch location to ease patch distribution

This commit is contained in:
Michael Scire 2018-07-29 11:27:19 -07:00
parent e697f6bdd0
commit 44e2412ae6
3 changed files with 7 additions and 7 deletions

View file

@ -285,7 +285,7 @@ Result NsoUtils::LoadNsosIntoProcessMemory(Handle process_h, u64 title_id, NsoLo
std::fill(map_base + bss_base, map_base + bss_base + bss_size, 0); std::fill(map_base + bss_base, map_base + bss_base + bss_size, 0);
/* Apply patches to loaded module. */ /* Apply patches to loaded module. */
PatchUtils::ApplyPatches(title_id, &g_nso_headers[i], map_base, bss_base); PatchUtils::ApplyPatches(&g_nso_headers[i], map_base, bss_base);
nso_map.Close(); nso_map.Close();

View file

@ -126,10 +126,10 @@ static void ApplyIpsPatch(u8 *mapped_nso, size_t mapped_size, bool is_ips32, FIL
} }
} }
void PatchUtils::ApplyPatches(u64 title_id, const NsoUtils::NsoHeader *header, u8 *mapped_nso, size_t mapped_size) { void PatchUtils::ApplyPatches(const NsoUtils::NsoHeader *header, u8 *mapped_nso, size_t mapped_size) {
/* Inspect all patches from /<title>/exefs/patches/<*>/<*>.ips. */ /* Inspect all patches from /atmosphere/exefs_patches/<*>/<*>.ips */
char path[FS_MAX_PATH+1] = {0}; char path[FS_MAX_PATH+1] = {0};
snprintf(path, sizeof(path) - 1, "sdmc:/atmosphere/titles/%016lx/exefs_patches", title_id); snprintf(path, sizeof(path) - 1, "sdmc:/atmosphere/exefs_patches");
DIR *patches_dir = opendir(path); DIR *patches_dir = opendir(path);
struct dirent *pdir_ent; struct dirent *pdir_ent;
if (patches_dir != NULL) { if (patches_dir != NULL) {
@ -138,7 +138,7 @@ void PatchUtils::ApplyPatches(u64 title_id, const NsoUtils::NsoHeader *header, u
if (strcmp(pdir_ent->d_name, ".") == 0 || strcmp(pdir_ent->d_name, "..") == 0) { if (strcmp(pdir_ent->d_name, ".") == 0 || strcmp(pdir_ent->d_name, "..") == 0) {
continue; continue;
} }
snprintf(path, sizeof(path) - 1, "sdmc:/atmosphere/titles/%016lx/exefs_patches/%s", title_id, pdir_ent->d_name); snprintf(path, sizeof(path) - 1, "sdmc:/atmosphere/exefs_patches/%s", pdir_ent->d_name);
DIR *patch_dir = opendir(path); DIR *patch_dir = opendir(path);
struct dirent *ent; struct dirent *ent;
if (patch_dir != NULL) { if (patch_dir != NULL) {
@ -149,7 +149,7 @@ void PatchUtils::ApplyPatches(u64 title_id, const NsoUtils::NsoHeader *header, u
} }
size_t name_len = strlen(ent->d_name); 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)) { 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/titles/%016lx/exefs_patches/%s/%s", title_id, pdir_ent->d_name, ent->d_name); snprintf(path, sizeof(path) - 1, "sdmc:/atmosphere/exefs_patches/%s/%s", pdir_ent->d_name, ent->d_name);
FILE *f_ips = fopen(path, "rb"); FILE *f_ips = fopen(path, "rb");
if (f_ips != NULL) { if (f_ips != NULL) {
u8 header[5]; u8 header[5];

View file

@ -6,5 +6,5 @@
class PatchUtils { class PatchUtils {
public: public:
static void ApplyPatches(u64 title_id, const NsoUtils::NsoHeader *header, u8 *mapped_nso, size_t size); static void ApplyPatches(const NsoUtils::NsoHeader *header, u8 *mapped_nso, size_t size);
}; };