From 88b1a67f98d9f708cc743ec2661ae72fd20edecd Mon Sep 17 00:00:00 2001 From: riperiperi Date: Thu, 7 Jun 2018 00:25:59 +0100 Subject: [PATCH] Add UncheckedReadBytes in AMemory, for MemoryHelper when checks disabled --- ChocolArm64/Memory/AMemory.cs | 7 +++++++ ChocolArm64/Memory/AMemoryHelper.cs | 6 ++++++ 2 files changed, 13 insertions(+) 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++)