Merge pull request #56 from jakcron/model-refactor

Model refactor
This commit is contained in:
Jack 2018-10-27 15:07:26 +08:00 committed by GitHub
commit 44a9f7744c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
113 changed files with 15041 additions and 14185 deletions

View file

@ -1,124 +1,124 @@

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

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

View file

@ -1,58 +1,58 @@
#pragma once
#include <string>
#include <fnd/ISerialisable.h>
#include <nn/es/ticket.h>
namespace nn
{
namespace es
{
class SectionHeader_V2 :
public fnd::ISerialisable
{
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;
// export/import binary
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;
};
}
#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;
};
}
}

View file

@ -1,103 +1,103 @@
#pragma once
#include <string>
#include <fnd/ISerialisable.h>
#include <fnd/List.h>
#include <nn/es/ticket.h>
namespace nn
{
namespace es
{
class TicketBody_V2 :
public fnd::ISerialisable
{
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;
// export/import binary
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;
};
}
#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;
};
}
}

View file

@ -1,23 +1,23 @@
#pragma once
#include <fnd/types.h>
#include <fnd/Vec.h>
namespace fnd
{
class ISerialisable
{
public:
virtual ~ISerialisable() = 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;
};
#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;
};
}

View file

@ -1,170 +1,170 @@
<?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\IFile.h" />
<ClInclude Include="include\fnd\io.h" />
<ClInclude Include="include\fnd\ISerialisable.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>
<?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>

View file

@ -1,144 +1,144 @@
<?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\IFile.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\fnd\io.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\fnd\ISerialisable.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>
<?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>

View file

@ -1,72 +1,72 @@
#pragma once
#include <nn/hac/aset.h>
#include <fnd/List.h>
#include <fnd/ISerialisable.h>
namespace nn
{
namespace hac
{
class AssetHeader :
public fnd::ISerialisable
{
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;
// export/import binary
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;
};
}
#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;
};
}
}

View file

@ -1,33 +1,33 @@
#pragma once
#include <fnd/types.h>
#include <nn/hac/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)
}
#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)
}
}

View file

@ -1,14 +1,14 @@
#pragma once
#include <nn/hac/nro.h>
#include <nn/hac/macro.h>
namespace nn
{
namespace hac
{
namespace nro
{
static const uint64_t kNroHomebrewStructMagic = _MAKE_STRUCT_MAGIC_U64("HOMEBREW");
}
}
#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");
}
}
}

View file

@ -1,134 +1,134 @@
<?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\aset.h" />
<ClInclude Include="include\nn\hac\AssetHeader.h" />
<ClInclude Include="include\nn\hac\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>
<?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>

View file

@ -1,36 +1,39 @@
<?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>
<ClInclude Include="include\nn\hac\aset.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\AssetHeader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\nro-hb.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="source\AssetHeader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="makefile" />
</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>
<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>

View file

@ -0,0 +1,57 @@
#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;
};
}
}

View file

@ -1,56 +0,0 @@
#pragma once
#include <string>
#include <fnd/types.h>
#include <fnd/ISerialisable.h>
#include <nn/hac/aci.h>
#include <nn/hac/FileSystemAccessControlBinary.h>
#include <nn/hac/ServiceAccessControlBinary.h>
#include <nn/hac/KernelCapabilityBinary.h>
namespace nn
{
namespace hac
{
class AccessControlInfoBinary : public fnd::ISerialisable
{
public:
AccessControlInfoBinary();
AccessControlInfoBinary(const AccessControlInfoBinary& other);
void operator=(const AccessControlInfoBinary& other);
bool operator==(const AccessControlInfoBinary& other) const;
bool operator!=(const AccessControlInfoBinary& other) const;
// export/import binary
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::FileSystemAccessControlBinary& getFileSystemAccessControl() const;
void setFileSystemAccessControl(const FileSystemAccessControlBinary& fac);
const nn::hac::ServiceAccessControlBinary& getServiceAccessControl() const;
void setServiceAccessControl(const ServiceAccessControlBinary& sac);
const nn::hac::KernelCapabilityBinary& getKernelCapabilities() const;
void setKernelCapabilities(const KernelCapabilityBinary& kc);
private:
const std::string kModuleName = "ACCESS_CONTROL_INFO_BINARY";
// raw data
fnd::Vec<byte_t> mRawBinary;
// variables
uint64_t mProgramId;
nn::hac::FileSystemAccessControlBinary mFileSystemAccessControl;
nn::hac::ServiceAccessControlBinary mServiceAccessControl;
nn::hac::KernelCapabilityBinary mKernelCapabilities;
};
}
}

View file

@ -0,0 +1,92 @@
#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;
};
}
}

View file

@ -1,91 +0,0 @@
#pragma once
#include <string>
#include <fnd/types.h>
#include <fnd/List.h>
#include <fnd/ISerialisable.h>
#include <nn/hac/aci.h>
#include <nn/hac/FileSystemAccessControlBinary.h>
#include <nn/hac/ServiceAccessControlBinary.h>
#include <nn/hac/KernelCapabilityBinary.h>
namespace nn
{
namespace hac
{
class AccessControlInfoDescBinary : public fnd::ISerialisable
{
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);
}
};
AccessControlInfoDescBinary();
AccessControlInfoDescBinary(const AccessControlInfoDescBinary& other);
void operator=(const AccessControlInfoDescBinary& other);
bool operator==(const AccessControlInfoDescBinary& other) const;
bool operator!=(const AccessControlInfoDescBinary& other) const;
// export/import binary
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& getNcaHeaderSignature2Key() const;
void setNcaHeaderSignature2Key(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::FileSystemAccessControlBinary& getFileSystemAccessControl() const;
void setFileSystemAccessControl(const FileSystemAccessControlBinary& fac);
const nn::hac::ServiceAccessControlBinary& getServiceAccessControl() const;
void setServiceAccessControl(const ServiceAccessControlBinary& sac);
const nn::hac::KernelCapabilityBinary& getKernelCapabilities() const;
void setKernelCapabilities(const KernelCapabilityBinary& kc);
private:
const std::string kModuleName = "ACCESS_CONTROL_INFO_DESC_BINARY";
// raw data
fnd::Vec<byte_t> mRawBinary;
// variables
fnd::rsa::sRsa2048Key mNcaHeaderSignature2Key;
fnd::List<aci::Flag> mFlags;
sProgramIdRestrict mProgramIdRestrict;
nn::hac::FileSystemAccessControlBinary mFileSystemAccessControl;
nn::hac::ServiceAccessControlBinary mServiceAccessControl;
nn::hac::KernelCapabilityBinary mKernelCapabilities;
};
}
}

View file

@ -0,0 +1,46 @@
#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;
};
}
}

View file

@ -1,269 +1,269 @@
#pragma once
#include <string>
#include <fnd/types.h>
#include <fnd/ISerialisable.h>
#include <fnd/List.h>
#include <nn/hac/nacp.h>
namespace nn
{
namespace hac
{
class ApplicationControlPropertyBinary :
public fnd::ISerialisable
{
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);
}
};
ApplicationControlPropertyBinary();
ApplicationControlPropertyBinary(const ApplicationControlPropertyBinary& other);
void operator=(const ApplicationControlPropertyBinary& other);
bool operator==(const ApplicationControlPropertyBinary& other) const;
bool operator!=(const ApplicationControlPropertyBinary& other) const;
// export/import binary
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::TouchScreenUsageMode getTouchScreenUsageMode() const;
void setTouchScreenUsageMode(nacp::TouchScreenUsageMode 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);
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::TouchScreenUsageMode mTouchScreenUsageMode;
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;
};
}
#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::TouchScreenUsageMode getTouchScreenUsageMode() const;
void setTouchScreenUsageMode(nacp::TouchScreenUsageMode 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);
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::TouchScreenUsageMode mTouchScreenUsageMode;
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;
};
}
}

View file

@ -1,15 +1,15 @@
#pragma once
#include <nn/hac/nacp.h>
namespace nn
{
namespace hac
{
class ApplicationControlPropertyUtils
{
public:
static bool validateSaveDataSizeMax(int64_t size, int64_t alignment);
static bool validateSaveDataSize(int64_t size);
};
}
#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);
};
}
}

View file

@ -0,0 +1,46 @@
#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;
};
}
}

View file

@ -0,0 +1,121 @@
#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;
};
}
}

View file

@ -1,17 +1,17 @@
#pragma once
#include <nn/hac/nca.h>
namespace nn
{
namespace hac
{
class NcaUtils
{
public:
static inline size_t sectorToOffset(size_t sector_index) { return sector_index * nn::hac::nca::kSectorSize; }
static void decryptNcaHeader(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);
};
}
#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);
};
}
}

View file

@ -0,0 +1,59 @@
#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;
};
}
}

View file

@ -0,0 +1,113 @@
#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;
};
}
}

View file

@ -1,254 +0,0 @@
#pragma once
#include <string>
#include <cstring>
#include <fnd/ISerialisable.h>
#include <fnd/List.h>
#include <nn/hac/cnmt.h>
namespace nn
{
namespace hac
{
class ContentMetaBinary :
public fnd::ISerialisable
{
public:
struct ContentInfo
{
fnd::sha::sSha256Hash hash;
byte_t nca_id[cnmt::kContentIdLen];
size_t size;
cnmt::ContentType type;
void operator=(const ContentInfo& other)
{
hash = other.hash;
memcpy(nca_id, other.nca_id, cnmt::kContentIdLen);
size = other.size;
type = other.type;
}
bool operator==(const ContentInfo& other) const
{
return (hash == other.hash) \
&& (memcmp(nca_id, other.nca_id, cnmt::kContentIdLen) == 0) \
&& (size == other.size) \
&& (type == other.type);
}
bool operator!=(const ContentInfo& other) const
{
return !operator==(other);
}
};
struct ContentMetaInfo
{
uint64_t id;
uint32_t version;
cnmt::ContentMetaType type;
byte_t attributes;
void operator=(const ContentMetaInfo& other)
{
id = other.id;
version = other.version;
type = other.type;
attributes = other.attributes;
}
bool operator==(const ContentMetaInfo& other) const
{
return (id == other.id) \
&& (version == other.version) \
&& (type == other.type) \
&& (attributes == other.attributes);
}
bool operator!=(const ContentMetaInfo& other) const
{
return !operator==(other);
}
};
struct ApplicationMetaExtendedHeader
{
uint64_t patch_id;
uint32_t required_system_version;
void operator=(const ApplicationMetaExtendedHeader& other)
{
patch_id = other.patch_id;
required_system_version = other.required_system_version;
}
bool operator==(const ApplicationMetaExtendedHeader& other) const
{
return (patch_id == other.patch_id) \
&& (required_system_version == other.required_system_version);
}
bool operator!=(const ApplicationMetaExtendedHeader& other) const
{
return !operator==(other);
}
};
struct PatchMetaExtendedHeader
{
uint64_t application_id;
uint32_t required_system_version;
void operator=(const PatchMetaExtendedHeader& other)
{
application_id = other.application_id;
required_system_version = other.required_system_version;
}
bool operator==(const PatchMetaExtendedHeader& other) const
{
return (application_id == other.application_id) \
&& (required_system_version == other.required_system_version);
}
bool operator!=(const PatchMetaExtendedHeader& other) const
{
return !operator==(other);
}
};
struct AddOnContentMetaExtendedHeader
{
uint64_t application_id;
uint32_t required_application_version;
void operator=(const AddOnContentMetaExtendedHeader& other)
{
application_id = other.application_id;
required_application_version = other.required_application_version;
}
bool operator==(const AddOnContentMetaExtendedHeader& other) const
{
return (application_id == other.application_id) \
&& (required_application_version == other.required_application_version);
}
bool operator!=(const AddOnContentMetaExtendedHeader& other) const
{
return !operator==(other);
}
};
struct DeltaMetaExtendedHeader
{
uint64_t application_id;
void operator=(const DeltaMetaExtendedHeader& other)
{
application_id = other.application_id;
}
bool operator==(const DeltaMetaExtendedHeader& other) const
{
return (application_id == other.application_id);
}
bool operator!=(const DeltaMetaExtendedHeader& other) const
{
return !operator==(other);
}
};
ContentMetaBinary();
ContentMetaBinary(const ContentMetaBinary& other);
void operator=(const ContentMetaBinary& other);
bool operator==(const ContentMetaBinary& other) const;
bool operator!=(const ContentMetaBinary& other) const;
// export/import binary
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 getType() const;
void setType(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<nn::hac::ContentMetaBinary::ContentInfo>& getContentInfo() const;
void setContentInfo(const fnd::List<nn::hac::ContentMetaBinary::ContentInfo>& info);
const fnd::List<nn::hac::ContentMetaBinary::ContentMetaInfo>& getContentMetaInfo() const;
void setContentMetaInfo(const fnd::List<nn::hac::ContentMetaBinary::ContentMetaInfo>& info);
const fnd::Vec<byte_t>& getExtendedData() const;
void setExtendedData(const fnd::Vec<byte_t>& data);
const nn::hac::sDigest& getDigest() const;
void setDigest(const nn::hac::sDigest& digest);
private:
const std::string kModuleName = "CONTENT_META_BINARY";
// 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<nn::hac::ContentMetaBinary::ContentInfo> mContentInfo;
fnd::List<nn::hac::ContentMetaBinary::ContentMetaInfo> mContentMetaInfo;
fnd::Vec<byte_t> mExtendedData;
nn::hac::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;
};
}
}

View file

@ -0,0 +1,55 @@
#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;
};
}
}

View file

@ -0,0 +1,47 @@
#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;
};
}
}

View file

@ -1,77 +1,78 @@
#pragma once
#include <string>
#include <fnd/types.h>
#include <fnd/ISerialisable.h>
#include <fnd/List.h>
#include <nn/hac/fac.h>
namespace nn
{
namespace hac
{
class FileSystemAccessControlBinary : public fnd::ISerialisable
{
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);
}
};
FileSystemAccessControlBinary();
FileSystemAccessControlBinary(const FileSystemAccessControlBinary& other);
void operator=(const FileSystemAccessControlBinary& other);
bool operator==(const FileSystemAccessControlBinary& other) const;
bool operator!=(const FileSystemAccessControlBinary& other) const;
// export/import binary
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_BINARY";
// 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;
};
}
#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;
};
}
}

View file

@ -1,127 +1,127 @@
#pragma once
#include <nn/hac/xci.h>
#include <fnd/ISerialisable.h>
#include <fnd/List.h>
namespace nn
{
namespace hac
{
class XciHeader :
public fnd::ISerialisable
{
public:
XciHeader();
XciHeader(const XciHeader& other);
void operator=(const XciHeader& other);
bool operator==(const XciHeader& other) const;
bool operator!=(const XciHeader& other) const;
// export/import binary
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 = "XCI_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 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;
};
}
#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;
};
}
}

View file

@ -1,16 +1,16 @@
#pragma once
#include <nn/hac/xci.h>
namespace nn
{
namespace hac
{
class XciUtils
{
public:
static inline uint64_t blockToAddr(uint32_t block) { return ((uint64_t)block) << 9; }
static void getXciHeaderAesIv(const nn::hac::sXciHeader* hdr, byte_t* iv);
static void decryptXciHeader(const byte_t* src, byte_t* dst, const byte_t* key);
};
}
#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);
};
}
}

View file

@ -1,70 +1,70 @@
#pragma once
#include <nn/hac/hierarchicalintegrity.h>
#include <fnd/ISerialisable.h>
#include <fnd/List.h>
#include <fnd/sha.h>
namespace nn
{
namespace hac
{
class HierarchicalIntegrityHeader :
public fnd::ISerialisable
{
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;
// export/import binary
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;
};
}
#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;
};
}
}

View file

@ -1,71 +1,71 @@
#pragma once
#include <nn/hac/hierarchicalsha256.h>
#include <fnd/ISerialisable.h>
#include <fnd/List.h>
namespace nn
{
namespace hac
{
class HierarchicalSha256Header :
public fnd::ISerialisable
{
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;
// export/import binary
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;
};
}
#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;
};
}
}

View file

@ -1,78 +1,78 @@
#pragma once
#include <string>
#include <vector>
#include <fnd/ISerialisable.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 KernelCapabilityBinary :
public fnd::ISerialisable
{
public:
KernelCapabilityBinary();
KernelCapabilityBinary(const KernelCapabilityBinary& other);
void operator=(const KernelCapabilityBinary& other);
bool operator==(const KernelCapabilityBinary& other) const;
bool operator!=(const KernelCapabilityBinary& other) const;
// export/import binary
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 = "KC_BINARY";
// raw binary
fnd::Vec<byte_t> mRawBinary;
// variables
ThreadInfoHandler mThreadInfo;
SystemCallHandler mSystemCalls;
MemoryMappingHandler mMemoryMap;
InteruptHandler mInterupts;
MiscParamsHandler mMiscParams;
KernelVersionHandler mKernelVersion;
HandleTableSizeHandler mHandleTableSize;
MiscFlagsHandler mMiscFlags;
};
}
#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;
};
}
}

View file

@ -1,52 +1,52 @@
#pragma once
#include <fnd/types.h>
#include <nn/hac/kc.h>
namespace nn
{
namespace hac
{
class KernelCapabilityEntry
{
public:
KernelCapabilityEntry();
KernelCapabilityEntry(kc::KernelCapId type);
KernelCapabilityEntry(kc::KernelCapId type, uint32_t field);
void operator=(const KernelCapabilityEntry& other);
bool operator==(const KernelCapabilityEntry& other) const;
bool operator!=(const KernelCapabilityEntry& other) const;
uint32_t getCap() const;
void setCap(uint32_t cap);
kc::KernelCapId getType() const;
void setType(kc::KernelCapId type);
uint32_t getField() const;
void setField(uint32_t field);
private:
kc::KernelCapId mType;
uint32_t mField;
inline uint32_t getFieldShift() const { return mType + 1; }
inline uint32_t getFieldMask() const { return BIT(31 - mType) - 1; }
inline uint32_t getCapMask() const { return BIT(mType) - 1; }
inline kc::KernelCapId getCapId(uint32_t cap) const
{
kc::KernelCapId id = kc::KC_INVALID;
for (byte_t tmp = 0; tmp < 31; tmp++)
{
if (((cap >> tmp) & 1) == 0)
{
id = (kc::KernelCapId)tmp;
break;
}
}
return id;
}
};
}
#pragma once
#include <fnd/types.h>
#include <nn/hac/define/kc.h>
namespace nn
{
namespace hac
{
class KernelCapabilityEntry
{
public:
KernelCapabilityEntry();
KernelCapabilityEntry(kc::KernelCapId type);
KernelCapabilityEntry(kc::KernelCapId type, uint32_t field);
void operator=(const KernelCapabilityEntry& other);
bool operator==(const KernelCapabilityEntry& other) const;
bool operator!=(const KernelCapabilityEntry& other) const;
uint32_t getCap() const;
void setCap(uint32_t cap);
kc::KernelCapId getType() const;
void setType(kc::KernelCapId type);
uint32_t getField() const;
void setField(uint32_t field);
private:
kc::KernelCapId mType;
uint32_t mField;
inline uint32_t getFieldShift() const { return mType + 1; }
inline uint32_t getFieldMask() const { return BIT(31 - mType) - 1; }
inline uint32_t getCapMask() const { return BIT(mType) - 1; }
inline kc::KernelCapId getCapId(uint32_t cap) const
{
kc::KernelCapId id = kc::KC_INVALID;
for (byte_t tmp = 0; tmp < 31; tmp++)
{
if (((cap >> tmp) & 1) == 0)
{
id = (kc::KernelCapId)tmp;
break;
}
}
return id;
}
};
}
}

View file

@ -1,80 +1,80 @@
#pragma once
#include <string>
#include <fnd/List.h>
#include <fnd/ISerialisable.h>
#include <nn/hac/meta.h>
#include <nn/hac/AccessControlInfoBinary.h>
#include <nn/hac/AccessControlInfoDescBinary.h>
namespace nn
{
namespace hac
{
class MetaBinary :
public fnd::ISerialisable
{
public:
MetaBinary();
MetaBinary(const MetaBinary& other);
void operator=(const MetaBinary& other);
bool operator==(const MetaBinary& other) const;
bool operator!=(const MetaBinary& other) const;
// export/import binary
void toBytes();
void fromBytes(const byte_t* bytes, size_t len);
const fnd::Vec<byte_t>& getBytes() const;
// variables
void clear();
meta::InstructionType getInstructionType() const;
void setInstructionType(meta::InstructionType type);
meta::ProcAddrSpaceType getProcAddressSpaceType() const;
void setProcAddressSpaceType(meta::ProcAddrSpaceType type);
byte_t getMainThreadPriority() const;
void setMainThreadPriority(byte_t priority);
byte_t getMainThreadCpuId() const;
void setMainThreadCpuId(byte_t cpu_id);
uint32_t getVersion() const;
void setVersion(uint32_t version);
uint32_t getMainThreadStackSize() const;
void setMainThreadStackSize(uint32_t size);
const std::string& getName() const;
void setName(const std::string& name);
const std::string& getProductCode() const;
void setProductCode(const std::string& product_code);
const AccessControlInfoBinary& getAci() const;
void setAci(const AccessControlInfoBinary& aci);
const AccessControlInfoDescBinary& getAcid() const;
void setAcid(const AccessControlInfoDescBinary& acid);
private:
const std::string kModuleName = "META_BINARY";
// raw binary
fnd::Vec<byte_t> mRawBinary;
// variables
meta::InstructionType mInstructionType;
meta::ProcAddrSpaceType mProcAddressSpaceType;
byte_t mMainThreadPriority;
byte_t mMainThreadCpuId;
uint32_t mVersion;
uint32_t mMainThreadStackSize;
std::string mName;
std::string mProductCode;
AccessControlInfoBinary mAci;
AccessControlInfoDescBinary mAcid;
};
}
}
#pragma once
#include <string>
#include <fnd/List.h>
#include <fnd/IByteModel.h>
#include <nn/hac/define/meta.h>
#include <nn/hac/AccessControlInfo.h>
#include <nn/hac/AccessControlInfoDesc.h>
namespace nn
{
namespace hac
{
class Meta :
public fnd::IByteModel
{
public:
Meta();
Meta(const Meta& other);
void operator=(const Meta& other);
bool operator==(const Meta& other) const;
bool operator!=(const Meta& other) const;
// IByteModel
void toBytes();
void fromBytes(const byte_t* bytes, size_t len);
const fnd::Vec<byte_t>& getBytes() const;
// variables
void clear();
meta::InstructionType getInstructionType() const;
void setInstructionType(meta::InstructionType type);
meta::ProcAddrSpaceType getProcAddressSpaceType() const;
void setProcAddressSpaceType(meta::ProcAddrSpaceType type);
byte_t getMainThreadPriority() const;
void setMainThreadPriority(byte_t priority);
byte_t getMainThreadCpuId() const;
void setMainThreadCpuId(byte_t cpu_id);
uint32_t getVersion() const;
void setVersion(uint32_t version);
uint32_t getMainThreadStackSize() const;
void setMainThreadStackSize(uint32_t size);
const std::string& getName() const;
void setName(const std::string& name);
const std::string& getProductCode() const;
void setProductCode(const std::string& product_code);
const AccessControlInfo& getAci() const;
void setAci(const AccessControlInfo& aci);
const AccessControlInfoDesc& getAcid() const;
void setAcid(const AccessControlInfoDesc& acid);
private:
const std::string kModuleName = "META";
// raw binary
fnd::Vec<byte_t> mRawBinary;
// variables
meta::InstructionType mInstructionType;
meta::ProcAddrSpaceType mProcAddressSpaceType;
byte_t mMainThreadPriority;
byte_t mMainThreadCpuId;
uint32_t mVersion;
uint32_t mMainThreadStackSize;
std::string mName;
std::string mProductCode;
AccessControlInfo mAci;
AccessControlInfoDesc mAcid;
};
}
}

View file

@ -1,115 +0,0 @@
#pragma once
#include <nn/hac/nca.h>
#include <fnd/ISerialisable.h>
#include <fnd/List.h>
namespace nn
{
namespace hac
{
class NcaHeader :
public fnd::ISerialisable
{
public:
enum FormatVersion
{
NCA2_FORMAT,
NCA3_FORMAT
};
struct sPartition
{
byte_t index;
uint64_t offset;
uint64_t size;
fnd::sha::sSha256Hash hash;
const sPartition& operator=(const sPartition& other)
{
index = other.index;
offset = other.offset;
size = other.size;
hash = other.hash;
return *this;
}
bool operator==(const sPartition& other) const
{
return (index == other.index) \
&& (offset == other.offset) \
&& (size == other.size) \
&& (hash == other.hash);
}
bool operator!=(const sPartition& other) const
{
return !operator==(other);
}
};
NcaHeader();
NcaHeader(const NcaHeader& other);
void operator=(const NcaHeader& other);
bool operator==(const NcaHeader& other) const;
bool operator!=(const NcaHeader& other) const;
// export/import binary
void toBytes();
void fromBytes(const byte_t* bytes, size_t len);
const fnd::Vec<byte_t>& getBytes() const;
// variables
void clear();
FormatVersion getFormatVersion() const;
void setFormatVersion(FormatVersion 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 getKaekIndex() const;
void setKaekIndex(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<sPartition>& getPartitions() const;
void setPartitions(const fnd::List<sPartition>& partitions);
const fnd::List<fnd::aes::sAes128Key>& getEncAesKeys() const;
void setEncAesKeys(const fnd::List<fnd::aes::sAes128Key>& keys);
private:
const std::string kModuleName = "NCA_HEADER";
// binary
fnd::Vec<byte_t> mRawBinary;
// data
FormatVersion 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;
byte_t mRightsId[nca::kRightsIdLen];
fnd::List<sPartition> mPartitions;
fnd::List<fnd::aes::sAes128Key> mEncAesKeys;
uint64_t blockNumToSize(uint32_t block_num) const;
uint32_t sizeToBlockNum(uint64_t real_size) const;
};
}
}

View file

@ -1,141 +1,141 @@
#pragma once
#include <cstring>
#include <nn/hac/nro.h>
#include <fnd/ISerialisable.h>
#include <fnd/List.h>
namespace nn
{
namespace hac
{
class NroHeader :
public fnd::ISerialisable
{
public:
struct sRoCrt
{
byte_t data[nro::kRoCrtSize];
void operator=(const sRoCrt& other)
{
memcpy(data, other.data, nro::kRoCrtSize);
}
bool operator==(const sRoCrt& other) const
{
return memcmp(data, other.data, nro::kRoCrtSize) == 0;
}
bool operator!=(const sRoCrt& other) const
{
return !(*this == other);
}
};
struct sModuleId
{
byte_t data[nro::kModuleIdSize];
void operator=(const sModuleId& other)
{
memcpy(data, other.data, nro::kModuleIdSize);
}
bool operator==(const sModuleId& other) const
{
return memcmp(data, other.data, nro::kModuleIdSize) == 0;
}
bool operator!=(const sModuleId& other) const
{
return !(*this == other);
}
};
struct sSection
{
uint32_t memory_offset;
uint32_t size;
void operator=(const sSection& other)
{
memory_offset = other.memory_offset;
size = other.size;
}
bool operator==(const sSection& other) const
{
return (memory_offset == other.memory_offset) \
&& (size == other.size);
}
bool operator!=(const sSection& other) const
{
return !(*this == other);
}
};
NroHeader();
NroHeader(const NroHeader& other);
void operator=(const NroHeader& other);
bool operator==(const NroHeader& other) const;
bool operator!=(const NroHeader& other) const;
// export/import binary
void toBytes();
void fromBytes(const byte_t* bytes, size_t len);
const fnd::Vec<byte_t>& getBytes() const;
// variables
void clear();
const sRoCrt& getRoCrt() const;
void setRoCrt(const sRoCrt& ro_crt);
uint32_t getNroSize() const;
void setNroSize(uint32_t size);
const sSection& getTextInfo() const;
void setTextInfo(const sSection& info);
const sSection& getRoInfo() const;
void setRoInfo(const sSection& info);
const sSection& getDataInfo() const;
void setDataInfo(const sSection& info);
uint32_t getBssSize() const;
void setBssSize(uint32_t size);
const sModuleId& getModuleId() const;
void setModuleId(const sModuleId& id);
const sSection& getRoEmbeddedInfo() const;
void setRoEmbeddedInfo(const sSection& info);
const sSection& getRoDynStrInfo() const;
void setRoDynStrInfo(const sSection& info);
const sSection& getRoDynSymInfo() const;
void setRoDynSymInfo(const sSection& info);
private:
const std::string kModuleName = "NRO_HEADER";
// binary
fnd::Vec<byte_t> mRawBinary;
// data
sRoCrt mRoCrt;
uint32_t mNroSize;
sSection mTextInfo;
sSection mRoInfo;
sSection mDataInfo;
uint32_t mBssSize;
sModuleId mModuleId;
sSection mRoEmbeddedInfo;
sSection mRoDynStrInfo;
sSection mRoDynSymInfo;
};
}
#pragma once
#include <cstring>
#include <nn/hac/define/nro.h>
#include <fnd/IByteModel.h>
#include <fnd/List.h>
namespace nn
{
namespace hac
{
class NroHeader :
public fnd::IByteModel
{
public:
struct sRoCrt
{
byte_t data[nro::kRoCrtSize];
void operator=(const sRoCrt& other)
{
memcpy(data, other.data, nro::kRoCrtSize);
}
bool operator==(const sRoCrt& other) const
{
return memcmp(data, other.data, nro::kRoCrtSize) == 0;
}
bool operator!=(const sRoCrt& other) const
{
return !(*this == other);
}
};
struct sModuleId
{
byte_t data[nro::kModuleIdSize];
void operator=(const sModuleId& other)
{
memcpy(data, other.data, nro::kModuleIdSize);
}
bool operator==(const sModuleId& other) const
{
return memcmp(data, other.data, nro::kModuleIdSize) == 0;
}
bool operator!=(const sModuleId& other) const
{
return !(*this == other);
}
};
struct sSection
{
uint32_t memory_offset;
uint32_t size;
void operator=(const sSection& other)
{
memory_offset = other.memory_offset;
size = other.size;
}
bool operator==(const sSection& other) const
{
return (memory_offset == other.memory_offset) \
&& (size == other.size);
}
bool operator!=(const sSection& other) const
{
return !(*this == other);
}
};
NroHeader();
NroHeader(const NroHeader& other);
void operator=(const NroHeader& other);
bool operator==(const NroHeader& other) const;
bool operator!=(const NroHeader& 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 sRoCrt& getRoCrt() const;
void setRoCrt(const sRoCrt& ro_crt);
uint32_t getNroSize() const;
void setNroSize(uint32_t size);
const sSection& getTextInfo() const;
void setTextInfo(const sSection& info);
const sSection& getRoInfo() const;
void setRoInfo(const sSection& info);
const sSection& getDataInfo() const;
void setDataInfo(const sSection& info);
uint32_t getBssSize() const;
void setBssSize(uint32_t size);
const sModuleId& getModuleId() const;
void setModuleId(const sModuleId& id);
const sSection& getRoEmbeddedInfo() const;
void setRoEmbeddedInfo(const sSection& info);
const sSection& getRoDynStrInfo() const;
void setRoDynStrInfo(const sSection& info);
const sSection& getRoDynSymInfo() const;
void setRoDynSymInfo(const sSection& info);
private:
const std::string kModuleName = "NRO_HEADER";
// binary
fnd::Vec<byte_t> mRawBinary;
// data
sRoCrt mRoCrt;
uint32_t mNroSize;
sSection mTextInfo;
sSection mRoInfo;
sSection mDataInfo;
uint32_t mBssSize;
sModuleId mModuleId;
sSection mRoEmbeddedInfo;
sSection mRoDynStrInfo;
sSection mRoDynSymInfo;
};
}
}

View file

@ -1,149 +1,149 @@
#pragma once
#include <cstring>
#include <nn/hac/nso.h>
#include <fnd/ISerialisable.h>
#include <fnd/List.h>
namespace nn
{
namespace hac
{
class NsoHeader :
public fnd::ISerialisable
{
public:
struct sModuleId
{
byte_t data[nso::kModuleIdSize];
void operator=(const sModuleId& other)
{
memcpy(data, other.data, nso::kModuleIdSize);
}
bool operator==(const sModuleId& other) const
{
return memcmp(data, other.data, nso::kModuleIdSize) == 0;
}
bool operator!=(const sModuleId& other) const
{
return !(*this == other);
}
};
struct sLayout
{
uint32_t offset;
uint32_t size;
void operator=(const sLayout& other)
{
offset = other.offset;
size = other.size;
}
bool operator==(const sLayout& other) const
{
return (offset == other.offset) \
&& (size == other.size);
}
bool operator!=(const sLayout& other) const
{
return !(*this == other);
}
};
struct sCodeSegment
{
sLayout file_layout;
sLayout memory_layout;
bool is_compressed;
bool is_hashed;
fnd::sha::sSha256Hash hash;
void operator=(const sCodeSegment& other)
{
file_layout = other.file_layout;
memory_layout = other.memory_layout;
is_compressed = other.is_compressed;
is_hashed = other.is_hashed;
hash = other.hash;
}
bool operator==(const sCodeSegment& other) const
{
return (file_layout == other.file_layout) \
&& (memory_layout == other.memory_layout) \
&& (is_compressed == other.is_compressed) \
&& (is_hashed == other.is_hashed) \
&& (hash == other.hash);
}
bool operator!=(const sCodeSegment& other) const
{
return !(*this == other);
}
};
NsoHeader();
NsoHeader(const NsoHeader& other);
void operator=(const NsoHeader& other);
bool operator==(const NsoHeader& other) const;
bool operator!=(const NsoHeader& other) const;
// export/import binary
void toBytes();
void fromBytes(const byte_t* bytes, size_t len);
const fnd::Vec<byte_t>& getBytes() const;
// variables
void clear();
const sModuleId& getModuleId() const;
void setModuleId(const sModuleId& id);
uint32_t getBssSize() const;
void setBssSize(uint32_t size);
const sCodeSegment& getTextSegmentInfo() const;
void setTextSegmentInfo(const sCodeSegment& info);
const sCodeSegment& getRoSegmentInfo() const;
void setRoSegmentInfo(const sCodeSegment& info);
const sCodeSegment& getDataSegmentInfo() const;
void setDataSegmentInfo(const sCodeSegment& info);
const sLayout& getModuleNameInfo() const;
void setModuleNameInfo(const sLayout& info);
const sLayout& getRoEmbeddedInfo() const;
void setRoEmbeddedInfo(const sLayout& info);
const sLayout& getRoDynStrInfo() const;
void setRoDynStrInfo(const sLayout& info);
const sLayout& getRoDynSymInfo() const;
void setRoDynSymInfo(const sLayout& info);
private:
const std::string kModuleName = "NSO_HEADER";
// binary
fnd::Vec<byte_t> mRawBinary;
// data
sModuleId mModuleId;
uint32_t mBssSize;
sCodeSegment mTextSegmentInfo;
sCodeSegment mRoSegmentInfo;
sCodeSegment mDataSegmentInfo;
sLayout mModuleNameInfo;
sLayout mRoEmbeddedInfo;
sLayout mRoDynStrInfo;
sLayout mRoDynSymInfo;
};
}
#pragma once
#include <cstring>
#include <nn/hac/define/nso.h>
#include <fnd/IByteModel.h>
#include <fnd/List.h>
namespace nn
{
namespace hac
{
class NsoHeader :
public fnd::IByteModel
{
public:
struct sModuleId
{
byte_t data[nso::kModuleIdSize];
void operator=(const sModuleId& other)
{
memcpy(data, other.data, nso::kModuleIdSize);
}
bool operator==(const sModuleId& other) const
{
return memcmp(data, other.data, nso::kModuleIdSize) == 0;
}
bool operator!=(const sModuleId& other) const
{
return !(*this == other);
}
};
struct sLayout
{
uint32_t offset;
uint32_t size;
void operator=(const sLayout& other)
{
offset = other.offset;
size = other.size;
}
bool operator==(const sLayout& other) const
{
return (offset == other.offset) \
&& (size == other.size);
}
bool operator!=(const sLayout& other) const
{
return !(*this == other);
}
};
struct sCodeSegment
{
sLayout file_layout;
sLayout memory_layout;
bool is_compressed;
bool is_hashed;
fnd::sha::sSha256Hash hash;
void operator=(const sCodeSegment& other)
{
file_layout = other.file_layout;
memory_layout = other.memory_layout;
is_compressed = other.is_compressed;
is_hashed = other.is_hashed;
hash = other.hash;
}
bool operator==(const sCodeSegment& other) const
{
return (file_layout == other.file_layout) \
&& (memory_layout == other.memory_layout) \
&& (is_compressed == other.is_compressed) \
&& (is_hashed == other.is_hashed) \
&& (hash == other.hash);
}
bool operator!=(const sCodeSegment& other) const
{
return !(*this == other);
}
};
NsoHeader();
NsoHeader(const NsoHeader& other);
void operator=(const NsoHeader& other);
bool operator==(const NsoHeader& other) const;
bool operator!=(const NsoHeader& 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 sModuleId& getModuleId() const;
void setModuleId(const sModuleId& id);
uint32_t getBssSize() const;
void setBssSize(uint32_t size);
const sCodeSegment& getTextSegmentInfo() const;
void setTextSegmentInfo(const sCodeSegment& info);
const sCodeSegment& getRoSegmentInfo() const;
void setRoSegmentInfo(const sCodeSegment& info);
const sCodeSegment& getDataSegmentInfo() const;
void setDataSegmentInfo(const sCodeSegment& info);
const sLayout& getModuleNameInfo() const;
void setModuleNameInfo(const sLayout& info);
const sLayout& getRoEmbeddedInfo() const;
void setRoEmbeddedInfo(const sLayout& info);
const sLayout& getRoDynStrInfo() const;
void setRoDynStrInfo(const sLayout& info);
const sLayout& getRoDynSymInfo() const;
void setRoDynSymInfo(const sLayout& info);
private:
const std::string kModuleName = "NSO_HEADER";
// binary
fnd::Vec<byte_t> mRawBinary;
// data
sModuleId mModuleId;
uint32_t mBssSize;
sCodeSegment mTextSegmentInfo;
sCodeSegment mRoSegmentInfo;
sCodeSegment mDataSegmentInfo;
sLayout mModuleNameInfo;
sLayout mRoEmbeddedInfo;
sLayout mRoDynStrInfo;
sLayout mRoDynSymInfo;
};
}
}

View file

@ -1,100 +1,100 @@
#pragma once
#include <string>
#include <fnd/types.h>
#include <fnd/ISerialisable.h>
#include <fnd/List.h>
#include <nn/hac/pfs.h>
namespace nn
{
namespace hac
{
class PfsHeader :
public fnd::ISerialisable
{
public:
enum FsType
{
TYPE_PFS0,
TYPE_HFS0
};
struct sFile
{
std::string name;
size_t offset;
size_t size;
size_t hash_protected_size;
fnd::sha::sSha256Hash hash;
sFile& operator=(const sFile& other)
{
name = other.name;
offset = other.offset;
size = other.size;
hash_protected_size = other.hash_protected_size;
hash = other.hash;
return *this;
}
bool operator==(const sFile& other) const
{
return (name == other.name) \
&& (offset == other.offset) \
&& (size == other.size) \
&& (hash_protected_size == other.hash_protected_size) \
&& (hash == other.hash);
}
bool operator!=(const sFile& other) const
{
return !operator==(other);
}
bool operator==(const std::string& other) const
{
return (name == other);
}
bool operator!=(const std::string& other) const
{
return !operator==(other);
}
};
PfsHeader();
PfsHeader(const PfsHeader& other);
void operator=(const PfsHeader& other);
bool operator==(const PfsHeader& other) const;
bool operator!=(const PfsHeader& other) const;
// export/import binary
void toBytes();
void fromBytes(const byte_t* bytes, size_t len);
const fnd::Vec<byte_t>& getBytes() const;
// variables
void clear();
FsType getFsType() const;
void setFsType(FsType type);
const fnd::List<sFile>& getFileList() const;
void addFile(const std::string& name, size_t size);
void addFile(const std::string& name, size_t size, size_t hash_protected_size, const fnd::sha::sSha256Hash& hash);
private:
const std::string kModuleName = "PFS_HEADER";
// binary blob
fnd::Vec<byte_t> mRawBinary;
// variables
FsType mFsType;
fnd::List<sFile> mFileList;
size_t getFileEntrySize(FsType fs_type);
void calculateOffsets(size_t data_offset);
};
}
#pragma once
#include <string>
#include <fnd/types.h>
#include <fnd/IByteModel.h>
#include <fnd/List.h>
#include <nn/hac/define/pfs.h>
namespace nn
{
namespace hac
{
class PartitionFsHeader :
public fnd::IByteModel
{
public:
enum FsType
{
TYPE_PFS0,
TYPE_HFS0
};
struct sFile
{
std::string name;
size_t offset;
size_t size;
size_t hash_protected_size;
fnd::sha::sSha256Hash hash;
sFile& operator=(const sFile& other)
{
name = other.name;
offset = other.offset;
size = other.size;
hash_protected_size = other.hash_protected_size;
hash = other.hash;
return *this;
}
bool operator==(const sFile& other) const
{
return (name == other.name) \
&& (offset == other.offset) \
&& (size == other.size) \
&& (hash_protected_size == other.hash_protected_size) \
&& (hash == other.hash);
}
bool operator!=(const sFile& other) const
{
return !operator==(other);
}
bool operator==(const std::string& other) const
{
return (name == other);
}
bool operator!=(const std::string& other) const
{
return !operator==(other);
}
};
PartitionFsHeader();
PartitionFsHeader(const PartitionFsHeader& other);
void operator=(const PartitionFsHeader& other);
bool operator==(const PartitionFsHeader& other) const;
bool operator!=(const PartitionFsHeader& other) const;
// IByteModel
void toBytes();
void fromBytes(const byte_t* bytes, size_t len);
const fnd::Vec<byte_t>& getBytes() const;
// variables
void clear();
FsType getFsType() const;
void setFsType(FsType type);
const fnd::List<sFile>& getFileList() const;
void addFile(const std::string& name, size_t size);
void addFile(const std::string& name, size_t size, size_t hash_protected_size, const fnd::sha::sSha256Hash& hash);
private:
const std::string kModuleName = "PARTITIONFS_HEADER";
// binary blob
fnd::Vec<byte_t> mRawBinary;
// variables
FsType mFsType;
fnd::List<sFile> mFileList;
size_t getFileEntrySize(FsType fs_type);
void calculateOffsets(size_t data_offset);
};
}
}

View file

@ -0,0 +1,51 @@
#pragma once
#include <string>
#include <cstring>
#include <fnd/IByteModel.h>
#include <nn/hac/define/cnmt.h>
namespace nn
{
namespace hac
{
class PatchMetaExtendedHeader :
public fnd::IByteModel
{
public:
PatchMetaExtendedHeader();
PatchMetaExtendedHeader(const PatchMetaExtendedHeader& other);
void operator=(const PatchMetaExtendedHeader& other);
bool operator==(const PatchMetaExtendedHeader& other) const;
bool operator!=(const PatchMetaExtendedHeader& 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 getRequiredSystemVersion() const;
void setRequiredSystemVersion(uint32_t sys_ver);
uint32_t getExtendedDataSize() const;
void setExtendedDataSize(uint32_t size);
private:
const std::string kModuleName = "PATCH_META_EXTENDED_HEADER";
// binary blob
fnd::Vec<byte_t> mRawBinary;
// variables
uint64_t mApplicationId;
uint32_t mRequiredSystemVersion;
uint32_t mExtendedDataSize;
};
}
}

View file

@ -0,0 +1,42 @@
#pragma once
#include <string>
#include <vector>
#include <fnd/IByteModel.h>
#include <fnd/List.h>
#include <nn/hac/ServiceAccessControlEntry.h>
namespace nn
{
namespace hac
{
class ServiceAccessControl :
public fnd::IByteModel
{
public:
ServiceAccessControl();
ServiceAccessControl(const ServiceAccessControl& other);
void operator=(const ServiceAccessControl& other);
bool operator==(const ServiceAccessControl& other) const;
bool operator!=(const ServiceAccessControl& 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<ServiceAccessControlEntry>& getServiceList() const;
void setServiceList(const fnd::List<ServiceAccessControlEntry>& list);
private:
const std::string kModuleName = "SERVICE_ACCESS_CONTROL";
// raw binary
fnd::Vec<byte_t> mRawBinary;
// variables
fnd::List<ServiceAccessControlEntry> mServices;
};
}
}

View file

@ -1,42 +0,0 @@
#pragma once
#include <string>
#include <vector>
#include <fnd/ISerialisable.h>
#include <fnd/List.h>
#include <nn/hac/ServiceAccessControlEntry.h>
namespace nn
{
namespace hac
{
class ServiceAccessControlBinary :
public fnd::ISerialisable
{
public:
ServiceAccessControlBinary();
ServiceAccessControlBinary(const ServiceAccessControlBinary& other);
void operator=(const ServiceAccessControlBinary& other);
bool operator==(const ServiceAccessControlBinary& other) const;
bool operator!=(const ServiceAccessControlBinary& other) const;
// export/import binary
void toBytes();
void fromBytes(const byte_t* bytes, size_t len);
const fnd::Vec<byte_t>& getBytes() const;
// variables
void clear();
const fnd::List<ServiceAccessControlEntry>& getServiceList() const;
void addService(const ServiceAccessControlEntry& service);
private:
const std::string kModuleName = "SERVICE_ACCESS_CONTROL_BINARY";
// raw binary
fnd::Vec<byte_t> mRawBinary;
// variables
fnd::List<ServiceAccessControlEntry> mServices;
};
}
}

View file

@ -1,51 +1,51 @@
#pragma once
#include <string>
#include <fnd/types.h>
#include <fnd/ISerialisable.h>
namespace nn
{
namespace hac
{
class ServiceAccessControlEntry :
public fnd::ISerialisable
{
public:
ServiceAccessControlEntry();
ServiceAccessControlEntry(const std::string& name, bool isServer);
ServiceAccessControlEntry(const ServiceAccessControlEntry& other);
void operator=(const ServiceAccessControlEntry& other);
bool operator==(const ServiceAccessControlEntry& other) const;
bool operator!=(const ServiceAccessControlEntry& other) const;
// export/import binary
void toBytes();
void fromBytes(const byte_t* bytes, size_t len);
const fnd::Vec<byte_t>& getBytes() const;
// variables
void clear();
bool isServer() const;
void setIsServer(bool isServer);
const std::string& getName() const;
void setName(const std::string& name);
private:
const std::string kModuleName = "SERVICE_ACCESS_CONTROL_ENTRY";
static const size_t kMaxServiceNameLen = 8;
enum ServiceAccessControlEntryFlag
{
SAC_IS_SERVER = _BIT(7),
SAC_NAME_LEN_MASK = _BIT(7) - 1
};
// raw binary
fnd::Vec<byte_t> mRawBinary;
// variables
bool mIsServer;
std::string mName;
};
}
#pragma once
#include <string>
#include <fnd/types.h>
#include <fnd/IByteModel.h>
namespace nn
{
namespace hac
{
class ServiceAccessControlEntry :
public fnd::IByteModel
{
public:
ServiceAccessControlEntry();
ServiceAccessControlEntry(const std::string& name, bool isServer);
ServiceAccessControlEntry(const ServiceAccessControlEntry& other);
void operator=(const ServiceAccessControlEntry& other);
bool operator==(const ServiceAccessControlEntry& other) const;
bool operator!=(const ServiceAccessControlEntry& other) const;
// IByteModel
void toBytes();
void fromBytes(const byte_t* bytes, size_t len);
const fnd::Vec<byte_t>& getBytes() const;
// variables
void clear();
bool isServer() const;
void setIsServer(bool isServer);
const std::string& getName() const;
void setName(const std::string& name);
private:
const std::string kModuleName = "SERVICE_ACCESS_CONTROL_ENTRY";
static const size_t kMaxServiceNameLen = 8;
enum ServiceAccessControlEntryFlag
{
SAC_IS_SERVER = _BIT(7),
SAC_NAME_LEN_MASK = _BIT(7) - 1
};
// raw binary
fnd::Vec<byte_t> mRawBinary;
// variables
bool mIsServer;
std::string mName;
};
}
}

View file

@ -1,56 +1,56 @@
#pragma once
#include <fnd/types.h>
#include <fnd/rsa.h>
#include <nn/hac/macro.h>
namespace nn
{
namespace hac
{
namespace aci
{
static const uint32_t kAciStructMagic = _MAKE_STRUCT_MAGIC_U32("ACI0");
static const uint32_t kAciDescStructMagic = _MAKE_STRUCT_MAGIC_U32("ACID");
static const size_t kSectionAlignSize = 0x10;
enum Flag
{
FLAG_PRODUCTION,
FLAG_UNQUALIFIED_APPROVAL
};
}
#pragma pack(push,1)
struct sAciSection
{
le_uint32_t offset;
le_uint32_t size;
};
struct sAciHeader
{
le_uint32_t st_magic;
byte_t reserved_00[0xC];
le_uint64_t program_id;
byte_t reserved_01[0x8];
sAciSection fac;
sAciSection sac;
sAciSection kc;
};
struct sAciDescHeader
{
byte_t signature[fnd::rsa::kRsa2048Size];
byte_t nca_rsa_signature2_modulus[fnd::rsa::kRsa2048Size];
le_uint32_t st_magic;
le_uint32_t signed_size;
byte_t reserved_00[0x4];
le_uint32_t flags;
le_uint64_t program_id_min;
le_uint64_t program_id_max;
sAciSection fac;
sAciSection sac;
sAciSection kc;
};
#pragma pack(pop)
}
#pragma once
#include <fnd/types.h>
#include <fnd/rsa.h>
#include <nn/hac/define/macro.h>
namespace nn
{
namespace hac
{
namespace aci
{
static const uint32_t kAciStructMagic = _MAKE_STRUCT_MAGIC_U32("ACI0");
static const uint32_t kAciDescStructMagic = _MAKE_STRUCT_MAGIC_U32("ACID");
static const size_t kSectionAlignSize = 0x10;
enum Flag
{
FLAG_PRODUCTION,
FLAG_UNQUALIFIED_APPROVAL
};
}
#pragma pack(push,1)
struct sAciSection
{
le_uint32_t offset;
le_uint32_t size;
};
struct sAciHeader
{
le_uint32_t st_magic;
byte_t reserved_00[0xC];
le_uint64_t program_id;
byte_t reserved_01[0x8];
sAciSection fac;
sAciSection sac;
sAciSection kc;
};
struct sAciDescHeader
{
byte_t signature[fnd::rsa::kRsa2048Size];
byte_t nca_rsa_signature2_modulus[fnd::rsa::kRsa2048Size];
le_uint32_t st_magic;
le_uint32_t signed_size;
byte_t reserved_00[0x4];
le_uint32_t flags;
le_uint64_t program_id_min;
le_uint64_t program_id_max;
sAciSection fac;
sAciSection sac;
sAciSection kc;
};
#pragma pack(pop)
}
}

View file

@ -1,138 +1,181 @@
#pragma once
#include <fnd/types.h>
#include <fnd/sha.h>
namespace nn
{
namespace hac
{
namespace cnmt
{
enum ContentType
{
TYPE_META = 0,
TYPE_PROGRAM,
TYPE_DATA,
TYPE_CONTROL,
TYPE_HTML_DOCUMENT,
TYPE_LEGAL_INFORMATION,
TYPE_DELTA_FRAGMENT
};
enum ContentMetaType
{
METATYPE_SYSTEM_PROGRAM = 1,
METATYPE_SYSTEM_DATA,
METATYPE_SYSTEM_UPDATE,
METATYPE_BOOT_IMAGE_PACKAGE,
METATYPE_BOOT_IMAGE_PACKAGE_SAFE,
METATYPE_APPLICATION = 0x80,
METATYPE_PATCH, // can have extended data
METATYPE_ADD_ON_CONTENT,
METATYPE_DELTA // can have extended data
};
enum UpdateType
{
UPDATETYPE_APPLY_AS_DELTA,
UPDATETYPE_OVERWRITE,
UPDATETYPE_CREATE
};
enum ContentMetaAttribute
{
ATTRIBUTE_INCLUDES_EX_FAT_DRIVER,
ATTRIBUTE_REBOOTLESS
};
static const uint32_t kRequiredSystemVersion = 335544320;
static const uint32_t kDefaultVersion = 335545344;
static const size_t kContentIdLen = 0x10;
static const size_t kDigestLen = 0x20;
}
#pragma pack(push,1)
/*
struct sContentMeta
{
sContentMetaHeader hdr;
byte_t exhdr[]; // optional
sContentInfo info[];
sContentMetaInfo meta[];
byte_t extdata[];
byte_t digest[32]
};
*/
struct sContentMetaHeader
{
le_uint64_t id;
le_uint32_t version;
byte_t type;
byte_t reserved_0;
le_uint16_t exhdr_size;
le_uint16_t content_count;
le_uint16_t content_meta_count;
byte_t attributes;
byte_t reserved_1[3];
le_uint32_t required_download_system_version;
byte_t reserved_2[4];
};
struct sContentInfo
{
fnd::sha::sSha256Hash content_hash;
byte_t content_id[cnmt::kContentIdLen];
le_uint32_t size_lower;
le_uint16_t size_higher;
byte_t content_type;
byte_t id_offset;
};
struct sContentMetaInfo
{
le_uint64_t id;
le_uint32_t version;
byte_t type;
byte_t attributes;
byte_t reserved[2];
};
struct sApplicationMetaExtendedHeader
{
le_uint64_t patch_id;
le_uint32_t required_system_version;
byte_t reserved[4];
};
struct sPatchMetaExtendedHeader
{
le_uint64_t application_id;
le_uint32_t required_system_version;
le_uint32_t extended_data_size;
byte_t reserved[8];
};
struct sAddOnContentMetaExtendedHeader
{
le_uint64_t application_id;
le_uint32_t required_application_version;
byte_t reserved[4];
};
struct sDeltaMetaExtendedHeader
{
le_uint64_t application_id;
le_uint32_t extended_data_size;
byte_t reserved[4];
};
struct sDigest
{
byte_t data[cnmt::kDigestLen];
};
#pragma pack(pop)
}
#pragma once
#include <fnd/types.h>
#include <fnd/sha.h>
namespace nn
{
namespace hac
{
namespace cnmt
{
enum ContentType
{
TYPE_META = 0,
TYPE_PROGRAM,
TYPE_DATA,
TYPE_CONTROL,
TYPE_HTML_DOCUMENT,
TYPE_LEGAL_INFORMATION,
TYPE_DELTA_FRAGMENT
};
enum ContentMetaType
{
METATYPE_SYSTEM_PROGRAM = 1,
METATYPE_SYSTEM_DATA,
METATYPE_SYSTEM_UPDATE,
METATYPE_BOOT_IMAGE_PACKAGE,
METATYPE_BOOT_IMAGE_PACKAGE_SAFE,
METATYPE_APPLICATION = 0x80,
METATYPE_PATCH, // can have extended data
METATYPE_ADD_ON_CONTENT,
METATYPE_DELTA // can have extended data
};
enum UpdateType
{
UPDATETYPE_APPLY_AS_DELTA,
UPDATETYPE_OVERWRITE,
UPDATETYPE_CREATE
};
enum ContentMetaAttribute
{
ATTRIBUTE_INCLUDES_EX_FAT_DRIVER,
ATTRIBUTE_REBOOTLESS
};
static const size_t kContentIdLen = 0x10;
static const size_t kDigestLen = 0x20;
struct sContentId
{
byte_t data[kContentIdLen];
void set(const byte_t content_id[kContentIdLen])
{
memcpy(this->data, content_id, kContentIdLen);
}
void operator=(const sContentId& other)
{
set(other.data);
}
bool operator==(const sContentId& other) const
{
return memcmp(this->data, other.data, kContentIdLen) == 0;
}
bool operator!=(const sContentId& other) const
{
return !(*this == other);
}
};
struct sDigest
{
byte_t data[kDigestLen];
void set(const byte_t digest[kDigestLen])
{
memcpy(this->data, digest, kDigestLen);
}
void operator=(const sDigest& other)
{
set(other.data);
}
bool operator==(const sDigest& other) const
{
return memcmp(this->data, other.data, kDigestLen) == 0;
}
bool operator!=(const sDigest& other) const
{
return !(*this == other);
}
};
}
#pragma pack(push,1)
/*
struct sContentMeta
{
sContentMetaHeader hdr;
byte_t exhdr[]; // optional
sContentInfo info[];
sContentMetaInfo meta[];
byte_t extdata[];
byte_t digest[32]
};
*/
struct sContentMetaHeader
{
le_uint64_t id;
le_uint32_t version;
byte_t type;
byte_t reserved_0;
le_uint16_t exhdr_size;
le_uint16_t content_count;
le_uint16_t content_meta_count;
byte_t attributes;
byte_t reserved_1[3];
le_uint32_t required_download_system_version;
byte_t reserved_2[4];
};
struct sContentInfo
{
fnd::sha::sSha256Hash content_hash;
cnmt::sContentId content_id;
le_uint32_t size_lower;
le_uint16_t size_higher;
byte_t content_type;
byte_t id_offset;
};
struct sContentMetaInfo
{
le_uint64_t id;
le_uint32_t version;
byte_t type;
byte_t attributes;
byte_t reserved[2];
};
struct sApplicationMetaExtendedHeader
{
le_uint64_t patch_id;
le_uint32_t required_system_version;
byte_t reserved[4];
};
struct sPatchMetaExtendedHeader
{
le_uint64_t application_id;
le_uint32_t required_system_version;
le_uint32_t extended_data_size;
byte_t reserved[8];
};
struct sAddOnContentMetaExtendedHeader
{
le_uint64_t application_id;
le_uint32_t required_application_version;
byte_t reserved[4];
};
struct sDeltaMetaExtendedHeader
{
le_uint64_t application_id;
le_uint32_t extended_data_size;
byte_t reserved[4];
};
#pragma pack(pop)
}
}

View file

@ -1,26 +1,26 @@
#pragma once
#include <fnd/types.h>
#include <nn/hac/macro.h>
namespace nn
{
namespace hac
{
namespace delta
{
static const uint32_t kDeltaStructMagic = _MAKE_STRUCT_MAGIC_U32("NDV0");
}
#pragma pack(push,1)
struct sDeltaHeader
{
le_uint32_t st_magic;
byte_t reserved_00[4];
le_uint64_t source_size;
le_uint64_t destination_size;
le_uint64_t header_size;
le_uint64_t body_size;
byte_t reserved_01[0x18];
};
#pragma pack(pop)
}
}
#pragma once
#include <fnd/types.h>
#include <nn/hac/define/macro.h>
namespace nn
{
namespace hac
{
namespace delta
{
static const uint32_t kDeltaStructMagic = _MAKE_STRUCT_MAGIC_U32("NDV0");
}
#pragma pack(push,1)
struct sDeltaHeader
{
le_uint32_t st_magic;
byte_t reserved_00[4];
le_uint64_t source_size;
le_uint64_t destination_size;
le_uint64_t header_size;
le_uint64_t body_size;
byte_t reserved_01[0x18];
};
#pragma pack(pop)
}
}

View file

@ -1,60 +1,60 @@
#pragma once
#include <fnd/types.h>
namespace nn
{
namespace hac
{
namespace fac
{
static const uint32_t kFacFormatVersion = 1;
static const size_t kSectionAlignSize = 4;
enum FsAccessFlag
{
FSA_APPLICATION_INFO,
FSA_BOOT_MODE_CONTROL,
FSA_CALIBRATION,
FSA_SYSTEM_SAVE_DATA,
FSA_GAME_CARD,
FSA_SAVE_DATA_BACKUP,
FSA_SAVE_DATA_MANAGEMENT,
FSA_BIS_ALL_RAW,
FSA_GAME_CARD_RAW,
FSA_GAME_CARD_PRIVATE,
FSA_SET_TIME,
FSA_CONTENT_MANAGER,
FSA_IMAGE_MANAGER,
FSA_CREATE_SAVE_DATA,
FSA_SYSTEM_SAVE_DATA_MANAGEMENT,
FSA_BIS_FILE_SYSTEM,
FSA_SYSTEM_UPDATE,
FSA_SAVE_DATA_META,
FSA_DEVICE_SAVE_CONTROL,
FSA_SETTINGS_CONTROL,
FSA_DEBUG = 62,
FSA_FULL_PERMISSION = 63,
};
enum SaveDataOwnerIdAccessType
{
SDO_READ = 1,
SDO_WRITE,
SDO_READWRITE
};
}
#pragma pack(push,1)
struct sFacHeader
{
le_uint32_t version; // default 1
le_uint64_t fac_flags;
struct sFacSection
{
le_uint32_t offset;
le_uint32_t size;
} content_owner_ids, save_data_owner_ids; // the data for these follow later in binary. start/end relative to base of FacData instance
};
#pragma pack(pop)
}
#pragma once
#include <fnd/types.h>
namespace nn
{
namespace hac
{
namespace fac
{
static const uint32_t kFacFormatVersion = 1;
static const size_t kSectionAlignSize = 4;
enum FsAccessFlag
{
FSA_APPLICATION_INFO,
FSA_BOOT_MODE_CONTROL,
FSA_CALIBRATION,
FSA_SYSTEM_SAVE_DATA,
FSA_GAME_CARD,
FSA_SAVE_DATA_BACKUP,
FSA_SAVE_DATA_MANAGEMENT,
FSA_BIS_ALL_RAW,
FSA_GAME_CARD_RAW,
FSA_GAME_CARD_PRIVATE,
FSA_SET_TIME,
FSA_CONTENT_MANAGER,
FSA_IMAGE_MANAGER,
FSA_CREATE_SAVE_DATA,
FSA_SYSTEM_SAVE_DATA_MANAGEMENT,
FSA_BIS_FILE_SYSTEM,
FSA_SYSTEM_UPDATE,
FSA_SAVE_DATA_META,
FSA_DEVICE_SAVE_CONTROL,
FSA_SETTINGS_CONTROL,
FSA_DEBUG = 62,
FSA_FULL_PERMISSION = 63,
};
enum SaveDataOwnerIdAccessType
{
SDO_READ = 1,
SDO_WRITE,
SDO_READWRITE
};
}
#pragma pack(push,1)
struct sFacHeader
{
le_uint32_t version; // default 1
le_uint64_t fac_flags;
struct sFacSection
{
le_uint32_t offset;
le_uint32_t size;
} content_owner_ids, save_data_owner_ids; // the data for these follow later in binary. start/end relative to base of FacData instance
};
#pragma pack(pop)
}
}

View file

@ -1,133 +1,133 @@
#pragma once
#include <fnd/types.h>
#include <fnd/List.h>
#include <fnd/aes.h>
#include <fnd/sha.h>
#include <fnd/rsa.h>
#include <nn/hac/macro.h>
namespace nn
{
namespace hac
{
namespace xci
{
static const uint32_t kXciStructMagic = _MAKE_STRUCT_MAGIC_U32("HEAD");
static const uint32_t kHeaderEncOffset = 0x90;
static const uint32_t kHeaderEncSize = 0x70;
static const uint32_t kPageSize = 0x200;
static const uint32_t kUppHashLen = 8;
/*
static const uint32_t kCardKeyAreaPageCount = 8;
static const uint32_t kCardHeaderPageCount = 1;
static const uint32_t kReservedAreaPageCount = 55;
static const uint32_t kCertAreaStartPageAddress = kCardHeaderPageCount + kReservedAreaPageCount + kCardKeyAreaPageCount;
static const uint32_t kCertAreaPageCount = 64;
static const uint32_t kNormalAreaStartPageAddress = kReservedAreaPageCount + kCertAreaPageCount + kCardHeaderPageCount + kCardKeyAreaPageCount;
*/
const std::string kUpdatePartitionStr = "update";
const std::string kLogoPartitionStr = "logo";
const std::string kNormalPartitionStr = "normal";
const std::string kSecurePartitionStr = "secure";
enum KekIndex
{
KEK_XCIE,
KEK_XCIR
};
enum RomSize
{
ROM_SIZE_1GB = 0xFA,
ROM_SIZE_2GB = 0xF8,
ROM_SIZE_4GB = 0xF0,
ROM_SIZE_8GB = 0xE0,
ROM_SIZE_16GB = 0xE1,
ROM_SIZE_32GB = 0xE2
};
enum HeaderFlags
{
FLAG_AUTOBOOT,
FLAG_HISTORY_ERASE,
FLAG_REPAIR_TOOL
};
enum FwVersionIndex
{
FWVER_MINOR,
FWVER_MAJOR
};
enum CardClockRate
{
CLOCK_RATE_25 = 10551312,
CLOCK_RATE_50 = 10551313,
};
}
#pragma pack(push,1)
struct sXciHeader
{
le_uint32_t st_magic;
le_uint32_t rom_area_start_page;
le_uint32_t backup_area_start_page;
byte_t key_flag;
byte_t rom_size;
byte_t card_header_version;
byte_t flags;
le_uint64_t package_id;
le_uint32_t valid_data_end_page;
byte_t reserved_00[4];
fnd::aes::sAesIvCtr aescbc_iv;
le_uint64_t partition_fs_header_address;
le_uint64_t partition_fs_header_size;
fnd::sha::sSha256Hash partition_fs_header_hash;
fnd::sha::sSha256Hash initial_data_hash;
le_uint32_t sel_sec;
le_uint32_t sel_t1_key;
le_uint32_t sel_key;
le_uint32_t lim_area;
// START ENCRYPTION
le_uint32_t fw_version[2];
le_uint32_t acc_ctrl_1;
le_uint32_t wait_1_time_read;
le_uint32_t wait_2_time_read;
le_uint32_t wait_1_time_write;
le_uint32_t wait_2_time_write;
le_uint32_t fw_mode;
le_uint32_t upp_version;
byte_t reserved_01[0x4];
byte_t upp_hash[xci::kUppHashLen];
le_uint64_t upp_id;
byte_t reserved_02[0x38];
// END ENCRYPTION
};
struct sXciHeaderPage
{
byte_t signature[fnd::rsa::kRsa2048Size];
sXciHeader header;
}; // sizeof() = 512 (1 page)
struct sInitialData
{
byte_t key_source[16]; // { package_id[8], zeros[8]}
byte_t title_key_enc[16];
byte_t ccm_mac[16];
byte_t ccm_nonce[12];
byte_t reserved[0x1c4];
}; // sizeof() = 512 (1 page)
struct sKeyDataArea
{
sInitialData initial_data; // AES128-CCM encrypted {titlekey[16]}
byte_t encrypted_00[xci::kPageSize * 6]; // AES128-CTR encrypted {titlekey[16]}
byte_t encrypted_00_aesctr_data[fnd::rsa::kRsa2048Size]; // RSA2048-OAEP-SHA256 encrypted AES-CTR data used for encrypted_00 {key[16],iv[16]}
byte_t reserved[xci::kPageSize - fnd::rsa::kRsa2048Size];
}; // sizeof() = 512*8 (8 pages)
#pragma pack(pop)
}
#pragma once
#include <fnd/types.h>
#include <fnd/List.h>
#include <fnd/aes.h>
#include <fnd/sha.h>
#include <fnd/rsa.h>
#include <nn/hac/define/macro.h>
namespace nn
{
namespace hac
{
namespace gc
{
static const uint32_t kGcHeaderStructMagic = _MAKE_STRUCT_MAGIC_U32("HEAD");
static const uint32_t kHeaderEncOffset = 0x90;
static const uint32_t kHeaderEncSize = 0x70;
static const uint32_t kPageSize = 0x200;
static const uint32_t kUppHashLen = 8;
/*
static const uint32_t kCardKeyAreaPageCount = 8;
static const uint32_t kCardHeaderPageCount = 1;
static const uint32_t kReservedAreaPageCount = 55;
static const uint32_t kCertAreaStartPageAddress = kCardHeaderPageCount + kReservedAreaPageCount + kCardKeyAreaPageCount;
static const uint32_t kCertAreaPageCount = 64;
static const uint32_t kNormalAreaStartPageAddress = kReservedAreaPageCount + kCertAreaPageCount + kCardHeaderPageCount + kCardKeyAreaPageCount;
*/
const std::string kUpdatePartitionStr = "update";
const std::string kLogoPartitionStr = "logo";
const std::string kNormalPartitionStr = "normal";
const std::string kSecurePartitionStr = "secure";
enum KekIndex
{
KEK_XCIE,
KEK_XCIR
};
enum RomSize
{
ROM_SIZE_1GB = 0xFA,
ROM_SIZE_2GB = 0xF8,
ROM_SIZE_4GB = 0xF0,
ROM_SIZE_8GB = 0xE0,
ROM_SIZE_16GB = 0xE1,
ROM_SIZE_32GB = 0xE2
};
enum HeaderFlags
{
FLAG_AUTOBOOT,
FLAG_HISTORY_ERASE,
FLAG_REPAIR_TOOL
};
enum FwVersionIndex
{
FWVER_MINOR,
FWVER_MAJOR
};
enum CardClockRate
{
CLOCK_RATE_25 = 10551312,
CLOCK_RATE_50 = 10551313,
};
}
#pragma pack(push,1)
struct sGcHeader
{
le_uint32_t st_magic;
le_uint32_t rom_area_start_page;
le_uint32_t backup_area_start_page;
byte_t key_flag;
byte_t rom_size;
byte_t card_header_version;
byte_t flags;
le_uint64_t package_id;
le_uint32_t valid_data_end_page;
byte_t reserved_00[4];
fnd::aes::sAesIvCtr aescbc_iv;
le_uint64_t partition_fs_header_address;
le_uint64_t partition_fs_header_size;
fnd::sha::sSha256Hash partition_fs_header_hash;
fnd::sha::sSha256Hash initial_data_hash;
le_uint32_t sel_sec;
le_uint32_t sel_t1_key;
le_uint32_t sel_key;
le_uint32_t lim_area;
// START ENCRYPTION
le_uint32_t fw_version[2];
le_uint32_t acc_ctrl_1;
le_uint32_t wait_1_time_read;
le_uint32_t wait_2_time_read;
le_uint32_t wait_1_time_write;
le_uint32_t wait_2_time_write;
le_uint32_t fw_mode;
le_uint32_t upp_version;
byte_t reserved_01[0x4];
byte_t upp_hash[gc::kUppHashLen];
le_uint64_t upp_id;
byte_t reserved_02[0x38];
// END ENCRYPTION
};
struct sGcHeaderPage
{
byte_t signature[fnd::rsa::kRsa2048Size];
sGcHeader header;
}; // sizeof() = 512 (1 page)
struct sInitialData
{
byte_t key_source[16]; // { package_id[8], zeros[8]}
byte_t title_key_enc[16];
byte_t ccm_mac[16];
byte_t ccm_nonce[12];
byte_t reserved[0x1c4];
}; // sizeof() = 512 (1 page)
struct sKeyDataArea
{
sInitialData initial_data; // AES128-CCM encrypted {titlekey[16]}
byte_t encrypted_00[gc::kPageSize * 6]; // AES128-CTR encrypted {titlekey[16]}
byte_t encrypted_00_aesctr_data[fnd::rsa::kRsa2048Size]; // RSA2048-OAEP-SHA256 encrypted AES-CTR data used for encrypted_00 {key[16],iv[16]}
byte_t reserved[gc::kPageSize - fnd::rsa::kRsa2048Size];
}; // sizeof() = 512*8 (8 pages)
#pragma pack(pop)
}
}

View file

@ -1,35 +1,35 @@
#pragma once
#include <fnd/types.h>
#include <nn/hac/macro.h>
namespace nn
{
namespace hac
{
namespace hierarchicalintegrity
{
static const uint32_t kStructMagic = _MAKE_STRUCT_MAGIC_U32("IVFC");
static const uint32_t kRomfsTypeId = 0x20000;
static const size_t kDefaultLayerNum = 6;
static const size_t kHeaderAlignLen = 0x20;
}
#pragma pack(push,1)
struct sHierarchicalIntegrityHeader
{
le_uint32_t st_magic;
le_uint32_t type_id;
le_uint32_t master_hash_size;
le_uint32_t layer_num;
};
struct sHierarchicalIntegrityLayerInfo // sizeof(0x18)
{
le_uint64_t offset;
le_uint64_t size;
le_uint32_t block_size;
byte_t reserved[4];
};
#pragma pack(pop)
}
#pragma once
#include <fnd/types.h>
#include <nn/hac/define/macro.h>
namespace nn
{
namespace hac
{
namespace hierarchicalintegrity
{
static const uint32_t kStructMagic = _MAKE_STRUCT_MAGIC_U32("IVFC");
static const uint32_t kRomfsTypeId = 0x20000;
static const size_t kDefaultLayerNum = 6;
static const size_t kHeaderAlignLen = 0x20;
}
#pragma pack(push,1)
struct sHierarchicalIntegrityHeader
{
le_uint32_t st_magic;
le_uint32_t type_id;
le_uint32_t master_hash_size;
le_uint32_t layer_num;
};
struct sHierarchicalIntegrityLayerInfo // sizeof(0x18)
{
le_uint64_t offset;
le_uint64_t size;
le_uint32_t block_size;
byte_t reserved[4];
};
#pragma pack(pop)
}
}

View file

@ -1,29 +1,29 @@
#pragma once
#include <fnd/types.h>
#include <fnd/sha.h>
namespace nn
{
namespace hac
{
namespace hierarchicalsha256
{
static const size_t kDefaultLayerNum = 2;
static const size_t kMaxLayerNum = 2;
}
#pragma pack(push,1)
struct sHierarchicalSha256Header
{
fnd::sha::sSha256Hash master_hash;
le_uint32_t hash_block_size;
le_uint32_t layer_num;
struct sLayer
{
le_uint64_t offset;
le_uint64_t size;
} layer[hierarchicalsha256::kMaxLayerNum];
};
#pragma pack(pop)
}
#pragma once
#include <fnd/types.h>
#include <fnd/sha.h>
namespace nn
{
namespace hac
{
namespace hierarchicalsha256
{
static const size_t kDefaultLayerNum = 2;
static const size_t kMaxLayerNum = 2;
}
#pragma pack(push,1)
struct sHierarchicalSha256Header
{
fnd::sha::sSha256Hash master_hash;
le_uint32_t hash_block_size;
le_uint32_t layer_num;
struct sLayer
{
le_uint64_t offset;
le_uint64_t size;
} layer[hierarchicalsha256::kMaxLayerNum];
};
#pragma pack(pop)
}
}

View file

@ -1,27 +1,27 @@
#pragma once
#include <fnd/types.h>
#include <fnd/rsa.h>
#include <nn/hac/macro.h>
namespace nn
{
namespace hac
{
namespace kc
{
enum KernelCapId
{
KC_INVALID = 0,
KC_THREAD_INFO = 3,
KC_ENABLE_SYSTEM_CALLS = 4,
KC_MEMORY_MAP = 6,
KC_IO_MEMORY_MAP = 7,
KC_ENABLE_INTERUPTS = 11,
KC_MISC_PARAMS = 13,
KC_KERNEL_VERSION = 14,
KC_HANDLE_TABLE_SIZE = 15,
KC_MISC_FLAGS = 16
};
}
}
#pragma once
#include <fnd/types.h>
#include <fnd/rsa.h>
#include <nn/hac/define/macro.h>
namespace nn
{
namespace hac
{
namespace kc
{
enum KernelCapId
{
KC_INVALID = 0,
KC_THREAD_INFO = 3,
KC_ENABLE_SYSTEM_CALLS = 4,
KC_MEMORY_MAP = 6,
KC_IO_MEMORY_MAP = 7,
KC_ENABLE_INTERUPTS = 11,
KC_MISC_PARAMS = 13,
KC_KERNEL_VERSION = 14,
KC_HANDLE_TABLE_SIZE = 15,
KC_MISC_FLAGS = 16
};
}
}
}

View file

@ -1,5 +1,5 @@
#pragma once
#include <cstdint>
#define _MAKE_STRUCT_MAGIC_U32(x) ((uint32_t)(x[3]) << 24 | (uint32_t)(x[2]) << 16 | (uint32_t)(x[1]) << 8 | (uint32_t)(x[0]))
#define _MAKE_STRUCT_MAGIC_U64(x) ((uint64_t)(x[7]) << 56 | (uint64_t)(x[6]) << 48 | (uint64_t)(x[5]) << 40 | (uint64_t)(x[4]) << 32 | (uint64_t)(x[3]) << 24 | (uint64_t)(x[2]) << 16 | (uint64_t)(x[1]) << 8 | (uint64_t)(x[0]))
#pragma once
#include <cstdint>
#define _MAKE_STRUCT_MAGIC_U32(x) ((uint32_t)(x[3]) << 24 | (uint32_t)(x[2]) << 16 | (uint32_t)(x[1]) << 8 | (uint32_t)(x[0]))
#define _MAKE_STRUCT_MAGIC_U64(x) ((uint64_t)(x[7]) << 56 | (uint64_t)(x[6]) << 48 | (uint64_t)(x[5]) << 40 | (uint64_t)(x[4]) << 32 | (uint64_t)(x[3]) << 24 | (uint64_t)(x[2]) << 16 | (uint64_t)(x[1]) << 8 | (uint64_t)(x[0]))

View file

@ -1,58 +1,58 @@
#pragma once
#include <fnd/types.h>
#include <nn/hac/macro.h>
namespace nn
{
namespace hac
{
namespace meta
{
static const uint32_t kMetaStructMagic = _MAKE_STRUCT_MAGIC_U32("META");
static const size_t kNameMaxLen = 0x10;
static const size_t kProductCodeMaxLen = 0x10;
static const uint32_t kMaxPriority = BIT(6) - 1;
static const size_t kSectionAlignSize = 0x10;
static const uint32_t kDefaultMainThreadStackSize = 4096;
enum InstructionType
{
INSTR_32BIT,
INSTR_64BIT,
};
enum ProcAddrSpaceType
{
ADDR_SPACE_64BIT = 1,
ADDR_SPACE_32BIT,
ADDR_SPACE_32BIT_NO_RESERVED,
};
}
#pragma pack(push,1)
struct sMetaSection
{
le_uint32_t offset;
le_uint32_t size;
};
struct sMetaHeader
{
le_uint32_t st_magic;
byte_t reserved_0[8];
byte_t flags;
byte_t reserved_1;
byte_t main_thread_priority;
byte_t main_thread_cpu_id;
byte_t reserved_2[8];
le_uint32_t version;
le_uint32_t main_thread_stack_size;
char name[meta::kNameMaxLen]; // important
char product_code[meta::kProductCodeMaxLen]; // can be empty
byte_t reserved_3[48];
sMetaSection aci;
sMetaSection acid;
};
#pragma pack(pop)
}
#pragma once
#include <fnd/types.h>
#include <nn/hac/define/macro.h>
namespace nn
{
namespace hac
{
namespace meta
{
static const uint32_t kMetaStructMagic = _MAKE_STRUCT_MAGIC_U32("META");
static const size_t kNameMaxLen = 0x10;
static const size_t kProductCodeMaxLen = 0x10;
static const uint32_t kMaxPriority = BIT(6) - 1;
static const size_t kSectionAlignSize = 0x10;
static const uint32_t kDefaultMainThreadStackSize = 4096;
enum InstructionType
{
INSTR_32BIT,
INSTR_64BIT,
};
enum ProcAddrSpaceType
{
ADDR_SPACE_64BIT = 1,
ADDR_SPACE_32BIT,
ADDR_SPACE_32BIT_NO_RESERVED,
};
}
#pragma pack(push,1)
struct sMetaSection
{
le_uint32_t offset;
le_uint32_t size;
};
struct sMetaHeader
{
le_uint32_t st_magic;
byte_t reserved_0[8];
byte_t flags;
byte_t reserved_1;
byte_t main_thread_priority;
byte_t main_thread_cpu_id;
byte_t reserved_2[8];
le_uint32_t version;
le_uint32_t main_thread_stack_size;
char name[meta::kNameMaxLen]; // important
char product_code[meta::kProductCodeMaxLen]; // can be empty
byte_t reserved_3[48];
sMetaSection aci;
sMetaSection acid;
};
#pragma pack(pop)
}
}

View file

@ -1,223 +1,223 @@
#pragma once
#include <fnd/types.h>
namespace nn
{
namespace hac
{
namespace nacp
{
static const size_t kNameLength = 0x200;
static const size_t kPublisherLength = 0x100;
static const size_t kMaxLanguageCount = 16;
static const size_t kIsbnLength = 37;
static const size_t kRatingAgeCount = 32;
static const size_t kDisplayVersionLength = 16;
static const size_t kApplicationErrorCodeCategoryLength = 8;
static const size_t kLocalCommunicationIdCount = 8;
static const size_t kBcatPassphraseLength = 65;
static const size_t kPlayLogQueryableApplicationIdCount = 16;
static const int8_t kUnusedAgeRating = -1;
enum AocRegistrationType
{
AOC_AllOnLaunch,
AOC_OnDemand
};
enum AttributeFlag
{
ATTR_None,
ATTR_Demo,
ATTR_RetailInteractiveDisplay
};
enum CrashReportMode
{
CREP_Deny,
CREP_Allow
};
enum DataLossConfirmation
{
DLOSS_None,
DLOSS_Required
};
enum Hdcp
{
HDCP_None,
HDCP_Required
};
enum Language
{
LANG_AmericanEnglish,
LANG_BritishEnglish,
LANG_Japanese,
LANG_French,
LANG_German,
LANG_LatinAmericanSpanish,
LANG_Spanish,
LANG_Italian,
LANG_Dutch,
LANG_CanadianFrench,
LANG_Portuguese,
LANG_Russian,
LANG_Korean,
LANG_TraditionalChinese,
LANG_SimplifiedChinese
};
enum LogoHandling
{
LHND_Auto,
LHND_None
};
enum LogoType
{
LOGO_LicensedByNintendo,
LOGO_DistributedByNintendo,
LOGO_Nintendo
};
enum Organisation
{
ORGN_CERO,
ORGN_GRACGCRB,
ORGN_GSRMR,
ORGN_ESRB,
ORGN_ClassInd,
ORGN_USK,
ORGN_PEGI,
ORGN_PEGIPortugal,
ORGN_PEGIBBFC,
ORGN_Russian,
ORGN_ACB,
ORGN_OFLC
};
enum ParentalControlFlag
{
PC_None,
PC_FreeCommunication
};
enum PlayLogPolicy
{
PLP_All,
PLP_LogOnly,
PLP_None
};
enum PlayLogQueryCapability
{
PLQC_None,
PLQC_Whitelist,
PLQC_All
};
enum RepairFlag
{
REPF_None,
REPF_SuppressGameCardAccess
};
enum RuntimeAocInstallMode
{
RTAOC_Deny,
RTAOC_AllowAppend
};
enum ScreenshotMode
{
SCRN_Allow,
SCRN_Deny
};
enum StartupUserAccount
{
USER_None,
USER_Required,
USER_RequiredWithNetworkServiceAccountAvailable
};
enum TouchScreenUsageMode
{
TOUCH_None,
TOUCH_Supported,
TOUCH_Required,
};
enum VideoCaptureMode
{
VCAP_Disable,
VCAP_Manual,
VCAP_Enable
};
}
#pragma pack(push,1)
struct sApplicationTitle
{
char name[nacp::kNameLength];
char publisher[nacp::kPublisherLength];
};
struct sApplicationControlProperty
{
sApplicationTitle title[nacp::kMaxLanguageCount];
char isbn[nacp::kIsbnLength];
byte_t startup_user_account;
byte_t touch_screen_usage;
byte_t add_on_content_registration_type;
le_uint32_t attribute_flag;
le_uint32_t supported_language_flag;
le_uint32_t parental_control_flag;
byte_t screenshot;
byte_t video_capture;
byte_t data_loss_confirmation;
byte_t play_log_policy;
le_uint64_t presence_group_id;
int8_t rating_age[nacp::kRatingAgeCount];
char display_version[nacp::kDisplayVersionLength];
le_uint64_t add_on_content_base_id;
le_uint64_t save_data_owner_id;
le_uint64_t user_account_save_data_size;
le_uint64_t user_account_save_data_journal_size;
le_uint64_t device_save_data_size;
le_uint64_t device_save_data_journal_size;
le_uint64_t bcat_delivery_cache_storage_size;
char application_error_code_category[nacp::kApplicationErrorCodeCategoryLength];
le_uint64_t local_communication_id[nacp::kLocalCommunicationIdCount];
byte_t logo_type;
byte_t logo_handling;
byte_t runtime_add_on_content_install;
byte_t reserved_00[3];
byte_t crash_report;
byte_t hdcp;
le_uint64_t seed_for_pseudo_device_id;
char bcat_passphrase[nacp::kBcatPassphraseLength];
byte_t reserved_01;
byte_t reserved_02[6]; //reserved_for_user_account_save_data_operation
le_uint64_t user_account_save_data_size_max;
le_uint64_t user_account_save_data_journal_size_max;
le_uint64_t device_save_data_size_max;
le_uint64_t device_save_data_journal_size_max;
le_uint64_t temporary_storage_size;
le_uint64_t cache_storage_size;
le_uint64_t cache_storage_journal_size;
le_uint64_t cache_storage_data_and_journal_size_max;
le_uint16_t cache_storage_index_max;
byte_t reserved_03[6];
le_uint64_t play_log_queryable_application_id[nacp::kPlayLogQueryableApplicationIdCount];
byte_t play_log_query_capability;
byte_t repair_flag;
byte_t program_index;
byte_t reserved_04[0xDED];
};
#pragma pack(pop)
}
#pragma once
#include <fnd/types.h>
namespace nn
{
namespace hac
{
namespace nacp
{
static const size_t kNameLength = 0x200;
static const size_t kPublisherLength = 0x100;
static const size_t kMaxLanguageCount = 16;
static const size_t kIsbnLength = 37;
static const size_t kRatingAgeCount = 32;
static const size_t kDisplayVersionLength = 16;
static const size_t kApplicationErrorCodeCategoryLength = 8;
static const size_t kLocalCommunicationIdCount = 8;
static const size_t kBcatPassphraseLength = 65;
static const size_t kPlayLogQueryableApplicationIdCount = 16;
static const int8_t kUnusedAgeRating = -1;
enum AocRegistrationType
{
AOC_AllOnLaunch,
AOC_OnDemand
};
enum AttributeFlag
{
ATTR_None,
ATTR_Demo,
ATTR_RetailInteractiveDisplay
};
enum CrashReportMode
{
CREP_Deny,
CREP_Allow
};
enum DataLossConfirmation
{
DLOSS_None,
DLOSS_Required
};
enum Hdcp
{
HDCP_None,
HDCP_Required
};
enum Language
{
LANG_AmericanEnglish,
LANG_BritishEnglish,
LANG_Japanese,
LANG_French,
LANG_German,
LANG_LatinAmericanSpanish,
LANG_Spanish,
LANG_Italian,
LANG_Dutch,
LANG_CanadianFrench,
LANG_Portuguese,
LANG_Russian,
LANG_Korean,
LANG_TraditionalChinese,
LANG_SimplifiedChinese
};
enum LogoHandling
{
LHND_Auto,
LHND_None
};
enum LogoType
{
LOGO_LicensedByNintendo,
LOGO_DistributedByNintendo,
LOGO_Nintendo
};
enum Organisation
{
ORGN_CERO,
ORGN_GRACGCRB,
ORGN_GSRMR,
ORGN_ESRB,
ORGN_ClassInd,
ORGN_USK,
ORGN_PEGI,
ORGN_PEGIPortugal,
ORGN_PEGIBBFC,
ORGN_Russian,
ORGN_ACB,
ORGN_OFLC
};
enum ParentalControlFlag
{
PC_None,
PC_FreeCommunication
};
enum PlayLogPolicy
{
PLP_All,
PLP_LogOnly,
PLP_None
};
enum PlayLogQueryCapability
{
PLQC_None,
PLQC_Whitelist,
PLQC_All
};
enum RepairFlag
{
REPF_None,
REPF_SuppressGameCardAccess
};
enum RuntimeAocInstallMode
{
RTAOC_Deny,
RTAOC_AllowAppend
};
enum ScreenshotMode
{
SCRN_Allow,
SCRN_Deny
};
enum StartupUserAccount
{
USER_None,
USER_Required,
USER_RequiredWithNetworkServiceAccountAvailable
};
enum TouchScreenUsageMode
{
TOUCH_None,
TOUCH_Supported,
TOUCH_Required,
};
enum VideoCaptureMode
{
VCAP_Disable,
VCAP_Manual,
VCAP_Enable
};
}
#pragma pack(push,1)
struct sApplicationTitle
{
char name[nacp::kNameLength];
char publisher[nacp::kPublisherLength];
};
struct sApplicationControlProperty
{
sApplicationTitle title[nacp::kMaxLanguageCount];
char isbn[nacp::kIsbnLength];
byte_t startup_user_account;
byte_t touch_screen_usage;
byte_t add_on_content_registration_type;
le_uint32_t attribute_flag;
le_uint32_t supported_language_flag;
le_uint32_t parental_control_flag;
byte_t screenshot;
byte_t video_capture;
byte_t data_loss_confirmation;
byte_t play_log_policy;
le_uint64_t presence_group_id;
int8_t rating_age[nacp::kRatingAgeCount];
char display_version[nacp::kDisplayVersionLength];
le_uint64_t add_on_content_base_id;
le_uint64_t save_data_owner_id;
le_uint64_t user_account_save_data_size;
le_uint64_t user_account_save_data_journal_size;
le_uint64_t device_save_data_size;
le_uint64_t device_save_data_journal_size;
le_uint64_t bcat_delivery_cache_storage_size;
char application_error_code_category[nacp::kApplicationErrorCodeCategoryLength];
le_uint64_t local_communication_id[nacp::kLocalCommunicationIdCount];
byte_t logo_type;
byte_t logo_handling;
byte_t runtime_add_on_content_install;
byte_t reserved_00[3];
byte_t crash_report;
byte_t hdcp;
le_uint64_t seed_for_pseudo_device_id;
char bcat_passphrase[nacp::kBcatPassphraseLength];
byte_t reserved_01;
byte_t reserved_02[6]; //reserved_for_user_account_save_data_operation
le_uint64_t user_account_save_data_size_max;
le_uint64_t user_account_save_data_journal_size_max;
le_uint64_t device_save_data_size_max;
le_uint64_t device_save_data_journal_size_max;
le_uint64_t temporary_storage_size;
le_uint64_t cache_storage_size;
le_uint64_t cache_storage_journal_size;
le_uint64_t cache_storage_data_and_journal_size_max;
le_uint16_t cache_storage_index_max;
byte_t reserved_03[6];
le_uint64_t play_log_queryable_application_id[nacp::kPlayLogQueryableApplicationIdCount];
byte_t play_log_query_capability;
byte_t repair_flag;
byte_t program_index;
byte_t reserved_04[0xDED];
};
#pragma pack(pop)
}
}

View file

@ -1,137 +1,144 @@
#pragma once
#include <fnd/types.h>
#include <fnd/aes.h>
#include <fnd/sha.h>
#include <fnd/rsa.h>
#include <nn/hac/macro.h>
namespace nn
{
namespace hac
{
namespace nca
{
static const uint32_t kNca2StructMagic = _MAKE_STRUCT_MAGIC_U32("NCA2");
static const uint32_t kNca3StructMagic = _MAKE_STRUCT_MAGIC_U32("NCA3");
static const size_t kSectorSize = 0x200;
static const size_t kPartitionNum = 4;
static const size_t kHeaderSectorNum = 6;
static const size_t kHeaderSize = kSectorSize * kHeaderSectorNum;
static const size_t kAesKeyNum = 16;
static const size_t kRightsIdLen = 0x10;
static const size_t kKeyAreaEncryptionKeyNum = 3;
static const size_t kFsHeaderHashSuperblockLen = 0x138;
static const uint16_t kDefaultFsHeaderVersion = 2;
enum ProgramPartitionId
{
PARTITION_CODE,
PARTITION_DATA,
PARTITION_LOGO,
};
enum DistributionType
{
DIST_DOWNLOAD,
DIST_GAME_CARD
};
enum ContentType
{
TYPE_PROGRAM,
TYPE_META,
TYPE_CONTROL,
TYPE_MANUAL,
TYPE_DATA,
TYPE_PUBLIC_DATA
};
enum KeyBankIndex
{
KEY_AESXTS_0,
KEY_AESXTS_1,
KEY_AESCTR,
KEY_UNUSED_3,
KEY_AESCTR_HW
};
enum KeyAreaEncryptionKeyIndex
{
KAEK_IDX_APPLICATION,
KAEK_IDX_OCEAN,
KAEK_IDX_SYSTEM
};
enum FormatType
{
FORMAT_ROMFS,
FORMAT_PFS0
};
enum HashType
{
HASH_AUTO,
HASH_NONE,
HASH_HIERARCHICAL_SHA256,
HASH_HIERARCHICAL_INTERGRITY // IVFC
};
enum EncryptionType
{
CRYPT_AUTO,
CRYPT_NONE,
CRYPT_AESXTS,
CRYPT_AESCTR,
CRYPT_AESCTREX
};
}
#pragma pack(push,1)
struct sNcaHeader
{
le_uint32_t st_magic;
byte_t distribution_type;
byte_t content_type;
byte_t key_generation;
byte_t key_area_encryption_key_index;
le_uint64_t content_size;
le_uint64_t program_id;
le_uint32_t content_index;
le_uint32_t sdk_addon_version;
byte_t key_generation_2;
byte_t reserved_2[0xf];
byte_t rights_id[nca::kRightsIdLen];
struct sNcaSection
{
le_uint32_t start; // block units
le_uint32_t end; // block units
byte_t enabled;
byte_t reserved[7];
} partition[nca::kPartitionNum];
fnd::sha::sSha256Hash partition_hash[nca::kPartitionNum];
fnd::aes::sAes128Key enc_aes_key[nca::kAesKeyNum];
};
struct sNcaFsHeader
{
le_uint16_t version;
byte_t format_type;
byte_t hash_type;
byte_t encryption_type;
byte_t reserved_0[3];
byte_t hash_superblock[nca::kFsHeaderHashSuperblockLen];
byte_t aes_ctr_upper[8];
byte_t reserved_1[0xB8];
};
struct sNcaHeaderBlock
{
byte_t signature_main[fnd::rsa::kRsa2048Size];
byte_t signature_acid[fnd::rsa::kRsa2048Size];
sNcaHeader header;
sNcaFsHeader fs_header[nn::hac::nca::kPartitionNum];
};
#pragma pack(pop)
}
#pragma once
#include <fnd/types.h>
#include <fnd/aes.h>
#include <fnd/sha.h>
#include <fnd/rsa.h>
#include <nn/hac/define/macro.h>
namespace nn
{
namespace hac
{
namespace nca
{
static const uint32_t kNca2StructMagic = _MAKE_STRUCT_MAGIC_U32("NCA2");
static const uint32_t kNca3StructMagic = _MAKE_STRUCT_MAGIC_U32("NCA3");
static const size_t kSectorSize = 0x200;
static const size_t kPartitionNum = 4;
static const size_t kHeaderSectorNum = 6;
static const size_t kHeaderSize = kSectorSize * kHeaderSectorNum;
static const size_t kRightsIdLen = 0x10;
static const size_t kKeyAreaSize = 0x100;
static const size_t kKeyAreaKeyNum = kKeyAreaSize / fnd::aes::kAes128KeySize;
static const size_t kKeyAreaEncryptionKeyNum = 3;
static const size_t kFsHeaderHashSuperblockLen = 0x138;
static const uint16_t kDefaultFsHeaderVersion = 2;
enum HeaderFormatVersion
{
FORMAT_NCA2 = 2,
FORMAT_NCA3 = 3
};
enum ProgramContentPartitionIndex
{
PARTITION_CODE = 0,
PARTITION_DATA = 1,
PARTITION_LOGO = 2,
};
enum DistributionType
{
DIST_DOWNLOAD,
DIST_GAME_CARD
};
enum ContentType
{
TYPE_PROGRAM,
TYPE_META,
TYPE_CONTROL,
TYPE_MANUAL,
TYPE_DATA,
TYPE_PUBLIC_DATA
};
enum KeyBankIndex
{
KEY_AESXTS_0,
KEY_AESXTS_1,
KEY_AESCTR,
KEY_UNUSED_3,
KEY_AESCTR_HW
};
enum KeyAreaEncryptionKeyIndex
{
KAEK_IDX_APPLICATION,
KAEK_IDX_OCEAN,
KAEK_IDX_SYSTEM
};
enum FormatType
{
FORMAT_ROMFS,
FORMAT_PFS0
};
enum HashType
{
HASH_AUTO,
HASH_NONE,
HASH_HIERARCHICAL_SHA256,
HASH_HIERARCHICAL_INTERGRITY // IVFC
};
enum EncryptionType
{
CRYPT_AUTO,
CRYPT_NONE,
CRYPT_AESXTS,
CRYPT_AESCTR,
CRYPT_AESCTREX
};
}
#pragma pack(push,1)
struct sContentArchiveHeader
{
le_uint32_t st_magic;
byte_t distribution_type;
byte_t content_type;
byte_t key_generation;
byte_t key_area_encryption_key_index;
le_uint64_t content_size;
le_uint64_t program_id;
le_uint32_t content_index;
le_uint32_t sdk_addon_version;
byte_t key_generation_2;
byte_t reserved_2[0xf];
byte_t rights_id[nca::kRightsIdLen];
struct sPartitionEntry
{
le_uint32_t start_blk; // block units
le_uint32_t end_blk; // block units
byte_t enabled;
byte_t reserved[7];
} partition_entry[nca::kPartitionNum];
fnd::sha::sSha256Hash fs_header_hash[nca::kPartitionNum];
byte_t key_area[nca::kKeyAreaSize];
};
struct sNcaFsHeader
{
le_uint16_t version;
byte_t format_type;
byte_t hash_type;
byte_t encryption_type;
byte_t reserved_0[3];
byte_t hash_superblock[nca::kFsHeaderHashSuperblockLen];
byte_t aes_ctr_upper[8];
byte_t reserved_1[0xB8];
};
struct sContentArchiveHeaderBlock
{
byte_t signature_main[fnd::rsa::kRsa2048Size];
byte_t signature_acid[fnd::rsa::kRsa2048Size];
sContentArchiveHeader header;
sNcaFsHeader fs_header[nn::hac::nca::kPartitionNum];
};
#pragma pack(pop)
}
}

View file

@ -1,45 +1,45 @@
#pragma once
#include <fnd/types.h>
#include <nn/hac/macro.h>
namespace nn
{
namespace hac
{
namespace nro
{
static const uint32_t kNroStructMagic = _MAKE_STRUCT_MAGIC_U32("NRO0");
static const uint32_t kDefaultFormatVersion = 0;
static const size_t kRoCrtSize = 8;
static const size_t kModuleIdSize = 32;
}
#pragma pack(push,1)
struct sNroSection
{
le_uint32_t memory_offset;
le_uint32_t size;
};
struct sNroHeader
{
byte_t ro_crt[nro::kRoCrtSize];
byte_t reserved_0[8];
le_uint32_t st_magic;
le_uint32_t format_version;
le_uint32_t size;
le_uint32_t flags;
sNroSection text;
sNroSection ro;
sNroSection data;
le_uint32_t bss_size;
byte_t reserved_1[4];
byte_t module_id[nro::kModuleIdSize];
byte_t reserved_2[8];
sNroSection embedded;
sNroSection dyn_str;
sNroSection dyn_sym;
};
#pragma pack(pop)
}
#pragma once
#include <fnd/types.h>
#include <nn/hac/define/macro.h>
namespace nn
{
namespace hac
{
namespace nro
{
static const uint32_t kNroStructMagic = _MAKE_STRUCT_MAGIC_U32("NRO0");
static const uint32_t kDefaultFormatVersion = 0;
static const size_t kRoCrtSize = 8;
static const size_t kModuleIdSize = 32;
}
#pragma pack(push,1)
struct sNroSection
{
le_uint32_t memory_offset;
le_uint32_t size;
};
struct sNroHeader
{
byte_t ro_crt[nro::kRoCrtSize];
byte_t reserved_0[8];
le_uint32_t st_magic;
le_uint32_t format_version;
le_uint32_t size;
le_uint32_t flags;
sNroSection text;
sNroSection ro;
sNroSection data;
le_uint32_t bss_size;
byte_t reserved_1[4];
byte_t module_id[nro::kModuleIdSize];
byte_t reserved_2[8];
sNroSection embedded;
sNroSection dyn_str;
sNroSection dyn_sym;
};
#pragma pack(pop)
}
}

View file

@ -1,39 +1,39 @@
#pragma once
#include <fnd/types.h>
#include <fnd/rsa.h>
#include <nn/hac/macro.h>
namespace nn
{
namespace hac
{
namespace nrr
{
static const uint32_t kNrrStructMagic = _MAKE_STRUCT_MAGIC_U32("NRR0");
}
#pragma pack(push,1)
struct sNrrCertificate
{
le_uint64_t application_id_mask;
le_uint64_t application_id_pattern;
byte_t nrr_body_modulus[fnd::rsa::kRsa2048Size];
byte_t nrr_cert_signature[fnd::rsa::kRsa2048Size];
};
struct sNrrHeader
{
le_uint32_t st_magic;
byte_t reserved_0[28];
sNrrCertificate certificate;
byte_t nrr_body_signature[fnd::rsa::kRsa2048Size];
le_uint64_t application_id;
le_uint32_t size;
byte_t reserved_1[4];
le_uint32_t hash_offset;
le_uint32_t hash_count;
byte_t reserved_2[8];
};
#pragma pack(pop)
}
#pragma once
#include <fnd/types.h>
#include <fnd/rsa.h>
#include <nn/hac/define/macro.h>
namespace nn
{
namespace hac
{
namespace nrr
{
static const uint32_t kNrrStructMagic = _MAKE_STRUCT_MAGIC_U32("NRR0");
}
#pragma pack(push,1)
struct sNrrCertificate
{
le_uint64_t application_id_mask;
le_uint64_t application_id_pattern;
byte_t nrr_body_modulus[fnd::rsa::kRsa2048Size];
byte_t nrr_cert_signature[fnd::rsa::kRsa2048Size];
};
struct sNrrHeader
{
le_uint32_t st_magic;
byte_t reserved_0[28];
sNrrCertificate certificate;
byte_t nrr_body_signature[fnd::rsa::kRsa2048Size];
le_uint64_t application_id;
le_uint32_t size;
byte_t reserved_1[4];
le_uint32_t hash_offset;
le_uint32_t hash_count;
byte_t reserved_2[8];
};
#pragma pack(pop)
}
}

View file

@ -1,68 +1,68 @@
#pragma once
#include <fnd/types.h>
#include <fnd/sha.h>
#include <nn/hac/macro.h>
namespace nn
{
namespace hac
{
namespace nso
{
static const uint32_t kNsoStructMagic = _MAKE_STRUCT_MAGIC_U32("NSO0");
static const uint32_t kDefaultFormatVersion = 0;
static const size_t kModuleIdSize = 32;
enum HeaderFlags
{
FLAG_TEXT_COMPRESS,
FLAG_RO_COMPRESS,
FLAG_DATA_COMPRESS,
FLAG_TEXT_HASH,
FLAG_RO_HASH,
FLAG_DATA_HASH
};
}
#pragma pack(push,1)
struct sNsoCodeSegment
{
le_uint32_t file_offset;
le_uint32_t memory_offset;
le_uint32_t size;
};
struct sNsoSection
{
le_uint32_t offset;
le_uint32_t size;
};
struct sNsoHeader
{
le_uint32_t st_magic;
le_uint32_t format_version;
byte_t reserved_1[4];
le_uint32_t flags;
sNsoCodeSegment text;
le_uint32_t module_name_offset;
sNsoCodeSegment ro;
le_uint32_t module_name_size;
sNsoCodeSegment data;
le_uint32_t bss_size;
byte_t module_id[nso::kModuleIdSize];
le_uint32_t text_file_size;
le_uint32_t ro_file_size;
le_uint32_t data_file_size;
byte_t reserved_2[28];
sNsoSection embedded;
sNsoSection dyn_str;
sNsoSection dyn_sym;
fnd::sha::sSha256Hash text_hash;
fnd::sha::sSha256Hash ro_hash;
fnd::sha::sSha256Hash data_hash;
};
#pragma pack(pop)
}
#pragma once
#include <fnd/types.h>
#include <fnd/sha.h>
#include <nn/hac/define/macro.h>
namespace nn
{
namespace hac
{
namespace nso
{
static const uint32_t kNsoStructMagic = _MAKE_STRUCT_MAGIC_U32("NSO0");
static const uint32_t kDefaultFormatVersion = 0;
static const size_t kModuleIdSize = 32;
enum HeaderFlags
{
FLAG_TEXT_COMPRESS,
FLAG_RO_COMPRESS,
FLAG_DATA_COMPRESS,
FLAG_TEXT_HASH,
FLAG_RO_HASH,
FLAG_DATA_HASH
};
}
#pragma pack(push,1)
struct sNsoCodeSegment
{
le_uint32_t file_offset;
le_uint32_t memory_offset;
le_uint32_t size;
};
struct sNsoSection
{
le_uint32_t offset;
le_uint32_t size;
};
struct sNsoHeader
{
le_uint32_t st_magic;
le_uint32_t format_version;
byte_t reserved_1[4];
le_uint32_t flags;
sNsoCodeSegment text;
le_uint32_t module_name_offset;
sNsoCodeSegment ro;
le_uint32_t module_name_size;
sNsoCodeSegment data;
le_uint32_t bss_size;
byte_t module_id[nso::kModuleIdSize];
le_uint32_t text_file_size;
le_uint32_t ro_file_size;
le_uint32_t data_file_size;
byte_t reserved_2[28];
sNsoSection embedded;
sNsoSection dyn_str;
sNsoSection dyn_sym;
fnd::sha::sSha256Hash text_hash;
fnd::sha::sSha256Hash ro_hash;
fnd::sha::sSha256Hash data_hash;
};
#pragma pack(pop)
}
}

View file

@ -1,45 +1,45 @@
#pragma once
#include <fnd/types.h>
#include <fnd/sha.h>
#include <nn/hac/macro.h>
namespace nn
{
namespace hac
{
namespace pfs
{
static const uint32_t kPfsStructMagic = _MAKE_STRUCT_MAGIC_U32("PFS0");
static const uint32_t kHashedPfsStructMagic = _MAKE_STRUCT_MAGIC_U32("HFS0");
static const size_t kHeaderAlign = 64;
}
#pragma pack(push,1)
struct sPfsHeader
{
le_uint32_t st_magic;
le_uint32_t file_num;
le_uint32_t name_table_size;
byte_t padding[4];
};
struct sPfsFile
{
le_uint64_t data_offset;
le_uint64_t size;
le_uint32_t name_offset;
byte_t padding[4];
}; // sizeof(0x18)
struct sHashedPfsFile
{
le_uint64_t data_offset;
le_uint64_t size;
le_uint32_t name_offset;
le_uint32_t hash_protected_size;
byte_t padding[8];
fnd::sha::sSha256Hash hash;
}; // sizeof(0x40)
#pragma pack(pop)
}
#pragma once
#include <fnd/types.h>
#include <fnd/sha.h>
#include <nn/hac/define/macro.h>
namespace nn
{
namespace hac
{
namespace pfs
{
static const uint32_t kPfsStructMagic = _MAKE_STRUCT_MAGIC_U32("PFS0");
static const uint32_t kHashedPfsStructMagic = _MAKE_STRUCT_MAGIC_U32("HFS0");
static const size_t kHeaderAlign = 64;
}
#pragma pack(push,1)
struct sPfsHeader
{
le_uint32_t st_magic;
le_uint32_t file_num;
le_uint32_t name_table_size;
byte_t padding[4];
};
struct sPfsFile
{
le_uint64_t data_offset;
le_uint64_t size;
le_uint32_t name_offset;
byte_t padding[4];
}; // sizeof(0x18)
struct sHashedPfsFile
{
le_uint64_t data_offset;
le_uint64_t size;
le_uint32_t name_offset;
le_uint32_t hash_protected_size;
byte_t padding[8];
fnd::sha::sSha256Hash hash;
}; // sizeof(0x40)
#pragma pack(pop)
}
}

View file

@ -1,60 +1,60 @@
#pragma once
#include <fnd/types.h>
namespace nn
{
namespace hac
{
namespace romfs
{
static const uint64_t kRomfsHeaderAlign = 0x200;
static const uint32_t kInvalidAddr = 0xffffffff;
enum HeaderSectionIndex
{
DIR_HASHMAP_TABLE,
DIR_NODE_TABLE,
FILE_HASHMAP_TABLE,
FILE_NODE_TABLE,
SECTION_NUM
};
}
#pragma pack(push,1)
struct sRomfsHeader
{
le_uint64_t header_size;
struct sSection
{
le_uint64_t offset;
le_uint64_t size;
} sections[romfs::SECTION_NUM];
le_uint64_t data_offset;
};
struct sRomfsDirEntry
{
le_uint32_t parent;
le_uint32_t sibling;
le_uint32_t child;
le_uint32_t file;
le_uint32_t hash;
le_uint32_t name_size;
char* name() { return ((char*)(this)) + sizeof(sRomfsDirEntry); }
const char* name() const { return ((char*)(this)) + sizeof(sRomfsDirEntry); }
};
struct sRomfsFileEntry
{
le_uint32_t parent;
le_uint32_t sibling;
le_uint64_t offset;
le_uint64_t size;
le_uint32_t hash;
le_uint32_t name_size;
char* name() { return ((char*)(this)) + sizeof(sRomfsFileEntry); }
const char* name() const { return ((char*)(this)) + sizeof(sRomfsFileEntry); }
};
#pragma pack(pop)
}
#pragma once
#include <fnd/types.h>
namespace nn
{
namespace hac
{
namespace romfs
{
static const uint64_t kRomfsHeaderAlign = 0x200;
static const uint32_t kInvalidAddr = 0xffffffff;
enum HeaderSectionIndex
{
DIR_HASHMAP_TABLE,
DIR_NODE_TABLE,
FILE_HASHMAP_TABLE,
FILE_NODE_TABLE,
SECTION_NUM
};
}
#pragma pack(push,1)
struct sRomfsHeader
{
le_uint64_t header_size;
struct sSection
{
le_uint64_t offset;
le_uint64_t size;
} sections[romfs::SECTION_NUM];
le_uint64_t data_offset;
};
struct sRomfsDirEntry
{
le_uint32_t parent;
le_uint32_t sibling;
le_uint32_t child;
le_uint32_t file;
le_uint32_t hash;
le_uint32_t name_size;
char* name() { return ((char*)(this)) + sizeof(sRomfsDirEntry); }
const char* name() const { return ((char*)(this)) + sizeof(sRomfsDirEntry); }
};
struct sRomfsFileEntry
{
le_uint32_t parent;
le_uint32_t sibling;
le_uint64_t offset;
le_uint64_t size;
le_uint32_t hash;
le_uint32_t name_size;
char* name() { return ((char*)(this)) + sizeof(sRomfsFileEntry); }
const char* name() const { return ((char*)(this)) + sizeof(sRomfsFileEntry); }
};
#pragma pack(pop)
}
}

View file

@ -1,228 +1,240 @@
<?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>
<ItemGroup>
<None Include="makefile" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="include\nn\hac\AccessControlInfoBinary.h" />
<ClInclude Include="include\nn\hac\AccessControlInfoDescBinary.h" />
<ClInclude Include="include\nn\hac\aci.h" />
<ClInclude Include="include\nn\hac\AesKeygen.h" />
<ClInclude Include="include\nn\hac\ApplicationControlPropertyBinary.h" />
<ClInclude Include="include\nn\hac\ApplicationControlPropertyUtils.h" />
<ClInclude Include="include\nn\hac\cnmt.h" />
<ClInclude Include="include\nn\hac\ContentMetaBinary.h" />
<ClInclude Include="include\nn\hac\delta.h" />
<ClInclude Include="include\nn\hac\fac.h" />
<ClInclude Include="include\nn\hac\FileSystemAccessControlBinary.h" />
<ClInclude Include="include\nn\hac\HandleTableSizeEntry.h" />
<ClInclude Include="include\nn\hac\HandleTableSizeHandler.h" />
<ClInclude Include="include\nn\hac\hierarchicalintegrity.h" />
<ClInclude Include="include\nn\hac\HierarchicalIntegrityHeader.h" />
<ClInclude Include="include\nn\hac\hierarchicalsha256.h" />
<ClInclude Include="include\nn\hac\HierarchicalSha256Header.h" />
<ClInclude Include="include\nn\hac\IdConverter.h" />
<ClInclude Include="include\nn\hac\IKernelCapabilityHandler.h" />
<ClInclude Include="include\nn\hac\InteruptEntry.h" />
<ClInclude Include="include\nn\hac\InteruptHandler.h" />
<ClInclude Include="include\nn\hac\kc.h" />
<ClInclude Include="include\nn\hac\KernelCapabilityBinary.h" />
<ClInclude Include="include\nn\hac\KernelCapabilityEntry.h" />
<ClInclude Include="include\nn\hac\KernelVersionEntry.h" />
<ClInclude Include="include\nn\hac\KernelVersionHandler.h" />
<ClInclude Include="include\nn\hac\macro.h" />
<ClInclude Include="include\nn\hac\MemoryMappingHandler.h" />
<ClInclude Include="include\nn\hac\MemoryPageEntry.h" />
<ClInclude Include="include\nn\hac\meta.h" />
<ClInclude Include="include\nn\hac\MetaBinary.h" />
<ClInclude Include="include\nn\hac\MiscFlagsEntry.h" />
<ClInclude Include="include\nn\hac\MiscFlagsHandler.h" />
<ClInclude Include="include\nn\hac\MiscParamsEntry.h" />
<ClInclude Include="include\nn\hac\MiscParamsHandler.h" />
<ClInclude Include="include\nn\hac\nacp.h" />
<ClInclude Include="include\nn\hac\nca.h" />
<ClInclude Include="include\nn\hac\NcaHeader.h" />
<ClInclude Include="include\nn\hac\NcaUtils.h" />
<ClInclude Include="include\nn\hac\nro.h" />
<ClInclude Include="include\nn\hac\NroHeader.h" />
<ClInclude Include="include\nn\hac\nrr.h" />
<ClInclude Include="include\nn\hac\nso.h" />
<ClInclude Include="include\nn\hac\NsoHeader.h" />
<ClInclude Include="include\nn\hac\pfs.h" />
<ClInclude Include="include\nn\hac\PfsHeader.h" />
<ClInclude Include="include\nn\hac\Result.h" />
<ClInclude Include="include\nn\hac\romfs.h" />
<ClInclude Include="include\nn\hac\ServiceAccessControlBinary.h" />
<ClInclude Include="include\nn\hac\ServiceAccessControlEntry.h" />
<ClInclude Include="include\nn\hac\SystemCallEntry.h" />
<ClInclude Include="include\nn\hac\SystemCallHandler.h" />
<ClInclude Include="include\nn\hac\ThreadInfoEntry.h" />
<ClInclude Include="include\nn\hac\ThreadInfoHandler.h" />
<ClInclude Include="include\nn\hac\xci.h" />
<ClInclude Include="include\nn\hac\XciHeader.h" />
<ClInclude Include="include\nn\hac\XciUtils.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="source\AccessControlInfoBinary.cpp" />
<ClCompile Include="source\AccessControlInfoDescBinary.cpp" />
<ClCompile Include="source\AesKeygen.cpp" />
<ClCompile Include="source\ApplicationControlPropertyBinary.cpp" />
<ClCompile Include="source\ApplicationControlPropertyUtils.cpp" />
<ClCompile Include="source\ContentMetaBinary.cpp" />
<ClCompile Include="source\FileSystemAccessControlBinary.cpp" />
<ClCompile Include="source\HandleTableSizeEntry.cpp" />
<ClCompile Include="source\HandleTableSizeHandler.cpp" />
<ClCompile Include="source\HierarchicalIntegrityHeader.cpp" />
<ClCompile Include="source\HierarchicalSha256Header.cpp" />
<ClCompile Include="source\IdConverter.cpp" />
<ClCompile Include="source\InteruptEntry.cpp" />
<ClCompile Include="source\InteruptHandler.cpp" />
<ClCompile Include="source\KernelCapabilityBinary.cpp" />
<ClCompile Include="source\KernelCapabilityEntry.cpp" />
<ClCompile Include="source\KernelVersionEntry.cpp" />
<ClCompile Include="source\KernelVersionHandler.cpp" />
<ClCompile Include="source\MemoryMappingHandler.cpp" />
<ClCompile Include="source\MemoryPageEntry.cpp" />
<ClCompile Include="source\MetaBinary.cpp" />
<ClCompile Include="source\MiscFlagsEntry.cpp" />
<ClCompile Include="source\MiscFlagsHandler.cpp" />
<ClCompile Include="source\MiscParamsEntry.cpp" />
<ClCompile Include="source\MiscParamsHandler.cpp" />
<ClCompile Include="source\NcaHeader.cpp" />
<ClCompile Include="source\NcaUtils.cpp" />
<ClCompile Include="source\NroHeader.cpp" />
<ClCompile Include="source\NsoHeader.cpp" />
<ClCompile Include="source\PfsHeader.cpp" />
<ClCompile Include="source\Result.cpp" />
<ClCompile Include="source\ServiceAccessControlBinary.cpp" />
<ClCompile Include="source\ServiceAccessControlEntry.cpp" />
<ClCompile Include="source\SystemCallEntry.cpp" />
<ClCompile Include="source\SystemCallHandler.cpp" />
<ClCompile Include="source\ThreadInfoEntry.cpp" />
<ClCompile Include="source\ThreadInfoHandler.cpp" />
<ClCompile Include="source\XciHeader.cpp" />
<ClCompile Include="source\XciUtils.cpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{91BA9E79-8242-4F7D-B997-0DFEC95EA22B}</ProjectGuid>
<RootNamespace>hac</RootNamespace>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
<ProjectName>libhac</ProjectName>
</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;..\libhac\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;..\libhac\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;..\libhac\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;..\libhac\include;</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<?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>
<ItemGroup>
<None Include="makefile" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="include\nn\hac\AccessControlInfo.h" />
<ClInclude Include="include\nn\hac\AccessControlInfoDesc.h" />
<ClInclude Include="include\nn\hac\AddOnContentMetaExtendedHeader.h" />
<ClInclude Include="include\nn\hac\AesKeygen.h" />
<ClInclude Include="include\nn\hac\ApplicationControlProperty.h" />
<ClInclude Include="include\nn\hac\ApplicationControlPropertyUtils.h" />
<ClInclude Include="include\nn\hac\ApplicationMetaExtendedHeader.h" />
<ClInclude Include="include\nn\hac\ContentArchiveHeader.h" />
<ClInclude Include="include\nn\hac\ContentArchiveUtils.h" />
<ClInclude Include="include\nn\hac\ContentInfo.h" />
<ClInclude Include="include\nn\hac\ContentMeta.h" />
<ClInclude Include="include\nn\hac\ContentMetaInfo.h" />
<ClInclude Include="include\nn\hac\define\aci.h" />
<ClInclude Include="include\nn\hac\define\cnmt.h" />
<ClInclude Include="include\nn\hac\define\delta.h" />
<ClInclude Include="include\nn\hac\define\fac.h" />
<ClInclude Include="include\nn\hac\define\gc.h" />
<ClInclude Include="include\nn\hac\define\hierarchicalintegrity.h" />
<ClInclude Include="include\nn\hac\define\hierarchicalsha256.h" />
<ClInclude Include="include\nn\hac\define\kc.h" />
<ClInclude Include="include\nn\hac\define\macro.h" />
<ClInclude Include="include\nn\hac\define\meta.h" />
<ClInclude Include="include\nn\hac\define\nacp.h" />
<ClInclude Include="include\nn\hac\define\nca.h" />
<ClInclude Include="include\nn\hac\define\nro.h" />
<ClInclude Include="include\nn\hac\define\nrr.h" />
<ClInclude Include="include\nn\hac\define\nso.h" />
<ClInclude Include="include\nn\hac\define\pfs.h" />
<ClInclude Include="include\nn\hac\define\romfs.h" />
<ClInclude Include="include\nn\hac\DeltaMetaExtendedHeader.h" />
<ClInclude Include="include\nn\hac\FileSystemAccessControl.h" />
<ClInclude Include="include\nn\hac\GameCardHeader.h" />
<ClInclude Include="include\nn\hac\GameCardUtils.h" />
<ClInclude Include="include\nn\hac\HandleTableSizeEntry.h" />
<ClInclude Include="include\nn\hac\HandleTableSizeHandler.h" />
<ClInclude Include="include\nn\hac\HierarchicalIntegrityHeader.h" />
<ClInclude Include="include\nn\hac\HierarchicalSha256Header.h" />
<ClInclude Include="include\nn\hac\IdConverter.h" />
<ClInclude Include="include\nn\hac\IKernelCapabilityHandler.h" />
<ClInclude Include="include\nn\hac\InteruptEntry.h" />
<ClInclude Include="include\nn\hac\InteruptHandler.h" />
<ClInclude Include="include\nn\hac\KernelCapabilityControl.h" />
<ClInclude Include="include\nn\hac\KernelCapabilityEntry.h" />
<ClInclude Include="include\nn\hac\KernelVersionEntry.h" />
<ClInclude Include="include\nn\hac\KernelVersionHandler.h" />
<ClInclude Include="include\nn\hac\MemoryMappingHandler.h" />
<ClInclude Include="include\nn\hac\MemoryPageEntry.h" />
<ClInclude Include="include\nn\hac\Meta.h" />
<ClInclude Include="include\nn\hac\MiscFlagsEntry.h" />
<ClInclude Include="include\nn\hac\MiscFlagsHandler.h" />
<ClInclude Include="include\nn\hac\MiscParamsEntry.h" />
<ClInclude Include="include\nn\hac\MiscParamsHandler.h" />
<ClInclude Include="include\nn\hac\NroHeader.h" />
<ClInclude Include="include\nn\hac\NsoHeader.h" />
<ClInclude Include="include\nn\hac\PartitionFsHeader.h" />
<ClInclude Include="include\nn\hac\PatchMetaExtendedHeader.h" />
<ClInclude Include="include\nn\hac\Result.h" />
<ClInclude Include="include\nn\hac\ServiceAccessControl.h" />
<ClInclude Include="include\nn\hac\ServiceAccessControlEntry.h" />
<ClInclude Include="include\nn\hac\SystemCallEntry.h" />
<ClInclude Include="include\nn\hac\SystemCallHandler.h" />
<ClInclude Include="include\nn\hac\ThreadInfoEntry.h" />
<ClInclude Include="include\nn\hac\ThreadInfoHandler.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="source\AccessControlInfo.cpp" />
<ClCompile Include="source\AccessControlInfoDesc.cpp" />
<ClCompile Include="source\AddOnContentMetaExtendedHeader.cpp" />
<ClCompile Include="source\AesKeygen.cpp" />
<ClCompile Include="source\ApplicationControlProperty.cpp" />
<ClCompile Include="source\ApplicationControlPropertyUtils.cpp" />
<ClCompile Include="source\ApplicationMetaExtendedHeader.cpp" />
<ClCompile Include="source\ContentArchiveHeader.cpp" />
<ClCompile Include="source\ContentArchiveUtils.cpp" />
<ClCompile Include="source\ContentInfo.cpp" />
<ClCompile Include="source\ContentMeta.cpp" />
<ClCompile Include="source\ContentMetaInfo.cpp" />
<ClCompile Include="source\DeltaMetaExtendedHeader.cpp" />
<ClCompile Include="source\FileSystemAccessControl.cpp" />
<ClCompile Include="source\GameCardHeader.cpp" />
<ClCompile Include="source\GameCardUtils.cpp" />
<ClCompile Include="source\HandleTableSizeEntry.cpp" />
<ClCompile Include="source\HandleTableSizeHandler.cpp" />
<ClCompile Include="source\HierarchicalIntegrityHeader.cpp" />
<ClCompile Include="source\HierarchicalSha256Header.cpp" />
<ClCompile Include="source\IdConverter.cpp" />
<ClCompile Include="source\InteruptEntry.cpp" />
<ClCompile Include="source\InteruptHandler.cpp" />
<ClCompile Include="source\KernelCapabilityControl.cpp" />
<ClCompile Include="source\KernelCapabilityEntry.cpp" />
<ClCompile Include="source\KernelVersionEntry.cpp" />
<ClCompile Include="source\KernelVersionHandler.cpp" />
<ClCompile Include="source\MemoryMappingHandler.cpp" />
<ClCompile Include="source\MemoryPageEntry.cpp" />
<ClCompile Include="source\Meta.cpp" />
<ClCompile Include="source\MiscFlagsEntry.cpp" />
<ClCompile Include="source\MiscFlagsHandler.cpp" />
<ClCompile Include="source\MiscParamsEntry.cpp" />
<ClCompile Include="source\MiscParamsHandler.cpp" />
<ClCompile Include="source\NroHeader.cpp" />
<ClCompile Include="source\NsoHeader.cpp" />
<ClCompile Include="source\PartitionFsHeader.cpp" />
<ClCompile Include="source\PatchMetaExtendedHeader.cpp" />
<ClCompile Include="source\Result.cpp" />
<ClCompile Include="source\ServiceAccessControl.cpp" />
<ClCompile Include="source\ServiceAccessControlEntry.cpp" />
<ClCompile Include="source\SystemCallEntry.cpp" />
<ClCompile Include="source\SystemCallHandler.cpp" />
<ClCompile Include="source\ThreadInfoEntry.cpp" />
<ClCompile Include="source\ThreadInfoHandler.cpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{91BA9E79-8242-4F7D-B997-0DFEC95EA22B}</ProjectGuid>
<RootNamespace>hac</RootNamespace>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
<ProjectName>libhac</ProjectName>
</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;..\libhac\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;..\libhac\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;..\libhac\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;..\libhac\include;</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -1,312 +1,345 @@
<?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\hac\AccessControlInfoBinary.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\AccessControlInfoDescBinary.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\aci.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\AesKeygen.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\ApplicationControlPropertyBinary.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\ApplicationControlPropertyUtils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\cnmt.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\ContentMetaBinary.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\delta.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\fac.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\FileSystemAccessControlBinary.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\HandleTableSizeEntry.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\HandleTableSizeHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\hierarchicalintegrity.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\HierarchicalIntegrityHeader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\hierarchicalsha256.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\HierarchicalSha256Header.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\IdConverter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\IKernelCapabilityHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\InteruptEntry.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\InteruptHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\kc.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\KernelCapabilityBinary.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\KernelCapabilityEntry.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\KernelVersionEntry.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\KernelVersionHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\macro.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\MemoryMappingHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\MemoryPageEntry.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\meta.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\MetaBinary.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\MiscFlagsEntry.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\MiscFlagsHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\MiscParamsEntry.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\MiscParamsHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\nacp.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\nca.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\NcaHeader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\NcaUtils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\nro.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\NroHeader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\nrr.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\nso.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\NsoHeader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\pfs.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\PfsHeader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\Result.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\romfs.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\ServiceAccessControlBinary.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\ServiceAccessControlEntry.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\SystemCallEntry.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\SystemCallHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\ThreadInfoEntry.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\ThreadInfoHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\xci.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\XciHeader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\XciUtils.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="source\AccessControlInfoBinary.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\AccessControlInfoDescBinary.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\AesKeygen.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\ApplicationControlPropertyBinary.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\ApplicationControlPropertyUtils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\ContentMetaBinary.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\FileSystemAccessControlBinary.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\HandleTableSizeEntry.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\HandleTableSizeHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\HierarchicalIntegrityHeader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\HierarchicalSha256Header.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\InteruptEntry.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\InteruptHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\KernelCapabilityBinary.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\KernelCapabilityEntry.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\KernelVersionEntry.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\KernelVersionHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\MemoryMappingHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\MemoryPageEntry.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\MiscFlagsEntry.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\MiscFlagsHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\MiscParamsEntry.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\MiscParamsHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\NcaHeader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\NcaUtils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\MetaBinary.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\NroHeader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\NsoHeader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\PfsHeader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\ServiceAccessControlBinary.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\ServiceAccessControlEntry.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\SystemCallEntry.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\SystemCallHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\ThreadInfoEntry.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\ThreadInfoHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\XciHeader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\XciUtils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\IdConverter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\Result.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>
<None Include="makefile" />
</ItemGroup>
<ItemGroup>
<Filter Include="Header Files">
<UniqueIdentifier>{040358e3-f1c5-4875-b34f-23607459567c}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files">
<UniqueIdentifier>{1c33ce2b-25c4-4857-966c-9dc24daf3f61}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\define">
<UniqueIdentifier>{a9fd54c0-9fd8-46a1-978e-fb531bf3ee1c}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="include\nn\hac\define\aci.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\cnmt.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\delta.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\fac.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\gc.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\hierarchicalintegrity.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\hierarchicalsha256.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\kc.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\macro.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\meta.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\nacp.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\nca.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\nro.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\nrr.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\nso.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\pfs.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\romfs.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\AccessControlInfo.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\AccessControlInfoDesc.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\AddOnContentMetaExtendedHeader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\AesKeygen.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\ApplicationControlProperty.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\ApplicationControlPropertyUtils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\ApplicationMetaExtendedHeader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\ContentArchiveHeader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\ContentArchiveUtils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\ContentInfo.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\ContentMeta.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\ContentMetaInfo.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\DeltaMetaExtendedHeader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\FileSystemAccessControl.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\GameCardHeader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\GameCardUtils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\HandleTableSizeEntry.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\HandleTableSizeHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\HierarchicalIntegrityHeader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\HierarchicalSha256Header.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\IdConverter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\IKernelCapabilityHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\InteruptEntry.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\InteruptHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\KernelCapabilityControl.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\KernelCapabilityEntry.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\KernelVersionEntry.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\KernelVersionHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\MemoryMappingHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\MemoryPageEntry.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\Meta.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\MiscFlagsEntry.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\MiscFlagsHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\MiscParamsEntry.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\MiscParamsHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\NroHeader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\NsoHeader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\PartitionFsHeader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\PatchMetaExtendedHeader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\Result.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\ServiceAccessControl.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\ServiceAccessControlEntry.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\SystemCallEntry.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\SystemCallHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\ThreadInfoEntry.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\ThreadInfoHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="source\AccessControlInfo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\AccessControlInfoDesc.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\AddOnContentMetaExtendedHeader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\AesKeygen.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\ApplicationControlProperty.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\ApplicationControlPropertyUtils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\ApplicationMetaExtendedHeader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\ContentArchiveHeader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\ContentArchiveUtils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\ContentInfo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\ContentMeta.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\ContentMetaInfo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\DeltaMetaExtendedHeader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\FileSystemAccessControl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\GameCardHeader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\GameCardUtils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\HandleTableSizeEntry.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\HandleTableSizeHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\HierarchicalIntegrityHeader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\HierarchicalSha256Header.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\IdConverter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\InteruptEntry.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\InteruptHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\KernelCapabilityControl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\KernelCapabilityEntry.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\KernelVersionEntry.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\KernelVersionHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\MemoryMappingHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\MemoryPageEntry.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\Meta.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\MiscFlagsEntry.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\MiscFlagsHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\MiscParamsEntry.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\MiscParamsHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\NroHeader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\NsoHeader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\PartitionFsHeader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\PatchMetaExtendedHeader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\Result.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\ServiceAccessControl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\ServiceAccessControlEntry.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\SystemCallEntry.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\SystemCallHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\ThreadInfoEntry.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\ThreadInfoHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View file

@ -1,173 +1,173 @@
#include <nn/hac/AccessControlInfoBinary.h>
nn::hac::AccessControlInfoBinary::AccessControlInfoBinary()
{
clear();
}
nn::hac::AccessControlInfoBinary::AccessControlInfoBinary(const AccessControlInfoBinary & other)
{
*this = other;
}
void nn::hac::AccessControlInfoBinary::operator=(const AccessControlInfoBinary & other)
{
mRawBinary = other.mRawBinary;
mProgramId = other.mProgramId;
mFileSystemAccessControl = other.mFileSystemAccessControl;
mServiceAccessControl = other.mServiceAccessControl;
mKernelCapabilities = other.mKernelCapabilities;
}
bool nn::hac::AccessControlInfoBinary::operator==(const AccessControlInfoBinary & other) const
{
return (mProgramId == other.mProgramId) \
&& (mFileSystemAccessControl == other.mFileSystemAccessControl) \
&& (mServiceAccessControl == other.mServiceAccessControl) \
&& (mKernelCapabilities == other.mKernelCapabilities);
}
bool nn::hac::AccessControlInfoBinary::operator!=(const AccessControlInfoBinary & other) const
{
return !(*this == other);
}
void nn::hac::AccessControlInfoBinary::toBytes()
{
// serialise the sections
mFileSystemAccessControl.toBytes();
mServiceAccessControl.toBytes();
mKernelCapabilities.toBytes();
// determine section layout
struct sLayout {
uint32_t offset, size;
} fac, sac, kc;
fac.offset = (uint32_t)align(sizeof(sAciHeader), aci::kSectionAlignSize);
fac.size = (uint32_t)mFileSystemAccessControl.getBytes().size();
sac.offset = (uint32_t)align(fac.offset + fac.size, aci::kSectionAlignSize);
sac.size = (uint32_t)mServiceAccessControl.getBytes().size();
kc.offset = (uint32_t)align(sac.offset + sac.size, aci::kSectionAlignSize);
kc.size = (uint32_t)mKernelCapabilities.getBytes().size();
// get total size
size_t total_size = _MAX(_MAX(fac.offset + fac.size, sac.offset + sac.size), kc.offset + kc.size);
mRawBinary.alloc(total_size);
sAciHeader* hdr = (sAciHeader*)mRawBinary.data();
// set type
hdr->st_magic = aci::kAciStructMagic;
// set program id
hdr->program_id = mProgramId;
// set offset/size
hdr->fac.offset = fac.offset;
hdr->fac.size = fac.size;
hdr->sac.offset = sac.offset;
hdr->sac.size = sac.size;
hdr->kc.offset = kc.offset;
hdr->kc.size = kc.size;
// write data
memcpy(mRawBinary.data() + fac.offset, mFileSystemAccessControl.getBytes().data(), fac.size);
memcpy(mRawBinary.data() + sac.offset, mServiceAccessControl.getBytes().data(), sac.size);
memcpy(mRawBinary.data() + kc.offset, mKernelCapabilities.getBytes().data(), kc.size);
}
void nn::hac::AccessControlInfoBinary::fromBytes(const byte_t* data, size_t len)
{
// check size
if (len < sizeof(sAciHeader))
{
throw fnd::Exception(kModuleName, "AccessControlInfo binary is too small");
}
// clear variables
clear();
// save a copy of the header
sAciHeader hdr;
memcpy((void*)&hdr, data, sizeof(sAciHeader));
// check magic
if (hdr.st_magic.get() != aci::kAciStructMagic)
{
throw fnd::Exception(kModuleName, "AccessControlInfo header corrupt");
}
// get total size
size_t total_size = _MAX(_MAX(hdr.fac.offset.get() + hdr.fac.size.get(), hdr.sac.offset.get() + hdr.sac.size.get()), hdr.kc.offset.get() + hdr.kc.size.get());
// validate binary size
if (len < total_size)
{
throw fnd::Exception(kModuleName, "AccessControlInfo binary is too small");
}
// allocate memory for header
mRawBinary.alloc(total_size);
memcpy(mRawBinary.data(), data, mRawBinary.size());
// save variables
mProgramId = hdr.program_id.get();
mFileSystemAccessControl.fromBytes(mRawBinary.data() + hdr.fac.offset.get(), hdr.fac.size.get());
mServiceAccessControl.fromBytes(mRawBinary.data() + hdr.sac.offset.get(), hdr.sac.size.get());
mKernelCapabilities.fromBytes(mRawBinary.data() + hdr.kc.offset.get(), hdr.kc.size.get());
}
const fnd::Vec<byte_t>& nn::hac::AccessControlInfoBinary::getBytes() const
{
return mRawBinary;
}
void nn::hac::AccessControlInfoBinary::clear()
{
mRawBinary.clear();
mProgramId = 0;
mFileSystemAccessControl.clear();
mServiceAccessControl.clear();
mKernelCapabilities.clear();
}
uint64_t nn::hac::AccessControlInfoBinary::getProgramId() const
{
return mProgramId;
}
void nn::hac::AccessControlInfoBinary::setProgramId(uint64_t program_id)
{
mProgramId = program_id;
}
const nn::hac::FileSystemAccessControlBinary& nn::hac::AccessControlInfoBinary::getFileSystemAccessControl() const
{
return mFileSystemAccessControl;
}
void nn::hac::AccessControlInfoBinary::setFileSystemAccessControl(const nn::hac::FileSystemAccessControlBinary& fac)
{
mFileSystemAccessControl = fac;
}
const nn::hac::ServiceAccessControlBinary& nn::hac::AccessControlInfoBinary::getServiceAccessControl() const
{
return mServiceAccessControl;
}
void nn::hac::AccessControlInfoBinary::setServiceAccessControl(const nn::hac::ServiceAccessControlBinary& sac)
{
mServiceAccessControl = sac;
}
const nn::hac::KernelCapabilityBinary& nn::hac::AccessControlInfoBinary::getKernelCapabilities() const
{
return mKernelCapabilities;
}
void nn::hac::AccessControlInfoBinary::setKernelCapabilities(const nn::hac::KernelCapabilityBinary& kc)
{
mKernelCapabilities = kc;
#include <nn/hac/AccessControlInfo.h>
nn::hac::AccessControlInfo::AccessControlInfo()
{
clear();
}
nn::hac::AccessControlInfo::AccessControlInfo(const AccessControlInfo & other)
{
*this = other;
}
void nn::hac::AccessControlInfo::operator=(const AccessControlInfo & other)
{
mRawBinary = other.mRawBinary;
mProgramId = other.mProgramId;
mFileSystemAccessControl = other.mFileSystemAccessControl;
mServiceAccessControl = other.mServiceAccessControl;
mKernelCapabilities = other.mKernelCapabilities;
}
bool nn::hac::AccessControlInfo::operator==(const AccessControlInfo & other) const
{
return (mProgramId == other.mProgramId) \
&& (mFileSystemAccessControl == other.mFileSystemAccessControl) \
&& (mServiceAccessControl == other.mServiceAccessControl) \
&& (mKernelCapabilities == other.mKernelCapabilities);
}
bool nn::hac::AccessControlInfo::operator!=(const AccessControlInfo & other) const
{
return !(*this == other);
}
void nn::hac::AccessControlInfo::toBytes()
{
// serialise the sections
mFileSystemAccessControl.toBytes();
mServiceAccessControl.toBytes();
mKernelCapabilities.toBytes();
// determine section layout
struct sLayout {
uint32_t offset, size;
} fac, sac, kc;
fac.offset = (uint32_t)align(sizeof(sAciHeader), aci::kSectionAlignSize);
fac.size = (uint32_t)mFileSystemAccessControl.getBytes().size();
sac.offset = (uint32_t)align(fac.offset + fac.size, aci::kSectionAlignSize);
sac.size = (uint32_t)mServiceAccessControl.getBytes().size();
kc.offset = (uint32_t)align(sac.offset + sac.size, aci::kSectionAlignSize);
kc.size = (uint32_t)mKernelCapabilities.getBytes().size();
// get total size
size_t total_size = _MAX(_MAX(fac.offset + fac.size, sac.offset + sac.size), kc.offset + kc.size);
mRawBinary.alloc(total_size);
sAciHeader* hdr = (sAciHeader*)mRawBinary.data();
// set type
hdr->st_magic = aci::kAciStructMagic;
// set program id
hdr->program_id = mProgramId;
// set offset/size
hdr->fac.offset = fac.offset;
hdr->fac.size = fac.size;
hdr->sac.offset = sac.offset;
hdr->sac.size = sac.size;
hdr->kc.offset = kc.offset;
hdr->kc.size = kc.size;
// write data
memcpy(mRawBinary.data() + fac.offset, mFileSystemAccessControl.getBytes().data(), fac.size);
memcpy(mRawBinary.data() + sac.offset, mServiceAccessControl.getBytes().data(), sac.size);
memcpy(mRawBinary.data() + kc.offset, mKernelCapabilities.getBytes().data(), kc.size);
}
void nn::hac::AccessControlInfo::fromBytes(const byte_t* data, size_t len)
{
// check size
if (len < sizeof(sAciHeader))
{
throw fnd::Exception(kModuleName, "AccessControlInfo binary is too small");
}
// clear variables
clear();
// save a copy of the header
sAciHeader hdr;
memcpy((void*)&hdr, data, sizeof(sAciHeader));
// check magic
if (hdr.st_magic.get() != aci::kAciStructMagic)
{
throw fnd::Exception(kModuleName, "AccessControlInfo header corrupt");
}
// get total size
size_t total_size = _MAX(_MAX(hdr.fac.offset.get() + hdr.fac.size.get(), hdr.sac.offset.get() + hdr.sac.size.get()), hdr.kc.offset.get() + hdr.kc.size.get());
// validate binary size
if (len < total_size)
{
throw fnd::Exception(kModuleName, "AccessControlInfo binary is too small");
}
// allocate memory for header
mRawBinary.alloc(total_size);
memcpy(mRawBinary.data(), data, mRawBinary.size());
// save variables
mProgramId = hdr.program_id.get();
mFileSystemAccessControl.fromBytes(mRawBinary.data() + hdr.fac.offset.get(), hdr.fac.size.get());
mServiceAccessControl.fromBytes(mRawBinary.data() + hdr.sac.offset.get(), hdr.sac.size.get());
mKernelCapabilities.fromBytes(mRawBinary.data() + hdr.kc.offset.get(), hdr.kc.size.get());
}
const fnd::Vec<byte_t>& nn::hac::AccessControlInfo::getBytes() const
{
return mRawBinary;
}
void nn::hac::AccessControlInfo::clear()
{
mRawBinary.clear();
mProgramId = 0;
mFileSystemAccessControl.clear();
mServiceAccessControl.clear();
mKernelCapabilities.clear();
}
uint64_t nn::hac::AccessControlInfo::getProgramId() const
{
return mProgramId;
}
void nn::hac::AccessControlInfo::setProgramId(uint64_t program_id)
{
mProgramId = program_id;
}
const nn::hac::FileSystemAccessControl& nn::hac::AccessControlInfo::getFileSystemAccessControl() const
{
return mFileSystemAccessControl;
}
void nn::hac::AccessControlInfo::setFileSystemAccessControl(const nn::hac::FileSystemAccessControl& fac)
{
mFileSystemAccessControl = fac;
}
const nn::hac::ServiceAccessControl& nn::hac::AccessControlInfo::getServiceAccessControl() const
{
return mServiceAccessControl;
}
void nn::hac::AccessControlInfo::setServiceAccessControl(const nn::hac::ServiceAccessControl& sac)
{
mServiceAccessControl = sac;
}
const nn::hac::KernelCapabilityControl& nn::hac::AccessControlInfo::getKernelCapabilities() const
{
return mKernelCapabilities;
}
void nn::hac::AccessControlInfo::setKernelCapabilities(const nn::hac::KernelCapabilityControl& kc)
{
mKernelCapabilities = kc;
}

View file

@ -1,251 +1,251 @@
#include <nn/hac/AccessControlInfoDescBinary.h>
nn::hac::AccessControlInfoDescBinary::AccessControlInfoDescBinary()
{
clear();
}
nn::hac::AccessControlInfoDescBinary::AccessControlInfoDescBinary(const AccessControlInfoDescBinary & other)
{
*this = other;
}
void nn::hac::AccessControlInfoDescBinary::operator=(const AccessControlInfoDescBinary & other)
{
mRawBinary = other.mRawBinary;
mNcaHeaderSignature2Key = other.mNcaHeaderSignature2Key;
mFlags = other.mFlags;
mProgramIdRestrict = other.mProgramIdRestrict;
mFileSystemAccessControl = other.mFileSystemAccessControl;
mServiceAccessControl = other.mServiceAccessControl;
mKernelCapabilities = other.mKernelCapabilities;
}
bool nn::hac::AccessControlInfoDescBinary::operator==(const AccessControlInfoDescBinary & other) const
{
return (mNcaHeaderSignature2Key == other.mNcaHeaderSignature2Key) \
&& (mFlags == other.mFlags) \
&& (mProgramIdRestrict == other.mProgramIdRestrict) \
&& (mFileSystemAccessControl == other.mFileSystemAccessControl) \
&& (mServiceAccessControl == other.mServiceAccessControl) \
&& (mKernelCapabilities == other.mKernelCapabilities);
}
bool nn::hac::AccessControlInfoDescBinary::operator!=(const AccessControlInfoDescBinary & other) const
{
return !(*this == other);
}
void nn::hac::AccessControlInfoDescBinary::toBytes()
{
// serialise the sections
mFileSystemAccessControl.toBytes();
mServiceAccessControl.toBytes();
mKernelCapabilities.toBytes();
// determine section layout
struct sLayout {
uint32_t offset, size;
} fac, sac, kc;
fac.offset = (uint32_t)align(sizeof(sAciDescHeader), aci::kSectionAlignSize);
fac.size = (uint32_t)mFileSystemAccessControl.getBytes().size();
sac.offset = (uint32_t)align(fac.offset + fac.size, aci::kSectionAlignSize);
sac.size = (uint32_t)mServiceAccessControl.getBytes().size();
kc.offset = (uint32_t)align(sac.offset + sac.size, aci::kSectionAlignSize);
kc.size = (uint32_t)mKernelCapabilities.getBytes().size();
// get total size
size_t total_size = _MAX(_MAX(fac.offset + fac.size, sac.offset + sac.size), kc.offset + kc.size);
mRawBinary.alloc(total_size);
sAciDescHeader* hdr = (sAciDescHeader*)mRawBinary.data();
// set rsa modulus
memcpy(hdr->nca_rsa_signature2_modulus, mNcaHeaderSignature2Key.modulus, fnd::rsa::kRsa2048Size);
// set type
hdr->st_magic = aci::kAciDescStructMagic;
// set "acid size"
hdr->signed_size = (uint32_t)(total_size - fnd::rsa::kRsa2048Size);
// set flags
uint32_t flags = 0;
for (size_t i = 0; i < mFlags.size(); i++)
flags |= _BIT(mFlags[i]);
hdr->flags = flags;
// set program id restrict settings
hdr->program_id_min = mProgramIdRestrict.min;
hdr->program_id_max = mProgramIdRestrict.max;
// set offset/size
hdr->fac.offset = fac.offset;
hdr->fac.size = fac.size;
hdr->sac.offset = sac.offset;
hdr->sac.size = sac.size;
hdr->kc.offset = kc.offset;
hdr->kc.size = kc.size;
// write data
memcpy(mRawBinary.data() + fac.offset, mFileSystemAccessControl.getBytes().data(), fac.size);
memcpy(mRawBinary.data() + sac.offset, mServiceAccessControl.getBytes().data(), sac.size);
memcpy(mRawBinary.data() + kc.offset, mKernelCapabilities.getBytes().data(), kc.size);
}
void nn::hac::AccessControlInfoDescBinary::fromBytes(const byte_t* data, size_t len)
{
// check size
if (len < sizeof(sAciDescHeader))
{
throw fnd::Exception(kModuleName, "AccessControlInfoDesc binary is too small");
}
// clear variables
clear();
// save a copy of the header
sAciDescHeader hdr;
memcpy((void*)&hdr, data, sizeof(sAciDescHeader));
// check magic
if (hdr.st_magic.get() != aci::kAciDescStructMagic)
{
throw fnd::Exception(kModuleName, "AccessControlInfoDesc header corrupt");
}
// get total size
size_t total_size = _MAX(_MAX(hdr.fac.offset.get() + hdr.fac.size.get(), hdr.sac.offset.get() + hdr.sac.size.get()), hdr.kc.offset.get() + hdr.kc.size.get());
// validate binary size
if (len < total_size)
{
throw fnd::Exception(kModuleName, "AccessControlInfoDesc binary is too small");
}
// allocate memory for header
mRawBinary.alloc(total_size);
memcpy(mRawBinary.data(), data, mRawBinary.size());
// save variables
memcpy(mNcaHeaderSignature2Key.modulus, hdr.nca_rsa_signature2_modulus, fnd::rsa::kRsa2048Size);
for (size_t i = 0; i < 32; i++)
{
if (_HAS_BIT(hdr.flags.get(), i))
mFlags.addElement((aci::Flag)i);
}
mProgramIdRestrict.min = hdr.program_id_min.get();
mProgramIdRestrict.max = hdr.program_id_max.get();
mFileSystemAccessControl.fromBytes(mRawBinary.data() + hdr.fac.offset.get(), hdr.fac.size.get());
mServiceAccessControl.fromBytes(mRawBinary.data() + hdr.sac.offset.get(), hdr.sac.size.get());
mKernelCapabilities.fromBytes(mRawBinary.data() + hdr.kc.offset.get(), hdr.kc.size.get());
}
const fnd::Vec<byte_t>& nn::hac::AccessControlInfoDescBinary::getBytes() const
{
return mRawBinary;
}
void nn::hac::AccessControlInfoDescBinary::generateSignature(const fnd::rsa::sRsa2048Key& key)
{
if (mRawBinary.size() == 0)
toBytes();
byte_t hash[fnd::sha::kSha256HashLen];
fnd::sha::Sha256(mRawBinary.data() + fnd::rsa::kRsa2048Size, mRawBinary.size() - fnd::rsa::kRsa2048Size, hash);
if (fnd::rsa::pss::rsaSign(key, fnd::sha::HASH_SHA256, hash, mRawBinary.data()) != 0)
{
throw fnd::Exception(kModuleName, "Failed to sign Access Control Info Desc");
}
}
void nn::hac::AccessControlInfoDescBinary::validateSignature(const fnd::rsa::sRsa2048Key& key) const
{
if (mRawBinary.size() == 0)
throw fnd::Exception(kModuleName, "No Access Control Info Desc binary exists to verify");
byte_t hash[fnd::sha::kSha256HashLen];
fnd::sha::Sha256(mRawBinary.data() + fnd::rsa::kRsa2048Size, mRawBinary.size() - fnd::rsa::kRsa2048Size, hash);
if (fnd::rsa::pss::rsaVerify(key, fnd::sha::HASH_SHA256, hash, mRawBinary.data()) != 0)
{
throw fnd::Exception(kModuleName, "Failed to verify Access Control Info Desc");
}
}
void nn::hac::AccessControlInfoDescBinary::clear()
{
mRawBinary.clear();
memset((void*)&mNcaHeaderSignature2Key, 0, sizeof(mNcaHeaderSignature2Key));
mFlags.clear();
mProgramIdRestrict.min = 0;
mProgramIdRestrict.max = 0;
mFileSystemAccessControl.clear();
mServiceAccessControl.clear();
mKernelCapabilities.clear();
}
const fnd::rsa::sRsa2048Key& nn::hac::AccessControlInfoDescBinary::getNcaHeaderSignature2Key() const
{
return mNcaHeaderSignature2Key;
}
void nn::hac::AccessControlInfoDescBinary::setNcaHeaderSignature2Key(const fnd::rsa::sRsa2048Key& key)
{
mNcaHeaderSignature2Key = key;
}
const fnd::List<nn::hac::aci::Flag>& nn::hac::AccessControlInfoDescBinary::getFlagList() const
{
return mFlags;
}
void nn::hac::AccessControlInfoDescBinary::setFlagList(const fnd::List<nn::hac::aci::Flag>& flags)
{
mFlags = flags;
}
const nn::hac::AccessControlInfoDescBinary::sProgramIdRestrict& nn::hac::AccessControlInfoDescBinary::getProgramIdRestrict() const
{
return mProgramIdRestrict;
}
void nn::hac::AccessControlInfoDescBinary::setProgramIdRestrict(const sProgramIdRestrict& pid_restrict)
{
mProgramIdRestrict = pid_restrict;
}
const nn::hac::FileSystemAccessControlBinary& nn::hac::AccessControlInfoDescBinary::getFileSystemAccessControl() const
{
return mFileSystemAccessControl;
}
void nn::hac::AccessControlInfoDescBinary::setFileSystemAccessControl(const nn::hac::FileSystemAccessControlBinary& fac)
{
mFileSystemAccessControl = fac;
}
const nn::hac::ServiceAccessControlBinary& nn::hac::AccessControlInfoDescBinary::getServiceAccessControl() const
{
return mServiceAccessControl;
}
void nn::hac::AccessControlInfoDescBinary::setServiceAccessControl(const nn::hac::ServiceAccessControlBinary& sac)
{
mServiceAccessControl = sac;
}
const nn::hac::KernelCapabilityBinary& nn::hac::AccessControlInfoDescBinary::getKernelCapabilities() const
{
return mKernelCapabilities;
}
void nn::hac::AccessControlInfoDescBinary::setKernelCapabilities(const nn::hac::KernelCapabilityBinary& kc)
{
mKernelCapabilities = kc;
#include <nn/hac/AccessControlInfoDesc.h>
nn::hac::AccessControlInfoDesc::AccessControlInfoDesc()
{
clear();
}
nn::hac::AccessControlInfoDesc::AccessControlInfoDesc(const AccessControlInfoDesc & other)
{
*this = other;
}
void nn::hac::AccessControlInfoDesc::operator=(const AccessControlInfoDesc & other)
{
mRawBinary = other.mRawBinary;
mContentArchiveHeaderSignature2Key = other.mContentArchiveHeaderSignature2Key;
mFlags = other.mFlags;
mProgramIdRestrict = other.mProgramIdRestrict;
mFileSystemAccessControl = other.mFileSystemAccessControl;
mServiceAccessControl = other.mServiceAccessControl;
mKernelCapabilities = other.mKernelCapabilities;
}
bool nn::hac::AccessControlInfoDesc::operator==(const AccessControlInfoDesc & other) const
{
return (mContentArchiveHeaderSignature2Key == other.mContentArchiveHeaderSignature2Key) \
&& (mFlags == other.mFlags) \
&& (mProgramIdRestrict == other.mProgramIdRestrict) \
&& (mFileSystemAccessControl == other.mFileSystemAccessControl) \
&& (mServiceAccessControl == other.mServiceAccessControl) \
&& (mKernelCapabilities == other.mKernelCapabilities);
}
bool nn::hac::AccessControlInfoDesc::operator!=(const AccessControlInfoDesc & other) const
{
return !(*this == other);
}
void nn::hac::AccessControlInfoDesc::toBytes()
{
// serialise the sections
mFileSystemAccessControl.toBytes();
mServiceAccessControl.toBytes();
mKernelCapabilities.toBytes();
// determine section layout
struct sLayout {
uint32_t offset, size;
} fac, sac, kc;
fac.offset = (uint32_t)align(sizeof(sAciDescHeader), aci::kSectionAlignSize);
fac.size = (uint32_t)mFileSystemAccessControl.getBytes().size();
sac.offset = (uint32_t)align(fac.offset + fac.size, aci::kSectionAlignSize);
sac.size = (uint32_t)mServiceAccessControl.getBytes().size();
kc.offset = (uint32_t)align(sac.offset + sac.size, aci::kSectionAlignSize);
kc.size = (uint32_t)mKernelCapabilities.getBytes().size();
// get total size
size_t total_size = _MAX(_MAX(fac.offset + fac.size, sac.offset + sac.size), kc.offset + kc.size);
mRawBinary.alloc(total_size);
sAciDescHeader* hdr = (sAciDescHeader*)mRawBinary.data();
// set rsa modulus
memcpy(hdr->nca_rsa_signature2_modulus, mContentArchiveHeaderSignature2Key.modulus, fnd::rsa::kRsa2048Size);
// set type
hdr->st_magic = aci::kAciDescStructMagic;
// set "acid size"
hdr->signed_size = (uint32_t)(total_size - fnd::rsa::kRsa2048Size);
// set flags
uint32_t flags = 0;
for (size_t i = 0; i < mFlags.size(); i++)
flags |= _BIT(mFlags[i]);
hdr->flags = flags;
// set program id restrict settings
hdr->program_id_min = mProgramIdRestrict.min;
hdr->program_id_max = mProgramIdRestrict.max;
// set offset/size
hdr->fac.offset = fac.offset;
hdr->fac.size = fac.size;
hdr->sac.offset = sac.offset;
hdr->sac.size = sac.size;
hdr->kc.offset = kc.offset;
hdr->kc.size = kc.size;
// write data
memcpy(mRawBinary.data() + fac.offset, mFileSystemAccessControl.getBytes().data(), fac.size);
memcpy(mRawBinary.data() + sac.offset, mServiceAccessControl.getBytes().data(), sac.size);
memcpy(mRawBinary.data() + kc.offset, mKernelCapabilities.getBytes().data(), kc.size);
}
void nn::hac::AccessControlInfoDesc::fromBytes(const byte_t* data, size_t len)
{
// check size
if (len < sizeof(sAciDescHeader))
{
throw fnd::Exception(kModuleName, "AccessControlInfoDesc binary is too small");
}
// clear variables
clear();
// save a copy of the header
sAciDescHeader hdr;
memcpy((void*)&hdr, data, sizeof(sAciDescHeader));
// check magic
if (hdr.st_magic.get() != aci::kAciDescStructMagic)
{
throw fnd::Exception(kModuleName, "AccessControlInfoDesc header corrupt");
}
// get total size
size_t total_size = _MAX(_MAX(hdr.fac.offset.get() + hdr.fac.size.get(), hdr.sac.offset.get() + hdr.sac.size.get()), hdr.kc.offset.get() + hdr.kc.size.get());
// validate binary size
if (len < total_size)
{
throw fnd::Exception(kModuleName, "AccessControlInfoDesc binary is too small");
}
// allocate memory for header
mRawBinary.alloc(total_size);
memcpy(mRawBinary.data(), data, mRawBinary.size());
// save variables
memcpy(mContentArchiveHeaderSignature2Key.modulus, hdr.nca_rsa_signature2_modulus, fnd::rsa::kRsa2048Size);
for (size_t i = 0; i < 32; i++)
{
if (_HAS_BIT(hdr.flags.get(), i))
mFlags.addElement((aci::Flag)i);
}
mProgramIdRestrict.min = hdr.program_id_min.get();
mProgramIdRestrict.max = hdr.program_id_max.get();
mFileSystemAccessControl.fromBytes(mRawBinary.data() + hdr.fac.offset.get(), hdr.fac.size.get());
mServiceAccessControl.fromBytes(mRawBinary.data() + hdr.sac.offset.get(), hdr.sac.size.get());
mKernelCapabilities.fromBytes(mRawBinary.data() + hdr.kc.offset.get(), hdr.kc.size.get());
}
const fnd::Vec<byte_t>& nn::hac::AccessControlInfoDesc::getBytes() const
{
return mRawBinary;
}
void nn::hac::AccessControlInfoDesc::generateSignature(const fnd::rsa::sRsa2048Key& key)
{
if (mRawBinary.size() == 0)
toBytes();
byte_t hash[fnd::sha::kSha256HashLen];
fnd::sha::Sha256(mRawBinary.data() + fnd::rsa::kRsa2048Size, mRawBinary.size() - fnd::rsa::kRsa2048Size, hash);
if (fnd::rsa::pss::rsaSign(key, fnd::sha::HASH_SHA256, hash, mRawBinary.data()) != 0)
{
throw fnd::Exception(kModuleName, "Failed to sign Access Control Info Desc");
}
}
void nn::hac::AccessControlInfoDesc::validateSignature(const fnd::rsa::sRsa2048Key& key) const
{
if (mRawBinary.size() == 0)
throw fnd::Exception(kModuleName, "No Access Control Info Desc binary exists to verify");
byte_t hash[fnd::sha::kSha256HashLen];
fnd::sha::Sha256(mRawBinary.data() + fnd::rsa::kRsa2048Size, mRawBinary.size() - fnd::rsa::kRsa2048Size, hash);
if (fnd::rsa::pss::rsaVerify(key, fnd::sha::HASH_SHA256, hash, mRawBinary.data()) != 0)
{
throw fnd::Exception(kModuleName, "Failed to verify Access Control Info Desc");
}
}
void nn::hac::AccessControlInfoDesc::clear()
{
mRawBinary.clear();
memset((void*)&mContentArchiveHeaderSignature2Key, 0, sizeof(mContentArchiveHeaderSignature2Key));
mFlags.clear();
mProgramIdRestrict.min = 0;
mProgramIdRestrict.max = 0;
mFileSystemAccessControl.clear();
mServiceAccessControl.clear();
mKernelCapabilities.clear();
}
const fnd::rsa::sRsa2048Key& nn::hac::AccessControlInfoDesc::getContentArchiveHeaderSignature2Key() const
{
return mContentArchiveHeaderSignature2Key;
}
void nn::hac::AccessControlInfoDesc::setContentArchiveHeaderSignature2Key(const fnd::rsa::sRsa2048Key& key)
{
mContentArchiveHeaderSignature2Key = key;
}
const fnd::List<nn::hac::aci::Flag>& nn::hac::AccessControlInfoDesc::getFlagList() const
{
return mFlags;
}
void nn::hac::AccessControlInfoDesc::setFlagList(const fnd::List<nn::hac::aci::Flag>& flags)
{
mFlags = flags;
}
const nn::hac::AccessControlInfoDesc::sProgramIdRestrict& nn::hac::AccessControlInfoDesc::getProgramIdRestrict() const
{
return mProgramIdRestrict;
}
void nn::hac::AccessControlInfoDesc::setProgramIdRestrict(const sProgramIdRestrict& pid_restrict)
{
mProgramIdRestrict = pid_restrict;
}
const nn::hac::FileSystemAccessControl& nn::hac::AccessControlInfoDesc::getFileSystemAccessControl() const
{
return mFileSystemAccessControl;
}
void nn::hac::AccessControlInfoDesc::setFileSystemAccessControl(const nn::hac::FileSystemAccessControl& fac)
{
mFileSystemAccessControl = fac;
}
const nn::hac::ServiceAccessControl& nn::hac::AccessControlInfoDesc::getServiceAccessControl() const
{
return mServiceAccessControl;
}
void nn::hac::AccessControlInfoDesc::setServiceAccessControl(const nn::hac::ServiceAccessControl& sac)
{
mServiceAccessControl = sac;
}
const nn::hac::KernelCapabilityControl& nn::hac::AccessControlInfoDesc::getKernelCapabilities() const
{
return mKernelCapabilities;
}
void nn::hac::AccessControlInfoDesc::setKernelCapabilities(const nn::hac::KernelCapabilityControl& kc)
{
mKernelCapabilities = kc;
}

View file

@ -0,0 +1,84 @@
#include <nn/hac/AddOnContentMetaExtendedHeader.h>
nn::hac::AddOnContentMetaExtendedHeader::AddOnContentMetaExtendedHeader()
{
clear();
}
nn::hac::AddOnContentMetaExtendedHeader::AddOnContentMetaExtendedHeader(const AddOnContentMetaExtendedHeader& other)
{
*this = other;
}
void nn::hac::AddOnContentMetaExtendedHeader::operator=(const AddOnContentMetaExtendedHeader& other)
{
clear();
mRawBinary = other.mRawBinary;
mApplicationId = other.mApplicationId;
mRequiredApplicationVersion = other.mRequiredApplicationVersion;
}
bool nn::hac::AddOnContentMetaExtendedHeader::operator==(const AddOnContentMetaExtendedHeader& other) const
{
return (mApplicationId == other.mApplicationId) \
&& (mRequiredApplicationVersion == other.mRequiredApplicationVersion);
}
bool nn::hac::AddOnContentMetaExtendedHeader::operator!=(const AddOnContentMetaExtendedHeader& other) const
{
return !(*this == other);
}
void nn::hac::AddOnContentMetaExtendedHeader::toBytes()
{
mRawBinary.alloc(sizeof(sAddOnContentMetaExtendedHeader));
sAddOnContentMetaExtendedHeader* info = (sAddOnContentMetaExtendedHeader*)mRawBinary.data();
info->application_id = mApplicationId;
info->required_application_version = mRequiredApplicationVersion;
}
void nn::hac::AddOnContentMetaExtendedHeader::fromBytes(const byte_t* bytes, size_t len)
{
if (len < sizeof(sAddOnContentMetaExtendedHeader))
{
throw fnd::Exception(kModuleName, "AddOnContentMetaExtendedHeader too small");
}
const sAddOnContentMetaExtendedHeader* info = (const sAddOnContentMetaExtendedHeader*)bytes;
mApplicationId = info->application_id.get();
mRequiredApplicationVersion = info->required_application_version.get();
}
const fnd::Vec<byte_t>& nn::hac::AddOnContentMetaExtendedHeader::getBytes() const
{
return mRawBinary;
}
void nn::hac::AddOnContentMetaExtendedHeader::clear()
{
mRawBinary.clear();
mApplicationId = 0;
mRequiredApplicationVersion = 0;
}
uint64_t nn::hac::AddOnContentMetaExtendedHeader::getApplicationId() const
{
return mApplicationId;
}
void nn::hac::AddOnContentMetaExtendedHeader::setApplicationId(uint64_t application_id)
{
mApplicationId = application_id;
}
uint32_t nn::hac::AddOnContentMetaExtendedHeader::getRequiredApplicationVersion() const
{
return mRequiredApplicationVersion;
}
void nn::hac::AddOnContentMetaExtendedHeader::setRequiredApplicationVersion(uint32_t sys_ver)
{
mRequiredApplicationVersion = sys_ver;
}

View file

@ -0,0 +1,84 @@
#include <nn/hac/ApplicationMetaExtendedHeader.h>
nn::hac::ApplicationMetaExtendedHeader::ApplicationMetaExtendedHeader()
{
clear();
}
nn::hac::ApplicationMetaExtendedHeader::ApplicationMetaExtendedHeader(const ApplicationMetaExtendedHeader& other)
{
*this = other;
}
void nn::hac::ApplicationMetaExtendedHeader::operator=(const ApplicationMetaExtendedHeader& other)
{
clear();
mRawBinary = other.mRawBinary;
mPatchId = other.mPatchId;
mRequiredSystemVersion = other.mRequiredSystemVersion;
}
bool nn::hac::ApplicationMetaExtendedHeader::operator==(const ApplicationMetaExtendedHeader& other) const
{
return (mPatchId == other.mPatchId) \
&& (mRequiredSystemVersion == other.mRequiredSystemVersion);
}
bool nn::hac::ApplicationMetaExtendedHeader::operator!=(const ApplicationMetaExtendedHeader& other) const
{
return !(*this == other);
}
void nn::hac::ApplicationMetaExtendedHeader::toBytes()
{
mRawBinary.alloc(sizeof(sApplicationMetaExtendedHeader));
sApplicationMetaExtendedHeader* info = (sApplicationMetaExtendedHeader*)mRawBinary.data();
info->patch_id = mPatchId;
info->required_system_version = mRequiredSystemVersion;
}
void nn::hac::ApplicationMetaExtendedHeader::fromBytes(const byte_t* bytes, size_t len)
{
if (len < sizeof(sApplicationMetaExtendedHeader))
{
throw fnd::Exception(kModuleName, "ApplicationMetaExtendedHeader too small");
}
const sApplicationMetaExtendedHeader* info = (const sApplicationMetaExtendedHeader*)bytes;
mPatchId = info->patch_id.get();
mRequiredSystemVersion = info->required_system_version.get();
}
const fnd::Vec<byte_t>& nn::hac::ApplicationMetaExtendedHeader::getBytes() const
{
return mRawBinary;
}
void nn::hac::ApplicationMetaExtendedHeader::clear()
{
mRawBinary.clear();
mPatchId = 0;
mRequiredSystemVersion = 0;
}
uint64_t nn::hac::ApplicationMetaExtendedHeader::getPatchId() const
{
return mPatchId;
}
void nn::hac::ApplicationMetaExtendedHeader::setPatchId(uint64_t application_id)
{
mPatchId = application_id;
}
uint32_t nn::hac::ApplicationMetaExtendedHeader::getRequiredSystemVersion() const
{
return mRequiredSystemVersion;
}
void nn::hac::ApplicationMetaExtendedHeader::setRequiredSystemVersion(uint32_t sys_ver)
{
mRequiredSystemVersion = sys_ver;
}

View file

@ -0,0 +1,334 @@
#include <nn/hac/ContentArchiveHeader.h>
nn::hac::ContentArchiveHeader::ContentArchiveHeader()
{
mRightsId.alloc(nca::kRightsIdLen);
mKeyArea.alloc(nca::kKeyAreaSize);
clear();
}
nn::hac::ContentArchiveHeader::ContentArchiveHeader(const ContentArchiveHeader & other) :
ContentArchiveHeader()
{
*this = other;
}
bool nn::hac::ContentArchiveHeader::operator==(const ContentArchiveHeader & other) const
{
return (mFormatVersion == other.mFormatVersion) \
&& (mDistributionType == other.mDistributionType) \
&& (mContentType == other.mContentType) \
&& (mKeyGeneration == other.mKeyGeneration) \
&& (mKaekIndex == other.mKaekIndex) \
&& (mContentSize == other.mContentSize) \
&& (mProgramId == other.mProgramId) \
&& (mContentIndex == other.mContentIndex) \
&& (mSdkAddonVersion == other.mSdkAddonVersion) \
&& (mRightsId == other.mRightsId) \
&& (mPartitionEntryList == other.mPartitionEntryList) \
&& (mKeyArea == other.mKeyArea);
}
bool nn::hac::ContentArchiveHeader::operator!=(const ContentArchiveHeader & other) const
{
return !(*this == other);
}
void nn::hac::ContentArchiveHeader::operator=(const ContentArchiveHeader & other)
{
mRawBinary = other.mRawBinary;
mDistributionType = other.mDistributionType;
mContentType = other.mContentType;
mKeyGeneration = other.mKeyGeneration;
mKaekIndex = other.mKaekIndex;
mContentSize = other.mContentSize;
mProgramId = other.mProgramId;
mContentIndex = other.mContentIndex;
mSdkAddonVersion = other.mSdkAddonVersion;
mRightsId = other.mRightsId;
mPartitionEntryList = other.mPartitionEntryList;
mKeyArea = other.mKeyArea;
}
void nn::hac::ContentArchiveHeader::toBytes()
{
mRawBinary.alloc(sizeof(sContentArchiveHeader));
sContentArchiveHeader* hdr = (sContentArchiveHeader*)mRawBinary.data();
// set header magic
switch(mFormatVersion)
{
case (nca::FORMAT_NCA2):
hdr->st_magic = nca::kNca2StructMagic;
break;
case (nca::FORMAT_NCA3):
hdr->st_magic = nca::kNca3StructMagic;
break;
default:
throw fnd::Exception(kModuleName, "Unsupported format version");
}
// set variables
hdr->distribution_type = mDistributionType;
hdr->content_type = mContentType;
if (mKeyGeneration > 2)
{
hdr->key_generation = 2;
hdr->key_generation_2 = mKeyGeneration;
}
else
{
hdr->key_generation = mKeyGeneration;
hdr->key_generation_2 = 0;
}
hdr->key_area_encryption_key_index = mKaekIndex;
hdr->content_size = mContentSize;
hdr->program_id = mProgramId;
hdr->content_index = mContentIndex;
hdr->sdk_addon_version = mSdkAddonVersion;
memcpy(hdr->rights_id, mRightsId.data(), nca::kRightsIdLen);
memcpy(hdr->key_area, mKeyArea.data(), nca::kKeyAreaSize);
for (size_t i = 0; i < mPartitionEntryList.size(); i++)
{
byte_t index = mPartitionEntryList[i].header_index;
if (index >= nca::kPartitionNum) continue;
hdr->partition_entry[index].start_blk = sizeToBlockNum(mPartitionEntryList[index].offset);
hdr->partition_entry[index].end_blk = (sizeToBlockNum(mPartitionEntryList[index].offset) + sizeToBlockNum(mPartitionEntryList[index].size));
hdr->partition_entry[index].enabled = true;
hdr->fs_header_hash[index] = mPartitionEntryList[i].fs_header_hash;
}
}
void nn::hac::ContentArchiveHeader::fromBytes(const byte_t * data, size_t len)
{
if (len < sizeof(sContentArchiveHeader))
{
throw fnd::Exception(kModuleName, "ContentArchive header size is too small");
}
clear();
mRawBinary.alloc(sizeof(sContentArchiveHeader));
memcpy(mRawBinary.data(), data, sizeof(sContentArchiveHeader));
sContentArchiveHeader* hdr = (sContentArchiveHeader*)mRawBinary.data();
// check magic
switch(hdr->st_magic.get())
{
case (nca::kNca2StructMagic) :
mFormatVersion = nca::FORMAT_NCA2;
break;
case (nca::kNca3StructMagic) :
mFormatVersion = nca::FORMAT_NCA3;
break;
throw fnd::Exception(kModuleName, "ContentArchive header corrupt (unrecognised header magic).");
}
// variables
mDistributionType = (nca::DistributionType)hdr->distribution_type;
mContentType = (nca::ContentType)hdr->content_type;
mKeyGeneration = _MAX(hdr->key_generation, hdr->key_generation_2);
mKaekIndex = hdr->key_area_encryption_key_index;
mContentSize = *hdr->content_size;
mProgramId = *hdr->program_id;
mContentIndex = *hdr->content_index;
mSdkAddonVersion = *hdr->sdk_addon_version;
memcpy(mRightsId.data(), hdr->rights_id, nca::kRightsIdLen);
memcpy(mKeyArea.data(), hdr->key_area, nca::kKeyAreaSize);
for (size_t i = 0; i < nca::kPartitionNum; i++)
{
if (hdr->partition_entry[i].enabled)
{
mPartitionEntryList.addElement({(byte_t)i, blockNumToSize(hdr->partition_entry[i].start_blk.get()), blockNumToSize(hdr->partition_entry[i].end_blk.get() - hdr->partition_entry[i].start_blk.get()), hdr->fs_header_hash[i] });
}
}
}
const fnd::Vec<byte_t>& nn::hac::ContentArchiveHeader::getBytes() const
{
return mRawBinary;
}
void nn::hac::ContentArchiveHeader::clear()
{
mFormatVersion = nca::FORMAT_NCA3;
mDistributionType = nca::DIST_DOWNLOAD;
mContentType = nca::TYPE_PROGRAM;
mKeyGeneration = 0;
mKaekIndex = 0;
mContentSize = 0;
mProgramId = 0;
mContentIndex = 0;
mSdkAddonVersion = 0;
memset(mRightsId.data(), 0, mRightsId.size());
mPartitionEntryList.clear();
memset(mKeyArea.data(), 0, mKeyArea.size());
}
byte_t nn::hac::ContentArchiveHeader::getFormatVersion() const
{
return mFormatVersion;
}
void nn::hac::ContentArchiveHeader::setFormatVersion(byte_t version)
{
mFormatVersion = version;
}
nn::hac::nca::DistributionType nn::hac::ContentArchiveHeader::getDistributionType() const
{
return mDistributionType;
}
void nn::hac::ContentArchiveHeader::setDistributionType(nca::DistributionType type)
{
mDistributionType = type;
}
nn::hac::nca::ContentType nn::hac::ContentArchiveHeader::getContentType() const
{
return mContentType;
}
void nn::hac::ContentArchiveHeader::setContentType(nca::ContentType type)
{
mContentType = type;
}
byte_t nn::hac::ContentArchiveHeader::getKeyGeneration() const
{
return mKeyGeneration;
}
void nn::hac::ContentArchiveHeader::setKeyGeneration(byte_t gen)
{
mKeyGeneration = gen;
}
byte_t nn::hac::ContentArchiveHeader::getKeyAreaEncryptionKeyIndex() const
{
return mKaekIndex;
}
void nn::hac::ContentArchiveHeader::setKeyAreaEncryptionKeyIndex(byte_t index)
{
mKaekIndex = index;
}
uint64_t nn::hac::ContentArchiveHeader::getContentSize() const
{
return mContentSize;
}
void nn::hac::ContentArchiveHeader::setContentSize(uint64_t size)
{
mContentSize = size;
}
uint64_t nn::hac::ContentArchiveHeader::getProgramId() const
{
return mProgramId;
}
void nn::hac::ContentArchiveHeader::setProgramId(uint64_t program_id)
{
mProgramId = program_id;
}
uint32_t nn::hac::ContentArchiveHeader::getContentIndex() const
{
return mContentIndex;
}
void nn::hac::ContentArchiveHeader::setContentIndex(uint32_t index)
{
mContentIndex = index;
}
uint32_t nn::hac::ContentArchiveHeader::getSdkAddonVersion() const
{
return mSdkAddonVersion;
}
void nn::hac::ContentArchiveHeader::setSdkAddonVersion(uint32_t version)
{
mSdkAddonVersion = version;
}
bool nn::hac::ContentArchiveHeader::hasRightsId() const
{
bool rightsIdIsSet = false;
for (size_t i = 0; i < nca::kRightsIdLen; i++)
{
if (mRightsId[i] != 0)
rightsIdIsSet = true;
}
return rightsIdIsSet;
}
const byte_t* nn::hac::ContentArchiveHeader::getRightsId() const
{
return mRightsId.data();
}
void nn::hac::ContentArchiveHeader::setRightsId(const byte_t* rights_id)
{
memcpy(mRightsId.data(), rights_id, nca::kRightsIdLen);
}
const fnd::List<nn::hac::ContentArchiveHeader::sPartitionEntry>& nn::hac::ContentArchiveHeader::getPartitionEntryList() const
{
return mPartitionEntryList;
}
void nn::hac::ContentArchiveHeader::setPartitionEntryList(const fnd::List<nn::hac::ContentArchiveHeader::sPartitionEntry>& partition_entry_list)
{
mPartitionEntryList = partition_entry_list;
// sanity check the list
if (mPartitionEntryList.size() >= nca::kPartitionNum)
{
throw fnd::Exception(kModuleName, "Too many partitions");
}
for (size_t i = 0; i < mPartitionEntryList.size(); i++)
{
if (mPartitionEntryList[i].header_index >= nca::kPartitionNum)
{
throw fnd::Exception(kModuleName, "Illegal partition index");
}
for (size_t j = i+1; j < mPartitionEntryList.size(); j++)
{
if (mPartitionEntryList[i].header_index == mPartitionEntryList[j].header_index)
{
throw fnd::Exception(kModuleName, "Duplicated partition index");
}
}
}
}
const byte_t* nn::hac::ContentArchiveHeader::getKeyArea() const
{
return mKeyArea.data();
}
void nn::hac::ContentArchiveHeader::setKeyArea(const byte_t* key_area)
{
memcpy(mKeyArea.data(), key_area, nca::kKeyAreaSize);
}
uint64_t nn::hac::ContentArchiveHeader::blockNumToSize(uint32_t block_num) const
{
return block_num * nca::kSectorSize;
}
uint32_t nn::hac::ContentArchiveHeader::sizeToBlockNum(uint64_t real_size) const
{
return (uint32_t)(align(real_size, nca::kSectorSize) / nca::kSectorSize);
}

View file

@ -1,58 +1,58 @@
#include <nn/hac/NcaUtils.h>
void nn::hac::NcaUtils::decryptNcaHeader(const byte_t* src, byte_t* dst, const fnd::aes::sAesXts128Key& key)
{
byte_t tweak[fnd::aes::kAesBlockSize];
// decrypt main header
byte_t raw_hdr[nn::hac::nca::kSectorSize];
fnd::aes::AesXtsMakeTweak(tweak, 1);
fnd::aes::AesXtsDecryptSector(src + sectorToOffset(1), nn::hac::nca::kSectorSize, key.key[0], key.key[1], tweak, raw_hdr);
bool useNca2SectorIndex = ((nn::hac::sNcaHeader*)(raw_hdr))->st_magic.get() == nn::hac::nca::kNca2StructMagic;
// decrypt whole header
for (size_t i = 0; i < nn::hac::nca::kHeaderSectorNum; i++)
{
fnd::aes::AesXtsMakeTweak(tweak, (i > 1 && useNca2SectorIndex)? 0 : i);
fnd::aes::AesXtsDecryptSector(src + sectorToOffset(i), nn::hac::nca::kSectorSize, key.key[0], key.key[1], tweak, dst + sectorToOffset(i));
}
}
byte_t nn::hac::NcaUtils::getMasterKeyRevisionFromKeyGeneration(byte_t key_generation)
{
byte_t masterkey_rev;
switch (key_generation)
{
case(0):
case(1):
masterkey_rev = 0;
break;
case(2):
masterkey_rev = 1;
break;
case(3):
masterkey_rev = 2;
break;
case(4):
masterkey_rev = 3;
break;
case(5):
masterkey_rev = 4;
break;
default:
masterkey_rev = key_generation - 1;
}
return masterkey_rev;
}
void nn::hac::NcaUtils::getNcaPartitionAesCtr(const nn::hac::sNcaFsHeader* hdr, byte_t* ctr)
{
for (size_t i = 0; i < 8; i++)
{
ctr[7-i] = hdr->aes_ctr_upper[i];
ctr[15-i] = 0;
}
#include <nn/hac/ContentArchiveUtils.h>
void nn::hac::ContentArchiveUtils::decryptContentArchiveHeader(const byte_t* src, byte_t* dst, const fnd::aes::sAesXts128Key& key)
{
byte_t tweak[fnd::aes::kAesBlockSize];
// decrypt main header
byte_t raw_hdr[nn::hac::nca::kSectorSize];
fnd::aes::AesXtsMakeTweak(tweak, 1);
fnd::aes::AesXtsDecryptSector(src + sectorToOffset(1), nn::hac::nca::kSectorSize, key.key[0], key.key[1], tweak, raw_hdr);
bool useNca2SectorIndex = ((nn::hac::sContentArchiveHeader*)(raw_hdr))->st_magic.get() == nn::hac::nca::kNca2StructMagic;
// decrypt whole header
for (size_t i = 0; i < nn::hac::nca::kHeaderSectorNum; i++)
{
fnd::aes::AesXtsMakeTweak(tweak, (i > 1 && useNca2SectorIndex)? 0 : i);
fnd::aes::AesXtsDecryptSector(src + sectorToOffset(i), nn::hac::nca::kSectorSize, key.key[0], key.key[1], tweak, dst + sectorToOffset(i));
}
}
byte_t nn::hac::ContentArchiveUtils::getMasterKeyRevisionFromKeyGeneration(byte_t key_generation)
{
byte_t masterkey_rev;
switch (key_generation)
{
case(0):
case(1):
masterkey_rev = 0;
break;
case(2):
masterkey_rev = 1;
break;
case(3):
masterkey_rev = 2;
break;
case(4):
masterkey_rev = 3;
break;
case(5):
masterkey_rev = 4;
break;
default:
masterkey_rev = key_generation - 1;
}
return masterkey_rev;
}
void nn::hac::ContentArchiveUtils::getNcaPartitionAesCtr(const nn::hac::sNcaFsHeader* hdr, byte_t* ctr)
{
for (size_t i = 0; i < 8; i++)
{
ctr[7-i] = hdr->aes_ctr_upper[i];
ctr[15-i] = 0;
}
}

View file

@ -0,0 +1,123 @@
#include <nn/hac/ContentInfo.h>
nn::hac::ContentInfo::ContentInfo()
{
clear();
}
nn::hac::ContentInfo::ContentInfo(const ContentInfo& other)
{
*this = other;
}
void nn::hac::ContentInfo::operator=(const ContentInfo& other)
{
clear();
mRawBinary = other.mRawBinary;
mHash = other.mHash;
mContentId = other.mContentId;
mSize = other.mSize;
mType = other.mType;
}
bool nn::hac::ContentInfo::operator==(const ContentInfo& other) const
{
return (mHash == other.mHash) \
&& (mContentId == other.mContentId) \
&& (mSize == other.mSize) \
&& (mType == other.mType);
}
bool nn::hac::ContentInfo::operator!=(const ContentInfo& other) const
{
return !(*this == other);
}
void nn::hac::ContentInfo::toBytes()
{
mRawBinary.alloc(sizeof(sContentInfo));
sContentInfo* info = (sContentInfo*)mRawBinary.data();
info->content_hash = mHash;
info->content_id = mContentId;
info->size_lower = mSize & (uint32_t)(-1);
info->size_higher = (mSize >> 32) & (uint16_t)(-1);
info->content_type = mType;
info->id_offset = mIdOffset;
}
void nn::hac::ContentInfo::fromBytes(const byte_t* bytes, size_t len)
{
if (len < sizeof(sContentInfo))
{
throw fnd::Exception(kModuleName, "ContentInfo too small");
}
const sContentInfo* info = (const sContentInfo*)bytes;
mHash = info->content_hash;
mContentId = info->content_id;
mSize = (uint64_t)(info->size_lower.get()) | (uint64_t)(info->size_higher.get()) << 32;
mType = (cnmt::ContentType)info->content_type;
mIdOffset = info->id_offset;
}
const fnd::Vec<byte_t>& nn::hac::ContentInfo::getBytes() const
{
return mRawBinary;
}
void nn::hac::ContentInfo::clear()
{
mRawBinary.clear();
}
const fnd::sha::sSha256Hash& nn::hac::ContentInfo::getContentHash() const
{
return mHash;
}
void nn::hac::ContentInfo::setContentHash(const fnd::sha::sSha256Hash& hash)
{
mHash = hash;
}
const nn::hac::cnmt::sContentId& nn::hac::ContentInfo::getContentId() const
{
return mContentId;
}
void nn::hac::ContentInfo::setContentId(const cnmt::sContentId& content_id)
{
mContentId = content_id;
}
size_t nn::hac::ContentInfo::getContentSize() const
{
return mSize;
}
void nn::hac::ContentInfo::setContentSize(size_t size)
{
mSize = size;
}
nn::hac::cnmt::ContentType nn::hac::ContentInfo::getContentType() const
{
return mType;
}
void nn::hac::ContentInfo::setContentType(cnmt::ContentType type)
{
mType = type;
}
byte_t nn::hac::ContentInfo::getIdOffset() const
{
return mIdOffset;
}
void nn::hac::ContentInfo::setIdOffset(byte_t id_offset)
{
mIdOffset = id_offset;
}

View file

@ -1,380 +1,368 @@
#include <nn/hac/ContentMetaBinary.h>
nn::hac::ContentMetaBinary::ContentMetaBinary()
{
clear();
}
nn::hac::ContentMetaBinary::ContentMetaBinary(const ContentMetaBinary & other)
{
*this = other;
}
void nn::hac::ContentMetaBinary::operator=(const ContentMetaBinary& other)
{
if (other.getBytes().size() > 0)
{
fromBytes(other.getBytes().data(), other.getBytes().size());
}
else
{
clear();
mTitleId = other.mTitleId;
mTitleVersion = other.mTitleVersion;
mType = other.mType;
mAttributes = other.mAttributes;
mRequiredDownloadSystemVersion = other.mRequiredDownloadSystemVersion;
mExtendedHeader = other.mExtendedHeader;
mApplicationMetaExtendedHeader = other.mApplicationMetaExtendedHeader;
mPatchMetaExtendedHeader = other.mPatchMetaExtendedHeader;
mAddOnContentMetaExtendedHeader = other.mAddOnContentMetaExtendedHeader;
mDeltaMetaExtendedHeader = other.mDeltaMetaExtendedHeader;
mContentInfo = other.mContentInfo;
mContentMetaInfo = other.mContentMetaInfo;
mExtendedData = other.mExtendedData;
memcpy(mDigest.data, other.mDigest.data, cnmt::kDigestLen);
}
}
bool nn::hac::ContentMetaBinary::operator==(const ContentMetaBinary& other) const
{
return (mTitleId == other.mTitleId) \
&& (mTitleVersion == other.mTitleVersion) \
&& (mType == other.mType) \
&& (mAttributes == other.mAttributes) \
&& (mRequiredDownloadSystemVersion == other.mRequiredDownloadSystemVersion) \
&& (mExtendedHeader == other.mExtendedHeader) \
&& (mApplicationMetaExtendedHeader == other.mApplicationMetaExtendedHeader) \
&& (mPatchMetaExtendedHeader == other.mPatchMetaExtendedHeader) \
&& (mAddOnContentMetaExtendedHeader == other.mAddOnContentMetaExtendedHeader) \
&& (mDeltaMetaExtendedHeader == other.mDeltaMetaExtendedHeader) \
&& (mContentInfo == other.mContentInfo) \
&& (mContentMetaInfo == other.mContentMetaInfo) \
&& (mExtendedData == other.mExtendedData) \
&& (memcmp(mDigest.data, other.mDigest.data, cnmt::kDigestLen) == 0);
}
bool nn::hac::ContentMetaBinary::operator!=(const ContentMetaBinary& other) const
{
return !(*this == other);
}
void nn::hac::ContentMetaBinary::toBytes()
{
throw fnd::Exception(kModuleName, "exportBinary() not implemented");
}
void nn::hac::ContentMetaBinary::fromBytes(const byte_t* data, size_t len)
{
// clear member variables
clear();
// validate layout
validateBinary(data, len);
// get pointer to header structure
const sContentMetaHeader* hdr = (const sContentMetaHeader*)data;
mTitleId = hdr->id.get();
mTitleVersion = hdr->version.get();
mType = (cnmt::ContentMetaType)hdr->type;
mAttributes = hdr->attributes;
mRequiredDownloadSystemVersion = hdr->required_download_system_version.get();
size_t exdata_size = 0;
// save exheader
if (hdr->exhdr_size.get() > 0)
{
mExtendedHeader.alloc(hdr->exhdr_size.get());
memcpy(mExtendedHeader.data(), data + getExtendedHeaderOffset(), hdr->exhdr_size.get());
switch (mType)
{
case (cnmt::METATYPE_APPLICATION):
mApplicationMetaExtendedHeader.patch_id = ((sApplicationMetaExtendedHeader*)mExtendedHeader.data())->patch_id.get();
mApplicationMetaExtendedHeader.required_system_version = ((sApplicationMetaExtendedHeader*)mExtendedHeader.data())->required_system_version.get();
break;
case (cnmt::METATYPE_PATCH):
mPatchMetaExtendedHeader.application_id = ((sPatchMetaExtendedHeader*)mExtendedHeader.data())->application_id.get();
mPatchMetaExtendedHeader.required_system_version = ((sPatchMetaExtendedHeader*)mExtendedHeader.data())->required_system_version.get();
break;
case (cnmt::METATYPE_ADD_ON_CONTENT):
mAddOnContentMetaExtendedHeader.application_id = ((sAddOnContentMetaExtendedHeader*)mExtendedHeader.data())->application_id.get();
mAddOnContentMetaExtendedHeader.required_application_version = ((sAddOnContentMetaExtendedHeader*)mExtendedHeader.data())->required_application_version.get();
break;
case (cnmt::METATYPE_DELTA):
mDeltaMetaExtendedHeader.application_id = ((sDeltaMetaExtendedHeader*)mExtendedHeader.data())->application_id.get();
break;
default:
break;
}
exdata_size = getExtendedDataSize(mType, mExtendedHeader.data());
}
// save content info
if (hdr->content_count.get() > 0)
{
const sContentInfo* info = (const sContentInfo*)(data + getContentInfoOffset(hdr->exhdr_size.get()));
ContentInfo cinfo;
for (size_t i = 0; i < hdr->content_count.get(); i++)
{
cinfo.hash = info[i].content_hash;
memcpy(cinfo.nca_id, info[i].content_id, cnmt::kContentIdLen);
cinfo.size = (uint64_t)(info[i].size_lower.get()) | (uint64_t)(info[i].size_higher.get()) << 32;
cinfo.type = (cnmt::ContentType)info[i].content_type;
mContentInfo.addElement(cinfo);
}
}
// save content meta info
if (hdr->content_meta_count.get() > 0)
{
const sContentMetaInfo* info = (const sContentMetaInfo*)(data + getContentMetaInfoOffset(hdr->exhdr_size.get(), hdr->content_count.get()));
ContentMetaInfo cmeta;
for (size_t i = 0; i < hdr->content_meta_count.get(); i++)
{
cmeta.id = info[i].id.get();
cmeta.version = info[i].version.get();
cmeta.type = (cnmt::ContentMetaType)info[i].type;
cmeta.attributes = info[i].attributes;
mContentMetaInfo.addElement(cmeta);
}
}
// save exdata
if (exdata_size > 0)
{
mExtendedData.alloc(exdata_size);
memcpy(mExtendedData.data(), data + getExtendedDataOffset(hdr->exhdr_size.get(), hdr->content_count.get(), hdr->content_meta_count.get()), exdata_size);
}
// save digest
memcpy(mDigest.data, data + getDigestOffset(hdr->exhdr_size.get(), hdr->content_count.get(), hdr->content_meta_count.get(), exdata_size), cnmt::kDigestLen);
}
const fnd::Vec<byte_t>& nn::hac::ContentMetaBinary::getBytes() const
{
return mRawBinary;
}
void nn::hac::ContentMetaBinary::clear()
{
mRawBinary.clear();
mTitleId = 0;
mTitleVersion = 0;
mType = cnmt::METATYPE_SYSTEM_PROGRAM;
mAttributes = 0;
mRequiredDownloadSystemVersion = 0;
mExtendedHeader.clear();
memset(&mApplicationMetaExtendedHeader, 0, sizeof(mApplicationMetaExtendedHeader));
memset(&mPatchMetaExtendedHeader, 0, sizeof(mPatchMetaExtendedHeader));
memset(&mAddOnContentMetaExtendedHeader, 0, sizeof(mAddOnContentMetaExtendedHeader));
memset(&mDeltaMetaExtendedHeader, 0, sizeof(mDeltaMetaExtendedHeader));
mContentInfo.clear();
mContentMetaInfo.clear();
mExtendedData.clear();
memset(mDigest.data, 0, cnmt::kDigestLen);
}
uint64_t nn::hac::ContentMetaBinary::getTitleId() const
{
return mTitleId;
}
void nn::hac::ContentMetaBinary::setTitleId(uint64_t title_id)
{
mTitleId = title_id;
}
uint32_t nn::hac::ContentMetaBinary::getTitleVersion() const
{
return mTitleVersion;
}
void nn::hac::ContentMetaBinary::setTitleVersion(uint32_t version)
{
mTitleVersion = version;
}
nn::hac::cnmt::ContentMetaType nn::hac::ContentMetaBinary::getType() const
{
return mType;
}
void nn::hac::ContentMetaBinary::setType(cnmt::ContentMetaType type)
{
mType = type;
}
byte_t nn::hac::ContentMetaBinary::getAttributes() const
{
return mAttributes;
}
void nn::hac::ContentMetaBinary::setAttributes(byte_t attributes)
{
mAttributes = attributes;
}
uint32_t nn::hac::ContentMetaBinary::getRequiredDownloadSystemVersion() const
{
return mRequiredDownloadSystemVersion;
}
void nn::hac::ContentMetaBinary::setRequiredDownloadSystemVersion(uint32_t version)
{
mRequiredDownloadSystemVersion = version;
}
const nn::hac::ContentMetaBinary::ApplicationMetaExtendedHeader& nn::hac::ContentMetaBinary::getApplicationMetaExtendedHeader() const
{
return mApplicationMetaExtendedHeader;
}
void nn::hac::ContentMetaBinary::setApplicationMetaExtendedHeader(const ApplicationMetaExtendedHeader& exhdr)
{
mApplicationMetaExtendedHeader = exhdr;
}
const nn::hac::ContentMetaBinary::PatchMetaExtendedHeader& nn::hac::ContentMetaBinary::getPatchMetaExtendedHeader() const
{
return mPatchMetaExtendedHeader;
}
void nn::hac::ContentMetaBinary::setPatchMetaExtendedHeader(const PatchMetaExtendedHeader& exhdr)
{
mPatchMetaExtendedHeader = exhdr;
}
const nn::hac::ContentMetaBinary::AddOnContentMetaExtendedHeader& nn::hac::ContentMetaBinary::getAddOnContentMetaExtendedHeader() const
{
return mAddOnContentMetaExtendedHeader;
}
void nn::hac::ContentMetaBinary::setAddOnContentMetaExtendedHeader(const AddOnContentMetaExtendedHeader& exhdr)
{
mAddOnContentMetaExtendedHeader = exhdr;
}
const nn::hac::ContentMetaBinary::DeltaMetaExtendedHeader& nn::hac::ContentMetaBinary::getDeltaMetaExtendedHeader() const
{
return mDeltaMetaExtendedHeader;
}
void nn::hac::ContentMetaBinary::setDeltaMetaExtendedHeader(const DeltaMetaExtendedHeader& exhdr)
{
mDeltaMetaExtendedHeader = exhdr;
}
const fnd::List<nn::hac::ContentMetaBinary::ContentInfo>& nn::hac::ContentMetaBinary::getContentInfo() const
{
return mContentInfo;
}
void nn::hac::ContentMetaBinary::setContentInfo(const fnd::List<nn::hac::ContentMetaBinary::ContentInfo>& info)
{
mContentInfo = info;
}
const fnd::List<nn::hac::ContentMetaBinary::ContentMetaInfo>& nn::hac::ContentMetaBinary::getContentMetaInfo() const
{
return mContentMetaInfo;
}
void nn::hac::ContentMetaBinary::setContentMetaInfo(const fnd::List<nn::hac::ContentMetaBinary::ContentMetaInfo>& info)
{
mContentMetaInfo = info;
}
const fnd::Vec<byte_t> & nn::hac::ContentMetaBinary::getExtendedData() const
{
return mExtendedData;
}
void nn::hac::ContentMetaBinary::setExtendedData(const fnd::Vec<byte_t> & data)
{
mExtendedData = data;
}
const nn::hac::sDigest & nn::hac::ContentMetaBinary::getDigest() const
{
return mDigest;
}
void nn::hac::ContentMetaBinary::setDigest(const nn::hac::sDigest & digest)
{
memcpy(mDigest.data, digest.data, cnmt::kDigestLen);
}
bool nn::hac::ContentMetaBinary::validateExtendedHeaderSize(cnmt::ContentMetaType type, size_t exhdrSize) const
{
bool validSize = false;
switch (type)
{
case (cnmt::METATYPE_APPLICATION):
validSize = (exhdrSize == sizeof(sApplicationMetaExtendedHeader));
break;
case (cnmt::METATYPE_PATCH):
validSize = (exhdrSize == sizeof(sPatchMetaExtendedHeader));
break;
case (cnmt::METATYPE_ADD_ON_CONTENT):
validSize = (exhdrSize == sizeof(sAddOnContentMetaExtendedHeader));
break;
case (cnmt::METATYPE_DELTA):
validSize = (exhdrSize == sizeof(sDeltaMetaExtendedHeader));
break;
default:
validSize = (exhdrSize == 0);
}
return validSize;
}
size_t nn::hac::ContentMetaBinary::getExtendedDataSize(cnmt::ContentMetaType type, const byte_t * data) const
{
size_t exdata_len = 0;
if (type == cnmt::METATYPE_PATCH)
{
const sPatchMetaExtendedHeader* exhdr = (const sPatchMetaExtendedHeader*)(data);
exdata_len = exhdr->extended_data_size.get();
}
else if (type == cnmt::METATYPE_DELTA)
{
const sDeltaMetaExtendedHeader* exhdr = (const sDeltaMetaExtendedHeader*)(data);
exdata_len = exhdr->extended_data_size.get();
}
return exdata_len;
}
void nn::hac::ContentMetaBinary::validateBinary(const byte_t * data, size_t len) const
{
// check if it is large enough to read the header
if (len < sizeof(sContentMetaHeader))
{
throw fnd::Exception(kModuleName, "Binary too small");
}
// get pointer to header structure
const sContentMetaHeader* hdr = (const sContentMetaHeader*)data;
// validate extended header size
if (validateExtendedHeaderSize((cnmt::ContentMetaType)hdr->type, hdr->exhdr_size.get()) == false)
{
throw fnd::Exception(kModuleName, "Invalid extended header size");
}
// check binary size again for new minimum size
if (len < getTotalSize(hdr->exhdr_size.get(), hdr->content_count.get(), hdr->content_meta_count.get(), 0))
{
throw fnd::Exception(kModuleName, "Binary too small");
}
// check binary size again with extended data size
if (len < getTotalSize(hdr->exhdr_size.get(), hdr->content_count.get(), hdr->content_meta_count.get(), getExtendedDataSize((cnmt::ContentMetaType)hdr->type, data + getExtendedHeaderOffset())))
{
throw fnd::Exception(kModuleName, "Binary too small");
}
#include <nn/hac/ContentMeta.h>
nn::hac::ContentMeta::ContentMeta()
{
clear();
}
nn::hac::ContentMeta::ContentMeta(const ContentMeta & other)
{
*this = other;
}
void nn::hac::ContentMeta::operator=(const ContentMeta& other)
{
if (other.getBytes().size() > 0)
{
fromBytes(other.getBytes().data(), other.getBytes().size());
}
else
{
clear();
mTitleId = other.mTitleId;
mTitleVersion = other.mTitleVersion;
mType = other.mType;
mAttributes = other.mAttributes;
mRequiredDownloadSystemVersion = other.mRequiredDownloadSystemVersion;
mApplicationMetaExtendedHeader = other.mApplicationMetaExtendedHeader;
mPatchMetaExtendedHeader = other.mPatchMetaExtendedHeader;
mAddOnContentMetaExtendedHeader = other.mAddOnContentMetaExtendedHeader;
mDeltaMetaExtendedHeader = other.mDeltaMetaExtendedHeader;
mContentInfo = other.mContentInfo;
mContentMetaInfo = other.mContentMetaInfo;
mExtendedData = other.mExtendedData;
memcpy(mDigest.data, other.mDigest.data, cnmt::kDigestLen);
}
}
bool nn::hac::ContentMeta::operator==(const ContentMeta& other) const
{
return (mTitleId == other.mTitleId) \
&& (mTitleVersion == other.mTitleVersion) \
&& (mType == other.mType) \
&& (mAttributes == other.mAttributes) \
&& (mRequiredDownloadSystemVersion == other.mRequiredDownloadSystemVersion) \
&& (mApplicationMetaExtendedHeader == other.mApplicationMetaExtendedHeader) \
&& (mPatchMetaExtendedHeader == other.mPatchMetaExtendedHeader) \
&& (mAddOnContentMetaExtendedHeader == other.mAddOnContentMetaExtendedHeader) \
&& (mDeltaMetaExtendedHeader == other.mDeltaMetaExtendedHeader) \
&& (mContentInfo == other.mContentInfo) \
&& (mContentMetaInfo == other.mContentMetaInfo) \
&& (mExtendedData == other.mExtendedData) \
&& (memcmp(mDigest.data, other.mDigest.data, cnmt::kDigestLen) == 0);
}
bool nn::hac::ContentMeta::operator!=(const ContentMeta& other) const
{
return !(*this == other);
}
void nn::hac::ContentMeta::toBytes()
{
throw fnd::Exception(kModuleName, "toBytes() not implemented");
}
void nn::hac::ContentMeta::fromBytes(const byte_t* data, size_t len)
{
// clear member variables
clear();
// validate layout
validateBinary(data, len);
// get pointer to header structure
const sContentMetaHeader* hdr = (const sContentMetaHeader*)data;
mTitleId = hdr->id.get();
mTitleVersion = hdr->version.get();
mType = (cnmt::ContentMetaType)hdr->type;
mAttributes = hdr->attributes;
mRequiredDownloadSystemVersion = hdr->required_download_system_version.get();
size_t exdata_size = 0;
// save exheader
if (hdr->exhdr_size.get() > 0)
{
switch (mType)
{
case (cnmt::METATYPE_APPLICATION):
mApplicationMetaExtendedHeader.fromBytes(data + getExtendedHeaderOffset(), hdr->exhdr_size.get());
exdata_size = 0;
break;
case (cnmt::METATYPE_PATCH):
mPatchMetaExtendedHeader.fromBytes(data + getExtendedHeaderOffset(), hdr->exhdr_size.get());
exdata_size = mPatchMetaExtendedHeader.getExtendedDataSize();
break;
case (cnmt::METATYPE_ADD_ON_CONTENT):
mAddOnContentMetaExtendedHeader.fromBytes(data + getExtendedHeaderOffset(), hdr->exhdr_size.get());
exdata_size = 0;
break;
case (cnmt::METATYPE_DELTA):
mDeltaMetaExtendedHeader.fromBytes(data + getExtendedHeaderOffset(), hdr->exhdr_size.get());
exdata_size = mDeltaMetaExtendedHeader.getExtendedDataSize();
break;
default:
throw fnd::Exception(kModuleName, "Unhandled extended header for ContentMeta");
//exdata_size = 0;
//break;
}
}
// save content info
if (hdr->content_count.get() > 0)
{
const sContentInfo* info = (const sContentInfo*)(data + getContentInfoOffset(hdr->exhdr_size.get()));
ContentInfo cinfo;
for (size_t i = 0; i < hdr->content_count.get(); i++)
{
cinfo.fromBytes((const byte_t*)&info[i], sizeof(sContentInfo));
mContentInfo.addElement(cinfo);
}
}
// save content meta info
if (hdr->content_meta_count.get() > 0)
{
const sContentMetaInfo* info = (const sContentMetaInfo*)(data + getContentMetaInfoOffset(hdr->exhdr_size.get(), hdr->content_count.get()));
ContentMetaInfo cmeta;
for (size_t i = 0; i < hdr->content_meta_count.get(); i++)
{
cmeta.fromBytes((const byte_t*)&info[i], sizeof(sContentMetaInfo));
mContentMetaInfo.addElement(cmeta);
}
}
// save exdata
if (exdata_size > 0)
{
mExtendedData.alloc(exdata_size);
memcpy(mExtendedData.data(), data + getExtendedDataOffset(hdr->exhdr_size.get(), hdr->content_count.get(), hdr->content_meta_count.get()), exdata_size);
}
// save digest
memcpy(mDigest.data, data + getDigestOffset(hdr->exhdr_size.get(), hdr->content_count.get(), hdr->content_meta_count.get(), exdata_size), cnmt::kDigestLen);
}
const fnd::Vec<byte_t>& nn::hac::ContentMeta::getBytes() const
{
return mRawBinary;
}
void nn::hac::ContentMeta::clear()
{
mRawBinary.clear();
mTitleId = 0;
mTitleVersion = 0;
mType = cnmt::METATYPE_SYSTEM_PROGRAM;
mAttributes = 0;
mRequiredDownloadSystemVersion = 0;
mApplicationMetaExtendedHeader.clear();
mPatchMetaExtendedHeader.clear();
mAddOnContentMetaExtendedHeader.clear();
mDeltaMetaExtendedHeader.clear();
mContentInfo.clear();
mContentMetaInfo.clear();
mExtendedData.clear();
memset(mDigest.data, 0, cnmt::kDigestLen);
}
uint64_t nn::hac::ContentMeta::getTitleId() const
{
return mTitleId;
}
void nn::hac::ContentMeta::setTitleId(uint64_t title_id)
{
mTitleId = title_id;
}
uint32_t nn::hac::ContentMeta::getTitleVersion() const
{
return mTitleVersion;
}
void nn::hac::ContentMeta::setTitleVersion(uint32_t version)
{
mTitleVersion = version;
}
nn::hac::cnmt::ContentMetaType nn::hac::ContentMeta::getContentMetaType() const
{
return mType;
}
void nn::hac::ContentMeta::setContentMetaType(cnmt::ContentMetaType type)
{
mType = type;
}
byte_t nn::hac::ContentMeta::getAttributes() const
{
return mAttributes;
}
void nn::hac::ContentMeta::setAttributes(byte_t attributes)
{
mAttributes = attributes;
}
uint32_t nn::hac::ContentMeta::getRequiredDownloadSystemVersion() const
{
return mRequiredDownloadSystemVersion;
}
void nn::hac::ContentMeta::setRequiredDownloadSystemVersion(uint32_t version)
{
mRequiredDownloadSystemVersion = version;
}
const nn::hac::ApplicationMetaExtendedHeader& nn::hac::ContentMeta::getApplicationMetaExtendedHeader() const
{
return mApplicationMetaExtendedHeader;
}
void nn::hac::ContentMeta::setApplicationMetaExtendedHeader(const ApplicationMetaExtendedHeader& exhdr)
{
mApplicationMetaExtendedHeader = exhdr;
}
const nn::hac::PatchMetaExtendedHeader& nn::hac::ContentMeta::getPatchMetaExtendedHeader() const
{
return mPatchMetaExtendedHeader;
}
void nn::hac::ContentMeta::setPatchMetaExtendedHeader(const PatchMetaExtendedHeader& exhdr)
{
mPatchMetaExtendedHeader = exhdr;
}
const nn::hac::AddOnContentMetaExtendedHeader& nn::hac::ContentMeta::getAddOnContentMetaExtendedHeader() const
{
return mAddOnContentMetaExtendedHeader;
}
void nn::hac::ContentMeta::setAddOnContentMetaExtendedHeader(const AddOnContentMetaExtendedHeader& exhdr)
{
mAddOnContentMetaExtendedHeader = exhdr;
}
const nn::hac::DeltaMetaExtendedHeader& nn::hac::ContentMeta::getDeltaMetaExtendedHeader() const
{
return mDeltaMetaExtendedHeader;
}
void nn::hac::ContentMeta::setDeltaMetaExtendedHeader(const DeltaMetaExtendedHeader& exhdr)
{
mDeltaMetaExtendedHeader = exhdr;
}
const fnd::List<nn::hac::ContentInfo>& nn::hac::ContentMeta::getContentInfo() const
{
return mContentInfo;
}
void nn::hac::ContentMeta::setContentInfo(const fnd::List<nn::hac::ContentInfo>& info)
{
mContentInfo = info;
}
const fnd::List<nn::hac::ContentMetaInfo>& nn::hac::ContentMeta::getContentMetaInfo() const
{
return mContentMetaInfo;
}
void nn::hac::ContentMeta::setContentMetaInfo(const fnd::List<nn::hac::ContentMetaInfo>& info)
{
mContentMetaInfo = info;
}
const fnd::Vec<byte_t> & nn::hac::ContentMeta::getExtendedData() const
{
return mExtendedData;
}
void nn::hac::ContentMeta::setExtendedData(const fnd::Vec<byte_t>& data)
{
mExtendedData = data;
}
const nn::hac::cnmt::sDigest & nn::hac::ContentMeta::getDigest() const
{
return mDigest;
}
void nn::hac::ContentMeta::setDigest(const nn::hac::cnmt::sDigest& digest)
{
mDigest = digest;
}
bool nn::hac::ContentMeta::validateExtendedHeaderSize(cnmt::ContentMetaType type, size_t exhdrSize) const
{
bool validSize = false;
switch (type)
{
case (cnmt::METATYPE_APPLICATION):
validSize = (exhdrSize == sizeof(sApplicationMetaExtendedHeader));
break;
case (cnmt::METATYPE_PATCH):
validSize = (exhdrSize == sizeof(sPatchMetaExtendedHeader));
break;
case (cnmt::METATYPE_ADD_ON_CONTENT):
validSize = (exhdrSize == sizeof(sAddOnContentMetaExtendedHeader));
break;
case (cnmt::METATYPE_DELTA):
validSize = (exhdrSize == sizeof(sDeltaMetaExtendedHeader));
break;
default:
validSize = (exhdrSize == 0);
}
return validSize;
}
size_t nn::hac::ContentMeta::getExtendedDataSize(cnmt::ContentMetaType type, const byte_t * data) const
{
size_t exdata_len = 0;
if (type == cnmt::METATYPE_PATCH)
{
const sPatchMetaExtendedHeader* exhdr = (const sPatchMetaExtendedHeader*)(data);
exdata_len = exhdr->extended_data_size.get();
}
else if (type == cnmt::METATYPE_DELTA)
{
const sDeltaMetaExtendedHeader* exhdr = (const sDeltaMetaExtendedHeader*)(data);
exdata_len = exhdr->extended_data_size.get();
}
return exdata_len;
}
void nn::hac::ContentMeta::validateBinary(const byte_t * data, size_t len) const
{
// check if it is large enough to read the header
if (len < sizeof(sContentMetaHeader))
{
throw fnd::Exception(kModuleName, "Binary too small");
}
// get pointer to header structure
const sContentMetaHeader* hdr = (const sContentMetaHeader*)data;
// validate extended header size
if (validateExtendedHeaderSize((cnmt::ContentMetaType)hdr->type, hdr->exhdr_size.get()) == false)
{
throw fnd::Exception(kModuleName, "Invalid extended header size");
}
// check binary size again for new minimum size
if (len < getTotalSize(hdr->exhdr_size.get(), hdr->content_count.get(), hdr->content_meta_count.get(), 0))
{
throw fnd::Exception(kModuleName, "Binary too small");
}
// check binary size again with extended data size
if (len < getTotalSize(hdr->exhdr_size.get(), hdr->content_count.get(), hdr->content_meta_count.get(), getExtendedDataSize((cnmt::ContentMetaType)hdr->type, data + getExtendedHeaderOffset())))
{
throw fnd::Exception(kModuleName, "Binary too small");
}
}

View file

@ -0,0 +1,114 @@
#include <nn/hac/ContentMetaInfo.h>
nn::hac::ContentMetaInfo::ContentMetaInfo()
{
clear();
}
nn::hac::ContentMetaInfo::ContentMetaInfo(const ContentMetaInfo& other)
{
*this = other;
}
void nn::hac::ContentMetaInfo::operator=(const ContentMetaInfo& other)
{
clear();
mRawBinary = other.mRawBinary;
mTitleId = other.mTitleId;
mTitleVersion = other.mTitleVersion;
mType = other.mType;
mAttributes = other.mAttributes;
}
bool nn::hac::ContentMetaInfo::operator==(const ContentMetaInfo& other) const
{
return (mTitleId == other.mTitleId) \
&& (mTitleVersion == other.mTitleVersion) \
&& (mType == other.mType) \
&& (mAttributes == other.mAttributes);
}
bool nn::hac::ContentMetaInfo::operator!=(const ContentMetaInfo& other) const
{
return !(*this == other);
}
void nn::hac::ContentMetaInfo::toBytes()
{
mRawBinary.alloc(sizeof(sContentMetaInfo));
sContentMetaInfo* info = (sContentMetaInfo*)mRawBinary.data();
info->id = mTitleId;
info->version = mTitleVersion;
info->type = mType;
info->attributes = mAttributes;
}
void nn::hac::ContentMetaInfo::fromBytes(const byte_t* bytes, size_t len)
{
if (len < sizeof(sContentMetaInfo))
{
throw fnd::Exception(kModuleName, "ContentMetaInfo too small");
}
const sContentMetaInfo* info = (const sContentMetaInfo*)bytes;
mTitleId = info->id.get();
mTitleVersion = info->version.get();
mType = (cnmt::ContentMetaType)info->type;
mAttributes = info->attributes;
}
const fnd::Vec<byte_t>& nn::hac::ContentMetaInfo::getBytes() const
{
return mRawBinary;
}
void nn::hac::ContentMetaInfo::clear()
{
mRawBinary.clear();
mTitleId = 0;
mTitleVersion = 0;
mType = cnmt::ContentMetaType::METATYPE_APPLICATION;
mAttributes = 0;
}
uint64_t nn::hac::ContentMetaInfo::getTitleId() const
{
return mTitleId;
}
void nn::hac::ContentMetaInfo::setTitleId(uint64_t title_id)
{
mTitleId = title_id;
}
uint32_t nn::hac::ContentMetaInfo::getTitleVersion() const
{
return mTitleVersion;
}
void nn::hac::ContentMetaInfo::setTitleVersion(uint32_t ver)
{
mTitleVersion = ver;
}
nn::hac::cnmt::ContentMetaType nn::hac::ContentMetaInfo::getContentMetaType() const
{
return mType;
}
void nn::hac::ContentMetaInfo::setContentMetaType(cnmt::ContentMetaType type)
{
mType = type;
}
byte_t nn::hac::ContentMetaInfo::getAttributes() const
{
return mAttributes;
}
void nn::hac::ContentMetaInfo::setAttributes(byte_t attr)
{
mAttributes = attr;
}

View file

@ -0,0 +1,84 @@
#include <nn/hac/DeltaMetaExtendedHeader.h>
nn::hac::DeltaMetaExtendedHeader::DeltaMetaExtendedHeader()
{
clear();
}
nn::hac::DeltaMetaExtendedHeader::DeltaMetaExtendedHeader(const DeltaMetaExtendedHeader& other)
{
*this = other;
}
void nn::hac::DeltaMetaExtendedHeader::operator=(const DeltaMetaExtendedHeader& other)
{
clear();
mRawBinary = other.mRawBinary;
mApplicationId = other.mApplicationId;
mExtendedDataSize = other.mExtendedDataSize;
}
bool nn::hac::DeltaMetaExtendedHeader::operator==(const DeltaMetaExtendedHeader& other) const
{
return (mApplicationId == other.mApplicationId) \
&& (mExtendedDataSize == other.mExtendedDataSize);
}
bool nn::hac::DeltaMetaExtendedHeader::operator!=(const DeltaMetaExtendedHeader& other) const
{
return !(*this == other);
}
void nn::hac::DeltaMetaExtendedHeader::toBytes()
{
mRawBinary.alloc(sizeof(sDeltaMetaExtendedHeader));
sDeltaMetaExtendedHeader* info = (sDeltaMetaExtendedHeader*)mRawBinary.data();
info->application_id = mApplicationId;
info->extended_data_size = mExtendedDataSize;
}
void nn::hac::DeltaMetaExtendedHeader::fromBytes(const byte_t* bytes, size_t len)
{
if (len < sizeof(sDeltaMetaExtendedHeader))
{
throw fnd::Exception(kModuleName, "DeltaMetaExtendedHeader too small");
}
const sDeltaMetaExtendedHeader* info = (const sDeltaMetaExtendedHeader*)bytes;
mApplicationId = info->application_id.get();
mExtendedDataSize = info->extended_data_size.get();
}
const fnd::Vec<byte_t>& nn::hac::DeltaMetaExtendedHeader::getBytes() const
{
return mRawBinary;
}
void nn::hac::DeltaMetaExtendedHeader::clear()
{
mRawBinary.clear();
mApplicationId = 0;
mExtendedDataSize = 0;
}
uint64_t nn::hac::DeltaMetaExtendedHeader::getApplicationId() const
{
return mApplicationId;
}
void nn::hac::DeltaMetaExtendedHeader::setApplicationId(uint64_t application_id)
{
mApplicationId = application_id;
}
uint32_t nn::hac::DeltaMetaExtendedHeader::getExtendedDataSize() const
{
return mExtendedDataSize;
}
void nn::hac::DeltaMetaExtendedHeader::setExtendedDataSize(uint32_t size)
{
mExtendedDataSize = size;
}

View file

@ -1,219 +1,219 @@
#include <cstring>
#include <nn/hac/FileSystemAccessControlBinary.h>
nn::hac::FileSystemAccessControlBinary::FileSystemAccessControlBinary()
{
clear();
}
nn::hac::FileSystemAccessControlBinary::FileSystemAccessControlBinary(const FileSystemAccessControlBinary & other)
{
*this = other;
}
void nn::hac::FileSystemAccessControlBinary::operator=(const FileSystemAccessControlBinary & other)
{
mRawBinary = other.mRawBinary;
mVersion = other.mVersion;
mFsaRights = other.mFsaRights;
mContentOwnerIdList = other.mContentOwnerIdList;
mSaveDataOwnerIdList = other.mSaveDataOwnerIdList;
}
bool nn::hac::FileSystemAccessControlBinary::operator==(const FileSystemAccessControlBinary & other) const
{
return (mVersion == other.mVersion) \
&& (mFsaRights == other.mFsaRights) \
&& (mContentOwnerIdList == other.mContentOwnerIdList) \
&& (mSaveDataOwnerIdList == other.mSaveDataOwnerIdList);
}
bool nn::hac::FileSystemAccessControlBinary::operator!=(const FileSystemAccessControlBinary & other) const
{
return !(*this == other);
}
void nn::hac::FileSystemAccessControlBinary::toBytes()
{
// determine section layout
struct sLayout {
uint32_t offset, size;
} content, savedata;
content.offset = (uint32_t)align(sizeof(sFacHeader), fac::kSectionAlignSize);
if (mContentOwnerIdList.size() > 0)
content.size = (uint32_t)(sizeof(uint32_t) + mContentOwnerIdList.size() * sizeof(uint64_t));
else
content.size = 0;
savedata.offset = (uint32_t)(content.offset + (content.size > 0 ? align(content.size, fac::kSectionAlignSize) : 0));
if (mSaveDataOwnerIdList.size() > 0)
savedata.size = (uint32_t)(sizeof(uint32_t) + align(mSaveDataOwnerIdList.size(), fac::kSectionAlignSize) + mSaveDataOwnerIdList.size() * sizeof(uint64_t));
else
savedata.size = 0;
// get total size
size_t total_size = _MAX(_MAX(content.offset + content.size, savedata.offset + savedata.size), align(sizeof(sFacHeader), fac::kSectionAlignSize));
mRawBinary.alloc(total_size);
sFacHeader* hdr = (sFacHeader*)mRawBinary.data();
// set type
hdr->version = mVersion;
// flags
uint64_t flag = 0;
for (size_t i = 0; i < mFsaRights.size(); i++)
{
flag |= _BIT((uint64_t)mFsaRights[i]);
}
hdr->fac_flags = flag;
// set offset/size
hdr->content_owner_ids.offset = content.offset;
if (content.size > 0)
hdr->content_owner_ids.size = content.size;
hdr->save_data_owner_ids.offset = savedata.offset;
if (savedata.size > 0)
hdr->save_data_owner_ids.size = savedata.size;
// set ids
le_uint32_t* content_owner_id_num = (le_uint32_t*)(mRawBinary.data() + content.offset);
le_uint64_t* content_owner_ids = (le_uint64_t*)(mRawBinary.data() + content.offset + sizeof(uint32_t));
content_owner_id_num->set((uint32_t)mContentOwnerIdList.size());
for (size_t i = 0; i < mContentOwnerIdList.size(); i++)
{
content_owner_ids[i] = mContentOwnerIdList[i];
}
le_uint32_t* save_data_owner_id_num = (le_uint32_t*)(mRawBinary.data() + savedata.offset);
byte_t* save_data_owner_id_accessibility_array = (mRawBinary.data() + savedata.offset + sizeof(uint32_t));
le_uint64_t* save_data_owner_ids = (le_uint64_t*)(mRawBinary.data() + savedata.offset + sizeof(uint32_t) + align(mSaveDataOwnerIdList.size(), sizeof(uint32_t)));
save_data_owner_id_num->set((uint32_t)mSaveDataOwnerIdList.size());
for (size_t i = 0; i < mSaveDataOwnerIdList.size(); i++)
{
save_data_owner_id_accessibility_array[i] = mSaveDataOwnerIdList[i].access_type;
save_data_owner_ids[i] = mSaveDataOwnerIdList[i].id;
}
}
void nn::hac::FileSystemAccessControlBinary::fromBytes(const byte_t* data, size_t len)
{
// check size
if (len < sizeof(sFacHeader))
{
throw fnd::Exception(kModuleName, "FileSystemAccessControlInfo binary is too small");
}
// clear variables
clear();
// save a copy of the header
sFacHeader hdr;
memcpy((void*)&hdr, data, sizeof(sFacHeader));
// check format version
if (hdr.version.get() != fac::kFacFormatVersion)
{
throw fnd::Exception(kModuleName, "FileSystemAccessControlInfo format version unsupported");
}
// get total size
size_t total_size = _MAX(_MAX(hdr.content_owner_ids.offset.get() + hdr.content_owner_ids.size.get(), hdr.save_data_owner_ids.offset.get() + hdr.save_data_owner_ids.size.get()), align(sizeof(sFacHeader), fac::kSectionAlignSize));
// validate binary size
if (len < total_size)
{
throw fnd::Exception(kModuleName, "FileSystemAccessControlInfo binary is too small");
}
// allocate memory
mRawBinary.alloc(total_size);
memcpy(mRawBinary.data(), data, mRawBinary.size());
// save variables
mVersion = hdr.version.get();
for (size_t i = 0; i < 64; i++)
{
if (_HAS_BIT(hdr.fac_flags.get(), i))
{
mFsaRights.addElement((fac::FsAccessFlag)i);
}
}
// save ids
if (hdr.content_owner_ids.size.get() > 0)
{
size_t content_owner_id_num = ((le_uint32_t*)(mRawBinary.data() + hdr.content_owner_ids.offset.get()))->get();
le_uint64_t* content_owner_ids = (le_uint64_t*)(mRawBinary.data() + hdr.content_owner_ids.offset.get() + sizeof(uint32_t));
for (size_t i = 0; i < content_owner_id_num; i++)
{
mContentOwnerIdList.addElement(content_owner_ids[i].get());
}
}
if (hdr.save_data_owner_ids.size.get() > 0)
{
size_t save_data_owner_id_num = ((le_uint32_t*)(mRawBinary.data() + hdr.save_data_owner_ids.offset.get()))->get();
byte_t* save_data_owner_id_accessibility_array = (mRawBinary.data() + hdr.save_data_owner_ids.offset.get() + sizeof(uint32_t));
le_uint64_t* save_data_owner_ids = (le_uint64_t*)(mRawBinary.data() + hdr.save_data_owner_ids.offset.get() + sizeof(uint32_t) + align(save_data_owner_id_num, fac::kSectionAlignSize));
for (size_t i = 0; i < save_data_owner_id_num; i++)
{
mSaveDataOwnerIdList.addElement({ (fac::SaveDataOwnerIdAccessType)save_data_owner_id_accessibility_array[i], save_data_owner_ids[i].get() });
}
}
}
const fnd::Vec<byte_t>& nn::hac::FileSystemAccessControlBinary::getBytes() const
{
return mRawBinary;
}
void nn::hac::FileSystemAccessControlBinary::clear()
{
mRawBinary.clear();
mVersion = 0;
mFsaRights.clear();
mContentOwnerIdList.clear();
mSaveDataOwnerIdList.clear();
}
uint32_t nn::hac::FileSystemAccessControlBinary::getFormatVersion() const
{
return mVersion;
}
void nn::hac::FileSystemAccessControlBinary::setFormatVersion(uint32_t format_version)
{
mVersion = format_version;
}
const fnd::List<nn::hac::fac::FsAccessFlag>& nn::hac::FileSystemAccessControlBinary::getFsaRightsList() const
{
return mFsaRights;
}
void nn::hac::FileSystemAccessControlBinary::setFsaRightsList(const fnd::List<fac::FsAccessFlag>& list)
{
mFsaRights = list;
}
const fnd::List<uint64_t>& nn::hac::FileSystemAccessControlBinary::getContentOwnerIdList() const
{
return mContentOwnerIdList;
}
void nn::hac::FileSystemAccessControlBinary::setContentOwnerIdList(const fnd::List<uint64_t>& list)
{
mContentOwnerIdList = list;
}
const fnd::List<nn::hac::FileSystemAccessControlBinary::sSaveDataOwnerId>& nn::hac::FileSystemAccessControlBinary::getSaveDataOwnerIdList() const
{
return mSaveDataOwnerIdList;
}
void nn::hac::FileSystemAccessControlBinary::setSaveDataOwnerIdList(const fnd::List<sSaveDataOwnerId>& list)
{
mSaveDataOwnerIdList = list;
#include <cstring>
#include <nn/hac/FileSystemAccessControl.h>
nn::hac::FileSystemAccessControl::FileSystemAccessControl()
{
clear();
}
nn::hac::FileSystemAccessControl::FileSystemAccessControl(const FileSystemAccessControl & other)
{
*this = other;
}
void nn::hac::FileSystemAccessControl::operator=(const FileSystemAccessControl & other)
{
mRawBinary = other.mRawBinary;
mVersion = other.mVersion;
mFsaRights = other.mFsaRights;
mContentOwnerIdList = other.mContentOwnerIdList;
mSaveDataOwnerIdList = other.mSaveDataOwnerIdList;
}
bool nn::hac::FileSystemAccessControl::operator==(const FileSystemAccessControl & other) const
{
return (mVersion == other.mVersion) \
&& (mFsaRights == other.mFsaRights) \
&& (mContentOwnerIdList == other.mContentOwnerIdList) \
&& (mSaveDataOwnerIdList == other.mSaveDataOwnerIdList);
}
bool nn::hac::FileSystemAccessControl::operator!=(const FileSystemAccessControl & other) const
{
return !(*this == other);
}
void nn::hac::FileSystemAccessControl::toBytes()
{
// determine section layout
struct sLayout {
uint32_t offset, size;
} content, savedata;
content.offset = (uint32_t)align(sizeof(sFacHeader), fac::kSectionAlignSize);
if (mContentOwnerIdList.size() > 0)
content.size = (uint32_t)(sizeof(uint32_t) + mContentOwnerIdList.size() * sizeof(uint64_t));
else
content.size = 0;
savedata.offset = (uint32_t)(content.offset + (content.size > 0 ? align(content.size, fac::kSectionAlignSize) : 0));
if (mSaveDataOwnerIdList.size() > 0)
savedata.size = (uint32_t)(sizeof(uint32_t) + align(mSaveDataOwnerIdList.size(), fac::kSectionAlignSize) + mSaveDataOwnerIdList.size() * sizeof(uint64_t));
else
savedata.size = 0;
// get total size
size_t total_size = _MAX(_MAX(content.offset + content.size, savedata.offset + savedata.size), align(sizeof(sFacHeader), fac::kSectionAlignSize));
mRawBinary.alloc(total_size);
sFacHeader* hdr = (sFacHeader*)mRawBinary.data();
// set type
hdr->version = mVersion;
// flags
uint64_t flag = 0;
for (size_t i = 0; i < mFsaRights.size(); i++)
{
flag |= _BIT((uint64_t)mFsaRights[i]);
}
hdr->fac_flags = flag;
// set offset/size
hdr->content_owner_ids.offset = content.offset;
if (content.size > 0)
hdr->content_owner_ids.size = content.size;
hdr->save_data_owner_ids.offset = savedata.offset;
if (savedata.size > 0)
hdr->save_data_owner_ids.size = savedata.size;
// set ids
le_uint32_t* content_owner_id_num = (le_uint32_t*)(mRawBinary.data() + content.offset);
le_uint64_t* content_owner_ids = (le_uint64_t*)(mRawBinary.data() + content.offset + sizeof(uint32_t));
content_owner_id_num->set((uint32_t)mContentOwnerIdList.size());
for (size_t i = 0; i < mContentOwnerIdList.size(); i++)
{
content_owner_ids[i] = mContentOwnerIdList[i];
}
le_uint32_t* save_data_owner_id_num = (le_uint32_t*)(mRawBinary.data() + savedata.offset);
byte_t* save_data_owner_id_accessibility_array = (mRawBinary.data() + savedata.offset + sizeof(uint32_t));
le_uint64_t* save_data_owner_ids = (le_uint64_t*)(mRawBinary.data() + savedata.offset + sizeof(uint32_t) + align(mSaveDataOwnerIdList.size(), sizeof(uint32_t)));
save_data_owner_id_num->set((uint32_t)mSaveDataOwnerIdList.size());
for (size_t i = 0; i < mSaveDataOwnerIdList.size(); i++)
{
save_data_owner_id_accessibility_array[i] = mSaveDataOwnerIdList[i].access_type;
save_data_owner_ids[i] = mSaveDataOwnerIdList[i].id;
}
}
void nn::hac::FileSystemAccessControl::fromBytes(const byte_t* data, size_t len)
{
// check size
if (len < sizeof(sFacHeader))
{
throw fnd::Exception(kModuleName, "FileSystemAccessControlInfo binary is too small");
}
// clear variables
clear();
// save a copy of the header
sFacHeader hdr;
memcpy((void*)&hdr, data, sizeof(sFacHeader));
// check format version
if (hdr.version.get() != fac::kFacFormatVersion)
{
throw fnd::Exception(kModuleName, "FileSystemAccessControlInfo format version unsupported");
}
// get total size
size_t total_size = _MAX(_MAX(hdr.content_owner_ids.offset.get() + hdr.content_owner_ids.size.get(), hdr.save_data_owner_ids.offset.get() + hdr.save_data_owner_ids.size.get()), align(sizeof(sFacHeader), fac::kSectionAlignSize));
// validate binary size
if (len < total_size)
{
throw fnd::Exception(kModuleName, "FileSystemAccessControlInfo binary is too small");
}
// allocate memory
mRawBinary.alloc(total_size);
memcpy(mRawBinary.data(), data, mRawBinary.size());
// save variables
mVersion = hdr.version.get();
for (size_t i = 0; i < 64; i++)
{
if (_HAS_BIT(hdr.fac_flags.get(), i))
{
mFsaRights.addElement((fac::FsAccessFlag)i);
}
}
// save ids
if (hdr.content_owner_ids.size.get() > 0)
{
size_t content_owner_id_num = ((le_uint32_t*)(mRawBinary.data() + hdr.content_owner_ids.offset.get()))->get();
le_uint64_t* content_owner_ids = (le_uint64_t*)(mRawBinary.data() + hdr.content_owner_ids.offset.get() + sizeof(uint32_t));
for (size_t i = 0; i < content_owner_id_num; i++)
{
mContentOwnerIdList.addElement(content_owner_ids[i].get());
}
}
if (hdr.save_data_owner_ids.size.get() > 0)
{
size_t save_data_owner_id_num = ((le_uint32_t*)(mRawBinary.data() + hdr.save_data_owner_ids.offset.get()))->get();
byte_t* save_data_owner_id_accessibility_array = (mRawBinary.data() + hdr.save_data_owner_ids.offset.get() + sizeof(uint32_t));
le_uint64_t* save_data_owner_ids = (le_uint64_t*)(mRawBinary.data() + hdr.save_data_owner_ids.offset.get() + sizeof(uint32_t) + align(save_data_owner_id_num, fac::kSectionAlignSize));
for (size_t i = 0; i < save_data_owner_id_num; i++)
{
mSaveDataOwnerIdList.addElement({ (fac::SaveDataOwnerIdAccessType)save_data_owner_id_accessibility_array[i], save_data_owner_ids[i].get() });
}
}
}
const fnd::Vec<byte_t>& nn::hac::FileSystemAccessControl::getBytes() const
{
return mRawBinary;
}
void nn::hac::FileSystemAccessControl::clear()
{
mRawBinary.clear();
mVersion = 0;
mFsaRights.clear();
mContentOwnerIdList.clear();
mSaveDataOwnerIdList.clear();
}
uint32_t nn::hac::FileSystemAccessControl::getFormatVersion() const
{
return mVersion;
}
void nn::hac::FileSystemAccessControl::setFormatVersion(uint32_t format_version)
{
mVersion = format_version;
}
const fnd::List<nn::hac::fac::FsAccessFlag>& nn::hac::FileSystemAccessControl::getFsaRightsList() const
{
return mFsaRights;
}
void nn::hac::FileSystemAccessControl::setFsaRightsList(const fnd::List<fac::FsAccessFlag>& list)
{
mFsaRights = list;
}
const fnd::List<uint64_t>& nn::hac::FileSystemAccessControl::getContentOwnerIdList() const
{
return mContentOwnerIdList;
}
void nn::hac::FileSystemAccessControl::setContentOwnerIdList(const fnd::List<uint64_t>& list)
{
mContentOwnerIdList = list;
}
const fnd::List<nn::hac::FileSystemAccessControl::sSaveDataOwnerId>& nn::hac::FileSystemAccessControl::getSaveDataOwnerIdList() const
{
return mSaveDataOwnerIdList;
}
void nn::hac::FileSystemAccessControl::setSaveDataOwnerIdList(const fnd::List<sSaveDataOwnerId>& list)
{
mSaveDataOwnerIdList = list;
}

View file

@ -1,16 +1,16 @@
#include <nn/hac/XciHeader.h>
#include <nn/hac/GameCardHeader.h>
nn::hac::XciHeader::XciHeader()
nn::hac::GameCardHeader::GameCardHeader()
{
clear();
}
nn::hac::XciHeader::XciHeader(const XciHeader& other)
nn::hac::GameCardHeader::GameCardHeader(const GameCardHeader& other)
{
*this = other;
}
void nn::hac::XciHeader::operator=(const XciHeader& other)
void nn::hac::GameCardHeader::operator=(const GameCardHeader& other)
{
mRomAreaStartPage = other.mRomAreaStartPage;
mBackupAreaStartPage = other.mBackupAreaStartPage;
@ -39,11 +39,11 @@ void nn::hac::XciHeader::operator=(const XciHeader& other)
mWait2TimeWrite = other.mWait2TimeWrite;
mFwMode = other.mFwMode;
mUppVersion = other.mUppVersion;
memcpy(mUppHash, other.mUppHash, xci::kUppHashLen);
memcpy(mUppHash, other.mUppHash, gc::kUppHashLen);
mUppId = other.mUppId;
}
bool nn::hac::XciHeader::operator==(const XciHeader& other) const
bool nn::hac::GameCardHeader::operator==(const GameCardHeader& other) const
{
return (mRomAreaStartPage == other.mRomAreaStartPage)
&& (mBackupAreaStartPage == other.mBackupAreaStartPage)
@ -72,42 +72,42 @@ bool nn::hac::XciHeader::operator==(const XciHeader& other) const
&& (mWait2TimeWrite == other.mWait2TimeWrite)
&& (mFwMode == other.mFwMode)
&& (mUppVersion == other.mUppVersion)
&& (memcmp(mUppHash, other.mUppHash, xci::kUppHashLen) == 0)
&& (memcmp(mUppHash, other.mUppHash, gc::kUppHashLen) == 0)
&& (mUppId == other.mUppId);
}
bool nn::hac::XciHeader::operator!=(const XciHeader& other) const
bool nn::hac::GameCardHeader::operator!=(const GameCardHeader& other) const
{
return !(*this == other);
}
void nn::hac::XciHeader::toBytes()
void nn::hac::GameCardHeader::toBytes()
{
fnd::Exception(kModuleName, "exportBinary() not implemented");
fnd::Exception(kModuleName, "toBytes() not implemented");
}
void nn::hac::XciHeader::fromBytes(const byte_t* data, size_t len)
void nn::hac::GameCardHeader::fromBytes(const byte_t* data, size_t len)
{
// check input data size
if (len < sizeof(sXciHeader))
if (len < sizeof(sGcHeader))
{
throw fnd::Exception(kModuleName, "XCI header size is too small");
throw fnd::Exception(kModuleName, "GameCardImage header size is too small");
}
// clear internal members
clear();
// allocate internal local binary copy
mRawBinary.alloc(sizeof(sXciHeader));
mRawBinary.alloc(sizeof(sGcHeader));
memcpy(mRawBinary.data(), data, mRawBinary.size());
// get sXciHeader ptr
const nn::hac::sXciHeader* hdr = (const nn::hac::sXciHeader*)mRawBinary.data();
// get sGcHeader ptr
const nn::hac::sGcHeader* hdr = (const nn::hac::sGcHeader*)mRawBinary.data();
// check XCI signature
if (hdr->st_magic.get() != xci::kXciStructMagic)
// check GameCardImage signature
if (hdr->st_magic.get() != gc::kGcHeaderStructMagic)
{
throw fnd::Exception(kModuleName, "XCI header corrupt");
throw fnd::Exception(kModuleName, "GameCardImage header corrupt");
}
mRomAreaStartPage = hdr->rom_area_start_page.get();
@ -133,8 +133,8 @@ void nn::hac::XciHeader::fromBytes(const byte_t* data, size_t len)
// if decrypted
if (hdr->reserved_02[sizeof(hdr->reserved_02)-1] == 0x00 && hdr->reserved_02[sizeof(hdr->reserved_02)-2] == 0x00)
{
mFwVersion[xci::FWVER_MAJOR] = hdr->fw_version[xci::FWVER_MAJOR].get();
mFwVersion[xci::FWVER_MINOR] = hdr->fw_version[xci::FWVER_MINOR].get();
mFwVersion[gc::FWVER_MAJOR] = hdr->fw_version[gc::FWVER_MAJOR].get();
mFwVersion[gc::FWVER_MINOR] = hdr->fw_version[gc::FWVER_MINOR].get();
mAccCtrl1 = hdr->acc_ctrl_1.get();
mWait1TimeRead = hdr->wait_1_time_read.get();
mWait2TimeRead = hdr->wait_2_time_read.get();
@ -142,19 +142,19 @@ void nn::hac::XciHeader::fromBytes(const byte_t* data, size_t len)
mWait2TimeWrite = hdr->wait_2_time_write.get();
mFwMode = hdr->fw_mode.get();
mUppVersion = hdr->upp_version.get();
memcpy(mUppHash, hdr->upp_hash, xci::kUppHashLen);
memcpy(mUppHash, hdr->upp_hash, gc::kUppHashLen);
mUppId = hdr->upp_id.get();
}
}
const fnd::Vec<byte_t>& nn::hac::XciHeader::getBytes() const
const fnd::Vec<byte_t>& nn::hac::GameCardHeader::getBytes() const
{
return mRawBinary;
}
// variables
void nn::hac::XciHeader::clear()
void nn::hac::GameCardHeader::clear()
{
mRomAreaStartPage = 0;
mBackupAreaStartPage = 0;
@ -183,297 +183,297 @@ void nn::hac::XciHeader::clear()
mWait2TimeWrite = 0;
mFwMode = 0;
mUppVersion = 0;
memset(mUppHash, 0, xci::kUppHashLen);
memset(mUppHash, 0, gc::kUppHashLen);
mUppId = 0;
}
uint32_t nn::hac::XciHeader::getRomAreaStartPage() const
uint32_t nn::hac::GameCardHeader::getRomAreaStartPage() const
{
return mRomAreaStartPage;
}
void nn::hac::XciHeader::setRomAreaStartPage(uint32_t startPage)
void nn::hac::GameCardHeader::setRomAreaStartPage(uint32_t startPage)
{
mRomAreaStartPage = startPage;
}
uint32_t nn::hac::XciHeader::getBackupAreaStartPage() const
uint32_t nn::hac::GameCardHeader::getBackupAreaStartPage() const
{
return mBackupAreaStartPage;
}
void nn::hac::XciHeader::setBackupAreaStartPage(uint32_t startPage)
void nn::hac::GameCardHeader::setBackupAreaStartPage(uint32_t startPage)
{
mBackupAreaStartPage = startPage;
}
byte_t nn::hac::XciHeader::getKekIndex() const
byte_t nn::hac::GameCardHeader::getKekIndex() const
{
return mKekIndex;
}
void nn::hac::XciHeader::setKekIndex(byte_t kekIndex)
void nn::hac::GameCardHeader::setKekIndex(byte_t kekIndex)
{
mKekIndex = kekIndex;
}
byte_t nn::hac::XciHeader::getTitleKeyDecIndex() const
byte_t nn::hac::GameCardHeader::getTitleKeyDecIndex() const
{
return mTitleKeyDecIndex;
}
void nn::hac::XciHeader::setTitleKeyDecIndex(byte_t index)
void nn::hac::GameCardHeader::setTitleKeyDecIndex(byte_t index)
{
mTitleKeyDecIndex = index;
}
byte_t nn::hac::XciHeader::getRomSizeType() const
byte_t nn::hac::GameCardHeader::getRomSizeType() const
{
return mRomSize;
}
void nn::hac::XciHeader::setRomSizeType(byte_t romSizeType)
void nn::hac::GameCardHeader::setRomSizeType(byte_t romSizeType)
{
mRomSize = romSizeType;
}
byte_t nn::hac::XciHeader::getCardHeaderVersion() const
byte_t nn::hac::GameCardHeader::getCardHeaderVersion() const
{
return mCardHeaderVersion;
}
void nn::hac::XciHeader::setCardHeaderVersion(byte_t version)
void nn::hac::GameCardHeader::setCardHeaderVersion(byte_t version)
{
mCardHeaderVersion = version;
}
byte_t nn::hac::XciHeader::getFlags() const
byte_t nn::hac::GameCardHeader::getFlags() const
{
return mFlags;
}
void nn::hac::XciHeader::setFlags(byte_t flags)
void nn::hac::GameCardHeader::setFlags(byte_t flags)
{
mFlags = flags;
}
uint64_t nn::hac::XciHeader::getPackageId() const
uint64_t nn::hac::GameCardHeader::getPackageId() const
{
return mPackageId;
}
void nn::hac::XciHeader::setPackageId(uint64_t id)
void nn::hac::GameCardHeader::setPackageId(uint64_t id)
{
mPackageId = id;
}
uint32_t nn::hac::XciHeader::getValidDataEndPage() const
uint32_t nn::hac::GameCardHeader::getValidDataEndPage() const
{
return mValidDataEndPage;
}
void nn::hac::XciHeader::setValidDataEndPage(uint32_t page)
void nn::hac::GameCardHeader::setValidDataEndPage(uint32_t page)
{
mValidDataEndPage = page;
}
const fnd::aes::sAesIvCtr& nn::hac::XciHeader::getAesCbcIv() const
const fnd::aes::sAesIvCtr& nn::hac::GameCardHeader::getAesCbcIv() const
{
return mAesCbcIv;
}
void nn::hac::XciHeader::setAesCbcIv(const fnd::aes::sAesIvCtr& iv)
void nn::hac::GameCardHeader::setAesCbcIv(const fnd::aes::sAesIvCtr& iv)
{
mAesCbcIv = iv;
}
uint64_t nn::hac::XciHeader::getPartitionFsAddress() const
uint64_t nn::hac::GameCardHeader::getPartitionFsAddress() const
{
return mPartitionFsHeaderAddress;
}
void nn::hac::XciHeader::setPartitionFsAddress(uint64_t address)
void nn::hac::GameCardHeader::setPartitionFsAddress(uint64_t address)
{
mPartitionFsHeaderAddress = address;
}
uint64_t nn::hac::XciHeader::getPartitionFsSize() const
uint64_t nn::hac::GameCardHeader::getPartitionFsSize() const
{
return mPartitionFsHeaderSize;
}
void nn::hac::XciHeader::setPartitionFsSize(uint64_t size)
void nn::hac::GameCardHeader::setPartitionFsSize(uint64_t size)
{
mPartitionFsHeaderSize = size;
}
const fnd::sha::sSha256Hash& nn::hac::XciHeader::getPartitionFsHash() const
const fnd::sha::sSha256Hash& nn::hac::GameCardHeader::getPartitionFsHash() const
{
return mPartitionFsHeaderHash;
}
void nn::hac::XciHeader::setPartitionFsHash(const fnd::sha::sSha256Hash& hash)
void nn::hac::GameCardHeader::setPartitionFsHash(const fnd::sha::sSha256Hash& hash)
{
mPartitionFsHeaderHash = hash;
}
const fnd::sha::sSha256Hash& nn::hac::XciHeader::getInitialDataHash() const
const fnd::sha::sSha256Hash& nn::hac::GameCardHeader::getInitialDataHash() const
{
return mInitialDataHash;
}
void nn::hac::XciHeader::setInitialDataHash(const fnd::sha::sSha256Hash& hash)
void nn::hac::GameCardHeader::setInitialDataHash(const fnd::sha::sSha256Hash& hash)
{
mInitialDataHash = hash;
}
uint32_t nn::hac::XciHeader::getSelSec() const
uint32_t nn::hac::GameCardHeader::getSelSec() const
{
return mSelSec;
}
void nn::hac::XciHeader::setSelSec(uint32_t sel_sec)
void nn::hac::GameCardHeader::setSelSec(uint32_t sel_sec)
{
mSelSec = sel_sec;
}
uint32_t nn::hac::XciHeader::getSelT1Key() const
uint32_t nn::hac::GameCardHeader::getSelT1Key() const
{
return mSelT1Key;
}
void nn::hac::XciHeader::setSelT1Key(uint32_t sel_t1_key)
void nn::hac::GameCardHeader::setSelT1Key(uint32_t sel_t1_key)
{
mSelT1Key = sel_t1_key;
}
uint32_t nn::hac::XciHeader::getSelKey() const
uint32_t nn::hac::GameCardHeader::getSelKey() const
{
return mSelKey;
}
void nn::hac::XciHeader::setSelKey(uint32_t sel_key)
void nn::hac::GameCardHeader::setSelKey(uint32_t sel_key)
{
mSelKey = sel_key;
}
uint32_t nn::hac::XciHeader::getLimAreaPage() const
uint32_t nn::hac::GameCardHeader::getLimAreaPage() const
{
return mLimAreaPage;
}
void nn::hac::XciHeader::setLimAreaPage(uint32_t page)
void nn::hac::GameCardHeader::setLimAreaPage(uint32_t page)
{
mLimAreaPage = page;
}
uint32_t nn::hac::XciHeader::getFwVerMajor() const
uint32_t nn::hac::GameCardHeader::getFwVerMajor() const
{
return mFwVersion[xci::FWVER_MAJOR];
return mFwVersion[gc::FWVER_MAJOR];
}
void nn::hac::XciHeader::setFwVerMajor(uint32_t ver)
void nn::hac::GameCardHeader::setFwVerMajor(uint32_t ver)
{
mFwVersion[xci::FWVER_MAJOR] = ver;
mFwVersion[gc::FWVER_MAJOR] = ver;
}
uint32_t nn::hac::XciHeader::getFwVerMinor() const
uint32_t nn::hac::GameCardHeader::getFwVerMinor() const
{
return mFwVersion[xci::FWVER_MINOR];
return mFwVersion[gc::FWVER_MINOR];
}
void nn::hac::XciHeader::setFwVerMinor(uint32_t ver)
void nn::hac::GameCardHeader::setFwVerMinor(uint32_t ver)
{
mFwVersion[xci::FWVER_MINOR] = ver;
mFwVersion[gc::FWVER_MINOR] = ver;
}
uint32_t nn::hac::XciHeader::getAccCtrl1() const
uint32_t nn::hac::GameCardHeader::getAccCtrl1() const
{
return mAccCtrl1;
}
void nn::hac::XciHeader::setAccCtrl1(uint32_t acc_ctrl_1)
void nn::hac::GameCardHeader::setAccCtrl1(uint32_t acc_ctrl_1)
{
mAccCtrl1 = acc_ctrl_1;
}
uint32_t nn::hac::XciHeader::getWait1TimeRead() const
uint32_t nn::hac::GameCardHeader::getWait1TimeRead() const
{
return mWait1TimeRead;
}
void nn::hac::XciHeader::setWait1TimeRead(uint32_t seconds)
void nn::hac::GameCardHeader::setWait1TimeRead(uint32_t seconds)
{
mWait1TimeRead = seconds;
}
uint32_t nn::hac::XciHeader::getWait2TimeRead() const
uint32_t nn::hac::GameCardHeader::getWait2TimeRead() const
{
return mWait2TimeRead;
}
void nn::hac::XciHeader::setWait2TimeRead(uint32_t seconds)
void nn::hac::GameCardHeader::setWait2TimeRead(uint32_t seconds)
{
mWait2TimeRead = seconds;
}
uint32_t nn::hac::XciHeader::getWait1TimeWrite() const
uint32_t nn::hac::GameCardHeader::getWait1TimeWrite() const
{
return mWait1TimeWrite;
}
void nn::hac::XciHeader::setWait1TimeWrite(uint32_t seconds)
void nn::hac::GameCardHeader::setWait1TimeWrite(uint32_t seconds)
{
mWait1TimeWrite = seconds;
}
uint32_t nn::hac::XciHeader::getWait2TimeWrite() const
uint32_t nn::hac::GameCardHeader::getWait2TimeWrite() const
{
return mWait2TimeWrite;
}
void nn::hac::XciHeader::setWait2TimeWrite(uint32_t seconds)
void nn::hac::GameCardHeader::setWait2TimeWrite(uint32_t seconds)
{
mWait2TimeWrite = seconds;
}
uint32_t nn::hac::XciHeader::getFwMode() const
uint32_t nn::hac::GameCardHeader::getFwMode() const
{
return mFwMode;
}
void nn::hac::XciHeader::setFwMode(uint32_t fw_mode)
void nn::hac::GameCardHeader::setFwMode(uint32_t fw_mode)
{
mFwMode = fw_mode;
}
uint32_t nn::hac::XciHeader::getUppVersion() const
uint32_t nn::hac::GameCardHeader::getUppVersion() const
{
return mUppVersion;
}
void nn::hac::XciHeader::setUppVersion(uint32_t version)
void nn::hac::GameCardHeader::setUppVersion(uint32_t version)
{
mUppVersion = version;
}
const byte_t* nn::hac::XciHeader::getUppHash() const
const byte_t* nn::hac::GameCardHeader::getUppHash() const
{
return mUppHash;
}
void nn::hac::XciHeader::setUppHash(const byte_t* hash)
void nn::hac::GameCardHeader::setUppHash(const byte_t* hash)
{
memcpy(mUppHash, hash, xci::kUppHashLen);
memcpy(mUppHash, hash, gc::kUppHashLen);
}
uint64_t nn::hac::XciHeader::getUppId() const
uint64_t nn::hac::GameCardHeader::getUppId() const
{
return mUppId;
}
void nn::hac::XciHeader::setUppId(uint64_t id)
void nn::hac::GameCardHeader::setUppId(uint64_t id)
{
mUppId = id;
}

View file

@ -0,0 +1,22 @@
#include <nn/hac/GameCardUtils.h>
void nn::hac::GameCardUtils::getXciHeaderAesIv(const nn::hac::sGcHeader* hdr, byte_t* iv)
{
for (size_t i = 0; i < 16; i++)
{
iv[15-i] = hdr->aescbc_iv.iv[i];
}
}
void nn::hac::GameCardUtils::decryptXciHeader(const byte_t* src, byte_t* dst, const byte_t* key)
{
byte_t iv[fnd::aes::kAesBlockSize];
getXciHeaderAesIv((const nn::hac::sGcHeader*)src, iv);
// copy plain
memcpy(dst, src, nn::hac::gc::kHeaderEncOffset);
// decrypt encrypted data
fnd::aes::AesCbcDecrypt(src + nn::hac::gc::kHeaderEncOffset, nn::hac::gc::kHeaderEncSize, key, iv, dst + nn::hac::gc::kHeaderEncOffset);
}

View file

@ -1,231 +1,231 @@
#include <nn/hac/KernelCapabilityBinary.h>
nn::hac::KernelCapabilityBinary::KernelCapabilityBinary()
{}
nn::hac::KernelCapabilityBinary::KernelCapabilityBinary(const KernelCapabilityBinary & other)
{
*this = other;
}
void nn::hac::KernelCapabilityBinary::operator=(const KernelCapabilityBinary & other)
{
clear();
mRawBinary = other.mRawBinary;
mThreadInfo = other.mThreadInfo;
mSystemCalls = other.mSystemCalls;
mMemoryMap = other.mMemoryMap;
mInterupts = other.mInterupts;
mMiscParams = other.mMiscParams;
mKernelVersion = other.mKernelVersion;
mHandleTableSize = other.mHandleTableSize;
mMiscFlags = other.mMiscFlags;
}
bool nn::hac::KernelCapabilityBinary::operator==(const KernelCapabilityBinary & other) const
{
return (mThreadInfo == other.mThreadInfo) \
&& (mSystemCalls == other.mSystemCalls) \
&& (mMemoryMap == other.mMemoryMap) \
&& (mInterupts == other.mInterupts) \
&& (mMiscParams == other.mMiscParams) \
&& (mKernelVersion == other.mKernelVersion) \
&& (mHandleTableSize == other.mHandleTableSize) \
&& (mMiscFlags == other.mMiscFlags);
}
bool nn::hac::KernelCapabilityBinary::operator!=(const KernelCapabilityBinary & other) const
{
return !(*this == other);
}
void nn::hac::KernelCapabilityBinary::toBytes()
{
fnd::List<KernelCapabilityEntry> caps;
// get kernel capabiliteis
mThreadInfo.exportKernelCapabilityList(caps);
mSystemCalls.exportKernelCapabilityList(caps);
mMemoryMap.exportKernelCapabilityList(caps);
mInterupts.exportKernelCapabilityList(caps);
mMiscParams.exportKernelCapabilityList(caps);
mKernelVersion.exportKernelCapabilityList(caps);
mHandleTableSize.exportKernelCapabilityList(caps);
mMiscFlags.exportKernelCapabilityList(caps);
// allocate memory
mRawBinary.alloc(caps.size() * sizeof(uint32_t));
// write to binary
uint32_t* raw_caps = (uint32_t*)mRawBinary.data();
for (size_t i = 0; i < caps.size(); i++)
{
raw_caps[i] = le_word(caps[i].getCap());
}
}
void nn::hac::KernelCapabilityBinary::fromBytes(const byte_t * data, size_t len)
{
if ((len % sizeof(uint32_t)) != 0)
{
throw fnd::Exception(kModuleName, "KernelCapabilityEntry list must be aligned to 4 bytes");
}
// save copy of KernelCapabilityBinary
mRawBinary.alloc(len);
memcpy(mRawBinary.data(), data, len);
fnd::List<KernelCapabilityEntry> threadInfoCaps;
fnd::List<KernelCapabilityEntry> systemCallCaps;
fnd::List<KernelCapabilityEntry> memoryMapCaps;
fnd::List<KernelCapabilityEntry> interuptCaps;
fnd::List<KernelCapabilityEntry> miscParamCaps;
fnd::List<KernelCapabilityEntry> kernelVersionCaps;
fnd::List<KernelCapabilityEntry> handleTableSizeCaps;
fnd::List<KernelCapabilityEntry> miscFlagsCaps;
const uint32_t* raw_caps = (const uint32_t*)mRawBinary.data();
size_t cap_num = mRawBinary.size() / sizeof(uint32_t);
KernelCapabilityEntry cap;
for (size_t i = 0; i < cap_num; i++)
{
cap.setCap(le_word(raw_caps[i]));
switch (cap.getType())
{
case (kc::KC_THREAD_INFO) :
threadInfoCaps.addElement(cap);
break;
case (kc::KC_ENABLE_SYSTEM_CALLS):
systemCallCaps.addElement(cap);
break;
case (kc::KC_MEMORY_MAP):
case (kc::KC_IO_MEMORY_MAP):
memoryMapCaps.addElement(cap);
break;
case (kc::KC_ENABLE_INTERUPTS):
interuptCaps.addElement(cap);
break;
case (kc::KC_MISC_PARAMS):
miscParamCaps.addElement(cap);
break;
case (kc::KC_KERNEL_VERSION):
kernelVersionCaps.addElement(cap);
break;
case (kc::KC_HANDLE_TABLE_SIZE):
handleTableSizeCaps.addElement(cap);
break;
case (kc::KC_MISC_FLAGS):
miscFlagsCaps.addElement(cap);
break;
default:
throw fnd::Exception(kModuleName, "Unsupported kernel capability type");
}
}
mThreadInfo.importKernelCapabilityList(threadInfoCaps);
mSystemCalls.importKernelCapabilityList(systemCallCaps);
mMemoryMap.importKernelCapabilityList(memoryMapCaps);
mInterupts.importKernelCapabilityList(interuptCaps);
mMiscParams.importKernelCapabilityList(miscParamCaps);
mKernelVersion.importKernelCapabilityList(kernelVersionCaps);
mHandleTableSize.importKernelCapabilityList(handleTableSizeCaps);
mMiscFlags.importKernelCapabilityList(miscFlagsCaps);
}
const fnd::Vec<byte_t>& nn::hac::KernelCapabilityBinary::getBytes() const
{
return mRawBinary;
}
void nn::hac::KernelCapabilityBinary::clear()
{
mRawBinary.clear();
mThreadInfo.clear();
mSystemCalls.clear();
mMemoryMap.clear();
mInterupts.clear();
mMiscParams.clear();
mKernelVersion.clear();
mHandleTableSize.clear();
mMiscFlags.clear();
}
const nn::hac::ThreadInfoHandler & nn::hac::KernelCapabilityBinary::getThreadInfo() const
{
return mThreadInfo;
}
nn::hac::ThreadInfoHandler & nn::hac::KernelCapabilityBinary::getThreadInfo()
{
return mThreadInfo;
}
const nn::hac::SystemCallHandler & nn::hac::KernelCapabilityBinary::getSystemCalls() const
{
return mSystemCalls;
}
nn::hac::SystemCallHandler & nn::hac::KernelCapabilityBinary::getSystemCalls()
{
return mSystemCalls;
}
const nn::hac::MemoryMappingHandler & nn::hac::KernelCapabilityBinary::getMemoryMaps() const
{
return mMemoryMap;
}
nn::hac::MemoryMappingHandler & nn::hac::KernelCapabilityBinary::getMemoryMaps()
{
return mMemoryMap;
}
const nn::hac::InteruptHandler & nn::hac::KernelCapabilityBinary::getInterupts() const
{
return mInterupts;
}
nn::hac::InteruptHandler & nn::hac::KernelCapabilityBinary::getInterupts()
{
return mInterupts;
}
const nn::hac::MiscParamsHandler & nn::hac::KernelCapabilityBinary::getMiscParams() const
{
return mMiscParams;
}
nn::hac::MiscParamsHandler & nn::hac::KernelCapabilityBinary::getMiscParams()
{
return mMiscParams;
}
const nn::hac::KernelVersionHandler & nn::hac::KernelCapabilityBinary::getKernelVersion() const
{
return mKernelVersion;
}
nn::hac::KernelVersionHandler & nn::hac::KernelCapabilityBinary::getKernelVersion()
{
return mKernelVersion;
}
const nn::hac::HandleTableSizeHandler & nn::hac::KernelCapabilityBinary::getHandleTableSize() const
{
return mHandleTableSize;
}
nn::hac::HandleTableSizeHandler & nn::hac::KernelCapabilityBinary::getHandleTableSize()
{
return mHandleTableSize;
}
const nn::hac::MiscFlagsHandler & nn::hac::KernelCapabilityBinary::getMiscFlags() const
{
return mMiscFlags;
}
nn::hac::MiscFlagsHandler & nn::hac::KernelCapabilityBinary::getMiscFlags()
{
return mMiscFlags;
#include <nn/hac/KernelCapabilityControl.h>
nn::hac::KernelCapabilityControl::KernelCapabilityControl()
{}
nn::hac::KernelCapabilityControl::KernelCapabilityControl(const KernelCapabilityControl & other)
{
*this = other;
}
void nn::hac::KernelCapabilityControl::operator=(const KernelCapabilityControl & other)
{
clear();
mRawBinary = other.mRawBinary;
mThreadInfo = other.mThreadInfo;
mSystemCalls = other.mSystemCalls;
mMemoryMap = other.mMemoryMap;
mInterupts = other.mInterupts;
mMiscParams = other.mMiscParams;
mKernelVersion = other.mKernelVersion;
mHandleTableSize = other.mHandleTableSize;
mMiscFlags = other.mMiscFlags;
}
bool nn::hac::KernelCapabilityControl::operator==(const KernelCapabilityControl & other) const
{
return (mThreadInfo == other.mThreadInfo) \
&& (mSystemCalls == other.mSystemCalls) \
&& (mMemoryMap == other.mMemoryMap) \
&& (mInterupts == other.mInterupts) \
&& (mMiscParams == other.mMiscParams) \
&& (mKernelVersion == other.mKernelVersion) \
&& (mHandleTableSize == other.mHandleTableSize) \
&& (mMiscFlags == other.mMiscFlags);
}
bool nn::hac::KernelCapabilityControl::operator!=(const KernelCapabilityControl & other) const
{
return !(*this == other);
}
void nn::hac::KernelCapabilityControl::toBytes()
{
fnd::List<KernelCapabilityEntry> caps;
// get kernel capabiliteis
mThreadInfo.exportKernelCapabilityList(caps);
mSystemCalls.exportKernelCapabilityList(caps);
mMemoryMap.exportKernelCapabilityList(caps);
mInterupts.exportKernelCapabilityList(caps);
mMiscParams.exportKernelCapabilityList(caps);
mKernelVersion.exportKernelCapabilityList(caps);
mHandleTableSize.exportKernelCapabilityList(caps);
mMiscFlags.exportKernelCapabilityList(caps);
// allocate memory
mRawBinary.alloc(caps.size() * sizeof(uint32_t));
// write to binary
uint32_t* raw_caps = (uint32_t*)mRawBinary.data();
for (size_t i = 0; i < caps.size(); i++)
{
raw_caps[i] = le_word(caps[i].getCap());
}
}
void nn::hac::KernelCapabilityControl::fromBytes(const byte_t * data, size_t len)
{
if ((len % sizeof(uint32_t)) != 0)
{
throw fnd::Exception(kModuleName, "KernelCapabilityEntry list must be aligned to 4 bytes");
}
// save copy of KernelCapabilityControl
mRawBinary.alloc(len);
memcpy(mRawBinary.data(), data, len);
fnd::List<KernelCapabilityEntry> threadInfoCaps;
fnd::List<KernelCapabilityEntry> systemCallCaps;
fnd::List<KernelCapabilityEntry> memoryMapCaps;
fnd::List<KernelCapabilityEntry> interuptCaps;
fnd::List<KernelCapabilityEntry> miscParamCaps;
fnd::List<KernelCapabilityEntry> kernelVersionCaps;
fnd::List<KernelCapabilityEntry> handleTableSizeCaps;
fnd::List<KernelCapabilityEntry> miscFlagsCaps;
const uint32_t* raw_caps = (const uint32_t*)mRawBinary.data();
size_t cap_num = mRawBinary.size() / sizeof(uint32_t);
KernelCapabilityEntry cap;
for (size_t i = 0; i < cap_num; i++)
{
cap.setCap(le_word(raw_caps[i]));
switch (cap.getType())
{
case (kc::KC_THREAD_INFO) :
threadInfoCaps.addElement(cap);
break;
case (kc::KC_ENABLE_SYSTEM_CALLS):
systemCallCaps.addElement(cap);
break;
case (kc::KC_MEMORY_MAP):
case (kc::KC_IO_MEMORY_MAP):
memoryMapCaps.addElement(cap);
break;
case (kc::KC_ENABLE_INTERUPTS):
interuptCaps.addElement(cap);
break;
case (kc::KC_MISC_PARAMS):
miscParamCaps.addElement(cap);
break;
case (kc::KC_KERNEL_VERSION):
kernelVersionCaps.addElement(cap);
break;
case (kc::KC_HANDLE_TABLE_SIZE):
handleTableSizeCaps.addElement(cap);
break;
case (kc::KC_MISC_FLAGS):
miscFlagsCaps.addElement(cap);
break;
default:
throw fnd::Exception(kModuleName, "Unsupported kernel capability type");
}
}
mThreadInfo.importKernelCapabilityList(threadInfoCaps);
mSystemCalls.importKernelCapabilityList(systemCallCaps);
mMemoryMap.importKernelCapabilityList(memoryMapCaps);
mInterupts.importKernelCapabilityList(interuptCaps);
mMiscParams.importKernelCapabilityList(miscParamCaps);
mKernelVersion.importKernelCapabilityList(kernelVersionCaps);
mHandleTableSize.importKernelCapabilityList(handleTableSizeCaps);
mMiscFlags.importKernelCapabilityList(miscFlagsCaps);
}
const fnd::Vec<byte_t>& nn::hac::KernelCapabilityControl::getBytes() const
{
return mRawBinary;
}
void nn::hac::KernelCapabilityControl::clear()
{
mRawBinary.clear();
mThreadInfo.clear();
mSystemCalls.clear();
mMemoryMap.clear();
mInterupts.clear();
mMiscParams.clear();
mKernelVersion.clear();
mHandleTableSize.clear();
mMiscFlags.clear();
}
const nn::hac::ThreadInfoHandler & nn::hac::KernelCapabilityControl::getThreadInfo() const
{
return mThreadInfo;
}
nn::hac::ThreadInfoHandler & nn::hac::KernelCapabilityControl::getThreadInfo()
{
return mThreadInfo;
}
const nn::hac::SystemCallHandler & nn::hac::KernelCapabilityControl::getSystemCalls() const
{
return mSystemCalls;
}
nn::hac::SystemCallHandler & nn::hac::KernelCapabilityControl::getSystemCalls()
{
return mSystemCalls;
}
const nn::hac::MemoryMappingHandler & nn::hac::KernelCapabilityControl::getMemoryMaps() const
{
return mMemoryMap;
}
nn::hac::MemoryMappingHandler & nn::hac::KernelCapabilityControl::getMemoryMaps()
{
return mMemoryMap;
}
const nn::hac::InteruptHandler & nn::hac::KernelCapabilityControl::getInterupts() const
{
return mInterupts;
}
nn::hac::InteruptHandler & nn::hac::KernelCapabilityControl::getInterupts()
{
return mInterupts;
}
const nn::hac::MiscParamsHandler & nn::hac::KernelCapabilityControl::getMiscParams() const
{
return mMiscParams;
}
nn::hac::MiscParamsHandler & nn::hac::KernelCapabilityControl::getMiscParams()
{
return mMiscParams;
}
const nn::hac::KernelVersionHandler & nn::hac::KernelCapabilityControl::getKernelVersion() const
{
return mKernelVersion;
}
nn::hac::KernelVersionHandler & nn::hac::KernelCapabilityControl::getKernelVersion()
{
return mKernelVersion;
}
const nn::hac::HandleTableSizeHandler & nn::hac::KernelCapabilityControl::getHandleTableSize() const
{
return mHandleTableSize;
}
nn::hac::HandleTableSizeHandler & nn::hac::KernelCapabilityControl::getHandleTableSize()
{
return mHandleTableSize;
}
const nn::hac::MiscFlagsHandler & nn::hac::KernelCapabilityControl::getMiscFlags() const
{
return mMiscFlags;
}
nn::hac::MiscFlagsHandler & nn::hac::KernelCapabilityControl::getMiscFlags()
{
return mMiscFlags;
}

View file

@ -1,295 +1,295 @@
#include <nn/hac/MetaBinary.h>
#include <fnd/SimpleTextOutput.h>
nn::hac::MetaBinary::MetaBinary()
{
clear();
}
nn::hac::MetaBinary::MetaBinary(const MetaBinary & other) :
MetaBinary()
{
*this = other;
}
void nn::hac::MetaBinary::operator=(const MetaBinary & other)
{
mRawBinary = other.mRawBinary;
mInstructionType = other.mInstructionType;
mProcAddressSpaceType = other.mProcAddressSpaceType;
mMainThreadPriority = other.mMainThreadPriority;
mMainThreadCpuId = other.mMainThreadCpuId;
mVersion = other.mVersion;
mMainThreadStackSize = other.mMainThreadStackSize;
mName = other.mName;
mProductCode = other.mProductCode;
mAci = other.mAci;
mAcid = other.mAcid;
}
bool nn::hac::MetaBinary::operator==(const MetaBinary & other) const
{
return (mInstructionType == other.mInstructionType) \
&& (mProcAddressSpaceType == other.mProcAddressSpaceType) \
&& (mMainThreadPriority == other.mMainThreadPriority) \
&& (mMainThreadCpuId == other.mMainThreadCpuId) \
&& (mVersion == other.mVersion) \
&& (mMainThreadStackSize == other.mMainThreadStackSize) \
&& (mName == other.mName) \
&& (mProductCode == other.mProductCode) \
&& (mAci == other.mAci) \
&& (mAcid == other.mAcid);
}
bool nn::hac::MetaBinary::operator!=(const MetaBinary & other) const
{
return !(*this == other);
}
void nn::hac::MetaBinary::toBytes()
{
if (mAcid.getBytes().size() == 0)
mAcid.toBytes();
if (mAci.getBytes().size() == 0)
mAci.toBytes();
// determine section layout
struct sLayout {
uint32_t offset, size;
} acid, aci;
acid.offset = (uint32_t)align(sizeof(sMetaHeader), meta::kSectionAlignSize);
acid.size = (uint32_t)mAcid.getBytes().size();
aci.offset = (uint32_t)(acid.offset + align(acid.size, meta::kSectionAlignSize));
aci.size = (uint32_t)mAci.getBytes().size();
// get total size
size_t total_size = _MAX(_MAX(acid.offset + acid.size, aci.offset + aci.size), align(sizeof(sMetaHeader), meta::kSectionAlignSize));
mRawBinary.alloc(total_size);
sMetaHeader* hdr = (sMetaHeader*)mRawBinary.data();
// set type
hdr->st_magic = meta::kMetaStructMagic;
// set variables
byte_t flag = ((byte_t)(mInstructionType & 1) | (byte_t)((mProcAddressSpaceType & 3) << 1)) & 0xf;
hdr->flags = flag;
hdr->main_thread_priority = mMainThreadPriority;
hdr->main_thread_cpu_id = mMainThreadCpuId;
hdr->version = mVersion;
hdr->main_thread_stack_size = mMainThreadStackSize;
strncpy(hdr->name, mName.c_str(), meta::kNameMaxLen);
strncpy(hdr->product_code, mProductCode.c_str(), meta::kProductCodeMaxLen);
// set offset/size
hdr->aci.offset = aci.offset;
hdr->aci.size = aci.size;
hdr->acid.offset = acid.offset;
hdr->acid.size = acid.size;
// write aci & acid
if (mAci.getBytes().size() > 0)
{
memcpy(mRawBinary.data() + aci.offset, mAci.getBytes().data(), mAci.getBytes().size());
}
if (mAcid.getBytes().size() > 0)
{
memcpy(mRawBinary.data() + acid.offset, mAcid.getBytes().data(), mAcid.getBytes().size());
}
}
void nn::hac::MetaBinary::fromBytes(const byte_t* data, size_t len)
{
// check size
if (len < sizeof(sMetaHeader))
{
throw fnd::Exception(kModuleName, "META binary is too small");
}
// clear variables
clear();
// save a copy of the header
sMetaHeader hdr;
memcpy((void*)&hdr, data, sizeof(sMetaHeader));
// check magic
if (hdr.st_magic.get() != meta::kMetaStructMagic)
{
throw fnd::Exception(kModuleName, "META header corrupt (unrecognised struct signature)");
}
// save variables
byte_t flag = hdr.flags & 0xf;
mInstructionType = (meta::InstructionType)(flag & 1);
mProcAddressSpaceType = (meta::ProcAddrSpaceType)((flag >> 1) & 3);
mMainThreadPriority = hdr.main_thread_priority;
mMainThreadCpuId = hdr.main_thread_cpu_id;
mVersion = hdr.version.get();
mMainThreadStackSize = hdr.main_thread_stack_size.get();
mName = std::string(hdr.name, _MIN(strlen(hdr.name), meta::kNameMaxLen));
mProductCode = std::string(hdr.product_code, _MIN(strlen(hdr.product_code), meta::kProductCodeMaxLen));
// total size
size_t total_size = _MAX(_MAX(hdr.acid.offset.get() + hdr.acid.size.get(), hdr.aci.offset.get() + hdr.aci.size.get()), sizeof(sMetaHeader));
// check size
if (total_size > len)
{
throw fnd::Exception(kModuleName, "META binary too small");
}
// save local copy
mRawBinary.alloc(total_size);
memcpy(mRawBinary.data(), data, mRawBinary.size());
// import Aci/Acid
if (hdr.aci.size.get())
{
mAci.fromBytes(mRawBinary.data() + hdr.aci.offset.get(), hdr.aci.size.get());
}
if (hdr.acid.size.get())
{
mAcid.fromBytes(mRawBinary.data() + hdr.acid.offset.get(), hdr.acid.size.get());
}
}
const fnd::Vec<byte_t>& nn::hac::MetaBinary::getBytes() const
{
return mRawBinary;
}
void nn::hac::MetaBinary::clear()
{
mRawBinary.clear();
mInstructionType = meta::INSTR_64BIT;
mProcAddressSpaceType = meta::ADDR_SPACE_64BIT;
mMainThreadPriority = 0;
mMainThreadCpuId = 0;
mVersion = 0;
mMainThreadStackSize = 0;
mName.clear();
mProductCode.clear();
mAci.clear();
mAcid.clear();
}
nn::hac::meta::InstructionType nn::hac::MetaBinary::getInstructionType() const
{
return mInstructionType;
}
void nn::hac::MetaBinary::setInstructionType(meta::InstructionType type)
{
mInstructionType = type;
}
nn::hac::meta::ProcAddrSpaceType nn::hac::MetaBinary::getProcAddressSpaceType() const
{
return mProcAddressSpaceType;
}
void nn::hac::MetaBinary::setProcAddressSpaceType(meta::ProcAddrSpaceType type)
{
mProcAddressSpaceType = type;
}
byte_t nn::hac::MetaBinary::getMainThreadPriority() const
{
return mMainThreadPriority;
}
void nn::hac::MetaBinary::setMainThreadPriority(byte_t priority)
{
if (priority > meta::kMaxPriority)
{
throw fnd::Exception(kModuleName, "Illegal main thread priority (range 0-63)");
}
mMainThreadPriority = priority;
}
byte_t nn::hac::MetaBinary::getMainThreadCpuId() const
{
return mMainThreadCpuId;
}
void nn::hac::MetaBinary::setMainThreadCpuId(byte_t core_num)
{
mMainThreadCpuId = core_num;
}
uint32_t nn::hac::MetaBinary::getVersion() const
{
return mVersion;
}
void nn::hac::MetaBinary::setVersion(uint32_t version)
{
mVersion = version;
}
uint32_t nn::hac::MetaBinary::getMainThreadStackSize() const
{
return mMainThreadStackSize;
}
void nn::hac::MetaBinary::setMainThreadStackSize(uint32_t size)
{
mMainThreadStackSize = size;
}
const std::string & nn::hac::MetaBinary::getName() const
{
return mName;
}
void nn::hac::MetaBinary::setName(const std::string & name)
{
if (name.length() > meta::kNameMaxLen)
{
throw fnd::Exception(kModuleName, "Name is too long");
}
mName = name;
}
const std::string & nn::hac::MetaBinary::getProductCode() const
{
return mProductCode;
}
void nn::hac::MetaBinary::setProductCode(const std::string & product_code)
{
if (product_code.length() > meta::kProductCodeMaxLen)
{
throw fnd::Exception(kModuleName, "Product Code is too long");
}
mProductCode = product_code;
}
const nn::hac::AccessControlInfoBinary & nn::hac::MetaBinary::getAci() const
{
return mAci;
}
void nn::hac::MetaBinary::setAci(const AccessControlInfoBinary & aci)
{
mAci = aci;
}
const nn::hac::AccessControlInfoDescBinary & nn::hac::MetaBinary::getAcid() const
{
return mAcid;
}
void nn::hac::MetaBinary::setAcid(const AccessControlInfoDescBinary & acid)
{
mAcid = acid;
#include <nn/hac/Meta.h>
#include <fnd/SimpleTextOutput.h>
nn::hac::Meta::Meta()
{
clear();
}
nn::hac::Meta::Meta(const Meta & other) :
Meta()
{
*this = other;
}
void nn::hac::Meta::operator=(const Meta & other)
{
mRawBinary = other.mRawBinary;
mInstructionType = other.mInstructionType;
mProcAddressSpaceType = other.mProcAddressSpaceType;
mMainThreadPriority = other.mMainThreadPriority;
mMainThreadCpuId = other.mMainThreadCpuId;
mVersion = other.mVersion;
mMainThreadStackSize = other.mMainThreadStackSize;
mName = other.mName;
mProductCode = other.mProductCode;
mAci = other.mAci;
mAcid = other.mAcid;
}
bool nn::hac::Meta::operator==(const Meta & other) const
{
return (mInstructionType == other.mInstructionType) \
&& (mProcAddressSpaceType == other.mProcAddressSpaceType) \
&& (mMainThreadPriority == other.mMainThreadPriority) \
&& (mMainThreadCpuId == other.mMainThreadCpuId) \
&& (mVersion == other.mVersion) \
&& (mMainThreadStackSize == other.mMainThreadStackSize) \
&& (mName == other.mName) \
&& (mProductCode == other.mProductCode) \
&& (mAci == other.mAci) \
&& (mAcid == other.mAcid);
}
bool nn::hac::Meta::operator!=(const Meta & other) const
{
return !(*this == other);
}
void nn::hac::Meta::toBytes()
{
if (mAcid.getBytes().size() == 0)
mAcid.toBytes();
if (mAci.getBytes().size() == 0)
mAci.toBytes();
// determine section layout
struct sLayout {
uint32_t offset, size;
} acid, aci;
acid.offset = (uint32_t)align(sizeof(sMetaHeader), meta::kSectionAlignSize);
acid.size = (uint32_t)mAcid.getBytes().size();
aci.offset = (uint32_t)(acid.offset + align(acid.size, meta::kSectionAlignSize));
aci.size = (uint32_t)mAci.getBytes().size();
// get total size
size_t total_size = _MAX(_MAX(acid.offset + acid.size, aci.offset + aci.size), align(sizeof(sMetaHeader), meta::kSectionAlignSize));
mRawBinary.alloc(total_size);
sMetaHeader* hdr = (sMetaHeader*)mRawBinary.data();
// set type
hdr->st_magic = meta::kMetaStructMagic;
// set variables
byte_t flag = ((byte_t)(mInstructionType & 1) | (byte_t)((mProcAddressSpaceType & 3) << 1)) & 0xf;
hdr->flags = flag;
hdr->main_thread_priority = mMainThreadPriority;
hdr->main_thread_cpu_id = mMainThreadCpuId;
hdr->version = mVersion;
hdr->main_thread_stack_size = mMainThreadStackSize;
strncpy(hdr->name, mName.c_str(), meta::kNameMaxLen);
strncpy(hdr->product_code, mProductCode.c_str(), meta::kProductCodeMaxLen);
// set offset/size
hdr->aci.offset = aci.offset;
hdr->aci.size = aci.size;
hdr->acid.offset = acid.offset;
hdr->acid.size = acid.size;
// write aci & acid
if (mAci.getBytes().size() > 0)
{
memcpy(mRawBinary.data() + aci.offset, mAci.getBytes().data(), mAci.getBytes().size());
}
if (mAcid.getBytes().size() > 0)
{
memcpy(mRawBinary.data() + acid.offset, mAcid.getBytes().data(), mAcid.getBytes().size());
}
}
void nn::hac::Meta::fromBytes(const byte_t* data, size_t len)
{
// check size
if (len < sizeof(sMetaHeader))
{
throw fnd::Exception(kModuleName, "META binary is too small");
}
// clear variables
clear();
// save a copy of the header
sMetaHeader hdr;
memcpy((void*)&hdr, data, sizeof(sMetaHeader));
// check magic
if (hdr.st_magic.get() != meta::kMetaStructMagic)
{
throw fnd::Exception(kModuleName, "META header corrupt (unrecognised struct signature)");
}
// save variables
byte_t flag = hdr.flags & 0xf;
mInstructionType = (meta::InstructionType)(flag & 1);
mProcAddressSpaceType = (meta::ProcAddrSpaceType)((flag >> 1) & 3);
mMainThreadPriority = hdr.main_thread_priority;
mMainThreadCpuId = hdr.main_thread_cpu_id;
mVersion = hdr.version.get();
mMainThreadStackSize = hdr.main_thread_stack_size.get();
mName = std::string(hdr.name, _MIN(strlen(hdr.name), meta::kNameMaxLen));
mProductCode = std::string(hdr.product_code, _MIN(strlen(hdr.product_code), meta::kProductCodeMaxLen));
// total size
size_t total_size = _MAX(_MAX(hdr.acid.offset.get() + hdr.acid.size.get(), hdr.aci.offset.get() + hdr.aci.size.get()), sizeof(sMetaHeader));
// check size
if (total_size > len)
{
throw fnd::Exception(kModuleName, "META binary too small");
}
// save local copy
mRawBinary.alloc(total_size);
memcpy(mRawBinary.data(), data, mRawBinary.size());
// import Aci/Acid
if (hdr.aci.size.get())
{
mAci.fromBytes(mRawBinary.data() + hdr.aci.offset.get(), hdr.aci.size.get());
}
if (hdr.acid.size.get())
{
mAcid.fromBytes(mRawBinary.data() + hdr.acid.offset.get(), hdr.acid.size.get());
}
}
const fnd::Vec<byte_t>& nn::hac::Meta::getBytes() const
{
return mRawBinary;
}
void nn::hac::Meta::clear()
{
mRawBinary.clear();
mInstructionType = meta::INSTR_64BIT;
mProcAddressSpaceType = meta::ADDR_SPACE_64BIT;
mMainThreadPriority = 0;
mMainThreadCpuId = 0;
mVersion = 0;
mMainThreadStackSize = 0;
mName.clear();
mProductCode.clear();
mAci.clear();
mAcid.clear();
}
nn::hac::meta::InstructionType nn::hac::Meta::getInstructionType() const
{
return mInstructionType;
}
void nn::hac::Meta::setInstructionType(meta::InstructionType type)
{
mInstructionType = type;
}
nn::hac::meta::ProcAddrSpaceType nn::hac::Meta::getProcAddressSpaceType() const
{
return mProcAddressSpaceType;
}
void nn::hac::Meta::setProcAddressSpaceType(meta::ProcAddrSpaceType type)
{
mProcAddressSpaceType = type;
}
byte_t nn::hac::Meta::getMainThreadPriority() const
{
return mMainThreadPriority;
}
void nn::hac::Meta::setMainThreadPriority(byte_t priority)
{
if (priority > meta::kMaxPriority)
{
throw fnd::Exception(kModuleName, "Illegal main thread priority (range 0-63)");
}
mMainThreadPriority = priority;
}
byte_t nn::hac::Meta::getMainThreadCpuId() const
{
return mMainThreadCpuId;
}
void nn::hac::Meta::setMainThreadCpuId(byte_t core_num)
{
mMainThreadCpuId = core_num;
}
uint32_t nn::hac::Meta::getVersion() const
{
return mVersion;
}
void nn::hac::Meta::setVersion(uint32_t version)
{
mVersion = version;
}
uint32_t nn::hac::Meta::getMainThreadStackSize() const
{
return mMainThreadStackSize;
}
void nn::hac::Meta::setMainThreadStackSize(uint32_t size)
{
mMainThreadStackSize = size;
}
const std::string & nn::hac::Meta::getName() const
{
return mName;
}
void nn::hac::Meta::setName(const std::string & name)
{
if (name.length() > meta::kNameMaxLen)
{
throw fnd::Exception(kModuleName, "Name is too long");
}
mName = name;
}
const std::string & nn::hac::Meta::getProductCode() const
{
return mProductCode;
}
void nn::hac::Meta::setProductCode(const std::string & product_code)
{
if (product_code.length() > meta::kProductCodeMaxLen)
{
throw fnd::Exception(kModuleName, "Product Code is too long");
}
mProductCode = product_code;
}
const nn::hac::AccessControlInfo & nn::hac::Meta::getAci() const
{
return mAci;
}
void nn::hac::Meta::setAci(const AccessControlInfo & aci)
{
mAci = aci;
}
const nn::hac::AccessControlInfoDesc & nn::hac::Meta::getAcid() const
{
return mAcid;
}
void nn::hac::Meta::setAcid(const AccessControlInfoDesc & acid)
{
mAcid = acid;
}

View file

@ -1,327 +0,0 @@
#include <nn/hac/NcaHeader.h>
nn::hac::NcaHeader::NcaHeader()
{
clear();
}
nn::hac::NcaHeader::NcaHeader(const NcaHeader & other)
{
*this = other;
}
bool nn::hac::NcaHeader::operator==(const NcaHeader & other) const
{
return (mDistributionType == other.mDistributionType) \
&& (mContentType == other.mContentType) \
&& (mKeyGeneration == other.mKeyGeneration) \
&& (mKaekIndex == other.mKaekIndex) \
&& (mContentSize == other.mContentSize) \
&& (mProgramId == other.mProgramId) \
&& (mContentIndex == other.mContentIndex) \
&& (mSdkAddonVersion == other.mSdkAddonVersion) \
&& (mPartitions == other.mPartitions) \
&& (mEncAesKeys == other.mEncAesKeys);
}
bool nn::hac::NcaHeader::operator!=(const NcaHeader & other) const
{
return !(*this == other);
}
void nn::hac::NcaHeader::operator=(const NcaHeader & other)
{
if (other.getBytes().size())
{
fromBytes(other.getBytes().data(), other.getBytes().size());
}
else
{
mRawBinary.clear();
mDistributionType = other.mDistributionType;
mContentType = other.mContentType;
mKeyGeneration = other.mKeyGeneration;
mKaekIndex = other.mKaekIndex;
mContentSize = other.mContentSize;
mProgramId = other.mProgramId;
mContentIndex = other.mContentIndex;
mSdkAddonVersion = other.mSdkAddonVersion;
mPartitions = other.mPartitions;
mEncAesKeys = other.mEncAesKeys;
}
}
void nn::hac::NcaHeader::toBytes()
{
mRawBinary.alloc(sizeof(sNcaHeader));
sNcaHeader* hdr = (sNcaHeader*)mRawBinary.data();
switch(mFormatVersion)
{
case (NCA2_FORMAT):
hdr->st_magic = nca::kNca2StructMagic;
break;
case (NCA3_FORMAT):
hdr->st_magic = nca::kNca3StructMagic;
break;
default:
throw fnd::Exception(kModuleName, "Unsupported format version");
}
hdr->distribution_type = mDistributionType;
hdr->content_type = mContentType;
if (mKeyGeneration > 2)
{
hdr->key_generation = 2;
hdr->key_generation_2 = mKeyGeneration;
}
else
{
hdr->key_generation = mKeyGeneration;
hdr->key_generation_2 = 0;
}
hdr->key_area_encryption_key_index = mKaekIndex;
hdr->content_size = mContentSize;
hdr->program_id = mProgramId;
hdr->content_index = mContentIndex;
hdr->sdk_addon_version = mSdkAddonVersion;
memcpy(hdr->rights_id, mRightsId, nca::kRightsIdLen);
// TODO: properly reconstruct NCA layout? atm in hands of user
for (size_t i = 0; i < mPartitions.size(); i++)
{
// determine partition index
byte_t idx = mPartitions[i].index;
if (mPartitions[i].index >= nca::kPartitionNum || hdr->partition[idx].enabled) continue;
hdr->partition[idx].start = sizeToBlockNum(mPartitions[i].offset);
hdr->partition[idx].end = (sizeToBlockNum(mPartitions[i].offset) + sizeToBlockNum(mPartitions[i].size));
hdr->partition[idx].enabled = true;
hdr->partition_hash[idx] = mPartitions[i].hash;
}
for (size_t i = 0; i < nca::kAesKeyNum; i++)
{
hdr->enc_aes_key[i] = mEncAesKeys[i];
}
}
void nn::hac::NcaHeader::fromBytes(const byte_t * data, size_t len)
{
if (len < sizeof(sNcaHeader))
{
throw fnd::Exception(kModuleName, "NCA header size is too small");
}
clear();
mRawBinary.alloc(sizeof(sNcaHeader));
memcpy(mRawBinary.data(), data, sizeof(sNcaHeader));
sNcaHeader* hdr = (sNcaHeader*)mRawBinary.data();
switch(hdr->st_magic.get())
{
case (nca::kNca2StructMagic) :
mFormatVersion = NCA2_FORMAT;
break;
case (nca::kNca3StructMagic) :
mFormatVersion = NCA3_FORMAT;
break;
throw fnd::Exception(kModuleName, "NCA header corrupt");
}
mDistributionType = (nca::DistributionType)hdr->distribution_type;
mContentType = (nca::ContentType)hdr->content_type;
mKeyGeneration = _MAX(hdr->key_generation, hdr->key_generation_2);
mKaekIndex = hdr->key_area_encryption_key_index;
mContentSize = *hdr->content_size;
mProgramId = *hdr->program_id;
mContentIndex = *hdr->content_index;
mSdkAddonVersion = *hdr->sdk_addon_version;
memcpy(mRightsId, hdr->rights_id, nca::kRightsIdLen);
for (size_t i = 0; i < nca::kPartitionNum; i++)
{
// skip sections that don't exist
if (hdr->partition[i].enabled == 0) continue;
// add high level struct
mPartitions.addElement({(byte_t)i, blockNumToSize(hdr->partition[i].start.get()), blockNumToSize(hdr->partition[i].end.get() - hdr->partition[i].start.get()), hdr->partition_hash[i] });
}
for (size_t i = 0; i < nca::kAesKeyNum; i++)
{
mEncAesKeys.addElement(hdr->enc_aes_key[i]);
}
}
const fnd::Vec<byte_t>& nn::hac::NcaHeader::getBytes() const
{
return mRawBinary;
}
void nn::hac::NcaHeader::clear()
{
mFormatVersion = NCA3_FORMAT;
mDistributionType = nca::DIST_DOWNLOAD;
mContentType = nca::TYPE_PROGRAM;
mKeyGeneration = 0;
mKaekIndex = 0;
mContentSize = 0;
mProgramId = 0;
mContentIndex = 0;
mSdkAddonVersion = 0;
mPartitions.clear();
mEncAesKeys.clear();
}
nn::hac::NcaHeader::FormatVersion nn::hac::NcaHeader::getFormatVersion() const
{
return mFormatVersion;
}
void nn::hac::NcaHeader::setFormatVersion(FormatVersion version)
{
mFormatVersion = version;
}
nn::hac::nca::DistributionType nn::hac::NcaHeader::getDistributionType() const
{
return mDistributionType;
}
void nn::hac::NcaHeader::setDistributionType(nca::DistributionType type)
{
mDistributionType = type;
}
nn::hac::nca::ContentType nn::hac::NcaHeader::getContentType() const
{
return mContentType;
}
void nn::hac::NcaHeader::setContentType(nca::ContentType type)
{
mContentType = type;
}
byte_t nn::hac::NcaHeader::getKeyGeneration() const
{
return mKeyGeneration;
}
void nn::hac::NcaHeader::setKeyGeneration(byte_t gen)
{
mKeyGeneration = gen;
}
byte_t nn::hac::NcaHeader::getKaekIndex() const
{
return mKaekIndex;
}
void nn::hac::NcaHeader::setKaekIndex(byte_t index)
{
mKaekIndex = index;
}
uint64_t nn::hac::NcaHeader::getContentSize() const
{
return mContentSize;
}
void nn::hac::NcaHeader::setContentSize(uint64_t size)
{
mContentSize = size;
}
uint64_t nn::hac::NcaHeader::getProgramId() const
{
return mProgramId;
}
void nn::hac::NcaHeader::setProgramId(uint64_t program_id)
{
mProgramId = program_id;
}
uint32_t nn::hac::NcaHeader::getContentIndex() const
{
return mContentIndex;
}
void nn::hac::NcaHeader::setContentIndex(uint32_t index)
{
mContentIndex = index;
}
uint32_t nn::hac::NcaHeader::getSdkAddonVersion() const
{
return mSdkAddonVersion;
}
void nn::hac::NcaHeader::setSdkAddonVersion(uint32_t version)
{
mSdkAddonVersion = version;
}
bool nn::hac::NcaHeader::hasRightsId() const
{
bool rightsIdIsSet = false;
for (size_t i = 0; i < nca::kRightsIdLen; i++)
{
if (mRightsId[i] != 0)
rightsIdIsSet = true;
}
return rightsIdIsSet;
}
const byte_t* nn::hac::NcaHeader::getRightsId() const
{
return mRightsId;
}
void nn::hac::NcaHeader::setRightsId(const byte_t* rights_id)
{
memcpy(mRightsId, rights_id, nca::kRightsIdLen);
}
const fnd::List<nn::hac::NcaHeader::sPartition>& nn::hac::NcaHeader::getPartitions() const
{
return mPartitions;
}
void nn::hac::NcaHeader::setPartitions(const fnd::List<nn::hac::NcaHeader::sPartition>& partitions)
{
mPartitions = partitions;
if (mPartitions.size() >= nca::kPartitionNum)
{
throw fnd::Exception(kModuleName, "Too many NCA partitions");
}
}
const fnd::List<fnd::aes::sAes128Key>& nn::hac::NcaHeader::getEncAesKeys() const
{
return mEncAesKeys;
}
void nn::hac::NcaHeader::setEncAesKeys(const fnd::List<fnd::aes::sAes128Key>& keys)
{
mEncAesKeys = keys;
}
uint64_t nn::hac::NcaHeader::blockNumToSize(uint32_t block_num) const
{
return block_num*nca::kSectorSize;
}
uint32_t nn::hac::NcaHeader::sizeToBlockNum(uint64_t real_size) const
{
return (uint32_t)(align(real_size, nca::kSectorSize) / nca::kSectorSize);
}

View file

@ -1,16 +1,16 @@
#include <nn/hac/PfsHeader.h>
#include <nn/hac/PartitionFsHeader.h>
nn::hac::PfsHeader::PfsHeader()
nn::hac::PartitionFsHeader::PartitionFsHeader()
{
clear();
}
nn::hac::PfsHeader::PfsHeader(const PfsHeader & other)
nn::hac::PartitionFsHeader::PartitionFsHeader(const PartitionFsHeader & other)
{
*this = other;
}
void nn::hac::PfsHeader::operator=(const PfsHeader & other)
void nn::hac::PartitionFsHeader::operator=(const PartitionFsHeader & other)
{
if (other.getBytes().size())
{
@ -24,24 +24,24 @@ void nn::hac::PfsHeader::operator=(const PfsHeader & other)
}
}
bool nn::hac::PfsHeader::operator==(const PfsHeader & other) const
bool nn::hac::PartitionFsHeader::operator==(const PartitionFsHeader & other) const
{
return (mFsType == other.mFsType) \
&& (mFileList == other.mFileList);
}
bool nn::hac::PfsHeader::operator!=(const PfsHeader & other) const
bool nn::hac::PartitionFsHeader::operator!=(const PartitionFsHeader & other) const
{
return !(*this == other);
}
const fnd::Vec<byte_t>& nn::hac::PfsHeader::getBytes() const
const fnd::Vec<byte_t>& nn::hac::PartitionFsHeader::getBytes() const
{
return mRawBinary;
}
void nn::hac::PfsHeader::toBytes()
void nn::hac::PartitionFsHeader::toBytes()
{
// calculate name table size
size_t name_table_size = 0;
@ -113,7 +113,7 @@ void nn::hac::PfsHeader::toBytes()
}
void nn::hac::PfsHeader::fromBytes(const byte_t* data, size_t len)
void nn::hac::PartitionFsHeader::fromBytes(const byte_t* data, size_t len)
{
// check input length meets minimum size
if (len < sizeof(sPfsHeader))
@ -195,39 +195,39 @@ void nn::hac::PfsHeader::fromBytes(const byte_t* data, size_t len)
}
void nn::hac::PfsHeader::clear()
void nn::hac::PartitionFsHeader::clear()
{
mRawBinary.clear();
mFsType = TYPE_PFS0;
mFileList.clear();
}
nn::hac::PfsHeader::FsType nn::hac::PfsHeader::getFsType() const
nn::hac::PartitionFsHeader::FsType nn::hac::PartitionFsHeader::getFsType() const
{
return mFsType;
}
void nn::hac::PfsHeader::setFsType(FsType type)
void nn::hac::PartitionFsHeader::setFsType(FsType type)
{
mFsType = type;
}
const fnd::List<nn::hac::PfsHeader::sFile>& nn::hac::PfsHeader::getFileList() const
const fnd::List<nn::hac::PartitionFsHeader::sFile>& nn::hac::PartitionFsHeader::getFileList() const
{
return mFileList;
}
void nn::hac::PfsHeader::addFile(const std::string & name, size_t size)
void nn::hac::PartitionFsHeader::addFile(const std::string & name, size_t size)
{
mFileList.addElement({ name, 0, size, 0 });
}
void nn::hac::PfsHeader::addFile(const std::string & name, size_t size, size_t hash_protected_size, const fnd::sha::sSha256Hash& hash)
void nn::hac::PartitionFsHeader::addFile(const std::string & name, size_t size, size_t hash_protected_size, const fnd::sha::sSha256Hash& hash)
{
mFileList.addElement({ name, 0, size, hash_protected_size, hash });
}
size_t nn::hac::PfsHeader::getFileEntrySize(FsType fs_type)
size_t nn::hac::PartitionFsHeader::getFileEntrySize(FsType fs_type)
{
size_t size = 0;
switch(fs_type)
@ -244,7 +244,7 @@ size_t nn::hac::PfsHeader::getFileEntrySize(FsType fs_type)
return size;
}
void nn::hac::PfsHeader::calculateOffsets(size_t data_offset)
void nn::hac::PartitionFsHeader::calculateOffsets(size_t data_offset)
{
for (size_t i = 0; i < mFileList.size(); i++)
{

View file

@ -0,0 +1,99 @@
#include <nn/hac/PatchMetaExtendedHeader.h>
nn::hac::PatchMetaExtendedHeader::PatchMetaExtendedHeader()
{
clear();
}
nn::hac::PatchMetaExtendedHeader::PatchMetaExtendedHeader(const PatchMetaExtendedHeader& other)
{
*this = other;
}
void nn::hac::PatchMetaExtendedHeader::operator=(const PatchMetaExtendedHeader& other)
{
clear();
mRawBinary = other.mRawBinary;
mApplicationId = other.mApplicationId;
mRequiredSystemVersion = other.mRequiredSystemVersion;
mExtendedDataSize = other.mExtendedDataSize;
}
bool nn::hac::PatchMetaExtendedHeader::operator==(const PatchMetaExtendedHeader& other) const
{
return (mApplicationId == other.mApplicationId) \
&& (mRequiredSystemVersion == other.mRequiredSystemVersion) \
&& (mExtendedDataSize == other.mExtendedDataSize);
}
bool nn::hac::PatchMetaExtendedHeader::operator!=(const PatchMetaExtendedHeader& other) const
{
return !(*this == other);
}
void nn::hac::PatchMetaExtendedHeader::toBytes()
{
mRawBinary.alloc(sizeof(sPatchMetaExtendedHeader));
sPatchMetaExtendedHeader* info = (sPatchMetaExtendedHeader*)mRawBinary.data();
info->application_id = mApplicationId;
info->required_system_version = mRequiredSystemVersion;
info->extended_data_size = mExtendedDataSize;
}
void nn::hac::PatchMetaExtendedHeader::fromBytes(const byte_t* bytes, size_t len)
{
if (len < sizeof(sPatchMetaExtendedHeader))
{
throw fnd::Exception(kModuleName, "PatchMetaExtendedHeader too small");
}
const sPatchMetaExtendedHeader* info = (const sPatchMetaExtendedHeader*)bytes;
mApplicationId = info->application_id.get();
mRequiredSystemVersion = info->required_system_version.get();
mExtendedDataSize = info->extended_data_size.get();
}
const fnd::Vec<byte_t>& nn::hac::PatchMetaExtendedHeader::getBytes() const
{
return mRawBinary;
}
void nn::hac::PatchMetaExtendedHeader::clear()
{
mRawBinary.clear();
mApplicationId = 0;
mRequiredSystemVersion = 0;
mExtendedDataSize = 0;
}
uint64_t nn::hac::PatchMetaExtendedHeader::getApplicationId() const
{
return mApplicationId;
}
void nn::hac::PatchMetaExtendedHeader::setApplicationId(uint64_t application_id)
{
mApplicationId = application_id;
}
uint32_t nn::hac::PatchMetaExtendedHeader::getRequiredSystemVersion() const
{
return mRequiredSystemVersion;
}
void nn::hac::PatchMetaExtendedHeader::setRequiredSystemVersion(uint32_t sys_ver)
{
mRequiredSystemVersion = sys_ver;
}
uint32_t nn::hac::PatchMetaExtendedHeader::getExtendedDataSize() const
{
return mExtendedDataSize;
}
void nn::hac::PatchMetaExtendedHeader::setExtendedDataSize(uint32_t size)
{
mExtendedDataSize = size;
}

View file

@ -1,79 +1,79 @@
#include <cstring>
#include <nn/hac/ServiceAccessControlBinary.h>
nn::hac::ServiceAccessControlBinary::ServiceAccessControlBinary()
{
clear();
}
nn::hac::ServiceAccessControlBinary::ServiceAccessControlBinary(const ServiceAccessControlBinary & other)
{
*this = other;
}
void nn::hac::ServiceAccessControlBinary::operator=(const ServiceAccessControlBinary & other)
{
mRawBinary = other.mRawBinary;
mServices = other.mServices;
}
bool nn::hac::ServiceAccessControlBinary::operator==(const ServiceAccessControlBinary & other) const
{
return (mServices == other.mServices);
}
bool nn::hac::ServiceAccessControlBinary::operator!=(const ServiceAccessControlBinary & other) const
{
return !(*this == other);
}
void nn::hac::ServiceAccessControlBinary::toBytes()
{
size_t totalSize = 0;
for (size_t i = 0; i < mServices.size(); i++)
{
mServices[i].toBytes();
totalSize += mServices[i].getBytes().size();
}
mRawBinary.alloc(totalSize);
for (size_t i = 0, pos = 0; i < mServices.size(); pos += mServices[i].getBytes().size(), i++)
{
memcpy((mRawBinary.data() + pos), mServices[i].getBytes().data(), mServices[i].getBytes().size());
}
}
void nn::hac::ServiceAccessControlBinary::fromBytes(const byte_t* data, size_t len)
{
clear();
mRawBinary.alloc(len);
memcpy(mRawBinary.data(), data, mRawBinary.size());
ServiceAccessControlEntry sac;
for (size_t pos = 0; pos < len; pos += mServices.atBack().getBytes().size())
{
sac.fromBytes((const byte_t*)(mRawBinary.data() + pos), len - pos);
mServices.addElement(sac);
}
}
const fnd::Vec<byte_t>& nn::hac::ServiceAccessControlBinary::getBytes() const
{
return mRawBinary;
}
void nn::hac::ServiceAccessControlBinary::clear()
{
mRawBinary.clear();
mServices.clear();
}
const fnd::List<nn::hac::ServiceAccessControlEntry>& nn::hac::ServiceAccessControlBinary::getServiceList() const
{
return mServices;
}
void nn::hac::ServiceAccessControlBinary::addService(const ServiceAccessControlEntry& service)
{
mServices.addElement(service);
#include <cstring>
#include <nn/hac/ServiceAccessControl.h>
nn::hac::ServiceAccessControl::ServiceAccessControl()
{
clear();
}
nn::hac::ServiceAccessControl::ServiceAccessControl(const ServiceAccessControl & other)
{
*this = other;
}
void nn::hac::ServiceAccessControl::operator=(const ServiceAccessControl & other)
{
mRawBinary = other.mRawBinary;
mServices = other.mServices;
}
bool nn::hac::ServiceAccessControl::operator==(const ServiceAccessControl & other) const
{
return (mServices == other.mServices);
}
bool nn::hac::ServiceAccessControl::operator!=(const ServiceAccessControl & other) const
{
return !(*this == other);
}
void nn::hac::ServiceAccessControl::toBytes()
{
size_t totalSize = 0;
for (size_t i = 0; i < mServices.size(); i++)
{
mServices[i].toBytes();
totalSize += mServices[i].getBytes().size();
}
mRawBinary.alloc(totalSize);
for (size_t i = 0, pos = 0; i < mServices.size(); pos += mServices[i].getBytes().size(), i++)
{
memcpy((mRawBinary.data() + pos), mServices[i].getBytes().data(), mServices[i].getBytes().size());
}
}
void nn::hac::ServiceAccessControl::fromBytes(const byte_t* data, size_t len)
{
clear();
mRawBinary.alloc(len);
memcpy(mRawBinary.data(), data, mRawBinary.size());
ServiceAccessControlEntry sac;
for (size_t pos = 0; pos < len; pos += mServices.atBack().getBytes().size())
{
sac.fromBytes((const byte_t*)(mRawBinary.data() + pos), len - pos);
mServices.addElement(sac);
}
}
const fnd::Vec<byte_t>& nn::hac::ServiceAccessControl::getBytes() const
{
return mRawBinary;
}
void nn::hac::ServiceAccessControl::clear()
{
mRawBinary.clear();
mServices.clear();
}
const fnd::List<nn::hac::ServiceAccessControlEntry>& nn::hac::ServiceAccessControl::getServiceList() const
{
return mServices;
}
void nn::hac::ServiceAccessControl::setServiceList(const fnd::List<ServiceAccessControlEntry>& list)
{
mServices = list;
}

View file

@ -1,22 +0,0 @@
#include <nn/hac/XciUtils.h>
void nn::hac::XciUtils::getXciHeaderAesIv(const nn::hac::sXciHeader* hdr, byte_t* iv)
{
for (size_t i = 0; i < 16; i++)
{
iv[15-i] = hdr->aescbc_iv.iv[i];
}
}
void nn::hac::XciUtils::decryptXciHeader(const byte_t* src, byte_t* dst, const byte_t* key)
{
byte_t iv[fnd::aes::kAesBlockSize];
getXciHeaderAesIv((const nn::hac::sXciHeader*)src, iv);
// copy plain
memcpy(dst, src, nn::hac::xci::kHeaderEncOffset);
// decrypt encrypted data
fnd::aes::AesCbcDecrypt(src + nn::hac::xci::kHeaderEncOffset, nn::hac::xci::kHeaderEncSize, key, iv, dst + nn::hac::xci::kHeaderEncOffset);
}

View file

@ -1,67 +1,67 @@
#pragma once
#include <string>
#include <fnd/ISerialisable.h>
#include <nn/pki/cert.h>
namespace nn
{
namespace pki
{
class CertificateBody
: public fnd::ISerialisable
{
public:
CertificateBody();
CertificateBody(const CertificateBody& other);
void operator=(const CertificateBody& other);
bool operator==(const CertificateBody& other) const;
bool operator!=(const CertificateBody& other) const;
// export/import binary
void toBytes();
void fromBytes(const byte_t* src, size_t size);
const fnd::Vec<byte_t>& getBytes() const;
// variables
void clear();
const std::string& getIssuer() const;
void setIssuer(const std::string& issuer);
pki::cert::PublicKeyType getPublicKeyType() const;
void setPublicKeyType(cert::PublicKeyType type);
const std::string& getSubject() const;
void setSubject(const std::string& subject);
uint32_t getCertId() const;
void setCertId(uint32_t id);
const fnd::rsa::sRsa4096Key& getRsa4098PublicKey() const;
void setRsa4098PublicKey(const fnd::rsa::sRsa4096Key& key);
const fnd::rsa::sRsa2048Key& getRsa2048PublicKey() const;
void setRsa2048PublicKey(const fnd::rsa::sRsa2048Key& key);
const fnd::ecdsa::sEcdsa240Point& getEcdsa240PublicKey() const;
void setEcdsa240PublicKey(const fnd::ecdsa::sEcdsa240Point& key);
private:
const std::string kModuleName = "CERTIFICATE_BODY";
// raw binary
fnd::Vec<byte_t> mRawBinary;
// variables
std::string mIssuer;
std::string mSubject;
uint32_t mCertId;
cert::PublicKeyType mPublicKeyType;
fnd::rsa::sRsa4096Key mRsa4096PublicKey;
fnd::rsa::sRsa2048Key mRsa2048PublicKey;
fnd::ecdsa::sEcdsa240Point mEcdsa240PublicKey;
};
}
#pragma once
#include <string>
#include <fnd/IByteModel.h>
#include <nn/pki/cert.h>
namespace nn
{
namespace pki
{
class CertificateBody
: public fnd::IByteModel
{
public:
CertificateBody();
CertificateBody(const CertificateBody& other);
void operator=(const CertificateBody& other);
bool operator==(const CertificateBody& other) const;
bool operator!=(const CertificateBody& other) const;
// IByteModel
void toBytes();
void fromBytes(const byte_t* src, size_t size);
const fnd::Vec<byte_t>& getBytes() const;
// variables
void clear();
const std::string& getIssuer() const;
void setIssuer(const std::string& issuer);
pki::cert::PublicKeyType getPublicKeyType() const;
void setPublicKeyType(cert::PublicKeyType type);
const std::string& getSubject() const;
void setSubject(const std::string& subject);
uint32_t getCertId() const;
void setCertId(uint32_t id);
const fnd::rsa::sRsa4096Key& getRsa4098PublicKey() const;
void setRsa4098PublicKey(const fnd::rsa::sRsa4096Key& key);
const fnd::rsa::sRsa2048Key& getRsa2048PublicKey() const;
void setRsa2048PublicKey(const fnd::rsa::sRsa2048Key& key);
const fnd::ecdsa::sEcdsa240Point& getEcdsa240PublicKey() const;
void setEcdsa240PublicKey(const fnd::ecdsa::sEcdsa240Point& key);
private:
const std::string kModuleName = "CERTIFICATE_BODY";
// raw binary
fnd::Vec<byte_t> mRawBinary;
// variables
std::string mIssuer;
std::string mSubject;
uint32_t mCertId;
cert::PublicKeyType mPublicKeyType;
fnd::rsa::sRsa4096Key mRsa4096PublicKey;
fnd::rsa::sRsa2048Key mRsa2048PublicKey;
fnd::ecdsa::sEcdsa240Point mEcdsa240PublicKey;
};
}
}

View file

@ -1,51 +1,51 @@
#pragma once
#include <string>
#include <fnd/ISerialisable.h>
#include <nn/pki/sign.h>
namespace nn
{
namespace pki
{
class SignatureBlock
: public fnd::ISerialisable
{
public:
SignatureBlock();
SignatureBlock(const SignatureBlock& other);
void operator=(const SignatureBlock& other);
bool operator==(const SignatureBlock& other) const;
bool operator!=(const SignatureBlock& other) const;
// export/import binary
void toBytes();
void fromBytes(const byte_t* src, size_t size);
const fnd::Vec<byte_t>& getBytes() const;
// variables
void clear();
pki::sign::SignatureId getSignType() const;
void setSignType(pki::sign::SignatureId type);
bool isLittleEndian() const;
void setLittleEndian(bool isLE);
const fnd::Vec<byte_t>& getSignature() const;
void setSignature(const fnd::Vec<byte_t>& signature);
private:
const std::string kModuleName = "SIGNATURE_BLOCK";
// raw binary
fnd::Vec<byte_t> mRawBinary;
// variables
pki::sign::SignatureId mSignType;
bool mIsLittleEndian;
fnd::Vec<byte_t> mSignature;
};
}
#pragma once
#include <string>
#include <fnd/IByteModel.h>
#include <nn/pki/sign.h>
namespace nn
{
namespace pki
{
class SignatureBlock
: public fnd::IByteModel
{
public:
SignatureBlock();
SignatureBlock(const SignatureBlock& other);
void operator=(const SignatureBlock& other);
bool operator==(const SignatureBlock& other) const;
bool operator!=(const SignatureBlock& other) const;
// IByteModel
void toBytes();
void fromBytes(const byte_t* src, size_t size);
const fnd::Vec<byte_t>& getBytes() const;
// variables
void clear();
pki::sign::SignatureId getSignType() const;
void setSignType(pki::sign::SignatureId type);
bool isLittleEndian() const;
void setLittleEndian(bool isLE);
const fnd::Vec<byte_t>& getSignature() const;
void setSignature(const fnd::Vec<byte_t>& signature);
private:
const std::string kModuleName = "SIGNATURE_BLOCK";
// raw binary
fnd::Vec<byte_t> mRawBinary;
// variables
pki::sign::SignatureId mSignType;
bool mIsLittleEndian;
fnd::Vec<byte_t> mSignature;
};
}
}

View file

@ -1,139 +1,139 @@
#pragma once
#include <string>
#include <fnd/ISerialisable.h>
#include <nn/pki/SignatureBlock.h>
namespace nn
{
namespace pki
{
template <class T>
class SignedData
: public fnd::ISerialisable
{
public:
SignedData();
SignedData(const SignedData& other);
void operator=(const SignedData& other);
bool operator==(const SignedData& other) const;
bool operator!=(const SignedData& other) const;
// export/import
void toBytes();
void fromBytes(const byte_t* src, size_t size);
const fnd::Vec<byte_t>& getBytes() const;
// variables
void clear();
const pki::SignatureBlock& getSignature() const;
void setSignature(const SignatureBlock& signature);
const T& getBody() const;
void setBody(const T& body);
private:
const std::string kModuleName = "SIGNED_DATA";
// raw binary
fnd::Vec<byte_t> mRawBinary;
// variables
SignatureBlock mSignature;
T mBody;
};
template <class T>
inline SignedData<T>::SignedData()
{
clear();
}
template <class T>
inline SignedData<T>::SignedData(const SignedData& other)
{
*this = other;
}
template <class T>
inline void SignedData<T>::operator=(const SignedData& other)
{
mRawBinary = other.mRawBinary;
mSignature = other.mSignature;
mBody = other.mBody;
}
template <class T>
inline bool SignedData<T>::operator==(const SignedData& other) const
{
return (mSignature == other.mSignature) \
&& (mBody == other.mBody);
}
template <class T>
inline bool SignedData<T>::operator!=(const SignedData& other) const
{
return !(*this == other);
}
template <class T>
inline void SignedData<T>::toBytes()
{
mSignature.toBytes();
mBody.toBytes();
mRawBinary.alloc(mSignature.getBytes().size() + mBody.getBytes().size());
memcpy(mRawBinary.data(), mSignature.getBytes().data(), mSignature.getBytes().size());
memcpy(mRawBinary.data() + mSignature.getBytes().size(), mBody.getBytes().data(), mBody.getBytes().size());
}
template <class T>
inline void SignedData<T>::fromBytes(const byte_t* src, size_t size)
{
mSignature.fromBytes(src, size);
mBody.fromBytes(src + mSignature.getBytes().size(), size - mSignature.getBytes().size());
mRawBinary.alloc(mSignature.getBytes().size() + mBody.getBytes().size());
memcpy(mRawBinary.data(), src, mRawBinary.size());
}
template <class T>
inline const fnd::Vec<byte_t>& SignedData<T>::getBytes() const
{
return mRawBinary;
}
template <class T>
inline void SignedData<T>::clear()
{
mRawBinary.clear();
mSignature.clear();
mBody.clear();
}
template <class T>
inline const pki::SignatureBlock& SignedData<T>::getSignature() const
{
return mSignature;
}
template <class T>
inline void SignedData<T>::setSignature(const SignatureBlock& signature)
{
mSignature = signature;
}
template <class T>
inline const T& SignedData<T>::getBody() const
{
return mBody;
}
template <class T>
inline void SignedData<T>::setBody(const T& body)
{
mBody = body;
}
}
#pragma once
#include <string>
#include <fnd/IByteModel.h>
#include <nn/pki/SignatureBlock.h>
namespace nn
{
namespace pki
{
template <class T>
class SignedData
: public fnd::IByteModel
{
public:
SignedData();
SignedData(const SignedData& other);
void operator=(const SignedData& other);
bool operator==(const SignedData& other) const;
bool operator!=(const SignedData& other) const;
// export/import
void toBytes();
void fromBytes(const byte_t* src, size_t size);
const fnd::Vec<byte_t>& getBytes() const;
// variables
void clear();
const pki::SignatureBlock& getSignature() const;
void setSignature(const SignatureBlock& signature);
const T& getBody() const;
void setBody(const T& body);
private:
const std::string kModuleName = "SIGNED_DATA";
// raw binary
fnd::Vec<byte_t> mRawBinary;
// variables
SignatureBlock mSignature;
T mBody;
};
template <class T>
inline SignedData<T>::SignedData()
{
clear();
}
template <class T>
inline SignedData<T>::SignedData(const SignedData& other)
{
*this = other;
}
template <class T>
inline void SignedData<T>::operator=(const SignedData& other)
{
mRawBinary = other.mRawBinary;
mSignature = other.mSignature;
mBody = other.mBody;
}
template <class T>
inline bool SignedData<T>::operator==(const SignedData& other) const
{
return (mSignature == other.mSignature) \
&& (mBody == other.mBody);
}
template <class T>
inline bool SignedData<T>::operator!=(const SignedData& other) const
{
return !(*this == other);
}
template <class T>
inline void SignedData<T>::toBytes()
{
mSignature.toBytes();
mBody.toBytes();
mRawBinary.alloc(mSignature.getBytes().size() + mBody.getBytes().size());
memcpy(mRawBinary.data(), mSignature.getBytes().data(), mSignature.getBytes().size());
memcpy(mRawBinary.data() + mSignature.getBytes().size(), mBody.getBytes().data(), mBody.getBytes().size());
}
template <class T>
inline void SignedData<T>::fromBytes(const byte_t* src, size_t size)
{
mSignature.fromBytes(src, size);
mBody.fromBytes(src + mSignature.getBytes().size(), size - mSignature.getBytes().size());
mRawBinary.alloc(mSignature.getBytes().size() + mBody.getBytes().size());
memcpy(mRawBinary.data(), src, mRawBinary.size());
}
template <class T>
inline const fnd::Vec<byte_t>& SignedData<T>::getBytes() const
{
return mRawBinary;
}
template <class T>
inline void SignedData<T>::clear()
{
mRawBinary.clear();
mSignature.clear();
mBody.clear();
}
template <class T>
inline const pki::SignatureBlock& SignedData<T>::getSignature() const
{
return mSignature;
}
template <class T>
inline void SignedData<T>::setSignature(const SignatureBlock& signature)
{
mSignature = signature;
}
template <class T>
inline const T& SignedData<T>::getBody() const
{
return mBody;
}
template <class T>
inline void SignedData<T>::setBody(const T& body)
{
mBody = body;
}
}
}

View file

@ -1,74 +1,74 @@
# Nintendo Switch Tool (NSTool) ![DeviceTag](https://img.shields.io/badge/Device-SWITCH-e60012.svg)
General purpose reading/extraction tool for Nintendo Switch file formats.
## 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)
* Nintendo Application Control Property (.nacp)
* ES Ticket (v2 only) (.tik)
* PKI Certificate (.cert)
# Usage
```
Usage: nstool [options... ] <file>
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, nacp, aset, cert, tik]
-y, --verify Verify file.
Output Options:
--showkeys Show keys generated.
--showlayout Show layout metadata.
-v, --verbose Verbose output.
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.
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).
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.
# Nintendo Switch Tool (NSTool) ![DeviceTag](https://img.shields.io/badge/Device-SWITCH-e60012.svg)
General purpose reading/extraction tool for Nintendo Switch file formats.
## 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)
* Nintendo Application Control Property (.nacp)
* ES Ticket (v2 only) (.tik)
* PKI Certificate (.cert)
# Usage
```
Usage: nstool [options... ] <file>
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, nacp, aset, cert, tik]
-y, --verify Verify file.
Output Options:
--showkeys Show keys generated.
--showlayout Show layout metadata.
-v, --verbose Verbose output.
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.
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).
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.

View file

@ -1,226 +1,226 @@
<?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>{AF09FA96-4463-417D-8FE6-526063F41349}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>nstool</RootNamespace>
<WindowsTargetPlatformVersion>10.0.16299.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>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</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 Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ProjectReference Include="..\..\lib\libpolarssl\libpolarssl.vcxproj">
<Project>{394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1}</Project>
</ProjectReference>
<ProjectReference Include="..\..\lib\liblz4\liblz4.vcxproj">
<Project>{AB0C3362-63AB-480A-ADBC-2EF7D859778B}</Project>
</ProjectReference>
<ProjectReference Include="..\..\lib\libes\libes.vcxproj">
<Project>{7be99936-0d40-410d-944b-4513c2eff8dc}</Project>
</ProjectReference>
<ProjectReference Include="..\..\lib\libfnd\libfnd.vcxproj">
<Project>{4d27edb9-5110-44fe-8ce2-d46c5ad3c55b}</Project>
</ProjectReference>
<ProjectReference Include="..\..\lib\libhac-hb\libhac-hb.vcxproj">
<Project>{738cb4fc-cd9e-4b81-a04b-deadbfa71c63}</Project>
</ProjectReference>
<ProjectReference Include="..\..\lib\libhac\libhac.vcxproj">
<Project>{91ba9e79-8242-4f7d-b997-0dfec95ea22b}</Project>
</ProjectReference>
<ProjectReference Include="..\..\lib\libpki\libpki.vcxproj">
<Project>{b9113734-6e84-44ff-8cf7-58199aa815c5}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="makefile" />
<None Include="README.md" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="source\AssetProcess.h" />
<ClInclude Include="source\CnmtProcess.h" />
<ClInclude Include="source\common.h" />
<ClInclude Include="source\ElfSymbolParser.h" />
<ClInclude Include="source\EsTikProcess.h" />
<ClInclude Include="source\KeyConfiguration.h" />
<ClInclude Include="source\MetaProcess.h" />
<ClInclude Include="source\NacpProcess.h" />
<ClInclude Include="source\NcaProcess.h" />
<ClInclude Include="source\NroProcess.h" />
<ClInclude Include="source\NsoProcess.h" />
<ClInclude Include="source\PfsProcess.h" />
<ClInclude Include="source\PkiCertProcess.h" />
<ClInclude Include="source\PkiValidator.h" />
<ClInclude Include="source\RoMetadataProcess.h" />
<ClInclude Include="source\RomfsProcess.h" />
<ClInclude Include="source\SdkApiString.h" />
<ClInclude Include="source\UserSettings.h" />
<ClInclude Include="source\version.h" />
<ClInclude Include="source\XciProcess.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="source\AssetProcess.cpp" />
<ClCompile Include="source\CnmtProcess.cpp" />
<ClCompile Include="source\ElfSymbolParser.cpp" />
<ClCompile Include="source\EsTikProcess.cpp" />
<ClCompile Include="source\KeyConfiguration.cpp" />
<ClCompile Include="source\main.cpp" />
<ClCompile Include="source\MetaProcess.cpp" />
<ClCompile Include="source\NacpProcess.cpp" />
<ClCompile Include="source\NcaProcess.cpp" />
<ClCompile Include="source\NroProcess.cpp" />
<ClCompile Include="source\NsoProcess.cpp" />
<ClCompile Include="source\PfsProcess.cpp" />
<ClCompile Include="source\PkiCertProcess.cpp" />
<ClCompile Include="source\PkiValidator.cpp" />
<ClCompile Include="source\RoMetadataProcess.cpp" />
<ClCompile Include="source\RomfsProcess.cpp" />
<ClCompile Include="source\SdkApiString.cpp" />
<ClCompile Include="source\UserSettings.cpp" />
<ClCompile Include="source\XciProcess.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<?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>{AF09FA96-4463-417D-8FE6-526063F41349}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>nstool</RootNamespace>
<WindowsTargetPlatformVersion>10.0.16299.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>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</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 Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ProjectReference Include="..\..\lib\libpolarssl\libpolarssl.vcxproj">
<Project>{394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1}</Project>
</ProjectReference>
<ProjectReference Include="..\..\lib\liblz4\liblz4.vcxproj">
<Project>{AB0C3362-63AB-480A-ADBC-2EF7D859778B}</Project>
</ProjectReference>
<ProjectReference Include="..\..\lib\libes\libes.vcxproj">
<Project>{7be99936-0d40-410d-944b-4513c2eff8dc}</Project>
</ProjectReference>
<ProjectReference Include="..\..\lib\libfnd\libfnd.vcxproj">
<Project>{4d27edb9-5110-44fe-8ce2-d46c5ad3c55b}</Project>
</ProjectReference>
<ProjectReference Include="..\..\lib\libhac-hb\libhac-hb.vcxproj">
<Project>{738cb4fc-cd9e-4b81-a04b-deadbfa71c63}</Project>
</ProjectReference>
<ProjectReference Include="..\..\lib\libhac\libhac.vcxproj">
<Project>{91ba9e79-8242-4f7d-b997-0dfec95ea22b}</Project>
</ProjectReference>
<ProjectReference Include="..\..\lib\libpki\libpki.vcxproj">
<Project>{b9113734-6e84-44ff-8cf7-58199aa815c5}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="makefile" />
<None Include="README.md" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="source\AssetProcess.h" />
<ClInclude Include="source\CnmtProcess.h" />
<ClInclude Include="source\common.h" />
<ClInclude Include="source\ElfSymbolParser.h" />
<ClInclude Include="source\EsTikProcess.h" />
<ClInclude Include="source\KeyConfiguration.h" />
<ClInclude Include="source\MetaProcess.h" />
<ClInclude Include="source\NacpProcess.h" />
<ClInclude Include="source\NcaProcess.h" />
<ClInclude Include="source\NroProcess.h" />
<ClInclude Include="source\NsoProcess.h" />
<ClInclude Include="source\PfsProcess.h" />
<ClInclude Include="source\PkiCertProcess.h" />
<ClInclude Include="source\PkiValidator.h" />
<ClInclude Include="source\RoMetadataProcess.h" />
<ClInclude Include="source\RomfsProcess.h" />
<ClInclude Include="source\SdkApiString.h" />
<ClInclude Include="source\UserSettings.h" />
<ClInclude Include="source\version.h" />
<ClInclude Include="source\GameCardProcess.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="source\AssetProcess.cpp" />
<ClCompile Include="source\CnmtProcess.cpp" />
<ClCompile Include="source\ElfSymbolParser.cpp" />
<ClCompile Include="source\EsTikProcess.cpp" />
<ClCompile Include="source\KeyConfiguration.cpp" />
<ClCompile Include="source\main.cpp" />
<ClCompile Include="source\MetaProcess.cpp" />
<ClCompile Include="source\NacpProcess.cpp" />
<ClCompile Include="source\NcaProcess.cpp" />
<ClCompile Include="source\NroProcess.cpp" />
<ClCompile Include="source\NsoProcess.cpp" />
<ClCompile Include="source\PfsProcess.cpp" />
<ClCompile Include="source\PkiCertProcess.cpp" />
<ClCompile Include="source\PkiValidator.cpp" />
<ClCompile Include="source\RoMetadataProcess.cpp" />
<ClCompile Include="source\RomfsProcess.cpp" />
<ClCompile Include="source\SdkApiString.cpp" />
<ClCompile Include="source\UserSettings.cpp" />
<ClCompile Include="source\GameCardProcess.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -1,142 +1,142 @@
<?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\KeyConfiguration.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>
<ClInclude Include="source\XciProcess.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\KeyConfiguration.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>
<ClCompile Include="source\XciProcess.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>
<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\KeyConfiguration.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>
<ClInclude Include="source\GameCardProcess.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\KeyConfiguration.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>
<ClCompile Include="source\GameCardProcess.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View file

@ -1,249 +1,249 @@
#include <iostream>
#include <iomanip>
#include <fnd/SimpleTextOutput.h>
#include <fnd/OffsetAdjustedIFile.h>
#include "CnmtProcess.h"
CnmtProcess::CnmtProcess() :
mFile(),
mCliOutputMode(_BIT(OUTPUT_BASIC)),
mVerify(false)
{
}
void CnmtProcess::process()
{
importCnmt();
if (_HAS_BIT(mCliOutputMode, OUTPUT_BASIC))
displayCnmt();
}
void CnmtProcess::setInputFile(const fnd::SharedPtr<fnd::IFile>& file)
{
mFile = file;
}
void CnmtProcess::setCliOutputMode(CliOutputMode type)
{
mCliOutputMode = type;
}
void CnmtProcess::setVerifyMode(bool verify)
{
mVerify = verify;
}
const nn::hac::ContentMetaBinary& CnmtProcess::getContentMetaBinary() const
{
return mCnmt;
}
void CnmtProcess::importCnmt()
{
fnd::Vec<byte_t> scratch;
if (*mFile == nullptr)
{
throw fnd::Exception(kModuleName, "No file reader set.");
}
scratch.alloc((*mFile)->size());
(*mFile)->read(scratch.data(), 0, scratch.size());
mCnmt.fromBytes(scratch.data(), scratch.size());
}
void CnmtProcess::displayCnmt()
{
#define _SPLIT_VER(ver) (uint32_t)((ver>>26) & 0x3f) << "." << (uint32_t)((ver>>20) & 0x3f) << "." << (uint32_t)((ver>>16) & 0xf) << "." << (uint32_t)(ver & 0xffff)
std::cout << "[ContentMeta]" << std::endl;
std::cout << " TitleId: 0x" << std::hex << std::setw(16) << std::setfill('0') << mCnmt.getTitleId() << std::endl;
std::cout << " Version: v" << std::dec << mCnmt.getTitleVersion() << " (" << _SPLIT_VER(mCnmt.getTitleVersion()) << ")"<< std::endl;
std::cout << " Type: " << getContentMetaTypeStr(mCnmt.getType()) << " (" << std::dec << mCnmt.getType() << ")" << std::endl;
std::cout << " Attributes: 0x" << std::hex << (uint32_t)mCnmt.getAttributes() << std::endl;
std::cout << " IncludesExFatDriver: " << getBoolStr(_HAS_BIT(mCnmt.getAttributes(), nn::hac::cnmt::ATTRIBUTE_INCLUDES_EX_FAT_DRIVER)) << std::endl;
std::cout << " Rebootless: " << getBoolStr(_HAS_BIT(mCnmt.getAttributes(), nn::hac::cnmt::ATTRIBUTE_REBOOTLESS)) << std::endl;
std::cout << " RequiredDownloadSystemVersion: v" << mCnmt.getRequiredDownloadSystemVersion() << " (" << _SPLIT_VER(mCnmt.getRequiredDownloadSystemVersion()) << ")"<< std::endl;
switch(mCnmt.getType())
{
case (nn::hac::cnmt::METATYPE_APPLICATION):
std::cout << " ApplicationExtendedHeader:" << std::endl;
std::cout << " RequiredSystemVersion: v" << std::dec << mCnmt.getApplicationMetaExtendedHeader().required_system_version << " (" << _SPLIT_VER(mCnmt.getApplicationMetaExtendedHeader().required_system_version) << ")"<< std::endl;
std::cout << " PatchId: 0x" << std::hex << std::setw(16) << std::setfill('0') << mCnmt.getApplicationMetaExtendedHeader().patch_id << std::endl;
break;
case (nn::hac::cnmt::METATYPE_PATCH):
std::cout << " PatchMetaExtendedHeader:" << std::endl;
std::cout << " RequiredSystemVersion: v" << std::dec << mCnmt.getPatchMetaExtendedHeader().required_system_version << " (" << _SPLIT_VER(mCnmt.getPatchMetaExtendedHeader().required_system_version) << ")"<< std::endl;
std::cout << " ApplicationId: 0x" << std::hex << std::setw(16) << std::setfill('0') << mCnmt.getPatchMetaExtendedHeader().application_id << std::endl;
break;
case (nn::hac::cnmt::METATYPE_ADD_ON_CONTENT):
std::cout << " AddOnContentMetaExtendedHeader:" << std::endl;
std::cout << " RequiredApplicationVersion: v" << std::dec << mCnmt.getAddOnContentMetaExtendedHeader().required_application_version << " (" << _SPLIT_VER(mCnmt.getAddOnContentMetaExtendedHeader().required_application_version) << ")" << std::endl;
std::cout << " ApplicationId: 0x" << std::hex << std::setw(16) << std::setfill('0') << mCnmt.getAddOnContentMetaExtendedHeader().application_id << std::endl;
break;
case (nn::hac::cnmt::METATYPE_DELTA):
std::cout << " DeltaMetaExtendedHeader:" << std::endl;
std::cout << " ApplicationId: 0x" << std::hex << std::setw(16) << std::setfill('0') << mCnmt.getDeltaMetaExtendedHeader().application_id << std::endl;
break;
default:
break;
}
if (mCnmt.getContentInfo().size() > 0)
{
printf(" ContentInfo:\n");
for (size_t i = 0; i < mCnmt.getContentInfo().size(); i++)
{
const nn::hac::ContentMetaBinary::ContentInfo& info = mCnmt.getContentInfo()[i];
std::cout << " " << std::dec << i << std::endl;
std::cout << " Type: " << getContentTypeStr(info.type) << " (" << std::dec << info.type << ")" << std::endl;
std::cout << " Id: " << fnd::SimpleTextOutput::arrayToString(info.nca_id, nn::hac::cnmt::kContentIdLen, false, "") << std::endl;
std::cout << " Size: 0x" << std::hex << info.size << std::endl;
std::cout << " Hash: " << fnd::SimpleTextOutput::arrayToString(info.hash.bytes, sizeof(info.hash), false, "") << std::endl;
}
}
if (mCnmt.getContentMetaInfo().size() > 0)
{
std::cout << " ContentMetaInfo:" << std::endl;
for (size_t i = 0; i < mCnmt.getContentMetaInfo().size(); i++)
{
const nn::hac::ContentMetaBinary::ContentMetaInfo& info = mCnmt.getContentMetaInfo()[i];
std::cout << " " << std::dec << i << std::endl;
std::cout << " Id: 0x" << std::hex << std::setw(16) << std::setfill('0') << info.id << std::endl;
std::cout << " Version: v" << std::dec << info.version << " (" << _SPLIT_VER(info.version) << ")"<< std::endl;
std::cout << " Type: " << getContentMetaTypeStr(info.type) << " (" << std::dec << info.type << ")" << std::endl;
std::cout << " Attributes: 0x" << std::hex << (uint32_t)info.attributes << std::endl;
std::cout << " IncludesExFatDriver: " << getBoolStr(_HAS_BIT(info.attributes, nn::hac::cnmt::ATTRIBUTE_INCLUDES_EX_FAT_DRIVER)) << std::endl;
std::cout << " Rebootless: " << getBoolStr(_HAS_BIT(info.attributes, nn::hac::cnmt::ATTRIBUTE_REBOOTLESS)) << std::endl;
}
}
std::cout << " Digest: " << fnd::SimpleTextOutput::arrayToString(mCnmt.getDigest().data, nn::hac::cnmt::kDigestLen, false, "") << std::endl;
#undef _SPLIT_VER
}
const char* CnmtProcess::getBoolStr(bool state) const
{
return state? "TRUE" : "FALSE";
}
const char* CnmtProcess::getContentTypeStr(nn::hac::cnmt::ContentType type) const
{
const char* str = nullptr;
switch (type)
{
case (nn::hac::cnmt::TYPE_META):
str = "Meta";
break;
case (nn::hac::cnmt::TYPE_PROGRAM):
str = "Program";
break;
case (nn::hac::cnmt::TYPE_DATA):
str = "Data";
break;
case (nn::hac::cnmt::TYPE_CONTROL):
str = "Control";
break;
case (nn::hac::cnmt::TYPE_HTML_DOCUMENT):
str = "HtmlDocument";
break;
case (nn::hac::cnmt::TYPE_LEGAL_INFORMATION):
str = "LegalInformation";
break;
case (nn::hac::cnmt::TYPE_DELTA_FRAGMENT):
str = "DeltaFragment";
break;
default:
str = "Unknown";
break;
}
return str;
}
const char* CnmtProcess::getContentMetaTypeStr(nn::hac::cnmt::ContentMetaType type) const
{
const char* str = nullptr;
switch (type)
{
case (nn::hac::cnmt::METATYPE_SYSTEM_PROGRAM):
str = "SystemProgram";
break;
case (nn::hac::cnmt::METATYPE_SYSTEM_DATA):
str = "SystemData";
break;
case (nn::hac::cnmt::METATYPE_SYSTEM_UPDATE):
str = "SystemUpdate";
break;
case (nn::hac::cnmt::METATYPE_BOOT_IMAGE_PACKAGE):
str = "BootImagePackage";
break;
case (nn::hac::cnmt::METATYPE_BOOT_IMAGE_PACKAGE_SAFE):
str = "BootImagePackageSafe";
break;
case (nn::hac::cnmt::METATYPE_APPLICATION):
str = "Application";
break;
case (nn::hac::cnmt::METATYPE_PATCH):
str = "Patch";
break;
case (nn::hac::cnmt::METATYPE_ADD_ON_CONTENT):
str = "AddOnContent";
break;
case (nn::hac::cnmt::METATYPE_DELTA):
str = "Delta";
break;
default:
str = "Unknown";
break;
}
return str;
}
const char* CnmtProcess::getUpdateTypeStr(nn::hac::cnmt::UpdateType type) const
{
const char* str = nullptr;
switch (type)
{
case (nn::hac::cnmt::UPDATETYPE_APPLY_AS_DELTA):
str = "ApplyAsDelta";
break;
case (nn::hac::cnmt::UPDATETYPE_OVERWRITE):
str = "Overwrite";
break;
case (nn::hac::cnmt::UPDATETYPE_CREATE):
str = "Create";
break;
default:
str = "Unknown";
break;
}
return str;
}
const char* CnmtProcess::getContentMetaAttrStr(nn::hac::cnmt::ContentMetaAttribute attr) const
{
const char* str = nullptr;
switch (attr)
{
case (nn::hac::cnmt::ATTRIBUTE_INCLUDES_EX_FAT_DRIVER):
str = "IncludesExFatDriver";
break;
case (nn::hac::cnmt::ATTRIBUTE_REBOOTLESS):
str = "Rebootless";
break;
default:
str = "Unknown";
break;
}
return str;
}
#include <iostream>
#include <iomanip>
#include <fnd/SimpleTextOutput.h>
#include <fnd/OffsetAdjustedIFile.h>
#include "CnmtProcess.h"
CnmtProcess::CnmtProcess() :
mFile(),
mCliOutputMode(_BIT(OUTPUT_BASIC)),
mVerify(false)
{
}
void CnmtProcess::process()
{
importCnmt();
if (_HAS_BIT(mCliOutputMode, OUTPUT_BASIC))
displayCnmt();
}
void CnmtProcess::setInputFile(const fnd::SharedPtr<fnd::IFile>& file)
{
mFile = file;
}
void CnmtProcess::setCliOutputMode(CliOutputMode type)
{
mCliOutputMode = type;
}
void CnmtProcess::setVerifyMode(bool verify)
{
mVerify = verify;
}
const nn::hac::ContentMeta& CnmtProcess::getContentMeta() const
{
return mCnmt;
}
void CnmtProcess::importCnmt()
{
fnd::Vec<byte_t> scratch;
if (*mFile == nullptr)
{
throw fnd::Exception(kModuleName, "No file reader set.");
}
scratch.alloc((*mFile)->size());
(*mFile)->read(scratch.data(), 0, scratch.size());
mCnmt.fromBytes(scratch.data(), scratch.size());
}
void CnmtProcess::displayCnmt()
{
#define _SPLIT_VER(ver) (uint32_t)((ver>>26) & 0x3f) << "." << (uint32_t)((ver>>20) & 0x3f) << "." << (uint32_t)((ver>>16) & 0xf) << "." << (uint32_t)(ver & 0xffff)
std::cout << "[ContentMeta]" << std::endl;
std::cout << " TitleId: 0x" << std::hex << std::setw(16) << std::setfill('0') << mCnmt.getTitleId() << std::endl;
std::cout << " Version: v" << std::dec << mCnmt.getTitleVersion() << " (" << _SPLIT_VER(mCnmt.getTitleVersion()) << ")"<< std::endl;
std::cout << " Type: " << getContentMetaTypeStr(mCnmt.getContentMetaType()) << " (" << std::dec << mCnmt.getContentMetaType() << ")" << std::endl;
std::cout << " Attributes: 0x" << std::hex << (uint32_t)mCnmt.getAttributes() << std::endl;
std::cout << " IncludesExFatDriver: " << getBoolStr(_HAS_BIT(mCnmt.getAttributes(), nn::hac::cnmt::ATTRIBUTE_INCLUDES_EX_FAT_DRIVER)) << std::endl;
std::cout << " Rebootless: " << getBoolStr(_HAS_BIT(mCnmt.getAttributes(), nn::hac::cnmt::ATTRIBUTE_REBOOTLESS)) << std::endl;
std::cout << " RequiredDownloadSystemVersion: v" << mCnmt.getRequiredDownloadSystemVersion() << " (" << _SPLIT_VER(mCnmt.getRequiredDownloadSystemVersion()) << ")"<< std::endl;
switch(mCnmt.getContentMetaType())
{
case (nn::hac::cnmt::METATYPE_APPLICATION):
std::cout << " ApplicationExtendedHeader:" << std::endl;
std::cout << " RequiredSystemVersion: v" << std::dec << mCnmt.getApplicationMetaExtendedHeader().getRequiredSystemVersion() << " (" << _SPLIT_VER(mCnmt.getApplicationMetaExtendedHeader().getRequiredSystemVersion()) << ")"<< std::endl;
std::cout << " PatchId: 0x" << std::hex << std::setw(16) << std::setfill('0') << mCnmt.getApplicationMetaExtendedHeader().getPatchId() << std::endl;
break;
case (nn::hac::cnmt::METATYPE_PATCH):
std::cout << " PatchMetaExtendedHeader:" << std::endl;
std::cout << " RequiredSystemVersion: v" << std::dec << mCnmt.getPatchMetaExtendedHeader().getRequiredSystemVersion() << " (" << _SPLIT_VER(mCnmt.getPatchMetaExtendedHeader().getRequiredSystemVersion()) << ")"<< std::endl;
std::cout << " ApplicationId: 0x" << std::hex << std::setw(16) << std::setfill('0') << mCnmt.getPatchMetaExtendedHeader().getApplicationId() << std::endl;
break;
case (nn::hac::cnmt::METATYPE_ADD_ON_CONTENT):
std::cout << " AddOnContentMetaExtendedHeader:" << std::endl;
std::cout << " RequiredApplicationVersion: v" << std::dec << mCnmt.getAddOnContentMetaExtendedHeader().getRequiredApplicationVersion() << " (" << _SPLIT_VER(mCnmt.getAddOnContentMetaExtendedHeader().getRequiredApplicationVersion()) << ")" << std::endl;
std::cout << " ApplicationId: 0x" << std::hex << std::setw(16) << std::setfill('0') << mCnmt.getAddOnContentMetaExtendedHeader().getApplicationId() << std::endl;
break;
case (nn::hac::cnmt::METATYPE_DELTA):
std::cout << " DeltaMetaExtendedHeader:" << std::endl;
std::cout << " ApplicationId: 0x" << std::hex << std::setw(16) << std::setfill('0') << mCnmt.getDeltaMetaExtendedHeader().getApplicationId() << std::endl;
break;
default:
break;
}
if (mCnmt.getContentInfo().size() > 0)
{
printf(" ContentInfo:\n");
for (size_t i = 0; i < mCnmt.getContentInfo().size(); i++)
{
const nn::hac::ContentInfo& info = mCnmt.getContentInfo()[i];
std::cout << " " << std::dec << i << std::endl;
std::cout << " Type: " << getContentTypeStr(info.getContentType()) << " (" << std::dec << info.getContentType() << ")" << std::endl;
std::cout << " Id: " << fnd::SimpleTextOutput::arrayToString(info.getContentId().data, nn::hac::cnmt::kContentIdLen, false, "") << std::endl;
std::cout << " Size: 0x" << std::hex << info.getContentSize() << std::endl;
std::cout << " Hash: " << fnd::SimpleTextOutput::arrayToString(info.getContentHash().bytes, sizeof(info.getContentHash()), false, "") << std::endl;
}
}
if (mCnmt.getContentMetaInfo().size() > 0)
{
std::cout << " ContentMetaInfo:" << std::endl;
for (size_t i = 0; i < mCnmt.getContentMetaInfo().size(); i++)
{
const nn::hac::ContentMetaInfo& info = mCnmt.getContentMetaInfo()[i];
std::cout << " " << std::dec << i << std::endl;
std::cout << " Id: 0x" << std::hex << std::setw(16) << std::setfill('0') << info.getTitleId() << std::endl;
std::cout << " Version: v" << std::dec << info.getTitleVersion() << " (" << _SPLIT_VER(info.getTitleVersion()) << ")"<< std::endl;
std::cout << " Type: " << getContentMetaTypeStr(info.getContentMetaType()) << " (" << std::dec << info.getContentMetaType() << ")" << std::endl;
std::cout << " Attributes: 0x" << std::hex << (uint32_t)info.getAttributes() << std::endl;
std::cout << " IncludesExFatDriver: " << getBoolStr(_HAS_BIT(info.getAttributes(), nn::hac::cnmt::ATTRIBUTE_INCLUDES_EX_FAT_DRIVER)) << std::endl;
std::cout << " Rebootless: " << getBoolStr(_HAS_BIT(info.getAttributes(), nn::hac::cnmt::ATTRIBUTE_REBOOTLESS)) << std::endl;
}
}
std::cout << " Digest: " << fnd::SimpleTextOutput::arrayToString(mCnmt.getDigest().data, nn::hac::cnmt::kDigestLen, false, "") << std::endl;
#undef _SPLIT_VER
}
const char* CnmtProcess::getBoolStr(bool state) const
{
return state? "TRUE" : "FALSE";
}
const char* CnmtProcess::getContentTypeStr(nn::hac::cnmt::ContentType type) const
{
const char* str = nullptr;
switch (type)
{
case (nn::hac::cnmt::TYPE_META):
str = "Meta";
break;
case (nn::hac::cnmt::TYPE_PROGRAM):
str = "Program";
break;
case (nn::hac::cnmt::TYPE_DATA):
str = "Data";
break;
case (nn::hac::cnmt::TYPE_CONTROL):
str = "Control";
break;
case (nn::hac::cnmt::TYPE_HTML_DOCUMENT):
str = "HtmlDocument";
break;
case (nn::hac::cnmt::TYPE_LEGAL_INFORMATION):
str = "LegalInformation";
break;
case (nn::hac::cnmt::TYPE_DELTA_FRAGMENT):
str = "DeltaFragment";
break;
default:
str = "Unknown";
break;
}
return str;
}
const char* CnmtProcess::getContentMetaTypeStr(nn::hac::cnmt::ContentMetaType type) const
{
const char* str = nullptr;
switch (type)
{
case (nn::hac::cnmt::METATYPE_SYSTEM_PROGRAM):
str = "SystemProgram";
break;
case (nn::hac::cnmt::METATYPE_SYSTEM_DATA):
str = "SystemData";
break;
case (nn::hac::cnmt::METATYPE_SYSTEM_UPDATE):
str = "SystemUpdate";
break;
case (nn::hac::cnmt::METATYPE_BOOT_IMAGE_PACKAGE):
str = "BootImagePackage";
break;
case (nn::hac::cnmt::METATYPE_BOOT_IMAGE_PACKAGE_SAFE):
str = "BootImagePackageSafe";
break;
case (nn::hac::cnmt::METATYPE_APPLICATION):
str = "Application";
break;
case (nn::hac::cnmt::METATYPE_PATCH):
str = "Patch";
break;
case (nn::hac::cnmt::METATYPE_ADD_ON_CONTENT):
str = "AddOnContent";
break;
case (nn::hac::cnmt::METATYPE_DELTA):
str = "Delta";
break;
default:
str = "Unknown";
break;
}
return str;
}
const char* CnmtProcess::getUpdateTypeStr(nn::hac::cnmt::UpdateType type) const
{
const char* str = nullptr;
switch (type)
{
case (nn::hac::cnmt::UPDATETYPE_APPLY_AS_DELTA):
str = "ApplyAsDelta";
break;
case (nn::hac::cnmt::UPDATETYPE_OVERWRITE):
str = "Overwrite";
break;
case (nn::hac::cnmt::UPDATETYPE_CREATE):
str = "Create";
break;
default:
str = "Unknown";
break;
}
return str;
}
const char* CnmtProcess::getContentMetaAttrStr(nn::hac::cnmt::ContentMetaAttribute attr) const
{
const char* str = nullptr;
switch (attr)
{
case (nn::hac::cnmt::ATTRIBUTE_INCLUDES_EX_FAT_DRIVER):
str = "IncludesExFatDriver";
break;
case (nn::hac::cnmt::ATTRIBUTE_REBOOTLESS):
str = "Rebootless";
break;
default:
str = "Unknown";
break;
}
return str;
}

View file

@ -1,40 +1,40 @@
#pragma once
#include <string>
#include <fnd/types.h>
#include <fnd/IFile.h>
#include <fnd/SharedPtr.h>
#include <nn/hac/ContentMetaBinary.h>
#include "common.h"
class CnmtProcess
{
public:
CnmtProcess();
void process();
void setInputFile(const fnd::SharedPtr<fnd::IFile>& file);
void setCliOutputMode(CliOutputMode type);
void setVerifyMode(bool verify);
const nn::hac::ContentMetaBinary& getContentMetaBinary() const;
private:
const std::string kModuleName = "CnmtProcess";
fnd::SharedPtr<fnd::IFile> mFile;
CliOutputMode mCliOutputMode;
bool mVerify;
nn::hac::ContentMetaBinary mCnmt;
void importCnmt();
void displayCnmt();
const char* getBoolStr(bool state) const;
const char* getContentTypeStr(nn::hac::cnmt::ContentType type) const;
const char* getContentMetaTypeStr(nn::hac::cnmt::ContentMetaType type) const;
const char* getUpdateTypeStr(nn::hac::cnmt::UpdateType type) const;
const char* getContentMetaAttrStr(nn::hac::cnmt::ContentMetaAttribute attr) const;
#pragma once
#include <string>
#include <fnd/types.h>
#include <fnd/IFile.h>
#include <fnd/SharedPtr.h>
#include <nn/hac/ContentMeta.h>
#include "common.h"
class CnmtProcess
{
public:
CnmtProcess();
void process();
void setInputFile(const fnd::SharedPtr<fnd::IFile>& file);
void setCliOutputMode(CliOutputMode type);
void setVerifyMode(bool verify);
const nn::hac::ContentMeta& getContentMeta() const;
private:
const std::string kModuleName = "CnmtProcess";
fnd::SharedPtr<fnd::IFile> mFile;
CliOutputMode mCliOutputMode;
bool mVerify;
nn::hac::ContentMeta mCnmt;
void importCnmt();
void displayCnmt();
const char* getBoolStr(bool state) const;
const char* getContentTypeStr(nn::hac::cnmt::ContentType type) const;
const char* getContentMetaTypeStr(nn::hac::cnmt::ContentMetaType type) const;
const char* getUpdateTypeStr(nn::hac::cnmt::UpdateType type) const;
const char* getContentMetaAttrStr(nn::hac::cnmt::ContentMetaAttribute attr) const;
};

View file

@ -2,10 +2,10 @@
#include <iomanip>
#include <fnd/SimpleTextOutput.h>
#include <fnd/OffsetAdjustedIFile.h>
#include <nn/hac/XciUtils.h>
#include "XciProcess.h"
#include <nn/hac/GameCardUtils.h>
#include "GameCardProcess.h"
XciProcess::XciProcess() :
GameCardProcess::GameCardProcess() :
mFile(),
mCliOutputMode(_BIT(OUTPUT_BASIC)),
mVerify(false),
@ -15,7 +15,7 @@ XciProcess::XciProcess() :
{
}
void XciProcess::process()
void GameCardProcess::process()
{
importHeader();
@ -34,37 +34,37 @@ void XciProcess::process()
processPartitionPfs();
}
void XciProcess::setInputFile(const fnd::SharedPtr<fnd::IFile>& file)
void GameCardProcess::setInputFile(const fnd::SharedPtr<fnd::IFile>& file)
{
mFile = file;
}
void XciProcess::setKeyCfg(const KeyConfiguration& keycfg)
void GameCardProcess::setKeyCfg(const KeyConfiguration& keycfg)
{
mKeyCfg = keycfg;
}
void XciProcess::setCliOutputMode(CliOutputMode type)
void GameCardProcess::setCliOutputMode(CliOutputMode type)
{
mCliOutputMode = type;
}
void XciProcess::setVerifyMode(bool verify)
void GameCardProcess::setVerifyMode(bool verify)
{
mVerify = verify;
}
void XciProcess::setPartitionForExtract(const std::string& partition_name, const std::string& extract_path)
void GameCardProcess::setPartitionForExtract(const std::string& partition_name, const std::string& extract_path)
{
mExtractInfo.addElement({partition_name, extract_path});
}
void XciProcess::setListFs(bool list_fs)
void GameCardProcess::setListFs(bool list_fs)
{
mListFs = list_fs;
}
void XciProcess::importHeader()
void GameCardProcess::importHeader()
{
fnd::Vec<byte_t> scratch;
@ -74,22 +74,22 @@ void XciProcess::importHeader()
}
// read header page
(*mFile)->read((byte_t*)&mHdrPage, 0, sizeof(nn::hac::sXciHeaderPage));
(*mFile)->read((byte_t*)&mHdrPage, 0, sizeof(nn::hac::sGcHeaderPage));
// allocate memory for and decrypt sXciHeader
scratch.alloc(sizeof(nn::hac::sXciHeader));
scratch.alloc(sizeof(nn::hac::sGcHeader));
fnd::aes::sAes128Key header_key;
mKeyCfg.getXciHeaderKey(header_key);
nn::hac::XciUtils::decryptXciHeader((const byte_t*)&mHdrPage.header, scratch.data(), header_key.key);
nn::hac::GameCardUtils::decryptXciHeader((const byte_t*)&mHdrPage.header, scratch.data(), header_key.key);
// deserialise header
mHdr.fromBytes(scratch.data(), scratch.size());
}
void XciProcess::displayHeader()
void GameCardProcess::displayHeader()
{
std::cout << "[XCI Header]" << std::endl;
std::cout << "[GameCard Header]" << std::endl;
std::cout << " CardHeaderVersion: " << std::dec << (uint32_t)mHdr.getCardHeaderVersion() << std::endl;
std::cout << " RomSize: " << getRomSizeStr(mHdr.getRomSizeType());
if (_HAS_BIT(mCliOutputMode, OUTPUT_EXTENDED))
@ -128,22 +128,22 @@ void XciProcess::displayHeader()
{
std::cout << " RomAreaStartPage: 0x" << std::hex << mHdr.getRomAreaStartPage();
if (mHdr.getRomAreaStartPage() != (uint32_t)(-1))
std::cout << " (0x" << std::hex << nn::hac::XciUtils::blockToAddr(mHdr.getRomAreaStartPage()) << ")";
std::cout << " (0x" << std::hex << nn::hac::GameCardUtils::blockToAddr(mHdr.getRomAreaStartPage()) << ")";
std::cout << std::endl;
std::cout << " BackupAreaStartPage: 0x" << std::hex << mHdr.getBackupAreaStartPage();
if (mHdr.getBackupAreaStartPage() != (uint32_t)(-1))
std::cout << " (0x" << std::hex << nn::hac::XciUtils::blockToAddr(mHdr.getBackupAreaStartPage()) << ")";
std::cout << " (0x" << std::hex << nn::hac::GameCardUtils::blockToAddr(mHdr.getBackupAreaStartPage()) << ")";
std::cout << std::endl;
std::cout << " ValidDataEndPage: 0x" << std::hex << mHdr.getValidDataEndPage();
if (mHdr.getValidDataEndPage() != (uint32_t)(-1))
std::cout << " (0x" << std::hex << nn::hac::XciUtils::blockToAddr(mHdr.getValidDataEndPage()) << ")";
std::cout << " (0x" << std::hex << nn::hac::GameCardUtils::blockToAddr(mHdr.getValidDataEndPage()) << ")";
std::cout << std::endl;
std::cout << " LimArea: 0x" << std::hex << mHdr.getLimAreaPage();
if (mHdr.getLimAreaPage() != (uint32_t)(-1))
std::cout << " (0x" << std::hex << nn::hac::XciUtils::blockToAddr(mHdr.getLimAreaPage()) << ")";
std::cout << " (0x" << std::hex << nn::hac::GameCardUtils::blockToAddr(mHdr.getLimAreaPage()) << ")";
std::cout << std::endl;
std::cout << " PartitionFs Header:" << std::endl;
@ -160,7 +160,7 @@ void XciProcess::displayHeader()
if (mHdr.getFwVerMinor() != 0)
{
std::cout << "[XCI Extended Header]" << std::endl;
std::cout << "[GameCard Extended Header]" << std::endl;
std::cout << " FwVersion: v" << std::dec << mHdr.getFwVerMajor() << "." << mHdr.getFwVerMinor() << std::endl;
std::cout << " AccCtrl1: 0x" << std::hex << mHdr.getAccCtrl1() << std::endl;
std::cout << " CardClockRate: " << getCardClockRate(mHdr.getAccCtrl1()) << std::endl;
@ -178,7 +178,7 @@ void XciProcess::displayHeader()
}
}
bool XciProcess::validateRegionOfFile(size_t offset, size_t len, const byte_t* test_hash)
bool GameCardProcess::validateRegionOfFile(size_t offset, size_t len, const byte_t* test_hash)
{
fnd::Vec<byte_t> scratch;
fnd::sha::sSha256Hash calc_hash;
@ -188,23 +188,23 @@ bool XciProcess::validateRegionOfFile(size_t offset, size_t len, const byte_t* t
return calc_hash.compare(test_hash);
}
void XciProcess::validateXciSignature()
void GameCardProcess::validateXciSignature()
{
fnd::rsa::sRsa2048Key header_sign_key;
fnd::sha::sSha256Hash calc_hash;
fnd::sha::Sha256((byte_t*)&mHdrPage.header, sizeof(nn::hac::sXciHeader), calc_hash.bytes);
fnd::sha::Sha256((byte_t*)&mHdrPage.header, sizeof(nn::hac::sGcHeader), calc_hash.bytes);
mKeyCfg.getXciHeaderSignKey(header_sign_key);
if (fnd::rsa::pkcs::rsaVerify(header_sign_key, fnd::sha::HASH_SHA256, calc_hash.bytes, mHdrPage.signature) != 0)
{
std::cout << "[WARNING] XCI Header Signature: FAIL" << std::endl;
std::cout << "[WARNING] GameCard Header Signature: FAIL" << std::endl;
}
}
void XciProcess::processRootPfs()
void GameCardProcess::processRootPfs()
{
if (mVerify && validateRegionOfFile(mHdr.getPartitionFsAddress(), mHdr.getPartitionFsSize(), mHdr.getPartitionFsHash().bytes) == false)
{
std::cout << "[WARNING] XCI Root HFS0: FAIL (bad hash)" << std::endl;
std::cout << "[WARNING] GameCard Root HFS0: FAIL (bad hash)" << std::endl;
}
mRootPfs.setInputFile(new fnd::OffsetAdjustedIFile(mFile, mHdr.getPartitionFsAddress(), mHdr.getPartitionFsSize()));
mRootPfs.setListFs(mListFs);
@ -214,15 +214,15 @@ void XciProcess::processRootPfs()
mRootPfs.process();
}
void XciProcess::processPartitionPfs()
void GameCardProcess::processPartitionPfs()
{
const fnd::List<nn::hac::PfsHeader::sFile>& rootPartitions = mRootPfs.getPfsHeader().getFileList();
const fnd::List<nn::hac::PartitionFsHeader::sFile>& rootPartitions = mRootPfs.getPfsHeader().getFileList();
for (size_t i = 0; i < rootPartitions.size(); i++)
{
// this must be validated here because only the size of the root partiton header is known at verification time
if (mVerify && validateRegionOfFile(mHdr.getPartitionFsAddress() + rootPartitions[i].offset, rootPartitions[i].hash_protected_size, rootPartitions[i].hash.bytes) == false)
{
std::cout << "[WARNING] XCI " << rootPartitions[i].name << " Partition HFS0: FAIL (bad hash)" << std::endl;
std::cout << "[WARNING] GameCard " << rootPartitions[i].name << " Partition HFS0: FAIL (bad hash)" << std::endl;
}
PfsProcess tmp;
@ -238,28 +238,28 @@ void XciProcess::processPartitionPfs()
}
}
const char* XciProcess::getRomSizeStr(byte_t rom_size) const
const char* GameCardProcess::getRomSizeStr(byte_t rom_size) const
{
const char* str = nullptr;
switch (rom_size)
{
case (nn::hac::xci::ROM_SIZE_1GB):
case (nn::hac::gc::ROM_SIZE_1GB):
str = "1GB";
break;
case (nn::hac::xci::ROM_SIZE_2GB):
case (nn::hac::gc::ROM_SIZE_2GB):
str = "2GB";
break;
case (nn::hac::xci::ROM_SIZE_4GB):
case (nn::hac::gc::ROM_SIZE_4GB):
str = "4GB";
break;
case (nn::hac::xci::ROM_SIZE_8GB):
case (nn::hac::gc::ROM_SIZE_8GB):
str = "8GB";
break;
case (nn::hac::xci::ROM_SIZE_16GB):
case (nn::hac::gc::ROM_SIZE_16GB):
str = "16GB";
break;
case (nn::hac::xci::ROM_SIZE_32GB):
case (nn::hac::gc::ROM_SIZE_32GB):
str = "32GB";
break;
default:
@ -270,19 +270,19 @@ const char* XciProcess::getRomSizeStr(byte_t rom_size) const
return str;
}
const char* XciProcess::getHeaderFlagStr(byte_t flag) const
const char* GameCardProcess::getHeaderFlagStr(byte_t flag) const
{
const char* str = nullptr;
switch (flag)
{
case (nn::hac::xci::FLAG_AUTOBOOT):
case (nn::hac::gc::FLAG_AUTOBOOT):
str = "AutoBoot";
break;
case (nn::hac::xci::FLAG_HISTORY_ERASE):
case (nn::hac::gc::FLAG_HISTORY_ERASE):
str = "HistoryErase";
break;
case (nn::hac::xci::FLAG_REPAIR_TOOL):
case (nn::hac::gc::FLAG_REPAIR_TOOL):
str = "RepairTool";
break;
default:
@ -294,16 +294,16 @@ const char* XciProcess::getHeaderFlagStr(byte_t flag) const
}
const char* XciProcess::getCardClockRate(uint32_t acc_ctrl_1) const
const char* GameCardProcess::getCardClockRate(uint32_t acc_ctrl_1) const
{
const char* str = nullptr;
switch (acc_ctrl_1)
{
case (nn::hac::xci::CLOCK_RATE_25):
case (nn::hac::gc::CLOCK_RATE_25):
str = "20 MHz";
break;
case (nn::hac::xci::CLOCK_RATE_50):
case (nn::hac::gc::CLOCK_RATE_50):
str = "50 MHz";
break;
default:

View file

@ -4,16 +4,16 @@
#include <fnd/IFile.h>
#include <fnd/SharedPtr.h>
#include <fnd/List.h>
#include <nn/hac/XciHeader.h>
#include <nn/hac/GameCardHeader.h>
#include "KeyConfiguration.h"
#include "PfsProcess.h"
#include "common.h"
class XciProcess
class GameCardProcess
{
public:
XciProcess();
GameCardProcess();
void process();
@ -28,7 +28,7 @@ public:
void setListFs(bool list_fs);
private:
const std::string kModuleName = "XciProcess";
const std::string kModuleName = "GameCardProcess";
const std::string kXciMountPointName = "gamecard:/";
fnd::SharedPtr<fnd::IFile> mFile;
@ -55,8 +55,8 @@ private:
bool mListFs;
nn::hac::sXciHeaderPage mHdrPage;
nn::hac::XciHeader mHdr;
nn::hac::sGcHeaderPage mHdrPage;
nn::hac::GameCardHeader mHdr;
PfsProcess mRootPfs;
fnd::List<sExtractInfo> mExtractInfo;

View file

@ -1,376 +1,376 @@
#include "KeyConfiguration.h"
#include <fnd/ResourceFileReader.h>
#include <fnd/SimpleTextOutput.h>
#include <nn/hac/AesKeygen.h>
#include <nn/hac/NcaUtils.h>
KeyConfiguration::KeyConfiguration()
{
clearGeneralKeyConfiguration();
clearNcaExternalKeys();
}
KeyConfiguration::KeyConfiguration(const KeyConfiguration& other)
{
*this = other;
}
void KeyConfiguration::operator=(const KeyConfiguration& other)
{
mAcidSignKey = other.mAcidSignKey;
mPkg2SignKey = other.mPkg2SignKey;
mNcaHeader0SignKey = other.mNcaHeader0SignKey;
mXciHeaderSignKey = other.mXciHeaderSignKey;
mNcaHeaderKey = other.mNcaHeaderKey;
mXciHeaderKey = other.mXciHeaderKey;
for (size_t i = 0; i < kMasterKeyNum; i++)
{
mPkg2Key[i] = other.mPkg2Key[i];
mPkg1Key[i] = other.mPkg1Key[i];
mNcaKeyAreaEncryptionKey[0][i] = other.mNcaKeyAreaEncryptionKey[0][i];
mNcaKeyAreaEncryptionKey[1][i] = other.mNcaKeyAreaEncryptionKey[1][i];
mNcaKeyAreaEncryptionKey[2][i] = other.mNcaKeyAreaEncryptionKey[2][i];
mNcaKeyAreaEncryptionKeyHw[0][i] = other.mNcaKeyAreaEncryptionKeyHw[0][i];
mNcaKeyAreaEncryptionKeyHw[1][i] = other.mNcaKeyAreaEncryptionKeyHw[1][i];
mNcaKeyAreaEncryptionKeyHw[2][i] = other.mNcaKeyAreaEncryptionKeyHw[2][i];
mETicketCommonKey[i] = other.mETicketCommonKey[i];
}
mPkiRootKeyList = other.mPkiRootKeyList;
mNcaExternalContentKeyList = other.mNcaExternalContentKeyList;
}
void KeyConfiguration::importHactoolGenericKeyfile(const std::string& path)
{
clearGeneralKeyConfiguration();
fnd::ResourceFileReader res;
try
{
res.processFile(path);
}
catch (const fnd::Exception&)
{
throw fnd::Exception(kModuleName, "Failed to open key file: " + path);
}
// internally used sources
fnd::aes::sAes128Key master_key[kMasterKeyNum] = { kNullAesKey };
fnd::aes::sAes128Key package2_key_source = kNullAesKey;
fnd::aes::sAes128Key ticket_titlekek_source = kNullAesKey;
fnd::aes::sAes128Key key_area_key_source[kNcaKeakNum] = { kNullAesKey, kNullAesKey, kNullAesKey };
fnd::aes::sAes128Key aes_kek_generation_source = kNullAesKey;
fnd::aes::sAes128Key aes_key_generation_source = kNullAesKey;
fnd::aes::sAes128Key nca_header_kek_source = kNullAesKey;
fnd::aes::sAesXts128Key nca_header_key_source = kNullAesXtsKey;
fnd::rsa::sRsa4096Key pki_root_sign_key = kNullRsa4096Key;
#define _CONCAT_2_STRINGS(str1, str2) ((str1) + "_" + (str2))
#define _CONCAT_3_STRINGS(str1, str2, str3) _CONCAT_2_STRINGS(_CONCAT_2_STRINGS(str1, str2), str3)
std::string key,val;
fnd::Vec<byte_t> dec_array;
#define _SAVE_KEYDATA(key_name, array, len) \
key = (key_name); \
val = res[key]; \
if (val.empty() == false) { \
fnd::SimpleTextOutput::stringToArray(val, dec_array); \
if (dec_array.size() != len) \
throw fnd::Exception(kModuleName, "Key: \"" + key_name + "\" has incorrect length"); \
memcpy(array, dec_array.data(), len); \
}
for (size_t nameidx = 0; nameidx < kNameVariantNum; nameidx++)
{
// import sources
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kPkg2Base[nameidx], kKeyStr, kSourceStr), package2_key_source.key, 0x10);
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kTicketCommonKeyBase[nameidx], kSourceStr), ticket_titlekek_source.key, 0x10);
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kNcaKeyAreaEncKeyBase[nameidx], kNcaKeyAreaKeyIndexStr[0], kSourceStr), key_area_key_source[0].key, 0x10);
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kNcaKeyAreaEncKeyBase[nameidx], kNcaKeyAreaKeyIndexStr[1], kSourceStr), key_area_key_source[1].key, 0x10);
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kNcaKeyAreaEncKeyBase[nameidx], kNcaKeyAreaKeyIndexStr[2], kSourceStr), key_area_key_source[2].key, 0x10);
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kKekGenBase[nameidx], kSourceStr), aes_kek_generation_source.key, 0x10);
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kKeyGenBase[nameidx], kSourceStr), aes_key_generation_source.key, 0x10);
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kXciHeaderBase[nameidx], kKekStr, kSourceStr), nca_header_kek_source.key, 0x10);
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kXciHeaderBase[nameidx], kKeyStr, kSourceStr), nca_header_key_source.key, 0x20);
// Store Key Variants/Derivatives
for (size_t mkeyidx = 0; mkeyidx < kMasterKeyNum; mkeyidx++)
{
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kMasterBase[nameidx], kKeyStr, kKeyIndex[mkeyidx]), master_key[mkeyidx].key, 0x10);
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kPkg1Base[nameidx], kKeyStr, kKeyIndex[mkeyidx]), mPkg1Key[mkeyidx].key, 0x10);
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kPkg2Base[nameidx], kKeyStr, kKeyIndex[mkeyidx]), mPkg2Key[mkeyidx].key, 0x10);
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kTicketCommonKeyBase[nameidx], kKeyIndex[mkeyidx]), mETicketCommonKey[mkeyidx].key, 0x10);
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kNcaKeyAreaEncKeyBase[nameidx], kNcaKeyAreaKeyIndexStr[0], kKeyIndex[mkeyidx]), mNcaKeyAreaEncryptionKey[0][mkeyidx].key, 0x10);
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kNcaKeyAreaEncKeyBase[nameidx], kNcaKeyAreaKeyIndexStr[1], kKeyIndex[mkeyidx]), mNcaKeyAreaEncryptionKey[1][mkeyidx].key, 0x10);
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kNcaKeyAreaEncKeyBase[nameidx], kNcaKeyAreaKeyIndexStr[2], kKeyIndex[mkeyidx]), mNcaKeyAreaEncryptionKey[2][mkeyidx].key, 0x10);
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kNcaKeyAreaEncKeyHwBase[nameidx], kNcaKeyAreaKeyIndexStr[0], kKeyIndex[mkeyidx]), mNcaKeyAreaEncryptionKeyHw[0][mkeyidx].key, 0x10);
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kNcaKeyAreaEncKeyHwBase[nameidx], kNcaKeyAreaKeyIndexStr[1], kKeyIndex[mkeyidx]), mNcaKeyAreaEncryptionKeyHw[1][mkeyidx].key, 0x10);
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kNcaKeyAreaEncKeyHwBase[nameidx], kNcaKeyAreaKeyIndexStr[2], kKeyIndex[mkeyidx]), mNcaKeyAreaEncryptionKeyHw[2][mkeyidx].key, 0x10);
}
// store nca header key
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kNcaHeaderBase[nameidx], kKeyStr), mNcaHeaderKey.key[0], 0x20);
// store xci header key
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kXciHeaderBase[nameidx], kKeyStr), mXciHeaderKey.key, 0x10);
// store rsa keys
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kNcaHeaderBase[nameidx], kRsaKeyPrivate), mNcaHeader0SignKey.priv_exponent, fnd::rsa::kRsa2048Size);
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kNcaHeaderBase[nameidx], kRsaKeyModulus), mNcaHeader0SignKey.modulus, fnd::rsa::kRsa2048Size);
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kXciHeaderBase[nameidx], kRsaKeyPrivate), mXciHeaderSignKey.priv_exponent, fnd::rsa::kRsa2048Size);
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kXciHeaderBase[nameidx], kRsaKeyModulus), mXciHeaderSignKey.modulus, fnd::rsa::kRsa2048Size);
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kAcidBase[nameidx], kRsaKeyPrivate), mAcidSignKey.priv_exponent, fnd::rsa::kRsa2048Size);
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kAcidBase[nameidx], kRsaKeyModulus), mAcidSignKey.modulus, fnd::rsa::kRsa2048Size);
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kPkg2Base[nameidx], kRsaKeyPrivate), mPkg2SignKey.priv_exponent, fnd::rsa::kRsa2048Size);
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kPkg2Base[nameidx], kRsaKeyModulus), mPkg2SignKey.modulus, fnd::rsa::kRsa2048Size);
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kPkiRootBase[nameidx], kRsaKeyPrivate), pki_root_sign_key.priv_exponent, fnd::rsa::kRsa4096Size);
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kPkiRootBase[nameidx], kRsaKeyModulus), pki_root_sign_key.modulus, fnd::rsa::kRsa4096Size);
}
#undef _SAVE_KEYDATA
#undef _CONCAT_3_STRINGS
#undef _CONCAT_2_STRINGS
// Derive keys
for (size_t i = 0; i < kMasterKeyNum; i++)
{
if (master_key[i] != kNullAesKey)
{
if (aes_kek_generation_source != kNullAesKey && aes_key_generation_source != kNullAesKey)
{
if (i == 0 && nca_header_kek_source != kNullAesKey && nca_header_key_source != kNullAesXtsKey)
{
if (mNcaHeaderKey == kNullAesXtsKey)
{
fnd::aes::sAes128Key nca_header_kek;
nn::hac::AesKeygen::generateKey(nca_header_kek.key, aes_kek_generation_source.key, nca_header_kek_source.key, aes_key_generation_source.key, master_key[i].key);
nn::hac::AesKeygen::generateKey(mNcaHeaderKey.key[0], nca_header_key_source.key[0], nca_header_kek.key);
nn::hac::AesKeygen::generateKey(mNcaHeaderKey.key[1], nca_header_key_source.key[1], nca_header_kek.key);
}
}
for (size_t j = 0; j < nn::hac::nca::kKeyAreaEncryptionKeyNum; j++)
{
if (key_area_key_source[j] != kNullAesKey && mNcaKeyAreaEncryptionKey[j][i] == kNullAesKey)
{
nn::hac::AesKeygen::generateKey(mNcaKeyAreaEncryptionKey[j][i].key, aes_kek_generation_source.key, key_area_key_source[j].key, aes_key_generation_source.key, master_key[i].key);
}
}
}
if (ticket_titlekek_source != kNullAesKey && mETicketCommonKey[i] == kNullAesKey)
{
nn::hac::AesKeygen::generateKey(mETicketCommonKey[i].key, ticket_titlekek_source.key, master_key[i].key);
}
if (package2_key_source != kNullAesKey && mPkg2Key[i] == kNullAesKey)
{
nn::hac::AesKeygen::generateKey(mPkg2Key[i].key, package2_key_source.key, master_key[i].key);
}
}
}
// populate pki root keys
if (pki_root_sign_key != kNullRsa4096Key)
{
sPkiRootKey tmp;
tmp.name = nn::pki::sign::kRootIssuerStr;
tmp.key_type = nn::pki::sign::SIGN_ALGO_RSA4096;
tmp.rsa4096_key = pki_root_sign_key;
mPkiRootKeyList.addElement(tmp);
}
}
void KeyConfiguration::clearGeneralKeyConfiguration()
{
mAcidSignKey = kNullRsa2048Key;
mPkg2SignKey = kNullRsa2048Key;
mNcaHeader0SignKey = kNullRsa2048Key;
mXciHeaderSignKey = kNullRsa2048Key;
mPkiRootKeyList.clear();
mNcaHeaderKey = kNullAesXtsKey;
mXciHeaderKey = kNullAesKey;
for (size_t i = 0; i < kMasterKeyNum; i++)
{
mPkg1Key[i] = kNullAesKey;
mPkg2Key[i] = kNullAesKey;
mETicketCommonKey[i] = kNullAesKey;
for (size_t j = 0; j < kNcaKeakNum; j++)
{
mNcaKeyAreaEncryptionKey[j][i] = kNullAesKey;
mNcaKeyAreaEncryptionKey[j][i] = kNullAesKey;
}
}
}
void KeyConfiguration::clearNcaExternalKeys()
{
mNcaExternalContentKeyList.clear();
}
bool KeyConfiguration::getNcaHeaderKey(fnd::aes::sAesXts128Key& key) const
{
return copyOutKeyResourceIfExists(mNcaHeaderKey, key, kNullAesXtsKey);
}
bool KeyConfiguration::getNcaHeader0SignKey(fnd::rsa::sRsa2048Key& key) const
{
return copyOutKeyResourceIfExists(mNcaHeader0SignKey, key, kNullRsa2048Key);
}
bool KeyConfiguration::getAcidSignKey(fnd::rsa::sRsa2048Key& key) const
{
return copyOutKeyResourceIfExists(mAcidSignKey, key, kNullRsa2048Key);
}
bool KeyConfiguration::getNcaKeyAreaEncryptionKey(byte_t masterkey_index, byte_t keak_type, fnd::aes::sAes128Key& key) const
{
if (keak_type >= kNcaKeakNum || masterkey_index >= kMasterKeyNum)
{
return false;
}
return copyOutKeyResourceIfExists(mNcaKeyAreaEncryptionKey[keak_type][masterkey_index], key, kNullAesKey);
}
bool KeyConfiguration::getNcaKeyAreaEncryptionKeyHw(byte_t masterkey_index, byte_t keak_type, fnd::aes::sAes128Key& key) const
{
if (keak_type >= kNcaKeakNum || masterkey_index >= kMasterKeyNum)
{
return false;
}
return copyOutKeyResourceIfExists(mNcaKeyAreaEncryptionKeyHw[keak_type][masterkey_index], key, kNullAesKey);
}
void KeyConfiguration::addNcaExternalContentKey(const byte_t rights_id[nn::hac::nca::kRightsIdLen], const fnd::aes::sAes128Key& key)
{
sNcaExternalContentKey tmp;
memcpy(tmp.rights_id.data, rights_id, nn::hac::nca::kRightsIdLen);
tmp.key = key;
if (mNcaExternalContentKeyList.hasElement(tmp))
return;
mNcaExternalContentKeyList.addElement(tmp);
}
bool KeyConfiguration::getNcaExternalContentKey(const byte_t rights_id[nn::hac::nca::kRightsIdLen], fnd::aes::sAes128Key& key) const
{
sRightsId id;
bool res_exists = false;
memcpy(id.data, rights_id, nn::hac::nca::kRightsIdLen);
for (size_t i = 0; i < mNcaExternalContentKeyList.size(); i++)
{
if (mNcaExternalContentKeyList[i].rights_id == id)
{
res_exists = true;
key = mNcaExternalContentKeyList[i].key;
break;
}
}
return res_exists;
}
bool KeyConfiguration::getPkg1Key(byte_t masterkey_index, fnd::aes::sAes128Key& key) const
{
if (masterkey_index >= kMasterKeyNum)
{
return false;
}
return copyOutKeyResourceIfExists(mPkg1Key[masterkey_index], key, kNullAesKey);
}
bool KeyConfiguration::getPkg2Key(byte_t masterkey_index, fnd::aes::sAes128Key& key) const
{
if (masterkey_index >= kMasterKeyNum)
{
return false;
}
return copyOutKeyResourceIfExists(mPkg2Key[masterkey_index], key, kNullAesKey);
}
bool KeyConfiguration::getPkg2SignKey(fnd::rsa::sRsa2048Key& key) const
{
return copyOutKeyResourceIfExists(mPkg2SignKey, key, kNullRsa2048Key);
}
bool KeyConfiguration::getXciHeaderSignKey(fnd::rsa::sRsa2048Key& key) const
{
return copyOutKeyResourceIfExists(mXciHeaderSignKey, key, kNullRsa2048Key);
}
bool KeyConfiguration::getXciHeaderKey(fnd::aes::sAes128Key& key) const
{
return copyOutKeyResourceIfExists(mXciHeaderKey, key, kNullAesKey);
}
bool KeyConfiguration::getETicketCommonKey(byte_t masterkey_index, fnd::aes::sAes128Key& key) const
{
if (masterkey_index >= kMasterKeyNum)
{
return false;
}
return copyOutKeyResourceIfExists(mETicketCommonKey[masterkey_index], key, kNullAesKey);
}
bool KeyConfiguration::getPkiRootSignKey(const std::string& root_name, fnd::rsa::sRsa4096Key& key) const
{
bool res_exists = false;
for (size_t i = 0; i < mPkiRootKeyList.size(); i++)
{
if (root_name == mPkiRootKeyList[i].name && mPkiRootKeyList[i].key_type == nn::pki::sign::SIGN_ALGO_RSA4096)
{
res_exists = true;
key = mPkiRootKeyList[i].rsa4096_key;
break;
}
}
return res_exists;
}
bool KeyConfiguration::getPkiRootSignKey(const std::string& root_name, fnd::rsa::sRsa2048Key& key) const
{
bool res_exists = false;
for (size_t i = 0; i < mPkiRootKeyList.size(); i++)
{
if (root_name == mPkiRootKeyList[i].name && mPkiRootKeyList[i].key_type == nn::pki::sign::SIGN_ALGO_RSA2048)
{
res_exists = true;
key = mPkiRootKeyList[i].rsa2048_key;
break;
}
}
return res_exists;
}
bool KeyConfiguration::getPkiRootSignKey(const std::string& root_name, fnd::ecdsa::sEcdsa240Key& key) const
{
bool res_exists = false;
for (size_t i = 0; i < mPkiRootKeyList.size(); i++)
{
if (root_name == mPkiRootKeyList[i].name && mPkiRootKeyList[i].key_type == nn::pki::sign::SIGN_ALGO_ECDSA240)
{
res_exists = true;
key = mPkiRootKeyList[i].ecdsa240_key;
break;
}
}
return res_exists;
#include "KeyConfiguration.h"
#include <fnd/ResourceFileReader.h>
#include <fnd/SimpleTextOutput.h>
#include <nn/hac/AesKeygen.h>
#include <nn/hac/ContentArchiveUtils.h>
KeyConfiguration::KeyConfiguration()
{
clearGeneralKeyConfiguration();
clearNcaExternalKeys();
}
KeyConfiguration::KeyConfiguration(const KeyConfiguration& other)
{
*this = other;
}
void KeyConfiguration::operator=(const KeyConfiguration& other)
{
mAcidSignKey = other.mAcidSignKey;
mPkg2SignKey = other.mPkg2SignKey;
mContentArchiveHeader0SignKey = other.mContentArchiveHeader0SignKey;
mXciHeaderSignKey = other.mXciHeaderSignKey;
mContentArchiveHeaderKey = other.mContentArchiveHeaderKey;
mXciHeaderKey = other.mXciHeaderKey;
for (size_t i = 0; i < kMasterKeyNum; i++)
{
mPkg2Key[i] = other.mPkg2Key[i];
mPkg1Key[i] = other.mPkg1Key[i];
mNcaKeyAreaEncryptionKey[0][i] = other.mNcaKeyAreaEncryptionKey[0][i];
mNcaKeyAreaEncryptionKey[1][i] = other.mNcaKeyAreaEncryptionKey[1][i];
mNcaKeyAreaEncryptionKey[2][i] = other.mNcaKeyAreaEncryptionKey[2][i];
mNcaKeyAreaEncryptionKeyHw[0][i] = other.mNcaKeyAreaEncryptionKeyHw[0][i];
mNcaKeyAreaEncryptionKeyHw[1][i] = other.mNcaKeyAreaEncryptionKeyHw[1][i];
mNcaKeyAreaEncryptionKeyHw[2][i] = other.mNcaKeyAreaEncryptionKeyHw[2][i];
mETicketCommonKey[i] = other.mETicketCommonKey[i];
}
mPkiRootKeyList = other.mPkiRootKeyList;
mNcaExternalContentKeyList = other.mNcaExternalContentKeyList;
}
void KeyConfiguration::importHactoolGenericKeyfile(const std::string& path)
{
clearGeneralKeyConfiguration();
fnd::ResourceFileReader res;
try
{
res.processFile(path);
}
catch (const fnd::Exception&)
{
throw fnd::Exception(kModuleName, "Failed to open key file: " + path);
}
// internally used sources
fnd::aes::sAes128Key master_key[kMasterKeyNum] = { kNullAesKey };
fnd::aes::sAes128Key package2_key_source = kNullAesKey;
fnd::aes::sAes128Key ticket_titlekek_source = kNullAesKey;
fnd::aes::sAes128Key key_area_key_source[kNcaKeakNum] = { kNullAesKey, kNullAesKey, kNullAesKey };
fnd::aes::sAes128Key aes_kek_generation_source = kNullAesKey;
fnd::aes::sAes128Key aes_key_generation_source = kNullAesKey;
fnd::aes::sAes128Key nca_header_kek_source = kNullAesKey;
fnd::aes::sAesXts128Key nca_header_key_source = kNullAesXtsKey;
fnd::rsa::sRsa4096Key pki_root_sign_key = kNullRsa4096Key;
#define _CONCAT_2_STRINGS(str1, str2) ((str1) + "_" + (str2))
#define _CONCAT_3_STRINGS(str1, str2, str3) _CONCAT_2_STRINGS(_CONCAT_2_STRINGS(str1, str2), str3)
std::string key,val;
fnd::Vec<byte_t> dec_array;
#define _SAVE_KEYDATA(key_name, array, len) \
key = (key_name); \
val = res[key]; \
if (val.empty() == false) { \
fnd::SimpleTextOutput::stringToArray(val, dec_array); \
if (dec_array.size() != len) \
throw fnd::Exception(kModuleName, "Key: \"" + key_name + "\" has incorrect length"); \
memcpy(array, dec_array.data(), len); \
}
for (size_t nameidx = 0; nameidx < kNameVariantNum; nameidx++)
{
// import sources
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kPkg2Base[nameidx], kKeyStr, kSourceStr), package2_key_source.key, 0x10);
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kTicketCommonKeyBase[nameidx], kSourceStr), ticket_titlekek_source.key, 0x10);
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kNcaKeyAreaEncKeyBase[nameidx], kNcaKeyAreaKeyIndexStr[0], kSourceStr), key_area_key_source[0].key, 0x10);
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kNcaKeyAreaEncKeyBase[nameidx], kNcaKeyAreaKeyIndexStr[1], kSourceStr), key_area_key_source[1].key, 0x10);
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kNcaKeyAreaEncKeyBase[nameidx], kNcaKeyAreaKeyIndexStr[2], kSourceStr), key_area_key_source[2].key, 0x10);
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kKekGenBase[nameidx], kSourceStr), aes_kek_generation_source.key, 0x10);
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kKeyGenBase[nameidx], kSourceStr), aes_key_generation_source.key, 0x10);
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kXciHeaderBase[nameidx], kKekStr, kSourceStr), nca_header_kek_source.key, 0x10);
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kXciHeaderBase[nameidx], kKeyStr, kSourceStr), nca_header_key_source.key, 0x20);
// Store Key Variants/Derivatives
for (size_t mkeyidx = 0; mkeyidx < kMasterKeyNum; mkeyidx++)
{
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kMasterBase[nameidx], kKeyStr, kKeyIndex[mkeyidx]), master_key[mkeyidx].key, 0x10);
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kPkg1Base[nameidx], kKeyStr, kKeyIndex[mkeyidx]), mPkg1Key[mkeyidx].key, 0x10);
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kPkg2Base[nameidx], kKeyStr, kKeyIndex[mkeyidx]), mPkg2Key[mkeyidx].key, 0x10);
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kTicketCommonKeyBase[nameidx], kKeyIndex[mkeyidx]), mETicketCommonKey[mkeyidx].key, 0x10);
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kNcaKeyAreaEncKeyBase[nameidx], kNcaKeyAreaKeyIndexStr[0], kKeyIndex[mkeyidx]), mNcaKeyAreaEncryptionKey[0][mkeyidx].key, 0x10);
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kNcaKeyAreaEncKeyBase[nameidx], kNcaKeyAreaKeyIndexStr[1], kKeyIndex[mkeyidx]), mNcaKeyAreaEncryptionKey[1][mkeyidx].key, 0x10);
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kNcaKeyAreaEncKeyBase[nameidx], kNcaKeyAreaKeyIndexStr[2], kKeyIndex[mkeyidx]), mNcaKeyAreaEncryptionKey[2][mkeyidx].key, 0x10);
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kNcaKeyAreaEncKeyHwBase[nameidx], kNcaKeyAreaKeyIndexStr[0], kKeyIndex[mkeyidx]), mNcaKeyAreaEncryptionKeyHw[0][mkeyidx].key, 0x10);
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kNcaKeyAreaEncKeyHwBase[nameidx], kNcaKeyAreaKeyIndexStr[1], kKeyIndex[mkeyidx]), mNcaKeyAreaEncryptionKeyHw[1][mkeyidx].key, 0x10);
_SAVE_KEYDATA(_CONCAT_3_STRINGS(kNcaKeyAreaEncKeyHwBase[nameidx], kNcaKeyAreaKeyIndexStr[2], kKeyIndex[mkeyidx]), mNcaKeyAreaEncryptionKeyHw[2][mkeyidx].key, 0x10);
}
// store nca header key
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kContentArchiveHeaderBase[nameidx], kKeyStr), mContentArchiveHeaderKey.key[0], 0x20);
// store xci header key
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kXciHeaderBase[nameidx], kKeyStr), mXciHeaderKey.key, 0x10);
// store rsa keys
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kContentArchiveHeaderBase[nameidx], kRsaKeyPrivate), mContentArchiveHeader0SignKey.priv_exponent, fnd::rsa::kRsa2048Size);
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kContentArchiveHeaderBase[nameidx], kRsaKeyModulus), mContentArchiveHeader0SignKey.modulus, fnd::rsa::kRsa2048Size);
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kXciHeaderBase[nameidx], kRsaKeyPrivate), mXciHeaderSignKey.priv_exponent, fnd::rsa::kRsa2048Size);
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kXciHeaderBase[nameidx], kRsaKeyModulus), mXciHeaderSignKey.modulus, fnd::rsa::kRsa2048Size);
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kAcidBase[nameidx], kRsaKeyPrivate), mAcidSignKey.priv_exponent, fnd::rsa::kRsa2048Size);
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kAcidBase[nameidx], kRsaKeyModulus), mAcidSignKey.modulus, fnd::rsa::kRsa2048Size);
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kPkg2Base[nameidx], kRsaKeyPrivate), mPkg2SignKey.priv_exponent, fnd::rsa::kRsa2048Size);
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kPkg2Base[nameidx], kRsaKeyModulus), mPkg2SignKey.modulus, fnd::rsa::kRsa2048Size);
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kPkiRootBase[nameidx], kRsaKeyPrivate), pki_root_sign_key.priv_exponent, fnd::rsa::kRsa4096Size);
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kPkiRootBase[nameidx], kRsaKeyModulus), pki_root_sign_key.modulus, fnd::rsa::kRsa4096Size);
}
#undef _SAVE_KEYDATA
#undef _CONCAT_3_STRINGS
#undef _CONCAT_2_STRINGS
// Derive keys
for (size_t i = 0; i < kMasterKeyNum; i++)
{
if (master_key[i] != kNullAesKey)
{
if (aes_kek_generation_source != kNullAesKey && aes_key_generation_source != kNullAesKey)
{
if (i == 0 && nca_header_kek_source != kNullAesKey && nca_header_key_source != kNullAesXtsKey)
{
if (mContentArchiveHeaderKey == kNullAesXtsKey)
{
fnd::aes::sAes128Key nca_header_kek;
nn::hac::AesKeygen::generateKey(nca_header_kek.key, aes_kek_generation_source.key, nca_header_kek_source.key, aes_key_generation_source.key, master_key[i].key);
nn::hac::AesKeygen::generateKey(mContentArchiveHeaderKey.key[0], nca_header_key_source.key[0], nca_header_kek.key);
nn::hac::AesKeygen::generateKey(mContentArchiveHeaderKey.key[1], nca_header_key_source.key[1], nca_header_kek.key);
}
}
for (size_t j = 0; j < nn::hac::nca::kKeyAreaEncryptionKeyNum; j++)
{
if (key_area_key_source[j] != kNullAesKey && mNcaKeyAreaEncryptionKey[j][i] == kNullAesKey)
{
nn::hac::AesKeygen::generateKey(mNcaKeyAreaEncryptionKey[j][i].key, aes_kek_generation_source.key, key_area_key_source[j].key, aes_key_generation_source.key, master_key[i].key);
}
}
}
if (ticket_titlekek_source != kNullAesKey && mETicketCommonKey[i] == kNullAesKey)
{
nn::hac::AesKeygen::generateKey(mETicketCommonKey[i].key, ticket_titlekek_source.key, master_key[i].key);
}
if (package2_key_source != kNullAesKey && mPkg2Key[i] == kNullAesKey)
{
nn::hac::AesKeygen::generateKey(mPkg2Key[i].key, package2_key_source.key, master_key[i].key);
}
}
}
// populate pki root keys
if (pki_root_sign_key != kNullRsa4096Key)
{
sPkiRootKey tmp;
tmp.name = nn::pki::sign::kRootIssuerStr;
tmp.key_type = nn::pki::sign::SIGN_ALGO_RSA4096;
tmp.rsa4096_key = pki_root_sign_key;
mPkiRootKeyList.addElement(tmp);
}
}
void KeyConfiguration::clearGeneralKeyConfiguration()
{
mAcidSignKey = kNullRsa2048Key;
mPkg2SignKey = kNullRsa2048Key;
mContentArchiveHeader0SignKey = kNullRsa2048Key;
mXciHeaderSignKey = kNullRsa2048Key;
mPkiRootKeyList.clear();
mContentArchiveHeaderKey = kNullAesXtsKey;
mXciHeaderKey = kNullAesKey;
for (size_t i = 0; i < kMasterKeyNum; i++)
{
mPkg1Key[i] = kNullAesKey;
mPkg2Key[i] = kNullAesKey;
mETicketCommonKey[i] = kNullAesKey;
for (size_t j = 0; j < kNcaKeakNum; j++)
{
mNcaKeyAreaEncryptionKey[j][i] = kNullAesKey;
mNcaKeyAreaEncryptionKey[j][i] = kNullAesKey;
}
}
}
void KeyConfiguration::clearNcaExternalKeys()
{
mNcaExternalContentKeyList.clear();
}
bool KeyConfiguration::getContentArchiveHeaderKey(fnd::aes::sAesXts128Key& key) const
{
return copyOutKeyResourceIfExists(mContentArchiveHeaderKey, key, kNullAesXtsKey);
}
bool KeyConfiguration::getContentArchiveHeader0SignKey(fnd::rsa::sRsa2048Key& key) const
{
return copyOutKeyResourceIfExists(mContentArchiveHeader0SignKey, key, kNullRsa2048Key);
}
bool KeyConfiguration::getAcidSignKey(fnd::rsa::sRsa2048Key& key) const
{
return copyOutKeyResourceIfExists(mAcidSignKey, key, kNullRsa2048Key);
}
bool KeyConfiguration::getNcaKeyAreaEncryptionKey(byte_t masterkey_index, byte_t keak_type, fnd::aes::sAes128Key& key) const
{
if (keak_type >= kNcaKeakNum || masterkey_index >= kMasterKeyNum)
{
return false;
}
return copyOutKeyResourceIfExists(mNcaKeyAreaEncryptionKey[keak_type][masterkey_index], key, kNullAesKey);
}
bool KeyConfiguration::getNcaKeyAreaEncryptionKeyHw(byte_t masterkey_index, byte_t keak_type, fnd::aes::sAes128Key& key) const
{
if (keak_type >= kNcaKeakNum || masterkey_index >= kMasterKeyNum)
{
return false;
}
return copyOutKeyResourceIfExists(mNcaKeyAreaEncryptionKeyHw[keak_type][masterkey_index], key, kNullAesKey);
}
void KeyConfiguration::addNcaExternalContentKey(const byte_t rights_id[nn::hac::nca::kRightsIdLen], const fnd::aes::sAes128Key& key)
{
sNcaExternalContentKey tmp;
memcpy(tmp.rights_id.data, rights_id, nn::hac::nca::kRightsIdLen);
tmp.key = key;
if (mNcaExternalContentKeyList.hasElement(tmp))
return;
mNcaExternalContentKeyList.addElement(tmp);
}
bool KeyConfiguration::getNcaExternalContentKey(const byte_t rights_id[nn::hac::nca::kRightsIdLen], fnd::aes::sAes128Key& key) const
{
sRightsId id;
bool res_exists = false;
memcpy(id.data, rights_id, nn::hac::nca::kRightsIdLen);
for (size_t i = 0; i < mNcaExternalContentKeyList.size(); i++)
{
if (mNcaExternalContentKeyList[i].rights_id == id)
{
res_exists = true;
key = mNcaExternalContentKeyList[i].key;
break;
}
}
return res_exists;
}
bool KeyConfiguration::getPkg1Key(byte_t masterkey_index, fnd::aes::sAes128Key& key) const
{
if (masterkey_index >= kMasterKeyNum)
{
return false;
}
return copyOutKeyResourceIfExists(mPkg1Key[masterkey_index], key, kNullAesKey);
}
bool KeyConfiguration::getPkg2Key(byte_t masterkey_index, fnd::aes::sAes128Key& key) const
{
if (masterkey_index >= kMasterKeyNum)
{
return false;
}
return copyOutKeyResourceIfExists(mPkg2Key[masterkey_index], key, kNullAesKey);
}
bool KeyConfiguration::getPkg2SignKey(fnd::rsa::sRsa2048Key& key) const
{
return copyOutKeyResourceIfExists(mPkg2SignKey, key, kNullRsa2048Key);
}
bool KeyConfiguration::getXciHeaderSignKey(fnd::rsa::sRsa2048Key& key) const
{
return copyOutKeyResourceIfExists(mXciHeaderSignKey, key, kNullRsa2048Key);
}
bool KeyConfiguration::getXciHeaderKey(fnd::aes::sAes128Key& key) const
{
return copyOutKeyResourceIfExists(mXciHeaderKey, key, kNullAesKey);
}
bool KeyConfiguration::getETicketCommonKey(byte_t masterkey_index, fnd::aes::sAes128Key& key) const
{
if (masterkey_index >= kMasterKeyNum)
{
return false;
}
return copyOutKeyResourceIfExists(mETicketCommonKey[masterkey_index], key, kNullAesKey);
}
bool KeyConfiguration::getPkiRootSignKey(const std::string& root_name, fnd::rsa::sRsa4096Key& key) const
{
bool res_exists = false;
for (size_t i = 0; i < mPkiRootKeyList.size(); i++)
{
if (root_name == mPkiRootKeyList[i].name && mPkiRootKeyList[i].key_type == nn::pki::sign::SIGN_ALGO_RSA4096)
{
res_exists = true;
key = mPkiRootKeyList[i].rsa4096_key;
break;
}
}
return res_exists;
}
bool KeyConfiguration::getPkiRootSignKey(const std::string& root_name, fnd::rsa::sRsa2048Key& key) const
{
bool res_exists = false;
for (size_t i = 0; i < mPkiRootKeyList.size(); i++)
{
if (root_name == mPkiRootKeyList[i].name && mPkiRootKeyList[i].key_type == nn::pki::sign::SIGN_ALGO_RSA2048)
{
res_exists = true;
key = mPkiRootKeyList[i].rsa2048_key;
break;
}
}
return res_exists;
}
bool KeyConfiguration::getPkiRootSignKey(const std::string& root_name, fnd::ecdsa::sEcdsa240Key& key) const
{
bool res_exists = false;
for (size_t i = 0; i < mPkiRootKeyList.size(); i++)
{
if (root_name == mPkiRootKeyList[i].name && mPkiRootKeyList[i].key_type == nn::pki::sign::SIGN_ALGO_ECDSA240)
{
res_exists = true;
key = mPkiRootKeyList[i].ecdsa240_key;
break;
}
}
return res_exists;
}

View file

@ -1,209 +1,209 @@
#pragma once
#include <string>
#include <cstring>
#include <fnd/types.h>
#include <fnd/aes.h>
#include <fnd/rsa.h>
#include <fnd/ecdsa.h>
#include <nn/hac/nca.h>
#include <nn/pki/SignedData.h>
#include <nn/es/TicketBody_V2.h>
class KeyConfiguration
{
public:
KeyConfiguration();
KeyConfiguration(const KeyConfiguration& other);
void operator=(const KeyConfiguration& other);
void importHactoolGenericKeyfile(const std::string& path);
//void importHactoolTitleKeyfile(const std::string& path);
void clearGeneralKeyConfiguration();
void clearNcaExternalKeys();
// nca keys
bool getNcaHeaderKey(fnd::aes::sAesXts128Key& key) const;
bool getNcaHeader0SignKey(fnd::rsa::sRsa2048Key& key) const;
bool getAcidSignKey(fnd::rsa::sRsa2048Key& key) const;
bool getNcaKeyAreaEncryptionKey(byte_t masterkey_index, byte_t keak_type, fnd::aes::sAes128Key& key) const;
bool getNcaKeyAreaEncryptionKeyHw(byte_t masterkey_index, byte_t keak_type, fnd::aes::sAes128Key& key) const;
// external content keys
void addNcaExternalContentKey(const byte_t rights_id[nn::hac::nca::kRightsIdLen], const fnd::aes::sAes128Key& key);
bool getNcaExternalContentKey(const byte_t rights_id[nn::hac::nca::kRightsIdLen], fnd::aes::sAes128Key& key) const;
// pkg1/pkg2
bool getPkg1Key(byte_t masterkey_index, fnd::aes::sAes128Key& key) const;
bool getPkg2Key(byte_t masterkey_index, fnd::aes::sAes128Key& key) const;
bool getPkg2SignKey(fnd::rsa::sRsa2048Key& key) const;
// xci keys
bool getXciHeaderSignKey(fnd::rsa::sRsa2048Key& key) const;
bool getXciHeaderKey(fnd::aes::sAes128Key& key) const;
// ticket
bool getETicketCommonKey(byte_t masterkey_index, fnd::aes::sAes128Key& key) const;
// pki
bool getPkiRootSignKey(const std::string& root_name, fnd::rsa::sRsa4096Key& key) const;
bool getPkiRootSignKey(const std::string& root_name, fnd::rsa::sRsa2048Key& key) const;
bool getPkiRootSignKey(const std::string& root_name, fnd::ecdsa::sEcdsa240Key& key) const;
private:
const std::string kModuleName = "KeyConfiguration";
const fnd::aes::sAes128Key kNullAesKey = {{0}};
const fnd::aes::sAesXts128Key kNullAesXtsKey = {{{0}}};
const fnd::rsa::sRsa4096Key kNullRsa4096Key = {{0}, {0}, {0}};
const fnd::rsa::sRsa2048Key kNullRsa2048Key = {{0}, {0}, {0}};
static const size_t kMasterKeyNum = 0x20;
static const size_t kNcaKeakNum = nn::hac::nca::kKeyAreaEncryptionKeyNum;
// keynames
enum NameVariantIndex
{
NNTOOLS,
LEGACY_HACTOOL,
LEGACY_0
};
static const size_t kNameVariantNum = 3;
const std::string kMasterBase[kNameVariantNum] = { "master", "master", "master" };
const std::string kPkg1Base[kNameVariantNum] = { "package1", "package1", "package1" };
const std::string kPkg2Base[kNameVariantNum] = { "package2", "package2", "package2" };
const std::string kXciHeaderBase[kNameVariantNum] = { "xci_header", "xci_header", "xci_header" };
const std::string kNcaHeaderBase[kNameVariantNum] = { "nca_header", "header", "nca_header" };
const std::string kAcidBase[kNameVariantNum] = { "acid", "acid", "acid" };
const std::string kPkiRootBase[kNameVariantNum] = { "pki_root", "pki_root", "pki_root" };
const std::string kTicketCommonKeyBase[kNameVariantNum] = { "ticket_commonkey", "titlekek", "ticket_commonkey" };
const std::string kNcaKeyAreaEncKeyBase[kNameVariantNum] = { "nca_key_area_key", "key_area_key", "nca_body_keak" };
const std::string kNcaKeyAreaEncKeyHwBase[kNameVariantNum] = { "nca_key_area_key_hw", "key_area_hw_key", "nca_key_area_key_hw" };
const std::string kKekGenBase[kNameVariantNum] = { "aes_kek_generation", "aes_kek_generation", "aes_kek_generation" };
const std::string kKeyGenBase[kNameVariantNum] = { "aes_key_generation", "aes_key_generation", "aes_key_generation" };
// misc str
const std::string kKeyStr = "key";
const std::string kKekStr = "kek";
const std::string kSourceStr = "source";
const std::string kRsaKeyModulus = "sign_key_modulus";
const std::string kRsaKeyPrivate = "sign_key_private";
const std::string kNcaKeyAreaKeyIndexStr[kNcaKeakNum] = { "application", "ocean", "system" };
const std::string kKeyIndex[kMasterKeyNum] = {"00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f"};
struct sRightsId
{
byte_t data[nn::hac::nca::kRightsIdLen];
void operator=(const sRightsId& other)
{
memcpy(this->data, other.data, nn::hac::nca::kRightsIdLen);
}
bool operator==(const sRightsId& other) const
{
return memcmp(this->data, other.data, nn::hac::nca::kRightsIdLen) == 0;
}
bool operator!=(const sRightsId& other) const
{
return !(operator==(other));
}
};
struct sNcaExternalContentKey
{
sRightsId rights_id;
fnd::aes::sAes128Key key;
void operator=(const sNcaExternalContentKey& other)
{
rights_id = other.rights_id;
key = other.key;
}
bool operator==(const sNcaExternalContentKey& other) const
{
return (rights_id == other.rights_id) \
&& (key == other.key);
}
bool operator!=(const sNcaExternalContentKey& other) const
{
return !(operator==(other));
}
};
struct sPkiRootKey
{
std::string name;
nn::pki::sign::SignatureAlgo key_type;
fnd::rsa::sRsa4096Key rsa4096_key;
fnd::rsa::sRsa2048Key rsa2048_key;
fnd::ecdsa::sEcdsa240Key ecdsa240_key;
void operator=(const sPkiRootKey& other)
{
name = other.name;
key_type = other.key_type;
rsa4096_key = other.rsa4096_key;
rsa2048_key = other.rsa2048_key;
ecdsa240_key = other.ecdsa240_key;
}
bool operator==(const sPkiRootKey& other) const
{
return (name == other.name) \
&& (key_type == other.key_type) \
&& (rsa4096_key == other.rsa4096_key) \
&& (rsa2048_key == other.rsa2048_key) \
&& (ecdsa240_key == other.ecdsa240_key);
}
bool operator!=(const sPkiRootKey& other) const
{
return !(operator==(other));
}
};
/* general key config */
// acid
fnd::rsa::sRsa2048Key mAcidSignKey;
// pkg1 and pkg2
fnd::aes::sAes128Key mPkg1Key[kMasterKeyNum];
fnd::rsa::sRsa2048Key mPkg2SignKey;
fnd::aes::sAes128Key mPkg2Key[kMasterKeyNum];
// nca
fnd::rsa::sRsa2048Key mNcaHeader0SignKey;
fnd::aes::sAesXts128Key mNcaHeaderKey;
fnd::aes::sAes128Key mNcaKeyAreaEncryptionKey[kNcaKeakNum][kMasterKeyNum];
fnd::aes::sAes128Key mNcaKeyAreaEncryptionKeyHw[kNcaKeakNum][kMasterKeyNum];
// xci
fnd::rsa::sRsa2048Key mXciHeaderSignKey;
fnd::aes::sAes128Key mXciHeaderKey;
// ticket
fnd::aes::sAes128Key mETicketCommonKey[kMasterKeyNum];
// pki
fnd::List<sPkiRootKey> mPkiRootKeyList;
/* Nca External Keys */
fnd::List<sNcaExternalContentKey> mNcaExternalContentKeyList;
template <class T>
bool copyOutKeyResourceIfExists(const T& src, T& dst, const T& null_sample) const
{
bool resource_exists = false;
if (src != null_sample)
{
resource_exists = true;
dst = src;
}
return resource_exists;
}
#pragma once
#include <string>
#include <cstring>
#include <fnd/types.h>
#include <fnd/aes.h>
#include <fnd/rsa.h>
#include <fnd/ecdsa.h>
#include <nn/hac/define/nca.h>
#include <nn/pki/SignedData.h>
#include <nn/es/TicketBody_V2.h>
class KeyConfiguration
{
public:
KeyConfiguration();
KeyConfiguration(const KeyConfiguration& other);
void operator=(const KeyConfiguration& other);
void importHactoolGenericKeyfile(const std::string& path);
//void importHactoolTitleKeyfile(const std::string& path);
void clearGeneralKeyConfiguration();
void clearNcaExternalKeys();
// nca keys
bool getContentArchiveHeaderKey(fnd::aes::sAesXts128Key& key) const;
bool getContentArchiveHeader0SignKey(fnd::rsa::sRsa2048Key& key) const;
bool getAcidSignKey(fnd::rsa::sRsa2048Key& key) const;
bool getNcaKeyAreaEncryptionKey(byte_t masterkey_index, byte_t keak_type, fnd::aes::sAes128Key& key) const;
bool getNcaKeyAreaEncryptionKeyHw(byte_t masterkey_index, byte_t keak_type, fnd::aes::sAes128Key& key) const;
// external content keys
void addNcaExternalContentKey(const byte_t rights_id[nn::hac::nca::kRightsIdLen], const fnd::aes::sAes128Key& key);
bool getNcaExternalContentKey(const byte_t rights_id[nn::hac::nca::kRightsIdLen], fnd::aes::sAes128Key& key) const;
// pkg1/pkg2
bool getPkg1Key(byte_t masterkey_index, fnd::aes::sAes128Key& key) const;
bool getPkg2Key(byte_t masterkey_index, fnd::aes::sAes128Key& key) const;
bool getPkg2SignKey(fnd::rsa::sRsa2048Key& key) const;
// xci keys
bool getXciHeaderSignKey(fnd::rsa::sRsa2048Key& key) const;
bool getXciHeaderKey(fnd::aes::sAes128Key& key) const;
// ticket
bool getETicketCommonKey(byte_t masterkey_index, fnd::aes::sAes128Key& key) const;
// pki
bool getPkiRootSignKey(const std::string& root_name, fnd::rsa::sRsa4096Key& key) const;
bool getPkiRootSignKey(const std::string& root_name, fnd::rsa::sRsa2048Key& key) const;
bool getPkiRootSignKey(const std::string& root_name, fnd::ecdsa::sEcdsa240Key& key) const;
private:
const std::string kModuleName = "KeyConfiguration";
const fnd::aes::sAes128Key kNullAesKey = {{0}};
const fnd::aes::sAesXts128Key kNullAesXtsKey = {{{0}}};
const fnd::rsa::sRsa4096Key kNullRsa4096Key = {{0}, {0}, {0}};
const fnd::rsa::sRsa2048Key kNullRsa2048Key = {{0}, {0}, {0}};
static const size_t kMasterKeyNum = 0x20;
static const size_t kNcaKeakNum = nn::hac::nca::kKeyAreaEncryptionKeyNum;
// keynames
enum NameVariantIndex
{
NNTOOLS,
LEGACY_HACTOOL,
LEGACY_0
};
static const size_t kNameVariantNum = 3;
const std::string kMasterBase[kNameVariantNum] = { "master", "master", "master" };
const std::string kPkg1Base[kNameVariantNum] = { "package1", "package1", "package1" };
const std::string kPkg2Base[kNameVariantNum] = { "package2", "package2", "package2" };
const std::string kXciHeaderBase[kNameVariantNum] = { "xci_header", "xci_header", "xci_header" };
const std::string kContentArchiveHeaderBase[kNameVariantNum] = { "nca_header", "header", "nca_header" };
const std::string kAcidBase[kNameVariantNum] = { "acid", "acid", "acid" };
const std::string kPkiRootBase[kNameVariantNum] = { "pki_root", "pki_root", "pki_root" };
const std::string kTicketCommonKeyBase[kNameVariantNum] = { "ticket_commonkey", "titlekek", "ticket_commonkey" };
const std::string kNcaKeyAreaEncKeyBase[kNameVariantNum] = { "nca_key_area_key", "key_area_key", "nca_body_keak" };
const std::string kNcaKeyAreaEncKeyHwBase[kNameVariantNum] = { "nca_key_area_key_hw", "key_area_hw_key", "nca_key_area_key_hw" };
const std::string kKekGenBase[kNameVariantNum] = { "aes_kek_generation", "aes_kek_generation", "aes_kek_generation" };
const std::string kKeyGenBase[kNameVariantNum] = { "aes_key_generation", "aes_key_generation", "aes_key_generation" };
// misc str
const std::string kKeyStr = "key";
const std::string kKekStr = "kek";
const std::string kSourceStr = "source";
const std::string kRsaKeyModulus = "sign_key_modulus";
const std::string kRsaKeyPrivate = "sign_key_private";
const std::string kNcaKeyAreaKeyIndexStr[kNcaKeakNum] = { "application", "ocean", "system" };
const std::string kKeyIndex[kMasterKeyNum] = {"00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f"};
struct sRightsId
{
byte_t data[nn::hac::nca::kRightsIdLen];
void operator=(const sRightsId& other)
{
memcpy(this->data, other.data, nn::hac::nca::kRightsIdLen);
}
bool operator==(const sRightsId& other) const
{
return memcmp(this->data, other.data, nn::hac::nca::kRightsIdLen) == 0;
}
bool operator!=(const sRightsId& other) const
{
return !(operator==(other));
}
};
struct sNcaExternalContentKey
{
sRightsId rights_id;
fnd::aes::sAes128Key key;
void operator=(const sNcaExternalContentKey& other)
{
rights_id = other.rights_id;
key = other.key;
}
bool operator==(const sNcaExternalContentKey& other) const
{
return (rights_id == other.rights_id) \
&& (key == other.key);
}
bool operator!=(const sNcaExternalContentKey& other) const
{
return !(operator==(other));
}
};
struct sPkiRootKey
{
std::string name;
nn::pki::sign::SignatureAlgo key_type;
fnd::rsa::sRsa4096Key rsa4096_key;
fnd::rsa::sRsa2048Key rsa2048_key;
fnd::ecdsa::sEcdsa240Key ecdsa240_key;
void operator=(const sPkiRootKey& other)
{
name = other.name;
key_type = other.key_type;
rsa4096_key = other.rsa4096_key;
rsa2048_key = other.rsa2048_key;
ecdsa240_key = other.ecdsa240_key;
}
bool operator==(const sPkiRootKey& other) const
{
return (name == other.name) \
&& (key_type == other.key_type) \
&& (rsa4096_key == other.rsa4096_key) \
&& (rsa2048_key == other.rsa2048_key) \
&& (ecdsa240_key == other.ecdsa240_key);
}
bool operator!=(const sPkiRootKey& other) const
{
return !(operator==(other));
}
};
/* general key config */
// acid
fnd::rsa::sRsa2048Key mAcidSignKey;
// pkg1 and pkg2
fnd::aes::sAes128Key mPkg1Key[kMasterKeyNum];
fnd::rsa::sRsa2048Key mPkg2SignKey;
fnd::aes::sAes128Key mPkg2Key[kMasterKeyNum];
// nca
fnd::rsa::sRsa2048Key mContentArchiveHeader0SignKey;
fnd::aes::sAesXts128Key mContentArchiveHeaderKey;
fnd::aes::sAes128Key mNcaKeyAreaEncryptionKey[kNcaKeakNum][kMasterKeyNum];
fnd::aes::sAes128Key mNcaKeyAreaEncryptionKeyHw[kNcaKeakNum][kMasterKeyNum];
// xci
fnd::rsa::sRsa2048Key mXciHeaderSignKey;
fnd::aes::sAes128Key mXciHeaderKey;
// ticket
fnd::aes::sAes128Key mETicketCommonKey[kMasterKeyNum];
// pki
fnd::List<sPkiRootKey> mPkiRootKeyList;
/* Nca External Keys */
fnd::List<sNcaExternalContentKey> mNcaExternalContentKeyList;
template <class T>
bool copyOutKeyResourceIfExists(const T& src, T& dst, const T& null_sample) const
{
bool resource_exists = false;
if (src != null_sample)
{
resource_exists = true;
dst = src;
}
return resource_exists;
}
};

File diff suppressed because it is too large Load diff

View file

@ -1,56 +1,56 @@
#pragma once
#include <string>
#include <fnd/types.h>
#include <fnd/IFile.h>
#include <fnd/SharedPtr.h>
#include <nn/hac/MetaBinary.h>
#include "KeyConfiguration.h"
#include "common.h"
class MetaProcess
{
public:
MetaProcess();
void process();
void setInputFile(const fnd::SharedPtr<fnd::IFile>& file);
void setKeyCfg(const KeyConfiguration& keycfg);
void setCliOutputMode(CliOutputMode type);
void setVerifyMode(bool verify);
const nn::hac::MetaBinary& getMetaBinary() const;
private:
const std::string kModuleName = "MetaProcess";
fnd::SharedPtr<fnd::IFile> mFile;
KeyConfiguration mKeyCfg;
CliOutputMode mCliOutputMode;
bool mVerify;
nn::hac::MetaBinary mMeta;
void importMeta();
void validateAcidSignature(const nn::hac::AccessControlInfoDescBinary& acid);
void validateAciFromAcid(const nn::hac::AccessControlInfoBinary& aci, const nn::hac::AccessControlInfoDescBinary& acid);
void displayMetaHeader(const nn::hac::MetaBinary& hdr);
void displayAciHdr(const nn::hac::AccessControlInfoBinary& aci);
void displayAciDescHdr(const nn::hac::AccessControlInfoDescBinary& aci);
void displayFac(const nn::hac::FileSystemAccessControlBinary& fac);
void displaySac(const nn::hac::ServiceAccessControlBinary& sac);
void displayKernelCap(const nn::hac::KernelCapabilityBinary& kern);
const char* getInstructionTypeStr(nn::hac::meta::InstructionType type) const;
const char* getProcAddressSpaceTypeStr(nn::hac::meta::ProcAddrSpaceType type) const;
const char* getAcidFlagStr(nn::hac::aci::Flag flag) const;
const char* getMiscFlagStr(nn::hac::MiscFlagsHandler::Flags flag) const;
const char* getFsaRightStr(nn::hac::fac::FsAccessFlag flag) const;
const char* getSaveDataOwnerAccessModeStr(nn::hac::fac::SaveDataOwnerIdAccessType type) const;
const char* getSystemCallStr(byte_t syscall_id) const;
const char* getMemMapPermStr(nn::hac::MemoryMappingHandler::MemoryPerm type) const;
const char* getMemMapTypeStr(nn::hac::MemoryMappingHandler::MappingType type) const;
#pragma once
#include <string>
#include <fnd/types.h>
#include <fnd/IFile.h>
#include <fnd/SharedPtr.h>
#include <nn/hac/Meta.h>
#include "KeyConfiguration.h"
#include "common.h"
class MetaProcess
{
public:
MetaProcess();
void process();
void setInputFile(const fnd::SharedPtr<fnd::IFile>& file);
void setKeyCfg(const KeyConfiguration& keycfg);
void setCliOutputMode(CliOutputMode type);
void setVerifyMode(bool verify);
const nn::hac::Meta& getMeta() const;
private:
const std::string kModuleName = "MetaProcess";
fnd::SharedPtr<fnd::IFile> mFile;
KeyConfiguration mKeyCfg;
CliOutputMode mCliOutputMode;
bool mVerify;
nn::hac::Meta mMeta;
void importMeta();
void validateAcidSignature(const nn::hac::AccessControlInfoDesc& acid);
void validateAciFromAcid(const nn::hac::AccessControlInfo& aci, const nn::hac::AccessControlInfoDesc& acid);
void displayMetaHeader(const nn::hac::Meta& hdr);
void displayAciHdr(const nn::hac::AccessControlInfo& aci);
void displayAciDescHdr(const nn::hac::AccessControlInfoDesc& aci);
void displayFac(const nn::hac::FileSystemAccessControl& fac);
void displaySac(const nn::hac::ServiceAccessControl& sac);
void displayKernelCap(const nn::hac::KernelCapabilityControl& kern);
const char* getInstructionTypeStr(nn::hac::meta::InstructionType type) const;
const char* getProcAddressSpaceTypeStr(nn::hac::meta::ProcAddrSpaceType type) const;
const char* getAcidFlagStr(nn::hac::aci::Flag flag) const;
const char* getMiscFlagStr(nn::hac::MiscFlagsHandler::Flags flag) const;
const char* getFsaRightStr(nn::hac::fac::FsAccessFlag flag) const;
const char* getSaveDataOwnerAccessModeStr(nn::hac::fac::SaveDataOwnerIdAccessType type) const;
const char* getSystemCallStr(byte_t syscall_id) const;
const char* getMemMapPermStr(nn::hac::MemoryMappingHandler::MemoryPerm type) const;
const char* getMemMapTypeStr(nn::hac::MemoryMappingHandler::MappingType type) const;
};

File diff suppressed because it is too large Load diff

View file

@ -1,53 +1,53 @@
#pragma once
#include <string>
#include <fnd/types.h>
#include <fnd/IFile.h>
#include <fnd/SharedPtr.h>
#include <nn/hac/ApplicationControlPropertyBinary.h>
#include "common.h"
class NacpProcess
{
public:
NacpProcess();
void process();
void setInputFile(const fnd::SharedPtr<fnd::IFile>& file);
void setCliOutputMode(CliOutputMode type);
void setVerifyMode(bool verify);
const nn::hac::ApplicationControlPropertyBinary& getApplicationControlPropertyBinary() const;
private:
const std::string kModuleName = "NacpProcess";
fnd::SharedPtr<fnd::IFile> mFile;
CliOutputMode mCliOutputMode;
bool mVerify;
nn::hac::ApplicationControlPropertyBinary mNacp;
void importNacp();
void displayNacp();
const char* getLanguageStr(nn::hac::nacp::Language var) const;
const char* getStartupUserAccountStr(nn::hac::nacp::StartupUserAccount var) const;
const char* getTouchScreenUsageModeStr(nn::hac::nacp::TouchScreenUsageMode var) const;
const char* getAocRegistrationTypeStr(nn::hac::nacp::AocRegistrationType var) const;
const char* getAttributeFlagStr(nn::hac::nacp::AttributeFlag var) const;
const char* getParentalControlFlagStr(nn::hac::nacp::ParentalControlFlag var) const;
const char* getScreenshotModeStr(nn::hac::nacp::ScreenshotMode var) const;
const char* getVideoCaptureModeStr(nn::hac::nacp::VideoCaptureMode var) const;
const char* getDataLossConfirmationStr(nn::hac::nacp::DataLossConfirmation var) const;
const char* getPlayLogPolicyStr(nn::hac::nacp::PlayLogPolicy var) const;
const char* getOrganisationStr(nn::hac::nacp::Organisation var) const;
const char* getLogoTypeStr(nn::hac::nacp::LogoType var) const;
const char* getLogoHandlingStr(nn::hac::nacp::LogoHandling var) const;
const char* getRuntimeAocInstallModeStr(nn::hac::nacp::RuntimeAocInstallMode var) const;
const char* getCrashReportModeStr(nn::hac::nacp::CrashReportMode var) const;
const char* getHdcpStr(nn::hac::nacp::Hdcp var) const;
const char* getPlayLogQueryCapabilityStr(nn::hac::nacp::PlayLogQueryCapability var) const;
const char* getRepairFlagStr(nn::hac::nacp::RepairFlag var) const;
std::string getSaveDataSizeStr(int64_t size) const;
#pragma once
#include <string>
#include <fnd/types.h>
#include <fnd/IFile.h>
#include <fnd/SharedPtr.h>
#include <nn/hac/ApplicationControlProperty.h>
#include "common.h"
class NacpProcess
{
public:
NacpProcess();
void process();
void setInputFile(const fnd::SharedPtr<fnd::IFile>& file);
void setCliOutputMode(CliOutputMode type);
void setVerifyMode(bool verify);
const nn::hac::ApplicationControlProperty& getApplicationControlProperty() const;
private:
const std::string kModuleName = "NacpProcess";
fnd::SharedPtr<fnd::IFile> mFile;
CliOutputMode mCliOutputMode;
bool mVerify;
nn::hac::ApplicationControlProperty mNacp;
void importNacp();
void displayNacp();
const char* getLanguageStr(nn::hac::nacp::Language var) const;
const char* getStartupUserAccountStr(nn::hac::nacp::StartupUserAccount var) const;
const char* getTouchScreenUsageModeStr(nn::hac::nacp::TouchScreenUsageMode var) const;
const char* getAocRegistrationTypeStr(nn::hac::nacp::AocRegistrationType var) const;
const char* getAttributeFlagStr(nn::hac::nacp::AttributeFlag var) const;
const char* getParentalControlFlagStr(nn::hac::nacp::ParentalControlFlag var) const;
const char* getScreenshotModeStr(nn::hac::nacp::ScreenshotMode var) const;
const char* getVideoCaptureModeStr(nn::hac::nacp::VideoCaptureMode var) const;
const char* getDataLossConfirmationStr(nn::hac::nacp::DataLossConfirmation var) const;
const char* getPlayLogPolicyStr(nn::hac::nacp::PlayLogPolicy var) const;
const char* getOrganisationStr(nn::hac::nacp::Organisation var) const;
const char* getLogoTypeStr(nn::hac::nacp::LogoType var) const;
const char* getLogoHandlingStr(nn::hac::nacp::LogoHandling var) const;
const char* getRuntimeAocInstallModeStr(nn::hac::nacp::RuntimeAocInstallMode var) const;
const char* getCrashReportModeStr(nn::hac::nacp::CrashReportMode var) const;
const char* getHdcpStr(nn::hac::nacp::Hdcp var) const;
const char* getPlayLogQueryCapabilityStr(nn::hac::nacp::PlayLogQueryCapability var) const;
const char* getRepairFlagStr(nn::hac::nacp::RepairFlag var) const;
std::string getSaveDataSizeStr(int64_t size) const;
};

File diff suppressed because it is too large Load diff

View file

@ -1,123 +1,123 @@
#pragma once
#include <string>
#include <fnd/types.h>
#include <fnd/IFile.h>
#include <fnd/SharedPtr.h>
#include <fnd/LayeredIntegrityMetadata.h>
#include <nn/hac/NcaHeader.h>
#include "KeyConfiguration.h"
#include "common.h"
class NcaProcess
{
public:
NcaProcess();
void process();
// generic
void setInputFile(const fnd::SharedPtr<fnd::IFile>& file);
void setKeyCfg(const KeyConfiguration& keycfg);
void setCliOutputMode(CliOutputMode type);
void setVerifyMode(bool verify);
// nca specfic
void setPartition0ExtractPath(const std::string& path);
void setPartition1ExtractPath(const std::string& path);
void setPartition2ExtractPath(const std::string& path);
void setPartition3ExtractPath(const std::string& path);
void setListFs(bool list_fs);
private:
const std::string kModuleName = "NcaProcess";
const std::string kNpdmExefsPath = "main.npdm";
// user options
fnd::SharedPtr<fnd::IFile> mFile;
KeyConfiguration mKeyCfg;
CliOutputMode mCliOutputMode;
bool mVerify;
struct sExtract
{
std::string path;
bool doExtract;
} mPartitionPath[nn::hac::nca::kPartitionNum];
bool mListFs;
// data
nn::hac::sNcaHeaderBlock mHdrBlock;
fnd::sha::sSha256Hash mHdrHash;
nn::hac::NcaHeader mHdr;
// crypto
struct sKeys
{
struct sKeyAreaKey
{
byte_t index;
bool decrypted;
fnd::aes::sAes128Key enc;
fnd::aes::sAes128Key dec;
void operator=(const sKeyAreaKey& other)
{
index = other.index;
decrypted = other.decrypted;
enc = other.enc;
dec = other.dec;
}
bool operator==(const sKeyAreaKey& other) const
{
return (index == other.index) \
&& (decrypted == other.decrypted) \
&& (enc == other.enc) \
&& (dec == other.dec);
}
bool operator!=(const sKeyAreaKey& other) const
{
return !(*this == other);
}
};
fnd::List<sKeyAreaKey> kak_list;
sOptional<fnd::aes::sAes128Key> aes_ctr;
} mContentKey;
struct sPartitionInfo
{
fnd::SharedPtr<fnd::IFile> reader;
std::string fail_reason;
size_t offset;
size_t size;
// meta data
nn::hac::nca::FormatType format_type;
nn::hac::nca::HashType hash_type;
nn::hac::nca::EncryptionType enc_type;
fnd::LayeredIntegrityMetadata layered_intergrity_metadata;
fnd::aes::sAesIvCtr aes_ctr;
} mPartitions[nn::hac::nca::kPartitionNum];
void importHeader();
void generateNcaBodyEncryptionKeys();
void generatePartitionConfiguration();
void validateNcaSignatures();
void displayHeader();
void processPartitions();
const char* getFormatVersionStr(nn::hac::NcaHeader::FormatVersion format_ver) const;
const char* getDistributionTypeStr(nn::hac::nca::DistributionType dist_type) const;
const char* getContentTypeStr(nn::hac::nca::ContentType cont_type) const;
const char* getEncryptionTypeStr(nn::hac::nca::EncryptionType enc_type) const;
const char* getHashTypeStr(nn::hac::nca::HashType hash_type) const;
const char* getFormatTypeStr(nn::hac::nca::FormatType format_type) const;
const char* getKaekIndexStr(nn::hac::nca::KeyAreaEncryptionKeyIndex keak_index) const;
const char* getContentTypeForMountStr(nn::hac::nca::ContentType cont_type) const;
const char* getProgramPartitionNameStr(size_t i) const;
#pragma once
#include <string>
#include <fnd/types.h>
#include <fnd/IFile.h>
#include <fnd/SharedPtr.h>
#include <fnd/LayeredIntegrityMetadata.h>
#include <nn/hac/ContentArchiveHeader.h>
#include "KeyConfiguration.h"
#include "common.h"
class NcaProcess
{
public:
NcaProcess();
void process();
// generic
void setInputFile(const fnd::SharedPtr<fnd::IFile>& file);
void setKeyCfg(const KeyConfiguration& keycfg);
void setCliOutputMode(CliOutputMode type);
void setVerifyMode(bool verify);
// nca specfic
void setPartition0ExtractPath(const std::string& path);
void setPartition1ExtractPath(const std::string& path);
void setPartition2ExtractPath(const std::string& path);
void setPartition3ExtractPath(const std::string& path);
void setListFs(bool list_fs);
private:
const std::string kModuleName = "NcaProcess";
const std::string kNpdmExefsPath = "main.npdm";
// user options
fnd::SharedPtr<fnd::IFile> mFile;
KeyConfiguration mKeyCfg;
CliOutputMode mCliOutputMode;
bool mVerify;
struct sExtract
{
std::string path;
bool doExtract;
} mPartitionPath[nn::hac::nca::kPartitionNum];
bool mListFs;
// data
nn::hac::sContentArchiveHeaderBlock mHdrBlock;
fnd::sha::sSha256Hash mHdrHash;
nn::hac::ContentArchiveHeader mHdr;
// crypto
struct sKeys
{
struct sKeyAreaKey
{
byte_t index;
bool decrypted;
fnd::aes::sAes128Key enc;
fnd::aes::sAes128Key dec;
void operator=(const sKeyAreaKey& other)
{
index = other.index;
decrypted = other.decrypted;
enc = other.enc;
dec = other.dec;
}
bool operator==(const sKeyAreaKey& other) const
{
return (index == other.index) \
&& (decrypted == other.decrypted) \
&& (enc == other.enc) \
&& (dec == other.dec);
}
bool operator!=(const sKeyAreaKey& other) const
{
return !(*this == other);
}
};
fnd::List<sKeyAreaKey> kak_list;
sOptional<fnd::aes::sAes128Key> aes_ctr;
} mContentKey;
struct sPartitionInfo
{
fnd::SharedPtr<fnd::IFile> reader;
std::string fail_reason;
size_t offset;
size_t size;
// meta data
nn::hac::nca::FormatType format_type;
nn::hac::nca::HashType hash_type;
nn::hac::nca::EncryptionType enc_type;
fnd::LayeredIntegrityMetadata layered_intergrity_metadata;
fnd::aes::sAesIvCtr aes_ctr;
} mPartitions[nn::hac::nca::kPartitionNum];
void importHeader();
void generateNcaBodyEncryptionKeys();
void generatePartitionConfiguration();
void validateNcaSignatures();
void displayHeader();
void processPartitions();
const char* getFormatVersionStr(byte_t format_ver) const;
const char* getDistributionTypeStr(nn::hac::nca::DistributionType dist_type) const;
const char* getContentTypeStr(nn::hac::nca::ContentType cont_type) const;
const char* getEncryptionTypeStr(nn::hac::nca::EncryptionType enc_type) const;
const char* getHashTypeStr(nn::hac::nca::HashType hash_type) const;
const char* getFormatTypeStr(nn::hac::nca::FormatType format_type) const;
const char* getKaekIndexStr(nn::hac::nca::KeyAreaEncryptionKeyIndex keak_index) const;
const char* getContentTypeForMountStr(nn::hac::nca::ContentType cont_type) const;
const char* getProgramPartitionNameStr(size_t i) const;
};

Some files were not shown because too many files have changed in this diff Show more