0746b83edf
* Rename CommandAttribute as CommandHIpcAttribute to prepare for 12.x changes * Implement inital support for TIPC and adds SM command ids * *Ipc to *ipc * Missed a ref in last commit... * CommandAttributeTIpc to CommandAttributeTipc * Addresses comment and fixes some bugs around TIPC doesn't have any padding requirements as buffer C isn't a thing Fix for RegisterService inverting two argument only on TIPC
42 lines
1,010 B
C#
42 lines
1,010 B
C#
using System;
|
|
using System.Security.Cryptography;
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Spl
|
|
{
|
|
[Service("csrng")]
|
|
class IRandomInterface : IpcService, IDisposable
|
|
{
|
|
private RNGCryptoServiceProvider _rng;
|
|
|
|
public IRandomInterface(ServiceCtx context)
|
|
{
|
|
_rng = new RNGCryptoServiceProvider();
|
|
}
|
|
|
|
[CommandHipc(0)]
|
|
// GetRandomBytes() -> buffer<unknown, 6>
|
|
public ResultCode GetRandomBytes(ServiceCtx context)
|
|
{
|
|
byte[] randomBytes = new byte[context.Request.ReceiveBuff[0].Size];
|
|
|
|
_rng.GetBytes(randomBytes);
|
|
|
|
context.Memory.Write((ulong)context.Request.ReceiveBuff[0].Position, randomBytes);
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
Dispose(true);
|
|
}
|
|
|
|
protected virtual void Dispose(bool disposing)
|
|
{
|
|
if (disposing)
|
|
{
|
|
_rng.Dispose();
|
|
}
|
|
}
|
|
}
|
|
} |