diff --git a/.gitignore b/.gitignore
index 6013d18..acccb6a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,20 +1,335 @@
-################################################################################
-# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
-################################################################################
-
-/.vs
-*.a
+bin/*
*.o
-*.exe
-*.db
-*.opendb
+*.a
+*.so.*
+
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
+
+# User-specific files
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUNIT
+*.VisualState.xml
+TestResult.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+**/Properties/launchSettings.json
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_i.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
*.log
-/bin/*
-/*/*/Debug
-/*/*/x64
-/*/*/bin
-/x64
-/Debug
-/test
-/sample
-.DS_Store
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# JustCode is a .NET coding add-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# CodeRush
+.cr/
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json
deleted file mode 100644
index d7e3785..0000000
--- a/.vscode/c_cpp_properties.json
+++ /dev/null
@@ -1,97 +0,0 @@
-{
- "configurations": [
- {
- "name": "Mac",
- "includePath": [
- "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1",
- "/usr/local/include",
- "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/include",
- "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",
- "/usr/include",
- "${workspaceRoot}",
- "${workspaceRoot}/lib/libfnd/include",
- "${workspaceRoot}/lib/libpolarssl/include",
- "${workspaceRoot}/lib/liblz4/include",
- "${workspaceRoot}/lib/libes/include",
- "${workspaceRoot}/lib/libpki/include",
- "${workspaceRoot}/lib/libhac/include",
- "${workspaceRoot}/lib/libhac-hb/include"
- ],
- "defines": [],
- "intelliSenseMode": "clang-x64",
- "browse": {
- "path": [
- "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1",
- "/usr/local/include",
- "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/include",
- "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include",
- "/usr/include",
- "${workspaceRoot}"
- ],
- "limitSymbolsToIncludedHeaders": true,
- "databaseFilename": ""
- },
- "macFrameworkPath": [
- "/System/Library/Frameworks",
- "/Library/Frameworks"
- ],
- "compilerPath": "/usr/bin/clang",
- "cStandard": "c11",
- "cppStandard": "c++17"
- },
- {
- "name": "Linux",
- "includePath": [
- "/usr/include",
- "/usr/local/include",
- "${workspaceRoot}"
- ],
- "defines": [],
- "intelliSenseMode": "clang-x64",
- "browse": {
- "path": [
- "/usr/include",
- "/usr/local/include",
- "${workspaceRoot}"
- ],
- "limitSymbolsToIncludedHeaders": true,
- "databaseFilename": ""
- },
- "compilerPath": "/usr/bin/clang",
- "cStandard": "c11",
- "cppStandard": "c++17"
- },
- {
- "name": "Win32",
- "includePath": [
- "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include",
- "${workspaceRoot}",
- "${workspaceRoot}/lib/libfnd/include",
- "${workspaceRoot}/lib/libpolarssl/include",
- "${workspaceRoot}/lib/liblz4/include",
- "${workspaceRoot}/lib/libes/include",
- "${workspaceRoot}/lib/libpki/include",
- "${workspaceRoot}/lib/libhac/include",
- "${workspaceRoot}/lib/libhac-hb/include"
- ],
- "defines": [
- "_DEBUG",
- "UNICODE",
- "_UNICODE"
- ],
- "intelliSenseMode": "msvc-x64",
- "browse": {
- "path": [
- "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include/*",
- "${workspaceRoot}"
- ],
- "limitSymbolsToIncludedHeaders": true,
- "databaseFilename": ""
- },
- "compilerPath": "/usr/bin/clang",
- "cStandard": "c11",
- "cppStandard": "c++17"
- }
- ],
- "version": 4
-}
\ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
deleted file mode 100644
index 768b573..0000000
--- a/.vscode/settings.json
+++ /dev/null
@@ -1,40 +0,0 @@
-{
- "files.associations": {
- "__config": "cpp",
- "__nullptr": "cpp",
- "cstddef": "cpp",
- "exception": "cpp",
- "initializer_list": "cpp",
- "new": "cpp",
- "stdexcept": "cpp",
- "type_traits": "cpp",
- "typeinfo": "cpp",
- "__split_buffer": "cpp",
- "__tree": "cpp",
- "bitset": "cpp",
- "iterator": "cpp",
- "map": "cpp",
- "string": "cpp",
- "string_view": "cpp",
- "utility": "cpp",
- "vector": "cpp",
- "istream": "cpp",
- "atomic": "cpp",
- "ios": "cpp",
- "system_error": "cpp",
- "__functional_base": "cpp",
- "locale": "cpp",
- "memory": "cpp",
- "tuple": "cpp",
- "__locale": "cpp",
- "cinttypes": "cpp",
- "__bit_reference": "cpp",
- "algorithm": "cpp",
- "__functional_base_03": "cpp",
- "__tuple": "cpp",
- "chrono": "cpp",
- "functional": "cpp",
- "limits": "cpp",
- "ratio": "cpp"
- }
-}
\ No newline at end of file
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
deleted file mode 100644
index 0325034..0000000
--- a/.vscode/tasks.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- // See https://go.microsoft.com/fwlink/?LinkId=733558
- // for the documentation about the tasks.json format
- "version": "2.0.0",
- "tasks": [
- {
- "label": "build",
- "type": "shell",
- "command": "make",
- "group": {
- "kind": "build",
- "isDefault": true
- }
- },
- {
- "label": "rebuild",
- "type": "shell",
- "command": "make rebuild"
- }
- ]
-}
\ No newline at end of file
diff --git a/BUILDING.md b/BUILDING.md
new file mode 100644
index 0000000..2d94e78
--- /dev/null
+++ b/BUILDING.md
@@ -0,0 +1,19 @@
+# Building
+## Linux (incl. Windows Subsystem for Linux) & MacOS - Makefile
+### Requirements
+* `make`
+* Terminal access
+* Typical GNU compatible development tools (e.g. `clang`, `g++`, `c++`, `ar` etc) with __C++11__ support
+
+### Using Makefile
+* `make` (default) - Compile program
+* `make clean` - Remove executable and object files
+
+## Native Win32 - Visual Studio
+### Requirements
+* [Visual Studio Community](https://visualstudio.microsoft.com/vs/community/) 2015 or 2017
+
+### Compiling NSTool
+* Open `build/visualstudio/nstool.sln` in Visual Studio
+* Select Target (e.g `Debug`|`Release` & `x64`)
+* Navigate to `Build`->`Build Solution`
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index 24d91e4..edbe185 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,5 +1,6 @@
-NNTools
-Copyright (c) 2017-2018 Jack
+MIT License
+
+Copyright (c) 2019 Jack
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -18,46 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-
-PolarSSL
-Copyright (C) 2006-2013, Brainspark B.V.
-All rights reserved.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along
-with this program; if not, write to the Free Software Foundation, Inc.,
-51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-LZ4 Library
-Copyright (c) 2011-2016, Yann Collet
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification,
-are permitted provided that the following conditions are met:
-
-* Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
-
-* Redistributions in binary form must reproduce the above copyright notice, this
- list of conditions and the following disclaimer in the documentation and/or
- other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
diff --git a/NNTools.sln b/NNTools.sln
deleted file mode 100644
index 249f281..0000000
--- a/NNTools.sln
+++ /dev/null
@@ -1,124 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.27428.2015
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{170B4A09-1B67-4A62-93AB-116EBCFF4A8C}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Programs", "Programs", "{E0863FCC-8E72-490D-BE1B-458F12CA8298}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8F6C846D-35E2-47FD-AF42-7A3FD036346E}"
- ProjectSection(SolutionItems) = preProject
- .gitignore = .gitignore
- LICENSE = LICENSE
- makefile = makefile
- README.md = README.md
- SWITCH_KEYS.md = SWITCH_KEYS.md
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nstool", "programs\nstool\nstool.vcxproj", "{AF09FA96-4463-417D-8FE6-526063F41349}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfnd", "lib\libfnd\libfnd.vcxproj", "{4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpolarssl", "lib\libpolarssl\libpolarssl.vcxproj", "{394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblz4", "lib\liblz4\liblz4.vcxproj", "{AB0C3362-63AB-480A-ADBC-2EF7D859778B}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpki", "lib\libpki\libpki.vcxproj", "{B9113734-6E84-44FF-8CF7-58199AA815C5}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libes", "lib\libes\libes.vcxproj", "{7BE99936-0D40-410D-944B-4513C2EFF8DC}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libhac", "lib\libhac\libhac.vcxproj", "{91BA9E79-8242-4F7D-B997-0DFEC95EA22B}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libhac-hb", "lib\libhac-hb\libhac-hb.vcxproj", "{738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {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
- {4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B}.Debug|x64.ActiveCfg = Debug|x64
- {4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B}.Debug|x64.Build.0 = Debug|x64
- {4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B}.Debug|x86.ActiveCfg = Debug|Win32
- {4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B}.Debug|x86.Build.0 = Debug|Win32
- {4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B}.Release|x64.ActiveCfg = Release|x64
- {4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B}.Release|x64.Build.0 = Release|x64
- {4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B}.Release|x86.ActiveCfg = Release|Win32
- {4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B}.Release|x86.Build.0 = Release|Win32
- {394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1}.Debug|x64.ActiveCfg = Debug|x64
- {394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1}.Debug|x64.Build.0 = Debug|x64
- {394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1}.Debug|x86.ActiveCfg = Debug|Win32
- {394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1}.Debug|x86.Build.0 = Debug|Win32
- {394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1}.Release|x64.ActiveCfg = Release|x64
- {394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1}.Release|x64.Build.0 = Release|x64
- {394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1}.Release|x86.ActiveCfg = Release|Win32
- {394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1}.Release|x86.Build.0 = Release|Win32
- {AB0C3362-63AB-480A-ADBC-2EF7D859778B}.Debug|x64.ActiveCfg = Debug|x64
- {AB0C3362-63AB-480A-ADBC-2EF7D859778B}.Debug|x64.Build.0 = Debug|x64
- {AB0C3362-63AB-480A-ADBC-2EF7D859778B}.Debug|x86.ActiveCfg = Debug|Win32
- {AB0C3362-63AB-480A-ADBC-2EF7D859778B}.Debug|x86.Build.0 = Debug|Win32
- {AB0C3362-63AB-480A-ADBC-2EF7D859778B}.Release|x64.ActiveCfg = Release|x64
- {AB0C3362-63AB-480A-ADBC-2EF7D859778B}.Release|x64.Build.0 = Release|x64
- {AB0C3362-63AB-480A-ADBC-2EF7D859778B}.Release|x86.ActiveCfg = Release|Win32
- {AB0C3362-63AB-480A-ADBC-2EF7D859778B}.Release|x86.Build.0 = Release|Win32
- {B9113734-6E84-44FF-8CF7-58199AA815C5}.Debug|x64.ActiveCfg = Debug|x64
- {B9113734-6E84-44FF-8CF7-58199AA815C5}.Debug|x64.Build.0 = Debug|x64
- {B9113734-6E84-44FF-8CF7-58199AA815C5}.Debug|x86.ActiveCfg = Debug|Win32
- {B9113734-6E84-44FF-8CF7-58199AA815C5}.Debug|x86.Build.0 = Debug|Win32
- {B9113734-6E84-44FF-8CF7-58199AA815C5}.Release|x64.ActiveCfg = Release|x64
- {B9113734-6E84-44FF-8CF7-58199AA815C5}.Release|x64.Build.0 = Release|x64
- {B9113734-6E84-44FF-8CF7-58199AA815C5}.Release|x86.ActiveCfg = Release|Win32
- {B9113734-6E84-44FF-8CF7-58199AA815C5}.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
- {7BE99936-0D40-410D-944B-4513C2EFF8DC}.Debug|x86.Build.0 = Debug|Win32
- {7BE99936-0D40-410D-944B-4513C2EFF8DC}.Release|x64.ActiveCfg = Release|x64
- {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
- {91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Debug|x64.ActiveCfg = Debug|x64
- {91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Debug|x64.Build.0 = Debug|x64
- {91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Debug|x86.ActiveCfg = Debug|Win32
- {91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Debug|x86.Build.0 = Debug|Win32
- {91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Release|x64.ActiveCfg = Release|x64
- {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
- {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Debug|x64.ActiveCfg = Debug|x64
- {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Debug|x64.Build.0 = Debug|x64
- {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Debug|x86.ActiveCfg = Debug|Win32
- {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Debug|x86.Build.0 = Debug|Win32
- {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Release|x64.ActiveCfg = Release|x64
- {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Release|x64.Build.0 = Release|x64
- {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Release|x86.ActiveCfg = Release|Win32
- {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Release|x86.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(NestedProjects) = preSolution
- {AF09FA96-4463-417D-8FE6-526063F41349} = {E0863FCC-8E72-490D-BE1B-458F12CA8298}
- {4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C}
- {394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C}
- {AB0C3362-63AB-480A-ADBC-2EF7D859778B} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C}
- {B9113734-6E84-44FF-8CF7-58199AA815C5} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C}
- {7BE99936-0D40-410D-944B-4513C2EFF8DC} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C}
- {91BA9E79-8242-4F7D-B997-0DFEC95EA22B} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C}
- {738CB4FC-CD9E-4B81-A04B-DEADBFA71C63} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C}
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {07DCCACC-D10D-47C9-85AE-FB9C54DB7D62}
- EndGlobalSection
-EndGlobal
diff --git a/NNTools.vcxproj b/NNTools.vcxproj
deleted file mode 100644
index d764e1b..0000000
--- a/NNTools.vcxproj
+++ /dev/null
@@ -1,119 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
- Debug
- x64
-
-
- Release
- x64
-
-
-
- 15.0
- {0A4197A1-76AD-4BF7-A29D-5CED369B72FD}
- NNTools
- 10.0.15063.0
- NNTools
-
-
-
- Application
- true
- v141
- MultiByte
-
-
- Application
- false
- v141
- true
- MultiByte
-
-
- Application
- true
- v141
- MultiByte
-
-
- Application
- false
- v141
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Level3
- Disabled
- true
-
-
-
-
- Level3
- Disabled
- true
-
-
-
-
- Level3
- MaxSpeed
- true
- true
- true
-
-
- true
- true
-
-
-
-
- Level3
- MaxSpeed
- true
- true
- true
-
-
- true
- true
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/NNTools.vcxproj.filters b/NNTools.vcxproj.filters
deleted file mode 100644
index 6a1782f..0000000
--- a/NNTools.vcxproj.filters
+++ /dev/null
@@ -1,17 +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
-
-
-
\ No newline at end of file
diff --git a/README.md b/README.md
index 48824a1..26112c8 100644
--- a/README.md
+++ b/README.md
@@ -1,26 +1,83 @@
-# NNTools
+# Nintendo Switch Tool (NSTool) ![DeviceTag](https://img.shields.io/badge/Device-SWITCH-e60012.svg)
+General purpose reading/extraction tool for Nintendo Switch file formats.
-Tools & Libraries for Nintendo devices.
+## Supported File Formats
+* Meta (.npdm)
+* PartitionFS (and HashedPartitionFS) (includes raw .nsp)
+* RomFS
+* GameCard Image (.xci)
+* Nintendo Content Archive (.nca)
+* Content Metadata (.cnmt)
+* Nintendo Software Object (.nso)
+* Nintendo Relocatable Software Object (.nro)
+* Kernel Initial Process List (.ini)
+* Kernel Initial Process (.kip)
+* Nintendo Application Control Property (.nacp)
+* ES Ticket (v2 only) (.tik)
+* PKI Certificate (.cert)
-[![License](https://img.shields.io/badge/license-MIT-blue.svg)](/LICENSE)
+# Usage
+```
+Usage: nstool [options... ]
-# Tools
-* [__nstool__](/programs/nstool/README.md) - General purpose read/extract tool for Nintendo Switch file formats.
+ General Options:
+ -d, --dev Use devkit keyset.
+ -k, --keyset Specify keyset file.
+ -t, --type Specify input file type. [xci, pfs, romfs, nca, meta, cnmt, nso, nro, ini, kip, nacp, aset, cert, tik]
+ -y, --verify Verify file.
-# Libraries
-* __libfnd__ - Foundation library. Provides file IO, crypto, CLI utils, string conversion, etc.
-* __libpki__ - Processes Nintendo's proprietary PKI.
-* __libes__ - Processes Nintendo's eShop file formats.
-* __libhac__ - Processes Nintendo Switch file formats.
-* __libhac-hb__ - Processes Nintendo Switch file formats (homebrew extensions).
+ Output Options:
+ --showkeys Show keys generated.
+ --showlayout Show layout metadata.
+ -v, --verbose Verbose output.
-# Dependencies
-* __libpolarssl__ - Cryptographic functions (AES,SHA,RSA). Clone of [polarssl](https://github.com/ARMmbed/mbedtls) (now mbedTLS).
-* __liblz4__ - Compression algorithms (LZ4). Clone of [lz4](https://github.com/lz4/lz4).
+ XCI (GameCard Image)
+ nstool [--listfs] [--update --logo --normal --secure ] <.xci file>
+ --listfs Print file system in embedded partitions.
+ --update Extract "update" partition to directory.
+ --logo Extract "logo" partition to directory.
+ --normal Extract "normal" partition to directory.
+ --secure Extract "secure" partition to directory.
-(Copies of these are included locally and are statically linked libraries)
+ PFS0/HFS0 (PartitionFs), RomFs, NSP (Ninendo Submission Package)
+ nstool [--listfs] [--fsdir ]
+ --listfs Print file system.
+ --fsdir Extract file system to directory.
+
+ NCA (Nintendo Content Archive)
+ nstool [--listfs] [--bodykey --titlekey ] [--part0 ...] <.nca file>
+ --listfs Print file system in embedded partitions.
+ --titlekey Specify title key extracted from ticket.
+ --bodykey Specify body encryption key.
+ --tik Specify ticket to source title key.
+ --cert Specify certificate chain to verify ticket.
+ --part0 Extract "partition 0" to directory.
+ --part1 Extract "partition 1" to directory.
+ --part2 Extract "partition 2" to directory.
+ --part3 Extract "partition 3" to directory.
+
+ NSO (Nintendo Software Object), NRO (Nintendo Relocatable Object)
+ nstool [--listapi --listsym] [--insttype ]
+ --listapi Print SDK API List.
+ --listsym Print Code Symbols.
+ --insttype Specify instruction type [64bit|32bit] (64bit is assumed).
+
+ INI (Initial Process List Blob)
+ nstool [--kipdir ]
+ --kipdir Extract embedded KIPs to directory.
+
+ ASET (Homebrew Asset Blob)
+ nstool [--listfs] [--icon --nacp --fsdir ]
+ --listfs Print filesystem in embedded RomFS partition.
+ --icon Extract icon partition to file.
+ --nacp Extract NACP partition to file.
+ --fsdir Extract RomFS partition to directory.
+```
+
+# External Keys
+NSTool doesn't embed any keys that are copyright protected. However keys can be imported via various keyset files.
+
+See [SWITCH_KEYS.md](/SWITCH_KEYS.md) for more info.
# Building
-On MacOS/Linux/WSL run `make`.
-
-For Windows, Visual Studio 2017 is supported.
\ No newline at end of file
+See [BUILDING.md](/BUILDING.md).
\ No newline at end of file
diff --git a/build/visualstudio/nstool.sln b/build/visualstudio/nstool.sln
new file mode 100644
index 0000000..8958846
--- /dev/null
+++ b/build/visualstudio/nstool.sln
@@ -0,0 +1,129 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.28010.2036
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nstool", "nstool\nstool.vcxproj", "{775EF5EB-CA49-4994-8AC4-47B4A5385266}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "deps", "deps", "{05929EAE-4471-4E8E-A6F3-793A81623D7F}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfnd", "..\..\deps\libfnd\build\visualstudio\libfnd\libfnd.vcxproj", "{4E578016-34BA-4A1E-B8EC-37A48780B6CA}"
+ ProjectSection(ProjectDependencies) = postProject
+ {E741ADED-7900-4E07-8DB0-D008C336C3FB} = {E741ADED-7900-4E07-8DB0-D008C336C3FB}
+ {7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C} = {7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblz4", "..\..\deps\liblz4\build\visualstudio\liblz4\liblz4.vcxproj", "{E741ADED-7900-4E07-8DB0-D008C336C3FB}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libnintendo-es", "..\..\deps\libnintendo-es\build\visualstudio\libnintendo-es\libnintendo-es.vcxproj", "{8616D6C9-C8DE-4C3F-AFC2-625636664C2B}"
+ ProjectSection(ProjectDependencies) = postProject
+ {4E578016-34BA-4A1E-B8EC-37A48780B6CA} = {4E578016-34BA-4A1E-B8EC-37A48780B6CA}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libnintendo-hac", "..\..\deps\libnintendo-hac\build\visualstudio\libnintendo-hac\libnintendo-hac.vcxproj", "{8885C125-83FB-4F73-A93A-C712B1434D54}"
+ ProjectSection(ProjectDependencies) = postProject
+ {4E578016-34BA-4A1E-B8EC-37A48780B6CA} = {4E578016-34BA-4A1E-B8EC-37A48780B6CA}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libnintendo-hac-hb", "..\..\deps\libnintendo-hac-hb\build\visualstudio\libnintendo-hac-hb\libnintendo-hac-hb.vcxproj", "{24D001B4-D439-4967-9371-DC3E0523EB19}"
+ ProjectSection(ProjectDependencies) = postProject
+ {4E578016-34BA-4A1E-B8EC-37A48780B6CA} = {4E578016-34BA-4A1E-B8EC-37A48780B6CA}
+ {8885C125-83FB-4F73-A93A-C712B1434D54} = {8885C125-83FB-4F73-A93A-C712B1434D54}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libnintendo-pki", "..\..\deps\libnintendo-pki\build\visualstudio\libnintendo-pki\libnintendo-pki.vcxproj", "{0BEF63A0-2801-4563-AB65-1E2FD881C3AF}"
+ ProjectSection(ProjectDependencies) = postProject
+ {4E578016-34BA-4A1E-B8EC-37A48780B6CA} = {4E578016-34BA-4A1E-B8EC-37A48780B6CA}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpolarssl", "..\..\deps\libpolarssl\build\visualstudio\libpolarssl\libpolarssl.vcxproj", "{7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {775EF5EB-CA49-4994-8AC4-47B4A5385266}.Debug|x64.ActiveCfg = Debug|x64
+ {775EF5EB-CA49-4994-8AC4-47B4A5385266}.Debug|x64.Build.0 = Debug|x64
+ {775EF5EB-CA49-4994-8AC4-47B4A5385266}.Debug|x86.ActiveCfg = Debug|Win32
+ {775EF5EB-CA49-4994-8AC4-47B4A5385266}.Debug|x86.Build.0 = Debug|Win32
+ {775EF5EB-CA49-4994-8AC4-47B4A5385266}.Release|x64.ActiveCfg = Release|x64
+ {775EF5EB-CA49-4994-8AC4-47B4A5385266}.Release|x64.Build.0 = Release|x64
+ {775EF5EB-CA49-4994-8AC4-47B4A5385266}.Release|x86.ActiveCfg = Release|Win32
+ {775EF5EB-CA49-4994-8AC4-47B4A5385266}.Release|x86.Build.0 = Release|Win32
+ {4E578016-34BA-4A1E-B8EC-37A48780B6CA}.Debug|x64.ActiveCfg = Debug|x64
+ {4E578016-34BA-4A1E-B8EC-37A48780B6CA}.Debug|x64.Build.0 = Debug|x64
+ {4E578016-34BA-4A1E-B8EC-37A48780B6CA}.Debug|x86.ActiveCfg = Debug|Win32
+ {4E578016-34BA-4A1E-B8EC-37A48780B6CA}.Debug|x86.Build.0 = Debug|Win32
+ {4E578016-34BA-4A1E-B8EC-37A48780B6CA}.Release|x64.ActiveCfg = Release|x64
+ {4E578016-34BA-4A1E-B8EC-37A48780B6CA}.Release|x64.Build.0 = Release|x64
+ {4E578016-34BA-4A1E-B8EC-37A48780B6CA}.Release|x86.ActiveCfg = Release|Win32
+ {4E578016-34BA-4A1E-B8EC-37A48780B6CA}.Release|x86.Build.0 = Release|Win32
+ {E741ADED-7900-4E07-8DB0-D008C336C3FB}.Debug|x64.ActiveCfg = Debug|x64
+ {E741ADED-7900-4E07-8DB0-D008C336C3FB}.Debug|x64.Build.0 = Debug|x64
+ {E741ADED-7900-4E07-8DB0-D008C336C3FB}.Debug|x86.ActiveCfg = Debug|Win32
+ {E741ADED-7900-4E07-8DB0-D008C336C3FB}.Debug|x86.Build.0 = Debug|Win32
+ {E741ADED-7900-4E07-8DB0-D008C336C3FB}.Release|x64.ActiveCfg = Release|x64
+ {E741ADED-7900-4E07-8DB0-D008C336C3FB}.Release|x64.Build.0 = Release|x64
+ {E741ADED-7900-4E07-8DB0-D008C336C3FB}.Release|x86.ActiveCfg = Release|Win32
+ {E741ADED-7900-4E07-8DB0-D008C336C3FB}.Release|x86.Build.0 = Release|Win32
+ {8616D6C9-C8DE-4C3F-AFC2-625636664C2B}.Debug|x64.ActiveCfg = Debug|x64
+ {8616D6C9-C8DE-4C3F-AFC2-625636664C2B}.Debug|x64.Build.0 = Debug|x64
+ {8616D6C9-C8DE-4C3F-AFC2-625636664C2B}.Debug|x86.ActiveCfg = Debug|Win32
+ {8616D6C9-C8DE-4C3F-AFC2-625636664C2B}.Debug|x86.Build.0 = Debug|Win32
+ {8616D6C9-C8DE-4C3F-AFC2-625636664C2B}.Release|x64.ActiveCfg = Release|x64
+ {8616D6C9-C8DE-4C3F-AFC2-625636664C2B}.Release|x64.Build.0 = Release|x64
+ {8616D6C9-C8DE-4C3F-AFC2-625636664C2B}.Release|x86.ActiveCfg = Release|Win32
+ {8616D6C9-C8DE-4C3F-AFC2-625636664C2B}.Release|x86.Build.0 = Release|Win32
+ {8885C125-83FB-4F73-A93A-C712B1434D54}.Debug|x64.ActiveCfg = Debug|x64
+ {8885C125-83FB-4F73-A93A-C712B1434D54}.Debug|x64.Build.0 = Debug|x64
+ {8885C125-83FB-4F73-A93A-C712B1434D54}.Debug|x86.ActiveCfg = Debug|Win32
+ {8885C125-83FB-4F73-A93A-C712B1434D54}.Debug|x86.Build.0 = Debug|Win32
+ {8885C125-83FB-4F73-A93A-C712B1434D54}.Release|x64.ActiveCfg = Release|x64
+ {8885C125-83FB-4F73-A93A-C712B1434D54}.Release|x64.Build.0 = Release|x64
+ {8885C125-83FB-4F73-A93A-C712B1434D54}.Release|x86.ActiveCfg = Release|Win32
+ {8885C125-83FB-4F73-A93A-C712B1434D54}.Release|x86.Build.0 = Release|Win32
+ {24D001B4-D439-4967-9371-DC3E0523EB19}.Debug|x64.ActiveCfg = Debug|x64
+ {24D001B4-D439-4967-9371-DC3E0523EB19}.Debug|x64.Build.0 = Debug|x64
+ {24D001B4-D439-4967-9371-DC3E0523EB19}.Debug|x86.ActiveCfg = Debug|Win32
+ {24D001B4-D439-4967-9371-DC3E0523EB19}.Debug|x86.Build.0 = Debug|Win32
+ {24D001B4-D439-4967-9371-DC3E0523EB19}.Release|x64.ActiveCfg = Release|x64
+ {24D001B4-D439-4967-9371-DC3E0523EB19}.Release|x64.Build.0 = Release|x64
+ {24D001B4-D439-4967-9371-DC3E0523EB19}.Release|x86.ActiveCfg = Release|Win32
+ {24D001B4-D439-4967-9371-DC3E0523EB19}.Release|x86.Build.0 = Release|Win32
+ {0BEF63A0-2801-4563-AB65-1E2FD881C3AF}.Debug|x64.ActiveCfg = Debug|x64
+ {0BEF63A0-2801-4563-AB65-1E2FD881C3AF}.Debug|x64.Build.0 = Debug|x64
+ {0BEF63A0-2801-4563-AB65-1E2FD881C3AF}.Debug|x86.ActiveCfg = Debug|Win32
+ {0BEF63A0-2801-4563-AB65-1E2FD881C3AF}.Debug|x86.Build.0 = Debug|Win32
+ {0BEF63A0-2801-4563-AB65-1E2FD881C3AF}.Release|x64.ActiveCfg = Release|x64
+ {0BEF63A0-2801-4563-AB65-1E2FD881C3AF}.Release|x64.Build.0 = Release|x64
+ {0BEF63A0-2801-4563-AB65-1E2FD881C3AF}.Release|x86.ActiveCfg = Release|Win32
+ {0BEF63A0-2801-4563-AB65-1E2FD881C3AF}.Release|x86.Build.0 = Release|Win32
+ {7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}.Debug|x64.ActiveCfg = Debug|x64
+ {7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}.Debug|x64.Build.0 = Debug|x64
+ {7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}.Debug|x86.ActiveCfg = Debug|Win32
+ {7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}.Debug|x86.Build.0 = Debug|Win32
+ {7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}.Release|x64.ActiveCfg = Release|x64
+ {7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}.Release|x64.Build.0 = Release|x64
+ {7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}.Release|x86.ActiveCfg = Release|Win32
+ {7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {4E578016-34BA-4A1E-B8EC-37A48780B6CA} = {05929EAE-4471-4E8E-A6F3-793A81623D7F}
+ {E741ADED-7900-4E07-8DB0-D008C336C3FB} = {05929EAE-4471-4E8E-A6F3-793A81623D7F}
+ {8616D6C9-C8DE-4C3F-AFC2-625636664C2B} = {05929EAE-4471-4E8E-A6F3-793A81623D7F}
+ {8885C125-83FB-4F73-A93A-C712B1434D54} = {05929EAE-4471-4E8E-A6F3-793A81623D7F}
+ {24D001B4-D439-4967-9371-DC3E0523EB19} = {05929EAE-4471-4E8E-A6F3-793A81623D7F}
+ {0BEF63A0-2801-4563-AB65-1E2FD881C3AF} = {05929EAE-4471-4E8E-A6F3-793A81623D7F}
+ {7A7C66F3-2B5B-4E23-85D8-2A74FEDAD92C} = {05929EAE-4471-4E8E-A6F3-793A81623D7F}
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {ABDCFB40-D6B3-44A9-92B5-0D7AB38D9FB8}
+ EndGlobalSection
+EndGlobal
diff --git a/build/visualstudio/nstool/nstool.vcxproj b/build/visualstudio/nstool/nstool.vcxproj
new file mode 100644
index 0000000..8d79358
--- /dev/null
+++ b/build/visualstudio/nstool/nstool.vcxproj
@@ -0,0 +1,194 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ 15.0
+ {775EF5EB-CA49-4994-8AC4-47B4A5385266}
+ nstool
+ 10.0.17134.0
+
+
+
+ Application
+ true
+ v141
+ MultiByte
+
+
+ Application
+ false
+ v141
+ true
+ MultiByte
+
+
+ Application
+ true
+ v141
+ MultiByte
+
+
+ Application
+ false
+ v141
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Level3
+ Disabled
+ true
+ true
+ $(ProjectDir)..\..\..\include;$(SolutionDir)..\..\deps\libfnd\include;$(SolutionDir)..\..\deps\libnintendo-es\include;$(SolutionDir)..\..\deps\libnintendo-pki\include;$(SolutionDir)..\..\deps\libnintendo-hac\include;$(SolutionDir)..\..\deps\libnintendo-hac-hb\include
+
+
+
+
+ Level3
+ Disabled
+ true
+ true
+ $(ProjectDir)..\..\..\include;$(SolutionDir)..\..\deps\libfnd\include;$(SolutionDir)..\..\deps\libnintendo-es\include;$(SolutionDir)..\..\deps\libnintendo-pki\include;$(SolutionDir)..\..\deps\libnintendo-hac\include;$(SolutionDir)..\..\deps\libnintendo-hac-hb\include
+
+
+
+
+ Level3
+ MaxSpeed
+ true
+ true
+ true
+ true
+ $(ProjectDir)..\..\..\include;$(SolutionDir)..\..\deps\libfnd\include;$(SolutionDir)..\..\deps\libnintendo-es\include;$(SolutionDir)..\..\deps\libnintendo-pki\include;$(SolutionDir)..\..\deps\libnintendo-hac\include;$(SolutionDir)..\..\deps\libnintendo-hac-hb\include
+
+
+ true
+ true
+
+
+
+
+ Level3
+ MaxSpeed
+ true
+ true
+ true
+ true
+ $(ProjectDir)..\..\..\include;$(SolutionDir)..\..\deps\libfnd\include;$(SolutionDir)..\..\deps\libnintendo-es\include;$(SolutionDir)..\..\deps\libnintendo-pki\include;$(SolutionDir)..\..\deps\libnintendo-hac\include;$(SolutionDir)..\..\deps\libnintendo-hac-hb\include
+
+
+ true
+ true
+
+
+
+
+ {4e578016-34ba-4a1e-b8ec-37a48780b6ca}
+
+
+ {e741aded-7900-4e07-8db0-d008c336c3fb}
+
+
+ {8616d6c9-c8de-4c3f-afc2-625636664c2b}
+
+
+ {24d001b4-d439-4967-9371-dc3e0523eb19}
+
+
+ {8885c125-83fb-4f73-a93a-c712b1434d54}
+
+
+ {0bef63a0-2801-4563-ab65-1e2fd881c3af}
+
+
+ {7a7c66f3-2b5b-4e23-85d8-2a74fedad92c}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/programs/nstool/nstool.vcxproj.filters b/build/visualstudio/nstool/nstool.vcxproj.filters
similarity index 57%
rename from programs/nstool/nstool.vcxproj.filters
rename to build/visualstudio/nstool/nstool.vcxproj.filters
index 243a78b..4ae16db 100644
--- a/programs/nstool/nstool.vcxproj.filters
+++ b/build/visualstudio/nstool/nstool.vcxproj.filters
@@ -1,154 +1,150 @@
-
-
-
-
- {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
-
-
- 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
-
-
+
+
+
+
+ {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
+
+
+
+
+ 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
+
+
+
+
+ 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
+
+
\ No newline at end of file
diff --git a/lib/libes/include/nn/es/SectionHeader_V2.h b/lib/libes/include/nn/es/SectionHeader_V2.h
deleted file mode 100644
index f472b6f..0000000
--- a/lib/libes/include/nn/es/SectionHeader_V2.h
+++ /dev/null
@@ -1,58 +0,0 @@
-#pragma once
-#include
-#include
-#include
-
-namespace nn
-{
-namespace es
-{
- class SectionHeader_V2 :
- public fnd::IByteModel
- {
- public:
- SectionHeader_V2();
- SectionHeader_V2(const SectionHeader_V2& other);
-
- void operator=(const SectionHeader_V2& other);
- bool operator==(const SectionHeader_V2& other) const;
- bool operator!=(const SectionHeader_V2& other) const;
-
- // IByteModel
- void toBytes();
- void fromBytes(const byte_t* data, size_t len);
- const fnd::Vec& getBytes() const;
-
- // variables
- virtual void clear();
-
- uint32_t getSectionOffset() const;
- void setSectionOffset(uint32_t offset);
-
- uint32_t getRecordSize() const;
- void setRecordSize(uint32_t size);
-
- uint32_t getSectionSize() const;
- void getSectionSize(uint32_t size);
-
- uint16_t getRecordNum() const;
- void setRecordNum(uint16_t record_num);
-
- ticket::SectionType getSectionType() const;
- void setSectionType(ticket::SectionType type);
-
- private:
- const std::string kModuleName = "SECTION_HEADER_V2";
-
- // raw binary
- fnd::Vec mRawBinary;
-
- // variables
- uint32_t mSectionOffset;
- uint32_t mRecordSize;
- uint32_t mSectionSize;
- uint16_t mRecordNum;
- ticket::SectionType mSectionType;
- };
-}
-}
\ No newline at end of file
diff --git a/lib/libes/include/nn/es/TicketBody_V2.h b/lib/libes/include/nn/es/TicketBody_V2.h
deleted file mode 100644
index 2a068b4..0000000
--- a/lib/libes/include/nn/es/TicketBody_V2.h
+++ /dev/null
@@ -1,103 +0,0 @@
-#pragma once
-#include
-#include
-#include
-#include
-
-namespace nn
-{
-namespace es
-{
- class TicketBody_V2 :
- public fnd::IByteModel
- {
- public:
- TicketBody_V2();
- TicketBody_V2(const TicketBody_V2& other);
-
- void operator=(const TicketBody_V2& other);
- bool operator==(const TicketBody_V2& other) const;
- bool operator!=(const TicketBody_V2& other) const;
-
- // IByteModel
- void toBytes();
- void fromBytes(const byte_t* bytes, size_t len);
- const fnd::Vec& getBytes() const;
-
- // variables
- void clear();
-
- const std::string& getIssuer() const;
- void setIssuer(const std::string& issuer);
-
- const byte_t* getEncTitleKey() const;
- void setEncTitleKey(const byte_t* data, size_t len);
-
- ticket::TitleKeyEncType getTitleKeyEncType() const;
- void setTitleKeyEncType(ticket::TitleKeyEncType type);
-
- uint16_t getTicketVersion() const;
- void setTicketVersion(uint16_t version);
-
- ticket::LicenseType getLicenseType() const;
- void setLicenseType(ticket::LicenseType type);
-
- byte_t getCommonKeyId() const;
- void setCommonKeyId(byte_t id);
-
- const fnd::List& getPropertyFlags() const;
- void setPropertyFlags(const fnd::List& flags);
-
- const byte_t* getReservedRegion() const;
- void setReservedRegion(const byte_t* data, size_t len);
-
- uint64_t getTicketId() const;
- void setTicketId(uint64_t id);
-
- uint64_t getDeviceId() const;
- void setDeviceId(uint64_t id);
-
- const byte_t* getRightsId() const;
- void setRightsId(const byte_t* id);
-
- uint32_t getAccountId() const;
- void setAccountId(uint32_t id);
-
- uint32_t getSectionTotalSize() const;
- void setSectionTotalSize(uint32_t size);
-
- uint32_t getSectionHeaderOffset() const;
- void setSectionHeaderOffset(uint32_t offset);
-
- uint16_t getSectionNum() const;
- void setSectionNum(uint16_t num);
-
- uint16_t getSectionEntrySize() const;
- void setSectionEntrySize(uint16_t size);
-
- private:
- const std::string kModuleName = "TICKET_BODY_V2";
-
- // raw binary
- fnd::Vec mRawBinary;
-
- // variables
- std::string mIssuer;
- byte_t mEncTitleKey[ticket::kEncTitleKeySize];
- ticket::TitleKeyEncType mEncType;
- uint16_t mTicketVersion;
- ticket::LicenseType mLicenseType;
- byte_t mCommonKeyId;
- fnd::List mPropertyFlags;
- byte_t mReservedRegion[ticket::kReservedRegionSize]; // explicitly reserved
- uint64_t mTicketId;
- uint64_t mDeviceId;
- byte_t mRightsId[ticket::kRightsIdSize];
- uint32_t mAccountId;
- uint32_t mSectTotalSize;
- uint32_t mSectHeaderOffset;
- uint16_t mSectNum;
- uint16_t mSectEntrySize;
- };
-}
-}
\ No newline at end of file
diff --git a/lib/libes/include/nn/es/ticket.h b/lib/libes/include/nn/es/ticket.h
deleted file mode 100644
index d2e953d..0000000
--- a/lib/libes/include/nn/es/ticket.h
+++ /dev/null
@@ -1,111 +0,0 @@
-#pragma once
-#include
-#include
-#include
-
-namespace nn
-{
-namespace es
-{
- namespace ticket
- {
- enum TitleKeyEncType
- {
- AES128_CBC,
- RSA2048
- };
-
- enum LicenseType
- {
- LICENSE_PERMANENT = 0,
- LICENSE_DEMO = 1,
- LICENSE_TRIAL = 2,
- LICENSE_RENTAL = 3,
- LICENSE_SUBSCRIPTION = 4,
- LICENSE_SERVICE = 5,
- };
-
- enum PropertyMaskFlags
- {
- FLAG_PRE_INSTALL,
- FLAG_SHARED_TITLE,
- FLAG_ALLOW_ALL_CONTENT
- };
-
- enum SectionType
- {
- SECTION_PERMANENT = 1,
- SECTION_SUBSCRIPTION = 2,
- SECTION_CONTENT = 3,
- SECTION_CONTENT_CONSUMPTION = 4,
- SECTION_ACCESS_TITLE = 5,
- SECTION_LIMITED_RESOURCE = 6,
- };
-
- static const size_t kIssuerSize = 0x40;
- static const byte_t kFormatVersion = 2;
- static const size_t kEncTitleKeySize = fnd::rsa::kRsa2048Size;
- static const size_t kReservedRegionSize = 8;
- static const size_t kRightsIdSize = 16;
- }
-#pragma pack(push,1)
- struct sTicketBody_v2
- {
- char issuer[ticket::kIssuerSize];
- byte_t enc_title_key[ticket::kEncTitleKeySize];
- byte_t format_version;
- byte_t title_key_enc_type;
- le_uint16_t ticket_version;
- byte_t license_type;
- byte_t common_key_id;
- byte_t property_mask;
- byte_t reserved_0;
- byte_t reserved_region[ticket::kReservedRegionSize]; // explicitly reserved
- le_uint64_t ticket_id;
- le_uint64_t device_id;
- byte_t rights_id[ticket::kRightsIdSize];
- le_uint32_t account_id;
- le_uint32_t sect_total_size;
- le_uint32_t sect_header_offset;
- le_uint16_t sect_num;
- le_uint16_t sect_entry_size;
- };
-
- struct sSectionHeader_v2
- {
- le_uint32_t section_offset;
- le_uint32_t record_size;
- le_uint32_t section_size;
- le_uint16_t record_num;
- le_uint16_t section_type;
- };
-
- struct sContentRecord_v1
- {
- private:
- static const size_t kAccessMaskSize = 0x80;
- static const uint16_t kGroupMask = 0xFC00;
- static const uint16_t kAccessMaskMask = 0x3FF;
-
- be_uint32_t group;
- byte_t access_mask[kAccessMaskSize];
- public:
- uint32_t index_group() const { return group.get(); }
- bool is_index_enabled(uint16_t index) const
- {
- return (index_group() == get_group(index)) \
- && ((access_mask[get_access_mask(index) / 8] & BIT(get_access_mask(index) % 8)) != 0);
- }
-
- void clear() { memset(this, 0, sizeof(sContentRecord_v1)); }
-
- void set_index_group(uint16_t index) { group = get_group(index); }
- void enable_index(uint16_t index) { access_mask[get_access_mask(index) / 8] |= BIT(get_access_mask(index) % 8); }
- void disable_index(uint16_t index) { access_mask[get_access_mask(index) / 8] &= ~BIT(get_access_mask(index) % 8); }
-
- inline uint16_t get_access_mask(uint16_t index) const { return index & kAccessMaskMask; }
- inline uint16_t get_group(uint16_t index) const { return index & kGroupMask; }
- };
-#pragma pack(pop)
-}
-}
\ No newline at end of file
diff --git a/lib/libes/libes.vcxproj b/lib/libes/libes.vcxproj
deleted file mode 100644
index b1fe783..0000000
--- a/lib/libes/libes.vcxproj
+++ /dev/null
@@ -1,134 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
- Debug
- x64
-
-
- Release
- x64
-
-
-
- {7BE99936-0D40-410D-944B-4513C2EFF8DC}
- 10.0.16299.0
-
-
-
- StaticLibrary
- true
- v141
- MultiByte
-
-
- StaticLibrary
- false
- v141
- true
- MultiByte
-
-
- StaticLibrary
- true
- v141
- MultiByte
-
-
- StaticLibrary
- false
- v141
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Level3
- Disabled
- true
- ..\libfnd\include;..\libes\include;
- _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
-
-
-
-
- Level3
- Disabled
- true
- ..\libfnd\include;..\libes\include;
- _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
-
-
-
-
- Level3
- MaxSpeed
- true
- true
- true
- ..\libfnd\include;..\libes\include;
- _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
-
-
- true
- true
-
-
-
-
- Level3
- MaxSpeed
- true
- true
- true
- ..\libfnd\include;..\libes\include;
- _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
-
-
- true
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/lib/libes/libes.vcxproj.filters b/lib/libes/libes.vcxproj.filters
deleted file mode 100644
index d55625c..0000000
--- a/lib/libes/libes.vcxproj.filters
+++ /dev/null
@@ -1,39 +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
-
-
-
-
- Source Files
-
-
- Source Files
-
-
-
\ No newline at end of file
diff --git a/lib/libes/libes.vcxproj.user b/lib/libes/libes.vcxproj.user
deleted file mode 100644
index be25078..0000000
--- a/lib/libes/libes.vcxproj.user
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/lib/libes/makefile b/lib/libes/makefile
deleted file mode 100644
index d8a204a..0000000
--- a/lib/libes/makefile
+++ /dev/null
@@ -1,46 +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 = 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-value
-CFLAGS = -std=c11 $(INCS) -Wall -Wno-unused-value
-ARFLAGS = cr -o
-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
-else
- UNAME = $(shell uname -s)
- ifeq ($(UNAME), Darwin)
- # MacOS Only Flags/Libs
- CFLAGS += -Wno-unused-private-field
- CXXFLAGS += -Wno-unused-private-field
- ARFLAGS = rc
- else
- # *nix Only Flags/Libs
- CFLAGS += -Wno-unused-but-set-variable
- CXXFLAGS += -Wno-unused-but-set-variable
- endif
-
-endif
-
-# Output
-OUTPUT = $(shell basename "$(CURDIR)").a
-
-main: build
-
-rebuild: clean build
-
-build: $(OBJS)
- ar $(ARFLAGS) $(OUTPUT) $(OBJS)
-
-clean:
- rm -rf $(OUTPUT) $(OBJS)
\ No newline at end of file
diff --git a/lib/libes/source/SectionHeader_V2.cpp b/lib/libes/source/SectionHeader_V2.cpp
deleted file mode 100644
index ae5ad04..0000000
--- a/lib/libes/source/SectionHeader_V2.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-#include
-
-nn::es::SectionHeader_V2::SectionHeader_V2()
-{}
-
-nn::es::SectionHeader_V2::SectionHeader_V2(const SectionHeader_V2 & other)
-{
- *this = other;
-}
-
-void nn::es::SectionHeader_V2::operator=(const SectionHeader_V2 & other)
-{
- if (other.getBytes().size())
- {
- fromBytes(other.getBytes().data(), other.getBytes().size());
- }
- else
- {
- mRawBinary.clear();
- mSectionOffset = other.mSectionOffset;
- mRecordSize = other.mRecordSize;
- mSectionSize = other.mSectionSize;
- mRecordNum = other.mRecordNum;
- mSectionType = other.mSectionType;
- }
-}
-
-bool nn::es::SectionHeader_V2::operator==(const SectionHeader_V2 & other) const
-{
- return (mSectionOffset == other.mSectionOffset) \
- && (mRecordSize == other.mRecordSize) \
- && (mSectionSize == other.mSectionSize) \
- && (mRecordNum == other.mRecordNum) \
- && (mSectionType == other.mSectionType);
-}
-
-bool nn::es::SectionHeader_V2::operator!=(const SectionHeader_V2 & other) const
-{
- return !(*this ==other);
-}
-
-void nn::es::SectionHeader_V2::toBytes()
-{
- mRawBinary.alloc(sizeof(sSectionHeader_v2));
- sSectionHeader_v2* hdr = (sSectionHeader_v2*)mRawBinary.data();
-
- hdr->section_offset = (mSectionOffset);
- hdr->record_size = (mRecordSize);
- hdr->section_size = (mSectionSize);
- hdr->record_num = (mRecordNum);
- hdr->section_type = (mSectionType);
-}
-
-void nn::es::SectionHeader_V2::fromBytes(const byte_t * bytes, size_t len)
-{
- if (len < sizeof(sSectionHeader_v2))
- {
- throw fnd::Exception(kModuleName, "Binary too small");
- }
-
- clear();
-
- mRawBinary.alloc(sizeof(sSectionHeader_v2));
- memcpy(mRawBinary.data(), bytes, mRawBinary.size());
- sSectionHeader_v2* hdr = (sSectionHeader_v2*)mRawBinary.data();
-
- mSectionOffset = hdr->section_offset.get();
- mRecordSize = hdr->record_size.get();
- mSectionSize = hdr->section_size.get();
- mRecordNum = hdr->record_num.get();
- mSectionType = (ticket::SectionType)hdr->section_type.get();
-}
-
-const fnd::Vec& nn::es::SectionHeader_V2::getBytes() const
-{
- return mRawBinary;
-}
-
-void nn::es::SectionHeader_V2::clear()
-{
- mRawBinary.clear();
- mSectionOffset = 0;
- mRecordSize = 0;
- mSectionSize = 0;
- mRecordNum = 0;
- mSectionType = ticket::SECTION_PERMANENT;
-}
-
-uint32_t nn::es::SectionHeader_V2::getSectionOffset() const
-{
- return mSectionOffset;
-}
-
-void nn::es::SectionHeader_V2::setSectionOffset(uint32_t offset)
-{
- mSectionOffset = offset;
-}
-
-uint32_t nn::es::SectionHeader_V2::getRecordSize() const
-{
- return mRecordSize;
-}
-
-void nn::es::SectionHeader_V2::setRecordSize(uint32_t size)
-{
- mRecordSize = size;
-}
-
-uint32_t nn::es::SectionHeader_V2::getSectionSize() const
-{
- return mSectionSize;
-}
-
-void nn::es::SectionHeader_V2::getSectionSize(uint32_t size)
-{
- mSectionSize = size;
-}
-
-uint16_t nn::es::SectionHeader_V2::getRecordNum() const
-{
- return mRecordNum;
-}
-
-void nn::es::SectionHeader_V2::setRecordNum(uint16_t record_num)
-{
- mRecordNum = record_num;
-}
-
-nn::es::ticket::SectionType nn::es::SectionHeader_V2::getSectionType() const
-{
- return mSectionType;
-}
-
-void nn::es::SectionHeader_V2::setSectionType(ticket::SectionType type)
-{
- mSectionType = type;
-}
-
-
diff --git a/lib/libes/source/TicketBody_V2.cpp b/lib/libes/source/TicketBody_V2.cpp
deleted file mode 100644
index 1a5302d..0000000
--- a/lib/libes/source/TicketBody_V2.cpp
+++ /dev/null
@@ -1,326 +0,0 @@
-#include
-
-nn::es::TicketBody_V2::TicketBody_V2()
-{
- clear();
-}
-
-nn::es::TicketBody_V2::TicketBody_V2(const TicketBody_V2 & other)
-{
- *this = other;
-}
-
-void nn::es::TicketBody_V2::operator=(const TicketBody_V2 & other)
-{
- if (other.getBytes().size())
- {
- fromBytes(other.getBytes().data(), other.getBytes().size());
- }
- else
- {
- clear();
- mIssuer = other.mIssuer;
- memcpy(mEncTitleKey, other.mEncTitleKey, ticket::kEncTitleKeySize);
- mEncType = other.mEncType;
- mTicketVersion = other.mTicketVersion;
- mLicenseType = other.mLicenseType;
- mCommonKeyId = other.mCommonKeyId;
- mPropertyFlags = other.mPropertyFlags;
- memcpy(mReservedRegion, other.mReservedRegion, ticket::kReservedRegionSize);
- mTicketId = other.mTicketId;
- mDeviceId = other.mDeviceId;
- memcpy(mRightsId, other.mRightsId, ticket::kRightsIdSize);
- mAccountId = other.mAccountId;
- mSectTotalSize = other.mSectTotalSize;
- mSectHeaderOffset = other.mSectHeaderOffset;
- mSectNum = other.mSectNum;
- mSectEntrySize = other.mSectEntrySize;
- }
-}
-
-bool nn::es::TicketBody_V2::operator==(const TicketBody_V2 & other) const
-{
- return (mIssuer == other.mIssuer) \
- && (memcmp(mEncTitleKey, other.mEncTitleKey, ticket::kEncTitleKeySize) == 0) \
- && (mEncType == other.mEncType) \
- && (mTicketVersion == other.mTicketVersion) \
- && (mLicenseType == other.mLicenseType) \
- && (mPropertyFlags == other.mPropertyFlags) \
- && (memcmp(mReservedRegion, other.mReservedRegion, ticket::kReservedRegionSize) == 0) \
- && (mTicketId == other.mTicketId) \
- && (mDeviceId == other.mDeviceId) \
- && (memcmp(mRightsId, other.mRightsId, ticket::kRightsIdSize) == 0) \
- && (mAccountId == other.mAccountId) \
- && (mSectTotalSize == other.mSectTotalSize) \
- && (mSectHeaderOffset == other.mSectHeaderOffset) \
- && (mSectNum == other.mSectNum) \
- && (mSectEntrySize == other.mSectEntrySize);
-}
-
-bool nn::es::TicketBody_V2::operator!=(const TicketBody_V2 & other) const
-{
- return !(*this == other);
-}
-
-void nn::es::TicketBody_V2::toBytes()
-{
- mRawBinary.alloc(sizeof(sTicketBody_v2));
- sTicketBody_v2* body = (sTicketBody_v2*)mRawBinary.data();
-
- body->format_version = (ticket::kFormatVersion);
-
- strncpy(body->issuer, mIssuer.c_str(), ticket::kIssuerSize);
- memcpy(body->enc_title_key, mEncTitleKey, ticket::kEncTitleKeySize);
- body->title_key_enc_type = (mEncType);
- body->ticket_version = (mTicketVersion);
- body->license_type = mLicenseType;
- body->common_key_id = mCommonKeyId;
- byte_t property_mask = 0;
- for (size_t i = 0; i < mPropertyFlags.size(); i++)
- {
- property_mask |= _BIT(mPropertyFlags[i]);
- }
- body->property_mask = (property_mask);
- memcpy(body->reserved_region, mReservedRegion, ticket::kReservedRegionSize);
- body->ticket_id = (mTicketId);
- body->device_id = (mDeviceId);
- memcpy(body->rights_id, mRightsId, ticket::kRightsIdSize);
- body->account_id = (mAccountId);
- body->sect_total_size = (mSectTotalSize);
- body->sect_header_offset = (mSectHeaderOffset);
- body->sect_num = (mSectNum);
- body->sect_entry_size = (mSectEntrySize);
-}
-
-void nn::es::TicketBody_V2::fromBytes(const byte_t * bytes, size_t len)
-{
- if (len < sizeof(sTicketBody_v2))
- {
- throw fnd::Exception(kModuleName, "Header size too small");
- }
-
- clear();
-
- mRawBinary.alloc(sizeof(sTicketBody_v2));
- memcpy(mRawBinary.data(), bytes, mRawBinary.size());
- sTicketBody_v2* body = (sTicketBody_v2*)mRawBinary.data();
-
- if (body->format_version != ticket::kFormatVersion)
- {
- throw fnd::Exception(kModuleName, "Unsupported format version");
- }
-
- mIssuer = std::string(body->issuer, _MIN(strlen(body->issuer), ticket::kIssuerSize));
- memcpy(mEncTitleKey, body->enc_title_key, ticket::kEncTitleKeySize);
- mEncType = (ticket::TitleKeyEncType)body->title_key_enc_type;
- mTicketVersion = body->ticket_version.get();
- mLicenseType = (ticket::LicenseType)body->license_type;
- mCommonKeyId = body->common_key_id;
- for (size_t i = 0; i < mPropertyFlags.size(); i++)
- {
- if (_HAS_BIT(body->property_mask, i))
- mPropertyFlags.addElement((ticket::PropertyMaskFlags)i);
- }
- memcpy(mReservedRegion, body->reserved_region, ticket::kReservedRegionSize);
- mTicketId = body->ticket_id.get();
- mDeviceId = body->device_id.get();
- memcpy(mRightsId, body->rights_id, ticket::kRightsIdSize);
- mAccountId = body->account_id.get();
- mSectTotalSize = body->sect_total_size.get();
- mSectHeaderOffset = body->sect_header_offset.get();
- mSectNum = body->sect_num.get();
- mSectEntrySize = body->sect_entry_size.get();
-}
-
-const fnd::Vec& nn::es::TicketBody_V2::getBytes() const
-{
- return mRawBinary;
-}
-
-void nn::es::TicketBody_V2::clear()
-{
- mRawBinary.clear();
- mIssuer.clear();
- memset(mEncTitleKey, 0, ticket::kEncTitleKeySize);
- mEncType = ticket::AES128_CBC;
- mTicketVersion = 0;
- mLicenseType = ticket::LICENSE_PERMANENT;
- mCommonKeyId = 0;
- mPropertyFlags.clear();
- memset(mReservedRegion, 0, ticket::kReservedRegionSize);
- mTicketId = 0;
- mDeviceId = 0;
- memset(mRightsId, 0, ticket::kRightsIdSize);
- mAccountId = 0;
- mSectTotalSize = 0;
- mSectHeaderOffset = 0;
- mSectNum = 0;
- mSectEntrySize = 0;
-}
-
-const std::string & nn::es::TicketBody_V2::getIssuer() const
-{
- return mIssuer;
-}
-
-void nn::es::TicketBody_V2::setIssuer(const std::string & issuer)
-{
- if (issuer.length() > ticket::kIssuerSize)
- {
- throw fnd::Exception(kModuleName, "Issuer is too long");
- }
-
- mIssuer = issuer;
-}
-
-const byte_t * nn::es::TicketBody_V2::getEncTitleKey() const
-{
- return mEncTitleKey;
-}
-
-void nn::es::TicketBody_V2::setEncTitleKey(const byte_t * data, size_t len)
-{
- memset(mEncTitleKey, 0, ticket::kEncTitleKeySize);
- memcpy(mEncTitleKey, data, _MIN(len, ticket::kEncTitleKeySize));
-}
-
-nn::es::ticket::TitleKeyEncType nn::es::TicketBody_V2::getTitleKeyEncType() const
-{
- return mEncType;
-}
-
-void nn::es::TicketBody_V2::setTitleKeyEncType(ticket::TitleKeyEncType type)
-{
- mEncType = type;
-}
-
-uint16_t nn::es::TicketBody_V2::getTicketVersion() const
-{
- return mTicketVersion;
-}
-
-void nn::es::TicketBody_V2::setTicketVersion(uint16_t version)
-{
- mTicketVersion = version;
-}
-
-nn::es::ticket::LicenseType nn::es::TicketBody_V2::getLicenseType() const
-{
- return mLicenseType;
-}
-
-void nn::es::TicketBody_V2::setLicenseType(ticket::LicenseType type)
-{
- mLicenseType = type;
-}
-
-byte_t nn::es::TicketBody_V2::getCommonKeyId() const
-{
- return mCommonKeyId;
-}
-
-void nn::es::TicketBody_V2::setCommonKeyId(byte_t id)
-{
- mCommonKeyId = id;
-}
-
-const fnd::List& nn::es::TicketBody_V2::getPropertyFlags() const
-{
- return mPropertyFlags;
-}
-
-void nn::es::TicketBody_V2::setPropertyFlags(const fnd::List& flags)
-{
- mPropertyFlags = flags;
-}
-
-const byte_t * nn::es::TicketBody_V2::getReservedRegion() const
-{
- return mReservedRegion;
-}
-
-void nn::es::TicketBody_V2::setReservedRegion(const byte_t * data, size_t len)
-{
- memset(mReservedRegion, 0, ticket::kReservedRegionSize);
- memcpy(mReservedRegion, data, _MIN(len, ticket::kReservedRegionSize));
-}
-
-uint64_t nn::es::TicketBody_V2::getTicketId() const
-{
- return mTicketId;
-}
-
-void nn::es::TicketBody_V2::setTicketId(uint64_t id)
-{
- mTicketId = id;
-}
-
-uint64_t nn::es::TicketBody_V2::getDeviceId() const
-{
- return mDeviceId;
-}
-
-void nn::es::TicketBody_V2::setDeviceId(uint64_t id)
-{
- mDeviceId = id;
-}
-
-const byte_t * nn::es::TicketBody_V2::getRightsId() const
-{
- return mRightsId;
-}
-
-void nn::es::TicketBody_V2::setRightsId(const byte_t * id)
-{
- memcpy(mRightsId, id, ticket::kRightsIdSize);
-}
-
-uint32_t nn::es::TicketBody_V2::getAccountId() const
-{
- return mAccountId;
-}
-
-void nn::es::TicketBody_V2::setAccountId(uint32_t id)
-{
- mAccountId = id;
-}
-
-uint32_t nn::es::TicketBody_V2::getSectionTotalSize() const
-{
- return mSectTotalSize;
-}
-
-void nn::es::TicketBody_V2::setSectionTotalSize(uint32_t size)
-{
- mSectTotalSize = size;
-}
-
-uint32_t nn::es::TicketBody_V2::getSectionHeaderOffset() const
-{
- return mSectHeaderOffset;
-}
-
-void nn::es::TicketBody_V2::setSectionHeaderOffset(uint32_t offset)
-{
- mSectHeaderOffset = offset;
-}
-
-uint16_t nn::es::TicketBody_V2::getSectionNum() const
-{
- return mSectNum;
-}
-
-void nn::es::TicketBody_V2::setSectionNum(uint16_t num)
-{
- mSectNum = num;
-}
-
-uint16_t nn::es::TicketBody_V2::getSectionEntrySize() const
-{
- return mSectEntrySize;
-}
-
-void nn::es::TicketBody_V2::setSectionEntrySize(uint16_t size)
-{
- mSectEntrySize = size;
-}
\ No newline at end of file
diff --git a/lib/libfnd/include/fnd/AesCtrWrappedIFile.h b/lib/libfnd/include/fnd/AesCtrWrappedIFile.h
deleted file mode 100644
index 88b2df6..0000000
--- a/lib/libfnd/include/fnd/AesCtrWrappedIFile.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#pragma once
-#include
-#include
-#include
-#include
-
-namespace fnd
-{
- class AesCtrWrappedIFile : public fnd::IFile
- {
- public:
- AesCtrWrappedIFile(const fnd::SharedPtr& file, const fnd::aes::sAes128Key& key, const fnd::aes::sAesIvCtr& ctr);
-
- size_t size();
- void seek(size_t offset);
- void read(byte_t* out, size_t len);
- void read(byte_t* out, size_t offset, size_t len);
- void write(const byte_t* out, size_t len);
- void write(const byte_t* out, size_t offset, size_t len);
- private:
- const std::string kModuleName = "AesCtrWrappedIFile";
- static const size_t kCacheSize = 0x10000;
- static const size_t kCacheSizeAllocSize = kCacheSize + fnd::aes::kAesBlockSize;
-
- fnd::SharedPtr mFile;
- fnd::aes::sAes128Key mKey;
- fnd::aes::sAesIvCtr mBaseCtr, mCurrentCtr;
- size_t mFileOffset;
-
- fnd::Vec mCache;
- };
-}
\ No newline at end of file
diff --git a/lib/libfnd/include/fnd/BitMath.h b/lib/libfnd/include/fnd/BitMath.h
deleted file mode 100644
index 722036a..0000000
--- a/lib/libfnd/include/fnd/BitMath.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
-BitMath.h
-(c) 2018 Jakcron
-*/
-#pragma once
-
-// to be deprecated
-#define BIT(n) (1ULL << (n))
-
-// Bit math macros
-#define _BIT(n) BIT(n)
-#define _HAS_BIT(val, bit) (((val) & _BIT(bit)) != 0)
-#define _SET_BIT(val, bit) ((val) |= _BIT(bit))
-#define _BITMASK(width) (_BIT(width)-1)
\ No newline at end of file
diff --git a/lib/libfnd/include/fnd/Endian.h b/lib/libfnd/include/fnd/Endian.h
deleted file mode 100644
index db793f8..0000000
--- a/lib/libfnd/include/fnd/Endian.h
+++ /dev/null
@@ -1,118 +0,0 @@
-#pragma once
-#include
-
-static inline uint16_t __local_bswap16(uint16_t x) {
- return ((x << 8) & 0xff00) | ((x >> 8) & 0x00ff);
-}
-
-
-static inline uint32_t __local_bswap32(uint32_t x) {
- return ((x << 24) & 0xff000000 ) |
- ((x << 8) & 0x00ff0000 ) |
- ((x >> 8) & 0x0000ff00 ) |
- ((x >> 24) & 0x000000ff );
-}
-
-static inline uint64_t __local_bswap64(uint64_t x)
-{
- return (uint64_t)__local_bswap32(x>>32) |
- ((uint64_t)__local_bswap32(x&0xFFFFFFFF) << 32);
-}
-
-#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
-static inline uint64_t be_dword(uint64_t a) { return __local_bswap64(a); }
-static inline uint32_t be_word(uint32_t a) { return __local_bswap32(a); }
-static inline uint16_t be_hword(uint16_t a) { return __local_bswap16(a); }
-static inline uint64_t le_dword(uint64_t a) { return a; }
-static inline uint32_t le_word(uint32_t a) { return a; }
-static inline uint16_t le_hword(uint16_t a) { return a; }
-#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
-static inline uint64_t be_dword(uint64_t a) { return a; }
-static inline uint32_t be_word(uint32_t a) { return a; }
-static inline uint16_t be_hword(uint16_t a) { return a; }
-static inline uint64_t le_dword(uint64_t a) { return __local_bswap64(a); }
-static inline uint32_t le_word(uint32_t a) { return __local_bswap32(a); }
-static inline uint16_t le_hword(uint16_t a) { return __local_bswap16(a); }
-#else
-#error "What's the endianness of the platform you're targeting?"
-#endif
-
-/*
-template
-class ISerialiseablePrimative {
-public:
- inline T get() const { return F(mVar);}
- inline void set(T var) { mVar = F(var); }
- inline T operator=(T var) { set(var); return get();}
- inline T operator*() const { return get(); }
-private:
- T mVar;
-};
-
-typedef ISerialiseablePrimative le_uint16_t;
-typedef ISerialiseablePrimative be_uint16_t;
-typedef ISerialiseablePrimative le_uint32_t;
-typedef ISerialiseablePrimative be_uint32_t;
-typedef ISerialiseablePrimative le_uint64_t;
-typedef ISerialiseablePrimative be_uint64_t;
-*/
-
-class le_uint16_t {
-public:
- inline uint16_t get() const { return le_hword(mVar);}
- inline void set(uint16_t var) { mVar = le_hword(var); }
- inline uint16_t operator=(uint16_t var) { set(var); return get();}
- inline uint16_t operator*() const { return get(); }
-private:
- uint16_t mVar;
-};
-
-class be_uint16_t {
-public:
- inline uint16_t get() const { return be_hword(mVar);}
- inline void set(uint16_t var) { mVar = be_hword(var); }
- inline uint16_t operator=(uint16_t var) { set(var); return get();}
- inline uint16_t operator*() const { return get(); }
-private:
- uint16_t mVar;
-};
-
-class le_uint32_t {
-public:
- inline uint32_t get() const { return le_word(mVar);}
- inline void set(uint32_t var) { mVar = le_word(var); }
- inline uint32_t operator=(uint32_t var) { set(var); return get();}
- inline uint32_t operator*() const { return get(); }
-private:
- uint32_t mVar;
-};
-
-class be_uint32_t {
-public:
- inline uint32_t get() const { return be_word(mVar);}
- inline void set(uint32_t var) { mVar = be_word(var); }
- inline uint32_t operator=(uint32_t var) { set(var); return get();}
- inline uint32_t operator*() const { return get(); }
-private:
- uint32_t mVar;
-};
-
-class le_uint64_t {
-public:
- inline uint64_t get() const { return le_dword(mVar);}
- inline void set(uint64_t var) { mVar = le_dword(var); }
- inline uint64_t operator=(uint64_t var) { set(var); return get();}
- inline uint64_t operator*() const { return get(); }
-private:
- uint64_t mVar;
-};
-
-class be_uint64_t {
-public:
- inline uint64_t get() const { return be_dword(mVar);}
- inline void set(uint64_t var) { mVar = be_dword(var); }
- inline uint64_t operator=(uint64_t var) { set(var); return get();}
- inline uint64_t operator*() const { return get(); }
-private:
- uint64_t mVar;
-};
\ No newline at end of file
diff --git a/lib/libfnd/include/fnd/Exception.h b/lib/libfnd/include/fnd/Exception.h
deleted file mode 100644
index e26c45e..0000000
--- a/lib/libfnd/include/fnd/Exception.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#pragma once
-#include
-#include
-
-namespace fnd
-{
- class Exception : public std::exception
- {
- public:
- Exception() noexcept;
- Exception(const std::string& what) noexcept;
- Exception(const std::string& module, const std::string& what) noexcept;
-
- const char* what() const noexcept;
- const char* module() const noexcept;
- const char* error() const noexcept;
- private:
- std::string what_;
- std::string module_;
- std::string error_;
- };
-}
-
-
diff --git a/lib/libfnd/include/fnd/IByteModel.h b/lib/libfnd/include/fnd/IByteModel.h
deleted file mode 100644
index 6f92187..0000000
--- a/lib/libfnd/include/fnd/IByteModel.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#pragma once
-#include
-#include
-
-namespace fnd
-{
- class IByteModel
- {
- public:
- virtual ~IByteModel() = default;
-
- // serialise
- virtual void toBytes() = 0;
- // deserialise
- virtual void fromBytes(const byte_t* data, size_t len) = 0;
-
- // get byte vector
- virtual const fnd::Vec& getBytes() const = 0;
-
- // clear data
- virtual void clear() = 0;
- };
-}
\ No newline at end of file
diff --git a/lib/libfnd/include/fnd/IFile.h b/lib/libfnd/include/fnd/IFile.h
deleted file mode 100644
index e93bbf0..0000000
--- a/lib/libfnd/include/fnd/IFile.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#pragma once
-#include
-
-namespace fnd
-{
- class IFile
- {
- public:
- virtual ~IFile() = default;
-
- virtual size_t size() = 0;
- virtual void seek(size_t offset) = 0;
- virtual void read(byte_t* out, size_t len) = 0;
- virtual void read(byte_t* out, size_t offset, size_t len) = 0;
- virtual void write(const byte_t* out, size_t len) = 0;
- virtual void write(const byte_t* out, size_t offset, size_t len) = 0;
- };
-}
diff --git a/lib/libfnd/include/fnd/LayeredIntegrityMetadata.h b/lib/libfnd/include/fnd/LayeredIntegrityMetadata.h
deleted file mode 100644
index 7d1e3ac..0000000
--- a/lib/libfnd/include/fnd/LayeredIntegrityMetadata.h
+++ /dev/null
@@ -1,59 +0,0 @@
-#pragma once
-#include
-#include
-#include
-
-namespace fnd
-{
- class LayeredIntegrityMetadata
- {
- public:
- struct sLayer
- {
- size_t offset;
- size_t size;
- size_t block_size;
-
- void operator=(const sLayer& other)
- {
- offset = other.offset;
- size = other.size;
- block_size = other.block_size;
- }
-
- bool operator==(const sLayer& other) const
- {
- return (offset == other.offset && size == other.size && block_size == other.block_size);
- }
-
- bool operator!=(const sLayer& other) const
- {
- return !(*this == other);
- }
- };
-
- LayeredIntegrityMetadata();
-
- void operator=(const LayeredIntegrityMetadata& other);
- bool operator==(const LayeredIntegrityMetadata& other) const;
- bool operator!=(const LayeredIntegrityMetadata& other) const;
-
- const fnd::List& getHashLayerInfo() const;
- void setHashLayerInfo(const fnd::List& layer_info);
-
- const sLayer& getDataLayer() const;
- void setDataLayerInfo(const sLayer& data_info);
-
- const fnd::List& getMasterHashList() const;
- void setMasterHashList(const fnd::List& master_hash_list);
-
- bool getAlignHashToBlock() const;
- void setAlignHashToBlock(bool doAlign);
- private:
- // data
- fnd::List mLayerInfo;
- sLayer mDataLayer;
- fnd::List mMasterHashList;
- bool mDoAlignHashToBlock;
- };
-}
\ No newline at end of file
diff --git a/lib/libfnd/include/fnd/LayeredIntegrityWrappedIFile.h b/lib/libfnd/include/fnd/LayeredIntegrityWrappedIFile.h
deleted file mode 100644
index 2bc2a4d..0000000
--- a/lib/libfnd/include/fnd/LayeredIntegrityWrappedIFile.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#pragma once
-#include
-#include
-#include
-#include
-#include
-#include
-
-namespace fnd
-{
- class LayeredIntegrityWrappedIFile : public fnd::IFile
- {
- public:
- LayeredIntegrityWrappedIFile(const fnd::SharedPtr& file, const LayeredIntegrityMetadata& hdr);
-
- size_t size();
- void seek(size_t offset);
- void read(byte_t* out, size_t len);
- void read(byte_t* out, size_t offset, size_t len);
- void write(const byte_t* out, size_t len);
- void write(const byte_t* out, size_t offset, size_t len);
- private:
- const std::string kModuleName = "LayeredIntegrityWrappedIFile";
- static const size_t kDefaultCacheSize = 0x10000;
- std::stringstream mErrorSs;
-
- fnd::SharedPtr mFile;
-
- // data file
- fnd::SharedPtr mData;
- size_t mDataOffset;
- size_t mDataBlockSize;
- fnd::List mDataHashLayer;
- bool mAlignHashCalcToBlock;
-
- fnd::Vec mCache;
- size_t mCacheBlockNum;
-
- inline size_t getOffsetBlock(size_t offset) const { return offset / mDataBlockSize; }
- inline size_t getOffsetInBlock(size_t offset) const { return offset % mDataBlockSize; }
- inline size_t getRemanderBlockReadSize(size_t total_size) const { return total_size % mDataBlockSize; }
- inline size_t getBlockNum(size_t total_size) const { return (total_size / mDataBlockSize) + (getRemanderBlockReadSize(total_size) > 0); }
-
- void initialiseDataLayer(const LayeredIntegrityMetadata& hdr);
- void readData(size_t block_offset, size_t block_num);
- };
-}
\ No newline at end of file
diff --git a/lib/libfnd/include/fnd/List.h b/lib/libfnd/include/fnd/List.h
deleted file mode 100644
index d15d8ba..0000000
--- a/lib/libfnd/include/fnd/List.h
+++ /dev/null
@@ -1,167 +0,0 @@
-#pragma once
-#include
-#include
-//#include
-
-namespace fnd
-{
- template
- class List
- {
- public:
- // constructors
- List();
- List(const List& other);
-
- // copy operator
- void operator=(const List& other);
-
- // equivalence operators
- bool operator==(const List& other) const;
- bool operator!=(const List& other) const;
-
- // back relative insertion
- void addElement(const T& element);
-
- // element access
- const T& operator[](size_t index) const;
- T& operator[](size_t index);
- const T& atBack() const;
- T& atBack();
-
- // element num
- size_t size() const;
-
- // clear List
- void clear();
-
- // element access by key
- template
- bool hasElement(const K& key) const;
- template
- const T& getElement(const K& key) const;
- template
- T& getElement(const K& key);
-
- private:
- std::vector m_Vec;
- };
-
- template
- inline List::List() :
- m_Vec()
- {
- }
-
- template
- inline List::List(const List& other) :
- List()
- {
- *this = other;
- }
-
- template
- inline void List::operator=(const List& other)
- {
- m_Vec = other.m_Vec;
- }
-
- template
- inline bool List::operator==(const List& other) const
- {
- return m_Vec == other.m_Vec;
- }
-
- template
- inline bool List::operator!=(const List& other) const
- {
- return !(*this == other);
- }
-
- template
- inline void List::addElement(const T & element)
- {
- m_Vec.push_back(element);
- }
-
- template
- inline const T & List::operator[](size_t index) const
- {
- return m_Vec[index];
- }
-
- template
- inline T & List::operator[](size_t index)
- {
- return m_Vec[index];
- }
-
- template
- inline const T & List::atBack() const
- {
- return m_Vec.back();
- }
-
- template
- inline T & List::atBack()
- {
- return m_Vec.back();
- }
-
- template
- inline size_t List::size() const
- {
- return m_Vec.size();
- }
-
- template
- inline void List::clear()
- {
- m_Vec.clear();
- }
-
- template
- template
- inline bool List::hasElement(const K & key) const
- {
- for (size_t i = 0; i < m_Vec.size(); i++)
- {
- if (m_Vec[i] == key)
- {
- return true;
- }
- }
-
- return false;
- }
-
- template
- template
- inline const T & List::getElement(const K & key) const
- {
- for (size_t i = 0; i < m_Vec.size(); i++)
- {
- if (m_Vec[i] == key)
- {
- return m_Vec[i];
- }
- }
-
- throw fnd::Exception("getElement(): element does not exist");
- }
-
- template
- template
- inline T & List::getElement(const K & key)
- {
- for (size_t i = 0; i < m_Vec.size(); i++)
- {
- if (m_Vec[i] == key)
- {
- return m_Vec[i];
- }
- }
-
- throw fnd::Exception("getElement(): element does not exist");
- }
-}
diff --git a/lib/libfnd/include/fnd/OffsetAdjustedIFile.h b/lib/libfnd/include/fnd/OffsetAdjustedIFile.h
deleted file mode 100644
index 706e63c..0000000
--- a/lib/libfnd/include/fnd/OffsetAdjustedIFile.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#pragma once
-#include
-#include
-
-namespace fnd
-{
- class OffsetAdjustedIFile : public fnd::IFile
- {
- public:
- OffsetAdjustedIFile(const fnd::SharedPtr& file, size_t offset, size_t size);
-
- size_t size();
- void seek(size_t offset);
- void read(byte_t* out, size_t len);
- void read(byte_t* out, size_t offset, size_t len);
- void write(const byte_t* out, size_t len);
- void write(const byte_t* out, size_t offset, size_t len);
- private:
- fnd::SharedPtr mFile;
- size_t mBaseOffset, mCurrentOffset;
- size_t mSize;
- };
-}
\ No newline at end of file
diff --git a/lib/libfnd/include/fnd/ResourceFileReader.h b/lib/libfnd/include/fnd/ResourceFileReader.h
deleted file mode 100644
index ed9eb05..0000000
--- a/lib/libfnd/include/fnd/ResourceFileReader.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#pragma once
-#include
-#include