mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2025-06-30 01:50:46 -07:00
ReadBytes function in AMemory, with cleaner range check. (#136)
This commit is contained in:
@ -301,6 +301,15 @@ namespace ChocolArm64.Memory
|
||||
return *((ulong*)(RamPtr + (uint)Position));
|
||||
}
|
||||
|
||||
public byte[] ReadBytes(long Position, long Size)
|
||||
{
|
||||
EnsureRangeIsValid(Position, Size, AMemoryPerm.Read);
|
||||
|
||||
byte[] Result = new byte[Size];
|
||||
Marshal.Copy((IntPtr)(RamPtr + (uint)Position), Result, 0, (int)Size);
|
||||
return Result;
|
||||
}
|
||||
|
||||
public Vector128<float> ReadVector8Unchecked(long Position)
|
||||
{
|
||||
if (Sse2.IsSupported)
|
||||
@ -611,6 +620,17 @@ namespace ChocolArm64.Memory
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsureRangeIsValid(long Position, long Size, AMemoryPerm Perm)
|
||||
{
|
||||
long EndPos = (Position + Size);
|
||||
Position = Position & ~AMemoryMgr.PageMask; //check base of each page
|
||||
while (Position < EndPos)
|
||||
{
|
||||
EnsureAccessIsValid(Position, Perm);
|
||||
Position += AMemoryMgr.PageSize;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
|
Reference in New Issue
Block a user