[Kernel] Read random device descriptors from the host RNG
Co-authored-by: Sekai <140012992+SekaixX@users.noreply.github.com>
This commit is contained in:
parent
4d8f5a75d5
commit
a662295409
|
|
@ -14,6 +14,7 @@ using System.Threading;
|
|||
using System.Runtime.InteropServices;
|
||||
using System.Linq;
|
||||
using System.Globalization;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace SharpEmu.Libs.Kernel;
|
||||
|
||||
|
|
@ -2325,6 +2326,25 @@ public static partial class KernelMemoryCompatExports
|
|||
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(
|
||||
ctx,
|
||||
fd,
|
||||
|
|
|
|||
Loading…
Reference in New Issue