Add UncheckedReadBytes in AMemory, for MemoryHelper when checks disabled

This commit is contained in:
riperiperi 2018-06-07 00:25:59 +01:00
parent df33dcc489
commit 88b1a67f98
2 changed files with 13 additions and 0 deletions

View file

@ -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<float> ReadVector8Unchecked(long Position)
{
if (Sse2.IsSupported)

View file

@ -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++)