aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBerkan Diler <b.diler@gmx.de>2022-11-16 19:34:18 +0100
committerGitHub <noreply@github.com>2022-11-16 15:34:18 -0300
commit11aae9cfbc07d337c8b222e15f5d8e676f3bf46f (patch)
tree40b0ea74e3bf3b630e36896a4ad96ca71648add6
parentb96794e72b76138ee1cf36226c47554b4cf1d670 (diff)
Make use of Random.Shared (#3852)1.1.347
-rw-r--r--Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/IFriendService.cs3
-rw-r--r--Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs2
-rw-r--r--Ryujinx.HLE/HOS/Services/Prepo/IPrepoService.cs2
-rw-r--r--Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs4
4 files changed, 4 insertions, 7 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/IFriendService.cs b/Ryujinx.HLE/HOS/Services/Friend/ServiceCreator/IFriendService.cs
index 1cf03f5b..77499fa5 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 851b67a5..4e445c4f 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 3fa1182d..019626f1 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 5590bfdd..0d1ae27f 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<NrrInfo>(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;