diff --git a/Memory/AMemory.cs b/Memory/AMemory.cs index 566e6b5..806a0b8 100644 --- a/Memory/AMemory.cs +++ b/Memory/AMemory.cs @@ -287,6 +287,14 @@ namespace ChocolArm64.Memory return Data; } + public void ReadBytes(long Position, byte[] Data, int StartIndex, int Size) + { + //Note: This will be moved later. + EnsureRangeIsValid(Position, (uint)Size); + + Marshal.Copy((IntPtr)Translate(Position), Data, StartIndex, Size); + } + public void WriteSByte(long Position, sbyte Value) { WriteByte(Position, (byte)Value); @@ -403,6 +411,27 @@ namespace ChocolArm64.Memory Marshal.Copy(Data, 0, (IntPtr)TranslateWrite(Position), Data.Length); } + public void WriteBytes(long Position, byte[] Data, int StartIndex, int Size) + { + //Note: This will be moved later. + //Using Translate instead of TranslateWrite is on purpose. + EnsureRangeIsValid(Position, (uint)Size); + + Marshal.Copy(Data, StartIndex, (IntPtr)Translate(Position), Size); + } + + public void CopyBytes(long Src, long Dst, long Size) + { + //Note: This will be moved later. + EnsureRangeIsValid(Src, Size); + EnsureRangeIsValid(Dst, Size); + + byte* SrcPtr = Translate(Src); + byte* DstPtr = TranslateWrite(Dst); + + Buffer.MemoryCopy(SrcPtr, DstPtr, Size, Size); + } + public void Map(long VA, long PA, long Size) { SetPTEntries(VA, RamPtr + PA, Size);