diff options
author | TSR Berry <20988865+TSRBerry@users.noreply.github.com> | 2023-04-08 01:22:00 +0200 |
---|---|---|
committer | Mary <thog@protonmail.com> | 2023-04-27 23:51:14 +0200 |
commit | cee712105850ac3385cd0091a923438167433f9f (patch) | |
tree | 4a5274b21d8b7f938c0d0ce18736d3f2993b11b1 /src/Ryujinx.HLE/Loaders/Npdm/ServiceAccessControl.cs | |
parent | cd124bda587ef09668a971fa1cac1c3f0cfc9f21 (diff) |
Move solution and projects to src
Diffstat (limited to 'src/Ryujinx.HLE/Loaders/Npdm/ServiceAccessControl.cs')
-rw-r--r-- | src/Ryujinx.HLE/Loaders/Npdm/ServiceAccessControl.cs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/Ryujinx.HLE/Loaders/Npdm/ServiceAccessControl.cs b/src/Ryujinx.HLE/Loaders/Npdm/ServiceAccessControl.cs new file mode 100644 index 00000000..54012b8a --- /dev/null +++ b/src/Ryujinx.HLE/Loaders/Npdm/ServiceAccessControl.cs @@ -0,0 +1,42 @@ +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Text; + +namespace Ryujinx.HLE.Loaders.Npdm +{ + public class ServiceAccessControl + { + public IReadOnlyDictionary<string, bool> Services { get; private set; } + + public ServiceAccessControl(Stream stream, int offset, int size) + { + stream.Seek(offset, SeekOrigin.Begin); + + BinaryReader reader = new BinaryReader(stream); + + int bytesRead = 0; + + Dictionary<string, bool> services = new Dictionary<string, bool>(); + + while (bytesRead != size) + { + byte controlByte = reader.ReadByte(); + + if (controlByte == 0) + { + break; + } + + int length = (controlByte & 0x07) + 1; + bool registerAllowed = (controlByte & 0x80) != 0; + + services[Encoding.ASCII.GetString(reader.ReadBytes(length))] = registerAllowed; + + bytesRead += length + 1; + } + + Services = new ReadOnlyDictionary<string, bool>(services); + } + } +} |