diff --git a/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/IFriendService.cs b/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/IFriendService.cs index 1cf03f5bc9..77499fa53a 100644 --- a/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/IFriendService.cs +++ b/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/IFriendService.cs @@ -266,9 +266,8 @@ namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator // NOTE: Calls nn::friends::detail::service::core::PlayHistoryManager::GetInstance and stores the instance. byte[] randomBytes = new byte[8]; - Random random = new Random(); - random.NextBytes(randomBytes); + Random.Shared.NextBytes(randomBytes); // NOTE: Calls nn::friends::detail::service::core::UuidManager::GetInstance and stores the instance. // Then call nn::friends::detail::service::core::AccountStorageManager::GetInstance and store the instance. diff --git a/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs b/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs index 851b67a5b7..4e445c4fcd 100644 --- a/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs +++ b/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs @@ -40,7 +40,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp { byte[] uuid = new byte[9]; - new Random().NextBytes(uuid); + Random.Shared.NextBytes(uuid); uuid[3] = (byte)(0x88 ^ uuid[0] ^ uuid[1] ^ uuid[2]); uuid[8] = (byte)(uuid[3] ^ uuid[4] ^ uuid[5] ^ uuid[6]); diff --git a/Ryujinx.HLE/HOS/Services/Prepo/IPrepoService.cs b/Ryujinx.HLE/HOS/Services/Prepo/IPrepoService.cs index 3fa1182db6..019626f1b5 100644 --- a/Ryujinx.HLE/HOS/Services/Prepo/IPrepoService.cs +++ b/Ryujinx.HLE/HOS/Services/Prepo/IPrepoService.cs @@ -89,7 +89,7 @@ namespace Ryujinx.HLE.HOS.Services.Prepo { byte[] randomBuffer = new byte[8]; - new Random().NextBytes(randomBuffer); + Random.Shared.NextBytes(randomBuffer); _systemSessionId = BitConverter.ToUInt64(randomBuffer, 0); } diff --git a/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs b/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs index 5590bfddf4..0d1ae27f25 100644 --- a/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs +++ b/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs @@ -32,8 +32,6 @@ namespace Ryujinx.HLE.HOS.Services.Ro private KProcess _owner; private IVirtualMemoryManager _ownerMm; - private static Random _random = new Random(); - public IRoInterface(ServiceCtx context) { _nrrInfos = new List(MaxNrr); @@ -283,7 +281,7 @@ namespace Ryujinx.HLE.HOS.Services.Ro { while (true) { - ulong randomOffset = (ulong)(uint)_random.Next(0, (int)addressSpacePageLimit) << 12; + ulong randomOffset = (ulong)(uint)Random.Shared.Next(0, (int)addressSpacePageLimit) << 12; targetAddress = memMgr.GetAddrSpaceBaseAddr() + randomOffset;