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