mirror of
https://github.com/jakcron/nstool.git
synced 2026-05-09 18:53:16 +00:00
Misc.
This commit is contained in:
parent
687185ee14
commit
34d9dea9fc
248
NNTools.sln
248
NNTools.sln
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,58 +1,58 @@
|
|||
#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;
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <nn/es/ticket.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace es
|
||||
{
|
||||
class SectionHeader_V2 :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
SectionHeader_V2();
|
||||
SectionHeader_V2(const SectionHeader_V2& other);
|
||||
|
||||
void operator=(const SectionHeader_V2& other);
|
||||
bool operator==(const SectionHeader_V2& other) const;
|
||||
bool operator!=(const SectionHeader_V2& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* data, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
virtual void clear();
|
||||
|
||||
uint32_t getSectionOffset() const;
|
||||
void setSectionOffset(uint32_t offset);
|
||||
|
||||
uint32_t getRecordSize() const;
|
||||
void setRecordSize(uint32_t size);
|
||||
|
||||
uint32_t getSectionSize() const;
|
||||
void getSectionSize(uint32_t size);
|
||||
|
||||
uint16_t getRecordNum() const;
|
||||
void setRecordNum(uint16_t record_num);
|
||||
|
||||
ticket::SectionType getSectionType() const;
|
||||
void setSectionType(ticket::SectionType type);
|
||||
|
||||
private:
|
||||
const std::string kModuleName = "SECTION_HEADER_V2";
|
||||
|
||||
// raw binary
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// variables
|
||||
uint32_t mSectionOffset;
|
||||
uint32_t mRecordSize;
|
||||
uint32_t mSectionSize;
|
||||
uint16_t mRecordNum;
|
||||
ticket::SectionType mSectionType;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,103 +1,103 @@
|
|||
#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;
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <fnd/List.h>
|
||||
#include <nn/es/ticket.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace es
|
||||
{
|
||||
class TicketBody_V2 :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
TicketBody_V2();
|
||||
TicketBody_V2(const TicketBody_V2& other);
|
||||
|
||||
void operator=(const TicketBody_V2& other);
|
||||
bool operator==(const TicketBody_V2& other) const;
|
||||
bool operator!=(const TicketBody_V2& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* bytes, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
const std::string& getIssuer() const;
|
||||
void setIssuer(const std::string& issuer);
|
||||
|
||||
const byte_t* getEncTitleKey() const;
|
||||
void setEncTitleKey(const byte_t* data, size_t len);
|
||||
|
||||
ticket::TitleKeyEncType getTitleKeyEncType() const;
|
||||
void setTitleKeyEncType(ticket::TitleKeyEncType type);
|
||||
|
||||
uint16_t getTicketVersion() const;
|
||||
void setTicketVersion(uint16_t version);
|
||||
|
||||
ticket::LicenseType getLicenseType() const;
|
||||
void setLicenseType(ticket::LicenseType type);
|
||||
|
||||
byte_t getCommonKeyId() const;
|
||||
void setCommonKeyId(byte_t id);
|
||||
|
||||
const fnd::List<es::ticket::PropertyMaskFlags>& getPropertyFlags() const;
|
||||
void setPropertyFlags(const fnd::List<es::ticket::PropertyMaskFlags>& flags);
|
||||
|
||||
const byte_t* getReservedRegion() const;
|
||||
void setReservedRegion(const byte_t* data, size_t len);
|
||||
|
||||
uint64_t getTicketId() const;
|
||||
void setTicketId(uint64_t id);
|
||||
|
||||
uint64_t getDeviceId() const;
|
||||
void setDeviceId(uint64_t id);
|
||||
|
||||
const byte_t* getRightsId() const;
|
||||
void setRightsId(const byte_t* id);
|
||||
|
||||
uint32_t getAccountId() const;
|
||||
void setAccountId(uint32_t id);
|
||||
|
||||
uint32_t getSectionTotalSize() const;
|
||||
void setSectionTotalSize(uint32_t size);
|
||||
|
||||
uint32_t getSectionHeaderOffset() const;
|
||||
void setSectionHeaderOffset(uint32_t offset);
|
||||
|
||||
uint16_t getSectionNum() const;
|
||||
void setSectionNum(uint16_t num);
|
||||
|
||||
uint16_t getSectionEntrySize() const;
|
||||
void setSectionEntrySize(uint16_t size);
|
||||
|
||||
private:
|
||||
const std::string kModuleName = "TICKET_BODY_V2";
|
||||
|
||||
// raw binary
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// variables
|
||||
std::string mIssuer;
|
||||
byte_t mEncTitleKey[ticket::kEncTitleKeySize];
|
||||
ticket::TitleKeyEncType mEncType;
|
||||
uint16_t mTicketVersion;
|
||||
ticket::LicenseType mLicenseType;
|
||||
byte_t mCommonKeyId;
|
||||
fnd::List<es::ticket::PropertyMaskFlags> mPropertyFlags;
|
||||
byte_t mReservedRegion[ticket::kReservedRegionSize]; // explicitly reserved
|
||||
uint64_t mTicketId;
|
||||
uint64_t mDeviceId;
|
||||
byte_t mRightsId[ticket::kRightsIdSize];
|
||||
uint32_t mAccountId;
|
||||
uint32_t mSectTotalSize;
|
||||
uint32_t mSectHeaderOffset;
|
||||
uint16_t mSectNum;
|
||||
uint16_t mSectEntrySize;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,72 +1,72 @@
|
|||
#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;
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include <nn/hac/define/aset.h>
|
||||
#include <fnd/List.h>
|
||||
#include <fnd/IByteModel.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class AssetHeader :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
struct sSection
|
||||
{
|
||||
uint64_t offset;
|
||||
uint64_t size;
|
||||
|
||||
void operator=(const sSection& other)
|
||||
{
|
||||
offset = other.offset;
|
||||
size = other.size;
|
||||
}
|
||||
|
||||
bool operator==(const sSection& other) const
|
||||
{
|
||||
return (offset == other.offset) \
|
||||
&& (size == other.size);
|
||||
}
|
||||
|
||||
bool operator!=(const sSection& other) const
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
};
|
||||
|
||||
AssetHeader();
|
||||
AssetHeader(const AssetHeader& other);
|
||||
|
||||
void operator=(const AssetHeader& other);
|
||||
bool operator==(const AssetHeader& other) const;
|
||||
bool operator!=(const AssetHeader& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* bytes, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
const sSection& getIconInfo() const;
|
||||
void setIconInfo(const sSection& info);
|
||||
|
||||
const sSection& getNacpInfo() const;
|
||||
void setNacpInfo(const sSection& info);
|
||||
|
||||
const sSection& getRomfsInfo() const;
|
||||
void setRomfsInfo(const sSection& info);
|
||||
private:
|
||||
const std::string kModuleName = "NRO_ASSET_HEADER";
|
||||
|
||||
// binary
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// data
|
||||
sSection mIconInfo;
|
||||
sSection mNacpInfo;
|
||||
sSection mRomfsInfo;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,33 +1,33 @@
|
|||
#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)
|
||||
}
|
||||
#pragma once
|
||||
#include <fnd/types.h>
|
||||
#include <nn/hac/define/macro.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
namespace aset
|
||||
{
|
||||
static const uint32_t kAssetStructMagic = _MAKE_STRUCT_MAGIC_U32("ASET");
|
||||
|
||||
static const uint32_t kDefaultAssetFormatVersion = 0;
|
||||
}
|
||||
|
||||
#pragma pack(push,1)
|
||||
struct sAssetSection
|
||||
{
|
||||
le_uint64_t offset;
|
||||
le_uint64_t size;
|
||||
};
|
||||
|
||||
struct sAssetHeader
|
||||
{
|
||||
le_uint32_t st_magic;
|
||||
le_uint32_t format_version;
|
||||
sAssetSection icon;
|
||||
sAssetSection nacp;
|
||||
sAssetSection romfs;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
#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");
|
||||
}
|
||||
}
|
||||
#pragma once
|
||||
#include <nn/hac/define/nro.h>
|
||||
#include <nn/hac/define/macro.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
namespace nro
|
||||
{
|
||||
static const uint64_t kNroHomebrewStructMagic = _MAKE_STRUCT_MAGIC_U64("HOMEBREW");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,134 +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\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>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}</ProjectGuid>
|
||||
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>..\libfnd\include;..\libhac\include;..\libhac-hb\include;</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>..\libfnd\include;..\libhac\include;..\libhac-hb\include;</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>..\libfnd\include;..\libhac\include;..\libhac-hb\include;</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>..\libfnd\include;..\libhac\include;..\libhac-hb\include;</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\nn\hac\AssetHeader.h" />
|
||||
<ClInclude Include="include\nn\hac\define\aset.h" />
|
||||
<ClInclude Include="include\nn\hac\define\nro-hb.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="source\AssetHeader.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="makefile" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
|
|
@ -1,39 +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>
|
||||
<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>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\define">
|
||||
<UniqueIdentifier>{33064298-d382-4e79-9fcd-bc401bdaa763}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\nn\hac\AssetHeader.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\nn\hac\define\aset.h">
|
||||
<Filter>Header Files\define</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\nn\hac\define\nro-hb.h">
|
||||
<Filter>Header Files\define</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="source\AssetHeader.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="makefile" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -1,57 +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;
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <fnd/types.h>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <nn/hac/define/aci.h>
|
||||
#include <nn/hac/FileSystemAccessControl.h>
|
||||
#include <nn/hac/ServiceAccessControl.h>
|
||||
#include <nn/hac/KernelCapabilityControl.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class AccessControlInfo :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
AccessControlInfo();
|
||||
AccessControlInfo(const AccessControlInfo& other);
|
||||
|
||||
void operator=(const AccessControlInfo& other);
|
||||
bool operator==(const AccessControlInfo& other) const;
|
||||
bool operator!=(const AccessControlInfo& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* data, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
uint64_t getProgramId() const;
|
||||
void setProgramId(uint64_t program_id);
|
||||
|
||||
const nn::hac::FileSystemAccessControl& getFileSystemAccessControl() const;
|
||||
void setFileSystemAccessControl(const FileSystemAccessControl& fac);
|
||||
|
||||
const nn::hac::ServiceAccessControl& getServiceAccessControl() const;
|
||||
void setServiceAccessControl(const ServiceAccessControl& sac);
|
||||
|
||||
const nn::hac::KernelCapabilityControl& getKernelCapabilities() const;
|
||||
void setKernelCapabilities(const KernelCapabilityControl& kc);
|
||||
private:
|
||||
const std::string kModuleName = "ACCESS_CONTROL_INFO_BINARY";
|
||||
|
||||
// raw data
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// variables
|
||||
uint64_t mProgramId;
|
||||
nn::hac::FileSystemAccessControl mFileSystemAccessControl;
|
||||
nn::hac::ServiceAccessControl mServiceAccessControl;
|
||||
nn::hac::KernelCapabilityControl mKernelCapabilities;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,92 +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;
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <fnd/types.h>
|
||||
#include <fnd/List.h>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <nn/hac/define/aci.h>
|
||||
#include <nn/hac/FileSystemAccessControl.h>
|
||||
#include <nn/hac/ServiceAccessControl.h>
|
||||
#include <nn/hac/KernelCapabilityControl.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class AccessControlInfoDesc :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
struct sProgramIdRestrict
|
||||
{
|
||||
uint64_t min;
|
||||
uint64_t max;
|
||||
|
||||
void operator=(const sProgramIdRestrict& other)
|
||||
{
|
||||
min = other.min;
|
||||
max = other.max;
|
||||
}
|
||||
|
||||
bool operator==(const sProgramIdRestrict& other) const
|
||||
{
|
||||
return (min == other.min) \
|
||||
&& (max == other.max);
|
||||
}
|
||||
|
||||
bool operator!=(const sProgramIdRestrict& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
};
|
||||
|
||||
AccessControlInfoDesc();
|
||||
AccessControlInfoDesc(const AccessControlInfoDesc& other);
|
||||
|
||||
void operator=(const AccessControlInfoDesc& other);
|
||||
bool operator==(const AccessControlInfoDesc& other) const;
|
||||
bool operator!=(const AccessControlInfoDesc& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* data, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
void generateSignature(const fnd::rsa::sRsa2048Key& key);
|
||||
void validateSignature(const fnd::rsa::sRsa2048Key& key) const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
const fnd::rsa::sRsa2048Key& getContentArchiveHeaderSignature2Key() const;
|
||||
void setContentArchiveHeaderSignature2Key(const fnd::rsa::sRsa2048Key& key);
|
||||
|
||||
const fnd::List<aci::Flag>& getFlagList() const;
|
||||
void setFlagList(const fnd::List<aci::Flag>& flags);
|
||||
|
||||
const sProgramIdRestrict& getProgramIdRestrict() const;
|
||||
void setProgramIdRestrict(const sProgramIdRestrict& pid_restrict);
|
||||
|
||||
const nn::hac::FileSystemAccessControl& getFileSystemAccessControl() const;
|
||||
void setFileSystemAccessControl(const FileSystemAccessControl& fac);
|
||||
|
||||
const nn::hac::ServiceAccessControl& getServiceAccessControl() const;
|
||||
void setServiceAccessControl(const ServiceAccessControl& sac);
|
||||
|
||||
const nn::hac::KernelCapabilityControl& getKernelCapabilities() const;
|
||||
void setKernelCapabilities(const KernelCapabilityControl& kc);
|
||||
private:
|
||||
const std::string kModuleName = "ACCESS_CONTROL_INFO_DESC_BINARY";
|
||||
|
||||
// raw data
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// variables
|
||||
fnd::rsa::sRsa2048Key mContentArchiveHeaderSignature2Key;
|
||||
fnd::List<aci::Flag> mFlags;
|
||||
sProgramIdRestrict mProgramIdRestrict;
|
||||
nn::hac::FileSystemAccessControl mFileSystemAccessControl;
|
||||
nn::hac::ServiceAccessControl mServiceAccessControl;
|
||||
nn::hac::KernelCapabilityControl mKernelCapabilities;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +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;
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <nn/hac/define/cnmt.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class AddOnContentMetaExtendedHeader :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
AddOnContentMetaExtendedHeader();
|
||||
AddOnContentMetaExtendedHeader(const AddOnContentMetaExtendedHeader& other);
|
||||
|
||||
void operator=(const AddOnContentMetaExtendedHeader& other);
|
||||
bool operator==(const AddOnContentMetaExtendedHeader& other) const;
|
||||
bool operator!=(const AddOnContentMetaExtendedHeader& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* bytes, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
uint64_t getApplicationId() const;
|
||||
void setApplicationId(uint64_t application_id);
|
||||
|
||||
uint32_t getRequiredApplicationVersion() const;
|
||||
void setRequiredApplicationVersion(uint32_t app_ver);
|
||||
private:
|
||||
const std::string kModuleName = "ADD_ON_CONTENT_META_EXTENDED_HEADER";
|
||||
|
||||
// binary blob
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// variables
|
||||
uint64_t mApplicationId;
|
||||
uint32_t mRequiredApplicationVersion;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,269 +1,269 @@
|
|||
#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;
|
||||
};
|
||||
}
|
||||
#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;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
#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);
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include <nn/hac/define/nacp.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class ApplicationControlPropertyUtils
|
||||
{
|
||||
public:
|
||||
static bool validateSaveDataSizeMax(int64_t size, int64_t alignment);
|
||||
static bool validateSaveDataSize(int64_t size);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +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;
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <nn/hac/define/cnmt.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class ApplicationMetaExtendedHeader :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
ApplicationMetaExtendedHeader();
|
||||
ApplicationMetaExtendedHeader(const ApplicationMetaExtendedHeader& other);
|
||||
|
||||
void operator=(const ApplicationMetaExtendedHeader& other);
|
||||
bool operator==(const ApplicationMetaExtendedHeader& other) const;
|
||||
bool operator!=(const ApplicationMetaExtendedHeader& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* bytes, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
uint64_t getPatchId() const;
|
||||
void setPatchId(uint64_t patch_id);
|
||||
|
||||
uint32_t getRequiredSystemVersion() const;
|
||||
void setRequiredSystemVersion(uint32_t sys_ver);
|
||||
private:
|
||||
const std::string kModuleName = "APPLICATION_META_EXTENDED_HEADER";
|
||||
|
||||
// binary blob
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// variables
|
||||
uint64_t mPatchId;
|
||||
uint32_t mRequiredSystemVersion;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,121 +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;
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include <nn/hac/define/nca.h>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <fnd/List.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class ContentArchiveHeader :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
struct sPartitionEntry
|
||||
{
|
||||
byte_t header_index;
|
||||
uint64_t offset;
|
||||
uint64_t size;
|
||||
fnd::sha::sSha256Hash fs_header_hash;
|
||||
|
||||
const sPartitionEntry& operator=(const sPartitionEntry& other)
|
||||
{
|
||||
header_index = other.header_index;
|
||||
offset = other.offset;
|
||||
size = other.size;
|
||||
fs_header_hash = other.fs_header_hash;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(const sPartitionEntry& other) const
|
||||
{
|
||||
return (header_index == other.header_index) \
|
||||
&& (offset == other.offset) \
|
||||
&& (size == other.size) \
|
||||
&& (fs_header_hash == other.fs_header_hash);
|
||||
}
|
||||
|
||||
bool operator!=(const sPartitionEntry& other) const
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
};
|
||||
|
||||
ContentArchiveHeader();
|
||||
ContentArchiveHeader(const ContentArchiveHeader& other);
|
||||
|
||||
void operator=(const ContentArchiveHeader& other);
|
||||
bool operator==(const ContentArchiveHeader& other) const;
|
||||
bool operator!=(const ContentArchiveHeader& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* bytes, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
byte_t getFormatVersion() const;
|
||||
void setFormatVersion(byte_t ver);
|
||||
|
||||
nca::DistributionType getDistributionType() const;
|
||||
void setDistributionType(nca::DistributionType type);
|
||||
|
||||
nca::ContentType getContentType() const;
|
||||
void setContentType(nca::ContentType type);
|
||||
|
||||
byte_t getKeyGeneration() const;
|
||||
void setKeyGeneration(byte_t gen);
|
||||
|
||||
byte_t getKeyAreaEncryptionKeyIndex() const;
|
||||
void setKeyAreaEncryptionKeyIndex(byte_t index);
|
||||
|
||||
uint64_t getContentSize() const;
|
||||
void setContentSize(uint64_t size);
|
||||
|
||||
uint64_t getProgramId() const;
|
||||
void setProgramId(uint64_t program_id);
|
||||
|
||||
uint32_t getContentIndex() const;
|
||||
void setContentIndex(uint32_t index);
|
||||
|
||||
uint32_t getSdkAddonVersion() const;
|
||||
void setSdkAddonVersion(uint32_t version);
|
||||
|
||||
bool hasRightsId() const;
|
||||
const byte_t* getRightsId() const;
|
||||
void setRightsId(const byte_t* rights_id);
|
||||
|
||||
const fnd::List<sPartitionEntry>& getPartitionEntryList() const;
|
||||
void setPartitionEntryList(const fnd::List<sPartitionEntry>& partition_entry_list);
|
||||
|
||||
const byte_t* getKeyArea() const;
|
||||
void setKeyArea(const byte_t* key_area);
|
||||
|
||||
private:
|
||||
const std::string kModuleName = "CONTENT_ARCHIVE_HEADER";
|
||||
|
||||
// binary
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// data
|
||||
byte_t mFormatVersion;
|
||||
nca::DistributionType mDistributionType;
|
||||
nca::ContentType mContentType;
|
||||
byte_t mKeyGeneration;
|
||||
byte_t mKaekIndex;
|
||||
uint64_t mContentSize;
|
||||
uint64_t mProgramId;
|
||||
uint32_t mContentIndex;
|
||||
uint32_t mSdkAddonVersion;
|
||||
fnd::Vec<byte_t> mRightsId;
|
||||
fnd::List<sPartitionEntry> mPartitionEntryList;
|
||||
fnd::Vec<byte_t> mKeyArea;
|
||||
|
||||
uint64_t blockNumToSize(uint32_t block_num) const;
|
||||
uint32_t sizeToBlockNum(uint64_t real_size) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,17 +1,17 @@
|
|||
#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);
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include <nn/hac/define/nca.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class ContentArchiveUtils
|
||||
{
|
||||
public:
|
||||
static inline size_t sectorToOffset(size_t sector_index) { return sector_index * nn::hac::nca::kSectorSize; }
|
||||
static void decryptContentArchiveHeader(const byte_t* src, byte_t* dst, const fnd::aes::sAesXts128Key& key);
|
||||
static byte_t getMasterKeyRevisionFromKeyGeneration(byte_t key_generation);
|
||||
static void getNcaPartitionAesCtr(const nn::hac::sNcaFsHeader* hdr, byte_t* ctr);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,113 +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;
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <fnd/List.h>
|
||||
#include <nn/hac/define/cnmt.h>
|
||||
#include <nn/hac/ContentInfo.h>
|
||||
#include <nn/hac/ContentMetaInfo.h>
|
||||
#include <nn/hac/ApplicationMetaExtendedHeader.h>
|
||||
#include <nn/hac/PatchMetaExtendedHeader.h>
|
||||
#include <nn/hac/AddOnContentMetaExtendedHeader.h>
|
||||
#include <nn/hac/DeltaMetaExtendedHeader.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class ContentMeta :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
ContentMeta();
|
||||
ContentMeta(const ContentMeta& other);
|
||||
|
||||
void operator=(const ContentMeta& other);
|
||||
bool operator==(const ContentMeta& other) const;
|
||||
bool operator!=(const ContentMeta& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* bytes, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
uint64_t getTitleId() const;
|
||||
void setTitleId(uint64_t title_id);
|
||||
|
||||
uint32_t getTitleVersion() const;
|
||||
void setTitleVersion(uint32_t version);
|
||||
|
||||
cnmt::ContentMetaType getContentMetaType() const;
|
||||
void setContentMetaType(cnmt::ContentMetaType type);
|
||||
|
||||
byte_t getAttributes() const;
|
||||
void setAttributes(byte_t attributes);
|
||||
|
||||
uint32_t getRequiredDownloadSystemVersion() const;
|
||||
void setRequiredDownloadSystemVersion(uint32_t version);
|
||||
|
||||
const ApplicationMetaExtendedHeader& getApplicationMetaExtendedHeader() const;
|
||||
void setApplicationMetaExtendedHeader(const ApplicationMetaExtendedHeader& exhdr);
|
||||
|
||||
const PatchMetaExtendedHeader& getPatchMetaExtendedHeader() const;
|
||||
void setPatchMetaExtendedHeader(const PatchMetaExtendedHeader& exhdr);
|
||||
|
||||
const AddOnContentMetaExtendedHeader& getAddOnContentMetaExtendedHeader() const;
|
||||
void setAddOnContentMetaExtendedHeader(const AddOnContentMetaExtendedHeader& exhdr);
|
||||
|
||||
const DeltaMetaExtendedHeader& getDeltaMetaExtendedHeader() const;
|
||||
void setDeltaMetaExtendedHeader(const DeltaMetaExtendedHeader& exhdr);
|
||||
|
||||
const fnd::List<ContentInfo>& getContentInfo() const;
|
||||
void setContentInfo(const fnd::List<ContentInfo>& info);
|
||||
|
||||
const fnd::List<ContentMetaInfo>& getContentMetaInfo() const;
|
||||
void setContentMetaInfo(const fnd::List<ContentMetaInfo>& info);
|
||||
|
||||
const fnd::Vec<byte_t>& getExtendedData() const;
|
||||
void setExtendedData(const fnd::Vec<byte_t>& data);
|
||||
|
||||
const cnmt::sDigest& getDigest() const;
|
||||
void setDigest(const cnmt::sDigest& digest);
|
||||
|
||||
|
||||
private:
|
||||
const std::string kModuleName = "CONTENT_META";
|
||||
|
||||
// binary blob
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// variables
|
||||
uint64_t mTitleId;
|
||||
uint32_t mTitleVersion;
|
||||
cnmt::ContentMetaType mType;
|
||||
byte_t mAttributes;
|
||||
uint32_t mRequiredDownloadSystemVersion;
|
||||
fnd::Vec<byte_t> mExtendedHeader;
|
||||
|
||||
ApplicationMetaExtendedHeader mApplicationMetaExtendedHeader;
|
||||
PatchMetaExtendedHeader mPatchMetaExtendedHeader;
|
||||
AddOnContentMetaExtendedHeader mAddOnContentMetaExtendedHeader;
|
||||
DeltaMetaExtendedHeader mDeltaMetaExtendedHeader;
|
||||
|
||||
fnd::List<ContentInfo> mContentInfo;
|
||||
fnd::List<ContentMetaInfo> mContentMetaInfo;
|
||||
fnd::Vec<byte_t> mExtendedData;
|
||||
cnmt::sDigest mDigest;
|
||||
|
||||
inline size_t getExtendedHeaderOffset() const { return sizeof(sContentMetaHeader); }
|
||||
inline size_t getContentInfoOffset(size_t exhdrSize) const { return getExtendedHeaderOffset() + exhdrSize; }
|
||||
inline size_t getContentMetaInfoOffset(size_t exhdrSize, size_t contentInfoNum) const { return getContentInfoOffset(exhdrSize) + contentInfoNum * sizeof(sContentInfo); }
|
||||
inline size_t getExtendedDataOffset(size_t exhdrSize, size_t contentInfoNum, size_t contentMetaNum) const { return getContentMetaInfoOffset(exhdrSize, contentInfoNum) + contentMetaNum * sizeof(sContentMetaInfo); }
|
||||
inline size_t getDigestOffset(size_t exhdrSize, size_t contentInfoNum, size_t contentMetaNum, size_t exdataSize) const { return getExtendedDataOffset(exhdrSize, contentInfoNum, contentMetaNum) + exdataSize; }
|
||||
inline size_t getTotalSize(size_t exhdrSize, size_t contentInfoNum, size_t contentMetaNum, size_t exdataSize) const { return getDigestOffset(exhdrSize, contentInfoNum, contentMetaNum, exdataSize) + cnmt::kDigestLen; }
|
||||
|
||||
bool validateExtendedHeaderSize(cnmt::ContentMetaType type, size_t exhdrSize) const;
|
||||
size_t getExtendedDataSize(cnmt::ContentMetaType type, const byte_t* data) const;
|
||||
void validateBinary(const byte_t* bytes, size_t len) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,55 +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;
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <nn/hac/define/cnmt.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class ContentMetaInfo :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
ContentMetaInfo();
|
||||
ContentMetaInfo(const ContentMetaInfo& other);
|
||||
|
||||
void operator=(const ContentMetaInfo& other);
|
||||
bool operator==(const ContentMetaInfo& other) const;
|
||||
bool operator!=(const ContentMetaInfo& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* bytes, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
uint64_t getTitleId() const;
|
||||
void setTitleId(uint64_t title_id);
|
||||
|
||||
uint32_t getTitleVersion() const;
|
||||
void setTitleVersion(uint32_t ver);
|
||||
|
||||
cnmt::ContentMetaType getContentMetaType() const;
|
||||
void setContentMetaType(cnmt::ContentMetaType type);
|
||||
|
||||
byte_t getAttributes() const;
|
||||
void setAttributes(byte_t attr);
|
||||
|
||||
private:
|
||||
const std::string kModuleName = "CONTENT_META_INFO";
|
||||
|
||||
// byte model
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// variables
|
||||
uint64_t mTitleId;
|
||||
uint32_t mTitleVersion;
|
||||
cnmt::ContentMetaType mType;
|
||||
byte_t mAttributes;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,47 +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;
|
||||
};
|
||||
}
|
||||
}
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <nn/hac/define/cnmt.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class DeltaMetaExtendedHeader :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
DeltaMetaExtendedHeader();
|
||||
DeltaMetaExtendedHeader(const DeltaMetaExtendedHeader& other);
|
||||
|
||||
void operator=(const DeltaMetaExtendedHeader& other);
|
||||
bool operator==(const DeltaMetaExtendedHeader& other) const;
|
||||
bool operator!=(const DeltaMetaExtendedHeader& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* bytes, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
uint64_t getApplicationId() const;
|
||||
void setApplicationId(uint64_t application_id);
|
||||
|
||||
uint32_t getExtendedDataSize() const;
|
||||
void setExtendedDataSize(uint32_t size);
|
||||
|
||||
private:
|
||||
const std::string kModuleName = "DELTA_META_EXTENDED_HEADER";
|
||||
|
||||
// binary blob
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// variables
|
||||
uint64_t mApplicationId;
|
||||
uint32_t mExtendedDataSize;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,78 +1,78 @@
|
|||
#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;
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <fnd/types.h>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <fnd/List.h>
|
||||
#include <nn/hac/define/fac.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class FileSystemAccessControl :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
struct sSaveDataOwnerId
|
||||
{
|
||||
nn::hac::fac::SaveDataOwnerIdAccessType access_type;
|
||||
uint64_t id;
|
||||
|
||||
void operator=(const sSaveDataOwnerId& other)
|
||||
{
|
||||
access_type = other.access_type;
|
||||
id = other.id;
|
||||
}
|
||||
|
||||
bool operator==(const sSaveDataOwnerId& other) const
|
||||
{
|
||||
return (access_type == other.access_type) \
|
||||
&& (id == other.id);
|
||||
}
|
||||
|
||||
bool operator!=(const sSaveDataOwnerId& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
};
|
||||
|
||||
FileSystemAccessControl();
|
||||
FileSystemAccessControl(const FileSystemAccessControl& other);
|
||||
|
||||
void operator=(const FileSystemAccessControl& other);
|
||||
bool operator==(const FileSystemAccessControl& other) const;
|
||||
bool operator!=(const FileSystemAccessControl& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* data, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
uint32_t getFormatVersion() const;
|
||||
void setFormatVersion(uint32_t version);
|
||||
|
||||
const fnd::List<fac::FsAccessFlag>& getFsaRightsList() const;
|
||||
void setFsaRightsList(const fnd::List<fac::FsAccessFlag>& list);
|
||||
|
||||
const fnd::List<uint64_t>& getContentOwnerIdList() const;
|
||||
void setContentOwnerIdList(const fnd::List<uint64_t>& list);
|
||||
|
||||
const fnd::List<sSaveDataOwnerId>& getSaveDataOwnerIdList() const;
|
||||
void setSaveDataOwnerIdList(const fnd::List<sSaveDataOwnerId>& list);
|
||||
private:
|
||||
const std::string kModuleName = "FILE_SYSTEM_ACCESS_CONTROL";
|
||||
|
||||
// raw data
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// variables
|
||||
uint32_t mVersion;
|
||||
fnd::List<fac::FsAccessFlag> mFsaRights;
|
||||
fnd::List<uint64_t> mContentOwnerIdList;
|
||||
fnd::List<sSaveDataOwnerId> mSaveDataOwnerIdList;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,127 +1,127 @@
|
|||
#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;
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include <nn/hac/define/gc.h>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <fnd/List.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class GameCardHeader :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
GameCardHeader();
|
||||
GameCardHeader(const GameCardHeader& other);
|
||||
|
||||
void operator=(const GameCardHeader& other);
|
||||
bool operator==(const GameCardHeader& other) const;
|
||||
bool operator!=(const GameCardHeader& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* bytes, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
uint32_t getRomAreaStartPage() const;
|
||||
void setRomAreaStartPage(uint32_t startPage);
|
||||
uint32_t getBackupAreaStartPage() const;
|
||||
void setBackupAreaStartPage(uint32_t startPage);
|
||||
byte_t getKekIndex() const;
|
||||
void setKekIndex(byte_t kekIndex);
|
||||
byte_t getTitleKeyDecIndex() const;
|
||||
void setTitleKeyDecIndex(byte_t index);
|
||||
byte_t getRomSizeType() const;
|
||||
void setRomSizeType(byte_t romSizeType);
|
||||
byte_t getCardHeaderVersion() const;
|
||||
void setCardHeaderVersion(byte_t version);
|
||||
byte_t getFlags() const;
|
||||
void setFlags(byte_t flags);
|
||||
uint64_t getPackageId() const;
|
||||
void setPackageId(uint64_t id);
|
||||
uint32_t getValidDataEndPage() const;
|
||||
void setValidDataEndPage(uint32_t page);
|
||||
const fnd::aes::sAesIvCtr& getAesCbcIv() const;
|
||||
void setAesCbcIv(const fnd::aes::sAesIvCtr& iv);
|
||||
uint64_t getPartitionFsAddress() const;
|
||||
void setPartitionFsAddress(uint64_t address);
|
||||
uint64_t getPartitionFsSize() const;
|
||||
void setPartitionFsSize(uint64_t size);
|
||||
const fnd::sha::sSha256Hash& getPartitionFsHash() const;
|
||||
void setPartitionFsHash(const fnd::sha::sSha256Hash& hash);
|
||||
const fnd::sha::sSha256Hash& getInitialDataHash() const;
|
||||
void setInitialDataHash(const fnd::sha::sSha256Hash& hash);
|
||||
uint32_t getSelSec() const;
|
||||
void setSelSec(uint32_t sel_sec);
|
||||
uint32_t getSelT1Key() const;
|
||||
void setSelT1Key(uint32_t sel_t1_key);
|
||||
uint32_t getSelKey() const;
|
||||
void setSelKey(uint32_t sel_key);
|
||||
uint32_t getLimAreaPage() const;
|
||||
void setLimAreaPage(uint32_t page);
|
||||
|
||||
uint32_t getFwVerMajor() const;
|
||||
void setFwVerMajor(uint32_t ver);
|
||||
uint32_t getFwVerMinor() const;
|
||||
void setFwVerMinor(uint32_t ver);
|
||||
uint32_t getAccCtrl1() const;
|
||||
void setAccCtrl1(uint32_t acc_ctrl_1);
|
||||
uint32_t getWait1TimeRead() const;
|
||||
void setWait1TimeRead(uint32_t seconds);
|
||||
uint32_t getWait2TimeRead() const;
|
||||
void setWait2TimeRead(uint32_t seconds);
|
||||
uint32_t getWait1TimeWrite() const;
|
||||
void setWait1TimeWrite(uint32_t seconds);
|
||||
uint32_t getWait2TimeWrite() const;
|
||||
void setWait2TimeWrite(uint32_t seconds);
|
||||
uint32_t getFwMode() const;
|
||||
void setFwMode(uint32_t fw_mode);
|
||||
uint32_t getUppVersion() const;
|
||||
void setUppVersion(uint32_t version);
|
||||
const byte_t* getUppHash() const;
|
||||
void setUppHash(const byte_t* hash);
|
||||
uint64_t getUppId() const;
|
||||
void setUppId(uint64_t id);
|
||||
|
||||
private:
|
||||
const std::string kModuleName = "GAMECARD_HEADER";
|
||||
|
||||
// binary
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// data
|
||||
uint32_t mRomAreaStartPage;
|
||||
uint32_t mBackupAreaStartPage;
|
||||
byte_t mKekIndex;
|
||||
byte_t mTitleKeyDecIndex;
|
||||
byte_t mRomSize;
|
||||
byte_t mCardHeaderVersion;
|
||||
byte_t mFlags;
|
||||
uint64_t mPackageId;
|
||||
uint32_t mValidDataEndPage;
|
||||
fnd::aes::sAesIvCtr mAesCbcIv;
|
||||
uint64_t mPartitionFsHeaderAddress;
|
||||
uint64_t mPartitionFsHeaderSize;
|
||||
fnd::sha::sSha256Hash mPartitionFsHeaderHash;
|
||||
fnd::sha::sSha256Hash mInitialDataHash;
|
||||
uint32_t mSelSec;
|
||||
uint32_t mSelT1Key;
|
||||
uint32_t mSelKey;
|
||||
uint32_t mLimAreaPage;
|
||||
|
||||
// Encrypted/Extended Data
|
||||
uint32_t mFwVersion[2];
|
||||
uint32_t mAccCtrl1;
|
||||
uint32_t mWait1TimeRead;
|
||||
uint32_t mWait2TimeRead;
|
||||
uint32_t mWait1TimeWrite;
|
||||
uint32_t mWait2TimeWrite;
|
||||
uint32_t mFwMode;
|
||||
uint32_t mUppVersion;
|
||||
byte_t mUppHash[8];
|
||||
uint64_t mUppId;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
#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);
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include <nn/hac/define/gc.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class GameCardUtils
|
||||
{
|
||||
public:
|
||||
static inline uint64_t blockToAddr(uint32_t block) { return ((uint64_t)block) << 9; }
|
||||
static void getXciHeaderAesIv(const nn::hac::sGcHeader* hdr, byte_t* iv);
|
||||
static void decryptXciHeader(const byte_t* src, byte_t* dst, const byte_t* key);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,70 +1,70 @@
|
|||
#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;
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include <nn/hac/define/hierarchicalintegrity.h>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <fnd/List.h>
|
||||
#include <fnd/sha.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class HierarchicalIntegrityHeader :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
struct sLayer
|
||||
{
|
||||
size_t offset;
|
||||
size_t size;
|
||||
size_t block_size;
|
||||
|
||||
void operator=(const sLayer& other)
|
||||
{
|
||||
offset = other.offset;
|
||||
size = other.size;
|
||||
block_size = other.block_size;
|
||||
}
|
||||
|
||||
bool operator==(const sLayer& other) const
|
||||
{
|
||||
return (offset == other.offset && size == other.size && block_size == other.block_size);
|
||||
}
|
||||
|
||||
bool operator!=(const sLayer& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
};
|
||||
|
||||
HierarchicalIntegrityHeader();
|
||||
HierarchicalIntegrityHeader(const HierarchicalIntegrityHeader& other);
|
||||
|
||||
void operator=(const HierarchicalIntegrityHeader& other);
|
||||
bool operator==(const HierarchicalIntegrityHeader& other) const;
|
||||
bool operator!=(const HierarchicalIntegrityHeader& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* bytes, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
const fnd::List<sLayer>& getLayerInfo() const;
|
||||
void setLayerInfo(const fnd::List<sLayer>& layer_info);
|
||||
|
||||
const fnd::List<fnd::sha::sSha256Hash>& getMasterHashList() const;
|
||||
void setMasterHashList(const fnd::List<fnd::sha::sSha256Hash>& master_hash_list);
|
||||
private:
|
||||
const std::string kModuleName = "HIERARCHICAL_INTEGRITY_HEADER";
|
||||
|
||||
// binary
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// data
|
||||
fnd::List<sLayer> mLayerInfo;
|
||||
fnd::List<fnd::sha::sSha256Hash> mMasterHashList;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,71 +1,71 @@
|
|||
#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;
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include <nn/hac/define/hierarchicalsha256.h>
|
||||
#include <fnd/IByteModel.h>
|
||||
#include <fnd/List.h>
|
||||
|
||||
namespace nn
|
||||
{
|
||||
namespace hac
|
||||
{
|
||||
class HierarchicalSha256Header :
|
||||
public fnd::IByteModel
|
||||
{
|
||||
public:
|
||||
struct sLayer
|
||||
{
|
||||
size_t offset;
|
||||
size_t size;
|
||||
|
||||
void operator=(const sLayer& other)
|
||||
{
|
||||
offset = other.offset;
|
||||
size = other.size;
|
||||
}
|
||||
|
||||
bool operator==(const sLayer& other) const
|
||||
{
|
||||
return (offset == other.offset && size == other.size);
|
||||
}
|
||||
|
||||
bool operator!=(const sLayer& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
};
|
||||
|
||||
HierarchicalSha256Header();
|
||||
HierarchicalSha256Header(const HierarchicalSha256Header& other);
|
||||
|
||||
void operator=(const HierarchicalSha256Header& other);
|
||||
bool operator==(const HierarchicalSha256Header& other) const;
|
||||
bool operator!=(const HierarchicalSha256Header& other) const;
|
||||
|
||||
// IByteModel
|
||||
void toBytes();
|
||||
void fromBytes(const byte_t* bytes, size_t len);
|
||||
const fnd::Vec<byte_t>& getBytes() const;
|
||||
|
||||
// variables
|
||||
void clear();
|
||||
|
||||
const fnd::sha::sSha256Hash& getMasterHash() const;
|
||||
void setMasterHash(const fnd::sha::sSha256Hash& master_hash);
|
||||
|
||||
size_t getHashBlockSize() const;
|
||||
void setHashBlockSize(size_t hash_block_size);
|
||||
|
||||
const fnd::List<sLayer>& getLayerInfo() const;
|
||||
void setLayerInfo(const fnd::List<sLayer>& layer_info);
|
||||
private:
|
||||
const std::string kModuleName = "HIERARCHICAL_SHA256_HEADER";
|
||||
|
||||
// binary
|
||||
fnd::Vec<byte_t> mRawBinary;
|
||||
|
||||
// data
|
||||
fnd::sha::sSha256Hash mMasterHash;
|
||||
size_t mHashBlockSize;
|
||||
fnd::List<sLayer> mLayerInfo;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,78 +1,78 @@
|
|||
#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;
|
||||
};
|
||||
}
|
||||
#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;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,52 +1,52 @@
|
|||
#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;
|
||||
}
|
||||
};
|
||||
}
|
||||
#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;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,141 +1,141 @@
|
|||
#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;
|
||||
};
|
||||
}
|
||||
#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;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,149 +1,149 @@
|
|||
#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;
|
||||
};
|
||||
}
|
||||
#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;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,100 +1,100 @@
|
|||
#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);
|
||||
};
|
||||
}
|
||||
#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);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,51 +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;
|
||||
};
|
||||
}
|
||||
}
|
||||
#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;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,42 +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;
|
||||
};
|
||||
}
|
||||
}
|
||||
#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;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,51 +1,51 @@
|
|||
#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;
|
||||
};
|
||||
}
|
||||
#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;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,56 +1,56 @@
|
|||
#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)
|
||||
}
|
||||
#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)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,181 +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 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)
|
||||
}
|
||||
#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)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,26 +1,26 @@
|
|||
#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)
|
||||
}
|
||||
}
|
||||
#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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
@ -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/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)
|
||||
}
|
||||
#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)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,35 +1,35 @@
|
|||
#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)
|
||||
}
|
||||
#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)
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +1,27 @@
|
|||
#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
|
||||
};
|
||||
}
|
||||
}
|
||||
#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
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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]))
|
||||
|
|
|
|||
|
|
@ -1,58 +1,58 @@
|
|||
#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)
|
||||
}
|
||||
#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)
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,144 +1,144 @@
|
|||
#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)
|
||||
}
|
||||
#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)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,45 +1,45 @@
|
|||
#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)
|
||||
}
|
||||
#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)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,39 +1,39 @@
|
|||
#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)
|
||||
}
|
||||
#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)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,68 +1,68 @@
|
|||
#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)
|
||||
}
|
||||
#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)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,45 +1,45 @@
|
|||
#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)
|
||||
}
|
||||
#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)
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,173 +1,173 @@
|
|||
#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;
|
||||
#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;
|
||||
}
|
||||
|
|
@ -1,251 +1,251 @@
|
|||
#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;
|
||||
#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;
|
||||
}
|
||||
|
|
@ -1,84 +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;
|
||||
#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;
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,84 +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;
|
||||
#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;
|
||||
}
|
||||
|
|
@ -1,334 +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);
|
||||
#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);
|
||||
}
|
||||
|
|
@ -1,58 +1,58 @@
|
|||
#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;
|
||||
}
|
||||
#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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,123 +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;
|
||||
#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;
|
||||
}
|
||||
|
|
@ -1,368 +1,368 @@
|
|||
#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");
|
||||
}
|
||||
#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");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,114 +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;
|
||||
}
|
||||
#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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,84 +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;
|
||||
#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;
|
||||
}
|
||||
|
|
@ -1,219 +1,219 @@
|
|||
#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;
|
||||
#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;
|
||||
}
|
||||
|
|
@ -1,231 +1,231 @@
|
|||
#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;
|
||||
#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;
|
||||
}
|
||||
|
|
@ -1,295 +1,295 @@
|
|||
#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;
|
||||
#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;
|
||||
}
|
||||
|
|
@ -1,99 +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;
|
||||
#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;
|
||||
}
|
||||
|
|
@ -1,79 +1,79 @@
|
|||
#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;
|
||||
#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;
|
||||
}
|
||||
|
|
@ -1,67 +1,67 @@
|
|||
#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;
|
||||
};
|
||||
}
|
||||
#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;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,51 +1,51 @@
|
|||
#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;
|
||||
};
|
||||
}
|
||||
#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;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,139 +1,139 @@
|
|||
#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;
|
||||
}
|
||||
}
|
||||
#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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,74 +1,74 @@
|
|||
# Nintendo Switch Tool (NSTool) 
|
||||
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) 
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -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\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>
|
||||
<?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>
|
||||
|
|
@ -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\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>
|
||||
<?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>
|
||||
|
|
@ -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::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;
|
||||
}
|
||||
#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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,40 +1,40 @@
|
|||
#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;
|
||||
#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;
|
||||
};
|
||||
|
|
@ -1,376 +1,376 @@
|
|||
#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;
|
||||
#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;
|
||||
}
|
||||
|
|
@ -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/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;
|
||||
}
|
||||
#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
|
|
@ -1,56 +1,56 @@
|
|||
#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;
|
||||
#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
|
|
@ -1,53 +1,53 @@
|
|||
#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;
|
||||
#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
|
|
@ -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/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;
|
||||
#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;
|
||||
};
|
||||
|
|
@ -1,172 +1,172 @@
|
|||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <fnd/SimpleTextOutput.h>
|
||||
#include <fnd/OffsetAdjustedIFile.h>
|
||||
#include <fnd/Vec.h>
|
||||
#include <fnd/lz4.h>
|
||||
#include <nn/hac/define/nro-hb.h>
|
||||
#include "NroProcess.h"
|
||||
|
||||
NroProcess::NroProcess():
|
||||
mFile(),
|
||||
mCliOutputMode(_BIT(OUTPUT_BASIC)),
|
||||
mVerify(false)
|
||||
{
|
||||
}
|
||||
|
||||
void NroProcess::process()
|
||||
{
|
||||
importHeader();
|
||||
importCodeSegments();
|
||||
|
||||
if (_HAS_BIT(mCliOutputMode, OUTPUT_BASIC))
|
||||
displayHeader();
|
||||
|
||||
processRoMeta();
|
||||
|
||||
if (mIsHomebrewNro)
|
||||
mAssetProc.process();
|
||||
}
|
||||
|
||||
void NroProcess::setInputFile(const fnd::SharedPtr<fnd::IFile>& file)
|
||||
{
|
||||
mFile = file;
|
||||
}
|
||||
|
||||
void NroProcess::setCliOutputMode(CliOutputMode type)
|
||||
{
|
||||
mCliOutputMode = type;
|
||||
}
|
||||
|
||||
void NroProcess::setVerifyMode(bool verify)
|
||||
{
|
||||
mVerify = verify;
|
||||
}
|
||||
|
||||
void NroProcess::setInstructionType(nn::hac::meta::InstructionType type)
|
||||
{
|
||||
mRoMeta.setInstructionType(type);
|
||||
}
|
||||
|
||||
void NroProcess::setListApi(bool listApi)
|
||||
{
|
||||
mRoMeta.setListApi(listApi);
|
||||
}
|
||||
|
||||
void NroProcess::setListSymbols(bool listSymbols)
|
||||
{
|
||||
mRoMeta.setListSymbols(listSymbols);
|
||||
}
|
||||
|
||||
void NroProcess::setAssetListFs(bool list)
|
||||
{
|
||||
mAssetProc.setListFs(list);
|
||||
}
|
||||
|
||||
void NroProcess::setAssetIconExtractPath(const std::string& path)
|
||||
{
|
||||
mAssetProc.setIconExtractPath(path);
|
||||
}
|
||||
|
||||
void NroProcess::setAssetNacpExtractPath(const std::string& path)
|
||||
{
|
||||
mAssetProc.setNacpExtractPath(path);
|
||||
}
|
||||
|
||||
void NroProcess::setAssetRomfsExtractPath(const std::string& path)
|
||||
{
|
||||
mAssetProc.setRomfsExtractPath(path);
|
||||
}
|
||||
|
||||
const RoMetadataProcess& NroProcess::getRoMetadataProcess() const
|
||||
{
|
||||
return mRoMeta;
|
||||
}
|
||||
|
||||
void NroProcess::importHeader()
|
||||
{
|
||||
fnd::Vec<byte_t> scratch;
|
||||
|
||||
if (*mFile == nullptr)
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "No file reader set.");
|
||||
}
|
||||
|
||||
if ((*mFile)->size() < sizeof(nn::hac::sNroHeader))
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "Corrupt NRO: file too small");
|
||||
}
|
||||
|
||||
scratch.alloc(sizeof(nn::hac::sNroHeader));
|
||||
(*mFile)->read(scratch.data(), 0, scratch.size());
|
||||
|
||||
mHdr.fromBytes(scratch.data(), scratch.size());
|
||||
|
||||
// setup homebrew extension
|
||||
nn::hac::sNroHeader* raw_hdr = (nn::hac::sNroHeader*)scratch.data();
|
||||
if (((le_uint64_t*)raw_hdr->reserved_0)->get() == nn::hac::nro::kNroHomebrewStructMagic && (*mFile)->size() > mHdr.getNroSize())
|
||||
{
|
||||
mIsHomebrewNro = true;
|
||||
mAssetProc.setInputFile(new fnd::OffsetAdjustedIFile(mFile, mHdr.getNroSize(), (*mFile)->size() - mHdr.getNroSize()));
|
||||
mAssetProc.setCliOutputMode(mCliOutputMode);
|
||||
mAssetProc.setVerifyMode(mVerify);
|
||||
}
|
||||
else
|
||||
mIsHomebrewNro = false;
|
||||
}
|
||||
|
||||
void NroProcess::importCodeSegments()
|
||||
{
|
||||
mTextBlob.alloc(mHdr.getTextInfo().size);
|
||||
(*mFile)->read(mTextBlob.data(), mHdr.getTextInfo().memory_offset, mTextBlob.size());
|
||||
mRoBlob.alloc(mHdr.getRoInfo().size);
|
||||
(*mFile)->read(mRoBlob.data(), mHdr.getRoInfo().memory_offset, mRoBlob.size());
|
||||
mDataBlob.alloc(mHdr.getDataInfo().size);
|
||||
(*mFile)->read(mDataBlob.data(), mHdr.getDataInfo().memory_offset, mDataBlob.size());
|
||||
}
|
||||
|
||||
void NroProcess::displayHeader()
|
||||
{
|
||||
std::cout << "[NRO Header]" << std::endl;
|
||||
std::cout << " RoCrt: " << fnd::SimpleTextOutput::arrayToString(mHdr.getRoCrt().data, nn::hac::nro::kRoCrtSize, false, "") << std::endl;
|
||||
std::cout << " ModuleId: " << fnd::SimpleTextOutput::arrayToString(mHdr.getModuleId().data, nn::hac::nro::kModuleIdSize, false, "") << std::endl;
|
||||
std::cout << " NroSize: 0x" << std::hex << mHdr.getNroSize() << std::endl;
|
||||
std::cout << " Program Sections:" << std::endl;
|
||||
std::cout << " .text:" << std::endl;
|
||||
std::cout << " Offset: 0x" << std::hex << mHdr.getTextInfo().memory_offset << std::endl;
|
||||
std::cout << " Size: 0x" << std::hex << mHdr.getTextInfo().size << std::endl;
|
||||
std::cout << " .ro:" << std::endl;
|
||||
std::cout << " Offset: 0x" << std::hex << mHdr.getRoInfo().memory_offset << std::endl;
|
||||
std::cout << " Size: 0x" << std::hex << mHdr.getRoInfo().size << std::endl;
|
||||
if (_HAS_BIT(mCliOutputMode, OUTPUT_EXTENDED))
|
||||
{
|
||||
std::cout << " .api_info:" << std::endl;
|
||||
std::cout << " Offset: 0x" << std::hex << mHdr.getRoEmbeddedInfo().memory_offset << std::endl;
|
||||
std::cout << " Size: 0x" << std::hex << mHdr.getRoEmbeddedInfo().size << std::endl;
|
||||
std::cout << " .dynstr:" << std::endl;
|
||||
std::cout << " Offset: 0x" << std::hex << mHdr.getRoDynStrInfo().memory_offset << std::endl;
|
||||
std::cout << " Size: 0x" << std::hex << mHdr.getRoDynStrInfo().size << std::endl;
|
||||
std::cout << " .dynsym:" << std::endl;
|
||||
std::cout << " Offset: 0x" << std::hex << mHdr.getRoDynSymInfo().memory_offset << std::endl;
|
||||
std::cout << " Size: 0x" << std::hex << mHdr.getRoDynSymInfo().size << std::endl;
|
||||
}
|
||||
std::cout << " .data:" << std::endl;
|
||||
std::cout << " Offset: 0x" << std::hex << mHdr.getDataInfo().memory_offset << std::endl;
|
||||
std::cout << " Size: 0x" << std::hex << mHdr.getDataInfo().size << std::endl;
|
||||
std::cout << " .bss:" << std::endl;
|
||||
std::cout << " Size: 0x" << std::hex << mHdr.getBssSize() << std::endl;
|
||||
}
|
||||
|
||||
void NroProcess::processRoMeta()
|
||||
{
|
||||
if (mRoBlob.size())
|
||||
{
|
||||
// setup ro metadata
|
||||
mRoMeta.setApiInfo(mHdr.getRoEmbeddedInfo().memory_offset, mHdr.getRoEmbeddedInfo().size);
|
||||
mRoMeta.setDynSym(mHdr.getRoDynSymInfo().memory_offset, mHdr.getRoDynSymInfo().size);
|
||||
mRoMeta.setDynStr(mHdr.getRoDynStrInfo().memory_offset, mHdr.getRoDynStrInfo().size);
|
||||
mRoMeta.setRoBinary(mRoBlob);
|
||||
mRoMeta.setCliOutputMode(mCliOutputMode);
|
||||
mRoMeta.process();
|
||||
}
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <fnd/SimpleTextOutput.h>
|
||||
#include <fnd/OffsetAdjustedIFile.h>
|
||||
#include <fnd/Vec.h>
|
||||
#include <fnd/lz4.h>
|
||||
#include <nn/hac/define/nro-hb.h>
|
||||
#include "NroProcess.h"
|
||||
|
||||
NroProcess::NroProcess():
|
||||
mFile(),
|
||||
mCliOutputMode(_BIT(OUTPUT_BASIC)),
|
||||
mVerify(false)
|
||||
{
|
||||
}
|
||||
|
||||
void NroProcess::process()
|
||||
{
|
||||
importHeader();
|
||||
importCodeSegments();
|
||||
|
||||
if (_HAS_BIT(mCliOutputMode, OUTPUT_BASIC))
|
||||
displayHeader();
|
||||
|
||||
processRoMeta();
|
||||
|
||||
if (mIsHomebrewNro)
|
||||
mAssetProc.process();
|
||||
}
|
||||
|
||||
void NroProcess::setInputFile(const fnd::SharedPtr<fnd::IFile>& file)
|
||||
{
|
||||
mFile = file;
|
||||
}
|
||||
|
||||
void NroProcess::setCliOutputMode(CliOutputMode type)
|
||||
{
|
||||
mCliOutputMode = type;
|
||||
}
|
||||
|
||||
void NroProcess::setVerifyMode(bool verify)
|
||||
{
|
||||
mVerify = verify;
|
||||
}
|
||||
|
||||
void NroProcess::setInstructionType(nn::hac::meta::InstructionType type)
|
||||
{
|
||||
mRoMeta.setInstructionType(type);
|
||||
}
|
||||
|
||||
void NroProcess::setListApi(bool listApi)
|
||||
{
|
||||
mRoMeta.setListApi(listApi);
|
||||
}
|
||||
|
||||
void NroProcess::setListSymbols(bool listSymbols)
|
||||
{
|
||||
mRoMeta.setListSymbols(listSymbols);
|
||||
}
|
||||
|
||||
void NroProcess::setAssetListFs(bool list)
|
||||
{
|
||||
mAssetProc.setListFs(list);
|
||||
}
|
||||
|
||||
void NroProcess::setAssetIconExtractPath(const std::string& path)
|
||||
{
|
||||
mAssetProc.setIconExtractPath(path);
|
||||
}
|
||||
|
||||
void NroProcess::setAssetNacpExtractPath(const std::string& path)
|
||||
{
|
||||
mAssetProc.setNacpExtractPath(path);
|
||||
}
|
||||
|
||||
void NroProcess::setAssetRomfsExtractPath(const std::string& path)
|
||||
{
|
||||
mAssetProc.setRomfsExtractPath(path);
|
||||
}
|
||||
|
||||
const RoMetadataProcess& NroProcess::getRoMetadataProcess() const
|
||||
{
|
||||
return mRoMeta;
|
||||
}
|
||||
|
||||
void NroProcess::importHeader()
|
||||
{
|
||||
fnd::Vec<byte_t> scratch;
|
||||
|
||||
if (*mFile == nullptr)
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "No file reader set.");
|
||||
}
|
||||
|
||||
if ((*mFile)->size() < sizeof(nn::hac::sNroHeader))
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "Corrupt NRO: file too small");
|
||||
}
|
||||
|
||||
scratch.alloc(sizeof(nn::hac::sNroHeader));
|
||||
(*mFile)->read(scratch.data(), 0, scratch.size());
|
||||
|
||||
mHdr.fromBytes(scratch.data(), scratch.size());
|
||||
|
||||
// setup homebrew extension
|
||||
nn::hac::sNroHeader* raw_hdr = (nn::hac::sNroHeader*)scratch.data();
|
||||
if (((le_uint64_t*)raw_hdr->reserved_0)->get() == nn::hac::nro::kNroHomebrewStructMagic && (*mFile)->size() > mHdr.getNroSize())
|
||||
{
|
||||
mIsHomebrewNro = true;
|
||||
mAssetProc.setInputFile(new fnd::OffsetAdjustedIFile(mFile, mHdr.getNroSize(), (*mFile)->size() - mHdr.getNroSize()));
|
||||
mAssetProc.setCliOutputMode(mCliOutputMode);
|
||||
mAssetProc.setVerifyMode(mVerify);
|
||||
}
|
||||
else
|
||||
mIsHomebrewNro = false;
|
||||
}
|
||||
|
||||
void NroProcess::importCodeSegments()
|
||||
{
|
||||
mTextBlob.alloc(mHdr.getTextInfo().size);
|
||||
(*mFile)->read(mTextBlob.data(), mHdr.getTextInfo().memory_offset, mTextBlob.size());
|
||||
mRoBlob.alloc(mHdr.getRoInfo().size);
|
||||
(*mFile)->read(mRoBlob.data(), mHdr.getRoInfo().memory_offset, mRoBlob.size());
|
||||
mDataBlob.alloc(mHdr.getDataInfo().size);
|
||||
(*mFile)->read(mDataBlob.data(), mHdr.getDataInfo().memory_offset, mDataBlob.size());
|
||||
}
|
||||
|
||||
void NroProcess::displayHeader()
|
||||
{
|
||||
std::cout << "[NRO Header]" << std::endl;
|
||||
std::cout << " RoCrt: " << fnd::SimpleTextOutput::arrayToString(mHdr.getRoCrt().data, nn::hac::nro::kRoCrtSize, false, "") << std::endl;
|
||||
std::cout << " ModuleId: " << fnd::SimpleTextOutput::arrayToString(mHdr.getModuleId().data, nn::hac::nro::kModuleIdSize, false, "") << std::endl;
|
||||
std::cout << " NroSize: 0x" << std::hex << mHdr.getNroSize() << std::endl;
|
||||
std::cout << " Program Sections:" << std::endl;
|
||||
std::cout << " .text:" << std::endl;
|
||||
std::cout << " Offset: 0x" << std::hex << mHdr.getTextInfo().memory_offset << std::endl;
|
||||
std::cout << " Size: 0x" << std::hex << mHdr.getTextInfo().size << std::endl;
|
||||
std::cout << " .ro:" << std::endl;
|
||||
std::cout << " Offset: 0x" << std::hex << mHdr.getRoInfo().memory_offset << std::endl;
|
||||
std::cout << " Size: 0x" << std::hex << mHdr.getRoInfo().size << std::endl;
|
||||
if (_HAS_BIT(mCliOutputMode, OUTPUT_EXTENDED))
|
||||
{
|
||||
std::cout << " .api_info:" << std::endl;
|
||||
std::cout << " Offset: 0x" << std::hex << mHdr.getRoEmbeddedInfo().memory_offset << std::endl;
|
||||
std::cout << " Size: 0x" << std::hex << mHdr.getRoEmbeddedInfo().size << std::endl;
|
||||
std::cout << " .dynstr:" << std::endl;
|
||||
std::cout << " Offset: 0x" << std::hex << mHdr.getRoDynStrInfo().memory_offset << std::endl;
|
||||
std::cout << " Size: 0x" << std::hex << mHdr.getRoDynStrInfo().size << std::endl;
|
||||
std::cout << " .dynsym:" << std::endl;
|
||||
std::cout << " Offset: 0x" << std::hex << mHdr.getRoDynSymInfo().memory_offset << std::endl;
|
||||
std::cout << " Size: 0x" << std::hex << mHdr.getRoDynSymInfo().size << std::endl;
|
||||
}
|
||||
std::cout << " .data:" << std::endl;
|
||||
std::cout << " Offset: 0x" << std::hex << mHdr.getDataInfo().memory_offset << std::endl;
|
||||
std::cout << " Size: 0x" << std::hex << mHdr.getDataInfo().size << std::endl;
|
||||
std::cout << " .bss:" << std::endl;
|
||||
std::cout << " Size: 0x" << std::hex << mHdr.getBssSize() << std::endl;
|
||||
}
|
||||
|
||||
void NroProcess::processRoMeta()
|
||||
{
|
||||
if (mRoBlob.size())
|
||||
{
|
||||
// setup ro metadata
|
||||
mRoMeta.setApiInfo(mHdr.getRoEmbeddedInfo().memory_offset, mHdr.getRoEmbeddedInfo().size);
|
||||
mRoMeta.setDynSym(mHdr.getRoDynSymInfo().memory_offset, mHdr.getRoDynSymInfo().size);
|
||||
mRoMeta.setDynStr(mHdr.getRoDynStrInfo().memory_offset, mHdr.getRoDynStrInfo().size);
|
||||
mRoMeta.setRoBinary(mRoBlob);
|
||||
mRoMeta.setCliOutputMode(mCliOutputMode);
|
||||
mRoMeta.process();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,53 +1,53 @@
|
|||
#pragma once
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <fnd/types.h>
|
||||
#include <fnd/IFile.h>
|
||||
#include <fnd/SharedPtr.h>
|
||||
#include <nn/hac/define/meta.h>
|
||||
#include <nn/hac/NroHeader.h>
|
||||
#include "AssetProcess.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "RoMetadataProcess.h"
|
||||
|
||||
class NroProcess
|
||||
{
|
||||
public:
|
||||
NroProcess();
|
||||
|
||||
void process();
|
||||
|
||||
void setInputFile(const fnd::SharedPtr<fnd::IFile>& file);
|
||||
void setCliOutputMode(CliOutputMode type);
|
||||
void setVerifyMode(bool verify);
|
||||
|
||||
void setInstructionType(nn::hac::meta::InstructionType type);
|
||||
void setListApi(bool listApi);
|
||||
void setListSymbols(bool listSymbols);
|
||||
|
||||
// for homebrew NROs with Asset blobs appended
|
||||
void setAssetListFs(bool list);
|
||||
void setAssetIconExtractPath(const std::string& path);
|
||||
void setAssetNacpExtractPath(const std::string& path);
|
||||
void setAssetRomfsExtractPath(const std::string& path);
|
||||
|
||||
const RoMetadataProcess& getRoMetadataProcess() const;
|
||||
private:
|
||||
const std::string kModuleName = "NroProcess";
|
||||
|
||||
fnd::SharedPtr<fnd::IFile> mFile;
|
||||
CliOutputMode mCliOutputMode;
|
||||
bool mVerify;
|
||||
|
||||
nn::hac::NroHeader mHdr;
|
||||
fnd::Vec<byte_t> mTextBlob, mRoBlob, mDataBlob;
|
||||
RoMetadataProcess mRoMeta;
|
||||
bool mIsHomebrewNro;
|
||||
AssetProcess mAssetProc;
|
||||
|
||||
void importHeader();
|
||||
void importCodeSegments();
|
||||
void displayHeader();
|
||||
void processRoMeta();
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <fnd/types.h>
|
||||
#include <fnd/IFile.h>
|
||||
#include <fnd/SharedPtr.h>
|
||||
#include <nn/hac/define/meta.h>
|
||||
#include <nn/hac/NroHeader.h>
|
||||
#include "AssetProcess.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "RoMetadataProcess.h"
|
||||
|
||||
class NroProcess
|
||||
{
|
||||
public:
|
||||
NroProcess();
|
||||
|
||||
void process();
|
||||
|
||||
void setInputFile(const fnd::SharedPtr<fnd::IFile>& file);
|
||||
void setCliOutputMode(CliOutputMode type);
|
||||
void setVerifyMode(bool verify);
|
||||
|
||||
void setInstructionType(nn::hac::meta::InstructionType type);
|
||||
void setListApi(bool listApi);
|
||||
void setListSymbols(bool listSymbols);
|
||||
|
||||
// for homebrew NROs with Asset blobs appended
|
||||
void setAssetListFs(bool list);
|
||||
void setAssetIconExtractPath(const std::string& path);
|
||||
void setAssetNacpExtractPath(const std::string& path);
|
||||
void setAssetRomfsExtractPath(const std::string& path);
|
||||
|
||||
const RoMetadataProcess& getRoMetadataProcess() const;
|
||||
private:
|
||||
const std::string kModuleName = "NroProcess";
|
||||
|
||||
fnd::SharedPtr<fnd::IFile> mFile;
|
||||
CliOutputMode mCliOutputMode;
|
||||
bool mVerify;
|
||||
|
||||
nn::hac::NroHeader mHdr;
|
||||
fnd::Vec<byte_t> mTextBlob, mRoBlob, mDataBlob;
|
||||
RoMetadataProcess mRoMeta;
|
||||
bool mIsHomebrewNro;
|
||||
AssetProcess mAssetProc;
|
||||
|
||||
void importHeader();
|
||||
void importCodeSegments();
|
||||
void displayHeader();
|
||||
void processRoMeta();
|
||||
};
|
||||
|
|
@ -1,237 +1,237 @@
|
|||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <fnd/SimpleTextOutput.h>
|
||||
#include <fnd/OffsetAdjustedIFile.h>
|
||||
#include <fnd/Vec.h>
|
||||
#include <fnd/lz4.h>
|
||||
#include "NsoProcess.h"
|
||||
|
||||
NsoProcess::NsoProcess():
|
||||
mFile(),
|
||||
mCliOutputMode(_BIT(OUTPUT_BASIC)),
|
||||
mVerify(false)
|
||||
{
|
||||
}
|
||||
|
||||
void NsoProcess::process()
|
||||
{
|
||||
importHeader();
|
||||
importCodeSegments();
|
||||
if (_HAS_BIT(mCliOutputMode, OUTPUT_BASIC))
|
||||
displayNsoHeader();
|
||||
|
||||
processRoMeta();
|
||||
}
|
||||
|
||||
void NsoProcess::setInputFile(const fnd::SharedPtr<fnd::IFile>& file)
|
||||
{
|
||||
mFile = file;
|
||||
}
|
||||
|
||||
void NsoProcess::setCliOutputMode(CliOutputMode type)
|
||||
{
|
||||
mCliOutputMode = type;
|
||||
}
|
||||
|
||||
void NsoProcess::setVerifyMode(bool verify)
|
||||
{
|
||||
mVerify = verify;
|
||||
}
|
||||
|
||||
void NsoProcess::setInstructionType(nn::hac::meta::InstructionType type)
|
||||
{
|
||||
mRoMeta.setInstructionType(type);
|
||||
}
|
||||
|
||||
void NsoProcess::setListApi(bool listApi)
|
||||
{
|
||||
mRoMeta.setListApi(listApi);
|
||||
}
|
||||
|
||||
void NsoProcess::setListSymbols(bool listSymbols)
|
||||
{
|
||||
mRoMeta.setListSymbols(listSymbols);
|
||||
}
|
||||
|
||||
const RoMetadataProcess& NsoProcess::getRoMetadataProcess() const
|
||||
{
|
||||
return mRoMeta;
|
||||
}
|
||||
|
||||
void NsoProcess::importHeader()
|
||||
{
|
||||
fnd::Vec<byte_t> scratch;
|
||||
|
||||
if (*mFile == nullptr)
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "No file reader set.");
|
||||
}
|
||||
|
||||
if ((*mFile)->size() < sizeof(nn::hac::sNsoHeader))
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "Corrupt NSO: file too small");
|
||||
}
|
||||
|
||||
scratch.alloc(sizeof(nn::hac::sNsoHeader));
|
||||
(*mFile)->read(scratch.data(), 0, scratch.size());
|
||||
|
||||
mHdr.fromBytes(scratch.data(), scratch.size());
|
||||
}
|
||||
|
||||
void NsoProcess::importCodeSegments()
|
||||
{
|
||||
fnd::Vec<byte_t> scratch;
|
||||
uint32_t decompressed_len;
|
||||
fnd::sha::sSha256Hash calc_hash;
|
||||
|
||||
// process text segment
|
||||
if (mHdr.getTextSegmentInfo().is_compressed)
|
||||
{
|
||||
scratch.alloc(mHdr.getTextSegmentInfo().file_layout.size);
|
||||
(*mFile)->read(scratch.data(), mHdr.getTextSegmentInfo().file_layout.offset, scratch.size());
|
||||
mTextBlob.alloc(mHdr.getTextSegmentInfo().memory_layout.size);
|
||||
fnd::lz4::decompressData(scratch.data(), (uint32_t)scratch.size(), mTextBlob.data(), (uint32_t)mTextBlob.size(), decompressed_len);
|
||||
if (decompressed_len != mTextBlob.size())
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "NSO text segment failed to decompress");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mTextBlob.alloc(mHdr.getTextSegmentInfo().file_layout.size);
|
||||
(*mFile)->read(mTextBlob.data(), mHdr.getTextSegmentInfo().file_layout.offset, mTextBlob.size());
|
||||
}
|
||||
if (mHdr.getTextSegmentInfo().is_hashed)
|
||||
{
|
||||
fnd::sha::Sha256(mTextBlob.data(), mTextBlob.size(), calc_hash.bytes);
|
||||
if (calc_hash != mHdr.getTextSegmentInfo().hash)
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "NSO text segment failed SHA256 verification");
|
||||
}
|
||||
}
|
||||
|
||||
// process ro segment
|
||||
if (mHdr.getRoSegmentInfo().is_compressed)
|
||||
{
|
||||
scratch.alloc(mHdr.getRoSegmentInfo().file_layout.size);
|
||||
(*mFile)->read(scratch.data(), mHdr.getRoSegmentInfo().file_layout.offset, scratch.size());
|
||||
mRoBlob.alloc(mHdr.getRoSegmentInfo().memory_layout.size);
|
||||
fnd::lz4::decompressData(scratch.data(), (uint32_t)scratch.size(), mRoBlob.data(), (uint32_t)mRoBlob.size(), decompressed_len);
|
||||
if (decompressed_len != mRoBlob.size())
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "NSO ro segment failed to decompress");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mRoBlob.alloc(mHdr.getRoSegmentInfo().file_layout.size);
|
||||
(*mFile)->read(mRoBlob.data(), mHdr.getRoSegmentInfo().file_layout.offset, mRoBlob.size());
|
||||
}
|
||||
if (mHdr.getRoSegmentInfo().is_hashed)
|
||||
{
|
||||
fnd::sha::Sha256(mRoBlob.data(), mRoBlob.size(), calc_hash.bytes);
|
||||
if (calc_hash != mHdr.getRoSegmentInfo().hash)
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "NSO ro segment failed SHA256 verification");
|
||||
}
|
||||
}
|
||||
|
||||
// process data segment
|
||||
if (mHdr.getDataSegmentInfo().is_compressed)
|
||||
{
|
||||
scratch.alloc(mHdr.getDataSegmentInfo().file_layout.size);
|
||||
(*mFile)->read(scratch.data(), mHdr.getDataSegmentInfo().file_layout.offset, scratch.size());
|
||||
mDataBlob.alloc(mHdr.getDataSegmentInfo().memory_layout.size);
|
||||
fnd::lz4::decompressData(scratch.data(), (uint32_t)scratch.size(), mDataBlob.data(), (uint32_t)mDataBlob.size(), decompressed_len);
|
||||
if (decompressed_len != mDataBlob.size())
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "NSO data segment failed to decompress");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mDataBlob.alloc(mHdr.getDataSegmentInfo().file_layout.size);
|
||||
(*mFile)->read(mDataBlob.data(), mHdr.getDataSegmentInfo().file_layout.offset, mDataBlob.size());
|
||||
}
|
||||
if (mHdr.getDataSegmentInfo().is_hashed)
|
||||
{
|
||||
fnd::sha::Sha256(mDataBlob.data(), mDataBlob.size(), calc_hash.bytes);
|
||||
if (calc_hash != mHdr.getDataSegmentInfo().hash)
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "NSO data segment failed SHA256 verification");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NsoProcess::displayNsoHeader()
|
||||
{
|
||||
std::cout << "[NSO Header]" << std::endl;
|
||||
std::cout << " ModuleId: " << fnd::SimpleTextOutput::arrayToString(mHdr.getModuleId().data, nn::hac::nso::kModuleIdSize, false, "") << std::endl;
|
||||
if (_HAS_BIT(mCliOutputMode, OUTPUT_LAYOUT))
|
||||
{
|
||||
std::cout << " Program Segments:" << std::endl;
|
||||
std::cout << " .module_name:" << std::endl;
|
||||
std::cout << " FileOffset: 0x" << std::hex << mHdr.getModuleNameInfo().offset << std::endl;
|
||||
std::cout << " FileSize: 0x" << std::hex << mHdr.getModuleNameInfo().size << std::endl;
|
||||
std::cout << " .text:" << std::endl;
|
||||
std::cout << " FileOffset: 0x" << std::hex << mHdr.getTextSegmentInfo().file_layout.offset << std::endl;
|
||||
std::cout << " FileSize: 0x" << std::hex << mHdr.getTextSegmentInfo().file_layout.size << (mHdr.getTextSegmentInfo().is_compressed? " (COMPRESSED)" : "") << std::endl;
|
||||
std::cout << " .ro:" << std::endl;
|
||||
std::cout << " FileOffset: 0x" << std::hex << mHdr.getRoSegmentInfo().file_layout.offset << std::endl;
|
||||
std::cout << " FileSize: 0x" << std::hex << mHdr.getRoSegmentInfo().file_layout.size << (mHdr.getRoSegmentInfo().is_compressed? " (COMPRESSED)" : "") << std::endl;
|
||||
std::cout << " .data:" << std::endl;
|
||||
std::cout << " FileOffset: 0x" << std::hex << mHdr.getDataSegmentInfo().file_layout.offset << std::endl;
|
||||
std::cout << " FileSize: 0x" << std::hex << mHdr.getDataSegmentInfo().file_layout.size << (mHdr.getDataSegmentInfo().is_compressed? " (COMPRESSED)" : "") << std::endl;
|
||||
}
|
||||
std::cout << " Program Sections:" << std::endl;
|
||||
std::cout << " .text:" << std::endl;
|
||||
std::cout << " MemoryOffset: 0x" << std::hex << mHdr.getTextSegmentInfo().memory_layout.offset << std::endl;
|
||||
std::cout << " MemorySize: 0x" << std::hex << mHdr.getTextSegmentInfo().memory_layout.size << std::endl;
|
||||
if (mHdr.getTextSegmentInfo().is_hashed && _HAS_BIT(mCliOutputMode, OUTPUT_EXTENDED))
|
||||
{
|
||||
std::cout << " Hash: " << fnd::SimpleTextOutput::arrayToString(mHdr.getTextSegmentInfo().hash.bytes, 32, false, "") << std::endl;
|
||||
}
|
||||
std::cout << " .ro:" << std::endl;
|
||||
std::cout << " MemoryOffset: 0x" << std::hex << mHdr.getRoSegmentInfo().memory_layout.offset << std::endl;
|
||||
std::cout << " MemorySize: 0x" << std::hex << mHdr.getRoSegmentInfo().memory_layout.size << std::endl;
|
||||
if (mHdr.getRoSegmentInfo().is_hashed && _HAS_BIT(mCliOutputMode, OUTPUT_EXTENDED))
|
||||
{
|
||||
std::cout << " Hash: " << fnd::SimpleTextOutput::arrayToString(mHdr.getRoSegmentInfo().hash.bytes, 32, false, "") << std::endl;
|
||||
}
|
||||
if (_HAS_BIT(mCliOutputMode, OUTPUT_EXTENDED))
|
||||
{
|
||||
std::cout << " .api_info:" << std::endl;
|
||||
std::cout << " MemoryOffset: 0x" << std::hex << mHdr.getRoEmbeddedInfo().offset << std::endl;
|
||||
std::cout << " MemorySize: 0x" << std::hex << mHdr.getRoEmbeddedInfo().size << std::endl;
|
||||
std::cout << " .dynstr:" << std::endl;
|
||||
std::cout << " MemoryOffset: 0x" << std::hex << mHdr.getRoDynStrInfo().offset << std::endl;
|
||||
std::cout << " MemorySize: 0x" << std::hex << mHdr.getRoDynStrInfo().size << std::endl;
|
||||
std::cout << " .dynsym:" << std::endl;
|
||||
std::cout << " MemoryOffset: 0x" << std::hex << mHdr.getRoDynSymInfo().offset << std::endl;
|
||||
std::cout << " MemorySize: 0x" << std::hex << mHdr.getRoDynSymInfo().size << std::endl;
|
||||
}
|
||||
|
||||
std::cout << " .data:" << std::endl;
|
||||
std::cout << " MemoryOffset: 0x" << std::hex << mHdr.getDataSegmentInfo().memory_layout.offset << std::endl;
|
||||
std::cout << " MemorySize: 0x" << std::hex << mHdr.getDataSegmentInfo().memory_layout.size << std::endl;
|
||||
if (mHdr.getDataSegmentInfo().is_hashed && _HAS_BIT(mCliOutputMode, OUTPUT_EXTENDED))
|
||||
{
|
||||
std::cout << " Hash: " << fnd::SimpleTextOutput::arrayToString(mHdr.getDataSegmentInfo().hash.bytes, 32, false, "") << std::endl;
|
||||
}
|
||||
std::cout << " .bss:" << std::endl;
|
||||
std::cout << " MemorySize: 0x" << std::hex << mHdr.getBssSize() << std::endl;
|
||||
}
|
||||
|
||||
void NsoProcess::processRoMeta()
|
||||
{
|
||||
if (mRoBlob.size())
|
||||
{
|
||||
// setup ro metadata
|
||||
mRoMeta.setApiInfo(mHdr.getRoEmbeddedInfo().offset, mHdr.getRoEmbeddedInfo().size);
|
||||
mRoMeta.setDynSym(mHdr.getRoDynSymInfo().offset, mHdr.getRoDynSymInfo().size);
|
||||
mRoMeta.setDynStr(mHdr.getRoDynStrInfo().offset, mHdr.getRoDynStrInfo().size);
|
||||
mRoMeta.setRoBinary(mRoBlob);
|
||||
mRoMeta.setCliOutputMode(mCliOutputMode);
|
||||
mRoMeta.process();
|
||||
}
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <fnd/SimpleTextOutput.h>
|
||||
#include <fnd/OffsetAdjustedIFile.h>
|
||||
#include <fnd/Vec.h>
|
||||
#include <fnd/lz4.h>
|
||||
#include "NsoProcess.h"
|
||||
|
||||
NsoProcess::NsoProcess():
|
||||
mFile(),
|
||||
mCliOutputMode(_BIT(OUTPUT_BASIC)),
|
||||
mVerify(false)
|
||||
{
|
||||
}
|
||||
|
||||
void NsoProcess::process()
|
||||
{
|
||||
importHeader();
|
||||
importCodeSegments();
|
||||
if (_HAS_BIT(mCliOutputMode, OUTPUT_BASIC))
|
||||
displayNsoHeader();
|
||||
|
||||
processRoMeta();
|
||||
}
|
||||
|
||||
void NsoProcess::setInputFile(const fnd::SharedPtr<fnd::IFile>& file)
|
||||
{
|
||||
mFile = file;
|
||||
}
|
||||
|
||||
void NsoProcess::setCliOutputMode(CliOutputMode type)
|
||||
{
|
||||
mCliOutputMode = type;
|
||||
}
|
||||
|
||||
void NsoProcess::setVerifyMode(bool verify)
|
||||
{
|
||||
mVerify = verify;
|
||||
}
|
||||
|
||||
void NsoProcess::setInstructionType(nn::hac::meta::InstructionType type)
|
||||
{
|
||||
mRoMeta.setInstructionType(type);
|
||||
}
|
||||
|
||||
void NsoProcess::setListApi(bool listApi)
|
||||
{
|
||||
mRoMeta.setListApi(listApi);
|
||||
}
|
||||
|
||||
void NsoProcess::setListSymbols(bool listSymbols)
|
||||
{
|
||||
mRoMeta.setListSymbols(listSymbols);
|
||||
}
|
||||
|
||||
const RoMetadataProcess& NsoProcess::getRoMetadataProcess() const
|
||||
{
|
||||
return mRoMeta;
|
||||
}
|
||||
|
||||
void NsoProcess::importHeader()
|
||||
{
|
||||
fnd::Vec<byte_t> scratch;
|
||||
|
||||
if (*mFile == nullptr)
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "No file reader set.");
|
||||
}
|
||||
|
||||
if ((*mFile)->size() < sizeof(nn::hac::sNsoHeader))
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "Corrupt NSO: file too small");
|
||||
}
|
||||
|
||||
scratch.alloc(sizeof(nn::hac::sNsoHeader));
|
||||
(*mFile)->read(scratch.data(), 0, scratch.size());
|
||||
|
||||
mHdr.fromBytes(scratch.data(), scratch.size());
|
||||
}
|
||||
|
||||
void NsoProcess::importCodeSegments()
|
||||
{
|
||||
fnd::Vec<byte_t> scratch;
|
||||
uint32_t decompressed_len;
|
||||
fnd::sha::sSha256Hash calc_hash;
|
||||
|
||||
// process text segment
|
||||
if (mHdr.getTextSegmentInfo().is_compressed)
|
||||
{
|
||||
scratch.alloc(mHdr.getTextSegmentInfo().file_layout.size);
|
||||
(*mFile)->read(scratch.data(), mHdr.getTextSegmentInfo().file_layout.offset, scratch.size());
|
||||
mTextBlob.alloc(mHdr.getTextSegmentInfo().memory_layout.size);
|
||||
fnd::lz4::decompressData(scratch.data(), (uint32_t)scratch.size(), mTextBlob.data(), (uint32_t)mTextBlob.size(), decompressed_len);
|
||||
if (decompressed_len != mTextBlob.size())
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "NSO text segment failed to decompress");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mTextBlob.alloc(mHdr.getTextSegmentInfo().file_layout.size);
|
||||
(*mFile)->read(mTextBlob.data(), mHdr.getTextSegmentInfo().file_layout.offset, mTextBlob.size());
|
||||
}
|
||||
if (mHdr.getTextSegmentInfo().is_hashed)
|
||||
{
|
||||
fnd::sha::Sha256(mTextBlob.data(), mTextBlob.size(), calc_hash.bytes);
|
||||
if (calc_hash != mHdr.getTextSegmentInfo().hash)
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "NSO text segment failed SHA256 verification");
|
||||
}
|
||||
}
|
||||
|
||||
// process ro segment
|
||||
if (mHdr.getRoSegmentInfo().is_compressed)
|
||||
{
|
||||
scratch.alloc(mHdr.getRoSegmentInfo().file_layout.size);
|
||||
(*mFile)->read(scratch.data(), mHdr.getRoSegmentInfo().file_layout.offset, scratch.size());
|
||||
mRoBlob.alloc(mHdr.getRoSegmentInfo().memory_layout.size);
|
||||
fnd::lz4::decompressData(scratch.data(), (uint32_t)scratch.size(), mRoBlob.data(), (uint32_t)mRoBlob.size(), decompressed_len);
|
||||
if (decompressed_len != mRoBlob.size())
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "NSO ro segment failed to decompress");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mRoBlob.alloc(mHdr.getRoSegmentInfo().file_layout.size);
|
||||
(*mFile)->read(mRoBlob.data(), mHdr.getRoSegmentInfo().file_layout.offset, mRoBlob.size());
|
||||
}
|
||||
if (mHdr.getRoSegmentInfo().is_hashed)
|
||||
{
|
||||
fnd::sha::Sha256(mRoBlob.data(), mRoBlob.size(), calc_hash.bytes);
|
||||
if (calc_hash != mHdr.getRoSegmentInfo().hash)
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "NSO ro segment failed SHA256 verification");
|
||||
}
|
||||
}
|
||||
|
||||
// process data segment
|
||||
if (mHdr.getDataSegmentInfo().is_compressed)
|
||||
{
|
||||
scratch.alloc(mHdr.getDataSegmentInfo().file_layout.size);
|
||||
(*mFile)->read(scratch.data(), mHdr.getDataSegmentInfo().file_layout.offset, scratch.size());
|
||||
mDataBlob.alloc(mHdr.getDataSegmentInfo().memory_layout.size);
|
||||
fnd::lz4::decompressData(scratch.data(), (uint32_t)scratch.size(), mDataBlob.data(), (uint32_t)mDataBlob.size(), decompressed_len);
|
||||
if (decompressed_len != mDataBlob.size())
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "NSO data segment failed to decompress");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mDataBlob.alloc(mHdr.getDataSegmentInfo().file_layout.size);
|
||||
(*mFile)->read(mDataBlob.data(), mHdr.getDataSegmentInfo().file_layout.offset, mDataBlob.size());
|
||||
}
|
||||
if (mHdr.getDataSegmentInfo().is_hashed)
|
||||
{
|
||||
fnd::sha::Sha256(mDataBlob.data(), mDataBlob.size(), calc_hash.bytes);
|
||||
if (calc_hash != mHdr.getDataSegmentInfo().hash)
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "NSO data segment failed SHA256 verification");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NsoProcess::displayNsoHeader()
|
||||
{
|
||||
std::cout << "[NSO Header]" << std::endl;
|
||||
std::cout << " ModuleId: " << fnd::SimpleTextOutput::arrayToString(mHdr.getModuleId().data, nn::hac::nso::kModuleIdSize, false, "") << std::endl;
|
||||
if (_HAS_BIT(mCliOutputMode, OUTPUT_LAYOUT))
|
||||
{
|
||||
std::cout << " Program Segments:" << std::endl;
|
||||
std::cout << " .module_name:" << std::endl;
|
||||
std::cout << " FileOffset: 0x" << std::hex << mHdr.getModuleNameInfo().offset << std::endl;
|
||||
std::cout << " FileSize: 0x" << std::hex << mHdr.getModuleNameInfo().size << std::endl;
|
||||
std::cout << " .text:" << std::endl;
|
||||
std::cout << " FileOffset: 0x" << std::hex << mHdr.getTextSegmentInfo().file_layout.offset << std::endl;
|
||||
std::cout << " FileSize: 0x" << std::hex << mHdr.getTextSegmentInfo().file_layout.size << (mHdr.getTextSegmentInfo().is_compressed? " (COMPRESSED)" : "") << std::endl;
|
||||
std::cout << " .ro:" << std::endl;
|
||||
std::cout << " FileOffset: 0x" << std::hex << mHdr.getRoSegmentInfo().file_layout.offset << std::endl;
|
||||
std::cout << " FileSize: 0x" << std::hex << mHdr.getRoSegmentInfo().file_layout.size << (mHdr.getRoSegmentInfo().is_compressed? " (COMPRESSED)" : "") << std::endl;
|
||||
std::cout << " .data:" << std::endl;
|
||||
std::cout << " FileOffset: 0x" << std::hex << mHdr.getDataSegmentInfo().file_layout.offset << std::endl;
|
||||
std::cout << " FileSize: 0x" << std::hex << mHdr.getDataSegmentInfo().file_layout.size << (mHdr.getDataSegmentInfo().is_compressed? " (COMPRESSED)" : "") << std::endl;
|
||||
}
|
||||
std::cout << " Program Sections:" << std::endl;
|
||||
std::cout << " .text:" << std::endl;
|
||||
std::cout << " MemoryOffset: 0x" << std::hex << mHdr.getTextSegmentInfo().memory_layout.offset << std::endl;
|
||||
std::cout << " MemorySize: 0x" << std::hex << mHdr.getTextSegmentInfo().memory_layout.size << std::endl;
|
||||
if (mHdr.getTextSegmentInfo().is_hashed && _HAS_BIT(mCliOutputMode, OUTPUT_EXTENDED))
|
||||
{
|
||||
std::cout << " Hash: " << fnd::SimpleTextOutput::arrayToString(mHdr.getTextSegmentInfo().hash.bytes, 32, false, "") << std::endl;
|
||||
}
|
||||
std::cout << " .ro:" << std::endl;
|
||||
std::cout << " MemoryOffset: 0x" << std::hex << mHdr.getRoSegmentInfo().memory_layout.offset << std::endl;
|
||||
std::cout << " MemorySize: 0x" << std::hex << mHdr.getRoSegmentInfo().memory_layout.size << std::endl;
|
||||
if (mHdr.getRoSegmentInfo().is_hashed && _HAS_BIT(mCliOutputMode, OUTPUT_EXTENDED))
|
||||
{
|
||||
std::cout << " Hash: " << fnd::SimpleTextOutput::arrayToString(mHdr.getRoSegmentInfo().hash.bytes, 32, false, "") << std::endl;
|
||||
}
|
||||
if (_HAS_BIT(mCliOutputMode, OUTPUT_EXTENDED))
|
||||
{
|
||||
std::cout << " .api_info:" << std::endl;
|
||||
std::cout << " MemoryOffset: 0x" << std::hex << mHdr.getRoEmbeddedInfo().offset << std::endl;
|
||||
std::cout << " MemorySize: 0x" << std::hex << mHdr.getRoEmbeddedInfo().size << std::endl;
|
||||
std::cout << " .dynstr:" << std::endl;
|
||||
std::cout << " MemoryOffset: 0x" << std::hex << mHdr.getRoDynStrInfo().offset << std::endl;
|
||||
std::cout << " MemorySize: 0x" << std::hex << mHdr.getRoDynStrInfo().size << std::endl;
|
||||
std::cout << " .dynsym:" << std::endl;
|
||||
std::cout << " MemoryOffset: 0x" << std::hex << mHdr.getRoDynSymInfo().offset << std::endl;
|
||||
std::cout << " MemorySize: 0x" << std::hex << mHdr.getRoDynSymInfo().size << std::endl;
|
||||
}
|
||||
|
||||
std::cout << " .data:" << std::endl;
|
||||
std::cout << " MemoryOffset: 0x" << std::hex << mHdr.getDataSegmentInfo().memory_layout.offset << std::endl;
|
||||
std::cout << " MemorySize: 0x" << std::hex << mHdr.getDataSegmentInfo().memory_layout.size << std::endl;
|
||||
if (mHdr.getDataSegmentInfo().is_hashed && _HAS_BIT(mCliOutputMode, OUTPUT_EXTENDED))
|
||||
{
|
||||
std::cout << " Hash: " << fnd::SimpleTextOutput::arrayToString(mHdr.getDataSegmentInfo().hash.bytes, 32, false, "") << std::endl;
|
||||
}
|
||||
std::cout << " .bss:" << std::endl;
|
||||
std::cout << " MemorySize: 0x" << std::hex << mHdr.getBssSize() << std::endl;
|
||||
}
|
||||
|
||||
void NsoProcess::processRoMeta()
|
||||
{
|
||||
if (mRoBlob.size())
|
||||
{
|
||||
// setup ro metadata
|
||||
mRoMeta.setApiInfo(mHdr.getRoEmbeddedInfo().offset, mHdr.getRoEmbeddedInfo().size);
|
||||
mRoMeta.setDynSym(mHdr.getRoDynSymInfo().offset, mHdr.getRoDynSymInfo().size);
|
||||
mRoMeta.setDynStr(mHdr.getRoDynStrInfo().offset, mHdr.getRoDynStrInfo().size);
|
||||
mRoMeta.setRoBinary(mRoBlob);
|
||||
mRoMeta.setCliOutputMode(mCliOutputMode);
|
||||
mRoMeta.process();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,47 +1,47 @@
|
|||
#pragma once
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <fnd/types.h>
|
||||
#include <fnd/IFile.h>
|
||||
#include <fnd/SharedPtr.h>
|
||||
#include <nn/hac/define/meta.h>
|
||||
#include <nn/hac/NsoHeader.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "RoMetadataProcess.h"
|
||||
|
||||
class NsoProcess
|
||||
{
|
||||
public:
|
||||
NsoProcess();
|
||||
|
||||
void process();
|
||||
|
||||
void setInputFile(const fnd::SharedPtr<fnd::IFile>& file);
|
||||
void setCliOutputMode(CliOutputMode type);
|
||||
void setVerifyMode(bool verify);
|
||||
|
||||
void setInstructionType(nn::hac::meta::InstructionType type);
|
||||
void setListApi(bool listApi);
|
||||
void setListSymbols(bool listSymbols);
|
||||
|
||||
const RoMetadataProcess& getRoMetadataProcess() const;
|
||||
private:
|
||||
const std::string kModuleName = "NsoProcess";
|
||||
|
||||
fnd::SharedPtr<fnd::IFile> mFile;
|
||||
CliOutputMode mCliOutputMode;
|
||||
bool mVerify;
|
||||
nn::hac::meta::InstructionType mInstructionType;
|
||||
bool mListApi;
|
||||
bool mListSymbols;
|
||||
|
||||
nn::hac::NsoHeader mHdr;
|
||||
fnd::Vec<byte_t> mTextBlob, mRoBlob, mDataBlob;
|
||||
RoMetadataProcess mRoMeta;
|
||||
|
||||
void importHeader();
|
||||
void importCodeSegments();
|
||||
void displayNsoHeader();
|
||||
void processRoMeta();
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <fnd/types.h>
|
||||
#include <fnd/IFile.h>
|
||||
#include <fnd/SharedPtr.h>
|
||||
#include <nn/hac/define/meta.h>
|
||||
#include <nn/hac/NsoHeader.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "RoMetadataProcess.h"
|
||||
|
||||
class NsoProcess
|
||||
{
|
||||
public:
|
||||
NsoProcess();
|
||||
|
||||
void process();
|
||||
|
||||
void setInputFile(const fnd::SharedPtr<fnd::IFile>& file);
|
||||
void setCliOutputMode(CliOutputMode type);
|
||||
void setVerifyMode(bool verify);
|
||||
|
||||
void setInstructionType(nn::hac::meta::InstructionType type);
|
||||
void setListApi(bool listApi);
|
||||
void setListSymbols(bool listSymbols);
|
||||
|
||||
const RoMetadataProcess& getRoMetadataProcess() const;
|
||||
private:
|
||||
const std::string kModuleName = "NsoProcess";
|
||||
|
||||
fnd::SharedPtr<fnd::IFile> mFile;
|
||||
CliOutputMode mCliOutputMode;
|
||||
bool mVerify;
|
||||
nn::hac::meta::InstructionType mInstructionType;
|
||||
bool mListApi;
|
||||
bool mListSymbols;
|
||||
|
||||
nn::hac::NsoHeader mHdr;
|
||||
fnd::Vec<byte_t> mTextBlob, mRoBlob, mDataBlob;
|
||||
RoMetadataProcess mRoMeta;
|
||||
|
||||
void importHeader();
|
||||
void importCodeSegments();
|
||||
void displayNsoHeader();
|
||||
void processRoMeta();
|
||||
};
|
||||
|
|
@ -1,283 +1,283 @@
|
|||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <fnd/types.h>
|
||||
|
||||
#include "RoMetadataProcess.h"
|
||||
|
||||
RoMetadataProcess::RoMetadataProcess() :
|
||||
mCliOutputMode(_BIT(OUTPUT_BASIC)),
|
||||
mInstructionType(nn::hac::meta::INSTR_64BIT),
|
||||
mListApi(false),
|
||||
mListSymbols(false),
|
||||
mApiInfo(),
|
||||
mDynSym(),
|
||||
mDynStr(),
|
||||
mRoBlob(),
|
||||
mSdkVerApiList(),
|
||||
mPublicApiList(),
|
||||
mDebugApiList(),
|
||||
mPrivateApiList(),
|
||||
mSymbolList()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RoMetadataProcess::process()
|
||||
{
|
||||
importApiList();
|
||||
|
||||
if (_HAS_BIT(mCliOutputMode, OUTPUT_BASIC))
|
||||
displayRoMetaData();
|
||||
}
|
||||
|
||||
void RoMetadataProcess::setRoBinary(const fnd::Vec<byte_t>& bin)
|
||||
{
|
||||
mRoBlob = bin;
|
||||
}
|
||||
|
||||
void RoMetadataProcess::setApiInfo(size_t offset, size_t size)
|
||||
{
|
||||
mApiInfo.offset = offset;
|
||||
mApiInfo.size = size;
|
||||
}
|
||||
void RoMetadataProcess::setDynSym(size_t offset, size_t size)
|
||||
{
|
||||
mDynSym.offset = offset;
|
||||
mDynSym.size = size;
|
||||
}
|
||||
void RoMetadataProcess::setDynStr(size_t offset, size_t size)
|
||||
{
|
||||
mDynStr.offset = offset;
|
||||
mDynStr.size = size;
|
||||
}
|
||||
|
||||
void RoMetadataProcess::setCliOutputMode(CliOutputMode type)
|
||||
{
|
||||
mCliOutputMode = type;
|
||||
}
|
||||
|
||||
void RoMetadataProcess::setInstructionType(nn::hac::meta::InstructionType type)
|
||||
{
|
||||
mInstructionType = type;
|
||||
}
|
||||
|
||||
void RoMetadataProcess::setListApi(bool listApi)
|
||||
{
|
||||
mListApi = listApi;
|
||||
}
|
||||
|
||||
void RoMetadataProcess::setListSymbols(bool listSymbols)
|
||||
{
|
||||
mListSymbols = listSymbols;
|
||||
}
|
||||
|
||||
const std::vector<SdkApiString>& RoMetadataProcess::getSdkVerApiList() const
|
||||
{
|
||||
return mSdkVerApiList;
|
||||
}
|
||||
|
||||
const std::vector<SdkApiString>& RoMetadataProcess::getPublicApiList() const
|
||||
{
|
||||
return mPublicApiList;
|
||||
}
|
||||
|
||||
const std::vector<SdkApiString>& RoMetadataProcess::getDebugApiList() const
|
||||
{
|
||||
return mDebugApiList;
|
||||
}
|
||||
|
||||
const std::vector<SdkApiString>& RoMetadataProcess::getPrivateApiList() const
|
||||
{
|
||||
return mPrivateApiList;
|
||||
}
|
||||
|
||||
const fnd::List<ElfSymbolParser::sElfSymbol>& RoMetadataProcess::getSymbolList() const
|
||||
{
|
||||
return mSymbolList.getSymbolList();
|
||||
}
|
||||
|
||||
void RoMetadataProcess::importApiList()
|
||||
{
|
||||
if (mRoBlob.size() == 0)
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "No ro binary set.");
|
||||
}
|
||||
|
||||
if (mApiInfo.size > 0)
|
||||
{
|
||||
std::stringstream list_stream(std::string((char*)mRoBlob.data() + mApiInfo.offset, mApiInfo.size));
|
||||
std::string api_str;
|
||||
|
||||
while(std::getline(list_stream, api_str, (char)0x00))
|
||||
{
|
||||
SdkApiString api(api_str);
|
||||
|
||||
if (api.getApiType() == SdkApiString::API_SDK_VERSION)
|
||||
mSdkVerApiList.push_back(api);
|
||||
else if (api.getApiType() == SdkApiString::API_MIDDLEWARE)
|
||||
mPublicApiList.push_back(api);
|
||||
else if (api.getApiType() == SdkApiString::API_DEBUG)
|
||||
mDebugApiList.push_back(api);
|
||||
else if (api.getApiType() == SdkApiString::API_PRIVATE)
|
||||
mPrivateApiList.push_back(api);
|
||||
}
|
||||
}
|
||||
|
||||
if (mDynSym.size > 0)
|
||||
{
|
||||
mSymbolList.parseData(mRoBlob.data() + mDynSym.offset, mDynSym.size, mRoBlob.data() + mDynStr.offset, mDynStr.size, mInstructionType == nn::hac::meta::INSTR_64BIT);
|
||||
}
|
||||
}
|
||||
|
||||
void RoMetadataProcess::displayRoMetaData()
|
||||
{
|
||||
size_t api_num = mSdkVerApiList.size() + mPublicApiList.size() + mDebugApiList.size() + mPrivateApiList.size();
|
||||
|
||||
if (api_num > 0 && (mListApi || _HAS_BIT(mCliOutputMode, OUTPUT_EXTENDED)))
|
||||
{
|
||||
std::cout << "[SDK API List]" << std::endl;
|
||||
if (mSdkVerApiList.size() > 0)
|
||||
{
|
||||
std::cout << " Sdk Revision: " << mSdkVerApiList[0].getModuleName() << std::endl;
|
||||
}
|
||||
if (mPublicApiList.size() > 0)
|
||||
{
|
||||
std::cout << " Public APIs:" << std::endl;
|
||||
for (size_t i = 0; i < mPublicApiList.size(); i++)
|
||||
{
|
||||
std::cout << " " << mPublicApiList[i].getModuleName() << " (vender: " << mPublicApiList[i].getVenderName() << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
if (mDebugApiList.size() > 0)
|
||||
{
|
||||
std::cout << " Debug APIs:" << std::endl;
|
||||
for (size_t i = 0; i < mDebugApiList.size(); i++)
|
||||
{
|
||||
std::cout << " " << mDebugApiList[i].getModuleName() << " (vender: " << mDebugApiList[i].getVenderName() << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
if (mPrivateApiList.size() > 0)
|
||||
{
|
||||
std::cout << " Private APIs:" << std::endl;
|
||||
for (size_t i = 0; i < mPrivateApiList.size(); i++)
|
||||
{
|
||||
std::cout << " " << mPrivateApiList[i].getModuleName() << " (vender: " << mPrivateApiList[i].getVenderName() << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mSymbolList.getSymbolList().size() > 0 && (mListSymbols || _HAS_BIT(mCliOutputMode, OUTPUT_EXTENDED)))
|
||||
{
|
||||
std::cout << "[Symbol List]" << std::endl;
|
||||
for (size_t i = 0; i < mSymbolList.getSymbolList().size(); i++)
|
||||
{
|
||||
const ElfSymbolParser::sElfSymbol& symbol = mSymbolList.getSymbolList()[i];
|
||||
std::cout << " " << symbol.name << " [SHN=" << getSectionIndexStr(symbol.shn_index) << " (" << std::hex << std::setw(4) << std::setfill('0') << symbol.shn_index << ")][STT=" << getSymbolTypeStr(symbol.symbol_type) << "][STB=" << getSymbolBindingStr(symbol.symbol_binding) << "]" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char* RoMetadataProcess::getSectionIndexStr(uint16_t shn_index) const
|
||||
{
|
||||
const char* str;
|
||||
switch (shn_index)
|
||||
{
|
||||
case (fnd::elf::SHN_UNDEF):
|
||||
str = "UNDEF";
|
||||
break;
|
||||
case (fnd::elf::SHN_LOPROC):
|
||||
str = "LOPROC";
|
||||
break;
|
||||
case (fnd::elf::SHN_HIPROC):
|
||||
str = "HIPROC";
|
||||
break;
|
||||
case (fnd::elf::SHN_LOOS):
|
||||
str = "LOOS";
|
||||
break;
|
||||
case (fnd::elf::SHN_HIOS):
|
||||
str = "HIOS";
|
||||
break;
|
||||
case (fnd::elf::SHN_ABS):
|
||||
str = "ABS";
|
||||
break;
|
||||
case (fnd::elf::SHN_COMMON):
|
||||
str = "COMMON";
|
||||
break;
|
||||
default:
|
||||
str = "UNKNOWN";
|
||||
break;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
const char* RoMetadataProcess::getSymbolTypeStr(byte_t symbol_type) const
|
||||
{
|
||||
const char* str;
|
||||
switch (symbol_type)
|
||||
{
|
||||
case (fnd::elf::STT_NOTYPE):
|
||||
str = "NOTYPE";
|
||||
break;
|
||||
case (fnd::elf::STT_OBJECT):
|
||||
str = "OBJECT";
|
||||
break;
|
||||
case (fnd::elf::STT_FUNC):
|
||||
str = "FUNC";
|
||||
break;
|
||||
case (fnd::elf::STT_SECTION):
|
||||
str = "SECTION";
|
||||
break;
|
||||
case (fnd::elf::STT_FILE):
|
||||
str = "FILE";
|
||||
break;
|
||||
case (fnd::elf::STT_LOOS):
|
||||
str = "LOOS";
|
||||
break;
|
||||
case (fnd::elf::STT_HIOS):
|
||||
str = "HIOS";
|
||||
break;
|
||||
case (fnd::elf::STT_LOPROC):
|
||||
str = "LOPROC";
|
||||
break;
|
||||
case (fnd::elf::STT_HIPROC):
|
||||
str = "HIPROC";
|
||||
break;
|
||||
default:
|
||||
str = "UNKNOWN";
|
||||
break;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
const char* RoMetadataProcess::getSymbolBindingStr(byte_t symbol_binding) const
|
||||
{
|
||||
const char* str;
|
||||
switch (symbol_binding)
|
||||
{
|
||||
case (fnd::elf::STB_LOCAL):
|
||||
str = "LOCAL";
|
||||
break;
|
||||
case (fnd::elf::STB_GLOBAL):
|
||||
str = "GLOBAL";
|
||||
break;
|
||||
case (fnd::elf::STB_WEAK):
|
||||
str = "WEAK";
|
||||
break;
|
||||
case (fnd::elf::STB_LOOS):
|
||||
str = "LOOS";
|
||||
break;
|
||||
case (fnd::elf::STB_HIOS):
|
||||
str = "HIOS";
|
||||
break;
|
||||
case (fnd::elf::STB_LOPROC):
|
||||
str = "LOPROC";
|
||||
break;
|
||||
case (fnd::elf::STB_HIPROC):
|
||||
str = "HIPROC";
|
||||
break;
|
||||
default:
|
||||
str = "UNKNOWN";
|
||||
break;
|
||||
}
|
||||
return str;
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <fnd/types.h>
|
||||
|
||||
#include "RoMetadataProcess.h"
|
||||
|
||||
RoMetadataProcess::RoMetadataProcess() :
|
||||
mCliOutputMode(_BIT(OUTPUT_BASIC)),
|
||||
mInstructionType(nn::hac::meta::INSTR_64BIT),
|
||||
mListApi(false),
|
||||
mListSymbols(false),
|
||||
mApiInfo(),
|
||||
mDynSym(),
|
||||
mDynStr(),
|
||||
mRoBlob(),
|
||||
mSdkVerApiList(),
|
||||
mPublicApiList(),
|
||||
mDebugApiList(),
|
||||
mPrivateApiList(),
|
||||
mSymbolList()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RoMetadataProcess::process()
|
||||
{
|
||||
importApiList();
|
||||
|
||||
if (_HAS_BIT(mCliOutputMode, OUTPUT_BASIC))
|
||||
displayRoMetaData();
|
||||
}
|
||||
|
||||
void RoMetadataProcess::setRoBinary(const fnd::Vec<byte_t>& bin)
|
||||
{
|
||||
mRoBlob = bin;
|
||||
}
|
||||
|
||||
void RoMetadataProcess::setApiInfo(size_t offset, size_t size)
|
||||
{
|
||||
mApiInfo.offset = offset;
|
||||
mApiInfo.size = size;
|
||||
}
|
||||
void RoMetadataProcess::setDynSym(size_t offset, size_t size)
|
||||
{
|
||||
mDynSym.offset = offset;
|
||||
mDynSym.size = size;
|
||||
}
|
||||
void RoMetadataProcess::setDynStr(size_t offset, size_t size)
|
||||
{
|
||||
mDynStr.offset = offset;
|
||||
mDynStr.size = size;
|
||||
}
|
||||
|
||||
void RoMetadataProcess::setCliOutputMode(CliOutputMode type)
|
||||
{
|
||||
mCliOutputMode = type;
|
||||
}
|
||||
|
||||
void RoMetadataProcess::setInstructionType(nn::hac::meta::InstructionType type)
|
||||
{
|
||||
mInstructionType = type;
|
||||
}
|
||||
|
||||
void RoMetadataProcess::setListApi(bool listApi)
|
||||
{
|
||||
mListApi = listApi;
|
||||
}
|
||||
|
||||
void RoMetadataProcess::setListSymbols(bool listSymbols)
|
||||
{
|
||||
mListSymbols = listSymbols;
|
||||
}
|
||||
|
||||
const std::vector<SdkApiString>& RoMetadataProcess::getSdkVerApiList() const
|
||||
{
|
||||
return mSdkVerApiList;
|
||||
}
|
||||
|
||||
const std::vector<SdkApiString>& RoMetadataProcess::getPublicApiList() const
|
||||
{
|
||||
return mPublicApiList;
|
||||
}
|
||||
|
||||
const std::vector<SdkApiString>& RoMetadataProcess::getDebugApiList() const
|
||||
{
|
||||
return mDebugApiList;
|
||||
}
|
||||
|
||||
const std::vector<SdkApiString>& RoMetadataProcess::getPrivateApiList() const
|
||||
{
|
||||
return mPrivateApiList;
|
||||
}
|
||||
|
||||
const fnd::List<ElfSymbolParser::sElfSymbol>& RoMetadataProcess::getSymbolList() const
|
||||
{
|
||||
return mSymbolList.getSymbolList();
|
||||
}
|
||||
|
||||
void RoMetadataProcess::importApiList()
|
||||
{
|
||||
if (mRoBlob.size() == 0)
|
||||
{
|
||||
throw fnd::Exception(kModuleName, "No ro binary set.");
|
||||
}
|
||||
|
||||
if (mApiInfo.size > 0)
|
||||
{
|
||||
std::stringstream list_stream(std::string((char*)mRoBlob.data() + mApiInfo.offset, mApiInfo.size));
|
||||
std::string api_str;
|
||||
|
||||
while(std::getline(list_stream, api_str, (char)0x00))
|
||||
{
|
||||
SdkApiString api(api_str);
|
||||
|
||||
if (api.getApiType() == SdkApiString::API_SDK_VERSION)
|
||||
mSdkVerApiList.push_back(api);
|
||||
else if (api.getApiType() == SdkApiString::API_MIDDLEWARE)
|
||||
mPublicApiList.push_back(api);
|
||||
else if (api.getApiType() == SdkApiString::API_DEBUG)
|
||||
mDebugApiList.push_back(api);
|
||||
else if (api.getApiType() == SdkApiString::API_PRIVATE)
|
||||
mPrivateApiList.push_back(api);
|
||||
}
|
||||
}
|
||||
|
||||
if (mDynSym.size > 0)
|
||||
{
|
||||
mSymbolList.parseData(mRoBlob.data() + mDynSym.offset, mDynSym.size, mRoBlob.data() + mDynStr.offset, mDynStr.size, mInstructionType == nn::hac::meta::INSTR_64BIT);
|
||||
}
|
||||
}
|
||||
|
||||
void RoMetadataProcess::displayRoMetaData()
|
||||
{
|
||||
size_t api_num = mSdkVerApiList.size() + mPublicApiList.size() + mDebugApiList.size() + mPrivateApiList.size();
|
||||
|
||||
if (api_num > 0 && (mListApi || _HAS_BIT(mCliOutputMode, OUTPUT_EXTENDED)))
|
||||
{
|
||||
std::cout << "[SDK API List]" << std::endl;
|
||||
if (mSdkVerApiList.size() > 0)
|
||||
{
|
||||
std::cout << " Sdk Revision: " << mSdkVerApiList[0].getModuleName() << std::endl;
|
||||
}
|
||||
if (mPublicApiList.size() > 0)
|
||||
{
|
||||
std::cout << " Public APIs:" << std::endl;
|
||||
for (size_t i = 0; i < mPublicApiList.size(); i++)
|
||||
{
|
||||
std::cout << " " << mPublicApiList[i].getModuleName() << " (vender: " << mPublicApiList[i].getVenderName() << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
if (mDebugApiList.size() > 0)
|
||||
{
|
||||
std::cout << " Debug APIs:" << std::endl;
|
||||
for (size_t i = 0; i < mDebugApiList.size(); i++)
|
||||
{
|
||||
std::cout << " " << mDebugApiList[i].getModuleName() << " (vender: " << mDebugApiList[i].getVenderName() << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
if (mPrivateApiList.size() > 0)
|
||||
{
|
||||
std::cout << " Private APIs:" << std::endl;
|
||||
for (size_t i = 0; i < mPrivateApiList.size(); i++)
|
||||
{
|
||||
std::cout << " " << mPrivateApiList[i].getModuleName() << " (vender: " << mPrivateApiList[i].getVenderName() << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mSymbolList.getSymbolList().size() > 0 && (mListSymbols || _HAS_BIT(mCliOutputMode, OUTPUT_EXTENDED)))
|
||||
{
|
||||
std::cout << "[Symbol List]" << std::endl;
|
||||
for (size_t i = 0; i < mSymbolList.getSymbolList().size(); i++)
|
||||
{
|
||||
const ElfSymbolParser::sElfSymbol& symbol = mSymbolList.getSymbolList()[i];
|
||||
std::cout << " " << symbol.name << " [SHN=" << getSectionIndexStr(symbol.shn_index) << " (" << std::hex << std::setw(4) << std::setfill('0') << symbol.shn_index << ")][STT=" << getSymbolTypeStr(symbol.symbol_type) << "][STB=" << getSymbolBindingStr(symbol.symbol_binding) << "]" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char* RoMetadataProcess::getSectionIndexStr(uint16_t shn_index) const
|
||||
{
|
||||
const char* str;
|
||||
switch (shn_index)
|
||||
{
|
||||
case (fnd::elf::SHN_UNDEF):
|
||||
str = "UNDEF";
|
||||
break;
|
||||
case (fnd::elf::SHN_LOPROC):
|
||||
str = "LOPROC";
|
||||
break;
|
||||
case (fnd::elf::SHN_HIPROC):
|
||||
str = "HIPROC";
|
||||
break;
|
||||
case (fnd::elf::SHN_LOOS):
|
||||
str = "LOOS";
|
||||
break;
|
||||
case (fnd::elf::SHN_HIOS):
|
||||
str = "HIOS";
|
||||
break;
|
||||
case (fnd::elf::SHN_ABS):
|
||||
str = "ABS";
|
||||
break;
|
||||
case (fnd::elf::SHN_COMMON):
|
||||
str = "COMMON";
|
||||
break;
|
||||
default:
|
||||
str = "UNKNOWN";
|
||||
break;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
const char* RoMetadataProcess::getSymbolTypeStr(byte_t symbol_type) const
|
||||
{
|
||||
const char* str;
|
||||
switch (symbol_type)
|
||||
{
|
||||
case (fnd::elf::STT_NOTYPE):
|
||||
str = "NOTYPE";
|
||||
break;
|
||||
case (fnd::elf::STT_OBJECT):
|
||||
str = "OBJECT";
|
||||
break;
|
||||
case (fnd::elf::STT_FUNC):
|
||||
str = "FUNC";
|
||||
break;
|
||||
case (fnd::elf::STT_SECTION):
|
||||
str = "SECTION";
|
||||
break;
|
||||
case (fnd::elf::STT_FILE):
|
||||
str = "FILE";
|
||||
break;
|
||||
case (fnd::elf::STT_LOOS):
|
||||
str = "LOOS";
|
||||
break;
|
||||
case (fnd::elf::STT_HIOS):
|
||||
str = "HIOS";
|
||||
break;
|
||||
case (fnd::elf::STT_LOPROC):
|
||||
str = "LOPROC";
|
||||
break;
|
||||
case (fnd::elf::STT_HIPROC):
|
||||
str = "HIPROC";
|
||||
break;
|
||||
default:
|
||||
str = "UNKNOWN";
|
||||
break;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
const char* RoMetadataProcess::getSymbolBindingStr(byte_t symbol_binding) const
|
||||
{
|
||||
const char* str;
|
||||
switch (symbol_binding)
|
||||
{
|
||||
case (fnd::elf::STB_LOCAL):
|
||||
str = "LOCAL";
|
||||
break;
|
||||
case (fnd::elf::STB_GLOBAL):
|
||||
str = "GLOBAL";
|
||||
break;
|
||||
case (fnd::elf::STB_WEAK):
|
||||
str = "WEAK";
|
||||
break;
|
||||
case (fnd::elf::STB_LOOS):
|
||||
str = "LOOS";
|
||||
break;
|
||||
case (fnd::elf::STB_HIOS):
|
||||
str = "HIOS";
|
||||
break;
|
||||
case (fnd::elf::STB_LOPROC):
|
||||
str = "LOPROC";
|
||||
break;
|
||||
case (fnd::elf::STB_HIPROC):
|
||||
str = "HIPROC";
|
||||
break;
|
||||
default:
|
||||
str = "UNKNOWN";
|
||||
break;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
|
@ -1,68 +1,68 @@
|
|||
#pragma once
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <fnd/types.h>
|
||||
#include <fnd/Vec.h>
|
||||
|
||||
#include <nn/hac/define/meta.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "SdkApiString.h"
|
||||
#include "ElfSymbolParser.h"
|
||||
|
||||
class RoMetadataProcess
|
||||
{
|
||||
public:
|
||||
RoMetadataProcess();
|
||||
|
||||
void process();
|
||||
|
||||
void setRoBinary(const fnd::Vec<byte_t>& bin);
|
||||
void setApiInfo(size_t offset, size_t size);
|
||||
void setDynSym(size_t offset, size_t size);
|
||||
void setDynStr(size_t offset, size_t size);
|
||||
|
||||
void setCliOutputMode(CliOutputMode type);
|
||||
|
||||
void setInstructionType(nn::hac::meta::InstructionType type);
|
||||
void setListApi(bool listApi);
|
||||
void setListSymbols(bool listSymbols);
|
||||
|
||||
const std::vector<SdkApiString>& getSdkVerApiList() const;
|
||||
const std::vector<SdkApiString>& getPublicApiList() const;
|
||||
const std::vector<SdkApiString>& getDebugApiList() const;
|
||||
const std::vector<SdkApiString>& getPrivateApiList() const;
|
||||
const fnd::List<ElfSymbolParser::sElfSymbol>& getSymbolList() const;
|
||||
private:
|
||||
const std::string kModuleName = "RoMetadataProcess";
|
||||
|
||||
CliOutputMode mCliOutputMode;
|
||||
nn::hac::meta::InstructionType mInstructionType;
|
||||
bool mListApi;
|
||||
bool mListSymbols;
|
||||
|
||||
struct sLayout
|
||||
{
|
||||
sLayout() : offset(0), size(0) {}
|
||||
size_t offset;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
sLayout mApiInfo;
|
||||
sLayout mDynSym;
|
||||
sLayout mDynStr;
|
||||
fnd::Vec<byte_t> mRoBlob;
|
||||
std::vector<SdkApiString> mSdkVerApiList;
|
||||
std::vector<SdkApiString> mPublicApiList;
|
||||
std::vector<SdkApiString> mDebugApiList;
|
||||
std::vector<SdkApiString> mPrivateApiList;
|
||||
|
||||
ElfSymbolParser mSymbolList;
|
||||
|
||||
void importApiList();
|
||||
void displayRoMetaData();
|
||||
|
||||
const char* getSectionIndexStr(uint16_t shn_index) const;
|
||||
const char* getSymbolTypeStr(byte_t symbol_type) const;
|
||||
const char* getSymbolBindingStr(byte_t symbol_binding) const;
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <fnd/types.h>
|
||||
#include <fnd/Vec.h>
|
||||
|
||||
#include <nn/hac/define/meta.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "SdkApiString.h"
|
||||
#include "ElfSymbolParser.h"
|
||||
|
||||
class RoMetadataProcess
|
||||
{
|
||||
public:
|
||||
RoMetadataProcess();
|
||||
|
||||
void process();
|
||||
|
||||
void setRoBinary(const fnd::Vec<byte_t>& bin);
|
||||
void setApiInfo(size_t offset, size_t size);
|
||||
void setDynSym(size_t offset, size_t size);
|
||||
void setDynStr(size_t offset, size_t size);
|
||||
|
||||
void setCliOutputMode(CliOutputMode type);
|
||||
|
||||
void setInstructionType(nn::hac::meta::InstructionType type);
|
||||
void setListApi(bool listApi);
|
||||
void setListSymbols(bool listSymbols);
|
||||
|
||||
const std::vector<SdkApiString>& getSdkVerApiList() const;
|
||||
const std::vector<SdkApiString>& getPublicApiList() const;
|
||||
const std::vector<SdkApiString>& getDebugApiList() const;
|
||||
const std::vector<SdkApiString>& getPrivateApiList() const;
|
||||
const fnd::List<ElfSymbolParser::sElfSymbol>& getSymbolList() const;
|
||||
private:
|
||||
const std::string kModuleName = "RoMetadataProcess";
|
||||
|
||||
CliOutputMode mCliOutputMode;
|
||||
nn::hac::meta::InstructionType mInstructionType;
|
||||
bool mListApi;
|
||||
bool mListSymbols;
|
||||
|
||||
struct sLayout
|
||||
{
|
||||
sLayout() : offset(0), size(0) {}
|
||||
size_t offset;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
sLayout mApiInfo;
|
||||
sLayout mDynSym;
|
||||
sLayout mDynStr;
|
||||
fnd::Vec<byte_t> mRoBlob;
|
||||
std::vector<SdkApiString> mSdkVerApiList;
|
||||
std::vector<SdkApiString> mPublicApiList;
|
||||
std::vector<SdkApiString> mDebugApiList;
|
||||
std::vector<SdkApiString> mPrivateApiList;
|
||||
|
||||
ElfSymbolParser mSymbolList;
|
||||
|
||||
void importApiList();
|
||||
void displayRoMetaData();
|
||||
|
||||
const char* getSectionIndexStr(uint16_t shn_index) const;
|
||||
const char* getSymbolTypeStr(byte_t symbol_type) const;
|
||||
const char* getSymbolBindingStr(byte_t symbol_binding) const;
|
||||
};
|
||||
|
|
@ -1,134 +1,134 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <fnd/types.h>
|
||||
#include <fnd/IFile.h>
|
||||
#include <fnd/SharedPtr.h>
|
||||
#include <fnd/Vec.h>
|
||||
#include <fnd/List.h>
|
||||
#include <nn/hac/define/romfs.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
class RomfsProcess
|
||||
{
|
||||
public:
|
||||
struct sDirectory;
|
||||
struct sFile;
|
||||
|
||||
struct sDirectory
|
||||
{
|
||||
std::string name;
|
||||
fnd::List<sDirectory> dir_list;
|
||||
fnd::List<sFile> file_list;
|
||||
|
||||
void operator=(const sDirectory& other)
|
||||
{
|
||||
name = other.name;
|
||||
dir_list = other.dir_list;
|
||||
file_list = other.file_list;
|
||||
}
|
||||
|
||||
bool operator==(const sDirectory& other) const
|
||||
{
|
||||
return (name == other.name) \
|
||||
&& (dir_list == other.dir_list) \
|
||||
&& (file_list == other.file_list);
|
||||
}
|
||||
|
||||
bool operator!=(const sDirectory& other) const
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
|
||||
bool operator==(const std::string& other) const
|
||||
{
|
||||
return (name == other);
|
||||
}
|
||||
};
|
||||
|
||||
struct sFile
|
||||
{
|
||||
std::string name;
|
||||
uint64_t offset;
|
||||
uint64_t size;
|
||||
|
||||
void operator=(const sFile& other)
|
||||
{
|
||||
name = other.name;
|
||||
offset = other.offset;
|
||||
size = other.size;
|
||||
}
|
||||
|
||||
bool operator==(const sFile& other) const
|
||||
{
|
||||
return (name == other.name) \
|
||||
&& (offset == other.offset) \
|
||||
&& (size == other.size);
|
||||
}
|
||||
|
||||
bool operator!=(const sFile& other) const
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
|
||||
bool operator==(const std::string& other) const
|
||||
{
|
||||
return (name == other);
|
||||
}
|
||||
};
|
||||
|
||||
RomfsProcess();
|
||||
|
||||
void process();
|
||||
|
||||
// generic
|
||||
void setInputFile(const fnd::SharedPtr<fnd::IFile>& file);
|
||||
void setCliOutputMode(CliOutputMode type);
|
||||
void setVerifyMode(bool verify);
|
||||
|
||||
// romfs specific
|
||||
void setMountPointName(const std::string& mount_name);
|
||||
void setExtractPath(const std::string& path);
|
||||
void setListFs(bool list_fs);
|
||||
|
||||
const sDirectory& getRootDir() const;
|
||||
private:
|
||||
const std::string kModuleName = "RomfsProcess";
|
||||
static const size_t kCacheSize = 0x10000;
|
||||
|
||||
fnd::SharedPtr<fnd::IFile> mFile;
|
||||
CliOutputMode mCliOutputMode;
|
||||
bool mVerify;
|
||||
|
||||
std::string mExtractPath;
|
||||
bool mExtract;
|
||||
std::string mMountName;
|
||||
bool mListFs;
|
||||
|
||||
fnd::Vec<byte_t> mCache;
|
||||
|
||||
size_t mDirNum;
|
||||
size_t mFileNum;
|
||||
nn::hac::sRomfsHeader mHdr;
|
||||
fnd::Vec<byte_t> mDirNodes;
|
||||
fnd::Vec<byte_t> mFileNodes;
|
||||
sDirectory mRootDir;
|
||||
|
||||
inline nn::hac::sRomfsDirEntry* get_dir_node(uint32_t offset) { return (nn::hac::sRomfsDirEntry*)(mDirNodes.data() + offset); }
|
||||
inline nn::hac::sRomfsFileEntry* get_file_node(uint32_t offset) { return (nn::hac::sRomfsFileEntry*)(mFileNodes.data() + offset); }
|
||||
|
||||
|
||||
void printTab(size_t tab) const;
|
||||
void displayFile(const sFile& file, size_t tab) const;
|
||||
void displayDir(const sDirectory& dir, size_t tab) const;
|
||||
|
||||
void displayHeader();
|
||||
void displayFs();
|
||||
|
||||
void extractDir(const std::string& path, const sDirectory& dir);
|
||||
void extractFs();
|
||||
|
||||
bool validateHeaderLayout(const nn::hac::sRomfsHeader* hdr) const;
|
||||
void importDirectory(uint32_t dir_offset, sDirectory& dir);
|
||||
void resolveRomfs();
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <fnd/types.h>
|
||||
#include <fnd/IFile.h>
|
||||
#include <fnd/SharedPtr.h>
|
||||
#include <fnd/Vec.h>
|
||||
#include <fnd/List.h>
|
||||
#include <nn/hac/define/romfs.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
class RomfsProcess
|
||||
{
|
||||
public:
|
||||
struct sDirectory;
|
||||
struct sFile;
|
||||
|
||||
struct sDirectory
|
||||
{
|
||||
std::string name;
|
||||
fnd::List<sDirectory> dir_list;
|
||||
fnd::List<sFile> file_list;
|
||||
|
||||
void operator=(const sDirectory& other)
|
||||
{
|
||||
name = other.name;
|
||||
dir_list = other.dir_list;
|
||||
file_list = other.file_list;
|
||||
}
|
||||
|
||||
bool operator==(const sDirectory& other) const
|
||||
{
|
||||
return (name == other.name) \
|
||||
&& (dir_list == other.dir_list) \
|
||||
&& (file_list == other.file_list);
|
||||
}
|
||||
|
||||
bool operator!=(const sDirectory& other) const
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
|
||||
bool operator==(const std::string& other) const
|
||||
{
|
||||
return (name == other);
|
||||
}
|
||||
};
|
||||
|
||||
struct sFile
|
||||
{
|
||||
std::string name;
|
||||
uint64_t offset;
|
||||
uint64_t size;
|
||||
|
||||
void operator=(const sFile& other)
|
||||
{
|
||||
name = other.name;
|
||||
offset = other.offset;
|
||||
size = other.size;
|
||||
}
|
||||
|
||||
bool operator==(const sFile& other) const
|
||||
{
|
||||
return (name == other.name) \
|
||||
&& (offset == other.offset) \
|
||||
&& (size == other.size);
|
||||
}
|
||||
|
||||
bool operator!=(const sFile& other) const
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
|
||||
bool operator==(const std::string& other) const
|
||||
{
|
||||
return (name == other);
|
||||
}
|
||||
};
|
||||
|
||||
RomfsProcess();
|
||||
|
||||
void process();
|
||||
|
||||
// generic
|
||||
void setInputFile(const fnd::SharedPtr<fnd::IFile>& file);
|
||||
void setCliOutputMode(CliOutputMode type);
|
||||
void setVerifyMode(bool verify);
|
||||
|
||||
// romfs specific
|
||||
void setMountPointName(const std::string& mount_name);
|
||||
void setExtractPath(const std::string& path);
|
||||
void setListFs(bool list_fs);
|
||||
|
||||
const sDirectory& getRootDir() const;
|
||||
private:
|
||||
const std::string kModuleName = "RomfsProcess";
|
||||
static const size_t kCacheSize = 0x10000;
|
||||
|
||||
fnd::SharedPtr<fnd::IFile> mFile;
|
||||
CliOutputMode mCliOutputMode;
|
||||
bool mVerify;
|
||||
|
||||
std::string mExtractPath;
|
||||
bool mExtract;
|
||||
std::string mMountName;
|
||||
bool mListFs;
|
||||
|
||||
fnd::Vec<byte_t> mCache;
|
||||
|
||||
size_t mDirNum;
|
||||
size_t mFileNum;
|
||||
nn::hac::sRomfsHeader mHdr;
|
||||
fnd::Vec<byte_t> mDirNodes;
|
||||
fnd::Vec<byte_t> mFileNodes;
|
||||
sDirectory mRootDir;
|
||||
|
||||
inline nn::hac::sRomfsDirEntry* get_dir_node(uint32_t offset) { return (nn::hac::sRomfsDirEntry*)(mDirNodes.data() + offset); }
|
||||
inline nn::hac::sRomfsFileEntry* get_file_node(uint32_t offset) { return (nn::hac::sRomfsFileEntry*)(mFileNodes.data() + offset); }
|
||||
|
||||
|
||||
void printTab(size_t tab) const;
|
||||
void displayFile(const sFile& file, size_t tab) const;
|
||||
void displayDir(const sDirectory& dir, size_t tab) const;
|
||||
|
||||
void displayHeader();
|
||||
void displayFs();
|
||||
|
||||
void extractDir(const std::string& path, const sDirectory& dir);
|
||||
void extractFs();
|
||||
|
||||
bool validateHeaderLayout(const nn::hac::sRomfsHeader* hdr) const;
|
||||
void importDirectory(uint32_t dir_offset, sDirectory& dir);
|
||||
void resolveRomfs();
|
||||
};
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,134 +1,134 @@
|
|||
#pragma once
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <fnd/types.h>
|
||||
#include <fnd/Vec.h>
|
||||
#include <fnd/List.h>
|
||||
#include <nn/pki/SignedData.h>
|
||||
#include <nn/pki/CertificateBody.h>
|
||||
#include <nn/hac/define/meta.h>
|
||||
#include "common.h"
|
||||
#include "KeyConfiguration.h"
|
||||
|
||||
class UserSettings
|
||||
{
|
||||
public:
|
||||
UserSettings();
|
||||
|
||||
void parseCmdArgs(const std::vector<std::string>& arg_list);
|
||||
void showHelp();
|
||||
|
||||
// generic options
|
||||
const std::string getInputPath() const;
|
||||
const KeyConfiguration& getKeyCfg() const;
|
||||
FileType getFileType() const;
|
||||
bool isVerifyFile() const;
|
||||
CliOutputMode getCliOutputMode() const;
|
||||
|
||||
// specialised toggles
|
||||
bool isListFs() const;
|
||||
bool isListApi() const;
|
||||
bool isListSymbols() const;
|
||||
nn::hac::meta::InstructionType getInstType() const;
|
||||
|
||||
// specialised paths
|
||||
const sOptional<std::string>& getXciUpdatePath() const;
|
||||
const sOptional<std::string>& getXciLogoPath() const;
|
||||
const sOptional<std::string>& getXciNormalPath() const;
|
||||
const sOptional<std::string>& getXciSecurePath() const;
|
||||
const sOptional<std::string>& getFsPath() const;
|
||||
const sOptional<std::string>& getNcaPart0Path() const;
|
||||
const sOptional<std::string>& getNcaPart1Path() const;
|
||||
const sOptional<std::string>& getNcaPart2Path() const;
|
||||
const sOptional<std::string>& getNcaPart3Path() const;
|
||||
const sOptional<std::string>& getAssetIconPath() const;
|
||||
const sOptional<std::string>& getAssetNacpPath() const;
|
||||
const fnd::List<nn::pki::SignedData<nn::pki::CertificateBody>>& getCertificateChain() const;
|
||||
|
||||
private:
|
||||
const std::string kModuleName = "UserSettings";
|
||||
|
||||
const std::string kHomeSwitchDirStr = ".switch";
|
||||
const std::string kGeneralKeyfileName[2] = { "prod.keys", "dev.keys" };
|
||||
const std::string kTitleKeyfileName = "title.keys";
|
||||
|
||||
|
||||
struct sCmdArgs
|
||||
{
|
||||
sCmdArgs() {}
|
||||
sOptional<std::string> input_path;
|
||||
sOptional<bool> devkit_keys;
|
||||
sOptional<std::string> keyset_path;
|
||||
sOptional<std::string> file_type;
|
||||
sOptional<bool> verify_file;
|
||||
sOptional<bool> show_keys;
|
||||
sOptional<bool> show_layout;
|
||||
sOptional<bool> verbose_output;
|
||||
sOptional<bool> list_fs;
|
||||
sOptional<std::string> update_path;
|
||||
sOptional<std::string> logo_path;
|
||||
sOptional<std::string> normal_path;
|
||||
sOptional<std::string> secure_path;
|
||||
sOptional<std::string> fs_path;
|
||||
sOptional<std::string> nca_titlekey;
|
||||
sOptional<std::string> nca_bodykey;
|
||||
sOptional<std::string> ticket_path;
|
||||
sOptional<std::string> cert_path;
|
||||
sOptional<std::string> part0_path;
|
||||
sOptional<std::string> part1_path;
|
||||
sOptional<std::string> part2_path;
|
||||
sOptional<std::string> part3_path;
|
||||
sOptional<bool> list_api;
|
||||
sOptional<bool> list_sym;
|
||||
sOptional<std::string> inst_type;
|
||||
sOptional<std::string> asset_icon_path;
|
||||
sOptional<std::string> asset_nacp_path;
|
||||
};
|
||||
|
||||
std::string mInputPath;
|
||||
FileType mFileType;
|
||||
KeyConfiguration mKeyCfg;
|
||||
bool mVerifyFile;
|
||||
CliOutputMode mOutputMode;
|
||||
|
||||
bool mListFs;
|
||||
sOptional<std::string> mXciUpdatePath;
|
||||
sOptional<std::string> mXciLogoPath;
|
||||
sOptional<std::string> mXciNormalPath;
|
||||
sOptional<std::string> mXciSecurePath;
|
||||
sOptional<std::string> mFsPath;
|
||||
|
||||
sOptional<std::string> mNcaPart0Path;
|
||||
sOptional<std::string> mNcaPart1Path;
|
||||
sOptional<std::string> mNcaPart2Path;
|
||||
sOptional<std::string> mNcaPart3Path;
|
||||
|
||||
sOptional<std::string> mAssetIconPath;
|
||||
sOptional<std::string> mAssetNacpPath;
|
||||
|
||||
fnd::List<nn::pki::SignedData<nn::pki::CertificateBody>> mCertChain;
|
||||
|
||||
bool mListApi;
|
||||
bool mListSymbols;
|
||||
nn::hac::meta::InstructionType mInstructionType;
|
||||
|
||||
void populateCmdArgs(const std::vector<std::string>& arg_list, sCmdArgs& cmd_args);
|
||||
void populateKeyset(sCmdArgs& args);
|
||||
void populateUserSettings(sCmdArgs& args);
|
||||
FileType getFileTypeFromString(const std::string& type_str);
|
||||
FileType determineFileTypeFromFile(const std::string& path);
|
||||
bool determineValidNcaFromSample(const fnd::Vec<byte_t>& sample) const;
|
||||
bool determineValidCnmtFromSample(const fnd::Vec<byte_t>& sample) const;
|
||||
bool determineValidNacpFromSample(const fnd::Vec<byte_t>& sample) const;
|
||||
bool determineValidEsCertFromSample(const fnd::Vec<byte_t>& sample) const;
|
||||
bool determineValidEsTikFromSample(const fnd::Vec<byte_t>& sample) const;
|
||||
nn::hac::meta::InstructionType getInstructionTypeFromString(const std::string& type_str);
|
||||
void getHomePath(std::string& path) const;
|
||||
void getSwitchPath(std::string& path) const;
|
||||
|
||||
void dumpKeyConfig() const;
|
||||
void dumpRsa2048Key(const fnd::rsa::sRsa2048Key& key, const std::string& name, size_t indent) const;
|
||||
void dumpRsa4096Key(const fnd::rsa::sRsa4096Key& key, const std::string& name, size_t indent) const;
|
||||
void dumpAesKey(const fnd::aes::sAes128Key& key, const std::string& name, size_t indent) const;
|
||||
void dumpAesXtsKey(const fnd::aes::sAesXts128Key& key, const std::string& name, size_t indent) const;
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <fnd/types.h>
|
||||
#include <fnd/Vec.h>
|
||||
#include <fnd/List.h>
|
||||
#include <nn/pki/SignedData.h>
|
||||
#include <nn/pki/CertificateBody.h>
|
||||
#include <nn/hac/define/meta.h>
|
||||
#include "common.h"
|
||||
#include "KeyConfiguration.h"
|
||||
|
||||
class UserSettings
|
||||
{
|
||||
public:
|
||||
UserSettings();
|
||||
|
||||
void parseCmdArgs(const std::vector<std::string>& arg_list);
|
||||
void showHelp();
|
||||
|
||||
// generic options
|
||||
const std::string getInputPath() const;
|
||||
const KeyConfiguration& getKeyCfg() const;
|
||||
FileType getFileType() const;
|
||||
bool isVerifyFile() const;
|
||||
CliOutputMode getCliOutputMode() const;
|
||||
|
||||
// specialised toggles
|
||||
bool isListFs() const;
|
||||
bool isListApi() const;
|
||||
bool isListSymbols() const;
|
||||
nn::hac::meta::InstructionType getInstType() const;
|
||||
|
||||
// specialised paths
|
||||
const sOptional<std::string>& getXciUpdatePath() const;
|
||||
const sOptional<std::string>& getXciLogoPath() const;
|
||||
const sOptional<std::string>& getXciNormalPath() const;
|
||||
const sOptional<std::string>& getXciSecurePath() const;
|
||||
const sOptional<std::string>& getFsPath() const;
|
||||
const sOptional<std::string>& getNcaPart0Path() const;
|
||||
const sOptional<std::string>& getNcaPart1Path() const;
|
||||
const sOptional<std::string>& getNcaPart2Path() const;
|
||||
const sOptional<std::string>& getNcaPart3Path() const;
|
||||
const sOptional<std::string>& getAssetIconPath() const;
|
||||
const sOptional<std::string>& getAssetNacpPath() const;
|
||||
const fnd::List<nn::pki::SignedData<nn::pki::CertificateBody>>& getCertificateChain() const;
|
||||
|
||||
private:
|
||||
const std::string kModuleName = "UserSettings";
|
||||
|
||||
const std::string kHomeSwitchDirStr = ".switch";
|
||||
const std::string kGeneralKeyfileName[2] = { "prod.keys", "dev.keys" };
|
||||
const std::string kTitleKeyfileName = "title.keys";
|
||||
|
||||
|
||||
struct sCmdArgs
|
||||
{
|
||||
sCmdArgs() {}
|
||||
sOptional<std::string> input_path;
|
||||
sOptional<bool> devkit_keys;
|
||||
sOptional<std::string> keyset_path;
|
||||
sOptional<std::string> file_type;
|
||||
sOptional<bool> verify_file;
|
||||
sOptional<bool> show_keys;
|
||||
sOptional<bool> show_layout;
|
||||
sOptional<bool> verbose_output;
|
||||
sOptional<bool> list_fs;
|
||||
sOptional<std::string> update_path;
|
||||
sOptional<std::string> logo_path;
|
||||
sOptional<std::string> normal_path;
|
||||
sOptional<std::string> secure_path;
|
||||
sOptional<std::string> fs_path;
|
||||
sOptional<std::string> nca_titlekey;
|
||||
sOptional<std::string> nca_bodykey;
|
||||
sOptional<std::string> ticket_path;
|
||||
sOptional<std::string> cert_path;
|
||||
sOptional<std::string> part0_path;
|
||||
sOptional<std::string> part1_path;
|
||||
sOptional<std::string> part2_path;
|
||||
sOptional<std::string> part3_path;
|
||||
sOptional<bool> list_api;
|
||||
sOptional<bool> list_sym;
|
||||
sOptional<std::string> inst_type;
|
||||
sOptional<std::string> asset_icon_path;
|
||||
sOptional<std::string> asset_nacp_path;
|
||||
};
|
||||
|
||||
std::string mInputPath;
|
||||
FileType mFileType;
|
||||
KeyConfiguration mKeyCfg;
|
||||
bool mVerifyFile;
|
||||
CliOutputMode mOutputMode;
|
||||
|
||||
bool mListFs;
|
||||
sOptional<std::string> mXciUpdatePath;
|
||||
sOptional<std::string> mXciLogoPath;
|
||||
sOptional<std::string> mXciNormalPath;
|
||||
sOptional<std::string> mXciSecurePath;
|
||||
sOptional<std::string> mFsPath;
|
||||
|
||||
sOptional<std::string> mNcaPart0Path;
|
||||
sOptional<std::string> mNcaPart1Path;
|
||||
sOptional<std::string> mNcaPart2Path;
|
||||
sOptional<std::string> mNcaPart3Path;
|
||||
|
||||
sOptional<std::string> mAssetIconPath;
|
||||
sOptional<std::string> mAssetNacpPath;
|
||||
|
||||
fnd::List<nn::pki::SignedData<nn::pki::CertificateBody>> mCertChain;
|
||||
|
||||
bool mListApi;
|
||||
bool mListSymbols;
|
||||
nn::hac::meta::InstructionType mInstructionType;
|
||||
|
||||
void populateCmdArgs(const std::vector<std::string>& arg_list, sCmdArgs& cmd_args);
|
||||
void populateKeyset(sCmdArgs& args);
|
||||
void populateUserSettings(sCmdArgs& args);
|
||||
FileType getFileTypeFromString(const std::string& type_str);
|
||||
FileType determineFileTypeFromFile(const std::string& path);
|
||||
bool determineValidNcaFromSample(const fnd::Vec<byte_t>& sample) const;
|
||||
bool determineValidCnmtFromSample(const fnd::Vec<byte_t>& sample) const;
|
||||
bool determineValidNacpFromSample(const fnd::Vec<byte_t>& sample) const;
|
||||
bool determineValidEsCertFromSample(const fnd::Vec<byte_t>& sample) const;
|
||||
bool determineValidEsTikFromSample(const fnd::Vec<byte_t>& sample) const;
|
||||
nn::hac::meta::InstructionType getInstructionTypeFromString(const std::string& type_str);
|
||||
void getHomePath(std::string& path) const;
|
||||
void getSwitchPath(std::string& path) const;
|
||||
|
||||
void dumpKeyConfig() const;
|
||||
void dumpRsa2048Key(const fnd::rsa::sRsa2048Key& key, const std::string& name, size_t indent) const;
|
||||
void dumpRsa4096Key(const fnd::rsa::sRsa4096Key& key, const std::string& name, size_t indent) const;
|
||||
void dumpAesKey(const fnd::aes::sAes128Key& key, const std::string& name, size_t indent) const;
|
||||
void dumpAesXtsKey(const fnd::aes::sAesXts128Key& key, const std::string& name, size_t indent) const;
|
||||
};
|
||||
|
|
@ -1,60 +1,60 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <fnd/types.h>
|
||||
#include <fnd/aes.h>
|
||||
#include <fnd/rsa.h>
|
||||
#include <nn/hac/define/nca.h>
|
||||
|
||||
static const size_t kMasterKeyNum = 0x20;
|
||||
static const size_t kNcaKeakNum = nn::hac::nca::kKeyAreaEncryptionKeyNum;
|
||||
|
||||
enum FileType
|
||||
{
|
||||
FILE_GC,
|
||||
FILE_NSP,
|
||||
FILE_PARTITIONFS,
|
||||
FILE_ROMFS,
|
||||
FILE_NCA,
|
||||
FILE_META,
|
||||
FILE_CNMT,
|
||||
FILE_NSO,
|
||||
FILE_NRO,
|
||||
FILE_NACP,
|
||||
FILE_PKI_CERT,
|
||||
FILE_ES_TIK,
|
||||
FILE_HB_ASSET,
|
||||
FILE_INVALID = -1,
|
||||
};
|
||||
|
||||
enum CliOutputModeFlag
|
||||
{
|
||||
OUTPUT_BASIC,
|
||||
OUTPUT_LAYOUT,
|
||||
OUTPUT_KEY_DATA,
|
||||
OUTPUT_EXTENDED
|
||||
};
|
||||
|
||||
typedef byte_t CliOutputMode;
|
||||
|
||||
template <typename T>
|
||||
struct sOptional
|
||||
{
|
||||
bool isSet;
|
||||
T var;
|
||||
inline sOptional() : isSet(false) {}
|
||||
inline sOptional(const T& other) : isSet(true), var(other) {}
|
||||
inline sOptional(const sOptional& other) : isSet(other.isSet), var(other.var) {}
|
||||
inline const T& operator=(const T& other) { isSet = true; var = other; return var; }
|
||||
inline const sOptional<T>& operator=(const sOptional<T>& other)
|
||||
{
|
||||
isSet = other.isSet;
|
||||
if (isSet) {
|
||||
var = other.var;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
inline T& operator*() { return var; }
|
||||
};
|
||||
|
||||
const byte_t kDummyRightsIdForUserTitleKey[nn::hac::nca::kRightsIdLen] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <fnd/types.h>
|
||||
#include <fnd/aes.h>
|
||||
#include <fnd/rsa.h>
|
||||
#include <nn/hac/define/nca.h>
|
||||
|
||||
static const size_t kMasterKeyNum = 0x20;
|
||||
static const size_t kNcaKeakNum = nn::hac::nca::kKeyAreaEncryptionKeyNum;
|
||||
|
||||
enum FileType
|
||||
{
|
||||
FILE_GC,
|
||||
FILE_NSP,
|
||||
FILE_PARTITIONFS,
|
||||
FILE_ROMFS,
|
||||
FILE_NCA,
|
||||
FILE_META,
|
||||
FILE_CNMT,
|
||||
FILE_NSO,
|
||||
FILE_NRO,
|
||||
FILE_NACP,
|
||||
FILE_PKI_CERT,
|
||||
FILE_ES_TIK,
|
||||
FILE_HB_ASSET,
|
||||
FILE_INVALID = -1,
|
||||
};
|
||||
|
||||
enum CliOutputModeFlag
|
||||
{
|
||||
OUTPUT_BASIC,
|
||||
OUTPUT_LAYOUT,
|
||||
OUTPUT_KEY_DATA,
|
||||
OUTPUT_EXTENDED
|
||||
};
|
||||
|
||||
typedef byte_t CliOutputMode;
|
||||
|
||||
template <typename T>
|
||||
struct sOptional
|
||||
{
|
||||
bool isSet;
|
||||
T var;
|
||||
inline sOptional() : isSet(false) {}
|
||||
inline sOptional(const T& other) : isSet(true), var(other) {}
|
||||
inline sOptional(const sOptional& other) : isSet(other.isSet), var(other.var) {}
|
||||
inline const T& operator=(const T& other) { isSet = true; var = other; return var; }
|
||||
inline const sOptional<T>& operator=(const sOptional<T>& other)
|
||||
{
|
||||
isSet = other.isSet;
|
||||
if (isSet) {
|
||||
var = other.var;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
inline T& operator*() { return var; }
|
||||
};
|
||||
|
||||
const byte_t kDummyRightsIdForUserTitleKey[nn::hac::nca::kRightsIdLen] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
||||
const byte_t kDummyRightsIdForUserBodyKey[nn::hac::nca::kRightsIdLen] = {0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe};
|
||||
|
|
@ -1,228 +1,228 @@
|
|||
#include <cstdio>
|
||||
#include <fnd/SimpleFile.h>
|
||||
#include <fnd/SharedPtr.h>
|
||||
#include <fnd/StringConv.h>
|
||||
#include "UserSettings.h"
|
||||
#include "GameCardProcess.h"
|
||||
#include "PfsProcess.h"
|
||||
#include "RomfsProcess.h"
|
||||
#include "NcaProcess.h"
|
||||
#include "MetaProcess.h"
|
||||
#include "CnmtProcess.h"
|
||||
#include "NsoProcess.h"
|
||||
#include "NroProcess.h"
|
||||
#include "NacpProcess.h"
|
||||
#include "PkiCertProcess.h"
|
||||
#include "EsTikProcess.h"
|
||||
#include "AssetProcess.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
int wmain(int argc, wchar_t** argv)
|
||||
#else
|
||||
int main(int argc, char** argv)
|
||||
#endif
|
||||
{
|
||||
std::vector<std::string> args;
|
||||
for (size_t i = 0; i < (size_t)argc; i++)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
args.push_back(fnd::StringConv::ConvertChar16ToChar8(std::u16string((char16_t*)argv[i])));
|
||||
#else
|
||||
args.push_back(argv[i]);
|
||||
#endif
|
||||
}
|
||||
|
||||
UserSettings user_set;
|
||||
try {
|
||||
user_set.parseCmdArgs(args);
|
||||
|
||||
fnd::SharedPtr<fnd::IFile> inputFile(new fnd::SimpleFile(user_set.getInputPath(), fnd::SimpleFile::Read));
|
||||
|
||||
if (user_set.getFileType() == FILE_GC)
|
||||
{
|
||||
GameCardProcess xci;
|
||||
|
||||
xci.setInputFile(inputFile);
|
||||
|
||||
xci.setKeyCfg(user_set.getKeyCfg());
|
||||
xci.setCliOutputMode(user_set.getCliOutputMode());
|
||||
xci.setVerifyMode(user_set.isVerifyFile());
|
||||
|
||||
if (user_set.getXciUpdatePath().isSet)
|
||||
xci.setPartitionForExtract(nn::hac::gc::kUpdatePartitionStr, user_set.getXciUpdatePath().var);
|
||||
if (user_set.getXciLogoPath().isSet)
|
||||
xci.setPartitionForExtract(nn::hac::gc::kLogoPartitionStr, user_set.getXciLogoPath().var);
|
||||
if (user_set.getXciNormalPath().isSet)
|
||||
xci.setPartitionForExtract(nn::hac::gc::kNormalPartitionStr, user_set.getXciNormalPath().var);
|
||||
if (user_set.getXciSecurePath().isSet)
|
||||
xci.setPartitionForExtract(nn::hac::gc::kSecurePartitionStr, user_set.getXciSecurePath().var);
|
||||
xci.setListFs(user_set.isListFs());
|
||||
|
||||
xci.process();
|
||||
}
|
||||
else if (user_set.getFileType() == FILE_PARTITIONFS || user_set.getFileType() == FILE_NSP)
|
||||
{
|
||||
PfsProcess pfs;
|
||||
|
||||
pfs.setInputFile(inputFile);
|
||||
pfs.setCliOutputMode(user_set.getCliOutputMode());
|
||||
pfs.setVerifyMode(user_set.isVerifyFile());
|
||||
|
||||
if (user_set.getFsPath().isSet)
|
||||
pfs.setExtractPath(user_set.getFsPath().var);
|
||||
pfs.setListFs(user_set.isListFs());
|
||||
|
||||
pfs.process();
|
||||
}
|
||||
else if (user_set.getFileType() == FILE_ROMFS)
|
||||
{
|
||||
RomfsProcess romfs;
|
||||
|
||||
romfs.setInputFile(inputFile);
|
||||
romfs.setCliOutputMode(user_set.getCliOutputMode());
|
||||
romfs.setVerifyMode(user_set.isVerifyFile());
|
||||
|
||||
if (user_set.getFsPath().isSet)
|
||||
romfs.setExtractPath(user_set.getFsPath().var);
|
||||
romfs.setListFs(user_set.isListFs());
|
||||
|
||||
romfs.process();
|
||||
}
|
||||
else if (user_set.getFileType() == FILE_NCA)
|
||||
{
|
||||
NcaProcess nca;
|
||||
|
||||
nca.setInputFile(inputFile);
|
||||
nca.setKeyCfg(user_set.getKeyCfg());
|
||||
nca.setCliOutputMode(user_set.getCliOutputMode());
|
||||
nca.setVerifyMode(user_set.isVerifyFile());
|
||||
|
||||
|
||||
if (user_set.getNcaPart0Path().isSet)
|
||||
nca.setPartition0ExtractPath(user_set.getNcaPart0Path().var);
|
||||
if (user_set.getNcaPart1Path().isSet)
|
||||
nca.setPartition1ExtractPath(user_set.getNcaPart1Path().var);
|
||||
if (user_set.getNcaPart2Path().isSet)
|
||||
nca.setPartition2ExtractPath(user_set.getNcaPart2Path().var);
|
||||
if (user_set.getNcaPart3Path().isSet)
|
||||
nca.setPartition3ExtractPath(user_set.getNcaPart3Path().var);
|
||||
nca.setListFs(user_set.isListFs());
|
||||
|
||||
nca.process();
|
||||
}
|
||||
else if (user_set.getFileType() == FILE_META)
|
||||
{
|
||||
MetaProcess npdm;
|
||||
|
||||
npdm.setInputFile(inputFile);
|
||||
npdm.setKeyCfg(user_set.getKeyCfg());
|
||||
npdm.setCliOutputMode(user_set.getCliOutputMode());
|
||||
npdm.setVerifyMode(user_set.isVerifyFile());
|
||||
|
||||
npdm.process();
|
||||
}
|
||||
else if (user_set.getFileType() == FILE_CNMT)
|
||||
{
|
||||
CnmtProcess cnmt;
|
||||
|
||||
cnmt.setInputFile(inputFile);
|
||||
cnmt.setCliOutputMode(user_set.getCliOutputMode());
|
||||
cnmt.setVerifyMode(user_set.isVerifyFile());
|
||||
|
||||
cnmt.process();
|
||||
}
|
||||
else if (user_set.getFileType() == FILE_NSO)
|
||||
{
|
||||
NsoProcess obj;
|
||||
|
||||
obj.setInputFile(inputFile);
|
||||
obj.setCliOutputMode(user_set.getCliOutputMode());
|
||||
obj.setVerifyMode(user_set.isVerifyFile());
|
||||
|
||||
obj.setInstructionType(user_set.getInstType());
|
||||
obj.setListApi(user_set.isListApi());
|
||||
obj.setListSymbols(user_set.isListSymbols());
|
||||
|
||||
obj.process();
|
||||
}
|
||||
else if (user_set.getFileType() == FILE_NRO)
|
||||
{
|
||||
NroProcess obj;
|
||||
|
||||
obj.setInputFile(inputFile);
|
||||
obj.setCliOutputMode(user_set.getCliOutputMode());
|
||||
obj.setVerifyMode(user_set.isVerifyFile());
|
||||
|
||||
obj.setInstructionType(user_set.getInstType());
|
||||
obj.setListApi(user_set.isListApi());
|
||||
obj.setListSymbols(user_set.isListSymbols());
|
||||
|
||||
if (user_set.getAssetIconPath().isSet)
|
||||
obj.setAssetIconExtractPath(user_set.getAssetIconPath().var);
|
||||
if (user_set.getAssetNacpPath().isSet)
|
||||
obj.setAssetNacpExtractPath(user_set.getAssetNacpPath().var);
|
||||
|
||||
if (user_set.getFsPath().isSet)
|
||||
obj.setAssetRomfsExtractPath(user_set.getFsPath().var);
|
||||
obj.setAssetListFs(user_set.isListFs());
|
||||
|
||||
obj.process();
|
||||
}
|
||||
else if (user_set.getFileType() == FILE_NACP)
|
||||
{
|
||||
NacpProcess nacp;
|
||||
|
||||
nacp.setInputFile(inputFile);
|
||||
nacp.setCliOutputMode(user_set.getCliOutputMode());
|
||||
nacp.setVerifyMode(user_set.isVerifyFile());
|
||||
|
||||
nacp.process();
|
||||
}
|
||||
else if (user_set.getFileType() == FILE_PKI_CERT)
|
||||
{
|
||||
PkiCertProcess cert;
|
||||
|
||||
cert.setInputFile(inputFile);
|
||||
cert.setKeyCfg(user_set.getKeyCfg());
|
||||
cert.setCliOutputMode(user_set.getCliOutputMode());
|
||||
cert.setVerifyMode(user_set.isVerifyFile());
|
||||
|
||||
cert.process();
|
||||
}
|
||||
else if (user_set.getFileType() == FILE_ES_TIK)
|
||||
{
|
||||
EsTikProcess tik;
|
||||
|
||||
tik.setInputFile(inputFile);
|
||||
tik.setKeyCfg(user_set.getKeyCfg());
|
||||
tik.setCertificateChain(user_set.getCertificateChain());
|
||||
tik.setCliOutputMode(user_set.getCliOutputMode());
|
||||
tik.setVerifyMode(user_set.isVerifyFile());
|
||||
|
||||
tik.process();
|
||||
}
|
||||
else if (user_set.getFileType() == FILE_HB_ASSET)
|
||||
{
|
||||
AssetProcess obj;
|
||||
|
||||
obj.setInputFile(inputFile);
|
||||
obj.setCliOutputMode(user_set.getCliOutputMode());
|
||||
obj.setVerifyMode(user_set.isVerifyFile());
|
||||
|
||||
if (user_set.getAssetIconPath().isSet)
|
||||
obj.setIconExtractPath(user_set.getAssetIconPath().var);
|
||||
if (user_set.getAssetNacpPath().isSet)
|
||||
obj.setNacpExtractPath(user_set.getAssetNacpPath().var);
|
||||
|
||||
if (user_set.getFsPath().isSet)
|
||||
obj.setRomfsExtractPath(user_set.getFsPath().var);
|
||||
obj.setListFs(user_set.isListFs());
|
||||
|
||||
obj.process();
|
||||
}
|
||||
}
|
||||
catch (const fnd::Exception& e) {
|
||||
printf("\n\n%s\n", e.what());
|
||||
}
|
||||
return 0;
|
||||
#include <cstdio>
|
||||
#include <fnd/SimpleFile.h>
|
||||
#include <fnd/SharedPtr.h>
|
||||
#include <fnd/StringConv.h>
|
||||
#include "UserSettings.h"
|
||||
#include "GameCardProcess.h"
|
||||
#include "PfsProcess.h"
|
||||
#include "RomfsProcess.h"
|
||||
#include "NcaProcess.h"
|
||||
#include "MetaProcess.h"
|
||||
#include "CnmtProcess.h"
|
||||
#include "NsoProcess.h"
|
||||
#include "NroProcess.h"
|
||||
#include "NacpProcess.h"
|
||||
#include "PkiCertProcess.h"
|
||||
#include "EsTikProcess.h"
|
||||
#include "AssetProcess.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
int wmain(int argc, wchar_t** argv)
|
||||
#else
|
||||
int main(int argc, char** argv)
|
||||
#endif
|
||||
{
|
||||
std::vector<std::string> args;
|
||||
for (size_t i = 0; i < (size_t)argc; i++)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
args.push_back(fnd::StringConv::ConvertChar16ToChar8(std::u16string((char16_t*)argv[i])));
|
||||
#else
|
||||
args.push_back(argv[i]);
|
||||
#endif
|
||||
}
|
||||
|
||||
UserSettings user_set;
|
||||
try {
|
||||
user_set.parseCmdArgs(args);
|
||||
|
||||
fnd::SharedPtr<fnd::IFile> inputFile(new fnd::SimpleFile(user_set.getInputPath(), fnd::SimpleFile::Read));
|
||||
|
||||
if (user_set.getFileType() == FILE_GC)
|
||||
{
|
||||
GameCardProcess xci;
|
||||
|
||||
xci.setInputFile(inputFile);
|
||||
|
||||
xci.setKeyCfg(user_set.getKeyCfg());
|
||||
xci.setCliOutputMode(user_set.getCliOutputMode());
|
||||
xci.setVerifyMode(user_set.isVerifyFile());
|
||||
|
||||
if (user_set.getXciUpdatePath().isSet)
|
||||
xci.setPartitionForExtract(nn::hac::gc::kUpdatePartitionStr, user_set.getXciUpdatePath().var);
|
||||
if (user_set.getXciLogoPath().isSet)
|
||||
xci.setPartitionForExtract(nn::hac::gc::kLogoPartitionStr, user_set.getXciLogoPath().var);
|
||||
if (user_set.getXciNormalPath().isSet)
|
||||
xci.setPartitionForExtract(nn::hac::gc::kNormalPartitionStr, user_set.getXciNormalPath().var);
|
||||
if (user_set.getXciSecurePath().isSet)
|
||||
xci.setPartitionForExtract(nn::hac::gc::kSecurePartitionStr, user_set.getXciSecurePath().var);
|
||||
xci.setListFs(user_set.isListFs());
|
||||
|
||||
xci.process();
|
||||
}
|
||||
else if (user_set.getFileType() == FILE_PARTITIONFS || user_set.getFileType() == FILE_NSP)
|
||||
{
|
||||
PfsProcess pfs;
|
||||
|
||||
pfs.setInputFile(inputFile);
|
||||
pfs.setCliOutputMode(user_set.getCliOutputMode());
|
||||
pfs.setVerifyMode(user_set.isVerifyFile());
|
||||
|
||||
if (user_set.getFsPath().isSet)
|
||||
pfs.setExtractPath(user_set.getFsPath().var);
|
||||
pfs.setListFs(user_set.isListFs());
|
||||
|
||||
pfs.process();
|
||||
}
|
||||
else if (user_set.getFileType() == FILE_ROMFS)
|
||||
{
|
||||
RomfsProcess romfs;
|
||||
|
||||
romfs.setInputFile(inputFile);
|
||||
romfs.setCliOutputMode(user_set.getCliOutputMode());
|
||||
romfs.setVerifyMode(user_set.isVerifyFile());
|
||||
|
||||
if (user_set.getFsPath().isSet)
|
||||
romfs.setExtractPath(user_set.getFsPath().var);
|
||||
romfs.setListFs(user_set.isListFs());
|
||||
|
||||
romfs.process();
|
||||
}
|
||||
else if (user_set.getFileType() == FILE_NCA)
|
||||
{
|
||||
NcaProcess nca;
|
||||
|
||||
nca.setInputFile(inputFile);
|
||||
nca.setKeyCfg(user_set.getKeyCfg());
|
||||
nca.setCliOutputMode(user_set.getCliOutputMode());
|
||||
nca.setVerifyMode(user_set.isVerifyFile());
|
||||
|
||||
|
||||
if (user_set.getNcaPart0Path().isSet)
|
||||
nca.setPartition0ExtractPath(user_set.getNcaPart0Path().var);
|
||||
if (user_set.getNcaPart1Path().isSet)
|
||||
nca.setPartition1ExtractPath(user_set.getNcaPart1Path().var);
|
||||
if (user_set.getNcaPart2Path().isSet)
|
||||
nca.setPartition2ExtractPath(user_set.getNcaPart2Path().var);
|
||||
if (user_set.getNcaPart3Path().isSet)
|
||||
nca.setPartition3ExtractPath(user_set.getNcaPart3Path().var);
|
||||
nca.setListFs(user_set.isListFs());
|
||||
|
||||
nca.process();
|
||||
}
|
||||
else if (user_set.getFileType() == FILE_META)
|
||||
{
|
||||
MetaProcess npdm;
|
||||
|
||||
npdm.setInputFile(inputFile);
|
||||
npdm.setKeyCfg(user_set.getKeyCfg());
|
||||
npdm.setCliOutputMode(user_set.getCliOutputMode());
|
||||
npdm.setVerifyMode(user_set.isVerifyFile());
|
||||
|
||||
npdm.process();
|
||||
}
|
||||
else if (user_set.getFileType() == FILE_CNMT)
|
||||
{
|
||||
CnmtProcess cnmt;
|
||||
|
||||
cnmt.setInputFile(inputFile);
|
||||
cnmt.setCliOutputMode(user_set.getCliOutputMode());
|
||||
cnmt.setVerifyMode(user_set.isVerifyFile());
|
||||
|
||||
cnmt.process();
|
||||
}
|
||||
else if (user_set.getFileType() == FILE_NSO)
|
||||
{
|
||||
NsoProcess obj;
|
||||
|
||||
obj.setInputFile(inputFile);
|
||||
obj.setCliOutputMode(user_set.getCliOutputMode());
|
||||
obj.setVerifyMode(user_set.isVerifyFile());
|
||||
|
||||
obj.setInstructionType(user_set.getInstType());
|
||||
obj.setListApi(user_set.isListApi());
|
||||
obj.setListSymbols(user_set.isListSymbols());
|
||||
|
||||
obj.process();
|
||||
}
|
||||
else if (user_set.getFileType() == FILE_NRO)
|
||||
{
|
||||
NroProcess obj;
|
||||
|
||||
obj.setInputFile(inputFile);
|
||||
obj.setCliOutputMode(user_set.getCliOutputMode());
|
||||
obj.setVerifyMode(user_set.isVerifyFile());
|
||||
|
||||
obj.setInstructionType(user_set.getInstType());
|
||||
obj.setListApi(user_set.isListApi());
|
||||
obj.setListSymbols(user_set.isListSymbols());
|
||||
|
||||
if (user_set.getAssetIconPath().isSet)
|
||||
obj.setAssetIconExtractPath(user_set.getAssetIconPath().var);
|
||||
if (user_set.getAssetNacpPath().isSet)
|
||||
obj.setAssetNacpExtractPath(user_set.getAssetNacpPath().var);
|
||||
|
||||
if (user_set.getFsPath().isSet)
|
||||
obj.setAssetRomfsExtractPath(user_set.getFsPath().var);
|
||||
obj.setAssetListFs(user_set.isListFs());
|
||||
|
||||
obj.process();
|
||||
}
|
||||
else if (user_set.getFileType() == FILE_NACP)
|
||||
{
|
||||
NacpProcess nacp;
|
||||
|
||||
nacp.setInputFile(inputFile);
|
||||
nacp.setCliOutputMode(user_set.getCliOutputMode());
|
||||
nacp.setVerifyMode(user_set.isVerifyFile());
|
||||
|
||||
nacp.process();
|
||||
}
|
||||
else if (user_set.getFileType() == FILE_PKI_CERT)
|
||||
{
|
||||
PkiCertProcess cert;
|
||||
|
||||
cert.setInputFile(inputFile);
|
||||
cert.setKeyCfg(user_set.getKeyCfg());
|
||||
cert.setCliOutputMode(user_set.getCliOutputMode());
|
||||
cert.setVerifyMode(user_set.isVerifyFile());
|
||||
|
||||
cert.process();
|
||||
}
|
||||
else if (user_set.getFileType() == FILE_ES_TIK)
|
||||
{
|
||||
EsTikProcess tik;
|
||||
|
||||
tik.setInputFile(inputFile);
|
||||
tik.setKeyCfg(user_set.getKeyCfg());
|
||||
tik.setCertificateChain(user_set.getCertificateChain());
|
||||
tik.setCliOutputMode(user_set.getCliOutputMode());
|
||||
tik.setVerifyMode(user_set.isVerifyFile());
|
||||
|
||||
tik.process();
|
||||
}
|
||||
else if (user_set.getFileType() == FILE_HB_ASSET)
|
||||
{
|
||||
AssetProcess obj;
|
||||
|
||||
obj.setInputFile(inputFile);
|
||||
obj.setCliOutputMode(user_set.getCliOutputMode());
|
||||
obj.setVerifyMode(user_set.isVerifyFile());
|
||||
|
||||
if (user_set.getAssetIconPath().isSet)
|
||||
obj.setIconExtractPath(user_set.getAssetIconPath().var);
|
||||
if (user_set.getAssetNacpPath().isSet)
|
||||
obj.setNacpExtractPath(user_set.getAssetNacpPath().var);
|
||||
|
||||
if (user_set.getFsPath().isSet)
|
||||
obj.setRomfsExtractPath(user_set.getFsPath().var);
|
||||
obj.setListFs(user_set.isListFs());
|
||||
|
||||
obj.process();
|
||||
}
|
||||
}
|
||||
catch (const fnd::Exception& e) {
|
||||
printf("\n\n%s\n", e.what());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in a new issue