├── .gitignore
├── 3DSExplorer
├── 3DSExplorer.sln
├── 3DSExplorer.suo
├── 3DSExplorer
│ ├── 3DSExplorer.csproj
│ ├── 3DSExplorer.csproj.user
│ ├── 3dglasses.ico
│ ├── 3ds_cube_icon.ico
│ ├── Crypt
│ │ ├── AES128CTR.cs
│ │ ├── CRC16.cs
│ │ ├── Crc32.cs
│ │ ├── LZSS.cs
│ │ ├── RSA.cs
│ │ └── StreamExtensions.cs
│ ├── DSDecmp
│ │ ├── CompositeCTRFormat.cs
│ │ ├── Exceptions
│ │ │ ├── InputTooLargeException.cs
│ │ │ ├── NotEnoughDataException.cs
│ │ │ ├── StreamTooShortException.cs
│ │ │ └── TooMuchInputException.cs
│ │ ├── Formats
│ │ │ ├── CompositeFormat.cs
│ │ │ ├── CompressionFormat.cs
│ │ │ ├── LZOvl.cs
│ │ │ └── Nitro
│ │ │ │ ├── CompositeFormats.cs
│ │ │ │ ├── Huffman.cs
│ │ │ │ ├── LZ10.cs
│ │ │ │ ├── LZ11.cs
│ │ │ │ ├── NitroCFormat.cs
│ │ │ │ └── RLE.cs
│ │ └── Utils
│ │ │ ├── IOUtils.cs
│ │ │ ├── LZUtil.cs
│ │ │ └── SimpleReversePrioQueue.cs
│ ├── Modules
│ │ ├── IContext.cs
│ │ ├── ModuleHelper.cs
│ │ ├── ProgressDialog.Designer.cs
│ │ ├── ProgressDialog.cs
│ │ ├── ProgressDialog.resx
│ │ ├── mdlArchivedCCI.cs
│ │ ├── mdlBanner.cs
│ │ ├── mdlCBMD.cs
│ │ ├── mdlCCI.cs
│ │ ├── mdlCGFX.cs
│ │ ├── mdlCIA.cs
│ │ ├── mdlCWAV.cs
│ │ ├── mdlCXI.cs
│ │ ├── mdlCertificate.cs
│ │ ├── mdlDARC.cs
│ │ ├── mdlICN.cs
│ │ ├── mdlMPO.cs
│ │ ├── mdlSaveFlash.cs
│ │ ├── mdlTMD.cs
│ │ └── mdlTicket.cs
│ ├── Program.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ ├── Settings.Designer.cs
│ │ └── Settings.settings
│ ├── Resources
│ │ ├── barcode-2d.png
│ │ ├── code.png
│ │ ├── cog.png
│ │ ├── cube_3.png
│ │ ├── cube_d.png
│ │ ├── cube_s.png
│ │ ├── disk.png
│ │ ├── door_in.png
│ │ ├── drive_disk.png
│ │ ├── folder.png
│ │ ├── help.png
│ │ ├── ico_3d_glasses_32.png
│ │ ├── information.png
│ │ ├── key1.png
│ │ ├── magnifier.png
│ │ ├── menuBack.png
│ │ ├── page_white.png
│ │ ├── page_white_copy.png
│ │ ├── page_white_zip.png
│ │ ├── parental.png
│ │ ├── select_by_intersection.png
│ │ ├── spinner.gif
│ │ ├── text_align_left.png
│ │ └── watermark.png
│ ├── SharpCompress.dll
│ ├── SharpGL.WinForms.dll
│ ├── SharpGL.dll
│ ├── TreeListView
│ │ ├── IColumnsProvider.cs
│ │ ├── MultiColumnTreeView.Designer.cs
│ │ ├── MultiColumnTreeView.cs
│ │ ├── MultiColumnTreeView.resx
│ │ ├── TreeListView.Designer.cs
│ │ ├── TreeListView.cs
│ │ └── TreeListView.resx
│ ├── Utils
│ │ ├── Anaglyph.cs
│ │ ├── FfmpegWrapper.cs
│ │ ├── ImageUtil.cs
│ │ ├── MarshalUtil.cs
│ │ ├── StringUtil.cs
│ │ ├── TitleInfo.cs
│ │ ├── WaveUtil.cs
│ │ ├── Winmm.cs
│ │ └── YouTube.cs
│ ├── app.config
│ ├── bin
│ │ ├── 3DSExplorer.exe
│ │ ├── 3DSExplorer.exe.config
│ │ ├── 3DSExplorer.pdb
│ │ ├── 3DSExplorer.vshost.exe
│ │ ├── 3DSExplorer.vshost.exe.config
│ │ ├── 3DSExplorer.vshost.exe.manifest
│ │ ├── SharpCompress.dll
│ │ ├── SharpGL.WinForms.dll
│ │ ├── SharpGL.dll
│ │ └── zxing.dll
│ ├── frm3DVideo.Designer.cs
│ ├── frm3DVideo.cs
│ ├── frm3DVideo.resx
│ ├── frmAbout.Designer.cs
│ ├── frmAbout.cs
│ ├── frmAbout.resx
│ ├── frmCheckSum.Designer.cs
│ ├── frmCheckSum.cs
│ ├── frmCheckSum.resx
│ ├── frmDSDecmpGUI.Designer.cs
│ ├── frmDSDecmpGUI.cs
│ ├── frmDSDecmpGUI.resx
│ ├── frmExplorer.Designer.cs
│ ├── frmExplorer.cs
│ ├── frmExplorer.resx
│ ├── frmHashTool.Designer.cs
│ ├── frmHashTool.cs
│ ├── frmHashTool.resx
│ ├── frmImageBox.Designer.cs
│ ├── frmImageBox.cs
│ ├── frmImageBox.resx
│ ├── frmInputBox.Designer.cs
│ ├── frmInputBox.cs
│ ├── frmInputBox.resx
│ ├── frmParentalControl.Designer.cs
│ ├── frmParentalControl.cs
│ ├── frmParentalControl.resx
│ ├── frmQRTool.Designer.cs
│ ├── frmQRTool.cs
│ ├── frmQRTool.resx
│ ├── frmXORTool.Designer.cs
│ ├── frmXORTool.cs
│ ├── frmXORTool.resx
│ ├── obj
│ │ └── Debug
│ │ │ ├── 3DSExplorer.csproj.GenerateResource.Cache
│ │ │ ├── 3DSExplorer.csprojResolveAssemblyReference.cache
│ │ │ ├── 3DSExplorer.exe
│ │ │ ├── 3DSExplorer.pdb
│ │ │ ├── DesignTimeResolveAssemblyReferences.cache
│ │ │ ├── DesignTimeResolveAssemblyReferencesInput.cache
│ │ │ ├── TempPE
│ │ │ └── Properties.Resources.Designer.cs.dll
│ │ │ ├── _3DSExplorer.ImageBox.resources
│ │ │ ├── _3DSExplorer.InputBox.resources
│ │ │ ├── _3DSExplorer.Modules.ProgressDialog.resources
│ │ │ ├── _3DSExplorer.Properties.Resources.resources
│ │ │ ├── _3DSExplorer.TreeListView.MultiColumnTreeView.resources
│ │ │ ├── _3DSExplorer.TreeListView.TreeListViewControl.resources
│ │ │ ├── _3DSExplorer.frm3DVideo.resources
│ │ │ ├── _3DSExplorer.frmAbout.resources
│ │ │ ├── _3DSExplorer.frmCheckSum.resources
│ │ │ ├── _3DSExplorer.frmDSDecmpGUI.resources
│ │ │ ├── _3DSExplorer.frmExplorer.resources
│ │ │ ├── _3DSExplorer.frmHashTool.resources
│ │ │ ├── _3DSExplorer.frmParentalControl.resources
│ │ │ ├── _3DSExplorer.frmQRTool.resources
│ │ │ └── _3DSExplorer.frmXORTool.resources
│ └── zxing.dll
└── README
├── 3DS_IconDecrypter
├── Makefile
├── lib.h
├── main.c
├── types.h
├── utils.c
└── utils.h
├── README.md
├── extdata_tool
├── COPYING
├── Makefile
├── aesmac.c
├── aesmac.h
├── ctr_crypto.c
├── ctr_crypto.h
├── ctx.h
├── extdata.c
├── extdata.h
├── lib.h
├── main.c
├── polarssl
│ ├── aes.c
│ ├── aes.h
│ ├── arc4.c
│ ├── arc4.h
│ ├── asn1.h
│ ├── asn1parse.c
│ ├── asn1write.c
│ ├── asn1write.h
│ ├── base64.c
│ ├── base64.h
│ ├── bignum.c
│ ├── bignum.h
│ ├── blowfish.c
│ ├── blowfish.h
│ ├── bn_mul.h
│ ├── camellia.c
│ ├── camellia.h
│ ├── certs.c
│ ├── certs.h
│ ├── cipher.c
│ ├── cipher.h
│ ├── cipher_wrap.c
│ ├── cipher_wrap.h
│ ├── config.h
│ ├── ctr_drbg.c
│ ├── ctr_drbg.h
│ ├── debug.c
│ ├── debug.h
│ ├── des.c
│ ├── des.h
│ ├── dhm.c
│ ├── dhm.h
│ ├── entropy.c
│ ├── entropy.h
│ ├── entropy_poll.c
│ ├── entropy_poll.h
│ ├── error.c
│ ├── error.h
│ ├── gcm.c
│ ├── gcm.h
│ ├── havege.c
│ ├── havege.h
│ ├── md.c
│ ├── md.h
│ ├── md2.c
│ ├── md2.h
│ ├── md4.c
│ ├── md4.h
│ ├── md5.c
│ ├── md5.h
│ ├── md_wrap.c
│ ├── md_wrap.h
│ ├── net.c
│ ├── net.h
│ ├── openssl.h
│ ├── padlock.c
│ ├── padlock.h
│ ├── pbkdf2.c
│ ├── pbkdf2.h
│ ├── pem.c
│ ├── pem.h
│ ├── pkcs11.c
│ ├── pkcs11.h
│ ├── pkcs12.c
│ ├── pkcs12.h
│ ├── pkcs5.c
│ ├── pkcs5.h
│ ├── rsa.c
│ ├── rsa.h
│ ├── sha1.c
│ ├── sha1.h
│ ├── sha2.c
│ ├── sha2.h
│ ├── sha4.c
│ ├── sha4.h
│ ├── ssl.h
│ ├── ssl_cache.c
│ ├── ssl_cache.h
│ ├── ssl_cli.c
│ ├── ssl_srv.c
│ ├── ssl_tls.c
│ ├── timing.c
│ ├── timing.h
│ ├── version.c
│ ├── version.h
│ ├── x509.h
│ ├── x509parse.c
│ ├── x509write.c
│ ├── x509write.h
│ ├── xtea.c
│ └── xtea.h
├── titledb.c
├── titledb.h
├── types.h
├── utils.c
├── utils.h
├── vsxe.c
└── vsxe.h
├── icn_extractor
├── COPYING
├── LodePNG
│ ├── decode_bmp.c
│ ├── decode_bmp.h
│ ├── lodepng.c
│ └── lodepng.h
├── README.md
├── bmp.h
├── lib.h
├── main.c
├── makefile
├── types.h
├── utils.c
└── utils.h
├── iconcache_tool
├── Makefile
└── main.c
├── make_banner
├── COPYING
├── README.md
├── bnr.c
├── bnr.h
├── icn.c
├── icn.h
├── main.c
├── main.h
├── makefile
├── types.h
├── utils.c
├── utils.h
├── yaml.c
└── yaml.h
├── make_cdn_cia
├── COPYING
├── Makefile
├── README.md
├── bin
│ └── make_cdn_cia.exe
├── cia.c
├── cia.h
├── lib.h
├── main.c
├── types.h
├── utils.c
└── utils.h
├── make_cia
├── COPYING
├── Makefile
├── README.md
├── cia.c
├── cia.h
├── ctr_crypto.c
├── ctr_crypto.h
├── ctr_keydata.h
├── ctx.h
├── lib.h
├── main.c
├── main.h
├── meta.c
├── meta.h
├── ncch.c
├── ncch.h
├── ncsd.c
├── ncsd.h
├── polarssl
│ ├── aes.c
│ ├── aes.h
│ ├── arc4.c
│ ├── arc4.h
│ ├── asn1.h
│ ├── asn1parse.c
│ ├── asn1write.c
│ ├── asn1write.h
│ ├── base64.c
│ ├── base64.h
│ ├── bignum.c
│ ├── bignum.h
│ ├── blowfish.c
│ ├── blowfish.h
│ ├── bn_mul.h
│ ├── camellia.c
│ ├── camellia.h
│ ├── certs.c
│ ├── certs.h
│ ├── cipher.c
│ ├── cipher.h
│ ├── cipher_wrap.c
│ ├── cipher_wrap.h
│ ├── config.h
│ ├── ctr_drbg.c
│ ├── ctr_drbg.h
│ ├── debug.c
│ ├── debug.h
│ ├── des.c
│ ├── des.h
│ ├── dhm.c
│ ├── dhm.h
│ ├── entropy.c
│ ├── entropy.h
│ ├── entropy_poll.c
│ ├── entropy_poll.h
│ ├── error.c
│ ├── error.h
│ ├── gcm.c
│ ├── gcm.h
│ ├── havege.c
│ ├── havege.h
│ ├── md.c
│ ├── md.h
│ ├── md2.c
│ ├── md2.h
│ ├── md4.c
│ ├── md4.h
│ ├── md5.c
│ ├── md5.h
│ ├── md_wrap.c
│ ├── md_wrap.h
│ ├── net.c
│ ├── net.h
│ ├── openssl.h
│ ├── padlock.c
│ ├── padlock.h
│ ├── pbkdf2.c
│ ├── pbkdf2.h
│ ├── pem.c
│ ├── pem.h
│ ├── pkcs11.c
│ ├── pkcs11.h
│ ├── pkcs12.c
│ ├── pkcs12.h
│ ├── pkcs5.c
│ ├── pkcs5.h
│ ├── rsa.c
│ ├── rsa.h
│ ├── sha1.c
│ ├── sha1.h
│ ├── sha2.c
│ ├── sha2.h
│ ├── sha4.c
│ ├── sha4.h
│ ├── ssl.h
│ ├── ssl_cache.c
│ ├── ssl_cache.h
│ ├── ssl_cli.c
│ ├── ssl_srv.c
│ ├── ssl_tls.c
│ ├── timing.c
│ ├── timing.h
│ ├── version.c
│ ├── version.h
│ ├── x509.h
│ ├── x509parse.c
│ ├── x509write.c
│ ├── x509write.h
│ ├── xtea.c
│ └── xtea.h
├── settings.c
├── settings.h
├── srl.c
├── srl.h
├── ticket.c
├── ticket.h
├── tmd.c
├── tmd.h
├── types.h
├── utils.c
└── utils.h
└── rom_tool
├── Makefile
├── ctx.h
├── lib.h
├── main.c
├── main.h
├── ncsd.c
├── ncsd.h
├── types.h
├── utils.c
└── utils.h
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | *.o
3 | *.c~
4 | *.h~
5 | *.txt
6 | *.sh
7 | *.bat
8 | make_banner.exe
9 | make_cdn_cia.exe
10 | make_cia.exe
11 | *.cia
12 | *.rkey
13 | *.cert
14 | *.icn
15 | *.bnr
16 | *.bsf
17 | *.cwav
18 | *.cbmd
19 | *.ctpk
20 | *.db
21 | *.bin
22 | *.dec
23 | *\test\*
24 |
25 | *.cxi
26 | *.cci
27 | *.csu
28 | *.3ds
29 | *.cfa
30 | *.tik
31 | *.tmd
32 | *.bak
33 | <<<<<<< HEAD
34 | *.dat
35 | *.zip
36 |
37 | .DS_Store
38 | =======
39 | >>>>>>> a52437dfd6eb15f50a6ad273c62b81211c492dd0
40 |
41 | ############
42 | ## Windows
43 | ############
44 |
45 | # Windows image file caches
46 | Thumbs.db
47 |
48 | # Folder config file
49 | Desktop.ini
50 |
51 |
52 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "3DSExplorer", "3DSExplorer\3DSExplorer.csproj", "{91B5ECFA-3A39-43D2-B8D3-60080AAC52BE}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Any CPU = Debug|Any CPU
9 | Release|Any CPU = Release|Any CPU
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {91B5ECFA-3A39-43D2-B8D3-60080AAC52BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13 | {91B5ECFA-3A39-43D2-B8D3-60080AAC52BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
14 | {91B5ECFA-3A39-43D2-B8D3-60080AAC52BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
15 | {91B5ECFA-3A39-43D2-B8D3-60080AAC52BE}.Release|Any CPU.Build.0 = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer.suo
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/3DSExplorer.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | publish\
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | en-US
16 | false
17 | ShowAllFiles
18 |
19 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/3dglasses.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/3dglasses.ico
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/3ds_cube_icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/3ds_cube_icon.ico
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Crypt/AES128CTR.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Aes128Ctr.cs
3 | //
4 | // Copyright 2011 Eli Sherer
5 | //
6 |
7 | using System;
8 | using System.Linq;
9 | using System.Security.Cryptography;
10 |
11 | namespace _3DSExplorer
12 | {
13 | public class Aes128Ctr
14 | {
15 | private const int KeySize = 128;
16 | private const int BlockSize = KeySize / 8;
17 |
18 | private readonly byte[] _key;
19 | private readonly byte[] _iv;
20 | private readonly AesManaged _am; //Aes for the counterBlock
21 |
22 | ///
23 | /// Constructor.
24 | ///
25 | /// Key byte array (should be 16 bytes long)
26 | /// Initialization Vector byte array (should be 16 bytes long)
27 | ///
28 | public Aes128Ctr(byte[] key, byte[] iv)
29 | {
30 | _key = new byte[BlockSize];
31 | _iv = new byte[BlockSize];
32 | Buffer.BlockCopy(key, 0, _key, 0, BlockSize);
33 | Buffer.BlockCopy(iv, 0, _iv, 0, BlockSize);
34 | _am = new AesManaged
35 | {
36 | KeySize = KeySize,
37 | Key = _key,
38 | IV = new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
39 | Mode = CipherMode.ECB,
40 | Padding = PaddingMode.None
41 | };
42 | }
43 |
44 | ///
45 | /// Decrypt or Encrypt a block in AES-128 CTR Mode (changes the input array)
46 | ///
47 | /// The same array that was input
48 | public void TransformBlock(byte[] input)
49 | {
50 | var ict = _am.CreateEncryptor(); //reflective
51 | var encryptedIV = new byte[BlockSize];
52 | var counter = BitConverter.ToUInt64(_iv.Reverse().ToArray(), 0); //get the nonce
53 |
54 | for (int offset = 0; offset < input.Length; offset += BlockSize, counter++)
55 | {
56 | for (int i = 0; i < 8; i++) //Push the new counter to the end of iv
57 | _iv[i + BlockSize - 8] = (byte)((counter >> ((7 - i) * 8)) & 0xff);
58 | ict.TransformBlock(_iv, 0, BlockSize, encryptedIV, 0); // ECB on counter
59 | // Xor it with the data
60 | for (int i = 0; i < BlockSize && i + offset < input.Length; i++)
61 | input[i + offset] ^= encryptedIV[i];
62 | }
63 | }
64 | }
65 | }
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Crypt/CRC16.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace _3DSExplorer
4 | {
5 | public class CRC16
6 | {
7 | private const ushort InitalValue = 0xFFFF;
8 | private const ushort Polynomial = 0x8005; // (1000 0000 0000 0101)
9 | private const ushort RevPolynomial = 0xA001; //reversed (1010 0000 0000 0001)
10 |
11 | public static byte[] GetCRC(byte[] message)
12 | {
13 | return GetCRC(message, 0, message.Length);
14 | }
15 |
16 | public static byte[] GetCRC(byte[] message, long offset, long length)
17 | {
18 | var crcFull = InitalValue;
19 |
20 | for (var i = offset; i < offset + length; i++)
21 | {
22 | crcFull = (ushort)(crcFull ^ message[i]);
23 | for (var j = 0; j < 8; j++)
24 | {
25 | var crclsb = (char)(crcFull & 0x0001);
26 | crcFull = (ushort)((crcFull >> 1) & 0x7FFF);
27 | if (crclsb == 1)
28 | crcFull = (ushort)(crcFull ^ RevPolynomial);
29 | }
30 | }
31 | return BitConverter.GetBytes(crcFull);
32 | }
33 |
34 | public static byte Xor2(byte[] crcBytes)
35 | {
36 | return (byte)(crcBytes[0] ^ crcBytes[1]);
37 | }
38 | }
39 |
40 | }
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/DSDecmp/CompositeCTRFormat.cs:
--------------------------------------------------------------------------------
1 | namespace DSDecmp.Formats.Nitro
2 | {
3 | ///
4 | /// A composite format with all formats supported natively by the NDS (but not LZ-Overlay)
5 | ///
6 | public class CompositeCTRFormat : CompositeFormat
7 | {
8 | ///
9 | /// Creates a new instance of the format composed of all native NDS compression formats.
10 | ///
11 | public CompositeCTRFormat()
12 | : base(new Huffman4(), new Huffman8(), new LZ10(), new LZ11(), new LZOvl()) { }
13 |
14 | ///
15 | /// Gets a short string identifying this compression format.
16 | ///
17 | public override string ShortFormatString
18 | {
19 | get { return "CTR"; }
20 | }
21 |
22 | ///
23 | /// Gets a short description of this compression format (used in the program usage).
24 | ///
25 | public override string Description
26 | {
27 | get { return "All formats natively supported by the CTR."; }
28 | }
29 |
30 | ///
31 | /// Gets if this format supports compressing a file.
32 | ///
33 | public override bool SupportsCompression
34 | {
35 | get { return true; }
36 | }
37 |
38 | ///
39 | /// Gets the value that must be given on the command line in order to compress using this format.
40 | ///
41 | public override string CompressionFlag
42 | {
43 | get { return "ctr*"; }
44 | }
45 |
46 | public CompressionFormat GetCompression(int index)
47 | {
48 | return formats[index];
49 |
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/DSDecmp/Exceptions/InputTooLargeException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace DSDecmp
6 | {
7 | ///
8 | /// An exception indicating that the file cannot be compressed, because the decompressed size
9 | /// cannot be represented in the current compression format.
10 | ///
11 | public class InputTooLargeException : Exception
12 | {
13 | ///
14 | /// Creates a new exception that indicates that the input is too big to be compressed.
15 | ///
16 | public InputTooLargeException()
17 | : base("The compression ratio is not high enough to fit the input "
18 | + "in a single compressed file.") { }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/DSDecmp/Exceptions/NotEnoughDataException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.IO;
5 |
6 | namespace DSDecmp
7 | {
8 | ///
9 | /// An exception that is thrown by the decompression functions when there
10 | /// is not enough data available in order to properly decompress the input.
11 | ///
12 | public class NotEnoughDataException : IOException
13 | {
14 | private long currentOutSize;
15 | private long totalOutSize;
16 | ///
17 | /// Gets the actual number of written bytes.
18 | ///
19 | public long WrittenLength { get { return this.currentOutSize; } }
20 | ///
21 | /// Gets the number of bytes that was supposed to be written.
22 | ///
23 | public long DesiredLength { get { return this.totalOutSize; } }
24 |
25 | ///
26 | /// Creates a new NotEnoughDataException.
27 | ///
28 | /// The actual number of written bytes.
29 | /// The desired number of written bytes.
30 | public NotEnoughDataException(long currentOutSize, long totalOutSize)
31 | : base("Not enough data availble; 0x" + currentOutSize.ToString("X")
32 | + " of " + (totalOutSize < 0 ? "???" : ("0x" + totalOutSize.ToString("X")))
33 | + " bytes written.")
34 | {
35 | this.currentOutSize = currentOutSize;
36 | this.totalOutSize = totalOutSize;
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/DSDecmp/Exceptions/StreamTooShortException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.IO;
5 |
6 | namespace DSDecmp
7 | {
8 | ///
9 | /// An exception thrown by the compression or decompression function, indicating that the
10 | /// given input length was too large for the given input stream.
11 | ///
12 | public class StreamTooShortException : EndOfStreamException
13 | {
14 | ///
15 | /// Creates a new exception that indicates that the stream was shorter than the given input length.
16 | ///
17 | public StreamTooShortException()
18 | : base("The end of the stream was reached "
19 | + "before the given amout of data was read.")
20 | { }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/DSDecmp/Exceptions/TooMuchInputException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace DSDecmp
6 | {
7 | ///
8 | /// An exception indication that the input has more data than required in order
9 | /// to decompress it. This may indicate that more sub-files are present in the file.
10 | ///
11 | public class TooMuchInputException : Exception
12 | {
13 | ///
14 | /// Gets the number of bytes read by the decompressed to decompress the stream.
15 | ///
16 | public long ReadBytes { get; private set; }
17 |
18 | ///
19 | /// Creates a new exception indicating that the input has more data than necessary for
20 | /// decompressing th stream. It may indicate that other data is present after the compressed
21 | /// stream.
22 | ///
23 | /// The number of bytes read by the decompressor.
24 | /// The indicated length of the input stream.
25 | public TooMuchInputException(long readBytes, long totLength)
26 | : base("The input contains more data than necessary. Only used 0x"
27 | + readBytes.ToString("X") + " of 0x" + totLength.ToString("X") + " bytes")
28 | {
29 | this.ReadBytes = readBytes;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/DSDecmp/Formats/Nitro/CompositeFormats.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace DSDecmp.Formats.Nitro
6 | {
7 | ///
8 | /// A composite format with all formats supported natively by the GBA.
9 | ///
10 | public class CompositeGBAFormat : CompositeFormat
11 | {
12 | ///
13 | /// Creates a new instance of the format composed of all native GBA compression formats.
14 | ///
15 | public CompositeGBAFormat()
16 | : base(new Huffman4(), new Huffman8(), new LZ10()) { }
17 |
18 | ///
19 | /// Gets a short string identifying this compression format.
20 | ///
21 | public override string ShortFormatString
22 | {
23 | get { return "GBA"; }
24 | }
25 |
26 | ///
27 | /// Gets a short description of this compression format (used in the program usage).
28 | ///
29 | public override string Description
30 | {
31 | get { return "All formats natively supported by the GBA."; }
32 | }
33 |
34 | ///
35 | /// Gets if this format supports compressing a file.
36 | ///
37 | public override bool SupportsCompression
38 | {
39 | get { return true; }
40 | }
41 |
42 | ///
43 | /// Gets the value that must be given on the command line in order to compress using this format.
44 | ///
45 | public override string CompressionFlag
46 | {
47 | get { return "gba*"; }
48 | }
49 | }
50 |
51 | ///
52 | /// A composite format with all formats supported natively by the NDS (but not LZ-Overlay)
53 | ///
54 | public class CompositeNDSFormat : CompositeFormat
55 | {
56 | ///
57 | /// Creates a new instance of the format composed of all native NDS compression formats.
58 | ///
59 | public CompositeNDSFormat()
60 | : base(new Huffman4(), new Huffman8(), new LZ10(), new LZ11()) { }
61 |
62 | ///
63 | /// Gets a short string identifying this compression format.
64 | ///
65 | public override string ShortFormatString
66 | {
67 | get { return "NDS"; }
68 | }
69 |
70 | ///
71 | /// Gets a short description of this compression format (used in the program usage).
72 | ///
73 | public override string Description
74 | {
75 | get { return "All formats natively supported by the NDS."; }
76 | }
77 |
78 | ///
79 | /// Gets if this format supports compressing a file.
80 | ///
81 | public override bool SupportsCompression
82 | {
83 | get { return true; }
84 | }
85 |
86 | ///
87 | /// Gets the value that must be given on the command line in order to compress using this format.
88 | ///
89 | public override string CompressionFlag
90 | {
91 | get { return "nds*"; }
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/DSDecmp/Utils/LZUtil.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace DSDecmp
6 | {
7 | ///
8 | /// Utility class for compression using LZ-like compression schemes.
9 | ///
10 | public static class LZUtil
11 | {
12 | ///
13 | /// Determine the maximum size of a LZ-compressed block starting at newPtr, using the already compressed data
14 | /// starting at oldPtr. Takes O(inLength * oldLength) = O(n^2) time.
15 | ///
16 | /// The start of the data that needs to be compressed.
17 | /// The number of bytes that still need to be compressed.
18 | /// (or: the maximum number of bytes that _may_ be compressed into one block)
19 | /// The start of the raw file.
20 | /// The number of bytes already compressed.
21 | /// The offset of the start of the longest block to refer to.
22 | /// The minimum allowed value for 'disp'.
23 | /// The length of the longest sequence of bytes that can be copied from the already decompressed data.
24 | public static unsafe int GetOccurrenceLength(byte* newPtr, int newLength, byte* oldPtr, int oldLength, out int disp, int minDisp = 1)
25 | {
26 | disp = 0;
27 | if (newLength == 0)
28 | return 0;
29 | int maxLength = 0;
30 | // try every possible 'disp' value (disp = oldLength - i)
31 | for (int i = 0; i < oldLength - minDisp; i++)
32 | {
33 | // work from the start of the old data to the end, to mimic the original implementation's behaviour
34 | // (and going from start to end or from end to start does not influence the compression ratio anyway)
35 | byte* currentOldStart = oldPtr + i;
36 | int currentLength = 0;
37 | // determine the length we can copy if we go back (oldLength - i) bytes
38 | // always check the next 'newLength' bytes, and not just the available 'old' bytes,
39 | // as the copied data can also originate from what we're currently trying to compress.
40 | for (int j = 0; j < newLength; j++)
41 | {
42 | // stop when the bytes are no longer the same
43 | if (*(currentOldStart + j) != *(newPtr + j))
44 | break;
45 | currentLength++;
46 | }
47 |
48 | // update the optimal value
49 | if (currentLength > maxLength)
50 | {
51 | maxLength = currentLength;
52 | disp = oldLength - i;
53 |
54 | // if we cannot do better anyway, stop trying.
55 | if (maxLength == newLength)
56 | break;
57 | }
58 | }
59 | return maxLength;
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Modules/IContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Windows.Forms;
4 |
5 | namespace _3DSExplorer.Modules
6 | {
7 | public class TreeViewContextTag
8 | {
9 | public IContext Context;
10 | public int Type;
11 | public object[] Values;
12 | public string ActivationString;
13 |
14 | public static TreeViewContextTag Create(IContext context)
15 | {
16 | return new TreeViewContextTag { Context = context};
17 | }
18 |
19 | public static TreeViewContextTag Create(IContext context, int type)
20 | {
21 | return new TreeViewContextTag { Context = context, Type = type };
22 | }
23 |
24 | public static TreeViewContextTag Create(IContext context, int type, string activation)
25 | {
26 | return new TreeViewContextTag { Context = context, Type = type, ActivationString = activation};
27 | }
28 |
29 | public static TreeViewContextTag Create(IContext context, int type, object[] values)
30 | {
31 | return new TreeViewContextTag {Context = context, Type = type, Values = values};
32 | }
33 |
34 | public static TreeViewContextTag Create(IContext context, int type, string activation, object[] values)
35 | {
36 | return new TreeViewContextTag { Context = context, Type = type, ActivationString = activation, Values = values };
37 | }
38 | }
39 |
40 | public interface IContext
41 | {
42 | bool Open(Stream fs);
43 | string GetErrorMessage();
44 | void Create(FileStream fs, FileStream src);
45 | void View(frmExplorer f, int view, object[] values);
46 | bool CanCreate();
47 | void Activate(string filePath, int type, object[] values);
48 |
49 | string GetFileFilter();
50 | TreeNode GetExplorerTopNode();
51 | TreeNode GetFileSystemTopNode();
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Modules/ProgressDialog.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace _3DSExplorer.Modules
5 | {
6 | public partial class ProgressDialog : Form
7 | {
8 | public int Value
9 | {
10 | get { return progressBar.Value; }
11 | set { progressBar.Value = value; }
12 | }
13 |
14 | public int Maximum
15 | {
16 | get { return progressBar.Maximum; }
17 | set { progressBar.Maximum = value; }
18 | }
19 |
20 | public int Step
21 | {
22 | get { return progressBar.Step; }
23 | set { progressBar.Step = value; }
24 | }
25 |
26 | public string Message
27 | {
28 | get { return lblMessage.Text; }
29 | set { lblMessage.Text = value; }
30 | }
31 |
32 | public event EventHandler CancelClicked
33 | {
34 | add { btnCancel.Click += value; }
35 | remove { btnCancel.Click -= value; }
36 | }
37 |
38 | public ProgressDialog(string title, int max)
39 | {
40 | InitializeComponent();
41 | Text = title;
42 | Maximum = max;
43 | }
44 |
45 | public void PerformStep()
46 | {
47 | progressBar.PerformStep();
48 | }
49 |
50 | private void ProgressDialog_FormClosing(object sender, FormClosingEventArgs e)
51 | {
52 | btnCancel.PerformClick();
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Modules/mdlArchivedCCI.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Windows.Forms;
4 | using SharpCompress.Archive;
5 |
6 | namespace _3DSExplorer.Modules
7 | {
8 | public class ArchivedCCIContext : IContext
9 | {
10 | public enum ArchivedCCIView
11 | {
12 | Archive
13 | };
14 |
15 | private string errorMessage = string.Empty;
16 | private string _cciName = string.Empty;
17 | private uint _crc;
18 | public CCIContext CCIContext;
19 |
20 | public bool Open(Stream fs)
21 | {
22 | var reader = ArchiveFactory.Open(fs);
23 |
24 | foreach (var entry in reader.Entries)
25 | if (entry.FilePath.EndsWith(".3ds") || entry.FilePath.EndsWith(".cci") || entry.FilePath.EndsWith(".csu"))
26 | {
27 | _cciName = entry.FilePath;
28 | _crc = entry.Crc;
29 | CCIContext = new CCIContext();
30 | var entryStream = entry.OpenEntryStream();
31 | var tempStream = new MemoryStream();
32 | //read only the first 0x5000 bytes
33 | var buffer = new byte[0x5000];
34 | entryStream.Read(buffer, 0, buffer.Length);
35 | tempStream.Write(buffer,0,buffer.Length);
36 | tempStream.Seek(0, SeekOrigin.Begin);
37 | CCIContext.Open(tempStream);
38 | break;
39 | }
40 | return true;
41 | }
42 |
43 | public string GetErrorMessage()
44 | {
45 | return errorMessage;
46 | }
47 |
48 | public void Create(FileStream fs, FileStream src)
49 | {
50 | throw new NotImplementedException();
51 | }
52 |
53 | public void View(frmExplorer f, int view, object[] values)
54 | {
55 | f.ClearInformation();
56 | switch ((ArchivedCCIView)view)
57 | {
58 | case ArchivedCCIView.Archive:
59 | f.SetGroupHeaders("CRC32");
60 | f.AddListItem(0x000, 0x000, _cciName, _crc , 0);
61 | break;
62 | }
63 | f.AutoAlignColumns();
64 | }
65 |
66 | public bool CanCreate()
67 | {
68 | return false;
69 | }
70 |
71 | public void Activate(string filePath, int type, object[] values)
72 | {
73 | throw new NotImplementedException();
74 | }
75 |
76 | public string GetFileFilter()
77 | {
78 | return "Archive files (zip/7z)|*.zip;*.7z";
79 | }
80 |
81 | public TreeNode GetExplorerTopNode()
82 | {
83 | var topNode = new TreeNode("Archive") { Tag = TreeViewContextTag.Create(this, (int)ArchivedCCIView.Archive) };
84 | topNode.Nodes.Add(CCIContext.GetExplorerTopNode());
85 | return topNode;
86 | }
87 |
88 | public TreeNode GetFileSystemTopNode()
89 | {
90 | var topNode = new TreeNode("Archive", 1, 1);
91 | //TODO: topNode.Nodes.Add(CCIContext.GetFileSystemTopNode());
92 | return topNode;
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Windows.Forms;
5 | using DSDecmp.Formats.Nitro;
6 |
7 | namespace _3DSExplorer
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// The main entry point for the application.
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.EnableVisualStyles();
18 | Application.SetCompatibleTextRenderingDefault(true);
19 | string[] args = Environment.GetCommandLineArgs();
20 | if (args.Length > 1)
21 | Application.Run(new frmExplorer(args[1]));
22 | else
23 | Application.Run(new frmExplorer());
24 |
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | [assembly: AssemblyFileVersion("1.5.3.0")] //for faster update status
5 |
6 | // General Information about an assembly is controlled through the following
7 | // set of attributes. Change these attribute values to modify the information
8 | // associated with an assembly.
9 | [assembly: AssemblyTitle("3DSExplorer")]
10 | [assembly: AssemblyDescription("C# 3DS Files Explorer")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("elisherer")]
13 | [assembly: AssemblyProduct("3DSExplorer")]
14 | [assembly: AssemblyCopyright("Copyright © elisherer")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 |
18 | // Setting ComVisible to false makes the types in this assembly not visible
19 | // to COM components. If you need to access a type in this assembly from
20 | // COM, set the ComVisible attribute to true on that type.
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 | [assembly: Guid("3535b0e7-09ee-4c0d-b922-5f7105edec59")]
25 |
26 | // Version information for an assembly consists of the following four values:
27 | //
28 | // Major Version
29 | // Minor Version
30 | // Build Number
31 | // Revision
32 | //
33 | // You can specify all the values or you can default the Build and Revision Numbers
34 | // by using the '*' as shown below:
35 | // [assembly: AssemblyVersion("1.0.*")]
36 | [assembly: AssemblyVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.1
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace _3DSExplorer.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 |
26 | [global::System.Configuration.UserScopedSettingAttribute()]
27 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
28 | [global::System.Configuration.DefaultSettingValueAttribute("True")]
29 | public bool CheckForUpdatesOnStartup {
30 | get {
31 | return ((bool)(this["CheckForUpdatesOnStartup"]));
32 | }
33 | set {
34 | this["CheckForUpdatesOnStartup"] = value;
35 | }
36 | }
37 |
38 | [global::System.Configuration.UserScopedSettingAttribute()]
39 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
40 | [global::System.Configuration.DefaultSettingValueAttribute("")]
41 | public string FFMpegPath {
42 | get {
43 | return ((string)(this["FFMpegPath"]));
44 | }
45 | set {
46 | this["FFMpegPath"] = value;
47 | }
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | True
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Resources/barcode-2d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/Resources/barcode-2d.png
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Resources/code.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/Resources/code.png
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Resources/cog.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/Resources/cog.png
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Resources/cube_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/Resources/cube_3.png
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Resources/cube_d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/Resources/cube_d.png
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Resources/cube_s.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/Resources/cube_s.png
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Resources/disk.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/Resources/disk.png
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Resources/door_in.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/Resources/door_in.png
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Resources/drive_disk.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/Resources/drive_disk.png
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Resources/folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/Resources/folder.png
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Resources/help.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/Resources/help.png
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Resources/ico_3d_glasses_32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/Resources/ico_3d_glasses_32.png
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Resources/information.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/Resources/information.png
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Resources/key1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/Resources/key1.png
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Resources/magnifier.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/Resources/magnifier.png
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Resources/menuBack.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/Resources/menuBack.png
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Resources/page_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/Resources/page_white.png
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Resources/page_white_copy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/Resources/page_white_copy.png
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Resources/page_white_zip.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/Resources/page_white_zip.png
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Resources/parental.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/Resources/parental.png
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Resources/select_by_intersection.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/Resources/select_by_intersection.png
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Resources/spinner.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/Resources/spinner.gif
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Resources/text_align_left.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/Resources/text_align_left.png
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Resources/watermark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/Resources/watermark.png
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/SharpCompress.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/SharpCompress.dll
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/SharpGL.WinForms.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/SharpGL.WinForms.dll
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/SharpGL.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/SharpGL.dll
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/TreeListView/IColumnsProvider.cs:
--------------------------------------------------------------------------------
1 | namespace _3DSExplorer.TreeListView
2 | {
3 | interface IColumnsProvider
4 | {
5 | System.Windows.Forms.ListView.ColumnHeaderCollection Columns { get; }
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/TreeListView/MultiColumnTreeView.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace _3DSExplorer.TreeListView
2 | {
3 | partial class MultiColumnTreeView
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Component Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.SuspendLayout();
32 | //
33 | // MultiColumnTreeView
34 | //
35 | this.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawText;
36 | this.LineColor = System.Drawing.Color.Black;
37 | this.AfterCollapse += new System.Windows.Forms.TreeViewEventHandler(this.treeView_AfterCollapse);
38 | this.DrawNode += new System.Windows.Forms.DrawTreeNodeEventHandler(this.treeView_DrawNode);
39 | this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseDown);
40 | this.AfterExpand += new System.Windows.Forms.TreeViewEventHandler(this.treeView_AfterExpand);
41 | this.ResumeLayout(false);
42 |
43 | }
44 |
45 | #endregion
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Utils/StringUtil.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace _3DSExplorer
5 | {
6 | public static class StringUtil
7 | {
8 | public static string ByteArrayToString(byte[] array)
9 | {
10 | if (array == null) return "NULL";
11 | int i;
12 | var arraystring = string.Empty;
13 | for (i = 0; i < array.Length && i < 40; i++)
14 | arraystring += String.Format("{0:X2}", array[i]);
15 | if (i == 40) return arraystring + "..."; //ellipsis
16 | return arraystring;
17 | }
18 |
19 | /*
20 | public static string ByteArrayToStringSpaces(byte[] array)
21 | {
22 | int i;
23 | var arraystring = string.Empty;
24 | for (i = 0; i < array.Length && i < 33; i++)
25 | arraystring += String.Format("{0:X2}", array[i]) + (i < array.Length - 1 ? " " : "");
26 | if (i == 33) return arraystring + "..."; //ellipsis
27 | return arraystring;
28 | }*/
29 |
30 | public static string CharArrayToString(char[] array)
31 | {
32 | if (array == null) return string.Empty;
33 | int i;
34 | var arraystring = string.Empty;
35 | for (i = 0; i < array.Length; i++)
36 | {
37 | if (array[i] == 0) break;
38 | arraystring += array[i];
39 | }
40 | return arraystring + "";
41 | }
42 |
43 | public static string ToHexString(int digits, ulong number)
44 | {
45 | var formatString = "{0:X" + digits + "}";
46 | return "0x" + String.Format(formatString, number);
47 | }
48 |
49 | public static string ToHexString(int digits, float number)
50 | {
51 | var formatString = "{0:X" + digits + "}";
52 | var unumber = BitConverter.ToUInt32(BitConverter.GetBytes(number),0);
53 | return "0x" + String.Format(formatString, unumber);
54 | }
55 |
56 | public static byte[] ParseKeyStringToByteArray(string str)
57 | {
58 | if (str.Equals("")) return new byte[0];
59 | if ((str.Length % 2 > 0) || (str.Length != 32)) return null; //must be a mutliple of 2
60 | var retArray = new byte[str.Length / 2];
61 | try
62 | {
63 | for (var i = 0; i < str.Length; i += 2)
64 | {
65 | retArray[i / 2] = Convert.ToByte(str.Substring(i, 2), 16);
66 | }
67 | }
68 | catch (Exception ex)
69 | {
70 | MessageBox.Show(@"Can't parse key string!\n" + ex.Message);
71 | return null;
72 | }
73 | return retArray;
74 | }
75 |
76 | public static byte[] ParseByteArray(string baString)
77 | {
78 | baString.Replace(" ", ""); //delete all spaces
79 | if (baString.Length % 2 != 0)
80 | return null;
81 | try
82 | {
83 | byte[] ret = new byte[(int)baString.Length / 2];
84 | for (int i = 0, j = 0; i < baString.Length; i += 2, j++)
85 | ret[j] = Convert.ToByte(baString.Substring(i, 2), 16);
86 | return ret;
87 | }
88 | catch
89 | {
90 | return null;
91 | }
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/Utils/WaveUtil.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | namespace _3DSExplorer
4 | {
5 | public static class WaveUtil
6 | {
7 | [DllImport("WinMM.dll")]
8 | private static extern bool PlaySound(string fname, int Mod, int flag);
9 |
10 | public static int SND_ASYNC = 0x0001; // play asynchronously
11 | public static int SND_FILENAME = 0x00020000; // use file name
12 | public static int SND_PURGE = 0x0040; // purge non-static events
13 |
14 | public static void PlayFile(string fname)
15 | {
16 | Play(fname, SND_FILENAME|SND_ASYNC);
17 | }
18 |
19 | public static void Play(string fname, int soundFlags)
20 | {
21 | PlaySound(fname, 0, soundFlags);
22 | }
23 |
24 | public static void StopPlay()
25 | {
26 | PlaySound(null, 0, SND_PURGE);
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | <_3DSExplorer.Properties.Settings>
10 |
11 | True
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/bin/3DSExplorer.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/bin/3DSExplorer.exe
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/bin/3DSExplorer.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | <_3DSExplorer.Properties.Settings>
10 |
11 | True
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/bin/3DSExplorer.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/bin/3DSExplorer.pdb
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/bin/3DSExplorer.vshost.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/bin/3DSExplorer.vshost.exe
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/bin/3DSExplorer.vshost.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | <_3DSExplorer.Properties.Settings>
10 |
11 | True
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/bin/3DSExplorer.vshost.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/bin/SharpCompress.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/bin/SharpCompress.dll
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/bin/SharpGL.WinForms.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/bin/SharpGL.WinForms.dll
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/bin/SharpGL.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/bin/SharpGL.dll
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/bin/zxing.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/bin/zxing.dll
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/frmCheckSum.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Windows.Forms;
4 | using _3DSExplorer.Crypt;
5 |
6 | namespace _3DSExplorer
7 | {
8 | public partial class frmCheckSum : Form
9 | {
10 | private QuickCrc32 _quickCrc;
11 | private string _filePath;
12 |
13 | private frmCheckSum(string filePath)
14 | {
15 | InitializeComponent();
16 | _quickCrc= new QuickCrc32(CRCProgressChanged,CRCProcessFinished);
17 | txtResult.Text = "Press 'Start'";
18 | btnStartStop.Text = "Start";
19 | _filePath = filePath;
20 | }
21 |
22 | private void CRCProgressChanged(int value)
23 | {
24 | pBar.Value = value;
25 | txtResult.Text = "Processing... " + value + "%";
26 | }
27 |
28 | private void CRCProcessFinished(uint result)
29 | {
30 | txtResult.Text = result == 0 ? "Press 'Start'" : StringUtil.ToHexString(8,result);
31 | btnStartStop.Text = "Start";
32 | pBar.Value = 0;
33 | }
34 |
35 | private void btnStartStop_Click(object sender, EventArgs e)
36 | {
37 | if (btnStartStop.Text == "Start")
38 | {
39 | _quickCrc.Calculate(_filePath);
40 | btnStartStop.Text = "Stop";
41 | }
42 | else
43 | {
44 | _quickCrc.Cancel();
45 | btnStartStop.Text = "Start";
46 | }
47 | }
48 |
49 | public static void ShowDialog(string filePath)
50 | {
51 | var form = new frmCheckSum(filePath);
52 | form.ShowDialog();
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/frmImageBox.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using System.Windows.Forms;
4 |
5 | namespace _3DSExplorer
6 | {
7 | public partial class ImageBox : Form
8 | {
9 | private Bitmap _bmp;
10 |
11 | private ImageBox()
12 | {
13 | InitializeComponent();
14 | }
15 |
16 | private void SetImage(Image image)
17 | {
18 | pictureBox.Image = image;
19 | _bmp = new Bitmap(image);
20 | pictureBox.Size = new Size(image.Width + 2,image.Height + 2);
21 | }
22 |
23 | public static DialogResult ShowDialog(Image image)
24 | {
25 | var imBox = new ImageBox();
26 | imBox.SetImage(image);
27 | return imBox.ShowDialog();
28 | }
29 |
30 | private void btnSave_Click(object sender, EventArgs e)
31 | {
32 | using (var sfd = new SaveFileDialog()) {
33 | sfd.Filter = @"PNG Image (*.png)|*.png|All Files (*.*)|*.*";
34 | if (sfd.ShowDialog() == DialogResult.OK)
35 | pictureBox.Image.Save(sfd.FileName, System.Drawing.Imaging.ImageFormat.Png);
36 | }
37 | }
38 |
39 | private void btnCopy_Click(object sender, EventArgs e)
40 | {
41 | Clipboard.SetImage(pictureBox.Image);
42 | }
43 |
44 | private void btnZoomIn_Click(object sender, EventArgs e)
45 | {
46 | btnZoomIn.Checked = !btnZoomIn.Checked;
47 | pictureBox.Width = pictureBox.Image.Width * (btnZoomIn.Checked ? 2 : 1);
48 | pictureBox.Height = pictureBox.Image.Height * (btnZoomIn.Checked ? 2 : 1);
49 | }
50 |
51 | private void pictureBox_MouseMove(object sender, MouseEventArgs e)
52 | {
53 | var clr = _bmp.GetPixel(e.X, e.Y);
54 | lblColor.Text = string.Format("RGBA({0},{1},{2},{3})", clr.R, clr.G, clr.B, clr.A);
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/frmInputBox.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace _3DSExplorer
5 | {
6 | public partial class InputBox : Form
7 | {
8 | private string _input;
9 |
10 | private InputBox()
11 | {
12 | InitializeComponent();
13 | Text = Application.ProductName;
14 | }
15 |
16 | private void SetLabels(string text)
17 | {
18 | lblMessage.Text = text;
19 | }
20 |
21 | public static string ShowDialog(string messageText)
22 | {
23 | var inBox = new InputBox();
24 | inBox.SetLabels(messageText);
25 | return inBox.ShowDialog() == DialogResult.OK ? inBox._input : null;
26 | }
27 |
28 | private void btnOK_Click(object sender, EventArgs e)
29 | {
30 | _input = txtInput.Text;
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/frmParentalControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using System.Windows.Forms;
4 | using _3DSExplorer.Crypt;
5 |
6 | namespace _3DSExplorer
7 | {
8 | public partial class frmParentalControl : Form
9 | {
10 | public frmParentalControl()
11 | {
12 | InitializeComponent();
13 |
14 | comboAlgorithm.SelectedIndex = 0;
15 | }
16 |
17 | private void buttonCalculate_Click(object sender, EventArgs e)
18 | {
19 | // Parse input
20 | var servicecode = (uint) numericEnquiryNumber.Value;
21 | var uday = (uint) dateTimeDevice.Value.Day;
22 | var umonth = (uint) dateTimeDevice.Value.Month;
23 | servicecode %= 10000;
24 | uday %= 100;
25 | umonth %= 100;
26 | var str = string.Format("{0:D02}{1:D02}{2:D04}", umonth, uday, servicecode);
27 | var array = Encoding.ASCII.GetBytes(str);
28 |
29 | var poly = comboAlgorithm.SelectedIndex == 0 ? 0xEDBA6320 : 0xEDB88320;
30 | var crc = Crc32.Compute(poly, 0xFFFFFFFF, 0x0000AAAA, array);
31 | crc += (uint) (comboAlgorithm.SelectedIndex == 0 ? 0x00001657 : 0x000014C1);
32 | if (comboAlgorithm.SelectedIndex == 0)
33 | {
34 | var crclong = (crc + 1)*(ulong)0xA7C5AC47;
35 | var crchi = (uint)(crclong >> 48); //shr 6 bytes
36 | crchi *= 0xFFFFF3CB;
37 | crc += (crchi << 5);
38 | }
39 | crc = crc % 100000;
40 |
41 | textCode.Text = string.Format("{0:D05}",crc);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/obj/Debug/3DSExplorer.csproj.GenerateResource.Cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/obj/Debug/3DSExplorer.csproj.GenerateResource.Cache
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/obj/Debug/3DSExplorer.csprojResolveAssemblyReference.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/obj/Debug/3DSExplorer.csprojResolveAssemblyReference.cache
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/obj/Debug/3DSExplorer.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/obj/Debug/3DSExplorer.exe
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/obj/Debug/3DSExplorer.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/obj/Debug/3DSExplorer.pdb
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/obj/Debug/DesignTimeResolveAssemblyReferences.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/obj/Debug/DesignTimeResolveAssemblyReferences.cache
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.ImageBox.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.ImageBox.resources
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.InputBox.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.InputBox.resources
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.Modules.ProgressDialog.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.Modules.ProgressDialog.resources
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.Properties.Resources.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.Properties.Resources.resources
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.TreeListView.MultiColumnTreeView.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.TreeListView.MultiColumnTreeView.resources
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.TreeListView.TreeListViewControl.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.TreeListView.TreeListViewControl.resources
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.frm3DVideo.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.frm3DVideo.resources
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.frmAbout.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.frmAbout.resources
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.frmCheckSum.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.frmCheckSum.resources
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.frmDSDecmpGUI.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.frmDSDecmpGUI.resources
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.frmExplorer.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.frmExplorer.resources
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.frmHashTool.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.frmHashTool.resources
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.frmParentalControl.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.frmParentalControl.resources
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.frmQRTool.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.frmQRTool.resources
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.frmXORTool.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/obj/Debug/_3DSExplorer.frmXORTool.resources
--------------------------------------------------------------------------------
/3DSExplorer/3DSExplorer/zxing.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/3DSExplorer/3DSExplorer/zxing.dll
--------------------------------------------------------------------------------
/3DSExplorer/README:
--------------------------------------------------------------------------------
1 | This is a modification of 3DSExplorer 1.5.3 by Eli Sherer
2 |
3 | Original 3DSExplorer Page: http://code.google.com/p/3dsexplorer/
4 | Eli's Website: http://sherer.co.il/#!
--------------------------------------------------------------------------------
/3DS_IconDecrypter/Makefile:
--------------------------------------------------------------------------------
1 | OBJS = utils.o main.o
2 | LIBS = -static-libgcc -static-libstdc++
3 | CXXFLAGS = -I.
4 | CFLAGS = --std=c99 -Wall -I.
5 | OUTPUT = 3DS_IconDecrypter
6 | CC = gcc
7 |
8 | main: $(OBJS) $(POLAR_OBJS)
9 | g++ -o $(OUTPUT) $(LIBS) $(OBJS)
10 |
11 |
12 | clean:
13 | rm -rf $(OUTPUT) $(OBJS) $(POLAR_OBJS)
--------------------------------------------------------------------------------
/3DS_IconDecrypter/lib.h:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | #ifdef _WIN32
11 | #include
12 | #include
13 | #include
14 | #include
15 | #else
16 | #include
17 | #include
18 | #endif
19 |
20 | #include "types.h"
21 | #include "utils.h"
22 |
23 |
24 |
--------------------------------------------------------------------------------
/3DS_IconDecrypter/types.h:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | //Bools
4 | typedef enum
5 | {
6 | False,
7 | True
8 | } _boolean;
9 |
10 | typedef enum
11 | {
12 | Good,
13 | Fail
14 | } return_basic;
15 |
16 | typedef enum
17 | {
18 | ARGC_FAIL = 1,
19 | ARGV_FAIL,
20 | IO_ERROR,
21 | aes_key_fail,
22 | rsa_key_fail,
23 | cia_type_fail,
24 | cert_gen_fail,
25 | content_mismatch,
26 | ticket_gen_fail,
27 | tmd_gen_fail,
28 | cia_header_gen_fail
29 | } errors;
30 |
31 | typedef enum
32 | {
33 | BE = 0,
34 | LE = 1
35 | } endianness_flag;
36 |
37 | typedef unsigned char u8;
38 | typedef unsigned short u16;
39 | typedef unsigned int u32;
40 | typedef unsigned long long u64;
41 |
42 | typedef signed char s8;
43 | typedef signed short s16;
44 | typedef signed int s32;
45 | typedef signed long long s64;
46 |
--------------------------------------------------------------------------------
/3DS_IconDecrypter/utils.h:
--------------------------------------------------------------------------------
1 | #ifndef _UTILS_H_
2 | #define _UTILS_H_
3 | typedef struct
4 | {
5 | char *argument;
6 | u16 arg_len;
7 | } __attribute__((__packed__))
8 | OPTION_CTX;
9 |
10 | typedef struct
11 | {
12 | u8 *buffer;
13 | u64 size;
14 | } __attribute__((__packed__))
15 | COMPONENT_STRUCT;
16 | #endif
17 |
18 | //MISC
19 | void char_to_int_array(unsigned char destination[], char source[], int size, int endianness, int base);
20 | void endian_memcpy(u8 *destination, u8 *source, u32 size, int endianness);
21 | void u8_hex_print_be(u8 *array, int len);
22 | void u8_hex_print_le(u8 *array, int len);
23 | u32 align_value(u32 value, u32 alignment);
24 | void resolve_flag(unsigned char flag, unsigned char *flag_bool);
25 | void resolve_flag_u16(u16 flag, unsigned char *flag_bool);
26 | int append_filextention(char *output, u16 max_outlen, char *input, char extention[]);
27 | //IO Related
28 | int ExportFileToFile(FILE *in, FILE *out, u64 size, u64 in_offset, u64 out_offset);
29 | void WriteBuffer(void *buffer, u64 size, u64 offset, FILE *output);
30 | void ReadFile_64(void *outbuff, u64 size, u64 offset, FILE *file);
31 | u64 GetFileSize_u64(char *filename);
32 | u32 GetFileSize_u32(FILE *file);
33 | int TruncateFile_u64(char *filename, u64 filelen);
34 | int fseek_64(FILE *fp, u64 file_pos, int whence);
35 | int makedir(const char* dir);
36 | char *getcwdir(char *buffer,int maxlen);
37 | void _free(void *ptr); // frees and nullifies pointer
38 | //Data Size conversion
39 | u16 u8_to_u16(u8 *value, u8 endianness);
40 | u32 u8_to_u32(u8 *value, u8 endianness);
41 | u64 u8_to_u64(u8 *value, u8 endianness);
42 | int u16_to_u8(u8 *out_value, u16 in_value, u8 endianness);
43 | int u32_to_u8(u8 *out_value, u32 in_value, u8 endianness);
44 | int u64_to_u8(u8 *out_value, u64 in_value, u8 endianness);
45 | //from ctrtool
46 | void memdump(FILE* fout, const char* prefix, const u8* data, u32 size);
47 |
48 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | CTR_Toolkit
2 | =============
3 |
4 | Legal, open source, 3DS toolkit. Compiles under Linux and Windows(MinGW).
5 |
6 | ## CTR_SDK Substitute Tools ##
7 |
8 | 1/ make_cia - Substitutes ctr_makecia32 - Generates CIA files
9 |
10 | 2/ make_banner - Substitutes ctr_makebanner32 - Generates ICN/BNR files
11 |
12 | ## CTR 'Extra Data' Tools ##
13 |
14 | 1/ extdata_tool - Read/Verify/Extract decrypted extdata. Generating/signing extdata is in an experimental phase.
15 |
16 | 2/ iconcache_tool - Extracts cached icon data from homemenu extdata
17 |
18 | 3/ 3DS_IconDecrypter - A tool to automate the process of decrypting icons from 3DS extdata.
19 |
20 | ## Other CTR Tools ##
21 |
22 | 1/ rom_tool - Tool for interpreting both debug/retail CCI files.
23 |
24 | 2/ make_cdn_cia - Repackages CDN content into a CIA file
25 |
26 | 3/ icn_extractor - Converts the embedded icon data in ICN files to PNG files
27 |
28 | 4/ 3DSExplorer - A fork of Eli Sherer's 3DSExplorer, with rom_tool's functionality added.
--------------------------------------------------------------------------------
/extdata_tool/Makefile:
--------------------------------------------------------------------------------
1 | OBJS = utils.o ctr_crypto.o main.o extdata.o aesmac.o vsxe.o titledb.o
2 | POLAR_OBJS = polarssl/aes.o polarssl/bignum.o polarssl/rsa.o polarssl/sha1.o polarssl/sha2.o polarssl/padlock.o polarssl/md.o polarssl/md_wrap.o polarssl/md2.o polarssl/md4.o polarssl/md5.o polarssl/sha4.o polarssl/base64.o polarssl/cipher.o polarssl/cipher_wrap.o polarssl/camellia.o polarssl/des.o polarssl/blowfish.o
3 | LIBS = -static-libgcc -static-libstdc++
4 | CXXFLAGS = -I.
5 | CFLAGS = --std=c99 -Wall -I.
6 | OUTPUT = bin/extdata_tool
7 | CC = gcc
8 |
9 | main: $(OBJS) $(POLAR_OBJS)
10 | g++ -o $(OUTPUT) $(LIBS) $(OBJS) $(POLAR_OBJS)
11 |
12 |
13 | clean:
14 | rm -rf $(OUTPUT) $(OBJS) $(POLAR_OBJS)
--------------------------------------------------------------------------------
/extdata_tool/aesmac.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright 2013 3DSGuy
3 |
4 | This file is part of extdata_tool.
5 |
6 | extdata_tool is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | extdata_tool is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with extdata_tool. If not, see .
18 | **/
19 | typedef enum
20 | {
21 | mac_import_db = 1,
22 | mac_title_db,
23 | mac_extdata,
24 | mac_sys_save,
25 | mac_sd_save,
26 | mac_card_save
27 | } aes_mac_types;
28 |
29 | typedef enum
30 | {
31 | CTR_EXT0 = 0,
32 | CTR_SYS0,
33 | CTR_NOR0,
34 | CTR_SAV0,
35 | CTR_SIGN,
36 | CTR_9DB0,
37 | } savegame_type_index;
38 |
39 | typedef struct
40 | {
41 | u8 savegame_type[0x8];
42 | u8 image_id[4];
43 | u8 subdir_id[4];
44 | u8 unknown[4];
45 | u8 image_id_dup[4];
46 | u8 subdir_id_dup[4];
47 | u8 diff_header[0x100];
48 | } extdata_sha256_block;
49 |
50 | typedef struct
51 | {
52 | u8 savegame_type[0x8];
53 | u8 save_id[0x8];
54 | u8 disa_header[0x100];
55 | } sys_savedata_sha256_block;
56 |
57 | typedef struct
58 | {
59 | u8 savegame_type[0x8];
60 | u8 disa_header[0x100];
61 | } ctr_nor0_sha256_block;
62 |
63 | typedef struct
64 | {
65 | u8 savegame_type[0x8];
66 | u8 disa_header[0x100];
67 | } ctr_sav0_sha256_block;
68 |
69 | typedef struct
70 | {
71 | u8 savegame_type[0x8];
72 | u8 ctr_nor0_block_hash[0x20];
73 | } gamecard_savegame_sha256_block;
74 |
75 | typedef struct
76 | {
77 | u8 savegame_type[0x8];
78 | u8 program_id[0x8];
79 | u8 ctr_sav0_block_hash[0x20];
80 | } sdcard_savegame_sha256_block;
81 |
82 | typedef struct
83 | {
84 | u8 savegame_type[0x8];
85 | u8 db_id[0x4];
86 | u8 diff_header[0x100];
87 | } db_sha256_block;
88 |
89 | typedef struct
90 | {
91 | // Input
92 | u8 header[0x100]; // DISA/DIFF header
93 | u8 type;
94 | u8 Verbose;
95 |
96 | //ExtData ONLY Input
97 | u8 image_id[4];
98 | u8 subdir_id[4];
99 | u8 is_quote_dat;
100 |
101 | // Sys Savedata ONLY input
102 | u8 saveid[8];
103 |
104 | // SD Savedata ONLY input
105 | u8 programid[8];
106 |
107 | // Output
108 | u8 hash[0x20];
109 | u8 aesmac[0x10];
110 | } AESMAC_CTX;
111 |
112 | int PrepAESMAC(AESMAC_CTX *ctx);
113 | int GenAESMAC(u8 KeyX[16], u8 KeyY[16], AESMAC_CTX *ctx);
114 |
--------------------------------------------------------------------------------
/extdata_tool/ctx.h:
--------------------------------------------------------------------------------
1 | /**
Copyright 2013 3DSGuy
This file is part of extdata_tool.
extdata_tool is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
extdata_tool is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with extdata_tool. If not, see .
**/
//Global Sizes
typedef enum
{
IO_PATH_LEN = 0x400,
EXTDATA_FS_MAX_PATH_LEN = 0x100
} global_sizes;
typedef enum
{
WIN_32 = 0x5C,
UNIX = 0x2F
} platform;
--------------------------------------------------------------------------------
/extdata_tool/lib.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright 2013 3DSGuy
3 |
4 | This file is part of extdata_tool.
5 |
6 | extdata_tool is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | extdata_tool is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with extdata_tool. If not, see .
18 | **/
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 | #ifdef _WIN32
26 | #include
27 | #include
28 | #include
29 | #include
30 | #else
31 | #include
32 | #include
33 | #endif
34 |
35 | #include "types.h"
36 | #include "utils.h"
37 | #include "ctx.h"
38 |
39 |
40 | #define ARG_ERROR 1
41 | #define IO_ERROR 2
42 | #define MEM_ERROR 3
43 |
--------------------------------------------------------------------------------
/extdata_tool/polarssl/arc4.h:
--------------------------------------------------------------------------------
1 | /**
2 | * \file arc4.h
3 | *
4 | * \brief The ARCFOUR stream cipher
5 | *
6 | * Copyright (C) 2006-2013, Brainspark B.V.
7 | *
8 | * This file is part of PolarSSL (http://www.polarssl.org)
9 | * Lead Maintainer: Paul Bakker
10 | *
11 | * All rights reserved.
12 | *
13 | * This program is free software; you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation; either version 2 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License along
24 | * with this program; if not, write to the Free Software Foundation, Inc.,
25 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 | */
27 | #ifndef POLARSSL_ARC4_H
28 | #define POLARSSL_ARC4_H
29 |
30 | #include "polarssl/config.h"
31 |
32 | #include
33 |
34 | #if !defined(POLARSSL_ARC4_ALT)
35 | // Regular implementation
36 | //
37 |
38 | /**
39 | * \brief ARC4 context structure
40 | */
41 | typedef struct
42 | {
43 | int x; /*!< permutation index */
44 | int y; /*!< permutation index */
45 | unsigned char m[256]; /*!< permutation table */
46 | }
47 | arc4_context;
48 |
49 | #ifdef __cplusplus
50 | extern "C" {
51 | #endif
52 |
53 | /**
54 | * \brief ARC4 key schedule
55 | *
56 | * \param ctx ARC4 context to be initialized
57 | * \param key the secret key
58 | * \param keylen length of the key
59 | */
60 | void arc4_setup( arc4_context *ctx, const unsigned char *key, unsigned int keylen );
61 |
62 | /**
63 | * \brief ARC4 cipher function
64 | *
65 | * \param ctx ARC4 context
66 | * \param length length of the input data
67 | * \param input buffer holding the input data
68 | * \param output buffer for the output data
69 | *
70 | * \return 0 if successful
71 | */
72 | int arc4_crypt( arc4_context *ctx, size_t length, const unsigned char *input,
73 | unsigned char *output );
74 |
75 | #ifdef __cplusplus
76 | }
77 | #endif
78 |
79 | #else /* POLARSSL_ARC4_ALT */
80 | #include "polarssl/arc4_alt.h"
81 | #endif /* POLARSSL_ARC4_ALT */
82 |
83 | #ifdef __cplusplus
84 | extern "C" {
85 | #endif
86 |
87 | /**
88 | * \brief Checkup routine
89 | *
90 | * \return 0 if successful, or 1 if the test failed
91 | */
92 | int arc4_self_test( int verbose );
93 |
94 | #ifdef __cplusplus
95 | }
96 | #endif
97 |
98 | #endif /* arc4.h */
99 |
--------------------------------------------------------------------------------
/extdata_tool/polarssl/asn1write.h:
--------------------------------------------------------------------------------
1 | /**
2 | * \file asn1write.h
3 | *
4 | * \brief ASN.1 buffer writing functionality
5 | *
6 | * Copyright (C) 2006-2012, Brainspark B.V.
7 | *
8 | * This file is part of PolarSSL (http://www.polarssl.org)
9 | * Lead Maintainer: Paul Bakker
10 | *
11 | * All rights reserved.
12 | *
13 | * This program is free software; you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation; either version 2 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License along
24 | * with this program; if not, write to the Free Software Foundation, Inc.,
25 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 | */
27 | #ifndef POLARSSL_ASN1_WRITE_H
28 | #define POLARSSL_ASN1_WRITE_H
29 |
30 | #include "polarssl/asn1.h"
31 |
32 | #define ASN1_CHK_ADD(g, f) if( ( ret = f ) < 0 ) return( ret ); else g += ret
33 |
34 | int asn1_write_len( unsigned char **p, unsigned char *start, size_t len );
35 | int asn1_write_tag( unsigned char **p, unsigned char *start, unsigned char tag );
36 | int asn1_write_mpi( unsigned char **p, unsigned char *start, mpi *X );
37 | int asn1_write_null( unsigned char **p, unsigned char *start );
38 | int asn1_write_oid( unsigned char **p, unsigned char *start, char *oid );
39 | int asn1_write_algorithm_identifier( unsigned char **p, unsigned char *start, char *algorithm_oid );
40 | int asn1_write_int( unsigned char **p, unsigned char *start, int val );
41 | int asn1_write_printable_string( unsigned char **p, unsigned char *start,
42 | char *text );
43 | int asn1_write_ia5_string( unsigned char **p, unsigned char *start,
44 | char *text );
45 |
46 | #endif /* POLARSSL_ASN1_WRITE_H */
47 |
--------------------------------------------------------------------------------
/extdata_tool/polarssl/base64.h:
--------------------------------------------------------------------------------
1 | /**
2 | * \file base64.h
3 | *
4 | * \brief RFC 1521 base64 encoding/decoding
5 | *
6 | * Copyright (C) 2006-2010, Brainspark B.V.
7 | *
8 | * This file is part of PolarSSL (http://www.polarssl.org)
9 | * Lead Maintainer: Paul Bakker
10 | *
11 | * All rights reserved.
12 | *
13 | * This program is free software; you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation; either version 2 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License along
24 | * with this program; if not, write to the Free Software Foundation, Inc.,
25 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 | */
27 | #ifndef POLARSSL_BASE64_H
28 | #define POLARSSL_BASE64_H
29 |
30 | #include
31 |
32 | #define POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL -0x002A /**< Output buffer too small. */
33 | #define POLARSSL_ERR_BASE64_INVALID_CHARACTER -0x002C /**< Invalid character in input. */
34 |
35 | #ifdef __cplusplus
36 | extern "C" {
37 | #endif
38 |
39 | /**
40 | * \brief Encode a buffer into base64 format
41 | *
42 | * \param dst destination buffer
43 | * \param dlen size of the buffer
44 | * \param src source buffer
45 | * \param slen amount of data to be encoded
46 | *
47 | * \return 0 if successful, or POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL.
48 | * *dlen is always updated to reflect the amount
49 | * of data that has (or would have) been written.
50 | *
51 | * \note Call this function with *dlen = 0 to obtain the
52 | * required buffer size in *dlen
53 | */
54 | int base64_encode( unsigned char *dst, size_t *dlen,
55 | const unsigned char *src, size_t slen );
56 |
57 | /**
58 | * \brief Decode a base64-formatted buffer
59 | *
60 | * \param dst destination buffer
61 | * \param dlen size of the buffer
62 | * \param src source buffer
63 | * \param slen amount of data to be decoded
64 | *
65 | * \return 0 if successful, POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL, or
66 | * POLARSSL_ERR_BASE64_INVALID_CHARACTER if the input data is
67 | * not correct. *dlen is always updated to reflect the amount
68 | * of data that has (or would have) been written.
69 | *
70 | * \note Call this function with *dlen = 0 to obtain the
71 | * required buffer size in *dlen
72 | */
73 | int base64_decode( unsigned char *dst, size_t *dlen,
74 | const unsigned char *src, size_t slen );
75 |
76 | /**
77 | * \brief Checkup routine
78 | *
79 | * \return 0 if successful, or 1 if the test failed
80 | */
81 | int base64_self_test( int verbose );
82 |
83 | #ifdef __cplusplus
84 | }
85 | #endif
86 |
87 | #endif /* base64.h */
88 |
--------------------------------------------------------------------------------
/extdata_tool/polarssl/certs.h:
--------------------------------------------------------------------------------
1 | /**
2 | * \file certs.h
3 | *
4 | * \brief Sample certificates and DHM parameters for testing
5 | *
6 | * Copyright (C) 2006-2010, Brainspark B.V.
7 | *
8 | * This file is part of PolarSSL (http://www.polarssl.org)
9 | * Lead Maintainer: Paul Bakker
10 | *
11 | * All rights reserved.
12 | *
13 | * This program is free software; you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation; either version 2 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License along
24 | * with this program; if not, write to the Free Software Foundation, Inc.,
25 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 | */
27 | #ifndef POLARSSL_CERTS_H
28 | #define POLARSSL_CERTS_H
29 |
30 | #ifdef __cplusplus
31 | extern "C" {
32 | #endif
33 |
34 | extern const char test_ca_crt[];
35 | extern const char test_ca_key[];
36 | extern const char test_ca_pwd[];
37 | extern const char test_srv_crt[];
38 | extern const char test_srv_key[];
39 | extern const char test_cli_crt[];
40 | extern const char test_cli_key[];
41 | extern const char test_dhm_params[];
42 |
43 | #ifdef __cplusplus
44 | }
45 | #endif
46 |
47 | #endif /* certs.h */
48 |
--------------------------------------------------------------------------------
/extdata_tool/polarssl/debug.h:
--------------------------------------------------------------------------------
1 | /**
2 | * \file debug.h
3 | *
4 | * \brief Debug functions
5 | *
6 | * Copyright (C) 2006-2011, Brainspark B.V.
7 | *
8 | * This file is part of PolarSSL (http://www.polarssl.org)
9 | * Lead Maintainer: Paul Bakker
10 | *
11 | * All rights reserved.
12 | *
13 | * This program is free software; you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation; either version 2 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License along
24 | * with this program; if not, write to the Free Software Foundation, Inc.,
25 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 | */
27 | #ifndef POLARSSL_DEBUG_H
28 | #define POLARSSL_DEBUG_H
29 |
30 | #include "polarssl/config.h"
31 | #include "polarssl/ssl.h"
32 |
33 | #if defined(POLARSSL_DEBUG_C)
34 |
35 | #define SSL_DEBUG_MSG( level, args ) \
36 | debug_print_msg( ssl, level, __FILE__, __LINE__, debug_fmt args );
37 |
38 | #define SSL_DEBUG_RET( level, text, ret ) \
39 | debug_print_ret( ssl, level, __FILE__, __LINE__, text, ret );
40 |
41 | #define SSL_DEBUG_BUF( level, text, buf, len ) \
42 | debug_print_buf( ssl, level, __FILE__, __LINE__, text, buf, len );
43 |
44 | #define SSL_DEBUG_MPI( level, text, X ) \
45 | debug_print_mpi( ssl, level, __FILE__, __LINE__, text, X );
46 |
47 | #define SSL_DEBUG_CRT( level, text, crt ) \
48 | debug_print_crt( ssl, level, __FILE__, __LINE__, text, crt );
49 |
50 | #else
51 |
52 | #define SSL_DEBUG_MSG( level, args ) do { } while( 0 )
53 | #define SSL_DEBUG_RET( level, text, ret ) do { } while( 0 )
54 | #define SSL_DEBUG_BUF( level, text, buf, len ) do { } while( 0 )
55 | #define SSL_DEBUG_MPI( level, text, X ) do { } while( 0 )
56 | #define SSL_DEBUG_CRT( level, text, crt ) do { } while( 0 )
57 |
58 | #endif
59 |
60 | #ifdef __cplusplus
61 | extern "C" {
62 | #endif
63 |
64 | char *debug_fmt( const char *format, ... );
65 |
66 | void debug_print_msg( const ssl_context *ssl, int level,
67 | const char *file, int line, const char *text );
68 |
69 | void debug_print_ret( const ssl_context *ssl, int level,
70 | const char *file, int line,
71 | const char *text, int ret );
72 |
73 | void debug_print_buf( const ssl_context *ssl, int level,
74 | const char *file, int line, const char *text,
75 | unsigned char *buf, size_t len );
76 |
77 | void debug_print_mpi( const ssl_context *ssl, int level,
78 | const char *file, int line,
79 | const char *text, const mpi *X );
80 |
81 | void debug_print_crt( const ssl_context *ssl, int level,
82 | const char *file, int line,
83 | const char *text, const x509_cert *crt );
84 |
85 | #ifdef __cplusplus
86 | }
87 | #endif
88 |
89 | #endif /* debug.h */
90 |
--------------------------------------------------------------------------------
/extdata_tool/polarssl/entropy_poll.h:
--------------------------------------------------------------------------------
1 | /**
2 | * \file entropy_poll.h
3 | *
4 | * \brief Platform-specific and custom entropy polling functions
5 | *
6 | * Copyright (C) 2006-2011, Brainspark B.V.
7 | *
8 | * This file is part of PolarSSL (http://www.polarssl.org)
9 | * Lead Maintainer: Paul Bakker
10 | *
11 | * All rights reserved.
12 | *
13 | * This program is free software; you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation; either version 2 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License along
24 | * with this program; if not, write to the Free Software Foundation, Inc.,
25 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 | */
27 | #ifndef POLARSSL_ENTROPY_POLL_H
28 | #define POLARSSL_ENTROPY_POLL_H
29 |
30 | #include
31 |
32 | #include "polarssl/config.h"
33 |
34 | #ifdef __cplusplus
35 | extern "C" {
36 | #endif
37 |
38 | /*
39 | * Default thresholds for built-in sources
40 | */
41 | #define ENTROPY_MIN_PLATFORM 128 /**< Minimum for platform source */
42 | #define ENTROPY_MIN_HAVEGE 128 /**< Minimum for HAVEGE */
43 | #define ENTROPY_MIN_HARDCLOCK 32 /**< Minimum for hardclock() */
44 |
45 | #if !defined(POLARSSL_NO_PLATFORM_ENTROPY)
46 | /**
47 | * \brief Platform-specific entropy poll callback
48 | */
49 | int platform_entropy_poll( void *data,
50 | unsigned char *output, size_t len, size_t *olen );
51 | #endif
52 |
53 | #if defined(POLARSSL_HAVEGE_C)
54 | /**
55 | * \brief HAVEGE based entropy poll callback
56 | *
57 | * Requires an HAVEGE state as its data pointer.
58 | */
59 | int havege_poll( void *data,
60 | unsigned char *output, size_t len, size_t *olen );
61 | #endif
62 |
63 | #if defined(POLARSSL_TIMING_C)
64 | /**
65 | * \brief hardclock-based entropy poll callback
66 | */
67 | int hardclock_poll( void *data,
68 | unsigned char *output, size_t len, size_t *olen );
69 | #endif
70 |
71 | #ifdef __cplusplus
72 | }
73 | #endif
74 |
75 | #endif /* entropy_poll.h */
76 |
--------------------------------------------------------------------------------
/extdata_tool/polarssl/havege.h:
--------------------------------------------------------------------------------
1 | /**
2 | * \file havege.h
3 | *
4 | * \brief HAVEGE: HArdware Volatile Entropy Gathering and Expansion
5 | *
6 | * Copyright (C) 2006-2010, Brainspark B.V.
7 | *
8 | * This file is part of PolarSSL (http://www.polarssl.org)
9 | * Lead Maintainer: Paul Bakker
10 | *
11 | * All rights reserved.
12 | *
13 | * This program is free software; you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation; either version 2 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License along
24 | * with this program; if not, write to the Free Software Foundation, Inc.,
25 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 | */
27 | #ifndef POLARSSL_HAVEGE_H
28 | #define POLARSSL_HAVEGE_H
29 |
30 | #include
31 |
32 | #define COLLECT_SIZE 1024
33 |
34 | /**
35 | * \brief HAVEGE state structure
36 | */
37 | typedef struct
38 | {
39 | int PT1, PT2, offset[2];
40 | int pool[COLLECT_SIZE];
41 | int WALK[8192];
42 | }
43 | havege_state;
44 |
45 | #ifdef __cplusplus
46 | extern "C" {
47 | #endif
48 |
49 | /**
50 | * \brief HAVEGE initialization
51 | *
52 | * \param hs HAVEGE state to be initialized
53 | */
54 | void havege_init( havege_state *hs );
55 |
56 | /**
57 | * \brief HAVEGE rand function
58 | *
59 | * \param p_rng A HAVEGE state
60 | * \param output Buffer to fill
61 | * \param len Length of buffer
62 | *
63 | * \return 0
64 | */
65 | int havege_random( void *p_rng, unsigned char *output, size_t len );
66 |
67 | #ifdef __cplusplus
68 | }
69 | #endif
70 |
71 | #endif /* havege.h */
72 |
--------------------------------------------------------------------------------
/extdata_tool/polarssl/md_wrap.h:
--------------------------------------------------------------------------------
1 | /**
2 | * \file md_wrap.h
3 | *
4 | * \brief Message digest wrappers.
5 | *
6 | * \author Adriaan de Jong
7 | *
8 | * Copyright (C) 2006-2011, Brainspark B.V.
9 | *
10 | * This file is part of PolarSSL (http://www.polarssl.org)
11 | * Lead Maintainer: Paul Bakker
12 | *
13 | * All rights reserved.
14 | *
15 | * This program is free software; you can redistribute it and/or modify
16 | * it under the terms of the GNU General Public License as published by
17 | * the Free Software Foundation; either version 2 of the License, or
18 | * (at your option) any later version.
19 | *
20 | * This program is distributed in the hope that it will be useful,
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 | * GNU General Public License for more details.
24 | *
25 | * You should have received a copy of the GNU General Public License along
26 | * with this program; if not, write to the Free Software Foundation, Inc.,
27 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 | */
29 | #ifndef POLARSSL_MD_WRAP_H
30 | #define POLARSSL_MD_WRAP_H
31 |
32 | #include "polarssl/config.h"
33 | #include "polarssl/md.h"
34 |
35 | #ifdef __cplusplus
36 | extern "C" {
37 | #endif
38 |
39 | #if defined(POLARSSL_MD2_C)
40 | extern const md_info_t md2_info;
41 | #endif
42 | #if defined(POLARSSL_MD4_C)
43 | extern const md_info_t md4_info;
44 | #endif
45 | #if defined(POLARSSL_MD5_C)
46 | extern const md_info_t md5_info;
47 | #endif
48 | #if defined(POLARSSL_SHA1_C)
49 | extern const md_info_t sha1_info;
50 | #endif
51 | #if defined(POLARSSL_SHA2_C)
52 | extern const md_info_t sha224_info;
53 | extern const md_info_t sha256_info;
54 | #endif
55 | #if defined(POLARSSL_SHA4_C)
56 | extern const md_info_t sha384_info;
57 | extern const md_info_t sha512_info;
58 | #endif
59 |
60 | #ifdef __cplusplus
61 | }
62 | #endif
63 |
64 | #endif /* POLARSSL_MD_WRAP_H */
65 |
--------------------------------------------------------------------------------
/extdata_tool/polarssl/pbkdf2.c:
--------------------------------------------------------------------------------
1 | /**
2 | * \file pbkdf2.c
3 | *
4 | * \brief Password-Based Key Derivation Function 2 (from PKCS#5)
5 | * DEPRECATED: Use pkcs5.c instead
6 | *
7 | * \author Mathias Olsson
8 | *
9 | * Copyright (C) 2006-2012, Brainspark B.V.
10 | *
11 | * This file is part of PolarSSL (http://www.polarssl.org)
12 | * Lead Maintainer: Paul Bakker
13 | *
14 | * All rights reserved.
15 | *
16 | * This program is free software; you can redistribute it and/or modify
17 | * it under the terms of the GNU General Public License as published by
18 | * the Free Software Foundation; either version 2 of the License, or
19 | * (at your option) any later version.
20 | *
21 | * This program is distributed in the hope that it will be useful,
22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 | * GNU General Public License for more details.
25 | *
26 | * You should have received a copy of the GNU General Public License along
27 | * with this program; if not, write to the Free Software Foundation, Inc.,
28 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 | */
30 | /*
31 | * PBKDF2 is part of PKCS#5
32 | *
33 | * http://tools.ietf.org/html/rfc2898 (Specification)
34 | * http://tools.ietf.org/html/rfc6070 (Test vectors)
35 | */
36 |
37 | #include "polarssl/config.h"
38 |
39 | #if defined(POLARSSL_PBKDF2_C)
40 |
41 | #include "polarssl/pbkdf2.h"
42 | #include "polarssl/pkcs5.h"
43 |
44 | int pbkdf2_hmac( md_context_t *ctx, const unsigned char *password, size_t plen,
45 | const unsigned char *salt, size_t slen,
46 | unsigned int iteration_count,
47 | uint32_t key_length, unsigned char *output )
48 | {
49 | return pkcs5_pbkdf2_hmac( ctx, password, plen, salt, slen, iteration_count,
50 | key_length, output );
51 | }
52 |
53 | #if defined(POLARSSL_SELF_TEST)
54 | int pbkdf2_self_test( int verbose )
55 | {
56 | return pkcs5_self_test( verbose );
57 | }
58 | #endif /* POLARSSL_SELF_TEST */
59 |
60 | #endif /* POLARSSL_PBKDF2_C */
61 |
--------------------------------------------------------------------------------
/extdata_tool/polarssl/pbkdf2.h:
--------------------------------------------------------------------------------
1 | /**
2 | * \file pbkdf2.h
3 | *
4 | * \brief Password-Based Key Derivation Function 2 (from PKCS#5)
5 | * DEPRECATED: use pkcs5.h instead.
6 | *
7 | * \author Mathias Olsson
8 | *
9 | * Copyright (C) 2006-2012, Brainspark B.V.
10 | *
11 | * This file is part of PolarSSL (http://www.polarssl.org)
12 | * Lead Maintainer: Paul Bakker
13 | *
14 | * All rights reserved.
15 | *
16 | * This program is free software; you can redistribute it and/or modify
17 | * it under the terms of the GNU General Public License as published by
18 | * the Free Software Foundation; either version 2 of the License, or
19 | * (at your option) any later version.
20 | *
21 | * This program is distributed in the hope that it will be useful,
22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 | * GNU General Public License for more details.
25 | *
26 | * You should have received a copy of the GNU General Public License along
27 | * with this program; if not, write to the Free Software Foundation, Inc.,
28 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 | */
30 | #ifndef POLARSSL_PBKDF2_H
31 | #define POLARSSL_PBKDF2_H
32 |
33 | #include
34 |
35 | #include "polarssl/md.h"
36 |
37 | #ifdef _MSC_VER
38 | #include
39 | typedef UINT32 uint32_t;
40 | #else
41 | #include
42 | #endif
43 |
44 | #define POLARSSL_ERR_PBKDF2_BAD_INPUT_DATA -0x007C /**< Bad input parameters to function. */
45 |
46 | #ifdef __cplusplus
47 | extern "C" {
48 | #endif
49 |
50 | /**
51 | * \brief PKCS#5 PBKDF2 using HMAC
52 | * DEPRECATED: Use pkcs5_pbkdf2_hmac() instead!
53 | *
54 | * \param ctx Generic HMAC context
55 | * \param password Password to use when generating key
56 | * \param plen Length of password
57 | * \param salt Salt to use when generating key
58 | * \param slen Length of salt
59 | * \param iteration_count Iteration count
60 | * \param key_length Length of generated key
61 | * \param output Generated key. Must be at least as big as key_length
62 | *
63 | * \returns 0 on success, or a PolarSSL error code if verification fails.
64 | */
65 | int pbkdf2_hmac( md_context_t *ctx, const unsigned char *password,
66 | size_t plen, const unsigned char *salt, size_t slen,
67 | unsigned int iteration_count,
68 | uint32_t key_length, unsigned char *output );
69 |
70 | /**
71 | * \brief Checkup routine
72 | * DEPRECATED: Use pkcs5_self_test() instead!
73 | *
74 | * \return 0 if successful, or 1 if the test failed
75 | */
76 | int pbkdf2_self_test( int verbose );
77 |
78 | #ifdef __cplusplus
79 | }
80 | #endif
81 |
82 | #endif /* pbkdf2.h */
83 |
--------------------------------------------------------------------------------
/extdata_tool/polarssl/timing.h:
--------------------------------------------------------------------------------
1 | /**
2 | * \file timing.h
3 | *
4 | * \brief Portable interface to the CPU cycle counter
5 | *
6 | * Copyright (C) 2006-2010, Brainspark B.V.
7 | *
8 | * This file is part of PolarSSL (http://www.polarssl.org)
9 | * Lead Maintainer: Paul Bakker
10 | *
11 | * All rights reserved.
12 | *
13 | * This program is free software; you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation; either version 2 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License along
24 | * with this program; if not, write to the Free Software Foundation, Inc.,
25 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 | */
27 | #ifndef POLARSSL_TIMING_H
28 | #define POLARSSL_TIMING_H
29 |
30 | /**
31 | * \brief timer structure
32 | */
33 | struct hr_time
34 | {
35 | unsigned char opaque[32];
36 | };
37 |
38 | #ifdef __cplusplus
39 | extern "C" {
40 | #endif
41 |
42 | extern volatile int alarmed;
43 |
44 | /**
45 | * \brief Return the CPU cycle counter value
46 | */
47 | unsigned long hardclock( void );
48 |
49 | /**
50 | * \brief Return the elapsed time in milliseconds
51 | *
52 | * \param val points to a timer structure
53 | * \param reset if set to 1, the timer is restarted
54 | */
55 | unsigned long get_timer( struct hr_time *val, int reset );
56 |
57 | /**
58 | * \brief Setup an alarm clock
59 | *
60 | * \param seconds delay before the "alarmed" flag is set
61 | */
62 | void set_alarm( int seconds );
63 |
64 | /**
65 | * \brief Sleep for a certain amount of time
66 | *
67 | * \param milliseconds delay in milliseconds
68 | */
69 | void m_sleep( int milliseconds );
70 |
71 | #ifdef __cplusplus
72 | }
73 | #endif
74 |
75 | #endif /* timing.h */
76 |
--------------------------------------------------------------------------------
/extdata_tool/polarssl/version.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Version information
3 | *
4 | * Copyright (C) 2006-2010, Brainspark B.V.
5 | *
6 | * This file is part of PolarSSL (http://www.polarssl.org)
7 | * Lead Maintainer: Paul Bakker
8 | *
9 | * All rights reserved.
10 | *
11 | * This program is free software; you can redistribute it and/or modify
12 | * it under the terms of the GNU General Public License as published by
13 | * the Free Software Foundation; either version 2 of the License, or
14 | * (at your option) any later version.
15 | *
16 | * This program is distributed in the hope that it will be useful,
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 | * GNU General Public License for more details.
20 | *
21 | * You should have received a copy of the GNU General Public License along
22 | * with this program; if not, write to the Free Software Foundation, Inc.,
23 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 | */
25 |
26 | #include "polarssl/config.h"
27 |
28 | #if defined(POLARSSL_VERSION_C)
29 |
30 | #include "polarssl/version.h"
31 | #include
32 |
33 | const char version[] = POLARSSL_VERSION_STRING;
34 |
35 | unsigned int version_get_number()
36 | {
37 | return POLARSSL_VERSION_NUMBER;
38 | }
39 |
40 | void version_get_string( char *string )
41 | {
42 | memcpy( string, POLARSSL_VERSION_STRING, sizeof( POLARSSL_VERSION_STRING ) );
43 | }
44 |
45 | void version_get_string_full( char *string )
46 | {
47 | memcpy( string, POLARSSL_VERSION_STRING_FULL, sizeof( POLARSSL_VERSION_STRING_FULL ) );
48 | }
49 |
50 | #endif /* POLARSSL_VERSION_C */
51 |
--------------------------------------------------------------------------------
/extdata_tool/polarssl/version.h:
--------------------------------------------------------------------------------
1 | /**
2 | * \file version.h
3 | *
4 | * \brief Run-time version information
5 | *
6 | * Copyright (C) 2006-2012, Brainspark B.V.
7 | *
8 | * This file is part of PolarSSL (http://www.polarssl.org)
9 | * Lead Maintainer: Paul Bakker
10 | *
11 | * All rights reserved.
12 | *
13 | * This program is free software; you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation; either version 2 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License along
24 | * with this program; if not, write to the Free Software Foundation, Inc.,
25 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 | */
27 | /*
28 | * This set of compile-time defines and run-time variables can be used to
29 | * determine the version number of the PolarSSL library used.
30 | */
31 | #ifndef POLARSSL_VERSION_H
32 | #define POLARSSL_VERSION_H
33 |
34 | #include "polarssl/config.h"
35 |
36 | /**
37 | * The version number x.y.z is split into three parts.
38 | * Major, Minor, Patchlevel
39 | */
40 | #define POLARSSL_VERSION_MAJOR 1
41 | #define POLARSSL_VERSION_MINOR 2
42 | #define POLARSSL_VERSION_PATCH 8
43 |
44 | /**
45 | * The single version number has the following structure:
46 | * MMNNPP00
47 | * Major version | Minor version | Patch version
48 | */
49 | #define POLARSSL_VERSION_NUMBER 0x01020800
50 | #define POLARSSL_VERSION_STRING "1.2.8"
51 | #define POLARSSL_VERSION_STRING_FULL "PolarSSL 1.2.8"
52 |
53 | #if defined(POLARSSL_VERSION_C)
54 |
55 | /**
56 | * Get the version number.
57 | *
58 | * \return The constructed version number in the format
59 | * MMNNPP00 (Major, Minor, Patch).
60 | */
61 | unsigned int version_get_number( void );
62 |
63 | /**
64 | * Get the version string ("x.y.z").
65 | *
66 | * \param string The string that will receive the value.
67 | * (Should be at least 9 bytes in size)
68 | */
69 | void version_get_string( char *string );
70 |
71 | /**
72 | * Get the full version string ("PolarSSL x.y.z").
73 | *
74 | * \param string The string that will receive the value.
75 | * (Should be at least 18 bytes in size)
76 | */
77 | void version_get_string_full( char *string );
78 |
79 | #endif /* POLARSSL_VERSION_C */
80 |
81 | #endif /* version.h */
82 |
--------------------------------------------------------------------------------
/extdata_tool/polarssl/x509write.h:
--------------------------------------------------------------------------------
1 | /**
2 | * \file x509write.h
3 | *
4 | * \brief X509 buffer writing functionality
5 | *
6 | * Copyright (C) 2006-2012, Brainspark B.V.
7 | *
8 | * This file is part of PolarSSL (http://www.polarssl.org)
9 | * Lead Maintainer: Paul Bakker
10 | *
11 | * All rights reserved.
12 | *
13 | * This program is free software; you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation; either version 2 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License along
24 | * with this program; if not, write to the Free Software Foundation, Inc.,
25 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 | */
27 | #ifndef POLARSSL_X509_WRITE_H
28 | #define POLARSSL_X509_WRITE_H
29 |
30 | #include "polarssl/rsa.h"
31 |
32 | typedef struct _x509_req_name
33 | {
34 | char oid[128];
35 | char name[128];
36 |
37 | struct _x509_req_name *next;
38 | }
39 | x509_req_name;
40 |
41 | int x509_write_pubkey_der( unsigned char *buf, size_t size, rsa_context *rsa );
42 | int x509_write_key_der( unsigned char *buf, size_t size, rsa_context *rsa );
43 | int x509_write_cert_req( unsigned char *buf, size_t size, rsa_context *rsa,
44 | x509_req_name *req_name, int hash_id );
45 |
46 | #endif /* POLARSSL_X509_WRITE_H */
47 |
--------------------------------------------------------------------------------
/extdata_tool/types.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright 2013 3DSGuy
3 |
4 | This file is part of extdata_tool.
5 |
6 | extdata_tool is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | extdata_tool is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with extdata_tool. If not, see .
18 | **/
19 | #include
20 | #include
21 | //Bools
22 | typedef enum
23 | {
24 | False,
25 | True
26 | } _boolean;
27 |
28 | typedef enum
29 | {
30 | Good,
31 | Fail
32 | } return_basic;
33 |
34 | typedef enum
35 | {
36 | ARG_ERROR = 1,
37 | IO_ERROR,
38 | MEM_ERROR,
39 | } errors;
40 |
41 | typedef enum
42 | {
43 | Invalid = -1,
44 | Valid = 0
45 | }Validity;
46 |
47 | typedef enum
48 | {
49 | BE = 0,
50 | LE = 1
51 | } endianness_flag;
52 |
53 | typedef enum
54 | {
55 | KB = 1024,
56 | MB = 1048576,
57 | GB = 1073741824
58 | } file_unit_size;
59 |
60 | typedef unsigned char u8;
61 | typedef unsigned short u16;
62 | typedef unsigned int u32;
63 | typedef unsigned long long u64;
64 |
65 | typedef signed char s8;
66 | typedef signed short s16;
67 | typedef signed int s32;
68 | typedef signed long long s64;
69 |
--------------------------------------------------------------------------------
/extdata_tool/utils.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright 2013 3DSGuy
3 |
4 | This file is part of extdata_tool.
5 |
6 | extdata_tool is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | extdata_tool is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with extdata_tool. If not, see .
18 | **/
19 | #ifndef _UTILS_H_
20 | #define _UTILS_H_
21 | typedef struct
22 | {
23 | char *argument;
24 | u16 arg_len;
25 | } __attribute__((__packed__))
26 | OPTION_CTX;
27 |
28 | typedef struct
29 | {
30 | u8 *buffer;
31 | u64 size;
32 | } __attribute__((__packed__))
33 | COMPONENT_STRUCT;
34 | #endif
35 |
36 | //MISC
37 | void char_to_u8_array(unsigned char destination[], char source[], int size, int endianness, int base);
38 | void endian_memcpy(u8 *destination, u8 *source, u32 size, int endianness);
39 | void u8_hex_print_be(u8 *array, int len);
40 | void u8_hex_print_le(u8 *array, int len);
41 | u32 align_value(u32 value, u32 alignment);
42 | int CheckBitmask(u16 Bitmask, u16 Bit);
43 | void resolve_flag(unsigned char flag, unsigned char *flag_bool);
44 | void resolve_flag_u16(u16 flag, unsigned char *flag_bool);
45 | int append_filextention(char *output, u16 max_outlen, char *input, char extention[]);
46 | //IO Related
47 | void WriteBuffer(void *buffer, u64 size, u64 offset, FILE *output);
48 | void ReadFile_64(void *outbuff, u64 size, u64 offset, FILE *file);
49 | u64 GetFileSize_u64(char *filename);
50 | u32 GetFileSize_u32(FILE *file);
51 | int TruncateFile_u64(char *filename, u64 filelen);
52 | int fseek_64(FILE *fp, u64 file_pos, int whence);
53 | int makedir(const char* dir);
54 | char *getcwdir(char *buffer,int maxlen);
55 | void _free(void *ptr); // frees and nullifies pointer
56 | //Data Size conversion
57 | u16 u8_to_u16(u8 *value, u8 endianness);
58 | u32 u8_to_u32(u8 *value, u8 endianness);
59 | u64 u8_to_u64(u8 *value, u8 endianness);
60 | int u16_to_u8(u8 *out_value, u16 in_value, u8 endianness);
61 | int u32_to_u8(u8 *out_value, u32 in_value, u8 endianness);
62 | int u64_to_u8(u8 *out_value, u64 in_value, u8 endianness);
63 | //from ctrtool
64 | void memdump(FILE* fout, const char* prefix, const u8* data, u32 size);
65 |
66 | // Adapted from http://rosettacode.org/wiki/Sorting_algorithms/Merge_sort#C
67 | void merge(u64 *left, int l_len, u64 *right, int r_len, u64 *out);
68 | void recur(u64 *buf, u64 *tmp, int len);
69 | void merge_sort(u64 *buf, int len);
70 |
--------------------------------------------------------------------------------
/extdata_tool/vsxe.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright 2013 3DSGuy
3 |
4 | This file is part of extdata_tool.
5 |
6 | extdata_tool is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | extdata_tool is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with extdata_tool. If not, see .
18 | **/
19 | typedef enum
20 | {
21 | vsxe_magic = 0x56535845,
22 | vsxe_magic_id = 0x30000
23 | } VSXE_data;
24 |
25 | typedef enum
26 | {
27 | VSXE_BAD_EXTDATA_TYPE = 20,
28 | VSXE_UNEXPECTED_DATA_IN_EXTDATA,
29 | VSXE_MEM_FAIL,
30 | } VSXE_errors;
31 |
32 | typedef enum
33 | {
34 | vsxe_extract = 0,
35 | vsxe_show_fs,
36 | vsxe_verbose,
37 | vsxe_fstable,
38 | } VSXE_OptionIndex;
39 |
40 | typedef enum
41 | {
42 | vsxe_fs_deleted = 0,
43 | vsxe_fs_modified = 2,
44 | } vsxe_fs_file_action;
45 |
46 | //Structs
47 | typedef struct
48 | {
49 | u8 parent_folder_index[4];
50 | char filename[0x10];
51 | u8 prev_folder_id[4];
52 | u8 last_folder_index[4];
53 | u8 last_file_index[4];
54 | u8 unk0[4];
55 | u8 unk1[4];
56 | } folder_entry;
57 |
58 | typedef struct
59 | {
60 | u8 parent_folder_index[4];
61 | char filename[0x10];
62 | u8 prev_file_id[4];
63 | u8 unk0[4];
64 | u8 unk1[4];
65 | u8 unique_extdata_id[8];
66 | u8 unk2[4];
67 | u8 unk3[4];
68 | } file_entry;
69 |
70 | typedef struct
71 | {
72 | //u8 unk0[40][4];
73 | u8 unk0[0x38];
74 | u8 folder_table_offset[8];
75 | } vsxe_data_table;
76 |
77 | typedef struct
78 | {
79 | u8 magic[4];
80 | u8 magic_id[4];
81 | u8 data_table_offset[8];
82 | u8 filesizeX[8];
83 | u8 filesizeY[8];
84 | u8 unk1[8];
85 | u8 last_used_file_action[4];
86 | u8 unk2[4];
87 | u8 last_used_file_extdata_id[4];
88 | u8 unk3[4];
89 | char last_used_file[0x100];
90 | } vsxe_header;
91 |
92 | typedef struct
93 | {
94 | u8 used_slots[4];
95 | u8 max_slots[4];
96 | u8 reserved[0x20];
97 | } folder_table_header;
98 |
99 | typedef struct
100 | {
101 | u8 used_slots[4];
102 | u8 max_slots[4];
103 | u8 reserved[0x28];
104 | } file_table_header;
105 |
106 |
107 | typedef struct
108 | {
109 | u8 *vsxe;
110 |
111 | u8 showfs;
112 | u8 showfs_tables;
113 | u8 verbose;
114 |
115 | // File I/O Paths
116 | char *input;
117 | char *output;
118 | char platform;
119 |
120 | // Header
121 | vsxe_header *header;
122 | vsxe_data_table *data_table;
123 |
124 | // Folders
125 | u64 folder_table_offset;
126 | u8 foldercount;
127 | folder_entry *folders;
128 |
129 | // Files
130 | u64 file_table_offset;
131 | u8 filecount;
132 | file_entry *files;
133 | } VSXE_INTERNAL_CONTEXT;
134 |
135 | typedef struct
136 | {
137 | u8 *vsxe;
138 |
139 | u8 Flags[3];
140 |
141 | char *input;
142 | char *output;
143 |
144 | char platform;
145 | } VSXEContext;
146 |
147 | // Prototypes
148 | int ProcessExtData_FS(VSXEContext *ctx);
149 | int IsVSXEFileSystem(u8 *vsxe);
--------------------------------------------------------------------------------
/icn_extractor/LodePNG/decode_bmp.c:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2005-2010 Lode Vandevenne
3 |
4 | This software is provided 'as-is', without any express or implied
5 | warranty. In no event will the authors be held liable for any damages
6 | arising from the use of this software.
7 |
8 | Permission is granted to anyone to use this software for any purpose,
9 | including commercial applications, and to alter it and redistribute it
10 | freely, subject to the following restrictions:
11 |
12 | 1. The origin of this software must not be misrepresented; you must not
13 | claim that you wrote the original software. If you use this software
14 | in a product, an acknowledgment in the product documentation would be
15 | appreciated but is not required.
16 |
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 |
20 | 3. This notice may not be removed or altered from any source
21 | distribution.
22 | */
23 |
24 | /*
25 | Adapted from example_bmp2png.cpp
26 | by Lode Vandevenne
27 |
28 | Retrieved from: http://lodev.org/lodepng/example_bmp2png.cpp
29 | */
30 | #include "../types.h"
31 |
32 | void DecodeBMPData(u8 *in, u8 *out, u16 width)
33 | {
34 | u16 scanlineBytes = width * 3;
35 |
36 | for(u16 y = 0; y < width; y++){
37 | for(u16 x = 0; x < width; x++){
38 | u16 bmpos = (width - y - 1) * scanlineBytes + 3 * x;
39 | u16 newpos = 4 * y * width + 4 * x;
40 | out[newpos + 0] = in[bmpos + 2]; //R
41 | out[newpos + 1] = in[bmpos + 1]; //G
42 | out[newpos + 2] = in[bmpos + 0]; //B
43 | out[newpos + 3] = 255; //A
44 | }
45 | }
46 | return;
47 | }
--------------------------------------------------------------------------------
/icn_extractor/LodePNG/decode_bmp.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2005-2010 Lode Vandevenne
3 |
4 | This software is provided 'as-is', without any express or implied
5 | warranty. In no event will the authors be held liable for any damages
6 | arising from the use of this software.
7 |
8 | Permission is granted to anyone to use this software for any purpose,
9 | including commercial applications, and to alter it and redistribute it
10 | freely, subject to the following restrictions:
11 |
12 | 1. The origin of this software must not be misrepresented; you must not
13 | claim that you wrote the original software. If you use this software
14 | in a product, an acknowledgment in the product documentation would be
15 | appreciated but is not required.
16 |
17 | 2. Altered source versions must be plainly marked as such, and must not be
18 | misrepresented as being the original software.
19 |
20 | 3. This notice may not be removed or altered from any source
21 | distribution.
22 | */
23 |
24 | /*
25 | Adapted from example_bmp2png.cpp
26 | by Lode Vandevenne
27 |
28 | Retrieved from: http://lodev.org/lodepng/example_bmp2png.cpp
29 | */
30 |
31 | void DecodeBMPData(u8 *in, u8 *out, u16 width);
--------------------------------------------------------------------------------
/icn_extractor/README.md:
--------------------------------------------------------------------------------
1 | #### CTR_Toolkit - ICN Icon Extractor - Takes the CTPK encoded icons from ICN files re-encoded them into PNG files ####
2 | #### Version: 0.4 2013 (C) 3DSGuy ####
3 |
4 | ### Usage ###
5 |
6 | Usage: icn_extractor
7 |
8 | OPTIONS Possible Values Explanation
9 | -i File-in Input ICN file.
10 | -s File-out Output path for small icon.
11 | -l File-out Output path for large icon.
12 |
13 | This program supports "drag & drop" (i.e. icn_extractor ). However only the large icon is outputted, and is written to the same path as the input icon, except the file extension is changed to ".png".
14 |
15 | ### Credits ###
16 | Big thanks to Lode Vandevenne who wrote the lodepng library, which I've used to handle bmp->png re-encoding.
17 | You can check out lodepng here: http://lodev.org/lodepng/
--------------------------------------------------------------------------------
/icn_extractor/bmp.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright 2013 3DSGuy
3 |
4 | This file is part of icn_extractor.
5 |
6 | icn_extractor is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | icn_extractor is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with icn_extractor. If not, see .
18 | **/
19 |
20 | typedef enum
21 | {
22 | red_mask = 0xF800,
23 | green_mask = 0x7E0,
24 | blue_mask = 0x1F
25 | } RGB565_BITMASK;
26 |
27 | typedef struct
28 | {
29 | u16 bfType;
30 | u32 bfSize;
31 | u16 bfReserved1;
32 | u16 bfReserved2;
33 | u32 bfOffBits;
34 | } _BITMAPFILEHEADER;
35 |
36 | typedef struct
37 | {
38 | u32 biSize;
39 | s32 biWidth;
40 | s32 biHeight;
41 | u16 biPlanes;
42 | u16 biBitCount;
43 | u32 biCompression;
44 | u32 biSizeImage;
45 | s32 biXPelsPerMeter;
46 | s32 biYPelsPerMeter;
47 | u32 biClrUsed;
48 | u32 biClrImportant;
49 | } _BITMAPINFOHEADER;
50 |
51 | typedef struct
52 | {
53 | u8 rgbtBlue;
54 | u8 rgbtGreen;
55 | u8 rgbtRed;
56 | } _RGBTRIPLE;
57 |
--------------------------------------------------------------------------------
/icn_extractor/lib.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright 2013 3DSGuy
3 |
4 | This file is part of icn_extractor.
5 |
6 | icn_extractor is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | icn_extractor is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with icn_extractor. If not, see .
18 | **/
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 |
29 | #ifdef _WIN32
30 | #include
31 | #include
32 | #include
33 | #include
34 | #else
35 | #include
36 | #include
37 | #endif
38 |
39 | #include "types.h"
40 | #include "utils.h"
41 |
42 |
43 |
--------------------------------------------------------------------------------
/icn_extractor/makefile:
--------------------------------------------------------------------------------
1 | all:
2 | gcc -std=c99 LodePNG/lodepng.c LodePNG/decode_bmp.c utils.c main.c -o icn_extractor
--------------------------------------------------------------------------------
/icn_extractor/types.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright 2013 3DSGuy
3 |
4 | This file is part of icn_extractor.
5 |
6 | icn_extractor is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | icn_extractor is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with icn_extractor. If not, see .
18 | **/
19 | #include
20 | #include
21 | //Bools
22 | typedef enum
23 | {
24 | False,
25 | True
26 | } _boolean;
27 |
28 | typedef enum
29 | {
30 | Good,
31 | Fail
32 | } return_basic;
33 |
34 | typedef enum
35 | {
36 | ARGC_FAIL = 1,
37 | ARGV_FAIL,
38 | aes_key_fail,
39 | rsa_key_fail,
40 | cia_type_fail,
41 | cert_gen_fail,
42 | content_mismatch,
43 | ticket_gen_fail,
44 | tmd_gen_fail,
45 | cia_header_gen_fail
46 | } errors;
47 |
48 | typedef enum
49 | {
50 | BE = 0,
51 | LE = 1
52 | } endianness_flag;
53 |
54 | typedef enum
55 | {
56 | KB = 1024,
57 | MB = 1048576,
58 | GB = 1073741824
59 | } file_unit_size;
60 |
61 | typedef unsigned char u8;
62 | typedef unsigned short u16;
63 | typedef unsigned int u32;
64 | typedef unsigned long long u64;
65 |
66 | typedef signed char s8;
67 | typedef signed short s16;
68 | typedef signed int s32;
69 | typedef signed long long s64;
70 |
--------------------------------------------------------------------------------
/icn_extractor/utils.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright 2013 3DSGuy
3 |
4 | This file is part of icn_extractor.
5 |
6 | icn_extractor is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | icn_extractor is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with icn_extractor. If not, see .
18 | **/
19 | #ifndef _UTILS_H_
20 | #define _UTILS_H_
21 | typedef struct
22 | {
23 | char *argument;
24 | u16 arg_len;
25 | } __attribute__((__packed__))
26 | OPTION_CTX;
27 |
28 | typedef struct
29 | {
30 | u8 *buffer;
31 | u64 size;
32 | } __attribute__((__packed__))
33 | COMPONENT_STRUCT;
34 | #endif
35 |
36 | //MISC
37 | void char_to_int_array(unsigned char destination[], char source[], int size, int endianness, int base);
38 | void endian_memcpy(u8 *destination, u8 *source, u32 size, int endianness);
39 | void u8_hex_print_be(u8 *array, int len);
40 | void u8_hex_print_le(u8 *array, int len);
41 | u32 align_value(u32 value, u32 alignment);
42 | void resolve_flag(unsigned char flag, unsigned char *flag_bool);
43 | void resolve_flag_u16(u16 flag, unsigned char *flag_bool);
44 | int append_filextention(char *output, u16 max_outlen, char *input, char extention[]);
45 | //IO Related
46 | void WriteBuffer(void *buffer, u64 size, u64 offset, FILE *output);
47 | void ReadFile_64(void *outbuff, u64 size, u64 offset, FILE *file);
48 | u64 GetFileSize_u64(char *filename);
49 | u32 GetFileSize_u32(FILE *file);
50 | int TruncateFile_u64(char *filename, u64 filelen);
51 | int fseek_64(FILE *fp, u64 file_pos, int whence);
52 | int makedir(const char* dir);
53 | char *getcwdir(char *buffer,int maxlen);
54 | void _free(void *ptr); // frees and nullifies pointer
55 | //Data Size conversion
56 | u16 u8_to_u16(u8 *value, u8 endianness);
57 | u32 u8_to_u32(u8 *value, u8 endianness);
58 | u64 u8_to_u64(u8 *value, u8 endianness);
59 | int u16_to_u8(u8 *out_value, u16 in_value, u8 endianness);
60 | int u32_to_u8(u8 *out_value, u32 in_value, u8 endianness);
61 | int u64_to_u8(u8 *out_value, u64 in_value, u8 endianness);
62 | //from ctrtool
63 | void memdump(FILE* fout, const char* prefix, const u8* data, u32 size);
64 |
65 |
--------------------------------------------------------------------------------
/iconcache_tool/Makefile:
--------------------------------------------------------------------------------
1 | all:
2 | gcc -std=c99 main.c -o iconcache_tool
--------------------------------------------------------------------------------
/iconcache_tool/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | const unsigned char null_entry[8] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
8 |
9 | void app_title(void);
10 | void help(char *app_name);
11 |
12 | void main(int argc, char *argv[])
13 | {
14 | if(argc != 4){
15 | printf("[!] Bad arguments\n");
16 | help(argv[0]);
17 | return;
18 | }
19 | FILE *cache = fopen(argv[1],"rb");
20 | FILE *cacheD = fopen(argv[2],"rb");
21 |
22 | chdir(argv[3]);
23 |
24 | unsigned char *buffer = malloc(0x36c0);
25 | for(int i = 0; i < 360/*360*/; i++){
26 | memset(buffer,0,0x36c0);
27 | fseek(cache,0x8+(0x10*i),SEEK_SET);
28 | fseek(cacheD,0x0+(0x36c0*i),SEEK_SET);
29 | unsigned char tmp[8];
30 | fread(&tmp,8,1,cache);
31 | if(memcmp(&tmp,null_entry,8) != 0){
32 | char iconname[30];
33 | sprintf(iconname,"%02x%02x%02x%02x%02x%02x%02x%02x.icn",tmp[7],tmp[6],tmp[5],tmp[4],tmp[3],tmp[2],tmp[1],tmp[0]);
34 | fread(buffer,0x36c0,1,cacheD);
35 | FILE *icon = fopen(iconname,"wb");
36 | fwrite(buffer,0x36c0,1,icon);
37 | fclose(icon);
38 | }
39 | }
40 |
41 | fclose(cache);
42 | fclose(cacheD);
43 | printf("Done\n");
44 | }
45 |
46 | void app_title(void)
47 | {
48 | printf("CTR_Toolkit - HomeMenu ICN Cache Tool\n");
49 | printf("Version 1.0 (C) 3DSGuy 2013\n");
50 | }
51 |
52 | void help(char *app_name)
53 | {
54 | app_title();
55 | printf("\nUsage: \n", app_name);
56 | }
--------------------------------------------------------------------------------
/make_banner/README.md:
--------------------------------------------------------------------------------
1 | #### CTR_Toolkit - make_banner - Generates ICN/BNR files ####
2 | #### Version: 2.0 2013 (C) 3DSGuy ####
3 |
4 | ### Usage ###
5 |
6 | Usage: make_banner [options] commands
7 |
8 | COMMANDS Parameters Explanation
9 | -h, --help Print this help.
10 | --makeicn File-out Generate an ICN file.
11 | --makebnr File-out Generate a BNR file.
12 | --readicn File-in Parse an ICN file.
13 | OPTIONS Possible Values Explanation
14 | -v, --verbose Enable verbose output.
15 | -b, --bsf File-in BSF file.
16 | -s, --small_icon File-in 'Small Icon' file.
17 | -l, --large_icon File-in 'Large Icon' file.
18 | -g, --cbmd File-in CBMD file.
19 | -a, --cwav File-in (B)CWAV file.
20 |
21 | Examples:
22 |
23 | Generating a BNR:
24 | makebanner --cbmd project.cbmd --cwav project.cwav --makebnr project.bnr
25 | or
26 | makebanner -g project.cbmd -a project.cwav --makebnr project.bnr
27 |
28 | Generating an ICN:
29 | makebanner --bsf project.bsf --small_icon 24x24.ctpk --large_icon 48x48.ctpk --makeicn project.icn
30 | or
31 | makebanner -b project.bsf -s 24x24.ctpk -l 48x48.ctpk --makeicn project.icn
32 |
33 | Checking/Reading an ICN:
34 | makebanner --readicn project.icn
35 |
36 | ### Creating Input Files ###
37 |
38 | Check the Banner Specification File (.BSF) comments for customising the BSF file.(The BSF file is a YAML file, which can be viewed and edited
39 | in a text editor.
40 |
41 | Generating .ctpk/.cwav/.cbmd TODO
42 |
43 | Sample Input files can be downloaded here: https://dl.dropbox.com/u/60710927/CTR/make_banner/SampleFiles.7z
44 |
45 | ### Credits ###
46 | A big thanks to s3my0n whom this program would not exist.
47 |
48 | ### Change Log ###
49 |
50 | Version 2.0:
51 | * Added new language (Traditional Chinese)
52 | * Can now specify EULA Version
53 | * Sets region lock correctly now
54 | * BSF format has changed slighly, re-download sample set for new version
55 |
56 | Version 1.2:
57 | * Refactored main.c (added main.h),
58 | * input syntax has changed
59 | * can perform multiple commands at once(makeicn, makebnr and readicn)
60 | * added experimental verbose mode(might remove later, as not really necissary)
61 |
62 | Version 1.1:
63 | * Added '--readicn' mode which allows checking of generated ICN files
64 | * Small bug fixes
65 |
66 | Version 1.0:
67 | * Initial Public release
68 | * Supports generating valid ICN / BNR files for the 3DS
--------------------------------------------------------------------------------
/make_banner/bnr.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright 2013 3DSGuy
3 |
4 | This file is part of make_banner.
5 |
6 | make_banner is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | make_banner is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with make_banner. If not, see .
18 | **/
19 | #include "types.h"
20 |
21 | #define CBMD_MAGIC 0x444D4243
22 | #define CWAV_MAGIC 0x56415743
23 |
24 | #define READ_FAIL 1
25 | #define WRITE_FAIL 2
26 |
27 | #define SIZE_OFFSET 0x84
28 |
29 | typedef struct
30 | {
31 | DWORD magic;
32 | WORD endianness;
33 | u8 unused[6];
34 | DWORD file_size;
35 | } __attribute__((__packed__))
36 | CWAV_HEADER;
37 |
38 | typedef struct
39 | {
40 | DWORD magic;
41 | u8 unused[0x80];
42 | DWORD file_size;
43 | } __attribute__((__packed__))
44 | CBMD_HEADER;
45 |
46 | typedef struct
47 | {
48 | int RESULT_CODE;
49 | u8 verbose_bool;
50 |
51 | //INPUT
52 | FILE *cbmd; //Banner Graphics File
53 | CBMD_HEADER cbmd_header;
54 | FILE *cwav; //Banner Audio File
55 | CWAV_HEADER cwav_header;
56 |
57 | //OUTPUT
58 | FILE *output; //Output .BNR file
59 | } __attribute__((__packed__))
60 | BNR_CONTEXT; //Context for BNR creation
61 |
62 | //Prototypes
63 | int bnr_main(BNR_CONTEXT bnr);
64 | DWORD size_u8toDWORD(u8 *size);
--------------------------------------------------------------------------------
/make_banner/main.h:
--------------------------------------------------------------------------------
1 | #include "types.h"
2 | /**
3 | Copyright 2013 3DSGuy
4 |
5 | This file is part of make_banner.
6 |
7 | make_banner is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | make_banner is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with make_banner. If not, see .
19 | **/
20 | #include "bnr.h"
21 | #include "icn.h"
22 |
23 | #define SUCCESS 0
24 | #define FAIL 1
25 |
26 | #define ARGC_FAIL 1
27 | #define ARGV_FAIL 2
28 |
29 | #define FILE_OPEN_FAIL 1
30 | #define FILE_CREATE_FAIL 2
31 |
32 | typedef struct
33 | {
34 | //Command Flags
35 | u8 make_icn;
36 | u8 make_bnr;
37 | u8 read_icn;
38 | u8 command_point;
39 | u8 verbose_bool;
40 |
41 | //Input
42 | //Make ICN
43 | u8 *input_bsf;
44 | u8 *input_small_icon;
45 | u8 *input_large_icon;
46 | u8 *output_icn;
47 |
48 | //Make BNR
49 | u8 *input_cbmd;
50 | u8 *input_cwav;
51 | u8 *output_bnr;
52 |
53 | //Read ICN
54 | u8 *input_icn;
55 | } __attribute__((__packed__))
56 | INPUT_CONTEXT;
--------------------------------------------------------------------------------
/make_banner/makefile:
--------------------------------------------------------------------------------
1 | all:
2 | gcc -std=c99 main.c icn.c bnr.c utils.c yaml.c -o bin/make_banner
3 |
4 | banner:
5 | bin\make_banner -v -g test\graphics.cbmd -a test\audio.cwav --makebnr bin\test.bnr
6 |
7 | icon:
8 | bin\make_banner -v -b test\test.bsf -s test\small_icon.ctpk -l test\large_icon.ctpk --makeicn bin\out.icn
9 |
--------------------------------------------------------------------------------
/make_banner/types.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright 2013 3DSGuy
3 |
4 | This file is part of make_banner.
5 |
6 | make_banner is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | make_banner is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with make_banner. If not, see .
18 | **/
19 | #include
20 | #include
21 |
22 | #define TRUE 1
23 | #define FALSE 0
24 |
25 | typedef unsigned char u8;
26 | typedef unsigned short u16;
27 | typedef unsigned int u32;
28 | typedef unsigned long long u64;
29 |
30 | typedef signed char s8;
31 | typedef signed short s16;
32 | typedef signed int s32;
33 | typedef signed long long s64;
34 |
35 | typedef uint32_t DWORD;
36 | typedef uint16_t WORD;
37 |
--------------------------------------------------------------------------------
/make_banner/utils.h:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright 2013 3DSGuy
3 |
4 | This file is part of make_banner.
5 |
6 | make_banner is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | make_banner is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with make_banner. If not, see .
18 | **/
19 | #include "yaml.h"
20 |
21 | #define BIG_ENDIAN 0
22 | #define LITTLE_ENDIAN 1
23 |
24 | #define HEX 16
25 | #define DEC 10
26 |
27 | void resolve_flag(unsigned char flag, unsigned char *flag_bool);
28 |
29 | void char_to_int_array(unsigned char destination[], unsigned char source[], int size, int endianness, int base);
30 | void endian_strcpy(unsigned char destination[], unsigned char source[], int size, int endianness);
31 |
32 | //like fgets(), except tabs are ignored
33 | char *search(char s[], int n, FILE *file);
34 |
35 | //Error printing functions
36 | void value_find_fail(const char key[]);
37 | void key_find_fail(const char category[]);
38 |
--------------------------------------------------------------------------------
/make_banner/yaml.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/make_banner/yaml.c
--------------------------------------------------------------------------------
/make_banner/yaml.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ihaveamac/ctr_toolkit/607297af00fb7eebfff4187b9ce04cd116a1a56f/make_banner/yaml.h
--------------------------------------------------------------------------------
/make_cdn_cia/Makefile:
--------------------------------------------------------------------------------
1 | all:
2 | gcc -std=c99 main.c cia.c utils.c -o bin/make_cdn_cia
--------------------------------------------------------------------------------
/make_cdn_cia/README.md:
--------------------------------------------------------------------------------
1 | #### CTR_Toolkit - make_cdn_cia - Generates CIA files from CDN Content ####
2 | #### Version: 1.0 2013 (C) 3DSGuy ####
3 |
4 | ### Usage ###
5 |
6 | Usage: make_cdn_cia