read system firmware version from nand
This commit is contained in:
parent
2d31c4394a
commit
220cd16380
3 changed files with 75 additions and 1 deletions
|
@ -23,8 +23,8 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
|
||||||
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
||||||
{
|
{
|
||||||
{ 1, SetCurrentProcess },
|
{ 1, SetCurrentProcess },
|
||||||
{ 11, OpenBisFileSystem },
|
|
||||||
{ 8, OpenFileSystemWithId },
|
{ 8, OpenFileSystemWithId },
|
||||||
|
{ 11, OpenBisFileSystem },
|
||||||
{ 18, OpenSdCardFileSystem },
|
{ 18, OpenSdCardFileSystem },
|
||||||
{ 51, OpenSaveDataFileSystem },
|
{ 51, OpenSaveDataFileSystem },
|
||||||
{ 52, OpenSaveDataFileSystemBySystemSaveDataId },
|
{ 52, OpenSaveDataFileSystemBySystemSaveDataId },
|
||||||
|
|
|
@ -5,6 +5,8 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using LibHac;
|
||||||
|
using Ryujinx.HLE.FileSystem;
|
||||||
|
|
||||||
namespace Ryujinx.HLE.HOS.Services.Set
|
namespace Ryujinx.HLE.HOS.Services.Set
|
||||||
{
|
{
|
||||||
|
@ -18,6 +20,7 @@ namespace Ryujinx.HLE.HOS.Services.Set
|
||||||
{
|
{
|
||||||
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
||||||
{
|
{
|
||||||
|
{ 3, GetFirmwareVersion },
|
||||||
{ 4, GetFirmwareVersion2 },
|
{ 4, GetFirmwareVersion2 },
|
||||||
{ 23, GetColorSetId },
|
{ 23, GetColorSetId },
|
||||||
{ 24, SetColorSetId },
|
{ 24, SetColorSetId },
|
||||||
|
@ -25,11 +28,25 @@ namespace Ryujinx.HLE.HOS.Services.Set
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static long GetFirmwareVersion(ServiceCtx Context)
|
||||||
|
{
|
||||||
|
return GetFirmwareVersion2(Context);
|
||||||
|
}
|
||||||
|
|
||||||
public static long GetFirmwareVersion2(ServiceCtx Context)
|
public static long GetFirmwareVersion2(ServiceCtx Context)
|
||||||
{
|
{
|
||||||
long ReplyPos = Context.Request.RecvListBuff[0].Position;
|
long ReplyPos = Context.Request.RecvListBuff[0].Position;
|
||||||
long ReplySize = Context.Request.RecvListBuff[0].Size;
|
long ReplySize = Context.Request.RecvListBuff[0].Size;
|
||||||
|
|
||||||
|
byte[] FirmwareData = GetFirmwareData(Context.Device);
|
||||||
|
|
||||||
|
if (FirmwareData != null)
|
||||||
|
{
|
||||||
|
Context.Memory.WriteBytes(ReplyPos, FirmwareData);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const byte MajorFWVersion = 0x03;
|
const byte MajorFWVersion = 0x03;
|
||||||
const byte MinorFWVersion = 0x00;
|
const byte MinorFWVersion = 0x00;
|
||||||
const byte MicroFWVersion = 0x00;
|
const byte MicroFWVersion = 0x00;
|
||||||
|
@ -148,5 +165,48 @@ namespace Ryujinx.HLE.HOS.Services.Set
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static byte[] GetFirmwareData(Switch Device)
|
||||||
|
{
|
||||||
|
byte[] Data = null;
|
||||||
|
|
||||||
|
long TitleId = 0x0100000000000809;
|
||||||
|
|
||||||
|
string Path = Device.System.ContentManager.GetInstalledPath(TitleId, ContentType.Data, StorageId.NandSystem);
|
||||||
|
|
||||||
|
if(string.IsNullOrWhiteSpace(Path))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
FileStream FirmwareStream = File.Open(Path, FileMode.Open, FileAccess.Read);
|
||||||
|
|
||||||
|
Nca FirmwareContent = new Nca(Device.System.KeySet, FirmwareStream, false);
|
||||||
|
|
||||||
|
Stream RomFsStream = FirmwareContent.OpenSection(0, false, Device.System.FsIntegrityCheckLevel);
|
||||||
|
|
||||||
|
if(RomFsStream == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Romfs FirmwareRomFs = new Romfs(RomFsStream);
|
||||||
|
|
||||||
|
using(MemoryStream MemoryStream = new MemoryStream())
|
||||||
|
{
|
||||||
|
using (Stream FirmwareFile = FirmwareRomFs.OpenFile("/file"))
|
||||||
|
{
|
||||||
|
FirmwareFile.CopyTo(MemoryStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
Data = MemoryStream.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
FirmwareContent.Dispose();
|
||||||
|
|
||||||
|
FirmwareStream.Dispose();
|
||||||
|
|
||||||
|
return Data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
14
Ryujinx/Properties/PublishProfiles/FolderProfile.pubxml
Normal file
14
Ryujinx/Properties/PublishProfiles/FolderProfile.pubxml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||||
|
-->
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<PublishProtocol>FileSystem</PublishProtocol>
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Any CPU</Platform>
|
||||||
|
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||||
|
<PublishDir>bin\Release\netcoreapp2.1\publish\</PublishDir>
|
||||||
|
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
Loading…
Add table
Add a link
Reference in a new issue