diff --git a/NXTools.sln b/NXTools.sln
index d0b43e6..93850f1 100644
--- a/NXTools.sln
+++ b/NXTools.sln
@@ -8,6 +8,10 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcrypto", "lib\libcrypto\crypto.vcxproj", "{6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libnx", "lib\libnx\nx.vcxproj", "{91BA9E79-8242-4F7D-B997-0DFEC95EA22B}"
+ ProjectSection(ProjectDependencies) = postProject
+ {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1} = {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}
+ {4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B} = {4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B}
+ EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{170B4A09-1B67-4A62-93AB-116EBCFF4A8C}"
ProjectSection(SolutionItems) = preProject
@@ -22,13 +26,14 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8F6C846D-35E2-47FD-AF42-7A3FD036346E}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
+ KEYS.md = KEYS.md
makefile = makefile
README.md = README.md
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libes", "lib\libes\es.vcxproj", "{7BE99936-0D40-410D-944B-4513C2EFF8DC}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tiktool", "programs\tiktool\tiktool.vcxproj", "{2200B834-F15A-4C6E-9DDB-6012B9A5C246}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nstool", "programs\nstool\nstool.vcxproj", "{AF09FA96-4463-417D-8FE6-526063F41349}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -62,30 +67,6 @@ Global
{91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Release|x64.Build.0 = Release|x64
{91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Release|x86.ActiveCfg = Release|Win32
{91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Release|x86.Build.0 = Release|Win32
- {7DA88C6F-4470-495D-995A-4F633F3370C1}.Debug|x64.ActiveCfg = Debug|x64
- {7DA88C6F-4470-495D-995A-4F633F3370C1}.Debug|x64.Build.0 = Debug|x64
- {7DA88C6F-4470-495D-995A-4F633F3370C1}.Debug|x86.ActiveCfg = Debug|Win32
- {7DA88C6F-4470-495D-995A-4F633F3370C1}.Debug|x86.Build.0 = Debug|Win32
- {7DA88C6F-4470-495D-995A-4F633F3370C1}.Release|x64.ActiveCfg = Release|x64
- {7DA88C6F-4470-495D-995A-4F633F3370C1}.Release|x64.Build.0 = Release|x64
- {7DA88C6F-4470-495D-995A-4F633F3370C1}.Release|x86.ActiveCfg = Release|Win32
- {7DA88C6F-4470-495D-995A-4F633F3370C1}.Release|x86.Build.0 = Release|Win32
- {550C6AC3-EBE0-46CA-AE6C-EEEB59DDF35C}.Debug|x64.ActiveCfg = Debug|x64
- {550C6AC3-EBE0-46CA-AE6C-EEEB59DDF35C}.Debug|x64.Build.0 = Debug|x64
- {550C6AC3-EBE0-46CA-AE6C-EEEB59DDF35C}.Debug|x86.ActiveCfg = Debug|Win32
- {550C6AC3-EBE0-46CA-AE6C-EEEB59DDF35C}.Debug|x86.Build.0 = Debug|Win32
- {550C6AC3-EBE0-46CA-AE6C-EEEB59DDF35C}.Release|x64.ActiveCfg = Release|x64
- {550C6AC3-EBE0-46CA-AE6C-EEEB59DDF35C}.Release|x64.Build.0 = Release|x64
- {550C6AC3-EBE0-46CA-AE6C-EEEB59DDF35C}.Release|x86.ActiveCfg = Release|Win32
- {550C6AC3-EBE0-46CA-AE6C-EEEB59DDF35C}.Release|x86.Build.0 = Release|Win32
- {BC2F2D07-BAB3-469C-9C25-8CC54F96F7AB}.Debug|x64.ActiveCfg = Debug|x64
- {BC2F2D07-BAB3-469C-9C25-8CC54F96F7AB}.Debug|x64.Build.0 = Debug|x64
- {BC2F2D07-BAB3-469C-9C25-8CC54F96F7AB}.Debug|x86.ActiveCfg = Debug|Win32
- {BC2F2D07-BAB3-469C-9C25-8CC54F96F7AB}.Debug|x86.Build.0 = Debug|Win32
- {BC2F2D07-BAB3-469C-9C25-8CC54F96F7AB}.Release|x64.ActiveCfg = Release|x64
- {BC2F2D07-BAB3-469C-9C25-8CC54F96F7AB}.Release|x64.Build.0 = Release|x64
- {BC2F2D07-BAB3-469C-9C25-8CC54F96F7AB}.Release|x86.ActiveCfg = Release|Win32
- {BC2F2D07-BAB3-469C-9C25-8CC54F96F7AB}.Release|x86.Build.0 = Release|Win32
{7BE99936-0D40-410D-944B-4513C2EFF8DC}.Debug|x64.ActiveCfg = Debug|x64
{7BE99936-0D40-410D-944B-4513C2EFF8DC}.Debug|x64.Build.0 = Debug|x64
{7BE99936-0D40-410D-944B-4513C2EFF8DC}.Debug|x86.ActiveCfg = Debug|Win32
@@ -94,22 +75,14 @@ Global
{7BE99936-0D40-410D-944B-4513C2EFF8DC}.Release|x64.Build.0 = Release|x64
{7BE99936-0D40-410D-944B-4513C2EFF8DC}.Release|x86.ActiveCfg = Release|Win32
{7BE99936-0D40-410D-944B-4513C2EFF8DC}.Release|x86.Build.0 = Release|Win32
- {2200B834-F15A-4C6E-9DDB-6012B9A5C246}.Debug|x64.ActiveCfg = Debug|x64
- {2200B834-F15A-4C6E-9DDB-6012B9A5C246}.Debug|x64.Build.0 = Debug|x64
- {2200B834-F15A-4C6E-9DDB-6012B9A5C246}.Debug|x86.ActiveCfg = Debug|Win32
- {2200B834-F15A-4C6E-9DDB-6012B9A5C246}.Debug|x86.Build.0 = Debug|Win32
- {2200B834-F15A-4C6E-9DDB-6012B9A5C246}.Release|x64.ActiveCfg = Release|x64
- {2200B834-F15A-4C6E-9DDB-6012B9A5C246}.Release|x64.Build.0 = Release|x64
- {2200B834-F15A-4C6E-9DDB-6012B9A5C246}.Release|x86.ActiveCfg = Release|Win32
- {2200B834-F15A-4C6E-9DDB-6012B9A5C246}.Release|x86.Build.0 = Release|Win32
- {007FF616-7B99-4CB3-84CD-39C47F64FC7E}.Debug|x64.ActiveCfg = Debug|x64
- {007FF616-7B99-4CB3-84CD-39C47F64FC7E}.Debug|x64.Build.0 = Debug|x64
- {007FF616-7B99-4CB3-84CD-39C47F64FC7E}.Debug|x86.ActiveCfg = Debug|Win32
- {007FF616-7B99-4CB3-84CD-39C47F64FC7E}.Debug|x86.Build.0 = Debug|Win32
- {007FF616-7B99-4CB3-84CD-39C47F64FC7E}.Release|x64.ActiveCfg = Release|x64
- {007FF616-7B99-4CB3-84CD-39C47F64FC7E}.Release|x64.Build.0 = Release|x64
- {007FF616-7B99-4CB3-84CD-39C47F64FC7E}.Release|x86.ActiveCfg = Release|Win32
- {007FF616-7B99-4CB3-84CD-39C47F64FC7E}.Release|x86.Build.0 = Release|Win32
+ {AF09FA96-4463-417D-8FE6-526063F41349}.Debug|x64.ActiveCfg = Debug|x64
+ {AF09FA96-4463-417D-8FE6-526063F41349}.Debug|x64.Build.0 = Debug|x64
+ {AF09FA96-4463-417D-8FE6-526063F41349}.Debug|x86.ActiveCfg = Debug|Win32
+ {AF09FA96-4463-417D-8FE6-526063F41349}.Debug|x86.Build.0 = Debug|Win32
+ {AF09FA96-4463-417D-8FE6-526063F41349}.Release|x64.ActiveCfg = Release|x64
+ {AF09FA96-4463-417D-8FE6-526063F41349}.Release|x64.Build.0 = Release|x64
+ {AF09FA96-4463-417D-8FE6-526063F41349}.Release|x86.ActiveCfg = Release|Win32
+ {AF09FA96-4463-417D-8FE6-526063F41349}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -118,12 +91,8 @@ Global
{4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C}
{6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C}
{91BA9E79-8242-4F7D-B997-0DFEC95EA22B} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C}
- {7DA88C6F-4470-495D-995A-4F633F3370C1} = {E0863FCC-8E72-490D-BE1B-458F12CA8298}
- {550C6AC3-EBE0-46CA-AE6C-EEEB59DDF35C} = {E0863FCC-8E72-490D-BE1B-458F12CA8298}
- {BC2F2D07-BAB3-469C-9C25-8CC54F96F7AB} = {E0863FCC-8E72-490D-BE1B-458F12CA8298}
{7BE99936-0D40-410D-944B-4513C2EFF8DC} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C}
- {2200B834-F15A-4C6E-9DDB-6012B9A5C246} = {E0863FCC-8E72-490D-BE1B-458F12CA8298}
- {007FF616-7B99-4CB3-84CD-39C47F64FC7E} = {E0863FCC-8E72-490D-BE1B-458F12CA8298}
+ {AF09FA96-4463-417D-8FE6-526063F41349} = {E0863FCC-8E72-490D-BE1B-458F12CA8298}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {07DCCACC-D10D-47C9-85AE-FB9C54DB7D62}
diff --git a/README.md b/README.md
index ee56681..7440a24 100644
--- a/README.md
+++ b/README.md
@@ -7,8 +7,6 @@ Tools & Libraries for NX (Nintendo Switch).
# Tools
* __nstool__ - read *.npdm, read/extract PartitionFS (PFS0|HFS0) blobs (including *.nsp), read *.xci
-* __ncatool__ - read/extract *.nca
-* __tiktool__ - read ticket fields.
# Libraries
@@ -17,6 +15,12 @@ Tools & Libraries for NX (Nintendo Switch).
* __libes__ - Handling of (NS relevant) eShop file type processing. (eTickets, etc)
* __libnx__ - Handling of NS file types
+# Building
+
+On MacOS/Linux/WSL run `make`.
+
+For Windows, Visual Studio 2017 is supported.
+
# External Keys
Programs/libraries don't embed any keys that are copyright protected. However keys can be imported via a keyset file.
diff --git a/lib/libcrypto/crypto.vcxproj b/lib/libcrypto/crypto.vcxproj
index b953c49..e14120d 100644
--- a/lib/libcrypto/crypto.vcxproj
+++ b/lib/libcrypto/crypto.vcxproj
@@ -129,6 +129,8 @@
+
+
@@ -139,6 +141,8 @@
+
+
diff --git a/lib/libcrypto/crypto.vcxproj.filters b/lib/libcrypto/crypto.vcxproj.filters
index 80b23f4..1447c9e 100644
--- a/lib/libcrypto/crypto.vcxproj.filters
+++ b/lib/libcrypto/crypto.vcxproj.filters
@@ -60,6 +60,12 @@
Header Files\polarssl
+
+ Header Files\polarssl
+
+
+ Header Files\polarssl
+
@@ -92,6 +98,12 @@
Source Files\polarssl
+
+ Source Files\polarssl
+
+
+ Source Files\polarssl
+
diff --git a/lib/libcrypto/crypto.vcxproj.user b/lib/libcrypto/crypto.vcxproj.user
new file mode 100644
index 0000000..be25078
--- /dev/null
+++ b/lib/libcrypto/crypto.vcxproj.user
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib/libfnd/fnd.vcxproj b/lib/libfnd/fnd.vcxproj
index 1e8d593..90edb79 100644
--- a/lib/libfnd/fnd.vcxproj
+++ b/lib/libfnd/fnd.vcxproj
@@ -124,10 +124,13 @@
+
+
+
@@ -136,6 +139,8 @@
+
+
diff --git a/lib/libfnd/fnd.vcxproj.filters b/lib/libfnd/fnd.vcxproj.filters
index 1b156a3..36b0ec3 100644
--- a/lib/libfnd/fnd.vcxproj.filters
+++ b/lib/libfnd/fnd.vcxproj.filters
@@ -48,6 +48,15 @@
Header Files
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
@@ -65,6 +74,12 @@
Source Files
+
+ Source Files
+
+
+ Source Files
+
diff --git a/lib/libfnd/fnd.vcxproj.user b/lib/libfnd/fnd.vcxproj.user
new file mode 100644
index 0000000..be25078
--- /dev/null
+++ b/lib/libfnd/fnd.vcxproj.user
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib/libfnd/include/fnd/io.h b/lib/libfnd/include/fnd/io.h
index 78c1cc0..df31808 100644
--- a/lib/libfnd/include/fnd/io.h
+++ b/lib/libfnd/include/fnd/io.h
@@ -12,5 +12,7 @@ namespace fnd
void writeFile(const std::string& path, const MemoryBlob& blob);
void writeFile(const std::string& path, const byte_t* data, size_t len);
void makeDirectory(const std::string& path);
+ void getEnvironVar(std::string& var, const std::string& key);
+ void makePath(std::string& out, const std::vector& elements);
}
}
diff --git a/lib/libfnd/source/io.cpp b/lib/libfnd/source/io.cpp
index 34f9dce..34b9210 100644
--- a/lib/libfnd/source/io.cpp
+++ b/lib/libfnd/source/io.cpp
@@ -1,7 +1,9 @@
#include
+#include
#include
#ifdef _WIN32
#include
+#include
#else
#include
#endif
@@ -24,54 +26,53 @@ size_t io::getFileSize(const std::string& path)
void io::readFile(const std::string& path, MemoryBlob & blob)
{
- FILE* fp;
- size_t filesz, filepos;
-
- if ((fp = fopen(path.c_str(), "rb")) == NULL)
+ fnd::SimpleFile file;
+ try
{
- throw Exception(kModuleName, "Failed to open \"" + path + "\"");
+ file.open(path, file.Read);
+ }
+ catch (const fnd::Exception&)
+ {
+ throw fnd::Exception(kModuleName, "Failed to open \"" + path + "\": does not exist");
}
- fseek(fp, 0, SEEK_END);
- filesz = ftell(fp);
- rewind(fp);
+ size_t filesz, filepos;
+ filesz = file.size();
+
try {
blob.alloc(filesz);
}
catch (const fnd::Exception& e)
{
- fclose(fp);
throw fnd::Exception(kModuleName, "Failed to allocate memory for file: " + std::string(e.what()));
}
for (filepos = 0; filesz > kBlockSize; filesz -= kBlockSize, filepos += kBlockSize)
{
- fread(blob.getBytes() + filepos, 1, kBlockSize, fp);
+ file.read(blob.getBytes() + filepos, kBlockSize);
}
if (filesz)
{
- fread(blob.getBytes() + filepos, 1, filesz, fp);
+ file.read(blob.getBytes() + filepos, filesz);
}
-
- fclose(fp);
}
void fnd::io::readFile(const std::string& path, size_t offset, size_t len, MemoryBlob& blob)
{
- FILE* fp;
- size_t filesz, filepos;
-
- if ((fp = fopen(path.c_str(), "rb")) == NULL)
+ fnd::SimpleFile file;
+ try
{
- throw Exception(kModuleName, "Failed to open \"" + path + "\": does not exist");
+ file.open(path, file.Read);
+ } catch (const fnd::Exception&)
+ {
+ throw fnd::Exception(kModuleName, "Failed to open \"" + path + "\": does not exist");
}
- fseek(fp, 0, SEEK_END);
- filesz = ftell(fp);
- rewind(fp);
- fseek(fp, offset, SEEK_SET);
+ size_t filesz, filepos;
+ filesz = file.size();
+ file.seek(offset);
if (filesz < len || filesz < offset || filesz < (offset + len))
{
@@ -80,24 +81,21 @@ void fnd::io::readFile(const std::string& path, size_t offset, size_t len, Memor
try
{
- blob.alloc(len);
+ blob.alloc(filesz);
} catch (const fnd::Exception& e)
{
- fclose(fp);
throw fnd::Exception(kModuleName, "Failed to allocate memory for file: " + std::string(e.what()));
}
- for (filepos = 0; len > kBlockSize; len -= kBlockSize, filepos += kBlockSize)
+ for (filepos = 0; filesz > kBlockSize; filesz -= kBlockSize, filepos += kBlockSize)
{
- fread(blob.getBytes() + filepos, 1, kBlockSize, fp);
+ file.read(blob.getBytes() + filepos, kBlockSize);
}
- if (len)
+ if (filesz)
{
- fread(blob.getBytes() + filepos, 1, len, fp);
+ file.read(blob.getBytes() + filepos, filesz);
}
-
- fclose(fp);
}
void io::writeFile(const std::string& path, const MemoryBlob & blob)
@@ -107,28 +105,29 @@ void io::writeFile(const std::string& path, const MemoryBlob & blob)
void io::writeFile(const std::string & path, const byte_t * data, size_t len)
{
- FILE* fp;
- size_t filesz, filepos;
-
- if ((fp = fopen(path.c_str(), "wb")) == NULL)
+ fnd::SimpleFile file;
+ try
{
- throw Exception(kModuleName, "Failed to open \"" + path + "\"");
+ file.open(path, file.Create);
+ } catch (const fnd::Exception&)
+ {
+ throw fnd::Exception(kModuleName, "Failed to open \"" + path + "\": does not exist");
}
+ size_t filesz, filepos;
+
filesz = len;
for (filepos = 0; filesz > kBlockSize; filesz -= kBlockSize, filepos += kBlockSize)
{
- fwrite(data + filepos, 1, kBlockSize, fp);
+ file.write(data + filepos, kBlockSize);
}
if (filesz)
{
- fwrite(data + filepos, 1, filesz, fp);
+ file.write(data + filepos, filesz);
}
-
- fclose(fp);
}
void io::makeDirectory(const std::string& path)
@@ -138,4 +137,46 @@ void io::makeDirectory(const std::string& path)
#else
mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
#endif
-}
\ No newline at end of file
+}
+
+void fnd::io::getEnvironVar(std::string & var, const std::string & key)
+{
+#ifdef _WIN32
+ char* var_tmp = nullptr;
+ size_t var_len = 0;
+ _dupenv_s(&var_tmp, &var_len, key.c_str());
+
+ if (var_len > 0)
+ {
+ var = std::string(var_tmp);
+ free(var_tmp);
+ }
+#else
+ char* var_tmp = nullptr;
+
+ var_tmp = getenv(key.c_str());
+
+ if (var_tmp != nullptr)
+ {
+ var = std::string(var_tmp);
+ }
+#endif
+}
+
+void fnd::io::makePath(std::string & out, const std::vector& elements)
+{
+ out.clear();
+ out = "";
+ for (size_t i = 0; i < elements.size(); i++)
+ {
+ if (i > 0)
+ {
+#ifdef _WIN32
+ out += "\\";
+#else
+ out += "/";
+#endif
+ }
+ out += elements[i];
+ }
+}
diff --git a/lib/libnx/include/nx/NXCrypto.h b/lib/libnx/include/nx/NXCrypto.h
deleted file mode 100644
index a1ea999..0000000
--- a/lib/libnx/include/nx/NXCrypto.h
+++ /dev/null
@@ -1,159 +0,0 @@
-#pragma once
-
-
-// AES
-namespace crypto
-{
-
- /*
- Keys mentioned in Content Archive Authoring library
- private RsaKey m_NcaHeader1SignKey;
- private RsaKey m_AcidSignKey;
- private RsaKey m_NrrCertificateSignKey;
- private AesKey m_ProdKeyAreaEncryptionKey;
- private AesKey m_ProdNcaHeaderEncryptionKek;
- private RsaKey m_ProdXciHeaderSignKey;
- private AesKey m_ProdXciInitialDataEncryptionKey;
- private AesKey m_ProdTitleKeyGenarateKey;
- private AesKey m_ProdETicketCommonKey;
- private RsaKey m_ProdETicketSignKey;
- */
- namespace aes
- {
-
- /*
- public static AesKey GetNcaExternalContentKey(IHashCalculator hashCalculator, ulong titleId)
- {
- Trace.Assert(hashCalculator != null, "IHashCalculator is null.");
- byte[] array = BitConverter.GetBytes(titleId).Reverse().ToArray();
- byte[] numArray = new byte[hashCalculator.HashSize];
- hashCalculator.CalculateHash(array, 0, (int)array.Length, numArray, 0);
- return new AesKey(((IEnumerable)numArray).Where((byte name, int index) => index < 16).ToArray());
- }
- */
- namespace nx
- {
- enum Aes128KeyId
- {
- NcaContentKey,
- NcaHeader,
- XciInitialData,
- XciHeader,
- ETicketCommonKey
- };
-
- enum HmacSha256KeyId
- {
- TitleKeyGenarateKey
- };
-
- namespace dev
- {
- // aes128-xts keys (seem to use 512 block sizes, aka 0x200 blocks)
- byte_t nca_body_key[2][16] =
- {
- { 0xE5, 0x64, 0xDB, 0xFE, 0x52, 0x93, 0x3A, 0x65, 0x3C, 0x8B, 0x5E, 0xF8, 0x2C, 0x9D, 0xF4, 0xB5 },
- { 0x60, 0x7B, 0x77, 0x3E, 0x31, 0xE9, 0x6A, 0x8F, 0x8E, 0x44, 0x5C, 0x98, 0x71, 0xC0, 0x57, 0xDB },
- };
-
- byte_t nca_header_key[2][16] =
- {
- { 0xCB, 0x9A, 0x93, 0x9F, 0x82, 0x72, 0x54, 0x4A, 0x74, 0x5D, 0x28, 0x46, 0x9D, 0xCC, 0x38, 0x12 },
- { 0x06, 0x31, 0x27, 0x06, 0xAE, 0x62, 0x56, 0x8C, 0x5B, 0x7E, 0xE6, 0x9F, 0x7E, 0x01, 0x02, 0x24 },
- };
-
- // aeskey, related to m_KeyAreaEncryptionKeyList (first in list?)
- byte_t key_area_encryption_key_0[0x10] = { 0x3A, 0x7C, 0x3E, 0x38, 0x4A, 0x8F, 0x22, 0xFF, 0x4B, 0x21, 0x57, 0x19, 0xB7, 0x81, 0xAD, 0x0C };
-
- byte_t titlekey_generate_key[0x20] = { 39, 111, 56, 188, 68, 106, 241, 86, 31, 44, 90, 111, 116, 32, 93, 197, 25, 181, 59, 188, 178, 159, 211, 175, 212, 178, 162, 4, 28, 152, 117, 126 };
-
- // aes128-cbc keys
- byte_t xci_header_key[16] = { 0x01, 0xC5, 0x8F, 0xE7, 0x00, 0x2D, 0x13, 0x5A, 0xB2, 0x9A, 0x3F, 0x69, 0x33, 0x95, 0x74, 0xB1 };
- byte_t eticket_common_key[16] = { 0x55, 0xA3, 0xF8, 0x72, 0xBD, 0xC8, 0x0C, 0x55, 0x5A, 0x65, 0x43, 0x81, 0x13, 0x9E, 0x15, 0x3B }; // lol this 3ds dev common key
-
- byte_t wii_sd_key[16] = { 0xAB, 0x01, 0xB9, 0xD8, 0xE1, 0x62, 0x2B, 0x08, 0xAF, 0xBA, 0xD8, 0x4D, 0xBF, 0xC2, 0xA5, 0x5D };
- }
-
- namespace prod
- {
- byte_t master_key[0x20][16] =
- {
- { 0xC2, 0xCA, 0xAF, 0xF0, 0x89, 0xB9, 0xAE, 0xD5, 0x56, 0x94, 0x87, 0x60, 0x55, 0x27, 0x1C, 0x7D },
- { 0x54, 0xE1, 0xB8, 0xE9, 0x99, 0xC2, 0xFD, 0x16, 0xCD, 0x07, 0xB6, 0x61, 0x09, 0xAC, 0xAA, 0xA6 },
- { 0x4F, 0x6B, 0x10, 0xD3, 0x30, 0x72, 0xAF, 0x2F, 0x25, 0x05, 0x62, 0xBF, 0xF0, 0x6B, 0x6D, 0xA3 },
- };
-
- byte_t nca_header_key[2][16] =
- {
- { 0xAE, 0xAA, 0xB1, 0xCA, 0x08, 0xAD, 0xF9, 0xBE, 0xF1, 0x29, 0x91, 0xF3, 0x69, 0xE3, 0xC5, 0x67 },
- { 0xD6, 0x88, 0x1E, 0x4E, 0x4A, 0x6A, 0x47, 0xA5, 0x1F, 0x6E, 0x48, 0x77, 0x06, 0x2D, 0x54, 0x2D }
- };
-
- byte_t xci_header_key[16] = { 0x01, 0xC5, 0x8F, 0xE7, 0x00, 0x2D, 0x13, 0x5A, 0xB2, 0x9A, 0x3F, 0x69, 0x33, 0x95, 0x74, 0xB1 };
- /*
- // encrypted with ProdNcaHeaderEncryptionKek
- byte_t nca_enc_header_key[2][16] =
- {
- { 0x5A, 0x3E, 0xD8, 0x4F, 0xDE, 0xC0, 0xD8, 0x26, 0x31, 0xF7, 0xE2, 0x5D, 0x19, 0x7B, 0xF5, 0xD0 },
- { 0x1C, 0x9B, 0x7B, 0xFA, 0xF6, 0x28, 0x18, 0x3D, 0x71, 0xF6, 0x4D, 0x73, 0xF1, 0x50, 0xB9, 0xD2 }
- };
- */
-
- }
-
-
-
- }
- }
-
- // RSA
- namespace rsa
- {
- namespace nx
- {
- enum Rsa2048PssKeyId // sign/validate
- {
- NcaHeader1, // also reference as "sign key data"
- Acid,
- NrrCertificate
- };
-
- enum Rsa2048Pkcs1KeyId // sign/validate
- {
- XciHeader,
- ETicket // XS00000020 or XS00000021 ident
- };
-
- enum RsaOaepKeyId // encrypt/decrypt
- {
- XciKeyArea
- };
-
- /*
- in regards to etickets
- %llx....string too long.invalid string position.CT..TW..NG..VP..PC..%08X....Contents of ticket at 0x%0*lx:.. Ticket ID = 0x%I64x... Version = %hd... Rights ID..... %02hhx..... Device ID = 0x%I64x... Issuer = %s.... SigType = 0x%0x..... AccountId = 0x%x.. LicenseType = %hhd.... CommonKeyId = %hhd.... PropertyMask = 0x%hx.. Title Key (encrypted and may be personalized):. .... sectTotalSize %d.. sectHdrOffset %d.. nSectHdrs %hd..... nSectHdrEntrySize %hd.....V1 Section Header %d:... sectOffset %d..... nRecords %d... recordSize %d..... sectionSize %d....PERMANENT...SUBSCRIPTION....CONTENT.CONTENT CONSUMPTION.ACCESS TITLE....Unknown.LIMITED RESOURCE.... sectionType %s.... V1 Section Records:... refId ..%02hhx .. refIdAttr %x... limit %x.... offset %x... accessMask:..... .... index %hx... code %hx.... accessTitleId %I64x..... accessTitleMask %I64x... Unknown Record Type %hx............
- */
-
- // unknown key "EncryptionKeyData"
-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0x34, 0xD0, 0xD7, 0xFD, 0xEF, 0x66, 0x92, 0xB3, 0x87, 0x64, 0xD9, 0x76, 0xDA, 0x6E, 0x3A, 0x19, 0x98, 0x1F, 0xBD, 0x1F, 0x25, 0x69, 0x9F, 0x28, 0xE6, 0x9E, 0xB7, 0x38, 0x92, 0x12, 0x16, 0xDE, 0xDA, 0xE2, 0xB9, 0x7E, 0xFA, 0x98, 0x94, 0xF4, 0x9A, 0xDF, 0x2D, 0xC0, 0x99, 0x83, 0x61, 0xAD, 0xB8, 0x3E, 0x27, 0x3F, 0x0E, 0xB8, 0x9E, 0x9B, 0x11, 0x78, 0xF1, 0x06, 0x30, 0x5B, 0xCA, 0xF4, 0xEB, 0x72, 0x20, 0xD3, 0x15, 0x15, 0xC0, 0xC7, 0x1A, 0x08, 0xAE, 0x6E, 0xB2, 0x02, 0x43, 0xE9 };
-
- // rsa2048-oaep-sha256 key
- byte_t xci_keyarea_labledigest[0x20] = { 0xB1, 0x7B, 0x5F, 0x65, 0x0E, 0x75, 0x90, 0xED, 0xFE, 0x3A, 0xF0, 0x75, 0x0B, 0x92, 0x05, 0xB3, 0x0E, 0x7D, 0x49, 0x89, 0x24, 0xD8, 0xE3, 0x85, 0xCB, 0x40, 0xE0, 0xE7, 0xF8, 0xDE, 0xF0, 0x77 };
- byte_t xci_keyarea_mod[0x100] = { 0xA6, 0x1A, 0x3F, 0x5E, 0x16, 0x94, 0x4D, 0x5F, 0x88, 0x07, 0x45, 0x92, 0x42, 0x02, 0x5C, 0xF8, 0xF8, 0x01, 0xA6, 0x8F, 0xF0, 0x77, 0x76, 0x06, 0x06, 0x4B, 0x67, 0x02, 0x35, 0x2F, 0xC2, 0xF6, 0xCD, 0x74, 0xBC, 0x57, 0x36, 0xA0, 0x61, 0x1D, 0xD6, 0x66, 0x35, 0x79, 0x6E, 0xB7, 0xFF, 0xC1, 0x05, 0xC6, 0x59, 0xD9, 0x1E, 0xC9, 0xC3, 0x1F, 0x5B, 0x17, 0xA9,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65, 0x82, 0x90, 0x09, 0xA4, 0x74, 0xA2, 0x3F, 0xEE, 0xC7, 0x75, 0x06, 0x29, 0x85 };
-
- }
-
- }
-
-}
diff --git a/lib/libnx/include/nx/npdm.h b/lib/libnx/include/nx/npdm.h
index 94f76ec..20aaa8a 100644
--- a/lib/libnx/include/nx/npdm.h
+++ b/lib/libnx/include/nx/npdm.h
@@ -14,6 +14,7 @@ namespace nx
static const size_t kProductCodeMaxLen = 0x10;
static const uint32_t kMaxPriority = BIT(6) -1 ;
static const size_t kNpdmAlignSize = 0x10;
+ static const uint32_t kDefaultMainThreadStackSize = 4096;
enum InstructionType
{
@@ -32,62 +33,24 @@ namespace nx
struct sNpdmHeader
{
- private:
- byte_t signature_[4]; // be"META"
+ char signature[4];
byte_t reserved_0[8];
- byte_t flags_;
+ byte_t flags;
byte_t reserved_1;
- byte_t main_thread_priority_; // 0-63 inclusive
- byte_t main_thread_cpu_id_;
+ byte_t main_thread_priority;
+ byte_t main_thread_cpu_id;
byte_t reserved_2[8];
- uint32_t version_;
- uint32_t main_thread_stack_size_; // default 4096
- byte_t name_[npdm::kNameMaxLen]; // important
- byte_t product_code_[npdm::kProductCodeMaxLen]; // can be empty
+ le_uint32_t version;
+ le_uint32_t main_thread_stack_size;
+ char name[npdm::kNameMaxLen]; // important
+ char product_code[npdm::kProductCodeMaxLen]; // can be empty
byte_t reserved_3[48];
// Access Control Info
struct sNpdmSection
{
- private:
- uint32_t offset_;
- uint32_t size_;
- public:
- uint32_t offset() const { return le_word(offset_); }
- void set_offset(uint32_t offset) { offset_ = le_word(offset); }
-
- uint32_t size() const { return le_word(size_); }
- void set_size(uint32_t size) { size_ = le_word(size); }
- } aci_, acid_;
- public:
- const char* signature() const { return (const char*)signature_; }
- void set_signature(const char* signature) { memcpy(signature_, signature, 4); }
-
- byte_t flags() const { return flags_; }
- void set_flags(byte_t flags) { flags_ = flags; }
-
- byte_t main_thread_priority() const { return main_thread_priority_; }
- void set_main_thread_priority(byte_t priority) { main_thread_priority_ = priority; }
-
- byte_t main_thread_cpu_id() const { return main_thread_cpu_id_; }
- void set_main_thread_cpu_id(byte_t cpu_id) { main_thread_cpu_id_ = cpu_id; }
-
- uint32_t version() const { return le_word(version_); }
- void set_version(uint32_t version) { version_ = le_word(version); }
-
- uint32_t main_thread_stack_size() const { return le_word(main_thread_stack_size_); }
- void set_main_thread_stack_size(uint32_t size) { main_thread_stack_size_ = le_word(size); }
-
- const char* name() const { return (const char*)name_; }
- void set_name(const char* name) { strncpy((char*)name_, name, npdm::kNameMaxLen); }
-
- const char* product_code() const { return (const char*)product_code_; }
- void set_product_code(const char* product_code) { strncpy((char*)product_code_, product_code, npdm::kProductCodeMaxLen); }
-
- const sNpdmSection& aci() const { return aci_; }
- sNpdmSection& aci() { return aci_; }
-
- const sNpdmSection& acid() const { return acid_; }
- sNpdmSection& acid() { return acid_; }
+ le_uint32_t offset;
+ le_uint32_t size;
+ } aci, acid;
};
#pragma pack(pop)
diff --git a/lib/libnx/nx.vcxproj b/lib/libnx/nx.vcxproj
index e3f0ec2..4f5ca30 100644
--- a/lib/libnx/nx.vcxproj
+++ b/lib/libnx/nx.vcxproj
@@ -19,9 +19,11 @@
+
+
@@ -29,6 +31,7 @@
+
@@ -40,12 +43,15 @@
+
+
+
@@ -53,11 +59,14 @@
+
+
+
@@ -74,6 +83,7 @@
+
@@ -84,6 +94,8 @@
+
+
diff --git a/lib/libnx/nx.vcxproj.filters b/lib/libnx/nx.vcxproj.filters
index 0466216..0c5cd52 100644
--- a/lib/libnx/nx.vcxproj.filters
+++ b/lib/libnx/nx.vcxproj.filters
@@ -117,6 +117,30 @@
Header Files
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
@@ -206,6 +230,18 @@
Source Files
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
diff --git a/lib/libnx/nx.vcxproj.user b/lib/libnx/nx.vcxproj.user
new file mode 100644
index 0000000..be25078
--- /dev/null
+++ b/lib/libnx/nx.vcxproj.user
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib/libnx/source/NpdmHeader.cpp b/lib/libnx/source/NpdmHeader.cpp
index b192f2c..28de4ac 100644
--- a/lib/libnx/source/NpdmHeader.cpp
+++ b/lib/libnx/source/NpdmHeader.cpp
@@ -88,21 +88,21 @@ void nx::NpdmHeader::exportBinary()
mBinaryBlob.alloc(sizeof(sNpdmHeader));
sNpdmHeader* hdr = (sNpdmHeader*)mBinaryBlob.getBytes();
- hdr->set_signature(npdm::kNpdmStructSig.c_str());
+ memcpy(hdr->signature, npdm::kNpdmStructSig.c_str(), 4);
byte_t flag = ((byte_t)(mInstructionType & 1) | (byte_t)((mProcAddressSpaceType & 3) << 1)) & 0xf;
- hdr->set_flags(flag);
- hdr->set_main_thread_priority(mMainThreadPriority);
- hdr->set_main_thread_cpu_id(mMainThreadCpuId);
- hdr->set_version(mVersion);
- hdr->set_main_thread_stack_size(mMainThreadStackSize);
- hdr->set_name(mName.c_str());
- hdr->set_product_code(mProductCode.c_str());
+ hdr->flags = flag;
+ hdr->main_thread_priority = mMainThreadPriority;
+ hdr->main_thread_cpu_id = mMainThreadCpuId;
+ hdr->version = mVersion;
+ hdr->main_thread_stack_size = mMainThreadStackSize;
+ strncpy(hdr->name, mName.c_str(), npdm::kNameMaxLen);
+ strncpy(hdr->product_code, mProductCode.c_str(), npdm::kProductCodeMaxLen);
calculateOffsets();
- hdr->aci().set_offset(mAciPos.offset);
- hdr->aci().set_size(mAciPos.size);
- hdr->acid().set_offset(mAcidPos.offset);
- hdr->acid().set_size(mAcidPos.size);
+ hdr->aci.offset = mAciPos.offset;
+ hdr->aci.size = mAciPos.size;
+ hdr->acid.offset = mAcidPos.offset;
+ hdr->acid.size = mAcidPos.size;
}
void nx::NpdmHeader::importBinary(const byte_t * bytes, size_t len)
@@ -118,32 +118,32 @@ void nx::NpdmHeader::importBinary(const byte_t * bytes, size_t len)
memcpy(mBinaryBlob.getBytes(), bytes, mBinaryBlob.getSize());
sNpdmHeader* hdr = (sNpdmHeader*)mBinaryBlob.getBytes();
- if (memcmp(npdm::kNpdmStructSig.c_str(), hdr->signature(), 4) != 0)
+ if (std::string(hdr->signature, 4) != npdm::kNpdmStructSig)
{
throw fnd::Exception(kModuleName, "NPDM header corrupt");
}
- byte_t flag = hdr->flags() & 0xf;
+ byte_t flag = hdr->flags & 0xf;
mInstructionType = (npdm::InstructionType)(flag & 1);
mProcAddressSpaceType = (npdm::ProcAddrSpaceType)((flag >> 1) & 3);
- mMainThreadPriority = hdr->main_thread_priority();
- mMainThreadCpuId = hdr->main_thread_cpu_id();
- mVersion = hdr->version();
- mMainThreadStackSize = hdr->main_thread_stack_size();
- mName = std::string(hdr->name(), npdm::kNameMaxLen);
+ mMainThreadPriority = hdr->main_thread_priority;
+ mMainThreadCpuId = hdr->main_thread_cpu_id;
+ mVersion = hdr->version.get();
+ mMainThreadStackSize = hdr->main_thread_stack_size.get();
+ mName = std::string(hdr->name, npdm::kNameMaxLen);
if (mName[0] == '\0')
{
mName.clear();
}
- mProductCode = std::string(hdr->product_code(), npdm::kProductCodeMaxLen);
+ mProductCode = std::string(hdr->product_code, npdm::kProductCodeMaxLen);
if (mProductCode[0] == '\0')
{
mProductCode.clear();
}
- mAciPos.offset = hdr->aci().offset();
- mAciPos.size = hdr->aci().size();
- mAcidPos.offset = hdr->acid().offset();
- mAcidPos.size = hdr->acid().size();
+ mAciPos.offset = hdr->aci.offset.get();
+ mAciPos.size = hdr->aci.size.get();
+ mAcidPos.offset = hdr->acid.offset.get();
+ mAcidPos.size = hdr->acid.size.get();
}
void nx::NpdmHeader::clear()
diff --git a/programs/makefile b/programs/makefile
index b670a6f..533c7af 100644
--- a/programs/makefile
+++ b/programs/makefile
@@ -1,4 +1,4 @@
-PROGS = nstool ncatool tiktool
+PROGS = nstool
BIN_DIR = "../bin"
main: build
diff --git a/programs/ncatool/makefile b/programs/ncatool/makefile
deleted file mode 100644
index da01e4a..0000000
--- a/programs/ncatool/makefile
+++ /dev/null
@@ -1,47 +0,0 @@
-# Sources
-SRC_DIR = source
-OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c)))
-
-# External dependencies
-DEPENDS = nx crypto fnd
-LIB_DIR = ../../lib
-LIBS = $(foreach dep,$(DEPENDS), -L"$(LIB_DIR)/lib$(dep)" -l$(dep))
-INCS = $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include")
-
-BIN_DIR = bin
-OUTPUT = $(BIN_DIR)/$(shell basename $(CURDIR))
-
-# Compiler Settings
-CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-value
-ifeq ($(OS),Windows_NT)
- # Windows Only Flags/Libs
- CC = x86_64-w64-mingw32-gcc
- CXX = x86_64-w64-mingw32-g++
- CFLAGS += -Wno-unused-but-set-variable
- CXXFLAGS += -Wno-unused-but-set-variable
- LIBS += -static
-else
- UNAME = $(shell uname -s)
- ifeq ($(UNAME), Darwin)
- # MacOS Only Flags/Libs
- CFLAGS += -Wno-unused-private-field
- CXXFLAGS += -Wno-unused-private-field
- LIBS +=
- else
- # *nix Only Flags/Libs
- CFLAGS += -Wno-unused-but-set-variable
- CXXFLAGS += -Wno-unused-but-set-variable
- LIBS +=
- endif
-endif
-
-all: build
-
-rebuild: clean build
-
-build: $(OBJS)
- mkdir -p $(BIN_DIR)
- $(CXX) $(OBJS) $(LIBS) -o $(OUTPUT)
-
-clean:
- rm -rf $(OBJS) $(OUTPUT) $(BIN_DIR)
\ No newline at end of file
diff --git a/programs/ncatool/ncatool.vcxproj.filters b/programs/ncatool/ncatool.vcxproj.filters
deleted file mode 100644
index f033c14..0000000
--- a/programs/ncatool/ncatool.vcxproj.filters
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hh;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
- Source Files
-
-
-
-
-
-
\ No newline at end of file
diff --git a/programs/ncatool/ncatool.vcxproj.user b/programs/ncatool/ncatool.vcxproj.user
deleted file mode 100644
index df9f8d9..0000000
--- a/programs/ncatool/ncatool.vcxproj.user
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
- ..\..\sample\nca\gfx\GfxPrimitiveRenderer.nca
- WindowsLocalDebugger
-
-
- ..\..\sample\nca\gfx\GfxPrimitiveRenderer.nca
- WindowsLocalDebugger
-
-
- ..\..\sample\nca\gfx\GfxPrimitiveRenderer.nca
- WindowsLocalDebugger
-
-
- ..\..\sample\nca\gfx\GfxPrimitiveRenderer.nca
- WindowsLocalDebugger
-
-
\ No newline at end of file
diff --git a/programs/ncatool/source/main.cpp b/programs/ncatool/source/main.cpp
deleted file mode 100644
index efdec4f..0000000
--- a/programs/ncatool/source/main.cpp
+++ /dev/null
@@ -1,237 +0,0 @@
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#ifdef _WIN32
-#include
-#else
-#include
-#endif
-
-std::string kFormatVersionStr[]
-{
- "NCA2",
- "NCA3"
-};
-
-std::string kDistributionTypeStr[]
-{
- "Download",
- "Game Card"
-};
-
-std::string kContentTypeStr[]
-{
- "Program",
- "Meta",
- "Control",
- "Manual",
- "Data"
-};
-
-std::string kEncryptionTypeStr[]
-{
- "Auto",
- "None",
- "AesXts",
- "AesCtr",
- "AesCtrEx"
-};
-
-std::string kHashTypeStr[]
-{
- "Auto",
- "UNKNOWN_1",
- "HierarchicalSha256",
- "HierarchicalIntegrity"
-};
-
-std::string kFormatTypeStr[]
-{
- "RomFs",
- "PartitionFs"
-};
-
-std::string kKaekIndexStr[]
-{
- "Application",
- "Ocean",
- "System"
-};
-
-
-enum KeysetType
-{
- KEYSET_DEV,
- KEYSET_PROD
-};
-
-static const byte_t* kNcaHeaderKey[2][2] =
-{
- { crypto::aes::nx::dev::nca_header_key[0], crypto::aes::nx::dev::nca_header_key[1] },
- { crypto::aes::nx::prod::nca_header_key[0], crypto::aes::nx::prod::nca_header_key[1] }
-};
-
-inline size_t sectorToOffset(size_t sector_index) { return nx::NcaUtils::sectorToOffset(sector_index); }
-
-void initNcaCtr(byte_t ctr[crypto::aes::kAesBlockSize], uint32_t generation)
-{
- memset(ctr, 0, crypto::aes::kAesBlockSize);
- for (size_t i = 0; i < 4; i++)
- {
- ctr[7 - i] = (generation >> i * 8) & 0xff;
- }
-}
-
-void decryptNcaHeader(byte_t header[nx::nca::kHeaderSize], const byte_t* key[2])
-{
- crypto::aes::sAesXts128Key a;
- a.set(key[0],key[1]);
- nx::NcaUtils::decryptNcaHeader(header, header, a);
-}
-
-bool testNcaHeaderKey(const byte_t* header_src, const byte_t* key[2])
-{
- bool validKey = false;
- byte_t header_dec[nx::nca::kSectorSize];
- byte_t tweak[crypto::aes::kAesBlockSize];
-
- // try key
- crypto::aes::AesXtsMakeTweak(tweak, 1);
- crypto::aes::AesXtsDecryptSector(header_src + sectorToOffset(1), nx::nca::kSectorSize, key[0], key[1], tweak, header_dec);
- if (memcmp(header_dec, nx::nca::kNca2Sig.c_str(), 4) == 0 || memcmp(header_dec, nx::nca::kNca3Sig.c_str(), 4) == 0)
- {
- validKey = true;
- }
-
- return validKey;
-}
-
-KeysetType getKeysetFromNcaHeader(const byte_t* header_src)
-{
- for (int i = 0; i < 2; i++)
- {
- if (testNcaHeaderKey(header_src, kNcaHeaderKey[i]) == true)
- {
- return (KeysetType)i;
- }
- }
-
- throw fnd::Exception("Failed to determine NCA header key");
-}
-
-void printHeader(const byte_t* header)
-{
- nx::NcaHeader hdr;
- hdr.importBinary(header + sectorToOffset(1), nx::nca::kSectorSize);
-
- printf("[NCA Header]\n");
- printf(" Format Type: %s\n", kFormatVersionStr[hdr.getFormatVersion()].c_str());
- printf(" Dist. Type: %s\n", kDistributionTypeStr[hdr.getDistributionType()].c_str());
- printf(" Content Type: %s\n", kContentTypeStr[hdr.getContentType()].c_str());
- printf(" Key Generation: %d\n", hdr.getKeyGeneration());
- printf(" Kaek Index: %s (%d)\n", kKaekIndexStr[hdr.getKaekIndex()].c_str(), hdr.getKaekIndex());
- printf(" Size: 0x%" PRIx64 "\n", hdr.getContentSize());
- printf(" ProgID: 0x%016" PRIx64 "\n", hdr.getProgramId());
- printf(" Content Index: %" PRIu32 "\n", hdr.getContentIndex());
- uint32_t ver = hdr.getSdkAddonVersion();
- printf(" SdkAddon Ver.: v%d.%d.%d (v%" PRIu32 ")\n", (ver>>24 & 0xff),(ver>>16 & 0xff),(ver>>8 & 0xff), ver);
- printf(" RightsId: ");
- fnd::SimpleTextOutput::hexDump(hdr.getRightsId(), 0x10);
- printf("\n");
- printf(" Encrypted Key Area:\n");
- crypto::aes::sAes128Key zero_key;
- memset(zero_key.key, 0, sizeof(zero_key));
- for (size_t i = 0; i < hdr.getEncAesKeys().getSize(); i++)
- {
- if (hdr.getEncAesKeys()[i] != zero_key)
- {
- printf(" %2lu: ", i);
- fnd::SimpleTextOutput::hexDump(hdr.getEncAesKeys()[i].key, crypto::aes::kAes128KeySize);
- printf("\n");
- }
- }
-
- printf(" Sections:\n");
- for (size_t i = 0; i < hdr.getPartitions().getSize(); i++)
- {
- const nx::NcaHeader::sPartition& partition = hdr.getPartitions()[i];
- printf(" %lu:\n", i);
- //printf(" Start Blk: %" PRId32 "\n", partition.start_blk);
- //printf(" End Blk: %" PRId32 "\n", partition.end_blk);
- printf(" Index: %d\n", partition.index);
- printf(" Offset: 0x%" PRIx64 "\n", partition.offset);
- printf(" Size: 0x%" PRIx64 "\n", partition.size);
-
-
- size_t sector_index = 2 + partition.index;
-
- crypto::sha::sSha256Hash ncaFsHeaderHash;
- crypto::sha::Sha256(header + sectorToOffset(sector_index), nx::nca::kSectorSize, ncaFsHeaderHash.bytes);
- if (partition.hash.compare(ncaFsHeaderHash) == false)
- {
- throw fnd::Exception("ncatool", "NcaFsHeader has bad sha256 hash");
- }
-
- const nx::sNcaFsHeader* fsHdr = (const nx::sNcaFsHeader*)(header + sectorToOffset(sector_index));
- printf(" FsHeader:\n");
- printf(" Version: 0x%d\n", fsHdr->version.get());
- printf(" Format Type: %s\n", kFormatTypeStr[fsHdr->format_type].c_str());
- printf(" Hash Type: %s\n", kHashTypeStr[fsHdr->hash_type].c_str());
- printf(" Enc. Type: %s\n", kEncryptionTypeStr[fsHdr->encryption_type].c_str());
- if (fsHdr->hash_type == nx::nca::HASH_HIERARCHICAL_INTERGRITY)
- {
- const nx::sIvfcHeader* hash_hdr = (const nx::sIvfcHeader*)(header + sectorToOffset(sector_index) + sizeof(nx::sNcaFsHeader));
- //printf(" HashHierarchicalIntegrity Header:\n");
- //printf(" ")
-
- }
- else if (fsHdr->hash_type == nx::nca::HASH_HIERARCHICAL_SHA256)
- {
- const nx::sHierarchicalSha256Header* hash_hdr = (const nx::sHierarchicalSha256Header*)(header + sectorToOffset(sector_index) + sizeof(nx::sNcaFsHeader));
- printf(" HashHierarchicalSha256 Header:\n");
- printf(" Master Hash: ");
- fnd::SimpleTextOutput::hexDump(hash_hdr->master_hash, 0x20);
- printf(" HashBlockSize: 0x%x\n", hash_hdr->hash_block_size.get());
- printf(" Unknown: 0x%x\n", hash_hdr->unk_0x02.get());
- printf(" HashDataOffset: 0x%" PRIx64 "\n", hash_hdr->hash_data.offset.get());
- printf(" HashDataSize: 0x%" PRIx64 "\n", hash_hdr->hash_data.size.get());
- printf(" HashTargetOffset: 0x%" PRIx64 "\n", hash_hdr->hash_target.offset.get());
- printf(" HashTargetSize: 0x%" PRIx64 "\n", hash_hdr->hash_target.size.get());
-
- }
-
- }
-}
-
-int main(int argc, char** argv)
-{
- if (argc < 2)
- {
- printf("usage: ncatool \n");
- return 1;
- }
-
- try
- {
- fnd::MemoryBlob nca;
- fnd::io::readFile(argv[1], 0x0, nx::nca::kHeaderSize, nca);
-
- KeysetType keyset = getKeysetFromNcaHeader(nca.getBytes());
-
- decryptNcaHeader(nca.getBytes(), kNcaHeaderKey[keyset]);
-
- printHeader(nca.getBytes());
- } catch (const fnd::Exception& e)
- {
- printf("%s\n",e.what());
- }
-
- return 0;
-}
\ No newline at end of file
diff --git a/programs/ncatool/ncatool.vcxproj b/programs/nstool/nstool.vcxproj
similarity index 69%
rename from programs/ncatool/ncatool.vcxproj
rename to programs/nstool/nstool.vcxproj
index 40f4b64..29fdb49 100644
--- a/programs/ncatool/ncatool.vcxproj
+++ b/programs/nstool/nstool.vcxproj
@@ -1,4 +1,4 @@
-
+
@@ -20,36 +20,37 @@
15.0
- {7DA88C6F-4470-495D-995A-4F633F3370C1}
- ncatool
- 10.0.15063.0
+ {AF09FA96-4463-417D-8FE6-526063F41349}
+ Win32Proj
+ nstool
+ 10.0.16299.0
Application
true
v141
- MultiByte
+ Unicode
Application
false
v141
true
- MultiByte
+ Unicode
Application
true
v141
- MultiByte
+ Unicode
Application
false
v141
true
- MultiByte
+ Unicode
@@ -69,61 +70,86 @@
-
-
-
- Level3
- Disabled
- true
- ..\..\lib\libfnd\include;..\..\lib\libcrypto\include;..\..\lib\libnx\include;
- _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
-
-
+
+ true
+
+
+ true
+
+
+ false
+
+
+ false
+
+ NotUsing
Level3
Disabled
true
+ _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
..\..\lib\libfnd\include;..\..\lib\libcrypto\include;..\..\lib\libnx\include;
- _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+
+ Console
+ true
+
+
+
+
+ NotUsing
+ Level3
+ Disabled
+ true
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ ..\..\lib\libfnd\include;..\..\lib\libcrypto\include;..\..\lib\libnx\include;
+
+
+ Console
+ true
+
+ NotUsing
Level3
MaxSpeed
true
true
true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
..\..\lib\libfnd\include;..\..\lib\libcrypto\include;..\..\lib\libnx\include;
- _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+ Console
true
true
+ true
+ NotUsing
Level3
MaxSpeed
true
true
true
+ NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
..\..\lib\libfnd\include;..\..\lib\libcrypto\include;..\..\lib\libnx\include;
- _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+ Console
true
true
+ true
-
-
-
-
-
-
{6adbb60d-dba0-411d-bd2d-a355ef8e0fe1}
@@ -135,6 +161,26 @@
{91ba9e79-8242-4f7d-b997-0dfec95ea22b}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/programs/nstool/nstool.vcxproj.filters b/programs/nstool/nstool.vcxproj.filters
new file mode 100644
index 0000000..c55aaf4
--- /dev/null
+++ b/programs/nstool/nstool.vcxproj.filters
@@ -0,0 +1,63 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+
+
+
+
\ No newline at end of file
diff --git a/programs/nstool/nstool.vcxproj.user b/programs/nstool/nstool.vcxproj.user
new file mode 100644
index 0000000..be25078
--- /dev/null
+++ b/programs/nstool/nstool.vcxproj.user
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/programs/nstool/source/UserSettings.cpp b/programs/nstool/source/UserSettings.cpp
index ea6c1ac..3b5c375 100644
--- a/programs/nstool/source/UserSettings.cpp
+++ b/programs/nstool/source/UserSettings.cpp
@@ -5,6 +5,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -256,16 +257,31 @@ void UserSettings::populateKeyset(sCmdArgs& args)
else
{
// open other resource files in $HOME/.switch/prod.keys (or $HOME/.switch/dev.keys if -d/--dev is set).
- char* home = nullptr;
- if (home == nullptr) home = getenv("HOME");
- if (home == nullptr) home = getenv("USERPROFILE");
- if (home == nullptr) return;
+ std::string home;
+ if (home.empty()) fnd::io::getEnvironVar(home, "HOME");
+ if (home.empty()) fnd::io::getEnvironVar(home, "USERPROFILE");
+ if (home.empty()) return;
const std::string kKeysetNameStr[2] = {"prod.keys", "dev.keys"};
+ const std::string kHomeSwitchDirStr = ".switch";
- std::string keyset_path = std::string(home) + std::string("/") + ".switch" + std::string("/") + kKeysetNameStr[args.devkit_keys.isSet ? *args.devkit_keys : 0];
- //std::cout << keyset_path << std::endl;
- res.processFile(keyset_path);
+ std::vector path_list;
+ path_list.push_back(home);
+ path_list.push_back(kHomeSwitchDirStr);
+ path_list.push_back(kKeysetNameStr[args.devkit_keys.isSet ? *args.devkit_keys : 0]);
+
+ std::string keyset_path;
+ fnd::io::makePath(keyset_path, path_list);
+
+ try
+ {
+ res.processFile(keyset_path);
+ }
+ catch (const fnd::Exception&)
+ {
+ return;
+ }
+
}
// suffix
@@ -552,25 +568,25 @@ FileType UserSettings::determineFileTypeFromFile(const std::string& path)
#define _ASSERT_SIZE(size) (blob.getSize() >= (size))
// test npdm
- if (_ASSERT_SIZE(0x100 + sizeof(nx::sXciHeader)) && memcmp(_QUICK_CAST(nx::sXciHeader, 0x100)->signature, nx::xci::kXciSig.c_str(), 4) == 0)
+ if (_ASSERT_SIZE(sizeof(nx::sXciHeaderPage)) && std::string(_QUICK_CAST(nx::sXciHeaderPage, 0)->header.signature, 4) == nx::xci::kXciSig)
file_type = FILE_XCI;
// test pfs0
- else if (_ASSERT_SIZE(sizeof(nx::sPfsHeader)) && memcmp(_QUICK_CAST(nx::sPfsHeader, 0)->signature, nx::pfs::kPfsSig.c_str(), 4) == 0)
+ else if (_ASSERT_SIZE(sizeof(nx::sPfsHeader)) && std::string(_QUICK_CAST(nx::sPfsHeader, 0)->signature, 4) == nx::pfs::kPfsSig)
file_type = FILE_PARTITIONFS;
// test hfs0
- else if (_ASSERT_SIZE(sizeof(nx::sPfsHeader)) && memcmp(_QUICK_CAST(nx::sPfsHeader, 0)->signature, nx::pfs::kHashedPfsSig.c_str(), 4) == 0)
+ else if (_ASSERT_SIZE(sizeof(nx::sPfsHeader)) && std::string(_QUICK_CAST(nx::sPfsHeader, 0)->signature, 4) == nx::pfs::kHashedPfsSig)
file_type = FILE_PARTITIONFS;
// test romfs
else if (_ASSERT_SIZE(sizeof(nx::sRomfsHeader)) && _QUICK_CAST(nx::sRomfsHeader, 0)->header_size.get() == sizeof(nx::sRomfsHeader) && _QUICK_CAST(nx::sRomfsHeader, 0)->header_size.get() == _QUICK_CAST(nx::sRomfsHeader, 0)->sections[0].offset.get())
file_type = FILE_ROMFS;
// test nca2
- else if (_ASSERT_SIZE(nx::nca::kHeaderSize) && memcmp(nca_header->signature, nx::nca::kNca2Sig.c_str(), 4) == 0)
+ else if (_ASSERT_SIZE(nx::nca::kHeaderSize) && std::string(nca_header->signature, 4) == nx::nca::kNca2Sig)
file_type = FILE_NCA;
// test nca3
- else if (_ASSERT_SIZE(nx::nca::kHeaderSize) && memcmp(nca_header->signature, nx::nca::kNca3Sig.c_str(), 4) == 0)
+ else if (_ASSERT_SIZE(nx::nca::kHeaderSize) && std::string(nca_header->signature, 4) == nx::nca::kNca3Sig)
file_type = FILE_NCA;
// test npdm
- else if (_ASSERT_SIZE(sizeof(nx::sNpdmHeader)) && memcmp(_QUICK_CAST(nx::sNpdmHeader, 0)->signature(), nx::npdm::kNpdmStructSig.c_str(), 4) == 0)
+ else if (_ASSERT_SIZE(sizeof(nx::sNpdmHeader)) && std::string(_QUICK_CAST(nx::sNpdmHeader, 0)->signature, 4) == nx::npdm::kNpdmStructSig)
file_type = FILE_NPDM;
// else unrecognised
else
diff --git a/programs/nstool/source/main.cpp b/programs/nstool/source/main.cpp
index ce6e9c8..4ea7765 100644
--- a/programs/nstool/source/main.cpp
+++ b/programs/nstool/source/main.cpp
@@ -1,4 +1,5 @@
#include
+#include
#include "UserSettings.h"
#include "XciProcess.h"
#include "PfsProcess.h"
diff --git a/programs/tiktool/makefile b/programs/tiktool/makefile
deleted file mode 100644
index 3cfd074..0000000
--- a/programs/tiktool/makefile
+++ /dev/null
@@ -1,47 +0,0 @@
-# Sources
-SRC_DIR = source
-OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c)))
-
-# External dependencies
-DEPENDS = es crypto fnd
-LIB_DIR = ../../lib
-LIBS = $(foreach dep,$(DEPENDS), -L"$(LIB_DIR)/lib$(dep)" -l$(dep))
-INCS = $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include")
-
-BIN_DIR = bin
-OUTPUT = $(BIN_DIR)/$(shell basename $(CURDIR))
-
-# Compiler Settings
-CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-value
-ifeq ($(OS),Windows_NT)
- # Windows Only Flags/Libs
- CC = x86_64-w64-mingw32-gcc
- CXX = x86_64-w64-mingw32-g++
- CFLAGS += -Wno-unused-but-set-variable
- CXXFLAGS += -Wno-unused-but-set-variable
- LIBS += -static
-else
- UNAME = $(shell uname -s)
- ifeq ($(UNAME), Darwin)
- # MacOS Only Flags/Libs
- CFLAGS += -Wno-unused-private-field
- CXXFLAGS += -Wno-unused-private-field
- LIBS +=
- else
- # *nix Only Flags/Libs
- CFLAGS += -Wno-unused-but-set-variable
- CXXFLAGS += -Wno-unused-but-set-variable
- LIBS +=
- endif
-endif
-
-all: build
-
-rebuild: clean build
-
-build: $(OBJS)
- mkdir -p $(BIN_DIR)
- $(CXX) $(OBJS) $(LIBS) -o $(OUTPUT)
-
-clean:
- rm -rf $(OBJS) $(OUTPUT) $(BIN_DIR)
\ No newline at end of file
diff --git a/programs/tiktool/source/main.cpp b/programs/tiktool/source/main.cpp
deleted file mode 100644
index 478d5b2..0000000
--- a/programs/tiktool/source/main.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-const std::string kTitleKeyPersonalisation[2] =
-{
- "Generic (AESCBC)",
- "Personalised (AESCBC/RSA2048)"
-};
-
-const std::string kLicenseType[6] =
-{
- "Permanent",
- "Demo",
- "Trial",
- "Rental",
- "Subscription",
- "Service"
-};
-
-const std::string kBooleanStr[2] =
-{
- "FALSE",
- "TRUE"
-};
-
-const byte_t eticket_common_key[16] = { 0x55, 0xA3, 0xF8, 0x72, 0xBD, 0xC8, 0x0C, 0x55, 0x5A, 0x65, 0x43, 0x81, 0x13, 0x9E, 0x15, 0x3B }; // lol this 3ds dev common key
-
-
-int main(int argc, char** argv)
-{
- if (argc < 2)
- {
- printf("usage: tiktool \n");
- return 1;
- }
-
- try
- {
- fnd::MemoryBlob file;
- fnd::io::readFile(argv[1], file);
-
- // import
- es::ETicketBody_V2 body;
- body.importBinary(file.getBytes() + 0x140, file.getSize() - 0x140);
-
- printf("[ETICKET]\n");
- printf(" Issuer: %s\n", body.getIssuer().c_str());
- printf(" Title Key:\n");
- printf(" EncMode: %s\n", kTitleKeyPersonalisation[body.getTitleKeyEncType()].c_str());
- printf(" CommonKeyId: %02X\n", body.getCommonKeyId());
- printf(" EncData:\n");
- size_t size = body.getTitleKeyEncType() == es::ETicketBody_V2::RSA2048 ? crypto::rsa::kRsa2048Size : crypto::aes::kAes128KeySize;
- fnd::SimpleTextOutput::hexDump(body.getEncTitleKey(), size, 0x10, 6);
-
- if (body.getTitleKeyEncType() == es::ETicketBody_V2::AES128_CBC && body.getCommonKeyId() == 0)
- {
- byte_t iv[crypto::aes::kAesBlockSize];
- byte_t key[crypto::aes::kAes128KeySize];
- memcpy(iv, body.getRightsId(), crypto::aes::kAesBlockSize);
- crypto::aes::AesCbcDecrypt(body.getEncTitleKey(), crypto::aes::kAes128KeySize, eticket_common_key, iv, key);
- size = crypto::aes::kAes128KeySize;
- printf(" TitleKey:\n");
- fnd::SimpleTextOutput::hexDump(key, size, 0x10, 6);
- }
- printf(" Version: v%d\n", body.getTicketVersion());
- printf(" License Type: %s\n", kLicenseType[body.getLicenseType()].c_str());
- printf(" Flags:\n");
- printf(" PreInstall: %s\n", kBooleanStr[body.isPreInstall()].c_str());
- printf(" SharedTitle: %s\n", kBooleanStr[body.isSharedTitle()].c_str());
- printf(" AllContent: %s\n", kBooleanStr[body.allowAllContent()].c_str());
- printf(" Reserved Region:\n");
- fnd::SimpleTextOutput::hexDump(body.getReservedRegion(), 8, 0x10, 4);
- printf(" TicketId: 0x%016" PRIx64 "\n", body.getTicketId());
- printf(" DeviceId: 0x%016" PRIx64 "\n", body.getDeviceId());
- printf(" RightsId: ");
- fnd::SimpleTextOutput::hexDump(body.getRightsId(), 16);
-
- } catch (const fnd::Exception& e)
- {
- printf("%s\n", e.what());
- }
-
- return 0;
-}
\ No newline at end of file
diff --git a/programs/tiktool/tiktool.vcxproj b/programs/tiktool/tiktool.vcxproj
deleted file mode 100644
index 6d2735c..0000000
--- a/programs/tiktool/tiktool.vcxproj
+++ /dev/null
@@ -1,140 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
- Debug
- x64
-
-
- Release
- x64
-
-
-
- {2200B834-F15A-4C6E-9DDB-6012B9A5C246}
- tiktool
- 8.1
-
-
-
- Application
- true
- v141
- MultiByte
-
-
- Application
- false
- v141
- true
- MultiByte
-
-
- Application
- true
- v141
- MultiByte
-
-
- Application
- false
- v141
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Level3
- Disabled
- true
- ..\..\lib\libfnd\include;..\..\lib\libcrypto\include;..\..\lib\libes\include;
- _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
-
-
-
-
- Level3
- Disabled
- true
- ..\..\lib\libfnd\include;..\..\lib\libcrypto\include;..\..\lib\libes\include;
- _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
-
-
-
-
- Level3
- MaxSpeed
- true
- true
- true
- ..\..\lib\libfnd\include;..\..\lib\libcrypto\include;..\..\lib\libes\include;
- _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
-
-
- true
- true
-
-
-
-
- Level3
- MaxSpeed
- true
- true
- true
- ..\..\lib\libfnd\include;..\..\lib\libcrypto\include;..\..\lib\libes\include;
- _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
-
-
- true
- true
-
-
-
-
-
-
-
-
-
-
- {6adbb60d-dba0-411d-bd2d-a355ef8e0fe1}
-
-
- {7be99936-0d40-410d-944b-4513c2eff8dc}
-
-
- {4d27edb9-5110-44fe-8ce2-d46c5ad3c55b}
-
-
-
-
-
-
\ No newline at end of file
diff --git a/programs/tiktool/tiktool.vcxproj.filters b/programs/tiktool/tiktool.vcxproj.filters
deleted file mode 100644
index f033c14..0000000
--- a/programs/tiktool/tiktool.vcxproj.filters
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hh;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
- Source Files
-
-
-
-
-
-
\ No newline at end of file