Permalink
Browse files

added optional nogc patch by putting file named 'nogc' in ReiNX folde…

…r; updated README
  • Loading branch information...
Reisyukaku committed Aug 4, 2018
1 parent bbff1c4 commit 70361a5ab046f0af83a3fb3d32c659e07e4da091
Showing with 40 additions and 35 deletions.
  1. +5 −4 README.md
  2. +35 −31 src/kippatches.c
View
@@ -20,12 +20,13 @@ To compile with Docker, `chmod +x docker-build.sh` and run the shell script `./d
* Optional custom kernel/secmon/warmboot
* Exclusive ReiNX sysmodules
* FS patches on the fly (NCA verify/cmac and optional nogc)
**FAQ:**
* Exclusive ReiNX sysmodules with built in ES patches
* Wheres muh 'sig patches'?
*Refer to the GBAtemp thread. Cant up them because its illegal*
**Official thread:**
[HERE](https://gbatemp.net/threads/official-reinx-thread.512203/)
**Credits:**
View
@@ -18,7 +18,7 @@
#include "hwinit/types.h"
#include "kippatches.h"
#include "fs.h"
#include "kippatches/fs.inc"
// TODO: get full hashes somewhere and not just the first 16 bytes
@@ -46,44 +46,48 @@ kippatchset_t kip_patches[] = {
};
int kippatch_apply(u8 *kipdata, u64 kipdata_len, kippatch_t *patch) {
if (!patch || !patch->diffs) return -1;
if (!patch || !patch->diffs) return -1;
for (kipdiff_t *diff = patch->diffs; diff->len; ++diff) {
if (!diff->len || diff->offset + diff->len > kipdata_len)
return 1 + (int)(diff - patch->diffs);
u8 *start = kipdata + diff->offset;
if (memcmp(start, diff->orig_bytes, diff->len))
return 1 + (int)(diff - patch->diffs);
// TODO: maybe start copying after every diff has been verified?
memcpy(start, diff->patch_bytes, diff->len);
}
for (kipdiff_t *diff = patch->diffs; diff->len; ++diff) {
if (!diff->len || diff->offset + diff->len > kipdata_len)
return 1 + (int)(diff - patch->diffs);
u8 *start = kipdata + diff->offset;
if (memcmp(start, diff->orig_bytes, diff->len))
return 1 + (int)(diff - patch->diffs);
// TODO: maybe start copying after every diff has been verified?
memcpy(start, diff->patch_bytes, diff->len);
}
return 0;
return 0;
}
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;
for (char **filtname = filter; filtname && *filtname; ++filtname) {
if (!strcmp(p->name, *filtname)) {
found = 1;
break;
}
}
for (kippatch_t *p = patchset->patches; p && p->name; ++p) {
int found = 0;
for (char **filtname = filter; filtname && *filtname; ++filtname) {
if (!strcmp(p->name, *filtname)) {
found = 1;
break;
}
}
if (!strcmp(p->name, "nogc")){
if(!fopen("/ReiNX/nogc", "rb")) {
fclose();
continue;
}
}
if (filter && !found) continue;
if (filter && !found) continue;
int r = kippatch_apply(kipdata, kipdata_len, p);
if (r) return r;
}
int r = kippatch_apply(kipdata, kipdata_len, p);
if (r) return r;
}
return 0;
return 0;
}
kippatchset_t *kippatch_find_set(u8 *kiphash, kippatchset_t *patchsets) {
for (kippatchset_t *ps = patchsets; ps && ps->kip_name; ++ps) {
if (!memcmp(kiphash, ps->kip_hash, 0x10))
return ps;
}
return NULL;
for (kippatchset_t *ps = patchsets; ps && ps->kip_name; ++ps) {
if (!memcmp(kiphash, ps->kip_hash, 0x10)) return ps;
}
return NULL;
}

0 comments on commit 70361a5

Please sign in to comment.