diff --git a/ChocolArm64/Memory/AMemory.cs b/ChocolArm64/Memory/AMemory.cs index c24a9e8ef..493dbe987 100644 --- a/ChocolArm64/Memory/AMemory.cs +++ b/ChocolArm64/Memory/AMemory.cs @@ -301,6 +301,13 @@ namespace ChocolArm64.Memory return *((ulong*)(RamPtr + (uint)Position)); } + public byte[] ReadByteArrayUnchecked(long Position, long Length) + { + byte[] Result = new byte[Length]; + Marshal.Copy((IntPtr)(RamPtr + (uint)Position), Result, 0, (int)Length); + return Result; + } + public Vector128 ReadVector8Unchecked(long Position) { if (Sse2.IsSupported) diff --git a/ChocolArm64/Memory/AMemoryHelper.cs b/ChocolArm64/Memory/AMemoryHelper.cs index 1e3462985..4cfa2360f 100644 --- a/ChocolArm64/Memory/AMemoryHelper.cs +++ b/ChocolArm64/Memory/AMemoryHelper.cs @@ -24,6 +24,7 @@ namespace ChocolArm64.Memory public static byte[] ReadBytes(AMemory Memory, long Position, long Size) { + if (AOptimizations.DisableMemoryChecks) return ReadBytesUnchecked(Memory, Position, Size); byte[] Data = new byte[Size]; for (long Offs = 0; Offs < Size; Offs++) @@ -34,6 +35,11 @@ namespace ChocolArm64.Memory return Data; } + public static byte[] ReadBytesUnchecked(AMemory Memory, long Position, long Size) + { + return Memory.ReadByteArrayUnchecked(Position, Size); + } + public static void WriteBytes(AMemory Memory, long Position, byte[] Data) { for (int Offs = 0; Offs < Data.Length; Offs++)