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:
Mary 2021-04-24 12:16:01 +02:00 committed by GitHub
parent c46f6879ff
commit 305f06eb71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
73 changed files with 707 additions and 716 deletions

View file

@ -16,16 +16,16 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
public ResultCode Get(ServiceCtx context)
{
context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize(0x80L);
context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize(0x80UL);
long bufferPosition = context.Request.RecvListBuff[0].Position;
ulong bufferPosition = context.Request.RecvListBuff[0].Position;
MemoryHelper.FillWithZeros(context.Memory, bufferPosition, 0x80);
// TODO: Determine the struct.
context.Memory.Write((ulong)bufferPosition, 0); // Unknown
context.Memory.Write((ulong)bufferPosition + 4, 1); // Icon ID. 0 = Mii, the rest are character icon IDs.
context.Memory.Write((ulong)bufferPosition + 8, (byte)1); // Profile icon background color ID
context.Memory.Write(bufferPosition, 0); // Unknown
context.Memory.Write(bufferPosition + 4, 1); // Icon ID. 0 = Mii, the rest are character icon IDs.
context.Memory.Write(bufferPosition + 8, (byte)1); // Profile icon background color ID
// 0x07 bytes - Unknown
// 0x10 bytes - Some ID related to the Mii? All zeros when a character icon is used.
// 0x60 bytes - Usually zeros?
@ -57,15 +57,15 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
public ResultCode LoadImage(ServiceCtx context)
{
long bufferPosition = context.Request.ReceiveBuff[0].Position;
long bufferLen = context.Request.ReceiveBuff[0].Size;
ulong bufferPosition = context.Request.ReceiveBuff[0].Position;
ulong bufferLen = context.Request.ReceiveBuff[0].Size;
if (_profile.Image.Length > bufferLen)
if ((ulong)_profile.Image.Length > bufferLen)
{
return ResultCode.InvalidBufferSize;
}
context.Memory.Write((ulong)bufferPosition, _profile.Image);
context.Memory.Write(bufferPosition, _profile.Image);
context.ResponseData.Write(_profile.Image.Length);
@ -74,12 +74,12 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
public ResultCode Store(ServiceCtx context)
{
long userDataPosition = context.Request.PtrBuff[0].Position;
long userDataSize = context.Request.PtrBuff[0].Size;
ulong userDataPosition = context.Request.PtrBuff[0].Position;
ulong userDataSize = context.Request.PtrBuff[0].Size;
byte[] userData = new byte[userDataSize];
context.Memory.Read((ulong)userDataPosition, userData);
context.Memory.Read(userDataPosition, userData);
// TODO: Read the nn::account::profile::ProfileBase and store everything in the savedata.
@ -90,19 +90,19 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
public ResultCode StoreWithImage(ServiceCtx context)
{
long userDataPosition = context.Request.PtrBuff[0].Position;
long userDataSize = context.Request.PtrBuff[0].Size;
ulong userDataPosition = context.Request.PtrBuff[0].Position;
ulong userDataSize = context.Request.PtrBuff[0].Size;
byte[] userData = new byte[userDataSize];
context.Memory.Read((ulong)userDataPosition, userData);
context.Memory.Read(userDataPosition, userData);
long profileImagePosition = context.Request.SendBuff[0].Position;
long profileImageSize = context.Request.SendBuff[0].Size;
ulong profileImagePosition = context.Request.SendBuff[0].Position;
ulong profileImageSize = context.Request.SendBuff[0].Size;
byte[] profileImageData = new byte[profileImageSize];
context.Memory.Read((ulong)profileImagePosition, profileImageData);
context.Memory.Read(profileImagePosition, profileImageData);
// TODO: Read the nn::account::profile::ProfileBase and store everything in the savedata.