aboutsummaryrefslogtreecommitdiff
path: root/ChocolArm64/Memory/AMemoryHelper.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ChocolArm64/Memory/AMemoryHelper.cs')
-rw-r--r--ChocolArm64/Memory/AMemoryHelper.cs24
1 files changed, 4 insertions, 20 deletions
diff --git a/ChocolArm64/Memory/AMemoryHelper.cs b/ChocolArm64/Memory/AMemoryHelper.cs
index 0a23a2f8..ea877834 100644
--- a/ChocolArm64/Memory/AMemoryHelper.cs
+++ b/ChocolArm64/Memory/AMemoryHelper.cs
@@ -26,12 +26,9 @@ namespace ChocolArm64.Memory
{
long Size = Marshal.SizeOf<T>();
- if ((ulong)(Position + Size) > AMemoryMgr.AddrSize)
- {
- throw new ArgumentOutOfRangeException(nameof(Position));
- }
+ Memory.EnsureRangeIsValid(Position, Size);
- IntPtr Ptr = new IntPtr((byte*)Memory.Ram + Position);
+ IntPtr Ptr = (IntPtr)Memory.Translate(Position);
return Marshal.PtrToStructure<T>(Ptr);
}
@@ -40,12 +37,9 @@ namespace ChocolArm64.Memory
{
long Size = Marshal.SizeOf<T>();
- if ((ulong)(Position + Size) > AMemoryMgr.AddrSize)
- {
- throw new ArgumentOutOfRangeException(nameof(Position));
- }
+ Memory.EnsureRangeIsValid(Position, Size);
- IntPtr Ptr = new IntPtr((byte*)Memory.Ram + Position);
+ IntPtr Ptr = (IntPtr)Memory.TranslateWrite(Position);
Marshal.StructureToPtr<T>(Value, Ptr, false);
}
@@ -69,15 +63,5 @@ namespace ChocolArm64.Memory
return Encoding.ASCII.GetString(MS.ToArray());
}
}
-
- public static long PageRoundUp(long Value)
- {
- return (Value + AMemoryMgr.PageMask) & ~AMemoryMgr.PageMask;
- }
-
- public static long PageRoundDown(long Value)
- {
- return Value & ~AMemoryMgr.PageMask;
- }
}
} \ No newline at end of file