2020-04-30 00:58:19 -04:00
|
|
|
using LibHac;
|
|
|
|
using Ryujinx.Common;
|
2019-09-18 20:45:11 -04:00
|
|
|
using Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator;
|
|
|
|
using Ryujinx.HLE.HOS.Services.Arp;
|
2019-09-10 05:55:28 -04:00
|
|
|
|
2018-08-16 19:47:36 -04:00
|
|
|
namespace Ryujinx.HLE.HOS.Services.Bcat
|
2018-07-23 10:20:16 -04:00
|
|
|
{
|
2020-04-30 00:58:19 -04:00
|
|
|
[Service("bcat:a", "bcat:a")]
|
|
|
|
[Service("bcat:m", "bcat:m")]
|
|
|
|
[Service("bcat:u", "bcat:u")]
|
|
|
|
[Service("bcat:s", "bcat:s")]
|
2018-07-23 10:20:16 -04:00
|
|
|
class IServiceCreator : IpcService
|
|
|
|
{
|
2021-07-13 10:48:54 -04:00
|
|
|
private LibHac.Bcat.Detail.Ipc.IServiceCreator _base;
|
2020-04-30 00:58:19 -04:00
|
|
|
|
|
|
|
public IServiceCreator(ServiceCtx context, string serviceName)
|
|
|
|
{
|
2021-07-13 10:48:54 -04:00
|
|
|
context.Device.System.LibHacHorizonClient.Sm.GetService(out _base, serviceName).ThrowIfFailure();
|
2020-04-30 00:58:19 -04:00
|
|
|
}
|
2018-07-23 10:20:16 -04:00
|
|
|
|
2021-04-13 18:01:24 -04:00
|
|
|
[CommandHipc(0)]
|
2020-04-30 00:58:19 -04:00
|
|
|
// CreateBcatService(pid) -> object<nn::bcat::detail::ipc::IBcatService>
|
2019-07-14 15:04:38 -04:00
|
|
|
public ResultCode CreateBcatService(ServiceCtx context)
|
2018-07-23 10:20:16 -04:00
|
|
|
{
|
2019-09-10 05:55:28 -04:00
|
|
|
// TODO: Call arp:r GetApplicationLaunchProperty with the pid to get the TitleId.
|
|
|
|
// Add an instance of nn::bcat::detail::service::core::PassphraseManager.
|
|
|
|
// Add an instance of nn::bcat::detail::service::ServiceMemoryManager.
|
|
|
|
// Add an instance of nn::bcat::detail::service::core::TaskManager who load "bcat-sys:/" system save data and open "dc/task.bin".
|
|
|
|
// If the file don't exist, create a new one (size of 0x800) and write 2 empty struct with a size of 0x400.
|
|
|
|
|
|
|
|
MakeObject(context, new IBcatService(ApplicationLaunchProperty.GetByPid(context)));
|
2018-07-23 10:20:16 -04:00
|
|
|
|
2019-09-10 05:55:28 -04:00
|
|
|
// NOTE: If the IBcatService is null this error is returned, Doesn't occur in our case.
|
|
|
|
// return ResultCode.NullObject;
|
2018-08-16 19:47:36 -04:00
|
|
|
|
2019-07-14 15:04:38 -04:00
|
|
|
return ResultCode.Success;
|
2018-07-23 10:20:16 -04:00
|
|
|
}
|
|
|
|
|
2021-04-13 18:01:24 -04:00
|
|
|
[CommandHipc(1)]
|
2020-04-30 00:58:19 -04:00
|
|
|
// CreateDeliveryCacheStorageService(pid) -> object<nn::bcat::detail::ipc::IDeliveryCacheStorageService>
|
2019-07-14 15:04:38 -04:00
|
|
|
public ResultCode CreateDeliveryCacheStorageService(ServiceCtx context)
|
2018-07-23 10:20:16 -04:00
|
|
|
{
|
2020-04-30 00:58:19 -04:00
|
|
|
ulong pid = context.RequestData.ReadUInt64();
|
2019-09-10 05:55:28 -04:00
|
|
|
|
2021-07-13 10:48:54 -04:00
|
|
|
Result rc = _base.CreateDeliveryCacheStorageService(out LibHac.Bcat.Detail.Ipc.IDeliveryCacheStorageService serv, pid);
|
2018-07-23 10:20:16 -04:00
|
|
|
|
2020-04-30 00:58:19 -04:00
|
|
|
if (rc.IsSuccess())
|
|
|
|
{
|
|
|
|
MakeObject(context, new IDeliveryCacheStorageService(context, serv));
|
|
|
|
}
|
2018-07-23 10:20:16 -04:00
|
|
|
|
2020-04-30 00:58:19 -04:00
|
|
|
return (ResultCode)rc.Value;
|
|
|
|
}
|
|
|
|
|
2021-04-13 18:01:24 -04:00
|
|
|
[CommandHipc(2)]
|
2020-04-30 00:58:19 -04:00
|
|
|
// CreateDeliveryCacheStorageServiceWithApplicationId(nn::ApplicationId) -> object<nn::bcat::detail::ipc::IDeliveryCacheStorageService>
|
|
|
|
public ResultCode CreateDeliveryCacheStorageServiceWithApplicationId(ServiceCtx context)
|
|
|
|
{
|
|
|
|
ApplicationId applicationId = context.RequestData.ReadStruct<ApplicationId>();
|
|
|
|
|
2021-07-13 10:48:54 -04:00
|
|
|
Result rc = _base.CreateDeliveryCacheStorageServiceWithApplicationId(out LibHac.Bcat.Detail.Ipc.IDeliveryCacheStorageService serv,
|
2020-04-30 00:58:19 -04:00
|
|
|
applicationId);
|
|
|
|
|
|
|
|
if (rc.IsSuccess())
|
|
|
|
{
|
|
|
|
MakeObject(context, new IDeliveryCacheStorageService(context, serv));
|
|
|
|
}
|
|
|
|
|
|
|
|
return (ResultCode)rc.Value;
|
2018-07-23 10:20:16 -04:00
|
|
|
}
|
|
|
|
}
|
2020-04-30 00:58:19 -04:00
|
|
|
}
|