[Kernel] Read random device descriptors from the host RNG

Co-authored-by: Sekai <140012992+SekaixX@users.noreply.github.com>
This commit is contained in:
ParantezTech 2026-10-08 23:44:39 +03:00
parent 4d8f5a75d5
commit a662295409
1 changed files with 20 additions and 0 deletions

View File

@ -14,6 +14,7 @@ using System.Threading;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Linq; using System.Linq;
using System.Globalization; using System.Globalization;
using System.Security.Cryptography;
namespace SharpEmu.Libs.Kernel; namespace SharpEmu.Libs.Kernel;
@ -2325,6 +2326,25 @@ public static partial class KernelMemoryCompatExports
return (int)OrbisGen2Result.ORBIS_GEN2_OK; return (int)OrbisGen2Result.ORBIS_GEN2_OK;
} }
bool isRandomDevice;
lock (_fdGate)
{
isRandomDevice = _randomDeviceDescriptors.Contains(fd);
}
if (isRandomDevice)
{
var randomBytes = GC.AllocateUninitializedArray<byte>(requested);
RandomNumberGenerator.Fill(randomBytes);
if (!ctx.Memory.TryWrite(bufferAddress, randomBytes))
{
return (int)OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT;
}
ctx[CpuRegister.Rax] = unchecked((ulong)requested);
return (int)OrbisGen2Result.ORBIS_GEN2_OK;
}
if (KernelSocketCompatExports.TryReadSocketFd( if (KernelSocketCompatExports.TryReadSocketFd(
ctx, ctx,
fd, fd,