mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-09-12 02:38:50 +02:00
* Rename enum fields
* Naming conventions
* Remove unneeded ".this"
* Remove unneeded semicolons
* Remove unused Usings
* Don't use var
* Remove unneeded enum underlying types
* Explicitly label class visibility
* Remove unneeded @ prefixes
* Remove unneeded commas
* Remove unneeded if expressions
* Method doesn't use unsafe code
* Remove unneeded casts
* Initialized objects don't need an empty constructor
* Remove settings from DotSettings
* Revert "Explicitly label class visibility"
This reverts commit ad5eb5787c
.
* Small changes
* Revert external enum renaming
* Changes from feedback
* Remove unneeded property setters
42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.IO;
|
|
using System.Text;
|
|
|
|
namespace Ryujinx.HLE.Loaders.Npdm
|
|
{
|
|
class ServiceAccessControl
|
|
{
|
|
public IReadOnlyDictionary<string, bool> Services { get; }
|
|
|
|
public ServiceAccessControl(Stream stream, int offset, int size)
|
|
{
|
|
stream.Seek(offset, SeekOrigin.Begin);
|
|
|
|
BinaryReader reader = new BinaryReader(stream);
|
|
|
|
int byteReaded = 0;
|
|
|
|
Dictionary<string, bool> services = new Dictionary<string, bool>();
|
|
|
|
while (byteReaded != size)
|
|
{
|
|
byte controlByte = reader.ReadByte();
|
|
|
|
if (controlByte == 0)
|
|
{
|
|
break;
|
|
}
|
|
|
|
int length = (controlByte & 0x07) + 1;
|
|
bool registerAllowed = (controlByte & 0x80) != 0;
|
|
|
|
services.Add(Encoding.ASCII.GetString(reader.ReadBytes(length), 0, length), registerAllowed);
|
|
|
|
byteReaded += length + 1;
|
|
}
|
|
|
|
Services = new ReadOnlyDictionary<string, bool>(services);
|
|
}
|
|
}
|
|
}
|