
* dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Restore a few unused methods and variables * Silence dotnet format IDE0060 warnings * Silence dotnet format IDE0052 warnings * Address or silence dotnet format IDE1006 warnings * Address dotnet format CA1816 warnings * Address or silence dotnet format CA2208 warnings * Address or silence dotnet format CA1806 and a few CA1854 warnings * Address dotnet format CA2211 warnings * Address dotnet format CA1822 warnings * Address or silence dotnet format CA1069 warnings * Make dotnet format succeed in style mode * Address or silence dotnet format CA2211 warnings * Address review comments * Address dotnet format CA2208 warnings properly * Make ProcessResult readonly * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Add previously silenced warnings back I have no clue how these disappeared * Revert formatting changes for while and for-loops * Format if-blocks correctly * Run dotnet format style after rebase * Run dotnet format whitespace after rebase * Run dotnet format style after rebase * Run dotnet format analyzers after rebase * Run dotnet format after rebase and remove unused usings - analyzers - style - whitespace * Disable 'prefer switch expression' rule * Add comments to disabled warnings * Fix a few disabled warnings * Fix naming rule violation, Convert shader properties to auto-property and convert values to const * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Start working on disabled warnings * Fix and silence a few dotnet-format warnings again * Run dotnet format after rebase * Use using declaration instead of block syntax * Address IDE0251 warnings * Address a few disabled IDE0060 warnings * Silence IDE0060 in .editorconfig * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * First dotnet format pass * Fix naming rule violations * Fix typo * Add trailing commas, use targeted new and use array initializer * Fix build issues * Fix remaining build issues * Remove SuppressMessage for CA1069 where possible * Address dotnet format issues * Address formatting issues Co-authored-by: Ac_K <acoustik666@gmail.com> * Add GetHashCode implementation for RenderingSurfaceInfo * Explicitly silence CA1822 for every affected method in Syscall * Address formatting issues in Demangler.cs * Address review feedback Co-authored-by: Ac_K <acoustik666@gmail.com> * Revert marking service methods as static * Next dotnet format pass * Address review feedback --------- Co-authored-by: Ac_K <acoustik666@gmail.com>
134 lines
6.0 KiB
C#
134 lines
6.0 KiB
C#
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Text;
|
|
|
|
namespace Ryujinx.HLE.HOS.Applets.Browser
|
|
{
|
|
class BrowserArgument
|
|
{
|
|
public WebArgTLVType Type { get; }
|
|
public byte[] Value { get; }
|
|
|
|
public BrowserArgument(WebArgTLVType type, byte[] value)
|
|
{
|
|
Type = type;
|
|
Value = value;
|
|
}
|
|
|
|
private static readonly Dictionary<WebArgTLVType, Type> _typeRegistry = new()
|
|
{
|
|
{ WebArgTLVType.InitialURL, typeof(string) },
|
|
{ WebArgTLVType.CallbackUrl, typeof(string) },
|
|
{ WebArgTLVType.CallbackableUrl, typeof(string) },
|
|
{ WebArgTLVType.ApplicationId, typeof(ulong) },
|
|
{ WebArgTLVType.DocumentPath, typeof(string) },
|
|
{ WebArgTLVType.DocumentKind, typeof(DocumentKind) },
|
|
{ WebArgTLVType.SystemDataId, typeof(ulong) },
|
|
{ WebArgTLVType.Whitelist, typeof(string) },
|
|
{ WebArgTLVType.NewsFlag, typeof(bool) },
|
|
{ WebArgTLVType.UserID, typeof(UserId) },
|
|
{ WebArgTLVType.ScreenShotEnabled, typeof(bool) },
|
|
{ WebArgTLVType.EcClientCertEnabled, typeof(bool) },
|
|
{ WebArgTLVType.UnknownFlag0x14, typeof(bool) },
|
|
{ WebArgTLVType.UnknownFlag0x15, typeof(bool) },
|
|
{ WebArgTLVType.PlayReportEnabled, typeof(bool) },
|
|
{ WebArgTLVType.BootDisplayKind, typeof(BootDisplayKind) },
|
|
{ WebArgTLVType.FooterEnabled, typeof(bool) },
|
|
{ WebArgTLVType.PointerEnabled, typeof(bool) },
|
|
{ WebArgTLVType.LeftStickMode, typeof(LeftStickMode) },
|
|
{ WebArgTLVType.KeyRepeatFrame1, typeof(int) },
|
|
{ WebArgTLVType.KeyRepeatFrame2, typeof(int) },
|
|
{ WebArgTLVType.BootAsMediaPlayerInverted, typeof(bool) },
|
|
{ WebArgTLVType.DisplayUrlKind, typeof(bool) },
|
|
{ WebArgTLVType.BootAsMediaPlayer, typeof(bool) },
|
|
{ WebArgTLVType.ShopJumpEnabled, typeof(bool) },
|
|
{ WebArgTLVType.MediaAutoPlayEnabled, typeof(bool) },
|
|
{ WebArgTLVType.LobbyParameter, typeof(string) },
|
|
{ WebArgTLVType.JsExtensionEnabled, typeof(bool) },
|
|
{ WebArgTLVType.AdditionalCommentText, typeof(string) },
|
|
{ WebArgTLVType.TouchEnabledOnContents, typeof(bool) },
|
|
{ WebArgTLVType.UserAgentAdditionalString, typeof(string) },
|
|
{ WebArgTLVType.MediaPlayerAutoCloseEnabled, typeof(bool) },
|
|
{ WebArgTLVType.PageCacheEnabled, typeof(bool) },
|
|
{ WebArgTLVType.WebAudioEnabled, typeof(bool) },
|
|
{ WebArgTLVType.PageFadeEnabled, typeof(bool) },
|
|
{ WebArgTLVType.BootLoadingIconEnabled, typeof(bool) },
|
|
{ WebArgTLVType.PageScrollIndicatorEnabled, typeof(bool) },
|
|
{ WebArgTLVType.MediaPlayerSpeedControlEnabled, typeof(bool) },
|
|
{ WebArgTLVType.OverrideWebAudioVolume, typeof(float) },
|
|
{ WebArgTLVType.OverrideMediaAudioVolume, typeof(float) },
|
|
{ WebArgTLVType.MediaPlayerUiEnabled, typeof(bool) },
|
|
};
|
|
|
|
public static (ShimKind, List<BrowserArgument>) ParseArguments(ReadOnlySpan<byte> data)
|
|
{
|
|
List<BrowserArgument> browserArguments = new();
|
|
|
|
WebArgHeader header = IApplet.ReadStruct<WebArgHeader>(data[..8]);
|
|
|
|
ReadOnlySpan<byte> rawTLVs = data[8..];
|
|
|
|
for (int i = 0; i < header.Count; i++)
|
|
{
|
|
WebArgTLV tlv = IApplet.ReadStruct<WebArgTLV>(rawTLVs);
|
|
ReadOnlySpan<byte> tlvData = rawTLVs.Slice(Unsafe.SizeOf<WebArgTLV>(), tlv.Size);
|
|
|
|
browserArguments.Add(new BrowserArgument((WebArgTLVType)tlv.Type, tlvData.ToArray()));
|
|
|
|
rawTLVs = rawTLVs[(Unsafe.SizeOf<WebArgTLV>() + tlv.Size)..];
|
|
}
|
|
|
|
return (header.ShimKind, browserArguments);
|
|
}
|
|
|
|
public object GetValue()
|
|
{
|
|
if (_typeRegistry.TryGetValue(Type, out Type valueType))
|
|
{
|
|
if (valueType == typeof(string))
|
|
{
|
|
return Encoding.UTF8.GetString(Value);
|
|
}
|
|
else if (valueType == typeof(bool))
|
|
{
|
|
return Value[0] == 1;
|
|
}
|
|
else if (valueType == typeof(uint))
|
|
{
|
|
return BitConverter.ToUInt32(Value);
|
|
}
|
|
else if (valueType == typeof(int))
|
|
{
|
|
return BitConverter.ToInt32(Value);
|
|
}
|
|
else if (valueType == typeof(ulong))
|
|
{
|
|
return BitConverter.ToUInt64(Value);
|
|
}
|
|
else if (valueType == typeof(long))
|
|
{
|
|
return BitConverter.ToInt64(Value);
|
|
}
|
|
else if (valueType == typeof(float))
|
|
{
|
|
return BitConverter.ToSingle(Value);
|
|
}
|
|
else if (valueType == typeof(UserId))
|
|
{
|
|
return new UserId(Value);
|
|
}
|
|
else if (valueType.IsEnum)
|
|
{
|
|
return Enum.ToObject(valueType, BitConverter.ToInt32(Value));
|
|
}
|
|
|
|
return $"{valueType.Name} parsing not implemented";
|
|
}
|
|
|
|
return $"Unknown value format (raw length: {Value.Length})";
|
|
}
|
|
}
|
|
}
|