Add NSP loading
This commit is contained in:
parent
013879af73
commit
b6d30d97dc
3 changed files with 48 additions and 0 deletions
|
@ -164,6 +164,45 @@ namespace Ryujinx.HLE.HOS
|
||||||
LoadNca(Nca);
|
LoadNca(Nca);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LoadNsp(string NspFile)
|
||||||
|
{
|
||||||
|
FileStream File = new FileStream(NspFile, FileMode.Open, FileAccess.Read);
|
||||||
|
Pfs Nsp = new Pfs(File);
|
||||||
|
|
||||||
|
Nca ProgramNca = null;
|
||||||
|
|
||||||
|
PfsFileEntry TicketFile = Nsp.Files.FirstOrDefault(x => x.Name.EndsWith(".tik"));
|
||||||
|
|
||||||
|
// Load title key from the NSP's ticket in case the user doesn't have a title key file
|
||||||
|
if (TicketFile != null)
|
||||||
|
{
|
||||||
|
// todo Change when Ticket(Stream) overload is added
|
||||||
|
BinaryReader TicketReader = new BinaryReader(Nsp.OpenFile(TicketFile));
|
||||||
|
Ticket Ticket = new Ticket(TicketReader);
|
||||||
|
|
||||||
|
byte[] TitleKey = Ticket.GetTitleKey(Keyset);
|
||||||
|
Keyset.TitleKeys[Ticket.RightsId] = TitleKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (PfsFileEntry NcaFile in Nsp.Files.Where(x => x.Name.EndsWith(".nca")))
|
||||||
|
{
|
||||||
|
Nca Nca = new Nca(Keyset, Nsp.OpenFile(NcaFile), true);
|
||||||
|
|
||||||
|
if (Nca.Header.ContentType == ContentType.Program)
|
||||||
|
{
|
||||||
|
ProgramNca = Nca;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ProgramNca == null)
|
||||||
|
{
|
||||||
|
Device.Log.PrintError(LogClass.Loader, "Could not find program NCA inside NSP file");
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadNca(ProgramNca);
|
||||||
|
}
|
||||||
|
|
||||||
public void LoadNca(Nca Nca)
|
public void LoadNca(Nca Nca)
|
||||||
{
|
{
|
||||||
NcaSection RomfsSection = Nca.Sections.FirstOrDefault(x => x.Type == SectionType.Romfs);
|
NcaSection RomfsSection = Nca.Sections.FirstOrDefault(x => x.Type == SectionType.Romfs);
|
||||||
|
|
|
@ -71,6 +71,11 @@ namespace Ryujinx.HLE
|
||||||
System.LoadNca(NcaFile);
|
System.LoadNca(NcaFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LoadNsp(string NspFile)
|
||||||
|
{
|
||||||
|
System.LoadNsp(NspFile);
|
||||||
|
}
|
||||||
|
|
||||||
public void LoadProgram(string FileName)
|
public void LoadProgram(string FileName)
|
||||||
{
|
{
|
||||||
System.LoadProgram(FileName);
|
System.LoadProgram(FileName);
|
||||||
|
|
|
@ -60,6 +60,10 @@ namespace Ryujinx
|
||||||
Console.WriteLine("Loading as NCA.");
|
Console.WriteLine("Loading as NCA.");
|
||||||
Device.LoadNca(args[0]);
|
Device.LoadNca(args[0]);
|
||||||
break;
|
break;
|
||||||
|
case ".nsp":
|
||||||
|
Console.WriteLine("Loading as NSP.");
|
||||||
|
Device.LoadNsp(args[0]);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Console.WriteLine("Loading as homebrew.");
|
Console.WriteLine("Loading as homebrew.");
|
||||||
Device.LoadProgram(args[0]);
|
Device.LoadProgram(args[0]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue