sf: finish conversion of libstrat to new definitions

This commit is contained in:
Michael Scire 2020-07-06 19:41:04 -07:00
parent 379bddf6d1
commit dd432f33e8
40 changed files with 498 additions and 413 deletions

View file

@ -127,23 +127,21 @@ namespace ams::sf::cmif {
}
};
template<typename T>
template<typename T> requires sf::IsServiceObject<T>
struct ServiceDispatchTraits {
static_assert(std::is_base_of<sf::IServiceObject, T>::value, "ServiceObjects must derive from sf::IServiceObject");
using ProcessHandlerType = decltype(ServiceDispatchMeta::ProcessHandler);
static constexpr inline auto DispatchTable = T::template s_CmifServiceDispatchTable<T>;
using DispatchTableType = decltype(DispatchTable);
static constexpr ProcessHandlerType ProcessHandlerImpl = ServiceObjectTraits<T>::IsMitmServiceObject ? (&impl::ServiceDispatchTableBase::ProcessMessageForMitm<DispatchTableType>)
: (&impl::ServiceDispatchTableBase::ProcessMessage<DispatchTableType>);
static constexpr ProcessHandlerType ProcessHandlerImpl = sf::IsMitmServiceObject<T> ? (&impl::ServiceDispatchTableBase::ProcessMessageForMitm<DispatchTableType>)
: (&impl::ServiceDispatchTableBase::ProcessMessage<DispatchTableType>);
static constexpr inline ServiceDispatchMeta Meta{&DispatchTable, ProcessHandlerImpl};
};
template<typename T>
NX_CONSTEXPR const ServiceDispatchMeta *GetServiceDispatchMeta() {
constexpr ALWAYS_INLINE const ServiceDispatchMeta *GetServiceDispatchMeta() {
return &ServiceDispatchTraits<T>::Meta;
}

View file

@ -69,12 +69,12 @@ namespace ams::sf::hipc {
virtual void CreateSessionObjectHolder(cmif::ServiceObjectHolder *out_obj, std::shared_ptr<::Service> *out_fsrv) const = 0;
};
template<typename ServiceImpl, auto MakeShared = std::make_shared<ServiceImpl>>
template<typename Interface, auto MakeShared>
class Server : public ServerBase {
NON_COPYABLE(Server);
NON_MOVEABLE(Server);
private:
static constexpr bool IsMitmServer = ServiceObjectTraits<ServiceImpl>::IsMitmServiceObject;
static constexpr bool IsMitmServer = sf::IsMitmServiceObject<Interface>;
public:
Server(Handle ph, sm::ServiceName sn, bool m, cmif::ServiceObjectHolder &&sh) : ServerBase(ph, sn, m, std::forward<cmif::ServiceObjectHolder>(sh)) {
/* ... */
@ -145,14 +145,14 @@ namespace ams::sf::hipc {
void ProcessDeferredSessions();
template<typename ServiceImpl, auto MakeShared = std::make_shared<ServiceImpl>>
template<typename Interface, auto MakeShared>
void RegisterServerImpl(Handle port_handle, sm::ServiceName service_name, bool managed, cmif::ServiceObjectHolder &&static_holder) {
/* Allocate server memory. */
auto *server = this->AllocateServer();
AMS_ABORT_UNLESS(server != nullptr);
new (server) Server<ServiceImpl, MakeShared>(port_handle, service_name, managed, std::forward<cmif::ServiceObjectHolder>(static_holder));
new (server) Server<Interface, MakeShared>(port_handle, service_name, managed, std::forward<cmif::ServiceObjectHolder>(static_holder));
if constexpr (!ServiceObjectTraits<ServiceImpl>::IsMitmServiceObject) {
if constexpr (!sf::IsMitmServiceObject<Interface>) {
/* Non-mitm server. */
os::SetWaitableHolderUserData(server, static_cast<uintptr_t>(UserDataTag::Server));
} else {
@ -163,9 +163,9 @@ namespace ams::sf::hipc {
os::LinkWaitableHolder(std::addressof(this->waitable_manager), server);
}
template<typename ServiceImpl>
static constexpr inline std::shared_ptr<ServiceImpl> MakeSharedMitm(std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &client_info) {
return std::make_shared<ServiceImpl>(std::forward<std::shared_ptr<::Service>>(s), client_info);
template<typename Interface, typename ServiceImpl>
static constexpr inline std::shared_ptr<Service> MakeSharedMitm(std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &client_info) {
return sf::MakeShared<Interface, ServiceImpl>(std::forward<std::shared_ptr<::Service>>(s), client_info);
}
Result InstallMitmServerImpl(Handle *out_port_handle, sm::ServiceName service_name, MitmQueryFunction query_func);
@ -187,21 +187,18 @@ namespace ams::sf::hipc {
os::InitializeWaitableManager(std::addressof(this->waitlist));
}
template<typename ServiceImpl, auto MakeShared = std::make_shared<ServiceImpl>>
void RegisterServer(Handle port_handle, std::shared_ptr<ServiceImpl> static_object = nullptr) {
static_assert(!ServiceObjectTraits<ServiceImpl>::IsMitmServiceObject, "RegisterServer requires non-mitm object. Use RegisterMitmServer instead.");
template<typename Interface, typename ServiceImpl, auto MakeShared = sf::MakeShared<Interface, ServiceImpl>> requires (sf::IsServiceObject<Interface> && !sf::IsMitmServiceObject<Interface>)
void RegisterServer(Handle port_handle, std::shared_ptr<Interface> static_object = nullptr) {
/* Register server. */
cmif::ServiceObjectHolder static_holder;
if (static_object != nullptr) {
static_holder = cmif::ServiceObjectHolder(std::move(static_object));
}
this->RegisterServerImpl<ServiceImpl, MakeShared>(port_handle, sm::InvalidServiceName, false, std::move(static_holder));
this->RegisterServerImpl<Interface, MakeShared>(port_handle, sm::InvalidServiceName, false, std::move(static_holder));
}
template<typename ServiceImpl, auto MakeShared = std::make_shared<ServiceImpl>>
Result RegisterServer(sm::ServiceName service_name, size_t max_sessions, std::shared_ptr<ServiceImpl> static_object = nullptr) {
static_assert(!ServiceObjectTraits<ServiceImpl>::IsMitmServiceObject, "RegisterServer requires non-mitm object. Use RegisterMitmServer instead.");
template<typename Interface, typename ServiceImpl, auto MakeShared = sf::MakeShared<Interface, ServiceImpl>> requires (sf::IsServiceObject<Interface> && !sf::IsMitmServiceObject<Interface>)
Result RegisterServer(sm::ServiceName service_name, size_t max_sessions, std::shared_ptr<Interface> static_object = nullptr) {
/* Register service. */
Handle port_handle;
R_TRY(sm::RegisterService(&port_handle, service_name, max_sessions, false));
@ -211,19 +208,17 @@ namespace ams::sf::hipc {
if (static_object != nullptr) {
static_holder = cmif::ServiceObjectHolder(std::move(static_object));
}
this->RegisterServerImpl<ServiceImpl, MakeShared>(port_handle, service_name, true, std::move(static_holder));
this->RegisterServerImpl<Interface, MakeShared>(port_handle, service_name, true, std::move(static_holder));
return ResultSuccess();
}
template<typename ServiceImpl, auto MakeShared = MakeSharedMitm<ServiceImpl>>
template<typename Interface, typename ServiceImpl, auto MakeShared = MakeSharedMitm<Interface, ServiceImpl>> requires (sf::IsMitmServiceObject<Interface>)
Result RegisterMitmServer(sm::ServiceName service_name) {
static_assert(ServiceObjectTraits<ServiceImpl>::IsMitmServiceObject, "RegisterMitmServer requires mitm object. Use RegisterServer instead.");
/* Install mitm service. */
Handle port_handle;
R_TRY(this->InstallMitmServerImpl(&port_handle, service_name, &ServiceImpl::ShouldMitm));
this->RegisterServerImpl<ServiceImpl, MakeShared>(port_handle, service_name, true, cmif::ServiceObjectHolder());
this->RegisterServerImpl<Interface, MakeShared>(port_handle, service_name, true, cmif::ServiceObjectHolder());
return ResultSuccess();
}

View file

@ -126,13 +126,21 @@ namespace ams::sf::impl {
return this->impl.NAME(std::forward<Arguments>(args)...); \
}
#define AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_IMPL_PTR(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \
template<typename ...Arguments> \
requires (std::same_as<std::tuple<Arguments...>, AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)> && \
std::same_as<RETURN, decltype(impl->NAME(std::declval<Arguments>()...))>) \
RETURN NAME (Arguments &&... args) { \
return this->impl->NAME(std::forward<Arguments>(args)...); \
}
#define AMS_SF_IMPL_DEFINE_INTERFACE_IMPL_FUNCTION_POINTER_HOLDER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \
template<typename A> struct NAME##FunctionPointerHolder; \
\
template<typename ...Arguments> \
requires std::same_as<std::tuple<Arguments...>, AMS_SF_IMPL_HELPER_FUNCTION_ARGS(CLASSNAME, NAME)> \
struct NAME##FunctionPointerHolder<std::tuple<Arguments...>> { \
static constexpr auto Value = static_cast<AMS_SF_IMPL_FUNCTION_POINTER_TYPE(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX)>(&ImplHolder::NAME##Invoker<Arguments...>); \
static constexpr auto Value = static_cast<AMS_SF_IMPL_FUNCTION_POINTER_TYPE(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX)>(&NAME##Invoker<Arguments...>); \
};
#define AMS_SF_IMPL_DEFINE_INTERFACE_SERVICE_COMMAND_META_HOLDER(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, VERSION_MIN, VERSION_MAX) \
@ -185,6 +193,8 @@ namespace ams::sf::impl {
{ \
/* ... */ \
} \
ALWAYS_INLINE T &GetImpl() { return this->impl; } \
ALWAYS_INLINE const T &GetImpl() const { return this->impl; } \
private: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_INVOKER) \
public: \
@ -198,6 +208,29 @@ namespace ams::sf::impl {
}; \
static_assert(Is##CLASSNAME<ImplHolder>); \
\
class ImplPointer : public S { \
private: \
T *impl; \
public: \
constexpr ImplPointer(T *t) \
: S(std::addressof(CommandPointerTableImpl)), impl(t) \
{ \
/* ... */ \
} \
ALWAYS_INLINE T &GetImpl() { return *this->impl; } \
ALWAYS_INLINE const T &GetImpl() const { return *this->impl; } \
private: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_INVOKER) \
public: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DECLARE_INTERFACE_FUNCTION_IMPL_PTR) \
private: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_INTERFACE_IMPL_FUNCTION_POINTER_HOLDER) \
public: \
static constexpr CommandPointerTable CommandPointerTableImpl = { \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_INTERFACE_COMMAND_POINTER_TABLE_MEMBER) \
}; \
}; \
static_assert(Is##CLASSNAME<ImplHolder>); \
}; \
private: \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_INTERFACE_SERVICE_COMMAND_META_HOLDER) \
@ -205,6 +238,9 @@ namespace ams::sf::impl {
template<typename T> requires (!std::same_as<CLASSNAME, T>&& Is##CLASSNAME<T>) \
using ImplHolder = typename ImplGenerator<CLASSNAME, T>::ImplHolder; \
\
template<typename T> requires (!std::same_as<CLASSNAME, T>&& Is##CLASSNAME<T>) \
using ImplPointer = typename ImplGenerator<CLASSNAME, T>::ImplPointer; \
\
AMS_SF_CMIF_IMPL_DEFINE_SERVICE_DISPATCH_TABLE { \
CMD_MACRO(CLASSNAME, AMS_SF_IMPL_DEFINE_CMIF_SERVICE_COMMAND_META_TABLE_ENTRY) \
}; \

View file

@ -25,6 +25,9 @@ namespace ams::sf {
virtual ~IServiceObject() { /* ... */ }
};
template<typename T>
concept IsServiceObject = std::derived_from<T, IServiceObject>;
class IMitmServiceObject : public IServiceObject {
protected:
std::shared_ptr<::Service> forward_service;
@ -37,26 +40,25 @@ namespace ams::sf {
static bool ShouldMitm(os::ProcessId process_id, ncm::ProgramId program_id);
};
template<typename T>
concept IsMitmServiceObject = IsServiceObject<T> && std::derived_from<T, IMitmServiceObject>;
/* Utility. */
#define AMS_SF_MITM_SERVICE_OBJECT_CTOR(cls) cls(std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &c) : ::ams::sf::IMitmServiceObject(std::forward<std::shared_ptr<::Service>>(s), c)
template<typename T>
struct ServiceObjectTraits {
static_assert(std::is_base_of<ams::sf::IServiceObject, T>::value, "ServiceObjectTraits requires ServiceObject");
static constexpr bool IsMitmServiceObject = std::is_base_of<IMitmServiceObject, T>::value;
struct SharedPointerHelper {
static constexpr void EmptyDelete(T *) { /* Empty deleter, for fake shared pointer. */ }
static constexpr std::shared_ptr<T> GetEmptyDeleteSharedPointer(T *srv_obj) {
return std::shared_ptr<T>(srv_obj, EmptyDelete);
}
};
};
template<typename Interface, typename Impl, typename... Arguments> requires std::constructible_from<Impl, Arguments...>
constexpr ALWAYS_INLINE std::shared_ptr<typename Interface::ImplHolder<Impl>> MakeShared(Arguments &&... args) {
return std::make_shared<typename Interface::ImplHolder<Impl>>(std::forward<Arguments>(args)...);
}
template<typename Interface, typename Impl>
constexpr ALWAYS_INLINE std::shared_ptr<typename Interface::ImplPointer<Impl>> GetSharedPointerTo(Impl *impl) {
return std::make_shared<typename Interface::ImplPointer<Impl>>(impl);
}
template<typename Interface, typename Impl>
constexpr ALWAYS_INLINE std::shared_ptr<typename Interface::ImplPointer<Impl>> GetSharedPointerTo(Impl &impl) {
return GetSharedPointerTo<Interface, Impl>(std::addressof(impl));
}
}

View file

@ -24,7 +24,7 @@ namespace ams::capsrv::server {
this->server_manager_holder.emplace();
/* Register the service. */
R_ABORT_UNLESS(this->server_manager_holder->RegisterServer<Service>(ServiceName, MaxSessions, sf::ServiceObjectTraits<Service>::SharedPointerHelper::GetEmptyDeleteSharedPointer(std::addressof(*this->service_holder))));
R_ABORT_UNLESS((this->server_manager_holder->RegisterServer<Interface, Service>(ServiceName, MaxSessions, sf::GetSharedPointerTo<Interface>(*this->service_holder))));
/* Initialize the idle event, we're idle initially. */
os::InitializeEvent(std::addressof(this->idle_event), true, os::EventClearMode_ManualClear);

View file

@ -26,6 +26,7 @@ namespace ams::capsrv::server {
static constexpr inline size_t MaxSessions = 2;
static constexpr inline sm::ServiceName ServiceName = sm::ServiceName::Encode("caps:dc");
using Interface = IDecoderControlService;
using Service = DecoderControlService;
using ServerOptions = sf::hipc::DefaultServerManagerOptions;
using ServerManager = sf::hipc::ServerManager<NumServers, ServerOptions, MaxSessions>;

View file

@ -18,17 +18,15 @@
namespace ams::capsrv::server {
class DecoderControlService final : public sf::IServiceObject {
protected:
enum class CommandId {
DecodeJpeg = 3001,
};
#define AMS_CAPSRV_DECODER_CONTROL_SERVICE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 3001, Result, DecodeJpeg, (const sf::OutNonSecureBuffer &out, const sf::InBuffer &in, u32 width, u32 height, const ScreenShotDecodeOption &option))
AMS_SF_DEFINE_INTERFACE(IDecoderControlService, AMS_CAPSRV_DECODER_CONTROL_SERVICE_INTERFACE_INFO)
class DecoderControlService final {
public:
/* Actual commands. */
virtual Result DecodeJpeg(const sf::OutNonSecureBuffer &out, const sf::InBuffer &in, u32 width, u32 height, const ScreenShotDecodeOption &option);
public:
DEFINE_SERVICE_DISPATCH_TABLE {
MAKE_SERVICE_COMMAND_META(DecodeJpeg)
};
Result DecodeJpeg(const sf::OutNonSecureBuffer &out, const sf::InBuffer &in, u32 width, u32 height, const ScreenShotDecodeOption &option);
};
static_assert(IsIDecoderControlService<DecoderControlService>);
}

View file

@ -20,19 +20,20 @@ namespace ams::erpt::srv {
class Attachment;
class AttachmentImpl final : public erpt::sf::IAttachment {
class AttachmentImpl final {
private:
Attachment *attachment;
public:
AttachmentImpl();
~AttachmentImpl();
public:
virtual Result Open(const AttachmentId &attachment_id) override final;
virtual Result Read(ams::sf::Out<u32> out_count, const ams::sf::OutBuffer &out_buffer) override final;
virtual Result SetFlags(AttachmentFlagSet flags) override final;
virtual Result GetFlags(ams::sf::Out<AttachmentFlagSet> out) override final;
virtual Result Close() override final;
virtual Result GetSize(ams::sf::Out<s64> out) override final;
Result Open(const AttachmentId &attachment_id);
Result Read(ams::sf::Out<u32> out_count, const ams::sf::OutBuffer &out_buffer);
Result SetFlags(AttachmentFlagSet flags);
Result GetFlags(ams::sf::Out<AttachmentFlagSet> out);
Result Close();
Result GetSize(ams::sf::Out<s64> out);
};
static_assert(erpt::sf::IsIAttachment<AttachmentImpl>);
}

View file

@ -18,19 +18,20 @@
namespace ams::erpt::srv {
class ContextImpl final : public erpt::sf::IContext {
class ContextImpl final {
public:
virtual Result SubmitContext(const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &data_buffer) override final;
virtual Result CreateReport(ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &data_buffer, const ams::sf::InBuffer &meta_buffer) override final;
virtual Result SetInitialLaunchSettingsCompletionTime(const time::SteadyClockTimePoint &time_point) override final;
virtual Result ClearInitialLaunchSettingsCompletionTime() override final;
virtual Result UpdatePowerOnTime() override final;
virtual Result UpdateAwakeTime() override final;
virtual Result SubmitMultipleCategoryContext(const MultipleCategoryContextEntry &ctx_entry, const ams::sf::InBuffer &str_buffer) override final;
virtual Result UpdateApplicationLaunchTime() override final;
virtual Result ClearApplicationLaunchTime() override final;
virtual Result SubmitAttachment(ams::sf::Out<AttachmentId> out, const ams::sf::InBuffer &attachment_name, const ams::sf::InBuffer &attachment_data) override final;
virtual Result CreateReportWithAttachments(ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &data_buffer, const ams::sf::InBuffer &attachment_ids_buffer) override final;
Result SubmitContext(const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &data_buffer);
Result CreateReport(ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &data_buffer, const ams::sf::InBuffer &meta_buffer);
Result SetInitialLaunchSettingsCompletionTime(const time::SteadyClockTimePoint &time_point);
Result ClearInitialLaunchSettingsCompletionTime();
Result UpdatePowerOnTime();
Result UpdateAwakeTime();
Result SubmitMultipleCategoryContext(const MultipleCategoryContextEntry &ctx_entry, const ams::sf::InBuffer &str_buffer);
Result UpdateApplicationLaunchTime();
Result ClearApplicationLaunchTime();
Result SubmitAttachment(ams::sf::Out<AttachmentId> out, const ams::sf::InBuffer &attachment_name, const ams::sf::InBuffer &attachment_data);
Result CreateReportWithAttachments(ReportType report_type, const ams::sf::InBuffer &ctx_buffer, const ams::sf::InBuffer &data_buffer, const ams::sf::InBuffer &attachment_ids_buffer);
};
static_assert(erpt::sf::IsIContext<ContextImpl>);
}

View file

@ -18,7 +18,7 @@
namespace ams::erpt::srv {
class ManagerImpl final : public erpt::sf::IManager, public util::IntrusiveListBaseNode<ManagerImpl> {
class ManagerImpl final : public util::IntrusiveListBaseNode<ManagerImpl> {
private:
os::SystemEvent system_event;
public:
@ -29,12 +29,13 @@ namespace ams::erpt::srv {
public:
static Result NotifyAll();
public:
virtual Result GetReportList(const ams::sf::OutBuffer &out_list, ReportType type_filter) override final;
virtual Result GetEvent(ams::sf::OutCopyHandle out) override final;
virtual Result CleanupReports() override final;
virtual Result DeleteReport(const ReportId &report_id) override final;
virtual Result GetStorageUsageStatistics(ams::sf::Out<StorageUsageStatistics> out) override final;
virtual Result GetAttachmentList(const ams::sf::OutBuffer &out_buf, const ReportId &report_id) override final;
Result GetReportList(const ams::sf::OutBuffer &out_list, ReportType type_filter);
Result GetEvent(ams::sf::OutCopyHandle out);
Result CleanupReports();
Result DeleteReport(const ReportId &report_id);
Result GetStorageUsageStatistics(ams::sf::Out<StorageUsageStatistics> out);
Result GetAttachmentList(const ams::sf::OutBuffer &out_buf, const ReportId &report_id);
};
static_assert(erpt::sf::IsIManager<ManagerImpl>);
}

View file

@ -20,19 +20,20 @@ namespace ams::erpt::srv {
class Report;
class ReportImpl final : public erpt::sf::IReport {
class ReportImpl final {
private:
Report *report;
public:
ReportImpl();
~ReportImpl();
public:
virtual Result Open(const ReportId &report_id) override final;
virtual Result Read(ams::sf::Out<u32> out_count, const ams::sf::OutBuffer &out_buffer) override final;
virtual Result SetFlags(ReportFlagSet flags) override final;
virtual Result GetFlags(ams::sf::Out<ReportFlagSet> out) override final;
virtual Result Close() override final;
virtual Result GetSize(ams::sf::Out<s64> out) override final;
Result Open(const ReportId &report_id);
Result Read(ams::sf::Out<u32> out_count, const ams::sf::OutBuffer &out_buffer);
Result SetFlags(ReportFlagSet flags);
Result GetFlags(ams::sf::Out<ReportFlagSet> out);
Result Close();
Result GetSize(ams::sf::Out<s64> out);
};
static_assert(erpt::sf::IsIReport<ReportImpl>);
}

View file

@ -42,7 +42,7 @@ namespace ams::erpt::srv {
class ErrorReportServiceManager : public ams::sf::hipc::ServerManager<ErrorReportNumServers, ErrorReportServerOptions, ErrorReportMaxSessions> {
private:
os::ThreadType thread;
std::shared_ptr<erpt::srv::ContextImpl> context_session_object;
std::shared_ptr<erpt::sf::IContext> context_session_object;
private:
static void ThreadFunction(void *_this) {
reinterpret_cast<ErrorReportServiceManager *>(_this)->SetupAndLoopProcess();
@ -51,14 +51,14 @@ namespace ams::erpt::srv {
void SetupAndLoopProcess();
public:
ErrorReportServiceManager(erpt::srv::ContextImpl *c)
: context_session_object(ams::sf::ServiceObjectTraits<erpt::srv::ContextImpl>::SharedPointerHelper::GetEmptyDeleteSharedPointer(c))
: context_session_object(ams::sf::GetSharedPointerTo<erpt::sf::IContext, erpt::srv::ContextImpl>(c))
{
/* ... */
}
Result Initialize() {
R_ABORT_UNLESS(this->RegisterServer<erpt::srv::ContextImpl>(ErrorReportContextServiceName, ErrorReportContextSessions, this->context_session_object));
R_ABORT_UNLESS(this->RegisterServer<erpt::srv::SessionImpl>(ErrorReportReportServiceName, ErrorReportReportSessions));
R_ABORT_UNLESS((this->RegisterServer<erpt::sf::IContext, erpt::srv::ContextImpl>(ErrorReportContextServiceName, ErrorReportContextSessions, this->context_session_object)));
R_ABORT_UNLESS((this->RegisterServer<erpt::sf::ISession, erpt::srv::SessionImpl>(ErrorReportReportServiceName, ErrorReportReportSessions)));
this->ResumeProcessing();
@ -117,7 +117,7 @@ namespace ams::erpt::srv {
}
}
erpt::srv::ContextImpl g_context_object;
constinit erpt::srv::ContextImpl g_context_object;
ErrorReportServiceManager g_erpt_server_manager(std::addressof(g_context_object));
}

View file

@ -21,34 +21,34 @@
namespace ams::erpt::srv {
Result SessionImpl::OpenReport(ams::sf::Out<std::shared_ptr<erpt::sf::IReport>> out) {
/* Create an interface. */
auto intf = std::shared_ptr<ReportImpl>(new (std::nothrow) ReportImpl);
R_UNLESS(intf != nullptr, erpt::ResultOutOfMemory());
namespace {
/* Return it. */
out.SetValue(std::move(intf));
return ResultSuccess();
template<typename Interface, typename Impl>
ALWAYS_INLINE Result OpenInterface(ams::sf::Out<std::shared_ptr<Interface>> &out) {
/* Define holder type. */
using Holder = typename Interface::ImplHolder<Impl>;
/* Create an interface holder. */
auto intf = std::shared_ptr<Holder>(new (std::nothrow) Holder);
R_UNLESS(intf != nullptr, erpt::ResultOutOfMemory());
/* Return it. */
out.SetValue(std::move(intf));
return ResultSuccess();
}
}
Result SessionImpl::OpenReport(ams::sf::Out<std::shared_ptr<erpt::sf::IReport>> out) {
return OpenInterface<erpt::sf::IReport, ReportImpl>(out);
}
Result SessionImpl::OpenManager(ams::sf::Out<std::shared_ptr<erpt::sf::IManager>> out) {
/* Create an interface. */
auto intf = std::shared_ptr<ManagerImpl>(new (std::nothrow) ManagerImpl);
R_UNLESS(intf != nullptr, erpt::ResultOutOfMemory());
/* Return it. */
out.SetValue(std::move(intf));
return ResultSuccess();
return OpenInterface<erpt::sf::IManager, ManagerImpl>(out);
}
Result SessionImpl::OpenAttachment(ams::sf::Out<std::shared_ptr<erpt::sf::IAttachment>> out) {
/* Create an interface. */
auto intf = std::shared_ptr<AttachmentImpl>(new (std::nothrow) AttachmentImpl);
R_UNLESS(intf != nullptr, erpt::ResultOutOfMemory());
/* Return it. */
out.SetValue(std::move(intf));
return ResultSuccess();
return OpenInterface<erpt::sf::IAttachment, AttachmentImpl>(out);
}
}

View file

@ -18,11 +18,12 @@
namespace ams::erpt::srv {
class SessionImpl final : public erpt::sf::ISession {
class SessionImpl final {
public:
virtual Result OpenReport(ams::sf::Out<std::shared_ptr<erpt::sf::IReport>> out) override final;
virtual Result OpenManager(ams::sf::Out<std::shared_ptr<erpt::sf::IManager>> out) override final;
virtual Result OpenAttachment(ams::sf::Out<std::shared_ptr<erpt::sf::IAttachment>> out) override final;
Result OpenReport(ams::sf::Out<std::shared_ptr<erpt::sf::IReport>> out);
Result OpenManager(ams::sf::Out<std::shared_ptr<erpt::sf::IManager>> out);
Result OpenAttachment(ams::sf::Out<std::shared_ptr<erpt::sf::IAttachment>> out);
};
static_assert(erpt::sf::IsISession<SessionImpl>);
}

View file

@ -254,7 +254,7 @@ namespace ams::fssrv::impl {
/* TODO: N creates an nn::fssystem::AsynchronousAccessFile here. */
std::shared_ptr<FileSystemInterfaceAdapter> shared_this = this->shared_from_this();
std::shared_ptr<fssrv::sf::IFile> file_intf = std::make_shared<fssrv::sf::IFile::ImplHolder<FileInterfaceAdapter>>(std::move(file), std::move(shared_this), std::move(open_count_semaphore));
auto file_intf = ams::sf::MakeShared<fssrv::sf::IFile, FileInterfaceAdapter>(std::move(file), std::move(shared_this), std::move(open_count_semaphore));
R_UNLESS(file_intf != nullptr, fs::ResultAllocationFailureInFileSystemInterfaceAdapter());
out.SetValue(std::move(file_intf), target_object_id);
@ -281,7 +281,7 @@ namespace ams::fssrv::impl {
const auto target_object_id = dir->GetDomainObjectId();
std::shared_ptr<FileSystemInterfaceAdapter> shared_this = this->shared_from_this();
std::shared_ptr<fssrv::sf::IDirectory> dir_intf = std::make_shared<fssrv::sf::IDirectory::ImplHolder<DirectoryInterfaceAdapter>>(std::move(dir), std::move(shared_this), std::move(open_count_semaphore));
auto dir_intf = ams::sf::MakeShared<fssrv::sf::IDirectory, DirectoryInterfaceAdapter>(std::move(dir), std::move(shared_this), std::move(open_count_semaphore));
R_UNLESS(dir_intf != nullptr, fs::ResultAllocationFailureInFileSystemInterfaceAdapter());
out.SetValue(std::move(dir_intf), target_object_id);

View file

@ -21,7 +21,7 @@
namespace ams::lr {
class AddOnContentLocationResolverImpl : public IAddOnContentLocationResolver {
class AddOnContentLocationResolverImpl {
private:
/* Storage for RegisteredData entries by data id. */
RegisteredStorages<ncm::DataId, 0x800> registered_storages;
@ -29,12 +29,13 @@ namespace ams::lr {
AddOnContentLocationResolverImpl() : registered_storages(hos::GetVersion() < hos::Version_9_0_0 ? 0x800 : 0x2) { /* ... */ }
/* Actual commands. */
virtual Result ResolveAddOnContentPath(sf::Out<Path> out, ncm::DataId id) override;
virtual Result RegisterAddOnContentStorageDeprecated(ncm::DataId id, ncm::StorageId storage_id) override;
virtual Result RegisterAddOnContentStorage(ncm::DataId id, ncm::ApplicationId application_id, ncm::StorageId storage_id) override;
virtual Result UnregisterAllAddOnContentPath() override;
virtual Result RefreshApplicationAddOnContent(const sf::InArray<ncm::ApplicationId> &ids) override;
virtual Result UnregisterApplicationAddOnContent(ncm::ApplicationId id) override;
Result ResolveAddOnContentPath(sf::Out<Path> out, ncm::DataId id);
Result RegisterAddOnContentStorageDeprecated(ncm::DataId id, ncm::StorageId storage_id);
Result RegisterAddOnContentStorage(ncm::DataId id, ncm::ApplicationId application_id, ncm::StorageId storage_id);
Result UnregisterAllAddOnContentPath();
Result RefreshApplicationAddOnContent(const sf::InArray<ncm::ApplicationId> &ids);
Result UnregisterApplicationAddOnContent(ncm::ApplicationId id);
};
static_assert(lr::IsIAddOnContentLocationResolver<AddOnContentLocationResolverImpl>);
}

View file

@ -42,7 +42,7 @@ namespace ams::lr {
LrLocationResolver lr;
R_TRY(lrOpenLocationResolver(static_cast<NcmStorageId>(storage_id), std::addressof(lr)));
*out = LocationResolver(std::make_shared<RemoteLocationResolverImpl>(lr));
*out = LocationResolver(sf::MakeShared<ILocationResolver, RemoteLocationResolverImpl>(lr));
return ResultSuccess();
}
@ -50,7 +50,7 @@ namespace ams::lr {
LrRegisteredLocationResolver lr;
R_TRY(lrOpenRegisteredLocationResolver(std::addressof(lr)));
*out = RegisteredLocationResolver(std::make_shared<RemoteRegisteredLocationResolverImpl>(lr));
*out = RegisteredLocationResolver(sf::MakeShared<IRegisteredLocationResolver, RemoteRegisteredLocationResolverImpl>(lr));
return ResultSuccess();
}

View file

@ -35,32 +35,33 @@ namespace ams::lr {
void GetContentStoragePath(Path *out, ncm::ContentId content_id);
public:
/* Actual commands. */
virtual Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id) override;
virtual Result RedirectProgramPath(const Path &path, ncm::ProgramId id) override;
virtual Result ResolveApplicationControlPath(sf::Out<Path> out, ncm::ProgramId id) override;
virtual Result ResolveApplicationHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id) override;
virtual Result ResolveDataPath(sf::Out<Path> out, ncm::DataId id) override;
virtual Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id) override;
virtual Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override;
virtual Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) override;
virtual Result RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override;
virtual Result ResolveApplicationLegalInformationPath(sf::Out<Path> out, ncm::ProgramId id) override;
virtual Result RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id) override;
virtual Result RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override;
virtual Result Refresh() override;
virtual Result RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id) override;
virtual Result RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override;
virtual Result ClearApplicationRedirectionDeprecated() override;
virtual Result ClearApplicationRedirection(const sf::InArray<ncm::ProgramId> &excluding_ids) override;
virtual Result EraseProgramRedirection(ncm::ProgramId id) override;
virtual Result EraseApplicationControlRedirection(ncm::ProgramId id) override;
virtual Result EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id) override;
virtual Result EraseApplicationLegalInformationRedirection(ncm::ProgramId id) override;
virtual Result ResolveProgramPathForDebug(sf::Out<Path> out, ncm::ProgramId id) override;
virtual Result RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id) override;
virtual Result RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id) override;
virtual Result RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override;
virtual Result EraseProgramRedirectionForDebug(ncm::ProgramId id) override;
Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id);
Result RedirectProgramPath(const Path &path, ncm::ProgramId id);
Result ResolveApplicationControlPath(sf::Out<Path> out, ncm::ProgramId id);
Result ResolveApplicationHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id);
Result ResolveDataPath(sf::Out<Path> out, ncm::DataId id);
Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id);
Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id);
Result RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result ResolveApplicationLegalInformationPath(sf::Out<Path> out, ncm::ProgramId id);
Result RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id);
Result RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result Refresh();
Result RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id);
Result RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result ClearApplicationRedirectionDeprecated();
Result ClearApplicationRedirection(const sf::InArray<ncm::ProgramId> &excluding_ids);
Result EraseProgramRedirection(ncm::ProgramId id);
Result EraseApplicationControlRedirection(ncm::ProgramId id);
Result EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id);
Result EraseApplicationLegalInformationRedirection(ncm::ProgramId id);
Result ResolveProgramPathForDebug(sf::Out<Path> out, ncm::ProgramId id);
Result RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id);
Result RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id);
Result RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result EraseProgramRedirectionForDebug(ncm::ProgramId id);
};
static_assert(lr::IsILocationResolver<ContentLocationResolverImpl>);
}

View file

@ -20,7 +20,7 @@
namespace ams::lr {
class LocationResolverImplBase : public ILocationResolver {
class LocationResolverImplBase {
NON_COPYABLE(LocationResolverImplBase);
NON_MOVEABLE(LocationResolverImplBase);
protected:

View file

@ -30,10 +30,10 @@ namespace ams::lr {
/* No existing resolver is present, create one. */
if (!resolver) {
if (storage_id == ncm::StorageId::Host) {
AMS_ABORT_UNLESS(this->location_resolvers.Insert(storage_id, std::make_shared<RedirectOnlyLocationResolverImpl>()));
AMS_ABORT_UNLESS(this->location_resolvers.Insert(storage_id, sf::MakeShared<ILocationResolver, RedirectOnlyLocationResolverImpl>()));
} else {
auto content_resolver = std::make_shared<ContentLocationResolverImpl>(storage_id);
R_TRY(content_resolver->Refresh());
auto content_resolver = sf::MakeShared<ILocationResolver, ContentLocationResolverImpl>(storage_id);
R_TRY(content_resolver->GetImpl().Refresh());
AMS_ABORT_UNLESS(this->location_resolvers.Insert(storage_id, std::move(content_resolver)));
}
@ -51,7 +51,7 @@ namespace ams::lr {
/* No existing resolver is present, create one. */
if (!this->registered_location_resolver) {
this->registered_location_resolver = std::make_shared<RegisteredLocationResolverImpl>();
this->registered_location_resolver = sf::MakeShared<IRegisteredLocationResolver, RegisteredLocationResolverImpl>();
}
/* Copy the output interface. */
@ -79,7 +79,7 @@ namespace ams::lr {
/* No existing resolver is present, create one. */
if (!this->add_on_content_location_resolver) {
this->add_on_content_location_resolver = std::make_shared<AddOnContentLocationResolverImpl>();
this->add_on_content_location_resolver = sf::MakeShared<IAddOnContentLocationResolver, AddOnContentLocationResolverImpl>();
}
/* Copy the output interface. */

View file

@ -24,32 +24,33 @@ namespace ams::lr {
~RedirectOnlyLocationResolverImpl();
public:
/* Actual commands. */
virtual Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id) override;
virtual Result RedirectProgramPath(const Path &path, ncm::ProgramId id) override;
virtual Result ResolveApplicationControlPath(sf::Out<Path> out, ncm::ProgramId id) override;
virtual Result ResolveApplicationHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id) override;
virtual Result ResolveDataPath(sf::Out<Path> out, ncm::DataId id) override;
virtual Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id) override;
virtual Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override;
virtual Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) override;
virtual Result RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override;
virtual Result ResolveApplicationLegalInformationPath(sf::Out<Path> out, ncm::ProgramId id) override;
virtual Result RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id) override;
virtual Result RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override;
virtual Result Refresh() override;
virtual Result RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id) override;
virtual Result RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override;
virtual Result ClearApplicationRedirectionDeprecated() override;
virtual Result ClearApplicationRedirection(const sf::InArray<ncm::ProgramId> &excluding_ids) override;
virtual Result EraseProgramRedirection(ncm::ProgramId id) override;
virtual Result EraseApplicationControlRedirection(ncm::ProgramId id) override;
virtual Result EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id) override;
virtual Result EraseApplicationLegalInformationRedirection(ncm::ProgramId id) override;
virtual Result ResolveProgramPathForDebug(sf::Out<Path> out, ncm::ProgramId id) override;
virtual Result RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id) override;
virtual Result RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id) override;
virtual Result RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override;
virtual Result EraseProgramRedirectionForDebug(ncm::ProgramId id) override;
Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id);
Result RedirectProgramPath(const Path &path, ncm::ProgramId id);
Result ResolveApplicationControlPath(sf::Out<Path> out, ncm::ProgramId id);
Result ResolveApplicationHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id);
Result ResolveDataPath(sf::Out<Path> out, ncm::DataId id);
Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id);
Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id);
Result RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result ResolveApplicationLegalInformationPath(sf::Out<Path> out, ncm::ProgramId id);
Result RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id);
Result RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result Refresh();
Result RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id);
Result RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result ClearApplicationRedirectionDeprecated();
Result ClearApplicationRedirection(const sf::InArray<ncm::ProgramId> &excluding_ids);
Result EraseProgramRedirection(ncm::ProgramId id);
Result EraseApplicationControlRedirection(ncm::ProgramId id);
Result EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id);
Result EraseApplicationLegalInformationRedirection(ncm::ProgramId id);
Result ResolveProgramPathForDebug(sf::Out<Path> out, ncm::ProgramId id);
Result RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id);
Result RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id);
Result RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result EraseProgramRedirectionForDebug(ncm::ProgramId id);
};
static_assert(lr::IsILocationResolver<RedirectOnlyLocationResolverImpl>);
}

View file

@ -21,7 +21,7 @@
namespace ams::lr {
class RegisteredLocationResolverImpl : public IRegisteredLocationResolver {
class RegisteredLocationResolverImpl {
private:
static constexpr size_t MaxRegisteredLocationsDeprecated = 0x10;
static constexpr size_t MaxRegisteredLocations = 0x20;
@ -49,20 +49,21 @@ namespace ams::lr {
~RegisteredLocationResolverImpl();
public:
/* Actual commands. */
virtual Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id) override;
virtual Result RegisterProgramPathDeprecated(const Path &path, ncm::ProgramId id) override;
virtual Result RegisterProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override;
virtual Result UnregisterProgramPath(ncm::ProgramId id) override;
virtual Result RedirectProgramPathDeprecated(const Path &path, ncm::ProgramId id) override;
virtual Result RedirectProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override;
virtual Result ResolveHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id) override;
virtual Result RegisterHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) override;
virtual Result RegisterHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override;
virtual Result UnregisterHtmlDocumentPath(ncm::ProgramId id) override;
virtual Result RedirectHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) override;
virtual Result RedirectHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override;
virtual Result Refresh() override;
virtual Result RefreshExcluding(const sf::InArray<ncm::ProgramId> &ids) override;
Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id);
Result RegisterProgramPathDeprecated(const Path &path, ncm::ProgramId id);
Result RegisterProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result UnregisterProgramPath(ncm::ProgramId id);
Result RedirectProgramPathDeprecated(const Path &path, ncm::ProgramId id);
Result RedirectProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result ResolveHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id);
Result RegisterHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id);
Result RegisterHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result UnregisterHtmlDocumentPath(ncm::ProgramId id);
Result RedirectHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id);
Result RedirectHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id);
Result Refresh();
Result RefreshExcluding(const sf::InArray<ncm::ProgramId> &ids);
};
static_assert(lr::IsIRegisteredLocationResolver<RegisteredLocationResolverImpl>);
}

View file

@ -18,7 +18,7 @@
namespace ams::lr {
class RemoteLocationResolverImpl : public ILocationResolver {
class RemoteLocationResolverImpl {
private:
::LrLocationResolver srv;
public:
@ -27,121 +27,122 @@ namespace ams::lr {
~RemoteLocationResolverImpl() { ::serviceClose(&srv.s); }
public:
/* Actual commands. */
virtual Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id) override {
return lrLrResolveProgramPath(std::addressof(this->srv), id.value, out->str);
Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id) {
return ::lrLrResolveProgramPath(std::addressof(this->srv), id.value, out->str);
}
virtual Result RedirectProgramPath(const Path &path, ncm::ProgramId id) override {
return lrLrRedirectProgramPath(std::addressof(this->srv), id.value, path.str);
Result RedirectProgramPath(const Path &path, ncm::ProgramId id) {
return ::lrLrRedirectProgramPath(std::addressof(this->srv), id.value, path.str);
}
virtual Result ResolveApplicationControlPath(sf::Out<Path> out, ncm::ProgramId id) override {
return lrLrResolveApplicationControlPath(std::addressof(this->srv), id.value, out->str);
Result ResolveApplicationControlPath(sf::Out<Path> out, ncm::ProgramId id) {
return ::lrLrResolveApplicationControlPath(std::addressof(this->srv), id.value, out->str);
}
virtual Result ResolveApplicationHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id) override {
return lrLrResolveApplicationHtmlDocumentPath(std::addressof(this->srv), id.value, out->str);
Result ResolveApplicationHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id) {
return ::lrLrResolveApplicationHtmlDocumentPath(std::addressof(this->srv), id.value, out->str);
}
virtual Result ResolveDataPath(sf::Out<Path> out, ncm::DataId id) override {
return lrLrResolveDataPath(std::addressof(this->srv), id.value, out->str);
Result ResolveDataPath(sf::Out<Path> out, ncm::DataId id) {
return ::lrLrResolveDataPath(std::addressof(this->srv), id.value, out->str);
}
virtual Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id) override {
return lrLrRedirectApplicationControlPath(std::addressof(this->srv), id.value, 0, path.str);
Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id) {
return ::lrLrRedirectApplicationControlPath(std::addressof(this->srv), id.value, 0, path.str);
}
virtual Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override {
return lrLrRedirectApplicationControlPath(std::addressof(this->srv), id.value, owner_id.value, path.str);
Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
return ::lrLrRedirectApplicationControlPath(std::addressof(this->srv), id.value, owner_id.value, path.str);
}
virtual Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) override {
return lrLrRedirectApplicationHtmlDocumentPath(std::addressof(this->srv), id.value, 0, path.str);
Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) {
return ::lrLrRedirectApplicationHtmlDocumentPath(std::addressof(this->srv), id.value, 0, path.str);
}
virtual Result RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override {
return lrLrRedirectApplicationHtmlDocumentPath(std::addressof(this->srv), id.value, owner_id.value, path.str);
Result RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
return ::lrLrRedirectApplicationHtmlDocumentPath(std::addressof(this->srv), id.value, owner_id.value, path.str);
}
virtual Result ResolveApplicationLegalInformationPath(sf::Out<Path> out, ncm::ProgramId id) override {
return lrLrResolveApplicationLegalInformationPath(std::addressof(this->srv), id.value, out->str);
Result ResolveApplicationLegalInformationPath(sf::Out<Path> out, ncm::ProgramId id) {
return ::lrLrResolveApplicationLegalInformationPath(std::addressof(this->srv), id.value, out->str);
}
virtual Result RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id) override {
return lrLrRedirectApplicationLegalInformationPath(std::addressof(this->srv), id.value, 0, path.str);
Result RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id) {
return ::lrLrRedirectApplicationLegalInformationPath(std::addressof(this->srv), id.value, 0, path.str);
}
virtual Result RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override {
return lrLrRedirectApplicationLegalInformationPath(std::addressof(this->srv), id.value, owner_id.value, path.str);
Result RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
return ::lrLrRedirectApplicationLegalInformationPath(std::addressof(this->srv), id.value, owner_id.value, path.str);
}
virtual Result Refresh() override {
return lrLrRefresh(std::addressof(this->srv));
Result Refresh() {
return ::lrLrRefresh(std::addressof(this->srv));
}
virtual Result RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id) override {
Result RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_ABORT();
}
virtual Result RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override {
Result RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
/* TODO: libnx bindings */
AMS_ABORT();
}
virtual Result ClearApplicationRedirectionDeprecated() override {
Result ClearApplicationRedirectionDeprecated() {
/* TODO: libnx bindings */
AMS_ABORT();
}
virtual Result ClearApplicationRedirection(const sf::InArray<ncm::ProgramId> &excluding_ids) override {
Result ClearApplicationRedirection(const sf::InArray<ncm::ProgramId> &excluding_ids) {
/* TODO: libnx bindings */
AMS_ABORT();
}
virtual Result EraseProgramRedirection(ncm::ProgramId id) override {
return lrLrEraseProgramRedirection(std::addressof(this->srv), id.value);
Result EraseProgramRedirection(ncm::ProgramId id) {
return ::lrLrEraseProgramRedirection(std::addressof(this->srv), id.value);
}
virtual Result EraseApplicationControlRedirection(ncm::ProgramId id) override {
Result EraseApplicationControlRedirection(ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_ABORT();
}
virtual Result EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id) override {
Result EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_ABORT();
}
virtual Result EraseApplicationLegalInformationRedirection(ncm::ProgramId id) override {
Result EraseApplicationLegalInformationRedirection(ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_ABORT();
}
virtual Result ResolveProgramPathForDebug(sf::Out<Path> out, ncm::ProgramId id) override {
Result ResolveProgramPathForDebug(sf::Out<Path> out, ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_ABORT();
}
virtual Result RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id) override {
Result RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_ABORT();
}
virtual Result RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id) override {
Result RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_ABORT();
}
virtual Result RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override {
Result RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
/* TODO: libnx bindings */
AMS_ABORT();
}
virtual Result EraseProgramRedirectionForDebug(ncm::ProgramId id) override {
Result EraseProgramRedirectionForDebug(ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_ABORT();
}
};
static_assert(lr::IsILocationResolver<RemoteLocationResolverImpl>);
}

View file

@ -19,7 +19,7 @@
namespace ams::lr {
class RemoteRegisteredLocationResolverImpl : public IRegisteredLocationResolver {
class RemoteRegisteredLocationResolverImpl {
private:
::LrRegisteredLocationResolver srv;
public:
@ -28,74 +28,75 @@ namespace ams::lr {
~RemoteRegisteredLocationResolverImpl() { ::serviceClose(&srv.s); }
public:
/* Actual commands. */
virtual Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id) override {
return lrRegLrResolveProgramPath(std::addressof(this->srv), static_cast<u64>(id), out->str);
Result ResolveProgramPath(sf::Out<Path> out, ncm::ProgramId id) {
return ::lrRegLrResolveProgramPath(std::addressof(this->srv), static_cast<u64>(id), out->str);
}
virtual Result RegisterProgramPathDeprecated(const Path &path, ncm::ProgramId id) override {
Result RegisterProgramPathDeprecated(const Path &path, ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_ABORT();
}
virtual Result RegisterProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override {
Result RegisterProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
/* TODO: libnx bindings */
AMS_ABORT();
}
virtual Result UnregisterProgramPath(ncm::ProgramId id) override {
Result UnregisterProgramPath(ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_ABORT();
}
virtual Result RedirectProgramPathDeprecated(const Path &path, ncm::ProgramId id) override {
Result RedirectProgramPathDeprecated(const Path &path, ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_ABORT();
}
virtual Result RedirectProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override {
Result RedirectProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
/* TODO: libnx bindings */
AMS_ABORT();
}
virtual Result ResolveHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id) override {
Result ResolveHtmlDocumentPath(sf::Out<Path> out, ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_ABORT();
}
virtual Result RegisterHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) override {
Result RegisterHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_ABORT();
}
virtual Result RegisterHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override {
Result RegisterHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
/* TODO: libnx bindings */
AMS_ABORT();
}
virtual Result UnregisterHtmlDocumentPath(ncm::ProgramId id) override {
Result UnregisterHtmlDocumentPath(ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_ABORT();
}
virtual Result RedirectHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) override {
Result RedirectHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) {
/* TODO: libnx bindings */
AMS_ABORT();
}
virtual Result RedirectHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override {
Result RedirectHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
/* TODO: libnx bindings */
AMS_ABORT();
}
virtual Result Refresh() override {
Result Refresh() {
/* TODO: libnx bindings */
AMS_ABORT();
}
virtual Result RefreshExcluding(const sf::InArray<ncm::ProgramId> &ids) override {
Result RefreshExcluding(const sf::InArray<ncm::ProgramId> &ids) {
/* TODO: libnx bindings */
AMS_ABORT();
}
};
static_assert(lr::IsIRegisteredLocationResolver<RemoteRegisteredLocationResolverImpl>);
}

View file

@ -27,7 +27,7 @@ namespace ams::ncm {
void Initialize() {
AMS_ASSERT(g_content_manager == nullptr);
R_ABORT_UNLESS(ncmInitialize());
g_content_manager = std::make_shared<RemoteContentManagerImpl>();
g_content_manager = sf::MakeShared<IContentManager, RemoteContentManagerImpl>();
}
void Finalize() {

View file

@ -553,23 +553,23 @@ namespace ams::ncm {
if (storage_id == StorageId::GameCard) {
/* Game card content storage is read only. */
auto content_storage = std::make_shared<ReadOnlyContentStorageImpl>();
R_TRY(content_storage->Initialize(root->path, MakeFlatContentFilePath));
auto content_storage = sf::MakeShared<IContentStorage, ReadOnlyContentStorageImpl>();
R_TRY(content_storage->GetImpl().Initialize(root->path, MakeFlatContentFilePath));
root->content_storage = std::move(content_storage);
} else {
/* Create a content storage. */
auto content_storage = std::make_shared<ContentStorageImpl>();
auto content_storage = sf::MakeShared<IContentStorage, ContentStorageImpl>();
/* Initialize content storage with an appropriate path function. */
switch (storage_id) {
case StorageId::BuiltInSystem:
R_TRY(content_storage->Initialize(root->path, MakeFlatContentFilePath, MakeFlatPlaceHolderFilePath, false, std::addressof(this->rights_id_cache)));
R_TRY(content_storage->GetImpl().Initialize(root->path, MakeFlatContentFilePath, MakeFlatPlaceHolderFilePath, false, std::addressof(this->rights_id_cache)));
break;
case StorageId::SdCard:
R_TRY(content_storage->Initialize(root->path, MakeSha256HierarchicalContentFilePath_ForFat16KCluster, MakeSha256HierarchicalPlaceHolderFilePath_ForFat16KCluster, true, std::addressof(this->rights_id_cache)));
R_TRY(content_storage->GetImpl().Initialize(root->path, MakeSha256HierarchicalContentFilePath_ForFat16KCluster, MakeSha256HierarchicalPlaceHolderFilePath_ForFat16KCluster, true, std::addressof(this->rights_id_cache)));
break;
default:
R_TRY(content_storage->Initialize(root->path, MakeSha256HierarchicalContentFilePath_ForFat16KCluster, MakeSha256HierarchicalPlaceHolderFilePath_ForFat16KCluster, false, std::addressof(this->rights_id_cache)));
R_TRY(content_storage->GetImpl().Initialize(root->path, MakeSha256HierarchicalContentFilePath_ForFat16KCluster, MakeSha256HierarchicalPlaceHolderFilePath_ForFat16KCluster, false, std::addressof(this->rights_id_cache)));
break;
}
@ -617,7 +617,7 @@ namespace ams::ncm {
R_TRY(root->kvs->Initialize(root->max_content_metas, root->memory_resource));
/* Create an on memory content meta database for game cards. */
root->content_meta_database = std::make_shared<OnMemoryContentMetaDatabaseImpl>(std::addressof(*root->kvs));
root->content_meta_database = sf::MakeShared<IContentMetaDatabase, OnMemoryContentMetaDatabaseImpl>(std::addressof(*root->kvs));
} else {
/* Mount save data for this root. */
R_TRY(fs::MountSystemSaveData(root->mount_name, root->info.space_id, root->info.id));
@ -630,7 +630,7 @@ namespace ams::ncm {
R_TRY(root->kvs->Load());
/* Create the content meta database. */
root->content_meta_database = std::make_shared<ContentMetaDatabaseImpl>(std::addressof(*root->kvs), root->mount_name);
root->content_meta_database = sf::MakeShared<IContentMetaDatabase, ContentMetaDatabaseImpl>(std::addressof(*root->kvs), root->mount_name);
mount_guard.Cancel();
}

View file

@ -18,7 +18,7 @@
namespace ams::ncm {
class ContentMetaDatabaseImplBase : public IContentMetaDatabase {
class ContentMetaDatabaseImplBase {
NON_COPYABLE(ContentMetaDatabaseImplBase);
NON_MOVEABLE(ContentMetaDatabaseImplBase);
protected:
@ -52,6 +52,32 @@ namespace ams::ncm {
R_TRY(this->GetContentMetaSize(out_size, key));
return this->kvs->GetValuePointer(reinterpret_cast<const ContentMetaHeader **>(out_value_ptr), key);
}
public:
/* Actual commands. */
virtual Result Set(const ContentMetaKey &key, sf::InBuffer value) = 0;
virtual Result Get(sf::Out<u64> out_size, const ContentMetaKey &key, sf::OutBuffer out_value) = 0;
virtual Result Remove(const ContentMetaKey &key) = 0;
virtual Result GetContentIdByType(sf::Out<ContentId> out_content_id, const ContentMetaKey &key, ContentType type) = 0;
virtual Result ListContentInfo(sf::Out<s32> out_entries_written, const sf::OutArray<ContentInfo> &out_info, const ContentMetaKey &key, s32 offset) = 0;
virtual Result List(sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ContentMetaKey> &out_info, ContentMetaType meta_type, ApplicationId application_id, u64 min, u64 max, ContentInstallType install_type) = 0;
virtual Result GetLatestContentMetaKey(sf::Out<ContentMetaKey> out_key, u64 id) = 0;
virtual Result ListApplication(sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ApplicationContentMetaKey> &out_keys, ContentMetaType meta_type) = 0;
virtual Result Has(sf::Out<bool> out, const ContentMetaKey &key) = 0;
virtual Result HasAll(sf::Out<bool> out, const sf::InArray<ContentMetaKey> &keys) = 0;
virtual Result GetSize(sf::Out<u64> out_size, const ContentMetaKey &key) = 0;
virtual Result GetRequiredSystemVersion(sf::Out<u32> out_version, const ContentMetaKey &key) = 0;
virtual Result GetPatchId(sf::Out<PatchId> out_patch_id, const ContentMetaKey &key) = 0;
virtual Result DisableForcibly() = 0;
virtual Result LookupOrphanContent(const sf::OutArray<bool> &out_orphaned, const sf::InArray<ContentId> &content_ids) = 0;
virtual Result Commit() = 0;
virtual Result HasContent(sf::Out<bool> out, const ContentMetaKey &key, const ContentId &content_id) = 0;
virtual Result ListContentMetaInfo(sf::Out<s32> out_entries_written, const sf::OutArray<ContentMetaInfo> &out_meta_info, const ContentMetaKey &key, s32 offset) = 0;
virtual Result GetAttributes(sf::Out<u8> out_attributes, const ContentMetaKey &key) = 0;
virtual Result GetRequiredApplicationVersion(sf::Out<u32> out_version, const ContentMetaKey &key) = 0;
virtual Result GetContentIdByTypeAndIdOffset(sf::Out<ContentId> out_content_id, const ContentMetaKey &key, ContentType type, u8 id_offset) = 0;
virtual Result GetCount(sf::Out<u32> out_count) = 0;
virtual Result GetOwnerApplicationId(sf::Out<ApplicationId> out_id, const ContentMetaKey &key) = 0;
};
static_assert(ncm::IsIContentMetaDatabase<ContentMetaDatabaseImplBase>);
}

View file

@ -18,7 +18,7 @@
namespace ams::ncm {
class ContentStorageImplBase : public IContentStorage {
class ContentStorageImplBase {
NON_COPYABLE(ContentStorageImplBase);
NON_MOVEABLE(ContentStorageImplBase);
protected:
@ -43,6 +43,39 @@ namespace ams::ncm {
}
return ResultSuccess();
}
public:
/* Actual commands. */
virtual Result GeneratePlaceHolderId(sf::Out<PlaceHolderId> out) = 0;
virtual Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) = 0;
virtual Result DeletePlaceHolder(PlaceHolderId placeholder_id) = 0;
virtual Result HasPlaceHolder(sf::Out<bool> out, PlaceHolderId placeholder_id) = 0;
virtual Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, sf::InBuffer data) = 0;
virtual Result Register(PlaceHolderId placeholder_id, ContentId content_id) = 0;
virtual Result Delete(ContentId content_id) = 0;
virtual Result Has(sf::Out<bool> out, ContentId content_id) = 0;
virtual Result GetPath(sf::Out<Path> out, ContentId content_id) = 0;
virtual Result GetPlaceHolderPath(sf::Out<Path> out, PlaceHolderId placeholder_id) = 0;
virtual Result CleanupAllPlaceHolder() = 0;
virtual Result ListPlaceHolder(sf::Out<s32> out_count, const sf::OutArray<PlaceHolderId> &out_buf) = 0;
virtual Result GetContentCount(sf::Out<s32> out_count) = 0;
virtual Result ListContentId(sf::Out<s32> out_count, const sf::OutArray<ContentId> &out_buf, s32 start_offset) = 0;
virtual Result GetSizeFromContentId(sf::Out<s64> out_size, ContentId content_id) = 0;
virtual Result DisableForcibly() = 0;
virtual Result RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) = 0;
virtual Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) = 0;
virtual Result ReadContentIdFile(sf::OutBuffer buf, ContentId content_id, s64 offset) = 0;
virtual Result GetRightsIdFromPlaceHolderIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, PlaceHolderId placeholder_id) = 0;
virtual Result GetRightsIdFromPlaceHolderId(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id) = 0;
virtual Result GetRightsIdFromContentIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, ContentId content_id) = 0;
virtual Result GetRightsIdFromContentId(sf::Out<ncm::RightsId> out_rights_id, ContentId content_id) = 0;
virtual Result WriteContentForDebug(ContentId content_id, s64 offset, sf::InBuffer data) = 0;
virtual Result GetFreeSpaceSize(sf::Out<s64> out_size) = 0;
virtual Result GetTotalSpaceSize(sf::Out<s64> out_size) = 0;
virtual Result FlushPlaceHolder() = 0;
virtual Result GetSizeFromPlaceHolderId(sf::Out<s64> out, PlaceHolderId placeholder_id) = 0;
virtual Result RepairInvalidFileAttribute() = 0;
virtual Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) = 0;
};
static_assert(ncm::IsIContentStorage<ContentStorageImplBase>);
}

View file

@ -20,80 +20,81 @@
namespace ams::ncm {
class RemoteContentManagerImpl final : public IContentManager {
class RemoteContentManagerImpl final {
public:
RemoteContentManagerImpl() { /* ... */ }
~RemoteContentManagerImpl() { /* ... */ }
public:
virtual Result CreateContentStorage(StorageId storage_id) override {
Result CreateContentStorage(StorageId storage_id) {
return ::ncmCreateContentStorage(static_cast<NcmStorageId>(storage_id));
}
virtual Result CreateContentMetaDatabase(StorageId storage_id) override {
Result CreateContentMetaDatabase(StorageId storage_id) {
return ::ncmCreateContentMetaDatabase(static_cast<NcmStorageId>(storage_id));
}
virtual Result VerifyContentStorage(StorageId storage_id) override {
Result VerifyContentStorage(StorageId storage_id) {
return ::ncmVerifyContentStorage(static_cast<NcmStorageId>(storage_id));
}
virtual Result VerifyContentMetaDatabase(StorageId storage_id) override {
Result VerifyContentMetaDatabase(StorageId storage_id) {
return ::ncmVerifyContentMetaDatabase(static_cast<NcmStorageId>(storage_id));
}
virtual Result OpenContentStorage(sf::Out<std::shared_ptr<IContentStorage>> out, StorageId storage_id) override {
Result OpenContentStorage(sf::Out<std::shared_ptr<IContentStorage>> out, StorageId storage_id) {
NcmContentStorage cs;
R_TRY(::ncmOpenContentStorage(std::addressof(cs), static_cast<NcmStorageId>(storage_id)));
out.SetValue(std::make_shared<RemoteContentStorageImpl>(cs));
out.SetValue(sf::MakeShared<IContentStorage, RemoteContentStorageImpl>(cs));
return ResultSuccess();
}
virtual Result OpenContentMetaDatabase(sf::Out<std::shared_ptr<IContentMetaDatabase>> out, StorageId storage_id) override {
Result OpenContentMetaDatabase(sf::Out<std::shared_ptr<IContentMetaDatabase>> out, StorageId storage_id) {
NcmContentMetaDatabase db;
R_TRY(::ncmOpenContentMetaDatabase(std::addressof(db), static_cast<NcmStorageId>(storage_id)));
out.SetValue(std::make_shared<RemoteContentMetaDatabaseImpl>(db));
out.SetValue(sf::MakeShared<IContentMetaDatabase, RemoteContentMetaDatabaseImpl>(db));
return ResultSuccess();
}
virtual Result CloseContentStorageForcibly(StorageId storage_id) override {
Result CloseContentStorageForcibly(StorageId storage_id) {
return ::ncmCloseContentStorageForcibly(static_cast<NcmStorageId>(storage_id));
}
virtual Result CloseContentMetaDatabaseForcibly(StorageId storage_id) override {
Result CloseContentMetaDatabaseForcibly(StorageId storage_id) {
return ::ncmCloseContentMetaDatabaseForcibly(static_cast<NcmStorageId>(storage_id));
}
virtual Result CleanupContentMetaDatabase(StorageId storage_id) override {
Result CleanupContentMetaDatabase(StorageId storage_id) {
return ::ncmCleanupContentMetaDatabase(static_cast<NcmStorageId>(storage_id));
}
virtual Result ActivateContentStorage(StorageId storage_id) override {
Result ActivateContentStorage(StorageId storage_id) {
return ::ncmActivateContentStorage(static_cast<NcmStorageId>(storage_id));
}
virtual Result InactivateContentStorage(StorageId storage_id) override {
Result InactivateContentStorage(StorageId storage_id) {
return ::ncmInactivateContentStorage(static_cast<NcmStorageId>(storage_id));
}
virtual Result ActivateContentMetaDatabase(StorageId storage_id) override {
Result ActivateContentMetaDatabase(StorageId storage_id) {
return ::ncmActivateContentMetaDatabase(static_cast<NcmStorageId>(storage_id));
}
virtual Result InactivateContentMetaDatabase(StorageId storage_id) override {
Result InactivateContentMetaDatabase(StorageId storage_id) {
return ::ncmInactivateContentMetaDatabase(static_cast<NcmStorageId>(storage_id));
}
virtual Result InvalidateRightsIdCache() override {
Result InvalidateRightsIdCache() {
return ::ncmInvalidateRightsIdCache();
}
virtual Result GetMemoryReport(sf::Out<MemoryReport> out) override {
Result GetMemoryReport(sf::Out<MemoryReport> out) {
/* TODO: libnx bindings */
AMS_ABORT();
}
};
static_assert(ncm::IsIContentManager<RemoteContentManagerImpl>);
}

View file

@ -18,7 +18,7 @@
namespace ams::ncm {
class RemoteContentMetaDatabaseImpl final : public IContentMetaDatabase {
class RemoteContentMetaDatabaseImpl final {
private:
::NcmContentMetaDatabase srv;
public:
@ -71,101 +71,101 @@ namespace ams::ncm {
return reinterpret_cast<const ::NcmContentId *>(std::addressof(c));
}
public:
virtual Result Set(const ContentMetaKey &key, sf::InBuffer value) override {
Result Set(const ContentMetaKey &key, sf::InBuffer value) {
return ncmContentMetaDatabaseSet(std::addressof(this->srv), Convert(key), value.GetPointer(), value.GetSize());
}
virtual Result Get(sf::Out<u64> out_size, const ContentMetaKey &key, sf::OutBuffer out_value) override {
Result Get(sf::Out<u64> out_size, const ContentMetaKey &key, sf::OutBuffer out_value) {
return ncmContentMetaDatabaseGet(std::addressof(this->srv), Convert(key), out_size.GetPointer(), out_value.GetPointer(), out_value.GetSize());
}
virtual Result Remove(const ContentMetaKey &key) override {
Result Remove(const ContentMetaKey &key) {
return ncmContentMetaDatabaseRemove(std::addressof(this->srv), Convert(key));
}
virtual Result GetContentIdByType(sf::Out<ContentId> out_content_id, const ContentMetaKey &key, ContentType type) override {
Result GetContentIdByType(sf::Out<ContentId> out_content_id, const ContentMetaKey &key, ContentType type) {
return ncmContentMetaDatabaseGetContentIdByType(std::addressof(this->srv), Convert(out_content_id.GetPointer()), Convert(key), static_cast<::NcmContentType>(type));
}
virtual Result ListContentInfo(sf::Out<s32> out_entries_written, const sf::OutArray<ContentInfo> &out_info, const ContentMetaKey &key, s32 offset) override {
Result ListContentInfo(sf::Out<s32> out_entries_written, const sf::OutArray<ContentInfo> &out_info, const ContentMetaKey &key, s32 offset) {
return ncmContentMetaDatabaseListContentInfo(std::addressof(this->srv), out_entries_written.GetPointer(), Convert(out_info.GetPointer()), out_info.GetSize(), Convert(key), offset);
}
virtual Result List(sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ContentMetaKey> &out_info, ContentMetaType meta_type, ApplicationId application_id, u64 min, u64 max, ContentInstallType install_type) override {
Result List(sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ContentMetaKey> &out_info, ContentMetaType meta_type, ApplicationId application_id, u64 min, u64 max, ContentInstallType install_type) {
return ncmContentMetaDatabaseList(std::addressof(this->srv), out_entries_total.GetPointer(), out_entries_written.GetPointer(), Convert(out_info.GetPointer()), out_info.GetSize(), static_cast<::NcmContentMetaType>(meta_type), application_id.value, min, max, static_cast<::NcmContentInstallType>(install_type));
}
virtual Result GetLatestContentMetaKey(sf::Out<ContentMetaKey> out_key, u64 id) override {
Result GetLatestContentMetaKey(sf::Out<ContentMetaKey> out_key, u64 id) {
return ncmContentMetaDatabaseGetLatestContentMetaKey(std::addressof(this->srv), Convert(out_key.GetPointer()), static_cast<u64>(id));
}
virtual Result ListApplication(sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ApplicationContentMetaKey> &out_keys, ContentMetaType meta_type) override {
Result ListApplication(sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ApplicationContentMetaKey> &out_keys, ContentMetaType meta_type) {
return ncmContentMetaDatabaseListApplication(std::addressof(this->srv), out_entries_total.GetPointer(), out_entries_written.GetPointer(), Convert(out_keys.GetPointer()), out_keys.GetSize(), static_cast<::NcmContentMetaType>(meta_type));
}
virtual Result Has(sf::Out<bool> out, const ContentMetaKey &key) override {
Result Has(sf::Out<bool> out, const ContentMetaKey &key) {
return ncmContentMetaDatabaseHas(std::addressof(this->srv), out.GetPointer(), Convert(key));
}
virtual Result HasAll(sf::Out<bool> out, const sf::InArray<ContentMetaKey> &keys) override {
Result HasAll(sf::Out<bool> out, const sf::InArray<ContentMetaKey> &keys) {
return ncmContentMetaDatabaseHasAll(std::addressof(this->srv), out.GetPointer(), Convert(keys.GetPointer()), keys.GetSize());
}
virtual Result GetSize(sf::Out<u64> out_size, const ContentMetaKey &key) override {
Result GetSize(sf::Out<u64> out_size, const ContentMetaKey &key) {
return ncmContentMetaDatabaseGetSize(std::addressof(this->srv), out_size.GetPointer(), Convert(key));
}
virtual Result GetRequiredSystemVersion(sf::Out<u32> out_version, const ContentMetaKey &key) override {
Result GetRequiredSystemVersion(sf::Out<u32> out_version, const ContentMetaKey &key) {
return ncmContentMetaDatabaseGetRequiredSystemVersion(std::addressof(this->srv), out_version.GetPointer(), Convert(key));
}
virtual Result GetPatchId(sf::Out<PatchId> out_patch_id, const ContentMetaKey &key) override {
Result GetPatchId(sf::Out<PatchId> out_patch_id, const ContentMetaKey &key) {
return ncmContentMetaDatabaseGetPatchId(std::addressof(this->srv), reinterpret_cast<u64 *>(out_patch_id.GetPointer()), Convert(key));
}
virtual Result DisableForcibly() override {
Result DisableForcibly() {
return ncmContentMetaDatabaseDisableForcibly(std::addressof(this->srv));
}
virtual Result LookupOrphanContent(const sf::OutArray<bool> &out_orphaned, const sf::InArray<ContentId> &content_ids) override {
Result LookupOrphanContent(const sf::OutArray<bool> &out_orphaned, const sf::InArray<ContentId> &content_ids) {
return ncmContentMetaDatabaseLookupOrphanContent(std::addressof(this->srv), out_orphaned.GetPointer(), Convert(content_ids.GetPointer()), std::min(out_orphaned.GetSize(), content_ids.GetSize()));
}
virtual Result Commit() override {
Result Commit() {
return ncmContentMetaDatabaseCommit(std::addressof(this->srv));
}
virtual Result HasContent(sf::Out<bool> out, const ContentMetaKey &key, const ContentId &content_id) override {
Result HasContent(sf::Out<bool> out, const ContentMetaKey &key, const ContentId &content_id) {
return ncmContentMetaDatabaseHasContent(std::addressof(this->srv), out.GetPointer(), Convert(key), Convert(content_id));
}
virtual Result ListContentMetaInfo(sf::Out<s32> out_entries_written, const sf::OutArray<ContentMetaInfo> &out_meta_info, const ContentMetaKey &key, s32 offset) override {
Result ListContentMetaInfo(sf::Out<s32> out_entries_written, const sf::OutArray<ContentMetaInfo> &out_meta_info, const ContentMetaKey &key, s32 offset) {
return ncmContentMetaDatabaseListContentMetaInfo(std::addressof(this->srv), out_entries_written.GetPointer(), out_meta_info.GetPointer(), out_meta_info.GetSize(), Convert(key), offset);
}
virtual Result GetAttributes(sf::Out<u8> out_attributes, const ContentMetaKey &key) override {
Result GetAttributes(sf::Out<u8> out_attributes, const ContentMetaKey &key) {
static_assert(sizeof(ContentMetaAttribute) == sizeof(u8));
return ncmContentMetaDatabaseGetAttributes(std::addressof(this->srv), Convert(key), out_attributes.GetPointer());
}
virtual Result GetRequiredApplicationVersion(sf::Out<u32> out_version, const ContentMetaKey &key) override {
Result GetRequiredApplicationVersion(sf::Out<u32> out_version, const ContentMetaKey &key) {
return ncmContentMetaDatabaseGetRequiredApplicationVersion(std::addressof(this->srv), out_version.GetPointer(), Convert(key));
}
virtual Result GetContentIdByTypeAndIdOffset(sf::Out<ContentId> out_content_id, const ContentMetaKey &key, ContentType type, u8 id_offset) override {
Result GetContentIdByTypeAndIdOffset(sf::Out<ContentId> out_content_id, const ContentMetaKey &key, ContentType type, u8 id_offset) {
return ncmContentMetaDatabaseGetContentIdByTypeAndIdOffset(std::addressof(this->srv), Convert(out_content_id.GetPointer()), Convert(key), static_cast<::NcmContentType>(type), id_offset);
}
virtual Result GetCount(sf::Out<u32> out_count) override {
Result GetCount(sf::Out<u32> out_count) {
/* TODO: libnx bindings */
AMS_ABORT();
}
virtual Result GetOwnerApplicationId(sf::Out<ApplicationId> out_id, const ContentMetaKey &key) override {
Result GetOwnerApplicationId(sf::Out<ApplicationId> out_id, const ContentMetaKey &key) {
/* TODO: libnx bindings */
AMS_ABORT();
}
};
static_assert(ncm::IsIContentMetaDatabase<RemoteContentMetaDatabaseImpl>);
}

View file

@ -18,7 +18,7 @@
namespace ams::ncm {
class RemoteContentStorageImpl final : public IContentStorage {
class RemoteContentStorageImpl final {
private:
::NcmContentStorage srv;
public:
@ -46,85 +46,85 @@ namespace ams::ncm {
return reinterpret_cast<::NcmContentId *>(std::addressof(c));
}
public:
virtual Result GeneratePlaceHolderId(sf::Out<PlaceHolderId> out) override {
Result GeneratePlaceHolderId(sf::Out<PlaceHolderId> out) {
return ncmContentStorageGeneratePlaceHolderId(std::addressof(this->srv), Convert(out.GetPointer()));
}
virtual Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) override {
Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) {
static_assert(alignof(ContentId) < alignof(PlaceHolderId));
return ncmContentStorageCreatePlaceHolder(std::addressof(this->srv), Convert(content_id), Convert(placeholder_id), size);
}
virtual Result DeletePlaceHolder(PlaceHolderId placeholder_id) override {
Result DeletePlaceHolder(PlaceHolderId placeholder_id) {
return ncmContentStorageDeletePlaceHolder(std::addressof(this->srv), Convert(placeholder_id));
}
virtual Result HasPlaceHolder(sf::Out<bool> out, PlaceHolderId placeholder_id) override {
Result HasPlaceHolder(sf::Out<bool> out, PlaceHolderId placeholder_id) {
return ncmContentStorageHasPlaceHolder(std::addressof(this->srv), out.GetPointer(), Convert(placeholder_id));
}
virtual Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, sf::InBuffer data) override {
Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, sf::InBuffer data) {
return ncmContentStorageWritePlaceHolder(std::addressof(this->srv), Convert(placeholder_id), offset, data.GetPointer(), data.GetSize());
}
virtual Result Register(PlaceHolderId placeholder_id, ContentId content_id) override {
Result Register(PlaceHolderId placeholder_id, ContentId content_id) {
static_assert(alignof(ContentId) < alignof(PlaceHolderId));
return ncmContentStorageRegister(std::addressof(this->srv), Convert(content_id), Convert(placeholder_id));
}
virtual Result Delete(ContentId content_id) override {
Result Delete(ContentId content_id) {
return ncmContentStorageDelete(std::addressof(this->srv), Convert(content_id));
}
virtual Result Has(sf::Out<bool> out, ContentId content_id) override {
Result Has(sf::Out<bool> out, ContentId content_id) {
return ncmContentStorageHas(std::addressof(this->srv), out.GetPointer(), Convert(content_id));
}
virtual Result GetPath(sf::Out<Path> out, ContentId content_id) override {
Result GetPath(sf::Out<Path> out, ContentId content_id) {
return ncmContentStorageGetPath(std::addressof(this->srv), out.GetPointer()->str, sizeof(out.GetPointer()->str), Convert(content_id));
}
virtual Result GetPlaceHolderPath(sf::Out<Path> out, PlaceHolderId placeholder_id) override {
Result GetPlaceHolderPath(sf::Out<Path> out, PlaceHolderId placeholder_id) {
return ncmContentStorageGetPlaceHolderPath(std::addressof(this->srv), out.GetPointer()->str, sizeof(out.GetPointer()->str), Convert(placeholder_id));
}
virtual Result CleanupAllPlaceHolder() override {
Result CleanupAllPlaceHolder() {
return ncmContentStorageCleanupAllPlaceHolder(std::addressof(this->srv));
}
virtual Result ListPlaceHolder(sf::Out<s32> out_count, const sf::OutArray<PlaceHolderId> &out_buf) override {
Result ListPlaceHolder(sf::Out<s32> out_count, const sf::OutArray<PlaceHolderId> &out_buf) {
return ncmContentStorageListPlaceHolder(std::addressof(this->srv), Convert(out_buf.GetPointer()), out_buf.GetSize(), out_count.GetPointer());
}
virtual Result GetContentCount(sf::Out<s32> out_count) override {
Result GetContentCount(sf::Out<s32> out_count) {
return ncmContentStorageGetContentCount(std::addressof(this->srv), out_count.GetPointer());
}
virtual Result ListContentId(sf::Out<s32> out_count, const sf::OutArray<ContentId> &out_buf, s32 offset) override {
Result ListContentId(sf::Out<s32> out_count, const sf::OutArray<ContentId> &out_buf, s32 offset) {
return ncmContentStorageListContentId(std::addressof(this->srv), Convert(out_buf.GetPointer()), out_buf.GetSize(), out_count.GetPointer(), offset);
}
virtual Result GetSizeFromContentId(sf::Out<s64> out_size, ContentId content_id) override {
Result GetSizeFromContentId(sf::Out<s64> out_size, ContentId content_id) {
return ncmContentStorageGetSizeFromContentId(std::addressof(this->srv), out_size.GetPointer(), Convert(content_id));
}
virtual Result DisableForcibly() override {
Result DisableForcibly() {
return ncmContentStorageDisableForcibly(std::addressof(this->srv));
}
virtual Result RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) override {
Result RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) {
return ncmContentStorageRevertToPlaceHolder(std::addressof(this->srv), Convert(placeholder_id), Convert(old_content_id), Convert(new_content_id));
}
virtual Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) override {
Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) {
return ncmContentStorageSetPlaceHolderSize(std::addressof(this->srv), Convert(placeholder_id), size);
}
virtual Result ReadContentIdFile(sf::OutBuffer buf, ContentId content_id, s64 offset) override {
Result ReadContentIdFile(sf::OutBuffer buf, ContentId content_id, s64 offset) {
return ncmContentStorageReadContentIdFile(std::addressof(this->srv), buf.GetPointer(), buf.GetSize(), Convert(content_id), offset);
}
virtual Result GetRightsIdFromPlaceHolderIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, PlaceHolderId placeholder_id) override {
Result GetRightsIdFromPlaceHolderIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, PlaceHolderId placeholder_id) {
::NcmRightsId rights_id;
R_TRY(ncmContentStorageGetRightsIdFromPlaceHolderId(std::addressof(this->srv), std::addressof(rights_id), Convert(placeholder_id)));
@ -133,7 +133,7 @@ namespace ams::ncm {
return ResultSuccess();
}
virtual Result GetRightsIdFromPlaceHolderId(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id) override {
Result GetRightsIdFromPlaceHolderId(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id) {
::NcmRightsId rights_id;
R_TRY(ncmContentStorageGetRightsIdFromPlaceHolderId(std::addressof(this->srv), std::addressof(rights_id), Convert(placeholder_id)));
@ -142,7 +142,7 @@ namespace ams::ncm {
return ResultSuccess();
}
virtual Result GetRightsIdFromContentIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, ContentId content_id) override {
Result GetRightsIdFromContentIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, ContentId content_id) {
::NcmRightsId rights_id;
R_TRY(ncmContentStorageGetRightsIdFromContentId(std::addressof(this->srv), std::addressof(rights_id), Convert(content_id)));
@ -151,7 +151,7 @@ namespace ams::ncm {
return ResultSuccess();
}
virtual Result GetRightsIdFromContentId(sf::Out<ncm::RightsId> out_rights_id, ContentId content_id) override {
Result GetRightsIdFromContentId(sf::Out<ncm::RightsId> out_rights_id, ContentId content_id) {
::NcmRightsId rights_id;
R_TRY(ncmContentStorageGetRightsIdFromContentId(std::addressof(this->srv), std::addressof(rights_id), Convert(content_id)));
@ -160,35 +160,36 @@ namespace ams::ncm {
return ResultSuccess();
}
virtual Result WriteContentForDebug(ContentId content_id, s64 offset, sf::InBuffer data) override {
Result WriteContentForDebug(ContentId content_id, s64 offset, sf::InBuffer data) {
return ncmContentStorageWriteContentForDebug(std::addressof(this->srv), Convert(content_id), offset, data.GetPointer(), data.GetSize());
}
virtual Result GetFreeSpaceSize(sf::Out<s64> out_size) override {
Result GetFreeSpaceSize(sf::Out<s64> out_size) {
return ncmContentStorageGetFreeSpaceSize(std::addressof(this->srv), out_size.GetPointer());
}
virtual Result GetTotalSpaceSize(sf::Out<s64> out_size) override {
Result GetTotalSpaceSize(sf::Out<s64> out_size) {
return ncmContentStorageGetTotalSpaceSize(std::addressof(this->srv), out_size.GetPointer());
}
virtual Result FlushPlaceHolder() override {
Result FlushPlaceHolder() {
return ncmContentStorageFlushPlaceHolder(std::addressof(this->srv));
}
virtual Result GetSizeFromPlaceHolderId(sf::Out<s64> out_size, PlaceHolderId placeholder_id) override {
Result GetSizeFromPlaceHolderId(sf::Out<s64> out_size, PlaceHolderId placeholder_id) {
return ncmContentStorageGetSizeFromPlaceHolderId(std::addressof(this->srv), out_size.GetPointer(), Convert(placeholder_id));
}
virtual Result RepairInvalidFileAttribute() override {
Result RepairInvalidFileAttribute() {
return ncmContentStorageRepairInvalidFileAttribute(std::addressof(this->srv));
}
virtual Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) override {
Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) {
static_assert(sizeof(::NcmRightsId) == sizeof(ncm::RightsId));
::NcmRightsId *out = reinterpret_cast<::NcmRightsId *>(out_rights_id.GetPointer());
return ncmContentStorageGetRightsIdFromPlaceHolderIdWithCache(std::addressof(this->srv), out, Convert(placeholder_id), Convert(cache_content_id));
}
};
static_assert(ncm::IsIContentStorage<RemoteContentStorageImpl>);
}

View file

@ -18,28 +18,29 @@
namespace ams::pgl {
class RemoteEventObserver final : public pgl::sf::IEventObserver {
class RemoteEventObserver final {
NON_COPYABLE(RemoteEventObserver);
NON_MOVEABLE(RemoteEventObserver);
private:
::PglEventObserver observer;
public:
constexpr RemoteEventObserver(const ::PglEventObserver &o) : observer(o) { /* ... */ }
virtual ~RemoteEventObserver() override {
~RemoteEventObserver() {
::pglEventObserverClose(std::addressof(this->observer));
}
virtual Result GetProcessEventHandle(ams::sf::OutCopyHandle out) override {
Result GetProcessEventHandle(ams::sf::OutCopyHandle out) {
::Event ev;
R_TRY(::pglEventObserverGetProcessEvent(std::addressof(this->observer), std::addressof(ev)));
out.SetValue(ev.revent);
return ResultSuccess();
}
virtual Result GetProcessEventInfo(ams::sf::Out<pm::ProcessEventInfo> out) override {
Result GetProcessEventInfo(ams::sf::Out<pm::ProcessEventInfo> out) {
static_assert(sizeof(*out.GetPointer()) == sizeof(::PmProcessEventInfo));
return ::pglEventObserverGetProcessEventInfo(std::addressof(this->observer), reinterpret_cast<::PmProcessEventInfo *>(out.GetPointer()));
}
};
static_assert(pgl::sf::IsIEventObserver<RemoteEventObserver>);
}

View file

@ -79,7 +79,7 @@ namespace ams::pgl {
::PglEventObserver obs;
R_TRY(::pglGetEventObserver(std::addressof(obs)));
auto remote_observer = std::make_shared<RemoteEventObserver>(obs);
auto remote_observer = ams::sf::MakeShared<pgl::sf::IEventObserver, RemoteEventObserver>(obs);
AMS_ABORT_UNLESS(remote_observer != nullptr);
*out = pgl::EventObserver(remote_observer);

View file

@ -66,13 +66,13 @@ namespace ams::pgl::srv {
this->event.Signal();
}
Result EventObserverInterface::GetProcessEventHandle(ams::sf::OutCopyHandle out) {
out.SetValue(GetReference(this->observer).GetEvent().GetReadableHandle());
Result ShellEventObserver::GetProcessEventHandle(ams::sf::OutCopyHandle out) {
out.SetValue(this->GetEvent().GetReadableHandle());
return ResultSuccess();
}
Result EventObserverInterface::GetProcessEventInfo(ams::sf::Out<pm::ProcessEventInfo> out) {
return GetReference(this->observer).PopEventInfo(out.GetPointer());
Result ShellEventObserver::GetProcessEventInfo(ams::sf::Out<pm::ProcessEventInfo> out) {
return this->PopEventInfo(out.GetPointer());
}
}
}

View file

@ -56,23 +56,10 @@ namespace ams::pgl::srv {
Result PopEventInfo(pm::ProcessEventInfo *out);
virtual void Notify(const pm::ProcessEventInfo &info) override final;
};
class EventObserverInterface final : public pgl::sf::IEventObserver {
private:
TYPED_STORAGE(ShellEventObserver) observer;
public:
EventObserverInterface() {
std::memset(std::addressof(this->observer), 0, sizeof(this->observer));
new (GetPointer(this->observer)) ShellEventObserver;
}
~EventObserverInterface() {
GetReference(this->observer).~ShellEventObserver();
}
public:
virtual Result GetProcessEventHandle(ams::sf::OutCopyHandle out) override final;
virtual Result GetProcessEventInfo(ams::sf::Out<pm::ProcessEventInfo> out) override final;
Result GetProcessEventHandle(ams::sf::OutCopyHandle out);
Result GetProcessEventInfo(ams::sf::Out<pm::ProcessEventInfo> out);
};
static_assert(pgl::sf::IsIEventObserver<ShellEventObserver>);
}

View file

@ -69,20 +69,22 @@ namespace ams::pgl::srv {
}
Result ShellInterface::GetShellEventObserver(ams::sf::Out<std::shared_ptr<pgl::sf::IEventObserver>> out) {
using Interface = typename pgl::sf::IEventObserver::ImplHolder<ShellEventObserver>;
/* Allocate a new interface. */
auto *observer_memory = this->memory_resource->Allocate(sizeof(EventObserverInterface), alignof(EventObserverInterface));
auto *observer_memory = this->memory_resource->Allocate(sizeof(Interface), alignof(Interface));
AMS_ABORT_UNLESS(observer_memory != nullptr);
/* Create the interface object. */
new (observer_memory) EventObserverInterface;
new (observer_memory) Interface;
/* Set the output. */
out.SetValue(std::shared_ptr<EventObserverInterface>(reinterpret_cast<EventObserverInterface *>(observer_memory), [&](EventObserverInterface *obj) {
out.SetValue(std::shared_ptr<pgl::sf::IEventObserver>(reinterpret_cast<Interface *>(observer_memory), [&](Interface *obj) {
/* Destroy the object. */
obj->~EventObserverInterface();
obj->~Interface();
/* Custom deleter: use the memory resource to free. */
this->memory_resource->Deallocate(obj, sizeof(EventObserverInterface), alignof(EventObserverInterface));
this->memory_resource->Deallocate(obj, sizeof(Interface), alignof(Interface));
}));
return ResultSuccess();
}

View file

@ -34,7 +34,7 @@ namespace ams::psc {
::PscPmModule module;
R_TRY(::pscmGetPmModule(std::addressof(module), static_cast<::PscPmModuleId>(mid), reinterpret_cast<const u16 *>(dependencies), dependency_count, clear_mode == os::EventClearMode_AutoClear));
this->intf = std::make_shared<RemotePmModule>(module);
this->intf = ams::sf::MakeShared<psc::sf::IPmModule, RemotePmModule>(module);
this->system_event.AttachReadableHandle(module.event.revent, false, clear_mode);
this->initialized = true;
return ResultSuccess();

View file

@ -18,41 +18,42 @@
namespace ams::psc {
class RemotePmModule final : public psc::sf::IPmModule {
class RemotePmModule final {
NON_COPYABLE(RemotePmModule);
NON_MOVEABLE(RemotePmModule);
private:
::PscPmModule module;
public:
constexpr RemotePmModule(const ::PscPmModule &m) : module(m) { /* ... */ }
virtual ~RemotePmModule() override {
~RemotePmModule() {
::pscPmModuleClose(std::addressof(this->module));
}
virtual Result Initialize(ams::sf::OutCopyHandle out, psc::PmModuleId module_id, const ams::sf::InBuffer &child_list) override final {
Result Initialize(ams::sf::OutCopyHandle out, psc::PmModuleId module_id, const ams::sf::InBuffer &child_list) {
/* NOTE: This functionality is already implemented by the libnx command we use to instantiate the PscPmModule. */
AMS_ABORT();
}
virtual Result GetRequest(ams::sf::Out<PmState> out_state, ams::sf::Out<PmFlagSet> out_flags) override final {
Result GetRequest(ams::sf::Out<PmState> out_state, ams::sf::Out<PmFlagSet> out_flags) {
static_assert(sizeof(PmState) == sizeof(::PscPmState));
static_assert(sizeof(PmFlagSet) == sizeof(u32));
return ::pscPmModuleGetRequest(std::addressof(this->module), reinterpret_cast<::PscPmState *>(out_state.GetPointer()), reinterpret_cast<u32 *>(out_flags.GetPointer()));
}
virtual Result Acknowledge() override final {
Result Acknowledge() {
/* NOTE: libnx does not separate acknowledge/acknowledgeEx. */
return ::pscPmModuleAcknowledge(std::addressof(this->module), static_cast<::PscPmState>(0));
}
virtual Result Finalize() override final {
Result Finalize() {
return ::pscPmModuleFinalize(std::addressof(this->module));
}
virtual Result AcknowledgeEx(PmState state) override final {
Result AcknowledgeEx(PmState state) {
static_assert(sizeof(state) == sizeof(::PscPmState));
return ::pscPmModuleAcknowledge(std::addressof(this->module), static_cast<::PscPmState>(state));
}
};
static_assert(psc::sf::IsIPmModule<RemotePmModule>);
}

View file

@ -20,11 +20,13 @@ namespace ams::sf::hipc::impl {
namespace {
class MitmQueryService : public IServiceObject {
private:
enum class CommandId {
ShouldMitm = 65000,
};
#define AMS_SF_HIPC_IMPL_I_MITM_QUERY_SERVICE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 65000, void, ShouldMitm, (sf::Out<bool> out, const sm::MitmProcessInfo &client_info))
AMS_SF_DEFINE_INTERFACE(IMitmQueryService, AMS_SF_HIPC_IMPL_I_MITM_QUERY_SERVICE_INTERFACE_INFO)
class MitmQueryService {
private:
ServerManagerBase::MitmQueryFunction query_function;
public:
@ -33,11 +35,8 @@ namespace ams::sf::hipc::impl {
void ShouldMitm(sf::Out<bool> out, const sm::MitmProcessInfo &client_info) {
out.SetValue(this->query_function(client_info));
}
public:
DEFINE_SERVICE_DISPATCH_TABLE {
MAKE_SERVICE_COMMAND_META(ShouldMitm),
};
};
static_assert(IsIMitmQueryService<MitmQueryService>);
/* Globals. */
os::Mutex g_query_server_lock(false);
@ -66,7 +65,7 @@ namespace ams::sf::hipc::impl {
g_constructed_server = true;
}
R_ABORT_UNLESS(GetPointer(g_query_server_storage)->RegisterSession(query_handle, cmif::ServiceObjectHolder(std::make_shared<MitmQueryService>(query_func))));
R_ABORT_UNLESS(GetPointer(g_query_server_storage)->RegisterSession(query_handle, cmif::ServiceObjectHolder(sf::MakeShared<IMitmQueryService, MitmQueryService>(query_func))));
if (AMS_UNLIKELY(!g_registered_any)) {
R_ABORT_UNLESS(os::CreateThread(std::addressof(g_query_server_process_thread), &QueryServerProcessThreadMain, GetPointer(g_query_server_storage), g_server_process_thread_stack, sizeof(g_server_process_thread_stack), AMS_GET_SYSTEM_THREAD_PRIORITY(mitm_sf, QueryServerProcessThread)));

View file

@ -19,15 +19,16 @@ namespace ams::sf::hipc {
namespace impl {
class HipcManager : public IServiceObject {
private:
enum class CommandId {
ConvertCurrentObjectToDomain = 0,
CopyFromCurrentDomain = 1,
CloneCurrentObject = 2,
QueryPointerBufferSize = 3,
CloneCurrentObjectEx = 4,
};
#define AMS_SF_HIPC_IMPL_I_HIPC_MANAGER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, ConvertCurrentObjectToDomain, (ams::sf::Out<ams::sf::cmif::DomainObjectId> out)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, CopyFromCurrentDomain, (ams::sf::OutMoveHandle out, ams::sf::cmif::DomainObjectId object_id)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, CloneCurrentObject, (ams::sf::OutMoveHandle out)) \
AMS_SF_METHOD_INFO(C, H, 3, void, QueryPointerBufferSize, (ams::sf::Out<u16> out)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, CloneCurrentObjectEx, (ams::sf::OutMoveHandle out, u32 tag))
AMS_SF_DEFINE_INTERFACE(IHipcManager, AMS_SF_HIPC_IMPL_I_HIPC_MANAGER_INTERFACE_INFO)
class HipcManager final {
private:
ServerDomainSessionManager *manager;
ServerSession *session;
@ -150,16 +151,8 @@ namespace ams::sf::hipc {
Result CloneCurrentObjectEx(sf::OutMoveHandle out, u32 tag) {
return this->CloneCurrentObjectImpl(out.GetHandlePointer(), this->manager->GetSessionManagerByTag(tag));
}
public:
DEFINE_SERVICE_DISPATCH_TABLE {
MAKE_SERVICE_COMMAND_META(ConvertCurrentObjectToDomain),
MAKE_SERVICE_COMMAND_META(CopyFromCurrentDomain),
MAKE_SERVICE_COMMAND_META(CloneCurrentObject),
MAKE_SERVICE_COMMAND_META(QueryPointerBufferSize),
MAKE_SERVICE_COMMAND_META(CloneCurrentObjectEx),
};
};
static_assert(IsIHipcManager<HipcManager>);
}
@ -168,7 +161,7 @@ namespace ams::sf::hipc {
/* Note: This is safe, as no additional references to the hipc manager can ever be stored. */
/* The shared pointer to stack object is definitely gross, though. */
impl::HipcManager hipc_manager(this, session);
return this->DispatchRequest(cmif::ServiceObjectHolder(std::move(ServiceObjectTraits<impl::HipcManager>::SharedPointerHelper::GetEmptyDeleteSharedPointer(&hipc_manager))), session, in_message, out_message);
return this->DispatchRequest(cmif::ServiceObjectHolder(sf::GetSharedPointerTo<impl::IHipcManager>(hipc_manager)), session, in_message, out_message);
}
}