From 305f06eb71a7832e6b0081a67015b66ced8a23cd Mon Sep 17 00:00:00 2001 From: Mary Date: Sat, 24 Apr 2021 12:16:01 +0200 Subject: 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 --- .../HOS/Services/Am/AppletAE/IStorageAccessor.cs | 22 +++++++++++----------- .../ApplicationProxy/IApplicationFunctions.cs | 16 ++++++++-------- 2 files changed, 19 insertions(+), 19 deletions(-) (limited to 'Ryujinx.HLE/HOS/Services/Am') diff --git a/Ryujinx.HLE/HOS/Services/Am/AppletAE/IStorageAccessor.cs b/Ryujinx.HLE/HOS/Services/Am/AppletAE/IStorageAccessor.cs index cdc59678..33f5393f 100644 --- a/Ryujinx.HLE/HOS/Services/Am/AppletAE/IStorageAccessor.cs +++ b/Ryujinx.HLE/HOS/Services/Am/AppletAE/IStorageAccessor.cs @@ -29,20 +29,20 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE return ResultCode.ObjectInvalid; } - long writePosition = context.RequestData.ReadInt64(); + ulong writePosition = context.RequestData.ReadUInt64(); - if (writePosition > _storage.Data.Length) + if (writePosition > (ulong)_storage.Data.Length) { return ResultCode.OutOfBounds; } - (long position, long size) = context.Request.GetBufferType0x21(); + (ulong position, ulong size) = context.Request.GetBufferType0x21(); - size = Math.Min(size, _storage.Data.Length - writePosition); + size = Math.Min(size, (ulong)_storage.Data.Length - writePosition); if (size > 0) { - long maxSize = _storage.Data.Length - writePosition; + ulong maxSize = (ulong)_storage.Data.Length - writePosition; if (size > maxSize) { @@ -51,7 +51,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE byte[] data = new byte[size]; - context.Memory.Read((ulong)position, data); + context.Memory.Read(position, data); Buffer.BlockCopy(data, 0, _storage.Data, (int)writePosition, (int)size); } @@ -63,22 +63,22 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE // Read(u64) -> buffer public ResultCode Read(ServiceCtx context) { - long readPosition = context.RequestData.ReadInt64(); + ulong readPosition = context.RequestData.ReadUInt64(); - if (readPosition > _storage.Data.Length) + if (readPosition > (ulong)_storage.Data.Length) { return ResultCode.OutOfBounds; } - (long position, long size) = context.Request.GetBufferType0x22(); + (ulong position, ulong size) = context.Request.GetBufferType0x22(); - size = Math.Min(size, _storage.Data.Length - readPosition); + size = Math.Min(size, (ulong)_storage.Data.Length - readPosition); byte[] data = new byte[size]; Buffer.BlockCopy(_storage.Data, (int)readPosition, data, 0, (int)size); - context.Memory.Write((ulong)position, data); + context.Memory.Write(position, data); return ResultCode.Success; } diff --git a/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/IApplicationFunctions.cs b/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/IApplicationFunctions.cs index a1a5d8c4..7c04a4d1 100644 --- a/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/IApplicationFunctions.cs +++ b/Ryujinx.HLE/HOS/Services/Am/AppletOE/ApplicationProxyService/ApplicationProxy/IApplicationFunctions.cs @@ -359,13 +359,13 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati // SetApplicationCopyrightImage(buffer frame_buffer, s32 x, s32 y, s32 width, s32 height, s32 window_origin_mode) public ResultCode SetApplicationCopyrightImage(ServiceCtx context) { - long frameBufferPos = context.Request.SendBuff[0].Position; - long frameBufferSize = context.Request.SendBuff[0].Size; - int x = context.RequestData.ReadInt32(); - int y = context.RequestData.ReadInt32(); - int width = context.RequestData.ReadInt32(); - int height = context.RequestData.ReadInt32(); - uint windowOriginMode = context.RequestData.ReadUInt32(); + ulong frameBufferPos = context.Request.SendBuff[0].Position; + ulong frameBufferSize = context.Request.SendBuff[0].Size; + int x = context.RequestData.ReadInt32(); + int y = context.RequestData.ReadInt32(); + int width = context.RequestData.ReadInt32(); + int height = context.RequestData.ReadInt32(); + uint windowOriginMode = context.RequestData.ReadUInt32(); ResultCode resultCode = ResultCode.InvalidParameters; @@ -388,7 +388,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati return resultCode; } - private ResultCode SetApplicationCopyrightImageImpl(int x, int y, int width, int height, long frameBufferPos, long frameBufferSize, uint windowOriginMode) + private ResultCode SetApplicationCopyrightImageImpl(int x, int y, int width, int height, ulong frameBufferPos, ulong frameBufferSize, uint windowOriginMode) { /* if (_copyrightBuffer == null) -- cgit v1.2.3