From 3d8238e1d572b3a66452f01b79981fcf19b0bdae Mon Sep 17 00:00:00 2001 From: yellows8 Date: Sat, 30 Dec 2017 22:13:59 -0500 Subject: [PATCH] Append custom data to the end of NRO for storing assets. --- src/elf2nro.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 2 deletions(-) diff --git a/src/elf2nro.c b/src/elf2nro.c index 175697c..e637264 100644 --- a/src/elf2nro.c +++ b/src/elf2nro.c @@ -34,6 +34,19 @@ typedef struct { u8 Padding[0x20]; } NroHeader; +typedef struct { + u64 offset; + u64 size; +} AssetSection; + +typedef struct { + u8 magic[4]; + u32 version; + AssetSection icon; + AssetSection nacp; + AssetSection romfs; +} AssetHeader; + uint8_t* ReadEntireFile(const char* fn, size_t* len_out) { FILE* fd = fopen(fn, "rb"); if (fd == NULL) @@ -61,8 +74,12 @@ uint8_t* ReadEntireFile(const char* fn, size_t* len_out) { } int main(int argc, char* argv[]) { - if (argc != 3) { - fprintf(stderr, "%s \n", argv[0]); + if (argc < 3) { + fprintf(stderr, "%s [options]\n\n", argv[0]); + fprintf(stderr, "Options:\n"); + fprintf(stderr, "--icon= Embeds icon into the output file.\n"); + fprintf(stderr, "--nacp= Embeds control.nacp into the output file.\n"); + fprintf(stderr, "--romfs= Embeds RomFS into the output file.\n");//TODO: Use directory for input instead. return EXIT_FAILURE; } @@ -85,6 +102,14 @@ int main(int argc, char* argv[]) { return EXIT_FAILURE; } + int argi; + char* icon_path = NULL, *nacp_path = NULL, *romfs_path = NULL; + for (argi=3; argi