2020-04-30 04:58:19 +00:00
|
|
|
using LibHac;
|
2021-12-23 16:55:50 +00:00
|
|
|
using LibHac.Common;
|
2020-04-30 04:58:19 +00:00
|
|
|
using Ryujinx.Common;
|
2019-09-19 00:45:11 +00:00
|
|
|
using Ryujinx.HLE.HOS.Services.Arp;
|
2023-03-04 13:43:08 +00:00
|
|
|
using Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator;
|
2019-09-10 09:55:28 +00:00
|
|
|
|
2018-08-16 23:47:36 +00:00
|
|
|
namespace Ryujinx.HLE.HOS.Services.Bcat
|
2018-07-23 14:20:16 +00:00
|
|
|
{
|
2020-04-30 04:58:19 +00:00
|
|
|
[Service("bcat:a", "bcat:a")]
|
|
|
|
[Service("bcat:m", "bcat:m")]
|
|
|
|
[Service("bcat:u", "bcat:u")]
|
|
|
|
[Service("bcat:s", "bcat:s")]
|
2021-12-23 16:55:50 +00:00
|
|
|
class IServiceCreator : DisposableIpcService
|
2018-07-23 14:20:16 +00:00
|
|
|
{
|
2021-12-23 16:55:50 +00:00
|
|
|
private SharedRef<LibHac.Bcat.Impl.Ipc.IServiceCreator> _base;
|
2020-04-30 04:58:19 +00:00
|
|
|
|
|
|
|
public IServiceCreator(ServiceCtx context, string serviceName)
|
|
|
|
{
|
2021-08-12 21:56:24 +00:00
|
|
|
var applicationClient = context.Device.System.LibHacHorizonManager.ApplicationClient;
|
2021-12-23 16:55:50 +00:00
|
|
|
applicationClient.Sm.GetService(ref _base, serviceName).ThrowIfFailure();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
{
|
|
|
|
if (isDisposing)
|
|
|
|
{
|
|
|
|
_base.Destroy();
|
|
|
|
}
|
2020-04-30 04:58:19 +00:00
|
|
|
}
|
2018-07-23 14:20:16 +00:00
|
|
|
|
2023-04-14 23:00:34 +00:00
|
|
|
[CommandCmif(0)]
|
2020-04-30 04:58:19 +00:00
|
|
|
// CreateBcatService(pid) -> object<nn::bcat::detail::ipc::IBcatService>
|
2019-07-14 19:04:38 +00:00
|
|
|
public ResultCode CreateBcatService(ServiceCtx context)
|
2018-07-23 14:20:16 +00:00
|
|
|
{
|
2019-09-10 09:55:28 +00: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 14:20:16 +00:00
|
|
|
|
2019-09-10 09:55:28 +00:00
|
|
|
// NOTE: If the IBcatService is null this error is returned, Doesn't occur in our case.
|
|
|
|
// return ResultCode.NullObject;
|
2018-08-16 23:47:36 +00:00
|
|
|
|
2019-07-14 19:04:38 +00:00
|
|
|
return ResultCode.Success;
|
2018-07-23 14:20:16 +00:00
|
|
|
}
|
|
|
|
|
2023-04-14 23:00:34 +00:00
|
|
|
[CommandCmif(1)]
|
2020-04-30 04:58:19 +00:00
|
|
|
// CreateDeliveryCacheStorageService(pid) -> object<nn::bcat::detail::ipc::IDeliveryCacheStorageService>
|
2019-07-14 19:04:38 +00:00
|
|
|
public ResultCode CreateDeliveryCacheStorageService(ServiceCtx context)
|
2018-07-23 14:20:16 +00:00
|
|
|
{
|
2020-04-30 04:58:19 +00:00
|
|
|
ulong pid = context.RequestData.ReadUInt64();
|
2019-09-10 09:55:28 +00:00
|
|
|
|
2021-12-23 16:55:50 +00:00
|
|
|
using var serv = new SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService>();
|
|
|
|
|
2023-03-02 02:42:27 +00:00
|
|
|
Result rc = _base.Get.CreateDeliveryCacheStorageService(ref serv.Ref, pid);
|
2018-07-23 14:20:16 +00:00
|
|
|
|
2020-04-30 04:58:19 +00:00
|
|
|
if (rc.IsSuccess())
|
|
|
|
{
|
2023-03-02 02:42:27 +00:00
|
|
|
MakeObject(context, new IDeliveryCacheStorageService(context, ref serv.Ref));
|
2020-04-30 04:58:19 +00:00
|
|
|
}
|
2018-07-23 14:20:16 +00:00
|
|
|
|
2020-04-30 04:58:19 +00:00
|
|
|
return (ResultCode)rc.Value;
|
|
|
|
}
|
|
|
|
|
2023-04-14 23:00:34 +00:00
|
|
|
[CommandCmif(2)]
|
2020-04-30 04:58:19 +00:00
|
|
|
// CreateDeliveryCacheStorageServiceWithApplicationId(nn::ApplicationId) -> object<nn::bcat::detail::ipc::IDeliveryCacheStorageService>
|
|
|
|
public ResultCode CreateDeliveryCacheStorageServiceWithApplicationId(ServiceCtx context)
|
|
|
|
{
|
|
|
|
ApplicationId applicationId = context.RequestData.ReadStruct<ApplicationId>();
|
|
|
|
|
2021-12-23 16:55:50 +00:00
|
|
|
using var service = new SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService>();
|
|
|
|
|
2023-03-02 02:42:27 +00:00
|
|
|
Result rc = _base.Get.CreateDeliveryCacheStorageServiceWithApplicationId(ref service.Ref, applicationId);
|
2020-04-30 04:58:19 +00:00
|
|
|
|
|
|
|
if (rc.IsSuccess())
|
|
|
|
{
|
2023-03-02 02:42:27 +00:00
|
|
|
MakeObject(context, new IDeliveryCacheStorageService(context, ref service.Ref));
|
2020-04-30 04:58:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (ResultCode)rc.Value;
|
2018-07-23 14:20:16 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-30 04:58:19 +00:00
|
|
|
}
|