2019-10-17 02:17:44 -04:00
|
|
|
using LibHac;
|
2020-03-25 04:14:35 -04:00
|
|
|
using LibHac.Common;
|
2019-05-31 20:31:10 -04:00
|
|
|
using LibHac.Fs;
|
2020-09-01 16:08:59 -04:00
|
|
|
using LibHac.Fs.Fsa;
|
2019-10-17 02:17:44 -04:00
|
|
|
using LibHac.FsSystem;
|
2022-03-22 15:46:16 -04:00
|
|
|
using LibHac.Ncm;
|
2022-01-12 06:22:19 -05:00
|
|
|
using LibHac.Tools.FsSystem.NcaUtils;
|
2018-10-17 13:15:50 -04:00
|
|
|
using Ryujinx.Common.Logging;
|
2018-08-16 19:47:36 -04:00
|
|
|
using Ryujinx.HLE.HOS.SystemState;
|
2021-06-28 14:54:45 -04:00
|
|
|
using Ryujinx.HLE.Utilities;
|
2018-04-25 20:52:22 -04:00
|
|
|
using System;
|
2018-04-21 19:04:43 -04:00
|
|
|
using System.IO;
|
|
|
|
using System.Text;
|
2018-03-01 15:23:55 -05:00
|
|
|
|
2019-09-18 20:45:11 -04:00
|
|
|
namespace Ryujinx.HLE.HOS.Services.Settings
|
2018-03-01 15:23:55 -05:00
|
|
|
{
|
2019-07-10 11:59:54 -04:00
|
|
|
[Service("set:sys")]
|
2018-04-06 00:01:52 -04:00
|
|
|
class ISystemSettingsServer : IpcService
|
2018-03-01 15:23:55 -05:00
|
|
|
{
|
2019-07-11 21:13:43 -04:00
|
|
|
public ISystemSettingsServer(ServiceCtx context) { }
|
2018-03-01 15:23:55 -05:00
|
|
|
|
2021-04-13 18:01:24 -04:00
|
|
|
[CommandHipc(3)]
|
2018-11-18 14:37:41 -05:00
|
|
|
// GetFirmwareVersion() -> buffer<nn::settings::system::FirmwareVersion, 0x1a, 0x100>
|
2019-07-14 15:04:38 -04:00
|
|
|
public ResultCode GetFirmwareVersion(ServiceCtx context)
|
2018-11-18 14:37:41 -05:00
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
return GetFirmwareVersion2(context);
|
2018-11-18 14:37:41 -05:00
|
|
|
}
|
|
|
|
|
2021-04-13 18:01:24 -04:00
|
|
|
[CommandHipc(4)]
|
2018-11-18 14:37:41 -05:00
|
|
|
// GetFirmwareVersion2() -> buffer<nn::settings::system::FirmwareVersion, 0x1a, 0x100>
|
2019-07-14 15:04:38 -04:00
|
|
|
public ResultCode GetFirmwareVersion2(ServiceCtx context)
|
2018-04-21 19:04:43 -04:00
|
|
|
{
|
2021-04-24 06:16:01 -04:00
|
|
|
ulong replyPos = context.Request.RecvListBuff[0].Position;
|
2021-02-17 15:10:53 -05:00
|
|
|
|
|
|
|
context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize(0x100L);
|
2018-04-21 19:04:43 -04:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
byte[] firmwareData = GetFirmwareData(context.Device);
|
2018-11-18 14:37:41 -05:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
if (firmwareData != null)
|
2018-11-18 14:37:41 -05:00
|
|
|
{
|
2021-04-24 06:16:01 -04:00
|
|
|
context.Memory.Write(replyPos, firmwareData);
|
2018-11-18 14:37:41 -05:00
|
|
|
|
2019-07-14 15:04:38 -04:00
|
|
|
return ResultCode.Success;
|
2018-11-18 14:37:41 -05:00
|
|
|
}
|
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
const byte majorFwVersion = 0x03;
|
|
|
|
const byte minorFwVersion = 0x00;
|
|
|
|
const byte microFwVersion = 0x00;
|
|
|
|
const byte unknown = 0x00; //Build?
|
2018-04-21 19:04:43 -04:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
const int revisionNumber = 0x0A;
|
2018-04-21 19:04:43 -04:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
const string platform = "NX";
|
|
|
|
const string unknownHex = "7fbde2b0bba4d14107bf836e4643043d9f6c8e47";
|
|
|
|
const string version = "3.0.0";
|
|
|
|
const string build = "NintendoSDK Firmware for NX 3.0.0-10.0";
|
2018-04-21 19:04:43 -04:00
|
|
|
|
2019-07-01 22:39:22 -04:00
|
|
|
// http://switchbrew.org/index.php?title=System_Version_Title
|
2018-12-06 06:16:24 -05:00
|
|
|
using (MemoryStream ms = new MemoryStream(0x100))
|
2018-04-21 19:04:43 -04:00
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
BinaryWriter writer = new BinaryWriter(ms);
|
2018-04-21 19:04:43 -04:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
writer.Write(majorFwVersion);
|
|
|
|
writer.Write(minorFwVersion);
|
|
|
|
writer.Write(microFwVersion);
|
|
|
|
writer.Write(unknown);
|
2018-04-21 19:04:43 -04:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
writer.Write(revisionNumber);
|
2018-04-21 19:04:43 -04:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
writer.Write(Encoding.ASCII.GetBytes(platform));
|
2018-04-21 19:04:43 -04:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
ms.Seek(0x28, SeekOrigin.Begin);
|
2018-06-09 12:05:41 -04:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
writer.Write(Encoding.ASCII.GetBytes(unknownHex));
|
2018-04-21 19:04:43 -04:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
ms.Seek(0x68, SeekOrigin.Begin);
|
2018-06-09 12:05:41 -04:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
writer.Write(Encoding.ASCII.GetBytes(version));
|
2018-04-21 19:04:43 -04:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
ms.Seek(0x80, SeekOrigin.Begin);
|
2018-06-09 12:05:41 -04:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
writer.Write(Encoding.ASCII.GetBytes(build));
|
2018-04-21 19:04:43 -04:00
|
|
|
|
2021-04-24 06:16:01 -04:00
|
|
|
context.Memory.Write(replyPos, ms.ToArray());
|
2018-04-21 19:04:43 -04:00
|
|
|
}
|
|
|
|
|
2019-07-14 15:04:38 -04:00
|
|
|
return ResultCode.Success;
|
2018-04-21 19:04:43 -04:00
|
|
|
}
|
|
|
|
|
2021-04-13 18:01:24 -04:00
|
|
|
[CommandHipc(23)]
|
2018-11-18 14:37:41 -05:00
|
|
|
// GetColorSetId() -> i32
|
2019-07-14 15:04:38 -04:00
|
|
|
public ResultCode GetColorSetId(ServiceCtx context)
|
2018-03-01 15:23:55 -05:00
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
context.ResponseData.Write((int)context.Device.System.State.ThemeColor);
|
2018-03-03 12:04:58 -05:00
|
|
|
|
2019-07-14 15:04:38 -04:00
|
|
|
return ResultCode.Success;
|
2018-03-01 15:23:55 -05:00
|
|
|
}
|
|
|
|
|
2021-04-13 18:01:24 -04:00
|
|
|
[CommandHipc(24)]
|
2018-11-18 14:37:41 -05:00
|
|
|
// GetColorSetId() -> i32
|
2019-07-14 15:04:38 -04:00
|
|
|
public ResultCode SetColorSetId(ServiceCtx context)
|
2018-04-06 00:01:52 -04:00
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
int colorSetId = context.RequestData.ReadInt32();
|
2018-04-16 20:24:42 -04:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
context.Device.System.State.ThemeColor = (ColorSet)colorSetId;
|
2018-08-14 18:02:42 -04:00
|
|
|
|
2019-07-14 15:04:38 -04:00
|
|
|
return ResultCode.Success;
|
2018-03-01 15:23:55 -05:00
|
|
|
}
|
2018-06-09 12:05:41 -04:00
|
|
|
|
2021-04-13 18:01:24 -04:00
|
|
|
[CommandHipc(37)]
|
2019-10-18 18:47:50 -04:00
|
|
|
// GetSettingsItemValueSize(buffer<nn::settings::SettingsName, 0x19>, buffer<nn::settings::SettingsItemKey, 0x19>) -> u64
|
|
|
|
public ResultCode GetSettingsItemValueSize(ServiceCtx context)
|
|
|
|
{
|
2021-04-24 06:16:01 -04:00
|
|
|
ulong classPos = context.Request.PtrBuff[0].Position;
|
|
|
|
ulong classSize = context.Request.PtrBuff[0].Size;
|
2019-10-18 18:47:50 -04:00
|
|
|
|
2021-04-24 06:16:01 -04:00
|
|
|
ulong namePos = context.Request.PtrBuff[1].Position;
|
|
|
|
ulong nameSize = context.Request.PtrBuff[1].Size;
|
2019-10-18 18:47:50 -04:00
|
|
|
|
2020-05-03 18:54:50 -04:00
|
|
|
byte[] classBuffer = new byte[classSize];
|
2019-10-18 18:47:50 -04:00
|
|
|
|
2021-04-24 06:16:01 -04:00
|
|
|
context.Memory.Read(classPos, classBuffer);
|
2020-05-03 18:54:50 -04:00
|
|
|
|
|
|
|
byte[] nameBuffer = new byte[nameSize];
|
|
|
|
|
2021-04-24 06:16:01 -04:00
|
|
|
context.Memory.Read(namePos, nameBuffer);
|
2020-05-03 18:54:50 -04:00
|
|
|
|
|
|
|
string askedSetting = Encoding.ASCII.GetString(classBuffer).Trim('\0') + "!" + Encoding.ASCII.GetString(nameBuffer).Trim('\0');
|
2019-10-18 18:47:50 -04:00
|
|
|
|
|
|
|
NxSettings.Settings.TryGetValue(askedSetting, out object nxSetting);
|
|
|
|
|
|
|
|
if (nxSetting != null)
|
|
|
|
{
|
|
|
|
ulong settingSize;
|
|
|
|
|
|
|
|
if (nxSetting is string stringValue)
|
|
|
|
{
|
|
|
|
settingSize = (ulong)stringValue.Length + 1;
|
|
|
|
}
|
|
|
|
else if (nxSetting is int)
|
|
|
|
{
|
|
|
|
settingSize = sizeof(int);
|
|
|
|
}
|
|
|
|
else if (nxSetting is bool)
|
|
|
|
{
|
|
|
|
settingSize = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
throw new NotImplementedException(nxSetting.GetType().Name);
|
|
|
|
}
|
|
|
|
|
|
|
|
context.ResponseData.Write(settingSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
}
|
|
|
|
|
2021-04-13 18:01:24 -04:00
|
|
|
[CommandHipc(38)]
|
2018-11-18 14:37:41 -05:00
|
|
|
// GetSettingsItemValue(buffer<nn::settings::SettingsName, 0x19, 0x48>, buffer<nn::settings::SettingsItemKey, 0x19, 0x48>) -> (u64, buffer<unknown, 6, 0>)
|
2019-07-14 15:04:38 -04:00
|
|
|
public ResultCode GetSettingsItemValue(ServiceCtx context)
|
2018-04-25 20:52:22 -04:00
|
|
|
{
|
2021-04-24 06:16:01 -04:00
|
|
|
ulong classPos = context.Request.PtrBuff[0].Position;
|
|
|
|
ulong classSize = context.Request.PtrBuff[0].Size;
|
2018-04-25 20:52:22 -04:00
|
|
|
|
2021-04-24 06:16:01 -04:00
|
|
|
ulong namePos = context.Request.PtrBuff[1].Position;
|
|
|
|
ulong nameSize = context.Request.PtrBuff[1].Size;
|
2018-04-25 20:52:22 -04:00
|
|
|
|
2021-04-24 06:16:01 -04:00
|
|
|
ulong replyPos = context.Request.ReceiveBuff[0].Position;
|
|
|
|
ulong replySize = context.Request.ReceiveBuff[0].Size;
|
2018-04-25 20:52:22 -04:00
|
|
|
|
2020-05-03 18:54:50 -04:00
|
|
|
byte[] classBuffer = new byte[classSize];
|
|
|
|
|
2021-04-24 06:16:01 -04:00
|
|
|
context.Memory.Read(classPos, classBuffer);
|
2020-05-03 18:54:50 -04:00
|
|
|
|
|
|
|
byte[] nameBuffer = new byte[nameSize];
|
|
|
|
|
2021-04-24 06:16:01 -04:00
|
|
|
context.Memory.Read(namePos, nameBuffer);
|
2018-04-25 20:52:22 -04:00
|
|
|
|
2020-05-03 18:54:50 -04:00
|
|
|
string askedSetting = Encoding.ASCII.GetString(classBuffer).Trim('\0') + "!" + Encoding.ASCII.GetString(nameBuffer).Trim('\0');
|
2018-04-25 20:52:22 -04:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
NxSettings.Settings.TryGetValue(askedSetting, out object nxSetting);
|
2018-04-25 20:52:22 -04:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
if (nxSetting != null)
|
2018-04-25 20:52:22 -04:00
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
byte[] settingBuffer = new byte[replySize];
|
2018-04-25 20:52:22 -04:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
if (nxSetting is string stringValue)
|
2018-04-25 20:52:22 -04:00
|
|
|
{
|
2021-04-24 06:16:01 -04:00
|
|
|
if ((ulong)(stringValue.Length + 1) > replySize)
|
2018-06-09 12:05:41 -04:00
|
|
|
{
|
2020-08-03 19:32:53 -04:00
|
|
|
Logger.Error?.Print(LogClass.ServiceSet, $"{askedSetting} String value size is too big!");
|
2018-04-25 20:52:22 -04:00
|
|
|
}
|
|
|
|
else
|
2018-06-09 12:05:41 -04:00
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
settingBuffer = Encoding.ASCII.GetBytes(stringValue + "\0");
|
2018-04-25 20:52:22 -04:00
|
|
|
}
|
|
|
|
}
|
2018-08-14 18:02:42 -04:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
if (nxSetting is int intValue)
|
2018-04-25 20:52:22 -04:00
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
settingBuffer = BitConverter.GetBytes(intValue);
|
2018-04-25 20:52:22 -04:00
|
|
|
}
|
2018-12-06 06:16:24 -05:00
|
|
|
else if (nxSetting is bool boolValue)
|
2018-04-25 20:52:22 -04:00
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
settingBuffer[0] = boolValue ? (byte)1 : (byte)0;
|
2018-04-25 20:52:22 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
throw new NotImplementedException(nxSetting.GetType().Name);
|
2018-04-25 20:52:22 -04:00
|
|
|
}
|
|
|
|
|
2021-04-24 06:16:01 -04:00
|
|
|
context.Memory.Write(replyPos, settingBuffer);
|
2018-04-25 20:52:22 -04:00
|
|
|
|
2020-08-03 19:32:53 -04:00
|
|
|
Logger.Debug?.Print(LogClass.ServiceSet, $"{askedSetting} set value: {nxSetting} as {nxSetting.GetType()}");
|
2018-04-25 20:52:22 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-03 19:32:53 -04:00
|
|
|
Logger.Error?.Print(LogClass.ServiceSet, $"{askedSetting} not found!");
|
2018-04-25 20:52:22 -04:00
|
|
|
}
|
|
|
|
|
2019-07-14 15:04:38 -04:00
|
|
|
return ResultCode.Success;
|
2018-04-25 20:52:22 -04:00
|
|
|
}
|
2018-11-18 14:37:41 -05:00
|
|
|
|
2022-05-05 14:23:30 -04:00
|
|
|
[CommandHipc(60)]
|
2021-02-09 03:41:31 -05:00
|
|
|
// IsUserSystemClockAutomaticCorrectionEnabled() -> bool
|
|
|
|
public ResultCode IsUserSystemClockAutomaticCorrectionEnabled(ServiceCtx context)
|
|
|
|
{
|
|
|
|
// NOTE: When set to true, is automatically synced with the internet.
|
|
|
|
context.ResponseData.Write(true);
|
|
|
|
|
2021-06-23 19:18:36 -04:00
|
|
|
Logger.Stub?.PrintStub(LogClass.ServiceSet);
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
}
|
|
|
|
|
2022-05-05 14:23:30 -04:00
|
|
|
[CommandHipc(62)]
|
|
|
|
// GetDebugModeFlag() -> bool
|
|
|
|
public ResultCode GetDebugModeFlag(ServiceCtx context)
|
|
|
|
{
|
|
|
|
context.ResponseData.Write(false);
|
|
|
|
|
|
|
|
Logger.Stub?.PrintStub(LogClass.ServiceSet);
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
}
|
|
|
|
|
2021-06-23 19:18:36 -04:00
|
|
|
[CommandHipc(77)]
|
|
|
|
// GetDeviceNickName() -> buffer<nn::settings::system::DeviceNickName, 0x16>
|
|
|
|
public ResultCode GetDeviceNickName(ServiceCtx context)
|
|
|
|
{
|
|
|
|
ulong deviceNickNameBufferPosition = context.Request.ReceiveBuff[0].Position;
|
|
|
|
ulong deviceNickNameBufferSize = context.Request.ReceiveBuff[0].Size;
|
|
|
|
|
|
|
|
if (deviceNickNameBufferPosition == 0)
|
|
|
|
{
|
|
|
|
return ResultCode.NullDeviceNicknameBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (deviceNickNameBufferSize != 0x80)
|
|
|
|
{
|
|
|
|
Logger.Warning?.Print(LogClass.ServiceSet, "Wrong buffer size");
|
|
|
|
}
|
|
|
|
|
|
|
|
context.Memory.Write(deviceNickNameBufferPosition, Encoding.ASCII.GetBytes(context.Device.System.State.DeviceNickName + '\0'));
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
[CommandHipc(78)]
|
|
|
|
// SetDeviceNickName(buffer<nn::settings::system::DeviceNickName, 0x15>)
|
|
|
|
public ResultCode SetDeviceNickName(ServiceCtx context)
|
|
|
|
{
|
|
|
|
ulong deviceNickNameBufferPosition = context.Request.SendBuff[0].Position;
|
|
|
|
ulong deviceNickNameBufferSize = context.Request.SendBuff[0].Size;
|
|
|
|
|
|
|
|
byte[] deviceNickNameBuffer = new byte[deviceNickNameBufferSize];
|
|
|
|
|
|
|
|
context.Memory.Read(deviceNickNameBufferPosition, deviceNickNameBuffer);
|
|
|
|
|
|
|
|
context.Device.System.State.DeviceNickName = Encoding.ASCII.GetString(deviceNickNameBuffer);
|
2021-02-09 03:41:31 -05:00
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
}
|
|
|
|
|
2021-06-28 14:54:45 -04:00
|
|
|
[CommandHipc(90)]
|
|
|
|
// GetMiiAuthorId() -> nn::util::Uuid
|
|
|
|
public ResultCode GetMiiAuthorId(ServiceCtx context)
|
|
|
|
{
|
|
|
|
// NOTE: If miiAuthorId is null ResultCode.NullMiiAuthorIdBuffer is returned.
|
|
|
|
// Doesn't occur in our case.
|
|
|
|
|
|
|
|
UInt128 miiAuthorId = Mii.Helper.GetDeviceId();
|
|
|
|
|
|
|
|
miiAuthorId.Write(context.ResponseData);
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
}
|
|
|
|
|
2019-07-14 15:04:38 -04:00
|
|
|
public byte[] GetFirmwareData(Switch device)
|
2018-11-18 14:37:41 -05:00
|
|
|
{
|
2021-04-24 06:16:01 -04:00
|
|
|
const ulong SystemVersionTitleId = 0x0100000000000809;
|
|
|
|
|
2022-03-22 15:46:16 -04:00
|
|
|
string contentPath = device.System.ContentManager.GetInstalledContentPath(SystemVersionTitleId, StorageId.BuiltInSystem, NcaContentType.Data);
|
2018-11-18 14:37:41 -05:00
|
|
|
|
2019-07-01 22:39:22 -04:00
|
|
|
if (string.IsNullOrWhiteSpace(contentPath))
|
2018-11-18 14:37:41 -05:00
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2019-01-04 19:41:49 -05:00
|
|
|
string firmwareTitlePath = device.FileSystem.SwitchPathToSystemPath(contentPath);
|
2018-11-18 14:37:41 -05:00
|
|
|
|
2019-05-31 20:31:10 -04:00
|
|
|
using(IStorage firmwareStorage = new LocalStorage(firmwareTitlePath, FileAccess.Read))
|
|
|
|
{
|
|
|
|
Nca firmwareContent = new Nca(device.System.KeySet, firmwareStorage);
|
2018-11-18 14:37:41 -05:00
|
|
|
|
2019-05-31 20:31:10 -04:00
|
|
|
if (!firmwareContent.CanOpenSection(NcaSectionType.Data))
|
2018-11-18 14:37:41 -05:00
|
|
|
{
|
2019-01-04 19:41:49 -05:00
|
|
|
return null;
|
2018-11-18 14:37:41 -05:00
|
|
|
}
|
|
|
|
|
2019-05-31 20:31:10 -04:00
|
|
|
IFileSystem firmwareRomFs = firmwareContent.OpenFileSystem(NcaSectionType.Data, device.System.FsIntegrityCheckLevel);
|
2018-11-18 14:37:41 -05:00
|
|
|
|
2021-12-23 11:55:50 -05:00
|
|
|
using var firmwareFile = new UniqueRef<IFile>();
|
|
|
|
|
|
|
|
Result result = firmwareRomFs.OpenFile(ref firmwareFile.Ref(), "/file".ToU8Span(), OpenMode.Read);
|
2019-10-17 02:17:44 -04:00
|
|
|
if (result.IsFailure())
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-12-23 11:55:50 -05:00
|
|
|
result = firmwareFile.Get.GetSize(out long fileSize);
|
2019-10-17 02:17:44 -04:00
|
|
|
if (result.IsFailure())
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
2018-11-18 14:37:41 -05:00
|
|
|
|
2019-10-17 02:17:44 -04:00
|
|
|
byte[] data = new byte[fileSize];
|
2019-01-04 19:41:49 -05:00
|
|
|
|
2021-12-23 11:55:50 -05:00
|
|
|
result = firmwareFile.Get.Read(out _, 0, data);
|
2019-10-17 02:17:44 -04:00
|
|
|
if (result.IsFailure())
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
2019-01-04 19:41:49 -05:00
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
2018-11-18 14:37:41 -05:00
|
|
|
}
|
2018-03-01 15:23:55 -05:00
|
|
|
}
|
2021-02-09 03:41:31 -05:00
|
|
|
}
|