mirror of
https://github.com/ryujinx-mirror/ryujinx.git
synced 2024-12-27 16:39:35 +00:00
7344dee475
* account: Adds Account Manager In a way to have Custom User Profiles merged in master faster, this PR adds a `AccountManager` class (based on `AccountUtils` class) and the following changes have been made: - Adds a "default profile values" which were the old hardcoded ones. - The image profile is moved to the Account service folder. - The hardcoded UserId for the savedata is now using the `AccountManager` last opened one. - The DeviceId in Mii service is changed to the right value (checked by REd sys:set call). * Fix csproj * Addresses gdkchan's comments * Fix UserProfile fields * Fix mii GetDeviceId() * Update Ryujinx.HLE.csproj
114 lines
3.8 KiB
C#
114 lines
3.8 KiB
C#
using Ryujinx.Common.Logging;
|
|
using Ryujinx.Cpu;
|
|
using Ryujinx.HLE.Utilities;
|
|
using System.Text;
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
|
|
{
|
|
class ProfileServer
|
|
{
|
|
private UserProfile _profile;
|
|
|
|
public ProfileServer(UserProfile profile)
|
|
{
|
|
_profile = profile;
|
|
}
|
|
|
|
public ResultCode Get(ServiceCtx context)
|
|
{
|
|
context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize(0x80L);
|
|
|
|
long bufferPosition = context.Request.RecvListBuff[0].Position;
|
|
|
|
MemoryHelper.FillWithZeros(context.Memory, bufferPosition, 0x80);
|
|
|
|
// TODO: Determine the struct.
|
|
context.Memory.Write((ulong)bufferPosition, 0); // Unknown
|
|
context.Memory.Write((ulong)bufferPosition + 4, 1); // Icon ID. 0 = Mii, the rest are character icon IDs.
|
|
context.Memory.Write((ulong)bufferPosition + 8, (byte)1); // Profile icon background color ID
|
|
// 0x07 bytes - Unknown
|
|
// 0x10 bytes - Some ID related to the Mii? All zeros when a character icon is used.
|
|
// 0x60 bytes - Usually zeros?
|
|
|
|
Logger.Stub?.PrintStub(LogClass.ServiceAcc);
|
|
|
|
return GetBase(context);
|
|
}
|
|
|
|
public ResultCode GetBase(ServiceCtx context)
|
|
{
|
|
_profile.UserId.Write(context.ResponseData);
|
|
|
|
context.ResponseData.Write(_profile.LastModifiedTimestamp);
|
|
|
|
byte[] username = StringUtils.GetFixedLengthBytes(_profile.Name, 0x20, Encoding.UTF8);
|
|
|
|
context.ResponseData.Write(username);
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
public ResultCode GetImageSize(ServiceCtx context)
|
|
{
|
|
context.ResponseData.Write(_profile.Image.Length);
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
public ResultCode LoadImage(ServiceCtx context)
|
|
{
|
|
long bufferPosition = context.Request.ReceiveBuff[0].Position;
|
|
long bufferLen = context.Request.ReceiveBuff[0].Size;
|
|
|
|
if (_profile.Image.Length > bufferLen)
|
|
{
|
|
return ResultCode.InvalidBufferSize;
|
|
}
|
|
|
|
context.Memory.Write((ulong)bufferPosition, _profile.Image);
|
|
|
|
context.ResponseData.Write(_profile.Image.Length);
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
public ResultCode Store(ServiceCtx context)
|
|
{
|
|
long userDataPosition = context.Request.PtrBuff[0].Position;
|
|
long userDataSize = context.Request.PtrBuff[0].Size;
|
|
|
|
byte[] userData = new byte[userDataSize];
|
|
|
|
context.Memory.Read((ulong)userDataPosition, userData);
|
|
|
|
// TODO: Read the nn::account::profile::ProfileBase and store everything in the savedata.
|
|
|
|
Logger.Stub?.PrintStub(LogClass.ServiceAcc, new { userDataSize });
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
public ResultCode StoreWithImage(ServiceCtx context)
|
|
{
|
|
long userDataPosition = context.Request.PtrBuff[0].Position;
|
|
long userDataSize = context.Request.PtrBuff[0].Size;
|
|
|
|
byte[] userData = new byte[userDataSize];
|
|
|
|
context.Memory.Read((ulong)userDataPosition, userData);
|
|
|
|
long profileImagePosition = context.Request.SendBuff[0].Position;
|
|
long profileImageSize = context.Request.SendBuff[0].Size;
|
|
|
|
byte[] profileImageData = new byte[profileImageSize];
|
|
|
|
context.Memory.Read((ulong)profileImagePosition, profileImageData);
|
|
|
|
// TODO: Read the nn::account::profile::ProfileBase and store everything in the savedata.
|
|
|
|
Logger.Stub?.PrintStub(LogClass.ServiceAcc, new { userDataSize, profileImageSize });
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
}
|
|
} |