mirror of
https://github.com/jakcron/nstool
synced 2024-12-24 21:51:14 +00:00
Make source code about nstool only.
This commit is contained in:
parent
7b8612f246
commit
75aaff3010
289 changed files with 7258 additions and 43389 deletions
351
.gitignore
vendored
351
.gitignore
vendored
|
@ -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/
|
||||
|
|
97
.vscode/c_cpp_properties.json
vendored
97
.vscode/c_cpp_properties.json
vendored
|
@ -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
|
||||
}
|
40
.vscode/settings.json
vendored
40
.vscode/settings.json
vendored
|
@ -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"
|
||||
}
|
||||
}
|
21
.vscode/tasks.json
vendored
21
.vscode/tasks.json
vendored
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
19
BUILDING.md
Normal file
19
BUILDING.md
Normal file
|
@ -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`
|
48
LICENSE
48
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.
|
124
NNTools.sln
124
NNTools.sln
|
@ -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
|
119
NNTools.vcxproj
119
NNTools.vcxproj
|
@ -1,119 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{0A4197A1-76AD-4BF7-A29D-5CED369B72FD}</ProjectGuid>
|
||||
<RootNamespace>NNTools</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>NNTools</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -1,17 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
</Project>
|
93
README.md
93
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... ] <file>
|
||||
|
||||
# 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 <dir> --logo <dir> --normal <dir> --secure <dir>] <.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 <dir>] <file>
|
||||
--listfs Print file system.
|
||||
--fsdir Extract file system to directory.
|
||||
|
||||
NCA (Nintendo Content Archive)
|
||||
nstool [--listfs] [--bodykey <key> --titlekey <key>] [--part0 <dir> ...] <.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 <inst. type>] <file>
|
||||
--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 <dir>] <file>
|
||||
--kipdir Extract embedded KIPs to directory.
|
||||
|
||||
ASET (Homebrew Asset Blob)
|
||||
nstool [--listfs] [--icon <file> --nacp <file> --fsdir <dir>] <file>
|
||||
--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.
|
||||
See [BUILDING.md](/BUILDING.md).
|
129
build/visualstudio/nstool.sln
Normal file
129
build/visualstudio/nstool.sln
Normal file
|
@ -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
|
194
build/visualstudio/nstool/nstool.vcxproj
Normal file
194
build/visualstudio/nstool/nstool.vcxproj
Normal file
|
@ -0,0 +1,194 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{775EF5EB-CA49-4994-8AC4-47B4A5385266}</ProjectGuid>
|
||||
<RootNamespace>nstool</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>$(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</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>$(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</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>$(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</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>$(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</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\deps\libfnd\build\visualstudio\libfnd\libfnd.vcxproj">
|
||||
<Project>{4e578016-34ba-4a1e-b8ec-37a48780b6ca}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\deps\liblz4\build\visualstudio\liblz4\liblz4.vcxproj">
|
||||
<Project>{e741aded-7900-4e07-8db0-d008c336c3fb}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\deps\libnintendo-es\build\visualstudio\libnintendo-es\libnintendo-es.vcxproj">
|
||||
<Project>{8616d6c9-c8de-4c3f-afc2-625636664c2b}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\deps\libnintendo-hac-hb\build\visualstudio\libnintendo-hac-hb\libnintendo-hac-hb.vcxproj">
|
||||
<Project>{24d001b4-d439-4967-9371-dc3e0523eb19}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\deps\libnintendo-hac\build\visualstudio\libnintendo-hac\libnintendo-hac.vcxproj">
|
||||
<Project>{8885c125-83fb-4f73-a93a-c712b1434d54}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\deps\libnintendo-pki\build\visualstudio\libnintendo-pki\libnintendo-pki.vcxproj">
|
||||
<Project>{0bef63a0-2801-4563-ab65-1e2fd881c3af}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\deps\libpolarssl\build\visualstudio\libpolarssl\libpolarssl.vcxproj">
|
||||
<Project>{7a7c66f3-2b5b-4e23-85d8-2a74fedad92c}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\src\AssetProcess.cpp" />
|
||||
<ClCompile Include="..\..\..\src\CnmtProcess.cpp" />
|
||||
<ClCompile Include="..\..\..\src\ElfSymbolParser.cpp" />
|
||||
<ClCompile Include="..\..\..\src\EsTikProcess.cpp" />
|
||||
<ClCompile Include="..\..\..\src\GameCardProcess.cpp" />
|
||||
<ClCompile Include="..\..\..\src\IniProcess.cpp" />
|
||||
<ClCompile Include="..\..\..\src\KeyConfiguration.cpp" />
|
||||
<ClCompile Include="..\..\..\src\KipProcess.cpp" />
|
||||
<ClCompile Include="..\..\..\src\main.cpp" />
|
||||
<ClCompile Include="..\..\..\src\MetaProcess.cpp" />
|
||||
<ClCompile Include="..\..\..\src\NacpProcess.cpp" />
|
||||
<ClCompile Include="..\..\..\src\NcaProcess.cpp" />
|
||||
<ClCompile Include="..\..\..\src\NroProcess.cpp" />
|
||||
<ClCompile Include="..\..\..\src\NsoProcess.cpp" />
|
||||
<ClCompile Include="..\..\..\src\PfsProcess.cpp" />
|
||||
<ClCompile Include="..\..\..\src\PkiCertProcess.cpp" />
|
||||
<ClCompile Include="..\..\..\src\PkiValidator.cpp" />
|
||||
<ClCompile Include="..\..\..\src\RoMetadataProcess.cpp" />
|
||||
<ClCompile Include="..\..\..\src\RomfsProcess.cpp" />
|
||||
<ClCompile Include="..\..\..\src\SdkApiString.cpp" />
|
||||
<ClCompile Include="..\..\..\src\UserSettings.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\src\AssetProcess.h" />
|
||||
<ClInclude Include="..\..\..\src\CnmtProcess.h" />
|
||||
<ClInclude Include="..\..\..\src\common.h" />
|
||||
<ClInclude Include="..\..\..\src\ElfSymbolParser.h" />
|
||||
<ClInclude Include="..\..\..\src\EsTikProcess.h" />
|
||||
<ClInclude Include="..\..\..\src\GameCardProcess.h" />
|
||||
<ClInclude Include="..\..\..\src\IniProcess.h" />
|
||||
<ClInclude Include="..\..\..\src\KeyConfiguration.h" />
|
||||
<ClInclude Include="..\..\..\src\KipProcess.h" />
|
||||
<ClInclude Include="..\..\..\src\MetaProcess.h" />
|
||||
<ClInclude Include="..\..\..\src\NacpProcess.h" />
|
||||
<ClInclude Include="..\..\..\src\NcaProcess.h" />
|
||||
<ClInclude Include="..\..\..\src\NroProcess.h" />
|
||||
<ClInclude Include="..\..\..\src\NsoProcess.h" />
|
||||
<ClInclude Include="..\..\..\src\PfsProcess.h" />
|
||||
<ClInclude Include="..\..\..\src\PkiCertProcess.h" />
|
||||
<ClInclude Include="..\..\..\src\PkiValidator.h" />
|
||||
<ClInclude Include="..\..\..\src\RoMetadataProcess.h" />
|
||||
<ClInclude Include="..\..\..\src\RomfsProcess.h" />
|
||||
<ClInclude Include="..\..\..\src\SdkApiString.h" />
|
||||
<ClInclude Include="..\..\..\src\UserSettings.h" />
|
||||
<ClInclude Include="..\..\..\src\version.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -1,154 +1,150 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="makefile" />
|
||||
<None Include="README.md" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="source\AssetProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="source\CnmtProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="source\common.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="source\ElfSymbolParser.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="source\EsTikProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="source\GameCardProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="source\IniProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="source\KeyConfiguration.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="source\KipProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="source\MetaProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="source\NacpProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="source\NcaProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="source\NroProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="source\NsoProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="source\PfsProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="source\PkiCertProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="source\PkiValidator.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="source\RoMetadataProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="source\RomfsProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="source\SdkApiString.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="source\UserSettings.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="source\version.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="source\AssetProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\CnmtProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\ElfSymbolParser.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\EsTikProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\GameCardProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\IniProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\KeyConfiguration.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\KipProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\MetaProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\NacpProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\NcaProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\NroProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\NsoProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\PfsProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\PkiCertProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\PkiValidator.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\RoMetadataProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\RomfsProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\SdkApiString.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\UserSettings.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\src\AssetProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\CnmtProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\ElfSymbolParser.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\EsTikProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\GameCardProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\IniProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\KeyConfiguration.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\KipProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\MetaProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\NacpProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\NcaProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\NroProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\NsoProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\PfsProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\PkiCertProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\PkiValidator.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\RoMetadataProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\RomfsProcess.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\SdkApiString.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\UserSettings.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\src\AssetProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\CnmtProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\common.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\ElfSymbolParser.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\EsTikProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\GameCardProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\IniProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\KeyConfiguration.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\KipProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\MetaProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\NacpProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\NcaProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\NroProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\NsoProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\PfsProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\PkiCertProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\PkiValidator.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\RoMetadataProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\RomfsProcess.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\SdkApiString.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\UserSettings.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\version.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,58 +0,0 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <nn/es/ticket.h>
|
||||
|
||||
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<byte_t>& 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<byte_t> mRawBinary;
|
||||
|
||||
// variables
|
||||
uint32_t mSectionOffset;
|
||||
uint32_t mRecordSize;
|
||||
uint32_t mSectionSize;
|
||||
uint16_t mRecordNum;
|
||||
ticket::SectionType mSectionType;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <fnd/List.h>
|
||||
#include <nn/es/ticket.h>
|
||||
|
||||
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<byte_t>& 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<es::ticket::PropertyMaskFlags>& getPropertyFlags() const;
|
||||
void setPropertyFlags(const fnd::List<es::ticket::PropertyMaskFlags>& 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<byte_t> mRawBinary;
|
||||
|
||||
// variables
|
||||
std::string mIssuer;
|
||||
byte_t mEncTitleKey[ticket::kEncTitleKeySize];
|
||||
ticket::TitleKeyEncType mEncType;
|
||||
uint16_t mTicketVersion;
|
||||
ticket::LicenseType mLicenseType;
|
||||
byte_t mCommonKeyId;
|
||||
fnd::List<es::ticket::PropertyMaskFlags> 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;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,111 +0,0 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <fnd/types.h>
|
||||
#include <fnd/rsa.h>
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
|
@ -1,134 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{7BE99936-0D40-410D-944B-4513C2EFF8DC}</ProjectGuid>
|
||||
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\libfnd\include;..\libes\include;</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\libfnd\include;..\libes\include;</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\libfnd\include;..\libes\include;</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\libfnd\include;..\libes\include;</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<None Include="makefile" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\nn\es\SectionHeader_V2.h" />
|
||||
<ClInclude Include="include\nn\es\ticket.h" />
|
||||
<ClInclude Include="include\nn\es\TicketBody_V2.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="source\SectionHeader_V2.cpp" />
|
||||
<ClCompile Include="source\TicketBody_V2.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -1,39 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="makefile" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\nn\es\SectionHeader_V2.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\nn\es\ticket.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\nn\es\TicketBody_V2.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="source\SectionHeader_V2.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\TicketBody_V2.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,4 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
</Project>
|
|
@ -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)
|
|
@ -1,139 +0,0 @@
|
|||
#include <nn/es/SectionHeader_V2.h>
|
||||
|
||||
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<byte_t>& 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;
|
||||
}
|
||||
|
||||
|
|
@ -1,326 +0,0 @@
|
|||
#include <nn/es/TicketBody_V2.h>
|
||||
|
||||
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<byte_t>& 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::ticket::PropertyMaskFlags>& nn::es::TicketBody_V2::getPropertyFlags() const
|
||||
{
|
||||
return mPropertyFlags;
|
||||
}
|
||||
|
||||
void nn::es::TicketBody_V2::setPropertyFlags(const fnd::List<nn::es::ticket::PropertyMaskFlags>& 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;
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
#pragma once
|
||||
#include <fnd/IFile.h>
|
||||
#include <fnd/SharedPtr.h>
|
||||
#include <fnd/Vec.h>
|
||||
#include <fnd/aes.h>
|
||||
|
||||
namespace fnd
|
||||
{
|
||||
class AesCtrWrappedIFile : public fnd::IFile
|
||||
{
|
||||
public:
|
||||
AesCtrWrappedIFile(const fnd::SharedPtr<fnd::IFile>& 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<fnd::IFile> mFile;
|
||||
fnd::aes::sAes128Key mKey;
|
||||
fnd::aes::sAesIvCtr mBaseCtr, mCurrentCtr;
|
||||
size_t mFileOffset;
|
||||
|
||||
fnd::Vec<byte_t> mCache;
|
||||
};
|
||||
}
|
|
@ -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)
|
|
@ -1,118 +0,0 @@
|
|||
#pragma once
|
||||
#include <cinttypes>
|
||||
|
||||
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 T, static T (*F)(T)>
|
||||
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<uint16_t, le_hword> le_uint16_t;
|
||||
typedef ISerialiseablePrimative<uint16_t, be_hword> be_uint16_t;
|
||||
typedef ISerialiseablePrimative<uint32_t, le_word> le_uint32_t;
|
||||
typedef ISerialiseablePrimative<uint32_t, be_word> be_uint32_t;
|
||||
typedef ISerialiseablePrimative<uint64_t, le_dword> le_uint64_t;
|
||||
typedef ISerialiseablePrimative<uint64_t, be_dword> 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;
|
||||
};
|
|
@ -1,24 +0,0 @@
|
|||
#pragma once
|
||||
#include <exception>
|
||||
#include <string>
|
||||
|
||||
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_;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
#pragma once
|
||||
#include <fnd/types.h>
|
||||
#include <fnd/Vec.h>
|
||||
|
||||
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<byte_t>& getBytes() const = 0;
|
||||
|
||||
// clear data
|
||||
virtual void clear() = 0;
|
||||
};
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
#pragma once
|
||||
#include <fnd/types.h>
|
||||
|
||||
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;
|
||||
};
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
#pragma once
|
||||
#include <fnd/types.h>
|
||||
#include <fnd/List.h>
|
||||
#include <fnd/sha.h>
|
||||
|
||||
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<sLayer>& getHashLayerInfo() const;
|
||||
void setHashLayerInfo(const fnd::List<sLayer>& layer_info);
|
||||
|
||||
const sLayer& getDataLayer() const;
|
||||
void setDataLayerInfo(const sLayer& data_info);
|
||||
|
||||
const fnd::List<fnd::sha::sSha256Hash>& getMasterHashList() const;
|
||||
void setMasterHashList(const fnd::List<fnd::sha::sSha256Hash>& master_hash_list);
|
||||
|
||||
bool getAlignHashToBlock() const;
|
||||
void setAlignHashToBlock(bool doAlign);
|
||||
private:
|
||||
// data
|
||||
fnd::List<sLayer> mLayerInfo;
|
||||
sLayer mDataLayer;
|
||||
fnd::List<fnd::sha::sSha256Hash> mMasterHashList;
|
||||
bool mDoAlignHashToBlock;
|
||||
};
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
#pragma once
|
||||
#include <sstream>
|
||||
#include <fnd/IFile.h>
|
||||
#include <fnd/SharedPtr.h>
|
||||
#include <fnd/Vec.h>
|
||||
#include <fnd/List.h>
|
||||
#include <fnd/LayeredIntegrityMetadata.h>
|
||||
|
||||
namespace fnd
|
||||
{
|
||||
class LayeredIntegrityWrappedIFile : public fnd::IFile
|
||||
{
|
||||
public:
|
||||
LayeredIntegrityWrappedIFile(const fnd::SharedPtr<fnd::IFile>& 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<fnd::IFile> mFile;
|
||||
|
||||
// data file
|
||||
fnd::SharedPtr<fnd::IFile> mData;
|
||||
size_t mDataOffset;
|
||||
size_t mDataBlockSize;
|
||||
fnd::List<fnd::sha::sSha256Hash> mDataHashLayer;
|
||||
bool mAlignHashCalcToBlock;
|
||||
|
||||
fnd::Vec<byte_t> 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);
|
||||
};
|
||||
}
|
|
@ -1,167 +0,0 @@
|
|||
#pragma once
|
||||
#include <fnd/types.h>
|
||||
#include <vector>
|
||||
//#include <fnd/Vec.h>
|
||||
|
||||
namespace fnd
|
||||
{
|
||||
template <class T>
|
||||
class List
|
||||
{
|
||||
public:
|
||||
// constructors
|
||||
List();
|
||||
List(const List<T>& other);
|
||||
|
||||
// copy operator
|
||||
void operator=(const List<T>& other);
|
||||
|
||||
// equivalence operators
|
||||
bool operator==(const List<T>& other) const;
|
||||
bool operator!=(const List<T>& 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 <class K>
|
||||
bool hasElement(const K& key) const;
|
||||
template <class K>
|
||||
const T& getElement(const K& key) const;
|
||||
template <class K>
|
||||
T& getElement(const K& key);
|
||||
|
||||
private:
|
||||
std::vector<T> m_Vec;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
inline List<T>::List() :
|
||||
m_Vec()
|
||||
{
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline List<T>::List(const List<T>& other) :
|
||||
List()
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void List<T>::operator=(const List<T>& other)
|
||||
{
|
||||
m_Vec = other.m_Vec;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool List<T>::operator==(const List<T>& other) const
|
||||
{
|
||||
return m_Vec == other.m_Vec;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool List<T>::operator!=(const List<T>& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void List<T>::addElement(const T & element)
|
||||
{
|
||||
m_Vec.push_back(element);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const T & List<T>::operator[](size_t index) const
|
||||
{
|
||||
return m_Vec[index];
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T & List<T>::operator[](size_t index)
|
||||
{
|
||||
return m_Vec[index];
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const T & List<T>::atBack() const
|
||||
{
|
||||
return m_Vec.back();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T & List<T>::atBack()
|
||||
{
|
||||
return m_Vec.back();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline size_t List<T>::size() const
|
||||
{
|
||||
return m_Vec.size();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void List<T>::clear()
|
||||
{
|
||||
m_Vec.clear();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
template<class K>
|
||||
inline bool List<T>::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<class T>
|
||||
template<class K>
|
||||
inline const T & List<T>::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<class T>
|
||||
template<class K>
|
||||
inline T & List<T>::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");
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
#pragma once
|
||||
#include <fnd/IFile.h>
|
||||
#include <fnd/SharedPtr.h>
|
||||
|
||||
namespace fnd
|
||||
{
|
||||
class OffsetAdjustedIFile : public fnd::IFile
|
||||
{
|
||||
public:
|
||||
OffsetAdjustedIFile(const fnd::SharedPtr<fnd::IFile>& 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<fnd::IFile> mFile;
|
||||
size_t mBaseOffset, mCurrentOffset;
|
||||
size_t mSize;
|
||||
};
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
namespace fnd
|
||||
{
|
||||
class ResourceFileReader
|
||||
{
|
||||
public:
|
||||
ResourceFileReader();
|
||||
|
||||
void processFile(const std::string& path);
|
||||
|
||||
bool doesExist(const std::string& key) const;
|
||||
const std::string& operator[](const std::string& key);
|
||||
|
||||
private:
|
||||
const std::string kModuleName = "ResourceFileReader";
|
||||
|
||||
std::map<std::string,std::string> mResources;
|
||||
};
|
||||
}
|
|
@ -1,141 +0,0 @@
|
|||
#pragma once
|
||||
#include <fnd/types.h>
|
||||
#include <cstdio>
|
||||
|
||||
namespace fnd
|
||||
{
|
||||
template <class T>
|
||||
class SharedPtr
|
||||
{
|
||||
public:
|
||||
SharedPtr();
|
||||
|
||||
// constructor for creating owner object
|
||||
SharedPtr(T* ptr);
|
||||
|
||||
// copy constructor
|
||||
SharedPtr(const SharedPtr<T>& other);
|
||||
|
||||
// destructor
|
||||
~SharedPtr();
|
||||
|
||||
// own operator
|
||||
void operator=(T* ptr);
|
||||
|
||||
// copy operator
|
||||
void operator=(const SharedPtr<T>& other);
|
||||
|
||||
// access ptr
|
||||
const T* operator*() const;
|
||||
T* operator*();
|
||||
|
||||
private:
|
||||
T* mPtr;
|
||||
size_t* mRefCnt;
|
||||
|
||||
void deletePtr();
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline SharedPtr<T>::SharedPtr() :
|
||||
mPtr(nullptr),
|
||||
mRefCnt(new size_t)
|
||||
{
|
||||
*mRefCnt = 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline SharedPtr<T>::SharedPtr(T* ptr) :
|
||||
SharedPtr()
|
||||
{
|
||||
*this = ptr;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline SharedPtr<T>::SharedPtr(const SharedPtr<T>& other) :
|
||||
SharedPtr()
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline SharedPtr<T>::~SharedPtr()
|
||||
{
|
||||
deletePtr();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void SharedPtr<T>::operator=(T* ptr)
|
||||
{
|
||||
deletePtr();
|
||||
if (ptr != nullptr)
|
||||
{
|
||||
mPtr = ptr;
|
||||
mRefCnt = new size_t;
|
||||
*mRefCnt = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
mPtr = nullptr;
|
||||
mRefCnt = new size_t;
|
||||
*mRefCnt = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void SharedPtr<T>::operator=(const SharedPtr<T>& other)
|
||||
{
|
||||
deletePtr();
|
||||
|
||||
mPtr = other.mPtr;
|
||||
mRefCnt = other.mRefCnt;
|
||||
*mRefCnt += 1;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline const T* SharedPtr<T>::operator*() const
|
||||
{
|
||||
return mPtr;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T* SharedPtr<T>::operator*()
|
||||
{
|
||||
return mPtr;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void SharedPtr<T>::deletePtr()
|
||||
{
|
||||
// if this is not the last reference
|
||||
if (*mRefCnt > 1)
|
||||
{
|
||||
// decrement reference count
|
||||
*mRefCnt -= 1;
|
||||
|
||||
// make ptrs null
|
||||
mPtr = nullptr;
|
||||
mRefCnt = nullptr;
|
||||
}
|
||||
// if this is the last refeference
|
||||
else if (*mRefCnt == 1)
|
||||
{
|
||||
// delete memory
|
||||
delete mPtr;
|
||||
delete mRefCnt;
|
||||
|
||||
// make ptrs null
|
||||
mPtr = nullptr;
|
||||
mRefCnt = nullptr;
|
||||
}
|
||||
// else if this is an empty refernce
|
||||
else if (*mRefCnt == 0)
|
||||
{
|
||||
delete mRefCnt;
|
||||
|
||||
mPtr = nullptr;
|
||||
mRefCnt = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
#pragma once
|
||||
#include <fnd/IFile.h>
|
||||
#include <string>
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
namespace fnd
|
||||
{
|
||||
class SimpleFile : public IFile
|
||||
{
|
||||
public:
|
||||
enum OpenMode
|
||||
{
|
||||
Read,
|
||||
Edit,
|
||||
Create
|
||||
};
|
||||
|
||||
SimpleFile();
|
||||
SimpleFile(const std::string& path, OpenMode mode);
|
||||
~SimpleFile();
|
||||
|
||||
void open(const std::string& path, OpenMode mode);
|
||||
bool isOpen() const;
|
||||
void close();
|
||||
size_t size();
|
||||
void seek(size_t offset);
|
||||
size_t pos();
|
||||
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 = "SimpleFile";
|
||||
|
||||
bool mOpen;
|
||||
OpenMode mMode;
|
||||
|
||||
#ifdef _WIN32
|
||||
HANDLE mFileHandle;
|
||||
DWORD getOpenModeFlag(OpenMode mode) const;
|
||||
DWORD getShareModeFlag(OpenMode mode) const;
|
||||
DWORD getCreationModeFlag(OpenMode mode) const;
|
||||
#else
|
||||
FILE* mFp;
|
||||
const char* getOpenModeStr(OpenMode mode);
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <fnd/types.h>
|
||||
#include <fnd/Vec.h>
|
||||
|
||||
namespace fnd
|
||||
{
|
||||
class SimpleTextOutput
|
||||
{
|
||||
public:
|
||||
static void hxdStyleDump(const byte_t* data, size_t len, size_t row_len, size_t byte_grouping_size);
|
||||
static void hxdStyleDump(const byte_t* data, size_t len);
|
||||
static void hexDump(const byte_t* data, size_t len, size_t row_len, size_t indent_len);
|
||||
static void hexDump(const byte_t* data, size_t len);
|
||||
static std::string arrayToString(const byte_t* data, size_t len, bool upper_case, const std::string& separator);
|
||||
static void stringToArray(const std::string& str, fnd::Vec<byte_t>& array);
|
||||
|
||||
private:
|
||||
static const size_t kDefaultRowLen = 0x10;
|
||||
static const size_t kDefaultByteGroupingSize = 1;
|
||||
};
|
||||
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
#pragma once
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
|
||||
namespace fnd
|
||||
{
|
||||
class StringConv
|
||||
{
|
||||
public:
|
||||
static std::u16string ConvertChar8ToChar16(const std::string& in);
|
||||
static std::string ConvertChar16ToChar8(const std::u16string& in);
|
||||
|
||||
private:
|
||||
static const char32_t kUtf16EncodeMax = 0x10FFFF;
|
||||
static const char32_t kUtf16NonNativeStart = 0x10000;
|
||||
static const char16_t kUtf16SurrogateBits = 10;
|
||||
static const char16_t kUtf16SurrogateMask = (1 << kUtf16SurrogateBits) - 1;
|
||||
static const char16_t kUtf16HighSurrogateStart = 0xD800;
|
||||
static const char16_t kUtf16HighSurrogateEnd = kUtf16HighSurrogateStart | kUtf16SurrogateMask;
|
||||
static const char16_t kUtf16LowSurrogateStart = 0xDC00;
|
||||
static const char16_t kUtf16LowSurrogateEnd = kUtf16LowSurrogateStart | kUtf16SurrogateMask;
|
||||
|
||||
static const char32_t kUtf8AsciiStart = 0x00;
|
||||
static const char32_t kUtf8AsciiEnd = 0x7F;
|
||||
static const char32_t kUtf82ByteStart = 0x80;
|
||||
static const char32_t kUtf82ByteEnd = 0x7FF;
|
||||
static const char32_t kUtf83ByteStart = 0x800;
|
||||
static const char32_t kUtf83ByteEnd = 0x7FFF;
|
||||
static const char32_t kUtf84ByteStart = 0x8000;
|
||||
static const char32_t kUtf84ByteEnd = 0x10FFFF;
|
||||
|
||||
|
||||
static inline uint8_t make_utf8_prefix(uint8_t prefix_bits) { return ((uint8_t)(-1)) << (8 - prefix_bits); }
|
||||
static inline uint8_t make_utf8_mask(uint8_t prefix_bits) { return ((uint8_t)(-1)) >> (prefix_bits + 1); }
|
||||
static inline uint8_t make_utf8(uint8_t prefix_bits, uint8_t data) { return make_utf8_prefix(prefix_bits) | (data & make_utf8_mask(prefix_bits)); }
|
||||
static inline uint8_t get_utf8_data(uint8_t prefix_bits, uint8_t utf8_chr) { return utf8_chr & make_utf8_mask(prefix_bits); }
|
||||
static inline bool utf8_has_prefix(uint8_t prefix_bits, uint8_t utf8_chr) { return ((utf8_chr & make_utf8_prefix(prefix_bits)) == make_utf8_prefix(prefix_bits)) && ((utf8_chr & ~make_utf8_mask(prefix_bits)) == make_utf8_prefix(prefix_bits)); }
|
||||
static inline uint8_t get_utf8_prefix(uint8_t utf8_chr)
|
||||
{
|
||||
uint8_t prefix = 0;
|
||||
while ((utf8_chr & (1 << 7)) != 0)
|
||||
{
|
||||
utf8_chr <<= 1;
|
||||
prefix++;
|
||||
}
|
||||
return prefix;
|
||||
}
|
||||
};
|
||||
}
|
|
@ -1,207 +0,0 @@
|
|||
#pragma once
|
||||
#include <fnd/types.h>
|
||||
|
||||
namespace fnd
|
||||
{
|
||||
template <class T>
|
||||
class Vec
|
||||
{
|
||||
public:
|
||||
// constructors
|
||||
Vec();
|
||||
Vec(const Vec<T>& other);
|
||||
Vec(const T* array, size_t num);
|
||||
~Vec();
|
||||
|
||||
// copy operator
|
||||
void operator=(const Vec<T>& other);
|
||||
|
||||
// equivalence operators
|
||||
bool operator==(const Vec<T>& other) const;
|
||||
bool operator!=(const Vec<T>& other) const;
|
||||
|
||||
// element access
|
||||
const T& operator[](size_t index) const;
|
||||
T& operator[](size_t index);
|
||||
|
||||
// raw access
|
||||
const T* data() const;
|
||||
T* data();
|
||||
|
||||
// element num
|
||||
size_t size() const;
|
||||
|
||||
// allocate vector
|
||||
void alloc(size_t new_size);
|
||||
|
||||
// resize vector
|
||||
void resize(size_t new_size);
|
||||
|
||||
// clear vector
|
||||
void clear();
|
||||
private:
|
||||
T* m_Vec;
|
||||
size_t m_Size;
|
||||
|
||||
void copyFrom(const T * array, size_t num);
|
||||
};
|
||||
|
||||
template<class T>
|
||||
inline Vec<T>::Vec() :
|
||||
m_Vec(nullptr),
|
||||
m_Size(0)
|
||||
{}
|
||||
|
||||
template<class T>
|
||||
inline Vec<T>::Vec(const Vec<T>& other) :
|
||||
Vec()
|
||||
{
|
||||
copyFrom(other.data(), other.size());
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Vec<T>::Vec(const T * array, size_t num) :
|
||||
Vec()
|
||||
{
|
||||
copyFrom(array, num);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Vec<T>::~Vec()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void Vec<T>::operator=(const Vec<T>& other)
|
||||
{
|
||||
copyFrom(other.data(), other.size());
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool Vec<T>::operator==(const Vec<T>& other) const
|
||||
{
|
||||
bool isEqual = true;
|
||||
|
||||
if (m_Size == other.m_Size)
|
||||
{
|
||||
for (size_t i = 0; i < m_Size && isEqual; i++)
|
||||
{
|
||||
if (m_Vec[i] != other.m_Vec[i])
|
||||
{
|
||||
isEqual = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
isEqual = false;
|
||||
}
|
||||
|
||||
return isEqual;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool Vec<T>::operator!=(const Vec<T>& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const T & Vec<T>::operator[](size_t index) const
|
||||
{
|
||||
return m_Vec[index];
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T & Vec<T>::operator[](size_t index)
|
||||
{
|
||||
return m_Vec[index];
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const T * Vec<T>::data() const
|
||||
{
|
||||
return m_Vec;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T * Vec<T>::data()
|
||||
{
|
||||
return m_Vec;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline size_t Vec<T>::size() const
|
||||
{
|
||||
return m_Size;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void Vec<T>::alloc(size_t new_size)
|
||||
{
|
||||
clear();
|
||||
m_Vec = new T[new_size];
|
||||
if (m_Vec == nullptr)
|
||||
{
|
||||
fnd::Exception("Vec", "Failed to allocate memory for vector");
|
||||
}
|
||||
for (size_t i = 0; i < new_size; i++)
|
||||
{
|
||||
m_Vec[i] = 0;
|
||||
}
|
||||
|
||||
m_Size = new_size;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void Vec<T>::resize(size_t new_size)
|
||||
{
|
||||
if (m_Vec != nullptr)
|
||||
{
|
||||
T* new_vec = new T[new_size];
|
||||
if (new_vec == nullptr)
|
||||
{
|
||||
fnd::Exception("Vec", "Failed to allocate memory for vector");
|
||||
}
|
||||
for (size_t i = 0; i < new_size; i++)
|
||||
{
|
||||
new_vec[i] = 0;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < _MIN(m_Size, new_size); i++)
|
||||
{
|
||||
new_vec[i] = m_Vec[i];
|
||||
}
|
||||
delete[] m_Vec;
|
||||
m_Vec = new_vec;
|
||||
m_Size = new_size;
|
||||
}
|
||||
else
|
||||
{
|
||||
alloc(new_size);
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void Vec<T>::clear()
|
||||
{
|
||||
if (m_Vec != nullptr)
|
||||
{
|
||||
delete[] m_Vec;
|
||||
}
|
||||
m_Vec = nullptr;
|
||||
m_Size = 0;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void Vec<T>::copyFrom(const T * array, size_t num)
|
||||
{
|
||||
clear();
|
||||
alloc(num);
|
||||
for (size_t i = 0; i < m_Size; i++)
|
||||
{
|
||||
m_Vec[i] = array[i];
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,117 +0,0 @@
|
|||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
namespace fnd
|
||||
{
|
||||
namespace aes
|
||||
{
|
||||
const size_t kAes128KeySize = 0x10;
|
||||
const size_t kAesBlockSize = 0x10;
|
||||
const size_t KAesCcmNonceSize = 0xc;
|
||||
|
||||
#pragma pack (push, 1)
|
||||
struct sAes128Key
|
||||
{
|
||||
uint8_t key[kAes128KeySize];
|
||||
|
||||
void set(const uint8_t key[kAes128KeySize])
|
||||
{
|
||||
memcpy(this->key, key, kAes128KeySize);
|
||||
}
|
||||
|
||||
bool compare(const sAes128Key& other) const
|
||||
{
|
||||
return memcmp(this->key, other.key, kAes128KeySize) == 0;
|
||||
}
|
||||
|
||||
void operator=(const sAes128Key& other)
|
||||
{
|
||||
set(other.key);
|
||||
}
|
||||
bool operator==(const sAes128Key& other) const
|
||||
{
|
||||
return compare(other);
|
||||
}
|
||||
bool operator!=(const sAes128Key& other) const
|
||||
{
|
||||
return !compare(other);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct sAesXts128Key
|
||||
{
|
||||
uint8_t key[2][kAes128KeySize];
|
||||
|
||||
void set(const uint8_t key_0[kAes128KeySize], const uint8_t key_1[kAes128KeySize])
|
||||
{
|
||||
memcpy(this->key[0], key_0, kAes128KeySize);
|
||||
memcpy(this->key[1], key_1, kAes128KeySize);
|
||||
}
|
||||
|
||||
bool compare(const sAesXts128Key& other) const
|
||||
{
|
||||
return memcmp(this->key[0], other.key[0], kAes128KeySize) == 0 && memcmp(this->key[1], other.key[1], kAes128KeySize) == 0;
|
||||
}
|
||||
|
||||
void operator=(const sAesXts128Key& other)
|
||||
{
|
||||
set(other.key[0], other.key[1]);
|
||||
}
|
||||
bool operator==(const sAesXts128Key& other) const
|
||||
{
|
||||
return compare(other);
|
||||
}
|
||||
bool operator!=(const sAesXts128Key& other) const
|
||||
{
|
||||
return !compare(other);
|
||||
}
|
||||
};
|
||||
|
||||
struct sAesIvCtr
|
||||
{
|
||||
uint8_t iv[kAesBlockSize];
|
||||
|
||||
void set(const uint8_t iv[kAes128KeySize])
|
||||
{
|
||||
memcpy(this->iv, iv, kAes128KeySize);
|
||||
}
|
||||
|
||||
bool compare(const sAesIvCtr& other) const
|
||||
{
|
||||
return memcmp(this->iv, other.iv, kAesBlockSize) == 0;
|
||||
}
|
||||
|
||||
void operator=(const sAesIvCtr& other)
|
||||
{
|
||||
set(other.iv);
|
||||
}
|
||||
bool operator==(const sAesIvCtr& other) const
|
||||
{
|
||||
return compare(other);
|
||||
}
|
||||
bool operator!=(const sAesIvCtr& other) const
|
||||
{
|
||||
return !compare(other);
|
||||
}
|
||||
};
|
||||
#pragma pack (pop)
|
||||
|
||||
// aes-128
|
||||
void AesEcbDecrypt(const uint8_t* in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t* out);
|
||||
void AesEcbEncrypt(const uint8_t* in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t* out);
|
||||
|
||||
void AesCtr(const uint8_t* in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t ctr[kAesBlockSize], uint8_t* out);
|
||||
void AesIncrementCounter(const uint8_t in[kAesBlockSize], size_t block_num, uint8_t out[kAesBlockSize]);
|
||||
|
||||
void AesCbcDecrypt(const uint8_t* in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t iv[kAesBlockSize], uint8_t* out);
|
||||
void AesCbcEncrypt(const uint8_t* in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t iv[kAesBlockSize], uint8_t* out);
|
||||
|
||||
void AesXtsDecryptSector(const uint8_t* in, uint64_t sector_size, const uint8_t key1[kAes128KeySize], const uint8_t key2[kAes128KeySize], uint8_t tweak[kAesBlockSize], uint8_t* out);
|
||||
void AesXtsEncryptSector(const uint8_t* in, uint64_t sector_size, const uint8_t key1[kAes128KeySize], const uint8_t key2[kAes128KeySize], uint8_t tweak[kAesBlockSize], uint8_t* out);
|
||||
void AesXtsMakeTweak(uint8_t tweak[kAesBlockSize], size_t block_index);
|
||||
|
||||
void GaloisFunc(uint8_t x[kAesBlockSize]);
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
namespace fnd
|
||||
{
|
||||
namespace base64
|
||||
{
|
||||
size_t B64_GetEncodeLen(const uint8_t* src, size_t slen);
|
||||
void B64_Encode(const uint8_t* src, size_t slen, uint8_t* dst, size_t dlen);
|
||||
size_t B64_GetDecodeLen(const uint8_t* src, size_t slen);
|
||||
void B64_Decode(const uint8_t* src, size_t slen, uint8_t* dst, size_t dlen);
|
||||
}
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
namespace fnd
|
||||
{
|
||||
namespace ecdsa
|
||||
{
|
||||
const size_t kEcdsa240Size = 0x1E;
|
||||
|
||||
enum EcdsaType
|
||||
{
|
||||
ECDSA_240,
|
||||
};
|
||||
|
||||
#pragma pack (push, 1)
|
||||
struct sEcdsa240Point
|
||||
{
|
||||
uint8_t r[kEcdsa240Size];
|
||||
uint8_t s[kEcdsa240Size];
|
||||
|
||||
void operator=(const sEcdsa240Point& other)
|
||||
{
|
||||
memcpy(this->r, other.r, kEcdsa240Size);
|
||||
memcpy(this->s, other.s, kEcdsa240Size);
|
||||
}
|
||||
|
||||
bool operator==(const sEcdsa240Point& other) const
|
||||
{
|
||||
return memcmp(this->r, other.r, kEcdsa240Size) == 0 \
|
||||
&& memcmp(this->s, other.s, kEcdsa240Size) == 0;
|
||||
}
|
||||
|
||||
bool operator!=(const sEcdsa240Point& other) const
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
};
|
||||
|
||||
struct sEcdsa240PrivateKey
|
||||
{
|
||||
uint8_t k[kEcdsa240Size];
|
||||
|
||||
void operator=(const sEcdsa240PrivateKey& other)
|
||||
{
|
||||
memcpy(this->k, other.k, kEcdsa240Size);
|
||||
}
|
||||
|
||||
bool operator==(const sEcdsa240PrivateKey& other) const
|
||||
{
|
||||
return memcmp(this->k, other.k, kEcdsa240Size) == 0;
|
||||
}
|
||||
|
||||
bool operator!=(const sEcdsa240PrivateKey& other) const
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
};
|
||||
|
||||
struct sEcdsa240Key
|
||||
{
|
||||
sEcdsa240Point pub;
|
||||
sEcdsa240PrivateKey pvt;
|
||||
|
||||
void operator=(const sEcdsa240Key& other)
|
||||
{
|
||||
this->pub = other.pub;
|
||||
this->pvt = other.pvt;
|
||||
}
|
||||
|
||||
bool operator==(const sEcdsa240Key& other) const
|
||||
{
|
||||
return this->pub == other.pub && this->pvt == other.pvt;
|
||||
}
|
||||
|
||||
bool operator!=(const sEcdsa240Key& other) const
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
};
|
||||
#pragma pack (pop)
|
||||
}
|
||||
}
|
|
@ -1,458 +0,0 @@
|
|||
#pragma once
|
||||
#include "types.h"
|
||||
|
||||
namespace fnd
|
||||
{
|
||||
namespace elf
|
||||
{
|
||||
/* These constants are for the segment types stored in the image headers */
|
||||
enum SegmentType
|
||||
{
|
||||
PT_NULL = 0,
|
||||
PT_LOAD = 1,
|
||||
PT_DYNAMIC = 2,
|
||||
PT_INTERP = 3,
|
||||
PT_NOTE = 4,
|
||||
PT_SHLIB = 5,
|
||||
PT_PHDR = 6,
|
||||
PT_TLS = 7, /* Thread local storage segment */
|
||||
PT_LOOS = 0x60000000, /* OS-specific */
|
||||
PT_HIOS = 0x6fffffff, /* OS-specific */
|
||||
PT_LOPROC = 0x70000000,
|
||||
PT_HIPROC = 0x7fffffff
|
||||
};
|
||||
|
||||
/* These constants define the different elf file types */
|
||||
enum ElfType
|
||||
{
|
||||
ET_NONE = 0,
|
||||
ET_REL = 1,
|
||||
ET_EXEC = 2,
|
||||
ET_DYN = 3,
|
||||
ET_CORE = 4,
|
||||
ET_LOPROC = 0xff00,
|
||||
ET_HIPROC = 0xffff
|
||||
};
|
||||
|
||||
/* This is the info that is needed to parse the dynamic section of the file */
|
||||
enum DynamicSectionType
|
||||
{
|
||||
DT_NULL = 0,
|
||||
DT_NEEDED = 1,
|
||||
DT_PLTRELSZ = 2,
|
||||
DT_PLTGOT = 3,
|
||||
DT_HASH = 4,
|
||||
DT_STRTAB = 5,
|
||||
DT_SYMTAB = 6,
|
||||
DT_RELA = 7,
|
||||
DT_RELASZ = 8,
|
||||
DT_RELAENT = 9,
|
||||
DT_STRSZ = 10,
|
||||
DT_SYMENT = 11,
|
||||
DT_INIT = 12,
|
||||
DT_FINI = 13,
|
||||
DT_SONAME = 14,
|
||||
DT_RPATH = 15,
|
||||
DT_SYMBOLIC = 16,
|
||||
DT_REL = 17,
|
||||
DT_RELSZ = 18,
|
||||
DT_RELENT = 19,
|
||||
DT_PLTREL = 20,
|
||||
DT_DEBUG = 21,
|
||||
DT_TEXTREL = 22,
|
||||
DT_JMPREL = 23,
|
||||
DT_ENCODING = 32,
|
||||
OLD_DT_LOOS = 0x60000000,
|
||||
DT_LOOS = 0x6000000d,
|
||||
DT_HIOS = 0x6ffff000,
|
||||
DT_VALRNGLO = 0x6ffffd00,
|
||||
DT_VALRNGHI = 0x6ffffdff,
|
||||
DT_ADDRRNGLO = 0x6ffffe00,
|
||||
DT_ADDRRNGHI = 0x6ffffeff,
|
||||
DT_VERSYM = 0x6ffffff0,
|
||||
DT_RELACOUNT = 0x6ffffff9,
|
||||
DT_RELCOUNT = 0x6ffffffa,
|
||||
DT_FLAGS_1 = 0x6ffffffb,
|
||||
DT_VERDEF = 0x6ffffffc,
|
||||
DT_VERDEFNUM = 0x6ffffffd,
|
||||
DT_VERNEED = 0x6ffffffe,
|
||||
DT_VERNEEDNUM = 0x6fffffff,
|
||||
OLD_DT_HIOS = 0x6fffffff,
|
||||
DT_LOPROC = 0x70000000,
|
||||
DT_HIPROC = 0x7fffffff
|
||||
};
|
||||
|
||||
/* This info is needed when parsing the symbol table */
|
||||
enum SymbolBinding
|
||||
{
|
||||
STB_LOCAL = 0,
|
||||
STB_GLOBAL = 1,
|
||||
STB_WEAK = 2,
|
||||
STB_LOOS = 10,
|
||||
STB_HIOS = 12,
|
||||
STB_LOPROC,
|
||||
STB_HIPROC = 0xf
|
||||
};
|
||||
|
||||
enum SymbolType
|
||||
{
|
||||
STT_NOTYPE = 0,
|
||||
STT_OBJECT = 1,
|
||||
STT_FUNC = 2,
|
||||
STT_SECTION = 3,
|
||||
STT_FILE = 4,
|
||||
STT_COMMON = 5,
|
||||
STT_TLS = 6,
|
||||
STT_LOOS = 10,
|
||||
STT_HIOS = 12,
|
||||
STT_LOPROC,
|
||||
STT_HIPROC = 0xf
|
||||
};
|
||||
|
||||
/* These constants define the permissions on sections in the program
|
||||
header, p_flags. */
|
||||
enum PermissionFlag
|
||||
{
|
||||
PF_R = 0x4,
|
||||
PF_W = 0x2,
|
||||
PF_X = 0x1
|
||||
};
|
||||
|
||||
/* sh_type */
|
||||
enum SectionHeaderType
|
||||
{
|
||||
SHT_NULL = 0,
|
||||
SHT_PROGBITS = 1,
|
||||
SHT_SYMTAB = 2,
|
||||
SHT_STRTAB = 3,
|
||||
SHT_RELA = 4,
|
||||
SHT_HASH = 5,
|
||||
SHT_DYNAMIC = 6,
|
||||
SHT_NOTE = 7,
|
||||
SHT_NOBITS = 8,
|
||||
SHT_REL = 9,
|
||||
SHT_SHLIB = 10,
|
||||
SHT_DYNSYM = 11,
|
||||
SHT_NUM = 12,
|
||||
SHT_LOPROC = 0x70000000,
|
||||
SHT_HIPROC = 0x7fffffff,
|
||||
SHT_LOUSER = 0x80000000,
|
||||
SHT_HIUSER = 0xffffffff
|
||||
};
|
||||
|
||||
/* sh_flags */
|
||||
enum SectionHeaderFlag
|
||||
{
|
||||
SHF_WRITE = 0x1,
|
||||
SHF_ALLOC = 0x2,
|
||||
SHF_EXECINSTR = 0x4,
|
||||
SHF_RELA_LIVEPATCH = 0x00100000,
|
||||
SHF_RO_AFTER_INIT = 0x00200000,
|
||||
SHF_MASKPROC = 0xf0000000
|
||||
};
|
||||
|
||||
/* special section indexes */
|
||||
enum SpecialSectionIndex
|
||||
{
|
||||
SHN_UNDEF = 0,
|
||||
SHN_LORESERVE = 0xff00,
|
||||
SHN_LOPROC = 0xff00,
|
||||
SHN_HIPROC = 0xff1f,
|
||||
SHN_LOOS = 0xff20,
|
||||
SHN_HIOS = 0xff3f,
|
||||
SHN_ABS = 0xfff1,
|
||||
SHN_COMMON = 0xfff2,
|
||||
SHN_HIRESERVE = 0xffff
|
||||
};
|
||||
|
||||
enum ElfIdentIndex
|
||||
{
|
||||
EI_MAG0 = 0, /* e_ident[] indexes */
|
||||
EI_MAG1 = 1,
|
||||
EI_MAG2 = 2,
|
||||
EI_MAG3 = 3,
|
||||
EI_CLASS = 4,
|
||||
EI_DATA = 5,
|
||||
EI_VERSION = 6,
|
||||
EI_OSABI = 7,
|
||||
EI_PAD = 8
|
||||
};
|
||||
|
||||
enum ElfClass
|
||||
{
|
||||
ELFCLASSNONE = 0, /* EI_CLASS */
|
||||
ELFCLASS32 = 1,
|
||||
ELFCLASS64 = 2,
|
||||
ELFCLASSNUM = 3
|
||||
};
|
||||
|
||||
enum ElfData
|
||||
{
|
||||
ELFDATANONE = 0, /* e_ident[EI_DATA] */
|
||||
ELFDATA2LSB = 1,
|
||||
ELFDATA2MSB = 2
|
||||
};
|
||||
|
||||
enum ElfVersion
|
||||
{
|
||||
EV_NONE = 0, /* e_version, EI_VERSION */
|
||||
EV_CURRENT = 1,
|
||||
EV_NUM = 2,
|
||||
};
|
||||
|
||||
enum ElfOsAbi
|
||||
{
|
||||
ELFOSABI_NONE = 0,
|
||||
ELFOSABI_LINUX =3
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Notes used in ET_CORE. Architectures export some of the arch register sets
|
||||
* using the corresponding note types via the PTRACE_GETREGSET and
|
||||
* PTRACE_SETREGSET requests.
|
||||
*/
|
||||
enum NoteType
|
||||
{
|
||||
NT_PRSTATUS = 1,
|
||||
NT_PRFPREG = 2,
|
||||
NT_PRPSINFO = 3,
|
||||
NT_TASKSTRUCT = 4,
|
||||
NT_AUXV = 6,
|
||||
/*
|
||||
* Note to userspace developers: size of NT_SIGINFO note may increase
|
||||
* in the future to accomodate more fields, don't assume it is fixed!
|
||||
*/
|
||||
NT_SIGINFO = 0x53494749,
|
||||
NT_FILE = 0x46494c45,
|
||||
NT_PRXFPREG = 0x46e62b7f, /* copied from gdb5.1/include/elf/common.h */
|
||||
NT_PPC_VMX = 0x100, /* PowerPC Altivec/VMX registers */
|
||||
NT_PPC_SPE = 0x101, /* PowerPC SPE/EVR registers */
|
||||
NT_PPC_VSX = 0x102, /* PowerPC VSX registers */
|
||||
NT_PPC_TAR = 0x103, /* Target Address Register */
|
||||
NT_PPC_PPR = 0x104, /* Program Priority Register */
|
||||
NT_PPC_DSCR = 0x105, /* Data Stream Control Register */
|
||||
NT_PPC_EBB = 0x106, /* Event Based Branch Registers */
|
||||
NT_PPC_PMU = 0x107, /* Performance Monitor Registers */
|
||||
NT_PPC_TM_CGPR = 0x108, /* TM checkpointed GPR Registers */
|
||||
NT_PPC_TM_CFPR = 0x109, /* TM checkpointed FPR Registers */
|
||||
NT_PPC_TM_CVMX = 0x10a, /* TM checkpointed VMX Registers */
|
||||
NT_PPC_TM_CVSX = 0x10b, /* TM checkpointed VSX Registers */
|
||||
NT_PPC_TM_SPR = 0x10c, /* TM Special Purpose Registers */
|
||||
NT_PPC_TM_CTAR = 0x10d, /* TM checkpointed Target Address Register */
|
||||
NT_PPC_TM_CPPR = 0x10e, /* TM checkpointed Program Priority Register */
|
||||
NT_PPC_TM_CDSCR = 0x10f, /* TM checkpointed Data Stream Control Register */
|
||||
NT_PPC_PKEY = 0x110, /* Memory Protection Keys registers */
|
||||
NT_386_TLS = 0x200, /* i386 TLS slots (struct user_desc) */
|
||||
NT_386_IOPERM = 0x201, /* x86 io permission bitmap (1=deny) */
|
||||
NT_X86_XSTATE = 0x202, /* x86 extended state using xsave */
|
||||
NT_S390_HIGH_GPRS = 0x300, /* s390 upper register halves */
|
||||
NT_S390_TIMER = 0x301, /* s390 timer register */
|
||||
NT_S390_TODCMP = 0x302, /* s390 TOD clock comparator register */
|
||||
NT_S390_TODPREG = 0x303, /* s390 TOD programmable register */
|
||||
NT_S390_CTRS = 0x304, /* s390 control registers */
|
||||
NT_S390_PREFIX = 0x305, /* s390 prefix register */
|
||||
NT_S390_LAST_BREAK = 0x306, /* s390 breaking event address */
|
||||
NT_S390_SYSTEM_CALL = 0x307, /* s390 system call restart data */
|
||||
NT_S390_TDB = 0x308, /* s390 transaction diagnostic block */
|
||||
NT_S390_VXRS_LOW = 0x309, /* s390 vector registers 0-15 upper half */
|
||||
NT_S390_VXRS_HIGH = 0x30a, /* s390 vector registers 16-31 */
|
||||
NT_S390_GS_CB = 0x30b, /* s390 guarded storage registers */
|
||||
NT_S390_GS_BC = 0x30c, /* s390 guarded storage broadcast control block */
|
||||
NT_S390_RI_CB = 0x30d, /* s390 runtime instrumentation */
|
||||
NT_ARM_VFP = 0x400, /* ARM VFP/NEON registers */
|
||||
NT_ARM_TLS = 0x401, /* ARM TLS register */
|
||||
NT_ARM_HW_BREAK = 0x402, /* ARM hardware breakpoint registers */
|
||||
NT_ARM_HW_WATCH = 0x403, /* ARM hardware watchpoint registers */
|
||||
NT_ARM_SYSTEM_CALL = 0x404, /* ARM system call number */
|
||||
NT_ARM_SVE = 0x405, /* ARM Scalable Vector Extension registers */
|
||||
NT_ARC_V2 = 0x600, /* ARCv2 accumulator/extra registers */
|
||||
NT_VMCOREDD = 0x700, /* Vmcore Device Dump Note */
|
||||
NT_MIPS_DSP = 0x800, /* MIPS DSP ASE registers */
|
||||
NT_MIPS_FP_MODE = 0x801, /* MIPS floating-point mode */
|
||||
};
|
||||
|
||||
static const size_t kEIdentSize = 0x10;
|
||||
static const byte_t kElfMagic[sizeof(uint32_t)] = {0x7f, 'E', 'L', 'F'};
|
||||
|
||||
|
||||
inline byte_t get_elf_st_bind(byte_t st_info) { return st_info >> 4; }
|
||||
inline byte_t get_elf_st_type(byte_t st_info) { return st_info & 0xf; }
|
||||
inline byte_t get_elf_st_info(byte_t st_bind, byte_t st_type) { return (st_type & 0xf) | ((st_bind & 0xf) << 4);}
|
||||
|
||||
/* The following are used with relocations */
|
||||
#define ELF32_R_SYM(x) ((x) >> 8)
|
||||
#define ELF32_R_TYPE(x) ((x) & 0xff)
|
||||
|
||||
#define ELF64_R_SYM(i) ((i) >> 32)
|
||||
#define ELF64_R_TYPE(i) ((i) & 0xffffffff)
|
||||
}
|
||||
|
||||
struct Elf32_Dyn
|
||||
{
|
||||
int32_t d_tag;
|
||||
union{
|
||||
int32_t d_val;
|
||||
uint32_t d_ptr;
|
||||
} d_un;
|
||||
};
|
||||
|
||||
struct Elf64_Dyn
|
||||
{
|
||||
int64_t d_tag; /* entry tag value */
|
||||
union {
|
||||
uint64_t d_val;
|
||||
uint64_t d_ptr;
|
||||
} d_un;
|
||||
};
|
||||
|
||||
struct Elf32_Rel
|
||||
{
|
||||
uint32_t r_offset;
|
||||
uint32_t r_info;
|
||||
};
|
||||
|
||||
struct Elf64_Rel
|
||||
{
|
||||
uint64_t r_offset; /* Location at which to apply the action */
|
||||
uint64_t r_info; /* index and type of relocation */
|
||||
};
|
||||
|
||||
struct Elf32_Rela
|
||||
{
|
||||
uint32_t r_offset;
|
||||
uint32_t r_info;
|
||||
int32_t r_addend;
|
||||
};
|
||||
|
||||
struct Elf64_Rela
|
||||
{
|
||||
uint64_t r_offset; /* Location at which to apply the action */
|
||||
uint64_t r_info; /* index and type of relocation */
|
||||
int64_t r_addend; /* Constant addend used to compute value */
|
||||
};
|
||||
|
||||
struct Elf32_Sym
|
||||
{
|
||||
uint32_t st_name;
|
||||
uint32_t st_value;
|
||||
uint32_t st_size;
|
||||
byte_t st_info;
|
||||
byte_t st_other;
|
||||
uint16_t st_shndx;
|
||||
};
|
||||
|
||||
struct Elf64_Sym
|
||||
{
|
||||
uint32_t st_name; /* Symbol name, index in string tbl */
|
||||
byte_t st_info; /* Type and binding attributes */
|
||||
byte_t st_other; /* No defined meaning, 0 */
|
||||
uint16_t st_shndx; /* Associated section index */
|
||||
uint64_t st_value; /* Value of the symbol */
|
||||
uint64_t st_size; /* Associated symbol size */
|
||||
};
|
||||
|
||||
struct Elf32_Ehdr
|
||||
{
|
||||
byte_t e_ident[elf::kEIdentSize];
|
||||
uint16_t e_type;
|
||||
uint16_t e_machine;
|
||||
uint32_t e_version;
|
||||
uint32_t e_entry; /* Entry point */
|
||||
uint32_t e_phoff;
|
||||
uint32_t e_shoff;
|
||||
uint32_t e_flags;
|
||||
uint16_t e_ehsize;
|
||||
uint16_t e_phentsize;
|
||||
uint16_t e_phnum;
|
||||
uint16_t e_shentsize;
|
||||
uint16_t e_shnum;
|
||||
uint16_t e_shstrndx;
|
||||
};
|
||||
|
||||
struct Elf64_Ehdr
|
||||
{
|
||||
byte_t e_ident[elf::kEIdentSize]; /* ELF "magic number" */
|
||||
uint16_t e_type;
|
||||
uint16_t e_machine;
|
||||
uint32_t e_version;
|
||||
uint64_t e_entry; /* Entry point virtual address */
|
||||
uint64_t e_phoff; /* Program header table file offset */
|
||||
uint64_t e_shoff; /* Section header table file offset */
|
||||
uint32_t e_flags;
|
||||
uint16_t e_ehsize;
|
||||
uint16_t e_phentsize;
|
||||
uint16_t e_phnum;
|
||||
uint16_t e_shentsize;
|
||||
uint16_t e_shnum;
|
||||
uint16_t e_shstrndx;
|
||||
};
|
||||
|
||||
struct Elf32_Phdr
|
||||
{
|
||||
uint32_t p_type;
|
||||
uint32_t p_offset;
|
||||
uint32_t p_vaddr;
|
||||
uint32_t p_paddr;
|
||||
uint32_t p_filesz;
|
||||
uint32_t p_memsz;
|
||||
uint32_t p_flags;
|
||||
uint32_t p_align;
|
||||
};
|
||||
|
||||
struct Elf64_Phdr
|
||||
{
|
||||
uint32_t p_type;
|
||||
uint32_t p_flags;
|
||||
uint64_t p_offset; /* Segment file offset */
|
||||
uint64_t p_vaddr; /* Segment virtual address */
|
||||
uint64_t p_paddr; /* Segment physical address */
|
||||
uint64_t p_filesz; /* Segment size in file */
|
||||
uint64_t p_memsz; /* Segment size in memory */
|
||||
uint64_t p_align; /* Segment alignment, file & memory */
|
||||
};
|
||||
|
||||
struct Elf32_Shdr
|
||||
{
|
||||
uint32_t sh_name;
|
||||
uint32_t sh_type;
|
||||
uint32_t sh_flags;
|
||||
uint32_t sh_addr;
|
||||
uint32_t sh_offset;
|
||||
uint32_t sh_size;
|
||||
uint32_t sh_link;
|
||||
uint32_t sh_info;
|
||||
uint32_t sh_addralign;
|
||||
uint32_t sh_entsize;
|
||||
};
|
||||
|
||||
struct Elf64_Shdr
|
||||
{
|
||||
uint32_t sh_name; /* Section name, index in string tbl */
|
||||
uint32_t sh_type; /* Type of section */
|
||||
uint64_t sh_flags; /* Miscellaneous section attributes */
|
||||
uint64_t sh_addr; /* Section virtual addr at execution */
|
||||
uint64_t sh_offset; /* Section file offset */
|
||||
uint64_t sh_size; /* Size of section in bytes */
|
||||
uint32_t sh_link; /* Index of another section */
|
||||
uint32_t sh_info; /* Additional section information */
|
||||
uint64_t sh_addralign; /* Section alignment */
|
||||
uint64_t sh_entsize; /* Entry size if section holds table */
|
||||
};
|
||||
|
||||
/* Note header in a PT_NOTE section */
|
||||
struct Elf32_Nhdr
|
||||
{
|
||||
uint32_t n_namesz; /* Name size */
|
||||
uint32_t n_descsz; /* Content size */
|
||||
uint32_t n_type; /* Content type */
|
||||
};
|
||||
|
||||
/* Note header in a PT_NOTE section */
|
||||
struct Elf64_Nhdr
|
||||
{
|
||||
uint32_t n_namesz; /* Name size */
|
||||
uint32_t n_descsz; /* Content size */
|
||||
uint32_t n_type; /* Content type */
|
||||
};
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
|
||||
namespace fnd
|
||||
{
|
||||
namespace io
|
||||
{
|
||||
#ifdef _WIN32
|
||||
const std::string kPathDivider = "\\";
|
||||
#else
|
||||
const std::string kPathDivider = "/";
|
||||
#endif
|
||||
|
||||
size_t getFileSize(const std::string& path);
|
||||
void makeDirectory(const std::string& path);
|
||||
void getEnvironVar(std::string& var, const std::string& key);
|
||||
void appendToPath(std::string& base, const std::string& add);
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
|
||||
namespace fnd
|
||||
{
|
||||
namespace lz4
|
||||
{
|
||||
void compressData(const uint8_t* src, uint32_t src_len, uint8_t* dst, uint32_t dst_capacity, uint32_t& compressed_size);
|
||||
void decompressData(const uint8_t* src, uint32_t src_len, uint8_t* dst, uint32_t dst_capacity, uint32_t& decompressed_size);
|
||||
}
|
||||
}
|
|
@ -1,124 +0,0 @@
|
|||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <fnd/sha.h>
|
||||
|
||||
namespace fnd
|
||||
{
|
||||
namespace rsa
|
||||
{
|
||||
const size_t kRsa1024Size = 0x80;
|
||||
const size_t kRsa2048Size = 0x100;
|
||||
const size_t kRsa4096Size = 0x200;
|
||||
const size_t kRsaPublicExponentSize = 4;
|
||||
|
||||
enum RsaType
|
||||
{
|
||||
RSA_1024,
|
||||
RSA_2048,
|
||||
RSA_4096,
|
||||
};
|
||||
|
||||
#pragma pack (push, 1)
|
||||
struct sRsa1024Key
|
||||
{
|
||||
uint8_t modulus[kRsa1024Size];
|
||||
uint8_t priv_exponent[kRsa1024Size];
|
||||
uint8_t public_exponent[kRsaPublicExponentSize];
|
||||
|
||||
void operator=(const sRsa1024Key& other)
|
||||
{
|
||||
memcpy(this->modulus, modulus, kRsa1024Size);
|
||||
memcpy(this->priv_exponent, priv_exponent, kRsa1024Size);
|
||||
memcpy(this->public_exponent, other.public_exponent, kRsaPublicExponentSize);
|
||||
}
|
||||
|
||||
bool operator==(const sRsa1024Key& other) const
|
||||
{
|
||||
return memcmp(this->modulus, other.modulus, kRsa1024Size) == 0 \
|
||||
&& memcmp(this->priv_exponent, other.priv_exponent, kRsa1024Size) == 0 \
|
||||
&& memcmp(this->public_exponent, other.public_exponent, kRsaPublicExponentSize) == 0;
|
||||
}
|
||||
|
||||
bool operator!=(const sRsa1024Key& other) const
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
};
|
||||
|
||||
struct sRsa2048Key
|
||||
{
|
||||
uint8_t modulus[kRsa2048Size];
|
||||
uint8_t priv_exponent[kRsa2048Size];
|
||||
uint8_t public_exponent[kRsaPublicExponentSize];
|
||||
|
||||
void operator=(const sRsa2048Key& other)
|
||||
{
|
||||
memcpy(this->modulus, other.modulus, kRsa2048Size);
|
||||
memcpy(this->priv_exponent, other.priv_exponent, kRsa2048Size);
|
||||
memcpy(this->public_exponent, other.public_exponent, kRsaPublicExponentSize);
|
||||
}
|
||||
|
||||
bool operator==(const sRsa2048Key& other) const
|
||||
{
|
||||
return memcmp(this->modulus, other.modulus, kRsa2048Size) == 0 && memcmp(this->priv_exponent, other.priv_exponent, kRsa2048Size) == 0 && memcmp(this->public_exponent, other.public_exponent, kRsaPublicExponentSize) == 0;
|
||||
}
|
||||
|
||||
bool operator!=(const sRsa2048Key& other) const
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
};
|
||||
|
||||
struct sRsa4096Key
|
||||
{
|
||||
uint8_t modulus[kRsa4096Size];
|
||||
uint8_t priv_exponent[kRsa4096Size];
|
||||
uint8_t public_exponent[kRsaPublicExponentSize];
|
||||
|
||||
void operator=(const sRsa4096Key& other)
|
||||
{
|
||||
memcpy(this->modulus, other.modulus, kRsa4096Size);
|
||||
memcpy(this->priv_exponent, other.priv_exponent, kRsa4096Size);
|
||||
memcpy(this->public_exponent, other.public_exponent, kRsaPublicExponentSize);
|
||||
}
|
||||
|
||||
bool operator==(const sRsa4096Key& other) const
|
||||
{
|
||||
return memcmp(this->modulus, other.modulus, kRsa4096Size) == 0 && memcmp(this->priv_exponent, other.priv_exponent, kRsa4096Size) == 0 && memcmp(this->public_exponent, other.public_exponent, kRsaPublicExponentSize) == 0;
|
||||
}
|
||||
|
||||
bool operator!=(const sRsa4096Key& other) const
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
};
|
||||
#pragma pack (pop)
|
||||
|
||||
namespace pkcs
|
||||
{
|
||||
// rsa1024
|
||||
int rsaSign(const sRsa1024Key& key, sha::HashType hash_type, const uint8_t* hash, uint8_t signature[kRsa1024Size]);
|
||||
int rsaVerify(const sRsa1024Key& key, sha::HashType hash_type, const uint8_t* hash, const uint8_t signature[kRsa1024Size]);
|
||||
// rsa2048
|
||||
int rsaSign(const sRsa2048Key& key, sha::HashType hash_type, const uint8_t* hash, uint8_t signature[kRsa2048Size]);
|
||||
int rsaVerify(const sRsa2048Key& key, sha::HashType hash_type, const uint8_t* hash, const uint8_t signature[kRsa2048Size]);
|
||||
// rsa4096
|
||||
int rsaSign(const sRsa4096Key& key, sha::HashType hash_type, const uint8_t* hash, uint8_t signature[kRsa4096Size]);
|
||||
int rsaVerify(const sRsa4096Key& key, sha::HashType hash_type, const uint8_t* hash, const uint8_t signature[kRsa4096Size]);
|
||||
}
|
||||
|
||||
namespace pss
|
||||
{
|
||||
// rsa1024
|
||||
//int rsaSign(const sRsa1024Key& key, sha::HashType hash_type, const uint8_t* hash, uint8_t signature[kRsa1024Size]);
|
||||
//int rsaVerify(const sRsa1024Key& key, sha::HashType hash_type, const uint8_t* hash, const uint8_t signature[kRsa1024Size]);
|
||||
// rsa2048
|
||||
int rsaSign(const sRsa2048Key& key, sha::HashType hash_type, const uint8_t* hash, uint8_t signature[kRsa2048Size]);
|
||||
int rsaVerify(const sRsa2048Key& key, sha::HashType hash_type, const uint8_t* hash, const uint8_t signature[kRsa2048Size]);
|
||||
// rsa4096
|
||||
//int rsaSign(const sRsa4096Key& key, sha::HashType hash_type, const uint8_t* hash, uint8_t signature[kRsa4096Size]);
|
||||
//int rsaVerify(const sRsa4096Key& key, sha::HashType hash_type, const uint8_t* hash, const uint8_t signature[kRsa4096Size]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,89 +0,0 @@
|
|||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
namespace fnd
|
||||
{
|
||||
namespace sha
|
||||
{
|
||||
const size_t kSha1HashLen = 20;
|
||||
const size_t kSha256HashLen = 32;
|
||||
|
||||
enum HashType
|
||||
{
|
||||
HASH_SHA1,
|
||||
HASH_SHA256
|
||||
};
|
||||
|
||||
#pragma pack (push, 1)
|
||||
struct sSha1Hash
|
||||
{
|
||||
uint8_t bytes[kSha1HashLen];
|
||||
|
||||
void set(const uint8_t hash[kSha1HashLen])
|
||||
{
|
||||
memcpy(this->bytes, hash, kSha1HashLen);
|
||||
}
|
||||
|
||||
bool compare(const uint8_t hash[kSha1HashLen]) const
|
||||
{
|
||||
return memcmp(this->bytes, hash, kSha1HashLen) == 0;
|
||||
}
|
||||
|
||||
bool compare(const sSha1Hash& other) const
|
||||
{
|
||||
return memcmp(this->bytes, other.bytes, kSha1HashLen) == 0;
|
||||
}
|
||||
|
||||
void operator=(const sSha1Hash& other)
|
||||
{
|
||||
set(other.bytes);
|
||||
}
|
||||
bool operator==(const sSha1Hash& other) const
|
||||
{
|
||||
return compare(other);
|
||||
}
|
||||
bool operator!=(const sSha1Hash& other) const
|
||||
{
|
||||
return !compare(other);
|
||||
}
|
||||
};
|
||||
|
||||
struct sSha256Hash
|
||||
{
|
||||
uint8_t bytes[kSha256HashLen];
|
||||
|
||||
void set(const uint8_t hash[kSha256HashLen])
|
||||
{
|
||||
memcpy(this->bytes, hash, kSha256HashLen);
|
||||
}
|
||||
|
||||
bool compare(const uint8_t hash[kSha256HashLen]) const
|
||||
{
|
||||
return memcmp(this->bytes, hash, kSha256HashLen) == 0;
|
||||
}
|
||||
|
||||
bool compare(const sSha256Hash& other) const
|
||||
{
|
||||
return memcmp(this->bytes, other.bytes, kSha256HashLen) == 0;
|
||||
}
|
||||
|
||||
void operator=(const sSha256Hash& other)
|
||||
{
|
||||
set(other.bytes);
|
||||
}
|
||||
bool operator==(const sSha256Hash& other) const
|
||||
{
|
||||
return compare(other);
|
||||
}
|
||||
bool operator!=(const sSha256Hash& other) const
|
||||
{
|
||||
return !compare(other);
|
||||
}
|
||||
};
|
||||
#pragma pack (pop)
|
||||
|
||||
void Sha1(const uint8_t* in, uint64_t size, uint8_t hash[kSha1HashLen]);
|
||||
void Sha256(const uint8_t* in, uint64_t size, uint8_t hash[kSha256HashLen]);
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
#pragma once
|
||||
#include <cinttypes>
|
||||
#include <fnd/Exception.h>
|
||||
#include <fnd/BitMath.h>
|
||||
#include <fnd/Endian.h>
|
||||
|
||||
typedef uint8_t byte_t;
|
||||
|
||||
#define _MIN(x,y) ((x) <= (y)? (x) : (y))
|
||||
#define _MAX(x,y) ((x) >= (y)? (x) : (y))
|
||||
|
||||
static inline uint64_t align(uint64_t size, uint64_t align)
|
||||
{
|
||||
return (size % align) == 0? size : (size - (size % align) + align);
|
||||
}
|
||||
|
|
@ -1,170 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B}</ProjectGuid>
|
||||
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\libfnd\include;..\libpolarssl\include;..\liblz4\include;</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\libfnd\include;..\libpolarssl\include;..\liblz4\include;</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\libfnd\include;..\libpolarssl\include;..\liblz4\include;</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\libfnd\include;..\libpolarssl\include;..\liblz4\include;</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<None Include="makefile" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\fnd\aes.h" />
|
||||
<ClInclude Include="include\fnd\AesCtrWrappedIFile.h" />
|
||||
<ClInclude Include="include\fnd\base64.h" />
|
||||
<ClInclude Include="include\fnd\BitMath.h" />
|
||||
<ClInclude Include="include\fnd\ecdsa.h" />
|
||||
<ClInclude Include="include\fnd\elf.h" />
|
||||
<ClInclude Include="include\fnd\Endian.h" />
|
||||
<ClInclude Include="include\fnd\Exception.h" />
|
||||
<ClInclude Include="include\fnd\IByteModel.h" />
|
||||
<ClInclude Include="include\fnd\IFile.h" />
|
||||
<ClInclude Include="include\fnd\io.h" />
|
||||
<ClInclude Include="include\fnd\LayeredIntegrityMetadata.h" />
|
||||
<ClInclude Include="include\fnd\LayeredIntegrityWrappedIFile.h" />
|
||||
<ClInclude Include="include\fnd\List.h" />
|
||||
<ClInclude Include="include\fnd\lz4.h" />
|
||||
<ClInclude Include="include\fnd\OffsetAdjustedIFile.h" />
|
||||
<ClInclude Include="include\fnd\ResourceFileReader.h" />
|
||||
<ClInclude Include="include\fnd\rsa.h" />
|
||||
<ClInclude Include="include\fnd\sha.h" />
|
||||
<ClInclude Include="include\fnd\SharedPtr.h" />
|
||||
<ClInclude Include="include\fnd\SimpleFile.h" />
|
||||
<ClInclude Include="include\fnd\SimpleTextOutput.h" />
|
||||
<ClInclude Include="include\fnd\StringConv.h" />
|
||||
<ClInclude Include="include\fnd\types.h" />
|
||||
<ClInclude Include="include\fnd\Vec.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="source\AesCtrWrappedIFile.cpp" />
|
||||
<ClCompile Include="source\aes_wrapper.cpp" />
|
||||
<ClCompile Include="source\base64_wrapper.cpp" />
|
||||
<ClCompile Include="source\Exception.cpp" />
|
||||
<ClCompile Include="source\io.cpp" />
|
||||
<ClCompile Include="source\LayeredIntegrityMetadata.cpp" />
|
||||
<ClCompile Include="source\LayeredIntegrityWrappedIFile.cpp" />
|
||||
<ClCompile Include="source\lz4_wrapper.cpp" />
|
||||
<ClCompile Include="source\OffsetAdjustedIFile.cpp" />
|
||||
<ClCompile Include="source\ResourceFileReader.cpp" />
|
||||
<ClCompile Include="source\rsa_wrapper.cpp" />
|
||||
<ClCompile Include="source\sha_wrapper.cpp" />
|
||||
<ClCompile Include="source\SimpleFile.cpp" />
|
||||
<ClCompile Include="source\SimpleTextOutput.cpp" />
|
||||
<ClCompile Include="source\StringConv.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -1,144 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="makefile" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\fnd\aes.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\fnd\AesCtrWrappedIFile.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\fnd\base64.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\fnd\BitMath.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\fnd\ecdsa.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\fnd\elf.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\fnd\Endian.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\fnd\Exception.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\fnd\IByteModel.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\fnd\IFile.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\fnd\io.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\fnd\LayeredIntegrityMetadata.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\fnd\LayeredIntegrityWrappedIFile.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\fnd\List.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\fnd\lz4.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\fnd\OffsetAdjustedIFile.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\fnd\ResourceFileReader.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\fnd\rsa.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\fnd\sha.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\fnd\SharedPtr.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\fnd\SimpleFile.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\fnd\SimpleTextOutput.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\fnd\StringConv.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\fnd\types.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\fnd\Vec.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="source\aes_wrapper.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\AesCtrWrappedIFile.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\base64_wrapper.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\Exception.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\io.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\LayeredIntegrityMetadata.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\LayeredIntegrityWrappedIFile.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\lz4_wrapper.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\OffsetAdjustedIFile.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\ResourceFileReader.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\rsa_wrapper.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\sha_wrapper.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\SimpleFile.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\SimpleTextOutput.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="source\StringConv.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,4 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
</Project>
|
|
@ -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 = polarssl lz4
|
||||
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)
|
|
@ -1,80 +0,0 @@
|
|||
#include <fnd/AesCtrWrappedIFile.h>
|
||||
|
||||
fnd::AesCtrWrappedIFile::AesCtrWrappedIFile(const fnd::SharedPtr<fnd::IFile>& file, const fnd::aes::sAes128Key& key, const fnd::aes::sAesIvCtr& ctr) :
|
||||
mFile(file),
|
||||
mKey(key),
|
||||
mBaseCtr(ctr),
|
||||
mFileOffset(0)
|
||||
{
|
||||
mCache.alloc(kCacheSizeAllocSize);
|
||||
}
|
||||
|
||||
size_t fnd::AesCtrWrappedIFile::size()
|
||||
{
|
||||
return (*mFile)->size();
|
||||
}
|
||||
|
||||
void fnd::AesCtrWrappedIFile::seek(size_t offset)
|
||||
{
|
||||
mFileOffset = offset;
|
||||
}
|
||||
|
||||
void fnd::AesCtrWrappedIFile::read(byte_t* out, size_t len)
|
||||
{
|
||||
size_t read_len;
|
||||
size_t read_pos;
|
||||
|
||||
size_t cache_reads = (len / kCacheSize) + ((len % kCacheSize) != 0);
|
||||
|
||||
for (size_t i = 0; i < cache_reads; i++)
|
||||
{
|
||||
read_len = _MIN(len - (i * kCacheSize), kCacheSize);
|
||||
read_pos = ((mFileOffset >> 4) << 4) + (i * kCacheSize);
|
||||
|
||||
(*mFile)->seek(read_pos);
|
||||
(*mFile)->read(mCache.data(), kCacheSizeAllocSize);
|
||||
|
||||
fnd::aes::AesIncrementCounter(mBaseCtr.iv, read_pos>>4, mCurrentCtr.iv);
|
||||
fnd::aes::AesCtr(mCache.data(), kCacheSizeAllocSize, mKey.key, mCurrentCtr.iv, mCache.data());
|
||||
|
||||
memcpy(out + (i * kCacheSize), mCache.data() + (mFileOffset & 0xf), read_len);
|
||||
}
|
||||
|
||||
seek(mFileOffset + len);
|
||||
}
|
||||
|
||||
void fnd::AesCtrWrappedIFile::read(byte_t* out, size_t offset, size_t len)
|
||||
{
|
||||
seek(offset);
|
||||
read(out, len);
|
||||
}
|
||||
|
||||
void fnd::AesCtrWrappedIFile::write(const byte_t* in, size_t len)
|
||||
{
|
||||
size_t write_len;
|
||||
size_t write_pos;
|
||||
|
||||
size_t cache_writes = (len / kCacheSize) + ((len % kCacheSize) != 0);
|
||||
|
||||
for (size_t i = 0; i < cache_writes; i++)
|
||||
{
|
||||
write_len = _MIN(len - (i * kCacheSize), kCacheSize);
|
||||
write_pos = ((mFileOffset >> 4) << 4) + (i * kCacheSize);
|
||||
|
||||
memcpy(mCache.data() + (mFileOffset & 0xf), in + (i * kCacheSize), write_len);
|
||||
|
||||
fnd::aes::AesIncrementCounter(mBaseCtr.iv, write_pos>>4, mCurrentCtr.iv);
|
||||
fnd::aes::AesCtr(mCache.data(), kCacheSizeAllocSize, mKey.key, mCurrentCtr.iv, mCache.data());
|
||||
|
||||
(*mFile)->seek(write_pos);
|
||||
(*mFile)->write(mCache.data(), kCacheSizeAllocSize);
|
||||
}
|
||||
|
||||
seek(mFileOffset + len);
|
||||
}
|
||||
|
||||
void fnd::AesCtrWrappedIFile::write(const byte_t* in, size_t offset, size_t len)
|
||||
{
|
||||
seek(offset);
|
||||
write(in, len);
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
#include <fnd/Exception.h>
|
||||
|
||||
using namespace fnd;
|
||||
|
||||
Exception::Exception() noexcept :
|
||||
what_(""),
|
||||
module_(""),
|
||||
error_("")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Exception::Exception(const std::string & what) noexcept :
|
||||
what_(what),
|
||||
module_(""),
|
||||
error_(what)
|
||||
{
|
||||
}
|
||||
|
||||
Exception::Exception(const std::string & module, const std::string & what) noexcept :
|
||||
what_(""),
|
||||
module_(module),
|
||||
error_(what)
|
||||
{
|
||||
if (module_.length() > 0)
|
||||
{
|
||||
what_ = "[" + module_ + " ERROR] " + error_;
|
||||
}
|
||||
else
|
||||
{
|
||||
what_ = error_;
|
||||
}
|
||||
}
|
||||
|
||||
const char* Exception::what() const noexcept
|
||||
{
|
||||
return what_.c_str();
|
||||
}
|
||||
|
||||
const char* Exception::module() const noexcept
|
||||
{
|
||||
return module_.c_str();
|
||||
}
|
||||
|
||||
const char * fnd::Exception::error() const noexcept
|
||||
{
|
||||
return error_.c_str();
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
#include <fnd/LayeredIntegrityMetadata.h>
|
||||
|
||||
fnd::LayeredIntegrityMetadata::LayeredIntegrityMetadata() :
|
||||
mLayerInfo(),
|
||||
mDataLayer(),
|
||||
mMasterHashList(),
|
||||
mDoAlignHashToBlock(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void fnd::LayeredIntegrityMetadata::operator=(const LayeredIntegrityMetadata& other)
|
||||
{
|
||||
mLayerInfo = other.mLayerInfo;
|
||||
mDataLayer = other.mDataLayer;
|
||||
mMasterHashList = other.mMasterHashList;
|
||||
mDoAlignHashToBlock = other.mDoAlignHashToBlock;
|
||||
}
|
||||
|
||||
bool fnd::LayeredIntegrityMetadata::operator==(const LayeredIntegrityMetadata& other) const
|
||||
{
|
||||
return (mLayerInfo == other.mLayerInfo) \
|
||||
&& (mDataLayer == other.mDataLayer) \
|
||||
&& (mMasterHashList == other.mMasterHashList) \
|
||||
&& (mDoAlignHashToBlock == other.mDoAlignHashToBlock);
|
||||
}
|
||||
|
||||
bool fnd::LayeredIntegrityMetadata::operator!=(const LayeredIntegrityMetadata& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
const fnd::List<fnd::LayeredIntegrityMetadata::sLayer>& fnd::LayeredIntegrityMetadata::getHashLayerInfo() const
|
||||
{
|
||||
return mLayerInfo;
|
||||
}
|
||||
|
||||
void fnd::LayeredIntegrityMetadata::setHashLayerInfo(const fnd::List<sLayer>& layer_info)
|
||||
{
|
||||
mLayerInfo = layer_info;
|
||||
}
|
||||
|
||||
const fnd::LayeredIntegrityMetadata::sLayer& fnd::LayeredIntegrityMetadata::getDataLayer() const
|
||||
{
|
||||
return mDataLayer;
|
||||
}
|
||||
|
||||
void fnd::LayeredIntegrityMetadata::setDataLayerInfo(const sLayer& data_info)
|
||||
{
|
||||
mDataLayer = data_info;
|
||||
}
|
||||
|
||||
const fnd::List<fnd::sha::sSha256Hash>& fnd::LayeredIntegrityMetadata::getMasterHashList() const
|
||||
{
|
||||
return mMasterHashList;
|
||||
}
|
||||
|
||||
void fnd::LayeredIntegrityMetadata::setMasterHashList(const fnd::List<fnd::sha::sSha256Hash>& master_hash_list)
|
||||
{
|
||||
mMasterHashList = master_hash_list;
|
||||
}
|
||||
|
||||
bool fnd::LayeredIntegrityMetadata::getAlignHashToBlock() const
|
||||
{
|
||||
return mDoAlignHashToBlock;
|
||||
}
|
||||
|
||||
void fnd::LayeredIntegrityMetadata::setAlignHashToBlock(bool doAlign)
|
||||
{
|
||||
mDoAlignHashToBlock = doAlign;
|
||||
}
|
|
@ -1,191 +0,0 @@
|
|||
#include <fnd/LayeredIntegrityWrappedIFile.h>
|
||||
#include <fnd/OffsetAdjustedIFile.h>
|
||||
|
||||
fnd::LayeredIntegrityWrappedIFile::LayeredIntegrityWrappedIFile(const fnd::SharedPtr<fnd::IFile>& file, const fnd::LayeredIntegrityMetadata& hdr) :
|
||||
mFile(file),
|
||||
mData(nullptr),
|
||||
mDataHashLayer(),
|
||||
mAlignHashCalcToBlock(false)
|
||||
{
|
||||
initialiseDataLayer(hdr);
|
||||
}
|
||||
|
||||
size_t fnd::LayeredIntegrityWrappedIFile::size()
|
||||
{
|
||||
return (*mData)->size();
|
||||
}
|
||||
|
||||
void fnd::LayeredIntegrityWrappedIFile::seek(size_t offset)
|
||||
{
|
||||
mDataOffset = offset;
|
||||
}
|
||||
|
||||
void fnd::LayeredIntegrityWrappedIFile::read(byte_t* out, size_t len)
|
||||
{
|
||||
struct sBlockPosition
|
||||
{
|
||||
size_t index;
|
||||
size_t pos;
|
||||
} start_blk, end_blk;
|
||||
|
||||
start_blk.index = getOffsetBlock(mDataOffset);
|
||||
start_blk.pos = getOffsetInBlock(mDataOffset);
|
||||
|
||||
end_blk.index = getOffsetBlock(mDataOffset + len);
|
||||
end_blk.pos = getOffsetInBlock(mDataOffset + len);
|
||||
if (end_blk.pos == 0 && len != 0)
|
||||
{
|
||||
end_blk.index -= 1;
|
||||
end_blk.pos = mDataBlockSize;
|
||||
}
|
||||
|
||||
size_t total_blk_num = (end_blk.index - start_blk.index) + 1;
|
||||
|
||||
size_t read_blk_num = 0;
|
||||
size_t cache_export_start_pos, cache_export_end_pos, cache_export_size;
|
||||
size_t export_pos = 0;
|
||||
for (size_t i = 0; i < total_blk_num; i += read_blk_num, export_pos += cache_export_size)
|
||||
{
|
||||
read_blk_num = _MIN(mCacheBlockNum, (total_blk_num - i));
|
||||
readData(start_blk.index + i, read_blk_num);
|
||||
|
||||
// if this is the first read, adjust offset
|
||||
if (i == 0)
|
||||
cache_export_start_pos = start_blk.pos;
|
||||
else
|
||||
cache_export_start_pos = 0;
|
||||
|
||||
// if this is the last block, adjust end offset
|
||||
if ((i + read_blk_num) == total_blk_num)
|
||||
cache_export_end_pos = ((read_blk_num - 1) * mDataBlockSize) + end_blk.pos;
|
||||
else
|
||||
cache_export_end_pos = read_blk_num * mDataBlockSize;
|
||||
|
||||
// determine cache export size
|
||||
cache_export_size = cache_export_end_pos - cache_export_start_pos;
|
||||
|
||||
memcpy(out + export_pos, mCache.data() + cache_export_start_pos, cache_export_size);
|
||||
}
|
||||
|
||||
// update offset
|
||||
seek(mDataOffset + len);
|
||||
}
|
||||
|
||||
void fnd::LayeredIntegrityWrappedIFile::read(byte_t* out, size_t offset, size_t len)
|
||||
{
|
||||
seek(offset);
|
||||
read(out, len);
|
||||
}
|
||||
|
||||
void fnd::LayeredIntegrityWrappedIFile::write(const byte_t* out, size_t len)
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "write() not supported");
|
||||
}
|
||||
|
||||
void fnd::LayeredIntegrityWrappedIFile::write(const byte_t* out, size_t offset, size_t len)
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "write() not supported");
|
||||
}
|
||||
|
||||
void fnd::LayeredIntegrityWrappedIFile::initialiseDataLayer(const fnd::LayeredIntegrityMetadata& hdr)
|
||||
{
|
||||
fnd::sha::sSha256Hash hash;
|
||||
fnd::Vec<byte_t> cur, prev;
|
||||
|
||||
mAlignHashCalcToBlock = hdr.getAlignHashToBlock();
|
||||
|
||||
// copy master hash into prev
|
||||
prev.alloc(sizeof(fnd::sha::sSha256Hash) * hdr.getMasterHashList().size());
|
||||
for (size_t i = 0; i < hdr.getMasterHashList().size(); i++)
|
||||
{
|
||||
((fnd::sha::sSha256Hash*)prev.data())[i] = hdr.getMasterHashList()[i];
|
||||
}
|
||||
|
||||
// check each hash layer
|
||||
for (size_t i = 0; i < hdr.getHashLayerInfo().size(); i++)
|
||||
{
|
||||
// get block size
|
||||
const fnd::LayeredIntegrityMetadata::sLayer& layer = hdr.getHashLayerInfo()[i];
|
||||
|
||||
// allocate layer
|
||||
cur.alloc(align(layer.size, layer.block_size));
|
||||
|
||||
// read layer
|
||||
(*mFile)->read(cur.data(), layer.offset, layer.size);
|
||||
|
||||
// validate blocks
|
||||
size_t validate_size;
|
||||
for (size_t j = 0; j < cur.size() / layer.block_size; j++)
|
||||
{
|
||||
validate_size = mAlignHashCalcToBlock? layer.block_size : _MIN(layer.size - (j * layer.block_size), layer.block_size);
|
||||
fnd::sha::Sha256(cur.data() + (j * layer.block_size), validate_size, hash.bytes);
|
||||
if (hash.compare(prev.data() + j * sizeof(fnd::sha::sSha256Hash)) == false)
|
||||
{
|
||||
mErrorSs << "Hash tree layer verification failed (layer: " << i << ", block: " << j << ")";
|
||||
throw fnd::Exception(kModuleName, mErrorSs.str());
|
||||
}
|
||||
}
|
||||
|
||||
// set prev to cur
|
||||
prev = cur;
|
||||
}
|
||||
|
||||
// save last layer as hash table for data layer
|
||||
fnd::sha::sSha256Hash* hash_list = (fnd::sha::sSha256Hash*)prev.data();
|
||||
for (size_t i = 0; i < prev.size() / sizeof(fnd::sha::sSha256Hash); i++)
|
||||
{
|
||||
mDataHashLayer.addElement(hash_list[i]);
|
||||
}
|
||||
|
||||
// generate reader for data layer
|
||||
mData = new fnd::OffsetAdjustedIFile(mFile, hdr.getDataLayer().offset, hdr.getDataLayer().size);
|
||||
mDataOffset = 0;
|
||||
mDataBlockSize = hdr.getDataLayer().block_size;
|
||||
|
||||
// allocate cache
|
||||
size_t cache_size = align(kDefaultCacheSize, mDataBlockSize);
|
||||
mCacheBlockNum = cache_size / mDataBlockSize;
|
||||
mCache.alloc(cache_size);
|
||||
}
|
||||
|
||||
void fnd::LayeredIntegrityWrappedIFile::readData(size_t block_offset, size_t block_num)
|
||||
{
|
||||
fnd::sha::sSha256Hash hash;
|
||||
|
||||
// determine read size
|
||||
size_t read_len = 0;
|
||||
if ((block_offset + block_num) == getBlockNum((*mData)->size()))
|
||||
{
|
||||
read_len = (block_num-1) * mDataBlockSize + getRemanderBlockReadSize((*mData)->size());
|
||||
memset(mCache.data(), 0, block_num * mDataBlockSize);
|
||||
}
|
||||
else if ((block_offset + block_num) < getBlockNum((*mData)->size()))
|
||||
{
|
||||
read_len = block_num * mDataBlockSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "Out of bounds file read");
|
||||
}
|
||||
|
||||
// read
|
||||
(*mData)->read(mCache.data(), block_offset * mDataBlockSize, read_len);
|
||||
|
||||
if (block_num > mCacheBlockNum)
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "Read excessive of cache size");
|
||||
}
|
||||
|
||||
// validate blocks
|
||||
size_t validate_size;
|
||||
for (size_t i = 0; i < block_num; i++)
|
||||
{
|
||||
validate_size = mAlignHashCalcToBlock? mDataBlockSize : _MIN(read_len - (i * mDataBlockSize), mDataBlockSize);
|
||||
fnd::sha::Sha256(mCache.data() + (i * mDataBlockSize), validate_size, hash.bytes);
|
||||
if (hash != mDataHashLayer[block_offset + i])
|
||||
{
|
||||
mErrorSs << "Hash tree layer verification failed (layer: data, block: " << (block_offset + i) << " ( " << i << "/" << block_num-1 << " ), offset: 0x" << std::hex << ((block_offset + i) * mDataBlockSize) << ", size: 0x" << std::hex << validate_size <<")";
|
||||
throw fnd::Exception(kModuleName, mErrorSs.str());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
#include <fnd/OffsetAdjustedIFile.h>
|
||||
|
||||
fnd::OffsetAdjustedIFile::OffsetAdjustedIFile(const fnd::SharedPtr<fnd::IFile>& file, size_t offset, size_t size) :
|
||||
mFile(file),
|
||||
mBaseOffset(offset),
|
||||
mCurrentOffset(0),
|
||||
mSize(size)
|
||||
{
|
||||
}
|
||||
|
||||
size_t fnd::OffsetAdjustedIFile::size()
|
||||
{
|
||||
return mSize;
|
||||
}
|
||||
|
||||
void fnd::OffsetAdjustedIFile::seek(size_t offset)
|
||||
{
|
||||
mCurrentOffset = _MIN(offset, mSize);
|
||||
}
|
||||
|
||||
void fnd::OffsetAdjustedIFile::read(byte_t* out, size_t len)
|
||||
{
|
||||
// assert proper position in file
|
||||
(*mFile)->seek(mCurrentOffset + mBaseOffset);
|
||||
(*mFile)->read(out, len);
|
||||
seek(mCurrentOffset + len);
|
||||
}
|
||||
|
||||
void fnd::OffsetAdjustedIFile::read(byte_t* out, size_t offset, size_t len)
|
||||
{
|
||||
seek(offset);
|
||||
read(out, len);
|
||||
}
|
||||
|
||||
void fnd::OffsetAdjustedIFile::write(const byte_t* out, size_t len)
|
||||
{
|
||||
// assert proper position in file
|
||||
(*mFile)->seek(mCurrentOffset + mBaseOffset);
|
||||
(*mFile)->write(out, len);
|
||||
seek(mCurrentOffset + len);
|
||||
}
|
||||
|
||||
void fnd::OffsetAdjustedIFile::write(const byte_t* out, size_t offset, size_t len)
|
||||
{
|
||||
seek(offset);
|
||||
write(out, len);
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
#include <fnd/types.h>
|
||||
#include <fnd/ResourceFileReader.h>
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
fnd::ResourceFileReader::ResourceFileReader()
|
||||
{
|
||||
}
|
||||
|
||||
inline bool isNotPrintable(char chr) { return isprint(chr) == false; }
|
||||
|
||||
void fnd::ResourceFileReader::processFile(const std::string& path)
|
||||
{
|
||||
std::ifstream file;
|
||||
file.open(path, std::ios::in);
|
||||
if (file.is_open() == false)
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "Failed to open file");
|
||||
}
|
||||
|
||||
std::string line, key, value;
|
||||
while (std::getline(file, line))
|
||||
{
|
||||
// read up to comment line
|
||||
if (line.find(";") != std::string::npos)
|
||||
line = line.substr(0, line.find(";"));
|
||||
|
||||
// change chars to lower string
|
||||
std::transform(line.begin(), line.end(), line.begin(), ::tolower);
|
||||
|
||||
// strip whitespace
|
||||
line.erase(std::remove(line.begin(), line.end(), ' '), line.end());
|
||||
|
||||
// strip nonprintable
|
||||
line.erase(std::remove_if(line.begin(), line.end(), isNotPrintable), line.end());
|
||||
|
||||
// skip lines that don't have '='
|
||||
if (line.find("=") == std::string::npos)
|
||||
continue;
|
||||
|
||||
key = line.substr(0,line.find("="));
|
||||
value = line.substr(line.find("=")+1);
|
||||
|
||||
// skip if key or value is empty
|
||||
if (key.empty() || value.empty())
|
||||
continue;
|
||||
|
||||
//std::cout << "[" + key + "]=(" + value + ")" << std::endl;
|
||||
|
||||
mResources[key] = value;
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
bool fnd::ResourceFileReader::doesExist(const std::string& key) const
|
||||
{
|
||||
return (mResources.find(key) != mResources.end());
|
||||
}
|
||||
|
||||
const std::string& fnd::ResourceFileReader::operator[](const std::string& key)
|
||||
{
|
||||
return mResources[key];
|
||||
}
|
|
@ -1,331 +0,0 @@
|
|||
#include <fnd/SimpleFile.h>
|
||||
#include <fnd/StringConv.h>
|
||||
|
||||
using namespace fnd;
|
||||
|
||||
SimpleFile::SimpleFile() :
|
||||
mOpen(false),
|
||||
mMode(Read),
|
||||
#ifdef _WIN32
|
||||
mFileHandle()
|
||||
#else
|
||||
mFp(nullptr)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
SimpleFile::SimpleFile(const std::string& path, OpenMode mode) :
|
||||
SimpleFile()
|
||||
{
|
||||
open(path, mode);
|
||||
}
|
||||
|
||||
SimpleFile::~SimpleFile()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void SimpleFile::open(const std::string& path, OpenMode mode)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
// convert string to unicode
|
||||
std::u16string unicodePath = fnd::StringConv::ConvertChar8ToChar16(path);
|
||||
|
||||
// save mode
|
||||
mMode = mode;
|
||||
|
||||
// open file
|
||||
mFileHandle = CreateFileW((LPCWSTR)unicodePath.c_str(),
|
||||
getOpenModeFlag(mMode),
|
||||
getShareModeFlag(mMode),
|
||||
0,
|
||||
getCreationModeFlag(mMode),
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
// check file handle
|
||||
if (mFileHandle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "Failed to open file.");
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
//close();
|
||||
mMode = mode;
|
||||
//printf("fopen(%s,%s);\n", path.c_str(), getOpenModeStr(mMode));
|
||||
mFp = fopen(path.c_str(), getOpenModeStr(mMode));
|
||||
if (mFp == nullptr)
|
||||
throw fnd::Exception(kModuleName, "Failed to open file.");
|
||||
mOpen = true;
|
||||
#endif
|
||||
|
||||
seek(0);
|
||||
}
|
||||
|
||||
bool SimpleFile::isOpen() const
|
||||
{
|
||||
return mOpen == true;
|
||||
}
|
||||
|
||||
void SimpleFile::close()
|
||||
{
|
||||
if (isOpen())
|
||||
{
|
||||
#ifdef _WIN32
|
||||
CloseHandle(mFileHandle);
|
||||
#else
|
||||
fclose(mFp);
|
||||
mFp = nullptr;
|
||||
#endif
|
||||
}
|
||||
mOpen = false;
|
||||
}
|
||||
|
||||
size_t SimpleFile::size()
|
||||
{
|
||||
size_t fsize = 0;
|
||||
#ifdef _WIN32
|
||||
if (mMode != Create)
|
||||
{
|
||||
LARGE_INTEGER win_fsize;
|
||||
if (GetFileSizeEx(mFileHandle, &win_fsize) == false)
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "Failed to check filesize");
|
||||
}
|
||||
|
||||
fsize = win_fsize.QuadPart;
|
||||
}
|
||||
else
|
||||
{
|
||||
fsize = 0;
|
||||
}
|
||||
#else
|
||||
size_t cur_pos = pos();
|
||||
fseek(mFp, 0, SEEK_END);
|
||||
fsize = pos();
|
||||
seek(cur_pos);
|
||||
#endif
|
||||
return fsize;
|
||||
}
|
||||
|
||||
void SimpleFile::seek(size_t offset)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
LARGE_INTEGER win_pos, out;
|
||||
win_pos.QuadPart = offset;
|
||||
if (SetFilePointerEx(
|
||||
mFileHandle,
|
||||
win_pos,
|
||||
&out,
|
||||
FILE_BEGIN
|
||||
) == false || out.QuadPart != win_pos.QuadPart)
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "Failed to change file offset");
|
||||
}
|
||||
#else
|
||||
fseek(mFp, offset, SEEK_SET);
|
||||
#endif
|
||||
}
|
||||
|
||||
size_t SimpleFile::pos()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
LARGE_INTEGER win_pos, out;
|
||||
win_pos.QuadPart = 0;
|
||||
if (SetFilePointerEx(
|
||||
mFileHandle,
|
||||
win_pos,
|
||||
&out,
|
||||
FILE_CURRENT
|
||||
) == false)
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "Failed to check file offset");
|
||||
}
|
||||
|
||||
return out.QuadPart;
|
||||
#else
|
||||
return ftell(mFp);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SimpleFile::read(byte_t* out, size_t len)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
LARGE_INTEGER win_len;
|
||||
win_len.QuadPart = len;
|
||||
|
||||
static const DWORD kDwordHalf = (MAXDWORD / (DWORD)2) + 1; // 0x80000000
|
||||
static const size_t kDwordFull = (size_t)kDwordHalf * (size_t)2; // 0x100000000
|
||||
|
||||
// if the size is greater than a DWORD, read it in parts,
|
||||
for (LONG i = 0; i < win_len.HighPart; i++)
|
||||
{
|
||||
// since kDwordFull isn't a valid DWORD value, read in two parts
|
||||
ReadFile(
|
||||
mFileHandle,
|
||||
out + i * kDwordFull,
|
||||
kDwordHalf,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
ReadFile(
|
||||
mFileHandle,
|
||||
out + i * kDwordFull + kDwordHalf,
|
||||
kDwordHalf,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
// read remainding low part
|
||||
if (win_len.LowPart > 0)
|
||||
{
|
||||
ReadFile(
|
||||
mFileHandle,
|
||||
out + win_len.HighPart * kDwordFull,
|
||||
win_len.LowPart,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
#else
|
||||
fread(out, len, 1, mFp);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SimpleFile::read(byte_t* out, size_t offset, size_t len)
|
||||
{
|
||||
seek(offset);
|
||||
read(out, len);
|
||||
}
|
||||
|
||||
void SimpleFile::write(const byte_t* out, size_t len)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
LARGE_INTEGER win_len;
|
||||
win_len.QuadPart = len;
|
||||
|
||||
static const DWORD kDwordHalf = ((DWORD)MAXDWORD / (DWORD)2) + 1; // 0x80000000
|
||||
static const size_t kDwordFull = (size_t)kDwordHalf * (size_t)2; // 0x100000000
|
||||
|
||||
// if the size is greater than a DWORD, read it in parts,
|
||||
for (LONG i = 0; i < win_len.HighPart; i++)
|
||||
{
|
||||
// since kDwordFull isn't a valid DWORD value, read in two parts
|
||||
WriteFile(
|
||||
mFileHandle,
|
||||
out + i * kDwordFull,
|
||||
kDwordHalf,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
WriteFile(
|
||||
mFileHandle,
|
||||
out + i * kDwordFull + kDwordHalf,
|
||||
kDwordHalf,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
// read remainding low part
|
||||
if (win_len.LowPart > 0)
|
||||
{
|
||||
WriteFile(
|
||||
mFileHandle,
|
||||
out + win_len.HighPart * kDwordFull,
|
||||
win_len.LowPart,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
#else
|
||||
fwrite(out, len, 1, mFp);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SimpleFile::write(const byte_t* out, size_t offset, size_t len)
|
||||
{
|
||||
seek(offset);
|
||||
write(out, len);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
DWORD SimpleFile::getOpenModeFlag(OpenMode mode) const
|
||||
{
|
||||
DWORD flag = 0;
|
||||
switch (mode)
|
||||
{
|
||||
case (Read):
|
||||
flag = GENERIC_READ;
|
||||
break;
|
||||
case (Edit):
|
||||
flag = GENERIC_READ | GENERIC_WRITE;
|
||||
break;
|
||||
case (Create):
|
||||
flag = GENERIC_WRITE;
|
||||
break;
|
||||
default:
|
||||
throw fnd::Exception(kModuleName, "Unknown open mode");
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
DWORD fnd::SimpleFile::getShareModeFlag(OpenMode mode) const
|
||||
{
|
||||
DWORD flag = 0;
|
||||
switch (mode)
|
||||
{
|
||||
case (Read):
|
||||
flag = FILE_SHARE_READ;
|
||||
break;
|
||||
case (Edit):
|
||||
flag = FILE_SHARE_READ;
|
||||
break;
|
||||
case (Create):
|
||||
flag = 0;
|
||||
break;
|
||||
default:
|
||||
throw fnd::Exception(kModuleName, "Unknown open mode");
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
DWORD fnd::SimpleFile::getCreationModeFlag(OpenMode mode) const
|
||||
{
|
||||
DWORD flag = 0;
|
||||
switch (mode)
|
||||
{
|
||||
case (Read):
|
||||
flag = OPEN_EXISTING;
|
||||
break;
|
||||
case (Edit):
|
||||
flag = OPEN_EXISTING;
|
||||
break;
|
||||
case (Create):
|
||||
flag = CREATE_ALWAYS;
|
||||
break;
|
||||
default:
|
||||
throw fnd::Exception(kModuleName, "Unknown open mode");
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
#else
|
||||
const char* SimpleFile::getOpenModeStr(OpenMode mode)
|
||||
{
|
||||
const char* str = "";
|
||||
switch(mode)
|
||||
{
|
||||
case (Read):
|
||||
str = "rb";
|
||||
break;
|
||||
case (Edit):
|
||||
str = "rb+";
|
||||
break;
|
||||
case (Create):
|
||||
str = "wb";
|
||||
break;
|
||||
default:
|
||||
throw fnd::Exception(kModuleName, "Unknown open mode");
|
||||
}
|
||||
return str;
|
||||
}
|
||||
#endif
|
|
@ -1,117 +0,0 @@
|
|||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <cstdio>
|
||||
#include <fnd/SimpleTextOutput.h>
|
||||
|
||||
void fnd::SimpleTextOutput::hxdStyleDump(const byte_t* data, size_t len, size_t row_len, size_t byte_grouping_size)
|
||||
{
|
||||
// iterate over blocks
|
||||
for (size_t i = 0; i < (len / row_len); i++)
|
||||
{
|
||||
printf("%08" PRIx64 " | ", (uint64_t)(i * row_len));
|
||||
// for block i print each byte
|
||||
for (size_t j = 0; j < row_len; j++)
|
||||
{
|
||||
printf("%02X", data[(i * row_len) + j]);
|
||||
if (((j+1) % byte_grouping_size) == 0)
|
||||
{
|
||||
putchar(' ');
|
||||
}
|
||||
}
|
||||
printf(" ");
|
||||
for (size_t j = 0; j < row_len; j++)
|
||||
{
|
||||
printf("%c", iscntrl(data[(i * row_len) + j]) ? '.' : data[(i * row_len) + j]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
if ((len % row_len) > 0)
|
||||
{
|
||||
size_t i = (len / row_len);
|
||||
printf("%08" PRIx64 " | ", (uint64_t)(i * row_len));
|
||||
// for block i print each byte
|
||||
for (size_t j = 0; j < row_len; j++)
|
||||
{
|
||||
if (j < (len % row_len))
|
||||
printf("%02X", data[(i * row_len) + j]);
|
||||
else
|
||||
printf(" ");
|
||||
if (((j+1) % byte_grouping_size) == 0)
|
||||
{
|
||||
putchar(' ');
|
||||
}
|
||||
}
|
||||
printf(" ");
|
||||
for (size_t j = 0; j < row_len; j++)
|
||||
{
|
||||
if (j < (len % row_len))
|
||||
printf("%c", iscntrl(data[(i * row_len) + j]) ? '.' : data[(i * row_len) + j]);
|
||||
else
|
||||
printf(" ");
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
void fnd::SimpleTextOutput::hxdStyleDump(const byte_t* data, size_t len)
|
||||
{
|
||||
hxdStyleDump(data, len, kDefaultRowLen, kDefaultByteGroupingSize);
|
||||
}
|
||||
|
||||
void fnd::SimpleTextOutput::hexDump(const byte_t* data, size_t len, size_t row_len, size_t indent_len)
|
||||
{
|
||||
for (size_t i = 0; i < len; i += row_len)
|
||||
{
|
||||
for (size_t j = 0; j < indent_len; j++)
|
||||
std::cout << " ";
|
||||
std::cout << arrayToString(data+i, _MIN(len-i, row_len), true, "") << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void fnd::SimpleTextOutput::hexDump(const byte_t* data, size_t len)
|
||||
{
|
||||
std::cout << arrayToString(data, len, true, "") << std::endl;
|
||||
}
|
||||
|
||||
std::string fnd::SimpleTextOutput::arrayToString(const byte_t* data, size_t len, bool upper_case, const std::string& separator)
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
if (upper_case)
|
||||
ss << std::uppercase;
|
||||
for (size_t i = 0; i < len; i++)
|
||||
{
|
||||
ss << std::hex << std::setw(2) << std::setfill('0') << (uint32_t)data[i];
|
||||
if (i+1 < len)
|
||||
ss << separator;
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
inline byte_t charToByte(char chr)
|
||||
{
|
||||
if (chr >= 'a' && chr <= 'f')
|
||||
return (chr - 'a') + 0xa;
|
||||
else if (chr >= 'A' && chr <= 'F')
|
||||
return (chr - 'A') + 0xa;
|
||||
else if (chr >= '0' && chr <= '9')
|
||||
return chr - '0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
void fnd::SimpleTextOutput::stringToArray(const std::string& str, fnd::Vec<byte_t>& array)
|
||||
{
|
||||
size_t size = str.size();
|
||||
if ((size % 2))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
array.alloc(size/2);
|
||||
|
||||
for (size_t i = 0; i < array.size(); i++)
|
||||
{
|
||||
array[i] = (charToByte(str[i * 2]) << 4) | charToByte(str[(i * 2) + 1]);
|
||||
}
|
||||
}
|
|
@ -1,147 +0,0 @@
|
|||
#include <fnd/StringConv.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
using namespace fnd;
|
||||
|
||||
std::u16string StringConv::ConvertChar8ToChar16(const std::string & in)
|
||||
{
|
||||
std::u32string unicode;
|
||||
size_t done = 0;
|
||||
for (size_t i = 0; i < in.length(); i += done)
|
||||
{
|
||||
// get number of leading high bits in first byte
|
||||
uint8_t prefix = get_utf8_prefix(in[i]);
|
||||
if (prefix == 1 || prefix > 4) // 1 is reserved for trailer bytes
|
||||
{
|
||||
throw std::logic_error("not a UTF-8 string");
|
||||
}
|
||||
|
||||
// if there are no prefix bits, this is ASCII
|
||||
if (prefix == 0)
|
||||
{
|
||||
unicode.push_back(in[i]);
|
||||
done = 1;
|
||||
}
|
||||
// otherwise this is a multibyte character
|
||||
else
|
||||
{
|
||||
// there must be enough characters
|
||||
if ((i + prefix) > in.length())
|
||||
{
|
||||
throw std::logic_error("not a UTF-8 string");
|
||||
}
|
||||
|
||||
char32_t uni = get_utf8_data(prefix, in[i]);
|
||||
|
||||
for (uint8_t j = 1; j < prefix; j++)
|
||||
{
|
||||
if (utf8_has_prefix(1, in[i + j]) == false)
|
||||
{
|
||||
throw std::logic_error("not a UTF-8 string");
|
||||
}
|
||||
|
||||
uni <<= 6;
|
||||
uni |= get_utf8_data(1, in[i + j]);
|
||||
}
|
||||
|
||||
if (uni >= kUtf16HighSurrogateStart && uni <= kUtf16LowSurrogateEnd)
|
||||
{
|
||||
throw std::logic_error("not a UTF-8 string");
|
||||
}
|
||||
|
||||
if (uni > kUtf16EncodeMax)
|
||||
{
|
||||
throw std::logic_error("not a UTF-8 string");
|
||||
}
|
||||
|
||||
unicode.push_back(uni);
|
||||
done = prefix;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::u16string utf16;
|
||||
for (size_t i = 0; i < unicode.size(); i++)
|
||||
{
|
||||
char32_t uni = unicode[i];
|
||||
if (uni < kUtf16NonNativeStart)
|
||||
{
|
||||
utf16.push_back((char16_t)uni);
|
||||
}
|
||||
else
|
||||
{
|
||||
uni -= kUtf16NonNativeStart;
|
||||
utf16.push_back(((uni >> kUtf16SurrogateBits) & kUtf16SurrogateMask) + kUtf16HighSurrogateStart);
|
||||
utf16.push_back((uni & kUtf16SurrogateMask) + kUtf16LowSurrogateStart);
|
||||
}
|
||||
}
|
||||
return utf16;
|
||||
}
|
||||
|
||||
std::string StringConv::ConvertChar16ToChar8(const std::u16string & in)
|
||||
{
|
||||
std::u32string unicode;
|
||||
size_t done = 0;
|
||||
for (size_t i = 0; i < in.length(); i+=done)
|
||||
{
|
||||
// this isn't a utf16 reserved character, so just add to unicode string
|
||||
if (in[i] < kUtf16HighSurrogateStart || in[i] > kUtf16LowSurrogateEnd)
|
||||
{
|
||||
unicode.push_back(in[i]);
|
||||
done = 1;
|
||||
}
|
||||
// otherwise we need to decode it
|
||||
else
|
||||
{
|
||||
// check that the high surrogate char exists first
|
||||
if (in[i] < kUtf16HighSurrogateStart || in[i] > kUtf16HighSurrogateEnd)
|
||||
{
|
||||
throw std::logic_error("not a UTF-16 string");
|
||||
}
|
||||
// check that the low surrogate char exists next
|
||||
if (i >= in.length() - 1 || in[i + 1] < kUtf16LowSurrogateStart || in[i + 1] > kUtf16LowSurrogateEnd)
|
||||
{
|
||||
throw std::logic_error("not a UTF-16 string");
|
||||
}
|
||||
|
||||
char32_t uni = ((in[i] & kUtf16SurrogateMask) << kUtf16SurrogateBits) | (in[i + 1] & kUtf16SurrogateMask) | 0x10000;
|
||||
|
||||
unicode.push_back(uni);
|
||||
done = 2;
|
||||
}
|
||||
}
|
||||
|
||||
std::string utf8;
|
||||
for (size_t i = 0; i < unicode.length(); i++)
|
||||
{
|
||||
if (unicode[i] <= kUtf8AsciiEnd)
|
||||
{
|
||||
utf8.push_back((char)unicode[i]);
|
||||
}
|
||||
else if (unicode[i] <= kUtf82ByteEnd)
|
||||
{
|
||||
utf8.push_back(make_utf8(2, (uint8_t)(unicode[i] >> 6)));
|
||||
utf8.push_back(make_utf8(1, (uint8_t)(unicode[i] >> 0)));
|
||||
}
|
||||
else if (unicode[i] <= kUtf83ByteEnd)
|
||||
{
|
||||
utf8.push_back(make_utf8(3, (uint8_t)(unicode[i] >> 12)));
|
||||
utf8.push_back(make_utf8(1, (uint8_t)(unicode[i] >> 6)));
|
||||
utf8.push_back(make_utf8(1, (uint8_t)(unicode[i] >> 0)));
|
||||
}
|
||||
else if (unicode[i] <= kUtf84ByteEnd)
|
||||
{
|
||||
utf8.push_back(make_utf8(4, (uint8_t)(unicode[i] >> 18)));
|
||||
utf8.push_back(make_utf8(1, (uint8_t)(unicode[i] >> 12)));
|
||||
utf8.push_back(make_utf8(1, (uint8_t)(unicode[i] >> 6)));
|
||||
utf8.push_back(make_utf8(1, (uint8_t)(unicode[i] >> 0)));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::logic_error("not a UTF-16 string");
|
||||
}
|
||||
}
|
||||
|
||||
return utf8;
|
||||
}
|
|
@ -1,159 +0,0 @@
|
|||
#include <fnd/aes.h>
|
||||
#include <polarssl/aes.h>
|
||||
|
||||
using namespace fnd::aes;
|
||||
|
||||
inline void XorBlock(const uint8_t a[kAesBlockSize], const uint8_t b[kAesBlockSize], uint8_t out[kAesBlockSize])
|
||||
{
|
||||
for (uint8_t i = 0; i < 16; i++)
|
||||
{
|
||||
out[i] = a[i] ^ b[i];
|
||||
}
|
||||
}
|
||||
|
||||
inline uint32_t getbe32(const uint8_t* data) { return data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3]; }
|
||||
inline void putbe32(uint8_t* data, uint32_t val) { data[0] = val >> 24; data[1] = val >> 16; data[2] = val >> 8; data[3] = val; }
|
||||
|
||||
|
||||
|
||||
void fnd::aes::AesEcbDecrypt(const uint8_t * in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t * out)
|
||||
{
|
||||
aes_context ctx;
|
||||
aes_setkey_dec(&ctx, key, 128);
|
||||
|
||||
for (size_t i = 0; i < size / kAesBlockSize; i++)
|
||||
{
|
||||
aes_crypt_ecb(&ctx, AES_DECRYPT, in + kAesBlockSize * i, out + kAesBlockSize * i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void fnd::aes::AesEcbEncrypt(const uint8_t * in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t * out)
|
||||
{
|
||||
aes_context ctx;
|
||||
aes_setkey_enc(&ctx, key, 128);
|
||||
for (size_t i = 0; i < size / kAesBlockSize; i++)
|
||||
{
|
||||
aes_crypt_ecb(&ctx, AES_ENCRYPT, in + kAesBlockSize * i, out + kAesBlockSize * i);
|
||||
}
|
||||
}
|
||||
|
||||
void fnd::aes::AesCtr(const uint8_t* in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t ctr[kAesBlockSize], uint8_t* out)
|
||||
{
|
||||
aes_context ctx;
|
||||
uint8_t block[kAesBlockSize] = { 0 };
|
||||
size_t counterOffset = 0;
|
||||
|
||||
aes_setkey_enc(&ctx, key, 128);
|
||||
aes_crypt_ctr(&ctx, size, &counterOffset, ctr, block, in, out);
|
||||
}
|
||||
|
||||
void fnd::aes::AesIncrementCounter(const uint8_t in[kAesBlockSize], size_t block_num, uint8_t out[kAesBlockSize])
|
||||
{
|
||||
memcpy(out, in, kAesBlockSize);
|
||||
|
||||
uint32_t ctr[4];
|
||||
ctr[3] = getbe32(&in[0]);
|
||||
ctr[2] = getbe32(&in[4]);
|
||||
ctr[1] = getbe32(&in[8]);
|
||||
ctr[0] = getbe32(&in[12]);
|
||||
|
||||
for (uint32_t i = 0; i < 4; i++) {
|
||||
uint64_t total = ctr[i] + block_num;
|
||||
// if there wasn't a wrap around, add the two together and exit
|
||||
if (total <= 0xffffffff) {
|
||||
ctr[i] += (uint32_t)block_num;
|
||||
break;
|
||||
}
|
||||
|
||||
// add the difference
|
||||
ctr[i] = (uint32_t)(total - 0x100000000);
|
||||
// carry to next word
|
||||
block_num = (uint32_t)(total >> 32);
|
||||
}
|
||||
|
||||
putbe32(&out[0], ctr[3]);
|
||||
putbe32(&out[4], ctr[2]);
|
||||
putbe32(&out[8], ctr[1]);
|
||||
putbe32(&out[12], ctr[0]);
|
||||
}
|
||||
|
||||
void fnd::aes::AesCbcDecrypt(const uint8_t* in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t iv[kAesBlockSize], uint8_t* out)
|
||||
{
|
||||
aes_context ctx;
|
||||
aes_setkey_dec(&ctx, key, 128);
|
||||
aes_crypt_cbc(&ctx, AES_DECRYPT, size, iv, in, out);
|
||||
}
|
||||
|
||||
void fnd::aes::AesCbcEncrypt(const uint8_t* in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t iv[kAesBlockSize], uint8_t* out)
|
||||
{
|
||||
aes_context ctx;
|
||||
aes_setkey_enc(&ctx, key, 128);
|
||||
aes_crypt_cbc(&ctx, AES_ENCRYPT, size, iv, in, out);
|
||||
}
|
||||
|
||||
void fnd::aes::AesXtsDecryptSector(const uint8_t * in, uint64_t sector_size, const uint8_t key1[kAes128KeySize], const uint8_t key2[kAes128KeySize], uint8_t tweak[kAesBlockSize], uint8_t * out)
|
||||
{
|
||||
aes_context data_ctx;
|
||||
aes_setkey_dec(&data_ctx, key1, 128);
|
||||
|
||||
uint8_t enc_tweak[kAesBlockSize];
|
||||
AesEcbEncrypt(tweak, kAesBlockSize, key2, enc_tweak);
|
||||
|
||||
size_t block_num = sector_size / kAesBlockSize;
|
||||
uint8_t block[kAesBlockSize];
|
||||
for (size_t i = 0; i < block_num; i++)
|
||||
{
|
||||
XorBlock(in + (i * kAesBlockSize), enc_tweak, block);
|
||||
aes_crypt_ecb(&data_ctx, AES_DECRYPT, block, block);
|
||||
XorBlock(block, enc_tweak, out + i * kAesBlockSize);
|
||||
GaloisFunc(enc_tweak);
|
||||
}
|
||||
|
||||
if (sector_size % kAesBlockSize)
|
||||
{
|
||||
// TODO: implement ciphertext stealing
|
||||
}
|
||||
}
|
||||
|
||||
void fnd::aes::AesXtsEncryptSector(const uint8_t * in, uint64_t sector_size, const uint8_t key1[kAes128KeySize], const uint8_t key2[kAes128KeySize], uint8_t tweak[kAesBlockSize], uint8_t * out)
|
||||
{
|
||||
aes_context data_ctx;
|
||||
aes_setkey_enc(&data_ctx, key1, 128);
|
||||
|
||||
uint8_t enc_tweak[kAesBlockSize];
|
||||
AesEcbEncrypt(tweak, kAesBlockSize, key2, enc_tweak);
|
||||
|
||||
size_t block_num = sector_size / kAesBlockSize;
|
||||
uint8_t block[kAesBlockSize];
|
||||
for (size_t i = 0; i < block_num; i++)
|
||||
{
|
||||
XorBlock(in + (i * kAesBlockSize), enc_tweak, block);
|
||||
aes_crypt_ecb(&data_ctx, AES_ENCRYPT, block, block);
|
||||
XorBlock(block, enc_tweak, out + (i * kAesBlockSize));
|
||||
GaloisFunc(enc_tweak);
|
||||
}
|
||||
|
||||
if (sector_size % kAesBlockSize)
|
||||
{
|
||||
// TODO: implement ciphertext stealing
|
||||
}
|
||||
}
|
||||
|
||||
void fnd::aes::AesXtsMakeTweak(uint8_t tweak[kAesBlockSize], size_t block_index)
|
||||
{
|
||||
memset(tweak, 0, kAesBlockSize);
|
||||
AesIncrementCounter(tweak, block_index, tweak);
|
||||
}
|
||||
|
||||
void fnd::aes::GaloisFunc(uint8_t x[kAesBlockSize])
|
||||
{
|
||||
uint8_t t = x[15];
|
||||
|
||||
for (uint8_t i = 15; i > 0; i--)
|
||||
{
|
||||
x[i] = (x[i] << 1) | (x[i - 1] & 0x80 ? 1 : 0);
|
||||
}
|
||||
|
||||
x[0] = (x[0] << 1) ^ (t & 0x80 ? 0x87 : 0x00);
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
#include <fnd/base64.h>
|
||||
#include <polarssl/base64.h>
|
||||
|
||||
size_t fnd::base64::B64_GetEncodeLen(const uint8_t* src, size_t slen)
|
||||
{
|
||||
size_t dlen = 0;
|
||||
|
||||
base64_encode(nullptr, &dlen, src, slen);
|
||||
|
||||
return dlen;
|
||||
}
|
||||
|
||||
void fnd::base64::B64_Encode(const uint8_t* src, size_t slen, uint8_t* dst, size_t dlen)
|
||||
{
|
||||
base64_encode(dst, &dlen, src, slen);
|
||||
}
|
||||
|
||||
size_t fnd::base64::B64_GetDecodeLen(const uint8_t* src, size_t slen)
|
||||
{
|
||||
size_t dlen = 0;
|
||||
|
||||
base64_decode(nullptr, &dlen, src, slen);
|
||||
|
||||
return dlen;
|
||||
}
|
||||
|
||||
void fnd::base64::B64_Decode(const uint8_t* src, size_t slen, uint8_t* dst, size_t dlen)
|
||||
{
|
||||
base64_decode(dst, &dlen, src, slen);
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
#include <fnd/io.h>
|
||||
#include <fnd/StringConv.h>
|
||||
#include <fnd/SimpleFile.h>
|
||||
#include <fstream>
|
||||
#ifdef _WIN32
|
||||
#include <direct.h>
|
||||
#include <cstdlib>
|
||||
#else
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
using namespace fnd;
|
||||
|
||||
size_t io::getFileSize(const std::string& path)
|
||||
{
|
||||
std::ifstream f;
|
||||
f.open(path, std::ios_base::binary | std::ios_base::in);
|
||||
if (!f.good() || f.eof() || !f.is_open()) { return 0; }
|
||||
f.seekg(0, std::ios_base::beg);
|
||||
std::ifstream::pos_type begin_pos = f.tellg();
|
||||
f.seekg(0, std::ios_base::end);
|
||||
return static_cast<size_t>(f.tellg() - begin_pos);
|
||||
}
|
||||
|
||||
void io::makeDirectory(const std::string& path)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
std::u16string wpath = fnd::StringConv::ConvertChar8ToChar16(path);
|
||||
_wmkdir((wchar_t*)wpath.c_str());
|
||||
#else
|
||||
mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
#endif
|
||||
}
|
||||
|
||||
void fnd::io::getEnvironVar(std::string & var, const std::string & key)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
char* var_tmp = nullptr;
|
||||
size_t var_len = 0;
|
||||
_dupenv_s(&var_tmp, &var_len, key.c_str());
|
||||
|
||||
if (var_len > 0)
|
||||
{
|
||||
var = std::string(var_tmp);
|
||||
free(var_tmp);
|
||||
}
|
||||
#else
|
||||
char* var_tmp = nullptr;
|
||||
|
||||
var_tmp = getenv(key.c_str());
|
||||
|
||||
if (var_tmp != nullptr)
|
||||
{
|
||||
var = std::string(var_tmp);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void fnd::io::appendToPath(std::string& base, const std::string& add)
|
||||
{
|
||||
if (add.empty())
|
||||
return;
|
||||
|
||||
if (base.empty())
|
||||
{
|
||||
base = add;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (base[base.length()-1] != io::kPathDivider[0])
|
||||
base += io::kPathDivider;
|
||||
base += add;
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
#include <fnd/lz4.h>
|
||||
#include <lz4.h>
|
||||
|
||||
void fnd::lz4::compressData(const uint8_t* src, uint32_t src_len, uint8_t* dst, uint32_t dst_capacity, uint32_t& compressed_size)
|
||||
{
|
||||
compressed_size = LZ4_compress_default((const char*)src, (char*)dst, (int)src_len, (int)dst_capacity);
|
||||
}
|
||||
|
||||
void fnd::lz4::decompressData(const uint8_t* src, uint32_t src_len, uint8_t* dst, uint32_t dst_capacity, uint32_t& decompressed_size)
|
||||
{
|
||||
decompressed_size = LZ4_decompress_safe((const char*)src, (char*)dst, (int)src_len, (int)dst_capacity);
|
||||
}
|
||||
|
||||
|
|
@ -1,214 +0,0 @@
|
|||
#include <fnd/rsa.h>
|
||||
#include <polarssl/rsa.h>
|
||||
#include <polarssl/md.h>
|
||||
#include <polarssl/entropy.h>
|
||||
#include <polarssl/ctr_drbg.h>
|
||||
|
||||
using namespace fnd::rsa;
|
||||
using namespace fnd::sha;
|
||||
|
||||
int getWrappedHashType(HashType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case HASH_SHA1:
|
||||
return SIG_RSA_SHA1;
|
||||
break;
|
||||
case HASH_SHA256:
|
||||
return SIG_RSA_SHA256;
|
||||
break;
|
||||
default:
|
||||
return SIG_RSA_RAW;
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int getMdWrappedHashType(HashType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case HASH_SHA1:
|
||||
return POLARSSL_MD_SHA1;
|
||||
break;
|
||||
case HASH_SHA256:
|
||||
return POLARSSL_MD_SHA256;
|
||||
break;
|
||||
default:
|
||||
return POLARSSL_MD_NONE;
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t getWrappedHashSize(HashType type)
|
||||
{
|
||||
uint32_t size = 0;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case HASH_SHA1:
|
||||
size = kSha1HashLen;
|
||||
break;
|
||||
case HASH_SHA256:
|
||||
size = kSha256HashLen;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
int fnd::rsa::pkcs::rsaSign(const sRsa1024Key & key, HashType hash_type, const uint8_t * hash, uint8_t signature[kRsa1024Size])
|
||||
{
|
||||
int ret;
|
||||
rsa_context ctx;
|
||||
rsa_init(&ctx, RSA_PKCS_V15, 0);
|
||||
|
||||
ctx.len = kRsa1024Size;
|
||||
mpi_read_binary(&ctx.D, key.priv_exponent, ctx.len);
|
||||
mpi_read_binary(&ctx.N, key.modulus, ctx.len);
|
||||
|
||||
ret = rsa_rsassa_pkcs1_v15_sign(&ctx, RSA_PRIVATE, getWrappedHashType(hash_type), getWrappedHashSize(hash_type), hash, signature);
|
||||
|
||||
rsa_free(&ctx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int fnd::rsa::pkcs::rsaVerify(const sRsa1024Key & key, HashType hash_type, const uint8_t * hash, const uint8_t signature[kRsa1024Size])
|
||||
{
|
||||
static const uint8_t public_exponent[3] = { 0x01, 0x00, 0x01 };
|
||||
|
||||
int ret;
|
||||
rsa_context ctx;
|
||||
rsa_init(&ctx, RSA_PKCS_V15, 0);
|
||||
|
||||
ctx.len = kRsa1024Size;
|
||||
mpi_read_binary(&ctx.E, public_exponent, sizeof(public_exponent));
|
||||
mpi_read_binary(&ctx.N, key.modulus, ctx.len);
|
||||
|
||||
ret = rsa_rsassa_pkcs1_v15_verify(&ctx, RSA_PUBLIC, getWrappedHashType(hash_type), getWrappedHashSize(hash_type), hash, signature);
|
||||
|
||||
rsa_free(&ctx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int fnd::rsa::pkcs::rsaSign(const sRsa2048Key & key, HashType hash_type, const uint8_t * hash, uint8_t signature[kRsa2048Size])
|
||||
{
|
||||
int ret;
|
||||
rsa_context ctx;
|
||||
rsa_init(&ctx, RSA_PKCS_V15, 0);
|
||||
|
||||
ctx.len = kRsa2048Size;
|
||||
mpi_read_binary(&ctx.D, key.priv_exponent, ctx.len);
|
||||
mpi_read_binary(&ctx.N, key.modulus, ctx.len);
|
||||
|
||||
ret = rsa_rsassa_pkcs1_v15_sign(&ctx, RSA_PRIVATE, getWrappedHashType(hash_type), getWrappedHashSize(hash_type), hash, signature);
|
||||
|
||||
rsa_free(&ctx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int fnd::rsa::pkcs::rsaVerify(const sRsa2048Key & key, HashType hash_type, const uint8_t * hash, const uint8_t signature[kRsa2048Size])
|
||||
{
|
||||
static const uint8_t public_exponent[3] = { 0x01, 0x00, 0x01 };
|
||||
|
||||
int ret;
|
||||
rsa_context ctx;
|
||||
rsa_init(&ctx, RSA_PKCS_V15, 0);
|
||||
|
||||
ctx.len = kRsa2048Size;
|
||||
mpi_read_binary(&ctx.E, public_exponent, sizeof(public_exponent));
|
||||
mpi_read_binary(&ctx.N, key.modulus, ctx.len);
|
||||
|
||||
ret = rsa_rsassa_pkcs1_v15_verify(&ctx, RSA_PUBLIC, getWrappedHashType(hash_type), getWrappedHashSize(hash_type), hash, signature);
|
||||
|
||||
rsa_free(&ctx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int fnd::rsa::pkcs::rsaSign(const sRsa4096Key & key, HashType hash_type, const uint8_t * hash, uint8_t signature[kRsa4096Size])
|
||||
{
|
||||
int ret;
|
||||
rsa_context ctx;
|
||||
rsa_init(&ctx, RSA_PKCS_V15, 0);
|
||||
|
||||
ctx.len = kRsa4096Size;
|
||||
mpi_read_binary(&ctx.D, key.priv_exponent, ctx.len);
|
||||
mpi_read_binary(&ctx.N, key.modulus, ctx.len);
|
||||
|
||||
ret = rsa_rsassa_pkcs1_v15_sign(&ctx, RSA_PRIVATE, getWrappedHashType(hash_type), getWrappedHashSize(hash_type), hash, signature);
|
||||
|
||||
rsa_free(&ctx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int fnd::rsa::pkcs::rsaVerify(const sRsa4096Key & key, HashType hash_type, const uint8_t * hash, const uint8_t signature[kRsa4096Size])
|
||||
{
|
||||
static const uint8_t public_exponent[3] = { 0x01, 0x00, 0x01 };
|
||||
|
||||
int ret;
|
||||
rsa_context ctx;
|
||||
rsa_init(&ctx, RSA_PKCS_V15, 0);
|
||||
|
||||
ctx.len = kRsa4096Size;
|
||||
mpi_read_binary(&ctx.E, public_exponent, sizeof(public_exponent));
|
||||
mpi_read_binary(&ctx.N, key.modulus, ctx.len);
|
||||
|
||||
ret = rsa_rsassa_pkcs1_v15_verify(&ctx, RSA_PUBLIC, getWrappedHashType(hash_type), getWrappedHashSize(hash_type), hash, signature);
|
||||
|
||||
rsa_free(&ctx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int fnd::rsa::pss::rsaSign(const sRsa2048Key & key, HashType hash_type, const uint8_t * hash, uint8_t signature[kRsa2048Size])
|
||||
{
|
||||
int ret;
|
||||
const char* pers = "fnd::rsa::pss::rsaSign";
|
||||
|
||||
// rsa
|
||||
rsa_context rsa;
|
||||
rsa_init(&rsa, RSA_PKCS_V21, getMdWrappedHashType(hash_type));
|
||||
rsa.len = kRsa2048Size;
|
||||
mpi_read_binary(&rsa.D, key.priv_exponent, rsa.len);
|
||||
mpi_read_binary(&rsa.N, key.modulus, rsa.len);
|
||||
|
||||
entropy_context entropy;
|
||||
entropy_init(&entropy);
|
||||
|
||||
ctr_drbg_context ctr_drbg;
|
||||
ctr_drbg_init(&ctr_drbg, entropy_func, &entropy, (const uint8_t*)pers, strlen(pers));
|
||||
|
||||
ret = rsa_rsassa_pss_sign(&rsa, ctr_drbg_random, &ctr_drbg, RSA_PRIVATE, getWrappedHashType(hash_type), getWrappedHashSize(hash_type), hash, signature);
|
||||
|
||||
rsa_free(&rsa);
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int fnd::rsa::pss::rsaVerify(const sRsa2048Key & key, HashType hash_type, const uint8_t * hash, const uint8_t signature[kRsa2048Size])
|
||||
{
|
||||
static const uint8_t public_exponent[3] = { 0x01, 0x00, 0x01 };
|
||||
|
||||
int ret;
|
||||
rsa_context ctx;
|
||||
rsa_init(&ctx, RSA_PKCS_V21, getMdWrappedHashType(hash_type));
|
||||
|
||||
ctx.len = kRsa2048Size;
|
||||
mpi_read_binary(&ctx.E, public_exponent, sizeof(public_exponent));
|
||||
mpi_read_binary(&ctx.N, key.modulus, ctx.len);
|
||||
|
||||
ret = rsa_rsassa_pss_verify(&ctx, RSA_PUBLIC, getWrappedHashType(hash_type), getWrappedHashSize(hash_type), hash, signature);
|
||||
|
||||
rsa_free(&ctx);
|
||||
|
||||
return ret;
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
#include <fnd/sha.h>
|
||||
#include <polarssl/sha1.h>
|
||||
#include <polarssl/sha2.h>
|
||||
|
||||
using namespace fnd::sha;
|
||||
|
||||
void fnd::sha::Sha1(const uint8_t* in, uint64_t size, uint8_t hash[kSha1HashLen])
|
||||
{
|
||||
sha1(in, size, hash);
|
||||
}
|
||||
|
||||
void fnd::sha::Sha256(const uint8_t* in, uint64_t size, uint8_t hash[kSha256HashLen])
|
||||
{
|
||||
sha2(in, size, hash, false);
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
#pragma once
|
||||
#include <nn/hac/define/aset.h>
|
||||
#include <fnd/List.h>
|
||||
#include <fnd/IByteModel.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class AssetHeader :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
struct sSection
|
||||
{
|
||||
uint64_t offset;
|
||||
uint64_t size;
|
||||
|
||||
void operator=(const sSection& other)
|
||||
{
|
||||
offset = other.offset;
|
||||
size = other.size;
|
||||
}
|
||||
|
||||
bool operator==(const sSection& other) const
|
||||
{
|
||||
return (offset == other.offset) \
|
||||
&& (size == other.size);
|
||||
}
|
||||
|
||||
bool operator!=(const sSection& other) const
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
};
|
||||
|
||||
AssetHeader();
|
||||
AssetHeader(const AssetHeader& other);
|
||||
|
||||
void operator=(const AssetHeader& other);
|
||||
bool operator==(const AssetHeader& other) const;
|
||||
bool operator!=(const AssetHeader& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* bytes, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
const sSection& getIconInfo() const;
|
||||
void setIconInfo(const sSection& info);
|
||||
|
||||
const sSection& getNacpInfo() const;
|
||||
void setNacpInfo(const sSection& info);
|
||||
|
||||
const sSection& getRomfsInfo() const;
|
||||
void setRomfsInfo(const sSection& info);
|
||||
private:
|
||||
const std::string kModuleName = "NRO_ASSET_HEADER";
|
||||
|
||||
// binary
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// data
|
||||
sSection mIconInfo;
|
||||
sSection mNacpInfo;
|
||||
sSection mRomfsInfo;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
#pragma once
|
||||
#include <fnd/types.h>
|
||||
#include <nn/hac/define/macro.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
namespace aset
|
||||
{
|
||||
static const uint32_t kAssetStructMagic = _MAKE_STRUCT_MAGIC_U32("ASET");
|
||||
|
||||
static const uint32_t kDefaultAssetFormatVersion = 0;
|
||||
}
|
||||
|
||||
#pragma pack(push,1)
|
||||
struct sAssetSection
|
||||
{
|
||||
le_uint64_t offset;
|
||||
le_uint64_t size;
|
||||
};
|
||||
|
||||
struct sAssetHeader
|
||||
{
|
||||
le_uint32_t st_magic;
|
||||
le_uint32_t format_version;
|
||||
sAssetSection icon;
|
||||
sAssetSection nacp;
|
||||
sAssetSection romfs;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
#pragma once
|
||||
#include <nn/hac/define/nro.h>
|
||||
#include <nn/hac/define/macro.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
namespace nro
|
||||
{
|
||||
static const uint64_t kNroHomebrewStructMagic = _MAKE_STRUCT_MAGIC_U64("HOMEBREW");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,134 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}</ProjectGuid>
|
||||
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>..\libfnd\include;..\libhac\include;..\libhac-hb\include;</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>..\libfnd\include;..\libhac\include;..\libhac-hb\include;</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>..\libfnd\include;..\libhac\include;..\libhac-hb\include;</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>..\libfnd\include;..\libhac\include;..\libhac-hb\include;</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\nn\hac\AssetHeader.h" />
|
||||
<ClInclude Include="include\nn\hac\define\aset.h" />
|
||||
<ClInclude Include="include\nn\hac\define\nro-hb.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="source\AssetHeader.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="makefile" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -1,39 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\define">
|
||||
<UniqueIdentifier>{33064298-d382-4e79-9fcd-bc401bdaa763}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\nn\hac\AssetHeader.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\nn\hac\define\aset.h">
|
||||
<Filter>Header Files\define</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\nn\hac\define\nro-hb.h">
|
||||
<Filter>Header Files\define</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="source\AssetHeader.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="makefile" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,4 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
</Project>
|
|
@ -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 hac
|
||||
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)
|
|
@ -1,135 +0,0 @@
|
|||
#include <cstring>
|
||||
#include <nn/hac/AssetHeader.h>
|
||||
|
||||
nn::hac::AssetHeader::AssetHeader()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
nn::hac::AssetHeader::AssetHeader(const AssetHeader& other)
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
void nn::hac::AssetHeader::operator=(const AssetHeader& other)
|
||||
{
|
||||
mRawBinary = other.mRawBinary;
|
||||
mIconInfo = other.mIconInfo;
|
||||
mNacpInfo = other.mNacpInfo;
|
||||
mRomfsInfo = other.mRomfsInfo;
|
||||
}
|
||||
|
||||
bool nn::hac::AssetHeader::operator==(const AssetHeader& other) const
|
||||
{
|
||||
return (mIconInfo == other.mIconInfo) \
|
||||
&& (mNacpInfo == other.mNacpInfo) \
|
||||
&& (mRomfsInfo == other.mRomfsInfo);
|
||||
}
|
||||
|
||||
bool nn::hac::AssetHeader::operator!=(const AssetHeader& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
void nn::hac::AssetHeader::toBytes()
|
||||
{
|
||||
mRawBinary.alloc(sizeof(sAssetHeader));
|
||||
nn::hac::sAssetHeader* hdr = (nn::hac::sAssetHeader*)mRawBinary.data();
|
||||
|
||||
// set header identifers
|
||||
hdr->st_magic = aset::kAssetStructMagic;
|
||||
hdr->format_version = aset::kDefaultAssetFormatVersion;
|
||||
|
||||
// set icon section
|
||||
hdr->icon.offset = mIconInfo.offset;
|
||||
hdr->icon.size = mIconInfo.size;
|
||||
|
||||
// set nacp section
|
||||
hdr->nacp.offset = mNacpInfo.offset;
|
||||
hdr->nacp.size = mNacpInfo.size;
|
||||
|
||||
// set romfs section
|
||||
hdr->romfs.offset = mRomfsInfo.offset;
|
||||
hdr->romfs.size = mRomfsInfo.size;
|
||||
}
|
||||
|
||||
void nn::hac::AssetHeader::fromBytes(const byte_t* bytes, size_t len)
|
||||
{
|
||||
// check input data size
|
||||
if (len < sizeof(sAssetHeader))
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "ASET header size is too small");
|
||||
}
|
||||
|
||||
// clear internal members
|
||||
clear();
|
||||
|
||||
// allocate internal local binary copy
|
||||
mRawBinary.alloc(sizeof(sAssetHeader));
|
||||
memcpy(mRawBinary.data(), bytes, mRawBinary.size());
|
||||
|
||||
// get sAssetHeader ptr
|
||||
const nn::hac::sAssetHeader* hdr = (const nn::hac::sAssetHeader*)mRawBinary.data();
|
||||
|
||||
// check NRO signature
|
||||
if (hdr->st_magic.get() != aset::kAssetStructMagic)
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "ASET header corrupt (unrecognised header signature)");
|
||||
}
|
||||
|
||||
// check NRO format version
|
||||
if (hdr->format_version.get() != aset::kDefaultAssetFormatVersion)
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "ASET header corrupt (unsupported format version)");
|
||||
}
|
||||
|
||||
mIconInfo.offset = hdr->icon.offset.get();
|
||||
mIconInfo.size = hdr->icon.size.get();
|
||||
mNacpInfo.offset = hdr->nacp.offset.get();
|
||||
mNacpInfo.size = hdr->nacp.size.get();
|
||||
mRomfsInfo.offset = hdr->romfs.offset.get();
|
||||
mRomfsInfo.size = hdr->romfs.size.get();
|
||||
}
|
||||
|
||||
const fnd::Vec<byte_t>& nn::hac::AssetHeader::getBytes() const
|
||||
{
|
||||
return mRawBinary;
|
||||
}
|
||||
|
||||
void nn::hac::AssetHeader::clear()
|
||||
{
|
||||
mRawBinary.clear();
|
||||
memset(&mIconInfo, 0, sizeof(mIconInfo));
|
||||
memset(&mNacpInfo, 0, sizeof(mNacpInfo));
|
||||
memset(&mRomfsInfo, 0, sizeof(mRomfsInfo));
|
||||
}
|
||||
|
||||
const nn::hac::AssetHeader::sSection& nn::hac::AssetHeader::getIconInfo() const
|
||||
{
|
||||
return mIconInfo;
|
||||
}
|
||||
|
||||
void nn::hac::AssetHeader::setIconInfo(const nn::hac::AssetHeader::sSection& info)
|
||||
{
|
||||
mIconInfo = info;
|
||||
}
|
||||
|
||||
const nn::hac::AssetHeader::sSection& nn::hac::AssetHeader::getNacpInfo() const
|
||||
{
|
||||
return mNacpInfo;
|
||||
}
|
||||
|
||||
void nn::hac::AssetHeader::setNacpInfo(const sSection& info)
|
||||
{
|
||||
mNacpInfo = info;
|
||||
}
|
||||
|
||||
const nn::hac::AssetHeader::sSection& nn::hac::AssetHeader::getRomfsInfo() const
|
||||
{
|
||||
return mRomfsInfo;
|
||||
}
|
||||
|
||||
void nn::hac::AssetHeader::setRomfsInfo(const sSection& info)
|
||||
{
|
||||
mRomfsInfo = info;
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <fnd/types.h>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <nn/hac/define/aci.h>
|
||||
#include <nn/hac/FileSystemAccessControl.h>
|
||||
#include <nn/hac/ServiceAccessControl.h>
|
||||
#include <nn/hac/KernelCapabilityControl.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class AccessControlInfo :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
AccessControlInfo();
|
||||
AccessControlInfo(const AccessControlInfo& other);
|
||||
|
||||
void operator=(const AccessControlInfo& other);
|
||||
bool operator==(const AccessControlInfo& other) const;
|
||||
bool operator!=(const AccessControlInfo& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* data, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
uint64_t getProgramId() const;
|
||||
void setProgramId(uint64_t program_id);
|
||||
|
||||
const nn::hac::FileSystemAccessControl& getFileSystemAccessControl() const;
|
||||
void setFileSystemAccessControl(const FileSystemAccessControl& fac);
|
||||
|
||||
const nn::hac::ServiceAccessControl& getServiceAccessControl() const;
|
||||
void setServiceAccessControl(const ServiceAccessControl& sac);
|
||||
|
||||
const nn::hac::KernelCapabilityControl& getKernelCapabilities() const;
|
||||
void setKernelCapabilities(const KernelCapabilityControl& kc);
|
||||
private:
|
||||
const std::string kModuleName = "ACCESS_CONTROL_INFO_BINARY";
|
||||
|
||||
// raw data
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// variables
|
||||
uint64_t mProgramId;
|
||||
nn::hac::FileSystemAccessControl mFileSystemAccessControl;
|
||||
nn::hac::ServiceAccessControl mServiceAccessControl;
|
||||
nn::hac::KernelCapabilityControl mKernelCapabilities;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <fnd/types.h>
|
||||
#include <fnd/List.h>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <nn/hac/define/aci.h>
|
||||
#include <nn/hac/FileSystemAccessControl.h>
|
||||
#include <nn/hac/ServiceAccessControl.h>
|
||||
#include <nn/hac/KernelCapabilityControl.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class AccessControlInfoDesc :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
struct sProgramIdRestrict
|
||||
{
|
||||
uint64_t min;
|
||||
uint64_t max;
|
||||
|
||||
void operator=(const sProgramIdRestrict& other)
|
||||
{
|
||||
min = other.min;
|
||||
max = other.max;
|
||||
}
|
||||
|
||||
bool operator==(const sProgramIdRestrict& other) const
|
||||
{
|
||||
return (min == other.min) \
|
||||
&& (max == other.max);
|
||||
}
|
||||
|
||||
bool operator!=(const sProgramIdRestrict& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
};
|
||||
|
||||
AccessControlInfoDesc();
|
||||
AccessControlInfoDesc(const AccessControlInfoDesc& other);
|
||||
|
||||
void operator=(const AccessControlInfoDesc& other);
|
||||
bool operator==(const AccessControlInfoDesc& other) const;
|
||||
bool operator!=(const AccessControlInfoDesc& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* data, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
void generateSignature(const fnd::rsa::sRsa2048Key& key);
|
||||
void validateSignature(const fnd::rsa::sRsa2048Key& key) const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
const fnd::rsa::sRsa2048Key& getContentArchiveHeaderSignature2Key() const;
|
||||
void setContentArchiveHeaderSignature2Key(const fnd::rsa::sRsa2048Key& key);
|
||||
|
||||
const fnd::List<aci::Flag>& getFlagList() const;
|
||||
void setFlagList(const fnd::List<aci::Flag>& flags);
|
||||
|
||||
const sProgramIdRestrict& getProgramIdRestrict() const;
|
||||
void setProgramIdRestrict(const sProgramIdRestrict& pid_restrict);
|
||||
|
||||
const nn::hac::FileSystemAccessControl& getFileSystemAccessControl() const;
|
||||
void setFileSystemAccessControl(const FileSystemAccessControl& fac);
|
||||
|
||||
const nn::hac::ServiceAccessControl& getServiceAccessControl() const;
|
||||
void setServiceAccessControl(const ServiceAccessControl& sac);
|
||||
|
||||
const nn::hac::KernelCapabilityControl& getKernelCapabilities() const;
|
||||
void setKernelCapabilities(const KernelCapabilityControl& kc);
|
||||
private:
|
||||
const std::string kModuleName = "ACCESS_CONTROL_INFO_DESC_BINARY";
|
||||
|
||||
// raw data
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// variables
|
||||
fnd::rsa::sRsa2048Key mContentArchiveHeaderSignature2Key;
|
||||
fnd::List<aci::Flag> mFlags;
|
||||
sProgramIdRestrict mProgramIdRestrict;
|
||||
nn::hac::FileSystemAccessControl mFileSystemAccessControl;
|
||||
nn::hac::ServiceAccessControl mServiceAccessControl;
|
||||
nn::hac::KernelCapabilityControl mKernelCapabilities;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <nn/hac/define/cnmt.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class AddOnContentMetaExtendedHeader :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
AddOnContentMetaExtendedHeader();
|
||||
AddOnContentMetaExtendedHeader(const AddOnContentMetaExtendedHeader& other);
|
||||
|
||||
void operator=(const AddOnContentMetaExtendedHeader& other);
|
||||
bool operator==(const AddOnContentMetaExtendedHeader& other) const;
|
||||
bool operator!=(const AddOnContentMetaExtendedHeader& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* bytes, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
uint64_t getApplicationId() const;
|
||||
void setApplicationId(uint64_t application_id);
|
||||
|
||||
uint32_t getRequiredApplicationVersion() const;
|
||||
void setRequiredApplicationVersion(uint32_t app_ver);
|
||||
private:
|
||||
const std::string kModuleName = "ADD_ON_CONTENT_META_EXTENDED_HEADER";
|
||||
|
||||
// binary blob
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// variables
|
||||
uint64_t mApplicationId;
|
||||
uint32_t mRequiredApplicationVersion;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <fnd/types.h>
|
||||
#include <fnd/aes.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class AesKeygen
|
||||
{
|
||||
public:
|
||||
|
||||
// 1 stage key generation dst = src_key.decrypt(src)
|
||||
static void generateKey(byte_t* dst, const byte_t* src, const byte_t* src_key);
|
||||
// 2 stage key generation dst = (src1_key.decrypt(src1)).decrypt(src2)
|
||||
static void generateKey(byte_t* dst, const byte_t* src1, const byte_t* src2, const byte_t* src1_key);
|
||||
// 3 stage key generation dst = ((src1_key.decrypt(src1)).decrypt(src2)).decrypt(src3)
|
||||
static void generateKey(byte_t* dst, const byte_t* src1, const byte_t* src2, const byte_t* src3, const byte_t* src1_key);
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,272 +0,0 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <fnd/types.h>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <fnd/List.h>
|
||||
#include <nn/hac/define/nacp.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class ApplicationControlProperty :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
struct sTitle
|
||||
{
|
||||
nacp::Language language;
|
||||
std::string name;
|
||||
std::string publisher;
|
||||
|
||||
void operator=(const sTitle& other)
|
||||
{
|
||||
language = other.language;
|
||||
name = other.name;
|
||||
publisher = other.publisher;
|
||||
}
|
||||
|
||||
bool operator==(const sTitle& other) const
|
||||
{
|
||||
return (language == other.language) \
|
||||
&& (name == other.name) \
|
||||
&& (publisher == other.publisher);
|
||||
}
|
||||
|
||||
bool operator!=(const sTitle& other) const
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
};
|
||||
|
||||
struct sRating
|
||||
{
|
||||
nacp::Organisation organisation;
|
||||
int8_t age;
|
||||
|
||||
void operator=(const sRating& other)
|
||||
{
|
||||
organisation = other.organisation;
|
||||
age = other.age;
|
||||
}
|
||||
|
||||
bool operator==(const sRating& other) const
|
||||
{
|
||||
return (organisation == other.organisation) \
|
||||
&& (age == other.age);
|
||||
}
|
||||
|
||||
bool operator!=(const sRating& other) const
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
};
|
||||
|
||||
struct sStorageSize
|
||||
{
|
||||
int64_t size;
|
||||
int64_t journal_size;
|
||||
|
||||
void operator=(const sStorageSize& other)
|
||||
{
|
||||
size = other.size;
|
||||
journal_size = other.journal_size;
|
||||
}
|
||||
|
||||
bool operator==(const sStorageSize& other) const
|
||||
{
|
||||
return (size == other.size) \
|
||||
&& (journal_size == other.journal_size);
|
||||
}
|
||||
|
||||
bool operator!=(const sStorageSize& other) const
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
};
|
||||
|
||||
ApplicationControlProperty();
|
||||
ApplicationControlProperty(const ApplicationControlProperty& other);
|
||||
|
||||
void operator=(const ApplicationControlProperty& other);
|
||||
bool operator==(const ApplicationControlProperty& other) const;
|
||||
bool operator!=(const ApplicationControlProperty& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* bytes, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
const fnd::List<sTitle>& getTitle() const;
|
||||
void setTitle(const fnd::List<sTitle>& title);
|
||||
|
||||
const std::string& getIsbn() const;
|
||||
void setIsbn(const std::string& isbn);
|
||||
|
||||
nacp::StartupUserAccount getStartupUserAccount() const;
|
||||
void setStartupUserAccount(nacp::StartupUserAccount var);
|
||||
|
||||
nacp::UserAccountSwitchLockValue getUserAccountSwitchLockValue() const;
|
||||
void setUserAccountSwitchLockValue(nacp::UserAccountSwitchLockValue var);
|
||||
|
||||
nacp::AocRegistrationType getAocRegistrationType() const;
|
||||
void setAocRegistrationType(nacp::AocRegistrationType var);
|
||||
|
||||
nacp::AttributeFlag getAttributeFlag() const;
|
||||
void setAttributeFlag(nacp::AttributeFlag var);
|
||||
|
||||
const fnd::List<nacp::Language>& getSupportedLanguages() const;
|
||||
void setSupportedLanguages(const fnd::List<nacp::Language>& var);
|
||||
|
||||
nacp::ParentalControlFlag getParentalControlFlag() const;
|
||||
void setParentalControlFlag(nacp::ParentalControlFlag var);
|
||||
|
||||
nacp::ScreenshotMode getScreenshotMode() const;
|
||||
void setScreenshotMode(nacp::ScreenshotMode var);
|
||||
|
||||
nacp::VideoCaptureMode getVideoCaptureMode() const;
|
||||
void setVideoCaptureMode(nacp::VideoCaptureMode var);
|
||||
|
||||
nacp::DataLossConfirmation getDataLossConfirmation() const;
|
||||
void setDataLossConfirmation(nacp::DataLossConfirmation var);
|
||||
|
||||
nacp::PlayLogPolicy getPlayLogPolicy() const;
|
||||
void setPlayLogPolicy(nacp::PlayLogPolicy var);
|
||||
|
||||
uint64_t getPresenceGroupId() const;
|
||||
void setPresenceGroupId(uint64_t var);
|
||||
|
||||
const fnd::List<sRating>& getRatingAge() const;
|
||||
void setRatingAge(const fnd::List<sRating>& var);
|
||||
|
||||
const std::string& getDisplayVersion() const;
|
||||
void setDisplayVersion(const std::string& var);
|
||||
|
||||
uint64_t getAocBaseId() const;
|
||||
void setAocBaseId(uint64_t var);
|
||||
|
||||
uint64_t getSaveDatawOwnerId() const;
|
||||
void setSaveDatawOwnerId(uint64_t var);
|
||||
|
||||
const sStorageSize& getUserAccountSaveDataSize() const;
|
||||
void setUserAccountSaveDataSize(const sStorageSize& var);
|
||||
|
||||
const sStorageSize& getDeviceSaveDataSize() const;
|
||||
void setDeviceSaveDataSize(const sStorageSize& var);
|
||||
|
||||
int64_t getBcatDeliveryCacheStorageSize() const;
|
||||
void setBcatDeliveryCacheStorageSize(int64_t var);
|
||||
|
||||
const std::string& getApplicationErrorCodeCategory() const;
|
||||
void setApplicationErrorCodeCategory(const std::string& var);
|
||||
|
||||
const fnd::List<uint64_t>& getLocalCommunicationId() const;
|
||||
void setLocalCommunicationId(const fnd::List<uint64_t>& var);
|
||||
|
||||
nacp::LogoType getLogoType() const;
|
||||
void setLogoType(nacp::LogoType var);
|
||||
|
||||
nacp::LogoHandling getLogoHandling() const;
|
||||
void setLogoHandling(nacp::LogoHandling var);
|
||||
|
||||
nacp::RuntimeAocInstallMode getRuntimeAocInstallMode() const;
|
||||
void setRuntimeAocInstallMode(nacp::RuntimeAocInstallMode var);
|
||||
|
||||
nacp::CrashReportMode getCrashReportMode() const;
|
||||
void setCrashReportMode(nacp::CrashReportMode var);
|
||||
|
||||
nacp::Hdcp getHdcp() const;
|
||||
void setHdcp(nacp::Hdcp var);
|
||||
|
||||
uint64_t getSeedForPsuedoDeviceId() const;
|
||||
void setSeedForPsuedoDeviceId(uint64_t var);
|
||||
|
||||
const std::string& getBcatPassphase() const;
|
||||
void setBcatPassphase(const std::string& var);
|
||||
|
||||
const sStorageSize& getUserAccountSaveDataMax() const;
|
||||
void setUserAccountSaveDataMax(const sStorageSize& var);
|
||||
|
||||
const sStorageSize& getDeviceSaveDataMax() const;
|
||||
void setDeviceSaveDataMax(const sStorageSize& var);
|
||||
|
||||
int64_t getTemporaryStorageSize() const;
|
||||
void setTemporaryStorageSize(int64_t var);
|
||||
|
||||
const sStorageSize& getCacheStorageSize() const;
|
||||
void setCacheStorageSize(const sStorageSize& var);
|
||||
|
||||
int64_t getCacheStorageDataAndJournalSizeMax() const;
|
||||
void setCacheStorageDataAndJournalSizeMax(int64_t var);
|
||||
|
||||
uint16_t getCacheStorageIndexMax() const;
|
||||
void setCacheStorageIndexMax(uint16_t var);
|
||||
|
||||
const fnd::List<uint64_t>& getPlayLogQueryableApplicationId() const;
|
||||
void setPlayLogQueryableApplicationId(const fnd::List<uint64_t>& var);
|
||||
|
||||
nacp::PlayLogQueryCapability getPlayLogQueryCapability() const;
|
||||
void setPlayLogQueryCapability(nacp::PlayLogQueryCapability var);
|
||||
|
||||
nacp::RepairFlag getRepairFlag() const;
|
||||
void setRepairFlag(nacp::RepairFlag var);
|
||||
|
||||
byte_t getProgramIndex() const;
|
||||
void setProgramIndex(byte_t var);
|
||||
|
||||
nacp::RequiredNetworkServiceLicenseOnLaunchValue getRequiredNetworkServiceLicenseOnLaunchValue() const;
|
||||
void setRequiredNetworkServiceLicenseOnLaunchValue(nacp::RequiredNetworkServiceLicenseOnLaunchValue var);
|
||||
|
||||
private:
|
||||
const std::string kModuleName = "APPLICATION_CONTROL_PROPERTY";
|
||||
|
||||
// raw data
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// variables
|
||||
fnd::List<sTitle> mTitle;
|
||||
std::string mIsbn;
|
||||
nacp::StartupUserAccount mStartupUserAccount;
|
||||
nacp::UserAccountSwitchLockValue mUserAccountSwitchLockValue;
|
||||
nacp::AocRegistrationType mAocRegistrationType;
|
||||
nacp::AttributeFlag mAttributeFlag;
|
||||
fnd::List<nn::hac::nacp::Language> mSupportedLanguages;
|
||||
nacp::ParentalControlFlag mParentalControlFlag;
|
||||
nacp::ScreenshotMode mScreenshotMode;
|
||||
nacp::VideoCaptureMode mVideoCaptureMode;
|
||||
nacp::DataLossConfirmation mDataLossConfirmation;
|
||||
nacp::PlayLogPolicy mPlayLogPolicy;
|
||||
uint64_t mPresenceGroupId;
|
||||
fnd::List<sRating> mRatingAge;
|
||||
std::string mDisplayVersion;
|
||||
uint64_t mAocBaseId;
|
||||
uint64_t mSaveDatawOwnerId;
|
||||
sStorageSize mUserAccountSaveDataSize;
|
||||
sStorageSize mDeviceSaveDataSize;
|
||||
int64_t mBcatDeliveryCacheStorageSize;
|
||||
std::string mApplicationErrorCodeCategory;
|
||||
fnd::List<uint64_t> mLocalCommunicationId;
|
||||
nacp::LogoType mLogoType;
|
||||
nacp::LogoHandling mLogoHandling;
|
||||
nacp::RuntimeAocInstallMode mRuntimeAocInstallMode;
|
||||
nacp::CrashReportMode mCrashReportMode;
|
||||
nacp::Hdcp mHdcp;
|
||||
uint64_t mSeedForPsuedoDeviceId;
|
||||
std::string mBcatPassphase;
|
||||
sStorageSize mUserAccountSaveDataMax;
|
||||
sStorageSize mDeviceSaveDataMax;
|
||||
int64_t mTemporaryStorageSize;
|
||||
sStorageSize mCacheStorageSize;
|
||||
int64_t mCacheStorageDataAndJournalSizeMax;
|
||||
uint16_t mCacheStorageIndexMax;
|
||||
fnd::List<uint64_t> mPlayLogQueryableApplicationId;
|
||||
nacp::PlayLogQueryCapability mPlayLogQueryCapability;
|
||||
nacp::RepairFlag mRepairFlag;
|
||||
byte_t mProgramIndex;
|
||||
nacp::RequiredNetworkServiceLicenseOnLaunchValue mRequiredNetworkServiceLicenseOnLaunchValue;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
#pragma once
|
||||
#include <nn/hac/define/nacp.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class ApplicationControlPropertyUtils
|
||||
{
|
||||
public:
|
||||
static bool validateSaveDataSizeMax(int64_t size, int64_t alignment);
|
||||
static bool validateSaveDataSize(int64_t size);
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <nn/hac/define/cnmt.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class ApplicationMetaExtendedHeader :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
ApplicationMetaExtendedHeader();
|
||||
ApplicationMetaExtendedHeader(const ApplicationMetaExtendedHeader& other);
|
||||
|
||||
void operator=(const ApplicationMetaExtendedHeader& other);
|
||||
bool operator==(const ApplicationMetaExtendedHeader& other) const;
|
||||
bool operator!=(const ApplicationMetaExtendedHeader& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* bytes, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
uint64_t getPatchId() const;
|
||||
void setPatchId(uint64_t patch_id);
|
||||
|
||||
uint32_t getRequiredSystemVersion() const;
|
||||
void setRequiredSystemVersion(uint32_t sys_ver);
|
||||
private:
|
||||
const std::string kModuleName = "APPLICATION_META_EXTENDED_HEADER";
|
||||
|
||||
// binary blob
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// variables
|
||||
uint64_t mPatchId;
|
||||
uint32_t mRequiredSystemVersion;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,121 +0,0 @@
|
|||
#pragma once
|
||||
#include <nn/hac/define/nca.h>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <fnd/List.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class ContentArchiveHeader :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
struct sPartitionEntry
|
||||
{
|
||||
byte_t header_index;
|
||||
uint64_t offset;
|
||||
uint64_t size;
|
||||
fnd::sha::sSha256Hash fs_header_hash;
|
||||
|
||||
const sPartitionEntry& operator=(const sPartitionEntry& other)
|
||||
{
|
||||
header_index = other.header_index;
|
||||
offset = other.offset;
|
||||
size = other.size;
|
||||
fs_header_hash = other.fs_header_hash;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(const sPartitionEntry& other) const
|
||||
{
|
||||
return (header_index == other.header_index) \
|
||||
&& (offset == other.offset) \
|
||||
&& (size == other.size) \
|
||||
&& (fs_header_hash == other.fs_header_hash);
|
||||
}
|
||||
|
||||
bool operator!=(const sPartitionEntry& other) const
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
};
|
||||
|
||||
ContentArchiveHeader();
|
||||
ContentArchiveHeader(const ContentArchiveHeader& other);
|
||||
|
||||
void operator=(const ContentArchiveHeader& other);
|
||||
bool operator==(const ContentArchiveHeader& other) const;
|
||||
bool operator!=(const ContentArchiveHeader& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* bytes, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
byte_t getFormatVersion() const;
|
||||
void setFormatVersion(byte_t ver);
|
||||
|
||||
nca::DistributionType getDistributionType() const;
|
||||
void setDistributionType(nca::DistributionType type);
|
||||
|
||||
nca::ContentType getContentType() const;
|
||||
void setContentType(nca::ContentType type);
|
||||
|
||||
byte_t getKeyGeneration() const;
|
||||
void setKeyGeneration(byte_t gen);
|
||||
|
||||
byte_t getKeyAreaEncryptionKeyIndex() const;
|
||||
void setKeyAreaEncryptionKeyIndex(byte_t index);
|
||||
|
||||
uint64_t getContentSize() const;
|
||||
void setContentSize(uint64_t size);
|
||||
|
||||
uint64_t getProgramId() const;
|
||||
void setProgramId(uint64_t program_id);
|
||||
|
||||
uint32_t getContentIndex() const;
|
||||
void setContentIndex(uint32_t index);
|
||||
|
||||
uint32_t getSdkAddonVersion() const;
|
||||
void setSdkAddonVersion(uint32_t version);
|
||||
|
||||
bool hasRightsId() const;
|
||||
const byte_t* getRightsId() const;
|
||||
void setRightsId(const byte_t* rights_id);
|
||||
|
||||
const fnd::List<sPartitionEntry>& getPartitionEntryList() const;
|
||||
void setPartitionEntryList(const fnd::List<sPartitionEntry>& partition_entry_list);
|
||||
|
||||
const byte_t* getKeyArea() const;
|
||||
void setKeyArea(const byte_t* key_area);
|
||||
|
||||
private:
|
||||
const std::string kModuleName = "CONTENT_ARCHIVE_HEADER";
|
||||
|
||||
// binary
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// data
|
||||
byte_t mFormatVersion;
|
||||
nca::DistributionType mDistributionType;
|
||||
nca::ContentType mContentType;
|
||||
byte_t mKeyGeneration;
|
||||
byte_t mKaekIndex;
|
||||
uint64_t mContentSize;
|
||||
uint64_t mProgramId;
|
||||
uint32_t mContentIndex;
|
||||
uint32_t mSdkAddonVersion;
|
||||
fnd::Vec<byte_t> mRightsId;
|
||||
fnd::List<sPartitionEntry> mPartitionEntryList;
|
||||
fnd::Vec<byte_t> mKeyArea;
|
||||
|
||||
uint64_t blockNumToSize(uint32_t block_num) const;
|
||||
uint32_t sizeToBlockNum(uint64_t real_size) const;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
#pragma once
|
||||
#include <nn/hac/define/nca.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class ContentArchiveUtils
|
||||
{
|
||||
public:
|
||||
static inline size_t sectorToOffset(size_t sector_index) { return sector_index * nn::hac::nca::kSectorSize; }
|
||||
static void decryptContentArchiveHeader(const byte_t* src, byte_t* dst, const fnd::aes::sAesXts128Key& key);
|
||||
static byte_t getMasterKeyRevisionFromKeyGeneration(byte_t key_generation);
|
||||
static void getNcaPartitionAesCtr(const nn::hac::sNcaFsHeader* hdr, byte_t* ctr);
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <nn/hac/define/cnmt.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class ContentInfo :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
ContentInfo();
|
||||
ContentInfo(const ContentInfo& other);
|
||||
|
||||
void operator=(const ContentInfo& other);
|
||||
bool operator==(const ContentInfo& other) const;
|
||||
bool operator!=(const ContentInfo& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* bytes, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
const fnd::sha::sSha256Hash& getContentHash() const;
|
||||
void setContentHash(const fnd::sha::sSha256Hash& hash);
|
||||
|
||||
const cnmt::sContentId& getContentId() const;
|
||||
void setContentId(const cnmt::sContentId& content_id);
|
||||
|
||||
size_t getContentSize() const;
|
||||
void setContentSize(size_t size);
|
||||
|
||||
cnmt::ContentType getContentType() const;
|
||||
void setContentType(cnmt::ContentType type);
|
||||
|
||||
byte_t getIdOffset() const;
|
||||
void setIdOffset(byte_t id_offset);
|
||||
|
||||
private:
|
||||
const std::string kModuleName = "CONTENT_INFO";
|
||||
|
||||
// binary blob
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// variables
|
||||
fnd::sha::sSha256Hash mHash;
|
||||
cnmt::sContentId mContentId;
|
||||
size_t mSize;
|
||||
cnmt::ContentType mType;
|
||||
byte_t mIdOffset;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,113 +0,0 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <fnd/List.h>
|
||||
#include <nn/hac/define/cnmt.h>
|
||||
#include <nn/hac/ContentInfo.h>
|
||||
#include <nn/hac/ContentMetaInfo.h>
|
||||
#include <nn/hac/ApplicationMetaExtendedHeader.h>
|
||||
#include <nn/hac/PatchMetaExtendedHeader.h>
|
||||
#include <nn/hac/AddOnContentMetaExtendedHeader.h>
|
||||
#include <nn/hac/DeltaMetaExtendedHeader.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class ContentMeta :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
ContentMeta();
|
||||
ContentMeta(const ContentMeta& other);
|
||||
|
||||
void operator=(const ContentMeta& other);
|
||||
bool operator==(const ContentMeta& other) const;
|
||||
bool operator!=(const ContentMeta& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* bytes, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
uint64_t getTitleId() const;
|
||||
void setTitleId(uint64_t title_id);
|
||||
|
||||
uint32_t getTitleVersion() const;
|
||||
void setTitleVersion(uint32_t version);
|
||||
|
||||
cnmt::ContentMetaType getContentMetaType() const;
|
||||
void setContentMetaType(cnmt::ContentMetaType type);
|
||||
|
||||
byte_t getAttributes() const;
|
||||
void setAttributes(byte_t attributes);
|
||||
|
||||
uint32_t getRequiredDownloadSystemVersion() const;
|
||||
void setRequiredDownloadSystemVersion(uint32_t version);
|
||||
|
||||
const ApplicationMetaExtendedHeader& getApplicationMetaExtendedHeader() const;
|
||||
void setApplicationMetaExtendedHeader(const ApplicationMetaExtendedHeader& exhdr);
|
||||
|
||||
const PatchMetaExtendedHeader& getPatchMetaExtendedHeader() const;
|
||||
void setPatchMetaExtendedHeader(const PatchMetaExtendedHeader& exhdr);
|
||||
|
||||
const AddOnContentMetaExtendedHeader& getAddOnContentMetaExtendedHeader() const;
|
||||
void setAddOnContentMetaExtendedHeader(const AddOnContentMetaExtendedHeader& exhdr);
|
||||
|
||||
const DeltaMetaExtendedHeader& getDeltaMetaExtendedHeader() const;
|
||||
void setDeltaMetaExtendedHeader(const DeltaMetaExtendedHeader& exhdr);
|
||||
|
||||
const fnd::List<ContentInfo>& getContentInfo() const;
|
||||
void setContentInfo(const fnd::List<ContentInfo>& info);
|
||||
|
||||
const fnd::List<ContentMetaInfo>& getContentMetaInfo() const;
|
||||
void setContentMetaInfo(const fnd::List<ContentMetaInfo>& info);
|
||||
|
||||
const fnd::Vec<byte_t>& getExtendedData() const;
|
||||
void setExtendedData(const fnd::Vec<byte_t>& data);
|
||||
|
||||
const cnmt::sDigest& getDigest() const;
|
||||
void setDigest(const cnmt::sDigest& digest);
|
||||
|
||||
|
||||
private:
|
||||
const std::string kModuleName = "CONTENT_META";
|
||||
|
||||
// binary blob
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// variables
|
||||
uint64_t mTitleId;
|
||||
uint32_t mTitleVersion;
|
||||
cnmt::ContentMetaType mType;
|
||||
byte_t mAttributes;
|
||||
uint32_t mRequiredDownloadSystemVersion;
|
||||
fnd::Vec<byte_t> mExtendedHeader;
|
||||
|
||||
ApplicationMetaExtendedHeader mApplicationMetaExtendedHeader;
|
||||
PatchMetaExtendedHeader mPatchMetaExtendedHeader;
|
||||
AddOnContentMetaExtendedHeader mAddOnContentMetaExtendedHeader;
|
||||
DeltaMetaExtendedHeader mDeltaMetaExtendedHeader;
|
||||
|
||||
fnd::List<ContentInfo> mContentInfo;
|
||||
fnd::List<ContentMetaInfo> mContentMetaInfo;
|
||||
fnd::Vec<byte_t> mExtendedData;
|
||||
cnmt::sDigest mDigest;
|
||||
|
||||
inline size_t getExtendedHeaderOffset() const { return sizeof(sContentMetaHeader); }
|
||||
inline size_t getContentInfoOffset(size_t exhdrSize) const { return getExtendedHeaderOffset() + exhdrSize; }
|
||||
inline size_t getContentMetaInfoOffset(size_t exhdrSize, size_t contentInfoNum) const { return getContentInfoOffset(exhdrSize) + contentInfoNum * sizeof(sContentInfo); }
|
||||
inline size_t getExtendedDataOffset(size_t exhdrSize, size_t contentInfoNum, size_t contentMetaNum) const { return getContentMetaInfoOffset(exhdrSize, contentInfoNum) + contentMetaNum * sizeof(sContentMetaInfo); }
|
||||
inline size_t getDigestOffset(size_t exhdrSize, size_t contentInfoNum, size_t contentMetaNum, size_t exdataSize) const { return getExtendedDataOffset(exhdrSize, contentInfoNum, contentMetaNum) + exdataSize; }
|
||||
inline size_t getTotalSize(size_t exhdrSize, size_t contentInfoNum, size_t contentMetaNum, size_t exdataSize) const { return getDigestOffset(exhdrSize, contentInfoNum, contentMetaNum, exdataSize) + cnmt::kDigestLen; }
|
||||
|
||||
bool validateExtendedHeaderSize(cnmt::ContentMetaType type, size_t exhdrSize) const;
|
||||
size_t getExtendedDataSize(cnmt::ContentMetaType type, const byte_t* data) const;
|
||||
void validateBinary(const byte_t* bytes, size_t len) const;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <nn/hac/define/cnmt.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class ContentMetaInfo :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
ContentMetaInfo();
|
||||
ContentMetaInfo(const ContentMetaInfo& other);
|
||||
|
||||
void operator=(const ContentMetaInfo& other);
|
||||
bool operator==(const ContentMetaInfo& other) const;
|
||||
bool operator!=(const ContentMetaInfo& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* bytes, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
uint64_t getTitleId() const;
|
||||
void setTitleId(uint64_t title_id);
|
||||
|
||||
uint32_t getTitleVersion() const;
|
||||
void setTitleVersion(uint32_t ver);
|
||||
|
||||
cnmt::ContentMetaType getContentMetaType() const;
|
||||
void setContentMetaType(cnmt::ContentMetaType type);
|
||||
|
||||
byte_t getAttributes() const;
|
||||
void setAttributes(byte_t attr);
|
||||
|
||||
private:
|
||||
const std::string kModuleName = "CONTENT_META_INFO";
|
||||
|
||||
// byte model
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// variables
|
||||
uint64_t mTitleId;
|
||||
uint32_t mTitleVersion;
|
||||
cnmt::ContentMetaType mType;
|
||||
byte_t mAttributes;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <nn/hac/define/cnmt.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class DeltaMetaExtendedHeader :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
DeltaMetaExtendedHeader();
|
||||
DeltaMetaExtendedHeader(const DeltaMetaExtendedHeader& other);
|
||||
|
||||
void operator=(const DeltaMetaExtendedHeader& other);
|
||||
bool operator==(const DeltaMetaExtendedHeader& other) const;
|
||||
bool operator!=(const DeltaMetaExtendedHeader& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* bytes, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
uint64_t getApplicationId() const;
|
||||
void setApplicationId(uint64_t application_id);
|
||||
|
||||
uint32_t getExtendedDataSize() const;
|
||||
void setExtendedDataSize(uint32_t size);
|
||||
|
||||
private:
|
||||
const std::string kModuleName = "DELTA_META_EXTENDED_HEADER";
|
||||
|
||||
// binary blob
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// variables
|
||||
uint64_t mApplicationId;
|
||||
uint32_t mExtendedDataSize;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <fnd/types.h>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <fnd/List.h>
|
||||
#include <nn/hac/define/fac.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class FileSystemAccessControl :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
struct sSaveDataOwnerId
|
||||
{
|
||||
nn::hac::fac::SaveDataOwnerIdAccessType access_type;
|
||||
uint64_t id;
|
||||
|
||||
void operator=(const sSaveDataOwnerId& other)
|
||||
{
|
||||
access_type = other.access_type;
|
||||
id = other.id;
|
||||
}
|
||||
|
||||
bool operator==(const sSaveDataOwnerId& other) const
|
||||
{
|
||||
return (access_type == other.access_type) \
|
||||
&& (id == other.id);
|
||||
}
|
||||
|
||||
bool operator!=(const sSaveDataOwnerId& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
};
|
||||
|
||||
FileSystemAccessControl();
|
||||
FileSystemAccessControl(const FileSystemAccessControl& other);
|
||||
|
||||
void operator=(const FileSystemAccessControl& other);
|
||||
bool operator==(const FileSystemAccessControl& other) const;
|
||||
bool operator!=(const FileSystemAccessControl& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* data, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
uint32_t getFormatVersion() const;
|
||||
void setFormatVersion(uint32_t version);
|
||||
|
||||
const fnd::List<fac::FsAccessFlag>& getFsaRightsList() const;
|
||||
void setFsaRightsList(const fnd::List<fac::FsAccessFlag>& list);
|
||||
|
||||
const fnd::List<uint64_t>& getContentOwnerIdList() const;
|
||||
void setContentOwnerIdList(const fnd::List<uint64_t>& list);
|
||||
|
||||
const fnd::List<sSaveDataOwnerId>& getSaveDataOwnerIdList() const;
|
||||
void setSaveDataOwnerIdList(const fnd::List<sSaveDataOwnerId>& list);
|
||||
private:
|
||||
const std::string kModuleName = "FILE_SYSTEM_ACCESS_CONTROL";
|
||||
|
||||
// raw data
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// variables
|
||||
uint32_t mVersion;
|
||||
fnd::List<fac::FsAccessFlag> mFsaRights;
|
||||
fnd::List<uint64_t> mContentOwnerIdList;
|
||||
fnd::List<sSaveDataOwnerId> mSaveDataOwnerIdList;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
#pragma once
|
||||
#include <nn/hac/define/gc.h>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <fnd/List.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class GameCardHeader :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
GameCardHeader();
|
||||
GameCardHeader(const GameCardHeader& other);
|
||||
|
||||
void operator=(const GameCardHeader& other);
|
||||
bool operator==(const GameCardHeader& other) const;
|
||||
bool operator!=(const GameCardHeader& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* bytes, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
uint32_t getRomAreaStartPage() const;
|
||||
void setRomAreaStartPage(uint32_t startPage);
|
||||
uint32_t getBackupAreaStartPage() const;
|
||||
void setBackupAreaStartPage(uint32_t startPage);
|
||||
byte_t getKekIndex() const;
|
||||
void setKekIndex(byte_t kekIndex);
|
||||
byte_t getTitleKeyDecIndex() const;
|
||||
void setTitleKeyDecIndex(byte_t index);
|
||||
byte_t getRomSizeType() const;
|
||||
void setRomSizeType(byte_t romSizeType);
|
||||
byte_t getCardHeaderVersion() const;
|
||||
void setCardHeaderVersion(byte_t version);
|
||||
byte_t getFlags() const;
|
||||
void setFlags(byte_t flags);
|
||||
uint64_t getPackageId() const;
|
||||
void setPackageId(uint64_t id);
|
||||
uint32_t getValidDataEndPage() const;
|
||||
void setValidDataEndPage(uint32_t page);
|
||||
const fnd::aes::sAesIvCtr& getAesCbcIv() const;
|
||||
void setAesCbcIv(const fnd::aes::sAesIvCtr& iv);
|
||||
uint64_t getPartitionFsAddress() const;
|
||||
void setPartitionFsAddress(uint64_t address);
|
||||
uint64_t getPartitionFsSize() const;
|
||||
void setPartitionFsSize(uint64_t size);
|
||||
const fnd::sha::sSha256Hash& getPartitionFsHash() const;
|
||||
void setPartitionFsHash(const fnd::sha::sSha256Hash& hash);
|
||||
const fnd::sha::sSha256Hash& getInitialDataHash() const;
|
||||
void setInitialDataHash(const fnd::sha::sSha256Hash& hash);
|
||||
uint32_t getSelSec() const;
|
||||
void setSelSec(uint32_t sel_sec);
|
||||
uint32_t getSelT1Key() const;
|
||||
void setSelT1Key(uint32_t sel_t1_key);
|
||||
uint32_t getSelKey() const;
|
||||
void setSelKey(uint32_t sel_key);
|
||||
uint32_t getLimAreaPage() const;
|
||||
void setLimAreaPage(uint32_t page);
|
||||
|
||||
uint32_t getFwVerMajor() const;
|
||||
void setFwVerMajor(uint32_t ver);
|
||||
uint32_t getFwVerMinor() const;
|
||||
void setFwVerMinor(uint32_t ver);
|
||||
uint32_t getAccCtrl1() const;
|
||||
void setAccCtrl1(uint32_t acc_ctrl_1);
|
||||
uint32_t getWait1TimeRead() const;
|
||||
void setWait1TimeRead(uint32_t seconds);
|
||||
uint32_t getWait2TimeRead() const;
|
||||
void setWait2TimeRead(uint32_t seconds);
|
||||
uint32_t getWait1TimeWrite() const;
|
||||
void setWait1TimeWrite(uint32_t seconds);
|
||||
uint32_t getWait2TimeWrite() const;
|
||||
void setWait2TimeWrite(uint32_t seconds);
|
||||
uint32_t getFwMode() const;
|
||||
void setFwMode(uint32_t fw_mode);
|
||||
uint32_t getUppVersion() const;
|
||||
void setUppVersion(uint32_t version);
|
||||
const byte_t* getUppHash() const;
|
||||
void setUppHash(const byte_t* hash);
|
||||
uint64_t getUppId() const;
|
||||
void setUppId(uint64_t id);
|
||||
|
||||
private:
|
||||
const std::string kModuleName = "GAMECARD_HEADER";
|
||||
|
||||
// binary
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// data
|
||||
uint32_t mRomAreaStartPage;
|
||||
uint32_t mBackupAreaStartPage;
|
||||
byte_t mKekIndex;
|
||||
byte_t mTitleKeyDecIndex;
|
||||
byte_t mRomSize;
|
||||
byte_t mCardHeaderVersion;
|
||||
byte_t mFlags;
|
||||
uint64_t mPackageId;
|
||||
uint32_t mValidDataEndPage;
|
||||
fnd::aes::sAesIvCtr mAesCbcIv;
|
||||
uint64_t mPartitionFsHeaderAddress;
|
||||
uint64_t mPartitionFsHeaderSize;
|
||||
fnd::sha::sSha256Hash mPartitionFsHeaderHash;
|
||||
fnd::sha::sSha256Hash mInitialDataHash;
|
||||
uint32_t mSelSec;
|
||||
uint32_t mSelT1Key;
|
||||
uint32_t mSelKey;
|
||||
uint32_t mLimAreaPage;
|
||||
|
||||
// Encrypted/Extended Data
|
||||
uint32_t mFwVersion[2];
|
||||
uint32_t mAccCtrl1;
|
||||
uint32_t mWait1TimeRead;
|
||||
uint32_t mWait2TimeRead;
|
||||
uint32_t mWait1TimeWrite;
|
||||
uint32_t mWait2TimeWrite;
|
||||
uint32_t mFwMode;
|
||||
uint32_t mUppVersion;
|
||||
byte_t mUppHash[8];
|
||||
uint64_t mUppId;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
#pragma once
|
||||
#include <nn/hac/define/gc.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class GameCardUtils
|
||||
{
|
||||
public:
|
||||
static inline uint64_t blockToAddr(uint32_t block) { return ((uint64_t)block) << 9; }
|
||||
static void getXciHeaderAesIv(const nn::hac::sGcHeader* hdr, byte_t* iv);
|
||||
static void decryptXciHeader(const byte_t* src, byte_t* dst, const byte_t* key);
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <fnd/types.h>
|
||||
#include <nn/hac/KernelCapabilityEntry.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class HandleTableSizeEntry
|
||||
{
|
||||
public:
|
||||
HandleTableSizeEntry();
|
||||
HandleTableSizeEntry(const KernelCapabilityEntry& kernel_cap);
|
||||
HandleTableSizeEntry(uint16_t size);
|
||||
|
||||
void operator=(const HandleTableSizeEntry& other);
|
||||
bool operator==(const HandleTableSizeEntry& other) const;
|
||||
bool operator!=(const HandleTableSizeEntry& other) const;
|
||||
|
||||
// kernel capability
|
||||
const KernelCapabilityEntry& getKernelCapability() const;
|
||||
void setKernelCapability(const KernelCapabilityEntry& kernel_cap);
|
||||
|
||||
// variables
|
||||
uint16_t getHandleTableSize() const;
|
||||
void setHandleTableSize(uint16_t size);
|
||||
private:
|
||||
const std::string kModuleName = "HANDLE_TABLE_SIZE_ENTRY";
|
||||
static const kc::KernelCapId kCapId = kc::KC_HANDLE_TABLE_SIZE;
|
||||
static const uint16_t kValBits = 10;
|
||||
static const uint16_t kMaxHandleTableSize = BIT(kValBits) - 1;
|
||||
|
||||
KernelCapabilityEntry mCap;
|
||||
uint16_t mHandleTableSize;
|
||||
|
||||
inline void updateCapField()
|
||||
{
|
||||
uint32_t field = mHandleTableSize & kMaxHandleTableSize;
|
||||
mCap.setField(field);
|
||||
}
|
||||
|
||||
inline void processCapField()
|
||||
{
|
||||
uint32_t field = mCap.getField();
|
||||
mHandleTableSize = field & kMaxHandleTableSize;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
#pragma once
|
||||
#include <nn/hac/IKernelCapabilityHandler.h>
|
||||
#include <nn/hac/HandleTableSizeEntry.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class HandleTableSizeHandler :
|
||||
public IKernelCapabilityHandler
|
||||
{
|
||||
public:
|
||||
HandleTableSizeHandler();
|
||||
|
||||
void operator=(const HandleTableSizeHandler& other);
|
||||
bool operator==(const HandleTableSizeHandler& other) const;
|
||||
bool operator!=(const HandleTableSizeHandler& other) const;
|
||||
|
||||
// kernel capabilty list in/out
|
||||
void importKernelCapabilityList(const fnd::List<KernelCapabilityEntry>& caps);
|
||||
void exportKernelCapabilityList(fnd::List<KernelCapabilityEntry>& caps) const;
|
||||
void clear();
|
||||
bool isSet() const;
|
||||
|
||||
// variables
|
||||
uint16_t getHandleTableSize() const;
|
||||
void setHandleTableSize(uint16_t size);
|
||||
|
||||
private:
|
||||
const std::string kModuleName = "HANDLE_TABLE_SIZE_HANDLER";
|
||||
static const size_t kMaxKernelCapNum = 1;
|
||||
|
||||
bool mIsSet;
|
||||
HandleTableSizeEntry mEntry;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
#pragma once
|
||||
#include <nn/hac/define/hierarchicalintegrity.h>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <fnd/List.h>
|
||||
#include <fnd/sha.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class HierarchicalIntegrityHeader :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
HierarchicalIntegrityHeader();
|
||||
HierarchicalIntegrityHeader(const HierarchicalIntegrityHeader& other);
|
||||
|
||||
void operator=(const HierarchicalIntegrityHeader& other);
|
||||
bool operator==(const HierarchicalIntegrityHeader& other) const;
|
||||
bool operator!=(const HierarchicalIntegrityHeader& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* bytes, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
const fnd::List<sLayer>& getLayerInfo() const;
|
||||
void setLayerInfo(const fnd::List<sLayer>& layer_info);
|
||||
|
||||
const fnd::List<fnd::sha::sSha256Hash>& getMasterHashList() const;
|
||||
void setMasterHashList(const fnd::List<fnd::sha::sSha256Hash>& master_hash_list);
|
||||
private:
|
||||
const std::string kModuleName = "HIERARCHICAL_INTEGRITY_HEADER";
|
||||
|
||||
// binary
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// data
|
||||
fnd::List<sLayer> mLayerInfo;
|
||||
fnd::List<fnd::sha::sSha256Hash> mMasterHashList;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
#pragma once
|
||||
#include <nn/hac/define/hierarchicalsha256.h>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <fnd/List.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class HierarchicalSha256Header :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
struct sLayer
|
||||
{
|
||||
size_t offset;
|
||||
size_t size;
|
||||
|
||||
void operator=(const sLayer& other)
|
||||
{
|
||||
offset = other.offset;
|
||||
size = other.size;
|
||||
}
|
||||
|
||||
bool operator==(const sLayer& other) const
|
||||
{
|
||||
return (offset == other.offset && size == other.size);
|
||||
}
|
||||
|
||||
bool operator!=(const sLayer& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
};
|
||||
|
||||
HierarchicalSha256Header();
|
||||
HierarchicalSha256Header(const HierarchicalSha256Header& other);
|
||||
|
||||
void operator=(const HierarchicalSha256Header& other);
|
||||
bool operator==(const HierarchicalSha256Header& other) const;
|
||||
bool operator!=(const HierarchicalSha256Header& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* bytes, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
const fnd::sha::sSha256Hash& getMasterHash() const;
|
||||
void setMasterHash(const fnd::sha::sSha256Hash& master_hash);
|
||||
|
||||
size_t getHashBlockSize() const;
|
||||
void setHashBlockSize(size_t hash_block_size);
|
||||
|
||||
const fnd::List<sLayer>& getLayerInfo() const;
|
||||
void setLayerInfo(const fnd::List<sLayer>& layer_info);
|
||||
private:
|
||||
const std::string kModuleName = "HIERARCHICAL_SHA256_HEADER";
|
||||
|
||||
// binary
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// data
|
||||
fnd::sha::sSha256Hash mMasterHash;
|
||||
size_t mHashBlockSize;
|
||||
fnd::List<sLayer> mLayerInfo;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
#pragma once
|
||||
#include <fnd/types.h>
|
||||
#include <fnd/List.h>
|
||||
#include <nn/hac/KernelCapabilityEntry.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class IKernelCapabilityHandler
|
||||
{
|
||||
public:
|
||||
virtual void importKernelCapabilityList(const fnd::List<KernelCapabilityEntry>& caps) = 0;
|
||||
virtual void exportKernelCapabilityList(fnd::List<KernelCapabilityEntry>& caps) const = 0;
|
||||
virtual void clear() = 0;
|
||||
virtual bool isSet() const = 0;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
#pragma once
|
||||
#include <fnd/types.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class IdConverter
|
||||
{
|
||||
public:
|
||||
static uint64_t convertToAocBaseId(uint64_t application_id);
|
||||
static uint64_t convertToDeltaId(uint64_t application_id);
|
||||
static uint64_t convertToPatchId(uint64_t application_id);
|
||||
|
||||
private:
|
||||
static const uint64_t kAocBaseId = 0x1000;
|
||||
static const uint64_t kDeltaId = 0xc00;
|
||||
static const uint64_t kPatchId = 0x800;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <fnd/List.h>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <nn/hac/define/ini.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class IniHeader :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
IniHeader();
|
||||
IniHeader(const IniHeader& other);
|
||||
|
||||
void operator=(const IniHeader& other);
|
||||
bool operator==(const IniHeader& other) const;
|
||||
bool operator!=(const IniHeader& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* data, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
uint32_t getSize() const;
|
||||
void setSize(uint32_t size);
|
||||
|
||||
uint32_t getKipNum() const;
|
||||
void setKipNum(uint32_t num);
|
||||
private:
|
||||
const std::string kModuleName = "INI_HEADER";
|
||||
|
||||
// raw binary
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// variables
|
||||
uint32_t mSize;
|
||||
uint32_t mKipNum;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <fnd/types.h>
|
||||
#include <nn/hac/KernelCapabilityEntry.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class InteruptEntry
|
||||
{
|
||||
public:
|
||||
static const uint32_t kInteruptBits = 10;
|
||||
static const uint32_t kInteruptMax = BIT(kInteruptBits) - 1;
|
||||
static const uint32_t kInteruptNum = 2;
|
||||
|
||||
InteruptEntry();
|
||||
InteruptEntry(const KernelCapabilityEntry& kernel_cap);
|
||||
InteruptEntry(uint32_t interupt0, uint32_t interupt1);
|
||||
|
||||
void operator=(const InteruptEntry& other);
|
||||
bool operator==(const InteruptEntry& other) const;
|
||||
bool operator!=(const InteruptEntry& other) const;
|
||||
|
||||
// kernel capability
|
||||
const KernelCapabilityEntry& getKernelCapability() const;
|
||||
void setKernelCapability(const KernelCapabilityEntry& kernel_cap);
|
||||
|
||||
// variables
|
||||
uint32_t operator[](size_t index) const;
|
||||
|
||||
uint32_t getInterupt(size_t index) const;
|
||||
void setInterupt(size_t index, uint32_t interupt);
|
||||
|
||||
private:
|
||||
const std::string kModuleName = "INTERUPT_ENTRY";
|
||||
static const kc::KernelCapId kCapId = kc::KC_ENABLE_INTERUPTS;
|
||||
|
||||
KernelCapabilityEntry mCap;
|
||||
uint32_t mInterupt[kInteruptNum];
|
||||
|
||||
inline void updateCapField()
|
||||
{
|
||||
uint32_t field = 0;
|
||||
field |= (uint32_t)(mInterupt[0] & kInteruptMax) << 0;
|
||||
field |= (uint32_t)(mInterupt[1] & kInteruptMax) << kInteruptBits;
|
||||
mCap.setField(field);
|
||||
}
|
||||
|
||||
inline void processCapField()
|
||||
{
|
||||
uint32_t field = mCap.getField();
|
||||
mInterupt[0] = (field >> 0) & kInteruptMax;
|
||||
mInterupt[1] = (field >> kInteruptBits) & kInteruptMax;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
#pragma once
|
||||
#include <nn/hac/IKernelCapabilityHandler.h>
|
||||
#include <nn/hac/InteruptEntry.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class InteruptHandler :
|
||||
public IKernelCapabilityHandler
|
||||
{
|
||||
public:
|
||||
InteruptHandler();
|
||||
|
||||
void operator=(const InteruptHandler& other);
|
||||
bool operator==(const InteruptHandler& other) const;
|
||||
bool operator!=(const InteruptHandler& other) const;
|
||||
|
||||
// kernel capabilty list in/out
|
||||
void importKernelCapabilityList(const fnd::List<KernelCapabilityEntry>& caps);
|
||||
void exportKernelCapabilityList(fnd::List<KernelCapabilityEntry>& caps) const;
|
||||
void clear();
|
||||
bool isSet() const;
|
||||
|
||||
// variables
|
||||
const fnd::List<uint16_t>& getInteruptList() const;
|
||||
void setInteruptList(const fnd::List<uint16_t>& interupts);
|
||||
|
||||
private:
|
||||
const std::string kModuleName = "INTERUPT_HANDLER";
|
||||
|
||||
bool mIsSet;
|
||||
fnd::List<uint16_t> mInterupts;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <fnd/List.h>
|
||||
#include <nn/hac/ThreadInfoHandler.h>
|
||||
#include <nn/hac/SystemCallHandler.h>
|
||||
#include <nn/hac/MemoryMappingHandler.h>
|
||||
#include <nn/hac/InteruptHandler.h>
|
||||
#include <nn/hac/MiscParamsHandler.h>
|
||||
#include <nn/hac/KernelVersionHandler.h>
|
||||
#include <nn/hac/HandleTableSizeHandler.h>
|
||||
#include <nn/hac/MiscFlagsHandler.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class KernelCapabilityControl :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
KernelCapabilityControl();
|
||||
KernelCapabilityControl(const KernelCapabilityControl& other);
|
||||
|
||||
void operator=(const KernelCapabilityControl& other);
|
||||
bool operator==(const KernelCapabilityControl& other) const;
|
||||
bool operator!=(const KernelCapabilityControl& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* bytes, size_t len);
|
||||
virtual const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables (consider further abstraction?)
|
||||
void clear();
|
||||
const ThreadInfoHandler& getThreadInfo() const;
|
||||
ThreadInfoHandler& getThreadInfo();
|
||||
|
||||
const SystemCallHandler& getSystemCalls() const;
|
||||
SystemCallHandler& getSystemCalls();
|
||||
|
||||
const MemoryMappingHandler& getMemoryMaps() const;
|
||||
MemoryMappingHandler& getMemoryMaps();
|
||||
|
||||
const InteruptHandler& getInterupts() const;
|
||||
InteruptHandler& getInterupts();
|
||||
|
||||
const MiscParamsHandler& getMiscParams() const;
|
||||
MiscParamsHandler& getMiscParams();
|
||||
|
||||
const KernelVersionHandler& getKernelVersion() const;
|
||||
KernelVersionHandler& getKernelVersion();
|
||||
|
||||
const HandleTableSizeHandler& getHandleTableSize() const;
|
||||
HandleTableSizeHandler& getHandleTableSize();
|
||||
|
||||
const MiscFlagsHandler& getMiscFlags() const;
|
||||
MiscFlagsHandler& getMiscFlags();
|
||||
|
||||
private:
|
||||
const std::string kModuleName = "KERNEL_CAPABILITY_CONTROL";
|
||||
|
||||
// raw binary
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// variables
|
||||
ThreadInfoHandler mThreadInfo;
|
||||
SystemCallHandler mSystemCalls;
|
||||
MemoryMappingHandler mMemoryMap;
|
||||
InteruptHandler mInterupts;
|
||||
MiscParamsHandler mMiscParams;
|
||||
KernelVersionHandler mKernelVersion;
|
||||
HandleTableSizeHandler mHandleTableSize;
|
||||
MiscFlagsHandler mMiscFlags;
|
||||
};
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue