blob: 81e758a8287d080baf37fc2077eead5b62437909 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
using Ryujinx.Cpu;
using Ryujinx.Memory;
using System;
using System.Runtime.InteropServices;
namespace Ryujinx.HLE.Utilities
{
class StructReader
{
private IVirtualMemoryManager _memory;
public ulong Position { get; private set; }
public StructReader(IVirtualMemoryManager memory, ulong position)
{
_memory = memory;
Position = position;
}
public T Read<T>() where T : unmanaged
{
T value = MemoryHelper.Read<T>(_memory, Position);
Position += (uint)Marshal.SizeOf<T>();
return value;
}
public ReadOnlySpan<T> Read<T>(int size) where T : unmanaged
{
ReadOnlySpan<byte> data = _memory.GetSpan(Position, size);
Position += (uint)size;
return MemoryMarshal.Cast<byte, T>(data);
}
}
}
|