ServiceAccessControl.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Text;
  5. namespace Ryujinx.HLE.Loaders.Npdm
  6. {
  7. public class ServiceAccessControl
  8. {
  9. public List<(string, bool)> Services = new List<(string, bool)>();
  10. public ServiceAccessControl(Stream ServiceAccessControlStream, int Offset, int Size)
  11. {
  12. ServiceAccessControlStream.Seek(Offset, SeekOrigin.Begin);
  13. BinaryReader Reader = new BinaryReader(ServiceAccessControlStream);
  14. int ByteReaded = 0;
  15. while (ByteReaded != Size)
  16. {
  17. byte ControlByte = Reader.ReadByte();
  18. if (ControlByte == 0x00) break;
  19. int Length = ((ControlByte & 0x07)) + 1;
  20. bool RegisterAllowed = ((ControlByte & 0x80) != 0);
  21. Services.Add((Encoding.ASCII.GetString(Reader.ReadBytes(Length), 0, Length), RegisterAllowed));
  22. ByteReaded += Length + 1;
  23. }
  24. }
  25. }
  26. }