From 3c9fffd56a68ebd128c202d387bf84e61fdb1fee Mon Sep 17 00:00:00 2001 From: 3DSGuy <3dsguy.dev@gmail.com> Date: Fri, 21 Feb 2014 03:14:00 +0800 Subject: [PATCH] makerom v0.2 --- Application.rsf | 37 - Makefile | 9 +- accessdesc_sig.h | 260 ++++++- cia.c | 14 +- elf.c | 222 +++--- exheader.c | 1069 +++++++++++++++++++++++++--- exheader.h | 151 ++-- keyset.c | 2 +- makerom.c | 6 +- ncch.c | 76 +- ncch.h | 3 +- ncsd.c | 105 +-- ncsd.h | 1 + romfs.c | 8 + romfs.h | 4 + Application.desc => sdapp_FW4X.rsf | 256 +++---- titleid.c | 60 +- titleid.h | 4 +- usersettings.c | 167 ++--- usersettings.h | 98 +-- yaml_ctr.c | 39 +- yaml_ctr.h | 8 - yamlsettings.c | 316 +------- yamlsettings.h | 7 +- 24 files changed, 1825 insertions(+), 1097 deletions(-) delete mode 100644 Application.rsf rename Application.desc => sdapp_FW4X.rsf (51%) diff --git a/Application.rsf b/Application.rsf deleted file mode 100644 index 33d5aa0..0000000 --- a/Application.rsf +++ /dev/null @@ -1,37 +0,0 @@ -# Default value for application -BasicInfo: - Title : "Homebrew" - CompanyCode : "00" - MediaSize : 128MB # 128MB / 256MB / 512MB / 1GB / 2GB - MediaFootPadding: false - ProductCode : "CTR-P-HAXX" - ContentType : Application # Application / SystemUpdate / Manual / Child / Trial - Logo : Nintendo # Nintendo / Licenced / Distributed - BackupMemoryType: None # None / 128KB / 512KB - -Rom: - # Specifies the root path of the file system to include in the ROM. - HostRoot: "$(ROMFS_ROOT)" - SaveDataSize: 512KB - - -TitleInfo: - UniqueId: 1337 - #TargetCategory: Contents - Category: Application - #DemoIndex: 1 - Version: 0 - -CardInfo: - #WritableAddress: 0x200 - #CardType : S2 # S1 / S2 - #CryptoType : 3 # 0 - 3 - CardDevice : NorFlash # NorFlash(0), None(1), BT(2) - #MediaType : CARD1 # Card1 / Card2 - -Option: - # ??????????????? true - UseOnSD: true # true if App is to be installed to SD - EnableCompress: true # true / false - FreeProductCode: true # true ??????????????????????? - EnableCrypt : true # fasle ???????? \ No newline at end of file diff --git a/Makefile b/Makefile index 7289448..8a40192 100644 --- a/Makefile +++ b/Makefile @@ -19,12 +19,11 @@ CFLAGS = --std=c99 -Wall -I. -DMAKEROM_VER_MAJOR=$(VER_MAJOR) -DMAKEROM_VER_MINO CC = gcc # MAKEROM Build Settings -MAKEROM_BUILD_FLAGS = -DPRIVATE_BUILD -DRETAIL_FSIGN -DELF_DEBUG +MAKEROM_BUILD_FLAGS = -DPRIVATE_BUILD #-DRETAIL_FSIGN #-DELF_DEBUG VER_MAJOR = 0 -VER_MINOR = 1 +VER_MINOR = 2 OUTPUT = makerom -# main: build rebuild: clean build @@ -38,7 +37,7 @@ clean: # Winfail compatibility rebuildwin: cleanwin build cleanwin: - del $(OUTPUT).exe *.o polarssl\*.o libyaml\*.o *.cci *.cia *.cxi *.cfa + del /Q objs $(OUTPUT).exe *.o polarssl\*.o libyaml\*.o *.cci *.cia *.cxi *.cfa #Test Functions @@ -56,4 +55,4 @@ ciagen: $(OUTPUT) -f cia -o content_test.cia -content testdata\app_zeroskey.cxi:0 -content testdata\manual_zeroskey.cfa:1 -content testdata\dlp_zeroskey.cfa:2 -encryptcia pyramids: - $(OUTPUT) -f cxi -accessdesc app -o pyramids.cxi -code pyramids\code.bin -exheader pyramids\exheader.bin -rsf pyramids\app.rsf -desc pyramids\build.desc -icon pyramids\icon.icn -banner pyramids\banner.bnr -romfs pyramids\romfs.bin \ No newline at end of file + $(OUTPUT) -f cxi -accessdesc app -o pyramids.cxi -code pyramids\code.bin -exheader pyramids\exheader.bin -rsf pyramids\app.rsf -desc pyramids\build.desc -icon pyramids\icon.icn -banner pyramids\banner.bnr -romfs pyramids\romfs.bin diff --git a/accessdesc_sig.h b/accessdesc_sig.h index 327e5cc..029cb48 100644 --- a/accessdesc_sig.h +++ b/accessdesc_sig.h @@ -1,52 +1,294 @@ #ifndef _ACCESSDESC_SIG_H_ #define _ACCESSDESC_SIG_H_ +/* CTR_SDK 1 (1.2.0) */ // APP -static const unsigned char App_HdrPubK[0x100] = +static const unsigned char App_sdk1_HdrPubK[0x100] = +{ + 0x9B, 0x82, 0x9C, 0x19, 0x01, 0x73, 0x23, 0x50, 0x89, 0xE3, 0x0B, 0xC8, 0x8F, 0xFB, 0xA5, 0xE4, 0xFD, 0x44, 0xAE, 0x49, 0x32, 0xC7, 0xEF, 0x0A, 0x7E, 0x93, 0x95, 0xBA, 0xA2, 0x48, 0x4D, 0x8E, 0x18, 0x82, 0x34, 0x66, 0xFE, 0xDA, 0x7A, 0x45, 0x4A, 0x7D, 0xD5, 0x3C, 0xC6, 0x5C, 0xE0, 0x71, 0xFC, 0xD0, 0x82, 0xCC, 0xB2, 0xCF, 0x77, 0x0E, 0xAD, 0xCD, 0xD2, 0xAC, 0x1D, 0x66, 0x1B, 0xC1, 0xEA, 0xAC, 0x39, 0x96, 0x2C, 0x52, 0xDE, 0xFF, 0xF2, 0x74, 0xF6, 0xC5, 0xCA, 0x99, 0x31, 0x95, 0x13, 0xBB, 0x3F, 0xED, 0x30, 0xAE, 0x0A, 0xD3, 0x86, 0x0D, 0x0B, 0xF5, 0x56, 0x7D, 0x33, 0xBA, 0xA1, 0x39, 0xA2, 0xF5, 0xB6, 0x47, 0x78, 0x1F, 0xFD, 0x04, 0xA3, 0x49, 0xA9, 0x10, 0xD3, 0x41, 0x2E, 0x92, 0x7D, 0xE1, 0xA4, 0xA8, 0x02, 0x18, 0x01, 0x2C, 0xC2, 0x61, 0xB1, 0xAC, 0xCB, 0xB3, 0x7A, 0x64, 0xB1, 0xC3, 0xE6, 0x3B, 0x50, 0xAD, 0xDD, 0x55, 0xAB, 0x28, 0xDA, 0x59, 0xE7, 0x57, 0x6A, 0x76, 0x4F, 0x6B, 0x08, 0xD1, 0x61, 0x7D, 0x28, 0xD5, 0x88, 0x7B, 0x8E, 0x80, 0x78, 0xF3, 0xFF, 0x50, 0x00, 0xBD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0x4D, 0xFA, 0xEF, 0x10, 0x03, 0xF1, 0x15, 0xD1, 0x0B, 0x71, 0xAD, 0x24, 0x23, 0x08, 0x5C, 0x91, 0xD7, 0x17, 0x18, 0x69, 0x04, 0xAB, 0x23, 0x91, 0x62, 0x7D, 0xE8, 0xB5, 0x90, 0xF1, 0x5C, 0x09, 0x28, 0x8C, 0x51, 0xB7, 0x38, 0x02, 0x26, 0x78, 0x8C, 0xA2, 0x05, 0x07, 0x53, 0x7D, 0x99, 0x46, 0xFD, 0x12, 0x77, 0x32, 0x0E, 0xA8, 0x54, 0xE3, 0x32, 0x0E, 0x93, 0x05, 0x10, 0xFA, 0x59, 0x7A, 0x5D, 0x2E, 0xDE, 0x32, 0xE8, 0xE9, 0xF0, 0x27, 0x4E, 0x08, 0x83, 0x08, 0xD4, 0x92, 0x58, 0x4D, 0x6D, 0x34, 0x9F, 0xD9, 0xAF, 0xA9, 0x01, 0x62, 0xB5, 0x1A, 0x1D, 0x7E, 0x8D, 0xBB, 0x8A, 0x58, 0xBA, 0xFF, 0xB4, 0xD3, 0x75, 0xF3, 0x44, 0xE7, 0x13, 0x05, 0xC6, 0xC5, 0xA4, 0xD2, 0x6B, 0x18, 0x31, 0x9F, 0xBE, 0x42, 0x45, 0x82, 0x2E, 0x47, 0x9B, 0x26, 0x73, 0x28, 0xD7, 0x9A, 0x64, 0xA6, 0x3D, 0x38, 0x9C, 0x11, 0x36, 0x01, 0x5B, 0x82, 0x2F, 0x7E, 0xA8, 0xC4, 0x82, 0x15, 0x6C, 0x0B, 0xBA, 0x1C, 0x58, 0xF5, 0x81, 0xF9, 0x45, 0xA9, 0xC6, 0x05, 0x6A, 0x2C, 0xA6, 0xCF, 0xF5, 0xDF, 0xEB, 0xBB, 0xC0, 0x92, 0xE3, 0xA6, 0x9D, 0x23, 0x09, 0x09, 0x0E, 0x98, 0x39 +}; + +static const unsigned char App_sdk1_AcexData[0x400] = +{ + 0x05, 0x90, 0xAF, 0x65, 0x16, 0x9F, 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00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x50, 0x54, 0x3A, 0x55, 0x00, 0x00, 0x00, 0x24, 0x68, 0x69, 0x6F, 0x46, 0x49, 0x4F, 0x00, 0x24, 0x68, 0x6F, 0x73, 0x74, 0x69, 0x6F, 0x30, 0x24, 0x68, 0x6F, 0x73, 0x74, 0x69, 0x6F, 0x31, 0x61, 0x63, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x00, 0x62, 0x6F, 0x73, 0x73, 0x3A, 0x55, 0x00, 0x00, 0x63, 0x61, 0x6D, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x63, 0x65, 0x63, 0x64, 0x3A, 0x75, 0x00, 0x00, 0x63, 0x66, 0x67, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x64, 0x6C, 0x70, 0x3A, 0x46, 0x4B, 0x43, 0x4C, 0x64, 0x6C, 0x70, 0x3A, 0x53, 0x52, 0x56, 0x52, 0x64, 0x73, 0x70, 0x3A, 0x3A, 0x44, 0x53, 0x50, 0x66, 0x72, 0x64, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x66, 0x73, 0x3A, 0x55, 0x53, 0x45, 0x52, 0x00, 0x67, 0x73, 0x70, 0x3A, 0x3A, 0x47, 0x70, 0x75, 0x68, 0x69, 0x64, 0x3A, 0x55, 0x53, 0x45, 0x52, 0x68, 0x74, 0x74, 0x70, 0x3A, 0x43, 0x00, 0x00, 0x6D, 0x69, 0x63, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x6E, 0x64, 0x6D, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x6E, 0x65, 0x77, 0x73, 0x3A, 0x75, 0x00, 0x00, 0x6E, 0x77, 0x6D, 0x3A, 0x3A, 0x55, 0x44, 0x53, 0x70, 0x74, 0x6D, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x70, 0x78, 0x69, 0x3A, 0x64, 0x65, 0x76, 0x00, 0x73, 0x6F, 0x63, 0x3A, 0x55, 0x00, 0x00, 0x00, 0x73, 0x73, 0x6C, 0x3A, 0x43, 0x00, 0x00, 0x00, 0x79, 0x32, 0x72, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x69, 0x72, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFB, 0xF0, 0xFF, 0xBF, 0xFF, 0xF1, 0xE7, 0x3F, 0x00, 0xF2, 0x00, 0xF0, 0x91, 0xFF, 0x00, 0xF6, 0x91, 0xFF, 0x50, 0xFF, 0x81, 0xFF, 0x58, 0xFF, 0x81, 0xFF, 0x70, 0xFF, 0x81, 0xFF, 0x78, 0xFF, 0x81, 0xFF, 0x01, 0x01, 0x00, 0xFF, 0x00, 0x02, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 +}; + +// DLP +static const unsigned char Dlp_sdk1_HdrPubK[0x100] = +{ + 0xD9, 0xF0, 0xC9, 0x35, 0x1E, 0x55, 0xD8, 0x7E, 0x96, 0x53, 0x33, 0x34, 0xBB, 0x8A, 0xAE, 0x03, 0x92, 0x35, 0xE2, 0x05, 0x58, 0x7C, 0xCC, 0x08, 0xB2, 0xDF, 0x43, 0x41, 0xB7, 0x7A, 0xB5, 0x29, 0xEE, 0x4E, 0xF3, 0xC7, 0x35, 0x3B, 0x7E, 0xC5, 0xEE, 0x74, 0xF0, 0xAA, 0x7E, 0x60, 0xF1, 0x28, 0x35, 0x17, 0xD6, 0xC9, 0x9A, 0xF2, 0x84, 0xFE, 0xC8, 0x93, 0x86, 0xF7, 0xA7, 0x36, 0xA6, 0xB0, 0x28, 0xDC, 0xE8, 0x38, 0x0B, 0x54, 0x42, 0x8D, 0x4E, 0x4B, 0x55, 0x0F, 0x4A, 0x0D, 0x72, 0xA0, 0x23, 0xC9, 0x68, 0x22, 0x37, 0x31, 0x88, 0x2C, 0x05, 0x49, 0x86, 0x80, 0x9A, 0xFC, 0x1D, 0x02, 0xE3, 0x20, 0x15, 0x0C, 0x7E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 0x2C, 0x29, 0x0D, 0xC1, 0x3D, 0x10, 0x65, 0x1E, 0xF1, 0x95, 0xE5, 0xF6, 0x45, 0x15, 0xBF, 0xE2, 0x30, 0xA6, 0x70, 0x19, 0xA4, 0x11, 0x57, 0x12, 0x1C, 0x81, 0x4B, 0x54, 0x04, 0xBE, 0x67, 0xF5, 0x00, 0x22, 0x06, 0xDA, 0x6B, 0xCE, 0x23, 0x3F, 0x86, 0xE4, 0x70, 0x6A, 0xD1, 0x3E, 0xE5, 0x74, 0x44, 0x86, 0xDA, 0xBE, 0x79 +}; + +static const unsigned char Dlp_sdk1_AcexData[0x400] = +{ + 0x13, 0xB2, 0xF4, 0x89, 0xBB, 0xB4, 0xFF, 0x55, 0x7E, 0x3E, 0x9B, 0x90, 0x44, 0x45, 0xC6, 0x8A, 0x17, 0x32, 0x91, 0x77, 0x7D, 0xCB, 0x4A, 0x26, 0x3D, 0xCA, 0xD8, 0x6E, 0x72, 0x27, 0x93, 0x9C, 0xE4, 0x27, 0xFE, 0x54, 0xDC, 0xE7, 0xDC, 0x02, 0x17, 0x9C, 0x82, 0xA8, 0xB0, 0xE8, 0x69, 0x07, 0xE3, 0x34, 0x0E, 0xBF, 0x17, 0x05, 0x58, 0x23, 0x5F, 0x6D, 0xDA, 0xE8, 0xC6, 0xEE, 0x49, 0x29, 0xEF, 0xD7, 0x48, 0x48, 0x41, 0xE2, 0x2A, 0x57, 0x2B, 0x21, 0x13, 0x64, 0xD4, 0x79, 0x5A, 0xE3, 0x84, 0xDA, 0x63, 0x9A, 0x07, 0x39, 0xE2, 0x7E, 0xA7, 0x56, 0x34, 0x1C, 0xE2, 0xAF, 0xCD, 0x65, 0xD1, 0xC0, 0x1B, 0x72, 0xB1, 0x1D, 0xFC, 0xE2, 0x6E, 0x0F, 0xC7, 0xB0, 0xF5, 0x84, 0x0F, 0xA5, 0x2B, 0xDF, 0x3A, 0xCF, 0x43, 0xE8, 0xE4, 0x07, 0x29, 0xC6, 0x41, 0x0E, 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15, 0x1E, 0x84, 0x00, 0xE3, 0x80, 0xD7, 0x89, 0x56, 0xEE, 0x60, 0x09, 0x1F, 0xD3, 0xBF, 0xBF, 0x50, 0x8F, 0xA3, 0x0C, 0x72, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x50, 0x54, 0x3A, 0x55, 0x00, 0x00, 0x00, 0x24, 0x68, 0x69, 0x6F, 0x46, 0x49, 0x4F, 0x00, 0x24, 0x68, 0x6F, 0x73, 0x74, 0x69, 0x6F, 0x30, 0x24, 0x68, 0x6F, 0x73, 0x74, 0x69, 0x6F, 0x31, 0x61, 0x63, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x00, 0x62, 0x6F, 0x73, 0x73, 0x3A, 0x55, 0x00, 0x00, 0x63, 0x61, 0x6D, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x63, 0x65, 0x63, 0x64, 0x3A, 0x75, 0x00, 0x00, 0x63, 0x66, 0x67, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x64, 0x6C, 0x70, 0x3A, 0x46, 0x4B, 0x43, 0x4C, 0x64, 0x6C, 0x70, 0x3A, 0x53, 0x52, 0x56, 0x52, 0x64, 0x73, 0x70, 0x3A, 0x3A, 0x44, 0x53, 0x50, 0x66, 0x72, 0x64, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x66, 0x73, 0x3A, 0x55, 0x53, 0x45, 0x52, 0x00, 0x67, 0x73, 0x70, 0x3A, 0x3A, 0x47, 0x70, 0x75, 0x68, 0x69, 0x64, 0x3A, 0x55, 0x53, 0x45, 0x52, 0x68, 0x74, 0x74, 0x70, 0x3A, 0x43, 0x00, 0x00, 0x6D, 0x69, 0x63, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x6E, 0x64, 0x6D, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x6E, 0x65, 0x77, 0x73, 0x3A, 0x75, 0x00, 0x00, 0x6E, 0x77, 0x6D, 0x3A, 0x3A, 0x55, 0x44, 0x53, 0x70, 0x74, 0x6D, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x70, 0x78, 0x69, 0x3A, 0x64, 0x65, 0x76, 0x00, 0x73, 0x6F, 0x63, 0x3A, 0x55, 0x00, 0x00, 0x00, 0x73, 0x73, 0x6C, 0x3A, 0x43, 0x00, 0x00, 0x00, 0x79, 0x32, 0x72, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x69, 0x72, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFB, 0xF0, 0xFF, 0xBF, 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0xB9, 0x17, 0xE0, 0x22, 0xCF, 0xB5, 0x00, 0x77, 0x2E, 0x31, 0xAD, 0xF7, 0xE5, 0xAD, 0x98, 0x14, 0xDF, 0x19, 0xF0, 0xC9, 0xBE, 0x37, 0xF6, 0xF0, 0x23, 0x66, 0xCF, 0x34, 0xE3, 0xD5, 0x8F, 0xD4, 0x07, 0xBA, 0x06, 0x56, 0x00, 0x66, 0x9A, 0xEB, 0x93 +}; + +static const unsigned char App_sdk2_HdrPrivK[0x100] = +{ + 0xBC, 0x49, 0x29, 0xB9, 0x01, 0x52, 0x31, 0x76, 0x4C, 0xBA, 0xB1, 0x29, 0x91, 0x77, 0x29, 0xF2, 0x54, 0xE4, 0x6C, 0xB5, 0x68, 0xE1, 0xF0, 0x28, 0xDB, 0x8E, 0x54, 0xA8, 0xB1, 0xA3, 0xBE, 0x3F, 0xCA, 0xCA, 0x95, 0x9D, 0x4E, 0x12, 0xD7, 0x77, 0x6F, 0xB0, 0x9D, 0x85, 0x91, 0x5D, 0x29, 0x3A, 0x54, 0x3A, 0xD6, 0xEE, 0x11, 0xE5, 0xDF, 0xEF, 0xEA, 0x45, 0xD3, 0xFE, 0x58, 0x03, 0x7B, 0xE4, 0x7B, 0x19, 0x75, 0x02, 0xFE, 0xDE, 0xFF, 0x8C, 0x28, 0x33, 0xFE, 0x10, 0x11, 0xD4, 0xCD, 0x13, 0x05, 0x26, 0x85, 0xC3, 0xA8, 0x8A, 0x7A, 0x8A, 0x77, 0x1D, 0x49, 0x25, 0x11, 0x34, 0xB0, 0xBF, 0x45, 0x56, 0xCE, 0x42, 0x2E, 0x1B, 0x5C, 0xC4, 0xDD, 0x71, 0xA0, 0x01, 0x50, 0x73, 0x21, 0xFF, 0x5D, 0x54, 0x6D, 0xDD, 0x3F, 0x14, 0x49, 0x4D, 0x44, 0x46, 0x12, 0x88, 0xD5, 0x92, 0xAE, 0xE2, 0xD0, 0xF6, 0x2C, 0x10, 0xD5, 0x67, 0x61, 0x87, 0x7F,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0x90, 0xB8, 0x37, 0x33, 0xFC, 0x73, 0xD6, 0x19, 0x11, 0xCA, 0x83, 0x2A, 0x58, 0x62, 0x9C, 0xB1, 0x83, 0x43, 0x1D, 0x2C, 0x00, 0xA2, 0xE5, 0x87, 0x97, 0x12, 0x63, 0x31, 0x83, 0x0E, 0xB1, 0x1E, 0x69, 0x99, 0x02, 0xAF, 0xDF, 0xFF, 0x0F, 0xA9, 0x7C, 0x1B, 0x33, 0x9E, 0xFF, 0x9C, 0x14, 0x19, 0xA6, 0xCA, 0xFD, 0xB9, 0x17, 0xE0, 0x22, 0xCF, 0xB5, 0x00, 0x77, 0x2E, 0x31, 0xAD, 0xF7, 0xE5, 0xAD, 0x98, 0x14, 0xDF, 0x19, 0xF0, 0xC9, 0xBE, 0x37, 0xF6, 0xF0, 0x23, 0x66, 0xCF, 0x34, 0xE3, 0xD5, 0x8F, 0xD4, 0x07, 0xBA, 0x06, 0x56, 0x00, 0x66, 0x9A, 0xEB, 0x93, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x50, 0x54, 0x3A, 0x55, 0x00, 0x00, 0x00, 0x24, 0x68, 0x69, 0x6F, 0x46, 0x49, 0x4F, 0x00, 0x24, 0x68, 0x6F, 0x73, 0x74, 0x69, 0x6F, 0x30, 0x24, 0x68, 0x6F, 0x73, 0x74, 0x69, 0x6F, 0x31, 0x61, 0x63, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x00, 0x62, 0x6F, 0x73, 0x73, 0x3A, 0x55, 0x00, 0x00, 0x63, 0x61, 0x6D, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x63, 0x65, 0x63, 0x64, 0x3A, 0x75, 0x00, 0x00, 0x63, 0x66, 0x67, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x64, 0x6C, 0x70, 0x3A, 0x46, 0x4B, 0x43, 0x4C, 0x64, 0x6C, 0x70, 0x3A, 0x53, 0x52, 0x56, 0x52, 0x64, 0x73, 0x70, 0x3A, 0x3A, 0x44, 0x53, 0x50, 0x66, 0x72, 0x64, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x66, 0x73, 0x3A, 0x55, 0x53, 0x45, 0x52, 0x00, 0x67, 0x73, 0x70, 0x3A, 0x3A, 0x47, 0x70, 0x75, 0x68, 0x69, 0x64, 0x3A, 0x55, 0x53, 0x45, 0x52, 0x68, 0x74, 0x74, 0x70, 0x3A, 0x43, 0x00, 0x00, 0x6D, 0x69, 0x63, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x6E, 0x64, 0x6D, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x6E, 0x65, 0x77, 0x73, 0x3A, 0x75, 0x00, 0x00, 0x6E, 0x77, 0x6D, 0x3A, 0x3A, 0x55, 0x44, 0x53, 0x70, 0x74, 0x6D, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x70, 0x78, 0x69, 0x3A, 0x64, 0x65, 0x76, 0x00, 0x73, 0x6F, 0x63, 0x3A, 0x55, 0x00, 0x00, 0x00, 0x73, 0x73, 0x6C, 0x3A, 0x43, 0x00, 0x00, 0x00, 0x79, 0x32, 0x72, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x69, 0x72, 0x3A, 0x55, 0x53, 0x45, 0x52, 0x00, 0x6C, 0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00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 +}; + +// DLP +static const unsigned char Dlp_sdk2_HdrPubK[0x100] = +{ + 0xB9, 0xDE, 0x3D, 0xC0, 0x55, 0xB9, 0xCC, 0x3F, 0x55, 0xE0, 0x61, 0x1D, 0x6F, 0xCF, 0x3E, 0x7F, 0xE2, 0xF7, 0xF5, 0xAD, 0x5C, 0x02, 0x7F, 0x17, 0x5B, 0x44, 0x2F, 0x2D, 0xDC, 0xD4, 0xA6, 0x63, 0xD2, 0xA7, 0x82, 0xD3, 0x00, 0x77, 0xC8, 0x0B, 0x28, 0x09, 0x3D, 0x81, 0x86, 0x93, 0xF5, 0xF6, 0xE4, 0x69, 0x3B, 0x60, 0x4C, 0x7F, 0x8D, 0x72, 0xA3, 0x22, 0x42, 0x86, 0x87, 0x06, 0xD8, 0x29, 0x89, 0x8A, 0x9F, 0x5F, 0x6C, 0x06, 0x0C, 0x96, 0x84, 0x00, 0x24, 0x5D, 0x0B, 0xEA, 0x15, 0xEC, 0xAD, 0x90, 0xA4, 0x0C, 0x7B, 0xAE, 0x0E, 0x85, 0x3E, 0xA2, 0x20, 0x04, 0xE8, 0xD9, 0x59, 0x0F, 0x31, 0x0E, 0xD4, 0x5D, 0xC1, 0x18, 0xED, 0x0E, 0xB4, 0xD2, 0x5E, 0x65, 0xA2, 0x78, 0x0C, 0x76, 0x03, 0x3A, 0x71, 0x18, 0xE4, 0x38, 0x44, 0x14, 0xE0, 0x93, 0x84, 0xFE, 0x34, 0x82, 0xCA, 0x0B, 0xB8, 0xF2, 0x41, 0xAB, 0x63, 0xF3, 0xDE, 0xAE, 0xF4, 0x36, 0x81, 0xA4, 0x78, 0x7B, 0xF9, 0xA8, 0xFB, 0xC9, 0xA7, 0x6E, 0xA4, 0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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x50, 0x54, 0x3A, 0x55, 0x00, 0x00, 0x00, 0x24, 0x68, 0x69, 0x6F, 0x46, 0x49, 0x4F, 0x00, 0x24, 0x68, 0x6F, 0x73, 0x74, 0x69, 0x6F, 0x30, 0x24, 0x68, 0x6F, 0x73, 0x74, 0x69, 0x6F, 0x31, 0x61, 0x63, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x00, 0x62, 0x6F, 0x73, 0x73, 0x3A, 0x55, 0x00, 0x00, 0x63, 0x61, 0x6D, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x63, 0x65, 0x63, 0x64, 0x3A, 0x75, 0x00, 0x00, 0x63, 0x66, 0x67, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x64, 0x6C, 0x70, 0x3A, 0x46, 0x4B, 0x43, 0x4C, 0x64, 0x6C, 0x70, 0x3A, 0x53, 0x52, 0x56, 0x52, 0x64, 0x73, 0x70, 0x3A, 0x3A, 0x44, 0x53, 0x50, 0x66, 0x72, 0x64, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x66, 0x73, 0x3A, 0x55, 0x53, 0x45, 0x52, 0x00, 0x67, 0x73, 0x70, 0x3A, 0x3A, 0x47, 0x70, 0x75, 0x68, 0x69, 0x64, 0x3A, 0x55, 0x53, 0x45, 0x52, 0x68, 0x74, 0x74, 0x70, 0x3A, 0x43, 0x00, 0x00, 0x6D, 0x69, 0x63, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x6E, 0x64, 0x6D, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x6E, 0x65, 0x77, 0x73, 0x3A, 0x75, 0x00, 0x00, 0x6E, 0x77, 0x6D, 0x3A, 0x3A, 0x55, 0x44, 0x53, 0x70, 0x74, 0x6D, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x70, 0x78, 0x69, 0x3A, 0x64, 0x65, 0x76, 0x00, 0x73, 0x6F, 0x63, 0x3A, 0x55, 0x00, 0x00, 0x00, 0x73, 0x73, 0x6C, 0x3A, 0x43, 0x00, 0x00, 0x00, 0x79, 0x32, 0x72, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x69, 0x72, 0x3A, 0x55, 0x53, 0x45, 0x52, 0x00, 0x6C, 0x64, 0x72, 0x3A, 0x72, 0x6F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFB, 0xF0, 0xFF, 0xBF, 0xFF, 0xF1, 0xE7, 0x3F, 0x00, 0xF2, 0x00, 0xF0, 0x91, 0xFF, 0x00, 0xF6, 0x91, 0xFF, 0x50, 0xFF, 0x81, 0xFF, 0x58, 0xFF, 0x81, 0xFF, 0x70, 0xFF, 0x81, 0xFF, 0x78, 0xFF, 0x81, 0xFF, 0x01, 0x01, 0x00, 0xFF, 0x00, 0x02, 0x00, 0xFE, 0x1D, 0x02, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF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5D, 0xA5, 0x78, 0x32, 0xAD, 0x04, 0xDD, 0x96, 0x6E, 0xDC, 0x75, 0xFF, 0xC2, 0x2F, 0xFA, 0xA2, 0xEE, 0x46, 0x89, 0xCD, 0xAE, 0x69, 0x92, 0xA4, 0x48, 0xBC, 0x46, 0x47, 0xC4, 0x8C, 0x89, 0x63, 0xE1, 0x0A, 0x4D, 0x1C, 0xDC, 0x46, 0x2F, 0x5B, 0x70, 0x8A, 0x7C, 0xE9, 0x22, 0x9C, 0x09, 0x0B, 0xA8, 0x97, 0x40, 0xCA, 0x2A, 0x7D, 0x84, 0xA1, 0x04, 0x4A, 0x2E, 0xDB, 0xD7, 0xD0, 0x64, 0x43, 0x9C, 0xD0, 0x78, 0x11, 0x41, 0x88, 0x33, 0xDD, 0x31, 0x62, 0x90, 0x2D, 0x17, 0xF2, 0xC6, 0xA9, 0x2B, 0x9C, 0x70, 0xAB, 0xDC, 0xD3, 0xAB, 0x5D, 0xDA, 0xEE, 0x3D, 0x6C, 0x0E, 0x81, 0xFF, 0xF6, 0x67, 0x5A, 0x44, 0xF9, 0xAC, 0x07, 0x3D, 0x23, 0x94, 0x75, 0x65, 0x93, 0x20, 0x0C, 0xC5, 0x76, 0x1D, 0x0F, 0x65, 0x06, 0x3D, 0x21, 0xA2, 0xF0, 0x96, 0x80, 0xB7, 0x0A, 0x49, 0x53, 0x38, 0xA3, 0x5D, 0xC0, 0x74, 0x3C, 0xA4, 0xD9, 0x40, 0x36, 0x85, 0x1F, 0x8C, 0xD1, 0x2D, 0x15, 0xF9, 0xEF, 0x24, 0xA9, 0x7E, 0x9D, 0xB2, 0x1E, 0xF8, 0xA0, 0x72, 0x81, 0x17, 0x77, 0x73, 0xB1, 0x56, 0x7F, 0xAD, 0x05, 0xA2, 0xD2, 0x30, 0x5A, 0xF5, 0xD3, 0xAF, 0x0F, 0x10, 0x4A, 0x52, 0xD8, 0x09, 0x47, 0x97 }; -static const unsigned char App_HdrPrivK[0x100] = +static const unsigned char App_sd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 0x54, 0x71, 0x1C, 0xF4, 0x82, 0xC0, 0x66, 0x74, 0xEA, 0x9C, 0x83, 0x3C, 0x27, 0x01, 0xDF, 0x6F, 0x56, 0xA8, 0x1B, 0xE3, 0x68, 0x55, 0x9F, 0xAB, 0x90, 0x67, 0x20, 0x25, 0xFA, 0x3D, 0x51, 0x2A, 0x23, 0x16, 0xCB, 0x06, 0x5A, 0xAD, 0xAC, 0xC8, 0x47, 0xF9, 0x39, 0x2E, 0x6A, 0xF8, 0xFA, 0x0A, 0xE8, 0x8A, 0x64, 0x84, 0x6B, 0xED, 0xDA, 0x8F, 0x2A, 0x08, 0x86, 0x8F, 0x56, 0x69, 0x64, 0xC3, 0x98, 0x55, 0x37, 0x9A, 0x48, 0x40, 0xDA, 0xD5, 0x03, 0x21 }; -static const unsigned char App_AcexData[0x400] = +static const unsigned char App_sdk5_AcexData[0x400] = { 0xDF, 0x1C, 0x8B, 0x98, 0xE4, 0x6F, 0xA2, 0x35, 0x6C, 0xC3, 0x18, 0x17, 0x98, 0xF3, 0xCE, 0x54, 0x7E, 0x14, 0x2E, 0x7F, 0x1E, 0xD8, 0x6D, 0xCF, 0xBC, 0x29, 0x4E, 0xFE, 0x32, 0x2E, 0xC1, 0x11, 0xAD, 0x46, 0x9A, 0xC6, 0x70, 0xEA, 0xEE, 0x28, 0x55, 0x22, 0xE1, 0x36, 0x05, 0x1C, 0x04, 0x8A, 0xCE, 0x0F, 0x0C, 0x83, 0x8F, 0xC8, 0xD6, 0xDE, 0x11, 0x8E, 0xEA, 0xCF, 0xAD, 0x9B, 0xCF, 0x81, 0x0D, 0xEB, 0x71, 0x13, 0xB3, 0xD3, 0xAE, 0x83, 0x02, 0x4C, 0x0E, 0x10, 0x50, 0x59, 0x3C, 0xEE, 0x60, 0x06, 0xFB, 0x8C, 0x7F, 0xC2, 0x20, 0x24, 0x01, 0x62, 0x55, 0x87, 0x60, 0x0F, 0xAD, 0xFA, 0x73, 0x2E, 0xF6, 0x65, 0x62, 0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 0x3C, 0xA4, 0xD9, 0x40, 0x36, 0x85, 0x1F, 0x8C, 0xD1, 0x2D, 0x15, 0xF9, 0xEF, 0x24, 0xA9, 0x7E, 0x9D, 0xB2, 0x1E, 0xF8, 0xA0, 0x72, 0x81, 0x17, 0x77, 0x73, 0xB1, 0x56, 0x7F, 0xAD, 0x05, 0xA2, 0xD2, 0x30, 0x5A, 0xF5, 0xD3, 0xAF, 0x0F, 0x10, 0x4A, 0x52, 0xD8, 0x09, 0x47, 0x97, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x18, 0x9E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x50, 0x54, 0x3A, 0x55, 0x00, 0x00, 0x00, 0x24, 0x68, 0x69, 0x6F, 0x46, 0x49, 0x4F, 0x00, 0x24, 0x68, 0x6F, 0x73, 0x74, 0x69, 0x6F, 0x30, 0x24, 0x68, 0x6F, 0x73, 0x74, 0x69, 0x6F, 0x31, 0x61, 0x63, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x00, 0x62, 0x6F, 0x73, 0x73, 0x3A, 0x55, 0x00, 0x00, 0x63, 0x61, 0x6D, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x63, 0x65, 0x63, 0x64, 0x3A, 0x75, 0x00, 0x00, 0x63, 0x66, 0x67, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x64, 0x6C, 0x70, 0x3A, 0x46, 0x4B, 0x43, 0x4C, 0x64, 0x6C, 0x70, 0x3A, 0x53, 0x52, 0x56, 0x52, 0x64, 0x73, 0x70, 0x3A, 0x3A, 0x44, 0x53, 0x50, 0x66, 0x72, 0x64, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x66, 0x73, 0x3A, 0x55, 0x53, 0x45, 0x52, 0x00, 0x67, 0x73, 0x70, 0x3A, 0x3A, 0x47, 0x70, 0x75, 0x68, 0x69, 0x64, 0x3A, 0x55, 0x53, 0x45, 0x52, 0x68, 0x74, 0x74, 0x70, 0x3A, 0x43, 0x00, 0x00, 0x6D, 0x69, 0x63, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x6E, 0x64, 0x6D, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x6E, 0x65, 0x77, 0x73, 0x3A, 0x75, 0x00, 0x00, 0x6E, 0x77, 0x6D, 0x3A, 0x3A, 0x55, 0x44, 0x53, 0x70, 0x74, 0x6D, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x70, 0x78, 0x69, 0x3A, 0x64, 0x65, 0x76, 0x00, 0x73, 0x6F, 0x63, 0x3A, 0x55, 0x00, 0x00, 0x00, 0x73, 0x73, 0x6C, 0x3A, 0x43, 0x00, 0x00, 0x00, 0x79, 0x32, 0x72, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x6C, 0x64, 0x72, 0x3A, 0x72, 0x6F, 0x00, 0x00, 0x69, 0x72, 0x3A, 0x55, 0x53, 0x45, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4E, 0x9F, 0xFA, 0xF0, 0xFF, 0xBF, 0xFF, 0xF1, 0xE7, 0x3F, 0x00, 0xF2, 0x00, 0xF0, 0x91, 0xFF, 0x00, 0xF6, 0x91, 0xFF, 0x50, 0xFF, 0x81, 0xFF, 0x58, 0xFF, 0x81, 0xFF, 0x70, 0xFF, 0x81, 0xFF, 0x78, 0xFF, 0x81, 0xFF, 0x01, 0x01, 0x00, 0xFF, 0x00, 0x02, 0x00, 0xFE, 0x21, 0x02, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }; // DEMO -static const unsigned char Demo_HdrPubK[0x100] = +static const unsigned char Demo_sdk5_HdrPubK[0x100] = { 0xB5, 0x11, 0x8D, 0x9E, 0x2D, 0xDB, 0x70, 0x6D, 0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 0x5C, 0xB8, 0xEC, 0xBE, 0xFC, 0xD9, 0x98, 0x6A, 0x08, 0xD0, 0x5C, 0x4D, 0x78, 0x2D, 0x4D, 0x07, 0xAD, 0x5E, 0xB8, 0x51, 0x40, 0xE2, 0x2A, 0x7F, 0xB1, 0x54, 0x47, 0x5C, 0x99, 0x12, 0xC2, 0x6D, 0x5E, 0xED, 0x25, 0x30, 0x6A, 0x99, 0xC5, 0x0D, 0x65, 0x83, 0x68, 0x3A, 0xFD, 0x82, 0x59, 0x0D, 0xCE, 0x0B, 0x49, 0xBE, 0x17, 0x46, 0x51, 0xA9, 0xB6, 0x54, 0xE1, 0x18, 0xBD, 0x49, 0xE6, 0x7F }; -static const unsigned char Demo_HdrPrivK[0x100] = +static const unsigned char Demo_sdk5_HdrPrivK[0x100] = { 0x1D, 0x7B, 0x79, 0x32, 0xAB, 0x46, 0xD2, 0xBC, 0x8E, 0xD6, 0x7F, 0x8F, 0x3A, 0x85, 0xAD, 0xA5, 0x8B, 0xA9, 0x0D, 0xA9, 0xDA, 0x0F, 0xEF, 0x61, 0x04, 0xBA, 0x35, 0x39, 0x36, 0x03, 0xD8, 0x68, 0x5F, 0x9F, 0x2F, 0xD6, 0xF6, 0x38, 0x96, 0xFD, 0xE7, 0xEA, 0x89, 0xD8, 0x7F, 0x7E, 0xC5, 0x29, 0x2F, 0xD9, 0x3B, 0x02, 0xE7, 0x1F, 0xBD, 0x63, 0x9C, 0x21, 0xD8, 0xFF, 0x43, 0x8A, 0x74, 0xCD, 0x3D, 0x4C, 0x09, 0xEE, 0xDB, 0xE0, 0xBE, 0x03, 0xD1, 0x92, 0xD7, 0x22, 0x35, 0x5A, 0x8C, 0xCE, 0xBE, 0x2B, 0xB4, 0x81, 0x47, 0x3F, 0x45, 0x75, 0x33, 0x31, 0x6B, 0xFF, 0x43, 0x5D, 0x17, 0x43, 0xAE, 0xD1, 0x25, 0xF7, 0xD9, 0xD5, 0x5C, 0xB6, 0x92, 0x5C, 0xB3, 0xF3, 0xF7, 0x65, 0x9F, 0x4C, 0x05, 0x12, 0xEC, 0xA8, 0x6D, 0x70, 0x65, 0x57, 0x6C, 0xD8, 0xE3, 0xD6, 0xFA, 0xC1, 0xFD, 0x54, 0xE8, 0x34, 0x67, 0x4D, 0x0A, 0x14, 0x2F, 0xA3, 0xD4, 0x81, 0x8C, 0xC3, 0xD0, 0x8B, 0x09, 0x08, 0x90, 0x70, 0x68, 0xA0, 0x0E, 0xD1, 0x0B, 0xAA, 0x71, 0xEC, 0x9A, 0x1A, 0x83, 0xFF, 0xA1, 0x70, 0xEB, 0xAC, 0xF2, 0xE9, 0x80, 0xA1, 0xB8, 0x20, 0x31, 0x83, 0xF5, 0x37, 0x01, 0x72, 0x06, 0x50, 0x05, 0x3F, 0x14, 0xF9, 0x29, 0x48, 0x84, 0xA0, 0x0E, 0xF7, 0xB8, 0x1D, 0xA3, 0x36, 0x5A, 0x78, 0x6D, 0x83, 0x90, 0x27, 0xE3, 0x50, 0x49, 0x2F, 0x65, 0xE5, 0x61, 0xED, 0x65, 0xBE, 0xEA, 0x34, 0xA6, 0x6A, 0xEF, 0x49, 0xB4, 0xE0, 0xBC, 0xC2, 0xA5, 0xB8, 0xEB, 0xA9, 0x2F, 0xBA, 0x26, 0x76, 0xB2, 0x5A, 0x3A, 0x3B, 0xFD, 0xAD, 0xFB, 0xE4, 0x79, 0xE2, 0x85, 0x54, 0x5B, 0xAB, 0x1F, 0x0A, 0xE5, 0x8B, 0x77, 0x3A, 0x10, 0x98, 0x26, 0x74, 0xC8, 0xB0, 0x82, 0xB1, 0xF9, 0x8F, 0x68, 0x59 }; -static const unsigned char Demo_AcexData[0x400] = +static const unsigned char Demo_sdk5_AcexData[0x400] = { 0xD3, 0x7D, 0x42, 0xBA, 0x6A, 0x1E, 0xD8, 0x07, 0x3C, 0x4A, 0xC4, 0xCD, 0x8C, 0x68, 0x3D, 0xCD, 0xCD, 0xBD, 0x9D, 0xCE, 0xB5, 0x2A, 0xF9, 0x63,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 0xCA, 0x97, 0xA1, 0xE5, 0xCE, 0x72, 0x63, 0xCF, 0x74, 0xD0, 0x20, 0xD9, 0xDE, 0x3F, 0xBB, 0x11, 0xF9, 0x21, 0xAB, 0x3F, 0x54, 0x41, 0xA7, 0xAA, 0xCA, 0xFC, 0xE1, 0x1A, 0x8C, 0x12, 0xC9, 0x39, 0x13, 0x5A, 0x81, 0x29, 0x49, 0xE8, 0xFB, 0x48, 0xC9, 0x4D, 0x50, 0x87, 0xAE, 0x51, 0xFB, 0x94, 0xFC, 0xF0, 0x9C, 0x70, 0x1C, 0xE8, 0x6E, 0x44, 0x53, 0x1E, 0x2F, 0x27, 0x5C, 0xB8, 0xEC, 0xBE, 0xFC, 0xD9, 0x98, 0x6A, 0x08, 0xD0, 0x5C, 0x4D, 0x78, 0x2D, 0x4D, 0x07, 0xAD, 0x5E, 0xB8, 0x51, 0x40, 0xE2, 0x2A, 0x7F, 0xB1, 0x54, 0x47, 0x5C, 0x99, 0x12, 0xC2, 0x6D, 0x5E, 0xED, 0x25, 0x30, 0x6A, 0x99, 0xC5, 0x0D, 0x65, 0x83, 0x68, 0x3A, 0xFD, 0x82, 0x59, 0x0D, 0xCE, 0x0B, 0x49, 0xBE, 0x17, 0x46, 0x51, 0xA9, 0xB6, 0x54, 0xE1, 0x18, 0xBD, 0x49, 0xE6, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0x02, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x18, 0x9E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x50, 0x54, 0x3A, 0x55, 0x00, 0x00, 0x00, 0x24, 0x68, 0x69, 0x6F, 0x46, 0x49, 0x4F, 0x00, 0x24, 0x68, 0x6F, 0x73, 0x74, 0x69, 0x6F, 0x30, 0x24, 0x68, 0x6F, 0x73, 0x74, 0x69, 0x6F, 0x31, 0x61, 0x63, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x00, 0x62, 0x6F, 0x73, 0x73, 0x3A, 0x55, 0x00, 0x00, 0x63, 0x61, 0x6D, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x63, 0x65, 0x63, 0x64, 0x3A, 0x75, 0x00, 0x00, 0x63, 0x66, 0x67, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x64, 0x6C, 0x70, 0x3A, 0x46, 0x4B, 0x43, 0x4C, 0x64, 0x6C, 0x70, 0x3A, 0x53, 0x52, 0x56, 0x52, 0x64, 0x73, 0x70, 0x3A, 0x3A, 0x44, 0x53, 0x50, 0x66, 0x72, 0x64, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x66, 0x73, 0x3A, 0x55, 0x53, 0x45, 0x52, 0x00, 0x67, 0x73, 0x70, 0x3A, 0x3A, 0x47, 0x70, 0x75, 0x68, 0x69, 0x64, 0x3A, 0x55, 0x53, 0x45, 0x52, 0x68, 0x74, 0x74, 0x70, 0x3A, 0x43, 0x00, 0x00, 0x6D, 0x69, 0x63, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x6E, 0x64, 0x6D, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x6E, 0x65, 0x77, 0x73, 0x3A, 0x75, 0x00, 0x00, 0x6E, 0x77, 0x6D, 0x3A, 0x3A, 0x55, 0x44, 0x53, 0x70, 0x74, 0x6D, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x70, 0x78, 0x69, 0x3A, 0x64, 0x65, 0x76, 0x00, 0x73, 0x6F, 0x63, 0x3A, 0x55, 0x00, 0x00, 0x00, 0x73, 0x73, 0x6C, 0x3A, 0x43, 0x00, 0x00, 0x00, 0x79, 0x32, 0x72, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x6C, 0x64, 0x72, 0x3A, 0x72, 0x6F, 0x00, 0x00, 0x69, 0x72, 0x3A, 0x55, 0x53, 0x45, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4E, 0x9F, 0xFA, 0xF0, 0xFF, 0xBF, 0xFF, 0xF1, 0xE7, 0x3F, 0x00, 0xF2, 0x00, 0xF0, 0x91, 0xFF, 0x00, 0xF6, 0x91, 0xFF, 0x50, 0xFF, 0x81, 0xFF, 0x58, 0xFF, 0x81, 0xFF, 0x70, 0xFF, 0x81, 0xFF, 0x78, 0xFF, 0x81, 0xFF, 0x01, 0x01, 0x00, 0xFF, 0x00, 0x02, 0x00, 0xFE, 0x21, 0x02, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }; // DLP -static const unsigned char Dlp_HdrPubK[0x100] = +static const unsigned char Dlp_sdk5_HdrPubK[0x100] = { 0xB3, 0x16, 0x68, 0xF1, 0xED, 0x59, 0xC8, 0x7F, 0xC6, 0x50, 0x21, 0xFE, 0x36, 0x7C, 0x55, 0xE7, 0x07, 0xF9, 0x1D, 0x1B, 0xF5, 0xB1, 0x2A, 0x6B, 0x3A, 0xDE, 0x2D, 0x4C, 0x51, 0xCD, 0x4C, 0x9F, 0xEE, 0x1D, 0xE4, 0xE8, 0xF0, 0xFD, 0x09, 0x8E, 0x0F, 0x92, 0x5F, 0xDB, 0x9C, 0x5C, 0x15, 0x55, 0x1A, 0x4D, 0x04, 0x8C, 0xB0, 0xA4, 0x88, 0x97, 0xC4, 0xD5, 0x92, 0x04, 0x42, 0x33, 0x84, 0x81, 0x06, 0xD6, 0xF2, 0x17, 0xDE, 0x83, 0x17, 0x50, 0xD0, 0x47, 0x61, 0x14, 0x0D, 0xB7, 0xC7, 0xA0, 0xC1, 0x8B, 0x82, 0x47, 0x13, 0xEE, 0x76, 0xA2, 0xA3, 0x8D, 0xCE, 0x55, 0xC1, 0xF3, 0x7A, 0xEA, 0x91, 0xE1, 0xB9, 0x2F, 0x8F, 0x9B, 0xC3, 0x7B, 0x51, 0x2F, 0xE7, 0xAD, 0x93, 0x9C, 0xFD, 0xDF, 0x19, 0xC8, 0x6C, 0x24, 0xC2, 0xE2, 0x91, 0x97, 0x1F, 0xEB, 0x4B, 0xD4, 0x46, 0x6C, 0x06, 0x93, 0xAF, 0xF5, 0x5E, 0x8F, 0x77, 0x25, 0xC4, 0x28, 0xC0, 0x82, 0x4A, 0x78, 0xE9, 0x14, 0x08, 0xC3, 0xC3, 0x58, 0x24, 0x44, 0x2D, 0x2B, 0xA7, 0xEE, 0x28, 0xEF, 0x1B, 0x6D, 0xAA, 0x9C, 0xED, 0x7F, 0x35, 0xCE, 0x86, 0x5C, 0x6B, 0x8A, 0x23, 0xD3, 0x9D, 0x05, 0x8F, 0xD2, 0x41, 0x93, 0x1D, 0x1D, 0x7E, 0xB0, 0x46, 0x23, 0x63, 0x07, 0xEA, 0x5F, 0x26, 0xE3, 0x81, 0x27, 0xB3, 0x95, 0xB1, 0x93, 0x59, 0xD4, 0x1A, 0xB8, 0x73, 0xD0, 0x09, 0x95, 0x2B, 0xE8, 0x8B, 0xE2, 0x73, 0x5F, 0x34, 0xB9, 0x98, 0x82, 0xF0, 0x11, 0xC6, 0x8F, 0x12, 0x4D, 0x09, 0x57, 0x10, 0x97, 0x22, 0x0E, 0xC8, 0x7D, 0x40, 0xC1, 0x9D, 0x12, 0x1F, 0x71, 0xFE, 0x1E, 0x1A, 0x8C, 0x3F, 0x56, 0xAC, 0x43, 0xC3, 0x66, 0x0C, 0x81, 0xAE, 0xC1, 0x8F, 0x68, 0xFF, 0x87, 0x07, 0x3C, 0xCD, 0x0A, 0x23, 0xDE, 0xBA, 0x9B }; -static const unsigned char Dlp_HdrPrivK[0x100] = +static const unsigned char Dlp_sdk5_HdrPrivK[0x100] = { 0x77, 0xC2, 0x7A, 0xB7, 0x9E, 0x13, 0xB6, 0x62, 0xCC, 0x09, 0x76, 0x51, 0xFB, 0xB9, 0xB5, 0xF0, 0x63, 0x82, 0x91, 0x96, 0xCA, 0xFC, 0x88, 0xF3, 0x60, 0x50, 0x87, 0x56, 0x4C, 0x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, 0xAC, 0x14, 0x85, 0x56, 0xC0, 0xFD, 0xD6, 0x01, 0xB3, 0x40, 0xA3, 0x1A, 0x32, 0x78, 0xA0, 0xDD, 0x21, 0x75, 0xBF, 0x24, 0xD2, 0x93, 0x85, 0xED, 0x22, 0xAD, 0x99, 0x91, 0x87, 0x4A, 0xEC, 0xC0, 0x6C, 0x71, 0x00, 0x76, 0x08, 0x23, 0xA2, 0xF3, 0xCF, 0x61 }; -static const unsigned char Dlp_AcexData[0x400] = +static const unsigned char Dlp_sdk5_AcexData[0x400] = { 0xAC, 0xE2, 0xA7, 0xC3, 0x00, 0xDE, 0xE8, 0xE9, 0xE0, 0x03, 0xB3, 0x54, 0x08, 0xA8, 0xF8, 0x3A, 0x2E, 0xD8, 0x10, 0x6B, 0xEC, 0xDC, 0x4E, 0xEE, 0x62, 0x10, 0x71, 0x49, 0xD4, 0x43, 0xB1, 0x0E, 0x6B, 0x8C, 0xD7, 0x54, 0xD5, 0x62, 0x28, 0x3F, 0xAA, 0xDE, 0xA9, 0x7D, 0xED, 0x37, 0x7C, 0xE7, 0x89, 0x0B, 0x02, 0xB2, 0x72, 0x4B, 0x17, 0xDB, 0xE2, 0xD3, 0x7C, 0x94, 0x12, 0x3F, 0x2E, 0xA1, 0x08, 0x99, 0xCC, 0x7F, 0x93, 0xE6, 0x38, 0xC9, 0x37, 0x84, 0xD7, 0x11, 0x9D, 0x02, 0x4D, 0x66, 0xB4, 0x70, 0x9F, 0xD8, 0xC6, 0xDD, 0xD5, 0x13, 0x52, 0xF0, 0xA6, 0x78, 0x8C, 0x8E, 0x15, 0xA0, 0xA1, 0xF3, 0xC4, 0xC3, 0x48, 0x45, 0xA5, 0xBE, 0xC9, 0x7A, 0x8B, 0xD3, 0x95, 0xA5, 0x4C, 0xF1, 0xB3, 0x0C, 0x6C, 0x76, 0xA7, 0x57, 0xA1, 0x77, 0xDF, 0x2F, 0xC8, 0x06, 0xA6, 0x0D, 0x1A, 0x09, 0xE4, 0x38, 0x64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C, 0x81, 0xAE, 0xC1, 0x8F, 0x68, 0xFF, 0x87, 0x07, 0x3C, 0xCD, 0x0A, 0x23, 0xDE, 0xBA, 0x9B, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x18, 0x9E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x50, 0x54, 0x3A, 0x55, 0x00, 0x00, 0x00, 0x24, 0x68, 0x69, 0x6F, 0x46, 0x49, 0x4F, 0x00, 0x24, 0x68, 0x6F, 0x73, 0x74, 0x69, 0x6F, 0x30, 0x24, 0x68, 0x6F, 0x73, 0x74, 0x69, 0x6F, 0x31, 0x61, 0x63, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x00, 0x62, 0x6F, 0x73, 0x73, 0x3A, 0x55, 0x00, 0x00, 0x63, 0x61, 0x6D, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x63, 0x65, 0x63, 0x64, 0x3A, 0x75, 0x00, 0x00, 0x63, 0x66, 0x67, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x64, 0x6C, 0x70, 0x3A, 0x46, 0x4B, 0x43, 0x4C, 0x64, 0x6C, 0x70, 0x3A, 0x53, 0x52, 0x56, 0x52, 0x64, 0x73, 0x70, 0x3A, 0x3A, 0x44, 0x53, 0x50, 0x66, 0x72, 0x64, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x66, 0x73, 0x3A, 0x55, 0x53, 0x45, 0x52, 0x00, 0x67, 0x73, 0x70, 0x3A, 0x3A, 0x47, 0x70, 0x75, 0x68, 0x69, 0x64, 0x3A, 0x55, 0x53, 0x45, 0x52, 0x68, 0x74, 0x74, 0x70, 0x3A, 0x43, 0x00, 0x00, 0x6D, 0x69, 0x63, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x6E, 0x64, 0x6D, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x6E, 0x65, 0x77, 0x73, 0x3A, 0x75, 0x00, 0x00, 0x6E, 0x77, 0x6D, 0x3A, 0x3A, 0x55, 0x44, 0x53, 0x70, 0x74, 0x6D, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x70, 0x78, 0x69, 0x3A, 0x64, 0x65, 0x76, 0x00, 0x73, 0x6F, 0x63, 0x3A, 0x55, 0x00, 0x00, 0x00, 0x73, 0x73, 0x6C, 0x3A, 0x43, 0x00, 0x00, 0x00, 0x79, 0x32, 0x72, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x6C, 0x64, 0x72, 0x3A, 0x72, 0x6F, 0x00, 0x00, 0x69, 0x72, 0x3A, 0x55, 0x53, 0x45, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4E, 0x9F, 0xFA, 0xF0, 0xFF, 0xBF, 0xFF, 0xF1, 0xE7, 0x3F, 0x00, 0xF2, 0x00, 0xF0, 0x91, 0xFF, 0x00, 0xF6, 0x91, 0xFF, 0x50, 0xFF, 0x81, 0xFF, 0x58, 0xFF, 0x81, 0xFF, 0x70, 0xFF, 0x81, 0xFF, 0x78, 0xFF, 0x81, 0xFF, 0x01, 0x01, 0x00, 0xFF, 0x00, 0x02, 0x00, 0xFE, 0x21, 0x02, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }; +/* SDK 7 (7.1.0) */ +// APP +static const unsigned char App_sdk7_HdrPubK[0x100] = +{ + 0x9B, 0x3B, 0x52, 0x2D, 0x61, 0xF5, 0x0D, 0x14, + 0x96, 0x09, 0x7A, 0x66, 0xC9, 0x86, 0x4C, 0x51, + 0x61, 0x7D, 0xF8, 0x9B, 0xFD, 0xB0, 0x3E, 0x44, + 0xC5, 0x0D, 0xC2, 0x6B, 0x6C, 0x66, 0x63, 0x3E, + 0xE7, 0xC8, 0x04, 0xCB, 0x06, 0xC8, 0x35, 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 0x41, 0x9D, 0xF4, 0x58, 0x90, 0x67, + 0xA8, 0x71, 0xD4, 0x09, 0x67, 0xF7, 0x55, 0xEF, + 0xD3, 0x7C, 0x7D, 0x2F, 0x76, 0x84, 0x70, 0x6E, + 0xAA, 0x75, 0x7D, 0xA9, 0x95, 0x42, 0xEF, 0x28, + 0x29, 0x48, 0xCD, 0x79, 0xA8, 0x16, 0xB6, 0xB5 +}; + +static const unsigned char App_sdk7_HdrPrivK[0x100] = +{ + +}; + +static const unsigned char App_sdk7_AcexData[0x400] = +{ + 0x06, 0xDD, 0x68, 0x17, 0xAA, 0x40, 0x3A, 0x75, + 0xD2, 0xCF, 0xA2, 0x5A, 0xC8, 0x1B, 0x74, 0x9D, + 0x91, 0xCD, 0x38, 0x4E, 0xCA, 0x19, 0x60, 0x8E, + 0x39, 0x71, 0x6C, 0xB9, 0xF9, 0x9F, 0x68, 0x44, + 0xCF, 0x33, 0x94, 0x54, 0x72, 0xCC, 0xC6, 0x33, + 0x96, 0x9F, 0x12, 0x07, 0xE9, 0x38, 0x87, 0x70, + 0x11, 0x51, 0xFD, 0xBF, 0xD9, 0x2D, 0xFA, 0x3F, + 0x70, 0x42, 0x75, 0x39, 0xE3, 0x97, 0x85, 0xAF, + 0x7B, 0xC5, 0x87, 0x9B, 0x0B, 0xF9, 0xE4, 0x1C, + 0xC5, 0x6B, 0x44, 0x2A, 0x10, 0x14, 0x86, 0xAA, + 0xFE, 0x9E, 0x5B, 0x1D, 0x15, 0xBA, 0x8C, 0x34, + 0xA2, 0xAF, 0x14, 0xD0, 0xD4, 0x0E, 0x7B, 0x3A, + 0xD5, 0x3C, 0x53, 0xDB, 0x7C, 0xBE, 0x44, 0x58, + 0x79, 0x42, 0x23, 0x3A, 0x77, 0xA3, 0x2C, 0xB9, + 0xEB, 0x62, 0x19, 0x94, 0x2B, 0xA0, 0x67, 0x94, + 0xC6, 0xB2, 0x90, 0xC6, 0x61, 0xFD, 0x43, 0xEC, + 0xEA, 0x27, 0x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, 0x7D, 0x2F, 0x76, 0x84, 0x70, 0x6E, + 0xAA, 0x75, 0x7D, 0xA9, 0x95, 0x42, 0xEF, 0x28, + 0x29, 0x48, 0xCD, 0x79, 0xA8, 0x16, 0xB6, 0xB5, + 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x04, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x18, + 0x9E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x88, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x24, 0x68, 0x69, 0x6F, 0x46, 0x49, 0x4F, 0x00, + 0x24, 0x68, 0x6F, 0x73, 0x74, 0x69, 0x6F, 0x30, + 0x24, 0x68, 0x6F, 0x73, 0x74, 0x69, 0x6F, 0x31, + 0x63, 0x66, 0x67, 0x3A, 0x75, 0x00, 0x00, 0x00, + 0x66, 0x73, 0x3A, 0x55, 0x53, 0x45, 0x52, 0x00, + 0x67, 0x73, 0x70, 0x3A, 0x3A, 0x47, 0x70, 0x75, + 0x68, 0x69, 0x64, 0x3A, 0x55, 0x53, 0x45, 0x52, + 0x6E, 0x64, 0x6D, 0x3A, 0x75, 0x00, 0x00, 0x00, + 0x70, 0x78, 0x69, 0x3A, 0x64, 0x65, 0x76, 0x00, + 0x41, 0x50, 0x54, 0x3A, 0x41, 0x00, 0x00, 0x00, + 0x61, 0x63, 0x3A, 0x75, 0x00, 0x00, 0x00, 0x00, + 0x61, 0x63, 0x74, 0x3A, 0x75, 0x00, 0x00, 0x00, + 0x61, 0x6D, 0x3A, 0x61, 0x70, 0x70, 0x00, 0x00, + 0x62, 0x6F, 0x73, 0x73, 0x3A, 0x55, 0x00, 0x00, + 0x63, 0x61, 0x6D, 0x3A, 0x75, 0x00, 0x00, 0x00, + 0x63, 0x65, 0x63, 0x64, 0x3A, 0x75, 0x00, 0x00, + 0x64, 0x6C, 0x70, 0x3A, 0x46, 0x4B, 0x43, 0x4C, + 0x64, 0x6C, 0x70, 0x3A, 0x53, 0x52, 0x56, 0x52, + 0x64, 0x73, 0x70, 0x3A, 0x3A, 0x44, 0x53, 0x50, + 0x66, 0x72, 0x64, 0x3A, 0x75, 0x00, 0x00, 0x00, + 0x68, 0x74, 0x74, 0x70, 0x3A, 0x43, 0x00, 0x00, + 0x69, 0x72, 0x3A, 0x55, 0x53, 0x45, 0x52, 0x00, + 0x6C, 0x64, 0x72, 0x3A, 0x72, 0x6F, 0x00, 0x00, + 0x6D, 0x69, 0x63, 0x3A, 0x75, 0x00, 0x00, 0x00, + 0x6E, 0x65, 0x77, 0x73, 0x3A, 0x75, 0x00, 0x00, + 0x6E, 0x69, 0x6D, 0x3A, 0x61, 0x6F, 0x63, 0x00, + 0x6E, 0x77, 0x6D, 0x3A, 0x3A, 0x55, 0x44, 0x53, + 0x70, 0x74, 0x6D, 0x3A, 0x75, 0x00, 0x00, 0x00, + 0x73, 0x6F, 0x63, 0x3A, 0x55, 0x00, 0x00, 0x00, + 0x73, 0x73, 0x6C, 0x3A, 0x43, 0x00, 0x00, 0x00, + 0x79, 0x32, 0x72, 0x3A, 0x75, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x4E, 0x9F, 0xFA, 0xF0, 0xFF, 0xBF, 0xFF, 0xF1, + 0xE7, 0x3F, 0x00, 0xF2, 0x00, 0xF0, 0x91, 0xFF, + 0x00, 0xF6, 0x91, 0xFF, 0x50, 0xFF, 0x81, 0xFF, + 0x58, 0xFF, 0x81, 0xFF, 0x70, 0xFF, 0x81, 0xFF, + 0x78, 0xFF, 0x81, 0xFF, 0x01, 0x01, 0x00, 0xFF, + 0x00, 0x02, 0x00, 0xFE, 0x27, 0x02, 0x00, 0xFC, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 +}; + #endif \ No newline at end of file diff --git a/cia.c b/cia.c index 07986ae..b7bb609 100644 --- a/cia.c +++ b/cia.c @@ -134,7 +134,7 @@ int get_CIASettings(cia_settings *ciaset, user_settings *usrset) if(result) return result; } - else if(usrset->Content0IsCci){ + else if(usrset->ConvertCci){ result = GetSettingsFromCci(ciaset); if(result) return result; } @@ -227,7 +227,7 @@ int GetSettingsFromNcch0(cia_settings *ciaset, u32 ncch0_offset) } } else if(result != 0){ - fprintf(stderr,"[CIA ERROR] Content 0 Is Corrupt\n"); + fprintf(stderr,"[CIA ERROR] Content 0 Is Corrupt (res = %d)\n",result); return CIA_INVALID_NCCH0; } @@ -241,8 +241,8 @@ int GetSettingsFromNcch0(cia_settings *ciaset, u32 ncch0_offset) ExtendedHeader_Struct *ExHeader = malloc(ncch_ctx->exheader_size); if(!ExHeader){ fprintf(stderr,"[CIA ERROR] MEM ERROR\n"); free(ExeFs); return MEM_ERROR; } - GetNCCHSection(ExeFs, ncch_ctx->exefs_size, 0, ncch0, ncch_ctx, ciaset->keys, ncch_exefs); - GetNCCHSection((u8*)ExHeader, ncch_ctx->exheader_size, 0, ncch0, ncch_ctx, ciaset->keys, ncch_ExHeader); + if(!(ciaset->content.IsCfa||ciaset->content.KeyNotFound)) GetNCCHSection(ExeFs, ncch_ctx->exefs_size, 0, ncch0, ncch_ctx, ciaset->keys, ncch_exefs); + if(!(ciaset->content.IsCfa||ciaset->content.KeyNotFound)) GetNCCHSection((u8*)ExHeader, ncch_ctx->exheader_size, 0, ncch0, ncch_ctx, ciaset->keys, ncch_ExHeader); result = GetCIADataFromNcch(ciaset,hdr,ExHeader); // Data For TMD if(result) goto finish; @@ -536,7 +536,7 @@ int WriteCurrentSectionstoFile(cia_settings *ciaset) int WriteContentsToFile(cia_settings *ciaset, user_settings *usrset) { u8 *Content0 = ciaset->content.content0; - if(usrset->Content0IsCci) Content0 = (u8*)(ciaset->content.content0+ciaset->content.CCIContentOffsets[0]); + if(usrset->ConvertCci) Content0 = (u8*)(ciaset->content.content0+ciaset->content.CCIContentOffsets[0]); ctr_sha(Content0,ciaset->content.ContentSize[0],ciaset->content.ContentHash[0],CTR_SHA_256); if(ciaset->content.EncryptContents) { @@ -546,7 +546,7 @@ int WriteContentsToFile(cia_settings *ciaset, user_settings *usrset) WriteBuffer(Content0,ciaset->content.ContentSize[0],ciaset->content.ContentOffset[0]+ciaset->CIA_Sections.ContentOffset,ciaset->out); // Free Buffer if Not CCI - if(!usrset->Content0IsCci){ + if(!usrset->ConvertCci){ free(usrset->Content0.buffer); usrset->Content0.buffer = NULL; usrset->Content0.size = 0; @@ -571,7 +571,7 @@ int WriteContentsToFile(cia_settings *ciaset, user_settings *usrset) free(ContentBuff); } } - else if(usrset->Content0IsCci){ + else if(usrset->ConvertCci){ for(int i = 1; i < ciaset->content.ContentCount; i++){ u8 *ContentBuff = (u8*)(ciaset->content.content0+ciaset->content.CCIContentOffsets[i]); ctr_sha(ContentBuff,ciaset->content.ContentSize[i],ciaset->content.ContentHash[i],CTR_SHA_256); diff --git a/elf.c b/elf.c index 18b701f..67850b0 100644 --- a/elf.c +++ b/elf.c @@ -157,8 +157,8 @@ int ImportExeFsCodeBinaryFromFile(ncch_settings *ncchset) u32 GetPageSize(ncch_settings *ncchset) { - if(ncchset->yaml_set->DefaultSpec.Option.PageSize) - return strtoul(ncchset->yaml_set->DefaultSpec.Option.PageSize,NULL,10); + if(ncchset->yaml_set->Option.PageSize) + return strtoul(ncchset->yaml_set->Option.PageSize,NULL,10); return 0x1000; } @@ -181,16 +181,16 @@ int GetBSS_SizeFromElf(ElfContext *elf, u8 *ElfFile, ncch_settings *ncchset) int ImportPlainRegionFromElf(ElfContext *elf, u8 *ElfFile, ncch_settings *ncchset) // Doesn't work same as N makerom { - if(!ncchset->yaml_set->DefaultSpec.PlainRegionNum) return 0; - u16 *Index = malloc(sizeof(u16)*ncchset->yaml_set->DefaultSpec.PlainRegionNum); + if(!ncchset->yaml_set->PlainRegionNum) return 0; + u16 *Index = malloc(sizeof(u16)*ncchset->yaml_set->PlainRegionNum); /* Getting Index Values for each section */ - for(int i = 0; i < ncchset->yaml_set->DefaultSpec.PlainRegionNum; i++){ - Index[i] = GetElfSectionIndexFromName(ncchset->yaml_set->DefaultSpec.PlainRegion[i],elf,ElfFile); + for(int i = 0; i < ncchset->yaml_set->PlainRegionNum; i++){ + Index[i] = GetElfSectionIndexFromName(ncchset->yaml_set->PlainRegion[i],elf,ElfFile); } // Eliminating Duplicated Sections - for(int i = ncchset->yaml_set->DefaultSpec.PlainRegionNum - 1; i >= 0; i--){ + for(int i = ncchset->yaml_set->PlainRegionNum - 1; i >= 0; i--){ for(int j = i-1; j >= 0; j--){ if(Index[i] == Index[j]) Index[i] = 0; } @@ -198,7 +198,7 @@ int ImportPlainRegionFromElf(ElfContext *elf, u8 *ElfFile, ncch_settings *ncchse /* Calculating Total Size of Data */ u64 TotalSize = 0; - for(int i = 0; i < ncchset->yaml_set->DefaultSpec.PlainRegionNum; i++){ + for(int i = 0; i < ncchset->yaml_set->PlainRegionNum; i++){ TotalSize += elf->Sections[Index[i]].Size; } @@ -210,7 +210,7 @@ int ImportPlainRegionFromElf(ElfContext *elf, u8 *ElfFile, ncch_settings *ncchse /* Storing Sections */ u64 pos = 0; - for(int i = 0; i < ncchset->yaml_set->DefaultSpec.PlainRegionNum; i++){ + for(int i = 0; i < ncchset->yaml_set->PlainRegionNum; i++){ memcpy((ncchset->Sections.PlainRegion.buffer+pos),elf->Sections[Index[i]].Ptr,elf->Sections[Index[i]].Size); pos += elf->Sections[Index[i]].Size; } @@ -227,11 +227,11 @@ int CreateExeFsCode(ElfContext *elf, u8 *ElfFile, ncch_settings *ncchset) CodeSegment Data; memset(&Data,0,sizeof(CodeSegment)); - int result = CreateCodeSegmentFromElf(&Text,elf,ElfFile,ncchset->yaml_set->DefaultSpec.ExeFs.Text,ncchset->yaml_set->DefaultSpec.ExeFs.TextNum); + int result = CreateCodeSegmentFromElf(&Text,elf,ElfFile,ncchset->yaml_set->ExeFs.Text,ncchset->yaml_set->ExeFs.TextNum); if(result) return result; - result = CreateCodeSegmentFromElf(&RO,elf,ElfFile,ncchset->yaml_set->DefaultSpec.ExeFs.ReadOnly,ncchset->yaml_set->DefaultSpec.ExeFs.ReadOnlyNum); + result = CreateCodeSegmentFromElf(&RO,elf,ElfFile,ncchset->yaml_set->ExeFs.ReadOnly,ncchset->yaml_set->ExeFs.ReadOnlyNum); if(result) return result; - result = CreateCodeSegmentFromElf(&Data,elf,ElfFile,ncchset->yaml_set->DefaultSpec.ExeFs.ReadWrite,ncchset->yaml_set->DefaultSpec.ExeFs.ReadWriteNum); + result = CreateCodeSegmentFromElf(&Data,elf,ElfFile,ncchset->yaml_set->ExeFs.ReadWrite,ncchset->yaml_set->ExeFs.ReadWriteNum); if(result) return result; /* Allocating Buffer for ExeFs Code */ @@ -283,40 +283,40 @@ int CreateCodeSegmentFromElf(CodeSegment *out, ElfContext *elf, u8 *ElfFile, cha { u16 ContinuousSegmentNum = 0; memset(out,0,sizeof(CodeSegment)); - ElfSegment **ContinuousSegments = GetContinuousSegments(&ContinuousSegmentNum,elf,Names,NameNum); - if (ContinuousSegments == NULL){ - if(!ContinuousSegmentNum) // Nothing Was Found - return 0; - else // Error with found segments - return ELF_SEGMENTS_NOT_CONTINUOUS; - } - - /* Getting Segment Size/Settings */ - u32 vAddr = 0; - u32 memorySize = 0; - for(int i = 0; i < ContinuousSegmentNum; i++){ - if (i==0){ - vAddr = ContinuousSegments[i]->VAddr; - } - else{ // Add rounded size from previous segment - u32 num = ContinuousSegments[i]->VAddr - (vAddr + memorySize); - memorySize += num; - } - - memorySize += ContinuousSegments[i]->Header->SizeInMemory; - for (int j = 0; j < ContinuousSegments[i]->SectionNum; j++){ - ElfSectionEntry *Section = &ContinuousSegments[i]->Sections[j]; - if (IsBss(Section) && j == (ContinuousSegments[i]->SectionNum-1)) - memorySize -= Section->Size; - } - } - - // For Check -#ifdef ELF_DEBUG - printf("Address: 0x%x\n",vAddr); - printf("Size: 0x%x\n",memorySize); -#endif - + ElfSegment **ContinuousSegments = GetContinuousSegments(&ContinuousSegmentNum,elf,Names,NameNum); + if (ContinuousSegments == NULL){ + if(!ContinuousSegmentNum) // Nothing Was Found + return 0; + else // Error with found segments + return ELF_SEGMENTS_NOT_CONTINUOUS; + } + + /* Getting Segment Size/Settings */ + u32 vAddr = 0; + u32 memorySize = 0; + for(int i = 0; i < ContinuousSegmentNum; i++){ + if (i==0){ + vAddr = ContinuousSegments[i]->VAddr; + } + else{ // Add rounded size from previous segment + u32 num = ContinuousSegments[i]->VAddr - (vAddr + memorySize); + memorySize += num; + } + + memorySize += ContinuousSegments[i]->Header->SizeInMemory; + for (int j = 0; j < ContinuousSegments[i]->SectionNum; j++){ + ElfSectionEntry *Section = &ContinuousSegments[i]->Sections[j]; + if (IsBss(Section) && j == (ContinuousSegments[i]->SectionNum-1)) + memorySize -= Section->Size; + } + } + + // For Check +#ifdef ELF_DEBUG + printf("Address: 0x%x\n",vAddr); + printf("Size: 0x%x\n",memorySize); +#endif + out->Address = vAddr; out->Size = memorySize; out->MaxPageNum = SizeToPage(memorySize,elf); @@ -325,28 +325,28 @@ int CreateCodeSegmentFromElf(CodeSegment *out, ElfContext *elf, u8 *ElfFile, cha /* Writing Segment to Buffer */ vAddr = 0; memorySize = 0; - for(int i = 0; i < ContinuousSegmentNum; i++){ - if (i==0){ - vAddr = ContinuousSegments[i]->VAddr; - } - else{ - u32 num = ContinuousSegments[i]->VAddr - (vAddr + memorySize); - memorySize += num; - } - u32 size = 0; - for (int j = 0; j < ContinuousSegments[i]->SectionNum; j++){ - ElfSectionEntry *Section = &ContinuousSegments[i]->Sections[j]; - if (!IsBss(Section)){ - u8 *pos = (out->Data + memorySize + size); - memcpy(pos,Section->Ptr,Section->Size); - size += Section->Size; - } - - else if (j == (ContinuousSegments[i]->SectionNum-1)) - memorySize -= Section->Size; - else - size += Section->Size; - } + for(int i = 0; i < ContinuousSegmentNum; i++){ + if (i==0){ + vAddr = ContinuousSegments[i]->VAddr; + } + else{ + u32 num = ContinuousSegments[i]->VAddr - (vAddr + memorySize); + memorySize += num; + } + u32 size = 0; + for (int j = 0; j < ContinuousSegments[i]->SectionNum; j++){ + ElfSectionEntry *Section = &ContinuousSegments[i]->Sections[j]; + if (!IsBss(Section)){ + u8 *pos = (out->Data + memorySize + size); + memcpy(pos,Section->Ptr,Section->Size); + size += Section->Size; + } + + else if (j == (ContinuousSegments[i]->SectionNum-1)) + memorySize -= Section->Size; + else + size += Section->Size; + } } free(ContinuousSegments); @@ -354,52 +354,52 @@ int CreateCodeSegmentFromElf(CodeSegment *out, ElfContext *elf, u8 *ElfFile, cha } -ElfSegment** GetContinuousSegments(u16 *ContinuousSegmentNum, ElfContext *elf, char **Names, u32 NameNum) -{ - u16 SegmentNum = 0; - ElfSegment **Segments = GetSegments(&SegmentNum, elf, Names, NameNum); - if (Segments == NULL || SegmentNum == 0){ // No Segments for the names were found - //printf("Not Found Segment\n"); - return NULL; - } - - if (SegmentNum == 1){ //Return as there is no need to check - *ContinuousSegmentNum = SegmentNum; - return Segments; - } - - u32 vAddr = Segments[0]->VAddr + Segments[0]->Header->SizeInMemory; - for (int i = 1; i < SegmentNum; i++){ - if (Segments[i]->VAddr != (u32)align_value(vAddr,Segments[i]->Header->Alignment)){ //Each Segment must start after each other - fprintf(stderr,"[ELF ERROR] %s segment and %s segment are not continuous\n", Segments[i]->Name, Segments[i - 1]->Name); - free(Segments); - *ContinuousSegmentNum = 0xffff; // Signify to function that an error occured - return NULL; - } - } - *ContinuousSegmentNum = SegmentNum; - return Segments; +ElfSegment** GetContinuousSegments(u16 *ContinuousSegmentNum, ElfContext *elf, char **Names, u32 NameNum) +{ + u16 SegmentNum = 0; + ElfSegment **Segments = GetSegments(&SegmentNum, elf, Names, NameNum); + if (Segments == NULL || SegmentNum == 0){ // No Segments for the names were found + //printf("Not Found Segment\n"); + return NULL; + } + + if (SegmentNum == 1){ //Return as there is no need to check + *ContinuousSegmentNum = SegmentNum; + return Segments; + } + + u32 vAddr = Segments[0]->VAddr + Segments[0]->Header->SizeInMemory; + for (int i = 1; i < SegmentNum; i++){ + if (Segments[i]->VAddr != (u32)align_value(vAddr,Segments[i]->Header->Alignment)){ //Each Segment must start after each other + fprintf(stderr,"[ELF ERROR] %s segment and %s segment are not continuous\n", Segments[i]->Name, Segments[i - 1]->Name); + free(Segments); + *ContinuousSegmentNum = 0xffff; // Signify to function that an error occured + return NULL; + } + } + *ContinuousSegmentNum = SegmentNum; + return Segments; } -ElfSegment** GetSegments(u16 *SegmentNum, ElfContext *elf, char **Names, u32 NameNum) -{ - if (Names == NULL) - { - return NULL; - } - - ElfSegment **Segments = malloc(sizeof(ElfSegment*)*NameNum); - *SegmentNum = 0; // There can be a max of NameNum Segments, however, they might not all exist - for (int i = 0; i < NameNum; i++){ - for(int j = 0; j < elf->ActiveSegments; j++){ - if(strcmp(Names[i],elf->Segments[j].Name) == 0){ // If there is a match, store Segment data pointer & increment index - Segments[*SegmentNum] = &elf->Segments[j]; - *SegmentNum = *SegmentNum + 1; - } - } - } - return Segments; +ElfSegment** GetSegments(u16 *SegmentNum, ElfContext *elf, char **Names, u32 NameNum) +{ + if (Names == NULL) + { + return NULL; + } + + ElfSegment **Segments = malloc(sizeof(ElfSegment*)*NameNum); + *SegmentNum = 0; // There can be a max of NameNum Segments, however, they might not all exist + for (int i = 0; i < NameNum; i++){ + for(int j = 0; j < elf->ActiveSegments; j++){ + if(strcmp(Names[i],elf->Segments[j].Name) == 0){ // If there is a match, store Segment data pointer & increment index + Segments[*SegmentNum] = &elf->Segments[j]; + *SegmentNum = *SegmentNum + 1; + } + } + } + return Segments; } // ELF Functions diff --git a/exheader.c b/exheader.c index 61866c0..d84de8b 100644 --- a/exheader.c +++ b/exheader.c @@ -3,7 +3,7 @@ #include "exheader.h" #include "titleid.h" -#include "polarssl\base64.h" +#include "polarssl/base64.h" #ifndef RETAIL_FSIGN #include "accessdesc_sig.h" // For AccessDesc Presets @@ -15,14 +15,46 @@ void free_ExHeaderSettings(exheader_settings *exhdrset); int get_ExHeaderSettingsFromNcchset(exheader_settings *exhdrset, ncch_settings *ncchset); int get_ExHeaderSettingsFromYaml(exheader_settings *exhdrset); -void AdjustBooleans(desc_settings *yaml); -int get_ExHeaderCodeSetInfo(exhdr_CodeSetInfo *CodeSetInfo, desc_settings *yaml); -int get_ExHeaderDependencyList(u8 *DependencyList, desc_settings *yaml); -int get_ExHeaderSystemInfo(exhdr_SystemInfo *SystemInfo, desc_settings *yaml); -int get_ExHeaderARM11SystemLocalInfo(exhdr_ARM11SystemLocalCapabilities *arm11, desc_settings *yaml); -int get_ExHeaderARM11KernelInfo(exhdr_ARM11KernelCapabilities *arm11, desc_settings *yaml); -int get_ExHeaderARM9AccessControlInfo(exhdr_ARM9AccessControlInfo *arm9, desc_settings *yaml); - +void AdjustBooleans(rsf_settings *yaml); +int get_ExHeaderCodeSetInfo(exhdr_CodeSetInfo *CodeSetInfo, rsf_settings *yaml); +int get_ExHeaderDependencyList(u8 *DependencyList, rsf_settings *yaml); +int get_ExHeaderSystemInfo(exhdr_SystemInfo *SystemInfo, rsf_settings *yaml); +int get_ExHeaderARM11SystemLocalInfo(exhdr_ARM11SystemLocalCapabilities *arm11, rsf_settings *yaml); +int SetARM11SystemLocalInfoFlags(exhdr_ARM11SystemLocalCapabilities *arm11, rsf_settings *yaml); +int GetAppType(int *AppType, rsf_settings *yaml); +int SetARM11ResLimitDesc(exhdr_ARM11SystemLocalCapabilities *arm11, rsf_settings *yaml); +int SetARM11StorageInfo(exhdr_ARM11SystemLocalCapabilities *arm11, rsf_settings *yaml); +int SetARM11StorageInfoSystemSaveDataId(exhdr_ARM11SystemLocalCapabilities *arm11, rsf_settings *yaml); +int SetARM11StorageInfoExtSaveDataId(exhdr_ARM11SystemLocalCapabilities *arm11, rsf_settings *yaml); +int SetARM11StorageInfoOtherUserSaveData(exhdr_ARM11SystemLocalCapabilities *arm11, rsf_settings *yaml); +bool CheckCondiditionsForNewAccessibleSaveDataIds(rsf_settings *yaml); +int SetARM11StorageInfoAccessibleSaveDataIds(exhdr_ARM11SystemLocalCapabilities *arm11, rsf_settings *yaml); +int SetARM11ServiceAccessControl(exhdr_ARM11SystemLocalCapabilities *arm11, rsf_settings *yaml); +int get_ExHeaderARM11KernelInfo(exhdr_ARM11KernelCapabilities *arm11, rsf_settings *yaml); +int SetARM11KernelDescSysCallControl(ARM11KernelCapabilityDescriptor *desc, rsf_settings *yaml); +int GetARM11SysCalls(ARM11KernelCapabilityDescriptor *desc, rsf_settings *yaml); +void EnableSystemCall(ARM11KernelCapabilityDescriptor *desc, int SysCall); +void DisableSystemCall(ARM11KernelCapabilityDescriptor *desc, int SysCall); +int SetARM11KernelDescInteruptNumList(ARM11KernelCapabilityDescriptor *desc, rsf_settings *yaml); +int GetARM11Interupts(ARM11KernelCapabilityDescriptor *desc, rsf_settings *yaml); +void EnableInterupt(ARM11KernelCapabilityDescriptor *desc, int Interrupt, int i); +int SetARM11KernelDescAddressMapping(ARM11KernelCapabilityDescriptor *desc, rsf_settings *yaml); +int GetARM11IOMappings(ARM11KernelCapabilityDescriptor *desc, rsf_settings *yaml); +int GetARM11StaticMappings(ARM11KernelCapabilityDescriptor *desc, rsf_settings *yaml); +bool IsEndAddress(u32 Address); +bool IsStartAddress(u32 Address); +u32 GetIOMappingDesc(u32 Address); +u32 GetStaticMappingDesc(u32 Address, bool IsReadOnly); +u32 GetMappingDesc(u32 Address, u32 PrefixVal, s32 numPrefixBits, bool IsRO); +int SetARM11KernelDescOtherCapabilities(ARM11KernelCapabilityDescriptor *desc, rsf_settings *yaml); +int SetARM11KernelDescHandleTableSize(ARM11KernelCapabilityDescriptor *desc, rsf_settings *yaml); +int SetARM11KernelDescReleaseKernelVersion(ARM11KernelCapabilityDescriptor *desc, rsf_settings *yaml); +void SetARM11KernelDescValue(ARM11KernelCapabilityDescriptor *desc, u16 Index, u32 Value); +void SetARM11KernelDescBitmask(ARM11KernelCapabilityDescriptor *desc, u32 Bitmask); +void AllocateARM11KernelDescMemory(ARM11KernelCapabilityDescriptor *desc, u16 Num); +u32 GetDescPrefixMask(int numPrefixBits); +u32 GetDescPrefixBits(int numPrefixBits, u32 PrefixVal); +int get_ExHeaderARM9AccessControlInfo(exhdr_ARM9AccessControlInfo *arm9, rsf_settings *yaml); int set_AccessDesc(exheader_settings *exhdrset, ncch_settings *ncchset); /* ExHeader Signature Functions */ @@ -58,9 +90,6 @@ int BuildExHeader(ncch_settings *ncchset) result = set_AccessDesc(exhdrset,ncchset); if(result) goto finish; - - memcpy(&exhdrset->ExHdr->ARM11SystemLocalCapabilities.Flags,&exhdrset->ExHdr->AccessDescriptor.ARM11SystemLocalCapabilities.Flags,0x1f8); - finish: if(result) fprintf(stderr,"[EXHEADER ERROR] Failed to create ExHeader\n"); free_ExHeaderSettings(exhdrset); @@ -92,7 +121,7 @@ int get_ExHeaderSettingsFromNcchset(exheader_settings *exhdrset, ncch_settings * /* Import ExHeader template */ if(ncchset->ComponentFilePtrs.exheader_size){ - u32 import_size = min_u64(0x400,ncchset->ComponentFilePtrs.exheader_size); + u32 import_size = min_u64(0x40,ncchset->ComponentFilePtrs.exheader_size); ReadFile_64(ncchset->Sections.ExHeader.buffer,import_size,0,ncchset->ComponentFilePtrs.exheader); } @@ -122,6 +151,8 @@ int get_ExHeaderSettingsFromNcchset(exheader_settings *exhdrset, ncch_settings * exhdrset->ExHdr->CodeSetInfo.Flags.flag |= ExeFsCodeCompress; if(ncchset->Options.UseOnSD) exhdrset->ExHdr->CodeSetInfo.Flags.flag |= RetailSDAppFlag; + if(!ncchset->Options.UseRomFS) // Move this later + exhdrset->ExHdr->ARM11SystemLocalCapabilities.StorageInfo.OtherAttributes |= 1 << NOT_USE_ROMFS; return 0; } @@ -153,45 +184,48 @@ finish: return result; } -void AdjustBooleans(desc_settings *yaml) +void AdjustBooleans(rsf_settings *yaml) { - if(yaml->DefaultSpec.AccessControlInfo.DisableDebug == -1) yaml->DefaultSpec.AccessControlInfo.DisableDebug = 0; - if(yaml->DefaultSpec.AccessControlInfo.EnableForceDebug == -1) yaml->DefaultSpec.AccessControlInfo.EnableForceDebug = 0; - if(yaml->DefaultSpec.AccessControlInfo.CanWriteSharedPage == -1) yaml->DefaultSpec.AccessControlInfo.CanWriteSharedPage = 0; - if(yaml->DefaultSpec.AccessControlInfo.CanUsePrivilegedPriority == -1) yaml->DefaultSpec.AccessControlInfo.CanUsePrivilegedPriority = 0; - if(yaml->DefaultSpec.AccessControlInfo.CanUseNonAlphabetAndNumber == -1) yaml->DefaultSpec.AccessControlInfo.CanUseNonAlphabetAndNumber = 0; - if(yaml->DefaultSpec.AccessControlInfo.PermitMainFunctionArgument == -1) yaml->DefaultSpec.AccessControlInfo.PermitMainFunctionArgument = 0; - if(yaml->DefaultSpec.AccessControlInfo.CanShareDeviceMemory == -1) yaml->DefaultSpec.AccessControlInfo.CanShareDeviceMemory = 0; - if(yaml->DefaultSpec.AccessControlInfo.UseOtherVariationSaveData == -1) yaml->DefaultSpec.AccessControlInfo.UseOtherVariationSaveData = 0; - if(yaml->DefaultSpec.AccessControlInfo.UseExtSaveData == -1) yaml->DefaultSpec.AccessControlInfo.UseExtSaveData = 0; - if(yaml->DefaultSpec.AccessControlInfo.RunnableOnSleep == -1) yaml->DefaultSpec.AccessControlInfo.RunnableOnSleep = 0; - if(yaml->DefaultSpec.AccessControlInfo.SpecialMemoryArrange == -1) yaml->DefaultSpec.AccessControlInfo.SpecialMemoryArrange = 0; + if(yaml->AccessControlInfo.DisableDebug == -1) yaml->AccessControlInfo.DisableDebug = 0; + if(yaml->AccessControlInfo.EnableForceDebug == -1) yaml->AccessControlInfo.EnableForceDebug = 0; + if(yaml->AccessControlInfo.CanWriteSharedPage == -1) yaml->AccessControlInfo.CanWriteSharedPage = 0; + if(yaml->AccessControlInfo.CanUsePrivilegedPriority == -1) yaml->AccessControlInfo.CanUsePrivilegedPriority = 0; + if(yaml->AccessControlInfo.CanUseNonAlphabetAndNumber == -1) yaml->AccessControlInfo.CanUseNonAlphabetAndNumber = 0; + if(yaml->AccessControlInfo.PermitMainFunctionArgument == -1) yaml->AccessControlInfo.PermitMainFunctionArgument = 0; + if(yaml->AccessControlInfo.CanShareDeviceMemory == -1) yaml->AccessControlInfo.CanShareDeviceMemory = 0; + if(yaml->AccessControlInfo.UseOtherVariationSaveData == -1) yaml->AccessControlInfo.UseOtherVariationSaveData = 0; + if(yaml->AccessControlInfo.UseExtSaveData == -1) yaml->AccessControlInfo.UseExtSaveData = 0; + if(yaml->AccessControlInfo.UseExtendedSaveDataAccessControl == -1) yaml->AccessControlInfo.UseExtendedSaveDataAccessControl = 0; + if(yaml->AccessControlInfo.RunnableOnSleep == -1) yaml->AccessControlInfo.RunnableOnSleep = 0; + if(yaml->AccessControlInfo.SpecialMemoryArrange == -1) yaml->AccessControlInfo.SpecialMemoryArrange = 0; } -int get_ExHeaderCodeSetInfo(exhdr_CodeSetInfo *CodeSetInfo, desc_settings *yaml) +int get_ExHeaderCodeSetInfo(exhdr_CodeSetInfo *CodeSetInfo, rsf_settings *yaml) { /* Name */ - if(yaml->DefaultSpec.BasicInfo.Title){ - if(strlen(yaml->DefaultSpec.BasicInfo.Title) > 8){ + if(yaml->BasicInfo.Title){ + if(strlen(yaml->BasicInfo.Title) > 8){ fprintf(stderr,"[EXHEADER ERROR] Parameter Too Long 'BasicInfo/Title'\n"); return EXHDR_BAD_YAML_OPT; } - strcpy((char*)CodeSetInfo->Name,yaml->DefaultSpec.BasicInfo.Title); + strcpy((char*)CodeSetInfo->Name,yaml->BasicInfo.Title); } else{ fprintf(stderr,"[EXHEADER ERROR] Parameter Not Found: 'BasicInfo/Title'\n"); + return EXHDR_BAD_YAML_OPT; } /* Stack Size */ - if(yaml->DefaultSpec.SystemControlInfo.StackSize){ - u32 StackSize = strtoul(yaml->DefaultSpec.SystemControlInfo.StackSize,NULL,0); + if(yaml->SystemControlInfo.StackSize){ + u32 StackSize = strtoul(yaml->SystemControlInfo.StackSize,NULL,0); u32_to_u8(CodeSetInfo->StackSize,StackSize,LE); } else{ fprintf(stderr,"[EXHEADER ERROR] Parameter Not Found: 'SystemControlInfo/StackSize'\n"); + return EXHDR_BAD_YAML_OPT; } /* Remaster Version */ - if(yaml->DefaultSpec.SystemControlInfo.RemasterVersion){ - u16 RemasterVersion = strtol(yaml->DefaultSpec.SystemControlInfo.RemasterVersion,NULL,0); + if(yaml->SystemControlInfo.RemasterVersion){ + u16 RemasterVersion = strtol(yaml->SystemControlInfo.RemasterVersion,NULL,0); u16_to_u8(CodeSetInfo->Flags.remasterVersion,RemasterVersion,LE); } else{ @@ -200,39 +234,39 @@ int get_ExHeaderCodeSetInfo(exhdr_CodeSetInfo *CodeSetInfo, desc_settings *yaml) return 0; } -int get_ExHeaderDependencyList(u8 *DependencyList, desc_settings *yaml) +int get_ExHeaderDependencyList(u8 *DependencyList, rsf_settings *yaml) { - if(yaml->DefaultSpec.SystemControlInfo.DependencyNum > 0x30){ + if(yaml->SystemControlInfo.DependencyNum > 0x30){ fprintf(stderr,"[EXHEADER ERROR] Too Many Dependency IDs\n"); return EXHDR_BAD_YAML_OPT; } - for(int i = 0; i < yaml->DefaultSpec.SystemControlInfo.DependencyNum; i++){ + for(int i = 0; i < yaml->SystemControlInfo.DependencyNum; i++){ u8 *pos = (DependencyList + 0x8*i); - u64 TitleID = strtoull(yaml->DefaultSpec.SystemControlInfo.Dependency[i],NULL,0); + u64 TitleID = strtoull(yaml->SystemControlInfo.Dependency[i],NULL,0); u64_to_u8(pos,TitleID,LE); } return 0; } -int get_ExHeaderSystemInfo(exhdr_SystemInfo *SystemInfo, desc_settings *yaml) +int get_ExHeaderSystemInfo(exhdr_SystemInfo *SystemInfo, rsf_settings *yaml) { /* SaveDataSize */ - if(yaml->DefaultSpec.Rom.SaveDataSize){ - u64 SaveDataSize = strtoull(yaml->DefaultSpec.Rom.SaveDataSize,NULL,10); - if(strstr(yaml->DefaultSpec.Rom.SaveDataSize,"K")){ - char *str = strstr(yaml->DefaultSpec.Rom.SaveDataSize,"K"); + if(yaml->Rom.SaveDataSize){ + u64 SaveDataSize = strtoull(yaml->Rom.SaveDataSize,NULL,10); + if(strstr(yaml->Rom.SaveDataSize,"K")){ + char *str = strstr(yaml->Rom.SaveDataSize,"K"); if(strcmp(str,"K") == 0 || strcmp(str,"KB") == 0 ){ SaveDataSize = SaveDataSize*KB; } } - else if(strstr(yaml->DefaultSpec.Rom.SaveDataSize,"M")){ - char *str = strstr(yaml->DefaultSpec.Rom.SaveDataSize,"M"); + else if(strstr(yaml->Rom.SaveDataSize,"M")){ + char *str = strstr(yaml->Rom.SaveDataSize,"M"); if(strcmp(str,"M") == 0 || strcmp(str,"MB") == 0 ){ SaveDataSize = SaveDataSize*MB; } } - else if(strstr(yaml->DefaultSpec.Rom.SaveDataSize,"G")){ - char *str = strstr(yaml->DefaultSpec.Rom.SaveDataSize,"G"); + else if(strstr(yaml->Rom.SaveDataSize,"G")){ + char *str = strstr(yaml->Rom.SaveDataSize,"G"); if(strcmp(str,"G") == 0 || strcmp(str,"GB") == 0 ){ SaveDataSize = SaveDataSize*GB; } @@ -251,8 +285,8 @@ int get_ExHeaderSystemInfo(exhdr_SystemInfo *SystemInfo, desc_settings *yaml) u64_to_u8(SystemInfo->SaveDataSize,0,LE); } /* Jump Id */ - if(yaml->DefaultSpec.SystemControlInfo.JumpId){ - u64 JumpId = strtoull(yaml->DefaultSpec.SystemControlInfo.JumpId,NULL,0); + if(yaml->SystemControlInfo.JumpId){ + u64 JumpId = strtoull(yaml->SystemControlInfo.JumpId,NULL,0); u64_to_u8(SystemInfo->JumpId,JumpId,LE); } else{ @@ -264,28 +298,875 @@ int get_ExHeaderSystemInfo(exhdr_SystemInfo *SystemInfo, desc_settings *yaml) return 0; } -int get_ExHeaderARM11SystemLocalInfo(exhdr_ARM11SystemLocalCapabilities *arm11, desc_settings *yaml) +int get_ExHeaderARM11SystemLocalInfo(exhdr_ARM11SystemLocalCapabilities *arm11, rsf_settings *yaml) { /* Program Id */ u64 ProgramId = 0; int result = GetProgramID(&ProgramId,yaml,true); if(result) return result; u64_to_u8(arm11->ProgramId,ProgramId,LE); - return 0; + /* Flags */ - //u32_to_u8( -} + result = SetARM11SystemLocalInfoFlags(arm11, yaml); + if(result) return result; -int get_ExHeaderARM11KernelInfo(exhdr_ARM11KernelCapabilities *arm11, desc_settings *yaml) -{ + /* Resource Limit Descriptors */ + result = SetARM11ResLimitDesc(arm11, yaml); + if(result) return result; + + /* Storage Info */ + result = SetARM11StorageInfo(arm11, yaml); + if(result) return result; + + /* Service Access Control */ + result = SetARM11ServiceAccessControl(arm11, yaml); + if(result) return result; + + /* Resource Limit Category */ + if(yaml->AccessControlInfo.ResourceLimitCategory){ + if(strcasecmp(yaml->AccessControlInfo.ResourceLimitCategory,"application") == 0) arm11->ResourceLimitCategory = resrc_limit_APPLICATION; + else if(strcasecmp(yaml->AccessControlInfo.ResourceLimitCategory,"sysapplet") == 0) arm11->ResourceLimitCategory = resrc_limit_SYS_APPLET; + else if(strcasecmp(yaml->AccessControlInfo.ResourceLimitCategory,"libapplet") == 0) arm11->ResourceLimitCategory = resrc_limit_LIB_APPLET; + else if(strcasecmp(yaml->AccessControlInfo.ResourceLimitCategory,"other") == 0) arm11->ResourceLimitCategory = resrc_limit_OTHER; + } + + /* Finish */ return 0; } -int get_ExHeaderARM9AccessControlInfo(exhdr_ARM9AccessControlInfo *arm9, desc_settings *yaml) +int SetARM11SystemLocalInfoFlags(exhdr_ARM11SystemLocalCapabilities *arm11, rsf_settings *yaml) { + /* Core Version */ + if(yaml->AccessControlInfo.CoreVersion){ + u32 Version = strtoul(yaml->AccessControlInfo.CoreVersion,NULL,0); + u32_to_u8(&arm11->Flags[0],Version,LE); + } + else{ + fprintf(stderr,"[EXHEADER ERROR] Parameter Not Found: 'AccessControlInfo/CoreVersion'\n"); + return EXHDR_BAD_YAML_OPT; + } + + /* Byte[6] */ + u8 AffinityMask = 0; + u8 IdealProcessor = 0; + u8 SystemMode = 0; + if(yaml->AccessControlInfo.AffinityMask){ + AffinityMask = strtol(yaml->AccessControlInfo.AffinityMask,NULL,0); + if(AffinityMask != 0 && AffinityMask != 1){ + fprintf(stderr,"[EXHEADER ERROR] Unexpected AffinityMask: %d. Expected range: 0x0 - 0x1\n",AffinityMask); + return EXHDR_BAD_YAML_OPT; + } + } + if(yaml->AccessControlInfo.IdealProcessor){ + IdealProcessor = strtol(yaml->AccessControlInfo.IdealProcessor,NULL,0); + if(IdealProcessor != 0 && IdealProcessor != 1){ + fprintf(stderr,"[EXHEADER ERROR] Unexpected IdealProcessor: %d. Expected range: 0x0 - 0x1\n",IdealProcessor); + return EXHDR_BAD_YAML_OPT; + } + } + if(yaml->AccessControlInfo.SystemMode){ + SystemMode = strtol(yaml->AccessControlInfo.SystemMode,NULL,0); + if(SystemMode > 15){ + fprintf(stderr,"[EXHEADER ERROR] Unexpected SystemMode: 0x%x. Expected range: 0x0 - 0xf\n",SystemMode); + return EXHDR_BAD_YAML_OPT; + } + } + arm11->Flags[6] = (u8)(SystemMode << 4 | AffinityMask << 2 | IdealProcessor); + + /* Thread Priority */ + if(yaml->AccessControlInfo.Priority){ + u8 Priority = strtoul(yaml->AccessControlInfo.Priority,NULL,0); + int ProccessType = 0; + GetAppType(&ProccessType,yaml); + if(ProccessType == processtype_APPLICATION || ProccessType == processtype_DEFAULT){ + Priority += 32; + } + if(Priority > 127){ + fprintf(stderr,"[EXHEADER ERROR] Invalid Priority: %d\n",Priority); + return EXHDR_BAD_YAML_OPT; + } + arm11->Flags[7] = Priority; + } + else{ + fprintf(stderr,"[EXHEADER ERROR] Parameter Not Found: 'AccessControlInfo/Priority'\n"); + return EXHDR_BAD_YAML_OPT; + } + return 0; } +int GetAppType(int *AppType, rsf_settings *yaml) +{ + *AppType = processtype_DEFAULT; + if(yaml->SystemControlInfo.AppType){ + if(strcasecmp(yaml->SystemControlInfo.AppType,"application") == 0) *AppType = processtype_APPLICATION; + else if(strcasecmp(yaml->SystemControlInfo.AppType,"system") == 0) *AppType = processtype_SYSTEM; + } + return 0; +} + +int SetARM11ResLimitDesc(exhdr_ARM11SystemLocalCapabilities *arm11, rsf_settings *yaml) +{ + for(int i = 0; i < 16; i++){ + if(i == 0){ + /* MaxCpu */ + // N's makerom actually reads this from the pre-made accessdesc. Damn cheaters. But we can improvise + if(yaml->AccessControlInfo.MaxCpu){ + arm11->ResourceLimitDescriptor[i][0] = strtol(yaml->AccessControlInfo.MaxCpu,NULL,0); + } + } + } + + return 0; +} + +int SetARM11StorageInfo(exhdr_ARM11SystemLocalCapabilities *arm11, rsf_settings *yaml) +{ + if(yaml->AccessControlInfo.UseExtendedSaveDataAccessControl || yaml->AccessControlInfo.AccessibleSaveDataIds){ + /* Accessible SaveData IDs */ + if(!CheckCondiditionsForNewAccessibleSaveDataIds(yaml)) + return EXHDR_BAD_YAML_OPT; + SetARM11StorageInfoAccessibleSaveDataIds(arm11,yaml); + } + else{ + /* Extdata Id */ + int ret = SetARM11StorageInfoExtSaveDataId(arm11,yaml); + if(ret) return ret; + /* OtherUserSaveData */ + SetARM11StorageInfoOtherUserSaveData(arm11,yaml); + } + + /* System Savedata Id */ + SetARM11StorageInfoSystemSaveDataId(arm11,yaml); + + /* FileSystem Access Info */ + u32 AccessInfo = 0; + for(int i = 0; i < yaml->AccessControlInfo.FileSystemAccessNum; i++){ + if(strcmp(yaml->AccessControlInfo.FileSystemAccess[i],"CategorySystemApplication") == 0) + AccessInfo |= 1 << CATEGORY_SYSTEM_APPLICATION; + else if(strcmp(yaml->AccessControlInfo.FileSystemAccess[i],"CategoryHardwareCheck") == 0) + AccessInfo |= 1 << CATEGORY_HARDWARE_CHECK; + else if(strcmp(yaml->AccessControlInfo.FileSystemAccess[i],"CategoryFileSystemTool") == 0) + AccessInfo |= 1 << CATEGORY_FILE_SYSTEM_TOOL; + else if(strcmp(yaml->AccessControlInfo.FileSystemAccess[i],"Debug") == 0) + AccessInfo |= 1 << DEBUG; + else if(strcmp(yaml->AccessControlInfo.FileSystemAccess[i],"TwlCardBackup") == 0) + AccessInfo |= 1 << TWL_CARD_BACKUP; + else if(strcmp(yaml->AccessControlInfo.FileSystemAccess[i],"TwlNandData") == 0) + AccessInfo |= 1 << TWL_NAND_DATA; + else if(strcmp(yaml->AccessControlInfo.FileSystemAccess[i],"Boss") == 0) + AccessInfo |= 1 << BOSS; + else if(strcmp(yaml->AccessControlInfo.FileSystemAccess[i],"DirectSdmc") == 0) + AccessInfo |= 1 << DIRECT_SDMC; + else if(strcmp(yaml->AccessControlInfo.FileSystemAccess[i],"Core") == 0) + AccessInfo |= 1 << CORE; + else if(strcmp(yaml->AccessControlInfo.FileSystemAccess[i],"CtrNandRo") == 0) + AccessInfo |= 1 << CTR_NAND_RO; + else if(strcmp(yaml->AccessControlInfo.FileSystemAccess[i],"CtrNandRw") == 0) + AccessInfo |= 1 << CTR_NAND_RW; + else if(strcmp(yaml->AccessControlInfo.FileSystemAccess[i],"CtrNandRoWrite") == 0) + AccessInfo |= 1 << CTR_NAND_RO_WRITE; + else if(strcmp(yaml->AccessControlInfo.FileSystemAccess[i],"CategorySystemSettings") == 0) + AccessInfo |= 1 << CATEGORY_SYSTEM_SETTINGS; + else if(strcmp(yaml->AccessControlInfo.FileSystemAccess[i],"CardBoard") == 0) + AccessInfo |= 1 << CARD_BOARD; + else if(strcmp(yaml->AccessControlInfo.FileSystemAccess[i],"ExportImportIvs") == 0) + AccessInfo |= 1 << EXPORT_IMPORT_IVS; + else if(strcmp(yaml->AccessControlInfo.FileSystemAccess[i],"DirectSdmcWrite") == 0) + AccessInfo |= 1 << DIRECT_SDMC_WRITE; + else if(strcmp(yaml->AccessControlInfo.FileSystemAccess[i],"SwitchCleanup") == 0) + AccessInfo |= 1 << SWITCH_CLEANUP; + else if(strcmp(yaml->AccessControlInfo.FileSystemAccess[i],"SaveDataMove") == 0) + AccessInfo |= 1 << SAVE_DATA_MOVE; + else if(strcmp(yaml->AccessControlInfo.FileSystemAccess[i],"Shop") == 0) + AccessInfo |= 1 << SHOP; + else if(strcmp(yaml->AccessControlInfo.FileSystemAccess[i],"Shell") == 0) + AccessInfo |= 1 << SHELL; + else if(strcmp(yaml->AccessControlInfo.FileSystemAccess[i],"CategoryHomeMenu") == 0) + AccessInfo |= 1 << CATEGORY_HOME_MENU; + else{ + fprintf(stderr,"[EXHEADER ERROR] Invalid FileSystemAccess Name: '%s'\n",yaml->AccessControlInfo.FileSystemAccess[i]); + return EXHDR_BAD_YAML_OPT; + } + } + u32_to_u8(arm11->StorageInfo.AccessInfo,AccessInfo,LE); + return 0; +} + +int SetARM11StorageInfoSystemSaveDataId(exhdr_ARM11SystemLocalCapabilities *arm11, rsf_settings *yaml) +{ + if(yaml->AccessControlInfo.SystemSaveDataId1){ + u32 SaveId = strtoul(yaml->AccessControlInfo.SystemSaveDataId1,NULL,0); + u32_to_u8(arm11->StorageInfo.SystemSaveDataId,SaveId,LE); + } + if(yaml->AccessControlInfo.SystemSaveDataId2){ + u32 SaveId = strtoul(yaml->AccessControlInfo.SystemSaveDataId2,NULL,0); + u32_to_u8(&arm11->StorageInfo.SystemSaveDataId[4],SaveId,LE); + } + return 0; +} + +int SetARM11StorageInfoExtSaveDataId(exhdr_ARM11SystemLocalCapabilities *arm11, rsf_settings *yaml) +{ + if(yaml->AccessControlInfo.ExtSaveDataId){ + if(!yaml->AccessControlInfo.UseExtSaveData){ + fprintf(stderr,"[EXHEADER ERROR] Failed to set ExtSaveDataId. UseExtSaveData must be true.\n"); + return EXHDR_BAD_YAML_OPT; + } + u32 ExtdataIdLow = strtoul(yaml->AccessControlInfo.ExtSaveDataId,NULL,0); + u32_to_u8(arm11->StorageInfo.ExtSaveDataId,ExtdataIdLow,LE); + } + return 0; +} + +int SetARM11StorageInfoOtherUserSaveData(exhdr_ARM11SystemLocalCapabilities *arm11, rsf_settings *yaml) +{ + u64 Value = 0; + if(yaml->AccessControlInfo.OtherUserSaveDataId1) + Value = 0xffffff & strtoul(yaml->AccessControlInfo.OtherUserSaveDataId1,NULL,0); + Value = Value << 20; + if(yaml->AccessControlInfo.OtherUserSaveDataId2) + Value |= 0xffffff & strtoul(yaml->AccessControlInfo.OtherUserSaveDataId2,NULL,0); + Value = Value << 20; + if(yaml->AccessControlInfo.OtherUserSaveDataId3) + Value |= 0xffffff & strtoul(yaml->AccessControlInfo.OtherUserSaveDataId3,NULL,0); + + /* UseOtherVariationSaveData Flag */ + if(yaml->AccessControlInfo.UseOtherVariationSaveData){ + Value |= 0x1000000000000000; + } + u64_to_u8(arm11->StorageInfo.StorageAccessableUniqueIds,Value,LE); + return 0; +} + +bool CheckCondiditionsForNewAccessibleSaveDataIds(rsf_settings *yaml) +{ + if(!yaml->AccessControlInfo.UseExtendedSaveDataAccessControl){ + if(yaml->AccessControlInfo.AccessibleSaveDataIds) + fprintf(stderr,"[EXHEADER ERROR] AccessibleSaveDataIds is unavailable if UseExtendedSaveDataAccessControl is false.\n"); + return false; + } + + if(yaml->AccessControlInfo.AccessibleSaveDataIdsNum > 6){ + fprintf(stderr,"[EXHEADER ERROR] Too many UniqueId in \"AccessibleSaveDataIds\".\n"); + return false; + } + + if(yaml->AccessControlInfo.UseExtSaveData){ + fprintf(stderr,"[EXHEADER ERROR] UseExtSaveData must be false if AccessibleSaveDataIds is specified.\n"); + return false; + } + if (yaml->AccessControlInfo.ExtSaveDataId){ + fprintf(stderr,"[EXHEADER ERROR] ExtSaveDataId is unavailable if AccessibleSaveDataIds is specified.\n"); + return false; + } + if (yaml->AccessControlInfo.OtherUserSaveDataId1){ + if(strtoul(yaml->AccessControlInfo.OtherUserSaveDataId1,NULL,0) > 0){ + fprintf(stderr,"[EXHEADER ERROR] OtherUserSaveDataId1 must be 0 if AccessibleSaveDataIds is specified.\n"); + return false; + } + } + if (yaml->AccessControlInfo.OtherUserSaveDataId2){ + if(strtoul(yaml->AccessControlInfo.OtherUserSaveDataId2,NULL,0) > 0){ + fprintf(stderr,"[EXHEADER ERROR] OtherUserSaveDataId2 must be 0 if AccessibleSaveDataIds is specified.\n"); + return false; + } + } + if (yaml->AccessControlInfo.OtherUserSaveDataId3){ + if(strtoul(yaml->AccessControlInfo.OtherUserSaveDataId3,NULL,0) > 0){ + fprintf(stderr,"[EXHEADER ERROR] OtherUserSaveDataId3 must be 0 if AccessibleSaveDataIds is specified.\n"); + return false; + } + } + return true; +} + +int SetARM11StorageInfoAccessibleSaveDataIds(exhdr_ARM11SystemLocalCapabilities *arm11, rsf_settings *yaml) +{ + u64 RegionExtSaveDataId = 0; + u64 RegionOtherUseSaveData = 0; + + if(yaml->AccessControlInfo.AccessibleSaveDataIdsNum > 0){ + u32 Max = yaml->AccessControlInfo.AccessibleSaveDataIdsNum < 3 ? yaml->AccessControlInfo.AccessibleSaveDataIdsNum : 3; + for(int i = 0; i < Max; i++){ + u32 UniqueID = 0xffffff & strtoul(yaml->AccessControlInfo.AccessibleSaveDataIds[i],NULL,0); + RegionOtherUseSaveData = RegionOtherUseSaveData << 20; + RegionOtherUseSaveData |= UniqueID; + } + } + if(yaml->AccessControlInfo.AccessibleSaveDataIdsNum > 3){ + for(int i = 3; i < yaml->AccessControlInfo.AccessibleSaveDataIdsNum; i++){ + u32 UniqueID = 0xffffff & strtoul(yaml->AccessControlInfo.AccessibleSaveDataIds[i],NULL,0); + RegionExtSaveDataId = RegionExtSaveDataId << 20; + RegionExtSaveDataId |= UniqueID; + } + } + + arm11->StorageInfo.OtherAttributes |= 1 << USE_EXTENDED_SAVEDATA_ACCESS_CONTROL; + + /* UseOtherVariationSaveData Flag */ + if(yaml->AccessControlInfo.UseOtherVariationSaveData){ + RegionOtherUseSaveData |= 0x1000000000000000; + } + + u64_to_u8(arm11->StorageInfo.ExtSaveDataId,RegionExtSaveDataId,LE); + u64_to_u8(arm11->StorageInfo.StorageAccessableUniqueIds,RegionOtherUseSaveData,LE); + return 0; +} + +int SetARM11ServiceAccessControl(exhdr_ARM11SystemLocalCapabilities *arm11, rsf_settings *yaml) +{ + if(yaml->AccessControlInfo.ServiceAccessControl){ + if(yaml->AccessControlInfo.ServiceAccessControlNum > 32){ + fprintf(stderr,"[EXHEADER ERROR] Too Many SVC Handles, maximum is 32\n"); + return EXHDR_BAD_YAML_OPT; + } + for(int i = 0; i < yaml->AccessControlInfo.ServiceAccessControlNum; i++){ + int svc_handle_len = strlen(yaml->AccessControlInfo.ServiceAccessControl[i]); + if(svc_handle_len > 8){ + fprintf(stderr,"[EXHEADER ERROR] SVC Handle: '%s' is too long\n",yaml->AccessControlInfo.ServiceAccessControl[i]); + return EXHDR_BAD_YAML_OPT; + } + memcpy(arm11->ServiceAccessControl[i],yaml->AccessControlInfo.ServiceAccessControl[i],svc_handle_len); + } + } + else{ + fprintf(stderr,"[EXHEADER ERROR] Parameter Not Found: 'AccessControlInfo/ServiceAccessControl'\n"); + return EXHDR_BAD_YAML_OPT; + } + return 0; +} + +int get_ExHeaderARM11KernelInfo(exhdr_ARM11KernelCapabilities *arm11, rsf_settings *yaml) +{ + int result = 0; + ARM11KernelCapabilityDescriptor desc[6]; + memset(&desc,0,sizeof(ARM11KernelCapabilityDescriptor)*6); + + /* Get Descriptors */ + result = SetARM11KernelDescSysCallControl(&desc[0],yaml); + if(result) goto finish; + result = SetARM11KernelDescInteruptNumList(&desc[1],yaml); + if(result) goto finish; + result = SetARM11KernelDescAddressMapping(&desc[2],yaml); + if(result) goto finish; + result = SetARM11KernelDescOtherCapabilities(&desc[3],yaml); + if(result) goto finish; + result = SetARM11KernelDescHandleTableSize(&desc[4],yaml); + if(result) goto finish; + result = SetARM11KernelDescReleaseKernelVersion(&desc[5],yaml); + + /* Write Descriptors To Exheader */ + u16 TotalDesc = 0; + for(int i = 0; i < 6; i++){ + TotalDesc += desc[i].num; + } + if(TotalDesc >= 28){ + fprintf(stderr,"[EXHEADER ERROR] Too many Kernel Capabilities.\n"); + result = EXHDR_BAD_YAML_OPT; + goto finish; + } + u16 DescIndex = 0; + for(int i = 0; i < 6; i++){ + for(int j = 0; j < desc[i].num; j++){ + u32_to_u8(arm11->descriptors[DescIndex],desc[i].Data[j],LE); + DescIndex++; + } + } + + /* Fill Remaining Descriptors with 0xffffffff */ + for(int i = DescIndex; i < 28; i++){ + u32_to_u8(arm11->descriptors[i],0xffffffff,LE); + } + +finish: + for(int i = 0; i < 6; i++){ + free(desc[i].Data); + } + return result; +} + +int SetARM11KernelDescSysCallControl(ARM11KernelCapabilityDescriptor *desc, rsf_settings *yaml) +{ + int ret = 0; + + // Create Temporary Descriptor + ARM11KernelCapabilityDescriptor tmp; + memset(&tmp,0,sizeof(ARM11KernelCapabilityDescriptor)); + + AllocateARM11KernelDescMemory(&tmp,8); + for(int i = 0; i < 8; i++) + SetARM11KernelDescValue(&tmp,i,desc_SysCallControl | (i << 24)); + + // Get SysCalls + ret = GetARM11SysCalls(&tmp,yaml); + if(ret) goto finish; + + // Count Active Syscall Descs + u16 ActiveSysCallDesc = 0; + for(int i = 0; i < 8; i++) + if((tmp.Data[i] & 0x00ffffff) != 0) + ActiveSysCallDesc++; + + // Transfer Active Syscall Descs to out Descriptor + AllocateARM11KernelDescMemory(desc,ActiveSysCallDesc); + u16 SysCallDescPos = 0; + for(int i = 0; i < 8; i++){ + if((tmp.Data[i] & 0x00ffffff) != 0) { + SetARM11KernelDescValue(desc,SysCallDescPos,tmp.Data[i]); + SysCallDescPos++; + } + } + +finish: + // Free data in Temporary Descriptor + free(tmp.Data); + return ret; +} + +int GetARM11SysCalls(ARM11KernelCapabilityDescriptor *desc, rsf_settings *yaml) +{ + if(!yaml->AccessControlInfo.SystemCallAccess){ + fprintf(stderr,"[EXHEADER ERROR] Parameter not found: 'AccessControlInfo/SystemCallAccess'\n"); + return EXHDR_BAD_YAML_OPT; + } + for(int i = 0; i < yaml->AccessControlInfo.SystemCallAccessNum; i++){ + int SysCall = strtoul(yaml->AccessControlInfo.SystemCallAccess[i],NULL,0); + if(SysCall > 184){ + fprintf(stderr,"[EXHEADER ERROR] Unexpected Syscall: 0x%02x. Expected Range: 0x00 - 0xB8\n",SysCall); + return EXHDR_BAD_YAML_OPT; + } + EnableSystemCall(desc,SysCall); + } + + return 0; +} + +void EnableSystemCall(ARM11KernelCapabilityDescriptor *desc, int SysCall) +{ + int num = SysCall / 24; + int num1 = SysCall % 24; + desc->Data[num] |= 1 << (num1 & 31); +} + +void DisableSystemCall(ARM11KernelCapabilityDescriptor *desc, int SysCall) +{ + int num = SysCall / 24; + int num1 = SysCall % 24; + desc->Data[num] = desc->Data[num] & ~(1 << (num1 & 31)); +} + +int SetARM11KernelDescInteruptNumList(ARM11KernelCapabilityDescriptor *desc, rsf_settings *yaml) +{ + int ret = 0; + + // Create Temporary Descriptor + ARM11KernelCapabilityDescriptor tmp; + memset(&tmp,0,sizeof(ARM11KernelCapabilityDescriptor)); + + AllocateARM11KernelDescMemory(&tmp,8); + + // Get Interupts + ret = GetARM11Interupts(&tmp,yaml); + if(ret) goto finish; + + // Count Active Interupt Descs + u16 ActiveInteruptDesc = 0; + for(int i = 0; i < 8; i++) + if(tmp.Data[i]) + ActiveInteruptDesc++; + + // Transfer Active Interupt Descs to output Descriptor + AllocateARM11KernelDescMemory(desc,ActiveInteruptDesc); + u16 InteruptDescPos = 0; + for(int i = 0; i < 8; i++){ + if(tmp.Data[i]) { + SetARM11KernelDescValue(desc,InteruptDescPos,(tmp.Data[i] & 0x0fffffff) | desc_InteruptNumList); + InteruptDescPos++; + } + } + +finish: + // Free data in Temporary Descriptor + free(tmp.Data); + return ret; +} + +int GetARM11Interupts(ARM11KernelCapabilityDescriptor *desc, rsf_settings *yaml) +{ + if(!yaml->AccessControlInfo.InterruptNumbers){ + return 0; + } + if(yaml->AccessControlInfo.InterruptNumbersNum > 32){ + fprintf(stderr,"[EXHEADER ERROR] Too many Interupts. Maximum is 32\n"); + return EXHDR_BAD_YAML_OPT; + } + for(int i = 0; i < yaml->AccessControlInfo.InterruptNumbersNum; i++){ + int Interrupt = strtoul(yaml->AccessControlInfo.InterruptNumbers[i],NULL,0); + if(Interrupt > 0x7f){ + fprintf(stderr,"[EXHEADER ERROR] Unexpected Interupt: 0x%02x. Expected Range: 0x00 - 0x7f\n",Interrupt); + return EXHDR_BAD_YAML_OPT; + } + EnableInterupt(desc,Interrupt,i); + } + + return 0; +} + +void EnableInterupt(ARM11KernelCapabilityDescriptor *desc, int Interrupt, int i) +{ + int num = i / 4; + if(num*4 == i) desc->Data[num] |= 0xffffffff; + desc->Data[num] = desc->Data[num] << 7; + desc->Data[num] |= Interrupt; +} + +int SetARM11KernelDescAddressMapping(ARM11KernelCapabilityDescriptor *desc, rsf_settings *yaml) +{ + int ret = 0; + // Create Temporary Descriptors + ARM11KernelCapabilityDescriptor io_tmp; + memset(&io_tmp,0,sizeof(ARM11KernelCapabilityDescriptor)); + ARM11KernelCapabilityDescriptor static_tmp; + memset(&static_tmp,0,sizeof(ARM11KernelCapabilityDescriptor)); + + // Getting IO Mapping + ret = GetARM11IOMappings(&io_tmp,yaml); + if(ret) goto finish; + + // Getting Static Mapping + ret = GetARM11StaticMappings(&static_tmp,yaml); + if(ret) goto finish; + + + // Creating Output Descriptor and Combining the two MemMap Descriptors + AllocateARM11KernelDescMemory(desc,io_tmp.num+static_tmp.num); + u16 MemMapDescPos = 0; + for(int i = 0; i < io_tmp.num; i++){ + SetARM11KernelDescValue(desc,MemMapDescPos,io_tmp.Data[i]); + MemMapDescPos++; + } + for(int i = 0; i < static_tmp.num; i++){ + SetARM11KernelDescValue(desc,MemMapDescPos,static_tmp.Data[i]); + MemMapDescPos++; + } + +finish: + free(io_tmp.Data); + free(static_tmp.Data); + return ret; +} + +int GetARM11IOMappings(ARM11KernelCapabilityDescriptor *desc, rsf_settings *yaml) +{ + if(!yaml->AccessControlInfo.IORegisterMapping) + return 0; + + AllocateARM11KernelDescMemory(desc,yaml->AccessControlInfo.IORegisterMappingNum*2); + u16 DescUsed = 0; + for(int i = 0; i < yaml->AccessControlInfo.IORegisterMappingNum; i++){ + if(strlen(yaml->AccessControlInfo.IORegisterMapping[i])){ + char *AddressStartStr = yaml->AccessControlInfo.IORegisterMapping[i]; + char *AddressEndStr = strstr(AddressStartStr,"-"); + if(AddressEndStr){ + if(strlen(AddressEndStr) > 1) + AddressEndStr = (AddressEndStr+1); + else + AddressEndStr = NULL; + } + u32 AddressStart = strtoul(AddressStartStr,NULL,16); + if(!IsStartAddress(AddressStart)){ + fprintf(stderr,"[EXHEADER ERROR] Address 0x%x is not valid mapping start address.\n",AddressStart); + return EXHDR_BAD_YAML_OPT; + } + if(!AddressEndStr){ // No End Addr Was Specified + SetARM11KernelDescValue(desc,DescUsed,GetIOMappingDesc(AddressStart)); + DescUsed++; + goto skip; + } + + u32 AddressEnd = strtoul(AddressEndStr,NULL,16); + if(!IsEndAddress(AddressEnd)){ + fprintf(stderr,"[EXHEADER ERROR] Address 0x%x is not valid mapping end address.\n",AddressEnd); + return EXHDR_BAD_YAML_OPT; + } + + u32 DescStartAddr = GetStaticMappingDesc(AddressStart,false); + u32 DescEndAddr = GetStaticMappingDesc(AddressEnd+0x1000,false); + if(DescStartAddr != DescEndAddr){ + SetARM11KernelDescValue(desc,DescUsed,DescStartAddr); + SetARM11KernelDescValue(desc,DescUsed+1,DescEndAddr); + DescUsed += 2; + goto skip; + } + else{ + SetARM11KernelDescValue(desc,DescUsed,GetIOMappingDesc(AddressStart)); + DescUsed++; + goto skip; + } + } + + skip: ; + } + desc->num = DescUsed; + return 0; +} + +int GetARM11StaticMappings(ARM11KernelCapabilityDescriptor *desc, rsf_settings *yaml) +{ + if(!yaml->AccessControlInfo.MemoryMapping) + return 0; + + AllocateARM11KernelDescMemory(desc,yaml->AccessControlInfo.MemoryMappingNum*2); + u16 DescUsed = 0; + for(int i = 0; i < yaml->AccessControlInfo.MemoryMappingNum; i++){ + if(strlen(yaml->AccessControlInfo.MemoryMapping[i])){ + char *AddressStartStr = yaml->AccessControlInfo.MemoryMapping[i]; + char *AddressEndStr = strstr(AddressStartStr,"-"); + char *ROFlagStr = strstr(AddressStartStr,":"); + bool IsRO = false; + if(ROFlagStr) + IsRO = strcasecmp(ROFlagStr,":r") == 0 ? true : false; + + if(AddressEndStr){ + if(strlen(AddressEndStr) > 1) { + AddressEndStr = (AddressEndStr+1); + if(AddressEndStr == ROFlagStr) + AddressEndStr = NULL; + } + else + AddressEndStr = NULL; + } + u32 AddressStart = strtoul(AddressStartStr,NULL,16); + if(!IsStartAddress(AddressStart)){ + fprintf(stderr,"[EXHEADER ERROR] Address 0x%x (%s) is not valid mapping start address.\n",AddressStart,AddressStartStr); + return EXHDR_BAD_YAML_OPT; + } + if(!AddressEndStr){ // No End Addr Was Specified + SetARM11KernelDescValue(desc,DescUsed,GetStaticMappingDesc(AddressStart,IsRO)); + SetARM11KernelDescValue(desc,DescUsed+1,GetStaticMappingDesc(AddressStart+0x1000, true)); + DescUsed += 2; + goto skip; + } + + u32 AddressEnd = strtoul(AddressEndStr,NULL,16); + if(!IsEndAddress(AddressEnd)){ + fprintf(stderr,"[EXHEADER ERROR] Address 0x%x (%s) is not valid mapping end address.\n",AddressEnd,AddressEndStr); + return EXHDR_BAD_YAML_OPT; + } + + u32 DescStartAddr = GetStaticMappingDesc(AddressStart,IsRO); + u32 DescEndAddr = GetStaticMappingDesc(AddressEnd+0x1000,true); + if(DescStartAddr != DescEndAddr){ + SetARM11KernelDescValue(desc,DescUsed,DescStartAddr); + SetARM11KernelDescValue(desc,DescUsed+1,DescEndAddr); + DescUsed += 2; + goto skip; + } + else{ + SetARM11KernelDescValue(desc,DescUsed,GetStaticMappingDesc(AddressStart,IsRO)); + SetARM11KernelDescValue(desc,DescUsed+1,GetStaticMappingDesc(AddressStart+0x1000, true)); + DescUsed += 2; + goto skip; + } + } + + skip: ; + } + desc->num = DescUsed; + return 0; +} + +bool IsEndAddress(u32 Address) +{ + return (Address & 0xfff) == 0xfff; +} + +bool IsStartAddress(u32 Address) +{ + return (Address & 0xfff) == 0; +} + +u32 GetIOMappingDesc(u32 Address) +{ + return GetMappingDesc(Address,0xFFE,0xC,false); +} + +u32 GetStaticMappingDesc(u32 Address, bool IsReadOnly) +{ + return GetMappingDesc(Address,0x7FC,0xB,IsReadOnly); +} + +u32 GetMappingDesc(u32 Address, u32 PrefixVal, s32 numPrefixBits, bool IsRO) +{ + u32 PrefixMask = GetDescPrefixMask(numPrefixBits); + u32 PrefixBits = GetDescPrefixBits(numPrefixBits,PrefixVal); + u32 Desc = (Address >> 12 & ~PrefixMask) | PrefixBits; + if (IsRO) + Desc |= 0x100000; + return Desc; +} + +int SetARM11KernelDescOtherCapabilities(ARM11KernelCapabilityDescriptor *desc, rsf_settings *yaml) +{ + u32 OtherCapabilities = 0; + + if(!yaml->AccessControlInfo.DisableDebug) + OtherCapabilities |= 1 << PERMIT_DEBUG; + if(yaml->AccessControlInfo.EnableForceDebug) + OtherCapabilities |= 1 << FORCE_DEBUG; + if(yaml->AccessControlInfo.CanUseNonAlphabetAndNumber) + OtherCapabilities |= 1 << CAN_USE_NON_ALPHABET_AND_NUMBER; + if(yaml->AccessControlInfo.CanWriteSharedPage) + OtherCapabilities |= 1 << CAN_WRITE_SHARED_PAGE; + if(yaml->AccessControlInfo.CanUsePrivilegedPriority) + OtherCapabilities |= 1 << CAN_USE_PRIVILEGE_PRIORITY; + if(yaml->AccessControlInfo.PermitMainFunctionArgument) + OtherCapabilities |= 1 << PERMIT_MAIN_FUNCTION_ARGUMENT; + if(yaml->AccessControlInfo.CanShareDeviceMemory) + OtherCapabilities |= 1 << CAN_SHARE_DEVICE_MEMORY; + if(yaml->AccessControlInfo.RunnableOnSleep) + OtherCapabilities |= 1 << RUNNABLE_ON_SLEEP; + if(yaml->AccessControlInfo.SpecialMemoryArrange) + OtherCapabilities |= 1 << SPECIAL_MEMORY_ARRANGE; + + if(yaml->AccessControlInfo.MemoryType){ + u32 MemType = 0; + if(strcasecmp(yaml->AccessControlInfo.MemoryType,"application") == 0) + MemType = memtype_APPLICATION; + else if(strcasecmp(yaml->AccessControlInfo.MemoryType,"system") == 0) + MemType = memtype_SYSTEM; + else if(strcasecmp(yaml->AccessControlInfo.MemoryType,"base") == 0) + MemType = memtype_BASE; + else{ + fprintf(stderr,"[EXHEADER ERROR] Invalid memory type: '%s'\n",yaml->AccessControlInfo.MemoryType); + return EXHDR_BAD_YAML_OPT; + } + OtherCapabilities = (OtherCapabilities & -3841) | MemType << 8; + } + + if(OtherCapabilities){ + AllocateARM11KernelDescMemory(desc,1); + SetARM11KernelDescBitmask(desc,desc_OtherCapabilities); + SetARM11KernelDescValue(desc,0,OtherCapabilities); + } + return 0; +} + +int SetARM11KernelDescHandleTableSize(ARM11KernelCapabilityDescriptor *desc, rsf_settings *yaml) +{ + if(yaml->AccessControlInfo.HandleTableSize){ + u16 HandleTableSize = strtoul(yaml->AccessControlInfo.HandleTableSize,NULL,0); + if(HandleTableSize > 1023){ + fprintf(stderr,"[EXHEADER ERROR] Too large handle table size\n"); + return EXHDR_BAD_YAML_OPT; + } + AllocateARM11KernelDescMemory(desc,1); + SetARM11KernelDescBitmask(desc,desc_HandleTableSize); + SetARM11KernelDescValue(desc,0,HandleTableSize); + } + else{ + fprintf(stderr,"[EXHEADER ERROR] Parameter Not Found: 'AccessControlInfo/HandleTableSize'\n"); + return EXHDR_BAD_YAML_OPT; + } + return 0; +} + +int SetARM11KernelDescReleaseKernelVersion(ARM11KernelCapabilityDescriptor *desc, rsf_settings *yaml) +{ + if(yaml->AccessControlInfo.ReleaseKernelMajor && yaml->AccessControlInfo.ReleaseKernelMinor){ + u32 releaseKernelMajor = strtoul(yaml->AccessControlInfo.ReleaseKernelMajor,NULL,0); + u32 releaseKernelMinor = strtoul(yaml->AccessControlInfo.ReleaseKernelMinor,NULL,0); + if (releaseKernelMajor > 255 || releaseKernelMinor > 255){ + fprintf(stderr,"[EXHEADER ERROR] Invalid release kernel version"); + } + AllocateARM11KernelDescMemory(desc,1); + SetARM11KernelDescBitmask(desc,desc_KernelReleaseVersion); + SetARM11KernelDescValue(desc,0,(releaseKernelMajor << 8 | releaseKernelMinor)); + } + return 0; +} + +void SetARM11KernelDescValue(ARM11KernelCapabilityDescriptor *desc, u16 Index, u32 Value) +{ + if(Index >= desc->num) return; + desc->Data[Index] |= Value; +} + +void SetARM11KernelDescBitmask(ARM11KernelCapabilityDescriptor *desc, u32 Bitmask) +{ + for(int i = 0; i < desc->num; i++) + SetARM11KernelDescValue(desc,i,Bitmask); +} + +void AllocateARM11KernelDescMemory(ARM11KernelCapabilityDescriptor *desc, u16 Num) +{ + if(Num == 0) return; + desc->num = Num; + desc->Data = malloc(sizeof(u32)*Num); + memset(desc->Data,0,sizeof(u32)*Num); + return; +} + +u32 GetDescPrefixMask(int numPrefixBits) +{ + return (u32)(~((1 << (32 - (numPrefixBits & 31))) - 1)); +} + +u32 GetDescPrefixBits(int numPrefixBits, u32 PrefixVal) +{ + return PrefixVal << (32 - (numPrefixBits & 31)); +} + +int get_ExHeaderARM9AccessControlInfo(exhdr_ARM9AccessControlInfo *arm9, rsf_settings *yaml) +{ + u32 Arm9AccessControl = 0; + for(int i = 0; i < yaml->AccessControlInfo.IoAccessControlNum; i++){ + if(strcmp(yaml->AccessControlInfo.IoAccessControl[i],"FsMountNand") == 0) + Arm9AccessControl |= 1 << FS_MOUNT_NAND; + else if(strcmp(yaml->AccessControlInfo.IoAccessControl[i],"FsMountNandRoWrite") == 0) + Arm9AccessControl |= 1 << FS_MOUNT_NAND_RO_WRITE; + else if(strcmp(yaml->AccessControlInfo.IoAccessControl[i],"FsMountTwln") == 0) + Arm9AccessControl |= 1 << FS_MOUNT_TWLN; + else if(strcmp(yaml->AccessControlInfo.IoAccessControl[i],"FsMountWnand") == 0) + Arm9AccessControl |= 1 << FS_MOUNT_WNAND; + else if(strcmp(yaml->AccessControlInfo.IoAccessControl[i],"FsMountCardSpi") == 0) + Arm9AccessControl |= 1 << FS_MOUNT_CARD_SPI; + else if(strcmp(yaml->AccessControlInfo.IoAccessControl[i],"UseSdif3") == 0) + Arm9AccessControl |= 1 << USE_SDIF3; + else if(strcmp(yaml->AccessControlInfo.IoAccessControl[i],"CreateSeed") == 0) + Arm9AccessControl |= 1 << CREATE_SEED; + else if(strcmp(yaml->AccessControlInfo.IoAccessControl[i],"UseCardSpi") == 0) + Arm9AccessControl |= 1 << USE_CARD_SPI; + else{ + fprintf(stderr,"[EXHEADER ERROR] Invalid IoAccessControl Name: '%s'\n",yaml->AccessControlInfo.IoAccessControl[i]); + return EXHDR_BAD_YAML_OPT; + } + } + + for(int i = 0; i < yaml->AccessControlInfo.FileSystemAccessNum; i++){ + if(strcmp(yaml->AccessControlInfo.FileSystemAccess[i],"DirectSdmc") == 0) + Arm9AccessControl |= 1 << USE_DIRECT_SDMC; + } + + if(yaml->Option.UseOnSD) + Arm9AccessControl |= 1 << SD_APPLICATION; + + u32_to_u8(arm9->descriptors,Arm9AccessControl,LE); + + if(yaml->AccessControlInfo.DescVersion){ + arm9->descriptors[15] = strtol(yaml->AccessControlInfo.DescVersion,NULL,0); + } + else{ + fprintf(stderr,"[EXHEADER ERROR] Parameter Not Found: 'AccessControlInfo/DescVersion'\n"); + return EXHDR_BAD_YAML_OPT; + } + + return 0; +} + + + int set_AccessDesc(exheader_settings *exhdrset, ncch_settings *ncchset) { switch(ncchset->Options.accessdesc){ @@ -300,26 +1181,10 @@ int set_AccessDesc(exheader_settings *exhdrset, ncch_settings *ncchset) memcpy(&exhdrset->ExHdr->AccessDescriptor.ARM9AccessControlInfo,&exhdrset->ExHdr->ARM9AccessControlInfo,sizeof(exhdr_ARM9AccessControlInfo)); /* Sign AccessDesc */ return SignAccessDesc(exhdrset->ExHdr,exhdrset->keys); -#ifndef RETAIL_FSIGN - case app : - memcpy(ncchset->CxiRsaKey.PrivK,(u8*)App_HdrPrivK,0x100); - memcpy(ncchset->CxiRsaKey.PubK,(u8*)App_HdrPubK,0x100); - memcpy(&exhdrset->ExHdr->AccessDescriptor.signature,(u8*)App_AcexData,0x400); - return 0; - case demo : - memcpy(ncchset->CxiRsaKey.PrivK,(u8*)Demo_HdrPrivK,0x100); - memcpy(ncchset->CxiRsaKey.PubK,(u8*)Demo_HdrPubK,0x100); - memcpy(&exhdrset->ExHdr->AccessDescriptor.signature,(u8*)Demo_AcexData,0x400); - return 0; - case dlp : - memcpy(ncchset->CxiRsaKey.PrivK,(u8*)Dlp_HdrPrivK,0x100); - memcpy(ncchset->CxiRsaKey.PubK,(u8*)Dlp_HdrPubK,0x100); - memcpy(&exhdrset->ExHdr->AccessDescriptor.signature,(u8*)Dlp_AcexData,0x400); - return 0; - case use_desc_file: + case use_spec_file: /* Yaml Option Sanity Checks */ if(!exhdrset->yaml->CommonHeaderKey.Found){ - fprintf(stderr,"[EXHEADER ERROR] Desc Section 'CommonHeaderKey' not found\n"); + fprintf(stderr,"[EXHEADER ERROR] RSF Section 'CommonHeaderKey' not found\n"); return COMMON_HEADER_KEY_NOT_FOUND; } if(!exhdrset->yaml->CommonHeaderKey.D){ @@ -338,20 +1203,20 @@ int set_AccessDesc(exheader_settings *exhdrset, ncch_settings *ncchset) fprintf(stderr,"[EXHEADER ERROR] 'CommonHeaderKey/Modulus' has invalid length (%d)\n",strlen(exhdrset->yaml->CommonHeaderKey.Modulus)); return COMMON_HEADER_KEY_NOT_FOUND; } - if(!exhdrset->yaml->AccessControlDescriptor.AccCtlDescSign){ - fprintf(stderr,"[EXHEADER ERROR] 'AccessControlDescriptor/Signature' not found\n"); + if(!exhdrset->yaml->CommonHeaderKey.AccCtlDescSign){ + fprintf(stderr,"[EXHEADER ERROR] 'CommonHeaderKey/Signature' not found\n"); return COMMON_HEADER_KEY_NOT_FOUND; } - if(strlen(exhdrset->yaml->AccessControlDescriptor.AccCtlDescSign) != 350){ - fprintf(stderr,"[EXHEADER ERROR] 'AccessControlDescriptor/Signature' has invalid length (%d)\n",strlen(exhdrset->yaml->AccessControlDescriptor.AccCtlDescSign)); + if(strlen(exhdrset->yaml->CommonHeaderKey.AccCtlDescSign) != 350){ + fprintf(stderr,"[EXHEADER ERROR] 'CommonHeaderKey/Signature' has invalid length (%d)\n",strlen(exhdrset->yaml->CommonHeaderKey.AccCtlDescSign)); return COMMON_HEADER_KEY_NOT_FOUND; } - if(!exhdrset->yaml->AccessControlDescriptor.AccCtlDescBin){ - fprintf(stderr,"[EXHEADER ERROR] 'AccessControlDescriptor/Descriptor' not found\n"); + if(!exhdrset->yaml->CommonHeaderKey.AccCtlDescBin){ + fprintf(stderr,"[EXHEADER ERROR] 'CommonHeaderKey/Descriptor' not found\n"); return COMMON_HEADER_KEY_NOT_FOUND; } - if(strlen(exhdrset->yaml->AccessControlDescriptor.AccCtlDescBin) != 696){ - fprintf(stderr,"[EXHEADER ERROR] 'AccessControlDescriptor/Descriptor' has invalid length (%d)\n",strlen(exhdrset->yaml->AccessControlDescriptor.AccCtlDescBin)); + if(strlen(exhdrset->yaml->CommonHeaderKey.AccCtlDescBin) != 695){ + fprintf(stderr,"[EXHEADER ERROR] 'CommonHeaderKey/Descriptor' has invalid length (%d)\n",strlen(exhdrset->yaml->CommonHeaderKey.AccCtlDescBin)); return COMMON_HEADER_KEY_NOT_FOUND; } /* Set RSA Keys */ @@ -367,17 +1232,33 @@ int set_AccessDesc(exheader_settings *exhdrset, ncch_settings *ncchset) memcpy(ncchset->CxiRsaKey.PrivK,tmp,0x100); /* Set AccessDesc */ out = 0x500; - result = base64_decode(tmp,&out,(const u8*)exhdrset->yaml->AccessControlDescriptor.AccCtlDescSign,strlen(exhdrset->yaml->AccessControlDescriptor.AccCtlDescSign)); + result = base64_decode(tmp,&out,(const u8*)exhdrset->yaml->CommonHeaderKey.AccCtlDescSign,strlen(exhdrset->yaml->CommonHeaderKey.AccCtlDescSign)); if(result) goto finish; memcpy(exhdrset->ExHdr->AccessDescriptor.signature,tmp,0x100); memcpy(exhdrset->ExHdr->AccessDescriptor.ncchpubkeymodulus,ncchset->CxiRsaKey.PubK,0x100); out = 0x500; - result = base64_decode(tmp,&out,(const u8*)exhdrset->yaml->AccessControlDescriptor.AccCtlDescBin,strlen(exhdrset->yaml->AccessControlDescriptor.AccCtlDescBin)); + result = base64_decode(tmp,&out,(const u8*)exhdrset->yaml->CommonHeaderKey.AccCtlDescBin,strlen(exhdrset->yaml->CommonHeaderKey.AccCtlDescBin)); if(result) goto finish; memcpy(&exhdrset->ExHdr->AccessDescriptor.ARM11SystemLocalCapabilities,tmp,0x200); finish: free(tmp); - return result; + return result; +#ifndef RETAIL_FSIGN + case app : + memcpy(ncchset->CxiRsaKey.PrivK,(u8*)App_sdk5_HdrPrivK,0x100); + memcpy(ncchset->CxiRsaKey.PubK,(u8*)App_sdk5_HdrPubK,0x100); + memcpy(&exhdrset->ExHdr->AccessDescriptor.signature,(u8*)App_sdk5_AcexData,0x400); + return 0; + case demo : + memcpy(ncchset->CxiRsaKey.PrivK,(u8*)Demo_sdk5_HdrPrivK,0x100); + memcpy(ncchset->CxiRsaKey.PubK,(u8*)Demo_sdk5_HdrPubK,0x100); + memcpy(&exhdrset->ExHdr->AccessDescriptor.signature,(u8*)Demo_sdk5_AcexData,0x400); + return 0; + case dlp : + memcpy(ncchset->CxiRsaKey.PrivK,(u8*)Dlp_sdk5_HdrPrivK,0x100); + memcpy(ncchset->CxiRsaKey.PubK,(u8*)Dlp_sdk5_HdrPubK,0x100); + memcpy(&exhdrset->ExHdr->AccessDescriptor.signature,(u8*)Dlp_sdk5_AcexData,0x400); + return 0; #endif } return 0; @@ -441,22 +1322,22 @@ int GetDependancyList_frm_exhdr(u8 *Dest,ExtendedHeader_Struct *hdr) int GetSaveDataSize_yaml(u64 *SaveDataSize, user_settings *usrset) { - if(usrset->yaml_set.DefaultSpec.Rom.SaveDataSize){ - *SaveDataSize = strtoull(usrset->yaml_set.DefaultSpec.Rom.SaveDataSize,NULL,10); - if(strstr(usrset->yaml_set.DefaultSpec.Rom.SaveDataSize,"K")){ - char *str = strstr(usrset->yaml_set.DefaultSpec.Rom.SaveDataSize,"K"); + if(usrset->yaml_set.Rom.SaveDataSize){ + *SaveDataSize = strtoull(usrset->yaml_set.Rom.SaveDataSize,NULL,10); + if(strstr(usrset->yaml_set.Rom.SaveDataSize,"K")){ + char *str = strstr(usrset->yaml_set.Rom.SaveDataSize,"K"); if(strcmp(str,"K") == 0 || strcmp(str,"KB") == 0 ){ *SaveDataSize = *SaveDataSize*KB; } } - else if(strstr(usrset->yaml_set.DefaultSpec.Rom.SaveDataSize,"M")){ - char *str = strstr(usrset->yaml_set.DefaultSpec.Rom.SaveDataSize,"M"); + else if(strstr(usrset->yaml_set.Rom.SaveDataSize,"M")){ + char *str = strstr(usrset->yaml_set.Rom.SaveDataSize,"M"); if(strcmp(str,"M") == 0 || strcmp(str,"MB") == 0 ){ *SaveDataSize = *SaveDataSize*MB; } } - else if(strstr(usrset->yaml_set.DefaultSpec.Rom.SaveDataSize,"G")){ - char *str = strstr(usrset->yaml_set.DefaultSpec.Rom.SaveDataSize,"G"); + else if(strstr(usrset->yaml_set.Rom.SaveDataSize,"G")){ + char *str = strstr(usrset->yaml_set.Rom.SaveDataSize,"G"); if(strcmp(str,"G") == 0 || strcmp(str,"GB") == 0 ){ *SaveDataSize = *SaveDataSize*GB; } @@ -478,11 +1359,11 @@ int GetSaveDataSize_yaml(u64 *SaveDataSize, user_settings *usrset) int GetRemasterVersion_yaml(u16 *RemasterVersion, user_settings *usrset) { - char *Str = usrset->yaml_set.DefaultSpec.SystemControlInfo.RemasterVersion; + char *Str = usrset->yaml_set.SystemControlInfo.RemasterVersion; if(!Str){ *RemasterVersion = 0; return 0; } *RemasterVersion = strtol(Str,NULL,0); return 0; -} \ No newline at end of file +} diff --git a/exheader.h b/exheader.h index b2ebe83..c49cf0f 100644 --- a/exheader.h +++ b/exheader.h @@ -15,24 +15,84 @@ typedef enum typedef enum { - APPLICATION = 1, - SYSTEM = 2, - BASE = 3 + memtype_APPLICATION = 1, + memtype_SYSTEM = 2, + memtype_BASE = 3 } MemoryTypeName; typedef enum { - PERMIT_DEBUG = 1, - FORCE_DEBUG = 2, - CAN_USE_NON_ALPHABET_AND_NUMBER = 4, - CAN_WRITE_SHARED_PAGE = 8, - CAN_USE_PRIVILEGE_PRIORITY = 16, - PERMIT_MAIN_FUNCTION_ARGUMENT = 32, - CAN_SHARE_DEVICE_MEMORY = 64, - RUNNABLE_ON_SLEEP = 128, - SPECIAL_MEMORY_ARRANGE = 4096 + processtype_DEFAULT = -1, + processtype_SYSTEM = 0, + processtype_APPLICATION = 1 +} ProcessTypeName; + +typedef enum +{ + resrc_limit_APPLICATION, + resrc_limit_SYS_APPLET, + resrc_limit_LIB_APPLET, + resrc_limit_OTHER +} ResourceLimitCategoryName; + +typedef enum +{ + PERMIT_DEBUG, + FORCE_DEBUG, + CAN_USE_NON_ALPHABET_AND_NUMBER, + CAN_WRITE_SHARED_PAGE, + CAN_USE_PRIVILEGE_PRIORITY, + PERMIT_MAIN_FUNCTION_ARGUMENT, + CAN_SHARE_DEVICE_MEMORY, + RUNNABLE_ON_SLEEP, + SPECIAL_MEMORY_ARRANGE = 12, } OtherCapabilities_Flagbitmask; +typedef enum +{ + CATEGORY_SYSTEM_APPLICATION, + CATEGORY_HARDWARE_CHECK, + CATEGORY_FILE_SYSTEM_TOOL, + DEBUG, + TWL_CARD_BACKUP, + TWL_NAND_DATA, + BOSS, + DIRECT_SDMC, + CORE, + CTR_NAND_RO, + CTR_NAND_RW, + CTR_NAND_RO_WRITE, + CATEGORY_SYSTEM_SETTINGS, + CARD_BOARD, + EXPORT_IMPORT_IVS, + DIRECT_SDMC_WRITE, + SWITCH_CLEANUP, + SAVE_DATA_MOVE, + SHOP, + SHELL, + CATEGORY_HOME_MENU +} FileSystemAccess; + +typedef enum +{ + NOT_USE_ROMFS, + USE_EXTENDED_SAVEDATA_ACCESS_CONTROL +} AttributeName; + +typedef enum +{ + FS_MOUNT_NAND, + FS_MOUNT_NAND_RO_WRITE, + FS_MOUNT_TWLN, + FS_MOUNT_WNAND, + FS_MOUNT_CARD_SPI, + USE_SDIF3, + CREATE_SEED, + USE_CARD_SPI, + SD_APPLICATION, + USE_DIRECT_SDMC +} Arm9Capability; + typedef struct { u8 reserved[5]; @@ -68,20 +128,20 @@ typedef struct typedef struct { - u8 extsavedataid[8]; - u8 systemsavedataid[8]; - u8 reserved[8]; - u8 accessinfo[7]; - u8 otherattributes; + u8 ExtSaveDataId[8]; + u8 SystemSaveDataId[8]; + u8 StorageAccessableUniqueIds[8]; + //u8 reserved[7]; + //u8 flag; + u8 AccessInfo[7]; + u8 OtherAttributes; } exhdr_StorageInfo; typedef struct { u8 ProgramId[8]; u8 Flags[8]; - u8 MaxCpu; - u8 Reserved0; - u8 ResourceLimitDescriptor[15][2]; + u8 ResourceLimitDescriptor[16][2]; exhdr_StorageInfo StorageInfo; u8 ServiceAccessControl[32][8]; // Those char[8] svc handles u8 Reserved1[0x1f]; @@ -90,45 +150,30 @@ typedef struct typedef struct { - u8 descriptors[28][4];// Descripters are a collection of u32s, with bitmask idents so they can be identified, no matter the pos - /* - struct - { - u32 data[8]; - } SystemCallAccessControl; + u16 num; + u32 *Data; +} ARM11KernelCapabilityDescriptor; - struct - { - u32 data[8]; - } InterruptNumberList; +typedef enum +{ + desc_InteruptNumList = 0xe0000000, + desc_SysCallControl = 0xf0000000, + desc_KernelReleaseVersion = 0xfc000000, + desc_HandleTableSize = 0xfe000000, + desc_OtherCapabilities = 0xff000000, + desc_MappingStatic = 0xff800000, + desc_MappingIO = 0xffc00000, +} ARM11KernelCapabilityDescriptorBitmask; - struct - { - - } AddressMapping; - - struct - { - u32 Data; // le u32 : Flags - } OtherCapabilities; - - struct - { - u32 Data; - } HandleTableSize; - - struct - { - u32 Data; - } ReleaseKernelVersion; - */ +typedef struct +{ + u8 descriptors[28][4];// Descripters are a collection of u32s, with bitmask idents so they can be identified, 'no matter the pos' u8 reserved[0x10]; } exhdr_ARM11KernelCapabilities; typedef struct { - u8 descriptors[15]; - u8 descversion; + u8 descriptors[16]; //descriptors[15] = DescVersion } exhdr_ARM9AccessControlInfo; typedef struct @@ -157,7 +202,7 @@ typedef struct typedef struct { keys_struct *keys; - desc_settings *yaml; + rsf_settings *yaml; /* Output */ ExtendedHeader_Struct *ExHdr; // is the exheader output buffer ptr(in ncchset) cast as exheader struct ptr; diff --git a/keyset.c b/keyset.c index db089bf..d0b3d6f 100644 --- a/keyset.c +++ b/keyset.c @@ -29,7 +29,7 @@ void InitKeys(keys_struct *keys) // NCCH keys->aes.NormalKey = (u8*)zeros_fixed_aesKey; - SetSystemFixedKey(keys,(u8*)zeros_fixed_aesKey); + //SetSystemFixedKey(keys,(u8*)zeros_fixed_aesKey); /* RSA Keys */ // CIA diff --git a/makerom.c b/makerom.c index 7ae172b..0791e45 100644 --- a/makerom.c +++ b/makerom.c @@ -16,7 +16,7 @@ int main(int argc, char *argv[]) result = ParseArgs(argc,argv,usrset); if(result < 0) goto fail_finalise; - // Import RSF/DESC Settings if present + // Import RSF Settings if present result = GetYamlSettings(usrset); if(result < 0) goto fail_finalise; @@ -43,7 +43,7 @@ int main(int argc, char *argv[]) ReadFile_64(usrset->Content0.buffer,size,0,srl); fclose(srl); } - else if(usrset->Content0IsCci){ + else if(usrset->ConvertCci){ FILE *cci = fopen(usrset->CciPath,"rb"); if(!cci) {fprintf(stderr,"[MAKEROM ERROR] Failed to open CCI: %s\n",usrset->CciPath); goto fail_finalise;} fclose(cci); @@ -57,7 +57,7 @@ int main(int argc, char *argv[]) else{// Build Content 0 result = build_NCCH(usrset); if(result < 0) { - fprintf(stderr,"[ERROR] %s generation failed\n",usrset->build_ncch_type == CXI? "CXI" : "CFA"); + //fprintf(stderr,"[ERROR] %s generation failed\n",usrset->build_ncch_type == CXI? "CXI" : "CFA"); fprintf(stderr,"[RESULT] Failed to build outfile\n"); goto fail_finalise; } diff --git a/ncch.c b/ncch.c index 07627ff..832fed8 100644 --- a/ncch.c +++ b/ncch.c @@ -170,22 +170,30 @@ int SetBasicOptions(ncch_settings *ncchset, user_settings *usrset) ncchset->Options.IncludeExeFsLogo = usrset->include_exefs_logo; - if(usrset->yaml_set.DefaultSpec.Option.EnableCompress != -1) ncchset->Options.CompressCode = usrset->yaml_set.DefaultSpec.Option.EnableCompress; + if(usrset->yaml_set.Option.EnableCompress != -1) ncchset->Options.CompressCode = usrset->yaml_set.Option.EnableCompress; else ncchset->Options.CompressCode = true; - if(usrset->yaml_set.DefaultSpec.Option.UseOnSD != -1) ncchset->Options.UseOnSD = usrset->yaml_set.DefaultSpec.Option.UseOnSD; + if(usrset->yaml_set.Option.UseOnSD != -1) ncchset->Options.UseOnSD = usrset->yaml_set.Option.UseOnSD; else ncchset->Options.UseOnSD = false; + usrset->yaml_set.Option.UseOnSD = ncchset->Options.UseOnSD; - if(usrset->yaml_set.DefaultSpec.Option.EnableCrypt != -1) ncchset->Options.Encrypt = usrset->yaml_set.DefaultSpec.Option.EnableCrypt; + if(usrset->yaml_set.Option.EnableCrypt != -1) ncchset->Options.Encrypt = usrset->yaml_set.Option.EnableCrypt; else ncchset->Options.Encrypt = true; - if(usrset->yaml_set.DefaultSpec.Option.FreeProductCode != -1) ncchset->Options.FreeProductCode = usrset->yaml_set.DefaultSpec.Option.FreeProductCode; + if(usrset->yaml_set.Option.FreeProductCode != -1) ncchset->Options.FreeProductCode = usrset->yaml_set.Option.FreeProductCode; else ncchset->Options.FreeProductCode = false; ncchset->Options.IsCfa = (usrset->build_ncch_type == CFA); ncchset->Options.IsBuildingCodeSection = (usrset->elf_path != NULL); + ncchset->Options.UseRomFS = ((ncchset->yaml_set->Rom.HostRoot && strlen(ncchset->yaml_set->Rom.HostRoot) > 0) || usrset->romfs_path); + + if(ncchset->Options.IsCfa && !ncchset->Options.UseRomFS){ + fprintf(stderr,"[NCCH ERROR] 'Rom/HostRoot' must be set\n"); + return NCCH_BAD_YAML_SET; + } + ncchset->Options.accessdesc = usrset->accessdesc; ncchset->CxiRsaKey.PrivK = malloc(0x100); @@ -289,38 +297,38 @@ int ImportLogo(ncch_settings *ncchset) if(!ncchset->Sections.Logo.buffer) {fprintf(stderr,"[NCCH ERROR] MEM ERROR\n"); return MEM_ERROR;} ReadFile_64(ncchset->Sections.Logo.buffer,ncchset->Sections.Logo.size,0,ncchset->ComponentFilePtrs.logo); } - else if(ncchset->yaml_set->DefaultSpec.BasicInfo.Logo){ - if(strcasecmp(ncchset->yaml_set->DefaultSpec.BasicInfo.Logo,"nintendo") == 0){ + else if(ncchset->yaml_set->BasicInfo.Logo){ + if(strcasecmp(ncchset->yaml_set->BasicInfo.Logo,"nintendo") == 0){ ncchset->Sections.Logo.size = 0x2000; ncchset->Sections.Logo.buffer = malloc(ncchset->Sections.Logo.size); if(!ncchset->Sections.Logo.buffer) {fprintf(stderr,"[NCCH ERROR] MEM ERROR\n"); return MEM_ERROR;} memcpy(ncchset->Sections.Logo.buffer,Nintendo_LZ,0x2000); } - else if(strcasecmp(ncchset->yaml_set->DefaultSpec.BasicInfo.Logo,"licensed") == 0){ + else if(strcasecmp(ncchset->yaml_set->BasicInfo.Logo,"licensed") == 0){ ncchset->Sections.Logo.size = 0x2000; ncchset->Sections.Logo.buffer = malloc(ncchset->Sections.Logo.size); if(!ncchset->Sections.Logo.buffer) {fprintf(stderr,"[NCCH ERROR] MEM ERROR\n"); return MEM_ERROR;} memcpy(ncchset->Sections.Logo.buffer,Nintendo_LicensedBy_LZ,0x2000); } - else if(strcasecmp(ncchset->yaml_set->DefaultSpec.BasicInfo.Logo,"distributed") == 0){ + else if(strcasecmp(ncchset->yaml_set->BasicInfo.Logo,"distributed") == 0){ ncchset->Sections.Logo.size = 0x2000; ncchset->Sections.Logo.buffer = malloc(ncchset->Sections.Logo.size); if(!ncchset->Sections.Logo.buffer) {fprintf(stderr,"[NCCH ERROR] MEM ERROR\n"); return MEM_ERROR;} memcpy(ncchset->Sections.Logo.buffer,Nintendo_DistributedBy_LZ,0x2000); } - else if(strcasecmp(ncchset->yaml_set->DefaultSpec.BasicInfo.Logo,"ique") == 0){ + else if(strcasecmp(ncchset->yaml_set->BasicInfo.Logo,"ique") == 0){ ncchset->Sections.Logo.size = 0x2000; ncchset->Sections.Logo.buffer = malloc(ncchset->Sections.Logo.size); if(!ncchset->Sections.Logo.buffer) {fprintf(stderr,"[NCCH ERROR] MEM ERROR\n"); return MEM_ERROR;} memcpy(ncchset->Sections.Logo.buffer,iQue_with_ISBN_LZ,0x2000); } - else if(strcasecmp(ncchset->yaml_set->DefaultSpec.BasicInfo.Logo,"ique_without_isbn") == 0){ + else if(strcasecmp(ncchset->yaml_set->BasicInfo.Logo,"iqueforsystem") == 0){ ncchset->Sections.Logo.size = 0x2000; ncchset->Sections.Logo.buffer = malloc(ncchset->Sections.Logo.size); if(!ncchset->Sections.Logo.buffer) {fprintf(stderr,"[NCCH ERROR] MEM ERROR\n"); return MEM_ERROR;} memcpy(ncchset->Sections.Logo.buffer,iQue_without_ISBN_LZ,0x2000); } - else if(strcasecmp(ncchset->yaml_set->DefaultSpec.BasicInfo.Logo,"none") != 0){ + else if(strcasecmp(ncchset->yaml_set->BasicInfo.Logo,"none") != 0){ fprintf(stderr,"[NCCH ERROR] Invalid logo name\n"); return NCCH_BAD_YAML_SET; } @@ -342,21 +350,21 @@ int SetCommonHeaderBasicData(ncch_settings *ncchset, NCCH_Header *hdr) u64_to_u8(hdr->title_id,ProgramId,LE); /* Get Product Code and Maker Code */ - if(ncchset->yaml_set->DefaultSpec.BasicInfo.ProductCode){ - if(!IsValidProductCode((char*)ncchset->yaml_set->DefaultSpec.BasicInfo.ProductCode,ncchset->Options.FreeProductCode)){ + if(ncchset->yaml_set->BasicInfo.ProductCode){ + if(!IsValidProductCode((char*)ncchset->yaml_set->BasicInfo.ProductCode,ncchset->Options.FreeProductCode)){ fprintf(stderr,"[NCCH ERROR] Invalid Product Code\n"); return NCCH_BAD_YAML_SET; } - memcpy(hdr->product_code,ncchset->yaml_set->DefaultSpec.BasicInfo.ProductCode,strlen((char*)ncchset->yaml_set->DefaultSpec.BasicInfo.ProductCode)); + memcpy(hdr->product_code,ncchset->yaml_set->BasicInfo.ProductCode,strlen((char*)ncchset->yaml_set->BasicInfo.ProductCode)); } else memcpy(hdr->product_code,"CTR-P-CTAP",10); - if(ncchset->yaml_set->DefaultSpec.BasicInfo.CompanyCode){ - if(strlen((char*)ncchset->yaml_set->DefaultSpec.BasicInfo.CompanyCode) != 2){ + if(ncchset->yaml_set->BasicInfo.CompanyCode){ + if(strlen((char*)ncchset->yaml_set->BasicInfo.CompanyCode) != 2){ fprintf(stderr,"[NCCH ERROR] Company code length must be 2\n"); return NCCH_BAD_YAML_SET; } - memcpy(hdr->maker_code,ncchset->yaml_set->DefaultSpec.BasicInfo.CompanyCode,2); + memcpy(hdr->maker_code,ncchset->yaml_set->BasicInfo.CompanyCode,2); } else memcpy(hdr->maker_code,"00",2); @@ -364,10 +372,10 @@ int SetCommonHeaderBasicData(ncch_settings *ncchset, NCCH_Header *hdr) hdr->flags[ContentUnitSize] = 0; /* Setting ContentPlatform */ - if(ncchset->yaml_set->DefaultSpec.TitleInfo.Platform){ - if(strcasecmp(ncchset->yaml_set->DefaultSpec.TitleInfo.Platform,"ctr") == 0) hdr->flags[ContentPlatform] = 1; + if(ncchset->yaml_set->TitleInfo.Platform){ + if(strcasecmp(ncchset->yaml_set->TitleInfo.Platform,"ctr") == 0) hdr->flags[ContentPlatform] = 1; else{ - fprintf(stderr,"[NCCH ERROR] Invalid Platform: %s\n",ncchset->yaml_set->DefaultSpec.TitleInfo.Platform); + fprintf(stderr,"[NCCH ERROR] Invalid Platform: %s\n",ncchset->yaml_set->TitleInfo.Platform); return NCCH_BAD_YAML_SET; } } @@ -384,14 +392,14 @@ int SetCommonHeaderBasicData(ncch_settings *ncchset, NCCH_Header *hdr) hdr->flags[ContentType] = 0; if(ncchset->Sections.RomFs.size) hdr->flags[ContentType] |= RomFS; if(ncchset->Sections.ExeFs.size) hdr->flags[ContentType] |= ExeFS; - if(ncchset->yaml_set->DefaultSpec.BasicInfo.ContentType){ - if(strcmp(ncchset->yaml_set->DefaultSpec.BasicInfo.ContentType,"Application") == 0) hdr->flags[ContentType] |= 0; - else if(strcmp(ncchset->yaml_set->DefaultSpec.BasicInfo.ContentType,"SystemUpdate") == 0) hdr->flags[ContentType] |= SystemUpdate; - else if(strcmp(ncchset->yaml_set->DefaultSpec.BasicInfo.ContentType,"Manual") == 0) hdr->flags[ContentType] |= Manual; - else if(strcmp(ncchset->yaml_set->DefaultSpec.BasicInfo.ContentType,"Child") == 0) hdr->flags[ContentType] |= Child; - else if(strcmp(ncchset->yaml_set->DefaultSpec.BasicInfo.ContentType,"Trial") == 0) hdr->flags[ContentType] |= Trial; + if(ncchset->yaml_set->BasicInfo.ContentType){ + if(strcmp(ncchset->yaml_set->BasicInfo.ContentType,"Application") == 0) hdr->flags[ContentType] |= 0; + else if(strcmp(ncchset->yaml_set->BasicInfo.ContentType,"SystemUpdate") == 0) hdr->flags[ContentType] |= SystemUpdate; + else if(strcmp(ncchset->yaml_set->BasicInfo.ContentType,"Manual") == 0) hdr->flags[ContentType] |= Manual; + else if(strcmp(ncchset->yaml_set->BasicInfo.ContentType,"Child") == 0) hdr->flags[ContentType] |= Child; + else if(strcmp(ncchset->yaml_set->BasicInfo.ContentType,"Trial") == 0) hdr->flags[ContentType] |= Trial; else{ - fprintf(stderr,"[NCCH ERROR] Invalid ContentType '%s'\n",ncchset->yaml_set->DefaultSpec.BasicInfo.ContentType); + fprintf(stderr,"[NCCH ERROR] Invalid ContentType '%s'\n",ncchset->yaml_set->BasicInfo.ContentType); return NCCH_BAD_YAML_SET; } } @@ -669,6 +677,9 @@ int VerifyNCCH(u8 *ncch, keys_struct *keys, bool SuppressOutput) // Checking Exheader Hash to see if decryption was sucessful ctr_sha(ExHeader,0x400,Hash,CTR_SHA_256); if(memcmp(Hash,hdr->extended_header_sha_256_hash,0x20) != 0){ + //memdump(stdout,"Expected Hash: ",hdr->extended_header_sha_256_hash,0x20); + //memdump(stdout,"Actual Hash: ",Hash,0x20); + //memdump(stdout,"Exheader: ",(u8*)ExHeader,0x400); if(!SuppressOutput) { fprintf(stderr,"[NCCH ERROR] ExHeader Hashcheck Failed\n"); fprintf(stderr,"[NCCH ERROR] CXI is corrupt\n"); @@ -871,7 +882,14 @@ bool IsCfa(NCCH_Header* hdr) u32 GetNCCH_MediaUnitSize(NCCH_Header* hdr) { - return 0x200*pow(2,hdr->flags[ContentUnitSize]); + u16 version = u8_to_u16(hdr->version,LE); + u32 ret = 0; + if (version == 1) + ret = 1; + else if (version == 2 || version == 0) + ret = 1 << (hdr->flags[ContentUnitSize] + 9); + return ret; + //return 0x200*pow(2,hdr->flags[ContentUnitSize]); } u32 GetNCCH_MediaSize(NCCH_Header* hdr) @@ -884,7 +902,7 @@ ncch_key_type GetNCCHKeyType(NCCH_Header* hdr) // Non-Secure Key Options if((hdr->flags[OtherFlag] & NoCrypto) == NoCrypto) return NoKey; if((hdr->flags[OtherFlag] & FixedCryptoKey) == FixedCryptoKey){ - if((hdr->program_id[3] & 0x10) == 0x10) return KeyIsSystemFixed; + if((hdr->program_id[4] & 0x10) == 0x10) return KeyIsSystemFixed; else return KeyIsNormalFixed; } diff --git a/ncch.h b/ncch.h index a58ac6f..b3948ad 100644 --- a/ncch.h +++ b/ncch.h @@ -124,7 +124,7 @@ typedef struct typedef struct { keys_struct *keys; - desc_settings *yaml_set; + rsf_settings *yaml_set; COMPONENT_STRUCT *out; struct{ @@ -145,6 +145,7 @@ typedef struct bool FreeProductCode; bool IsCfa; bool IsBuildingCodeSection; + bool UseRomFS; } Options; struct diff --git a/ncsd.c b/ncsd.c index c79acba..edcce60 100644 --- a/ncsd.c +++ b/ncsd.c @@ -15,8 +15,8 @@ int get_CCISettings(cci_settings *cciset, user_settings *usrset); void free_CCISettings(cci_settings *set); /* CCI Data Gen/Write */ -int GenNCSDHeader(cci_settings *cciset, user_settings *usrset); -int GenCardInfoHeader(cci_settings *cciset, user_settings *usrset); +int BuildNCSDHeader(cci_settings *cciset, user_settings *usrset); +int BuildCardInfoHeader(cci_settings *cciset, user_settings *usrset); int WriteCCI_HDR_ToFile(cci_settings *cciset); int WriteCCI_Content_ToFile(cci_settings *cciset,user_settings *usrset); int WriteCCI_DummyBytes(cci_settings *cciset); @@ -27,11 +27,9 @@ int GetDataFromContent0(cci_settings *cciset, user_settings *usrset); int GetContentFP(cci_settings *cciset, user_settings *usrset); /* Get Data from YAML Settings */ +int GetNCSDFlags(cci_settings *cciset, rsf_settings *yaml); int GetMediaSize(cci_settings *cciset, user_settings *usrset); u64 GetUnusedSize(u64 MediaSize, u8 CardType); -int GetMediaType(cci_settings *cciset, user_settings *usrset); -int GetPlatform(cci_settings *cciset, user_settings *usrset); -int GetCardDevice(cci_settings *cciset, user_settings *usrset); int GetWriteableAddress(cci_settings *cciset, user_settings *usrset); int GetCardInfoBitmask(cci_settings *cciset, user_settings *usrset); @@ -62,9 +60,9 @@ int build_CCI(user_settings *usrset) } // Generate NCSD Header and Additional Header - result = GenNCSDHeader(cciset,usrset); + result = BuildNCSDHeader(cciset,usrset); if(result) goto finish; - GenCardInfoHeader(cciset,usrset); + BuildCardInfoHeader(cciset,usrset); // Write to File WriteCCI_HDR_ToFile(cciset); @@ -103,27 +101,23 @@ int get_CCISettings(cci_settings *cciset, user_settings *usrset) ctx.keys = &usrset->keys; int result = 0; - /* Importing Data from Content0 */ + /* Importing Data from Content */ result = CheckContent0(cciset,usrset); if(result) return result; result = GetDataFromContent0(cciset,usrset); if(result) return result; - result = GetMediaSize(cciset,usrset); + result = GetContentFP(cciset,usrset); if(result) return result; + + /* Getting Data from YAML */ - result = GetMediaType(cciset,usrset); + result = GetNCSDFlags(cciset,&usrset->yaml_set); if(result) return result; - result = GetPlatform(cciset,usrset); - if(result) return result; - - result = GetCardDevice(cciset,usrset); - if(result) return result; - - result = GetContentFP(cciset,usrset); + result = GetMediaSize(cciset,usrset); if(result) return result; result = CheckMediaSize(cciset); @@ -151,7 +145,7 @@ void free_CCISettings(cci_settings *set) free(set); } -int GenNCSDHeader(cci_settings *cciset, user_settings *usrset) +int BuildNCSDHeader(cci_settings *cciset, user_settings *usrset) { memcpy((u8*)ctx.commonHDR.magic,"NCSD",4); u32_to_u8((u8*)ctx.commonHDR.media_size,(cciset->MediaSize/cciset->MediaUnitSize),LE); @@ -169,14 +163,15 @@ int GenNCSDHeader(cci_settings *cciset, user_settings *usrset) return 0; } -int GenCardInfoHeader(cci_settings *cciset, user_settings *usrset) +int BuildCardInfoHeader(cci_settings *cciset, user_settings *usrset) { u32_to_u8((u8*)ctx.CardInfoHDR.writable_address,(cciset->WritableAddress/cciset->MediaUnitSize),LE); u32_to_u8((u8*)ctx.CardInfoHDR.card_info_bitmask,cciset->CardInfoBitmask,BE); u32_to_u8((u8*)ctx.CardInfoHDR.media_size_used,cciset->TotalContentSize,LE); memcpy((u8*)ctx.CardInfoHDR.ncch_0_title_id,cciset->ContentTitleID[0],8); memcpy((u8*)ctx.CardInfoHDR.initial_data,cciset->InitialData,0x30); - if(!(usrset->OmitImportedNcchHdr && !usrset->IsBuildingNCCH0)) memcpy((u8*)ctx.CardInfoHDR.ncch_0_header,cciset->NCCH_HDR,0x100); + if(!(usrset->OmitImportedNcchHdr && !usrset->IsBuildingNCCH0)) + memcpy((u8*)ctx.CardInfoHDR.ncch_0_header,cciset->NCCH_HDR,0x100); memcpy((u8*)ctx.DevCardInfoHDR.TitleKey,cciset->TitleKey,0x10); return 0; } @@ -304,6 +299,12 @@ int GetDataFromContent0(cci_settings *cciset, user_settings *usrset) cciset->NCCH_HDR = hdr; + u16 ncch_format_ver = u8_to_u16(hdr->version,LE); + if(ncch_format_ver != 0 && ncch_format_ver != 2){ + fprintf(stderr,"[CCI ERROR] NCCH type %d Not Supported\n",ncch_format_ver); + return FAILED_TO_IMPORT_FILE; + } + //memdump(stdout,"ncch0 head: ",(cciset->ncch0+0x100),0x100); //memdump(stdout,"ncch0 head: ",(u8*)(hdr),0x100); @@ -334,7 +335,7 @@ int GetDataFromContent0(cci_settings *cciset, user_settings *usrset) int GetMediaSize(cci_settings *cciset, user_settings *usrset) { - char *MediaSizeStr = usrset->yaml_set.DefaultSpec.BasicInfo.MediaSize; + char *MediaSizeStr = usrset->yaml_set.BasicInfo.MediaSize; if(!MediaSizeStr) cciset->MediaSize = (u64)GB*2; else{ if(strcasecmp(MediaSizeStr,"128MB") == 0) cciset->MediaSize = (u64)MB*128; @@ -352,7 +353,7 @@ int GetMediaSize(cci_settings *cciset, user_settings *usrset) } } - if(usrset->yaml_set.DefaultSpec.BasicInfo.MediaFootPadding != -1) cciset->MediaFootPadding = usrset->yaml_set.DefaultSpec.BasicInfo.MediaFootPadding; + if(usrset->yaml_set.BasicInfo.MediaFootPadding != -1) cciset->MediaFootPadding = usrset->yaml_set.BasicInfo.MediaFootPadding; return 0; } @@ -384,51 +385,57 @@ u64 GetUnusedSize(u64 MediaSize, u8 CardType) return 0; } -int GetMediaType(cci_settings *cciset, user_settings *usrset) +int GetNCSDFlags(cci_settings *cciset, rsf_settings *yaml) { - char *MediaTypeStr = usrset->yaml_set.DefaultSpec.CardInfo.MediaType; - if(!MediaTypeStr) cciset->NCSD_Flags[MediaTypeIndex] = CARD1; + /* BackupWriteWaitTime */ + cciset->NCSD_Flags[FW6x_BackupWriteWaitTime] = 0; + if(yaml->CardInfo.BackupWriteWaitTime){ + u32 WaitTime = strtoul(yaml->CardInfo.BackupWriteWaitTime,NULL,0); + if(WaitTime > 255){ + fprintf(stderr,"[CCI ERROR] Invalid Card BackupWriteWaitTime (%d) : must 0-255\n",WaitTime); + return EXHDR_BAD_YAML_OPT; + } + cciset->NCSD_Flags[FW6x_BackupWriteWaitTime] = (u8)WaitTime; + } + + /* FW6x SaveCrypto */ + cciset->NCSD_Flags[FW6x_SaveCryptoFlag] = 1; + + /* MediaType */ + if(!yaml->CardInfo.MediaType) cciset->NCSD_Flags[MediaTypeIndex] = CARD1; else{ - if(strcasecmp(MediaTypeStr,"Card1") == 0) cciset->NCSD_Flags[MediaTypeIndex] = CARD1; - else if(strcasecmp(MediaTypeStr,"Card2") == 0) cciset->NCSD_Flags[MediaTypeIndex] = CARD2; + if(strcasecmp(yaml->CardInfo.MediaType,"Card1") == 0) cciset->NCSD_Flags[MediaTypeIndex] = CARD1; + else if(strcasecmp(yaml->CardInfo.MediaType,"Card2") == 0) cciset->NCSD_Flags[MediaTypeIndex] = CARD2; else { - fprintf(stderr,"[CCI ERROR] Invalid MediaType: %s\n",MediaTypeStr); + fprintf(stderr,"[CCI ERROR] Invalid MediaType: %s\n",yaml->CardInfo.MediaType); return INVALID_YAML_OPT; } } - return 0; -} -int GetPlatform(cci_settings *cciset, user_settings *usrset) -{ - char *PlatformStr = usrset->yaml_set.DefaultSpec.TitleInfo.Platform; - if(!PlatformStr) cciset->NCSD_Flags[MediaPlatformIndex] = CTR; + /* Platform */ + if(!yaml->TitleInfo.Platform) cciset->NCSD_Flags[MediaPlatformIndex] = CTR; else{ - if(strcasecmp(PlatformStr,"ctr") == 0) cciset->NCSD_Flags[MediaPlatformIndex] = CTR; + if(strcasecmp(yaml->TitleInfo.Platform,"ctr") == 0) cciset->NCSD_Flags[MediaPlatformIndex] = CTR; else { - fprintf(stderr,"[CCI ERROR] Invalid Platform: %s\n",PlatformStr); + fprintf(stderr,"[CCI ERROR] Invalid Platform: %s\n",yaml->TitleInfo.Platform); return INVALID_YAML_OPT; } } - return 0; -} -int GetCardDevice(cci_settings *cciset, user_settings *usrset) -{ - char *CardDeviceStr = usrset->yaml_set.DefaultSpec.CardInfo.CardDevice; - if(!CardDeviceStr) cciset->NCSD_Flags[CardDeviceFlag] = CARD_DEVICE_NONE; + /* CardDevice */ + if(!yaml->CardInfo.CardDevice) cciset->NCSD_Flags[CardDeviceFlag] = CARD_DEVICE_NONE; else{ - if(strcmp(CardDeviceStr,"NorFlash") == 0) { + if(strcmp(yaml->CardInfo.CardDevice,"NorFlash") == 0) { cciset->NCSD_Flags[CardDeviceFlag] = CARD_DEVICE_NOR_FLASH; if(cciset->NCSD_Flags[MediaTypeIndex] == CARD2){ fprintf(stderr,"[CCI WARNING] 'CardDevice: NorFlash' is invalid on Card2\n"); cciset->NCSD_Flags[CardDeviceFlag] = CARD_DEVICE_NONE; } } - else if(strcmp(CardDeviceStr,"None") == 0) cciset->NCSD_Flags[CardDeviceFlag] = CARD_DEVICE_NONE; - else if(strcmp(CardDeviceStr,"BT") == 0) cciset->NCSD_Flags[CardDeviceFlag] = CARD_DEVICE_BT; + else if(strcmp(yaml->CardInfo.CardDevice,"None") == 0) cciset->NCSD_Flags[CardDeviceFlag] = CARD_DEVICE_NONE; + else if(strcmp(yaml->CardInfo.CardDevice,"BT") == 0) cciset->NCSD_Flags[CardDeviceFlag] = CARD_DEVICE_BT; else { - fprintf(stderr,"[CCI ERROR] Invalid CardDevice: %s\n",CardDeviceStr); + fprintf(stderr,"[CCI ERROR] Invalid CardDevice: %s\n",yaml->CardInfo.CardDevice); return INVALID_YAML_OPT; } } @@ -440,7 +447,7 @@ int GetWriteableAddress(cci_settings *cciset, user_settings *usrset) int result = GetSaveDataSize_yaml(&cciset->SaveDataSize,usrset); if(result) return result; - char *WriteableAddressStr = usrset->yaml_set.DefaultSpec.CardInfo.WritableAddress;; + char *WriteableAddressStr = usrset->yaml_set.CardInfo.WritableAddress;; cciset->WritableAddress = -1; if(cciset->NCSD_Flags[MediaTypeIndex] != CARD2) return 0; // Can only be set for Card2 Media @@ -471,7 +478,7 @@ int GetWriteableAddress(cci_settings *cciset, user_settings *usrset) int GetCardInfoBitmask(cci_settings *cciset, user_settings *usrset) { - char *str = usrset->yaml_set.DefaultSpec.CardInfo.CardType; + char *str = usrset->yaml_set.CardInfo.CardType; if(!str) cciset->CardInfoBitmask |= 0; else{ if(strcasecmp(str,"s1") == 0) cciset->CardInfoBitmask |= 0; @@ -482,7 +489,7 @@ int GetCardInfoBitmask(cci_settings *cciset, user_settings *usrset) } } - str = usrset->yaml_set.DefaultSpec.CardInfo.CryptoType; + str = usrset->yaml_set.CardInfo.CryptoType; if(!str) cciset->CardInfoBitmask |= (3*0x40); else{ int Value = strtol(str,NULL,10); diff --git a/ncsd.h b/ncsd.h index ff0e7b7..cb96145 100644 --- a/ncsd.h +++ b/ncsd.h @@ -14,6 +14,7 @@ typedef enum typedef enum { + FW6x_BackupWriteWaitTime = 0, FW6x_SaveCryptoFlag = 1, CardDeviceFlag = 3, MediaPlatformIndex = 4, diff --git a/romfs.c b/romfs.c index e95b919..7a0adcd 100644 --- a/romfs.c +++ b/romfs.c @@ -9,6 +9,10 @@ int ImportRomFsBinaryFromFile(ncch_settings *ncchset); int BuildRomFs(ncch_settings *ncchset) { int result = 0; + + // If Not Using RomFS Return + if(!ncchset->Options.UseRomFS) return result; + if(ncchset->ComponentFilePtrs.romfs){ // The user has specified a pre-built RomFs Binary result = ImportRomFsBinaryFromFile(ncchset); return result; @@ -25,6 +29,10 @@ int ImportRomFsBinaryFromFile(ncch_settings *ncchset) ncchset->Sections.RomFs.buffer = malloc(ncchset->Sections.RomFs.size); if(!ncchset->Sections.RomFs.buffer) {fprintf(stderr,"[ROMFS ERROR] MEM ERROR\n"); return MEM_ERROR;} ReadFile_64(ncchset->Sections.RomFs.buffer,ncchset->Sections.RomFs.size,0,ncchset->ComponentFilePtrs.romfs); + if(memcmp(ncchset->Sections.RomFs.buffer,"IVFC",4) != 0){ + fprintf(stderr,"[ROMFS ERROR] Invalid RomFS Binary.\n"); + return INVALID_ROMFS_FILE; + } return 0; } diff --git a/romfs.h b/romfs.h index 36f688f..34dcc1a 100644 --- a/romfs.h +++ b/romfs.h @@ -1,6 +1,10 @@ #ifndef _ROMFS_H_ #define _ROMFS_H_ +typedef enum +{ + INVALID_ROMFS_FILE = -10, +} romfs_errors; #endif diff --git a/Application.desc b/sdapp_FW4X.rsf similarity index 51% rename from Application.desc rename to sdapp_FW4X.rsf index b3a6094..86d22a6 100644 --- a/Application.desc +++ b/sdapp_FW4X.rsf @@ -1,24 +1,52 @@ +# Default value for application +BasicInfo: + Title : "Pyramids" + CompanyCode : "00" + ProductCode : "CTR-T-JA9P" + ContentType : Application # Application / SystemUpdate / Manual / Child / Trial + Logo : Licensed # Nintendo / Licensed / Distributed / iQue / iQueForSystem + BackupMemoryType: None # None / 128KB / 512KB + +TitleInfo: + Category: Application + UniqueId: 0x60f + +Option: + UseOnSD: true # true if App is to be installed to SD + EnableCompress: true + FreeProductCode: true + EnableCrypt : true + +Rom: + SaveDataSize: 128KB + +ExeFs: + ReadOnly: + - .rodata + #- RO + ReadWrite: + - .data + #- RW + Text: + - .text + #- STUP_ENTRY + +# Don't Modify Below here AccessControlInfo: + MaxCpu: 0x9E AffinityMask: 1 - AutoGen: true CoreVersion: 2 DescVersion: 2 - Descriptor: | - AP///wAABAACAAAAAAAFGJ4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAiIAAAAAAAABBUFQ6VQAAACRo - aW9GSU8AJGhvc3RpbzAkaG9zdGlvMWFjOnUAAAAAYm9zczpVAABjYW06dQAA - AGNlY2Q6dQAAY2ZnOnUAAABkbHA6RktDTGRscDpTUlZSZHNwOjpEU1BmcmQ6 - dQAAAGZzOlVTRVIAZ3NwOjpHcHVoaWQ6VVNFUmh0dHA6QwAAbWljOnUAAABu - ZG06dQAAAG5ld3M6dQAAbndtOjpVRFNwdG06dQAAAHB4aTpkZXYAc29jOlUA - AABzc2w6QwAAAHkycjp1AAAAbGRyOnJvAABpcjpVU0VSAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAABOn/rw/7//8ec/APIA8JH/APaR/1D/gf9Y/4H/cP+B/3j/gf8B - AQD/AAIA/iECAPz///////////////////////////////////////////// - ////////////////////////////////////////AAAAAAAAAAAAAAAAAAAA - AAADAAAAAAAAAAAAAAAAAAI= - DisableDebug: false - EnableInterruptNumbers: - EnableSystemCalls: + HandleTableSize: 512 + IORegisterMapping: + - 1ff50000-1ff57fff + - 1ff70000-1ff77fff + IdealProcessor: 0 + MemoryMapping: + - 1f000000-1f5fffff:r + Priority: 16 + InterruptNumbers: + SystemCallAccess: ArbitrateAddress: 34 Break: 60 CancelTimer: 28 @@ -70,23 +98,7 @@ AccessControlInfo: UnmapMemoryBlock: 32 WaitSynchronization1: 36 WaitSynchronizationN: 37 - FileSystemAccess: - - Debug - - DirectSdmc - - DirectSdmcWrite - HandleTableSize: 512 - IORegisterMapping: - - 1ff50000-1ff57fff - - 1ff70000-1ff77fff - IdealProcessor: 1 - IoAccessControl: - - UseDirectSdmc - - SdApplication - MemoryMapping: - - 1f000000-1f5fffff:r MemoryType: Application - Priority: 24 - ProgramId: 0x00040000ffffff00L ReleaseKernelMajor: "02" ReleaseKernelMinor: "33" ServiceAccessControl: @@ -118,15 +130,41 @@ AccessControlInfo: - y2r:u - ldr:ro - ir:USER - Signature: | - 3xyLmORvojVswxgXmPPOVH4ULn8e2G3PvClO/jIuwRGtRprGcOruKFUi4TYF - HASKzg8Mg4/I1t4RjurPrZvPgQ3rcROz066DAkwOEFBZPO5gBvuMf8IgJAFi - VYdgD636cy72ZWLS5RBFaXA5A9E57FDB1CU5spARTpXLGevKD7X6x7Di1+Bx - w+VVM55c3E07URENMXiWytcYWO4A6SjyaHbUV/5lsUtJP/amWErH/MS7YbxY - jVVl5gp5OUG4gGH3BcP+1osJgsJfplb57h0OBj6fP/GTmk+i1ZGHiv7Pw/yK - scR46dEa97HTIMuDvgPVyqVeF6aRENS+I9ZLTwOprg== - StorageId: - - 0 + +SystemControlInfo: + Dependency: + ac: 0x0004013000002402L + am: 0x0004013000001502L + boss: 0x0004013000003402L + camera: 0x0004013000001602L + cecd: 0x0004013000002602L + cfg: 0x0004013000001702L + codec: 0x0004013000001802L + csnd: 0x0004013000002702L + dlp: 0x0004013000002802L + dsp: 0x0004013000001a02L + friends: 0x0004013000003202L + gpio: 0x0004013000001b02L + gsp: 0x0004013000001c02L + hid: 0x0004013000001d02L + http: 0x0004013000002902L + i2c: 0x0004013000001e02L + ir: 0x0004013000003302L + mcu: 0x0004013000001f02L + mic: 0x0004013000002002L + ndm: 0x0004013000002b02L + news: 0x0004013000003502L + nim: 0x0004013000002c02L + nwm: 0x0004013000002d02L + pdn: 0x0004013000002102L + ps: 0x0004013000003102L + ptm: 0x0004013000002202L + ro: 0x0004013000003702L + socket: 0x0004013000002e02L + spi: 0x0004013000002302L + ssl: 0x0004013000002f02L + StackSize: 0x40000 + CommonHeaderKey: D: | jL2yO86eUQnYbXIrzgFVMm7FVze0LglZ2f5g+c42hWoEdnb5BOotaMQPBfqt @@ -135,20 +173,6 @@ CommonHeaderKey: 0RCb66lYcr2h/p2G7SnpKUliS9h9KnpmG+UEgVYQUK+4SCfByUa9PxYGpT0E nw1UcRz0gsBmdOqcgzwnAd9vVqgb42hVn6uQZyAl+j1RKiMWywZarazIR/k5 Lmr4+groimSEa+3ajyoIho9WaWTDmFU3mkhA2tUDIQ== - DP: | - pD8c9uymjXDj6oyhx7EmQcrEDizxsj6hTjJ0x3G/PYNv/v2/DA9gp3X30h35 - uRZ1O+SgonWCGVnOJ7Wfjr4w2cOcSzxpzT3PQsS6Gs9z0RvcDsUHRL5f2EiT - 6A1ZPj6xyzmo9Ts6w9yfxCwaHci0f2hP9bq9FimfFKigCoNcFBE= - DQ: | - y+6Pado7N+SIZJgQ7zEGyQ7/SxGHHEy5uW04HHde9IqHD5HFGG2GegF655mM - iI9ja1eTCh/AFs8xjAg0drQEvB5q80TjPNKtwVUT8ghOlN3xTzpdaLwX0d+c - Twy74VY4KPawcdDeLaGFtXknhFOdGmIbx+BInibz7NZ9eLqGwaE= - Exponent: | - AQAB - InverseQ: | - tc9/lcF837g8AdfyeuCyuLyd36Zm1ZmJ1VSSuH8y3/1ZhBYZkOFXxU7EhMvJ - FyAu4qyCA9otzCXM+cqKxE3ZCkSconsXOu8szZTwuINSkwHlt22FtiTfPt+V - /g5kjtkjoZVOGfSvvfel9Smwy1yrFvKfi/yJsjATeNFjiEquV/w= Modulus: | z+yySANtuAnjXGxiLKlJ4fT0DGzD5S+dUKArWgDGcgALowRdlEbnABtIhbVh LMl0yitDE8F4l1wzLwfHhfDa22CWUA98S3rXF53k5cOrb12leDKtBN2Wbtx1 @@ -156,103 +180,23 @@ CommonHeaderKey: BEou29fQZEOc0HgRQYgz3TFikC0X8sapK5xwq9zTq13a7j1sDoH/9mdaRPms Bz0jlHVlkyAMxXYdD2UGPSGi8JaAtwpJUzijXcB0PKTZQDaFH4zRLRX57ySp fp2yHvigcoEXd3OxVn+tBaLSMFr1068PEEpS2AlHlw== - P: | - 6SdD3AiAybNamgUgGJduyFWO1/LeakmoJm+23IEJADyU4nz+reGjxQnMrR+x - syuB8VPGuf1z0SInfRIu9PEjIfW9/H/fZ59GwckQuJbneODjW7KU1jM3cTVX - +AWvaxWDwlCUmVSYD2OySUJlo3szGmBYh/o/tKAq7kElaaOt+cc= - Q: | - 5EyO8bCyfqgLTfipAG/nNLObQbqMyARdQfudxh4eQqHmzblEM3jareuA8eUZ - K8pIaP+U9UfxwWTeFsOulrpsm04j4gS71WGNx3YwOIRPXXOn7zBkxA3AO9qq - K8lMeV3gNsdt4Fz8Zh2F68HSP4avB+ThO2S18SXMyIkcM7Sbw7E= -DefaultSpec: - AccessControlInfo: - ServiceAccessControl: - - APT:U - - $hioFIO - - $hostio0 - - $hostio1 - - ac:u - - boss:U - - cam:u - - cecd:u - - cfg:u - - dlp:FKCL - - dlp:SRVR - - dsp::DSP - - frd:u - - fs:USER - - gsp::Gpu - - hid:USER - - http:C - - mic:u - - ndm:u - - news:u - - nwm::UDS - - ptm:u - - pxi:dev - - soc:U - - ssl:C - - y2r:u - - ldr:ro - - ir:USER - AffinityMask: 1 - FirmwareVersion: 2 - HandleTableSize: 512 - IORegisterMapping: - - 1ff50000-1ff57fff - - 1ff70000-1ff77fff - IdealProcessor: 0 - MemoryMapping: - - 1f000000-1f5fffff:r - Priority: 16 - BasicInfo: - CompanyCode: "00" - Logo: Nintendo - Title: default - ExeFs: - ReadOnly: - - RO - ReadWrite: - - RW - Text: - - STUP_ENTRY - PlainRegion: - - .module_id - Rom: - DefaultReject: - - .* - File: - - "*" - SystemControlInfo: - Dependency: - ac: 0x0004013000002402L - am: 0x0004013000001502L - boss: 0x0004013000003402L - camera: 0x0004013000001602L - cecd: 0x0004013000002602L - cfg: 0x0004013000001702L - codec: 0x0004013000001802L - csnd: 0x0004013000002702L - dlp: 0x0004013000002802L - dsp: 0x0004013000001a02L - friends: 0x0004013000003202L - gpio: 0x0004013000001b02L - gsp: 0x0004013000001c02L - hid: 0x0004013000001d02L - http: 0x0004013000002902L - i2c: 0x0004013000001e02L - ir: 0x0004013000003302L - mcu: 0x0004013000001f02L - mic: 0x0004013000002002L - ndm: 0x0004013000002b02L - news: 0x0004013000003502L - nim: 0x0004013000002c02L - nwm: 0x0004013000002d02L - pdn: 0x0004013000002102L - ps: 0x0004013000003102L - ptm: 0x0004013000002202L - ro: 0x0004013000003702L - socket: 0x0004013000002e02L - spi: 0x0004013000002302L - ssl: 0x0004013000002f02L - StackSize: 262144 + Signature: | + 3xyLmORvojVswxgXmPPOVH4ULn8e2G3PvClO/jIuwRGtRprGcOruKFUi4TYF + HASKzg8Mg4/I1t4RjurPrZvPgQ3rcROz066DAkwOEFBZPO5gBvuMf8IgJAFi + VYdgD636cy72ZWLS5RBFaXA5A9E57FDB1CU5spARTpXLGevKD7X6x7Di1+Bx + w+VVM55c3E07URENMXiWytcYWO4A6SjyaHbUV/5lsUtJP/amWErH/MS7YbxY + jVVl5gp5OUG4gGH3BcP+1osJgsJfplb57h0OBj6fP/GTmk+i1ZGHiv7Pw/yK + scR46dEa97HTIMuDvgPVyqVeF6aRENS+I9ZLTwOprg== + Descriptor: | + AP///wAABAACAAAAAAAFGJ4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAiIAAAAAAAABBUFQ6VQAAACRo + aW9GSU8AJGhvc3RpbzAkaG9zdGlvMWFjOnUAAAAAYm9zczpVAABjYW06dQAA + AGNlY2Q6dQAAY2ZnOnUAAABkbHA6RktDTGRscDpTUlZSZHNwOjpEU1BmcmQ6 + dQAAAGZzOlVTRVIAZ3NwOjpHcHVoaWQ6VVNFUmh0dHA6QwAAbWljOnUAAABu + ZG06dQAAAG5ld3M6dQAAbndtOjpVRFNwdG06dQAAAHB4aTpkZXYAc29jOlUA + AABzc2w6QwAAAHkycjp1AAAAbGRyOnJvAABpcjpVU0VSAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAABOn/rw/7//8ec/APIA8JH/APaR/1D/gf9Y/4H/cP+B/3j/gf8B + AQD/AAIA/iECAPz///////////////////////////////////////////// + ////////////////////////////////////////AAAAAAAAAAAAAAAAAAAA + AAADAAAAAAAAAAAAAAAAAAI= \ No newline at end of file diff --git a/titleid.c b/titleid.c index 8740c69..dba5c67 100644 --- a/titleid.c +++ b/titleid.c @@ -6,16 +6,16 @@ u32 SetPIDCategoryFromName(char *Category); u32 SetPIDCategoryFromFlags(char **CategoryFlags, u32 FlagNum); u32 SetPIDCategoryFromFlag(u32 Category, u32 Flag, char *FlagName); u32 SetPIDUniqueId(char *UniqueIdStr); -u16 SetTitleVariation(u16 Category, desc_settings *yaml_set); +u16 SetTitleVariation(u16 Category, rsf_settings *yaml_set); u64 ConvertTwlIdToCtrId(u64 pgid) { return 0x0004800000000000 | (pgid & 0x00007FFFFFFFFFFF); } -int GetProgramID(u64 *dest, desc_settings *yaml, bool IsForExheader) +int GetProgramID(u64 *dest, rsf_settings *yaml, bool IsForExheader) { - if(yaml->DefaultSpec.TitleInfo.Category && yaml->DefaultSpec.TitleInfo.CategoryFlags){ + if(yaml->TitleInfo.Category && yaml->TitleInfo.CategoryFlags){ fprintf(stderr,"[ERROR] Can not set Cateory and CategoryFlags at the same time.\n"); return PID_BAD_YAML_SET; } @@ -25,20 +25,21 @@ int GetProgramID(u64 *dest, desc_settings *yaml, bool IsForExheader) u16 m_Variation = 0; // Getting Category - if(yaml->DefaultSpec.TitleInfo.Category) - m_Category = SetPIDCategoryFromName(yaml->DefaultSpec.TitleInfo.Category); - else if(yaml->DefaultSpec.TitleInfo.CategoryFlags) - m_Category = SetPIDCategoryFromFlags(yaml->DefaultSpec.TitleInfo.CategoryFlags,yaml->DefaultSpec.TitleInfo.CategoryFlagsNum); - if(IsForExheader && yaml->DefaultSpec.TitleInfo.TargetCategory) - m_Category = SetPIDCategoryFromName(yaml->DefaultSpec.TitleInfo.TargetCategory); + if(yaml->TitleInfo.Category) + m_Category = SetPIDCategoryFromName(yaml->TitleInfo.Category); + else if(yaml->TitleInfo.CategoryFlags) + m_Category = SetPIDCategoryFromFlags(yaml->TitleInfo.CategoryFlags,yaml->TitleInfo.CategoryFlagsNum); + if(IsForExheader && yaml->TitleInfo.TargetCategory) + m_Category = SetPIDCategoryFromName(yaml->TitleInfo.TargetCategory); if(m_Category == PID_INVALID_CATEGORY) // Error occured return PID_BAD_YAML_SET; // Getting UniqueId - if(yaml->DefaultSpec.TitleInfo.UniqueId) UniqueId = SetPIDUniqueId(yaml->DefaultSpec.TitleInfo.UniqueId); - else UniqueId = 0xf7fff; - if(UniqueId == PID_INVALID_UNIQUE_ID) // Error occured + if(yaml->TitleInfo.UniqueId) UniqueId = SetPIDUniqueId(yaml->TitleInfo.UniqueId); + else{ + fprintf(stderr,"[ERROR] ParameterNotFound: TitleInfo/UniqueId\n"); return PID_BAD_YAML_SET; + } m_Variation = SetTitleVariation(m_Category,yaml); if(m_Variation == PID_INVALID_VARIATION) // Error occured @@ -58,10 +59,13 @@ int GetProgramID(u64 *dest, desc_settings *yaml, bool IsForExheader) return 0; } -int GetUniqueID(u32 *dest, desc_settings *yaml) +int GetUniqueID(u32 *dest, rsf_settings *yaml) { - if(yaml->DefaultSpec.TitleInfo.UniqueId) *dest = SetPIDUniqueId(yaml->DefaultSpec.TitleInfo.UniqueId); - else *dest = 0xf7fff; + if(yaml->TitleInfo.UniqueId) *dest = 0xffffff & SetPIDUniqueId(yaml->TitleInfo.UniqueId); + else{ + fprintf(stderr,"[ERROR] ParameterNotFound: TitleInfo/UniqueId\n"); + return PID_BAD_YAML_SET; + } return 0; } @@ -137,16 +141,14 @@ u32 SetPIDCategoryFromFlag(u32 Category, u32 Flag, char *FlagName) u32 SetPIDUniqueId(char *UniqueIdStr) { - u32 UniqueId = strtoul(UniqueIdStr,NULL,0); - if(UniqueId > 0xffffff) return PID_INVALID_UNIQUE_ID; - return UniqueId; + return 0xffffff & strtoull(UniqueIdStr,NULL,0); } -u16 SetTitleVariation(u16 Category, desc_settings *yaml_set) +u16 SetTitleVariation(u16 Category, rsf_settings *yaml_set) { if(IsDemo(Category)){ - if(yaml_set->DefaultSpec.TitleInfo.DemoIndex){ - u16 DemoIndex = strtol(yaml_set->DefaultSpec.TitleInfo.DemoIndex,NULL,10); + if(yaml_set->TitleInfo.DemoIndex){ + u16 DemoIndex = strtol(yaml_set->TitleInfo.DemoIndex,NULL,10); if(DemoIndex > 255 || DemoIndex == 0){ fprintf(stderr,"[ERROR] Invalid demo index '%d'\n",DemoIndex); return PID_INVALID_VARIATION; @@ -160,8 +162,8 @@ u16 SetTitleVariation(u16 Category, desc_settings *yaml_set) } else if(IsDlpChild(Category)){ - if(yaml_set->DefaultSpec.TitleInfo.ChildIndex){ - u16 ChildIndex = strtol(yaml_set->DefaultSpec.TitleInfo.ChildIndex,NULL,10); + if(yaml_set->TitleInfo.ChildIndex){ + u16 ChildIndex = strtol(yaml_set->TitleInfo.ChildIndex,NULL,10); if(ChildIndex > 255){ fprintf(stderr,"[ERROR] Invalid child index '%d'\n",ChildIndex); return PID_INVALID_VARIATION; @@ -172,8 +174,8 @@ u16 SetTitleVariation(u16 Category, desc_settings *yaml_set) return 0; } else if(IsAddOnContent(Category)){ - if(yaml_set->DefaultSpec.TitleInfo.Variation){ - u16 DataTitleIndex = strtol(yaml_set->DefaultSpec.TitleInfo.Variation,NULL,10); + if(yaml_set->TitleInfo.Variation){ // Might Rename to DataTitleIndex + u16 DataTitleIndex = strtol(yaml_set->TitleInfo.Variation,NULL,10); if(DataTitleIndex > 255){ fprintf(stderr,"[ERROR] Invalid variation '%d'\n",DataTitleIndex); return PID_INVALID_VARIATION; @@ -184,8 +186,8 @@ u16 SetTitleVariation(u16 Category, desc_settings *yaml_set) return 0; } else if(IsContents(Category)){ - if(yaml_set->DefaultSpec.TitleInfo.ContentsIndex){ - u16 ContentsIndex = strtol(yaml_set->DefaultSpec.TitleInfo.ContentsIndex,NULL,10); + if(yaml_set->TitleInfo.ContentsIndex){ + u16 ContentsIndex = strtol(yaml_set->TitleInfo.ContentsIndex,NULL,10); if(ContentsIndex > 255){ fprintf(stderr,"[ERROR] Invalid content index '%d'\n",ContentsIndex); return PID_INVALID_VARIATION; @@ -196,8 +198,8 @@ u16 SetTitleVariation(u16 Category, desc_settings *yaml_set) return 0; } else{ - if(yaml_set->DefaultSpec.TitleInfo.Version){ - u16 Version = strtol(yaml_set->DefaultSpec.TitleInfo.Version,NULL,10); + if(yaml_set->TitleInfo.Version){ + u16 Version = strtol(yaml_set->TitleInfo.Version,NULL,10); if(Version > 255){ fprintf(stderr,"[ERROR] Invalid version '%d'\n",Version); return PID_INVALID_VARIATION; diff --git a/titleid.h b/titleid.h index 943cf02..c0a1228 100644 --- a/titleid.h +++ b/titleid.h @@ -88,8 +88,8 @@ typedef enum u64 ConvertTwlIdToCtrId(u64 pgid); -int GetProgramID(u64 *dest, desc_settings *yaml, bool IsForExheader); -int GetUniqueID(u32 *dest, desc_settings *yaml); +int GetProgramID(u64 *dest, rsf_settings *yaml, bool IsForExheader); +int GetUniqueID(u32 *dest, rsf_settings *yaml); bool IsDemo(u16 Category); bool IsSystem(u16 Category); diff --git a/usersettings.c b/usersettings.c index 6a3110d..ec512db 100644 --- a/usersettings.c +++ b/usersettings.c @@ -31,7 +31,7 @@ int ParseArgs(int argc, char *argv[], user_settings *usr_settings) // Allocating Memory for Content Path Ptrs usr_settings->ContentPath = malloc(CIA_MAX_CONTENT*sizeof(char*)); if(usr_settings->ContentPath == NULL){ - fprintf(stderr,"[ERROR] MEM ERROR\n"); + fprintf(stderr,"[SETTING ERROR] MEM ERROR\n"); return USR_MEM_ERROR; } memset(usr_settings->ContentPath,0,CIA_MAX_CONTENT*sizeof(char*)); @@ -60,13 +60,13 @@ int ParseArgs(int argc, char *argv[], user_settings *usr_settings) if(!usr_settings->outfile){ char *source_path = NULL; if(usr_settings->IsBuildingNCCH0) source_path = usr_settings->rsf_path; - else if(usr_settings->Content0IsCci) source_path = usr_settings->CciPath; + else if(usr_settings->ConvertCci) source_path = usr_settings->CciPath; else if(usr_settings->Content0IsSrl) source_path = usr_settings->SrlPath; else source_path = usr_settings->ContentPath[0]; u16 outfile_len = strlen(source_path) + 3; usr_settings->outfile = malloc(outfile_len); if(!usr_settings->outfile){ - fprintf(stderr,"[ERROR] MEM ERROR\n"); + fprintf(stderr,"[SETTING ERROR] MEM ERROR\n"); return USR_MEM_ERROR; } usr_settings->outfile_mallocd = true; @@ -82,7 +82,7 @@ void SetDefaults(user_settings *set) #ifdef RETAIL_FSIGN set->accessdesc = auto_gen; #else - set->accessdesc = use_desc_file; + set->accessdesc = use_spec_file; #endif set->include_exefs_logo = false; set->out_format = CXI; @@ -90,7 +90,7 @@ void SetDefaults(user_settings *set) // Content0 Info set->Content0IsNcch = true; - set->Content0IsCci = false; + set->ConvertCci = false; set->Content0IsSrl = false; set->Version[0] = 0xffff; @@ -131,14 +131,6 @@ int SetArgument(int argc, int i, char *argv[], user_settings *set) set->rsf_path = argv[i+1]; return 2; } - else if(strcmp(argv[i],"-desc") == 0){ - if(!HasParam){ - PrintNeedsParam("-desc"); - return USR_ARG_REQ_PARAM; - } - set->desc_path = argv[i+1]; - return 2; - } else if(strcmp(argv[i],"-icon") == 0){ if(!HasParam){ PrintNeedsParam("-icon"); @@ -210,7 +202,7 @@ int SetArgument(int argc, int i, char *argv[], user_settings *set) PrintNeedsParam("-cci"); return USR_ARG_REQ_PARAM; } - set->Content0IsCci = true; + set->ConvertCci = true; set->Content0IsSrl = false; set->Content0IsNcch = false; set->IsBuildingNCCH0 = false; @@ -223,7 +215,7 @@ int SetArgument(int argc, int i, char *argv[], user_settings *set) PrintNeedsParam("-srl"); return USR_ARG_REQ_PARAM; } - set->Content0IsCci = false; + set->ConvertCci = false; set->Content0IsSrl = true; set->Content0IsNcch = false; set->IsBuildingNCCH0 = false; @@ -323,25 +315,27 @@ int SetArgument(int argc, int i, char *argv[], user_settings *set) free(key); return 2; } - #else + #endif else if(strcmp(argv[i],"-accessdesc") == 0){ if(!HasParam){ PrintNeedsParam("-accessdesc"); return USR_ARG_REQ_PARAM; } - if(strcasecmp(argv[i+1],"usedesc") == 0) set->accessdesc = use_desc_file; - else if(strcasecmp(argv[i+1],"autogen") == 0 || strcasecmp(argv[i+1],"auto") == 0) set->accessdesc = auto_gen; - else if(strcasecmp(argv[i+1],"app") == 0) set->accessdesc = app; - else if(strcasecmp(argv[i+1],"demo") == 0) set->accessdesc = demo; - else if(strcasecmp(argv[i+1],"dlpchild") == 0 || strcasecmp(argv[i+1],"dlp") == 0) set->accessdesc = dlp; + if(strcasecmp(argv[i+1],"UseRsf") == 0) set->accessdesc = use_spec_file; + else if(strcasecmp(argv[i+1],"AutoGen") == 0 || strcasecmp(argv[i+1],"Auto") == 0) set->accessdesc = auto_gen; +#ifndef RETAIL_FSIGN + else if(strcasecmp(argv[i+1],"App") == 0) set->accessdesc = app; + else if(strcasecmp(argv[i+1],"Demo") == 0) set->accessdesc = demo; + else if(strcasecmp(argv[i+1],"DlpChild") == 0 || strcasecmp(argv[i+1],"Dlp") == 0) set->accessdesc = dlp; +#endif else{ fprintf(stderr,"[-] Accessdesc pre-set '%s' not recognised\n",argv[i+1]); return USR_BAD_ARG; } return 2; } - #endif + else if(strcmp(argv[i],"-exefslogo") == 0){ if(HasParam){ PrintNoNeedParam("-exefslogo"); @@ -401,14 +395,14 @@ int SetArgument(int argc, int i, char *argv[], user_settings *set) } char *pos = strstr(argv[i+1],":"); if(!pos){ - fprintf(stderr,"[ERROR] Bad argument '%s %s', correct format:\n",argv[i],argv[i+1]); + fprintf(stderr,"[SETTING ERROR] Bad argument '%s %s', correct format:\n",argv[i],argv[i+1]); fprintf(stderr," -content :\n"); fprintf(stderr," If generating a CIA, then use the format:\n"); fprintf(stderr," -content ::\n"); return USR_BAD_ARG; } if(strlen(pos) < 2){ - fprintf(stderr,"[ERROR] Bad argument '%s %s', correct format:\n",argv[i],argv[i+1]); + fprintf(stderr,"[SETTING ERROR] Bad argument '%s %s', correct format:\n",argv[i],argv[i+1]); fprintf(stderr," -content :\n"); fprintf(stderr," If generating a CIA, then use the format:\n"); fprintf(stderr," -content ::\n"); @@ -423,12 +417,12 @@ int SetArgument(int argc, int i, char *argv[], user_settings *set) if(content_index == 0) set->IsBuildingNCCH0 = false; if(set->ContentPath[content_index] != NULL){ - fprintf(stderr,"[-] Content %d is already specified\n",content_index); + fprintf(stderr,"[SETTING ERROR] Content %d is already specified\n",content_index); return USR_BAD_ARG; } set->ContentPath[content_index] = malloc(path_len); if(set->ContentPath[content_index] == NULL){ - fprintf(stderr,"[-] MEM ERROR\n"); + fprintf(stderr,"[SETTING ERROR] MEM ERROR\n"); return USR_MEM_ERROR; } memset(set->ContentPath[content_index],0,path_len); @@ -443,12 +437,14 @@ int SetArgument(int argc, int i, char *argv[], user_settings *set) /* Return Next Arg Pos*/ return 2; } + /* else if(strncmp(argv[i],"-D",2) == 0){ fprintf(stderr,"[WARNING] -DNAME=VALUE not implemented yet\n"); } + */ // If not a valid argument - fprintf(stderr,"[ERROR] Unrecognised argument '%s'\n",argv[i]); + fprintf(stderr,"[SETTING ERROR] Unrecognised argument '%s'\n",argv[i]); return USR_UNK_ARG; } @@ -456,25 +452,25 @@ int CheckArgumentCombination(user_settings *set) { for(int i = 0; i < CIA_MAX_CONTENT; i++){ if( i > CCI_MAX_CONTENT-1 && set->ContentPath[i] && set->out_format == CCI){ - fprintf(stderr,"[ERROR] Content indexes > 7 are invalid for CCI\n"); + fprintf(stderr,"[SETTING ERROR] Content indexes > 7 are invalid for CCI\n"); return USR_BAD_ARG; } if(set->ContentPath[i] && (set->out_format == CXI || set->out_format == CFA)){ - fprintf(stderr,"[ERROR] You cannot specify content while outputting CXI/CFA files\n"); + fprintf(stderr,"[SETTING ERROR] You cannot specify content while outputting CXI/CFA files\n"); return USR_BAD_ARG; } } if((set->out_format == CXI || set->out_format == CFA) && set->build_ncch_type > 0){ - fprintf(stderr,"[ERROR] Arguments '-f cxi|cfa' and '-ncch cxi|cfa' are invalid\n"); + fprintf(stderr,"[SETTING ERROR] Arguments '-f cxi|cfa' and '-ncch cxi|cfa' are invalid\n"); return USR_BAD_ARG; } if(set->build_ncch_type > 0 && !set->IsBuildingNCCH0){ - fprintf(stderr,"[ERROR] Arguments '-content %s:0' and '-ncch cxi|cfa' cannot be used together\n",set->ContentPath[0]); + fprintf(stderr,"[SETTING ERROR] Arguments '-content %s:0' and '-ncch cxi|cfa' cannot be used together\n",set->ContentPath[0]); return USR_BAD_ARG; } if(set->elf_path && set->exefs_code_path){ - fprintf(stderr,"[ERROR] Arguments '-elf' and '-code' cannot be used together\n"); + fprintf(stderr,"[SETTING ERROR] Arguments '-elf' and '-code' cannot be used together\n"); return USR_BAD_ARG; } @@ -495,10 +491,6 @@ int CheckArgumentCombination(user_settings *set) PrintNeedsArgument("-rsf"); return USR_BAD_ARG; } - if((buildCXI && !set->desc_path) && !(set->exefs_code_path && (set->accessdesc != use_desc_file))){ - PrintNeedsArgument("-desc"); - return USR_BAD_ARG; - } if(buildCXI && !set->exheader_path && set->exefs_code_path){ PrintNeedsArgument("-exheader"); return USR_BAD_ARG; @@ -509,10 +501,6 @@ int CheckArgumentCombination(user_settings *set) PrintArgumentInvalid("-elf"); return USR_BAD_ARG; } - if(!buildCXI && set->desc_path){ - PrintArgumentInvalid("-desc"); - return USR_BAD_ARG; - } if(!buildCXI && set->exefs_code_path){ PrintArgumentInvalid("-code"); return USR_BAD_ARG; @@ -555,19 +543,13 @@ void InvalidateRSFBooleans(rsf_settings *rsf_set) rsf_set->AccessControlInfo.CanShareDeviceMemory = -1; rsf_set->AccessControlInfo.UseOtherVariationSaveData = -1; rsf_set->AccessControlInfo.UseExtSaveData = -1; + rsf_set->AccessControlInfo.UseExtendedSaveDataAccessControl = -1; rsf_set->AccessControlInfo.RunnableOnSleep = -1; rsf_set->AccessControlInfo.SpecialMemoryArrange = -1; rsf_set->BasicInfo.MediaFootPadding = -1; } -void InvalidateDESCBooleans(desc_settings *desc_set) -{ - desc_set->AccessControlDescriptor.RunnableOnSleep = -1; - desc_set->AccessControlDescriptor.SpecialMemoryArrange = -1; - desc_set->AccessControlDescriptor.AutoGen = -1; -} - void init_UserSettings(user_settings *usr_settings) { memset(usr_settings,0,sizeof(user_settings)); @@ -589,7 +571,6 @@ void free_RsfSettings(rsf_settings *set) free(set->AccessControlInfo.Priority); free(set->AccessControlInfo.MemoryType); free(set->AccessControlInfo.SystemMode); - free(set->AccessControlInfo.FirmwareVersion); free(set->AccessControlInfo.CoreVersion); free(set->AccessControlInfo.HandleTableSize); free(set->AccessControlInfo.SystemSaveDataId1); @@ -598,10 +579,15 @@ void free_RsfSettings(rsf_settings *set) free(set->AccessControlInfo.OtherUserSaveDataId2); free(set->AccessControlInfo.OtherUserSaveDataId3); free(set->AccessControlInfo.ExtSaveDataId); - free(set->AccessControlInfo.ExtSaveDataNumber); free(set->AccessControlInfo.SystemMode); free(set->AccessControlInfo.AffinityMask); - + free(set->AccessControlInfo.DescVersion); + free(set->AccessControlInfo.CryptoKey); + free(set->AccessControlInfo.ResourceLimitCategory); + free(set->AccessControlInfo.ReleaseKernelMajor); + free(set->AccessControlInfo.ReleaseKernelMinor); + free(set->AccessControlInfo.MaxCpu); + for(u32 i = 0; i < set->AccessControlInfo.MemoryMappingNum; i++){ free(set->AccessControlInfo.MemoryMapping[i]); } @@ -641,6 +627,11 @@ void free_RsfSettings(rsf_settings *set) free(set->AccessControlInfo.StorageId[i]); } free(set->AccessControlInfo.StorageId); + + for(u32 i = 0; i < set->AccessControlInfo.AccessibleSaveDataIdsNum; i++){ + free(set->AccessControlInfo.AccessibleSaveDataIds[i]); + } + free(set->AccessControlInfo.AccessibleSaveDataIds); //SystemControlInfo free(set->SystemControlInfo.AppType); @@ -733,62 +724,8 @@ void free_RsfSettings(rsf_settings *set) free(set->CardInfo.CryptoType); free(set->CardInfo.CardDevice); free(set->CardInfo.MediaType); -} + free(set->CardInfo.BackupWriteWaitTime); -void free_DescSettings(desc_settings *set) -{ - //AccessControlDescriptor - free(set->AccessControlDescriptor.ProgramIdDesc); - free(set->AccessControlDescriptor.PriorityDesc); - free(set->AccessControlDescriptor.AffinityMaskDesc); - free(set->AccessControlDescriptor.IdealProcessorDesc); - free(set->AccessControlDescriptor.FirmwareVersionDesc); - free(set->AccessControlDescriptor.HandleTableSizeDesc); - free(set->AccessControlDescriptor.MemoryTypeDesc); - free(set->AccessControlDescriptor.DescVersionDesc); - free(set->AccessControlDescriptor.SystemModeDesc); - free(set->AccessControlDescriptor.AccCtlDescSign); - free(set->AccessControlDescriptor.AccCtlDescBin); - free(set->AccessControlDescriptor.CryptoKey); - free(set->AccessControlDescriptor.ResourceLimitCategory); - free(set->AccessControlDescriptor.ReleaseKernelMajor); - free(set->AccessControlDescriptor.ReleaseKernelMinor); - - for(u32 i = 0; i < set->AccessControlDescriptor.ServiceAccessControlDescNum; i++){ - free(set->AccessControlDescriptor.ServiceAccessControlDesc[i]); - } - free(set->AccessControlDescriptor.ServiceAccessControlDesc); - - for(u32 i = 0; i < set->AccessControlDescriptor.MemoryMappingDescNum; i++){ - free(set->AccessControlDescriptor.MemoryMappingDesc[i]); - } - free(set->AccessControlDescriptor.MemoryMappingDesc); - - for(u32 i = 0; i < set->AccessControlDescriptor.IORegisterMappingDescNum; i++){ - free(set->AccessControlDescriptor.IORegisterMappingDesc[i]); - } - free(set->AccessControlDescriptor.IORegisterMappingDesc); - - for(u32 i = 0; i < set->AccessControlDescriptor.Arm9AccessControlDescNum; i++){ - free(set->AccessControlDescriptor.Arm9AccessControlDesc[i]); - } - free(set->AccessControlDescriptor.Arm9AccessControlDesc); - - for(u32 i = 0; i < set->AccessControlDescriptor.EnableInterruptNumbersNum; i++){ - free(set->AccessControlDescriptor.EnableInterruptNumbers[i]); - } - free(set->AccessControlDescriptor.EnableInterruptNumbers); - - for(u32 i = 0; i < set->AccessControlDescriptor.EnableSystemCallsNum; i++){ - free(set->AccessControlDescriptor.EnableSystemCalls[i]); - } - free(set->AccessControlDescriptor.EnableSystemCalls); - - for(u32 i = 0; i < set->AccessControlDescriptor.StorageIdDescNum; i++){ - free(set->AccessControlDescriptor.StorageIdDesc[i]); - } - free(set->AccessControlDescriptor.StorageIdDesc); - //CommonHeaderKey free(set->CommonHeaderKey.D); free(set->CommonHeaderKey.P); @@ -798,8 +735,8 @@ void free_DescSettings(desc_settings *set) free(set->CommonHeaderKey.InverseQ); free(set->CommonHeaderKey.Modulus); free(set->CommonHeaderKey.Exponent); - - free_RsfSettings(&set->DefaultSpec); + free(set->CommonHeaderKey.AccCtlDescSign); + free(set->CommonHeaderKey.AccCtlDescBin); } void free_UserSettings(user_settings *usr_settings) @@ -813,7 +750,7 @@ void free_UserSettings(user_settings *usr_settings) } // Free Spec File Setting - free_DescSettings(&usr_settings->yaml_set); + free_RsfSettings(&usr_settings->yaml_set); // Free Key Data FreeKeys(&usr_settings->keys); @@ -833,22 +770,22 @@ void free_UserSettings(user_settings *usr_settings) void PrintNeedsArgument(char *arg) { - fprintf(stderr,"[ERROR] Argument '%s' is required\n",arg); + fprintf(stderr,"[SETTING ERROR] Argument '%s' is required\n",arg); } void PrintArgumentInvalid(char *arg) { - fprintf(stderr,"[ERROR] Argument '%s' is invalid\n",arg); + fprintf(stderr,"[SETTING ERROR] Argument '%s' is invalid\n",arg); } void PrintNeedsParam(char *arg) { - fprintf(stderr,"[ERROR] '%s' requires a parameter\n",arg); + fprintf(stderr,"[SETTING ERROR] '%s' requires a parameter\n",arg); } void PrintNoNeedParam(char *arg) { - fprintf(stderr,"[ERROR] '%s' does not take a parameter\n",arg); + fprintf(stderr,"[SETTING ERROR] '%s' does not take a parameter\n",arg); } void DisplayHelp(char *app_name) @@ -869,15 +806,13 @@ void DisplayHelp(char *app_name) printf("NCCH Options:\n"); printf(" -ncch0 NCCH Format (cxi|cfa)\n"); printf(" -elf ELF File\n"); - printf(" -desc Desc File\n"); printf(" -icon Icon File\n"); printf(" -banner Banner File\n"); printf(" -logo Logo File\n"); printf(" -exefslogo Include Logo in ExeFs\n"); + printf(" -accessdesc (AutoGen|UseRsf)\n"); #ifdef RETAIL_FSIGN - printf(" -sysfixedkey <32 hex chars> Specify SystemFixed Key\n"); -#else - printf(" -accessdesc (AutoGen|UseDesc|App|Demo|Dlp)\n"); + printf(" -sysfixedkey <32 hex chars> Specify SystemFixed Key\n"); #endif #ifdef PRIVATE_BUILD printf(" -code Specify ExeFs code File\n"); diff --git a/usersettings.h b/usersettings.h index 6ef1b4b..9e15b24 100644 --- a/usersettings.h +++ b/usersettings.h @@ -18,7 +18,7 @@ typedef enum typedef enum { auto_gen, - use_desc_file, + use_spec_file, app, demo, dlp, @@ -35,10 +35,8 @@ typedef enum static const char output_extention[4][5] = {".cxi",".cfa",".cci",".cia"}; - typedef struct { - // Based on SDK 5.x makerom struct{ // Booleans int NoPadding; @@ -52,8 +50,8 @@ typedef struct char *PageSize; // String Collections - u32 AppendSystemCallNum; - char **AppendSystemCall; + u32 AppendSystemCallNum; // DELETE + char **AppendSystemCall; // DELETE } Option; struct{ @@ -67,16 +65,16 @@ typedef struct int CanShareDeviceMemory; int UseOtherVariationSaveData; int UseExtSaveData; + int UseExtendedSaveDataAccessControl; int RunnableOnSleep; int SpecialMemoryArrange; // Strings - char *ProgramId; + char *ProgramId; // DELETE char *IdealProcessor; char *Priority; char *MemoryType; char *SystemMode; - char *FirmwareVersion; char *CoreVersion; char *HandleTableSize; char *SystemSaveDataId1; @@ -85,8 +83,14 @@ typedef struct char *OtherUserSaveDataId2; char *OtherUserSaveDataId3; char *ExtSaveDataId; - char *ExtSaveDataNumber; char *AffinityMask; + // Strings From DESC + char *DescVersion; + char *CryptoKey; // DELETE + char *ResourceLimitCategory; + char *ReleaseKernelMajor; + char *ReleaseKernelMinor; + char *MaxCpu; // String Collections u32 MemoryMappingNum; @@ -96,15 +100,17 @@ typedef struct u32 FileSystemAccessNum; char **FileSystemAccess; u32 IoAccessControlNum; - char **IoAccessControl; + char **IoAccessControl; //Equiv to Arm9AccessControl u32 InterruptNumbersNum; char **InterruptNumbers; u32 SystemCallAccessNum; char **SystemCallAccess; u32 ServiceAccessControlNum; char **ServiceAccessControl; - u32 StorageIdNum; - char **StorageId; + u32 StorageIdNum; // DELETE + char **StorageId; // DELETE + u32 AccessibleSaveDataIdsNum; + char **AccessibleSaveDataIds; } AccessControlInfo; struct{ @@ -137,7 +143,7 @@ typedef struct struct{ // Strings char *HostRoot; - char *Padding; + char *Padding; // DELETE char *SaveDataSize; // String Collections @@ -171,7 +177,7 @@ typedef struct char *Version; char *ContentsIndex; char *Variation; - char *Use; + char *Use; // DELETE char *ChildIndex; char *DemoIndex; char *TargetCategory; @@ -187,57 +193,12 @@ typedef struct char *CryptoType; char *CardDevice; char *MediaType; + char *BackupWriteWaitTime; } CardInfo; -} rsf_settings; + struct{ + bool Found; -typedef struct -{ - struct{ - bool Found; - - // Booleans - int RunnableOnSleep; - int SpecialMemoryArrange; - int AutoGen; - - // String - char *ProgramIdDesc; - char *PriorityDesc; - char *AffinityMaskDesc; - char *IdealProcessorDesc; - char *FirmwareVersionDesc; - char *HandleTableSizeDesc; - char *MemoryTypeDesc; - char *DescVersionDesc; - char *SystemModeDesc; - char *AccCtlDescSign; - char *AccCtlDescBin; - char *CryptoKey; - char *ResourceLimitCategory; - char *ReleaseKernelMajor; - char *ReleaseKernelMinor; - - // String Collections - u32 ServiceAccessControlDescNum; - char **ServiceAccessControlDesc; - u32 MemoryMappingDescNum; - char **MemoryMappingDesc; - u32 IORegisterMappingDescNum; - char **IORegisterMappingDesc; - u32 Arm9AccessControlDescNum; - char **Arm9AccessControlDesc; //Equiv to IoAccessControl - u32 EnableInterruptNumbersNum; - char **EnableInterruptNumbers; - u32 EnableSystemCallsNum; - char **EnableSystemCalls; - u32 StorageIdDescNum; - char **StorageIdDesc; - } AccessControlDescriptor; - - struct{ - bool Found; - char *D; char *P; char *Q; @@ -246,10 +207,11 @@ typedef struct char *InverseQ; char *Modulus; char *Exponent; + + char *AccCtlDescSign; + char *AccCtlDescBin; } CommonHeaderKey; - - rsf_settings DefaultSpec; -} desc_settings; +} rsf_settings; typedef struct { @@ -260,7 +222,7 @@ typedef struct output_format out_format; // Content0 - bool Content0IsCci; + bool ConvertCci; char *CciPath; bool Content0IsSrl; char *SrlPath; @@ -273,7 +235,6 @@ typedef struct // Ncch0 Build bool IsBuildingNCCH0; output_format build_ncch_type; - char *desc_path; char *elf_path; char *icon_path; char *banner_path; @@ -300,7 +261,7 @@ typedef struct keys_struct keys; // RSF/DESC Imported Settings - desc_settings yaml_set; + rsf_settings yaml_set; } user_settings; #endif @@ -312,7 +273,4 @@ int ParseArgs(int argc, char *argv[], user_settings *usr_settings); void ReadYAMLtest(char *filepath); void InvalidateRSFBooleans(rsf_settings *rsf_set); -void InvalidateDESCBooleans(desc_settings *desc_set); - void free_RsfSettings(rsf_settings *set); -void free_DescSettings(desc_settings *set); \ No newline at end of file diff --git a/yaml_ctr.c b/yaml_ctr.c index 58579c3..6b6b6cb 100644 --- a/yaml_ctr.c +++ b/yaml_ctr.c @@ -3,7 +3,7 @@ // Private Prototypes void InitYamlContext(ctr_yaml_context *ctx); -int ParseSpecFile(void *set, char *path, specfile_type type); +int ParseSpecFile(rsf_settings *set, char *path); void CheckEvent(ctr_yaml_context *ctx); void BadYamlFormatting(void); @@ -11,33 +11,27 @@ void BadYamlFormatting(void); // Code int GetYamlSettings(user_settings *set) { - rsf_settings rsf_set; - memset(&rsf_set,0,sizeof(rsf_settings)); - desc_settings desc_set; - memset(&desc_set,0,sizeof(desc_settings)); - InvalidateRSFBooleans(&rsf_set); - InvalidateDESCBooleans(&desc_set); - InvalidateRSFBooleans(&desc_set.DefaultSpec); - if(set->rsf_path){ - int res = ParseSpecFile(&rsf_set,set->rsf_path,type_rsf); - if(res) return res; + memset(&set->yaml_set,0,sizeof(rsf_settings)); + InvalidateRSFBooleans(&set->yaml_set); + int ret = 0; + if(set->rsf_path) { + FILE *tmp = fopen(set->rsf_path,"rb"); + if(!tmp) { + fprintf(stderr,"[YAML ERROR] Failed to open %s\n",set->rsf_path); + return FAILED_TO_OPEN_FILE; + } + fclose(tmp); + ret = ParseSpecFile(&set->yaml_set,set->rsf_path); } - if(set->desc_path){ - int res = ParseSpecFile(&desc_set,set->desc_path,type_desc); - if(res) return res; - } - return MergeSpecData(&set->yaml_set,&desc_set,&rsf_set); + return ret; } -int ParseSpecFile(void *set, char *path, specfile_type type) +int ParseSpecFile(rsf_settings *set, char *path) { ctr_yaml_context *ctx = malloc(sizeof(ctr_yaml_context)); InitYamlContext(ctx); - - /* Set Specfile Type */ - ctx->type = type; /* Create the Parser object. */ yaml_parser_initialize(&ctx->parser); @@ -63,8 +57,7 @@ int ParseSpecFile(void *set, char *path, specfile_type type) if(EventIsScalar(ctx)){ - if(ctx->type == type_rsf) EvaluateRSF((rsf_settings*)set,ctx); - else EvaluateDESC((desc_settings*)set,ctx); + EvaluateRSF(set,ctx); if(ctx->error) goto error; break; } @@ -93,7 +86,7 @@ int ParseSpecFile(void *set, char *path, specfile_type type) /* On error. */ error: - fprintf(stderr,"[-] Error Proccessing %s file\n",ctx->type? "DESC" : "RSF"); + fprintf(stderr,"[-] Error Proccessing RSF file\n"); /* Destroy the Parser object. */ yaml_parser_delete(&ctx->parser); diff --git a/yaml_ctr.h b/yaml_ctr.h index dd1a232..7f1cfaa 100644 --- a/yaml_ctr.h +++ b/yaml_ctr.h @@ -10,12 +10,6 @@ typedef enum YAML_UNKNOWN_KEY = -5, } ctr_yaml_error; -typedef enum -{ - type_rsf, - type_desc, -} specfile_type; - typedef struct { // For Continued Parsing of file @@ -30,8 +24,6 @@ typedef struct yaml_event_type_t prev_event; u32 Level; - // Spec File Type - specfile_type type; } ctr_yaml_context; #endif diff --git a/yamlsettings.c b/yamlsettings.c index 0764048..67a7392 100644 --- a/yamlsettings.c +++ b/yamlsettings.c @@ -1,170 +1,6 @@ #include "lib.h" #include "yamlsettings.h" -void RsfSettingTransferSingle(char **src, char **dst, char **dmp); -void RsfSettingTransferMultiple(char ***src, u32 *src_num, char ***dst, u32 *dst_num, char ***dmp, u32 *dmp_num); - -int MergeSpecData(desc_settings *out, desc_settings *desc, rsf_settings *rsf) -{ - // Setup - memcpy(out,desc,sizeof(desc_settings)); // Using desc as base, then adding rsf settings - rsf_settings *rsf_dst = &out->DefaultSpec; - rsf_settings *rsf_src = rsf; - rsf_settings *rsf_dmp = &desc->DefaultSpec; // for unneeded ptrs which need freeing - memset(rsf_dmp,0,sizeof(rsf_settings)); - - // Booleans - if(rsf_src->Option.NoPadding != -1) rsf_dst->Option.NoPadding = rsf_src->Option.NoPadding; - if(rsf_src->Option.AllowUnalignedSection != -1) rsf_dst->Option.AllowUnalignedSection = rsf_src->Option.AllowUnalignedSection; - if(rsf_src->Option.EnableCrypt != -1) rsf_dst->Option.EnableCrypt = rsf_src->Option.EnableCrypt; - if(rsf_src->Option.EnableCompress != -1) rsf_dst->Option.EnableCompress = rsf_src->Option.EnableCompress; - if(rsf_src->Option.FreeProductCode != -1) rsf_dst->Option.FreeProductCode = rsf_src->Option.FreeProductCode; - if(rsf_src->Option.UseOnSD != -1) rsf_dst->Option.UseOnSD = rsf_src->Option.UseOnSD; - - if(rsf_src->AccessControlInfo.DisableDebug != -1) rsf_dst->AccessControlInfo.DisableDebug = rsf_src->AccessControlInfo.DisableDebug; - if(rsf_src->AccessControlInfo.EnableForceDebug != -1) rsf_dst->AccessControlInfo.EnableForceDebug = rsf_src->AccessControlInfo.EnableForceDebug; - if(rsf_src->AccessControlInfo.CanWriteSharedPage != -1) rsf_dst->AccessControlInfo.CanWriteSharedPage = rsf_src->AccessControlInfo.CanWriteSharedPage; - if(rsf_src->AccessControlInfo.CanUsePrivilegedPriority != -1) rsf_dst->AccessControlInfo.CanUsePrivilegedPriority = rsf_src->AccessControlInfo.CanUsePrivilegedPriority; - if(rsf_src->AccessControlInfo.CanUseNonAlphabetAndNumber != -1) rsf_dst->AccessControlInfo.CanUseNonAlphabetAndNumber = rsf_src->AccessControlInfo.CanUseNonAlphabetAndNumber; - if(rsf_src->AccessControlInfo.PermitMainFunctionArgument != -1) rsf_dst->AccessControlInfo.PermitMainFunctionArgument = rsf_src->AccessControlInfo.PermitMainFunctionArgument; - if(rsf_src->AccessControlInfo.CanShareDeviceMemory != -1) rsf_dst->AccessControlInfo.CanShareDeviceMemory = rsf_src->AccessControlInfo.CanShareDeviceMemory; - if(rsf_src->AccessControlInfo.UseOtherVariationSaveData != -1) rsf_dst->AccessControlInfo.UseOtherVariationSaveData = rsf_src->AccessControlInfo.UseOtherVariationSaveData; - if(rsf_src->AccessControlInfo.UseExtSaveData != -1) rsf_dst->AccessControlInfo.UseExtSaveData = rsf_src->AccessControlInfo.UseExtSaveData; - if(rsf_src->AccessControlInfo.RunnableOnSleep != -1) rsf_dst->AccessControlInfo.RunnableOnSleep = rsf_src->AccessControlInfo.RunnableOnSleep; - if(rsf_src->AccessControlInfo.SpecialMemoryArrange != -1) rsf_dst->AccessControlInfo.SpecialMemoryArrange = rsf_src->AccessControlInfo.SpecialMemoryArrange; - - if(rsf_src->BasicInfo.MediaFootPadding != -1) rsf_dst->BasicInfo.MediaFootPadding = rsf_src->BasicInfo.MediaFootPadding; - - // Strings - //Option - RsfSettingTransferSingle(&rsf_src->Option.PageSize,&rsf_dst->Option.PageSize,&rsf_dmp->Option.PageSize); - RsfSettingTransferMultiple(&rsf_src->Option.AppendSystemCall,&rsf_src->Option.AppendSystemCallNum,&rsf_dst->Option.AppendSystemCall,&rsf_dst->Option.AppendSystemCallNum,&rsf_dmp->Option.AppendSystemCall,&rsf_dmp->Option.AppendSystemCallNum); - - //AccessControlInfo - RsfSettingTransferSingle(&rsf_src->AccessControlInfo.ProgramId,&rsf_dst->AccessControlInfo.ProgramId,&rsf_dmp->AccessControlInfo.ProgramId); - RsfSettingTransferSingle(&rsf_src->AccessControlInfo.IdealProcessor,&rsf_dst->AccessControlInfo.IdealProcessor,&rsf_dmp->AccessControlInfo.IdealProcessor); - RsfSettingTransferSingle(&rsf_src->AccessControlInfo.Priority,&rsf_dst->AccessControlInfo.Priority,&rsf_dmp->AccessControlInfo.Priority); - RsfSettingTransferSingle(&rsf_src->AccessControlInfo.MemoryType,&rsf_dst->AccessControlInfo.MemoryType,&rsf_dmp->AccessControlInfo.MemoryType); - RsfSettingTransferSingle(&rsf_src->AccessControlInfo.SystemMode,&rsf_dst->AccessControlInfo.SystemMode,&rsf_dmp->AccessControlInfo.SystemMode); - RsfSettingTransferSingle(&rsf_src->AccessControlInfo.FirmwareVersion,&rsf_dst->AccessControlInfo.FirmwareVersion,&rsf_dmp->AccessControlInfo.FirmwareVersion); - RsfSettingTransferSingle(&rsf_src->AccessControlInfo.CoreVersion,&rsf_dst->AccessControlInfo.CoreVersion,&rsf_dmp->AccessControlInfo.CoreVersion); - RsfSettingTransferSingle(&rsf_src->AccessControlInfo.HandleTableSize,&rsf_dst->AccessControlInfo.HandleTableSize,&rsf_dmp->AccessControlInfo.HandleTableSize); - RsfSettingTransferSingle(&rsf_src->AccessControlInfo.SystemSaveDataId1,&rsf_dst->AccessControlInfo.SystemSaveDataId1,&rsf_dmp->AccessControlInfo.SystemSaveDataId1); - RsfSettingTransferSingle(&rsf_src->AccessControlInfo.SystemSaveDataId2,&rsf_dst->AccessControlInfo.SystemSaveDataId2,&rsf_dmp->AccessControlInfo.SystemSaveDataId2); - RsfSettingTransferSingle(&rsf_src->AccessControlInfo.OtherUserSaveDataId1,&rsf_dst->AccessControlInfo.OtherUserSaveDataId1,&rsf_dmp->AccessControlInfo.OtherUserSaveDataId1); - RsfSettingTransferSingle(&rsf_src->AccessControlInfo.OtherUserSaveDataId2,&rsf_dst->AccessControlInfo.OtherUserSaveDataId2,&rsf_dmp->AccessControlInfo.OtherUserSaveDataId2); - RsfSettingTransferSingle(&rsf_src->AccessControlInfo.OtherUserSaveDataId3,&rsf_dst->AccessControlInfo.OtherUserSaveDataId3,&rsf_dmp->AccessControlInfo.OtherUserSaveDataId3); - RsfSettingTransferSingle(&rsf_src->AccessControlInfo.ExtSaveDataId,&rsf_dst->AccessControlInfo.ExtSaveDataId,&rsf_dmp->AccessControlInfo.ExtSaveDataId); - RsfSettingTransferSingle(&rsf_src->AccessControlInfo.ExtSaveDataNumber,&rsf_dst->AccessControlInfo.ExtSaveDataNumber,&rsf_dmp->AccessControlInfo.ExtSaveDataNumber); - RsfSettingTransferSingle(&rsf_src->AccessControlInfo.SystemMode,&rsf_dst->AccessControlInfo.SystemMode,&rsf_dmp->AccessControlInfo.SystemMode); - RsfSettingTransferSingle(&rsf_src->AccessControlInfo.AffinityMask,&rsf_dst->AccessControlInfo.AffinityMask,&rsf_dmp->AccessControlInfo.AffinityMask); - RsfSettingTransferMultiple(&rsf_src->AccessControlInfo.MemoryMapping,&rsf_src->AccessControlInfo.MemoryMappingNum,&rsf_dst->AccessControlInfo.MemoryMapping,&rsf_dst->AccessControlInfo.MemoryMappingNum,&rsf_dmp->AccessControlInfo.MemoryMapping,&rsf_dmp->AccessControlInfo.MemoryMappingNum); - RsfSettingTransferMultiple(&rsf_src->AccessControlInfo.IORegisterMapping,&rsf_src->AccessControlInfo.IORegisterMappingNum,&rsf_dst->AccessControlInfo.IORegisterMapping,&rsf_dst->AccessControlInfo.IORegisterMappingNum,&rsf_dmp->AccessControlInfo.IORegisterMapping,&rsf_dmp->AccessControlInfo.IORegisterMappingNum); - RsfSettingTransferMultiple(&rsf_src->AccessControlInfo.FileSystemAccess,&rsf_src->AccessControlInfo.FileSystemAccessNum,&rsf_dst->AccessControlInfo.FileSystemAccess,&rsf_dst->AccessControlInfo.FileSystemAccessNum,&rsf_dmp->AccessControlInfo.FileSystemAccess,&rsf_dmp->AccessControlInfo.FileSystemAccessNum); - RsfSettingTransferMultiple(&rsf_src->AccessControlInfo.IoAccessControl,&rsf_src->AccessControlInfo.IoAccessControlNum,&rsf_dst->AccessControlInfo.IoAccessControl,&rsf_dst->AccessControlInfo.IoAccessControlNum,&rsf_dmp->AccessControlInfo.IoAccessControl,&rsf_dmp->AccessControlInfo.IoAccessControlNum); - RsfSettingTransferMultiple(&rsf_src->AccessControlInfo.InterruptNumbers,&rsf_src->AccessControlInfo.InterruptNumbersNum,&rsf_dst->AccessControlInfo.InterruptNumbers,&rsf_dst->AccessControlInfo.InterruptNumbersNum,&rsf_dmp->AccessControlInfo.InterruptNumbers,&rsf_dmp->AccessControlInfo.InterruptNumbersNum); - RsfSettingTransferMultiple(&rsf_src->AccessControlInfo.SystemCallAccess,&rsf_src->AccessControlInfo.SystemCallAccessNum,&rsf_dst->AccessControlInfo.SystemCallAccess,&rsf_dst->AccessControlInfo.SystemCallAccessNum,&rsf_dmp->AccessControlInfo.SystemCallAccess,&rsf_dmp->AccessControlInfo.SystemCallAccessNum); - RsfSettingTransferMultiple(&rsf_src->AccessControlInfo.ServiceAccessControl,&rsf_src->AccessControlInfo.ServiceAccessControlNum,&rsf_dst->AccessControlInfo.ServiceAccessControl,&rsf_dst->AccessControlInfo.ServiceAccessControlNum,&rsf_dmp->AccessControlInfo.ServiceAccessControl,&rsf_dmp->AccessControlInfo.ServiceAccessControlNum); - RsfSettingTransferMultiple(&rsf_src->AccessControlInfo.StorageId,&rsf_src->AccessControlInfo.StorageIdNum,&rsf_dst->AccessControlInfo.StorageId,&rsf_dst->AccessControlInfo.StorageIdNum,&rsf_dmp->AccessControlInfo.StorageId,&rsf_dmp->AccessControlInfo.StorageIdNum); - - - //SystemControlInfo - RsfSettingTransferSingle(&rsf_src->SystemControlInfo.StackSize,&rsf_dst->SystemControlInfo.StackSize,&rsf_dmp->SystemControlInfo.StackSize); - RsfSettingTransferSingle(&rsf_src->SystemControlInfo.AppType,&rsf_dst->SystemControlInfo.AppType,&rsf_dmp->SystemControlInfo.AppType); - RsfSettingTransferSingle(&rsf_src->SystemControlInfo.RemasterVersion,&rsf_dst->SystemControlInfo.RemasterVersion,&rsf_dmp->SystemControlInfo.RemasterVersion); - RsfSettingTransferSingle(&rsf_src->SystemControlInfo.JumpId,&rsf_dst->SystemControlInfo.JumpId,&rsf_dmp->SystemControlInfo.JumpId); - RsfSettingTransferMultiple(&rsf_src->SystemControlInfo.Dependency,&rsf_src->SystemControlInfo.DependencyNum,&rsf_dst->SystemControlInfo.Dependency,&rsf_dst->SystemControlInfo.DependencyNum,&rsf_dmp->SystemControlInfo.Dependency,&rsf_dmp->SystemControlInfo.DependencyNum); - - //BasicInfo - RsfSettingTransferSingle(&rsf_src->BasicInfo.Title,&rsf_dst->BasicInfo.Title,&rsf_dmp->BasicInfo.Title); - RsfSettingTransferSingle(&rsf_src->BasicInfo.CompanyCode,&rsf_dst->BasicInfo.CompanyCode,&rsf_dmp->BasicInfo.CompanyCode); - RsfSettingTransferSingle(&rsf_src->BasicInfo.ProductCode,&rsf_dst->BasicInfo.ProductCode,&rsf_dmp->BasicInfo.ProductCode); - RsfSettingTransferSingle(&rsf_src->BasicInfo.MediaSize,&rsf_dst->BasicInfo.MediaSize,&rsf_dmp->BasicInfo.MediaSize); - RsfSettingTransferSingle(&rsf_src->BasicInfo.ContentType,&rsf_dst->BasicInfo.ContentType,&rsf_dmp->BasicInfo.ContentType); - RsfSettingTransferSingle(&rsf_src->BasicInfo.Logo,&rsf_dst->BasicInfo.Logo,&rsf_dmp->BasicInfo.Logo); - RsfSettingTransferSingle(&rsf_src->BasicInfo.BackupMemoryType,&rsf_dst->BasicInfo.BackupMemoryType,&rsf_dmp->BasicInfo.BackupMemoryType); - RsfSettingTransferSingle(&rsf_src->BasicInfo.InitialCode,&rsf_dst->BasicInfo.InitialCode,&rsf_dmp->BasicInfo.InitialCode); - - //Rom - RsfSettingTransferSingle(&rsf_src->Rom.HostRoot,&rsf_dst->Rom.HostRoot,&rsf_dmp->Rom.HostRoot); - RsfSettingTransferSingle(&rsf_src->Rom.Padding,&rsf_dst->Rom.Padding,&rsf_dmp->Rom.Padding); - RsfSettingTransferSingle(&rsf_src->Rom.SaveDataSize,&rsf_dst->Rom.SaveDataSize,&rsf_dmp->Rom.SaveDataSize); - RsfSettingTransferMultiple(&rsf_src->Rom.DefaultReject,&rsf_src->Rom.DefaultRejectNum,&rsf_dst->Rom.DefaultReject,&rsf_dst->Rom.DefaultRejectNum,&rsf_dmp->Rom.DefaultReject,&rsf_dmp->Rom.DefaultRejectNum); - RsfSettingTransferMultiple(&rsf_src->Rom.Reject,&rsf_src->Rom.RejectNum,&rsf_dst->Rom.Reject,&rsf_dst->Rom.RejectNum,&rsf_dmp->Rom.Reject,&rsf_dmp->Rom.RejectNum); - RsfSettingTransferMultiple(&rsf_src->Rom.Include,&rsf_src->Rom.IncludeNum,&rsf_dst->Rom.Include,&rsf_dst->Rom.IncludeNum,&rsf_dmp->Rom.Include,&rsf_dmp->Rom.IncludeNum); - RsfSettingTransferMultiple(&rsf_src->Rom.File,&rsf_src->Rom.FileNum,&rsf_dst->Rom.File,&rsf_dst->Rom.FileNum,&rsf_dmp->Rom.File,&rsf_dmp->Rom.FileNum); - - //ExeFs - RsfSettingTransferMultiple(&rsf_src->ExeFs.Text,&rsf_src->ExeFs.TextNum,&rsf_dst->ExeFs.Text,&rsf_dst->ExeFs.TextNum,&rsf_dmp->ExeFs.Text,&rsf_dmp->ExeFs.TextNum); - RsfSettingTransferMultiple(&rsf_src->ExeFs.ReadOnly,&rsf_src->ExeFs.ReadOnlyNum,&rsf_dst->ExeFs.ReadOnly,&rsf_dst->ExeFs.ReadOnlyNum,&rsf_dmp->ExeFs.ReadOnly,&rsf_dmp->ExeFs.ReadOnlyNum); - RsfSettingTransferMultiple(&rsf_src->ExeFs.ReadWrite,&rsf_src->ExeFs.ReadWriteNum,&rsf_dst->ExeFs.ReadWrite,&rsf_dst->ExeFs.ReadWriteNum,&rsf_dmp->ExeFs.ReadWrite,&rsf_dmp->ExeFs.ReadWriteNum); - - //PlainRegion - RsfSettingTransferMultiple(&rsf_src->PlainRegion,&rsf_src->PlainRegionNum,&rsf_dst->PlainRegion,&rsf_dst->PlainRegionNum,&rsf_dmp->PlainRegion,&rsf_dmp->PlainRegionNum); - - //TitleInfo - RsfSettingTransferSingle(&rsf_src->TitleInfo.Platform,&rsf_dst->TitleInfo.Platform,&rsf_dmp->TitleInfo.Platform); - RsfSettingTransferSingle(&rsf_src->TitleInfo.Category,&rsf_dst->TitleInfo.Category,&rsf_dmp->TitleInfo.Category); - RsfSettingTransferSingle(&rsf_src->TitleInfo.UniqueId,&rsf_dst->TitleInfo.UniqueId,&rsf_dmp->TitleInfo.UniqueId); - RsfSettingTransferSingle(&rsf_src->TitleInfo.Version,&rsf_dst->TitleInfo.Version,&rsf_dmp->TitleInfo.Version); - RsfSettingTransferSingle(&rsf_src->TitleInfo.ContentsIndex,&rsf_dst->TitleInfo.ContentsIndex,&rsf_dmp->TitleInfo.ContentsIndex); - RsfSettingTransferSingle(&rsf_src->TitleInfo.Variation,&rsf_dst->TitleInfo.Variation,&rsf_dmp->TitleInfo.Variation); - RsfSettingTransferSingle(&rsf_src->TitleInfo.Use,&rsf_dst->TitleInfo.Use,&rsf_dmp->TitleInfo.Use); - RsfSettingTransferSingle(&rsf_src->TitleInfo.ChildIndex,&rsf_dst->TitleInfo.ChildIndex,&rsf_dmp->TitleInfo.ChildIndex); - RsfSettingTransferSingle(&rsf_src->TitleInfo.DemoIndex,&rsf_dst->TitleInfo.DemoIndex,&rsf_dmp->TitleInfo.DemoIndex); - RsfSettingTransferSingle(&rsf_src->TitleInfo.TargetCategory,&rsf_dst->TitleInfo.TargetCategory,&rsf_dmp->TitleInfo.TargetCategory); - RsfSettingTransferMultiple(&rsf_src->TitleInfo.CategoryFlags,&rsf_src->TitleInfo.CategoryFlagsNum,&rsf_dst->TitleInfo.CategoryFlags,&rsf_dst->TitleInfo.CategoryFlagsNum,&rsf_dmp->TitleInfo.CategoryFlags,&rsf_dmp->TitleInfo.CategoryFlagsNum); - - //CardInfo - RsfSettingTransferSingle(&rsf_src->CardInfo.WritableAddress,&rsf_dst->CardInfo.WritableAddress,&rsf_dmp->CardInfo.WritableAddress); - RsfSettingTransferSingle(&rsf_src->CardInfo.CardType,&rsf_dst->CardInfo.CardType,&rsf_dmp->CardInfo.CardType); - RsfSettingTransferSingle(&rsf_src->CardInfo.CryptoType,&rsf_dst->CardInfo.CryptoType,&rsf_dmp->CardInfo.CryptoType); - RsfSettingTransferSingle(&rsf_src->CardInfo.CardDevice,&rsf_dst->CardInfo.CardDevice,&rsf_dmp->CardInfo.CardDevice); - RsfSettingTransferSingle(&rsf_src->CardInfo.MediaType,&rsf_dst->CardInfo.MediaType,&rsf_dmp->CardInfo.MediaType); - - free_RsfSettings(rsf_dmp); - - memset(desc,0,sizeof(desc_settings)); - memset(rsf,0,sizeof(rsf_settings)); - - return 0; -} - -void RsfSettingTransferSingle(char **src, char **dst, char **dmp) -{ - if(*src){ // RSF Setting was set - if(*dst) *dmp = *dst; // DESC was also set, so send ptr to dump - else *dmp = NULL; - *dst = *src; // Set DESC Ptr to RSF's ptr - *src = NULL; // Setting to NULL Just in case - } - else{ - *dmp = NULL; - } -} - -void RsfSettingTransferMultiple(char ***src, u32 *src_num, char ***dst, u32 *dst_num, char ***dmp, u32 *dmp_num) -{ - if(*src){ - if(*dst){ - *dmp = *dst; - *dmp_num = *dst_num; - } - else{ - *dmp = NULL; - *dmp_num = 0; - } - *dst = *src; - *dst_num = *src_num; - *src = NULL; - *src_num = 0; - } - else{ - *dmp = NULL; - *dmp_num = 0; - } -} - void EvaluateRSF(rsf_settings *rsf, ctr_yaml_context *ctx) { u32 start_level = ctx->Level-1; @@ -181,7 +17,8 @@ void EvaluateRSF(rsf_settings *rsf, ctr_yaml_context *ctx) else if(cmpYamlValue("PlainRegion",ctx)) {FinishEvent(ctx); GET_PlainRegion(ctx,rsf); goto GET_NextGroup;} else if(cmpYamlValue("TitleInfo",ctx)) {FinishEvent(ctx); GET_TitleInfo(ctx,rsf); goto GET_NextGroup;} else if(cmpYamlValue("CardInfo",ctx)) {FinishEvent(ctx); GET_CardInfo(ctx,rsf); goto GET_NextGroup;} - + else if(cmpYamlValue("CommonHeaderKey",ctx)) {FinishEvent(ctx); GET_CommonHeaderKey(ctx,rsf); goto GET_NextGroup;} + // If not recognised escape: fprintf(stderr,"[-] Unrecognised Key: '%s'\n",GetYamlString(ctx)); FinishEvent(ctx); @@ -205,42 +42,6 @@ void EvaluateRSF(rsf_settings *rsf, ctr_yaml_context *ctx) goto CHECK_Group; } -void EvaluateDESC(desc_settings *desc, ctr_yaml_context *ctx) -{ - /* Check Group Key for Validity */ - CHECK_Group: - //printf("%s\n",GetYamlString(ctx)); - if(cmpYamlValue("AccessControlDescriptor",ctx)) {FinishEvent(ctx); GET_AccessControlDescriptor(ctx,desc); goto GET_NextGroup;} - else if(cmpYamlValue("CommonHeaderKey",ctx)) {FinishEvent(ctx); GET_CommonHeaderKey(ctx,desc); goto GET_NextGroup;} - else if(cmpYamlValue("DefaultSpec",ctx)) { - FinishEvent(ctx); - if(!CheckMappingEvent(ctx)) return; - GetEvent(ctx); - EvaluateRSF(&desc->DefaultSpec,ctx); - goto GET_NextGroup; - } - - // If not recognised escape: - fprintf(stderr,"[-] Unrecognised Key: '%s' (DESC)\n",GetYamlString(ctx)); - FinishEvent(ctx); - ctx->error = YAML_BAD_GROUP_HEADER; - return; - - /* Get Next Group and call check */ - GET_NextGroup: - // If done return - if(ctx->done || ctx->error) return; - - // Recursively getting events until done or has value - if(!ctx->event.type) GetEvent(ctx); - while(!EventIsScalar(ctx)){ - if(ctx->done || ctx->error) return; - FinishEvent(ctx); - GetEvent(ctx); - } - goto CHECK_Group; -} - void GET_Option(ctr_yaml_context *ctx, rsf_settings *rsf) { /* Checking That Group is in a map */ @@ -291,6 +92,7 @@ void GET_AccessControlInfo(ctr_yaml_context *ctx, rsf_settings *rsf) else if(cmpYamlValue("CanShareDeviceMemory",ctx)) rsf->AccessControlInfo.CanShareDeviceMemory = SetBoolYAMLValue("CanShareDeviceMemory",ctx); else if(cmpYamlValue("UseOtherVariationSaveData",ctx)) rsf->AccessControlInfo.UseOtherVariationSaveData = SetBoolYAMLValue("UseOtherVariationSaveData",ctx); else if(cmpYamlValue("UseExtSaveData",ctx)) rsf->AccessControlInfo.UseExtSaveData = SetBoolYAMLValue("UseExtSaveData",ctx); + else if(cmpYamlValue("UseExtendedSaveDataAccessControl",ctx)) rsf->AccessControlInfo.UseExtendedSaveDataAccessControl = SetBoolYAMLValue("UseExtendedSaveDataAccessControl",ctx); else if(cmpYamlValue("RunnableOnSleep",ctx)) rsf->AccessControlInfo.RunnableOnSleep = SetBoolYAMLValue("RunnableOnSleep",ctx); else if(cmpYamlValue("SpecialMemoryArrange",ctx)) rsf->AccessControlInfo.SpecialMemoryArrange = SetBoolYAMLValue("SpecialMemoryArrange",ctx); @@ -300,7 +102,6 @@ void GET_AccessControlInfo(ctr_yaml_context *ctx, rsf_settings *rsf) else if(cmpYamlValue("Priority",ctx)) SetSimpleYAMLValue(&rsf->AccessControlInfo.Priority,"Priority",ctx,0); else if(cmpYamlValue("MemoryType",ctx)) SetSimpleYAMLValue(&rsf->AccessControlInfo.MemoryType,"MemoryType",ctx,0); else if(cmpYamlValue("SystemMode",ctx)) SetSimpleYAMLValue(&rsf->AccessControlInfo.SystemMode,"SystemMode",ctx,0); - else if(cmpYamlValue("FirmwareVersion",ctx)) SetSimpleYAMLValue(&rsf->AccessControlInfo.FirmwareVersion,"FirmwareVersion",ctx,0); else if(cmpYamlValue("CoreVersion",ctx)) SetSimpleYAMLValue(&rsf->AccessControlInfo.CoreVersion,"CoreVersion",ctx,0); else if(cmpYamlValue("HandleTableSize",ctx)) SetSimpleYAMLValue(&rsf->AccessControlInfo.HandleTableSize,"HandleTableSize",ctx,0); else if(cmpYamlValue("SystemSaveDataId1",ctx)) SetSimpleYAMLValue(&rsf->AccessControlInfo.SystemSaveDataId1,"SystemSaveDataId1",ctx,0); @@ -309,9 +110,14 @@ void GET_AccessControlInfo(ctr_yaml_context *ctx, rsf_settings *rsf) else if(cmpYamlValue("OtherUserSaveDataId2",ctx)) SetSimpleYAMLValue(&rsf->AccessControlInfo.OtherUserSaveDataId2,"OtherUserSaveDataId2",ctx,0); else if(cmpYamlValue("OtherUserSaveDataId3",ctx)) SetSimpleYAMLValue(&rsf->AccessControlInfo.OtherUserSaveDataId3,"OtherUserSaveDataId3",ctx,0); else if(cmpYamlValue("ExtSaveDataId",ctx)) SetSimpleYAMLValue(&rsf->AccessControlInfo.ExtSaveDataId,"ExtSaveDataId",ctx,0); - else if(cmpYamlValue("ExtSaveDataNumber",ctx)) SetSimpleYAMLValue(&rsf->AccessControlInfo.ExtSaveDataNumber,"ExtSaveDataNumber",ctx,0); else if(cmpYamlValue("AffinityMask",ctx)) SetSimpleYAMLValue(&rsf->AccessControlInfo.AffinityMask,"AffinityMask",ctx,0); - + else if(cmpYamlValue("DescVersion",ctx)) SetSimpleYAMLValue(&rsf->AccessControlInfo.DescVersion,"DescVersion",ctx,0); + else if(cmpYamlValue("CryptoKey",ctx)) SetSimpleYAMLValue(&rsf->AccessControlInfo.CryptoKey,"CryptoKey",ctx,0); + else if(cmpYamlValue("ResourceLimitCategory",ctx)) SetSimpleYAMLValue(&rsf->AccessControlInfo.ResourceLimitCategory,"ResourceLimitCategory",ctx,0); + else if(cmpYamlValue("ReleaseKernelMajor",ctx)) SetSimpleYAMLValue(&rsf->AccessControlInfo.ReleaseKernelMajor,"ReleaseKernelMajor",ctx,0); + else if(cmpYamlValue("ReleaseKernelMinor",ctx)) SetSimpleYAMLValue(&rsf->AccessControlInfo.ReleaseKernelMinor,"ReleaseKernelMinor",ctx,0); + else if(cmpYamlValue("MaxCpu",ctx)) SetSimpleYAMLValue(&rsf->AccessControlInfo.MaxCpu,"MaxCpu",ctx,0); + else if(cmpYamlValue("MemoryMapping",ctx)) rsf->AccessControlInfo.MemoryMappingNum = SetYAMLSequence(&rsf->AccessControlInfo.MemoryMapping,"MemoryMapping",ctx); else if(cmpYamlValue("IORegisterMapping",ctx)) rsf->AccessControlInfo.IORegisterMappingNum = SetYAMLSequence(&rsf->AccessControlInfo.IORegisterMapping,"IORegisterMapping",ctx); @@ -321,7 +127,8 @@ void GET_AccessControlInfo(ctr_yaml_context *ctx, rsf_settings *rsf) else if(cmpYamlValue("SystemCallAccess",ctx)) rsf->AccessControlInfo.SystemCallAccessNum = SetYAMLSequenceFromMapping(&rsf->AccessControlInfo.SystemCallAccess,"SystemCallAccess",ctx,false); else if(cmpYamlValue("ServiceAccessControl",ctx)) rsf->AccessControlInfo.ServiceAccessControlNum = SetYAMLSequence(&rsf->AccessControlInfo.ServiceAccessControl,"ServiceAccessControl",ctx); else if(cmpYamlValue("StorageId",ctx)) rsf->AccessControlInfo.StorageIdNum = SetYAMLSequence(&rsf->AccessControlInfo.StorageId,"StorageId",ctx); - + else if(cmpYamlValue("AccessibleSaveDataIds",ctx)) rsf->AccessControlInfo.AccessibleSaveDataIdsNum = SetYAMLSequence(&rsf->AccessControlInfo.AccessibleSaveDataIds,"AccessibleSaveDataIds",ctx); + else{ fprintf(stderr,"[-] Unrecognised key '%s'\n",GetYamlString(ctx)); ctx->error = YAML_UNKNOWN_KEY; @@ -515,7 +322,8 @@ void GET_CardInfo(ctr_yaml_context *ctx, rsf_settings *rsf) else if(cmpYamlValue("CryptoType",ctx)) SetSimpleYAMLValue(&rsf->CardInfo.CryptoType,"CryptoType",ctx,0); else if(cmpYamlValue("CardDevice",ctx)) SetSimpleYAMLValue(&rsf->CardInfo.CardDevice,"CardDevice",ctx,0); else if(cmpYamlValue("MediaType",ctx)) SetSimpleYAMLValue(&rsf->CardInfo.MediaType,"MediaType",ctx,0); - + else if(cmpYamlValue("BackupWriteWaitTime",ctx)) SetSimpleYAMLValue(&rsf->CardInfo.BackupWriteWaitTime,"BackupWriteWaitTime",ctx,0); + else{ fprintf(stderr,"[-] Unrecognised key '%s'\n",GetYamlString(ctx)); ctx->error = YAML_UNKNOWN_KEY; @@ -529,99 +337,29 @@ void GET_CardInfo(ctr_yaml_context *ctx, rsf_settings *rsf) FinishEvent(ctx); } -void GET_AccessControlDescriptor(ctr_yaml_context *ctx, desc_settings *desc) -{ - /* Checking That Group is in a map */ - if(!CheckMappingEvent(ctx)) return; - - u32 InitLevel = ctx->Level; - - /* Checking each child */ - GetEvent(ctx); - desc->AccessControlDescriptor.Found = true; - while(ctx->Level == InitLevel){ - if(ctx->error || ctx->done) return; - // Handle childs - else if(cmpYamlValue("RunnableOnSleep",ctx)) desc->AccessControlDescriptor.RunnableOnSleep = SetBoolYAMLValue("RunnableOnSleep",ctx); - else if(cmpYamlValue("SpecialMemoryArrange",ctx)) desc->AccessControlDescriptor.SpecialMemoryArrange = SetBoolYAMLValue("SpecialMemoryArrange",ctx); - else if(cmpYamlValue("AutoGen",ctx)) desc->AccessControlDescriptor.AutoGen = SetBoolYAMLValue("AutoGen",ctx); - - else if(cmpYamlValue("ProgramId",ctx)) SetSimpleYAMLValue(&desc->AccessControlDescriptor.ProgramIdDesc,"ProgramId",ctx,0); - else if(cmpYamlValue("Priority",ctx)) SetSimpleYAMLValue(&desc->AccessControlDescriptor.PriorityDesc,"Priority",ctx,0); - else if(cmpYamlValue("AffinityMask",ctx)) SetSimpleYAMLValue(&desc->AccessControlDescriptor.AffinityMaskDesc,"AffinityMask",ctx,0); - else if(cmpYamlValue("IdealProcessor",ctx)) SetSimpleYAMLValue(&desc->AccessControlDescriptor.IdealProcessorDesc,"IdealProcessor",ctx,0); - else if(cmpYamlValue("FirmwareVersion",ctx)) SetSimpleYAMLValue(&desc->AccessControlDescriptor.FirmwareVersionDesc,"FirmwareVersion",ctx,0); - else if(cmpYamlValue("HandleTableSize",ctx)) SetSimpleYAMLValue(&desc->AccessControlDescriptor.HandleTableSizeDesc,"HandleTableSize",ctx,0); - else if(cmpYamlValue("MemoryType",ctx)) SetSimpleYAMLValue(&desc->AccessControlDescriptor.MemoryTypeDesc,"MemoryType",ctx,0); - else if(cmpYamlValue("SystemMode",ctx)) SetSimpleYAMLValue(&desc->AccessControlDescriptor.SystemModeDesc,"SystemMode",ctx,0); - else if(cmpYamlValue("DescVersion",ctx)) SetSimpleYAMLValue(&desc->AccessControlDescriptor.DescVersionDesc,"DescVersion",ctx,0); - else if(cmpYamlValue("Signature",ctx)) SetSimpleYAMLValue(&desc->AccessControlDescriptor.AccCtlDescSign,"Signature",ctx,0); - else if(cmpYamlValue("Descriptor",ctx)) SetSimpleYAMLValue(&desc->AccessControlDescriptor.AccCtlDescBin,"Descriptor",ctx,0); - else if(cmpYamlValue("CryptoKey",ctx)) SetSimpleYAMLValue(&desc->AccessControlDescriptor.CryptoKey,"CryptoKey",ctx,0); - else if(cmpYamlValue("ResourceLimitCategory",ctx)) SetSimpleYAMLValue(&desc->AccessControlDescriptor.ResourceLimitCategory,"ResourceLimitCategory",ctx,0); - else if(cmpYamlValue("ReleaseKernelMajor",ctx)) SetSimpleYAMLValue(&desc->AccessControlDescriptor.ReleaseKernelMajor,"ReleaseKernelMajor",ctx,0); - else if(cmpYamlValue("ReleaseKernelMinor",ctx)) SetSimpleYAMLValue(&desc->AccessControlDescriptor.ReleaseKernelMinor,"ReleaseKernelMinor",ctx,0); - - - else if(cmpYamlValue("ServiceAccessControl",ctx)) desc->AccessControlDescriptor.ServiceAccessControlDescNum = SetYAMLSequence(&desc->AccessControlDescriptor.ServiceAccessControlDesc,"ServiceAccessControl",ctx); - else if(cmpYamlValue("MemoryMapping",ctx)) desc->AccessControlDescriptor.MemoryMappingDescNum = SetYAMLSequence(&desc->AccessControlDescriptor.MemoryMappingDesc,"MemoryMapping",ctx); - else if(cmpYamlValue("IORegisterMapping",ctx)) desc->AccessControlDescriptor.IORegisterMappingDescNum = SetYAMLSequence(&desc->AccessControlDescriptor.IORegisterMappingDesc,"IORegisterMapping",ctx); - else if(cmpYamlValue("Arm9AccessControl",ctx)) desc->AccessControlDescriptor.Arm9AccessControlDescNum = SetYAMLSequence(&desc->AccessControlDescriptor.Arm9AccessControlDesc,"Arm9AccessControl",ctx); - else if(cmpYamlValue("EnableInterruptNumbers",ctx)) desc->AccessControlDescriptor.EnableInterruptNumbersNum = SetYAMLSequence(&desc->AccessControlDescriptor.EnableInterruptNumbers,"EnableInterruptNumbers",ctx); - else if(cmpYamlValue("EnableSystemCalls",ctx)) desc->AccessControlDescriptor.EnableSystemCallsNum = SetYAMLSequenceFromMapping(&desc->AccessControlDescriptor.EnableSystemCalls,"EnableSystemCalls",ctx,false); - else if(cmpYamlValue("StorageId",ctx)) desc->AccessControlDescriptor.StorageIdDescNum = SetYAMLSequence(&desc->AccessControlDescriptor.StorageIdDesc,"StorageId",ctx); - - - // These keys while not caught by makerom, are ignored - else if(cmpYamlValue("DisableDebug",ctx)) SkipYAMLGroup(ctx); - else if(cmpYamlValue("EnableForceDebug",ctx)) SkipYAMLGroup(ctx); - else if(cmpYamlValue("CanWriteSharedPage",ctx)) SkipYAMLGroup(ctx); - else if(cmpYamlValue("CanUsePrivilegedPriority",ctx)) SkipYAMLGroup(ctx); - else if(cmpYamlValue("CanUseNonAlphabetAndNumber",ctx)) SkipYAMLGroup(ctx); - else if(cmpYamlValue("PermitMainFunctionArgument",ctx)) SkipYAMLGroup(ctx); - else if(cmpYamlValue("CanShareDeviceMemory",ctx)) SkipYAMLGroup(ctx); - else if(cmpYamlValue("CoreVersion",ctx)) SkipYAMLGroup(ctx); - else if(cmpYamlValue("FileSystemAccess",ctx)) SkipYAMLGroup(ctx); - else if(cmpYamlValue("IoAccessControl",ctx)) SkipYAMLGroup(ctx); - else if(cmpYamlValue("SystemSaveDataId1",ctx)) SkipYAMLGroup(ctx); - else if(cmpYamlValue("SystemSaveDataId2",ctx)) SkipYAMLGroup(ctx); - // Ignored Values End - - else{ - fprintf(stderr,"[-] Unrecognised key '%s'\n",GetYamlString(ctx)); - ctx->error = YAML_UNKNOWN_KEY; - FinishEvent(ctx); - return; - } - // Finish event start next - FinishEvent(ctx); - GetEvent(ctx); - } - - FinishEvent(ctx); -} - -void GET_CommonHeaderKey(ctr_yaml_context *ctx, desc_settings *desc) +void GET_CommonHeaderKey(ctr_yaml_context *ctx, rsf_settings *rsf) { /* Checking That Group is in a map */ if(!CheckMappingEvent(ctx)) return; u32 InitLevel = ctx->Level; /* Checking each child */ GetEvent(ctx); - desc->CommonHeaderKey.Found = true; + rsf->CommonHeaderKey.Found = true; while(ctx->Level == InitLevel){ if(ctx->error || ctx->done) return; // Handle childs - if(cmpYamlValue("D",ctx)) SetSimpleYAMLValue(&desc->CommonHeaderKey.D,"D",ctx,0); - else if(cmpYamlValue("P",ctx)) SetSimpleYAMLValue(&desc->CommonHeaderKey.P,"P",ctx,0); - else if(cmpYamlValue("Q",ctx)) SetSimpleYAMLValue(&desc->CommonHeaderKey.Q,"Q",ctx,0); - else if(cmpYamlValue("DP",ctx)) SetSimpleYAMLValue(&desc->CommonHeaderKey.DP,"DP",ctx,0); - else if(cmpYamlValue("DQ",ctx)) SetSimpleYAMLValue(&desc->CommonHeaderKey.DQ,"DQ",ctx,0); - else if(cmpYamlValue("InverseQ",ctx)) SetSimpleYAMLValue(&desc->CommonHeaderKey.InverseQ,"InverseQ",ctx,0); - else if(cmpYamlValue("Modulus",ctx)) SetSimpleYAMLValue(&desc->CommonHeaderKey.Modulus,"Modulus",ctx,0); - else if(cmpYamlValue("Exponent",ctx)) SetSimpleYAMLValue(&desc->CommonHeaderKey.Exponent,"Exponent",ctx,0); - + if(cmpYamlValue("D",ctx)) SetSimpleYAMLValue(&rsf->CommonHeaderKey.D,"D",ctx,0); + else if(cmpYamlValue("P",ctx)) SetSimpleYAMLValue(&rsf->CommonHeaderKey.P,"P",ctx,0); + else if(cmpYamlValue("Q",ctx)) SetSimpleYAMLValue(&rsf->CommonHeaderKey.Q,"Q",ctx,0); + else if(cmpYamlValue("DP",ctx)) SetSimpleYAMLValue(&rsf->CommonHeaderKey.DP,"DP",ctx,0); + else if(cmpYamlValue("DQ",ctx)) SetSimpleYAMLValue(&rsf->CommonHeaderKey.DQ,"DQ",ctx,0); + else if(cmpYamlValue("InverseQ",ctx)) SetSimpleYAMLValue(&rsf->CommonHeaderKey.InverseQ,"InverseQ",ctx,0); + else if(cmpYamlValue("Modulus",ctx)) SetSimpleYAMLValue(&rsf->CommonHeaderKey.Modulus,"Modulus",ctx,0); + else if(cmpYamlValue("Exponent",ctx)) SetSimpleYAMLValue(&rsf->CommonHeaderKey.Exponent,"Exponent",ctx,0); + else if(cmpYamlValue("Signature",ctx)) SetSimpleYAMLValue(&rsf->CommonHeaderKey.AccCtlDescSign,"Signature",ctx,0); + else if(cmpYamlValue("Descriptor",ctx)) SetSimpleYAMLValue(&rsf->CommonHeaderKey.AccCtlDescBin,"Descriptor",ctx,0); + else{ fprintf(stderr,"[-] Unrecognised key '%s'\n",GetYamlString(ctx)); ctx->error = YAML_UNKNOWN_KEY; diff --git a/yamlsettings.h b/yamlsettings.h index bd602ab..2958c95 100644 --- a/yamlsettings.h +++ b/yamlsettings.h @@ -1,7 +1,6 @@ -int MergeSpecData(desc_settings *out, desc_settings *desc, rsf_settings *rsf); +int MergeSpecData(rsf_settings *out, rsf_settings *desc, rsf_settings *rsf); void EvaluateRSF(rsf_settings *rsf, ctr_yaml_context *ctx); -void EvaluateDESC(desc_settings *desc, ctr_yaml_context *ctx); void GET_Option(ctr_yaml_context *ctx, rsf_settings *rsf); void GET_AccessControlInfo(ctr_yaml_context *ctx, rsf_settings *rsf); @@ -12,6 +11,4 @@ void GET_ExeFs(ctr_yaml_context *ctx, rsf_settings *rsf); void GET_PlainRegion(ctr_yaml_context *ctx, rsf_settings *rsf); void GET_TitleInfo(ctr_yaml_context *ctx, rsf_settings *rsf); void GET_CardInfo(ctr_yaml_context *ctx, rsf_settings *rsf); - -void GET_AccessControlDescriptor(ctr_yaml_context *ctx, desc_settings *desc); -void GET_CommonHeaderKey(ctr_yaml_context *ctx, desc_settings *desc); \ No newline at end of file +void GET_CommonHeaderKey(ctr_yaml_context *ctx, rsf_settings *rsf); \ No newline at end of file