ServiceCtx.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using ChocolArm64.Memory;
  2. using Ryujinx.OsHle.Handles;
  3. using Ryujinx.OsHle.Ipc;
  4. using System.IO;
  5. namespace Ryujinx.OsHle
  6. {
  7. class ServiceCtx
  8. {
  9. public Switch Ns { get; private set; }
  10. public AMemory Memory { get; private set; }
  11. public HSession Session { get; private set; }
  12. public IpcMessage Request { get; private set; }
  13. public IpcMessage Response { get; private set; }
  14. public BinaryReader RequestData { get; private set; }
  15. public BinaryWriter ResponseData { get; private set; }
  16. public ServiceCtx(
  17. Switch Ns,
  18. AMemory Memory,
  19. HSession Session,
  20. IpcMessage Request,
  21. IpcMessage Response,
  22. BinaryReader RequestData,
  23. BinaryWriter ResponseData)
  24. {
  25. this.Ns = Ns;
  26. this.Memory = Memory;
  27. this.Session = Session;
  28. this.Request = Request;
  29. this.Response = Response;
  30. this.RequestData = RequestData;
  31. this.ResponseData = ResponseData;
  32. }
  33. public T GetObject<T>()
  34. {
  35. object Obj = null;
  36. if (Session is HSessionObj SessionObj)
  37. {
  38. Obj = SessionObj.Obj;
  39. }
  40. if (Session is HDomain Dom)
  41. {
  42. Obj = Dom.GetObject(Request.DomObjId);
  43. }
  44. return Obj is T ? (T)Obj : default(T);
  45. }
  46. }
  47. }