Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ ../Project_CTR/ctrtool/ctrtool -i Animal\ Crossing\ New\ Leaf.cci
- Header: NCSD
- Signature: 693B0DD5D77CBCFD027DB4035B8B7DC03A603A2E1ED2DF24C411C763C06928FF
- 3CD2190657F653C730CA87500E1B0A7986F815D19EB60D9FE539C55BD63FFD88
- 69351AD5341AD1D7B95417245B1B05987308962487D5316F82DF985BBE83E178
- 8CAFC64411135D155094F71A0D9D22C2497F1E2903E98C7979A5638CD048058D
- D938FD10A4E1C6EFBC0A19608A0E89B26CEE118B131E1C92698C4E465EFE57B8
- D13685C2A40B6ADAE955CDB20A2036A44C785C89247E19E9E1210C4A69A565F4
- 6E6CDF0CD0F39923DB3298B6934F2D65FABFC713268F89F2EE81121BF6272971
- 3A00D20942253DE087650BC843AC5ECD2AC21B17EF0103911E692E7753735C17
- Media size: 0x00200000
- Media id: 0004000000086300
- Partition 0
- Id: 0063080000000400
- Area: 0x00004000-0x2E21B000
- Filesystem: 00
- Encryption: 00
- Partition 1
- Id: 0063080000000500
- Area: 0x2E21B000-0x2E3B9000
- Filesystem: 00
- Encryption: 00
- Partition 7
- Id: 0063080000005010
- Area: 0x2E3B9000-0x301DE200
- Filesystem: 00
- Encryption: 00
- Extended header hash: 0000000000000000000000000000000000000000000000000000000000000000
- Additional header size: 00000000
- Sector zero offset: 00000000
- Flags: 0000000201020000
- > Mediaunit size: 0x200
- > Mediatype: Card2
- > Card Device: None
- NCCH:
- Header: NCCH
- Signature: E84881480B99482B8E0CE47D1E5011C1ED1FD4C0AB78F37F274B4090BAA5633A
- 1981D906FB3F759DC84892660C5F076CCA2D3995F9F17116FDE16F4CE91F46E7
- E8DE2B26E13139A6476C208ACBC132D57580970E18D4F5A2161E6CF3EF47049E
- D5E106C54683C5C4B3AD2AF058DC175EFD0F27D43E245F379F9874894A18E2A5
- A9C55CD41217B70E1FB338A801CD5A67110FF5926CAA01318E7201FE6EFD18A8
- 32BBFC7B1B113E5799AC58B0C350E8803EC6C6E6A369A8BB88E777316D6668C3
- 20037219FF8B26BF2ED35896C385A68D0F539B6441C3EE76EC28BB37158500CD
- 423DE991168D11EA4B560B5404C9071A4A9DB8F79798D3948804F099407D3111
- Content size: 0x2e217000
- Partition id: 0004000000086300
- Maker code: 01
- Version: 2
- Title seed check: 00000000
- Program id: 0004000000086300
- Logo hash: 0000000000000000000000000000000000000000000000000000000000000000
- Product code: CTR-P-EGDE
- Exheader size: 00000400
- Exheader hash: FAAB6E8A7DF201F8EB76CF85CCD28445087810853FDB263EFA45FF26A6602869
- Flags: 0000030100000000
- > Mediaunit size: 0x200
- > Crypto key: Secure (0)
- > Form type: Executable content
- > Content type: Application
- > Content platform: CTR
- Plain region offset: 0x00004a00
- Plain region size: 0x00000200
- Logo offset: 0x00000000
- Logo size: 0x00000000
- ExeFS offset: 0x00004c00
- ExeFS size: 0x0093c000
- ExeFS hash region size: 0x00000200
- RomFS offset: 0x00941000
- RomFS size: 0x2d8da000
- RomFS hash region size: 0x00000200
- ExeFS Hash: E56E528883D121143223B37D3D2EF81BA78DC62153FA0EC8B9D7F50DCE6910CA
- RomFS Hash: 1C9FC48D72A41ABB12759776A09C33B151DEC74E34EF5693D5E4683CDBEB55AC
- Extended header:
- Signature: 85AE5B21E943694DEC4DBDCA4ED65CD8A88E16A4574CADE9CABDA5A173287A39
- 516CCE01B0A13E68FBB57C79343474A6FD2BC0CFA240D52A9DF48C49A4EA958C
- 4A6E592FA25C50FF888C34FBECCFA0EC70CA1CA6EBD3E68BE4DA87275CED0605
- 653218D75875016CCC422A86EB974DAAA5255959AC0971493906158715860BE7
- A88C017917BEA0397CC003ED8667F5BFB7700B13967B18CDCDD1A5BF5B3A6A0F
- C2D0545E3B26531886799F840AA693EA59930D9C0A9F30C022232FFFEE8E0D5E
- BD66BAC8F915B30A83EFAAF38B065C4FD93AD31C044E3C4511184CA47322D909
- 75AA080598E235442CAAEBC778CAC4398BDC43260786F0C1A1E3A4564041A7DC
- NCCH Hdr RSA Modulus: F684CAC0FC4DED1F5F4DA89F1F147C10FAD3FFAD88ED097C9DF818C5163615A8
- 564160A249B50F9120E49C1361D8B7B4610D1EEB3F37039F885166213530A94B
- 0CA21F25625F4D8153FCA7E30C3C07499C27A131430E87C0A4BE6B3B50A48DA7
- 4AD93CE4975D60E11DF19BF1B59B5BE53D8DFB4526E13DD7EDD0AD3E6084F31C
- 7EEE146702367B23D87005B1666D162F618CA74717A93356EBE35DDE8BB33C6E
- 398466B8E77B0F3D9660735ADA88C7C70C08D43A109C927D16E0FCE182644381
- 6441BB3D894C16078E91391F2FBBBFC87688BF4E64FD55FAD32B1795832B7710
- D3BAA26AD590F85BA23EA72061A5D6B1A51157E6A5BC07EBD41B1EAAB7F5CEF3
- Name: GARDEN
- Flag: 00
- Remaster version: 0003
- Code text address: 0x00100000
- Code text size: 0x007B92D8
- Code text max pages: 0x000007BA (0x007BA000)
- Code ro address: 0x008BA000
- Code ro size: 0x0010FE34
- Code ro max pages: 0x00000110 (0x00110000)
- Code data address: 0x009CA000
- Code data size: 0x00036100
- Code data max pages: 0x00000037 (0x00037000)
- Code bss size: 0x0016E28C
- Code stack size: 0x00040000
- Dependency: 0004013000002402
- Dependency: 0004013000001502
- Dependency: 0004013000003402
- Dependency: 0004013000001602
- Dependency: 0004013000002602
- Dependency: 0004013000001702
- Dependency: 0004013000001802
- Dependency: 0004013000002702
- Dependency: 0004013000002802
- Dependency: 0004013000001a02
- Dependency: 0004013000003202
- Dependency: 0004013000001b02
- Dependency: 0004013000001c02
- Dependency: 0004013000001d02
- Dependency: 0004013000002902
- Dependency: 0004013000001e02
- Dependency: 0004013000003302
- Dependency: 0004013000001f02
- Dependency: 0004013000002002
- Dependency: 0004013000002b02
- Dependency: 0004013000003502
- Dependency: 0004013000002c02
- Dependency: 0004013000002d02
- Dependency: 0004013000002102
- Dependency: 0004013000003102
- Dependency: 0004013000002202
- Dependency: 0004013000003702
- Dependency: 0004013000002e02
- Dependency: 0004013000002302
- Dependency: 0004013000002f02
- Savedata size: 10M
- Jump id: 0004000000086300
- Program id: 0004000000086300
- Core version: 0x2
- System mode: 64MB
- System mode (New3DS): 64MB
- CPU Speed (New3DS): 268MHz
- Enable L2 Cache: NO
- Ideal processor: 0
- Affinity mask: 1
- Main thread priority: 48
- Ext savedata id: 0x863
- System savedata id 1: 0x0
- System savedata id 2: 0x0
- OtherUserSaveDataId1: 0x0
- OtherUserSaveDataId2: 0x0
- OtherUserSaveDataId3: 0x0
- Accessible Savedata Ids:
- Other Variation Saves: Inaccessible
- Access info: 0x80
- > Direct SDMC
- Mapping static address: 0x1FF50000 (RW)
- Mapping static address: 0x1FF58000 (RW)
- Mapping static address: 0x1FF70000 (RW)
- Mapping static address: 0x1FF78000 (RW)
- Mapping static address: 0x1F000000 (RO)
- Mapping static address: 0x1F600000 (RO)
- Kernel flags:
- > Allow debug: YES
- > Force debug: NO
- > Allow non-alphanum: NO
- > Shared page writing: NO
- > Privilege priority: NO
- > Allow main() args: NO
- > Shared device mem: NO
- > Runnable on sleep: NO
- > Special memory: NO
- > Access Core 2: NO
- > Memory type: APPLICATION
- Handle table size: 0x200
- Kernel release version: 2.32
- Allowed systemcalls: 0x01, 0x02, 0x03, 0x06, 0x08, 0x09, 0x0A, 0x0B
- 0x0C, 0x0F, 0x11, 0x13, 0x14, 0x15, 0x16, 0x17
- 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F
- 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x27, 0x28
- 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30
- 0x31, 0x32, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A
- 0x3B, 0x3C, 0x3D
- Allowed interrupts: none
- ARM9 Desc. version: 0x2
- Mount NAND fs: NO
- Mount NAND RO write fs: NO
- Mount NAND TWL fs: NO
- Mount NAND W fs: NO
- Mount CARD SPI fs: NO
- Use SDIF3: NO
- Create seed: NO
- Use CARD SPI: NO
- SD Application: NO
- Use Direct SDMC: YES
- Service access:
- > 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
- > nim:aoc
- > am:app
- Reslimit category: 00
- ExeFS:
- Section name: .code
- Section offset: 0x00000200
- Section size: 0x00901000
- Section hash: 1CA065692824C8B95C57CC7DFDCB99A517302139B5BEAB0BCB4415DB2DE36B04
- Section name: banner
- Section offset: 0x00901200
- Section size: 0x00035570
- Section hash: 44B43A9F6C6167EABA45C3013D944F25F277D29D14F575F2079ECC9DCE02E1E2
- Section name: icon
- Section offset: 0x00936800
- Section size: 0x000036c0
- Section hash: 5C3C12FC2E5A4DB49D47D78143BDCF5F681E3A881B83386862513965944F371E
- Section name: logo
- Section offset: 0x0093a000
- Section size: 0x00002000
- Section hash: 2A98C49D919E254E15DC213CAB47A800ED63B248DCD43119E8FB82D9E62AE51C
- IVFC:
- Header: IVFC
- Id: 00010000
- Level 0:
- Data offset: 0x2dc68000
- Data size: 0x0000c000
- Hash offset: 0x00941060
- Hash block size: 0x00001000
- Level 1:
- Data offset: 0x2dc74000
- Data size: 0x005a7000
- Hash offset: 0x2dc68000
- Hash block size: 0x00001000
- Level 2:
- Data offset: 0x00942000
- Data size: 0x2d326000
- Hash offset: 0x2dc74000
- Hash block size: 0x00001000
- RomFS:
- Header size: 0x00000028
- Section 0 offset: 0x00942028
- Section 0 size: 0x00000F1C
- Section 1 offset: 0x00942F44
- Section 1 size: 0x0000A6D8
- Section 2 offset: 0x0094D61C
- Section 2 size: 0x0000CA64
- Section 3 offset: 0x0095A080
- Section 3 size: 0x000E5CEC
- Data offset: 0x00A3FD70
- $ ../Project_CTR/ctrtool/ctrtool -i Animal\ Crossing\ New\ Leaf.cxi
- NCCH:
- Header: NCCH
- Signature: C4078BE08D324B316ADA335679A147B7AD5CA4F132BC47CA3AF917561D78DAB5
- B91977767319CB0DC62A7C8056D97D4D391B783B20FB09C6CBAB65B5BA32F618
- 871CAB3DF271F14DC0F02355C98E37B20439143E035AF4F144A1A3A2C9385E4A
- CA32586EFE85E4EF35E50F1E22B3194EFA4370AB74E498A1C418C9EB9DF48979
- 6B537AA59137BA93FBC5F87B7D4D11B759B323061637EE0CCEBE3643FB2F8FA6
- C25B21589B3E1695F29B5814B8019E0D60B02F1C32FEEE74DF6AEE9DF47CEA6C
- 8B29124BF135C7A397B978F0F60D12D1342A1BD93B80C827BAE04E1F1286A2F6
- 16710A69F77CA8EFEA198D8263B15E7C6F6FCD6AC15B0F3770AB44515242E6A0
- Content size: 0x2de14000
- Partition id: 0004000000086300
- Maker code: 01
- Version: 2
- Title seed check: 00000000
- Program id: 0004000000086300
- Logo hash: 2A98C49D919E254E15DC213CAB47A800ED63B248DCD43119E8FB82D9E62AE51C
- Product code: CTR-P-EGDE
- Exheader size: 00000400
- Exheader hash: E2586BAD440E31D41B6B3D4771ACD502EDC42D433252ACE40120D760A6588062
- Flags: 0500030100000000
- > Mediaunit size: 0x200
- > Crypto key: None
- > Form type: Executable content
- > Content type: Application
- > Content platform: CTR
- Plain region offset: 0x00002a00
- Plain region size: 0x00000200
- Logo offset: 0x00000a00
- Logo size: 0x00002000
- ExeFS offset: 0x00002c00
- ExeFS size: 0x00536600
- ExeFS hash region size: 0x00000200
- RomFS offset: 0x0053a000
- RomFS size: 0x2d8da000
- RomFS hash region size: 0x00000200
- ExeFS Hash: F630BBD7B8B907A43865342F45400CCE6C91726BCE1C9CF1FEEC2A1799B573D2
- RomFS Hash: 1C9FC48D72A41ABB12759776A09C33B151DEC74E34EF5693D5E4683CDBEB55AC
- Extended header:
- Signature: 27A07395C64DC7EEA919A2A563C4595694D69150FA77C15F5DBA18B5393717D1
- 727FE3937B30D7AED52E1A2FB94BD6C7260CCB63197A28C23FDC66F464A5EB76
- B3661FA1954DB8E21A010F0BE739A675F4190F2A1A41595108E9D6B624F7950A
- 9969256B0F6DB9C38FF64859F0189A6E6A9328E131E5C1C69230C5716B1CE0DD
- FB007A91E0AFE837210516B886535D9B7095030FCB6A56CFFA5F6A27E4262839
- 393586F57FF0330A0D42EAF08C9E9CBCA088C20BD29912E61ADD54D9A3839F48
- E6B1276C7FA5651B1CCB9662331509FFE64983CF3BFD78DB463EC2E1A3BD7F6C
- C8B431FB2A2DF9207E3BD01683CCBA0B8734BE6DFE49D640E2820FAE125E7592
- NCCH Hdr RSA Modulus: CAC588C7F12A092B7649C0A835751082C2B5E5B2E9C81888F39889BF9DE6E40B
- 715DDD3F138271F2ED318699D947FEC57A7593E1F86DC63D9BE11599E1C2E05C
- 384B35A24D3EE2CEFBB308A3DD0C2631849227C88A8EC883A86CA7A339719EF1
- 349101DF114A9CF98BF92F46440A7238F38B6D233389BF6634A786E6ADF2DEF9
- AB16A140EED8F76CDC0092CB3149FC266424088FC660FF1EE3F0DDFB6D0D0F49
- 7CAD03EC9F6358FA46DFA2640ECC8557E72C617F59B8627D590EF684969942B0
- 398380B5522E073F92E39EF547EBA7D7D415F1228232BE2AD08C01CC30A91196
- F6E92BEA0EF82D0DB191D51A9451B98539B0AF9F549E99E146E56FE25F4B4E23
- Name: GARDEN
- Flag: 03 [compressed][sd app]
- Remaster version: 0003
- Code text address: 0x00100000
- Code text size: 0x007B92D8
- Code text max pages: 0x000007BA (0x007BA000)
- Code ro address: 0x008BA000
- Code ro size: 0x0010FE34
- Code ro max pages: 0x00000110 (0x00110000)
- Code data address: 0x009CA000
- Code data size: 0x00036100
- Code data max pages: 0x00000037 (0x00037000)
- Code bss size: 0x0016E28C
- Code stack size: 0x00040000
- Savedata size: 10M
- Jump id: 0004000000086300
- Program id: 0004000000086300
- Core version: 0x2
- System mode: 64MB
- System mode (New3DS): 64MB
- CPU Speed (New3DS): 268MHz
- Enable L2 Cache: NO
- Ideal processor: 0
- Affinity mask: 1
- Main thread priority: 48
- Ext savedata id: 0x863
- System savedata id 1: 0x0
- System savedata id 2: 0x0
- OtherUserSaveDataId1: 0x0
- OtherUserSaveDataId2: 0x0
- OtherUserSaveDataId3: 0x0
- Accessible Savedata Ids:
- Other Variation Saves: Inaccessible
- Access info: 0x80
- > Direct SDMC
- Mapping static address: 0x1FF50000 (RW)
- Mapping static address: 0x1FF51000 (RO)
- Mapping static address: 0x1FF58000 (RW)
- Mapping static address: 0x1FF59000 (RO)
- Mapping static address: 0x1FF70000 (RW)
- Mapping static address: 0x1FF71000 (RO)
- Mapping static address: 0x1FF78000 (RW)
- Mapping static address: 0x1FF79000 (RO)
- Mapping static address: 0x1F000000 (RO)
- Mapping static address: 0x1F001000 (RO)
- Mapping static address: 0x1F600000 (RO)
- Mapping static address: 0x1F601000 (RO)
- Kernel flags:
- > Allow debug: YES
- > Force debug: NO
- > Allow non-alphanum: NO
- > Shared page writing: NO
- > Privilege priority: NO
- > Allow main() args: NO
- > Shared device mem: NO
- > Runnable on sleep: NO
- > Special memory: NO
- > Access Core 2: NO
- > Memory type: APPLICATION
- Handle table size: 0x200
- Kernel release version: 2.32
- Allowed systemcalls: 0x01, 0x02, 0x03, 0x06, 0x08, 0x09, 0x0A, 0x0B
- 0x0C, 0x0F, 0x11, 0x13, 0x14, 0x15, 0x16, 0x17
- 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F
- 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x27, 0x28
- 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30
- 0x31, 0x32, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A
- 0x3B, 0x3C, 0x3D
- Allowed interrupts: none
- ARM9 Desc. version: 0x2
- Mount NAND fs: NO
- Mount NAND RO write fs: NO
- Mount NAND TWL fs: NO
- Mount NAND W fs: NO
- Mount CARD SPI fs: NO
- Use SDIF3: NO
- Create seed: NO
- Use CARD SPI: NO
- SD Application: YES
- Use Direct SDMC: YES
- Service access:
- > 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
- > nim:aoc
- > am:app
- Reslimit category: 00
- ExeFS:
- Section name: .code
- Section offset: 0x00000200
- Section size: 0x004fb50c
- Section hash: F159FB07BF8CE7D6F28FDD995F5F749930CA396BB2D5BA3EB5D56EF929F43DF5
- Section name: banner
- Section offset: 0x004fb800
- Section size: 0x00035570
- Section hash: 44B43A9F6C6167EABA45C3013D944F25F277D29D14F575F2079ECC9DCE02E1E2
- Section name: icon
- Section offset: 0x00530e00
- Section size: 0x000036c0
- Section hash: 5C3C12FC2E5A4DB49D47D78143BDCF5F681E3A881B83386862513965944F371E
- Section name: logo
- Section offset: 0x00534600
- Section size: 0x00002000
- Section hash: 2A98C49D919E254E15DC213CAB47A800ED63B248DCD43119E8FB82D9E62AE51C
- IVFC:
- Header: IVFC
- Id: 00010000
- Level 0:
- Data offset: 0x2d861000
- Data size: 0x0000c000
- Hash offset: 0x0053a060
- Hash block size: 0x00001000
- Level 1:
- Data offset: 0x2d86d000
- Data size: 0x005a7000
- Hash offset: 0x2d861000
- Hash block size: 0x00001000
- Level 2:
- Data offset: 0x0053b000
- Data size: 0x2d326000
- Hash offset: 0x2d86d000
- Hash block size: 0x00001000
- RomFS:
- Header size: 0x00000028
- Section 0 offset: 0x0053B028
- Section 0 size: 0x00000F1C
- Section 1 offset: 0x0053BF44
- Section 1 size: 0x0000A6D8
- Section 2 offset: 0x0054661C
- Section 2 size: 0x0000CA64
- Section 3 offset: 0x00553080
- Section 3 size: 0x000E5CEC
- Data offset: 0x00638D70
- $ cat ../makecia.sh
- #!/bin/sh
- DIR=$(dirname "$1")
- BASENAME=${DIR}/$(basename -s .cci "$1")
- EXHEADERFILE=${DIR}/exheader.bin
- RSFFILE=${BASENAME}.rsf
- CXIFILE=${BASENAME}.cxi
- CIAFILE=${BASENAME}.cia
- echo "Directory: ${DIR}"
- echo "Base name: ${BASENAME}"
- echo "ExHeader file: ${EXHEADERFILE}"
- echo "RSF File: ${RSFFILE}"
- echo "CXI File: ${CXIFILE}"
- set -x
- python3 /home/paul/3ds/rsfgen.py "$1" "${EXHEADERFILE}" >"${RSFFILE}"
- /home/paul/3ds/Project_CTR/makerom/makerom -f ncch -icon "${DIR}/exefs/icon.bin" \
- -banner "${DIR}/exefs/banner.bin" -exefslogo -code "${DIR}/exefs/code.bin" \
- -exheader "${DIR}/exheader.bin" -plainrgn "${DIR}/plainrgn.bin" -romfs \
- "${DIR}/romfs.bin" -rsf "${RSFFILE}" -o "${CXIFILE}"
- /home/paul/3ds/Project_CTR/makerom/makerom -f cia -content "${CXIFILE}:0" \
- -o "${CIAFILE}"
- #rm "${RSFFILE}" "${CXIFILE}"
- $ cat ../rsfgen.py
- import struct
- import binascii
- import os
- import argparse
- MEDIA_BLOCK_SIZE = 0x200
- KILOBYTE = 1024
- MEGABYTE = 1024**2
- GIGABYTE = 1024**3
- spoof = 0
- i = 0
- sysCalls = (
- 'Unknown',
- 'ControlMemory',
- 'QueryMemory',
- 'ExitProcess',
- 'GetProcessAffinityMask',
- 'SetProcessAffinityMask',
- 'SetProcessIdealProcessor',
- 'GetProcessIdealProcessor',
- 'CreateThread',
- 'ExitThread',
- 'SleepThread',
- 'GetThreadPriority',
- 'SetThreadPriority',
- 'GetThreadAffinityMask',
- 'SetThreadAffinityMask',
- 'GetThreadIdealProcessor',
- 'SetThreadIdealProcessor',
- 'GetCurrentProcessorNumber',
- 'Run',
- 'CreateMutex',
- 'ReleaseMutex',
- 'CreateSemaphore',
- 'ReleaseSemaphore',
- 'CreateEvent',
- 'SignalEvent',
- 'ClearEvent',
- 'CreateTimer',
- 'SetTimer',
- 'CancelTimer',
- 'ClearTimer',
- 'CreateMemoryBlock',
- 'MapMemoryBlock',
- 'UnmapMemoryBlock',
- 'CreateAddressArbiter',
- 'ArbitrateAddress',
- 'CloseHandle',
- 'WaitSynchronization1',
- 'WaitSynchronizationN',
- 'SignalAndWait',
- 'DuplicateHandle',
- 'GetSystemTick',
- 'GetHandleInfo',
- 'GetSystemInfo',
- 'GetProcessInfo',
- 'GetThreadInfo',
- 'ConnectToPort',
- 'SendSyncRequest1',
- 'SendSyncRequest2',
- 'SendSyncRequest3',
- 'SendSyncRequest4',
- 'SendSyncRequest',
- 'OpenProcess',
- 'OpenThread',
- 'GetProcessId',
- 'GetProcessIdOfThread',
- 'GetThreadId',
- 'GetResourceLimit',
- 'GetResourceLimitLimitValues',
- 'GetResourceLimitCurrentValues',
- 'GetThreadContext',
- 'Break',
- 'OutputDebugString'
- )
- # An unknown attribute is documented but not supported by makerom
- FSAccessInfo = (
- 'CategorySystemApplication',
- 'CategoryHardwareCheck',
- 'CategoryFileSystemTool',
- 'Debug',
- 'TwlCardBackup',
- 'TwlNandData',
- 'Boss',
- 'DirectSdmc',
- 'Core',
- 'CtrNandRo',
- 'CtrNandRw',
- 'CtrNandRoWrite',
- 'CategorySystemSettings',
- 'CardBoard',
- 'ExportImportIvs',
- 'DirectSdmcWrite',
- 'SwitchCleanup',
- 'SaveDataMove',
- 'Shop',
- 'Shell',
- 'CategoryHomeMenu'
- )
- # SD Application (8) is set by Options/UseOnSD
- # Mount sdmc:/ (9) is set by FileSystemAccess flags
- ARM9Access = (
- 'FsMountNand',
- 'FsMountNandRoWrite',
- 'FsMountTwln',
- 'FsMountWnand',
- 'FsMountCardSpi',
- 'UseSdif3',
- 'CreateSeed',
- 'UseCardSpi',
- )
- rsffile = {
- 'Option': {
- 'UseOnSD': 'True',
- 'EnableCompress': 'True',
- 'FreeProductCode': 'True',
- 'EnableCrypt': 'False',
- 'MediaFootPadding': 'False'
- }, 'AccessControlInfo': {
- 'DisableDebug': '',
- 'EnableForceDebug': '',
- 'CanWriteSharedPage': '',
- 'CanUsePrivilegedPriority': '',
- 'CanUseNonAlphabetAndNumber': '',
- 'PermitMainFunctionArgument': '',
- 'CanShareDeviceMemory': '',
- 'RunnableOnSleep': '',
- 'SpecialMemoryArrange': '',
- 'UseOtherVariationSaveData': '',
- 'CanAccessCore2': '',
- 'UseExtSaveData': '',
- 'EnableL2Cache': '',
- 'IdealProcessor': '',
- 'Priority': '',
- 'MemoryType': 'Application',
- 'SystemMode': '',
- 'SystemModeExt': '',
- 'CpuSpeed': '',
- 'CoreVersion': '',
- 'HandleTableSize': '',
- 'SystemSaveDataId1': '',
- 'SystemSaveDataId2': '',
- 'OtherUserSaveDataId1': '',
- 'OtherUserSaveDataId2': '',
- 'OtherUserSaveDataId3': '',
- 'ExtSaveDataId': '',
- 'AffinityMask': '',
- 'DescVersion': '',
- 'ResourceLimitCategory': '',
- 'ReleaseKernelMajor': '',
- 'ReleaseKernelMinor': '',
- 'MaxCpu': '',
- 'MemoryMapping': [],
- 'IORegisterMapping': [],
- 'FileSystemAccess': [],
- 'IoAccessControl': [],
- 'InterruptNumbers': [],
- 'SystemCallAccess': [],
- 'ServiceAccessControl': [],
- 'AccessibleSaveDataIds': []
- }, 'SystemControlInfo': {
- 'StackSize': '',
- 'RemasterVersion': '',
- 'JumpId': '',
- 'SaveDataSize': '',
- 'Dependency': []
- }, 'BasicInfo': {
- 'Title': '',
- 'CompanyCode': '',
- 'ProductCode': '',
- 'ContentType': 'Application',
- 'Logo': 'Nintendo'
- }, 'RomFs': {
- 'RootPath': '',
- }, 'TitleInfo': {
- 'Category': 'Application',
- 'UniqueId': ''
- }
- }
- # NOTE: TitleInfo is all from the Program ID field in the NCCH header
- # Version, ContentsIndex, Variation, ChildIndex and DemoIndex all are the
- # "Variation" byte in different contexts. None of them do anything for
- # Applications.
- # TargetCategory sets Category in the case of constructing an exheader. Not
- # sure about the specific details, but Category should always work.
- # CategoryFlags sets more specific flags. Category can't be set at the same
- # time.
- # https://www.3dbrew.org/wiki/NCSD
- # NCSD header
- # Offset Size Description
- # 0x000 0x100 RSA-2048 SHA-256 signature of the NCSD header (rsasig)
- # 0x100 4 Magic Number 'NCSD' (magic)
- # 0x104 4 Size of the NCSD image, in media units (1 media unit = 0x200 bytes) (mediasize)
- # 0x108 8 Media ID (mediaid)
- # 0x110 8 Partitions FS type (0=None, 1=Normal, 3=FIRM, 4=AGB_FIRM save) (type)
- # 0x118 8 Partitions crypt type (crypttype)
- # 0x120 0x40=(4+4)*8 Offset & Length partition table, in media units (offsets lenghts)
- # 0x160 0xA0 ...
- # For carts,
- # Offset Size Description
- # 0x160 0x20 Exheader SHA-256 hash (exhdrhash)
- # 0x180 0x4 Additional header size (addhdrsize)
- # 0x184 0x4 Sector zero offset (zerooffset)
- # 0x188 8 Partition Flags (See Below) (flags)
- # 0x190 0x40=8*8 Partition ID table (partids)
- # 0x1D0 0x30 Reserved
- # 0x200 0xE Reserved?
- # 0x20E 0x1 Support for this was implemented with 9.6.0-X FIRM. Bit0=1 enables using bits 1-2, it's unknown what these two bits are actually used for(the value of these two bits get compared with some other value during NCSD verification/loading). This appears to enable a new, likely hardware-based, antipiracy check on cartridges. (exflags)
- # 0x20F 0x1 Support for this was implemented with 9.6.0-X FIRM, see below regarding save crypto. (savecrypto)
- ncsdHdrStruct = struct.Struct("<256s4sIQQQ16I32sIIQ8Q62xBB")
- # https://www.3dbrew.org/wiki/NCCH
- # NCCH Header
- # OFFSET SIZE DESCRIPTION
- # 0x000 0x100 RSA-2048 signature of the NCCH header, using SHA-256. (rsasig)
- # 0x100 4 Magic ID, always 'NCCH' (magic)
- # 0x104 4 Content size, in media units (1 media unit = 0x200 bytes) (mediasize)
- # 0x108 8 Partition ID (partitionid)
- # 0x110 2 Maker code (makercode)
- # 0x112 2 Version (version)
- # 0x114 4 When ncchflag[7] = 0x20 starting with FIRM 9.6.0-X, this is compared with the first output u32 from a SHA256 hash. The data used for that hash is 0x18-bytes: <0x10-long title-unique content lock seed> <programID from NCCH+0x118>. This hash is only used for verification of the content lock seed, and is not the actual keyY. (lockhash)
- # 0x118 8 Program ID (programid)
- # 0x120 0x10 Reserved
- # 0x130 0x20 Logo Region SHA-256 hash. (For applications built with SDK 5+) (Supported from firmware: 5.0.0-11) (logohash)
- # 0x150 0x10 Product code (productcode)
- # 0x160 0x20 Extended header SHA-256 hash (SHA256 of 2x Alignment Size, beginning at 0x0 of ExHeader) (exhdrhash)
- # 0x180 4 Extended header size (exhdrsize)
- # 0x184 4 Reserved
- # 0x188 8 Flags (See Below) (flags)
- # 0x190 4 Plain region offset, in media units (plainoffset)
- # 0x194 4 Plain region size, in media units (plainsize)
- # 0x198 4 Logo Region offset, in media units (For applications built with SDK 5+) (Supported from firmware: 5.0.0-11) (logooffset)
- # 0x19c 4 Logo Region size, in media units (For applications built with SDK 5+) (Supported from firmware: 5.0.0-11) (logosize)
- # 0x1A0 4 ExeFS offset, in media units (exefsoffset)
- # 0x1A4 4 ExeFS size, in media units (exefssize)
- # 0x1A8 4 ExeFS hash region size, in media units (exefshashsize)
- # 0x1AC 4 Reserved
- # 0x1B0 4 RomFS offset, in media units (romfsoffset)
- # 0x1B4 4 RomFS size, in media units (romfssize)
- # 0x1B8 4 RomFS hash region size, in media units (romfshashsize)
- # 0x1BC 4 Reserved
- # 0x1C0 0x20 ExeFS superblock SHA-256 hash - (SHA-256 hash, starting at 0x0 of the ExeFS over the number of media units specified in the ExeFS hash region size) (exefssuperhash)
- # 0x1E0 0x20 RomFS superblock SHA-256 hash - (SHA-256 hash, starting at 0x0 of the RomFS over the number of media units specified in the RomFS hash region size) (romfssuperhash)
- ncchHdrStruct = struct.Struct("<256s4sIQ2sHIQ16x32s16s32sI4xQIIIIIII4xIII4x32s32s")
- # https://www.3dbrew.org/wiki/NCCH/Extended_Header
- # System Control Info
- # Offset Size Description
- # 0x0 0x8 Application Title (title)
- # 0x8 0x5 Reserved
- # 0xD 0x1 Flag (Bit0: CompressExefsCode, Bit1: SDApplication) (flag)
- # 0xE 0x2 Remaster Version (remaster)
- # 0x10 0xC Text Code Set Info (textaddr textpages textsize)
- # 0x1C 0x4 Stack Size (stack)
- # 0x20 0xC ReadOnly Code Set Info (roaddr ropages rosize)
- # 0x2C 0x4 Reserved
- # 0x30 0xC Data Code Set Info (dataaddr datapages datasize)
- # 0x3C 0x4 BSS Size (bsssize)
- # 0x40 0x180 (48*8) Dependency Module (Program ID) List (dependencies)
- # 0x1C0 0x40 SystemInfo (savesize jumpid)
- # Code Set Info
- # Offset Size Description
- # 0x0 0x4 Address
- # 0x4 0x4 Physical region size (in page-multiples)
- # 0x8 0x4 Size (in bytes)
- # System Info
- # Offset Size Description
- # 0x0 0x8 SaveData Size
- # 0x8 0x8 Jump ID
- # 0x10 0x30 Reserved
- sysCtrlInfoStruct = struct.Struct("<8s5xBHIIIIIII4xIIII48QQQ48x")
- # Access Control Info
- # Offset Size Description
- # 0x0 0x170 ARM11 Local System Capabilities
- # 0x170 0x80 ARM11 Kernel Capabilities
- # 0x1F0 0x10 ARM9 Access Control
- # ARM11 Local System Capabilities
- # Offset Size Description
- # 0x0 0x8 Program ID (programid)
- # 0x8 0x4 Core Version (The Title ID low of the required FIRM) (corever)
- # 0xC 0x1 Flag1 (1b l2cache, 1b cpuspeed, 6b nothing) (flag1)
- # 0xD 0x1 Flag2 (4b sysmodeext 0='Legacy' 1='124MB' 2='178MB' (dev unit?)) (flag2)
- # 0xE 0x1 Flag0 (flag0)
- # 0xF 0x1 Priority (priority)
- # 0x10 0x20 (16*2) Resource Limit Descriptors (reslimits)
- # 0x30 0x20 Storage Info (extdataid syssaveid(1,2) storageid fsaccess otherattrib)
- # 0x50 0x100 (32*8) Service Access Control (services)
- # 0x150 0x10 (2*8) Extended Service Access Control, support for this was implemented with 9.3.0-X. (services)
- # 0x160 0xF Reserved
- # 0x16F 0x1 Resource Limit Category. (0 = APPLICATION, 1 = SYS_APPLET, 2 = LIB_APPLET, 3 = OTHER(sysmodules running under the BASE memregion)) (category)
- # ARM11 Kernel Capabilities
- # Offset Size Description
- # 0x0 0x70 (28*4) Descriptors (kernelcaps)
- # 0x70 0x10 Reserved
- # ARM9 Access Control
- # Offset Size Description
- # 0x0 0xF Descriptors (arm9caps)
- # 0xF 0x1 ARM9 Descriptor Version. Originally this value had to be >=2. Starting with 9.3.0-X this value has to be either value 2 or value 3. (arm9ver)
- # Storage Info
- # Offset Size Description
- # 0x0 0x8 Extdata ID
- # 0x8 (2*4) System Save Data Ids
- # 0x10 0x8 Storage Accessable Unique Ids
- # 0x18 0x7 File System Access Info
- # 0x1F 0x1 Other Attributes
- # I implemented ARM9 Access Control as 'I11xB' instead of the documented 15 bytes
- # field since this makes it easier, and makerom treats tha field as a 32 bit
- # value anyway.
- accCtrlInfoStruct = struct.Struct("<QIBBBB16HQQQQ272s15xB28I16xI11xB")
- def makeNcsdHdrDictFromTuple(buffer):
- return({
- 'rsasig': buffer[0],
- 'magic': buffer[1],
- 'mediasize': buffer[2],
- 'mediaid': buffer[3],
- 'type': buffer[4],
- 'crypttype': buffer[5],
- 'offsets': tuple(buffer[6:22][x] for x in range(0, 16, 2)), # 6 + 16
- 'lengths': tuple(buffer[6:22][x] for x in range(1, 16, 2)),
- 'exhdrhash': buffer[22],
- 'addheadersize': buffer[23],
- 'zerooffset': buffer[24],
- 'flags': buffer[25],
- 'partids': range(26, 33), # 26 + 8
- 'exflags': buffer[34],
- 'savecrypto': buffer[35]
- })
- def makeNcchHdrDictFromTuple(buffer):
- return({
- 'rsasig': buffer[0],
- 'magic': buffer[1],
- 'mediasize': buffer[2],
- 'partitionid': buffer[3],
- 'makercode': buffer[4],
- 'version': buffer[5],
- 'lockhash': buffer[6],
- 'programid': buffer[7],
- 'logohash': buffer[8],
- 'productcode': buffer[9],
- 'exhdrhash': buffer[10],
- 'exhdrsize': buffer[11],
- 'flags': buffer[12],
- 'plainoffset': buffer[13],
- 'plainsize': buffer[14],
- 'logooffset': buffer[15],
- 'logosize': buffer[16],
- 'exefsoffset': buffer[17],
- 'exefssize': buffer[18],
- 'exefshashsize': buffer[19],
- 'romfsoffset': buffer[20],
- 'romfssize': buffer[21],
- 'romfshashsize': buffer[22],
- 'exefssuperhash': buffer[23],
- 'romfssuperhash': buffer[24]
- })
- def makeSysCtrlInfoDictFromTuple(buffer):
- return({
- 'title': buffer[0],
- 'flag': buffer[1],
- 'remaster': buffer[2],
- 'textaddr': buffer[3],
- 'textpages': buffer[4],
- 'textsize': buffer[5],
- 'stack': buffer[6],
- 'roaddr': buffer[7],
- 'ropages': buffer[8],
- 'rosize': buffer[9],
- 'dataaddr': buffer[10],
- 'datapages': buffer[11],
- 'datasize': buffer[12],
- 'bsssize': buffer[13],
- 'dependencies': buffer[14:62], # 14 + 48
- 'savesize': buffer[62],
- 'jumpid': buffer[63]
- })
- def makeAccCtrlInfoDictFromTuple(buffer):
- return({
- 'programid': buffer[0],
- 'corever': buffer[1],
- 'flag1': buffer[2],
- 'flag2': buffer[3],
- 'flag0': buffer[4],
- 'priority': buffer[5],
- 'reslimits': buffer[6:22],
- 'extdataid': buffer[22],
- 'syssaveid1': buffer[23] >> 0 & 0xFFFFFFFF,
- 'syssaveid2': buffer[23] >> 32 & 0xFFFFFFFF,
- 'storageid': buffer[24],
- 'fsaccess': buffer[25] & 0xFFFFFFFFFFFFFF,
- 'otherattrib': buffer[25] >> 56 & 0xFF,
- 'services': tuple(buffer[26][x:x+8] for x in range(0, 272, 8)), # 34 entries of 8 bytes each
- 'category': buffer[27],
- 'kernelcaps': buffer[28:56], # 28 + 28
- 'arm9caps': buffer[56],
- 'arm9ver': buffer[57]
- })
- def warning(warning):
- print("WARNING: %s" % warning, file=sys.stderr)
- def populateRSFFile():
- # AccessControlInfo
- # handle those annoying ARM11 Kernel Capabilities values
- for caps in accCtrlInfo['kernelcaps']:
- # InterruptNumbers
- # each has 4 interrupts packed in, 7 bits each
- if caps & 0xF0000000 == 0xE0000000:
- ints = (caps >> 0 & 0x7F, caps >> 7 & 0x7F, caps >> 14 & 0x7F, caps >> 21 & 0x7F)
- for intr in ints:
- if intr == 0:
- break
- rsffile['AccessControlInfo']['InterruptNumers'].append(intr)
- # SystemCallAccess
- # first 3 bits after the descriptor value indicate a group of 24 syscalls
- # the next 24 bits are a mask for this group.
- elif caps & 0xF8000000 == 0xF0000000:
- scstart = (caps >> 24 & 0x7) * 24
- for sc in enumerate(sysCalls[scstart:scstart+24]):
- if caps & (1 << sc[0]) != 0:
- rsffile['AccessControlInfo']['SystemCallAccess']\
- .append("%s: %d" % (sc[1], scstart + sc[0]))
- # ReleaseKernelMajor, ReleaseKernelMinor
- elif caps & 0xFE000000 == 0xFC000000:
- rsffile['AccessControlInfo']['ReleaseKernelMinor'] = caps >> 0 & 0xFF
- rsffile['AccessControlInfo']['ReleaseKernelMajor'] = caps >> 8 & 0xFF
- # HandleTableSize
- elif caps & 0xFF000000 == 0xFE000000:
- rsffile['AccessControlInfo']['HandleTableSize'] = caps & 0x7FFFF
- # DisableDebug, EnableForceDebug, CanWriteSharedPage, CanUsePrivilegedPriority,
- # CanUseNonAlphabetAndNumber, PermitMainFunctionArgument, CanShareDeviceMemory,
- # RunnableOnSleep, SpecialMemoryArrange
- elif caps & 0xFF800000 == 0xFF000000:
- if caps & 0x1 != 0:
- rsffile['AccessControlInfo']['DisableDebug'] = 'False'
- else:
- rsffile['AccessControlInfo']['DisableDebug'] = 'True'
- if caps & 0x2 != 0:
- rsffile['AccessControlInfo']['EnableForceDebug'] = 'True'
- else:
- rsffile['AccessControlInfo']['EnableForceDebug'] = 'False'
- if caps & 0x4 != 0:
- rsffile['AccessControlInfo']['CanUseNonAlphabetAndNumber'] = 'True'
- else:
- rsffile['AccessControlInfo']['CanUseNonAlphabetAndNumber'] = 'False'
- if caps & 0x8 != 0:
- rsffile['AccessControlInfo']['CanWriteSharedPage'] = 'True'
- else:
- rsffile['AccessControlInfo']['CanWriteSharedPage'] = 'False'
- if caps & 0x10 != 0:
- rsffile['AccessControlInfo']['CanUsePrivilegedPriority'] = 'True'
- else:
- rsffile['AccessControlInfo']['CanUsePrivilegedPriority'] = 'False'
- if caps & 0x20 != 0:
- rsffile['AccessControlInfo']['PermitMainFunctionArgument'] = 'True'
- else:
- rsffile['AccessControlInfo']['PermitMainFunctionArgument'] = 'False'
- if caps & 0x40 != 0:
- rsffile['AccessControlInfo']['CanShareDeviceMemory'] = 'True'
- else:
- rsffile['AccessControlInfo']['CanShareDeviceMemory'] = 'False'
- if caps & 0x80 != 0:
- rsffile['AccessControlInfo']['RunnableOnSleep'] = 'True'
- else:
- rsffile['AccessControlInfo']['RunnableOnSleep'] = 'False'
- if caps & 0x800 != 0:
- rsffile['AccessControlInfo']['SpecialMemoryArrange'] = 'True'
- else:
- rsffile['AccessControlInfo']['SpecialMemoryArrange'] = 'False'
- if caps & 0x1000 != 0:
- rsffile['AccessControlInfo']['CanAccessCore2'] = 'True'
- else:
- rsffile['AccessControlInfo']['CanAccessCore2'] = 'False'
- # MemoryMapping
- elif caps & 0xFFC00000 == 0xFF800000:
- if caps & 0x100000 != 0: #read only
- rsffile['AccessControlInfo']['MemoryMapping']\
- .append("0x%0.1X%0.2X%0.2X000:r" % (caps >> 16 & 0xF, caps >> 8 & 0xFF, caps & 0xFF))
- else: #read write
- rsffile['AccessControlInfo']['MemoryMapping']\
- .append("0x%0.1X%0.2X%0.2X000" % (caps >> 16 & 0xF, caps >> 8 & 0xFF, caps & 0xFF))
- # IORegisterMapping
- elif caps & 0xFFF00000 == 0xFFE00000:
- rsffile['AccessControlInfo']['IORegisterMapping']\
- .append("0x%0.1X%0.2X%0.2X000" % (caps >> 16 & 0xF, caps >> 8 & 0xFF, caps & 0xFF))
- # Empty entry
- elif caps == 0xFFFFFFFF:
- pass
- else:
- warning("Unsupported ARM9 Kernel Capabilities Descriptor %0.8X!" % caps)
- # UseExtSaveData, EXtSaveDataId, UseOtherVariationSaveData, AccessibleSaveDataIds
- # makerom indicates a mask of 0xFFFFFF but only shifts 20 bits
- if accCtrlInfo['otherattrib'] & 0x2 != 0:
- ids = (accCtrlInfo['extdataid'] >> 0 & 0xFFFFF,
- accCtrlInfo['extdataid'] >> 20 & 0xFFFFF,
- accCtrlInfo['extdataid'] >> 40 & 0xFFFFF,
- accCtrlInfo['storageid'] >> 0 & 0xFFFFF,
- accCtrlInfo['storageid'] >> 20 & 0xFFFFF,
- accCtrlInfo['storageid'] >> 40 & 0xFFFFF)
- for id in ids:
- if id != 0x00000:
- rsffile['AccessControlInfo']['AccessibleSaveDataIds'].append(id)
- del rsffile['AccessControlInfo']['OtherUserSaveDataId1']
- del rsffile['AccessControlInfo']['OtherUserSaveDataId2']
- del rsffile['AccessControlInfo']['OtherUserSaveDataId3']
- else:
- del rsffile['AccessControlInfo']['AccessibleSaveDataIds']
- if accCtrlInfo['extdataid'] != 0:
- rsffile['AccessControlInfo']['UseExtSaveData'] = 'True'
- rsffile['AccessControlInfo']['ExtSaveDataId'] = accCtrlInfo['extdataid']
- ids = (accCtrlInfo['storageid'] >> 0 & 0xFFFFF,
- accCtrlInfo['storageid'] >> 20 & 0xFFFFF,
- accCtrlInfo['storageid'] >> 40 & 0xFFFFF)
- if ids[0] != 0:
- rsffile['AccessControlInfo']['OtherUserSaveDataId1'] = ids[0]
- else:
- del rsffile['AccessControlInfo']['OtherUserSaveDataId1']
- if ids[1] != 0:
- rsffile['AccessControlInfo']['OtherUserSaveDataId2'] = ids[1]
- else:
- del rsffile['AccessControlInfo']['OtherUserSaveDataId2']
- if ids[2] != 0:
- rsffile['AccessControlInfo']['OtherUserSaveDataId3'] = ids[2]
- else:
- del rsffile['AccessControlInfo']['OtherUserSaveDataId3']
- if accCtrlInfo['storageid'] & 0x1000000000000000 != 0:
- rsffile['AccessControlInfo']['UseOtherVariationSaveData'] = 'True'
- else:
- rsffile['AccessControlInfo']['UseOtherVariationSaveData'] = 'False'
- # SystemSaveDataId(1,2)
- if accCtrlInfo['syssaveid1'] != 0:
- rsffile['AccessControlInfo']['SystemSaveDataId1'] = accCtrlInfo['syssaveid1']
- else:
- del rsffile['AccessControlInfo']['SystemSaveDataId1']
- if accCtrlInfo['syssaveid2'] != 0:
- rsffile['AccessControlInfo']['SystemSaveDataId2'] = accCtrlInfo['syssaveid2']
- else:
- del rsffile['AccessControlInfo']['SystemSaveDataId2']
- # EnableL2Cache, CpuSpeed
- if accCtrlInfo['flag1'] & 0x1 != 0:
- rsffile['AccessControlInfo']['EnableL2Cache'] = 'True'
- else:
- rsffile['AccessControlInfo']['EnableL2Cache'] = 'False'
- # this is just a flag, makerom will not accept other values for this
- if accCtrlInfo['flag1'] & 0x2 != 0:
- rsffile['AccessControlInfo']['CpuSpeed'] = '804mhz'
- else:
- rsffile['AccessControlInfo']['CpuSpeed'] = '268mhz'
- # IdealProcessor, AffinityMask, Priority, CoreVersion, DescVersion
- # ResourceLimtCategory, MaxCpu
- rsffile['AccessControlInfo']['IdealProcessor'] = accCtrlInfo['flag0'] >> 0 & 0x3
- rsffile['AccessControlInfo']['AffinityMask'] = accCtrlInfo['flag0'] >> 2 & 0x3
- rsffile['AccessControlInfo']['Priority'] = accCtrlInfo['priority'] - 32 # makerom increases this value by 32 for applications
- rsffile['AccessControlInfo']['CoreVersion'] = accCtrlInfo['corever']
- rsffile['AccessControlInfo']['DescVersion'] = accCtrlInfo['arm9ver']
- rsffile['AccessControlInfo']['ResourceLimitCategory'] = accCtrlInfo['category']
- rsffile['AccessControlInfo']['MaxCpu'] = accCtrlInfo['reslimits'][0]
- # SystemMode
- if accCtrlInfo['flag0'] >> 4 & 0xF == 0:
- rsffile['AccessControlInfo']['SystemMode'] = '64MB'
- elif accCtrlInfo['flag0'] >> 4 & 0xF == 1:
- rsffile['AccessControlInfo']['SystemMode'] = 'UNK'
- elif accCtrlInfo['flag0'] >> 4 & 0xF == 2:
- rsffile['AccessControlInfo']['SystemMode'] = '96MB'
- elif accCtrlInfo['flag0'] >> 4 & 0xF == 3:
- rsffile['AccessControlInfo']['SystemMode'] = '80MB'
- elif accCtrlInfo['flag0'] >> 4 & 0xF == 4:
- rsffile['AccessControlInfo']['SystemMode'] = '72MB'
- elif accCtrlInfo['flag0'] >> 4 & 0xF == 5:
- rsffile['AccessControlInfo']['SystemMode'] = '32MB'
- else:
- warning("Invalid SystemMode, ignoring!")
- del rsffile['AccessControlInfo']['SystemMode']
- # SystemModeExt
- # These are also just flags, they can't be set to any other value.
- if accCtrlInfo['flag2'] & 0x4 == 0:
- rsffile['AccessControlInfo']['SystemModeExt'] = 'Legacy'
- elif accCtrlInfo['flag2'] & 0x4 == 1:
- rsffile['AccessControlInfo']['SystemModeExt'] = '124MB'
- elif accCtrlInfo['flag2'] & 0x4 == 2:
- rsffile['AccessControlInfo']['SystemModeExt'] = '178MB'
- else:
- warning("Invalid SystemModeExt, ignoring!")
- del rsffile['AccessControlInfo']['SystemModeExt']
- # FileSystemAccess
- for fsPerm in enumerate(FSAccessInfo):
- if accCtrlInfo['fsaccess'] & (1 << fsPerm[0]) != 0:
- rsffile['AccessControlInfo']['FileSystemAccess'].append(fsPerm[1])
- # IoAccessControl
- for cap in enumerate(ARM9Access):
- if accCtrlInfo['arm9caps'] & (1 << cap[0]) != 0:
- rsffile['AccessControlInfo']['IoAccessControl'].append(cap[1])
- # ServiceAccessControl
- # These need to be converted to real strings later
- for service in accCtrlInfo['services']:
- if service != b'\x00\x00\x00\x00\x00\x00\x00\x00':
- rsffile['AccessControlInfo']['ServiceAccessControl'].append(service)
- # SystemControlInfo
- # StackSize, RemasterVersion, JumpId, SaveDataSize
- rsffile['SystemControlInfo']['StackSize'] = sysCtrlInfo['stack']
- rsffile['SystemControlInfo']['RemasterVersion'] = sysCtrlInfo['remaster']
- rsffile['SystemControlInfo']['JumpId'] = sysCtrlInfo['jumpid']
- rsffile['SystemControlInfo']['SaveDataSize'] = sysCtrlInfo['savesize'] # needs to be made "human readable" later
- # Dependency
- for dep in sysCtrlInfo['dependencies']:
- if dep != 0:
- rsffile['SystemControlInfo']['Dependency'].append(dep)
- # BasicInfo
- # Title, CompanyCode, ProductCode
- # These all need to be made in to proper strings
- rsffile['BasicInfo']['Title'] = sysCtrlInfo['title']
- rsffile['BasicInfo']['CompanyCode'] = ncchHdr['makercode']
- rsffile['BasicInfo']['ProductCode'] = ncchHdr['productcode']
- # TitleInfo
- # UniqueId
- rsffile['TitleInfo']['UniqueId'] = ncchHdr['programid'] >> 8 & 0xFFFFFF
- def reformatData():
- # Reformat fields that need it
- for i in range(len(rsffile['AccessControlInfo']['InterruptNumbers'])):
- rsffile['AccessControlInfo']['InterruptNumbers'][i] =\
- "0x%0.2X" % rsffile['AccessControlInfo']['InterruptNumbers'][i]
- rsffile['AccessControlInfo']['HandleTableSize'] =\
- "0x%0.2X" % rsffile['AccessControlInfo']['HandleTableSize']
- # this is possibly removed
- if 'AccessibleSaveDataIds' in rsffile['AccessControlInfo']:
- for i in range(len(rsffile['AccessControlInfo']['AccessibleSaveDataIds'])):
- rsffile['AccessControlInfo']['AccessibleSaveDataIds'][i] =\
- "0x%0.6X" % rsffile['AccessControlInfo']['AccessibleSaveDataIds'][i]
- if 'ExtSaveDataId' in rsffile['AccessControlInfo']:
- rsffile['AccessControlInfo']['ExtSaveDataId'] =\
- "0x%0.16X" % rsffile['AccessControlInfo']['ExtSaveDataId']
- rsffile['AccessControlInfo']['CoreVersion'] =\
- "0x%X" % rsffile['AccessControlInfo']['CoreVersion']
- rsffile['AccessControlInfo']['DescVersion'] =\
- "0x%X" % rsffile['AccessControlInfo']['DescVersion']
- rsffile['AccessControlInfo']['ResourceLimitCategory'] =\
- "%0.2X" % rsffile['AccessControlInfo']['ResourceLimitCategory']
- rsffile['AccessControlInfo']['MaxCpu'] =\
- "0x%X" % rsffile['AccessControlInfo']['MaxCpu']
- if 'SystemSaveDataId1' in rsffile['AccessControlInfo']:
- rsffile['AccessControlInfo']['SystemSaveDataId1'] =\
- "0x%0.8X" % rsffile['AccessControlInfo']['SystemSaveDataId1']
- if 'SystemSaveDataId2' in rsffile['AccessControlInfo']:
- rsffile['AccessControlInfo']['SystemSaveDataId2'] =\
- "0x%0.8X" % rsffile['AccessControlInfo']['SystemSaveDataId2']
- if 'OtherUserSaveDataId1' in rsffile['AccessControlInfo']:
- rsffile['AccessControlInfo']['OtherUserSaveDataId1'] =\
- "0x%0.8X" % rsffile['AccessControlInfo']['OtherUserSaveDataId1']
- if 'OtherUserSaveDataId2' in rsffile['AccessControlInfo']:
- rsffile['AccessControlInfo']['OtherUserSaveDataId2'] =\
- "0x%0.8X" % rsffile['AccessControlInfo']['OtherUserSaveDataId2']
- if 'OtherUserSaveDataId3' in rsffile['AccessControlInfo']:
- rsffile['AccessControlInfo']['OtherUserSaveDataId3'] =\
- "0x%0.8X" % rsffile['AccessControlInfo']['OtherUserSaveDataId3']
- for i in range(len(rsffile['AccessControlInfo']['ServiceAccessControl'])):
- service = rsffile['AccessControlInfo']['ServiceAccessControl'][i]
- endchar = service.find(0x00)
- if endchar == -1:
- rsffile['AccessControlInfo']['ServiceAccessControl'][i] =\
- service.decode('ascii')
- else:
- rsffile['AccessControlInfo']['ServiceAccessControl'][i] =\
- service[:endchar].decode('ascii')
- rsffile['SystemControlInfo']['StackSize'] =\
- "0x%0.8X" % rsffile['SystemControlInfo']['StackSize']
- rsffile['SystemControlInfo']['RemasterVersion'] =\
- "%0.4X" % rsffile['SystemControlInfo']['RemasterVersion']
- rsffile['SystemControlInfo']['JumpId'] =\
- "0x%0.16X" % rsffile['SystemControlInfo']['JumpId']
- savesize = rsffile['SystemControlInfo']['SaveDataSize']
- if savesize >= GIGABYTE and (savesize % GIGABYTE) == 0:
- rsffile['SystemControlInfo']['SaveDataSize'] = "%dGB" % (savesize / GIGABYTE)
- elif savesize >= MEGABYTE and savesize < GIGABYTE and (savesize % MEGABYTE) == 0:
- rsffile['SystemControlInfo']['SaveDataSize'] = "%dMB" % (savesize / MEGABYTE)
- elif savesize >= KILOBYTE and savesize < MEGABYTE and (savesize % KILOBYTE) == 0:
- rsffile['SystemControlInfo']['SaveDataSize'] = "%dKB" % (savesize / KILOBYTE)
- else: # This probably doesn't work but it shouldn't ever come up
- rsffile['SystemControlInfo']['SaveDataSize'] = "%d" % savesize
- for i in range(len(rsffile['SystemControlInfo']['Dependency'])):
- rsffile['SystemControlInfo']['Dependency'][i] =\
- "0x%0.16XL" % rsffile['SystemControlInfo']['Dependency'][i]
- title = rsffile['BasicInfo']['Title']
- endchar = title.find(0x00)
- if endchar == -1:
- rsffile['BasicInfo']['Title'] =\
- title.decode('ascii')
- else:
- rsffile['BasicInfo']['Title'] =\
- title[:endchar].decode('ascii')
- rsffile['BasicInfo']['CompanyCode'] =\
- rsffile['BasicInfo']['CompanyCode'].decode('ascii')
- pcode = rsffile['BasicInfo']['ProductCode']
- rsffile['BasicInfo']['ProductCode'] =\
- pcode[:pcode.find(b'\x00')].decode('ascii')
- rsffile['TitleInfo']['UniqueId'] =\
- "0x%0.6X" % rsffile['TitleInfo']['UniqueId']
- # Not much safeguarding in this, but it's only a problem if you're noodling around
- # Very VERY simple YAML printer
- def writeRSF():
- for category in rsffile.keys():
- print("%s:" % (category))
- for item in rsffile[category].keys():
- if type(rsffile[category][item]) is str:
- print(" %s: %s" % (item, rsffile[category][item]))
- elif type(rsffile[category][item]) is int:
- print(" %s: %d" % (item, rsffile[category][item]))
- elif type(rsffile[category][item]) is list:
- print(" %s:" % (item))
- if item == 'SystemCallAccess' or item == 'Dependency':
- for value in rsffile[category][item]:
- print(" %s" % (value))
- else:
- for value in rsffile[category][item]:
- print(" - %s" % (value))
- parser = argparse.ArgumentParser(description="Generate RSF file from 3DS ROM and exheader.")
- parser.add_argument('rom', metavar="<ROM File>", type=str, help="ROM file to read data from.")
- parser.add_argument('exheader', metavar="<ExHeader file>", type=str, help="File containing the ExHeader.")
- parser.add_argument('--romfsdir', metavar="<RomFs dir>", type=str, help="Specify a RomFs path.")
- args = parser.parse_args()
- with open(args.rom, 'rb') as f:
- ncsdHdr = makeNcsdHdrDictFromTuple(ncsdHdrStruct.unpack(f.read(ncsdHdrStruct.size)))
- f.seek(ncsdHdr['offsets'][0] * MEDIA_BLOCK_SIZE)
- ncchHdr = makeNcchHdrDictFromTuple(ncchHdrStruct.unpack(f.read(ncchHdrStruct.size)))
- with open(args.exheader, 'rb') as f:
- sysCtrlInfo = makeSysCtrlInfoDictFromTuple(sysCtrlInfoStruct.unpack(f.read(sysCtrlInfoStruct.size)))
- accCtrlInfo = makeAccCtrlInfoDictFromTuple(accCtrlInfoStruct.unpack(f.read(accCtrlInfoStruct.size)))
- populateRSFFile()
- if args.romfsdir != None:
- rsffile['RomFs']['RootPath'] = args.romfsdir
- else:
- del rsffile['RomFs']
- reformatData()
- writeRSF()
- $ cat Animal\ Crossing\ New\ Leaf.rsf
- TitleInfo:
- Category: Application
- UniqueId: 0x000863
- BasicInfo:
- ProductCode: CTR-P-EGDE
- ContentType: Application
- Title: GARDEN
- CompanyCode: 01
- Logo: Nintendo
- AccessControlInfo:
- IdealProcessor: 0
- CanUsePrivilegedPriority: False
- ReleaseKernelMajor: 2
- EnableForceDebug: False
- AffinityMask: 1
- SystemMode: 64MB
- SystemCallAccess:
- ControlMemory: 1
- QueryMemory: 2
- ExitProcess: 3
- SetProcessIdealProcessor: 6
- CreateThread: 8
- ExitThread: 9
- SleepThread: 10
- GetThreadPriority: 11
- SetThreadPriority: 12
- GetThreadIdealProcessor: 15
- GetCurrentProcessorNumber: 17
- CreateMutex: 19
- ReleaseMutex: 20
- CreateSemaphore: 21
- ReleaseSemaphore: 22
- CreateEvent: 23
- SignalEvent: 24
- ClearEvent: 25
- CreateTimer: 26
- SetTimer: 27
- CancelTimer: 28
- ClearTimer: 29
- CreateMemoryBlock: 30
- MapMemoryBlock: 31
- UnmapMemoryBlock: 32
- CreateAddressArbiter: 33
- ArbitrateAddress: 34
- CloseHandle: 35
- WaitSynchronization1: 36
- WaitSynchronizationN: 37
- DuplicateHandle: 39
- GetSystemTick: 40
- GetHandleInfo: 41
- GetSystemInfo: 42
- GetProcessInfo: 43
- GetThreadInfo: 44
- ConnectToPort: 45
- SendSyncRequest1: 46
- SendSyncRequest2: 47
- SendSyncRequest3: 48
- SendSyncRequest4: 49
- SendSyncRequest: 50
- GetProcessId: 53
- GetProcessIdOfThread: 54
- GetThreadId: 55
- GetResourceLimit: 56
- GetResourceLimitLimitValues: 57
- GetResourceLimitCurrentValues: 58
- GetThreadContext: 59
- Break: 60
- OutputDebugString: 61
- SystemModeExt: Legacy
- EnableL2Cache: False
- ResourceLimitCategory: 00
- IoAccessControl:
- PermitMainFunctionArgument: False
- MaxCpu: 0x9E
- RunnableOnSleep: False
- CanUseNonAlphabetAndNumber: False
- SpecialMemoryArrange: False
- CanWriteSharedPage: False
- CpuSpeed: 268mhz
- IORegisterMapping:
- CanShareDeviceMemory: False
- CanAccessCore2: False
- UseExtSaveData: True
- UseOtherVariationSaveData: False
- MemoryType: Application
- FileSystemAccess:
- - DirectSdmc
- MemoryMapping:
- - 0x1FF50000
- - 0x1FF58000
- - 0x1FF70000
- - 0x1FF78000
- - 0x1F000000:r
- - 0x1F600000:r
- ReleaseKernelMinor: 32
- 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
- - nim:aoc
- - am:app
- DisableDebug: False
- CoreVersion: 0x2
- InterruptNumbers:
- Priority: 16
- DescVersion: 0x2
- ExtSaveDataId: 0x0000000000000863
- HandleTableSize: 0x200
- Option:
- EnableCrypt: False
- UseOnSD: True
- FreeProductCode: True
- MediaFootPadding: False
- EnableCompress: True
- SystemControlInfo:
- Dependency:
- 0x0004013000002402L
- 0x0004013000001502L
- 0x0004013000003402L
- 0x0004013000001602L
- 0x0004013000002602L
- 0x0004013000001702L
- 0x0004013000001802L
- 0x0004013000002702L
- 0x0004013000002802L
- 0x0004013000001A02L
- 0x0004013000003202L
- 0x0004013000001B02L
- 0x0004013000001C02L
- 0x0004013000001D02L
- 0x0004013000002902L
- 0x0004013000001E02L
- 0x0004013000003302L
- 0x0004013000001F02L
- 0x0004013000002002L
- 0x0004013000002B02L
- 0x0004013000003502L
- 0x0004013000002C02L
- 0x0004013000002D02L
- 0x0004013000002102L
- 0x0004013000003102L
- 0x0004013000002202L
- 0x0004013000003702L
- 0x0004013000002E02L
- 0x0004013000002302L
- 0x0004013000002F02L
- SaveDataSize: 10MB
- StackSize: 0x00040000
- RemasterVersion: 0003
- JumpId: 0x0004000000086300
- $ ../makecia.sh Animal\ Crossing\ New\ Leaf.cci
- Directory: .
- Base name: ./Animal Crossing New Leaf
- ExHeader file: ./exheader.bin
- RSF File: ./Animal Crossing New Leaf.rsf
- CXI File: ./Animal Crossing New Leaf.cxi
- + python3 /home/paul/3ds/rsfgen.py 'Animal Crossing New Leaf.cci' ./exheader.bin
- + /home/paul/3ds/Project_CTR/makerom/makerom -f ncch -icon ./exefs/icon.bin -banner ./exefs/banner.bin -exefslogo -code ./exefs/code.bin -exheader ./exheader.bin -plainrgn ./plainrgn.bin -romfs ./romfs.bin -rsf './Animal Crossing New Leaf.rsf' -o './Animal Crossing New Leaf.cxi'
- + /home/paul/3ds/Project_CTR/makerom/makerom -f cia -content './Animal Crossing New Leaf.cxi:0' -o './Animal Crossing New Leaf.cia'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement