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