ServiceAccessControl.cs 1.0 KB

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