ServiceSm.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using Ryujinx.Core.OsHle.Handles;
  2. using Ryujinx.Core.OsHle.Ipc;
  3. namespace Ryujinx.Core.OsHle.Services
  4. {
  5. static partial class Service
  6. {
  7. private const int SmNotInitialized = 0x415;
  8. public static long SmInitialize(ServiceCtx Context)
  9. {
  10. Context.Session.Initialize();
  11. return 0;
  12. }
  13. public static long SmGetService(ServiceCtx Context)
  14. {
  15. //Only for kernel version > 3.0.0.
  16. if (!Context.Session.IsInitialized)
  17. {
  18. //return SmNotInitialized;
  19. }
  20. string Name = string.Empty;
  21. for (int Index = 0; Index < 8 &&
  22. Context.RequestData.BaseStream.Position <
  23. Context.RequestData.BaseStream.Length; Index++)
  24. {
  25. byte Chr = Context.RequestData.ReadByte();
  26. if (Chr >= 0x20 && Chr < 0x7f)
  27. {
  28. Name += (char)Chr;
  29. }
  30. }
  31. HSession Session = new HSession(Name);
  32. int Handle = Context.Ns.Os.Handles.GenerateId(Session);
  33. Context.Response.HandleDesc = IpcHandleDesc.MakeMove(Handle);
  34. return 0;
  35. }
  36. }
  37. }