diff options
Diffstat (limited to 'Ryujinx.HLE/Utilities')
| -rw-r--r-- | Ryujinx.HLE/Utilities/EndianSwap.cs | 14 | ||||
| -rw-r--r-- | Ryujinx.HLE/Utilities/FontUtils.cs | 18 | ||||
| -rw-r--r-- | Ryujinx.HLE/Utilities/IntUtils.cs | 16 | ||||
| -rw-r--r-- | Ryujinx.HLE/Utilities/LinuxError.cs | 5 | ||||
| -rw-r--r-- | Ryujinx.HLE/Utilities/StringUtils.cs | 52 | ||||
| -rw-r--r-- | Ryujinx.HLE/Utilities/StructReader.cs | 28 | ||||
| -rw-r--r-- | Ryujinx.HLE/Utilities/StructWriter.cs | 12 | ||||
| -rw-r--r-- | Ryujinx.HLE/Utilities/UInt128.cs | 26 | ||||
| -rw-r--r-- | Ryujinx.HLE/Utilities/WSAError.cs | 83 |
9 files changed, 130 insertions, 124 deletions
diff --git a/Ryujinx.HLE/Utilities/EndianSwap.cs b/Ryujinx.HLE/Utilities/EndianSwap.cs index 5d0c8a84..df08191a 100644 --- a/Ryujinx.HLE/Utilities/EndianSwap.cs +++ b/Ryujinx.HLE/Utilities/EndianSwap.cs @@ -2,16 +2,16 @@ { static class EndianSwap { - public static ushort Swap16(ushort Value) => (ushort)(((Value >> 8) & 0xff) | (Value << 8)); + public static ushort Swap16(ushort value) => (ushort)(((value >> 8) & 0xff) | (value << 8)); - public static int Swap32(int Value) + public static int Swap32(int value) { - uint UintVal = (uint)Value; + uint uintVal = (uint)value; - return (int)(((UintVal >> 24) & 0x000000ff) | - ((UintVal >> 8) & 0x0000ff00) | - ((UintVal << 8) & 0x00ff0000) | - ((UintVal << 24) & 0xff000000)); + return (int)(((uintVal >> 24) & 0x000000ff) | + ((uintVal >> 8) & 0x0000ff00) | + ((uintVal << 8) & 0x00ff0000) | + ((uintVal << 24) & 0xff000000)); } } } diff --git a/Ryujinx.HLE/Utilities/FontUtils.cs b/Ryujinx.HLE/Utilities/FontUtils.cs index efe7560c..3da0ef68 100644 --- a/Ryujinx.HLE/Utilities/FontUtils.cs +++ b/Ryujinx.HLE/Utilities/FontUtils.cs @@ -6,29 +6,29 @@ namespace Ryujinx.HLE.Utilities { private static readonly uint FontKey = 0x06186249; - public static byte[] DecryptFont(Stream BFTTFStream) + public static byte[] DecryptFont(Stream bfttfStream) { uint KXor(uint In) => In ^ 0x06186249; - using (BinaryReader Reader = new BinaryReader(BFTTFStream)) + using (BinaryReader reader = new BinaryReader(bfttfStream)) { - using (MemoryStream TTFStream = new MemoryStream()) + using (MemoryStream ttfStream = new MemoryStream()) { - using (BinaryWriter Output = new BinaryWriter(TTFStream)) + using (BinaryWriter output = new BinaryWriter(ttfStream)) { - if (KXor(Reader.ReadUInt32()) != 0x18029a7f) + if (KXor(reader.ReadUInt32()) != 0x18029a7f) { throw new InvalidDataException("Error: Input file is not in BFTTF format!"); } - BFTTFStream.Position += 4; + bfttfStream.Position += 4; - for (int i = 0; i < (BFTTFStream.Length - 8) / 4; i++) + for (int i = 0; i < (bfttfStream.Length - 8) / 4; i++) { - Output.Write(KXor(Reader.ReadUInt32())); + output.Write(KXor(reader.ReadUInt32())); } - return TTFStream.ToArray(); + return ttfStream.ToArray(); } } } diff --git a/Ryujinx.HLE/Utilities/IntUtils.cs b/Ryujinx.HLE/Utilities/IntUtils.cs index 57e9d396..a7178d80 100644 --- a/Ryujinx.HLE/Utilities/IntUtils.cs +++ b/Ryujinx.HLE/Utilities/IntUtils.cs @@ -2,24 +2,24 @@ namespace Ryujinx.HLE.Utilities { static class IntUtils { - public static int AlignUp(int Value, int Size) + public static int AlignUp(int value, int size) { - return (Value + (Size - 1)) & ~(Size - 1); + return (value + (size - 1)) & ~(size - 1); } - public static long AlignUp(long Value, int Size) + public static long AlignUp(long value, int size) { - return (Value + (Size - 1)) & ~((long)Size - 1); + return (value + (size - 1)) & ~((long)size - 1); } - public static int AlignDown(int Value, int Size) + public static int AlignDown(int value, int size) { - return Value & ~(Size - 1); + return value & ~(size - 1); } - public static long AlignDown(long Value, int Size) + public static long AlignDown(long value, int size) { - return Value & ~((long)Size - 1); + return value & ~((long)size - 1); } } } diff --git a/Ryujinx.HLE/Utilities/LinuxError.cs b/Ryujinx.HLE/Utilities/LinuxError.cs index 5c322f83..81a9d7be 100644 --- a/Ryujinx.HLE/Utilities/LinuxError.cs +++ b/Ryujinx.HLE/Utilities/LinuxError.cs @@ -1,5 +1,8 @@ +using System.Diagnostics.CodeAnalysis; + namespace Ryujinx.HLE.Utilities { + [SuppressMessage("ReSharper", "InconsistentNaming")] enum LinuxError { SUCCESS = 0, @@ -147,6 +150,6 @@ namespace Ryujinx.HLE.Utilities ERFKILL = 132 /* Operation not possible due to RF-kill */, - EHWPOISON = 133 /* Memory page has hardware error */, + EHWPOISON = 133 /* Memory page has hardware error */ } }
\ No newline at end of file diff --git a/Ryujinx.HLE/Utilities/StringUtils.cs b/Ryujinx.HLE/Utilities/StringUtils.cs index a10273ee..e6602f48 100644 --- a/Ryujinx.HLE/Utilities/StringUtils.cs +++ b/Ryujinx.HLE/Utilities/StringUtils.cs @@ -9,67 +9,67 @@ namespace Ryujinx.HLE.Utilities { static class StringUtils { - public static byte[] GetFixedLengthBytes(string InputString, int Size, Encoding Encoding) + public static byte[] GetFixedLengthBytes(string inputString, int size, Encoding encoding) { - InputString = InputString + "\0"; + inputString = inputString + "\0"; - int BytesCount = Encoding.GetByteCount(InputString); + int bytesCount = encoding.GetByteCount(inputString); - byte[] Output = new byte[Size]; + byte[] output = new byte[size]; - if (BytesCount < Size) + if (bytesCount < size) { - Encoding.GetBytes(InputString, 0, InputString.Length, Output, 0); + encoding.GetBytes(inputString, 0, inputString.Length, output, 0); } else { - int NullSize = Encoding.GetByteCount("\0"); + int nullSize = encoding.GetByteCount("\0"); - Output = Encoding.GetBytes(InputString); + output = encoding.GetBytes(inputString); - Array.Resize(ref Output, Size - NullSize); + Array.Resize(ref output, size - nullSize); - Output = Output.Concat(Encoding.GetBytes("\0")).ToArray(); + output = output.Concat(encoding.GetBytes("\0")).ToArray(); } - return Output; + return output; } - public static byte[] HexToBytes(string HexString) + public static byte[] HexToBytes(string hexString) { //Ignore last charactor if HexLength % 2 != 0. - int BytesInHex = HexString.Length / 2; + int bytesInHex = hexString.Length / 2; - byte[] Output = new byte[BytesInHex]; + byte[] output = new byte[bytesInHex]; - for (int Index = 0; Index < BytesInHex; Index++) + for (int index = 0; index < bytesInHex; index++) { - Output[Index] = byte.Parse(HexString.Substring(Index * 2, 2), NumberStyles.HexNumber); + output[index] = byte.Parse(hexString.Substring(index * 2, 2), NumberStyles.HexNumber); } - return Output; + return output; } - public static string ReadUtf8String(ServiceCtx Context, int Index = 0) + public static string ReadUtf8String(ServiceCtx context, int index = 0) { - long Position = Context.Request.PtrBuff[Index].Position; - long Size = Context.Request.PtrBuff[Index].Size; + long position = context.Request.PtrBuff[index].Position; + long size = context.Request.PtrBuff[index].Size; - using (MemoryStream MS = new MemoryStream()) + using (MemoryStream ms = new MemoryStream()) { - while (Size-- > 0) + while (size-- > 0) { - byte Value = Context.Memory.ReadByte(Position++); + byte value = context.Memory.ReadByte(position++); - if (Value == 0) + if (value == 0) { break; } - MS.WriteByte(Value); + ms.WriteByte(value); } - return Encoding.UTF8.GetString(MS.ToArray()); + return Encoding.UTF8.GetString(ms.ToArray()); } } } diff --git a/Ryujinx.HLE/Utilities/StructReader.cs b/Ryujinx.HLE/Utilities/StructReader.cs index 19fd2674..441dfd19 100644 --- a/Ryujinx.HLE/Utilities/StructReader.cs +++ b/Ryujinx.HLE/Utilities/StructReader.cs @@ -5,41 +5,41 @@ namespace Ryujinx.HLE.Utilities { class StructReader { - private MemoryManager Memory; + private MemoryManager _memory; public long Position { get; private set; } - public StructReader(MemoryManager Memory, long Position) + public StructReader(MemoryManager memory, long position) { - this.Memory = Memory; - this.Position = Position; + _memory = memory; + Position = position; } public T Read<T>() where T : struct { - T Value = MemoryHelper.Read<T>(Memory, Position); + T value = MemoryHelper.Read<T>(_memory, Position); Position += Marshal.SizeOf<T>(); - return Value; + return value; } - public T[] Read<T>(int Size) where T : struct + public T[] Read<T>(int size) where T : struct { - int StructSize = Marshal.SizeOf<T>(); + int structSize = Marshal.SizeOf<T>(); - int Count = Size / StructSize; + int count = size / structSize; - T[] Output = new T[Count]; + T[] output = new T[count]; - for (int Index = 0; Index < Count; Index++) + for (int index = 0; index < count; index++) { - Output[Index] = MemoryHelper.Read<T>(Memory, Position); + output[index] = MemoryHelper.Read<T>(_memory, Position); - Position += StructSize; + Position += structSize; } - return Output; + return output; } } } diff --git a/Ryujinx.HLE/Utilities/StructWriter.cs b/Ryujinx.HLE/Utilities/StructWriter.cs index a537e7a4..86cfeedd 100644 --- a/Ryujinx.HLE/Utilities/StructWriter.cs +++ b/Ryujinx.HLE/Utilities/StructWriter.cs @@ -5,19 +5,19 @@ namespace Ryujinx.HLE.Utilities { class StructWriter { - private MemoryManager Memory; + private MemoryManager _memory; public long Position { get; private set; } - public StructWriter(MemoryManager Memory, long Position) + public StructWriter(MemoryManager memory, long position) { - this.Memory = Memory; - this.Position = Position; + _memory = memory; + Position = position; } - public void Write<T>(T Value) where T : struct + public void Write<T>(T value) where T : struct { - MemoryHelper.Write(Memory, Position, Value); + MemoryHelper.Write(_memory, Position, value); Position += Marshal.SizeOf<T>(); } diff --git a/Ryujinx.HLE/Utilities/UInt128.cs b/Ryujinx.HLE/Utilities/UInt128.cs index 14e04e4a..9e685c18 100644 --- a/Ryujinx.HLE/Utilities/UInt128.cs +++ b/Ryujinx.HLE/Utilities/UInt128.cs @@ -6,30 +6,30 @@ namespace Ryujinx.HLE.Utilities { public struct UInt128 { - public long High { get; private set; } - public long Low { get; private set; } + public long High { get; } + public long Low { get; } - public UInt128(long Low, long High) + public UInt128(long low, long high) { - this.Low = Low; - this.High = High; + Low = low; + High = high; } - public UInt128(string UInt128Hex) + public UInt128(string hex) { - if (UInt128Hex == null || UInt128Hex.Length != 32 || !UInt128Hex.All("0123456789abcdefABCDEF".Contains)) + if (hex == null || hex.Length != 32 || !hex.All("0123456789abcdefABCDEF".Contains)) { - throw new ArgumentException("Invalid Hex value!", nameof(UInt128Hex)); + throw new ArgumentException("Invalid Hex value!", nameof(hex)); } - Low = Convert.ToInt64(UInt128Hex.Substring(16), 16); - High = Convert.ToInt64(UInt128Hex.Substring(0, 16), 16); + Low = Convert.ToInt64(hex.Substring(16), 16); + High = Convert.ToInt64(hex.Substring(0, 16), 16); } - public void Write(BinaryWriter BinaryWriter) + public void Write(BinaryWriter binaryWriter) { - BinaryWriter.Write(Low); - BinaryWriter.Write(High); + binaryWriter.Write(Low); + binaryWriter.Write(High); } public override string ToString() diff --git a/Ryujinx.HLE/Utilities/WSAError.cs b/Ryujinx.HLE/Utilities/WSAError.cs index ff0896d4..81294b8b 100644 --- a/Ryujinx.HLE/Utilities/WSAError.cs +++ b/Ryujinx.HLE/Utilities/WSAError.cs @@ -1,6 +1,9 @@ -namespace Ryujinx.HLE.Utilities +using System.Diagnostics.CodeAnalysis; + +namespace Ryujinx.HLE.Utilities { - enum WSAError + [SuppressMessage("ReSharper", "InconsistentNaming")] + enum WsaError { /* * All Windows Sockets error constants are biased by WSABASEERR from @@ -21,43 +24,43 @@ /* * Windows Sockets definitions of regular Berkeley error constants */ - WSAEWOULDBLOCK = (WSABASEERR + 35), - WSAEINPROGRESS = (WSABASEERR + 36), - WSAEALREADY = (WSABASEERR + 37), - WSAENOTSOCK = (WSABASEERR + 38), - WSAEDESTADDRREQ = (WSABASEERR + 39), - WSAEMSGSIZE = (WSABASEERR + 40), - WSAEPROTOTYPE = (WSABASEERR + 41), - WSAENOPROTOOPT = (WSABASEERR + 42), - WSAEPROTONOSUPPORT = (WSABASEERR + 43), - WSAESOCKTNOSUPPORT = (WSABASEERR + 44), - WSAEOPNOTSUPP = (WSABASEERR + 45), - WSAEPFNOSUPPORT = (WSABASEERR + 46), - WSAEAFNOSUPPORT = (WSABASEERR + 47), - WSAEADDRINUSE = (WSABASEERR + 48), - WSAEADDRNOTAVAIL = (WSABASEERR + 49), - WSAENETDOWN = (WSABASEERR + 50), - WSAENETUNREACH = (WSABASEERR + 51), - WSAENETRESET = (WSABASEERR + 52), - WSAECONNABORTED = (WSABASEERR + 53), - WSAECONNRESET = (WSABASEERR + 54), - WSAENOBUFS = (WSABASEERR + 55), - WSAEISCONN = (WSABASEERR + 56), - WSAENOTCONN = (WSABASEERR + 57), - WSAESHUTDOWN = (WSABASEERR + 58), - WSAETOOMANYREFS = (WSABASEERR + 59), - WSAETIMEDOUT = (WSABASEERR + 60), - WSAECONNREFUSED = (WSABASEERR + 61), - WSAELOOP = (WSABASEERR + 62), - WSAENAMETOOLONG = (WSABASEERR + 63), - WSAEHOSTDOWN = (WSABASEERR + 64), - WSAEHOSTUNREACH = (WSABASEERR + 65), - WSAENOTEMPTY = (WSABASEERR + 66), - WSAEPROCLIM = (WSABASEERR + 67), - WSAEUSERS = (WSABASEERR + 68), - WSAEDQUOT = (WSABASEERR + 69), - WSAESTALE = (WSABASEERR + 70), - WSAEREMOTE = (WSABASEERR + 71), + WSAEWOULDBLOCK = (WSABASEERR + 35), + WSAEINPROGRESS = (WSABASEERR + 36), + WSAEALREADY = (WSABASEERR + 37), + WSAENOTSOCK = (WSABASEERR + 38), + WSAEDESTADDRREQ = (WSABASEERR + 39), + WSAEMSGSIZE = (WSABASEERR + 40), + WSAEPROTOTYPE = (WSABASEERR + 41), + WSAENOPROTOOPT = (WSABASEERR + 42), + WSAEPROTONOSUPPORT = (WSABASEERR + 43), + WSAESOCKTNOSUPPORT = (WSABASEERR + 44), + WSAEOPNOTSUPP = (WSABASEERR + 45), + WSAEPFNOSUPPORT = (WSABASEERR + 46), + WSAEAFNOSUPPORT = (WSABASEERR + 47), + WSAEADDRINUSE = (WSABASEERR + 48), + WSAEADDRNOTAVAIL = (WSABASEERR + 49), + WSAENETDOWN = (WSABASEERR + 50), + WSAENETUNREACH = (WSABASEERR + 51), + WSAENETRESET = (WSABASEERR + 52), + WSAECONNABORTED = (WSABASEERR + 53), + WSAECONNRESET = (WSABASEERR + 54), + WSAENOBUFS = (WSABASEERR + 55), + WSAEISCONN = (WSABASEERR + 56), + WSAENOTCONN = (WSABASEERR + 57), + WSAESHUTDOWN = (WSABASEERR + 58), + WSAETOOMANYREFS = (WSABASEERR + 59), + WSAETIMEDOUT = (WSABASEERR + 60), + WSAECONNREFUSED = (WSABASEERR + 61), + WSAELOOP = (WSABASEERR + 62), + WSAENAMETOOLONG = (WSABASEERR + 63), + WSAEHOSTDOWN = (WSABASEERR + 64), + WSAEHOSTUNREACH = (WSABASEERR + 65), + WSAENOTEMPTY = (WSABASEERR + 66), + WSAEPROCLIM = (WSABASEERR + 67), + WSAEUSERS = (WSABASEERR + 68), + WSAEDQUOT = (WSABASEERR + 69), + WSAESTALE = (WSABASEERR + 70), + WSAEREMOTE = (WSABASEERR + 71), /* * Extended Windows Sockets error constant definitions @@ -126,6 +129,6 @@ * buffer in general */ WSA_QOS_TRAFFIC_CTRL_ERROR = (WSABASEERR + 1014), /* problem with some part of the flowspec */ - WSA_QOS_GENERIC_ERROR = (WSABASEERR + 1015), + WSA_QOS_GENERIC_ERROR = (WSABASEERR + 1015) } } |
