diff --git a/.gitignore b/.gitignore index a33e3f3..28707b3 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,8 @@ *.log /bin/* /*/*/Debug +/*/*/x64 +/x64 +/Debug +/test /sample diff --git a/NXTools.sln b/NXTools.sln index e7d9026..7e78817 100644 --- a/NXTools.sln +++ b/NXTools.sln @@ -3,11 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfnd", "lib\fnd\fnd.vcxproj", "{4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfnd", "lib\libfnd\fnd.vcxproj", "{4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcrypto", "lib\crypto\crypto.vcxproj", "{6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}" +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\nx\nx.vcxproj", "{91BA9E79-8242-4F7D-B997-0DFEC95EA22B}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libnx", "lib\libnx\nx.vcxproj", "{91BA9E79-8242-4F7D-B997-0DFEC95EA22B}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ncatool", "programs\ncatool\ncatool.vcxproj", "{7DA88C6F-4470-495D-995A-4F633F3370C1}" EndProject @@ -32,7 +32,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pfstool", "programs\pfstool\pfstool.vcxproj", "{BC2F2D07-BAB3-469C-9C25-8CC54F96F7AB}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libes", "lib\es\es.vcxproj", "{7BE99936-0D40-410D-944B-4513C2EFF8DC}" +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}" EndProject diff --git a/lib/crypto/crypto.vcxproj.filters b/lib/crypto/crypto.vcxproj.filters deleted file mode 100644 index b8415e2..0000000 --- a/lib/crypto/crypto.vcxproj.filters +++ /dev/null @@ -1,48 +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 - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - - \ No newline at end of file diff --git a/lib/es/es.vcxproj b/lib/libcrypto/crypto.vcxproj similarity index 61% rename from lib/es/es.vcxproj rename to lib/libcrypto/crypto.vcxproj index 84be88b..b953c49 100644 --- a/lib/es/es.vcxproj +++ b/lib/libcrypto/crypto.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -19,35 +19,36 @@ - {7BE99936-0D40-410D-944B-4513C2EFF8DC} - es - 8.1 - libes + 15.0 + {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1} + crypto + 10.0.15063.0 + libcrypto - Application + StaticLibrary true - v140 + v141 MultiByte - Application + StaticLibrary false - v140 + v141 true MultiByte - Application + StaticLibrary true - v140 + v141 MultiByte - Application + StaticLibrary false - v140 + v141 true MultiByte @@ -75,7 +76,8 @@ Level3 Disabled true - ..\ + ..\libfnd\include;..\libcrypto\include;..\libcrypto\source\libpolarssl\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -83,7 +85,8 @@ Level3 Disabled true - ..\ + ..\libfnd\include;..\libcrypto\include;..\libcrypto\source\libpolarssl\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -93,7 +96,8 @@ true true true - ..\ + ..\libfnd\include;..\libcrypto\include;..\libcrypto\source\libpolarssl\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true @@ -107,26 +111,43 @@ true true true - ..\ + ..\libfnd\include;..\libcrypto\include;..\libcrypto\source\libpolarssl\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true true + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - diff --git a/lib/libcrypto/crypto.vcxproj.filters b/lib/libcrypto/crypto.vcxproj.filters new file mode 100644 index 0000000..80b23f4 --- /dev/null +++ b/lib/libcrypto/crypto.vcxproj.filters @@ -0,0 +1,99 @@ + + + + + {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 + + + {c24d0e3f-1a38-486c-9bad-b7db5b39eee2} + + + {50821199-d06b-4e82-b424-3f17b60f1a9e} + + + {012a6f22-d10a-4ca3-b7c3-4c31c6ff1cc1} + + + + + Header Files\crypto + + + Header Files\crypto + + + Header Files\crypto + + + Header Files\crypto + + + Header Files\polarssl + + + Header Files\polarssl + + + Header Files\polarssl + + + Header Files\polarssl + + + Header Files\polarssl + + + Header Files\polarssl + + + Header Files\polarssl + + + Header Files\polarssl + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files\polarssl + + + Source Files\polarssl + + + Source Files\polarssl + + + Source Files\polarssl + + + Source Files\polarssl + + + Source Files\polarssl + + + + + + \ No newline at end of file diff --git a/lib/crypto/aes_ctr_stream.h b/lib/libcrypto/include/crypto/AesCtrStream.h similarity index 99% rename from lib/crypto/aes_ctr_stream.h rename to lib/libcrypto/include/crypto/AesCtrStream.h index 963df7b..b4eea4a 100644 --- a/lib/crypto/aes_ctr_stream.h +++ b/lib/libcrypto/include/crypto/AesCtrStream.h @@ -1,7 +1,7 @@ #pragma once #include #include -#include +#include #include namespace crypto diff --git a/lib/crypto/aes.h b/lib/libcrypto/include/crypto/aes.h similarity index 100% rename from lib/crypto/aes.h rename to lib/libcrypto/include/crypto/aes.h diff --git a/lib/crypto/rsa.h b/lib/libcrypto/include/crypto/rsa.h similarity index 100% rename from lib/crypto/rsa.h rename to lib/libcrypto/include/crypto/rsa.h diff --git a/lib/crypto/sha.h b/lib/libcrypto/include/crypto/sha.h similarity index 100% rename from lib/crypto/sha.h rename to lib/libcrypto/include/crypto/sha.h diff --git a/lib/libcrypto/makefile b/lib/libcrypto/makefile new file mode 100644 index 0000000..e763fae --- /dev/null +++ b/lib/libcrypto/makefile @@ -0,0 +1,37 @@ +# Sources +SRC_DIR = source source/libpolarssl/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 = fnd +LIB_DIR = .. +INCS = -I"include" -I"source/libpolarssl/include" $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") + + +# Compiler Settings +CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-but-set-variable -Wno-unused-value +CFLAGS = -std=c11 $(INCS) -Wall -Wno-unused-but-set-variable -Wno-unused-value +ifeq ($(OS),Windows_NT) + # Windows Only Flags/Libs + CC = x86_64-w64-mingw32-gcc + CXX = x86_64-w64-mingw32-g++ + CFLAGS += + CXXFLAGS += +else + # *nix Only Flags/Libs + CFLAGS += + CXXFLAGS += +endif + +# Output +OUTPUT = $(shell basename $(CURDIR)).a + +main: build + +rebuild: clean build + +build: $(OBJS) + ar cr -o $(OUTPUT) $(OBJS) + +clean: + rm -rf $(OUTPUT) $(OBJS) \ No newline at end of file diff --git a/lib/crypto/aes_ctr_stream.cpp b/lib/libcrypto/source/AesCtrStream.cpp similarity index 98% rename from lib/crypto/aes_ctr_stream.cpp rename to lib/libcrypto/source/AesCtrStream.cpp index a02c642..9ab8c99 100644 --- a/lib/crypto/aes_ctr_stream.cpp +++ b/lib/libcrypto/source/AesCtrStream.cpp @@ -1,4 +1,4 @@ -#include "aes_ctr_stream.h" +#include using namespace crypto::aes; diff --git a/lib/crypto/aes.cpp b/lib/libcrypto/source/aes.cpp similarity index 98% rename from lib/crypto/aes.cpp rename to lib/libcrypto/source/aes.cpp index 732d1ba..851434e 100644 --- a/lib/crypto/aes.cpp +++ b/lib/libcrypto/source/aes.cpp @@ -1,5 +1,5 @@ -#include "aes.h" -#include "polarssl/aes.h" +#include +#include using namespace crypto::aes; @@ -150,7 +150,7 @@ void crypto::aes::GaloisFunc(uint8_t x[kAesBlockSize]) { uint8_t t = x[15]; - for (uint8_t i = 16; i > 0; i--) + for (uint8_t i = 15; i > 0; i--) { x[i] = (x[i] << 1) | (x[i - 1] & 0x80 ? 1 : 0); } diff --git a/lib/crypto/polarssl/aes.h b/lib/libcrypto/source/libpolarssl/include/polarssl/aes.h similarity index 99% rename from lib/crypto/polarssl/aes.h rename to lib/libcrypto/source/libpolarssl/include/polarssl/aes.h index 92fca54..f78fbd9 100644 --- a/lib/crypto/polarssl/aes.h +++ b/lib/libcrypto/source/libpolarssl/include/polarssl/aes.h @@ -34,6 +34,7 @@ #ifdef _MSC_VER #include typedef UINT32 uint32_t; +typedef UINT64 uint64_t; #else #include #endif diff --git a/lib/crypto/polarssl/base64.h b/lib/libcrypto/source/libpolarssl/include/polarssl/base64.h similarity index 100% rename from lib/crypto/polarssl/base64.h rename to lib/libcrypto/source/libpolarssl/include/polarssl/base64.h diff --git a/lib/crypto/polarssl/bignum.h b/lib/libcrypto/source/libpolarssl/include/polarssl/bignum.h similarity index 100% rename from lib/crypto/polarssl/bignum.h rename to lib/libcrypto/source/libpolarssl/include/polarssl/bignum.h diff --git a/lib/crypto/polarssl/bn_mul.h b/lib/libcrypto/source/libpolarssl/include/polarssl/bn_mul.h similarity index 100% rename from lib/crypto/polarssl/bn_mul.h rename to lib/libcrypto/source/libpolarssl/include/polarssl/bn_mul.h diff --git a/lib/crypto/polarssl/config.h b/lib/libcrypto/source/libpolarssl/include/polarssl/config.h similarity index 100% rename from lib/crypto/polarssl/config.h rename to lib/libcrypto/source/libpolarssl/include/polarssl/config.h diff --git a/lib/crypto/polarssl/rsa.h b/lib/libcrypto/source/libpolarssl/include/polarssl/rsa.h similarity index 100% rename from lib/crypto/polarssl/rsa.h rename to lib/libcrypto/source/libpolarssl/include/polarssl/rsa.h diff --git a/lib/crypto/polarssl/sha1.h b/lib/libcrypto/source/libpolarssl/include/polarssl/sha1.h similarity index 100% rename from lib/crypto/polarssl/sha1.h rename to lib/libcrypto/source/libpolarssl/include/polarssl/sha1.h diff --git a/lib/crypto/polarssl/sha2.h b/lib/libcrypto/source/libpolarssl/include/polarssl/sha2.h similarity index 100% rename from lib/crypto/polarssl/sha2.h rename to lib/libcrypto/source/libpolarssl/include/polarssl/sha2.h diff --git a/lib/crypto/makefile b/lib/libcrypto/source/libpolarssl/makefile similarity index 69% rename from lib/crypto/makefile rename to lib/libcrypto/source/libpolarssl/makefile index 6b16e04..f2d86c3 100644 --- a/lib/crypto/makefile +++ b/lib/libcrypto/source/libpolarssl/makefile @@ -1,12 +1,16 @@ # Sources -SRC_DIR = . polarssl +SRC_DIR = source OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c))) -INC_DIR = .. -INCS = $(foreach dir,$(INC_DIR), -I"$(dir)") +# External dependencies +DEPENDS = +LIB_DIR = .. +INCS = -I"include" $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") + # Compiler Settings CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-but-set-variable -Wno-unused-value +CFLAGS = -std=c11 $(INCS) -Wall -Wno-unused-but-set-variable -Wno-unused-value ifeq ($(OS),Windows_NT) # Windows Only Flags/Libs CC = x86_64-w64-mingw32-gcc @@ -20,7 +24,7 @@ else endif # Output -OUTPUT = ../lib$(shell basename $(CURDIR)).a +OUTPUT = $(shell basename $(CURDIR)).a main: build diff --git a/lib/crypto/polarssl/aes.c b/lib/libcrypto/source/libpolarssl/source/polar_aes.c similarity index 99% rename from lib/crypto/polarssl/aes.c rename to lib/libcrypto/source/libpolarssl/source/polar_aes.c index 65c2b1f..f8293e6 100644 --- a/lib/crypto/polarssl/aes.c +++ b/lib/libcrypto/source/libpolarssl/source/polar_aes.c @@ -29,13 +29,13 @@ * http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf */ -#include "config.h" +#include #if defined(POLARSSL_AES_C) -#include "aes.h" +#include #if defined(POLARSSL_PADLOCK_C) -#include "padlock.h" +#include #endif #if !defined(POLARSSL_AES_ALT) diff --git a/lib/crypto/polarssl/base64.c b/lib/libcrypto/source/libpolarssl/source/polar_base64.c similarity index 99% rename from lib/crypto/polarssl/base64.c rename to lib/libcrypto/source/libpolarssl/source/polar_base64.c index c99192a..b596527 100644 --- a/lib/crypto/polarssl/base64.c +++ b/lib/libcrypto/source/libpolarssl/source/polar_base64.c @@ -23,11 +23,11 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "config.h" +#include #if defined(POLARSSL_BASE64_C) -#include "base64.h" +#include #ifdef _MSC_VER #include diff --git a/lib/crypto/polarssl/bignum.c b/lib/libcrypto/source/libpolarssl/source/polar_bignum.c similarity index 99% rename from lib/crypto/polarssl/bignum.c rename to lib/libcrypto/source/libpolarssl/source/polar_bignum.c index 2a40ff4..839ec30 100644 --- a/lib/crypto/polarssl/bignum.c +++ b/lib/libcrypto/source/libpolarssl/source/polar_bignum.c @@ -30,12 +30,12 @@ * http://math.libtomcrypt.com/files/tommath.pdf */ -#include "config.h" +#include #if defined(POLARSSL_BIGNUM_C) -#include "bignum.h" -#include "bn_mul.h" +#include +#include #include diff --git a/lib/crypto/polarssl/rsa.c b/lib/libcrypto/source/libpolarssl/source/polar_rsa.c similarity index 99% rename from lib/crypto/polarssl/rsa.c rename to lib/libcrypto/source/libpolarssl/source/polar_rsa.c index 29dd7bf..a877233 100644 --- a/lib/crypto/polarssl/rsa.c +++ b/lib/libcrypto/source/libpolarssl/source/polar_rsa.c @@ -29,14 +29,14 @@ * http://www.cacr.math.uwaterloo.ca/hac/about/chap8.pdf */ -#include "config.h" +#include #if defined(POLARSSL_RSA_C) -#include "rsa.h" +#include #if defined(POLARSSL_PKCS1_V21) -#include "md.h" +#include #endif #include diff --git a/lib/crypto/polarssl/sha1.c b/lib/libcrypto/source/libpolarssl/source/polar_sha1.c similarity index 99% rename from lib/crypto/polarssl/sha1.c rename to lib/libcrypto/source/libpolarssl/source/polar_sha1.c index c56a6a8..36b4c73 100644 --- a/lib/crypto/polarssl/sha1.c +++ b/lib/libcrypto/source/libpolarssl/source/polar_sha1.c @@ -28,11 +28,11 @@ * http://www.itl.nist.gov/fipspubs/fip180-1.htm */ -#include "config.h" +#include #if defined(POLARSSL_SHA1_C) -#include "sha1.h" +#include #if defined(POLARSSL_FS_IO) || defined(POLARSSL_SELF_TEST) #include diff --git a/lib/crypto/polarssl/sha2.c b/lib/libcrypto/source/libpolarssl/source/polar_sha2.c similarity index 99% rename from lib/crypto/polarssl/sha2.c rename to lib/libcrypto/source/libpolarssl/source/polar_sha2.c index 319d7e8..6c19082 100644 --- a/lib/crypto/polarssl/sha2.c +++ b/lib/libcrypto/source/libpolarssl/source/polar_sha2.c @@ -28,11 +28,11 @@ * http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf */ -#include "config.h" +#include #if defined(POLARSSL_SHA2_C) -#include "sha2.h" +#include #if defined(POLARSSL_FS_IO) || defined(POLARSSL_SELF_TEST) #include diff --git a/lib/crypto/rsa.cpp b/lib/libcrypto/source/rsa.cpp similarity index 98% rename from lib/crypto/rsa.cpp rename to lib/libcrypto/source/rsa.cpp index 55195eb..f302990 100644 --- a/lib/crypto/rsa.cpp +++ b/lib/libcrypto/source/rsa.cpp @@ -1,5 +1,5 @@ -#include "rsa.h" -#include "polarssl/rsa.h" +#include +#include using namespace crypto::rsa; using namespace crypto::sha; diff --git a/lib/crypto/sha.cpp b/lib/libcrypto/source/sha.cpp similarity index 77% rename from lib/crypto/sha.cpp rename to lib/libcrypto/source/sha.cpp index 3839f99..c625c95 100644 --- a/lib/crypto/sha.cpp +++ b/lib/libcrypto/source/sha.cpp @@ -1,6 +1,6 @@ -#include "sha.h" -#include "polarssl/sha1.h" -#include "polarssl/sha2.h" +#include +#include +#include using namespace crypto::sha; diff --git a/lib/crypto/crypto.vcxproj b/lib/libes/es.vcxproj similarity index 74% rename from lib/crypto/crypto.vcxproj rename to lib/libes/es.vcxproj index 2ab9ade..8b81816 100644 --- a/lib/crypto/crypto.vcxproj +++ b/lib/libes/es.vcxproj @@ -19,34 +19,33 @@ - 15.0 - {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1} - crypto - 10.0.15063.0 - libcrypto + {7BE99936-0D40-410D-944B-4513C2EFF8DC} + es + 8.1 + libes - Application + StaticLibrary true v141 MultiByte - Application + StaticLibrary false v141 true MultiByte - Application + StaticLibrary true v141 MultiByte - Application + StaticLibrary false v141 true @@ -76,7 +75,8 @@ Level3 Disabled true - ..\ + ..\libfnd\include;..\libcrypto\include;..\libes\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -84,7 +84,8 @@ Level3 Disabled true - ..\ + ..\libfnd\include;..\libcrypto\include;..\libes\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -94,6 +95,8 @@ true true true + ..\libfnd\include;..\libcrypto\include;..\libes\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true @@ -107,27 +110,27 @@ true true true + ..\libfnd\include;..\libcrypto\include;..\libes\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true true - - - - - - - - - - - - + + + + + + + + + + diff --git a/lib/es/es.vcxproj.filters b/lib/libes/es.vcxproj.filters similarity index 77% rename from lib/es/es.vcxproj.filters rename to lib/libes/es.vcxproj.filters index 73aad3f..a86064e 100644 --- a/lib/es/es.vcxproj.filters +++ b/lib/libes/es.vcxproj.filters @@ -18,24 +18,24 @@ - + Header Files - + Header Files - + Header Files - + Source Files - + Source Files - + Source Files diff --git a/lib/es/ETicketBody_V2.h b/lib/libes/include/es/ETicketBody_V2.h similarity index 98% rename from lib/es/ETicketBody_V2.h rename to lib/libes/include/es/ETicketBody_V2.h index 0b5d4ff..8f68b3c 100644 --- a/lib/es/ETicketBody_V2.h +++ b/lib/libes/include/es/ETicketBody_V2.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include #include #include @@ -60,6 +60,9 @@ namespace es LicenseType getLicenseType() const; void setLicenseType(LicenseType type); + u8 getCommonKeyId() const; + void setCommonKeyId(u8 id); + bool isPreInstall() const; void setIsPreInstall(bool isPreInstall); @@ -196,7 +199,7 @@ namespace es TitleKeyEncType mEncType; // 0 = aes-cbc, 1 = rsa2048 u16 mTicketVersion; LicenseType mLicenseType; - u8 kCommonKeyId; + u8 mCommonKeyId; bool mPreInstall; bool mSharedTitle; bool mAllowAllContent; diff --git a/lib/es/ETicketContentRecord_V1.h b/lib/libes/include/es/ETicketContentRecord_V1.h similarity index 93% rename from lib/es/ETicketContentRecord_V1.h rename to lib/libes/include/es/ETicketContentRecord_V1.h index c1a9533..56d9be4 100644 --- a/lib/es/ETicketContentRecord_V1.h +++ b/lib/libes/include/es/ETicketContentRecord_V1.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include #include #include @@ -13,6 +13,7 @@ namespace es ETicketContentRecord_V1(); private: + const std::string kModuleName = "ETICKET_CONTENT_RECORD_V1"; #pragma pack (push, 1) struct sContentRecord_v1 diff --git a/lib/es/ETicketSectionHeader_V2.h b/lib/libes/include/es/ETicketSectionHeader_V2.h similarity index 98% rename from lib/es/ETicketSectionHeader_V2.h rename to lib/libes/include/es/ETicketSectionHeader_V2.h index 9447185..ae810b5 100644 --- a/lib/es/ETicketSectionHeader_V2.h +++ b/lib/libes/include/es/ETicketSectionHeader_V2.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include #include namespace es diff --git a/lib/nx/makefile b/lib/libes/makefile similarity index 68% rename from lib/nx/makefile rename to lib/libes/makefile index cea813e..920e98d 100644 --- a/lib/nx/makefile +++ b/lib/libes/makefile @@ -1,12 +1,16 @@ # Sources -SRC_DIR = . +SRC_DIR = source OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c))) -INC_DIR = .. -INCS = $(foreach dir,$(INC_DIR), -I"$(dir)/") +# External dependencies +DEPENDS = fnd crypto +LIB_DIR = .. +INCS = -I"include" $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") + # Compiler Settings CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-but-set-variable -Wno-unused-value +CFLAGS = -std=c11 $(INCS) -Wall -Wno-unused-but-set-variable -Wno-unused-value ifeq ($(OS),Windows_NT) # Windows Only Flags/Libs CC = x86_64-w64-mingw32-gcc @@ -20,7 +24,7 @@ else endif # Output -OUTPUT = ../lib$(shell basename $(CURDIR)).a +OUTPUT = $(shell basename $(CURDIR)).a main: build diff --git a/lib/es/ETicketBody_V2.cpp b/lib/libes/source/ETicketBody_V2.cpp similarity index 97% rename from lib/es/ETicketBody_V2.cpp rename to lib/libes/source/ETicketBody_V2.cpp index e14f8e1..a199b6f 100644 --- a/lib/es/ETicketBody_V2.cpp +++ b/lib/libes/source/ETicketBody_V2.cpp @@ -1,4 +1,4 @@ -#include "ETicketBody_V2.h" +#include @@ -234,6 +234,16 @@ void es::ETicketBody_V2::setLicenseType(LicenseType type) mLicenseType = type; } +u8 es::ETicketBody_V2::getCommonKeyId() const +{ + return mCommonKeyId; +} + +void es::ETicketBody_V2::setCommonKeyId(u8 id) +{ + mCommonKeyId = id; +} + bool es::ETicketBody_V2::isPreInstall() const { return mPreInstall; diff --git a/lib/es/ETicketContentRecord_V1.cpp b/lib/libes/source/ETicketContentRecord_V1.cpp similarity index 60% rename from lib/es/ETicketContentRecord_V1.cpp rename to lib/libes/source/ETicketContentRecord_V1.cpp index bb4dcfe..acc97fc 100644 --- a/lib/es/ETicketContentRecord_V1.cpp +++ b/lib/libes/source/ETicketContentRecord_V1.cpp @@ -1,4 +1,4 @@ -#include "ETicketContentRecord_V1.h" +#include diff --git a/lib/es/ETicketSectionHeader_V2.cpp b/lib/libes/source/ETicketSectionHeader_V2.cpp similarity index 98% rename from lib/es/ETicketSectionHeader_V2.cpp rename to lib/libes/source/ETicketSectionHeader_V2.cpp index 3ca5246..9eb2a0e 100644 --- a/lib/es/ETicketSectionHeader_V2.cpp +++ b/lib/libes/source/ETicketSectionHeader_V2.cpp @@ -1,4 +1,4 @@ -#include "ETicketSectionHeader_V2.h" +#include diff --git a/lib/fnd/fnd.vcxproj b/lib/libfnd/fnd.vcxproj similarity index 77% rename from lib/fnd/fnd.vcxproj rename to lib/libfnd/fnd.vcxproj index 858c981..b74a6d7 100644 --- a/lib/fnd/fnd.vcxproj +++ b/lib/libfnd/fnd.vcxproj @@ -27,26 +27,26 @@ - Application + StaticLibrary true v141 MultiByte - Application + StaticLibrary false v141 true MultiByte - Application + StaticLibrary true v141 MultiByte - Application + StaticLibrary false v141 true @@ -76,7 +76,8 @@ Level3 Disabled true - ..\ + ..\libfnd\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -84,7 +85,8 @@ Level3 Disabled true - ..\ + ..\libfnd\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -94,7 +96,8 @@ true true true - C:\Users\jkrca\Source\Repos\NXTools\lib;%(AdditionalIncludeDirectories) + ..\libfnd\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true @@ -108,6 +111,8 @@ true true true + ..\libfnd\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true @@ -115,20 +120,20 @@ - - - - - - - - + + + + + + + + - - - - + + + + diff --git a/lib/fnd/fnd.vcxproj.filters b/lib/libfnd/fnd.vcxproj.filters similarity index 73% rename from lib/fnd/fnd.vcxproj.filters rename to lib/libfnd/fnd.vcxproj.filters index e73663b..3d1dee6 100644 --- a/lib/fnd/fnd.vcxproj.filters +++ b/lib/libfnd/fnd.vcxproj.filters @@ -15,42 +15,42 @@ - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Source Files - + Source Files - + Source Files - + Source Files diff --git a/lib/fnd/exception.h b/lib/libfnd/include/fnd/Exception.h similarity index 100% rename from lib/fnd/exception.h rename to lib/libfnd/include/fnd/Exception.h diff --git a/lib/fnd/ISerialiseableBinary.h b/lib/libfnd/include/fnd/ISerialiseableBinary.h similarity index 100% rename from lib/fnd/ISerialiseableBinary.h rename to lib/libfnd/include/fnd/ISerialiseableBinary.h diff --git a/lib/fnd/List.h b/lib/libfnd/include/fnd/List.h similarity index 100% rename from lib/fnd/List.h rename to lib/libfnd/include/fnd/List.h diff --git a/lib/fnd/memory_blob.h b/lib/libfnd/include/fnd/MemoryBlob.h similarity index 100% rename from lib/fnd/memory_blob.h rename to lib/libfnd/include/fnd/MemoryBlob.h diff --git a/lib/fnd/string_conv.h b/lib/libfnd/include/fnd/StringConv.h similarity index 100% rename from lib/fnd/string_conv.h rename to lib/libfnd/include/fnd/StringConv.h diff --git a/lib/fnd/elf.h b/lib/libfnd/include/fnd/elf.h similarity index 100% rename from lib/fnd/elf.h rename to lib/libfnd/include/fnd/elf.h diff --git a/lib/fnd/io.h b/lib/libfnd/include/fnd/io.h similarity index 90% rename from lib/fnd/io.h rename to lib/libfnd/include/fnd/io.h index 28fa7ef..7e05f50 100644 --- a/lib/fnd/io.h +++ b/lib/libfnd/include/fnd/io.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include namespace fnd { diff --git a/lib/fnd/types.h b/lib/libfnd/include/fnd/types.h similarity index 98% rename from lib/fnd/types.h rename to lib/libfnd/include/fnd/types.h index 3f87609..3ed1ae8 100644 --- a/lib/fnd/types.h +++ b/lib/libfnd/include/fnd/types.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include typedef uint64_t dword_t; typedef uint32_t word_t; diff --git a/lib/es/makefile b/lib/libfnd/makefile similarity index 69% rename from lib/es/makefile rename to lib/libfnd/makefile index cea813e..f2d86c3 100644 --- a/lib/es/makefile +++ b/lib/libfnd/makefile @@ -1,12 +1,16 @@ # Sources -SRC_DIR = . +SRC_DIR = source OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c))) -INC_DIR = .. -INCS = $(foreach dir,$(INC_DIR), -I"$(dir)/") +# External dependencies +DEPENDS = +LIB_DIR = .. +INCS = -I"include" $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") + # Compiler Settings CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-but-set-variable -Wno-unused-value +CFLAGS = -std=c11 $(INCS) -Wall -Wno-unused-but-set-variable -Wno-unused-value ifeq ($(OS),Windows_NT) # Windows Only Flags/Libs CC = x86_64-w64-mingw32-gcc @@ -20,7 +24,7 @@ else endif # Output -OUTPUT = ../lib$(shell basename $(CURDIR)).a +OUTPUT = $(shell basename $(CURDIR)).a main: build diff --git a/lib/fnd/exception.cpp b/lib/libfnd/source/Exception.cpp similarity index 96% rename from lib/fnd/exception.cpp rename to lib/libfnd/source/Exception.cpp index ed2c609..c50f256 100644 --- a/lib/fnd/exception.cpp +++ b/lib/libfnd/source/Exception.cpp @@ -1,4 +1,4 @@ -#include "exception.h" +#include using namespace fnd; diff --git a/lib/fnd/memory_blob.cpp b/lib/libfnd/source/MemoryBlob.cpp similarity index 97% rename from lib/fnd/memory_blob.cpp rename to lib/libfnd/source/MemoryBlob.cpp index 33b817e..2456972 100644 --- a/lib/fnd/memory_blob.cpp +++ b/lib/libfnd/source/MemoryBlob.cpp @@ -1,4 +1,4 @@ -#include "memory_blob.h" +#include using namespace fnd; diff --git a/lib/fnd/string_conv.cpp b/lib/libfnd/source/StringConv.cpp similarity index 99% rename from lib/fnd/string_conv.cpp rename to lib/libfnd/source/StringConv.cpp index ed77b9a..8b9fcc6 100644 --- a/lib/fnd/string_conv.cpp +++ b/lib/libfnd/source/StringConv.cpp @@ -1,4 +1,4 @@ -#include "string_conv.h" +#include #include #include diff --git a/lib/fnd/io.cpp b/lib/libfnd/source/io.cpp similarity index 98% rename from lib/fnd/io.cpp rename to lib/libfnd/source/io.cpp index b01b337..cc6066f 100644 --- a/lib/fnd/io.cpp +++ b/lib/libfnd/source/io.cpp @@ -1,4 +1,4 @@ -#include "io.h" +#include using namespace fnd; diff --git a/lib/nx/AciBinary.h b/lib/libnx/include/nx/AciBinary.h similarity index 97% rename from lib/nx/AciBinary.h rename to lib/libnx/include/nx/AciBinary.h index 3b7810a..312fa42 100644 --- a/lib/nx/AciBinary.h +++ b/lib/libnx/include/nx/AciBinary.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include #include #include #include diff --git a/lib/nx/AciHeader.h b/lib/libnx/include/nx/AciHeader.h similarity index 99% rename from lib/nx/AciHeader.h rename to lib/libnx/include/nx/AciHeader.h index f45694a..c7686cc 100644 --- a/lib/nx/AciHeader.h +++ b/lib/libnx/include/nx/AciHeader.h @@ -1,7 +1,7 @@ #pragma once #include #include -#include +#include #include namespace nx diff --git a/lib/nx/AcidBinary.h b/lib/libnx/include/nx/AcidBinary.h similarity index 97% rename from lib/nx/AcidBinary.h rename to lib/libnx/include/nx/AcidBinary.h index 4f27159..6d4cd52 100644 --- a/lib/nx/AcidBinary.h +++ b/lib/libnx/include/nx/AcidBinary.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include #include #include diff --git a/lib/nx/FacBinary.h b/lib/libnx/include/nx/FacBinary.h similarity index 97% rename from lib/nx/FacBinary.h rename to lib/libnx/include/nx/FacBinary.h index 4b9d4e6..fa9c6b0 100644 --- a/lib/nx/FacBinary.h +++ b/lib/libnx/include/nx/FacBinary.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include #include #include diff --git a/lib/nx/FacHeader.h b/lib/libnx/include/nx/FacHeader.h similarity index 99% rename from lib/nx/FacHeader.h rename to lib/libnx/include/nx/FacHeader.h index 10e1773..e2edfee 100644 --- a/lib/nx/FacHeader.h +++ b/lib/libnx/include/nx/FacHeader.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include #include #include diff --git a/lib/nx/HandleTableSizeEntry.h b/lib/libnx/include/nx/HandleTableSizeEntry.h similarity index 100% rename from lib/nx/HandleTableSizeEntry.h rename to lib/libnx/include/nx/HandleTableSizeEntry.h diff --git a/lib/nx/HandleTableSizeHandler.h b/lib/libnx/include/nx/HandleTableSizeHandler.h similarity index 100% rename from lib/nx/HandleTableSizeHandler.h rename to lib/libnx/include/nx/HandleTableSizeHandler.h diff --git a/lib/nx/IKernelCapabilityHandler.h b/lib/libnx/include/nx/IKernelCapabilityHandler.h similarity index 100% rename from lib/nx/IKernelCapabilityHandler.h rename to lib/libnx/include/nx/IKernelCapabilityHandler.h diff --git a/lib/nx/InteruptEntry.h b/lib/libnx/include/nx/InteruptEntry.h similarity index 100% rename from lib/nx/InteruptEntry.h rename to lib/libnx/include/nx/InteruptEntry.h diff --git a/lib/nx/InteruptHandler.h b/lib/libnx/include/nx/InteruptHandler.h similarity index 100% rename from lib/nx/InteruptHandler.h rename to lib/libnx/include/nx/InteruptHandler.h diff --git a/lib/nx/KcBinary.h b/lib/libnx/include/nx/KcBinary.h similarity index 98% rename from lib/nx/KcBinary.h rename to lib/libnx/include/nx/KcBinary.h index a339d27..47780cb 100644 --- a/lib/nx/KcBinary.h +++ b/lib/libnx/include/nx/KcBinary.h @@ -1,7 +1,7 @@ #pragma once #include #include -#include +#include #include #include #include diff --git a/lib/nx/KernelCapability.h b/lib/libnx/include/nx/KernelCapability.h similarity index 100% rename from lib/nx/KernelCapability.h rename to lib/libnx/include/nx/KernelCapability.h diff --git a/lib/nx/KernelVersionEntry.h b/lib/libnx/include/nx/KernelVersionEntry.h similarity index 100% rename from lib/nx/KernelVersionEntry.h rename to lib/libnx/include/nx/KernelVersionEntry.h diff --git a/lib/nx/KernelVersionHandler.h b/lib/libnx/include/nx/KernelVersionHandler.h similarity index 100% rename from lib/nx/KernelVersionHandler.h rename to lib/libnx/include/nx/KernelVersionHandler.h diff --git a/lib/nx/MemoryMappingHandler.h b/lib/libnx/include/nx/MemoryMappingHandler.h similarity index 100% rename from lib/nx/MemoryMappingHandler.h rename to lib/libnx/include/nx/MemoryMappingHandler.h diff --git a/lib/nx/MemoryPageEntry.h b/lib/libnx/include/nx/MemoryPageEntry.h similarity index 100% rename from lib/nx/MemoryPageEntry.h rename to lib/libnx/include/nx/MemoryPageEntry.h diff --git a/lib/nx/MiscFlagsEntry.h b/lib/libnx/include/nx/MiscFlagsEntry.h similarity index 100% rename from lib/nx/MiscFlagsEntry.h rename to lib/libnx/include/nx/MiscFlagsEntry.h diff --git a/lib/nx/MiscFlagsHandler.h b/lib/libnx/include/nx/MiscFlagsHandler.h similarity index 100% rename from lib/nx/MiscFlagsHandler.h rename to lib/libnx/include/nx/MiscFlagsHandler.h diff --git a/lib/nx/MiscParamsEntry.h b/lib/libnx/include/nx/MiscParamsEntry.h similarity index 100% rename from lib/nx/MiscParamsEntry.h rename to lib/libnx/include/nx/MiscParamsEntry.h diff --git a/lib/nx/MiscParamsHandler.h b/lib/libnx/include/nx/MiscParamsHandler.h similarity index 100% rename from lib/nx/MiscParamsHandler.h rename to lib/libnx/include/nx/MiscParamsHandler.h diff --git a/lib/nx/NXCrypto.h b/lib/libnx/include/nx/NXCrypto.h similarity index 99% rename from lib/nx/NXCrypto.h rename to lib/libnx/include/nx/NXCrypto.h index 76c781b..9269643 100644 --- a/lib/nx/NXCrypto.h +++ b/lib/libnx/include/nx/NXCrypto.h @@ -69,6 +69,8 @@ namespace crypto // aes128-cbc keys u8 xci_header_key[16] = { 0x01, 0xc5, 0x8f, 0xe7, 0x2d, 0x13, 0x5a, 0xb2, 0x9a, 0x3f, 0x69, 0x33, 0x95, 0x74, 0xb1 }; u8 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 + + u8 wii_sd_key[16] = { 0xAB, 0x01, 0xB9, 0xD8, 0xE1, 0x62, 0x2B, 0x08, 0xAF, 0xBA, 0xD8, 0x4D, 0xBF, 0xC2, 0xA5, 0x5D }; } namespace prod diff --git a/lib/nx/NcaHeader.h b/lib/libnx/include/nx/NcaHeader.h similarity index 99% rename from lib/nx/NcaHeader.h rename to lib/libnx/include/nx/NcaHeader.h index 0484a13..8dc0cea 100644 --- a/lib/nx/NcaHeader.h +++ b/lib/libnx/include/nx/NcaHeader.h @@ -1,7 +1,7 @@ #pragma once #include #include -#include +#include #include #include #include diff --git a/lib/nx/NpdmBinary.h b/lib/libnx/include/nx/NpdmBinary.h similarity index 97% rename from lib/nx/NpdmBinary.h rename to lib/libnx/include/nx/NpdmBinary.h index d61466f..fb01c59 100644 --- a/lib/nx/NpdmBinary.h +++ b/lib/libnx/include/nx/NpdmBinary.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include #include #include #include diff --git a/lib/nx/NpdmFile.h b/lib/libnx/include/nx/NpdmFile.h similarity index 100% rename from lib/nx/NpdmFile.h rename to lib/libnx/include/nx/NpdmFile.h diff --git a/lib/nx/NpdmHeader.h b/lib/libnx/include/nx/NpdmHeader.h similarity index 99% rename from lib/nx/NpdmHeader.h rename to lib/libnx/include/nx/NpdmHeader.h index ddb11ef..c54b0fd 100644 --- a/lib/nx/NpdmHeader.h +++ b/lib/libnx/include/nx/NpdmHeader.h @@ -1,7 +1,7 @@ #pragma once #include #include -#include +#include #include namespace nx diff --git a/lib/nx/PfsHeader.h b/lib/libnx/include/nx/PfsHeader.h similarity index 98% rename from lib/nx/PfsHeader.h rename to lib/libnx/include/nx/PfsHeader.h index d1e7d39..1a70f4e 100644 --- a/lib/nx/PfsHeader.h +++ b/lib/libnx/include/nx/PfsHeader.h @@ -1,7 +1,7 @@ #pragma once #include #include -#include +#include #include #include diff --git a/lib/nx/SacBinary.h b/lib/libnx/include/nx/SacBinary.h similarity index 97% rename from lib/nx/SacBinary.h rename to lib/libnx/include/nx/SacBinary.h index 6b5fd7c..b1c816e 100644 --- a/lib/nx/SacBinary.h +++ b/lib/libnx/include/nx/SacBinary.h @@ -1,7 +1,7 @@ #pragma once #include #include -#include +#include #include #include #include diff --git a/lib/nx/SacEntry.h b/lib/libnx/include/nx/SacEntry.h similarity index 97% rename from lib/nx/SacEntry.h rename to lib/libnx/include/nx/SacEntry.h index 55dbf3f..6900a26 100644 --- a/lib/nx/SacEntry.h +++ b/lib/libnx/include/nx/SacEntry.h @@ -1,7 +1,7 @@ #pragma once #include #include -#include +#include #include namespace nx diff --git a/lib/nx/SystemCallEntry.h b/lib/libnx/include/nx/SystemCallEntry.h similarity index 100% rename from lib/nx/SystemCallEntry.h rename to lib/libnx/include/nx/SystemCallEntry.h diff --git a/lib/nx/SystemCallHandler.h b/lib/libnx/include/nx/SystemCallHandler.h similarity index 100% rename from lib/nx/SystemCallHandler.h rename to lib/libnx/include/nx/SystemCallHandler.h diff --git a/lib/nx/ThreadInfoEntry.h b/lib/libnx/include/nx/ThreadInfoEntry.h similarity index 100% rename from lib/nx/ThreadInfoEntry.h rename to lib/libnx/include/nx/ThreadInfoEntry.h diff --git a/lib/nx/ThreadInfoHandler.h b/lib/libnx/include/nx/ThreadInfoHandler.h similarity index 100% rename from lib/nx/ThreadInfoHandler.h rename to lib/libnx/include/nx/ThreadInfoHandler.h diff --git a/lib/nx/XciHeader.h b/lib/libnx/include/nx/XciHeader.h similarity index 98% rename from lib/nx/XciHeader.h rename to lib/libnx/include/nx/XciHeader.h index e707413..a13bd55 100644 --- a/lib/nx/XciHeader.h +++ b/lib/libnx/include/nx/XciHeader.h @@ -1,7 +1,7 @@ #pragma once #include #include -#include +#include #include #include diff --git a/lib/fnd/makefile b/lib/libnx/makefile similarity index 68% rename from lib/fnd/makefile rename to lib/libnx/makefile index cea813e..920e98d 100644 --- a/lib/fnd/makefile +++ b/lib/libnx/makefile @@ -1,12 +1,16 @@ # Sources -SRC_DIR = . +SRC_DIR = source OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c))) -INC_DIR = .. -INCS = $(foreach dir,$(INC_DIR), -I"$(dir)/") +# External dependencies +DEPENDS = fnd crypto +LIB_DIR = .. +INCS = -I"include" $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include") + # Compiler Settings CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-but-set-variable -Wno-unused-value +CFLAGS = -std=c11 $(INCS) -Wall -Wno-unused-but-set-variable -Wno-unused-value ifeq ($(OS),Windows_NT) # Windows Only Flags/Libs CC = x86_64-w64-mingw32-gcc @@ -20,7 +24,7 @@ else endif # Output -OUTPUT = ../lib$(shell basename $(CURDIR)).a +OUTPUT = $(shell basename $(CURDIR)).a main: build diff --git a/lib/nx/nx.vcxproj b/lib/libnx/nx.vcxproj similarity index 54% rename from lib/nx/nx.vcxproj rename to lib/libnx/nx.vcxproj index 9a92938..432e43c 100644 --- a/lib/nx/nx.vcxproj +++ b/lib/libnx/nx.vcxproj @@ -19,70 +19,73 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 15.0 @@ -93,26 +96,26 @@ - Application + StaticLibrary true v141 MultiByte - Application + StaticLibrary false v141 true MultiByte - Application + StaticLibrary true v141 MultiByte - Application + StaticLibrary false v141 true @@ -142,7 +145,8 @@ Level3 Disabled true - ..\ + ..\libfnd\include;..\libcrypto\include;..\libnx\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -150,7 +154,8 @@ Level3 Disabled true - ..\ + ..\libfnd\include;..\libcrypto\include;..\libnx\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -160,7 +165,8 @@ true true true - ..\ + ..\libfnd\include;..\libcrypto\include;..\libnx\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true @@ -174,6 +180,8 @@ true true true + ..\libfnd\include;..\libcrypto\include;..\libnx\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true diff --git a/lib/nx/nx.vcxproj.filters b/lib/libnx/nx.vcxproj.filters similarity index 56% rename from lib/nx/nx.vcxproj.filters rename to lib/libnx/nx.vcxproj.filters index 594b901..995cebf 100644 --- a/lib/nx/nx.vcxproj.filters +++ b/lib/libnx/nx.vcxproj.filters @@ -15,192 +15,192 @@ - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + 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 - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files diff --git a/lib/nx/AciBinary.cpp b/lib/libnx/source/AciBinary.cpp similarity index 99% rename from lib/nx/AciBinary.cpp rename to lib/libnx/source/AciBinary.cpp index 7b73205..9879127 100644 --- a/lib/nx/AciBinary.cpp +++ b/lib/libnx/source/AciBinary.cpp @@ -1,4 +1,4 @@ -#include "AciBinary.h" +#include diff --git a/lib/nx/AciHeader.cpp b/lib/libnx/source/AciHeader.cpp similarity index 99% rename from lib/nx/AciHeader.cpp rename to lib/libnx/source/AciHeader.cpp index e743747..11c7be1 100644 --- a/lib/nx/AciHeader.cpp +++ b/lib/libnx/source/AciHeader.cpp @@ -1,4 +1,4 @@ -#include "AciHeader.h" +#include using namespace nx; diff --git a/lib/nx/AcidBinary.cpp b/lib/libnx/source/AcidBinary.cpp similarity index 99% rename from lib/nx/AcidBinary.cpp rename to lib/libnx/source/AcidBinary.cpp index 3224405..7da5b09 100644 --- a/lib/nx/AcidBinary.cpp +++ b/lib/libnx/source/AcidBinary.cpp @@ -1,4 +1,4 @@ -#include "AcidBinary.h" +#include diff --git a/lib/nx/FacBinary.cpp b/lib/libnx/source/FacBinary.cpp similarity index 99% rename from lib/nx/FacBinary.cpp rename to lib/libnx/source/FacBinary.cpp index d6a4f1d..db74f68 100644 --- a/lib/nx/FacBinary.cpp +++ b/lib/libnx/source/FacBinary.cpp @@ -1,4 +1,4 @@ -#include "FacBinary.h" +#include diff --git a/lib/nx/FacHeader.cpp b/lib/libnx/source/FacHeader.cpp similarity index 99% rename from lib/nx/FacHeader.cpp rename to lib/libnx/source/FacHeader.cpp index 85d1660..ffac90f 100644 --- a/lib/nx/FacHeader.cpp +++ b/lib/libnx/source/FacHeader.cpp @@ -1,4 +1,4 @@ -#include "FacHeader.h" +#include diff --git a/lib/nx/HandleTableSizeEntry.cpp b/lib/libnx/source/HandleTableSizeEntry.cpp similarity index 96% rename from lib/nx/HandleTableSizeEntry.cpp rename to lib/libnx/source/HandleTableSizeEntry.cpp index ebd7ff3..0b99811 100644 --- a/lib/nx/HandleTableSizeEntry.cpp +++ b/lib/libnx/source/HandleTableSizeEntry.cpp @@ -1,4 +1,4 @@ -#include "HandleTableSizeEntry.h" +#include diff --git a/lib/nx/HandleTableSizeHandler.cpp b/lib/libnx/source/HandleTableSizeHandler.cpp similarity index 97% rename from lib/nx/HandleTableSizeHandler.cpp rename to lib/libnx/source/HandleTableSizeHandler.cpp index 1fe65b8..96d5905 100644 --- a/lib/nx/HandleTableSizeHandler.cpp +++ b/lib/libnx/source/HandleTableSizeHandler.cpp @@ -1,4 +1,4 @@ -#include "HandleTableSizeHandler.h" +#include diff --git a/lib/nx/InteruptEntry.cpp b/lib/libnx/source/InteruptEntry.cpp similarity index 97% rename from lib/nx/InteruptEntry.cpp rename to lib/libnx/source/InteruptEntry.cpp index 63b8bee..4335d1b 100644 --- a/lib/nx/InteruptEntry.cpp +++ b/lib/libnx/source/InteruptEntry.cpp @@ -1,4 +1,4 @@ -#include "InteruptEntry.h" +#include diff --git a/lib/nx/InteruptHandler.cpp b/lib/libnx/source/InteruptHandler.cpp similarity index 98% rename from lib/nx/InteruptHandler.cpp rename to lib/libnx/source/InteruptHandler.cpp index 346a519..129b22c 100644 --- a/lib/nx/InteruptHandler.cpp +++ b/lib/libnx/source/InteruptHandler.cpp @@ -1,4 +1,4 @@ -#include "InteruptHandler.h" +#include diff --git a/lib/nx/KcBinary.cpp b/lib/libnx/source/KcBinary.cpp similarity index 99% rename from lib/nx/KcBinary.cpp rename to lib/libnx/source/KcBinary.cpp index b0e932d..6291d4b 100644 --- a/lib/nx/KcBinary.cpp +++ b/lib/libnx/source/KcBinary.cpp @@ -1,4 +1,4 @@ -#include "KcBinary.h" +#include diff --git a/lib/nx/KernelCapability.cpp b/lib/libnx/source/KernelCapability.cpp similarity index 97% rename from lib/nx/KernelCapability.cpp rename to lib/libnx/source/KernelCapability.cpp index 15e8e33..a1b2a88 100644 --- a/lib/nx/KernelCapability.cpp +++ b/lib/libnx/source/KernelCapability.cpp @@ -1,4 +1,4 @@ -#include "KernelCapability.h" +#include using namespace nx; diff --git a/lib/nx/KernelVersionEntry.cpp b/lib/libnx/source/KernelVersionEntry.cpp similarity index 97% rename from lib/nx/KernelVersionEntry.cpp rename to lib/libnx/source/KernelVersionEntry.cpp index 19277ce..11c3de7 100644 --- a/lib/nx/KernelVersionEntry.cpp +++ b/lib/libnx/source/KernelVersionEntry.cpp @@ -1,4 +1,4 @@ -#include "KernelVersionEntry.h" +#include diff --git a/lib/nx/KernelVersionHandler.cpp b/lib/libnx/source/KernelVersionHandler.cpp similarity index 98% rename from lib/nx/KernelVersionHandler.cpp rename to lib/libnx/source/KernelVersionHandler.cpp index f312f5e..ab1791f 100644 --- a/lib/nx/KernelVersionHandler.cpp +++ b/lib/libnx/source/KernelVersionHandler.cpp @@ -1,4 +1,4 @@ -#include "KernelVersionHandler.h" +#include diff --git a/lib/nx/MemoryMappingHandler.cpp b/lib/libnx/source/MemoryMappingHandler.cpp similarity index 98% rename from lib/nx/MemoryMappingHandler.cpp rename to lib/libnx/source/MemoryMappingHandler.cpp index c37a123..d8b29cf 100644 --- a/lib/nx/MemoryMappingHandler.cpp +++ b/lib/libnx/source/MemoryMappingHandler.cpp @@ -1,5 +1,5 @@ -#include "MemoryMappingHandler.h" -#include "MemoryPageEntry.h" +#include +#include nx::MemoryMappingHandler::MemoryMappingHandler() : diff --git a/lib/nx/MemoryPageEntry.cpp b/lib/libnx/source/MemoryPageEntry.cpp similarity index 98% rename from lib/nx/MemoryPageEntry.cpp rename to lib/libnx/source/MemoryPageEntry.cpp index b005d0e..0456393 100644 --- a/lib/nx/MemoryPageEntry.cpp +++ b/lib/libnx/source/MemoryPageEntry.cpp @@ -1,4 +1,4 @@ -#include "MemoryPageEntry.h" +#include diff --git a/lib/nx/MiscFlagsEntry.cpp b/lib/libnx/source/MiscFlagsEntry.cpp similarity index 96% rename from lib/nx/MiscFlagsEntry.cpp rename to lib/libnx/source/MiscFlagsEntry.cpp index 4b40de6..292fd7c 100644 --- a/lib/nx/MiscFlagsEntry.cpp +++ b/lib/libnx/source/MiscFlagsEntry.cpp @@ -1,4 +1,4 @@ -#include "MiscFlagsEntry.h" +#include diff --git a/lib/nx/MiscFlagsHandler.cpp b/lib/libnx/source/MiscFlagsHandler.cpp similarity index 98% rename from lib/nx/MiscFlagsHandler.cpp rename to lib/libnx/source/MiscFlagsHandler.cpp index f2a63d6..9dcbf0f 100644 --- a/lib/nx/MiscFlagsHandler.cpp +++ b/lib/libnx/source/MiscFlagsHandler.cpp @@ -1,4 +1,4 @@ -#include "MiscFlagsHandler.h" +#include diff --git a/lib/nx/MiscParamsEntry.cpp b/lib/libnx/source/MiscParamsEntry.cpp similarity index 96% rename from lib/nx/MiscParamsEntry.cpp rename to lib/libnx/source/MiscParamsEntry.cpp index 581d303..24b9ae5 100644 --- a/lib/nx/MiscParamsEntry.cpp +++ b/lib/libnx/source/MiscParamsEntry.cpp @@ -1,4 +1,4 @@ -#include "MiscParamsEntry.h" +#include diff --git a/lib/nx/MiscParamsHandler.cpp b/lib/libnx/source/MiscParamsHandler.cpp similarity index 97% rename from lib/nx/MiscParamsHandler.cpp rename to lib/libnx/source/MiscParamsHandler.cpp index 7f69909..8948974 100644 --- a/lib/nx/MiscParamsHandler.cpp +++ b/lib/libnx/source/MiscParamsHandler.cpp @@ -1,4 +1,4 @@ -#include "MiscParamsHandler.h" +#include diff --git a/lib/nx/NcaHeader.cpp b/lib/libnx/source/NcaHeader.cpp similarity index 99% rename from lib/nx/NcaHeader.cpp rename to lib/libnx/source/NcaHeader.cpp index 7f51aaa..ca19423 100644 --- a/lib/nx/NcaHeader.cpp +++ b/lib/libnx/source/NcaHeader.cpp @@ -1,5 +1,4 @@ -#include "NcaHeader.h" -#include +#include using namespace nx; diff --git a/lib/nx/NpdmBinary.cpp b/lib/libnx/source/NpdmBinary.cpp similarity index 98% rename from lib/nx/NpdmBinary.cpp rename to lib/libnx/source/NpdmBinary.cpp index 43380eb..97a6e9c 100644 --- a/lib/nx/NpdmBinary.cpp +++ b/lib/libnx/source/NpdmBinary.cpp @@ -1,4 +1,4 @@ -#include "NpdmBinary.h" +#include diff --git a/lib/nx/NpdmHeader.cpp b/lib/libnx/source/NpdmHeader.cpp similarity index 99% rename from lib/nx/NpdmHeader.cpp rename to lib/libnx/source/NpdmHeader.cpp index d5f73dc..bbe9892 100644 --- a/lib/nx/NpdmHeader.cpp +++ b/lib/libnx/source/NpdmHeader.cpp @@ -1,4 +1,4 @@ -#include "NpdmHeader.h" +#include diff --git a/lib/nx/PfsHeader.cpp b/lib/libnx/source/PfsHeader.cpp similarity index 99% rename from lib/nx/PfsHeader.cpp rename to lib/libnx/source/PfsHeader.cpp index 205a26f..53b4a0e 100644 --- a/lib/nx/PfsHeader.cpp +++ b/lib/libnx/source/PfsHeader.cpp @@ -1,4 +1,4 @@ -#include "PfsHeader.h" +#include diff --git a/lib/nx/SacBinary.cpp b/lib/libnx/source/SacBinary.cpp similarity index 98% rename from lib/nx/SacBinary.cpp rename to lib/libnx/source/SacBinary.cpp index 5cab445..5ec9d2a 100644 --- a/lib/nx/SacBinary.cpp +++ b/lib/libnx/source/SacBinary.cpp @@ -1,4 +1,4 @@ -#include "SacBinary.h" +#include using namespace nx; diff --git a/lib/nx/SacEntry.cpp b/lib/libnx/source/SacEntry.cpp similarity index 99% rename from lib/nx/SacEntry.cpp rename to lib/libnx/source/SacEntry.cpp index b2065a5..66acc87 100644 --- a/lib/nx/SacEntry.cpp +++ b/lib/libnx/source/SacEntry.cpp @@ -1,4 +1,4 @@ -#include "SacEntry.h" +#include using namespace nx; diff --git a/lib/nx/SystemCallEntry.cpp b/lib/libnx/source/SystemCallEntry.cpp similarity index 97% rename from lib/nx/SystemCallEntry.cpp rename to lib/libnx/source/SystemCallEntry.cpp index dde30ba..a2c9861 100644 --- a/lib/nx/SystemCallEntry.cpp +++ b/lib/libnx/source/SystemCallEntry.cpp @@ -1,4 +1,4 @@ -#include "SystemCallEntry.h" +#include diff --git a/lib/nx/SystemCallHandler.cpp b/lib/libnx/source/SystemCallHandler.cpp similarity index 97% rename from lib/nx/SystemCallHandler.cpp rename to lib/libnx/source/SystemCallHandler.cpp index ed86344..21b0b1a 100644 --- a/lib/nx/SystemCallHandler.cpp +++ b/lib/libnx/source/SystemCallHandler.cpp @@ -1,5 +1,5 @@ -#include "SystemCallHandler.h" -#include "SystemCallEntry.h" +#include +#include nx::SystemCallHandler::SystemCallHandler() : diff --git a/lib/nx/ThreadInfoEntry.cpp b/lib/libnx/source/ThreadInfoEntry.cpp similarity index 98% rename from lib/nx/ThreadInfoEntry.cpp rename to lib/libnx/source/ThreadInfoEntry.cpp index fdddb95..b07089d 100644 --- a/lib/nx/ThreadInfoEntry.cpp +++ b/lib/libnx/source/ThreadInfoEntry.cpp @@ -1,4 +1,4 @@ -#include "ThreadInfoEntry.h" +#include diff --git a/lib/nx/ThreadInfoHandler.cpp b/lib/libnx/source/ThreadInfoHandler.cpp similarity index 98% rename from lib/nx/ThreadInfoHandler.cpp rename to lib/libnx/source/ThreadInfoHandler.cpp index 43e8983..2dad8ec 100644 --- a/lib/nx/ThreadInfoHandler.cpp +++ b/lib/libnx/source/ThreadInfoHandler.cpp @@ -1,4 +1,4 @@ -#include "ThreadInfoHandler.h" +#include diff --git a/lib/nx/XciHeader.cpp b/lib/libnx/source/XciHeader.cpp similarity index 55% rename from lib/nx/XciHeader.cpp rename to lib/libnx/source/XciHeader.cpp index e9f52c4..35a96ad 100644 --- a/lib/nx/XciHeader.cpp +++ b/lib/libnx/source/XciHeader.cpp @@ -1,4 +1,4 @@ -#include "XciHeader.h" +#include diff --git a/lib/makefile b/lib/makefile index cc5fbcb..9dd2971 100644 --- a/lib/makefile +++ b/lib/makefile @@ -1,4 +1,4 @@ -LIBS = fnd crypto es nx +LIBS = libfnd libcrypto libes libnx main: build rebuild: clean build diff --git a/programs/makefile b/programs/makefile index 14bea3d..5cf9eaf 100644 --- a/programs/makefile +++ b/programs/makefile @@ -1,13 +1,14 @@ PROGS = ncatool npdmtool pfstool tiktool +BIN_DIR = "../bin" main: build rebuild: clean build build: - mkdir -p "../bin" - @$(foreach prog,$(PROGS), cd $(prog) && $(MAKE) && cd ..;) + mkdir -p $(BIN_DIR) + @$(foreach prog,$(PROGS), cd $(prog) && $(MAKE) && cd .. && cp -r $(prog)/bin/* $(BIN_DIR);) clean: @$(foreach prog,$(PROGS), cd $(prog) && $(MAKE) clean && cd ..;) - #rm -rf "../bin" \ No newline at end of file + rm -rf $(BIN_DIR) \ No newline at end of file diff --git a/programs/ncatool/bin/ncatool b/programs/ncatool/bin/ncatool new file mode 100644 index 0000000..45b6d15 Binary files /dev/null and b/programs/ncatool/bin/ncatool differ diff --git a/programs/ncatool/makefile b/programs/ncatool/makefile index 117d52e..3d96a8d 100644 --- a/programs/ncatool/makefile +++ b/programs/ncatool/makefile @@ -1,16 +1,15 @@ # Sources -SRC_DIR = . +SRC_DIR = source OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c))) -#local dependencies +# 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") -LIBS = -L"$(LIB_DIR)" $(foreach dep,$(DEPENDS), -l"$(dep)") -INCS = -I"$(LIB_DIR)/" - -OUTPUT = ../../bin/$(shell basename $(CURDIR)) +BIN_DIR = bin +OUTPUT = $(BIN_DIR)/$(shell basename $(CURDIR)) # Compiler Settings CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-but-set-variable -Wno-unused-value @@ -33,7 +32,8 @@ all: build rebuild: clean build build: $(OBJS) + mkdir -p $(BIN_DIR) $(CXX) $(OBJS) $(LIBS) -o $(OUTPUT) clean: - rm -rf $(OBJS) $(OUTPUT) \ No newline at end of file + rm -rf $(OBJS) $(OUTPUT) $(BIN_DIR) \ No newline at end of file diff --git a/programs/ncatool/ncatool.vcxproj b/programs/ncatool/ncatool.vcxproj index 3b70f76..40f4b64 100644 --- a/programs/ncatool/ncatool.vcxproj +++ b/programs/ncatool/ncatool.vcxproj @@ -75,7 +75,8 @@ Level3 Disabled true - ..\..\lib + ..\..\lib\libfnd\include;..\..\lib\libcrypto\include;..\..\lib\libnx\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -83,7 +84,8 @@ Level3 Disabled true - ..\..\lib + ..\..\lib\libfnd\include;..\..\lib\libcrypto\include;..\..\lib\libnx\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -93,7 +95,8 @@ true true true - C:\Users\jkrca\Source\Repos\NXTools\lib + ..\..\lib\libfnd\include;..\..\lib\libcrypto\include;..\..\lib\libnx\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true @@ -107,6 +110,8 @@ true true true + ..\..\lib\libfnd\include;..\..\lib\libcrypto\include;..\..\lib\libnx\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true @@ -114,11 +119,22 @@ - + + + + {6adbb60d-dba0-411d-bd2d-a355ef8e0fe1} + + + {4d27edb9-5110-44fe-8ce2-d46c5ad3c55b} + + + {91ba9e79-8242-4f7d-b997-0dfec95ea22b} + + diff --git a/programs/ncatool/ncatool.vcxproj.filters b/programs/ncatool/ncatool.vcxproj.filters index 61ac64b..f033c14 100644 --- a/programs/ncatool/ncatool.vcxproj.filters +++ b/programs/ncatool/ncatool.vcxproj.filters @@ -15,7 +15,7 @@ - + Source Files diff --git a/programs/ncatool/ncatool.vcxproj.user b/programs/ncatool/ncatool.vcxproj.user new file mode 100644 index 0000000..df9f8d9 --- /dev/null +++ b/programs/ncatool/ncatool.vcxproj.user @@ -0,0 +1,19 @@ + + + + ..\..\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/main.cpp b/programs/ncatool/source/main.cpp similarity index 92% rename from programs/ncatool/main.cpp rename to programs/ncatool/source/main.cpp index bc985a6..f6bb365 100644 --- a/programs/ncatool/main.cpp +++ b/programs/ncatool/source/main.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include #include @@ -195,16 +195,13 @@ int main(int argc, char** argv) } if (argc == 4) { - printf("encrypt test\n"); - u8 sect[kNcaSectorSize] = { 0 }; - u8 enc_sect[kNcaSectorSize * 6]; - u8 tweak[crypto::aes::kAesBlockSize]; + printf("decrypt test\n"); + u8 sect[kNcaSectorSize];; for (size_t i = 0; i < 6; i++) { - crypto::aes::AesXtsMakeTweak(tweak, i); - crypto::aes::AesXtsEncryptSector(sect, kNcaSectorSize, crypto::aes::nx::dev::nca_header_key[0], crypto::aes::nx::dev::nca_header_key[1], tweak, enc_sect + i*kNcaSectorSize); + decryptNcaSectorXts(nca, sect, i, crypto::aes::nx::dev::nca_header_key[0], crypto::aes::nx::dev::nca_header_key[1]); + dumpNcaSector(sect); } - fnd::io::writeFile("testenc.bin", enc_sect, kNcaSectorSize * 6); } } catch (const fnd::Exception& e) diff --git a/programs/npdmtool/bin/npdmtool b/programs/npdmtool/bin/npdmtool new file mode 100644 index 0000000..3a06484 Binary files /dev/null and b/programs/npdmtool/bin/npdmtool differ diff --git a/programs/npdmtool/makefile b/programs/npdmtool/makefile index 117d52e..3d96a8d 100644 --- a/programs/npdmtool/makefile +++ b/programs/npdmtool/makefile @@ -1,16 +1,15 @@ # Sources -SRC_DIR = . +SRC_DIR = source OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c))) -#local dependencies +# 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") -LIBS = -L"$(LIB_DIR)" $(foreach dep,$(DEPENDS), -l"$(dep)") -INCS = -I"$(LIB_DIR)/" - -OUTPUT = ../../bin/$(shell basename $(CURDIR)) +BIN_DIR = bin +OUTPUT = $(BIN_DIR)/$(shell basename $(CURDIR)) # Compiler Settings CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-but-set-variable -Wno-unused-value @@ -33,7 +32,8 @@ all: build rebuild: clean build build: $(OBJS) + mkdir -p $(BIN_DIR) $(CXX) $(OBJS) $(LIBS) -o $(OUTPUT) clean: - rm -rf $(OBJS) $(OUTPUT) \ No newline at end of file + rm -rf $(OBJS) $(OUTPUT) $(BIN_DIR) \ No newline at end of file diff --git a/programs/npdmtool/npdmtool.vcxproj b/programs/npdmtool/npdmtool.vcxproj index d1e94ed..3dfdca2 100644 --- a/programs/npdmtool/npdmtool.vcxproj +++ b/programs/npdmtool/npdmtool.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -27,26 +27,26 @@ Application true - v140 + v141 MultiByte Application false - v140 + v141 true MultiByte Application true - v140 + v141 MultiByte Application false - v140 + v141 true MultiByte @@ -74,7 +74,8 @@ Level3 Disabled true - ..\..\lib + ..\..\lib\libfnd\include;..\..\lib\libcrypto\include;..\..\lib\libnx\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -82,7 +83,8 @@ Level3 Disabled true - ..\..\lib + ..\..\lib\libfnd\include;..\..\lib\libcrypto\include;..\..\lib\libnx\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -92,6 +94,8 @@ true true true + ..\..\lib\libfnd\include;..\..\lib\libcrypto\include;..\..\lib\libnx\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true @@ -105,6 +109,8 @@ true true true + ..\..\lib\libfnd\include;..\..\lib\libcrypto\include;..\..\lib\libnx\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true @@ -112,10 +118,18 @@ - + - + + {6adbb60d-dba0-411d-bd2d-a355ef8e0fe1} + + + {4d27edb9-5110-44fe-8ce2-d46c5ad3c55b} + + + {91ba9e79-8242-4f7d-b997-0dfec95ea22b} + diff --git a/programs/npdmtool/npdmtool.vcxproj.filters b/programs/npdmtool/npdmtool.vcxproj.filters index e0418b2..4c0a72b 100644 --- a/programs/npdmtool/npdmtool.vcxproj.filters +++ b/programs/npdmtool/npdmtool.vcxproj.filters @@ -15,10 +15,7 @@ - - - - + Source Files diff --git a/programs/npdmtool/main.cpp b/programs/npdmtool/source/main.cpp similarity index 99% rename from programs/npdmtool/main.cpp rename to programs/npdmtool/source/main.cpp index 7d418ce..8c20784 100644 --- a/programs/npdmtool/main.cpp +++ b/programs/npdmtool/source/main.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/programs/pfstool/bin/pfstool b/programs/pfstool/bin/pfstool new file mode 100644 index 0000000..54932be Binary files /dev/null and b/programs/pfstool/bin/pfstool differ diff --git a/programs/pfstool/makefile b/programs/pfstool/makefile index 117d52e..3d96a8d 100644 --- a/programs/pfstool/makefile +++ b/programs/pfstool/makefile @@ -1,16 +1,15 @@ # Sources -SRC_DIR = . +SRC_DIR = source OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c))) -#local dependencies +# 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") -LIBS = -L"$(LIB_DIR)" $(foreach dep,$(DEPENDS), -l"$(dep)") -INCS = -I"$(LIB_DIR)/" - -OUTPUT = ../../bin/$(shell basename $(CURDIR)) +BIN_DIR = bin +OUTPUT = $(BIN_DIR)/$(shell basename $(CURDIR)) # Compiler Settings CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-but-set-variable -Wno-unused-value @@ -33,7 +32,8 @@ all: build rebuild: clean build build: $(OBJS) + mkdir -p $(BIN_DIR) $(CXX) $(OBJS) $(LIBS) -o $(OUTPUT) clean: - rm -rf $(OBJS) $(OUTPUT) \ No newline at end of file + rm -rf $(OBJS) $(OUTPUT) $(BIN_DIR) \ No newline at end of file diff --git a/programs/pfstool/pfstool.vcxproj b/programs/pfstool/pfstool.vcxproj index 7e15c82..f9d21c8 100644 --- a/programs/pfstool/pfstool.vcxproj +++ b/programs/pfstool/pfstool.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -27,26 +27,26 @@ Application true - v140 + v141 MultiByte Application false - v140 + v141 true MultiByte Application true - v140 + v141 MultiByte Application false - v140 + v141 true MultiByte @@ -74,7 +74,8 @@ Level3 Disabled true - ..\..\lib + ..\..\lib\libfnd\include;..\..\lib\libcrypto\include;..\..\lib\libnx\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -82,7 +83,8 @@ Level3 Disabled true - ..\..\lib + ..\..\lib\libfnd\include;..\..\lib\libcrypto\include;..\..\lib\libnx\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -92,7 +94,8 @@ true true true - ..\..\lib + ..\..\lib\libfnd\include;..\..\lib\libcrypto\include;..\..\lib\libnx\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true @@ -106,7 +109,8 @@ true true true - ..\..\lib + ..\..\lib\libfnd\include;..\..\lib\libcrypto\include;..\..\lib\libnx\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true @@ -114,11 +118,22 @@ - + + + + {6adbb60d-dba0-411d-bd2d-a355ef8e0fe1} + + + {4d27edb9-5110-44fe-8ce2-d46c5ad3c55b} + + + {91ba9e79-8242-4f7d-b997-0dfec95ea22b} + + diff --git a/programs/pfstool/pfstool.vcxproj.filters b/programs/pfstool/pfstool.vcxproj.filters index 61ac64b..f033c14 100644 --- a/programs/pfstool/pfstool.vcxproj.filters +++ b/programs/pfstool/pfstool.vcxproj.filters @@ -15,7 +15,7 @@ - + Source Files diff --git a/programs/pfstool/main.cpp b/programs/pfstool/source/main.cpp similarity index 97% rename from programs/pfstool/main.cpp rename to programs/pfstool/source/main.cpp index 6d9a12f..d86507a 100644 --- a/programs/pfstool/main.cpp +++ b/programs/pfstool/source/main.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/programs/tiktool/bin/tiktool b/programs/tiktool/bin/tiktool new file mode 100644 index 0000000..7d37d92 Binary files /dev/null and b/programs/tiktool/bin/tiktool differ diff --git a/programs/tiktool/main.cpp b/programs/tiktool/main.cpp deleted file mode 100644 index 708e40a..0000000 --- a/programs/tiktool/main.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include -#include -#include -#include - -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("Issuer: %s\n", body.getIssuer().c_str()); - - - } catch (const fnd::Exception& e) - { - printf("%s\n", e.what()); - } - - return 0; -} \ No newline at end of file diff --git a/programs/tiktool/makefile b/programs/tiktool/makefile index 38dc36b..5377914 100644 --- a/programs/tiktool/makefile +++ b/programs/tiktool/makefile @@ -1,16 +1,15 @@ # Sources -SRC_DIR = . +SRC_DIR = source OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c))) -#local dependencies +# 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") -LIBS = -L"$(LIB_DIR)" $(foreach dep,$(DEPENDS), -l"$(dep)") -INCS = -I"$(LIB_DIR)/" - -OUTPUT = ../../bin/$(shell basename $(CURDIR)) +BIN_DIR = bin +OUTPUT = $(BIN_DIR)/$(shell basename $(CURDIR)) # Compiler Settings CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-but-set-variable -Wno-unused-value @@ -33,7 +32,8 @@ all: build rebuild: clean build build: $(OBJS) + mkdir -p $(BIN_DIR) $(CXX) $(OBJS) $(LIBS) -o $(OUTPUT) clean: - rm -rf $(OBJS) $(OUTPUT) \ No newline at end of file + 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 new file mode 100644 index 0000000..ef1c34a --- /dev/null +++ b/programs/tiktool/source/main.cpp @@ -0,0 +1,107 @@ +#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" +}; + +u8 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:"); + size_t size = body.getTitleKeyEncType() == es::ETicketBody_V2::RSA2048 ? crypto::rsa::kRsa2048Size : crypto::aes::kAes128KeySize; + for (u32 i = 0; i < size; i++) + { + if (i % 16 == 0) + { + printf("\n "); + } + printf("%02X%s", body.getEncTitleKey()[i], (i+1 != size) ? "" : "\n"); + } + + if (body.getTitleKeyEncType() == es::ETicketBody_V2::AES128_CBC && body.getCommonKeyId() == 0) + { + u8 iv[crypto::aes::kAesBlockSize]; + u8 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:"); + for (u32 i = 0; i < size; i++) + { + if (i % 16 == 0) + { + printf("\n "); + } + printf("%02X%s", key[i], (i + 1 != size) ? "" : "\n"); + } + } + 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:"); + for (u32 i = 0; i < 8; i++) + { + if (i % 16 == 0) + { + printf("\n "); + } + printf("%02X%s", body.getReservedRegion()[i], (i + 1 != 8) ? "" : "\n"); + } + printf(" TicketId: 0x%016" PRIx64 "\n", body.getTicketId()); + printf(" DeviceId: 0x%016" PRIx64 "\n", body.getDeviceId()); + + + } 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 index 29fba34..6d2735c 100644 --- a/programs/tiktool/tiktool.vcxproj +++ b/programs/tiktool/tiktool.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -27,26 +27,26 @@ Application true - v140 + v141 MultiByte Application false - v140 + v141 true MultiByte Application true - v140 + v141 MultiByte Application false - v140 + v141 true MultiByte @@ -74,7 +74,8 @@ Level3 Disabled true - ..\..\lib + ..\..\lib\libfnd\include;..\..\lib\libcrypto\include;..\..\lib\libes\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -82,7 +83,8 @@ Level3 Disabled true - ..\..\lib + ..\..\lib\libfnd\include;..\..\lib\libcrypto\include;..\..\lib\libes\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -92,7 +94,8 @@ true true true - ..\..\lib + ..\..\lib\libfnd\include;..\..\lib\libcrypto\include;..\..\lib\libes\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true @@ -106,7 +109,8 @@ true true true - ..\..\lib + ..\..\lib\libfnd\include;..\..\lib\libcrypto\include;..\..\lib\libes\include; + _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true @@ -114,11 +118,22 @@ - + + + + {6adbb60d-dba0-411d-bd2d-a355ef8e0fe1} + + + {7be99936-0d40-410d-944b-4513c2eff8dc} + + + {4d27edb9-5110-44fe-8ce2-d46c5ad3c55b} + + diff --git a/programs/tiktool/tiktool.vcxproj.filters b/programs/tiktool/tiktool.vcxproj.filters index 61ac64b..f033c14 100644 --- a/programs/tiktool/tiktool.vcxproj.filters +++ b/programs/tiktool/tiktool.vcxproj.filters @@ -15,7 +15,7 @@ - + Source Files