Stratosphere: Add support for custom KIPs/INI in Fusee

This commit is contained in:
Michael Scire
2018-04-11 21:56:11 -06:00
parent e5a0cb1abe
commit 0674c4b64f
4 changed files with 127 additions and 10 deletions

View File

@@ -1,5 +1,6 @@
#include "utils.h"
#include "masterkey.h"
#include "stratosphere.h"
#include "package2.h"
#include "kip.h"
#include "se.h"
@@ -9,7 +10,6 @@
/* This *greatly* simplifies logic. */
unsigned char g_patched_package2[PACKAGE2_SIZE_MAX];
unsigned char g_package2_sections[PACKAGE2_SECTION_MAX][PACKAGE2_SIZE_MAX];
unsigned char g_package2_work_buffer[PACKAGE2_SIZE_MAX];
package2_header_t *g_patched_package2_header = (package2_header_t *)g_patched_package2;
@@ -36,7 +36,7 @@ void package2_patch(void *package2_address) {
package2_fixup_header_and_section_hashes();
/* Relocate Package2. */
memcpy(NX_BOOTLOADER_PACKAGE2_LOAD_ADDRESS, g_patched_package2, PACKAGE2_SIZE_MAX);
memcpy(NX_BOOTLOADER_PACKAGE2_LOAD_ADDRESS, g_patched_package2, sizeof(g_patched_package2));
}
static void package2_crypt_ctr(unsigned int master_key_rev, void *dst, size_t dst_size, const void *src, size_t src_size, const void *ctr, size_t ctr_size) {
@@ -211,14 +211,15 @@ void package2_patch_kernel(void) {
/* TODO: What kind of patching do we want to try to do here? */
}
void package2_patch_ini1(void) {
ini1_header_t *ini_header = (ini1_header_t *)g_package2_sections[PACKAGE2_SECTION_INI1];
if (ini_header->magic != MAGIC_INI1) {
printk("Error: INI1 section appears to not contain an INI1!\n");
generic_panic();
}
/* TODO */
/* TODO: Do we want to support loading another INI from sd:/whatever/INI1.bin? */
ini1_header_t *inis_to_merge[STRATOSPHERE_INI1_MAX] = {0};
inis_to_merge[STRATOSPHERE_INI1_EMBEDDED] = stratosphere_get_ini1();
inis_to_merge[STRATOSPHERE_INI1_PACKAGE2] = (ini1_header_t *)g_package2_sections[PACKAGE2_SECTION_INI1];
/* Merge all of the INI1s. */
stratosphere_merge_inis(g_package2_sections[PACKAGE2_SECTION_INI1], inis_to_merge, STRATOSPHERE_INI1_MAX);
}
void package2_fixup_header_and_section_hashes(void) {