StructWriter.cs 559 B

12345678910111213141516171819202122232425
  1. using ARMeilleure.Memory;
  2. using System.Runtime.InteropServices;
  3. namespace Ryujinx.HLE.Utilities
  4. {
  5. class StructWriter
  6. {
  7. private IMemoryManager _memory;
  8. public long Position { get; private set; }
  9. public StructWriter(IMemoryManager memory, long position)
  10. {
  11. _memory = memory;
  12. Position = position;
  13. }
  14. public void Write<T>(T value) where T : struct
  15. {
  16. MemoryHelper.Write(_memory, Position, value);
  17. Position += Marshal.SizeOf<T>();
  18. }
  19. }
  20. }