1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-12-03 20:32:02 +00:00
Ryujinx/Ryujinx.HLE/HOS/Services/Acc/IProfile.cs

89 lines
2.6 KiB
C#
Raw Normal View History

using ChocolArm64.Memory;
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.SystemState;
using Ryujinx.HLE.Utilities;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text;
namespace Ryujinx.HLE.HOS.Services.Acc
{
class IProfile : IpcService
{
2018-12-01 20:01:59 +00:00
private Dictionary<int, ServiceProcessRequest> _commands;
2018-12-01 20:01:59 +00:00
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
2018-12-01 20:01:59 +00:00
private UserProfile _profile;
2018-12-01 20:01:59 +00:00
private Stream _profilePictureStream;
2018-12-01 20:01:59 +00:00
public IProfile(UserProfile profile)
{
2018-12-01 20:01:59 +00:00
_commands = new Dictionary<int, ServiceProcessRequest>()
{
{ 0, Get },
{ 1, GetBase },
{ 10, GetImageSize },
{ 11, LoadImage },
};
2018-12-01 20:24:37 +00:00
_profile = profile;
2018-12-01 20:01:59 +00:00
_profilePictureStream = Assembly.GetCallingAssembly().GetManifestResourceStream("Ryujinx.HLE.RyujinxProfileImage.jpg");
}
2018-12-01 20:01:59 +00:00
public long Get(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAcc, "Stubbed.");
2018-12-01 20:01:59 +00:00
long position = context.Request.ReceiveBuff[0].Position;
2018-12-01 20:01:59 +00:00
MemoryHelper.FillWithZeros(context.Memory, position, 0x80);
2018-12-01 20:01:59 +00:00
context.Memory.WriteInt32(position, 0);
context.Memory.WriteInt32(position + 4, 1);
context.Memory.WriteInt64(position + 8, 1);
2018-12-01 20:01:59 +00:00
return GetBase(context);
}
2018-12-01 20:01:59 +00:00
public long GetBase(ServiceCtx context)
{
2018-12-01 20:01:59 +00:00
_profile.Uuid.Write(context.ResponseData);
2018-12-01 20:01:59 +00:00
context.ResponseData.Write(_profile.LastModifiedTimestamp);
2018-12-01 20:01:59 +00:00
byte[] username = StringUtils.GetFixedLengthBytes(_profile.Name, 0x20, Encoding.UTF8);
2018-12-01 20:01:59 +00:00
context.ResponseData.Write(username);
2018-04-24 19:57:39 +01:00
return 0;
}
2018-12-01 20:01:59 +00:00
private long LoadImage(ServiceCtx context)
{
2018-12-01 20:01:59 +00:00
long bufferPosition = context.Request.ReceiveBuff[0].Position;
long bufferLen = context.Request.ReceiveBuff[0].Size;
2018-12-01 20:01:59 +00:00
byte[] profilePictureData = new byte[bufferLen];
2018-12-01 20:01:59 +00:00
_profilePictureStream.Read(profilePictureData, 0, profilePictureData.Length);
2018-12-01 20:01:59 +00:00
context.Memory.WriteBytes(bufferPosition, profilePictureData);
2018-12-01 20:01:59 +00:00
context.ResponseData.Write(_profilePictureStream.Length);
return 0;
}
2018-12-01 20:01:59 +00:00
private long GetImageSize(ServiceCtx context)
{
2018-12-01 20:01:59 +00:00
context.ResponseData.Write(_profilePictureStream.Length);
return 0;
}
}
}