HLE: Fix integer sign inconcistency accross the codebase (#2222)
* Make all title id instances unsigned * Replace address and size with ulong instead of signed types Long overdue change. Also change some logics here and there to optimize with the new memory manager. * Address Ac_K's comments * Remove uneeded cast all around * Fixes some others misalignment
This commit is contained in:
parent
c46f6879ff
commit
305f06eb71
73 changed files with 707 additions and 716 deletions
|
@ -29,7 +29,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings
|
|||
// GetFirmwareVersion2() -> buffer<nn::settings::system::FirmwareVersion, 0x1a, 0x100>
|
||||
public ResultCode GetFirmwareVersion2(ServiceCtx context)
|
||||
{
|
||||
long replyPos = context.Request.RecvListBuff[0].Position;
|
||||
ulong replyPos = context.Request.RecvListBuff[0].Position;
|
||||
|
||||
context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize(0x100L);
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings
|
|||
|
||||
if (firmwareData != null)
|
||||
{
|
||||
context.Memory.Write((ulong)replyPos, firmwareData);
|
||||
context.Memory.Write(replyPos, firmwareData);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings
|
|||
|
||||
writer.Write(Encoding.ASCII.GetBytes(build));
|
||||
|
||||
context.Memory.Write((ulong)replyPos, ms.ToArray());
|
||||
context.Memory.Write(replyPos, ms.ToArray());
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
|
@ -110,19 +110,19 @@ namespace Ryujinx.HLE.HOS.Services.Settings
|
|||
// GetSettingsItemValueSize(buffer<nn::settings::SettingsName, 0x19>, buffer<nn::settings::SettingsItemKey, 0x19>) -> u64
|
||||
public ResultCode GetSettingsItemValueSize(ServiceCtx context)
|
||||
{
|
||||
long classPos = context.Request.PtrBuff[0].Position;
|
||||
long classSize = context.Request.PtrBuff[0].Size;
|
||||
ulong classPos = context.Request.PtrBuff[0].Position;
|
||||
ulong classSize = context.Request.PtrBuff[0].Size;
|
||||
|
||||
long namePos = context.Request.PtrBuff[1].Position;
|
||||
long nameSize = context.Request.PtrBuff[1].Size;
|
||||
ulong namePos = context.Request.PtrBuff[1].Position;
|
||||
ulong nameSize = context.Request.PtrBuff[1].Size;
|
||||
|
||||
byte[] classBuffer = new byte[classSize];
|
||||
|
||||
context.Memory.Read((ulong)classPos, classBuffer);
|
||||
context.Memory.Read(classPos, classBuffer);
|
||||
|
||||
byte[] nameBuffer = new byte[nameSize];
|
||||
|
||||
context.Memory.Read((ulong)namePos, nameBuffer);
|
||||
context.Memory.Read(namePos, nameBuffer);
|
||||
|
||||
string askedSetting = Encoding.ASCII.GetString(classBuffer).Trim('\0') + "!" + Encoding.ASCII.GetString(nameBuffer).Trim('\0');
|
||||
|
||||
|
@ -159,22 +159,22 @@ namespace Ryujinx.HLE.HOS.Services.Settings
|
|||
// GetSettingsItemValue(buffer<nn::settings::SettingsName, 0x19, 0x48>, buffer<nn::settings::SettingsItemKey, 0x19, 0x48>) -> (u64, buffer<unknown, 6, 0>)
|
||||
public ResultCode GetSettingsItemValue(ServiceCtx context)
|
||||
{
|
||||
long classPos = context.Request.PtrBuff[0].Position;
|
||||
long classSize = context.Request.PtrBuff[0].Size;
|
||||
ulong classPos = context.Request.PtrBuff[0].Position;
|
||||
ulong classSize = context.Request.PtrBuff[0].Size;
|
||||
|
||||
long namePos = context.Request.PtrBuff[1].Position;
|
||||
long nameSize = context.Request.PtrBuff[1].Size;
|
||||
ulong namePos = context.Request.PtrBuff[1].Position;
|
||||
ulong nameSize = context.Request.PtrBuff[1].Size;
|
||||
|
||||
long replyPos = context.Request.ReceiveBuff[0].Position;
|
||||
long replySize = context.Request.ReceiveBuff[0].Size;
|
||||
ulong replyPos = context.Request.ReceiveBuff[0].Position;
|
||||
ulong replySize = context.Request.ReceiveBuff[0].Size;
|
||||
|
||||
byte[] classBuffer = new byte[classSize];
|
||||
|
||||
context.Memory.Read((ulong)classPos, classBuffer);
|
||||
context.Memory.Read(classPos, classBuffer);
|
||||
|
||||
byte[] nameBuffer = new byte[nameSize];
|
||||
|
||||
context.Memory.Read((ulong)namePos, nameBuffer);
|
||||
context.Memory.Read(namePos, nameBuffer);
|
||||
|
||||
string askedSetting = Encoding.ASCII.GetString(classBuffer).Trim('\0') + "!" + Encoding.ASCII.GetString(nameBuffer).Trim('\0');
|
||||
|
||||
|
@ -186,7 +186,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings
|
|||
|
||||
if (nxSetting is string stringValue)
|
||||
{
|
||||
if (stringValue.Length + 1 > replySize)
|
||||
if ((ulong)(stringValue.Length + 1) > replySize)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.ServiceSet, $"{askedSetting} String value size is too big!");
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings
|
|||
throw new NotImplementedException(nxSetting.GetType().Name);
|
||||
}
|
||||
|
||||
context.Memory.Write((ulong)replyPos, settingBuffer);
|
||||
context.Memory.Write(replyPos, settingBuffer);
|
||||
|
||||
Logger.Debug?.Print(LogClass.ServiceSet, $"{askedSetting} set value: {nxSetting} as {nxSetting.GetType()}");
|
||||
}
|
||||
|
@ -235,8 +235,9 @@ namespace Ryujinx.HLE.HOS.Services.Settings
|
|||
|
||||
public byte[] GetFirmwareData(Switch device)
|
||||
{
|
||||
long titleId = 0x0100000000000809;
|
||||
string contentPath = device.System.ContentManager.GetInstalledContentPath(titleId, StorageId.NandSystem, NcaContentType.Data);
|
||||
const ulong SystemVersionTitleId = 0x0100000000000809;
|
||||
|
||||
string contentPath = device.System.ContentManager.GetInstalledContentPath(SystemVersionTitleId, StorageId.NandSystem, NcaContentType.Data);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(contentPath))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue