mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-06-01 18:09:15 +00:00
@@ -56,6 +56,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
||||
Logger.Warning?.Print(LogClass.Application, $"The command line specified profile named '{initialProfileName}' was not found");
|
||||
}
|
||||
}
|
||||
|
||||
OpenUser(commandLineUserProfileOverride.IsNull ? _accountSaveDataManager.LastOpened : commandLineUserProfileOverride);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Microsoft.IO;
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
||||
using System.IO;
|
||||
@@ -11,7 +12,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.Storage
|
||||
public static byte[] MakeLaunchParams(UserProfile userProfile)
|
||||
{
|
||||
// Size needs to be at least 0x88 bytes otherwise application errors.
|
||||
using MemoryStream ms = MemoryStreamManager.Shared.GetStream();
|
||||
using RecyclableMemoryStream ms = MemoryStreamManager.Shared.GetStream();
|
||||
BinaryWriter writer = new(ms);
|
||||
|
||||
ms.SetLength(0x88);
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace Ryujinx.HLE.HOS.Services.Caps
|
||||
};
|
||||
|
||||
// NOTE: The hex hash is a HMAC-SHA256 (first 32 bytes) using a hardcoded secret key over the titleId, we can simulate it by hashing the titleId instead.
|
||||
string hash = Convert.ToHexString(SHA256.HashData(BitConverter.GetBytes(titleId))).Remove(0x20);
|
||||
string hash = Convert.ToHexString(SHA256.HashData(BitConverter.GetBytes(titleId)))[..0x20];
|
||||
string folderPath = Path.Combine(_sdCardPath, "Nintendo", "Album", currentDateTime.Year.ToString("00"), currentDateTime.Month.ToString("00"), currentDateTime.Day.ToString("00"));
|
||||
string filePath = GenerateFilePath(folderPath, applicationAlbumEntry, currentDateTime, hash);
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Ryujinx.HLE.HOS.Services.Caps
|
||||
|
||||
MemoryHelper.FillWithZeros(context.Memory, applicationAlbumFileEntryPosition, (int)applicationAlbumFileEntrySize);
|
||||
|
||||
if (contentType > ContentType.Unknown || contentType == ContentType.ExtraMovie)
|
||||
if (contentType is > ContentType.Unknown or ContentType.ExtraMovie)
|
||||
{
|
||||
resultCode = ResultCode.InvalidContentType;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,6 @@ namespace Ryujinx.HLE.HOS.Services.Caps
|
||||
ulong screenshotDataPosition = context.Request.SendBuff[1].Position;
|
||||
ulong screenshotDataSize = context.Request.SendBuff[1].Size;
|
||||
|
||||
|
||||
// TODO: Parse the application data: At 0x00 it's UserData (Size of 0x400), at 0x404 it's a uint UserDataSize (Always empty for now).
|
||||
_ = context.Memory.GetSpan(applicationDataPosition, (int)applicationDataSize).ToArray();
|
||||
|
||||
@@ -89,7 +88,6 @@ namespace Ryujinx.HLE.HOS.Services.Caps
|
||||
ulong screenshotDataPosition = context.Request.SendBuff[1].Position;
|
||||
ulong screenshotDataSize = context.Request.SendBuff[1].Size;
|
||||
|
||||
|
||||
// TODO: Parse the UserIdList.
|
||||
_ = context.Memory.GetSpan(userIdListPosition, (int)userIdListSize).ToArray();
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
|
||||
using SharedRef<LibHac.FsSrv.Sf.IDirectory> dir = new();
|
||||
|
||||
Result result = _fileSystem.Get.OpenDirectory(ref dir.Ref, name, mode);
|
||||
Result result = _fileSystem.Get.OpenDirectory(ref dir.Ref, in name, mode);
|
||||
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
{
|
||||
_baseStorage = SharedRef<LibHac.FsSrv.Sf.IStorage>.CreateMove(ref baseStorage);
|
||||
}
|
||||
|
||||
|
||||
private const string Xc2JpTitleId = "0100f3400332c000";
|
||||
private const string Xc2GlobalTitleId = "0100e95004038000";
|
||||
private static bool IsXc2 => TitleIDs.CurrentApplication.Value.OrDefault() is Xc2GlobalTitleId or Xc2JpTitleId;
|
||||
@@ -41,7 +41,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
|
||||
using WritableRegion region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true);
|
||||
Result result = _baseStorage.Get.Read((long)offset, new OutBuffer(region.Memory.Span), (long)size);
|
||||
|
||||
|
||||
if (context.Device.DirtyHacks.IsEnabled(DirtyHack.Xc2MenuSoftlockFix) && IsXc2)
|
||||
{
|
||||
// Add a load-bearing sleep to avoid XC2 softlock
|
||||
|
||||
@@ -753,7 +753,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
|
||||
public ResultCode OpenCloudBackupWorkStorageFileSystem(ServiceCtx context)
|
||||
{
|
||||
CloudBackupWorkStorageId storageId = (CloudBackupWorkStorageId)context.RequestData.ReadInt32();
|
||||
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceFs, new { storageId });
|
||||
throw new NotImplementedException(); // reimplementing behavior from LibHac 0.19.0
|
||||
}
|
||||
@@ -1232,9 +1232,9 @@ namespace Ryujinx.HLE.HOS.Services.Fs
|
||||
{
|
||||
BisPartitionId partitionId = (BisPartitionId)context.RequestData.ReadInt32();
|
||||
ref readonly FspPath path = ref FileSystemProxyHelper.GetFspPath(context);
|
||||
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceFs, new { partitionId, path });
|
||||
|
||||
|
||||
throw new NotImplementedException(); // reimplementing behavior from LibHac 0.19.0
|
||||
}
|
||||
|
||||
|
||||
@@ -42,9 +42,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid.HidServer
|
||||
|
||||
public static bool IsValidNpadIdType(NpadIdType npadIdType)
|
||||
{
|
||||
return (npadIdType >= NpadIdType.Player1 && npadIdType <= NpadIdType.Player8) ||
|
||||
npadIdType == NpadIdType.Handheld ||
|
||||
npadIdType == NpadIdType.Unknown;
|
||||
return npadIdType is >= NpadIdType.Player1 and <= NpadIdType.Player8 or
|
||||
NpadIdType.Handheld or
|
||||
NpadIdType.Unknown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
|
||||
[CommandCmif(26)]
|
||||
// ActivateDebugMouse(nn::applet::AppletResourceUserId)
|
||||
public ResultCode ActivateDebugMouse(ServiceCtx context)
|
||||
@@ -702,7 +702,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
|
||||
[CommandCmif(92)]
|
||||
// SetGestureOutputRanges(pid, ushort Unknown0)
|
||||
public ResultCode SetGestureOutputRanges(ServiceCtx context)
|
||||
@@ -1161,59 +1161,54 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
||||
NpadStyleIndex deviceType = (NpadStyleIndex)deviceHandle.DeviceType;
|
||||
NpadIdType npadIdType = (NpadIdType)deviceHandle.PlayerId;
|
||||
|
||||
if (deviceType < NpadStyleIndex.System || deviceType >= NpadStyleIndex.FullKey)
|
||||
if (!HidUtils.IsValidNpadIdType(npadIdType))
|
||||
{
|
||||
if (!HidUtils.IsValidNpadIdType(npadIdType))
|
||||
{
|
||||
return ResultCode.InvalidNpadIdType;
|
||||
}
|
||||
|
||||
if (deviceHandle.Position > 1)
|
||||
{
|
||||
return ResultCode.InvalidDeviceIndex;
|
||||
}
|
||||
|
||||
VibrationDeviceType vibrationDeviceType = VibrationDeviceType.None;
|
||||
|
||||
if (Enum.IsDefined(deviceType))
|
||||
{
|
||||
vibrationDeviceType = VibrationDeviceType.LinearResonantActuator;
|
||||
}
|
||||
else if ((uint)deviceType == 8)
|
||||
{
|
||||
vibrationDeviceType = VibrationDeviceType.GcErm;
|
||||
}
|
||||
|
||||
VibrationDevicePosition vibrationDevicePosition = VibrationDevicePosition.None;
|
||||
|
||||
if (vibrationDeviceType == VibrationDeviceType.LinearResonantActuator)
|
||||
{
|
||||
if (deviceHandle.Position == 0)
|
||||
{
|
||||
vibrationDevicePosition = VibrationDevicePosition.Left;
|
||||
}
|
||||
else if (deviceHandle.Position == 1)
|
||||
{
|
||||
vibrationDevicePosition = VibrationDevicePosition.Right;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException($"{nameof(deviceHandle.Position)} contains an invalid value: {deviceHandle.Position}");
|
||||
}
|
||||
}
|
||||
|
||||
VibrationDeviceValue deviceInfo = new()
|
||||
{
|
||||
DeviceType = vibrationDeviceType,
|
||||
Position = vibrationDevicePosition,
|
||||
};
|
||||
|
||||
context.ResponseData.WriteStruct(deviceInfo);
|
||||
|
||||
return ResultCode.Success;
|
||||
return ResultCode.InvalidNpadIdType;
|
||||
}
|
||||
|
||||
return ResultCode.InvalidNpadDeviceType;
|
||||
if (deviceHandle.Position > 1)
|
||||
{
|
||||
return ResultCode.InvalidDeviceIndex;
|
||||
}
|
||||
|
||||
VibrationDeviceType vibrationDeviceType = VibrationDeviceType.None;
|
||||
|
||||
if (Enum.IsDefined(deviceType))
|
||||
{
|
||||
vibrationDeviceType = VibrationDeviceType.LinearResonantActuator;
|
||||
}
|
||||
else if ((uint)deviceType == 8)
|
||||
{
|
||||
vibrationDeviceType = VibrationDeviceType.GcErm;
|
||||
}
|
||||
|
||||
VibrationDevicePosition vibrationDevicePosition = VibrationDevicePosition.None;
|
||||
|
||||
if (vibrationDeviceType == VibrationDeviceType.LinearResonantActuator)
|
||||
{
|
||||
if (deviceHandle.Position == 0)
|
||||
{
|
||||
vibrationDevicePosition = VibrationDevicePosition.Left;
|
||||
}
|
||||
else if (deviceHandle.Position == 1)
|
||||
{
|
||||
vibrationDevicePosition = VibrationDevicePosition.Right;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException($"{nameof(deviceHandle.Position)} contains an invalid value: {deviceHandle.Position}");
|
||||
}
|
||||
}
|
||||
|
||||
VibrationDeviceValue deviceInfo = new()
|
||||
{
|
||||
DeviceType = vibrationDeviceType,
|
||||
Position = vibrationDevicePosition,
|
||||
};
|
||||
|
||||
context.ResponseData.WriteStruct(deviceInfo);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(201)]
|
||||
|
||||
@@ -10,9 +10,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
||||
|
||||
[CommandCmif(1)]
|
||||
// GetBusHandle(nn::hid::NpadIdType, nn::hidbus::BusType, nn::applet::AppletResourceUserId) -> (bool HasHandle, nn::hidbus::BusHandle)
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public ResultCode GetBusHandle(ServiceCtx context)
|
||||
#pragma warning restore CA1822
|
||||
{
|
||||
NpadIdType npadIdType = (NpadIdType)context.RequestData.ReadInt32();
|
||||
context.RequestData.BaseStream.Position += 4; // Padding
|
||||
|
||||
@@ -172,9 +172,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs
|
||||
{
|
||||
NpadIdType npadIdType = (NpadIdType)context.RequestData.ReadUInt32();
|
||||
|
||||
if (npadIdType > NpadIdType.Player8 &&
|
||||
npadIdType != NpadIdType.Unknown &&
|
||||
npadIdType != NpadIdType.Handheld)
|
||||
if (npadIdType is > NpadIdType.Player8 and
|
||||
not NpadIdType.Unknown and
|
||||
not NpadIdType.Handheld)
|
||||
{
|
||||
return ResultCode.NpadIdOutOfRange;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory
|
||||
/// </summary>
|
||||
[FieldOffset(0x9A00)]
|
||||
public Array10<NpadState> Npads;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Debug mouse.
|
||||
/// </summary>
|
||||
|
||||
@@ -26,17 +26,17 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
public IpcService(ServerBase server = null, bool registerTipc = false)
|
||||
{
|
||||
Stopwatch sw = Stopwatch.StartNew();
|
||||
|
||||
|
||||
CmifCommands = GetType()
|
||||
.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public)
|
||||
.SelectMany(methodInfo => methodInfo.GetCustomAttributes<CommandCmifAttribute>()
|
||||
.Select(command => (command.Id, methodInfo)))
|
||||
.ToDictionary(command => command.Id, command => command.methodInfo);
|
||||
|
||||
|
||||
sw.Stop();
|
||||
|
||||
|
||||
Logger.Debug?.Print(
|
||||
LogClass.Emulation,
|
||||
LogClass.Emulation,
|
||||
$"{CmifCommands.Count} Cmif commands loaded in {sw.ElapsedTicks} ticks ({Stopwatch.Frequency} tps).",
|
||||
GetType().AsPrettyString()
|
||||
);
|
||||
@@ -50,16 +50,16 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
.SelectMany(methodInfo => methodInfo.GetCustomAttributes<CommandTipcAttribute>()
|
||||
.Select(command => (command.Id, methodInfo)))
|
||||
.ToDictionary(command => command.Id, command => command.methodInfo);
|
||||
|
||||
|
||||
sw.Stop();
|
||||
|
||||
|
||||
Logger.Debug?.Print(
|
||||
LogClass.Emulation,
|
||||
LogClass.Emulation,
|
||||
$"{TipcCommands.Count} Tipc commands loaded in {sw.ElapsedTicks} ticks ({Stopwatch.Frequency} tps).",
|
||||
GetType().AsPrettyString()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Server = server;
|
||||
|
||||
_parent = this;
|
||||
@@ -202,7 +202,6 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
{
|
||||
string serviceName;
|
||||
|
||||
|
||||
serviceName = (this is not DummyService dummyService) ? GetType().FullName : dummyService.ServiceName;
|
||||
|
||||
Logger.Warning?.Print(LogClass.KernelIpc, $"Missing service {serviceName}: {commandId} ignored");
|
||||
|
||||
@@ -175,7 +175,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator
|
||||
|
||||
// NOTE: Return ResultCode.InvalidArgument if ip_address and subnet_mask are null, doesn't occur in our case.
|
||||
|
||||
if (_state == NetworkState.AccessPointCreated || _state == NetworkState.StationConnected)
|
||||
if (_state is NetworkState.AccessPointCreated or NetworkState.StationConnected)
|
||||
{
|
||||
ProxyConfig config = _state switch
|
||||
{
|
||||
@@ -522,7 +522,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator
|
||||
return _nifmResultCode;
|
||||
}
|
||||
|
||||
if (_state == NetworkState.AccessPoint || _state == NetworkState.AccessPointCreated)
|
||||
if (_state is NetworkState.AccessPoint or NetworkState.AccessPointCreated)
|
||||
{
|
||||
DestroyNetworkImpl(DisconnectReason.DestroyedByUser);
|
||||
}
|
||||
@@ -698,12 +698,12 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator
|
||||
return _nifmResultCode;
|
||||
}
|
||||
|
||||
if (bufferSize == 0 || bufferSize > LdnConst.AdvertiseDataSizeMax)
|
||||
if (bufferSize is 0 or > LdnConst.AdvertiseDataSizeMax)
|
||||
{
|
||||
return ResultCode.InvalidArgument;
|
||||
}
|
||||
|
||||
if (_state == NetworkState.AccessPoint || _state == NetworkState.AccessPointCreated)
|
||||
if (_state is NetworkState.AccessPoint or NetworkState.AccessPointCreated)
|
||||
{
|
||||
byte[] advertiseData = new byte[bufferSize];
|
||||
|
||||
@@ -733,7 +733,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator
|
||||
return ResultCode.InvalidArgument;
|
||||
}
|
||||
|
||||
if (_state == NetworkState.AccessPoint || _state == NetworkState.AccessPointCreated)
|
||||
if (_state is NetworkState.AccessPoint or NetworkState.AccessPointCreated)
|
||||
{
|
||||
return _accessPoint.SetStationAcceptPolicy(acceptPolicy);
|
||||
}
|
||||
@@ -807,7 +807,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator
|
||||
return _nifmResultCode;
|
||||
}
|
||||
|
||||
if (_state == NetworkState.Station || _state == NetworkState.StationConnected)
|
||||
if (_state is NetworkState.Station or NetworkState.StationConnected)
|
||||
{
|
||||
DisconnectImpl(DisconnectReason.DisconnectedByUser);
|
||||
}
|
||||
@@ -1089,13 +1089,14 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator
|
||||
case MultiplayerMode.LdnRyu:
|
||||
try
|
||||
{
|
||||
string ldnServer = context.Device.Configuration.MultiplayerLdnServer
|
||||
string ldnServer = context.Device.Configuration.MultiplayerLdnServer
|
||||
?? throw new InvalidOperationException("Cannot initialize RyuLDN with a null Multiplayer server.");
|
||||
|
||||
if (!IPAddress.TryParse(ldnServer, out IPAddress ipAddress))
|
||||
{
|
||||
ipAddress = Dns.GetHostEntry(ldnServer).AddressList[0];
|
||||
}
|
||||
|
||||
NetworkClient = new LdnMasterProxyClient(ipAddress.ToString(), SharedConstants.LanPlayPort, context.Device.Configuration);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -1104,6 +1105,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator
|
||||
Logger.Error?.Print(LogClass.ServiceLdn, ex.Message);
|
||||
NetworkClient = new LdnDisabledClient();
|
||||
}
|
||||
|
||||
break;
|
||||
case MultiplayerMode.LdnMitm:
|
||||
NetworkClient = new LdnMitmClient(context.Device.Configuration);
|
||||
|
||||
@@ -59,6 +59,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnMitm
|
||||
{
|
||||
Scan?.Invoke(endPoint, LanPacketType.ScanResponse, SpanHelpers.AsSpan<NetworkInfo, byte>(ref _discovery.NetworkInfo).ToArray());
|
||||
}
|
||||
|
||||
break;
|
||||
case LanPacketType.ScanResponse:
|
||||
// UDP
|
||||
|
||||
@@ -179,8 +179,6 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
|
||||
_error.Set();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void HandleInitialize(LdnHeader header, InitializeMessage initialize)
|
||||
{
|
||||
InitializeMemory = initialize;
|
||||
|
||||
@@ -47,6 +47,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
|
||||
{
|
||||
Logger.Error?.PrintMsg(LogClass.ServiceLdn, "Tcp proxy networking is untested. Please report this game so that it can be tested.");
|
||||
}
|
||||
|
||||
return domain == AddressFamily.InterNetwork && (protocol == ProtocolType.Tcp || protocol == ProtocolType.Udp);
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,6 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
|
||||
return _receiveQueue.Count > 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public bool Writable => Connected || ProtocolType == ProtocolType.Udp;
|
||||
@@ -256,6 +255,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
|
||||
{
|
||||
_proxy.ReturnEphemeralPort(ProtocolType, (ushort)((IPEndPoint)LocalEndPoint).Port);
|
||||
}
|
||||
|
||||
IPEndPoint asIPEndpoint = (IPEndPoint)localEP;
|
||||
if (asIPEndpoint.Port == 0)
|
||||
{
|
||||
|
||||
@@ -156,7 +156,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
|
||||
if (_publicPort != 0)
|
||||
{
|
||||
_ = Executor.ExecuteAfterDelayAsync(
|
||||
PortLeaseRenew.Seconds(),
|
||||
PortLeaseRenew.Seconds(),
|
||||
_disposedCancellation.Token,
|
||||
RefreshLease);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Loader
|
||||
{
|
||||
[SuppressMessage("Design", "CA1069: Enums values should not be duplicated")]
|
||||
enum ResultCode
|
||||
{
|
||||
ModuleId = 9,
|
||||
|
||||
@@ -124,7 +124,6 @@ namespace Ryujinx.HLE.HOS.Services.Mii
|
||||
}
|
||||
|
||||
if (_isTestModeEnabled)
|
||||
#pragma warning disable CS0162
|
||||
{
|
||||
result = _horizonClient.Fs.CreateSystemSaveData(saveDataId, 0x10000, 0x10000,
|
||||
SaveDataFlags.KeepAfterResettingSystemSaveDataWithoutUserSaveData);
|
||||
@@ -133,7 +132,6 @@ namespace Ryujinx.HLE.HOS.Services.Mii
|
||||
return result;
|
||||
}
|
||||
}
|
||||
#pragma warning restore CS0162
|
||||
else
|
||||
{
|
||||
result = _horizonClient.Fs.CreateSystemSaveData(saveDataId, SystemProgramId.Ns.Value, 0x10000,
|
||||
@@ -155,6 +153,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii
|
||||
{
|
||||
_mountCounter++;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,202 +76,252 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types
|
||||
{
|
||||
return 50;
|
||||
}
|
||||
|
||||
if (!Nickname.IsValid())
|
||||
{
|
||||
return 51;
|
||||
}
|
||||
|
||||
if ((byte)FontRegion > 3)
|
||||
{
|
||||
return 23;
|
||||
}
|
||||
|
||||
if (FavoriteColor > 11)
|
||||
{
|
||||
return 22;
|
||||
}
|
||||
|
||||
if (Gender > Gender.Max)
|
||||
{
|
||||
return 24;
|
||||
}
|
||||
|
||||
if ((sbyte)Height < 0)
|
||||
{
|
||||
return 32;
|
||||
}
|
||||
|
||||
if ((sbyte)Build < 0)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (Type > 1)
|
||||
{
|
||||
return 53;
|
||||
}
|
||||
|
||||
if (RegionMove > 3)
|
||||
{
|
||||
return 49;
|
||||
}
|
||||
|
||||
if (FacelineType > FacelineType.Max)
|
||||
{
|
||||
return 21;
|
||||
}
|
||||
|
||||
if (FacelineColor > FacelineColor.Max)
|
||||
{
|
||||
return 18;
|
||||
}
|
||||
|
||||
if (FacelineWrinkle > FacelineWrinkle.Max)
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
|
||||
if (FacelineMake > FacelineMake.Max)
|
||||
{
|
||||
return 19;
|
||||
}
|
||||
|
||||
if (HairType > HairType.Max)
|
||||
{
|
||||
return 31;
|
||||
}
|
||||
|
||||
if (HairColor > CommonColor.Max)
|
||||
{
|
||||
return 29;
|
||||
}
|
||||
|
||||
if (HairFlip > HairFlip.Max)
|
||||
{
|
||||
return 30;
|
||||
}
|
||||
|
||||
if (EyeType > EyeType.Max)
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
if (EyeColor > CommonColor.Max)
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
if (EyeScale > 7)
|
||||
{
|
||||
return 7;
|
||||
}
|
||||
|
||||
if (EyeAspect > 6)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
if (EyeRotate > 7)
|
||||
{
|
||||
return 6;
|
||||
}
|
||||
|
||||
if (EyeX > 12)
|
||||
{
|
||||
return 9;
|
||||
}
|
||||
|
||||
if (EyeY > 18)
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
if (EyebrowType > EyebrowType.Max)
|
||||
{
|
||||
return 15;
|
||||
}
|
||||
|
||||
if (EyebrowColor > CommonColor.Max)
|
||||
{
|
||||
return 12;
|
||||
}
|
||||
|
||||
if (EyebrowScale > 8)
|
||||
{
|
||||
return 14;
|
||||
}
|
||||
|
||||
if (EyebrowAspect > 6)
|
||||
{
|
||||
return 11;
|
||||
}
|
||||
|
||||
if (EyebrowRotate > 11)
|
||||
{
|
||||
return 13;
|
||||
}
|
||||
|
||||
if (EyebrowX > 12)
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
if (EyebrowY - 3 > 15)
|
||||
{
|
||||
return 17;
|
||||
}
|
||||
|
||||
if (NoseType > NoseType.Max)
|
||||
{
|
||||
return 47;
|
||||
}
|
||||
|
||||
if (NoseScale > 8)
|
||||
{
|
||||
return 46;
|
||||
}
|
||||
|
||||
if (NoseY > 18)
|
||||
{
|
||||
return 48;
|
||||
}
|
||||
|
||||
if (MouthType > MouthType.Max)
|
||||
{
|
||||
return 40;
|
||||
}
|
||||
|
||||
if (MouthColor > CommonColor.Max)
|
||||
{
|
||||
return 38;
|
||||
}
|
||||
|
||||
if (MouthScale > 8)
|
||||
{
|
||||
return 39;
|
||||
}
|
||||
|
||||
if (MouthAspect > 6)
|
||||
{
|
||||
return 37;
|
||||
}
|
||||
|
||||
if (MouthY > 18)
|
||||
{
|
||||
return 41;
|
||||
}
|
||||
|
||||
if (BeardColor > CommonColor.Max)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (BeardType > BeardType.Max)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (MustacheType > MustacheType.Max)
|
||||
{
|
||||
return 43;
|
||||
}
|
||||
|
||||
if (MustacheScale > 8)
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
|
||||
if (MustacheY > 16)
|
||||
{
|
||||
return 44;
|
||||
}
|
||||
|
||||
if (GlassType > GlassType.Max)
|
||||
{
|
||||
return 27;
|
||||
}
|
||||
|
||||
if (GlassColor > CommonColor.Max)
|
||||
{
|
||||
return 25;
|
||||
}
|
||||
|
||||
if (GlassScale > 7)
|
||||
{
|
||||
return 26;
|
||||
}
|
||||
|
||||
if (GlassY > 20)
|
||||
{
|
||||
return 28;
|
||||
}
|
||||
|
||||
if (MoleType > MoleType.Max)
|
||||
{
|
||||
return 34;
|
||||
}
|
||||
|
||||
if (MoleScale > 8)
|
||||
{
|
||||
return 33;
|
||||
}
|
||||
|
||||
if (MoleX > 16)
|
||||
{
|
||||
return 35;
|
||||
}
|
||||
|
||||
if (MoleY >= 31)
|
||||
{
|
||||
return 36;
|
||||
|
||||
@@ -27,14 +27,12 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
return new VirtualAmiiboFile();
|
||||
}
|
||||
|
||||
byte[] initialCounter = new byte[16];
|
||||
|
||||
const int totalPages = 135;
|
||||
const int pageSize = 4;
|
||||
const int totalBytes = totalPages * pageSize;
|
||||
|
||||
if (fileBytes.Length == 532)
|
||||
{
|
||||
int totalPages = 135;
|
||||
int pageSize = 4;
|
||||
int totalBytes = totalPages * pageSize;
|
||||
|
||||
// add 8 bytes to the end of the file
|
||||
byte[] newFileBytes = new byte[totalBytes];
|
||||
Array.Copy(fileBytes, newFileBytes, fileBytes.Length);
|
||||
@@ -54,7 +52,6 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
byte[] writeCounter = new byte[2];
|
||||
byte[] appId = new byte[8];
|
||||
byte[] settingsBytes = new byte[2];
|
||||
byte formData = 0;
|
||||
byte[] applicationAreas = new byte[216];
|
||||
byte[] dataFull = amiiboDump.GetData();
|
||||
Logger.Debug?.Print(LogClass.ServiceNfp, $"Data Full Length: {dataFull.Length}");
|
||||
@@ -94,7 +91,6 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
// Bytes 0 and 1 are amiibo ID, byte 2 is set ID, byte 3 is form data
|
||||
Array.Copy(pageData, 0, amiiboID, 0, 2);
|
||||
setID[0] = pageData[2];
|
||||
formData = pageData[3];
|
||||
break;
|
||||
case 64:
|
||||
case 65:
|
||||
@@ -145,6 +141,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
{
|
||||
VirtualAmiibo.ApplicationBytes = applicationAreas;
|
||||
}
|
||||
|
||||
VirtualAmiibo.NickName = nickName;
|
||||
return virtualAmiiboFile;
|
||||
}
|
||||
@@ -161,6 +158,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
Logger.Error?.Print(LogClass.ServiceNfp, $"Error reading file: {ex.Message}");
|
||||
return false;
|
||||
}
|
||||
|
||||
string keyRetailBinPath = GetKeyRetailBinPath();
|
||||
if (string.IsNullOrEmpty(keyRetailBinPath))
|
||||
{
|
||||
@@ -207,6 +205,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
Logger.Error?.Print(LogClass.ServiceNfp, "Failed to encrypt data correctly.");
|
||||
return false;
|
||||
}
|
||||
|
||||
inputFile = inputFile.Replace("_modified", string.Empty);
|
||||
// Save the encrypted data to file or return it for saving externally
|
||||
string outputFilePath = Path.Combine(Path.GetDirectoryName(inputFile), Path.GetFileNameWithoutExtension(inputFile) + "_modified.bin");
|
||||
@@ -235,6 +234,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
Logger.Error?.Print(LogClass.ServiceNfp, $"Error reading file: {ex.Message}");
|
||||
return false;
|
||||
}
|
||||
|
||||
string keyRetailBinPath = GetKeyRetailBinPath();
|
||||
if (string.IsNullOrEmpty(keyRetailBinPath))
|
||||
{
|
||||
@@ -259,6 +259,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
Logger.Error?.Print(LogClass.ServiceNfp, "Invalid tag data length. Expected 540 bytes.");
|
||||
return false;
|
||||
}
|
||||
|
||||
byte[] encryptedData = amiiboDecryptor.EncryptAmiiboDump(oldData).GetData();
|
||||
|
||||
if (encryptedData == null || encryptedData.Length != readBytes.Length)
|
||||
@@ -266,6 +267,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
Logger.Error?.Print(LogClass.ServiceNfp, "Failed to encrypt data correctly.");
|
||||
return false;
|
||||
}
|
||||
|
||||
inputFile = inputFile.Replace("_modified", string.Empty);
|
||||
// Save the encrypted data to file or return it for saving externally
|
||||
string outputFilePath = Path.Combine(Path.GetDirectoryName(inputFile), Path.GetFileNameWithoutExtension(inputFile) + "_modified.bin");
|
||||
@@ -316,6 +318,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
else
|
||||
crc >>= 1;
|
||||
}
|
||||
|
||||
table[i] = crc;
|
||||
}
|
||||
|
||||
@@ -325,6 +328,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
byte index = (byte)((result & 0xFF) ^ b);
|
||||
result = (result >> 8) ^ table[index];
|
||||
}
|
||||
|
||||
return ~result;
|
||||
}
|
||||
|
||||
@@ -335,17 +339,17 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
|
||||
public static bool HasAmiiboKeyFile => File.Exists(GetKeyRetailBinPath());
|
||||
|
||||
|
||||
public static DateTime DateTimeFromTag(ushort value)
|
||||
|
||||
public static DateTime DateTimeFromTag(ushort dateTimeTag)
|
||||
{
|
||||
try
|
||||
{
|
||||
int day = value & 0x1F;
|
||||
int month = (value >> 5) & 0x0F;
|
||||
int year = (value >> 9) & 0x7F;
|
||||
int day = dateTimeTag & 0x1F;
|
||||
int month = (dateTimeTag >> 5) & 0x0F;
|
||||
int year = (dateTimeTag >> 9) & 0x7F;
|
||||
|
||||
if (day == 0 || month == 0 || month > 12 || day > DateTime.DaysInMonth(2000 + year, month))
|
||||
throw new ArgumentOutOfRangeException();
|
||||
throw new ArgumentOutOfRangeException(nameof(dateTimeTag), "Invalid date in tag.");
|
||||
|
||||
return new DateTime(2000 + year, month, day);
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
{
|
||||
public class AmiiboDump
|
||||
{
|
||||
private AmiiboMasterKey dataMasterKey;
|
||||
private AmiiboMasterKey tagMasterKey;
|
||||
private readonly AmiiboMasterKey dataMasterKey;
|
||||
private readonly AmiiboMasterKey tagMasterKey;
|
||||
|
||||
private bool isLocked;
|
||||
private byte[] data;
|
||||
private readonly byte[] data;
|
||||
private byte[] hmacTagKey;
|
||||
private byte[] hmacDataKey;
|
||||
private byte[] aesKey;
|
||||
@@ -49,6 +49,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
{
|
||||
extract[i] = 0x00;
|
||||
}
|
||||
|
||||
seed.AddRange(extract.Take(append));
|
||||
|
||||
// Add the magic bytes
|
||||
@@ -70,6 +71,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
{
|
||||
paddedUser[i] = (byte)(user[i] ^ key.XorPad[i]);
|
||||
}
|
||||
|
||||
seed.AddRange(paddedUser);
|
||||
|
||||
byte[] seedBytes = seed.ToArray();
|
||||
@@ -134,9 +136,8 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
|
||||
private void DeriveKeysAndCipher()
|
||||
{
|
||||
byte[] discard;
|
||||
// Derive HMAC Tag Key
|
||||
this.hmacTagKey = DeriveKey(this.tagMasterKey, false, out discard, out discard);
|
||||
this.hmacTagKey = DeriveKey(this.tagMasterKey, false, out _, out _);
|
||||
|
||||
// Derive HMAC Data Key and AES Key/IV
|
||||
this.hmacDataKey = DeriveKey(this.dataMasterKey, true, out aesKey, out aesIv);
|
||||
@@ -182,27 +183,25 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
byte[] counter = new byte[blockSize];
|
||||
Array.Copy(iv, counter, blockSize);
|
||||
|
||||
using (ICryptoTransform encryptor = aes.CreateEncryptor())
|
||||
using ICryptoTransform encryptor = aes.CreateEncryptor();
|
||||
byte[] encryptedCounter = new byte[blockSize];
|
||||
|
||||
for (int i = 0; i < data.Length; i += blockSize)
|
||||
{
|
||||
byte[] encryptedCounter = new byte[blockSize];
|
||||
// Encrypt the counter
|
||||
encryptor.TransformBlock(counter, 0, blockSize, encryptedCounter, 0);
|
||||
|
||||
for (int i = 0; i < data.Length; i += blockSize)
|
||||
// Determine the number of bytes to process in this block
|
||||
int blockLength = Math.Min(blockSize, data.Length - i);
|
||||
|
||||
// XOR the encrypted counter with the plaintext/ciphertext block
|
||||
for (int j = 0; j < blockLength; j++)
|
||||
{
|
||||
// Encrypt the counter
|
||||
encryptor.TransformBlock(counter, 0, blockSize, encryptedCounter, 0);
|
||||
|
||||
// Determine the number of bytes to process in this block
|
||||
int blockLength = Math.Min(blockSize, data.Length - i);
|
||||
|
||||
// XOR the encrypted counter with the plaintext/ciphertext block
|
||||
for (int j = 0; j < blockLength; j++)
|
||||
{
|
||||
output[i + j] = (byte)(data[i + j] ^ encryptedCounter[j]);
|
||||
}
|
||||
|
||||
// Increment the counter
|
||||
IncrementCounter(counter);
|
||||
output[i + j] = (byte)(data[i + j] ^ encryptedCounter[j]);
|
||||
}
|
||||
|
||||
// Increment the counter
|
||||
IncrementCounter(counter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -145,6 +145,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_cancelTokenSource = new CancellationTokenSource();
|
||||
Task.Run(() =>
|
||||
{
|
||||
@@ -196,6 +197,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
@@ -601,7 +603,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
|
||||
}
|
||||
else
|
||||
{
|
||||
if (context.Device.System.NfpDevices[i].State == NfpDeviceState.TagMounted || context.Device.System.NfpDevices[i].State == NfpDeviceState.TagFound)
|
||||
if (context.Device.System.NfpDevices[i].State is NfpDeviceState.TagMounted or NfpDeviceState.TagFound)
|
||||
{
|
||||
byte[] uuid = VirtualAmiibo.GenerateUuid(context.Device.System.NfpDevices[i].AmiiboId, context.Device.System.NfpDevices[i].UseRandomUuid);
|
||||
|
||||
@@ -877,6 +879,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
|
||||
return ResultCode.Success;
|
||||
}
|
||||
}
|
||||
|
||||
return ResultCode.DeviceNotFound;
|
||||
}
|
||||
|
||||
@@ -972,7 +975,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
|
||||
{
|
||||
// TODO: Find the differencies between IUser and ISystem/IDebug.
|
||||
|
||||
if (_permissionLevel == NfpPermissionLevel.Debug || _permissionLevel == NfpPermissionLevel.System)
|
||||
if (_permissionLevel is NfpPermissionLevel.Debug or NfpPermissionLevel.System)
|
||||
{
|
||||
return GetRegisterInfo(context);
|
||||
}
|
||||
|
||||
@@ -75,6 +75,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
|
||||
nickname = NickName;
|
||||
NickName = string.Empty;
|
||||
}
|
||||
|
||||
UtilityImpl utilityImpl = new(tickSource);
|
||||
CharInfo charInfo = new();
|
||||
|
||||
@@ -109,6 +110,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
|
||||
AmiiboBinReader.SaveBinFile(InputBin, virtualAmiiboFile.NickName);
|
||||
return;
|
||||
}
|
||||
|
||||
SaveAmiiboFile(virtualAmiiboFile);
|
||||
}
|
||||
|
||||
@@ -139,6 +141,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
|
||||
ApplicationBytes = [];
|
||||
return bytes;
|
||||
}
|
||||
|
||||
VirtualAmiiboFile virtualAmiiboFile = LoadAmiiboFile(amiiboId);
|
||||
|
||||
foreach (VirtualAmiiboApplicationArea applicationArea in virtualAmiiboFile.ApplicationAreas)
|
||||
@@ -179,6 +182,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
|
||||
AmiiboBinReader.SaveBinFile(InputBin, applicationAreaData);
|
||||
return;
|
||||
}
|
||||
|
||||
VirtualAmiiboFile virtualAmiiboFile = LoadAmiiboFile(amiiboId);
|
||||
|
||||
if (virtualAmiiboFile.ApplicationAreas.Any(item => item.ApplicationAreaId == OpenedApplicationAreaId))
|
||||
@@ -246,6 +250,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
return File.Exists(Path.Join(AppDataManager.BaseDirPath, "system", "amiibo", $"{virtualAmiiboFile.AmiiboId}.json"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -400,7 +400,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
||||
|
||||
private NvInternalResult SetTimeslice(ref uint timeslice)
|
||||
{
|
||||
if (timeslice < 1000 || timeslice > 50000)
|
||||
if (timeslice is < 1000 or > 50000)
|
||||
{
|
||||
return NvInternalResult.InvalidInput;
|
||||
}
|
||||
@@ -562,7 +562,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
||||
|
||||
private static Host1xContext GetHost1XContext(GpuContext gpu, ulong pid)
|
||||
{
|
||||
return _host1xContextRegistry.GetOrAdd(pid, (ulong key) => new Host1xContext(gpu, key));
|
||||
return _host1xContextRegistry.GetOrAdd(pid, key => new Host1xContext(gpu, key));
|
||||
}
|
||||
|
||||
public static void Destroy()
|
||||
|
||||
@@ -66,6 +66,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl
|
||||
{
|
||||
configArgument.CopyTo(arguments);
|
||||
}
|
||||
|
||||
break;
|
||||
case 0x1c:
|
||||
result = CallIoctlMethod<uint>(EventSignal, arguments);
|
||||
@@ -224,7 +225,6 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private NvInternalResult EventUnregister(ref uint userEventId)
|
||||
@@ -243,9 +243,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl
|
||||
return NvInternalResult.Success;
|
||||
}
|
||||
|
||||
if (hostEvent.State == NvHostEventState.Available ||
|
||||
hostEvent.State == NvHostEventState.Cancelled ||
|
||||
hostEvent.State == NvHostEventState.Signaled)
|
||||
if (hostEvent.State is NvHostEventState.Available or
|
||||
NvHostEventState.Cancelled or
|
||||
NvHostEventState.Signaled)
|
||||
{
|
||||
_events[userEventId].CloseEvent(Context);
|
||||
_events[userEventId] = null;
|
||||
@@ -392,9 +392,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl
|
||||
{
|
||||
lock (hostEvent.Lock)
|
||||
{
|
||||
if (hostEvent.State == NvHostEventState.Available ||
|
||||
hostEvent.State == NvHostEventState.Signaled ||
|
||||
hostEvent.State == NvHostEventState.Cancelled)
|
||||
if (hostEvent.State is NvHostEventState.Available or
|
||||
NvHostEventState.Signaled or
|
||||
NvHostEventState.Cancelled)
|
||||
{
|
||||
bool timedOut = hostEvent.Wait(_device.Gpu, fence);
|
||||
|
||||
@@ -456,9 +456,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl
|
||||
|
||||
if (Event != null)
|
||||
{
|
||||
if (Event.State == NvHostEventState.Available ||
|
||||
Event.State == NvHostEventState.Signaled ||
|
||||
Event.State == NvHostEventState.Cancelled)
|
||||
if (Event.State is NvHostEventState.Available or
|
||||
NvHostEventState.Signaled or
|
||||
NvHostEventState.Cancelled)
|
||||
{
|
||||
eventIndex = index;
|
||||
|
||||
|
||||
@@ -124,6 +124,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
||||
{
|
||||
targetPrevAddress = InvalidAddress;
|
||||
}
|
||||
|
||||
node = node.Previous;
|
||||
_tree.Remove(prevAddress);
|
||||
_list.Remove(_dictionary[prevAddress]);
|
||||
@@ -151,6 +152,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
||||
{
|
||||
targetNextAddress = InvalidAddress;
|
||||
}
|
||||
|
||||
_tree.Remove(nextAddress);
|
||||
_list.Remove(_dictionary[nextAddress]);
|
||||
_dictionary.Remove(nextAddress);
|
||||
@@ -212,6 +214,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
||||
Logger.Debug?.Print(LogClass.ServiceNv, $"Target address was invalid, set to ceiling of 0x{address:X}; resulted in 0x{targetAddress:X}");
|
||||
}
|
||||
}
|
||||
|
||||
while (address < AddressSpaceSize)
|
||||
{
|
||||
if (targetAddress != InvalidAddress)
|
||||
@@ -278,6 +281,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Logger.Debug?.Print(LogClass.ServiceNv, $"No suitable address range found; returning: 0x{InvalidAddress:X}.");
|
||||
freeAddressStartPosition = InvalidAddress;
|
||||
}
|
||||
@@ -303,6 +307,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
||||
return !(gpuVa >= floorAddress && ((gpuVa + size) <= _tree.Get(floorAddress)));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Ryujinx.HLE.HOS.Services.Pctl.ParentalControlServiceFactory
|
||||
{
|
||||
_ratingAge[i] = Convert.ToInt32(context.Device.Processes.ActiveApplication.ApplicationControlProperties.RatingAge[i]);
|
||||
}
|
||||
|
||||
|
||||
_parentalControlFlag = context.Device.Processes.ActiveApplication.ApplicationControlProperties.ParentalControlFlag;
|
||||
}
|
||||
}
|
||||
@@ -180,7 +180,6 @@ namespace Ryujinx.HLE.HOS.Services.Pctl.ParentalControlServiceFactory
|
||||
|
||||
#pragma warning disable // Remove unnecessary value assignment
|
||||
bool stereoVisionRestriction = false;
|
||||
#pragma warning restore IDE0059
|
||||
|
||||
if (_stereoVisionRestrictionConfigurable)
|
||||
{
|
||||
|
||||
@@ -259,6 +259,7 @@ namespace Ryujinx.HLE.HOS.Services.Ro
|
||||
return baseAddress + size + GuardPagesSize <= memInfo.Address + memInfo.Size;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -313,7 +314,7 @@ namespace Ryujinx.HLE.HOS.Services.Ro
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
private Result SetNroMemoryPermissions(KProcess process, IExecutable relocatableObject, ulong baseAddress)
|
||||
private Result SetNroMemoryPermissions(KProcess process, NroExecutable relocatableObject, ulong baseAddress)
|
||||
{
|
||||
ulong textStart = baseAddress + relocatableObject.TextOffset;
|
||||
ulong roStart = baseAddress + relocatableObject.RoOffset;
|
||||
|
||||
@@ -5,6 +5,7 @@ using LibHac.FsSystem;
|
||||
using LibHac.Ncm;
|
||||
using LibHac.Tools.FsSystem;
|
||||
using LibHac.Tools.FsSystem.NcaUtils;
|
||||
using Microsoft.IO;
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.HLE.Exceptions;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
@@ -161,7 +162,7 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pl
|
||||
static uint KXor(uint data) => data ^ FontKey;
|
||||
|
||||
using BinaryReader reader = new(bfttfStream);
|
||||
using MemoryStream ttfStream = MemoryStreamManager.Shared.GetStream();
|
||||
using RecyclableMemoryStream ttfStream = MemoryStreamManager.Shared.GetStream();
|
||||
using BinaryWriter output = new(ttfStream);
|
||||
|
||||
if (KXor(reader.ReadUInt32()) != BFTTFMagic)
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
// not large enough.
|
||||
private const int PointerBufferSize = 0x8000;
|
||||
|
||||
private static uint[] _defaultCapabilities => [
|
||||
private static uint[] DefaultCapabilities => [
|
||||
(((uint)KScheduler.CpuCoresCount - 1) << 24) + (((uint)KScheduler.CpuCoresCount - 1) << 16) + 0x63F7u,
|
||||
0x1FFFFFCF,
|
||||
0x207FFFEF,
|
||||
@@ -47,10 +47,10 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
private readonly Dictionary<int, IpcService> _sessions = new();
|
||||
private readonly Dictionary<int, Func<IpcService>> _ports = new();
|
||||
|
||||
private readonly MemoryStream _requestDataStream;
|
||||
private readonly RecyclableMemoryStream _requestDataStream;
|
||||
private readonly BinaryReader _requestDataReader;
|
||||
|
||||
private readonly MemoryStream _responseDataStream;
|
||||
private readonly RecyclableMemoryStream _responseDataStream;
|
||||
private readonly BinaryWriter _responseDataWriter;
|
||||
|
||||
private int _isDisposed = 0;
|
||||
@@ -81,7 +81,7 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
|
||||
ProcessCreationInfo creationInfo = new("Service", 1, 0, 0x8000000, 1, Flags, 0, 0);
|
||||
|
||||
KernelStatic.StartInitialProcess(context, creationInfo, _defaultCapabilities, 44, Main);
|
||||
KernelStatic.StartInitialProcess(context, creationInfo, DefaultCapabilities, 44, Main);
|
||||
}
|
||||
|
||||
private void AddPort(int serverPortHandle, Func<IpcService> objectFactory)
|
||||
@@ -353,8 +353,8 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
_requestDataStream.Write(request.RawData);
|
||||
_requestDataStream.Position = 0;
|
||||
|
||||
if (request.Type == IpcMessageType.CmifRequest ||
|
||||
request.Type == IpcMessageType.CmifRequestWithContext)
|
||||
if (request.Type is IpcMessageType.CmifRequest or
|
||||
IpcMessageType.CmifRequestWithContext)
|
||||
{
|
||||
response.Type = IpcMessageType.CmifResponse;
|
||||
|
||||
@@ -374,8 +374,8 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
|
||||
response.RawData = _responseDataStream.ToArray();
|
||||
}
|
||||
else if (request.Type == IpcMessageType.CmifControl ||
|
||||
request.Type == IpcMessageType.CmifControlWithContext)
|
||||
else if (request.Type is IpcMessageType.CmifControl or
|
||||
IpcMessageType.CmifControlWithContext)
|
||||
{
|
||||
#pragma warning disable IDE0059 // Remove unnecessary value assignment
|
||||
uint magic = (uint)_requestDataReader.ReadUInt64();
|
||||
@@ -425,7 +425,7 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
throw new NotImplementedException(cmdId.ToString());
|
||||
}
|
||||
}
|
||||
else if (request.Type == IpcMessageType.CmifCloseSession || request.Type == IpcMessageType.TipcCloseSession)
|
||||
else if (request.Type is IpcMessageType.CmifCloseSession or IpcMessageType.TipcCloseSession)
|
||||
{
|
||||
DestroySession(serverSessionHandle);
|
||||
shouldReply = false;
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings
|
||||
|
||||
RegionCode regionCode = (RegionCode)context.Device.System.State.DesiredRegionCode;
|
||||
|
||||
if (regionCode < RegionCode.Min || regionCode > RegionCode.Max)
|
||||
if (regionCode is < RegionCode.Min or > RegionCode.Max)
|
||||
{
|
||||
regionCode = RegionCode.USA;
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ namespace Ryujinx.HLE.HOS.Services.Sm
|
||||
{
|
||||
byte chr = context.RequestData.ReadByte();
|
||||
|
||||
if (chr >= 0x20 && chr < 0x7f)
|
||||
if (chr is >= 0x20 and < 0x7f)
|
||||
{
|
||||
nameBuilder.Append((char)chr);
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Operation failed with error {errorCode}.");
|
||||
}
|
||||
|
||||
result = -1;
|
||||
}
|
||||
|
||||
@@ -102,7 +103,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
||||
}
|
||||
|
||||
LinuxError errno = LinuxError.SUCCESS;
|
||||
ISocket newBsdSocket;
|
||||
ManagedSocket newBsdSocket;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -412,7 +413,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
||||
{
|
||||
static bool IsUnexpectedLinuxError(LinuxError error)
|
||||
{
|
||||
return error != LinuxError.SUCCESS && error != LinuxError.ETIMEDOUT;
|
||||
return error is not LinuxError.SUCCESS and not LinuxError.ETIMEDOUT;
|
||||
}
|
||||
|
||||
// Hybrid approach
|
||||
@@ -817,7 +818,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
||||
{
|
||||
Logger.Warning?.PrintMsg(LogClass.ServiceBsd, $"Invalid socket fd '{socketFd}'.");
|
||||
}
|
||||
|
||||
|
||||
return WriteBsdResult(context, 0, errno);
|
||||
}
|
||||
|
||||
@@ -933,7 +934,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
||||
{
|
||||
errno = LinuxError.EINVAL;
|
||||
|
||||
if (how >= 0 && how <= 2)
|
||||
if (how is >= 0 and <= 2)
|
||||
{
|
||||
errno = socket.Shutdown((BsdSocketShutdownFlags)how);
|
||||
}
|
||||
@@ -950,7 +951,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
||||
|
||||
LinuxError errno = LinuxError.EINVAL;
|
||||
|
||||
if (how >= 0 && how <= 2)
|
||||
if (how is >= 0 and <= 2)
|
||||
{
|
||||
errno = _context.ShutdownAllSockets((BsdSocketShutdownFlags)how);
|
||||
}
|
||||
@@ -1057,7 +1058,6 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
||||
return WriteBsdResult(context, newSockFd, errno);
|
||||
}
|
||||
|
||||
|
||||
[CommandCmif(29)] // 7.0.0+
|
||||
// RecvMMsg(u32 fd, u32 vlen, u32 flags, u32 reserved, nn::socket::TimeVal timeout) -> (i32 ret, u32 bsd_errno, buffer<bytes, 6> message);
|
||||
public ResultCode RecvMMsg(ServiceCtx context)
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||
|
||||
isValidEvent = true;
|
||||
}
|
||||
|
||||
if (evnt.Data.InputEvents.HasFlag(PollEventTypeMask.Output))
|
||||
{
|
||||
waiters.Add(socket.WriteEvent);
|
||||
@@ -91,7 +92,6 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||
outputEvents |= PollEventTypeMask.Output;
|
||||
}
|
||||
|
||||
|
||||
if (outputEvents != 0)
|
||||
{
|
||||
evnt.Data.OutputEvents = outputEvents;
|
||||
|
||||
@@ -109,6 +109,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||
}
|
||||
|
||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||
}
|
||||
}
|
||||
@@ -128,6 +129,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||
}
|
||||
|
||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||
}
|
||||
}
|
||||
@@ -148,6 +150,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||
{
|
||||
Logger.Info?.PrintMsg(LogClass.ServiceBsd, $"Connecting to: {ProtocolType}/***:{remoteEndPoint.Port}");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Socket.Connect(remoteEndPoint);
|
||||
@@ -166,6 +169,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||
}
|
||||
|
||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||
}
|
||||
}
|
||||
@@ -200,6 +204,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||
}
|
||||
|
||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||
}
|
||||
}
|
||||
@@ -223,6 +228,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||
}
|
||||
|
||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||
}
|
||||
}
|
||||
@@ -259,6 +265,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||
}
|
||||
|
||||
receiveSize = -1;
|
||||
|
||||
result = WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||
@@ -314,6 +321,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||
}
|
||||
|
||||
receiveSize = -1;
|
||||
|
||||
result = WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||
@@ -341,6 +349,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||
}
|
||||
|
||||
sendSize = -1;
|
||||
|
||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||
@@ -361,6 +370,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||
}
|
||||
|
||||
sendSize = -1;
|
||||
|
||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||
@@ -402,6 +412,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||
}
|
||||
|
||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||
}
|
||||
}
|
||||
@@ -452,6 +463,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||
}
|
||||
|
||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||
}
|
||||
}
|
||||
@@ -480,7 +492,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||
return true;
|
||||
}
|
||||
|
||||
private static IList<ArraySegment<byte>> ConvertMessagesToBuffer(BsdMMsgHdr message)
|
||||
private static ArraySegment<byte>[] ConvertMessagesToBuffer(BsdMMsgHdr message)
|
||||
{
|
||||
int segmentCount = 0;
|
||||
int index = 0;
|
||||
@@ -588,6 +600,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||
}
|
||||
|
||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||
}
|
||||
}
|
||||
@@ -630,6 +643,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||
}
|
||||
|
||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
enum WsaError
|
||||
{
|
||||
/*
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Proxy
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
FilterSockets(readEvents, readDefault, (socket) => socket.Readable);
|
||||
FilterSockets(writeEvents, writeDefault, (socket) => socket.Writable);
|
||||
@@ -77,6 +77,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Proxy
|
||||
{
|
||||
Logger.Info?.PrintMsg(LogClass.ServiceBsd, $"Opening socket using host networking stack");
|
||||
}
|
||||
|
||||
return new DefaultSocket(domain, type, protocol, lanInterfaceId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types
|
||||
{
|
||||
[SuppressMessage("Design", "CA1069: Enums values should not be duplicated")]
|
||||
enum BsdSocketOption
|
||||
{
|
||||
SoDebug = 0x1,
|
||||
|
||||
@@ -2,7 +2,6 @@ using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
enum LinuxError
|
||||
{
|
||||
SUCCESS = 0,
|
||||
|
||||
@@ -14,10 +14,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd
|
||||
class IManager : IpcService
|
||||
{
|
||||
public static readonly NsdSettings NsdSettings;
|
||||
#pragma warning disable IDE0052 // Remove unread private member
|
||||
private readonly FqdnResolver _fqdnResolver;
|
||||
#pragma warning restore IDE0052
|
||||
|
||||
private readonly bool _isInitialized = false;
|
||||
|
||||
public IManager(ServiceCtx context)
|
||||
|
||||
@@ -24,10 +24,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd.Manager
|
||||
|
||||
public static ResultCode Resolve(string address, out string resolvedAddress)
|
||||
{
|
||||
if (address == "api.sect.srv.nintendo.net" ||
|
||||
address == "ctest.cdn.nintendo.net" ||
|
||||
address == "ctest.cdn.n.nintendoswitch.cn" ||
|
||||
address == "unknown.dummy.nintendo.net")
|
||||
if (address is "api.sect.srv.nintendo.net" or
|
||||
"ctest.cdn.nintendo.net" or
|
||||
"ctest.cdn.n.nintendoswitch.cn" or
|
||||
"unknown.dummy.nintendo.net")
|
||||
{
|
||||
resolvedAddress = address;
|
||||
}
|
||||
|
||||
@@ -84,6 +84,7 @@ namespace Ryujinx.HLE.HOS.Services.Spl
|
||||
{
|
||||
configValue = (ulong)DramId.IcosaSamsung4GiB;
|
||||
}
|
||||
|
||||
break;
|
||||
case ConfigItem.SecurityEngineInterruptNumber:
|
||||
return SmcResult.NotImplemented;
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace Ryujinx.HLE.HOS.Services.Ssl
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
|
||||
[CommandCmif(100)]
|
||||
// CreateContextForSystem(u64 pid, nn::ssl::sf::SslVersion, u64)
|
||||
public ResultCode CreateContextForSystem(ServiceCtx context)
|
||||
@@ -132,23 +132,23 @@ namespace Ryujinx.HLE.HOS.Services.Ssl
|
||||
ulong pid = context.RequestData.ReadUInt64();
|
||||
SslVersion sslVersion = (SslVersion)context.RequestData.ReadUInt32();
|
||||
ulong pidPlaceholder = context.RequestData.ReadUInt64();
|
||||
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { pid, sslVersion, pidPlaceholder });
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
|
||||
[CommandCmif(101)]
|
||||
// SetThreadCoreMask(u64 mask)
|
||||
public ResultCode SetThreadCoreMask(ServiceCtx context)
|
||||
{
|
||||
ulong mask = context.RequestData.ReadUInt64();
|
||||
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { mask });
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
|
||||
[CommandCmif(102)]
|
||||
// GetThreadCoreMask() -> u64
|
||||
public ResultCode GetThreadCoreMask(ServiceCtx context)
|
||||
@@ -157,7 +157,7 @@ namespace Ryujinx.HLE.HOS.Services.Ssl
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
|
||||
[CommandCmif(103)]
|
||||
// VerifySignature(buffer<0x5> unknownInput1, buffer<0x5> unknownInput2, buffer<0x5> unknownInput3, buffer<bytes, 4> unknown1)
|
||||
public ResultCode VerifySignature(ServiceCtx context)
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Ryujinx.HLE.HOS.Services.Ssl.SslService
|
||||
private SessionCacheMode _sessionCacheMode;
|
||||
private string _hostName;
|
||||
|
||||
private ISslConnectionBase _connection;
|
||||
private SslManagedSocketConnection _connection;
|
||||
private BsdContext _bsdContext;
|
||||
private readonly ulong _processId;
|
||||
|
||||
@@ -296,7 +296,6 @@ namespace Ryujinx.HLE.HOS.Services.Ssl.SslService
|
||||
|
||||
using WritableRegion region = context.Memory.GetWritableRegion(context.Request.ReceiveBuff[0].Position, (int)context.Request.ReceiveBuff[0].Size);
|
||||
|
||||
|
||||
// TODO: Better error management.
|
||||
result = _connection.Peek(out int peekCount, region.Memory);
|
||||
|
||||
|
||||
@@ -336,7 +336,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
||||
|
||||
public Status SetMaxAcquiredBufferCount(int maxAcquiredBufferCount)
|
||||
{
|
||||
if (maxAcquiredBufferCount < 0 || maxAcquiredBufferCount > BufferSlotArray.MaxAcquiredBuffers)
|
||||
if (maxAcquiredBufferCount is < 0 or > BufferSlotArray.MaxAcquiredBuffers)
|
||||
{
|
||||
return Status.BadValue;
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
||||
{
|
||||
BufferState state = Slots[slot].BufferState;
|
||||
|
||||
if (state == BufferState.Queued || state == BufferState.Dequeued)
|
||||
if (state is BufferState.Queued or BufferState.Dequeued)
|
||||
{
|
||||
maxBufferCount = slot + 1;
|
||||
}
|
||||
|
||||
@@ -636,6 +636,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
||||
|
||||
status = Status.Success;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -758,7 +759,6 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
||||
return Status.BadValue;
|
||||
}
|
||||
|
||||
|
||||
if (maxBufferCount < Core.MaxBufferCountCached)
|
||||
{
|
||||
for (int slot = maxBufferCount; slot < Core.MaxBufferCountCached; slot++)
|
||||
@@ -791,6 +791,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
||||
{
|
||||
freeSlot = slot;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -2,7 +2,6 @@ using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
||||
{
|
||||
[SuppressMessage("Design", "CA1069: Enums values should not be duplicated")]
|
||||
enum Status
|
||||
{
|
||||
Success = 0,
|
||||
|
||||
@@ -189,7 +189,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
||||
return Vi.ResultCode.InvalidValue;
|
||||
}
|
||||
|
||||
if (layer.State != LayerState.ManagedClosed && layer.State != LayerState.ManagedOpened)
|
||||
if (layer.State is not LayerState.ManagedClosed and not LayerState.ManagedOpened)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.SurfaceFlinger, $"Failed to destroy managed layer {layerId} (permission denied)");
|
||||
|
||||
@@ -393,7 +393,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
||||
|
||||
PostFrameBuffer(layer, item);
|
||||
}
|
||||
else if (acquireStatus != Status.NoBufferAvailaible && acquireStatus != Status.InvalidOperation)
|
||||
else if (acquireStatus is not Status.NoBufferAvailaible and not Status.InvalidOperation)
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
@@ -421,8 +421,8 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
||||
Format format = ConvertColorFormat(item.GraphicBuffer.Object.Buffer.Surfaces[0].ColorFormat);
|
||||
|
||||
byte bytesPerPixel =
|
||||
format == Format.B5G6R5Unorm ||
|
||||
format == Format.R4G4B4A4Unorm ? (byte)2 : (byte)4;
|
||||
format is Format.B5G6R5Unorm or
|
||||
Format.R4G4B4A4Unorm ? (byte)2 : (byte)4;
|
||||
|
||||
int gobBlocksInY = 1 << item.GraphicBuffer.Object.Buffer.Surfaces[0].BlockHeightLog2;
|
||||
|
||||
|
||||
@@ -49,7 +49,6 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
||||
Logger.Error?.Print(LogClass.SurfaceFlinger, "Android fence didn't signal in 3000 ms");
|
||||
Wait(gpuContext, Timeout.InfiniteTimeSpan);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public bool Wait(GpuContext gpuContext, TimeSpan timeout)
|
||||
|
||||
@@ -2,7 +2,6 @@ using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
||||
{
|
||||
[SuppressMessage("Design", "CA1069: Enums values should not be duplicated")]
|
||||
enum ColorFormat : ulong
|
||||
{
|
||||
#pragma warning disable IDE0055 // Disable formatting
|
||||
|
||||
@@ -26,7 +26,6 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock
|
||||
public byte Type;
|
||||
public ushort Unknown;
|
||||
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1, Size = Size)]
|
||||
private struct LocationNameStorageHolder
|
||||
{
|
||||
|
||||
@@ -2,7 +2,6 @@ using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Time
|
||||
{
|
||||
[SuppressMessage("Design", "CA1069: Enums values should not be duplicated")]
|
||||
public enum ResultCode
|
||||
{
|
||||
ModuleId = 116,
|
||||
|
||||
@@ -222,7 +222,6 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||
{
|
||||
seconds = 0;
|
||||
|
||||
|
||||
bool isValid = GetNum(name, ref namePosition, out int num, 0, HoursPerDays * DaysPerWeek - 1);
|
||||
if (!isValid)
|
||||
{
|
||||
@@ -264,6 +263,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||
seconds += num;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -486,7 +486,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||
return false;
|
||||
}
|
||||
|
||||
if (name[namePosition] != '\0' && name[namePosition] != ',' && name[namePosition] != ';')
|
||||
if (name[namePosition] is not (byte)'\0' and not (byte)',' and not (byte)';')
|
||||
{
|
||||
bool isValid = GetOffset(name.ToArray(), ref namePosition, ref dstOffset);
|
||||
|
||||
@@ -506,7 +506,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||
namePosition = 0;
|
||||
}
|
||||
|
||||
if (name[namePosition] == ',' || name[namePosition] == ';')
|
||||
if (name[namePosition] is (byte)',' or (byte)';')
|
||||
{
|
||||
namePosition++;
|
||||
|
||||
@@ -744,6 +744,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||
{
|
||||
outRules.Chars[charsPosition + i] = destName[i];
|
||||
}
|
||||
|
||||
outRules.Chars[charsPosition + destLen] = 0;
|
||||
}
|
||||
|
||||
@@ -763,6 +764,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||
{
|
||||
value += SecondsPerDay;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RuleType.DayOfYear:
|
||||
@@ -923,7 +925,6 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (streamLength < (timeCount * TimeTypeSize
|
||||
+ timeCount
|
||||
+ typeCount * 6
|
||||
@@ -1051,7 +1052,6 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||
outRules.Ttis[i].IsGMT = p[0] != 0;
|
||||
p = p[1..];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
long position = (workBuffer.Length - p.Length);
|
||||
@@ -1554,7 +1554,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||
|
||||
int savedSeconds;
|
||||
|
||||
if (calendarTime.Second >= 0 && calendarTime.Second < SecondsPerMinute)
|
||||
if (calendarTime.Second is >= 0 and < SecondsPerMinute)
|
||||
{
|
||||
savedSeconds = 0;
|
||||
}
|
||||
|
||||
@@ -152,7 +152,6 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||
|
||||
TimeZone.ParseTimeZoneBinary(ref tzRule, tzif.Get.AsStream());
|
||||
|
||||
|
||||
TimeTypeInfo ttInfo;
|
||||
if (tzRule.TimeCount > 0) // Find the current transition period
|
||||
{
|
||||
@@ -164,6 +163,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||
fin = i;
|
||||
}
|
||||
}
|
||||
|
||||
ttInfo = tzRule.Ttis[tzRule.Types[fin]];
|
||||
}
|
||||
else if (tzRule.TypeCount >= 1) // Otherwise, use the first offset in TTInfo
|
||||
|
||||
@@ -4,9 +4,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService.ApplicationDisplayService
|
||||
{
|
||||
class IManagerDisplayService : IpcService
|
||||
{
|
||||
#pragma warning disable IDE0052 // Remove unread private member
|
||||
private readonly IApplicationDisplayService _applicationDisplayService;
|
||||
#pragma warning restore IDE0052
|
||||
|
||||
public IManagerDisplayService(IApplicationDisplayService applicationDisplayService)
|
||||
{
|
||||
|
||||
@@ -4,9 +4,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService.ApplicationDisplayService
|
||||
{
|
||||
class ISystemDisplayService : IpcService
|
||||
{
|
||||
#pragma warning disable IDE0052 // Remove unread private member
|
||||
private readonly IApplicationDisplayService _applicationDisplayService;
|
||||
#pragma warning restore IDE0052
|
||||
|
||||
public ISystemDisplayService(IApplicationDisplayService applicationDisplayService)
|
||||
{
|
||||
|
||||
@@ -148,7 +148,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService
|
||||
{
|
||||
byte chr = context.RequestData.ReadByte();
|
||||
|
||||
if (chr >= 0x20 && chr < 0x7f)
|
||||
if (chr is >= 0x20 and < 0x7f)
|
||||
{
|
||||
nameBuilder.Append((char)chr);
|
||||
}
|
||||
@@ -346,7 +346,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService
|
||||
return ResultCode.InvalidArguments;
|
||||
}
|
||||
|
||||
if (scalingMode != SourceScalingMode.ScaleToWindow && scalingMode != SourceScalingMode.PreserveAspectRatio)
|
||||
if (scalingMode is not SourceScalingMode.ScaleToWindow and not SourceScalingMode.PreserveAspectRatio)
|
||||
{
|
||||
// Invalid scaling mode specified.
|
||||
return ResultCode.InvalidScalingMode;
|
||||
|
||||
Reference in New Issue
Block a user