AmIApplicationFunctions.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System.IO;
  2. using static Ryujinx.OsHle.Objects.ObjHelper;
  3. namespace Ryujinx.OsHle.Objects
  4. {
  5. class AmIApplicationFunctions
  6. {
  7. private const uint LaunchParamsMagic = 0xc79497ca;
  8. public static long PopLaunchParameter(ServiceCtx Context)
  9. {
  10. //Only the first 0x18 bytes of the Data seems to be actually used.
  11. MakeObject(Context, new AmIStorage(MakeLaunchParams()));
  12. return 0;
  13. }
  14. public static long EnsureSaveData(ServiceCtx Context)
  15. {
  16. long UIdLow = Context.RequestData.ReadInt64();
  17. long UIdHigh = Context.RequestData.ReadInt64();
  18. Context.ResponseData.Write(0L);
  19. return 0;
  20. }
  21. public static long GetDesiredLanguage(ServiceCtx Context)
  22. {
  23. //This is an enumerator where each number is a differnet language.
  24. //0 is Japanese and 1 is English, need to figure out the other codes.
  25. Context.ResponseData.Write(1L);
  26. return 0;
  27. }
  28. public static long NotifyRunning(ServiceCtx Context)
  29. {
  30. Context.ResponseData.Write(1);
  31. return 0;
  32. }
  33. private static byte[] MakeLaunchParams()
  34. {
  35. //Size needs to be at least 0x88 bytes otherwise application errors.
  36. using (MemoryStream MS = new MemoryStream())
  37. {
  38. BinaryWriter Writer = new BinaryWriter(MS);
  39. MS.SetLength(0x88);
  40. Writer.Write(LaunchParamsMagic);
  41. Writer.Write(1); //IsAccountSelected? Only lower 8 bits actually used.
  42. Writer.Write(1L); //User Id Low (note: User Id needs to be != 0)
  43. Writer.Write(0L); //User Id High
  44. return MS.ToArray();
  45. }
  46. }
  47. }
  48. }