mirror of
https://git.ryujinx.app/projects/Kenji-NX.git
synced 2026-10-06 19:38:53 +02:00
misc: chore: Use explicit types & fix object creation
This commit is contained in:
@@ -191,10 +191,10 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
||||
|
||||
private void DeleteSaveData(UserId userId)
|
||||
{
|
||||
var saveDataFilter = SaveDataFilter.Make(programId: default, saveType: default,
|
||||
SaveDataFilter saveDataFilter = SaveDataFilter.Make(programId: default, saveType: default,
|
||||
new LibHac.Fs.UserId((ulong)userId.High, (ulong)userId.Low), saveDataId: default, index: default);
|
||||
|
||||
using var saveDataIterator = new UniqueRef<SaveDataIterator>();
|
||||
using UniqueRef<SaveDataIterator> saveDataIterator = new();
|
||||
|
||||
_horizonClient.Fs.OpenSaveDataIterator(ref saveDataIterator.Ref, SaveDataSpaceId.User, in saveDataFilter).ThrowIfFailure();
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using Ryujinx.Common.Utilities;
|
||||
using Ryujinx.HLE.HOS.Services.Account.Acc.Types;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
@@ -28,7 +29,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
||||
{
|
||||
ProfilesJson profilesJson = JsonHelper.DeserializeFromFile(_profilesJsonPath, _serializerContext.ProfilesJson);
|
||||
|
||||
foreach (var profile in profilesJson.Profiles)
|
||||
foreach (UserProfileJson profile in profilesJson.Profiles)
|
||||
{
|
||||
UserProfile addedProfile = new(new UserId(profile.UserId), profile.Name, profile.Image, profile.LastModifiedTimestamp);
|
||||
|
||||
@@ -68,7 +69,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
||||
LastOpened = LastOpened.ToString(),
|
||||
};
|
||||
|
||||
foreach (var profile in profiles)
|
||||
foreach (KeyValuePair<string, UserProfile> profile in profiles)
|
||||
{
|
||||
profilesJson.Profiles.Add(new UserProfileJson()
|
||||
{
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
|
||||
byte[] deviceAccountId = new byte[0x10];
|
||||
RandomNumberGenerator.Fill(deviceAccountId);
|
||||
|
||||
var descriptor = new SecurityTokenDescriptor
|
||||
SecurityTokenDescriptor descriptor = new()
|
||||
{
|
||||
Subject = new ClaimsIdentity([new Claim(JwtRegisteredClaimNames.Sub, Convert.ToHexString(rawUserId).ToLower())]),
|
||||
SigningCredentials = credentials,
|
||||
|
||||
+1
-1
@@ -214,7 +214,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
|
||||
|
||||
_vrModeEnabled = vrModeEnabled;
|
||||
|
||||
using var lblApi = new LblApi();
|
||||
using LblApi lblApi = new();
|
||||
|
||||
if (vrModeEnabled)
|
||||
{
|
||||
|
||||
+3
-2
@@ -13,6 +13,7 @@ using Ryujinx.HLE.HOS.Services.Am.AppletAE.Storage;
|
||||
using Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.ApplicationProxy.Types;
|
||||
using Ryujinx.HLE.HOS.Services.Sdb.Pdm.QueryService;
|
||||
using Ryujinx.HLE.HOS.SystemState;
|
||||
using Ryujinx.HLE.Loaders.Processes;
|
||||
using Ryujinx.Horizon.Common;
|
||||
using System;
|
||||
using System.Numerics;
|
||||
@@ -117,7 +118,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
|
||||
public ResultCode EnsureSaveData(ServiceCtx context)
|
||||
{
|
||||
Uid userId = context.RequestData.ReadStruct<AccountUid>().ToLibHacUid();
|
||||
var process = context.Device.Processes.GetProcess(_pid);
|
||||
ProcessResult process = context.Device.Processes.GetProcess(_pid);
|
||||
|
||||
// Mask out the low nibble of the program ID to get the application ID
|
||||
ApplicationId applicationId = new(process.Identity.ApplicationId);
|
||||
@@ -238,7 +239,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.Applicati
|
||||
ushort index = (ushort)context.RequestData.ReadUInt64();
|
||||
long saveSize = context.RequestData.ReadInt64();
|
||||
long journalSize = context.RequestData.ReadInt64();
|
||||
var process = context.Device.Processes.GetProcess(_pid);
|
||||
ProcessResult process = context.Device.Processes.GetProcess(_pid);
|
||||
|
||||
// Mask out the low nibble of the program ID to get the application ID
|
||||
ApplicationId applicationId = new(process.Identity.ApplicationId);
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace Ryujinx.HLE.HOS.Services.Caps
|
||||
filePath = GenerateFilePath(folderPath, applicationAlbumEntry, currentDateTime, hash);
|
||||
}
|
||||
|
||||
using var bitmap = new SKBitmap(new SKImageInfo(ScreenshotWidth, ScreenshotHeight, SKColorType.Rgba8888));
|
||||
using SKBitmap bitmap = new(new SKImageInfo(ScreenshotWidth, ScreenshotHeight, SKColorType.Rgba8888));
|
||||
|
||||
IntPtr pixels = bitmap.GetPixels();
|
||||
|
||||
@@ -142,8 +142,8 @@ namespace Ryujinx.HLE.HOS.Services.Caps
|
||||
|
||||
Marshal.Copy(screenshotData, 0, pixels, ScreenshotDataSize);
|
||||
|
||||
using var data = bitmap.Encode(SKEncodedImageFormat.Jpeg, 80);
|
||||
using var file = File.OpenWrite(filePath);
|
||||
using SKData data = bitmap.Encode(SKEncodedImageFormat.Jpeg, 80);
|
||||
using FileStream file = File.OpenWrite(filePath);
|
||||
data.SaveTo(file);
|
||||
|
||||
return ResultCode.Success;
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
try
|
||||
{
|
||||
LocalStorage storage = new(pfsPath, FileAccess.Read, FileMode.Open);
|
||||
var pfs = new PartitionFileSystem();
|
||||
PartitionFileSystem pfs = new();
|
||||
using SharedRef<LibHac.Fs.Fsa.IFileSystem> nsp = new(pfs);
|
||||
pfs.Initialize(storage).ThrowIfFailure();
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
}
|
||||
|
||||
LibHac.Fs.Fsa.IFileSystem fileSystem = nca.OpenFileSystem(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel);
|
||||
using var sharedFs = new SharedRef<LibHac.Fs.Fsa.IFileSystem>(fileSystem);
|
||||
using SharedRef<LibHac.Fs.Fsa.IFileSystem> sharedFs = new(fileSystem);
|
||||
|
||||
using SharedRef<LibHac.FsSrv.Sf.IFileSystem> adapter = FileSystemInterfaceAdapter.CreateShared(ref sharedFs.Ref, true);
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
|
||||
string filename = fullPath.Replace(archivePath.FullName, string.Empty).TrimStart('\\');
|
||||
|
||||
using var ncaFile = new UniqueRef<LibHac.Fs.Fsa.IFile>();
|
||||
using UniqueRef<LibHac.Fs.Fsa.IFile> ncaFile = new();
|
||||
|
||||
Result result = nsp.OpenFile(ref ncaFile.Ref, filename.ToU8Span(), OpenMode.Read);
|
||||
if (result.IsFailure())
|
||||
@@ -122,14 +122,14 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
{
|
||||
foreach (DirectoryEntryEx ticketEntry in nsp.EnumerateEntries("/", "*.tik"))
|
||||
{
|
||||
using var ticketFile = new UniqueRef<LibHac.Fs.Fsa.IFile>();
|
||||
using UniqueRef<LibHac.Fs.Fsa.IFile> ticketFile = new();
|
||||
|
||||
Result result = nsp.OpenFile(ref ticketFile.Ref, ticketEntry.FullPath.ToU8Span(), OpenMode.Read);
|
||||
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
Ticket ticket = new(ticketFile.Get.AsStream());
|
||||
var titleKey = ticket.GetTitleKey(keySet);
|
||||
byte[] titleKey = ticket.GetTitleKey(keySet);
|
||||
|
||||
if (titleKey != null)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using LibHac;
|
||||
using LibHac.Common;
|
||||
using LibHac.Sf;
|
||||
using Ryujinx.Memory;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
{
|
||||
@@ -20,7 +21,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
ulong bufferAddress = context.Request.ReceiveBuff[0].Position;
|
||||
ulong bufferLen = context.Request.ReceiveBuff[0].Size;
|
||||
|
||||
using var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true);
|
||||
using WritableRegion region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true);
|
||||
Result result = _baseDirectory.Get.Read(out long entriesRead, new OutBuffer(region.Memory.Span));
|
||||
|
||||
context.ResponseData.Write(entriesRead);
|
||||
|
||||
@@ -3,6 +3,7 @@ using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Sf;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Memory;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
{
|
||||
@@ -28,7 +29,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
long offset = context.RequestData.ReadInt64();
|
||||
long size = context.RequestData.ReadInt64();
|
||||
|
||||
using var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true);
|
||||
using WritableRegion region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true);
|
||||
Result result = _baseFile.Get.Read(out long bytesRead, offset, new OutBuffer(region.Memory.Span), size, readOption);
|
||||
|
||||
context.ResponseData.Write(bytesRead);
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
uint mode = context.RequestData.ReadUInt32();
|
||||
|
||||
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
|
||||
using var file = new SharedRef<LibHac.FsSrv.Sf.IFile>();
|
||||
using SharedRef<LibHac.FsSrv.Sf.IFile> file = new();
|
||||
|
||||
Result result = _fileSystem.Get.OpenFile(ref file.Ref, in name, mode);
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
uint mode = context.RequestData.ReadUInt32();
|
||||
|
||||
ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context);
|
||||
using var dir = new SharedRef<LibHac.FsSrv.Sf.IDirectory>();
|
||||
using SharedRef<LibHac.FsSrv.Sf.IDirectory> dir = new();
|
||||
|
||||
Result result = _fileSystem.Get.OpenDirectory(ref dir.Ref, in name, mode);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using LibHac;
|
||||
using LibHac.Common;
|
||||
using LibHac.Sf;
|
||||
using Ryujinx.Memory;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
{
|
||||
@@ -31,7 +32,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
size = bufferLen;
|
||||
}
|
||||
|
||||
using var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true);
|
||||
using WritableRegion region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true);
|
||||
Result result = _baseStorage.Get.Read((long)offset, new OutBuffer(region.Memory.Span), (long)size);
|
||||
|
||||
return (ResultCode)result.Value;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using LibHac;
|
||||
using LibHac.Common;
|
||||
using LibHac.Sf;
|
||||
using Ryujinx.Memory;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Fs
|
||||
{
|
||||
@@ -20,7 +21,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs
|
||||
ulong bufferAddress = context.Request.ReceiveBuff[0].Position;
|
||||
ulong bufferLen = context.Request.ReceiveBuff[0].Size;
|
||||
|
||||
using var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true);
|
||||
using WritableRegion region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true);
|
||||
Result result = _baseReader.Get.Read(out long readCount, new OutBuffer(region.Memory.Span));
|
||||
|
||||
context.ResponseData.Write(readCount);
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs
|
||||
{
|
||||
IrCameraHandle irCameraHandle = context.RequestData.ReadStruct<IrCameraHandle>();
|
||||
ulong appletResourceUserId = context.RequestData.ReadUInt64();
|
||||
var packedMomentProcessorConfig = context.RequestData.ReadStruct<PackedMomentProcessorConfig>();
|
||||
PackedMomentProcessorConfig packedMomentProcessorConfig = context.RequestData.ReadStruct<PackedMomentProcessorConfig>();
|
||||
|
||||
CheckCameraHandle(irCameraHandle);
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs
|
||||
{
|
||||
IrCameraHandle irCameraHandle = context.RequestData.ReadStruct<IrCameraHandle>();
|
||||
ulong appletResourceUserId = context.RequestData.ReadUInt64();
|
||||
var packedClusteringProcessorConfig = context.RequestData.ReadStruct<PackedClusteringProcessorConfig>();
|
||||
PackedClusteringProcessorConfig packedClusteringProcessorConfig = context.RequestData.ReadStruct<PackedClusteringProcessorConfig>();
|
||||
|
||||
CheckCameraHandle(irCameraHandle);
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs
|
||||
{
|
||||
IrCameraHandle irCameraHandle = context.RequestData.ReadStruct<IrCameraHandle>();
|
||||
ulong appletResourceUserId = context.RequestData.ReadUInt64();
|
||||
var packedImageTransferProcessorConfig = context.RequestData.ReadStruct<PackedImageTransferProcessorConfig>();
|
||||
PackedImageTransferProcessorConfig packedImageTransferProcessorConfig = context.RequestData.ReadStruct<PackedImageTransferProcessorConfig>();
|
||||
|
||||
CheckCameraHandle(irCameraHandle);
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs
|
||||
{
|
||||
IrCameraHandle irCameraHandle = context.RequestData.ReadStruct<IrCameraHandle>();
|
||||
ulong appletResourceUserId = context.RequestData.ReadUInt64();
|
||||
var packedTeraPluginProcessorConfig = context.RequestData.ReadStruct<PackedTeraPluginProcessorConfig>();
|
||||
PackedTeraPluginProcessorConfig packedTeraPluginProcessorConfig = context.RequestData.ReadStruct<PackedTeraPluginProcessorConfig>();
|
||||
|
||||
CheckCameraHandle(irCameraHandle);
|
||||
|
||||
|
||||
@@ -248,7 +248,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnMitm
|
||||
|
||||
byte[] ip = address.GetAddressBytes();
|
||||
|
||||
var macAddress = new Array6<byte>();
|
||||
Array6<byte> macAddress = new();
|
||||
new byte[] { 0x02, 0x00, ip[0], ip[1], ip[2], ip[3] }.CopyTo(macAddress.AsSpan());
|
||||
|
||||
return macAddress;
|
||||
|
||||
+2
-2
@@ -112,7 +112,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnMitm.Proxy
|
||||
|
||||
lock (_scanLock)
|
||||
{
|
||||
var newResults = _scanResultsLast;
|
||||
Dictionary<ulong, NetworkInfo> newResults = _scanResultsLast;
|
||||
newResults.Clear();
|
||||
|
||||
_scanResultsLast = _scanResults;
|
||||
@@ -138,7 +138,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnMitm.Proxy
|
||||
|
||||
lock (_scanLock)
|
||||
{
|
||||
var results = new Dictionary<ulong, NetworkInfo>();
|
||||
Dictionary<ulong, NetworkInfo> results = new();
|
||||
|
||||
foreach (KeyValuePair<ulong, NetworkInfo> last in _scanResultsLast)
|
||||
{
|
||||
|
||||
@@ -493,7 +493,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
|
||||
SendAsync(_protocol.Encode(PacketId.CreateAccessPoint, request, advertiseData));
|
||||
|
||||
// Send a network change event with dummy data immediately. Necessary to avoid crashes in some games
|
||||
var networkChangeEvent = new NetworkChangeEventArgs(new NetworkInfo()
|
||||
NetworkChangeEventArgs networkChangeEvent = new(new NetworkInfo()
|
||||
{
|
||||
Common = new CommonNetworkInfo()
|
||||
{
|
||||
@@ -613,7 +613,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
|
||||
|
||||
SendAsync(_protocol.Encode(PacketId.Connect, request));
|
||||
|
||||
var networkChangeEvent = new NetworkChangeEventArgs(new NetworkInfo()
|
||||
NetworkChangeEventArgs networkChangeEvent = new(new NetworkInfo()
|
||||
{
|
||||
Common = request.NetworkInfo.Common,
|
||||
Ldn = request.NetworkInfo.Ldn
|
||||
|
||||
@@ -256,7 +256,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
|
||||
{
|
||||
_proxy.ReturnEphemeralPort(ProtocolType, (ushort)((IPEndPoint)LocalEndPoint).Port);
|
||||
}
|
||||
var asIPEndpoint = (IPEndPoint)localEP;
|
||||
IPEndPoint asIPEndpoint = (IPEndPoint)localEP;
|
||||
if (asIPEndpoint.Port == 0)
|
||||
{
|
||||
asIPEndpoint.Port = (ushort)_proxy.GetEphemeralPort(ProtocolType);
|
||||
|
||||
@@ -440,18 +440,18 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types
|
||||
|
||||
int indexFor4 = 3 * (int)age + 9 * (int)gender + (int)race;
|
||||
|
||||
var facelineTypeInfo = RandomMiiFacelineArray[indexFor4];
|
||||
var facelineColorInfo = RandomMiiFacelineColorArray[3 * (int)gender + (int)race];
|
||||
var facelineWrinkleInfo = RandomMiiFacelineWrinkleArray[indexFor4];
|
||||
var facelineMakeInfo = RandomMiiFacelineMakeArray[indexFor4];
|
||||
var hairTypeInfo = RandomMiiHairTypeArray[indexFor4];
|
||||
var hairColorInfo = RandomMiiHairColorArray[3 * (int)race + (int)age];
|
||||
var eyeTypeInfo = RandomMiiEyeTypeArray[indexFor4];
|
||||
var eyeColorInfo = RandomMiiEyeColorArray[(int)race];
|
||||
var eyebrowTypeInfo = RandomMiiEyebrowTypeArray[indexFor4];
|
||||
var noseTypeInfo = RandomMiiNoseTypeArray[indexFor4];
|
||||
var mouthTypeInfo = RandomMiiMouthTypeArray[indexFor4];
|
||||
var glassTypeInfo = RandomMiiGlassTypeArray[(int)age];
|
||||
RandomMiiData4 facelineTypeInfo = RandomMiiFacelineArray[indexFor4];
|
||||
RandomMiiData3 facelineColorInfo = RandomMiiFacelineColorArray[3 * (int)gender + (int)race];
|
||||
RandomMiiData4 facelineWrinkleInfo = RandomMiiFacelineWrinkleArray[indexFor4];
|
||||
RandomMiiData4 facelineMakeInfo = RandomMiiFacelineMakeArray[indexFor4];
|
||||
RandomMiiData4 hairTypeInfo = RandomMiiHairTypeArray[indexFor4];
|
||||
RandomMiiData3 hairColorInfo = RandomMiiHairColorArray[3 * (int)race + (int)age];
|
||||
RandomMiiData4 eyeTypeInfo = RandomMiiEyeTypeArray[indexFor4];
|
||||
RandomMiiData2 eyeColorInfo = RandomMiiEyeColorArray[(int)race];
|
||||
RandomMiiData4 eyebrowTypeInfo = RandomMiiEyebrowTypeArray[indexFor4];
|
||||
RandomMiiData4 noseTypeInfo = RandomMiiNoseTypeArray[indexFor4];
|
||||
RandomMiiData4 mouthTypeInfo = RandomMiiMouthTypeArray[indexFor4];
|
||||
RandomMiiData2 glassTypeInfo = RandomMiiGlassTypeArray[(int)age];
|
||||
|
||||
// Faceline
|
||||
coreData.FacelineType = (FacelineType)facelineTypeInfo.Values[utilImpl.GetRandom(facelineTypeInfo.ValuesCount)];
|
||||
|
||||
@@ -9,8 +9,8 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
|
||||
public AmiiboDecryptor(string keyRetailBinPath)
|
||||
{
|
||||
var combinedKeys = File.ReadAllBytes(keyRetailBinPath);
|
||||
var keys = AmiiboMasterKey.FromCombinedBin(combinedKeys);
|
||||
byte[] combinedKeys = File.ReadAllBytes(keyRetailBinPath);
|
||||
(AmiiboMasterKey DataKey, AmiiboMasterKey TagKey) keys = AmiiboMasterKey.FromCombinedBin(combinedKeys);
|
||||
DataKey = keys.DataKey;
|
||||
TagKey = keys.TagKey;
|
||||
}
|
||||
|
||||
@@ -85,13 +85,13 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
if (deriveAes)
|
||||
{
|
||||
// Derive AES Key and IV
|
||||
var dataForAes = new byte[2 + seedBytes.Length];
|
||||
byte[] dataForAes = new byte[2 + seedBytes.Length];
|
||||
dataForAes[0] = 0x00;
|
||||
dataForAes[1] = 0x00; // Counter (0)
|
||||
Array.Copy(seedBytes, 0, dataForAes, 2, seedBytes.Length);
|
||||
|
||||
byte[] derivedBytes;
|
||||
using (var hmac = new HMACSHA256(key.HmacKey))
|
||||
using (HMACSHA256 hmac = new(key.HmacKey))
|
||||
{
|
||||
derivedBytes = hmac.ComputeHash(dataForAes);
|
||||
}
|
||||
@@ -100,12 +100,12 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
derivedAesIv = derivedBytes.Skip(16).Take(16).ToArray();
|
||||
|
||||
// Derive HMAC Key
|
||||
var dataForHmacKey = new byte[2 + seedBytes.Length];
|
||||
byte[] dataForHmacKey = new byte[2 + seedBytes.Length];
|
||||
dataForHmacKey[0] = 0x00;
|
||||
dataForHmacKey[1] = 0x01; // Counter (1)
|
||||
Array.Copy(seedBytes, 0, dataForHmacKey, 2, seedBytes.Length);
|
||||
|
||||
using (var hmac = new HMACSHA256(key.HmacKey))
|
||||
using (HMACSHA256 hmac = new(key.HmacKey))
|
||||
{
|
||||
derivedBytes = hmac.ComputeHash(dataForHmacKey);
|
||||
}
|
||||
@@ -115,13 +115,13 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
else
|
||||
{
|
||||
// Derive HMAC Key only
|
||||
var dataForHmacKey = new byte[2 + seedBytes.Length];
|
||||
byte[] dataForHmacKey = new byte[2 + seedBytes.Length];
|
||||
dataForHmacKey[0] = 0x00;
|
||||
dataForHmacKey[1] = 0x01; // Counter (1)
|
||||
Array.Copy(seedBytes, 0, dataForHmacKey, 2, seedBytes.Length);
|
||||
|
||||
byte[] derivedBytes;
|
||||
using (var hmac = new HMACSHA256(key.HmacKey))
|
||||
using (HMACSHA256 hmac = new(key.HmacKey))
|
||||
{
|
||||
derivedBytes = hmac.ComputeHash(dataForHmacKey);
|
||||
}
|
||||
@@ -229,7 +229,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
Array.Copy(data, 0x054, tagHmacData, 8, 44);
|
||||
|
||||
byte[] tagHmac;
|
||||
using (var hmac = new HMACSHA256(hmacTagKey))
|
||||
using (HMACSHA256 hmac = new(hmacTagKey))
|
||||
{
|
||||
tagHmac = hmac.ComputeHash(tagHmacData);
|
||||
}
|
||||
@@ -258,7 +258,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
Array.Copy(data, 0x054, dataHmacData, offset, len5);
|
||||
|
||||
byte[] dataHmac;
|
||||
using (var hmac = new HMACSHA256(hmacDataKey))
|
||||
using (HMACSHA256 hmac = new(hmacDataKey))
|
||||
{
|
||||
dataHmac = hmac.ComputeHash(dataHmacData);
|
||||
}
|
||||
@@ -278,7 +278,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
Array.Copy(data, 0x054, tagHmacData, 8, 44);
|
||||
|
||||
byte[] calculatedTagHmac;
|
||||
using (var hmac = new HMACSHA256(hmacTagKey))
|
||||
using (HMACSHA256 hmac = new(hmacTagKey))
|
||||
{
|
||||
calculatedTagHmac = hmac.ComputeHash(tagHmacData);
|
||||
}
|
||||
@@ -312,7 +312,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
|
||||
Array.Copy(data, 0x054, dataHmacData, offset, len5);
|
||||
|
||||
byte[] calculatedDataHmac;
|
||||
using (var hmac = new HMACSHA256(hmacDataKey))
|
||||
using (HMACSHA256 hmac = new(hmacDataKey))
|
||||
{
|
||||
calculatedDataHmac = hmac.ComputeHash(dataHmacData);
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
||||
MemoryAllocator = new NvMemoryAllocator();
|
||||
Host1x = new Host1xDevice(gpu.Synchronization);
|
||||
Smmu = gpu.CreateDeviceMemoryManager(pid);
|
||||
var nvdec = new NvdecDevice(Smmu);
|
||||
var vic = new VicDevice(Smmu);
|
||||
NvdecDevice nvdec = new(Smmu);
|
||||
VicDevice vic = new(Smmu);
|
||||
Host1x.RegisterDevice(ClassId.Nvdec, nvdec);
|
||||
Host1x.RegisterDevice(ClassId.Vic, vic);
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
||||
|
||||
private NvInternalResult BindChannel(ref BindChannelArguments arguments)
|
||||
{
|
||||
var channelDeviceFile = INvDrvServices.DeviceFileIdRegistry.GetData<NvHostChannelDeviceFile>(arguments.Fd);
|
||||
NvHostChannelDeviceFile channelDeviceFile = INvDrvServices.DeviceFileIdRegistry.GetData<NvHostChannelDeviceFile>(arguments.Fd);
|
||||
if (channelDeviceFile == null)
|
||||
{
|
||||
// TODO: Return invalid Fd error.
|
||||
@@ -339,9 +339,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
||||
|
||||
for (uint i = 0; i < writeEntries; i++)
|
||||
{
|
||||
ref var region = ref regionsSpan[(int)i];
|
||||
ref VaRegion region = ref regionsSpan[(int)i];
|
||||
|
||||
var vmRegion = _vmRegions[i];
|
||||
VmRegion vmRegion = _vmRegions[i];
|
||||
uint pageSize = _pageSizes[i];
|
||||
|
||||
region.PageSize = pageSize;
|
||||
|
||||
+1
-1
@@ -169,7 +169,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
||||
{
|
||||
NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(Owner, commandBuffer.Mem);
|
||||
|
||||
var data = _memory.GetSpan(map.Address + commandBuffer.Offset, commandBuffer.WordsCount * 4);
|
||||
ReadOnlySpan<byte> data = _memory.GetSpan(map.Address + commandBuffer.Offset, commandBuffer.WordsCount * 4);
|
||||
|
||||
_host1xContext.Host1x.Submit(MemoryMarshal.Cast<byte, int>(data), _contextId);
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.HOS.Services.Arp;
|
||||
using Ryujinx.HLE.Loaders.Processes;
|
||||
using System;
|
||||
using static LibHac.Ns.ApplicationControlProperty;
|
||||
|
||||
@@ -53,7 +54,7 @@ namespace Ryujinx.HLE.HOS.Services.Pctl.ParentalControlServiceFactory
|
||||
if (titleId != 0)
|
||||
{
|
||||
_titleId = titleId;
|
||||
var process = context.Device.Processes.GetProcess(_pid);
|
||||
ProcessResult process = context.Device.Processes.GetProcess(_pid);
|
||||
|
||||
// TODO: Call nn::arp::GetApplicationControlProperty here when implemented, if it return ResultCode.Success we assign fields.
|
||||
_ratingAge = new int[process.ApplicationControlProperties.RatingAge.Length];
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pdm.QueryService
|
||||
MemoryHelper.FillWithZeros(context.Memory, outputPosition, (int)outputSize);
|
||||
|
||||
// Return ResultCode.ServiceUnavailable if data is locked by another process.
|
||||
var filteredApplicationPlayStatistics = _applicationPlayStatistics.AsEnumerable();
|
||||
IEnumerable<KeyValuePair<UserId, ApplicationPlayStatistics>> filteredApplicationPlayStatistics = _applicationPlayStatistics.AsEnumerable();
|
||||
|
||||
if (queryCapability == PlayLogQueryCapability.None)
|
||||
{
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pl
|
||||
Nca nca = new(_device.System.KeySet, ncaFileStream);
|
||||
IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _device.System.FsIntegrityCheckLevel);
|
||||
|
||||
using var fontFile = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> fontFile = new();
|
||||
|
||||
romfs.OpenFile(ref fontFile.Ref, ("/" + fontFilename).ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Microsoft.IO;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Common.Memory;
|
||||
@@ -82,7 +83,7 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
|
||||
KernelStatic.StartInitialProcess(context, creationInfo, _defaultCapabilities, 44, () =>
|
||||
{
|
||||
var currentThread = KernelStatic.GetCurrentThread();
|
||||
KThread currentThread = KernelStatic.GetCurrentThread();
|
||||
currentThread.HostThread.Name = $"{{{Name}}}";
|
||||
|
||||
Main();
|
||||
@@ -241,7 +242,7 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
}
|
||||
}
|
||||
|
||||
var rc = _context.Syscall.ReplyAndReceive(out int signaledIndex, handles.AsSpan(0, handleCount), replyTargetHandle, -1);
|
||||
Result rc = _context.Syscall.ReplyAndReceive(out int signaledIndex, handles.AsSpan(0, handleCount), replyTargetHandle, -1);
|
||||
|
||||
_selfThread.HandlePostSyscall();
|
||||
|
||||
@@ -313,7 +314,7 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
{
|
||||
_context.Syscall.CloseHandle(serverSessionHandle);
|
||||
|
||||
if (RemoveSessionObj(serverSessionHandle, out var session))
|
||||
if (RemoveSessionObj(serverSessionHandle, out IpcService session))
|
||||
{
|
||||
(session as IDisposable)?.Dispose();
|
||||
}
|
||||
@@ -457,7 +458,7 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
|
||||
response.RawData = _responseDataStream.ToArray();
|
||||
|
||||
var responseStream = response.GetStreamTipc();
|
||||
RecyclableMemoryStream responseStream = response.GetStreamTipc();
|
||||
_selfProcess.CpuMemory.Write(_selfThread.TlsAddress, responseStream.GetReadOnlySequence());
|
||||
MemoryStreamManager.Shared.ReleaseStream(responseStream);
|
||||
}
|
||||
@@ -468,7 +469,7 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
|
||||
if (!isTipcCommunication)
|
||||
{
|
||||
var responseStream = response.GetStream((long)_selfThread.TlsAddress, recvListAddr | ((ulong)PointerBufferSize << 48));
|
||||
RecyclableMemoryStream responseStream = response.GetStream((long)_selfThread.TlsAddress, recvListAddr | ((ulong)PointerBufferSize << 48));
|
||||
_selfProcess.CpuMemory.Write(_selfThread.TlsAddress, responseStream.GetReadOnlySequence());
|
||||
MemoryStreamManager.Shared.ReleaseStream(responseStream);
|
||||
}
|
||||
|
||||
@@ -317,7 +317,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings
|
||||
|
||||
IFileSystem firmwareRomFs = firmwareContent.OpenFileSystem(NcaSectionType.Data, device.System.FsIntegrityCheckLevel);
|
||||
|
||||
using var firmwareFile = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> firmwareFile = new();
|
||||
|
||||
Result result = firmwareRomFs.OpenFile(ref firmwareFile.Ref, "/file".ToU8Span(), OpenMode.Read);
|
||||
if (result.IsFailure())
|
||||
|
||||
@@ -331,9 +331,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
||||
}
|
||||
}
|
||||
|
||||
using var readFdsOut = context.Memory.GetWritableRegion(readFdsOutBufferPosition, (int)readFdsOutBufferSize);
|
||||
using var writeFdsOut = context.Memory.GetWritableRegion(writeFdsOutBufferPosition, (int)writeFdsOutBufferSize);
|
||||
using var errorFdsOut = context.Memory.GetWritableRegion(errorFdsOutBufferPosition, (int)errorFdsOutBufferSize);
|
||||
using WritableRegion readFdsOut = context.Memory.GetWritableRegion(readFdsOutBufferPosition, (int)readFdsOutBufferSize);
|
||||
using WritableRegion writeFdsOut = context.Memory.GetWritableRegion(writeFdsOutBufferPosition, (int)writeFdsOutBufferSize);
|
||||
using WritableRegion errorFdsOut = context.Memory.GetWritableRegion(errorFdsOutBufferPosition, (int)errorFdsOutBufferSize);
|
||||
|
||||
_context.BuildMask(readFds, readFdsOut.Memory.Span);
|
||||
_context.BuildMask(writeFds, writeFdsOut.Memory.Span);
|
||||
|
||||
@@ -304,7 +304,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||
|
||||
public static bool TryConvertSocketOption(BsdSocketOption option, SocketOptionLevel level, out SocketOptionName name)
|
||||
{
|
||||
var table = level switch
|
||||
Dictionary<BsdSocketOption, SocketOptionName> table = level switch
|
||||
{
|
||||
SocketOptionLevel.Socket => _soSocketOptionMap,
|
||||
SocketOptionLevel.IP => _ipSocketOptionMap,
|
||||
@@ -323,7 +323,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
||||
|
||||
public static LinuxError ValidateSocketOption(BsdSocketOption option, SocketOptionLevel level, bool write)
|
||||
{
|
||||
var table = level switch
|
||||
Dictionary<BsdSocketOption, OptionDir> table = level switch
|
||||
{
|
||||
SocketOptionLevel.Socket => _validSoSocketOptionMap,
|
||||
SocketOptionLevel.IP => _validIpSocketOptionMap,
|
||||
|
||||
@@ -13,9 +13,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Proxy
|
||||
|
||||
public static void Select(List<ISocketImpl> readEvents, List<ISocketImpl> writeEvents, List<ISocketImpl> errorEvents, int timeout)
|
||||
{
|
||||
var readDefault = readEvents.Select(x => (x as DefaultSocket)?.BaseSocket).Where(x => x != null).ToList();
|
||||
var writeDefault = writeEvents.Select(x => (x as DefaultSocket)?.BaseSocket).Where(x => x != null).ToList();
|
||||
var errorDefault = errorEvents.Select(x => (x as DefaultSocket)?.BaseSocket).Where(x => x != null).ToList();
|
||||
List<Socket> readDefault = readEvents.Select(x => (x as DefaultSocket)?.BaseSocket).Where(x => x != null).ToList();
|
||||
List<Socket> writeDefault = writeEvents.Select(x => (x as DefaultSocket)?.BaseSocket).Where(x => x != null).ToList();
|
||||
List<Socket> errorDefault = errorEvents.Select(x => (x as DefaultSocket)?.BaseSocket).Where(x => x != null).ToList();
|
||||
|
||||
if (readDefault.Count != 0 || writeDefault.Count != 0 || errorDefault.Count != 0)
|
||||
{
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy
|
||||
|
||||
public IPHostEntry ResolveAddress(string host)
|
||||
{
|
||||
foreach (var hostEntry in _mitmHostEntries)
|
||||
foreach (KeyValuePair<string, IPAddress> hostEntry in _mitmHostEntries)
|
||||
{
|
||||
// Check for AMS hosts file extension: "*"
|
||||
// NOTE: MatchesSimpleExpression also allows "?" as a wildcard
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace Ryujinx.HLE.HOS.Services.Ssl
|
||||
|
||||
IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel);
|
||||
|
||||
using var trustedCertsFileRef = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> trustedCertsFileRef = new();
|
||||
|
||||
Result result = romfs.OpenFile(ref trustedCertsFileRef.Ref, "/ssl_TrustedCerts.bdf".ToU8Span(), OpenMode.Read);
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace Ryujinx.HLE.HOS.Services.Ssl.SslService
|
||||
ulong bufferAddress = context.Request.ReceiveBuff[0].Position;
|
||||
ulong bufferLen = context.Request.ReceiveBuff[0].Size;
|
||||
|
||||
using (var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true))
|
||||
using (WritableRegion region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true))
|
||||
{
|
||||
Encoding.ASCII.GetBytes(_hostName, region.Memory.Span);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||
Nca nca = new(_virtualFileSystem.KeySet, ncaFileStream);
|
||||
IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel);
|
||||
|
||||
using var binaryListFile = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> binaryListFile = new();
|
||||
|
||||
romfs.OpenFile(ref binaryListFile.Ref, "/binaryList.txt".ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||
|
||||
public IEnumerable<(int Offset, string Location, string Abbr)> ParseTzOffsets()
|
||||
{
|
||||
var tzBinaryContentPath = GetTimeZoneBinaryTitleContentPath();
|
||||
string tzBinaryContentPath = GetTimeZoneBinaryTitleContentPath();
|
||||
|
||||
if (string.IsNullOrEmpty(tzBinaryContentPath))
|
||||
{
|
||||
@@ -128,7 +128,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||
}
|
||||
|
||||
List<(int Offset, string Location, string Abbr)> outList = [];
|
||||
var now = DateTimeOffset.Now.ToUnixTimeSeconds();
|
||||
long now = DateTimeOffset.Now.ToUnixTimeSeconds();
|
||||
using (IStorage ncaStorage = new LocalStorage(VirtualFileSystem.SwitchPathToSystemPath(tzBinaryContentPath), FileAccess.Read, FileMode.Open))
|
||||
using (IFileSystem romfs = new Nca(_virtualFileSystem.KeySet, ncaStorage).OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel))
|
||||
{
|
||||
@@ -139,7 +139,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||
continue;
|
||||
}
|
||||
|
||||
using var tzif = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> tzif = new();
|
||||
|
||||
if (romfs.OpenFile(ref tzif.Ref, $"/zoneinfo/{locName}".ToU8Span(), OpenMode.Read).IsFailure())
|
||||
{
|
||||
@@ -176,7 +176,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||
continue;
|
||||
}
|
||||
|
||||
var abbrStart = tzRule.Chars[ttInfo.AbbreviationListIndex..];
|
||||
Span<byte> abbrStart = tzRule.Chars[ttInfo.AbbreviationListIndex..];
|
||||
int abbrEnd = abbrStart.IndexOf((byte)0);
|
||||
|
||||
outList.Add((ttInfo.GmtOffset, locName, Encoding.UTF8.GetString(abbrStart[..abbrEnd])));
|
||||
@@ -269,7 +269,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
||||
Nca nca = new(_virtualFileSystem.KeySet, ncaFile);
|
||||
IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel);
|
||||
|
||||
using var timeZoneBinaryFile = new UniqueRef<IFile>();
|
||||
using UniqueRef<IFile> timeZoneBinaryFile = new();
|
||||
|
||||
Result result = romfs.OpenFile(ref timeZoneBinaryFile.Ref, $"/zoneinfo/{locationName}".ToU8Span(), OpenMode.Read);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user