View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -26,9 +26,7 @@
#define BOOT_PKG2_LOADED_4X 3
#define BOOT_DONE_4X 4
//Instructions
#define NOP 0xD503201F
#define ADRP(r, o) 0x90000000 | ((((o) >> 12) & 0x3) << 29) | ((((o) >> 12) & 0x1FFFFC) << 3) | ((r) & 0x1F)
#define PAYLOAD_ADDR 0xCFF00000
// TODO: Maybe find these with memsearch
static const pk11_offs _pk11_offs[] = {
@@ -39,23 +37,9 @@ static const pk11_offs _pk11_offs[] = {
{ "20170710161758", 2, 0x1A00, 0x3FE0, { 0, 1, 2 }, 0x4002D000, 0x8000D000, 1 }, //3.0.1 - 3.0.2
{ "20170921172629", 3, 0x1800, 0x3FE0, { 1, 2, 0 }, 0x4002B000, 0x4003B000, 0 }, //4.0.0 - 4.1.0
{ "20180220163747", 4, 0x1900, 0x3FE0, { 1, 2, 0 }, 0x4002B000, 0x4003B000, 0 }, //5.0.0 - 5.0.2
{ "20180802162753", 5, 0x1900, 0x3FE0, { 1, 2, 0 }, 0x4002B000, 0x4003D800, 0 }, //6.0.0
{ NULL, 0, 0, 0, 0 } // End.
};
#define NUM_KEYBLOB_KEYS 5
static const u8 keyblob_keyseeds[NUM_KEYBLOB_KEYS][0x10] = {
{ 0xDF, 0x20, 0x6F, 0x59, 0x44, 0x54, 0xEF, 0xDC, 0x70, 0x74, 0x48, 0x3B, 0x0D, 0xED, 0x9F, 0xD3 }, //1.0.0
{ 0x0C, 0x25, 0x61, 0x5D, 0x68, 0x4C, 0xEB, 0x42, 0x1C, 0x23, 0x79, 0xEA, 0x82, 0x25, 0x12, 0xAC }, //3.0.0
{ 0x33, 0x76, 0x85, 0xEE, 0x88, 0x4A, 0xAE, 0x0A, 0xC2, 0x8A, 0xFD, 0x7D, 0x63, 0xC0, 0x43, 0x3B }, //3.0.1
{ 0x2D, 0x1F, 0x48, 0x80, 0xED, 0xEC, 0xED, 0x3E, 0x3C, 0xF2, 0x48, 0xB5, 0x65, 0x7D, 0xF7, 0xBE }, //4.0.0
{ 0xBB, 0x5A, 0x01, 0xF9, 0x88, 0xAF, 0xF5, 0xFC, 0x6C, 0xFF, 0x07, 0x9E, 0x13, 0x3C, 0x39, 0x80 } //5.0.0
};
static const u8 cmac_keyseed[0x10] = { 0x59, 0xC7, 0xFB, 0x6F, 0xBE, 0x9B, 0xBE, 0x87, 0x65, 0x6B, 0x15, 0xC0, 0x53, 0x73, 0x36, 0xA5 };
static const u8 master_keyseed_retail[0x10] = { 0xD8, 0xA2, 0x41, 0x0A, 0xC6, 0xC5, 0x90, 0x01, 0xC6, 0x1D, 0x6A, 0x26, 0x7C, 0x51, 0x3F, 0x3C };
static const u8 console_keyseed[0x10] = { 0x4F, 0x02, 0x5F, 0x0E, 0xB6, 0x6D, 0x11, 0x0E, 0xDC, 0x32, 0x7D, 0x41, 0x86, 0xC2, 0xF4, 0x78 };
static const u8 key8_keyseed[] = { 0xFB, 0x8B, 0x6A, 0x9C, 0x79, 0x00, 0xC8, 0x49, 0xEF, 0xD2, 0x4D, 0x85, 0x4D, 0x30, 0xA0, 0xC7 };
static const u8 master_keyseed_4xx[0x10] = { 0x2D, 0xC1, 0xF4, 0x8D, 0xF3, 0x5B, 0x69, 0x33, 0x42, 0x10, 0xAC, 0x65, 0xDA, 0x90, 0x46, 0x66 };
static const u8 console_keyseed_4xx[0x10] = { 0x0C, 0x91, 0x09, 0xDB, 0x93, 0x93, 0x07, 0x81, 0x07, 0x3C, 0xC4, 0x16, 0x22, 0x7C, 0x6C, 0x28 };
void firmware();
View
@@ -17,7 +17,6 @@
#include <stddef.h>
#include <string.h>
#include "hwinit.h"
#include "hwinit/gfx.h"
#include "hwinit/ff.h"
#include "error.h"
#include "fs.h"
@@ -28,7 +27,7 @@ FATFS sd_fs;
int sd_mounted;
FIL fp;
u32 sd_mount() {
u32 sdMount() {
if (sd_mounted) return 1;
if (sdmmc_storage_init_sd(&sd_storage, &sd_sdmmc, SDMMC_1, SDMMC_BUS_WIDTH_4, 11) && f_mount(&sd_fs, "", 1) == FR_OK) {
@@ -39,6 +38,13 @@ u32 sd_mount() {
return 0;
}
void sdUnmount() {
if (!sd_mounted) return;
f_mount(NULL, "", 1);
sdmmc_storage_end(&sd_storage);
sd_mounted = 0;
}
u32 fopen(const char *path, const char *mode) {
u32 m = (mode[0] == 0x77 ? (FA_WRITE|FA_CREATE_NEW) : FA_READ);
if (f_open(&fp, path, m) != FR_OK)
View
@@ -16,7 +16,8 @@
#pragma once
u32 sd_mount();
u32 sdMount();
void sdUnmount();
u32 fopen(const char *path, const char *mode);
u32 fread(void *buf, size_t size, size_t ntimes);
u32 fwrite(void *buf, size_t size, size_t ntimes);
View

This file was deleted.

Oops, something went wrong.
View

This file was deleted.

Oops, something went wrong.
View
@@ -41,4 +41,7 @@
#include "hwinit/nx_emmc.h"
#include "hwinit/se.h"
#include "hwinit/se_t210.h"
#include "hwinit/mmc.h"
#include "hwinit/mmc.h"
#include "hwinit/gfx.h"
#define DEFAULT_TEXT_COL ORANGE
View
@@ -45,6 +45,6 @@
#define APBDEV_PMC_SCRATCH200 0x840
#define APBDEV_PMC_RST_STATUS_0 0x1B4
#define APBDEV_PMC_SECURE_SCRATCH49_0 0x3A4
#define APBDEV_PMC_SCRATCH49_0 0x244
#define APBDEV_PMC_SCRATCH49 0x244
#endif
View
@@ -52,6 +52,7 @@ enum KB_FIRMWARE_VERSION {
KB_FIRMWARE_VERSION_301 = 2,
KB_FIRMWARE_VERSION_400 = 3,
KB_FIRMWARE_VERSION_500 = 4,
KB_FIRMWARE_VERSION_600 = 5,
KB_FIRMWARE_VERSION_MAX
};
View
@@ -56,14 +56,27 @@ void exec_cfg(u32 *base, const cfg_op_t *ops, u32 num_ops)
base[ops[i].off] = ops[i].val;
}
uPtr memsearch(const u8 *startPos, u32 searchSize, const void *pattern, u32 patternSize) {
uPtr memsearch(void *startPos, size_t searchSize, void *pattern, size_t patternSize) {
if(!searchSize) return 0;
for (u8 *pos = (u8 *)startPos; pos <= startPos + searchSize - patternSize; pos++) {
for (u8 *pos = (u8*)startPos; pos <= (u8*)startPos + searchSize - patternSize; pos++) {
if (memcmp(pos, pattern, patternSize) == 0) return (uPtr)pos;
}
return 0;
}
//probably could be more optimized :<
uPtr getFreeSpace(void *start, size_t space, size_t searchSize) {
for(int i = 0; i < searchSize; i++) {
if(*(u8*)(start+i) == 0) {
for(int j=0;j<space;j++) {
if(*(u8*)(start+i+j) != 0) break;
if(j==space-1) return (uPtr)i;
}
}
}
return 0;
}
#define CRC32C_POLY 0x82F63B78
u32 crc32c(const void *buf, u32 len)
{
View
@@ -34,7 +34,8 @@ u32 get_tmr_us();
void musleep(u32 milliseconds);
void usleep(u32 microseconds);
void exec_cfg(u32 *base, const cfg_op_t *ops, u32 num_ops);
uPtr memsearch(const u8 *startPos, u32 searchSize, const void *pattern, u32 patternSize);
uPtr memsearch(void *startPos, size_t searchSize, void *pattern, size_t patternSize);
uPtr getFreeSpace(void *start, size_t space, size_t searchSize);
u32 crc32c(const void *buf, u32 len);
#endif
#endif
View

This file was deleted.

Oops, something went wrong.
View

This file was deleted.

Oops, something went wrong.
View
@@ -139,12 +139,59 @@ static kipdiff_t fs_diffs_510_nocmac[8] = {
{ 0, 0, NULL, NULL },
};
static kipdiff_t fs_diffs_600_exfat_nocmac[8] = {
{ 0x10B7F4, 4, "\x20\x0A\x00\x36", "\x1F\x20\x03\xD5" },
{ 0x10BCF8, 4, "\xA0\x03\x00\x36", "\x1F\x20\x03\xD5" },
{ 0x113934, 4, "\x60\x14\x00\x36", "\x1F\x20\x03\xD5" },
{ 0x11429C, 4, "\x60\x06\x00\x36", "\x1F\x20\x03\xD5" },
{ 0x1143DC, 4, "\x20\x07\x00\x36", "\x1F\x20\x03\xD5" },
{ 0x11B128, 4, "\xC0\x05\x00\x36", "\x1F\x20\x03\xD5" },
{ 0x11B254, 4, "\xC0\x06\x00\x36", "\x1F\x20\x03\xD5" },
{ 0, 0, NULL, NULL },
};
//exfat offsets are simply shifted by + 0xB700
static kipdiff_t fs_diffs_600_nocmac[8] = {
{ 0x1000F4, 4, "\x20\x0A\x00\x36", "\x1F\x20\x03\xD5" },
{ 0x1005F8, 4, "\xA0\x03\x00\x36", "\x1F\x20\x03\xD5" },
{ 0x108234, 4, "\x60\x14\x00\x36", "\x1F\x20\x03\xD5" },
{ 0x108B9C, 4, "\x60\x06\x00\x36", "\x1F\x20\x03\xD5" },
{ 0x108CDC, 4, "\x20\x07\x00\x36", "\x1F\x20\x03\xD5" },
{ 0x10FA28, 4, "\xC0\x05\x00\x36", "\x1F\x20\x03\xD5" },
{ 0x10FB54, 4, "\xC0\x06\x00\x36", "\x1F\x20\x03\xD5" },
{ 0, 0, NULL, NULL },
};
static kipdiff_t fs_diffs_510_nogc[3] = {
{ 0xCF794, 4, "\x14\x40\x80\x52", "\x14\x80\x80\x52" },
{ 0xD7770, 8, "\xF4\x4F\xBE\xA9\xFD\x7B\x01\xA9", "\xE0\x03\x1F\x2A\xC0\x03\x5F\xD6" },
{ 0, 0, NULL, NULL },
};
static kipdiff_t fs_diffs_600_exfat_nogc[3] = {
{ 0x15EFF4, 4, "\x14\x40\x80\x52", "\x14\x80\x80\x52" },
{ 0x138320, 8, "\xF4\x4F\xBE\xA9\xFD\x7B\x01\xA9", "\xE0\x03\x1F\x2A\xC0\x03\x5F\xD6" },
{ 0, 0, NULL, NULL },
};
static kipdiff_t fs_diffs_600_nogc[3] = {
{ 0x1538F4, 4, "\x14\x40\x80\x52", "\x14\x80\x80\x52" },
{ 0x12CC20, 8, "\xF4\x4F\xBE\xA9\xFD\x7B\x01\xA9", "\xE0\x03\x1F\x2A\xC0\x03\x5F\xD6" },
{ 0, 0, NULL, NULL },
};
static kipdiff_t fs_diffs_600_exfat_nosigchk[3] = {
{ 0x7C9A8, 4, "\x8E\x3E\x00\x94", "\xE0\x03\x1F\x2A" },
{ 0xF678C, 4, "\xC0\x03\x00\x36", "\x1F\x20\x03\xD5" },
{ 0, 0, NULL, NULL },
};
static kipdiff_t fs_diffs_600_nosigchk[3] = {
{ 0x712A8, 4, "\x8E\x3E\x00\x94", "\xE0\x03\x1F\x2A" },
{ 0xEB08C, 4, "\xC0\x03\x00\x36", "\x1F\x20\x03\xD5" },
{ 0, 0, NULL, NULL },
};
/* patches */
static kippatch_t fs_kip_patches_100[] = {
@@ -204,3 +251,31 @@ static kippatch_t fs_kip_patches_510[] = {
{ "nogc", fs_diffs_510_nogc },
{ NULL, NULL }
};
static kippatch_t fs_kip_patches_600_40[] = {
{ "nosigchk", fs_diffs_600_nosigchk },
{ "nocmac", fs_diffs_600_nocmac },
{ "nogc", fs_diffs_600_nogc },
{ NULL, NULL }
};
static kippatch_t fs_kip_patches_600_40_exfat[] = {
{ "nosigchk", fs_diffs_600_exfat_nosigchk },
{ "nocmac", fs_diffs_600_exfat_nocmac },
{ "nogc", fs_diffs_600_exfat_nogc },
{ NULL, NULL }
};
static kippatch_t fs_kip_patches_600_50[] = {
{ "nosigchk", fs_diffs_600_nosigchk },
{ "nocmac", fs_diffs_600_nocmac },
{ "nogc", fs_diffs_600_nogc },
{ NULL, NULL }
};
static kippatch_t fs_kip_patches_600_50_exfat[] = {
{ "nosigchk", fs_diffs_600_exfat_nosigchk },
{ "nocmac", fs_diffs_600_exfat_nocmac },
{ "nogc", fs_diffs_600_exfat_nogc },
{ NULL, NULL }
};
View
@@ -14,11 +14,48 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "hwinit/gfx.h"
#include "hwinit/list.h"
#include "hwinit.h"
#include "error.h"
#include "fs.h"
#include "package.h"
#include "kippatches/fs.inc"
u8 *ReadPackage1(sdmmc_storage_t *storage) {
u8 *pk11 = malloc(0x40000);
sdmmc_storage_read(storage, 0x100000 / NX_EMMC_BLOCKSIZE, 0x40000 / NX_EMMC_BLOCKSIZE, pk11);
return pk11;
}
u8 *ReadPackage2(sdmmc_storage_t *storage) {
// Read GPT partition.
LIST_INIT(gpt);
sdmmc_storage_set_mmc_partition(storage, 0);
print("Parsing GPT...\n");
nx_emmc_gpt_parse(&gpt, storage);
emmc_part_t *pkg2_part = nx_emmc_part_find(&gpt, "BCPKG2-1-Normal-Main");
nx_emmc_gpt_free(&gpt);
if (!pkg2_part) {
error("Failed to read GPT!\n");
return 0;
}
// Read Package2.
u8 *tmp = (u8 *)malloc(NX_EMMC_BLOCKSIZE);
print("Reading Package2 size...\n");
nx_emmc_part_read(storage, pkg2_part, 0x4000 / NX_EMMC_BLOCKSIZE, 1, tmp);
u32 *hdr = (u32 *)(tmp + 0x100);
u32 pkg2_size = hdr[0] ^ hdr[2] ^ hdr[3];
free(tmp);
u8 *pkg2 = malloc(ALIGN(pkg2_size, NX_EMMC_BLOCKSIZE));
print("Reading Package2...\n");
u32 ret = nx_emmc_part_read(storage, pkg2_part, 0x4000 / NX_EMMC_BLOCKSIZE, ALIGN(pkg2_size, NX_EMMC_BLOCKSIZE) / NX_EMMC_BLOCKSIZE, pkg2);
sdmmc_storage_end(storage);
if (!ret) {
error("Failed to read Package2!\n");
return 0;
}
return pkg2;
}
pkg2_hdr_t *unpackFirmwarePackage(u8 *data) {
print("Unpacking firmware...\n");
@@ -87,14 +124,6 @@ void pkg1_unpack(pk11_offs *offs, u8 *pkg1) {
}
}
const pkg2_kernel_id_t *pkg2_identify(u32 id)
{
for (u32 i = 0; _pkg2_kernel_ids[i].crc32c_id; i++)
if (id == _pkg2_kernel_ids[i].crc32c_id)
return &_pkg2_kernel_ids[i];
return NULL;
}
void buildFirmwarePackage(u8 *kernel, u32 kernel_size, link_t *kips_info) {
u8 *pdst = (u8 *)0xA9800000;
@@ -189,4 +218,170 @@ void loadKip(link_t *info, char *path) {
ki->kip1 = ckip;
ki->size = calcKipSize(ckip);
list_append(info, &ki->link);
}
// TODO: get full hashes somewhere and not just the first 16 bytes
// every second one is the exfat version
kippatchset_t kip_patches[] = {
{ "FS", "\xde\x9f\xdd\xa4\x08\x5d\xd5\xfe\x68\xdc\xb2\x0b\x41\x09\x5b\xb4", fs_kip_patches_100 },
{ "FS", "\xfc\x3e\x80\x99\x1d\xca\x17\x96\x4a\x12\x1f\x04\xb6\x1b\x17\x5e", fs_kip_patches_100 },
{ "FS", "\xcd\x7b\xbe\x18\xd6\x13\x0b\x28\xf6\x2f\x19\xfa\x79\x45\x53\x5b", fs_kip_patches_200 },
{ "FS", "\xe7\x66\x92\xdf\xaa\x04\x20\xe9\xfd\xd6\x8e\x43\x63\x16\x18\x18", fs_kip_patches_200 },
{ "FS", "\x0d\x70\x05\x62\x7b\x07\x76\x7c\x0b\x96\x3f\x9a\xff\xdd\xe5\x66", fs_kip_patches_210 },
{ "FS", "\xdb\xd8\x5f\xca\xcc\x19\x3d\xa8\x30\x51\xc6\x64\xe6\x45\x2d\x32", fs_kip_patches_210 },
{ "FS", "\xa8\x6d\xa5\xe8\x7e\xf1\x09\x7b\x23\xda\xb5\xb4\xdb\xba\xef\xe7", fs_kip_patches_300 },
{ "FS", "\x98\x1c\x57\xe7\xf0\x2f\x70\xf7\xbc\xde\x75\x31\x81\xd9\x01\xa6", fs_kip_patches_300 },
{ "FS", "\x57\x39\x7c\x06\x3f\x10\xb6\x31\x3f\x4d\x83\x76\x53\xcc\xc3\x71", fs_kip_patches_301 },
{ "FS", "\x07\x30\x99\xd7\xc6\xad\x7d\x89\x83\xbc\x7a\xdd\x93\x2b\xe3\xd1", fs_kip_patches_301 },
{ "FS", "\x06\xe9\x07\x19\x59\x5a\x01\x0c\x62\x46\xff\x70\x94\x6f\x10\xfb", fs_kip_patches_401 },
{ "FS", "\x54\x9b\x0f\x8d\x6f\x72\xc4\xe9\xf3\xfd\x1f\x19\xea\xce\x4a\x5a", fs_kip_patches_401 },
{ "FS", "\x80\x96\xaf\x7c\x6a\x35\xaa\x82\x71\xf3\x91\x69\x95\x41\x3b\x0b", fs_kip_patches_410 },
{ "FS", "\x02\xd5\xab\xaa\xfd\x20\xc8\xb0\x63\x3a\xa0\xdb\xae\xe0\x37\x7e", fs_kip_patches_410 },
{ "FS", "\xa6\xf2\x7a\xd9\xac\x7c\x73\xad\x41\x9b\x63\xb2\x3e\x78\x5a\x0c", fs_kip_patches_500 },
{ "FS", "\xce\x3e\xcb\xa2\xf2\xf0\x62\xf5\x75\xf8\xf3\x60\x84\x2b\x32\xb4", fs_kip_patches_500 },
{ "FS", "\x76\xf8\x74\x02\xc9\x38\x7c\x0f\x0a\x2f\xab\x1b\x45\xce\xbb\x93", fs_kip_patches_510 },
{ "FS", "\x10\xb2\xd8\x16\x05\x48\x85\x99\xdf\x22\x42\xcb\x6b\xac\x2d\xf1", fs_kip_patches_510 },
{ "FS", "\x1b\x82\xcb\x22\x18\x67\xcb\x52\xc4\x4a\x86\x9e\xa9\x1a\x1a\xdd", fs_kip_patches_600_40 },
{ "FS", "\x96\x6a\xdd\x3d\x20\xb6\x27\x13\x2c\x5a\x8d\xa4\x9a\xc9\xd8\xdd", fs_kip_patches_600_40_exfat },
{ "FS", "\x3a\x57\x4d\x43\x61\x86\x19\x1d\x17\x88\xeb\x2c\x0f\x07\x6b\x11", fs_kip_patches_600_50 },
{ "FS", "\x33\x05\x53\xf6\xb5\xfb\x55\xc4\xc2\xd7\xb7\x36\x24\x02\x76\xb3", fs_kip_patches_600_50_exfat },
{ NULL, NULL, NULL },
};
int kippatch_apply(u8 *kipdata, u64 kipdata_len, kippatch_t *patch) {
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))
continue;
// TODO: maybe start copying after every diff has been verified?
memcpy(start, diff->patch_bytes, diff->len);
}
return 0;
}
u32 *getSndPayload(u32 id, size_t *size) {
u32 *ret;
switch(id){
case 0:
*size = sizeof(PRC_ID_SND_100);
ret = PRC_ID_SND_100;
break;
case 1:
*size = sizeof(PRC_ID_SND_200);
ret = PRC_ID_SND_200;
break;
case 2:
*size = sizeof(PRC_ID_SND_300);
ret = PRC_ID_SND_300;
break;
case 3:
*size = sizeof(PRC_ID_SND_302);
ret = PRC_ID_SND_302;
break;
case 4:
*size = sizeof(PRC_ID_SND_400);
ret = PRC_ID_SND_400;
break;
case 5:
*size = sizeof(PRC_ID_SND_500);
ret = PRC_ID_SND_500;
break;
case 6:
*size = sizeof(PRC_ID_SND_600);
ret = PRC_ID_SND_600;
break;
}
return ret;
}
u32 *getRcvPayload(u32 id, size_t *size) {
u32 *ret;
switch(id){
case 0:
*size = sizeof(PRC_ID_RCV_100);
ret = PRC_ID_RCV_100;
break;
case 1:
*size = sizeof(PRC_ID_RCV_200);
ret = PRC_ID_RCV_200;
break;
case 2:
*size = sizeof(PRC_ID_RCV_300);
ret = PRC_ID_RCV_300;
break;
case 3:
*size = sizeof(PRC_ID_RCV_302);
ret = PRC_ID_RCV_302;
break;
case 4:
*size = sizeof(PRC_ID_RCV_400);
ret = PRC_ID_RCV_400;
break;
case 5:
*size = sizeof(PRC_ID_RCV_500);
ret = PRC_ID_RCV_500;
break;
case 6:
*size = sizeof(PRC_ID_RCV_600);
ret = PRC_ID_RCV_600;
break;
}
return ret;
}
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 *patchFilter[] = { "nosigchk", "nocmac", "nogc", NULL };
if (!fopen("/ReiNX/nogc", "rb")) {
patchFilter[2] = NULL;
fclose();
}
for (kippatch_t *p = patchset->patches; p && p->name; ++p) {
int found = 0;
for (char **filtname = patchFilter; filtname && *filtname; ++filtname) {
if (!strcmp(p->name, *filtname)) {
found = 1;
break;
}
}
if (patchFilter && !found) continue;
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;
}
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;
}
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

This file was deleted.

Oops, something went wrong.
View
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018 naehrwert
* Copyright (c) 2018 naehrwert, Reisyukaku
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -17,45 +17,51 @@
.section .text.start
.arm
.extern _reloc_ipl
.type _reloc_ipl, %function
.extern memset
.type memset, %function
.extern ipl_main
.type ipl_main, %function
.extern heap_init
.type heap_init, %function
.extern bootrom
.type bootrom, %function
.extern bootloader
.type bootloader, %function
.extern firmware
.type firmware, %function
.globl _start
.type _start, %function
_start:
ADR R0, _start
LDR R1, =__ipl_start
LDR R1, =payload_start
CMP R0, R1
BEQ _real_start
/* If we are not in the right location already, copy a relocator to upper IRAM. */
ADR R2, _reloc_ipl
ADR R2, reloc_payload
LDR R3, =0x4003FF00
MOV R4, #(_real_start - _reloc_ipl)
MOV R4, #(_real_start - reloc_payload)
_copy_loop:
LDMIA R2!, {R5}
STMIA R3!, {R5}
SUBS R4, #4
BNE _copy_loop
/* Use the relocator to copy ourselves into the right place. */
LDR R2, =__ipl_end
LDR R2, =payload_end
SUB R2, R2, R1
LDR R3, =_real_start
LDR R4, =0x4003FF00
BX R4
_reloc_ipl:
reloc_payload:
LDMIA R0!, {R4-R7}
STMIA R1!, {R4-R7}
SUBS R2, #0x10
BNE _reloc_ipl
BNE reloc_payload
/* Jump to the relocated entry. */
BX R3
@@ -73,18 +79,3 @@ _real_start:
BL bootloader
BL firmware
B .
.globl rebootRCM
.type rebootRCM, %function
rebootRCM:
MOVS R3, #2
LDR R2, =0x7000E450
LDR R1, [R2]
ORRS R3, R1
STR R3, [R2]
MOVS R3, #0x10
LDR R2, =0x7000E400
LDR R1, [R2]
ORRS R3, R1
MOVS R0, #0
STR R3, [R2]