Permalink
Browse files

Calypso: added nca/nsp FS patches all firmwares

  • Loading branch information...
psfree committed Aug 10, 2018
1 parent fb13e3f commit b00ff79fec93b38a90461733832686dcb6e528f8
Showing with 25 additions and 1 deletion.
  1. +25 −1 src/kippatches.c
View
@@ -17,10 +17,14 @@
#include <string.h>
#include "hwinit/types.h"
#include "hwinit/util.h"
#include "kippatches.h"
#include "fs.h"
#include "kippatches/fs.inc"
#define NOP 0xD503201F
// TODO: get full hashes somewhere and not just the first 16 bytes
// every second one is the exfat version
kippatchset_t kip_patches[] = {
@@ -61,6 +65,25 @@ int kippatch_apply(u8 *kipdata, u64 kipdata_len, kippatch_t *patch) {
return 0;
}
int nca_patch(u8 * kipdata, u64 kipdata_len) {
char pattern[8] = {0xE5, 0x07, 0x00, 0x32, 0xE0, 0x03, 0x16, 0xAA};
char buf[0x10];
memcpy(buf, kipdata+0x1C450, 0x10);
u32 * addr = memsearch(kipdata, kipdata_len, pattern, sizeof(pattern));
int ret=0;
int max_dist = 0x10;
for(int i=0; i<max_dist; i++) {
u32 op = addr[i];
if((op & 0xFC000000)==0x94000000) { //is a BL op
addr[i] = NOP;
ret=1;
break;
}
}
return ret;
}
int kippatch_apply_set(u8 *kipdata, u64 kipdata_len, kippatchset_t *patchset, char **filter) {
for (kippatch_t *p = patchset->patches; p && p->name; ++p) {
int found = 0;
@@ -76,7 +99,8 @@ int kippatch_apply_set(u8 *kipdata, u64 kipdata_len, kippatchset_t *patchset, ch
int r = kippatch_apply(kipdata, kipdata_len, p);
if (r) return r;
}
if(!strncmp("FS", patchset->kip_name, 2))
nca_patch(kipdata, kipdata_len);
return 0;
}

0 comments on commit b00ff79

Please sign in to comment.