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 --- Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs | 30 +++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'Ryujinx.HLE/HOS/Services/Nv') diff --git a/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs b/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs index 35bb4e6f..25279af3 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs @@ -73,8 +73,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv private NvResult GetIoctlArgument(ServiceCtx context, NvIoctl ioctlCommand, out Span arguments) { - (long inputDataPosition, long inputDataSize) = context.Request.GetBufferType0x21(0); - (long outputDataPosition, long outputDataSize) = context.Request.GetBufferType0x22(0); + (ulong inputDataPosition, ulong inputDataSize) = context.Request.GetBufferType0x21(0); + (ulong outputDataPosition, ulong outputDataSize) = context.Request.GetBufferType0x22(0); NvIoctl.Direction ioctlDirection = ioctlCommand.DirectionValue; uint ioctlSize = ioctlCommand.Size; @@ -106,7 +106,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv byte[] temp = new byte[inputDataSize]; - context.Memory.Read((ulong)inputDataPosition, temp); + context.Memory.Read(inputDataPosition, temp); Buffer.BlockCopy(temp, 0, outputData, 0, temp.Length); @@ -122,7 +122,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv { byte[] temp = new byte[inputDataSize]; - context.Memory.Read((ulong)inputDataPosition, temp); + context.Memory.Read(inputDataPosition, temp); arguments = new Span(temp); } @@ -226,10 +226,10 @@ namespace Ryujinx.HLE.HOS.Services.Nv if (errorCode == NvResult.Success) { - long pathPtr = context.Request.SendBuff[0].Position; - long pathSize = context.Request.SendBuff[0].Size; + ulong pathPtr = context.Request.SendBuff[0].Position; + ulong pathSize = context.Request.SendBuff[0].Size; - string path = MemoryHelper.ReadAsciiString(context.Memory, pathPtr, pathSize); + string path = MemoryHelper.ReadAsciiString(context.Memory, pathPtr, (long)pathSize); fd = Open(context, path); @@ -275,7 +275,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv if ((ioctlCommand.DirectionValue & NvIoctl.Direction.Write) != 0) { - context.Memory.Write((ulong)context.Request.GetBufferType0x22(0).Position, arguments.ToArray()); + context.Memory.Write(context.Request.GetBufferType0x22(0).Position, arguments.ToArray()); } } } @@ -470,13 +470,13 @@ namespace Ryujinx.HLE.HOS.Services.Nv int fd = context.RequestData.ReadInt32(); NvIoctl ioctlCommand = context.RequestData.ReadStruct(); - (long inlineInBufferPosition, long inlineInBufferSize) = context.Request.GetBufferType0x21(1); + (ulong inlineInBufferPosition, ulong inlineInBufferSize) = context.Request.GetBufferType0x21(1); errorCode = GetIoctlArgument(context, ioctlCommand, out Span arguments); byte[] temp = new byte[inlineInBufferSize]; - context.Memory.Read((ulong)inlineInBufferPosition, temp); + context.Memory.Read(inlineInBufferPosition, temp); Span inlineInBuffer = new Span(temp); @@ -497,7 +497,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv if ((ioctlCommand.DirectionValue & NvIoctl.Direction.Write) != 0) { - context.Memory.Write((ulong)context.Request.GetBufferType0x22(0).Position, arguments.ToArray()); + context.Memory.Write(context.Request.GetBufferType0x22(0).Position, arguments.ToArray()); } } } @@ -519,13 +519,13 @@ namespace Ryujinx.HLE.HOS.Services.Nv int fd = context.RequestData.ReadInt32(); NvIoctl ioctlCommand = context.RequestData.ReadStruct(); - (long inlineOutBufferPosition, long inlineOutBufferSize) = context.Request.GetBufferType0x22(1); + (ulong inlineOutBufferPosition, ulong inlineOutBufferSize) = context.Request.GetBufferType0x22(1); errorCode = GetIoctlArgument(context, ioctlCommand, out Span arguments); byte[] temp = new byte[inlineOutBufferSize]; - context.Memory.Read((ulong)inlineOutBufferPosition, temp); + context.Memory.Read(inlineOutBufferPosition, temp); Span inlineOutBuffer = new Span(temp); @@ -546,8 +546,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv if ((ioctlCommand.DirectionValue & NvIoctl.Direction.Write) != 0) { - context.Memory.Write((ulong)context.Request.GetBufferType0x22(0).Position, arguments.ToArray()); - context.Memory.Write((ulong)inlineOutBufferPosition, inlineOutBuffer.ToArray()); + context.Memory.Write(context.Request.GetBufferType0x22(0).Position, arguments.ToArray()); + context.Memory.Write(inlineOutBufferPosition, inlineOutBuffer.ToArray()); } } } -- cgit v1.2.3