diff --git a/Makefile.am b/Makefile.am index 053f26a..5b9636a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,9 +1,10 @@ # Makefile.am -- Process this file with automake to produce Makefile.in -bin_PROGRAMS = elf2nso elf2nro build_pfs0 +bin_PROGRAMS = elf2nso elf2nro build_pfs0 nacptool build_pfs0_SOURCES = src/build_pfs0.c src/types.h elf2nro_SOURCES = src/elf2nro.c src/elf64.h src/elf_common.h elf2nso_SOURCES = src/elf2nso.c src/sha256.c src/sha256.h src/elf64.h src/elf_common.h +nacptool_SOURCES = src/nacptool.c elf2nso_LDADD = @LZ4_LIBS@ diff --git a/src/nacptool.c b/src/nacptool.c new file mode 100644 index 0000000..d8985ad --- /dev/null +++ b/src/nacptool.c @@ -0,0 +1,123 @@ +#include +#include +#include +#include + +typedef uint64_t u64; +typedef uint32_t u32; +typedef uint8_t u8; + +typedef struct { + char name[0x200]; + char author[0x100]; +} NacpLanguageEntry; + +typedef struct { + NacpLanguageEntry lang[12]; + NacpLanguageEntry lang_unk[4];//? + + u8 x3000_unk[0x24];////Normally all-zero? + u32 x3024_unk; + u32 x3028_unk; + u32 x302C_unk; + u32 x3030_unk; + u32 x3034_unk; + u64 titleid0; + + u8 x3040_unk[0x20]; + char version[0x10]; + + u64 titleid_dlcbase; + u64 titleid1; + + u32 x3080_unk; + u32 x3084_unk; + u32 x3088_unk; + u8 x308C_unk[0x24];//zeros? + + u64 titleid2; + u64 titleids[7];//"Array of application titleIDs, normally the same as the above app-titleIDs. Only set for game-updates?" + + u32 x30F0_unk; + u32 x30F4_unk; + + u64 titleid3;//"Application titleID. Only set for game-updates?" + + char bcat_passphrase[0x40]; + u8 x3140_unk[0xEC0];//Normally all-zero? +} NacpStruct; + +int main(int argc, char* argv[]) { + if (argc < 6 || strncmp(argv[1], "--create", 8)!=0) { + fprintf(stderr, "%s --create [options]\n\n", argv[0]); + fprintf(stderr, "FLAGS:\n"); + fprintf(stderr, "--create : Create control.nacp for use with Switch homebrew applications.\n"); + fprintf(stderr, "Options:\n"); + fprintf(stderr, "--titleid= Set the application titleID.\n"); + return EXIT_FAILURE; + } + + NacpStruct nacp; + memset(&nacp, 0, sizeof(nacp)); + + if (sizeof(NacpStruct) != 0x4000) { + fprintf(stderr, "Bad compile environment!\n"); + return EXIT_FAILURE; + } + + char *name = argv[2]; + char *author = argv[3]; + char *names[12]; + char *authors[12]; + + int i; + for (i=0; i<12; i++) { + names[i] = name; + authors[i] = author; + } + + int argi; + u64 titleid=0; + for (argi=6; argi