aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/Utilities/StructWriter.cs
blob: 39644db5ce227f9ce44b075a94f3a7c3bbe91a5a (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
using Ryujinx.Cpu;
using Ryujinx.Memory;
using System.Runtime.InteropServices;

namespace Ryujinx.HLE.Utilities
{
    class StructWriter
    {
        private IVirtualMemoryManager _memory;

        public ulong Position { get; private set; }

        public StructWriter(IVirtualMemoryManager memory, ulong position)
        {
            _memory  = memory;
            Position = position;
        }

        public void Write<T>(T value) where T : struct
        {
            MemoryHelper.Write(_memory, Position, value);

            Position += (ulong)Marshal.SizeOf<T>();
        }

        public void SkipBytes(ulong count)
        {
            Position += count;
        }
    }
}