aboutsummaryrefslogtreecommitdiff
path: root/ChocolArm64/Memory
diff options
context:
space:
mode:
Diffstat (limited to 'ChocolArm64/Memory')
-rw-r--r--ChocolArm64/Memory/AMemory.cs29
1 files changed, 29 insertions, 0 deletions
diff --git a/ChocolArm64/Memory/AMemory.cs b/ChocolArm64/Memory/AMemory.cs
index 566e6b54..806a0b86 100644
--- a/ChocolArm64/Memory/AMemory.cs
+++ b/ChocolArm64/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);