2018-10-17 14:15:50 -03:00
|
|
|
using Ryujinx.Common.Logging;
|
2020-05-03 19:54:50 -03:00
|
|
|
using Ryujinx.Cpu;
|
2018-08-16 20:47:36 -03:00
|
|
|
using Ryujinx.HLE.Utilities;
|
2018-09-02 01:04:20 +03:00
|
|
|
using System.IO;
|
|
|
|
using System.Reflection;
|
2018-08-14 03:13:01 +03:00
|
|
|
using System.Text;
|
2018-02-09 21:14:55 -03:00
|
|
|
|
2019-09-19 02:45:11 +02:00
|
|
|
namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
2018-02-09 21:14:55 -03:00
|
|
|
{
|
2018-03-19 15:58:46 -03:00
|
|
|
class IProfile : IpcService
|
2018-02-09 21:14:55 -03:00
|
|
|
{
|
2018-12-06 05:16:24 -06:00
|
|
|
private UserProfile _profile;
|
2019-07-12 03:13:43 +02:00
|
|
|
private Stream _profilePictureStream;
|
2018-09-02 01:04:20 +03:00
|
|
|
|
2018-12-06 05:16:24 -06:00
|
|
|
public IProfile(UserProfile profile)
|
2018-02-09 21:14:55 -03:00
|
|
|
{
|
2019-07-12 03:13:43 +02:00
|
|
|
_profile = profile;
|
2018-12-06 05:16:24 -06:00
|
|
|
_profilePictureStream = Assembly.GetCallingAssembly().GetManifestResourceStream("Ryujinx.HLE.RyujinxProfileImage.jpg");
|
2018-02-09 21:14:55 -03:00
|
|
|
}
|
|
|
|
|
2019-07-12 03:13:43 +02:00
|
|
|
[Command(0)]
|
|
|
|
// Get() -> (nn::account::profile::ProfileBase, buffer<nn::account::profile::UserData, 0x1a>)
|
2019-07-14 21:04:38 +02:00
|
|
|
public ResultCode Get(ServiceCtx context)
|
2018-02-09 21:14:55 -03:00
|
|
|
{
|
2020-08-04 05:02:53 +05:30
|
|
|
Logger.Stub?.PrintStub(LogClass.ServiceAcc);
|
2018-04-17 03:24:42 +03:00
|
|
|
|
2018-12-06 05:16:24 -06:00
|
|
|
long position = context.Request.ReceiveBuff[0].Position;
|
2018-08-14 03:13:01 +03:00
|
|
|
|
2018-12-06 05:16:24 -06:00
|
|
|
MemoryHelper.FillWithZeros(context.Memory, position, 0x80);
|
2018-08-14 03:13:01 +03:00
|
|
|
|
2020-05-03 19:54:50 -03:00
|
|
|
context.Memory.Write((ulong)position, 0);
|
|
|
|
context.Memory.Write((ulong)position + 4, 1);
|
|
|
|
context.Memory.Write((ulong)position + 8, 1L);
|
2018-08-14 03:13:01 +03:00
|
|
|
|
2018-12-06 05:16:24 -06:00
|
|
|
return GetBase(context);
|
2018-08-14 03:13:01 +03:00
|
|
|
}
|
|
|
|
|
2019-07-12 03:13:43 +02:00
|
|
|
[Command(1)]
|
|
|
|
// GetBase() -> nn::account::profile::ProfileBase
|
2019-07-14 21:04:38 +02:00
|
|
|
public ResultCode GetBase(ServiceCtx context)
|
2018-08-14 03:13:01 +03:00
|
|
|
{
|
2019-06-16 00:35:38 +02:00
|
|
|
_profile.UserId.Write(context.ResponseData);
|
2018-08-14 03:13:01 +03:00
|
|
|
|
2018-12-06 05:16:24 -06:00
|
|
|
context.ResponseData.Write(_profile.LastModifiedTimestamp);
|
2018-08-14 03:13:01 +03:00
|
|
|
|
2018-12-06 05:16:24 -06:00
|
|
|
byte[] username = StringUtils.GetFixedLengthBytes(_profile.Name, 0x20, Encoding.UTF8);
|
2018-08-14 03:13:01 +03:00
|
|
|
|
2018-12-06 05:16:24 -06:00
|
|
|
context.ResponseData.Write(username);
|
2018-04-24 15:57:39 -03:00
|
|
|
|
2019-07-14 21:04:38 +02:00
|
|
|
return ResultCode.Success;
|
2018-02-09 21:14:55 -03:00
|
|
|
}
|
2018-09-02 01:04:20 +03:00
|
|
|
|
2019-07-12 03:13:43 +02:00
|
|
|
[Command(10)]
|
|
|
|
// GetImageSize() -> u32
|
2019-07-14 23:22:53 +02:00
|
|
|
public ResultCode GetImageSize(ServiceCtx context)
|
2019-07-12 03:13:43 +02:00
|
|
|
{
|
|
|
|
context.ResponseData.Write(_profilePictureStream.Length);
|
|
|
|
|
2019-07-14 21:04:38 +02:00
|
|
|
return ResultCode.Success;
|
2019-07-12 03:13:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
[Command(11)]
|
|
|
|
// LoadImage() -> (u32, buffer<bytes, 6>)
|
2019-07-14 23:22:53 +02:00
|
|
|
public ResultCode LoadImage(ServiceCtx context)
|
2018-09-02 01:04:20 +03:00
|
|
|
{
|
2018-12-06 05:16:24 -06:00
|
|
|
long bufferPosition = context.Request.ReceiveBuff[0].Position;
|
|
|
|
long bufferLen = context.Request.ReceiveBuff[0].Size;
|
2018-09-02 01:04:20 +03:00
|
|
|
|
2018-12-06 05:16:24 -06:00
|
|
|
byte[] profilePictureData = new byte[bufferLen];
|
2018-09-02 01:04:20 +03:00
|
|
|
|
2018-12-06 05:16:24 -06:00
|
|
|
_profilePictureStream.Read(profilePictureData, 0, profilePictureData.Length);
|
2018-09-02 01:04:20 +03:00
|
|
|
|
2020-05-03 19:54:50 -03:00
|
|
|
context.Memory.Write((ulong)bufferPosition, profilePictureData);
|
2018-09-02 01:04:20 +03:00
|
|
|
|
2018-12-06 05:16:24 -06:00
|
|
|
context.ResponseData.Write(_profilePictureStream.Length);
|
2018-09-02 01:04:20 +03:00
|
|
|
|
2019-07-14 21:04:38 +02:00
|
|
|
return ResultCode.Success;
|
2018-09-02 01:04:20 +03:00
|
|
|
}
|
2018-02-09 21:14:55 -03:00
|
|
|
}
|
|
|
|
}
|