diff options
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Set/ISystemSettingsServer.cs')
-rw-r--r-- | Ryujinx.HLE/HOS/Services/Set/ISystemSettingsServer.cs | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Set/ISystemSettingsServer.cs b/Ryujinx.HLE/HOS/Services/Set/ISystemSettingsServer.cs index b4464b77..8eec31cf 100644 --- a/Ryujinx.HLE/HOS/Services/Set/ISystemSettingsServer.cs +++ b/Ryujinx.HLE/HOS/Services/Set/ISystemSettingsServer.cs @@ -1,12 +1,13 @@ +using LibHac; +using LibHac.IO; using Ryujinx.Common.Logging; +using Ryujinx.HLE.FileSystem; using Ryujinx.HLE.HOS.Ipc; using Ryujinx.HLE.HOS.SystemState; using System; using System.Collections.Generic; using System.IO; using System.Text; -using LibHac; -using Ryujinx.HLE.FileSystem; namespace Ryujinx.HLE.HOS.Services.Set { @@ -173,7 +174,6 @@ namespace Ryujinx.HLE.HOS.Services.Set public static byte[] GetFirmwareData(Switch device) { - byte[] data = null; long titleId = 0x0100000000000809; string contentPath = device.System.ContentManager.GetInstalledContentPath(titleId, StorageId.NandSystem, ContentType.Data); @@ -182,32 +182,28 @@ namespace Ryujinx.HLE.HOS.Services.Set return null; } - string firmwareTitlePath = device.FileSystem.SwitchPathToSystemPath(contentPath); - FileStream firmwareStream = File.Open(firmwareTitlePath, FileMode.Open, FileAccess.Read); - Nca firmwareContent = new Nca(device.System.KeySet, firmwareStream, false); - Stream romFsStream = firmwareContent.OpenSection(0, false, device.System.FsIntegrityCheckLevel); + string firmwareTitlePath = device.FileSystem.SwitchPathToSystemPath(contentPath); - if(romFsStream == null) - { - return null; - } + using(FileStream firmwareStream = File.Open(firmwareTitlePath, FileMode.Open, FileAccess.Read)) + { + Nca firmwareContent = new Nca(device.System.KeySet, firmwareStream.AsStorage(), false); + IStorage romFsStorage = firmwareContent.OpenSection(0, false, device.System.FsIntegrityCheckLevel, false); - Romfs firmwareRomFs = new Romfs(romFsStream); - - using(MemoryStream memoryStream = new MemoryStream()) - { - using (Stream firmwareFile = firmwareRomFs.OpenFile("/file")) + if(romFsStorage == null) { - firmwareFile.CopyTo(memoryStream); + return null; } - data = memoryStream.ToArray(); - } + Romfs firmwareRomFs = new Romfs(romFsStorage); - firmwareContent.Dispose(); - firmwareStream.Dispose(); + IStorage firmwareFile = firmwareRomFs.OpenFile("/file"); - return data; + byte[] data = new byte[firmwareFile.Length]; + + firmwareFile.Read(data, 0); + + return data; + } } } } |