Pointer.cs 850 B

1234567891011121314151617181920212223242526272829303132
  1. using Ryujinx.Common.Logging;
  2. using Ryujinx.HLE.HOS.Tamper.Operations;
  3. using System.Runtime.CompilerServices;
  4. namespace Ryujinx.HLE.HOS.Tamper
  5. {
  6. class Pointer : IOperand
  7. {
  8. private IOperand _position;
  9. private ITamperedProcess _process;
  10. public Pointer(IOperand position, ITamperedProcess process)
  11. {
  12. _position = position;
  13. _process = process;
  14. }
  15. public T Get<T>() where T : unmanaged
  16. {
  17. return _process.ReadMemory<T>(_position.Get<ulong>());
  18. }
  19. public void Set<T>(T value) where T : unmanaged
  20. {
  21. ulong position = _position.Get<ulong>();
  22. Logger.Debug?.Print(LogClass.TamperMachine, $"0x{position:X16}@{Unsafe.SizeOf<T>()}: {value:X}");
  23. _process.WriteMemory(position, value);
  24. }
  25. }
  26. }