diff --git a/libraries/libstratosphere/include/stratosphere/ldr/impl/ldr_process_manager_interface.hpp b/libraries/libstratosphere/include/stratosphere/ldr/impl/ldr_process_manager_interface.hpp index 176ceba7a..4e0f36bb0 100644 --- a/libraries/libstratosphere/include/stratosphere/ldr/impl/ldr_process_manager_interface.hpp +++ b/libraries/libstratosphere/include/stratosphere/ldr/impl/ldr_process_manager_interface.hpp @@ -20,7 +20,7 @@ #include #define AMS_LDR_I_PROCESS_MANAGER_INTERFACE_INTERFACE_INFO(C, H) \ - AMS_SF_METHOD_INFO(C, H, 0, Result, CreateProcess, (sf::OutMoveHandle proc_h, ldr::PinId id, u32 flags, sf::CopyHandle reslimit_h), (proc_h, id, flags, reslimit_h)) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, CreateProcess, (sf::OutMoveHandle proc_h, ldr::PinId id, u32 flags, sf::CopyHandle &&reslimit_h), (proc_h, id, flags, std::move(reslimit_h))) \ AMS_SF_METHOD_INFO(C, H, 1, Result, GetProgramInfo, (sf::Out out_program_info, const ncm::ProgramLocation &loc), (out_program_info, loc)) \ AMS_SF_METHOD_INFO(C, H, 2, Result, PinProgram, (sf::Out out_id, const ncm::ProgramLocation &loc), (out_id, loc)) \ AMS_SF_METHOD_INFO(C, H, 3, Result, UnpinProgram, (ldr::PinId id), (id)) \ diff --git a/libraries/libstratosphere/include/stratosphere/pgl/pgl_event_observer.hpp b/libraries/libstratosphere/include/stratosphere/pgl/pgl_event_observer.hpp index 8e8a2a71a..5e6250aba 100644 --- a/libraries/libstratosphere/include/stratosphere/pgl/pgl_event_observer.hpp +++ b/libraries/libstratosphere/include/stratosphere/pgl/pgl_event_observer.hpp @@ -46,9 +46,12 @@ namespace ams::pgl { explicit EventObserverByCmif(ams::sf::SharedPointer intf) : m_cmif_interface(intf) { /* ... */ } public: virtual Result GetSystemEvent(os::SystemEventType *out) override { - ams::sf::CopyHandle handle; + ams::sf::NativeHandle handle; R_TRY(m_cmif_interface->GetProcessEventHandle(std::addressof(handle))); - os::AttachSystemEvent(out, handle.GetValue(), true, svc::InvalidHandle, false, os::EventClearMode_AutoClear); + + os::AttachReadableHandleToSystemEvent(out, handle.GetOsHandle(), handle.IsManaged(), os::EventClearMode_AutoClear); + handle.Detach(); + return ResultSuccess(); } @@ -70,7 +73,7 @@ namespace ams::pgl { virtual Result GetSystemEvent(os::SystemEventType *out) override { ams::tipc::CopyHandle handle; R_TRY(m_tipc_interface.GetProcessEventHandle(std::addressof(handle))); - os::AttachSystemEvent(out, handle.GetValue(), true, svc::InvalidHandle, false, os::EventClearMode_AutoClear); + os::AttachReadableHandleToSystemEvent(out, handle.GetValue(), true, os::EventClearMode_AutoClear); return ResultSuccess(); } diff --git a/libraries/libstratosphere/include/stratosphere/ro/impl/ro_ro_interface.hpp b/libraries/libstratosphere/include/stratosphere/ro/impl/ro_ro_interface.hpp index 33f306a49..e528c0772 100644 --- a/libraries/libstratosphere/include/stratosphere/ro/impl/ro_ro_interface.hpp +++ b/libraries/libstratosphere/include/stratosphere/ro/impl/ro_ro_interface.hpp @@ -24,7 +24,7 @@ AMS_SF_METHOD_INFO(C, H, 1, Result, UnmapManualLoadModuleMemory, (const sf::ClientProcessId &client_pid, u64 nro_address), (client_pid, nro_address)) \ AMS_SF_METHOD_INFO(C, H, 2, Result, RegisterModuleInfo, (const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size), (client_pid, nrr_address, nrr_size)) \ AMS_SF_METHOD_INFO(C, H, 3, Result, UnregisterModuleInfo, (const sf::ClientProcessId &client_pid, u64 nrr_address), (client_pid, nrr_address)) \ - AMS_SF_METHOD_INFO(C, H, 4, Result, RegisterProcessHandle, (const sf::ClientProcessId &client_pid, sf::CopyHandle process_h), (client_pid, process_h)) \ - AMS_SF_METHOD_INFO(C, H, 10, Result, RegisterProcessModuleInfo, (const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size, sf::CopyHandle process_h), (client_pid, nrr_address, nrr_size, process_h), hos::Version_7_0_0) + AMS_SF_METHOD_INFO(C, H, 4, Result, RegisterProcessHandle, (const sf::ClientProcessId &client_pid, sf::CopyHandle &&process_h), (client_pid, std::move(process_h))) \ + AMS_SF_METHOD_INFO(C, H, 10, Result, RegisterProcessModuleInfo, (const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size, sf::CopyHandle &&process_h), (client_pid, nrr_address, nrr_size, std::move(process_h)), hos::Version_7_0_0) AMS_SF_DEFINE_INTERFACE(ams::ro::impl, IRoInterface, AMS_RO_I_RO_INTERFACE_INTERFACE_INFO) diff --git a/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp b/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp index 285e05f8a..f31ab63de 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include @@ -199,15 +199,18 @@ namespace ams::sf::impl { template constexpr inline ArgumentType GetArgumentType = [] { + static_assert(!std::same_as); + static_assert(!std::same_as>); + if constexpr (sf::IsBuffer) { return ArgumentType::Buffer; } else if constexpr (IsInObject::value) { return ArgumentType::InObject; } else if constexpr (std::is_base_of::value) { return ArgumentType::OutObject; - } else if constexpr (std::is_base_of::value) { + } else if constexpr (std::same_as || std::same_as) { return ArgumentType::InHandle; - } else if constexpr (std::is_base_of::value) { + } else if constexpr (std::same_as || std::same_as) { return ArgumentType::OutHandle; } else if constexpr (std::is_base_of::value) { return ArgumentType::OutData; @@ -413,7 +416,7 @@ namespace ams::sf::impl { }; template - using DecayForCommandMetaArguments = typename std::conditional::type> && !std::is_base_of::type>::value, T, typename std::decay::type>::type; + using DecayForCommandMetaArguments = typename std::conditional<(sf::IsLargeData::type> && !std::is_base_of::type>::value), T, typename std::conditional<(std::same_as || std::same_as), typename std::decay::type &, typename std::decay::type>::type>::type; template struct CommandMetaInfo { @@ -625,38 +628,57 @@ namespace ams::sf::impl { }; template - class OutHandleHolder { + class InHandleHolder { public: static constexpr size_t NumMove = _NumMove; static constexpr size_t NumCopy = _NumCopy; private: MoveHandle move_handles[NumMove]; CopyHandle copy_handles[NumCopy]; - bool copy_managed[NumCopy]; public: - constexpr OutHandleHolder() : move_handles(), copy_handles(), copy_managed() { /* ... */ } + constexpr InHandleHolder() : move_handles(), copy_handles() { /* ... */ } template - constexpr inline MoveHandle *GetMoveHandlePointer() { + constexpr inline MoveHandle &SetMoveHandle(os::NativeHandle os_handle) { + static_assert(Index < NumMove); + move_handles[Index] = sf::NativeHandle(os_handle, true); + return move_handles[Index]; + } + + template + constexpr inline CopyHandle &SetCopyHandle(os::NativeHandle os_handle) { + static_assert(Index < NumCopy); + copy_handles[Index] = sf::NativeHandle(os_handle, true); + return copy_handles[Index]; + } + }; + + template + class OutHandleHolder { + public: + static constexpr size_t NumMove = _NumMove; + static constexpr size_t NumCopy = _NumCopy; + private: + NativeHandle move_handles[NumMove]; + NativeHandle copy_handles[NumCopy]; + public: + constexpr OutHandleHolder() : move_handles(), copy_handles() { /* ... */ } + + template + constexpr inline NativeHandle *GetMoveHandlePointer() { static_assert(Index < NumMove, "Index < NumMove"); - return &move_handles[Index]; + return move_handles + Index; } template - constexpr inline CopyHandle *GetCopyHandlePointer() { + constexpr inline NativeHandle *GetCopyHandlePointer() { static_assert(Index < NumCopy, "Index < NumCopy"); - return ©_handles[Index]; - } - - template - constexpr inline bool *GetCopyHandleManagedPointer() { - static_assert(Index < NumCopy, "Index < NumCopy"); - return ©_managed[Index]; + return copy_handles + Index; } constexpr inline void CopyTo(const cmif::ServiceDispatchContext &ctx, const HipcRequest &response, const size_t num_out_object_handles) { ctx.handles_to_close->num_handles = 0; - #define _SF_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(n) do { if constexpr (NumCopy > n) { const auto handle = copy_handles[n].GetValue(); response.copy_handles[n] = handle; if (copy_managed[n]) { ctx.handles_to_close->handles[ctx.handles_to_close->num_handles++] = handle; } } } while (0) + #define _SF_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(n) do { if constexpr (NumCopy > n) { const auto handle = copy_handles[n].GetOsHandle(); response.copy_handles[n] = handle; if (copy_handles[n].IsManaged()) { ctx.handles_to_close->handles[ctx.handles_to_close->num_handles++] = handle; } copy_handles[n].Detach(); } } while (0) _SF_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(0); _SF_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(1); _SF_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(2); @@ -666,7 +688,7 @@ namespace ams::sf::impl { _SF_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(6); _SF_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(7); #undef _SF_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE - #define _SF_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(n) do { if constexpr (NumMove > n) { response.move_handles[n + num_out_object_handles] = move_handles[n].GetValue(); } } while (0) + #define _SF_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(n) do { if constexpr (NumMove > n) { response.move_handles[n + num_out_object_handles] = move_handles[n].GetOsHandle(); move_handles[n].Detach(); } } while (0) _SF_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(0); _SF_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(1); _SF_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(2); @@ -830,6 +852,7 @@ namespace ams::sf::impl { using ArgsType = typename CommandMeta::ArgsType; using BufferArrayType = std::array; using OutRawHolderType = OutRawHolder; + using InHandleHolderType = InHandleHolder; using OutHandleHolderType = OutHandleHolder; using InOutObjectHolderType = InOutObjectHolder; @@ -1014,7 +1037,7 @@ namespace ams::sf::impl { /* Argument deserialization. */ private: template::type> - NX_CONSTEXPR typename std::tuple_element::type DeserializeArgumentImpl(const cmif::ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data, const OutRawHolderType &out_raw_holder, const BufferArrayType &buffers, OutHandleHolderType &out_handles_holder, InOutObjectHolderType &in_out_objects_holder) { + NX_CONSTEXPR typename std::tuple_element::type DeserializeArgumentImpl(const cmif::ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data, const OutRawHolderType &out_raw_holder, const BufferArrayType &buffers, InHandleHolderType &in_handles_holder, OutHandleHolderType &out_handles_holder, InOutObjectHolderType &in_out_objects_holder) { constexpr auto Info = CommandMeta::ArgumentSerializationInfos[Index]; if constexpr (Info.arg_type == ArgumentType::InData) { /* New in rawdata. */ @@ -1031,19 +1054,22 @@ namespace ams::sf::impl { return T(out_raw_holder.template GetAddress()); } else if constexpr (Info.arg_type == ArgumentType::InHandle) { /* New InHandle. */ + using InvokeType = typename std::tuple_element::type; if constexpr (std::is_same::value) { - return T(ctx.request.data.move_handles[Info.in_move_handle_index]); + static_assert(std::same_as); + return in_handles_holder.template SetMoveHandle(ctx.request.data.move_handles[Info.in_move_handle_index]); } else if constexpr (std::is_same::value) { - return T(ctx.request.data.copy_handles[Info.in_copy_handle_index]); + static_assert(std::same_as); + return in_handles_holder.template SetCopyHandle(ctx.request.data.copy_handles[Info.in_copy_handle_index]); } else { static_assert(!std::is_same::value, "Invalid InHandle kind"); } } else if constexpr (Info.arg_type == ArgumentType::OutHandle) { /* New OutHandle. */ - if constexpr (std::is_same>::value) { + if constexpr (std::is_same::value) { return T(out_handles_holder.template GetMoveHandlePointer()); - } else if constexpr (std::is_same>::value) { - return T(out_handles_holder.template GetCopyHandlePointer(), out_handles_holder.template GetCopyHandleManagedPointer()); + } else if constexpr (std::is_same::value) { + return T(out_handles_holder.template GetCopyHandlePointer()); } else { static_assert(!std::is_same::value, "Invalid OutHandle kind"); } @@ -1078,12 +1104,12 @@ namespace ams::sf::impl { } template - NX_CONSTEXPR ArgsTypeForInvoke DeserializeArgumentsImpl(const cmif::ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data, const OutRawHolderType &out_raw_holder, const BufferArrayType &buffers, OutHandleHolderType &out_handles_holder, InOutObjectHolderType &in_out_objects_holder, std::index_sequence) { - return ArgsTypeForInvoke { DeserializeArgumentImpl(ctx, in_raw_data, out_raw_holder, buffers, out_handles_holder, in_out_objects_holder)..., }; + NX_CONSTEXPR ArgsTypeForInvoke DeserializeArgumentsImpl(const cmif::ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data, const OutRawHolderType &out_raw_holder, const BufferArrayType &buffers, InHandleHolderType &in_handles_holder, OutHandleHolderType &out_handles_holder, InOutObjectHolderType &in_out_objects_holder, std::index_sequence) { + return ArgsTypeForInvoke { DeserializeArgumentImpl(ctx, in_raw_data, out_raw_holder, buffers, in_handles_holder, out_handles_holder, in_out_objects_holder)..., }; } public: - NX_CONSTEXPR ArgsTypeForInvoke DeserializeArguments(const cmif::ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data, const OutRawHolderType &out_raw_holder, const BufferArrayType &buffers, OutHandleHolderType &out_handles_holder, InOutObjectHolderType &in_out_objects_holder) { - return DeserializeArgumentsImpl(ctx, in_raw_data, out_raw_holder, buffers, out_handles_holder, in_out_objects_holder, std::make_index_sequence::value>{}); + NX_CONSTEXPR ArgsTypeForInvoke DeserializeArguments(const cmif::ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data, const OutRawHolderType &out_raw_holder, const BufferArrayType &buffers, InHandleHolderType &in_handles_holder, OutHandleHolderType &out_handles_holder, InOutObjectHolderType &in_out_objects_holder) { + return DeserializeArgumentsImpl(ctx, in_raw_data, out_raw_holder, buffers, in_handles_holder, out_handles_holder, in_out_objects_holder, std::make_index_sequence::value>{}); } }; @@ -1099,6 +1125,7 @@ namespace ams::sf::impl { constexpr Result InvokeServiceCommandImplCommon(CmifOutHeader **out_header_ptr, cmif::ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data, Result (*invoke_impl)(sf::IServiceObject *, Arguments &&...)) { using ImplProcessorType = HipcCommandProcessor; using BufferArrayType = std::array; + using InHandleHolderType = InHandleHolder; using OutHandleHolderType = OutHandleHolder; using OutRawHolderType = OutRawHolder; using InOutObjectHolderType = InOutObjectHolder; @@ -1133,39 +1160,43 @@ namespace ams::sf::impl { /* Decoding/Invocation. */ { - typename CommandMeta::ArgsTypeForInvoke args_tuple = ImplProcessorType::DeserializeArguments(ctx, in_raw_data, out_raw_holder, buffers, out_handles_holder, in_out_objects_holder); + Result command_result; + { + InHandleHolderType in_handles_holder; + typename CommandMeta::ArgsTypeForInvoke args_tuple = ImplProcessorType::DeserializeArguments(ctx, in_raw_data, out_raw_holder, buffers, in_handles_holder, out_handles_holder, in_out_objects_holder); - /* Handle in process ID holder if relevant. */ - if constexpr (CommandMeta::HasInProcessIdHolder) { - /* TODO: More precise value than 32? */ - static_assert(std::tuple_size::value <= 32, "Commands must have <= 32 arguments"); - os::ProcessId process_id{ctx.request.pid}; - #define _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(n) do { \ - using ArgsTypeForInvoke = typename CommandMeta::ArgsTypeForInvoke; \ - if constexpr (n < std::tuple_size::value) { \ - if constexpr (CommandMeta::template IsInProcessIdHolderIndex) { \ - R_TRY(MarshalProcessId(std::get(args_tuple), process_id)); \ - } \ - } \ - } while (0) - _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x00); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x01); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x02); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x03); - _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x04); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x05); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x06); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x07); - _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x08); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x09); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x0a); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x0b); - _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x0c); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x0d); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x0e); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x0f); - _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x10); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x11); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x12); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x13); - _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x14); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x15); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x16); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x17); - _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x18); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x19); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x1a); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x1b); - _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x1c); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x1d); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x1e); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x1f); - #undef _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID + /* Handle in process ID holder if relevant. */ + if constexpr (CommandMeta::HasInProcessIdHolder) { + /* TODO: More precise value than 32? */ + static_assert(std::tuple_size::value <= 32, "Commands must have <= 32 arguments"); + const os::ProcessId process_id{ctx.request.pid}; + #define _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(n) do { \ + using ArgsTypeForInvoke = typename CommandMeta::ArgsTypeForInvoke; \ + if constexpr (n < std::tuple_size::value) { \ + if constexpr (CommandMeta::template IsInProcessIdHolderIndex) { \ + R_TRY(MarshalProcessId(std::get(args_tuple), process_id)); \ + } \ + } \ + } while (0) + _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x00); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x01); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x02); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x03); + _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x04); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x05); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x06); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x07); + _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x08); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x09); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x0a); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x0b); + _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x0c); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x0d); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x0e); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x0f); + _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x10); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x11); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x12); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x13); + _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x14); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x15); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x16); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x17); + _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x18); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x19); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x1a); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x1b); + _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x1c); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x1d); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x1e); _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID(0x1f); + #undef _SF_IMPL_PROCESSOR_MARSHAL_PROCESS_ID + } + + using TrueArgumentsTuple = std::tuple; + + sf::IServiceObject * const this_ptr = ctx.srv_obj; + command_result = [this_ptr, invoke_impl, &args_tuple](std::index_sequence) ALWAYS_INLINE_LAMBDA { + return invoke_impl(this_ptr, std::forward::type>(std::get(args_tuple))...); + }(std::make_index_sequence::value>()); } - using TrueArgumentsTuple = std::tuple; - - sf::IServiceObject * const this_ptr = ctx.srv_obj; - const auto command_result = [this_ptr, invoke_impl, &args_tuple](std::index_sequence) ALWAYS_INLINE_LAMBDA { - return invoke_impl(this_ptr, std::forward::type>(std::get(args_tuple))...); - }(std::make_index_sequence::value>()); - if (R_FAILED(command_result)) { cmif::PointerAndSize out_raw_data; ctx.processor->PrepareForErrorReply(ctx, out_raw_data, runtime_metadata); diff --git a/libraries/libstratosphere/include/stratosphere/sf/sf_handles.hpp b/libraries/libstratosphere/include/stratosphere/sf/sf_handles.hpp deleted file mode 100644 index 0f8494052..000000000 --- a/libraries/libstratosphere/include/stratosphere/sf/sf_handles.hpp +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (c) Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include -#include -#include - -namespace ams::sf { - - namespace impl { - - struct InHandleTag{}; - struct OutHandleTag{}; - - template - struct InHandle : public InHandleTag { - os::NativeHandle handle; - - constexpr InHandle() : handle(os::InvalidNativeHandle) { /* ... */ } - constexpr InHandle(os::NativeHandle h) : handle(h) { /* ... */ } - constexpr InHandle(const InHandle &o) : handle(o.handle) { /* ... */ } - - constexpr void operator=(const os::NativeHandle &h) { this->handle = h; } - constexpr void operator=(const InHandle &o) { this->handle = o.handle; } - - constexpr /* TODO: explicit? */ operator os::NativeHandle() const { return this->handle; } - constexpr os::NativeHandle GetValue() const { return this->handle; } - }; - - template - class OutHandleImpl : public OutHandleTag { - static_assert(std::is_base_of::value, "OutHandleImpl requires InHandle base"); - private: - T *ptr; - public: - constexpr OutHandleImpl(T *p) : ptr(p) { /* ... */ } - - constexpr void SetValue(const os::NativeHandle &value) { - *this->ptr = value; - } - - constexpr void SetValue(const T &value) { - *this->ptr = value; - } - - constexpr const T &GetValue() const { - return *this->ptr; - } - - constexpr T *GetPointer() const { - return this->ptr; - } - - constexpr os::NativeHandle *GetHandlePointer() const { - return &this->ptr->handle; - } - - constexpr T &operator *() const { - return *this->ptr; - } - - constexpr T *operator ->() const { - return this->ptr; - } - }; - - } - - using MoveHandle = typename impl::InHandle; - using CopyHandle = typename impl::InHandle; - - static_assert(sizeof(MoveHandle) == sizeof(os::NativeHandle), "sizeof(MoveHandle)"); - static_assert(sizeof(CopyHandle) == sizeof(os::NativeHandle), "sizeof(CopyHandle)"); - - template<> - class IsOutForceEnabled : public std::true_type{}; - template<> - class IsOutForceEnabled : public std::true_type{}; - - template<> - class Out : public impl::OutHandleImpl { - private: - using T = MoveHandle; - using Base = impl::OutHandleImpl; - public: - constexpr Out(T *p) : Base(p) { /* ... */ } - - constexpr void SetValue(const os::NativeHandle &value) { - Base::SetValue(value); - } - - constexpr void SetValue(const T &value) { - Base::SetValue(value); - } - - constexpr const T &GetValue() const { - return Base::GetValue(); - } - - constexpr T *GetPointer() const { - return Base::GetPointer(); - } - - constexpr os::NativeHandle *GetHandlePointer() const { - return Base::GetHandlePointer(); - } - - constexpr T &operator *() const { - return Base::operator*(); - } - - constexpr T *operator ->() const { - return Base::operator->(); - } - }; - - template<> - class Out : public impl::OutHandleImpl { - private: - using T = CopyHandle; - using Base = impl::OutHandleImpl; - private: - bool *m_managed; - public: - constexpr Out(T *p) : Base(p), m_managed(nullptr) { /* ... */ } - constexpr Out(T *p, bool *m) : Base(p), m_managed(m) { /* ... */ } - - constexpr void SetValue(const os::NativeHandle &value) { - Base::SetValue(value); - } - - constexpr void SetValue(const T &value) { - Base::SetValue(value); - } - - constexpr void SetManaged(bool m) { - AMS_ASSERT(m_managed != nullptr); - *m_managed = m; - } - - constexpr const T &GetValue() const { - return Base::GetValue(); - } - - constexpr T *GetPointer() const { - return Base::GetPointer(); - } - - constexpr os::NativeHandle *GetHandlePointer() const { - return Base::GetHandlePointer(); - } - - constexpr T &operator *() const { - return Base::operator*(); - } - - constexpr T *operator ->() const { - return Base::operator->(); - } - }; - - using OutMoveHandle = sf::Out; - using OutCopyHandle = sf::Out; - -} diff --git a/libraries/libstratosphere/include/stratosphere/sf/sf_native_handle.hpp b/libraries/libstratosphere/include/stratosphere/sf/sf_native_handle.hpp index bc5a8f6aa..d83650784 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/sf_native_handle.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/sf_native_handle.hpp @@ -21,7 +21,8 @@ namespace ams::sf { class NativeHandle { - NON_COPYABLE(NativeHandle); + protected: + NON_COPYABLE(NativeHandle); private: os::NativeHandle m_handle; bool m_managed; @@ -77,12 +78,24 @@ namespace ams::sf { } }; - ALWAYS_INLINE void swap(NativeHandle &lhs, NativeHandle &rhs) { + class CopyHandle : public NativeHandle { + public: + using NativeHandle::NativeHandle; + using NativeHandle::operator=; + }; + + class MoveHandle : public NativeHandle { + public: + using NativeHandle::NativeHandle; + using NativeHandle::operator=; + }; + + constexpr ALWAYS_INLINE void swap(NativeHandle &lhs, NativeHandle &rhs) { lhs.swap(rhs); } template<> - class Out { + class Out { private: NativeHandle *m_ptr; public: @@ -92,9 +105,36 @@ namespace ams::sf { *m_ptr = std::move(v); } + ALWAYS_INLINE void SetValue(os::NativeHandle os_handle, bool managed) const { + return this->SetValue(NativeHandle(os_handle, managed)); + } + NativeHandle &operator*() const { return *m_ptr; } }; + template<> + class Out { + private: + NativeHandle *m_ptr; + public: + Out(NativeHandle *p) : m_ptr(p) { /* ... */ } + + void SetValue(NativeHandle v) const { + *m_ptr = std::move(v); + } + + ALWAYS_INLINE void SetValue(os::NativeHandle os_handle, bool managed) const { + return this->SetValue(NativeHandle(os_handle, managed)); + } + + NativeHandle &operator*() const { + return *m_ptr; + } + }; + + using OutCopyHandle = Out; + using OutMoveHandle = Out; + } \ No newline at end of file diff --git a/libraries/libstratosphere/include/stratosphere/tma/tma_i_socket.hpp b/libraries/libstratosphere/include/stratosphere/tma/tma_i_socket.hpp index 8926d674d..f416844a0 100644 --- a/libraries/libstratosphere/include/stratosphere/tma/tma_i_socket.hpp +++ b/libraries/libstratosphere/include/stratosphere/tma/tma_i_socket.hpp @@ -20,31 +20,31 @@ #include /* NOTE: Minimum firmware version not enforced for any commands. */ -#define AMS_TMA_I_SOCKET_INTERFACE_INFO(C, H) \ - AMS_SF_METHOD_INFO(C, H, 0, Result, Close, (sf::Out out_err, sf::Out out_res), (out_err, out_res)) \ - AMS_SF_METHOD_INFO(C, H, 1, Result, Connect, (sf::Out out_err, sf::Out out_res, const htcs::SockAddrHtcs &address), (out_err, out_res, address)) \ - AMS_SF_METHOD_INFO(C, H, 2, Result, Bind, (sf::Out out_err, sf::Out out_res, const htcs::SockAddrHtcs &address), (out_err, out_res, address)) \ - AMS_SF_METHOD_INFO(C, H, 3, Result, Listen, (sf::Out out_err, sf::Out out_res, s32 backlog_count), (out_err, out_res, backlog_count)) \ - AMS_SF_METHOD_INFO(C, H, 4, Result, Accept, (sf::Out out_err, sf::Out> out, sf::Out out_address), (out_err, out, out_address)) \ - AMS_SF_METHOD_INFO(C, H, 5, Result, Recv, (sf::Out out_err, sf::Out out_size, const sf::OutAutoSelectBuffer &buffer, s32 flags), (out_err, out_size, buffer, flags)) \ - AMS_SF_METHOD_INFO(C, H, 6, Result, Send, (sf::Out out_err, sf::Out out_size, const sf::InAutoSelectBuffer &buffer, s32 flags), (out_err, out_size, buffer, flags)) \ - AMS_SF_METHOD_INFO(C, H, 7, Result, Shutdown, (sf::Out out_err, sf::Out out_res, s32 how), (out_err, out_res, how)) \ - AMS_SF_METHOD_INFO(C, H, 8, Result, Fcntl, (sf::Out out_err, sf::Out out_res, s32 command, s32 value), (out_err, out_res, command, value)) \ - AMS_SF_METHOD_INFO(C, H, 9, Result, AcceptStart, (sf::Out out_task_id, sf::OutCopyHandle out_event), (out_task_id, out_event)) \ - AMS_SF_METHOD_INFO(C, H, 10, Result, AcceptResults, (sf::Out out_err, sf::Out> out, sf::Out out_address, u32 task_id), (out_err, out, out_address, task_id)) \ - AMS_SF_METHOD_INFO(C, H, 11, Result, RecvStart, (sf::Out out_task_id, sf::OutCopyHandle out_event, s32 mem_size, s32 flags), (out_task_id, out_event, mem_size, flags)) \ - AMS_SF_METHOD_INFO(C, H, 12, Result, RecvResults, (sf::Out out_err, sf::Out out_size, const sf::OutAutoSelectBuffer &buffer, u32 task_id), (out_err, out_size, buffer, task_id)) \ - AMS_SF_METHOD_INFO(C, H, 13, Result, RecvLargeStart, (sf::Out out_task_id, sf::OutCopyHandle out_event, s32 unaligned_size_start, s32 unaligned_size_end, s64 aligned_size, sf::CopyHandle mem_handle, s32 flags), (out_task_id, out_event, unaligned_size_start, unaligned_size_end, aligned_size, mem_handle, flags)) \ - AMS_SF_METHOD_INFO(C, H, 14, Result, SendStartOld, (sf::Out out_task_id, sf::OutCopyHandle out_event, const sf::InAutoSelectBuffer &buffer, s32 flags), (out_task_id, out_event, buffer, flags)) \ - AMS_SF_METHOD_INFO(C, H, 15, Result, SendLargeStart, (sf::Out out_task_id, sf::OutCopyHandle out_event, const sf::InAutoSelectBuffer &start_buffer, const sf::InAutoSelectBuffer &end_buffer, sf::CopyHandle mem_handle, s64 aligned_size, s32 flags), (out_task_id, out_event, start_buffer, end_buffer, mem_handle, aligned_size, flags)) \ - AMS_SF_METHOD_INFO(C, H, 16, Result, SendResults, (sf::Out out_err, sf::Out out_size, u32 task_id), (out_err, out_size, task_id)) \ - AMS_SF_METHOD_INFO(C, H, 17, Result, StartSend, (sf::Out out_task_id, sf::OutCopyHandle out_event, sf::Out out_max_size, s64 size, s32 flags), (out_task_id, out_event, out_max_size, size, flags)) \ - AMS_SF_METHOD_INFO(C, H, 18, Result, ContinueSendOld, (sf::Out out_size, sf::Out out_wait, const sf::InAutoSelectBuffer &buffer, u32 task_id), (out_size, out_wait, buffer, task_id)) \ - AMS_SF_METHOD_INFO(C, H, 19, Result, EndSend, (sf::Out out_err, sf::Out out_size, u32 task_id), (out_err, out_size, task_id)) \ - AMS_SF_METHOD_INFO(C, H, 20, Result, StartRecv, (sf::Out out_task_id, sf::OutCopyHandle out_event, s64 size, s32 flags), (out_task_id, out_event, size, flags)) \ - AMS_SF_METHOD_INFO(C, H, 21, Result, EndRecv, (sf::Out out_err, sf::Out out_size, const sf::OutAutoSelectBuffer &buffer, u32 task_id), (out_err, out_size, buffer, task_id)) \ - AMS_SF_METHOD_INFO(C, H, 22, Result, SendStart, (sf::Out out_task_id, sf::OutCopyHandle out_event, const sf::InNonSecureAutoSelectBuffer &buffer, s32 flags), (out_task_id, out_event, buffer, flags)) \ - AMS_SF_METHOD_INFO(C, H, 23, Result, ContinueSend, (sf::Out out_size, sf::Out out_wait, const sf::InNonSecureAutoSelectBuffer &buffer, u32 task_id), (out_size, out_wait, buffer, task_id)) \ +#define AMS_TMA_I_SOCKET_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, Close, (sf::Out out_err, sf::Out out_res), (out_err, out_res)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, Connect, (sf::Out out_err, sf::Out out_res, const htcs::SockAddrHtcs &address), (out_err, out_res, address)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, Bind, (sf::Out out_err, sf::Out out_res, const htcs::SockAddrHtcs &address), (out_err, out_res, address)) \ + AMS_SF_METHOD_INFO(C, H, 3, Result, Listen, (sf::Out out_err, sf::Out out_res, s32 backlog_count), (out_err, out_res, backlog_count)) \ + AMS_SF_METHOD_INFO(C, H, 4, Result, Accept, (sf::Out out_err, sf::Out> out, sf::Out out_address), (out_err, out, out_address)) \ + AMS_SF_METHOD_INFO(C, H, 5, Result, Recv, (sf::Out out_err, sf::Out out_size, const sf::OutAutoSelectBuffer &buffer, s32 flags), (out_err, out_size, buffer, flags)) \ + AMS_SF_METHOD_INFO(C, H, 6, Result, Send, (sf::Out out_err, sf::Out out_size, const sf::InAutoSelectBuffer &buffer, s32 flags), (out_err, out_size, buffer, flags)) \ + AMS_SF_METHOD_INFO(C, H, 7, Result, Shutdown, (sf::Out out_err, sf::Out out_res, s32 how), (out_err, out_res, how)) \ + AMS_SF_METHOD_INFO(C, H, 8, Result, Fcntl, (sf::Out out_err, sf::Out out_res, s32 command, s32 value), (out_err, out_res, command, value)) \ + AMS_SF_METHOD_INFO(C, H, 9, Result, AcceptStart, (sf::Out out_task_id, sf::OutCopyHandle out_event), (out_task_id, out_event)) \ + AMS_SF_METHOD_INFO(C, H, 10, Result, AcceptResults, (sf::Out out_err, sf::Out> out, sf::Out out_address, u32 task_id), (out_err, out, out_address, task_id)) \ + AMS_SF_METHOD_INFO(C, H, 11, Result, RecvStart, (sf::Out out_task_id, sf::OutCopyHandle out_event, s32 mem_size, s32 flags), (out_task_id, out_event, mem_size, flags)) \ + AMS_SF_METHOD_INFO(C, H, 12, Result, RecvResults, (sf::Out out_err, sf::Out out_size, const sf::OutAutoSelectBuffer &buffer, u32 task_id), (out_err, out_size, buffer, task_id)) \ + AMS_SF_METHOD_INFO(C, H, 13, Result, RecvLargeStart, (sf::Out out_task_id, sf::OutCopyHandle out_event, s32 unaligned_size_start, s32 unaligned_size_end, s64 aligned_size, sf::CopyHandle &&mem_handle, s32 flags), (out_task_id, out_event, unaligned_size_start, unaligned_size_end, aligned_size, std::move(mem_handle), flags)) \ + AMS_SF_METHOD_INFO(C, H, 14, Result, SendStartOld, (sf::Out out_task_id, sf::OutCopyHandle out_event, const sf::InAutoSelectBuffer &buffer, s32 flags), (out_task_id, out_event, buffer, flags)) \ + AMS_SF_METHOD_INFO(C, H, 15, Result, SendLargeStart, (sf::Out out_task_id, sf::OutCopyHandle out_event, const sf::InAutoSelectBuffer &start_buffer, const sf::InAutoSelectBuffer &end_buffer, sf::CopyHandle &&mem_handle, s64 aligned_size, s32 flags), (out_task_id, out_event, start_buffer, end_buffer, std::move(mem_handle), aligned_size, flags)) \ + AMS_SF_METHOD_INFO(C, H, 16, Result, SendResults, (sf::Out out_err, sf::Out out_size, u32 task_id), (out_err, out_size, task_id)) \ + AMS_SF_METHOD_INFO(C, H, 17, Result, StartSend, (sf::Out out_task_id, sf::OutCopyHandle out_event, sf::Out out_max_size, s64 size, s32 flags), (out_task_id, out_event, out_max_size, size, flags)) \ + AMS_SF_METHOD_INFO(C, H, 18, Result, ContinueSendOld, (sf::Out out_size, sf::Out out_wait, const sf::InAutoSelectBuffer &buffer, u32 task_id), (out_size, out_wait, buffer, task_id)) \ + AMS_SF_METHOD_INFO(C, H, 19, Result, EndSend, (sf::Out out_err, sf::Out out_size, u32 task_id), (out_err, out_size, task_id)) \ + AMS_SF_METHOD_INFO(C, H, 20, Result, StartRecv, (sf::Out out_task_id, sf::OutCopyHandle out_event, s64 size, s32 flags), (out_task_id, out_event, size, flags)) \ + AMS_SF_METHOD_INFO(C, H, 21, Result, EndRecv, (sf::Out out_err, sf::Out out_size, const sf::OutAutoSelectBuffer &buffer, u32 task_id), (out_err, out_size, buffer, task_id)) \ + AMS_SF_METHOD_INFO(C, H, 22, Result, SendStart, (sf::Out out_task_id, sf::OutCopyHandle out_event, const sf::InNonSecureAutoSelectBuffer &buffer, s32 flags), (out_task_id, out_event, buffer, flags)) \ + AMS_SF_METHOD_INFO(C, H, 23, Result, ContinueSend, (sf::Out out_size, sf::Out out_wait, const sf::InNonSecureAutoSelectBuffer &buffer, u32 task_id), (out_size, out_wait, buffer, task_id)) \ AMS_SF_METHOD_INFO(C, H, 130, Result, GetPrimitive, (sf::Out out), (out)) AMS_SF_DEFINE_INTERFACE(ams::tma, ISocket, AMS_TMA_I_SOCKET_INTERFACE_INFO) diff --git a/libraries/libstratosphere/include/stratosphere/usb/ds/usb_i_ds_service.hpp b/libraries/libstratosphere/include/stratosphere/usb/ds/usb_i_ds_service.hpp index 0d8fa12ed..1925e7e9c 100644 --- a/libraries/libstratosphere/include/stratosphere/usb/ds/usb_i_ds_service.hpp +++ b/libraries/libstratosphere/include/stratosphere/usb/ds/usb_i_ds_service.hpp @@ -20,17 +20,17 @@ #include #include -#define AMS_USB_I_DS_SERVICE_INTERFACE_INFO(C, H) \ - AMS_SF_METHOD_INFO(C, H, 0, Result, Bind, (usb::ComplexId complex_id, sf::CopyHandle process_h), (complex_id, process_h)) \ - AMS_SF_METHOD_INFO(C, H, 1, Result, RegisterInterface, (sf::Out> out, u8 bInterfaceNumber), (out, bInterfaceNumber)) \ - AMS_SF_METHOD_INFO(C, H, 2, Result, GetStateChangeEvent, (sf::OutCopyHandle out), (out)) \ - AMS_SF_METHOD_INFO(C, H, 3, Result, GetState, (sf::Out out), (out)) \ - AMS_SF_METHOD_INFO(C, H, 4, Result, ClearDeviceData, (), ()) \ - AMS_SF_METHOD_INFO(C, H, 5, Result, AddUsbStringDescriptor, (sf::Out out, const sf::InBuffer &desc), (out, desc)) \ - AMS_SF_METHOD_INFO(C, H, 6, Result, DeleteUsbStringDescriptor, (u8 index), (index)) \ - AMS_SF_METHOD_INFO(C, H, 7, Result, SetUsbDeviceDescriptor, (const sf::InBuffer &desc, usb::UsbDeviceSpeed speed), (desc, speed)) \ - AMS_SF_METHOD_INFO(C, H, 8, Result, SetBinaryObjectStore, (const sf::InBuffer &bos), (bos)) \ - AMS_SF_METHOD_INFO(C, H, 9, Result, Enable, (), ()) \ +#define AMS_USB_I_DS_SERVICE_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, Bind, (usb::ComplexId complex_id, sf::CopyHandle &&process_h), (complex_id, std::move(process_h))) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, RegisterInterface, (sf::Out> out, u8 bInterfaceNumber), (out, bInterfaceNumber)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, GetStateChangeEvent, (sf::OutCopyHandle out), (out)) \ + AMS_SF_METHOD_INFO(C, H, 3, Result, GetState, (sf::Out out), (out)) \ + AMS_SF_METHOD_INFO(C, H, 4, Result, ClearDeviceData, (), ()) \ + AMS_SF_METHOD_INFO(C, H, 5, Result, AddUsbStringDescriptor, (sf::Out out, const sf::InBuffer &desc), (out, desc)) \ + AMS_SF_METHOD_INFO(C, H, 6, Result, DeleteUsbStringDescriptor, (u8 index), (index)) \ + AMS_SF_METHOD_INFO(C, H, 7, Result, SetUsbDeviceDescriptor, (const sf::InBuffer &desc, usb::UsbDeviceSpeed speed), (desc, speed)) \ + AMS_SF_METHOD_INFO(C, H, 8, Result, SetBinaryObjectStore, (const sf::InBuffer &bos), (bos)) \ + AMS_SF_METHOD_INFO(C, H, 9, Result, Enable, (), ()) \ AMS_SF_METHOD_INFO(C, H, 10, Result, Disable, (), ()) /* TODO: Deprecated interface? */ diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.cpp index 319974f17..6fb040957 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.cpp @@ -53,7 +53,7 @@ namespace ams::erpt::srv { } Result ManagerImpl::GetEvent(ams::sf::OutCopyHandle out) { - out.SetValue(this->system_event.GetReadableHandle()); + out.SetValue(this->system_event.GetReadableHandle(), false); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/fs/impl/fs_event_notifier_object_adapter.hpp b/libraries/libstratosphere/source/fs/impl/fs_event_notifier_object_adapter.hpp index 15fd2da28..cc7293bb6 100644 --- a/libraries/libstratosphere/source/fs/impl/fs_event_notifier_object_adapter.hpp +++ b/libraries/libstratosphere/source/fs/impl/fs_event_notifier_object_adapter.hpp @@ -27,11 +27,12 @@ namespace ams::fs::impl { private: virtual Result DoBindEvent(os::SystemEventType *out, os::EventClearMode clear_mode) override { /* Get the handle. */ - sf::CopyHandle handle; + sf::NativeHandle handle; AMS_FS_R_TRY(m_object->GetEventHandle(std::addressof(handle))); /* Create the system event. */ - os::AttachReadableHandleToSystemEvent(out, handle, true, clear_mode); + os::AttachReadableHandleToSystemEvent(out, handle.GetOsHandle(), handle.IsManaged(), clear_mode); + handle.Detach(); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/gpio/gpio_client_api.cpp b/libraries/libstratosphere/source/gpio/gpio_client_api.cpp index 6c3d0604c..41e2b9ca9 100644 --- a/libraries/libstratosphere/source/gpio/gpio_client_api.cpp +++ b/libraries/libstratosphere/source/gpio/gpio_client_api.cpp @@ -181,10 +181,11 @@ namespace ams::gpio { Result BindInterrupt(os::SystemEventType *event, GpioPadSession *session) { AMS_ASSERT(session->_event == nullptr); - ams::sf::CopyHandle handle; + ams::sf::NativeHandle handle; R_TRY(GetInterface(session)->BindInterrupt(std::addressof(handle))); - os::AttachReadableHandleToSystemEvent(event, handle.GetValue(), true, os::EventClearMode_ManualClear); + os::AttachReadableHandleToSystemEvent(event, handle.GetOsHandle(), handle.IsManaged(), os::EventClearMode_ManualClear); + handle.Detach(); session->_event = event; return ResultSuccess(); diff --git a/libraries/libstratosphere/source/gpio/gpio_remote_pad_session_impl.hpp b/libraries/libstratosphere/source/gpio/gpio_remote_pad_session_impl.hpp index 7e0de7180..ca650712f 100644 --- a/libraries/libstratosphere/source/gpio/gpio_remote_pad_session_impl.hpp +++ b/libraries/libstratosphere/source/gpio/gpio_remote_pad_session_impl.hpp @@ -74,7 +74,7 @@ namespace ams::gpio { Result BindInterrupt(ams::sf::OutCopyHandle out) { ::Event ev; R_TRY(::gpioPadBindInterrupt(std::addressof(this->srv), std::addressof(ev))); - out.SetValue(ev.revent); + out.SetValue(ev.revent, true); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/htc/server/htc_htc_service_object.cpp b/libraries/libstratosphere/source/htc/server/htc_htc_service_object.cpp index 2d0f4378b..54fb92525 100644 --- a/libraries/libstratosphere/source/htc/server/htc_htc_service_object.cpp +++ b/libraries/libstratosphere/source/htc/server/htc_htc_service_object.cpp @@ -57,13 +57,13 @@ namespace ams::htc::server { Result HtcServiceObject::GetHostConnectionEvent(sf::OutCopyHandle out) { /* Set the output handle. */ - *out = m_observer.GetConnectEvent()->GetReadableHandle(); + out.SetValue(m_observer.GetConnectEvent()->GetReadableHandle(), false); return ResultSuccess(); } Result HtcServiceObject::GetHostDisconnectionEvent(sf::OutCopyHandle out) { /* Set the output handle. */ - *out = m_observer.GetDisconnectEvent()->GetReadableHandle(); + out.SetValue(m_observer.GetDisconnectEvent()->GetReadableHandle(), false); return ResultSuccess(); } @@ -87,7 +87,8 @@ namespace ams::htc::server { Result HtcServiceObject::RunOnHostStart(sf::Out out_id, sf::OutCopyHandle out, const sf::InBuffer &args) { /* Begin the run on host task. */ - R_TRY(m_misc_impl.RunOnHostBegin(out_id.GetPointer(), out.GetHandlePointer(), reinterpret_cast(args.GetPointer()), args.GetSize())); + os::NativeHandle event_handle; + R_TRY(m_misc_impl.RunOnHostBegin(out_id.GetPointer(), std::addressof(event_handle), reinterpret_cast(args.GetPointer()), args.GetSize())); /* Add the task id to our set. */ { @@ -95,8 +96,8 @@ namespace ams::htc::server { m_set.insert(*out_id); } - /* Mark the output event as managed. */ - out.SetManaged(true); + /* Set the output event. */ + out.SetValue(event_handle, true); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/htcs/client/htcs_session.cpp b/libraries/libstratosphere/source/htcs/client/htcs_session.cpp index 79643579b..4e9981aca 100644 --- a/libraries/libstratosphere/source/htcs/client/htcs_session.cpp +++ b/libraries/libstratosphere/source/htcs/client/htcs_session.cpp @@ -51,9 +51,9 @@ namespace ams::htcs::client { Result Accept(sf::Out out_err, sf::Out> out, sf::Out out_address) { AMS_ABORT("Not Implemented"); } Result Recv(sf::Out out_err, sf::Out out_size, const sf::OutAutoSelectBuffer &buffer, s32 flags) { AMS_ABORT("Not Implemented"); } Result Send(sf::Out out_err, sf::Out out_size, const sf::InAutoSelectBuffer &buffer, s32 flags) { AMS_ABORT("Not Implemented"); } - Result RecvLargeStart(sf::Out out_task_id, sf::OutCopyHandle out_event, s32 unaligned_size_start, s32 unaligned_size_end, s64 aligned_size, sf::CopyHandle mem_handle, s32 flags) { AMS_ABORT("Not Implemented"); } + Result RecvLargeStart(sf::Out out_task_id, sf::OutCopyHandle out_event, s32 unaligned_size_start, s32 unaligned_size_end, s64 aligned_size, sf::CopyHandle &&mem_handle, s32 flags) { AMS_ABORT("Not Implemented"); } Result SendStartOld(sf::Out out_task_id, sf::OutCopyHandle out_event, const sf::InAutoSelectBuffer &buffer, s32 flags) { AMS_ABORT("Not Implemented"); } - Result SendLargeStart(sf::Out out_task_id, sf::OutCopyHandle out_event, const sf::InAutoSelectBuffer &start_buffer, const sf::InAutoSelectBuffer &end_buffer, sf::CopyHandle mem_handle, s64 aligned_size, s32 flags) { AMS_ABORT("Not Implemented"); } + Result SendLargeStart(sf::Out out_task_id, sf::OutCopyHandle out_event, const sf::InAutoSelectBuffer &start_buffer, const sf::InAutoSelectBuffer &end_buffer, sf::CopyHandle &&mem_handle, s64 aligned_size, s32 flags) { AMS_ABORT("Not Implemented"); } Result ContinueSendOld(sf::Out out_size, sf::Out out_wait, const sf::InAutoSelectBuffer &buffer, u32 task_id) { AMS_ABORT("Not Implemented"); } Result Close(sf::Out out_err, sf::Out out_res); @@ -138,7 +138,11 @@ namespace ams::htcs::client { } Result RemoteManager::StartSelect(sf::Out out_task_id, sf::OutCopyHandle out_event, const sf::InMapAliasArray &read_handles, const sf::InMapAliasArray &write_handles, const sf::InMapAliasArray &exception_handles, s64 tv_sec, s64 tv_usec) { - return ::htcsStartSelect(out_task_id.GetPointer(), out_event.GetHandlePointer(), read_handles.GetPointer(), read_handles.GetSize(), write_handles.GetPointer(), write_handles.GetSize(), exception_handles.GetPointer(), exception_handles.GetSize(), tv_sec, tv_usec); + os::NativeHandle event_handle; + R_TRY(::htcsStartSelect(out_task_id.GetPointer(), std::addressof(event_handle), read_handles.GetPointer(), read_handles.GetSize(), write_handles.GetPointer(), write_handles.GetSize(), exception_handles.GetPointer(), exception_handles.GetSize(), tv_sec, tv_usec)); + + out_event.SetValue(event_handle, true); + return ResultSuccess(); } Result RemoteManager::EndSelect(sf::Out out_err, sf::Out out_count, const sf::OutMapAliasArray &read_handles, const sf::OutMapAliasArray &write_handles, const sf::OutMapAliasArray &exception_handles, u32 task_id) { @@ -172,7 +176,11 @@ namespace ams::htcs::client { } Result RemoteSocket::AcceptStart(sf::Out out_task_id, sf::OutCopyHandle out_event) { - return ::htcsSocketAcceptStart(std::addressof(m_s), out_task_id.GetPointer(), out_event.GetHandlePointer()); + os::NativeHandle event_handle; + R_TRY(::htcsSocketAcceptStart(std::addressof(m_s), out_task_id.GetPointer(), std::addressof(event_handle))); + + out_event.SetValue(event_handle, true); + return ResultSuccess(); } Result RemoteSocket::AcceptResults(sf::Out out_err, sf::Out> out, sf::Out out_address, u32 task_id) { @@ -187,7 +195,11 @@ namespace ams::htcs::client { } Result RemoteSocket::RecvStart(sf::Out out_task_id, sf::OutCopyHandle out_event, s32 mem_size, s32 flags) { - return ::htcsSocketRecvStart(std::addressof(m_s), out_task_id.GetPointer(), out_event.GetHandlePointer(), mem_size, flags); + os::NativeHandle event_handle; + R_TRY(::htcsSocketRecvStart(std::addressof(m_s), out_task_id.GetPointer(), std::addressof(event_handle), mem_size, flags)); + + out_event.SetValue(event_handle, true); + return ResultSuccess(); } Result RemoteSocket::RecvResults(sf::Out out_err, sf::Out out_size, const sf::OutAutoSelectBuffer &buffer, u32 task_id) { @@ -195,7 +207,11 @@ namespace ams::htcs::client { } Result RemoteSocket::SendStart(sf::Out out_task_id, sf::OutCopyHandle out_event, const sf::InNonSecureAutoSelectBuffer &buffer, s32 flags) { - return ::htcsSocketSendStart(std::addressof(m_s), out_task_id.GetPointer(), out_event.GetHandlePointer(), buffer.GetPointer(), buffer.GetSize(), flags); + os::NativeHandle event_handle; + R_TRY(::htcsSocketSendStart(std::addressof(m_s), out_task_id.GetPointer(), std::addressof(event_handle), buffer.GetPointer(), buffer.GetSize(), flags)); + + out_event.SetValue(event_handle, true); + return ResultSuccess(); } Result RemoteSocket::SendResults(sf::Out out_err, sf::Out out_size, u32 task_id) { @@ -203,7 +219,11 @@ namespace ams::htcs::client { } Result RemoteSocket::StartSend(sf::Out out_task_id, sf::OutCopyHandle out_event, sf::Out out_max_size, s64 size, s32 flags) { - return ::htcsSocketStartSend(std::addressof(m_s), out_task_id.GetPointer(), out_event.GetHandlePointer(), out_max_size.GetPointer(), size, flags); + os::NativeHandle event_handle; + R_TRY(::htcsSocketStartSend(std::addressof(m_s), out_task_id.GetPointer(), std::addressof(event_handle), out_max_size.GetPointer(), size, flags)); + + out_event.SetValue(event_handle, true); + return ResultSuccess(); } Result RemoteSocket::ContinueSend(sf::Out out_size, sf::Out out_wait, const sf::InNonSecureAutoSelectBuffer &buffer, u32 task_id) { @@ -215,7 +235,11 @@ namespace ams::htcs::client { } Result RemoteSocket::StartRecv(sf::Out out_task_id, sf::OutCopyHandle out_event, s64 size, s32 flags) { - return ::htcsSocketStartRecv(std::addressof(m_s), out_task_id.GetPointer(), out_event.GetHandlePointer(), size, flags); + os::NativeHandle event_handle; + R_TRY(::htcsSocketStartRecv(std::addressof(m_s), out_task_id.GetPointer(), std::addressof(event_handle), size, flags)); + + out_event.SetValue(event_handle, true); + return ResultSuccess(); } Result RemoteSocket::EndRecv(sf::Out out_err, sf::Out out_size, const sf::OutAutoSelectBuffer &buffer, u32 task_id) { diff --git a/libraries/libstratosphere/source/htcs/htcs_socket.cpp b/libraries/libstratosphere/source/htcs/htcs_socket.cpp index 1e6fffef2..ec4b1cb2f 100644 --- a/libraries/libstratosphere/source/htcs/htcs_socket.cpp +++ b/libraries/libstratosphere/source/htcs/htcs_socket.cpp @@ -496,11 +496,12 @@ namespace ams::htcs { /* Begin the accept. */ sf::SharedPointer res = nullptr; u32 task_id = 0; - sf::CopyHandle event_handle; + sf::NativeHandle event_handle; if (R_SUCCEEDED(socket->AcceptStart(std::addressof(task_id), std::addressof(event_handle)))) { /* Create system event. */ os::SystemEventType event; - os::AttachReadableHandleToSystemEvent(std::addressof(event), event_handle.GetValue(), true, os::EventClearMode_ManualClear); + os::AttachReadableHandleToSystemEvent(std::addressof(event), event_handle.GetOsHandle(), event_handle.IsManaged(), os::EventClearMode_ManualClear); + event_handle.Detach(); /* When we're done, clean up the event. */ ON_SCOPE_EXIT { os::DestroySystemEvent(std::addressof(event)); }; @@ -562,11 +563,12 @@ namespace ams::htcs { /* Begin the select. */ s32 res = -1; u32 task_id = 0; - sf::CopyHandle event_handle; + sf::NativeHandle event_handle; if (R_SUCCEEDED(g_manager->StartSelect(std::addressof(task_id), std::addressof(event_handle), InArray(read, num_read), InArray(write, num_write), InArray(except, num_except), tv_sec, tv_usec))) { /* Create system event. */ os::SystemEventType event; - os::AttachReadableHandleToSystemEvent(std::addressof(event), event_handle.GetValue(), true, os::EventClearMode_ManualClear); + os::AttachReadableHandleToSystemEvent(std::addressof(event), event_handle.GetOsHandle(), event_handle.IsManaged(), os::EventClearMode_ManualClear); + event_handle.Detach(); /* When we're done, clean up the event. */ ON_SCOPE_EXIT { os::DestroySystemEvent(std::addressof(event)); }; @@ -596,11 +598,12 @@ namespace ams::htcs { /* Start the receive. */ u32 task_id = 0; - sf::CopyHandle event_handle; + sf::NativeHandle event_handle; if (R_SUCCEEDED(socket->StartRecv(std::addressof(task_id), std::addressof(event_handle), static_cast(buffer_size), flags))) { /* Create system event. */ os::SystemEventType event; - os::AttachReadableHandleToSystemEvent(std::addressof(event), event_handle.GetValue(), true, os::EventClearMode_ManualClear); + os::AttachReadableHandleToSystemEvent(std::addressof(event), event_handle.GetOsHandle(), event_handle.IsManaged(), os::EventClearMode_ManualClear); + event_handle.Detach(); /* When we're done, clean up the event. */ ON_SCOPE_EXIT { os::DestroySystemEvent(std::addressof(event)); }; @@ -627,11 +630,12 @@ namespace ams::htcs { /* Start the send. */ u32 task_id = 0; s64 max_size = 0; - sf::CopyHandle event_handle; + sf::NativeHandle event_handle; if (R_SUCCEEDED(socket->StartSend(std::addressof(task_id), std::addressof(event_handle), std::addressof(max_size), static_cast(buffer_size), flags))) { /* Create system event. */ os::SystemEventType event; - os::AttachReadableHandleToSystemEvent(std::addressof(event), event_handle.GetValue(), true, os::EventClearMode_ManualClear); + os::AttachReadableHandleToSystemEvent(std::addressof(event), event_handle.GetOsHandle(), event_handle.IsManaged(), os::EventClearMode_ManualClear); + event_handle.Detach(); /* When we're done, clean up the event. */ ON_SCOPE_EXIT { os::DestroySystemEvent(std::addressof(event)); }; @@ -697,11 +701,12 @@ namespace ams::htcs { /* Start the receive. */ s64 res = -1; u32 task_id = 0; - sf::CopyHandle event_handle; + sf::NativeHandle event_handle; if (R_SUCCEEDED(socket->RecvStart(std::addressof(task_id), std::addressof(event_handle), static_cast(recv_size), flags))) { /* Create system event. */ os::SystemEventType event; - os::AttachReadableHandleToSystemEvent(std::addressof(event), event_handle.GetValue(), true, os::EventClearMode_ManualClear); + os::AttachReadableHandleToSystemEvent(std::addressof(event), event_handle.GetOsHandle(), event_handle.IsManaged(), os::EventClearMode_ManualClear); + event_handle.Detach(); /* When we're done, clean up the event. */ ON_SCOPE_EXIT { os::DestroySystemEvent(std::addressof(event)); }; @@ -729,11 +734,12 @@ namespace ams::htcs { /* Start the send. */ s64 res = -1; u32 task_id = 0; - sf::CopyHandle event_handle; + sf::NativeHandle event_handle; if (R_SUCCEEDED(socket->SendStart(std::addressof(task_id), std::addressof(event_handle), sf::InNonSecureAutoSelectBuffer(buffer, buffer_size), flags))) { /* Create system event. */ os::SystemEventType event; - os::AttachReadableHandleToSystemEvent(std::addressof(event), event_handle.GetValue(), true, os::EventClearMode_ManualClear); + os::AttachReadableHandleToSystemEvent(std::addressof(event), event_handle.GetOsHandle(), event_handle.IsManaged(), os::EventClearMode_ManualClear); + event_handle.Detach(); /* When we're done, clean up the event. */ ON_SCOPE_EXIT { os::DestroySystemEvent(std::addressof(event)); }; diff --git a/libraries/libstratosphere/source/htcs/server/htcs_manager_service_object.cpp b/libraries/libstratosphere/source/htcs/server/htcs_manager_service_object.cpp index 0ad5c1cb6..5d47f0ef9 100644 --- a/libraries/libstratosphere/source/htcs/server/htcs_manager_service_object.cpp +++ b/libraries/libstratosphere/source/htcs/server/htcs_manager_service_object.cpp @@ -79,10 +79,11 @@ namespace ams::htcs::server { auto *manager = impl::HtcsManagerHolder::GetHtcsManager(); /* Start the select. */ - R_TRY(manager->StartSelect(out_task_id.GetPointer(), out_event.GetHandlePointer(), read_handles.ToSpan(), write_handles.ToSpan(), exception_handles.ToSpan(), tv_sec, tv_usec)); + os::NativeHandle event_handle; + R_TRY(manager->StartSelect(out_task_id.GetPointer(), std::addressof(event_handle), read_handles.ToSpan(), write_handles.ToSpan(), exception_handles.ToSpan(), tv_sec, tv_usec)); - /* Mark the output event as managed. */ - out_event.SetManaged(true); + /* Set the output event handle. */ + out_event.SetValue(event_handle, true); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/htcs/server/htcs_socket_service_object.cpp b/libraries/libstratosphere/source/htcs/server/htcs_socket_service_object.cpp index 74ea19a4e..8645ccd88 100644 --- a/libraries/libstratosphere/source/htcs/server/htcs_socket_service_object.cpp +++ b/libraries/libstratosphere/source/htcs/server/htcs_socket_service_object.cpp @@ -118,10 +118,11 @@ namespace ams::htcs::server { auto *manager = impl::HtcsManagerHolder::GetHtcsManager(); /* Start the accept. */ - R_TRY(manager->AcceptStart(out_task_id.GetPointer(), out_event.GetHandlePointer(), m_desc)); + os::NativeHandle event_handle; + R_TRY(manager->AcceptStart(out_task_id.GetPointer(), std::addressof(event_handle), m_desc)); - /* Mark the output event as managed. */ - out_event.SetManaged(true); + /* Set the output event handle. */ + out_event.SetValue(event_handle, true); return ResultSuccess(); } @@ -147,10 +148,11 @@ namespace ams::htcs::server { auto *manager = impl::HtcsManagerHolder::GetHtcsManager(); /* Start the recv. */ - R_TRY(manager->RecvStart(out_task_id.GetPointer(), out_event.GetHandlePointer(), mem_size, m_desc, flags)); + os::NativeHandle event_handle; + R_TRY(manager->RecvStart(out_task_id.GetPointer(), std::addressof(event_handle), mem_size, m_desc, flags)); - /* Mark the output event as managed. */ - out_event.SetManaged(true); + /* Set the output event handle. */ + out_event.SetValue(event_handle, true); return ResultSuccess(); } @@ -164,13 +166,14 @@ namespace ams::htcs::server { return ResultSuccess(); } - Result SocketServiceObject::RecvLargeStart(sf::Out out_task_id, sf::OutCopyHandle out_event, s32 unaligned_size_start, s32 unaligned_size_end, s64 aligned_size, sf::CopyHandle mem_handle, s32 flags) { + Result SocketServiceObject::RecvLargeStart(sf::Out out_task_id, sf::OutCopyHandle out_event, s32 unaligned_size_start, s32 unaligned_size_end, s64 aligned_size, sf::CopyHandle &&mem_handle, s32 flags) { /* Check that the transfer memory size is okay. */ R_UNLESS(util::IsIntValueRepresentable(aligned_size), htcs::ResultInvalidSize()); /* Attach the transfer memory. */ os::TransferMemoryType tmem; - os::AttachTransferMemory(std::addressof(tmem), static_cast(aligned_size), mem_handle.GetValue(), true); + os::AttachTransferMemory(std::addressof(tmem), static_cast(aligned_size), mem_handle.GetOsHandle(), mem_handle.IsManaged()); + mem_handle.Detach(); ON_SCOPE_EXIT { os::DestroyTransferMemory(std::addressof(tmem)); }; /* Map the transfer memory. */ @@ -182,10 +185,11 @@ namespace ams::htcs::server { auto *manager = impl::HtcsManagerHolder::GetHtcsManager(); /* Start the large receive. */ - R_TRY(manager->RecvStart(out_task_id.GetPointer(), out_event.GetHandlePointer(), unaligned_size_start + aligned_size + unaligned_size_end, m_desc, flags)); + os::NativeHandle event_handle; + R_TRY(manager->RecvStart(out_task_id.GetPointer(), std::addressof(event_handle), unaligned_size_start + aligned_size + unaligned_size_end, m_desc, flags)); - /* Mark the output event as managed. */ - out_event.SetManaged(true); + /* Set the output event handle. */ + out_event.SetValue(event_handle, true); return ResultSuccess(); } @@ -193,7 +197,7 @@ namespace ams::htcs::server { return this->SendStart(out_task_id, out_event, sf::InNonSecureAutoSelectBuffer(buffer.GetPointer(), buffer.GetSize()), flags); } - Result SocketServiceObject::SendLargeStart(sf::Out out_task_id, sf::OutCopyHandle out_event, const sf::InAutoSelectBuffer &start_buffer, const sf::InAutoSelectBuffer &end_buffer, sf::CopyHandle mem_handle, s64 aligned_size, s32 flags) { + Result SocketServiceObject::SendLargeStart(sf::Out out_task_id, sf::OutCopyHandle out_event, const sf::InAutoSelectBuffer &start_buffer, const sf::InAutoSelectBuffer &end_buffer, sf::CopyHandle &&mem_handle, s64 aligned_size, s32 flags) { /* Check that the sizes are okay. */ R_UNLESS(util::IsIntValueRepresentable(start_buffer.GetSize()), htcs::ResultInvalidSize()); R_UNLESS(util::IsIntValueRepresentable(end_buffer.GetSize()), htcs::ResultInvalidSize()); @@ -201,7 +205,8 @@ namespace ams::htcs::server { /* Attach the transfer memory. */ os::TransferMemoryType tmem; - os::AttachTransferMemory(std::addressof(tmem), static_cast(aligned_size), mem_handle.GetValue(), true); + os::AttachTransferMemory(std::addressof(tmem), static_cast(aligned_size), mem_handle.GetOsHandle(), mem_handle.IsManaged()); + mem_handle.Detach(); ON_SCOPE_EXIT { os::DestroyTransferMemory(std::addressof(tmem)); }; /* Map the transfer memory. */ @@ -217,10 +222,11 @@ namespace ams::htcs::server { const char *pointers[NumBuffers] = { reinterpret_cast(start_buffer.GetPointer()), static_cast(address), reinterpret_cast(end_buffer.GetPointer()) }; s64 sizes[NumBuffers] = { static_cast(start_buffer.GetSize()), aligned_size, static_cast(end_buffer.GetSize()) }; - R_TRY(manager->SendLargeStart(out_task_id.GetPointer(), out_event.GetHandlePointer(), pointers, sizes, NumBuffers, m_desc, flags)); + os::NativeHandle event_handle; + R_TRY(manager->SendLargeStart(out_task_id.GetPointer(), std::addressof(event_handle), pointers, sizes, NumBuffers, m_desc, flags)); - /* Mark the output event as managed. */ - out_event.SetManaged(true); + /* Set the output event handle. */ + out_event.SetValue(event_handle, true); return ResultSuccess(); } @@ -239,13 +245,14 @@ namespace ams::htcs::server { auto *manager = impl::HtcsManagerHolder::GetHtcsManager(); /* Start the send. */ - R_TRY(manager->StartSend(out_task_id.GetPointer(), out_event.GetHandlePointer(), m_desc, size, flags)); + os::NativeHandle event_handle; + R_TRY(manager->StartSend(out_task_id.GetPointer(), std::addressof(event_handle), m_desc, size, flags)); /* Set the output max size to the size. */ *out_max_size = size; - /* Mark the output event as managed. */ - out_event.SetManaged(true); + /* Set the output event handle. */ + out_event.SetValue(event_handle, true); return ResultSuccess(); } @@ -268,10 +275,11 @@ namespace ams::htcs::server { auto *manager = impl::HtcsManagerHolder::GetHtcsManager(); /* Start the recv. */ - R_TRY(manager->StartRecv(out_task_id.GetPointer(), out_event.GetHandlePointer(), size, m_desc, flags)); + os::NativeHandle event_handle; + R_TRY(manager->StartRecv(out_task_id.GetPointer(), std::addressof(event_handle), size, m_desc, flags)); - /* Mark the output event as managed. */ - out_event.SetManaged(true); + /* Set the output event handle. */ + out_event.SetValue(event_handle, true); return ResultSuccess(); } @@ -293,10 +301,11 @@ namespace ams::htcs::server { auto *manager = impl::HtcsManagerHolder::GetHtcsManager(); /* Start the send. */ - R_TRY(manager->SendStart(out_task_id.GetPointer(), out_event.GetHandlePointer(), reinterpret_cast(buffer.GetPointer()), buffer.GetSize(), m_desc, flags)); + os::NativeHandle event_handle; + R_TRY(manager->SendStart(out_task_id.GetPointer(), std::addressof(event_handle), reinterpret_cast(buffer.GetPointer()), buffer.GetSize(), m_desc, flags)); - /* Mark the output event as managed. */ - out_event.SetManaged(true); + /* Set the output event handle. */ + out_event.SetValue(event_handle, true); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/htcs/server/htcs_socket_service_object.hpp b/libraries/libstratosphere/source/htcs/server/htcs_socket_service_object.hpp index 979cdbcf6..46a3cfe59 100644 --- a/libraries/libstratosphere/source/htcs/server/htcs_socket_service_object.hpp +++ b/libraries/libstratosphere/source/htcs/server/htcs_socket_service_object.hpp @@ -40,9 +40,9 @@ namespace ams::htcs::server { Result AcceptResults(sf::Out out_err, sf::Out> out, sf::Out out_address, u32 task_id); Result RecvStart(sf::Out out_task_id, sf::OutCopyHandle out_event, s32 mem_size, s32 flags); Result RecvResults(sf::Out out_err, sf::Out out_size, const sf::OutAutoSelectBuffer &buffer, u32 task_id); - Result RecvLargeStart(sf::Out out_task_id, sf::OutCopyHandle out_event, s32 unaligned_size_start, s32 unaligned_size_end, s64 aligned_size, sf::CopyHandle mem_handle, s32 flags); + Result RecvLargeStart(sf::Out out_task_id, sf::OutCopyHandle out_event, s32 unaligned_size_start, s32 unaligned_size_end, s64 aligned_size, sf::CopyHandle &&mem_handle, s32 flags); Result SendStartOld(sf::Out out_task_id, sf::OutCopyHandle out_event, const sf::InAutoSelectBuffer &buffer, s32 flags); - Result SendLargeStart(sf::Out out_task_id, sf::OutCopyHandle out_event, const sf::InAutoSelectBuffer &start_buffer, const sf::InAutoSelectBuffer &end_buffer, sf::CopyHandle mem_handle, s64 aligned_size, s32 flags); + Result SendLargeStart(sf::Out out_task_id, sf::OutCopyHandle out_event, const sf::InAutoSelectBuffer &start_buffer, const sf::InAutoSelectBuffer &end_buffer, sf::CopyHandle &&mem_handle, s64 aligned_size, s32 flags); Result SendResults(sf::Out out_err, sf::Out out_size, u32 task_id); Result StartSend(sf::Out out_task_id, sf::OutCopyHandle out_event, sf::Out out_max_size, s64 size, s32 flags); Result ContinueSendOld(sf::Out out_size, sf::Out out_wait, const sf::InAutoSelectBuffer &buffer, u32 task_id); diff --git a/libraries/libstratosphere/source/pgl/pgl_remote_event_observer.hpp b/libraries/libstratosphere/source/pgl/pgl_remote_event_observer.hpp index dac2a4346..31f891f97 100644 --- a/libraries/libstratosphere/source/pgl/pgl_remote_event_observer.hpp +++ b/libraries/libstratosphere/source/pgl/pgl_remote_event_observer.hpp @@ -32,13 +32,13 @@ namespace ams::pgl { Result GetProcessEventHandle(ams::sf::OutCopyHandle out) { ::Event ev; R_TRY(::pglEventObserverGetProcessEvent(std::addressof(this->observer), std::addressof(ev))); - out.SetValue(ev.revent); + out.SetValue(ev.revent, true); return ResultSuccess(); } Result GetProcessEventInfo(ams::sf::Out out) { static_assert(sizeof(*out.GetPointer()) == sizeof(::PmProcessEventInfo)); - return ::pglEventObserverGetProcessEventInfo(std::addressof(this->observer), reinterpret_cast<::PmProcessEventInfo *>(out.GetPointer())); + return ::pglEventObserverGetProcessEventInfo(std::addressof(this->observer), reinterpret_cast<::PmProcessEventInfo *>(out.GetPointer())); } Result GetProcessEventHandle(ams::tipc::OutCopyHandle out) { diff --git a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.cpp b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.cpp index 0e889addd..2d1558dd6 100644 --- a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.cpp +++ b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.cpp @@ -66,7 +66,7 @@ namespace ams::pgl::srv { } Result ShellEventObserverCmif::GetProcessEventHandle(ams::sf::OutCopyHandle out) { - out.SetValue(this->GetEvent().GetReadableHandle()); + out.SetValue(this->GetEvent().GetReadableHandle(), false); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_domain_session_manager.cpp b/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_domain_session_manager.cpp index 01086e150..7b5b5fc66 100644 --- a/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_domain_session_manager.cpp +++ b/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_domain_session_manager.cpp @@ -34,14 +34,14 @@ namespace ams::sf::hipc { ServerSession *session; bool is_mitm_session; private: - Result CloneCurrentObjectImpl(os::NativeHandle *out_client_handle, ServerSessionManager *tagged_manager) { + Result CloneCurrentObjectImpl(sf::OutMoveHandle &out_client_handle, ServerSessionManager *tagged_manager) { /* Clone the object. */ cmif::ServiceObjectHolder &&clone = this->session->srv_obj_holder.Clone(); R_UNLESS(clone, sf::hipc::ResultDomainObjectNotFound()); /* Create new session handles. */ - os::NativeHandle server_handle; - R_ABORT_UNLESS(hipc::CreateSession(&server_handle, out_client_handle)); + os::NativeHandle server_handle, client_handle; + R_ABORT_UNLESS(hipc::CreateSession(std::addressof(server_handle), std::addressof(client_handle))); /* Register with manager. */ if (!is_mitm_session) { @@ -53,6 +53,8 @@ namespace ams::sf::hipc { R_ABORT_UNLESS(tagged_manager->RegisterMitmSession(server_handle, std::move(clone), std::move(new_forward_service))); } + /* Set output client handle. */ + out_client_handle.SetValue(client_handle, false); return ResultSuccess(); } public: @@ -113,36 +115,47 @@ namespace ams::sf::hipc { auto &&object = domain->GetObject(object_id); if (!object) { R_UNLESS(this->is_mitm_session, sf::hipc::ResultDomainObjectNotFound()); - return cmifCopyFromCurrentDomain(this->session->forward_service->session, object_id.value, out.GetHandlePointer()); + + os::NativeHandle handle; + R_TRY(cmifCopyFromCurrentDomain(this->session->forward_service->session, object_id.value, std::addressof(handle))); + + out.SetValue(handle, false); + return ResultSuccess(); } if (!this->is_mitm_session || object_id.value != serviceGetObjectId(this->session->forward_service.get())) { /* Create new session handles. */ - os::NativeHandle server_handle; - R_ABORT_UNLESS(hipc::CreateSession(&server_handle, out.GetHandlePointer())); + os::NativeHandle server_handle, client_handle; + R_ABORT_UNLESS(hipc::CreateSession(std::addressof(server_handle), std::addressof(client_handle))); /* Register. */ R_ABORT_UNLESS(this->manager->RegisterSession(server_handle, std::move(object))); + + /* Set output client handle. */ + out.SetValue(client_handle, false); } else { /* Copy from the target domain. */ os::NativeHandle new_forward_target; R_TRY(cmifCopyFromCurrentDomain(this->session->forward_service->session, object_id.value, &new_forward_target)); /* Create new session handles. */ - os::NativeHandle server_handle; - R_ABORT_UNLESS(hipc::CreateSession(&server_handle, out.GetHandlePointer())); + os::NativeHandle server_handle, client_handle; + R_ABORT_UNLESS(hipc::CreateSession(std::addressof(server_handle), std::addressof(client_handle))); /* Register. */ std::shared_ptr<::Service> new_forward_service = std::move(ServerSession::CreateForwardService()); serviceCreate(new_forward_service.get(), new_forward_target); R_ABORT_UNLESS(this->manager->RegisterMitmSession(server_handle, std::move(object), std::move(new_forward_service))); + + /* Set output client handle. */ + out.SetValue(client_handle, false); } return ResultSuccess(); } Result CloneCurrentObject(sf::OutMoveHandle out) { - return this->CloneCurrentObjectImpl(out.GetHandlePointer(), this->manager); + return this->CloneCurrentObjectImpl(out, this->manager); } void QueryPointerBufferSize(sf::Out out) { @@ -150,7 +163,7 @@ namespace ams::sf::hipc { } Result CloneCurrentObjectEx(sf::OutMoveHandle out, u32 tag) { - return this->CloneCurrentObjectImpl(out.GetHandlePointer(), this->manager->GetSessionManagerByTag(tag)); + return this->CloneCurrentObjectImpl(out, this->manager->GetSessionManagerByTag(tag)); } }; static_assert(IsIHipcManager); diff --git a/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_update_observer_impl.hpp b/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_update_observer_impl.hpp index 26519a92c..2041d6176 100644 --- a/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_update_observer_impl.hpp +++ b/libraries/libstratosphere/source/sprofile/srv/sprofile_srv_profile_update_observer_impl.hpp @@ -65,7 +65,7 @@ namespace ams::sprofile::srv { } Result GetEventHandle(sf::OutCopyHandle out) { - out.SetValue(m_event.GetReadableHandle()); + out.SetValue(m_event.GetReadableHandle(), false); return ResultSuccess(); } public: diff --git a/libraries/libstratosphere/source/usb/usb_device.cpp b/libraries/libstratosphere/source/usb/usb_device.cpp index e89d76b8d..ddfcd0142 100644 --- a/libraries/libstratosphere/source/usb/usb_device.cpp +++ b/libraries/libstratosphere/source/usb/usb_device.cpp @@ -54,14 +54,15 @@ namespace ams::usb { } /* Bind the client process. */ - R_TRY(m_ds_service->Bind(complex_id, dd::GetCurrentProcessHandle())); + R_TRY(m_ds_service->Bind(complex_id, sf::CopyHandle(dd::GetCurrentProcessHandle(), false))); /* Get the state change event. */ - sf::CopyHandle event_handle; + sf::NativeHandle event_handle; R_TRY(m_ds_service->GetStateChangeEvent(std::addressof(event_handle))); /* Attach the state change event handle to our event. */ - os::AttachReadableHandleToSystemEvent(std::addressof(m_state_change_event), event_handle.GetValue(), true, os::EventClearMode_ManualClear); + os::AttachReadableHandleToSystemEvent(std::addressof(m_state_change_event), event_handle.GetOsHandle(), event_handle.IsManaged(), os::EventClearMode_ManualClear); + event_handle.Detach(); /* Mark ourselves as initialized. */ m_is_initialized = true; @@ -250,17 +251,21 @@ namespace ams::usb { auto intf_guard = SCOPE_GUARD { m_client->DeleteInterface(m_interface_num); m_interface = nullptr; }; /* Get events. */ - sf::CopyHandle setup_event_handle; - sf::CopyHandle ctrl_in_event_handle; - sf::CopyHandle ctrl_out_event_handle; + sf::NativeHandle setup_event_handle; + sf::NativeHandle ctrl_in_event_handle; + sf::NativeHandle ctrl_out_event_handle; R_TRY(m_interface->GetSetupEvent(std::addressof(setup_event_handle))); R_TRY(m_interface->GetCtrlInCompletionEvent(std::addressof(ctrl_in_event_handle))); R_TRY(m_interface->GetCtrlOutCompletionEvent(std::addressof(ctrl_out_event_handle))); /* Attach events. */ - os::AttachReadableHandleToSystemEvent(std::addressof(m_setup_event), setup_event_handle.GetValue(), true, os::EventClearMode_ManualClear); - os::AttachReadableHandleToSystemEvent(std::addressof(m_ctrl_in_completion_event), ctrl_in_event_handle.GetValue(), true, os::EventClearMode_ManualClear); - os::AttachReadableHandleToSystemEvent(std::addressof(m_ctrl_out_completion_event), ctrl_out_event_handle.GetValue(), true, os::EventClearMode_ManualClear); + os::AttachReadableHandleToSystemEvent(std::addressof(m_setup_event), setup_event_handle.GetOsHandle(), setup_event_handle.IsManaged(), os::EventClearMode_ManualClear); + os::AttachReadableHandleToSystemEvent(std::addressof(m_ctrl_in_completion_event), ctrl_in_event_handle.GetOsHandle(), ctrl_in_event_handle.IsManaged(), os::EventClearMode_ManualClear); + os::AttachReadableHandleToSystemEvent(std::addressof(m_ctrl_out_completion_event), ctrl_out_event_handle.GetOsHandle(), ctrl_out_event_handle.IsManaged(), os::EventClearMode_ManualClear); + + setup_event_handle.Detach(); + ctrl_in_event_handle.Detach(); + ctrl_out_event_handle.Detach(); /* Increment our client's reference count. */ ++m_client->m_reference_count; @@ -635,7 +640,7 @@ namespace ams::usb { auto ep_guard = SCOPE_GUARD { m_interface->DeleteEndpoint(m_address); m_endpoint = nullptr; }; /* Get completion event. */ - sf::CopyHandle event_handle; + sf::NativeHandle event_handle; R_TRY(m_endpoint->GetCompletionEvent(std::addressof(event_handle))); /* Increment our interface's reference count. */ @@ -643,7 +648,8 @@ namespace ams::usb { ++m_interface->m_client->m_reference_count; /* Attach our event. */ - os::AttachReadableHandleToSystemEvent(std::addressof(m_completion_event), event_handle, true, os::EventClearMode_ManualClear); + os::AttachReadableHandleToSystemEvent(std::addressof(m_completion_event), event_handle.GetOsHandle(), event_handle.IsManaged(), os::EventClearMode_ManualClear); + event_handle.Detach(); /* Mark initialized. */ m_is_initialized = true; diff --git a/libraries/libstratosphere/source/usb/usb_remote_ds_endpoint.cpp b/libraries/libstratosphere/source/usb/usb_remote_ds_endpoint.cpp index ea7d643f4..65f73c17d 100644 --- a/libraries/libstratosphere/source/usb/usb_remote_ds_endpoint.cpp +++ b/libraries/libstratosphere/source/usb/usb_remote_ds_endpoint.cpp @@ -35,10 +35,15 @@ namespace ams::usb { Result RemoteDsEndpoint::GetCompletionEvent(sf::OutCopyHandle out) { serviceAssumeDomain(std::addressof(m_srv)); - return serviceDispatch(std::addressof(m_srv), 2, + + os::NativeHandle event_handle; + R_TRY((serviceDispatch(std::addressof(m_srv), 2, .out_handle_attrs = { SfOutHandleAttr_HipcCopy }, - .out_handles = out.GetHandlePointer(), - ); + .out_handles = std::addressof(event_handle), + ))); + + out.SetValue(event_handle, true); + return ResultSuccess(); } Result RemoteDsEndpoint::GetUrbReport(sf::Out out) { diff --git a/libraries/libstratosphere/source/usb/usb_remote_ds_interface.cpp b/libraries/libstratosphere/source/usb/usb_remote_ds_interface.cpp index 4161dd4f9..ac26a1ce2 100644 --- a/libraries/libstratosphere/source/usb/usb_remote_ds_interface.cpp +++ b/libraries/libstratosphere/source/usb/usb_remote_ds_interface.cpp @@ -35,10 +35,15 @@ namespace ams::usb { Result RemoteDsInterface::GetSetupEvent(sf::OutCopyHandle out) { serviceAssumeDomain(std::addressof(m_srv)); - return serviceDispatch(std::addressof(m_srv), 1, + + os::NativeHandle event_handle; + R_TRY((serviceDispatch(std::addressof(m_srv), 1, .out_handle_attrs = { SfOutHandleAttr_HipcCopy }, - .out_handles = out.GetHandlePointer(), - ); + .out_handles = std::addressof(event_handle), + ))); + + out.SetValue(event_handle, true); + return ResultSuccess(); } Result RemoteDsInterface::GetSetupPacket(const sf::OutBuffer &out) { @@ -71,10 +76,15 @@ namespace ams::usb { Result RemoteDsInterface::GetCtrlInCompletionEvent(sf::OutCopyHandle out) { serviceAssumeDomain(std::addressof(m_srv)); - return serviceDispatch(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 5 : 7, + + os::NativeHandle event_handle; + R_TRY((serviceDispatch(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 5 : 7, .out_handle_attrs = { SfOutHandleAttr_HipcCopy }, - .out_handles = out.GetHandlePointer(), - ); + .out_handles = std::addressof(event_handle), + ))); + + out.SetValue(event_handle, true); + return ResultSuccess(); } Result RemoteDsInterface::GetCtrlInUrbReport(sf::Out out) { @@ -84,10 +94,15 @@ namespace ams::usb { Result RemoteDsInterface::GetCtrlOutCompletionEvent(sf::OutCopyHandle out) { serviceAssumeDomain(std::addressof(m_srv)); - return serviceDispatch(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 7 : 9, + + os::NativeHandle event_handle; + R_TRY((serviceDispatch(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 7 : 9, .out_handle_attrs = { SfOutHandleAttr_HipcCopy }, - .out_handles = out.GetHandlePointer(), - ); + .out_handles = std::addressof(event_handle), + ))); + + out.SetValue(event_handle, true); + return ResultSuccess(); } Result RemoteDsInterface::GetCtrlOutUrbReport(sf::Out out) { diff --git a/libraries/libstratosphere/source/usb/usb_remote_ds_service.cpp b/libraries/libstratosphere/source/usb/usb_remote_ds_service.cpp index 0472ae624..532424a09 100644 --- a/libraries/libstratosphere/source/usb/usb_remote_ds_service.cpp +++ b/libraries/libstratosphere/source/usb/usb_remote_ds_service.cpp @@ -19,12 +19,12 @@ namespace ams::usb { - Result RemoteDsService::Bind(usb::ComplexId complex_id, sf::CopyHandle process_h) { + Result RemoteDsService::Bind(usb::ComplexId complex_id, sf::CopyHandle &&process_h) { if (hos::GetVersion() >= hos::Version_11_0_0) { serviceAssumeDomain(std::addressof(m_srv)); R_TRY(serviceDispatchIn(std::addressof(m_srv), 0, complex_id, .in_num_handles = 1, - .in_handles = { process_h.GetValue() } + .in_handles = { process_h.GetOsHandle() } )); } else { serviceAssumeDomain(std::addressof(m_srv)); @@ -33,7 +33,7 @@ namespace ams::usb { serviceAssumeDomain(std::addressof(m_srv)); R_TRY(serviceDispatch(std::addressof(m_srv), 1, .in_num_handles = 1, - .in_handles = { process_h.GetValue() }) + .in_handles = { process_h.GetOsHandle() }) ); } @@ -56,10 +56,15 @@ namespace ams::usb { Result RemoteDsService::GetStateChangeEvent(sf::OutCopyHandle out) { serviceAssumeDomain(std::addressof(m_srv)); - return serviceDispatch(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 2 : 3, + + os::NativeHandle event_handle; + R_TRY((serviceDispatch(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 2 : 3, .out_handle_attrs = { SfOutHandleAttr_HipcCopy }, - .out_handles = out.GetHandlePointer(), - ); + .out_handles = std::addressof(event_handle), + ))); + + out.SetValue(event_handle, true); + return ResultSuccess(); } Result RemoteDsService::GetState(sf::Out out) { diff --git a/libraries/libstratosphere/source/usb/usb_remote_ds_service.hpp b/libraries/libstratosphere/source/usb/usb_remote_ds_service.hpp index f21f77c8a..663d36b49 100644 --- a/libraries/libstratosphere/source/usb/usb_remote_ds_service.hpp +++ b/libraries/libstratosphere/source/usb/usb_remote_ds_service.hpp @@ -29,7 +29,7 @@ namespace ams::usb { RemoteDsService(Service &srv, sf::ExpHeapAllocator *allocator) : m_srv(srv), m_allocator(allocator) { /* ... */ } virtual ~RemoteDsService() { serviceClose(std::addressof(m_srv)); } public: - Result Bind(usb::ComplexId complex_id, sf::CopyHandle process_h); + Result Bind(usb::ComplexId complex_id, sf::CopyHandle &&process_h); Result RegisterInterface(sf::Out> out, u8 bInterfaceNumber); Result GetStateChangeEvent(sf::OutCopyHandle out); Result GetState(sf::Out out); diff --git a/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.cpp b/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.cpp index 1c603353a..8a89c5c76 100644 --- a/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.cpp +++ b/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.cpp @@ -410,12 +410,12 @@ namespace ams::mitm::sysupdater { return ResultSuccess(); }; - Result SystemUpdateService::SetupUpdate(sf::CopyHandle transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat) { - return this->SetupUpdateImpl(transfer_memory.GetValue(), transfer_memory_size, path, exfat, GetFirmwareVariationId()); + Result SystemUpdateService::SetupUpdate(sf::CopyHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat) { + return this->SetupUpdateImpl(std::move(transfer_memory), transfer_memory_size, path, exfat, GetFirmwareVariationId()); } - Result SystemUpdateService::SetupUpdateWithVariation(sf::CopyHandle transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id) { - return this->SetupUpdateImpl(transfer_memory.GetValue(), transfer_memory_size, path, exfat, firmware_variation_id); + Result SystemUpdateService::SetupUpdateWithVariation(sf::CopyHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id) { + return this->SetupUpdateImpl(std::move(transfer_memory), transfer_memory_size, path, exfat, firmware_variation_id); } Result SystemUpdateService::RequestPrepareUpdate(sf::OutCopyHandle out_event_handle, sf::Out> out_async) { @@ -432,7 +432,7 @@ namespace ams::mitm::sysupdater { /* We prepared the task! */ this->requested_update = true; - out_event_handle.SetValue(async_result.GetImpl().GetEvent().GetReadableHandle()); + out_event_handle.SetValue(async_result.GetImpl().GetEvent().GetReadableHandle(), false); *out_async = std::move(async_result); return ResultSuccess(); @@ -469,10 +469,7 @@ namespace ams::mitm::sysupdater { return ResultSuccess(); } - Result SystemUpdateService::SetupUpdateImpl(os::NativeHandle transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id) { - /* Ensure the transfer memory handle is closed, if we exit before creating the management object. */ - auto handle_guard = SCOPE_GUARD { os::CloseNativeHandle(transfer_memory); }; - + Result SystemUpdateService::SetupUpdateImpl(sf::NativeHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id) { /* Ensure we don't already have an update set up. */ R_UNLESS(!this->setup_update, ns::ResultCardUpdateAlreadySetup()); @@ -484,18 +481,18 @@ namespace ams::mitm::sysupdater { } /* Initialize the update task. */ - handle_guard.Cancel(); - R_TRY(InitializeUpdateTask(transfer_memory, transfer_memory_size, path, exfat, firmware_variation_id)); + R_TRY(InitializeUpdateTask(std::move(transfer_memory), transfer_memory_size, path, exfat, firmware_variation_id)); /* The update is now set up. */ this->setup_update = true; return ResultSuccess(); } - Result SystemUpdateService::InitializeUpdateTask(os::NativeHandle transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id) { + Result SystemUpdateService::InitializeUpdateTask(sf::NativeHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id) { /* Map the transfer memory. */ const size_t tmem_buffer_size = static_cast(transfer_memory_size); - this->update_transfer_memory.emplace(tmem_buffer_size, transfer_memory, true); + this->update_transfer_memory.emplace(tmem_buffer_size, transfer_memory.GetOsHandle(), transfer_memory.IsManaged()); + transfer_memory.Detach(); void *tmem_buffer; R_TRY(this->update_transfer_memory->Map(std::addressof(tmem_buffer), os::MemoryPermission_None)); diff --git a/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.hpp b/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.hpp index 570c409b1..7952b4e61 100644 --- a/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.hpp +++ b/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.hpp @@ -40,14 +40,14 @@ namespace ams::mitm::sysupdater { } -#define AMS_SYSUPDATER_SYSTEM_UPDATE_INTERFACE_INFO(C, H) \ - AMS_SF_METHOD_INFO(C, H, 0, Result, GetUpdateInformation, (sf::Out out, const ncm::Path &path), (out, path)) \ - AMS_SF_METHOD_INFO(C, H, 1, Result, ValidateUpdate, (sf::Out out_validate_result, sf::Out out_validate_exfat_result, sf::Out out_validate_info, const ncm::Path &path), (out_validate_result, out_validate_exfat_result, out_validate_info, path)) \ - AMS_SF_METHOD_INFO(C, H, 2, Result, SetupUpdate, (sf::CopyHandle transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat), (transfer_memory, transfer_memory_size, path, exfat)) \ - AMS_SF_METHOD_INFO(C, H, 3, Result, SetupUpdateWithVariation, (sf::CopyHandle transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id), (transfer_memory, transfer_memory_size, path, exfat, firmware_variation_id)) \ - AMS_SF_METHOD_INFO(C, H, 4, Result, RequestPrepareUpdate, (sf::OutCopyHandle out_event_handle, sf::Out> out_async), (out_event_handle, out_async)) \ - AMS_SF_METHOD_INFO(C, H, 5, Result, GetPrepareUpdateProgress, (sf::Out out), (out)) \ - AMS_SF_METHOD_INFO(C, H, 6, Result, HasPreparedUpdate, (sf::Out out), (out)) \ +#define AMS_SYSUPDATER_SYSTEM_UPDATE_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, GetUpdateInformation, (sf::Out out, const ncm::Path &path), (out, path)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, ValidateUpdate, (sf::Out out_validate_result, sf::Out out_validate_exfat_result, sf::Out out_validate_info, const ncm::Path &path), (out_validate_result, out_validate_exfat_result, out_validate_info, path)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, SetupUpdate, (sf::CopyHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat), (std::move(transfer_memory), transfer_memory_size, path, exfat)) \ + AMS_SF_METHOD_INFO(C, H, 3, Result, SetupUpdateWithVariation, (sf::CopyHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id), (std::move(transfer_memory), transfer_memory_size, path, exfat, firmware_variation_id)) \ + AMS_SF_METHOD_INFO(C, H, 4, Result, RequestPrepareUpdate, (sf::OutCopyHandle out_event_handle, sf::Out> out_async), (out_event_handle, out_async)) \ + AMS_SF_METHOD_INFO(C, H, 5, Result, GetPrepareUpdateProgress, (sf::Out out), (out)) \ + AMS_SF_METHOD_INFO(C, H, 6, Result, HasPreparedUpdate, (sf::Out out), (out)) \ AMS_SF_METHOD_INFO(C, H, 7, Result, ApplyPreparedUpdate, (), ()) AMS_SF_DEFINE_INTERFACE(ams::mitm::sysupdater::impl, ISystemUpdateInterface, AMS_SYSUPDATER_SYSTEM_UPDATE_INTERFACE_INFO) @@ -64,13 +64,13 @@ namespace ams::mitm::sysupdater { public: constexpr SystemUpdateService() : apply_manager(), update_task(), update_transfer_memory(), setup_update(false), requested_update(false) { /* ... */ } private: - Result SetupUpdateImpl(os::NativeHandle transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id); - Result InitializeUpdateTask(os::NativeHandle transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id); + Result SetupUpdateImpl(sf::NativeHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id); + Result InitializeUpdateTask(sf::NativeHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id); public: Result GetUpdateInformation(sf::Out out, const ncm::Path &path); Result ValidateUpdate(sf::Out out_validate_result, sf::Out out_validate_exfat_result, sf::Out out_validate_info, const ncm::Path &path); - Result SetupUpdate(sf::CopyHandle transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat); - Result SetupUpdateWithVariation(sf::CopyHandle transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id); + Result SetupUpdate(sf::CopyHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat); + Result SetupUpdateWithVariation(sf::CopyHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id); Result RequestPrepareUpdate(sf::OutCopyHandle out_event_handle, sf::Out> out_async); Result GetPrepareUpdateProgress(sf::Out out); Result HasPreparedUpdate(sf::Out out); diff --git a/stratosphere/dmnt/source/cheat/dmnt_cheat_service.cpp b/stratosphere/dmnt/source/cheat/dmnt_cheat_service.cpp index 229ef6b7c..387bf84f0 100644 --- a/stratosphere/dmnt/source/cheat/dmnt_cheat_service.cpp +++ b/stratosphere/dmnt/source/cheat/dmnt_cheat_service.cpp @@ -28,7 +28,7 @@ namespace ams::dmnt::cheat { } void CheatService::GetCheatProcessEvent(sf::OutCopyHandle out_event) { - out_event.SetValue(dmnt::cheat::impl::GetCheatProcessEventHandle()); + out_event.SetValue(dmnt::cheat::impl::GetCheatProcessEventHandle(), false); } Result CheatService::GetCheatProcessMetadata(sf::Out out_metadata) { diff --git a/stratosphere/fatal/source/fatal_service.cpp b/stratosphere/fatal/source/fatal_service.cpp index 62f9c506f..f978f0ce8 100644 --- a/stratosphere/fatal/source/fatal_service.cpp +++ b/stratosphere/fatal/source/fatal_service.cpp @@ -148,7 +148,7 @@ namespace ams::fatal::srv { Result Service::GetFatalEvent(sf::OutCopyHandle out_h) { const os::SystemEventType *event; R_TRY(g_context.GetEvent(std::addressof(event))); - out_h.SetValue(os::GetReadableHandleOfSystemEvent(event)); + out_h.SetValue(os::GetReadableHandleOfSystemEvent(event), false); return ResultSuccess(); } diff --git a/stratosphere/loader/source/ldr_loader_service.cpp b/stratosphere/loader/source/ldr_loader_service.cpp index 97283b002..bfeaa96e7 100644 --- a/stratosphere/loader/source/ldr_loader_service.cpp +++ b/stratosphere/loader/source/ldr_loader_service.cpp @@ -56,10 +56,7 @@ namespace ams::ldr { } /* Official commands. */ - Result LoaderService::CreateProcess(sf::OutMoveHandle proc_h, PinId id, u32 flags, sf::CopyHandle reslimit_h) { - /* Ensure we close the input handle when we're done. */ - ON_SCOPE_EXIT { os::CloseNativeHandle(reslimit_h.GetValue()); }; - + Result LoaderService::CreateProcess(sf::OutMoveHandle out, PinId id, u32 flags, sf::CopyHandle &&reslimit_h) { ncm::ProgramLocation loc; cfg::OverrideStatus override_status; char path[FS_MAX_PATH]; @@ -71,7 +68,13 @@ namespace ams::ldr { R_TRY(ResolveContentPath(path, loc)); } - return ldr::CreateProcess(proc_h.GetHandlePointer(), id, loc, override_status, path, flags, reslimit_h.GetValue()); + /* Create the process. */ + os::NativeHandle process_handle; + R_TRY(ldr::CreateProcess(std::addressof(process_handle), id, loc, override_status, path, flags, reslimit_h.GetOsHandle())); + + /* Set output process handle. */ + out.SetValue(process_handle, true); + return ResultSuccess(); } Result LoaderService::GetProgramInfo(sf::Out out, const ncm::ProgramLocation &loc) { @@ -110,7 +113,11 @@ namespace ams::ldr { /* Atmosphere commands. */ Result LoaderService::AtmosphereRegisterExternalCode(sf::OutMoveHandle out, ncm::ProgramId program_id) { - return fssystem::CreateExternalCode(out.GetHandlePointer(), program_id); + os::NativeHandle handle; + R_TRY(fssystem::CreateExternalCode(std::addressof(handle), program_id)); + + out.SetValue(handle, true); + return ResultSuccess(); } void LoaderService::AtmosphereUnregisterExternalCode(ncm::ProgramId program_id) { diff --git a/stratosphere/loader/source/ldr_loader_service.hpp b/stratosphere/loader/source/ldr_loader_service.hpp index d1c774264..56313b8e5 100644 --- a/stratosphere/loader/source/ldr_loader_service.hpp +++ b/stratosphere/loader/source/ldr_loader_service.hpp @@ -21,7 +21,7 @@ namespace ams::ldr { class LoaderService { public: /* Official commands. */ - Result CreateProcess(sf::OutMoveHandle proc_h, PinId id, u32 flags, sf::CopyHandle reslimit_h); + Result CreateProcess(sf::OutMoveHandle proc_h, PinId id, u32 flags, sf::CopyHandle &&reslimit_h); Result GetProgramInfo(sf::Out out_program_info, const ncm::ProgramLocation &loc); Result PinProgram(sf::Out out_id, const ncm::ProgramLocation &loc); Result UnpinProgram(PinId id); diff --git a/stratosphere/pm/source/pm_debug_monitor_service.cpp b/stratosphere/pm/source/pm_debug_monitor_service.cpp index 9aba0b4ab..dd1a4fb64 100644 --- a/stratosphere/pm/source/pm_debug_monitor_service.cpp +++ b/stratosphere/pm/source/pm_debug_monitor_service.cpp @@ -39,7 +39,11 @@ namespace ams::pm { } Result DebugMonitorService::HookToCreateProcess(sf::OutCopyHandle out_hook, ncm::ProgramId program_id) { - return impl::HookToCreateProcess(out_hook.GetHandlePointer(), program_id); + os::NativeHandle event_handle; + R_TRY(impl::HookToCreateProcess(std::addressof(event_handle), program_id)); + + out_hook.SetValue(event_handle, false); + return ResultSuccess(); } Result DebugMonitorService::GetApplicationProcessId(sf::Out out) { @@ -47,7 +51,11 @@ namespace ams::pm { } Result DebugMonitorService::HookToCreateApplicationProcess(sf::OutCopyHandle out_hook) { - return impl::HookToCreateApplicationProcess(out_hook.GetHandlePointer()); + os::NativeHandle event_handle; + R_TRY(impl::HookToCreateApplicationProcess(std::addressof(event_handle))); + + out_hook.SetValue(event_handle, false); + return ResultSuccess(); } Result DebugMonitorService::ClearHook(u32 which) { @@ -56,7 +64,11 @@ namespace ams::pm { /* Atmosphere extension commands. */ Result DebugMonitorService::AtmosphereGetProcessInfo(sf::OutCopyHandle out_process_handle, sf::Out out_loc, sf::Out out_status, os::ProcessId process_id) { - return impl::AtmosphereGetProcessInfo(out_process_handle.GetHandlePointer(), out_loc.GetPointer(), out_status.GetPointer(), process_id); + os::NativeHandle process_handle; + R_TRY(impl::AtmosphereGetProcessInfo(std::addressof(process_handle), out_loc.GetPointer(), out_status.GetPointer(), process_id)); + + out_process_handle.SetValue(process_handle, false); + return ResultSuccess(); } Result DebugMonitorService::AtmosphereGetCurrentLimitInfo(sf::Out out_cur_val, sf::Out out_lim_val, u32 group, u32 resource) { diff --git a/stratosphere/pm/source/pm_shell_service.cpp b/stratosphere/pm/source/pm_shell_service.cpp index 01a5ccd17..2adf545b9 100644 --- a/stratosphere/pm/source/pm_shell_service.cpp +++ b/stratosphere/pm/source/pm_shell_service.cpp @@ -42,7 +42,10 @@ namespace ams::pm { } void ShellService::GetProcessEventHandle(sf::OutCopyHandle out) { - R_ABORT_UNLESS(impl::GetProcessEventHandle(out.GetHandlePointer())); + os::NativeHandle event_handle; + R_ABORT_UNLESS(impl::GetProcessEventHandle(std::addressof(event_handle))); + + out.SetValue(event_handle, false); } void ShellService::GetProcessEventInfo(sf::Out out) { @@ -74,7 +77,10 @@ namespace ams::pm { } void ShellService::GetBootFinishedEventHandle(sf::OutCopyHandle out) { - R_ABORT_UNLESS(impl::GetBootFinishedEventHandle(out.GetHandlePointer())); + os::NativeHandle event_handle; + R_ABORT_UNLESS(impl::GetBootFinishedEventHandle(std::addressof(event_handle))); + + out.SetValue(event_handle, false); } } diff --git a/stratosphere/ro/source/impl/ro_service_impl.cpp b/stratosphere/ro/source/impl/ro_service_impl.cpp index e8280a687..cb3f5a085 100644 --- a/stratosphere/ro/source/impl/ro_service_impl.cpp +++ b/stratosphere/ro/source/impl/ro_service_impl.cpp @@ -373,16 +373,12 @@ namespace ams::ro::impl { } /* Context utilities. */ - Result RegisterProcess(size_t *out_context_id, os::NativeHandle process_handle, os::ProcessId process_id) { - /* Ensure we manage process handle correctly. */ - auto handle_guard = SCOPE_GUARD { os::CloseNativeHandle(process_handle); }; - + Result RegisterProcess(size_t *out_context_id, sf::NativeHandle &&process_handle, os::ProcessId process_id) { /* Validate process handle. */ { - os::ProcessId handle_pid = os::InvalidProcessId; - /* Validate handle is a valid process handle. */ - R_UNLESS(R_SUCCEEDED(os::GetProcessId(&handle_pid, process_handle)), ResultInvalidProcess()); + os::ProcessId handle_pid; + R_UNLESS(R_SUCCEEDED(os::GetProcessId(&handle_pid, process_handle.GetOsHandle())), ResultInvalidProcess()); /* Validate process id. */ R_UNLESS(handle_pid == process_id, ResultInvalidProcess()); @@ -392,8 +388,8 @@ namespace ams::ro::impl { R_UNLESS(GetContextByProcessId(process_id) == nullptr, ResultInvalidSession()); /* Allocate a context to manage the process handle. */ - handle_guard.Cancel(); - *out_context_id = AllocateContext(process_handle, process_id); + *out_context_id = AllocateContext(process_handle.GetOsHandle(), process_id); + process_handle.Detach(); return ResultSuccess(); } @@ -411,9 +407,6 @@ namespace ams::ro::impl { /* Service implementations. */ Result RegisterModuleInfo(size_t context_id, os::NativeHandle process_handle, u64 nrr_address, u64 nrr_size, NrrKind nrr_kind, bool enforce_nrr_kind) { - /* Ensure we close the process handle when we're done with it. */ - ON_SCOPE_EXIT { os::CloseNativeHandle(process_handle); }; - /* Get context. */ ProcessContext *context = GetContextById(context_id); AMS_ABORT_UNLESS(context != nullptr); diff --git a/stratosphere/ro/source/impl/ro_service_impl.hpp b/stratosphere/ro/source/impl/ro_service_impl.hpp index abfe0c572..090a88834 100644 --- a/stratosphere/ro/source/impl/ro_service_impl.hpp +++ b/stratosphere/ro/source/impl/ro_service_impl.hpp @@ -30,7 +30,7 @@ namespace ams::ro::impl { bool ShouldEaseNroRestriction(); /* Context utilities. */ - Result RegisterProcess(size_t *out_context_id, os::NativeHandle process_handle, os::ProcessId process_id); + Result RegisterProcess(size_t *out_context_id, sf::NativeHandle &&process_handle, os::ProcessId process_id); Result ValidateProcess(size_t context_id, os::ProcessId process_id); void UnregisterProcess(size_t context_id); diff --git a/stratosphere/ro/source/ro_ro_service.cpp b/stratosphere/ro/source/ro_ro_service.cpp index 210ece817..52687bd36 100644 --- a/stratosphere/ro/source/ro_ro_service.cpp +++ b/stratosphere/ro/source/ro_ro_service.cpp @@ -55,21 +55,17 @@ namespace ams::ro { return impl::UnregisterModuleInfo(this->context_id, nrr_address); } - Result RoService::RegisterProcessHandle(const sf::ClientProcessId &client_pid, sf::CopyHandle process_h) { + Result RoService::RegisterProcessHandle(const sf::ClientProcessId &client_pid, sf::CopyHandle &&process_h) { /* Register the process. */ - return impl::RegisterProcess(std::addressof(this->context_id), process_h.GetValue(), client_pid.GetValue()); + return impl::RegisterProcess(std::addressof(this->context_id), std::move(process_h), client_pid.GetValue()); } - Result RoService::RegisterProcessModuleInfo(const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size, sf::CopyHandle process_h) { - /* Validate the process, ensuring we manage the process handle correctly. */ - { - auto handle_guard = SCOPE_GUARD { os::CloseNativeHandle(process_h.GetValue()); }; - R_TRY(impl::ValidateProcess(this->context_id, client_pid.GetValue())); - handle_guard.Cancel(); - } + Result RoService::RegisterProcessModuleInfo(const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size, sf::CopyHandle &&process_h) { + /* Validate the process. */ + R_TRY(impl::ValidateProcess(this->context_id, client_pid.GetValue())); /* Register the module. */ - return impl::RegisterModuleInfo(this->context_id, process_h.GetValue(), nrr_address, nrr_size, this->nrr_kind, this->nrr_kind == NrrKind_JitPlugin); + return impl::RegisterModuleInfo(this->context_id, process_h.GetOsHandle(), nrr_address, nrr_size, this->nrr_kind, this->nrr_kind == NrrKind_JitPlugin); } } diff --git a/stratosphere/ro/source/ro_ro_service.hpp b/stratosphere/ro/source/ro_ro_service.hpp index cc1bb1b59..57f588ce8 100644 --- a/stratosphere/ro/source/ro_ro_service.hpp +++ b/stratosphere/ro/source/ro_ro_service.hpp @@ -37,8 +37,8 @@ namespace ams::ro { Result UnmapManualLoadModuleMemory(const sf::ClientProcessId &client_pid, u64 nro_address); Result RegisterModuleInfo(const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size); Result UnregisterModuleInfo(const sf::ClientProcessId &client_pid, u64 nrr_address); - Result RegisterProcessHandle(const sf::ClientProcessId &client_pid, sf::CopyHandle process_h); - Result RegisterProcessModuleInfo(const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size, sf::CopyHandle process_h); + Result RegisterProcessHandle(const sf::ClientProcessId &client_pid, sf::CopyHandle &&process_h); + Result RegisterProcessModuleInfo(const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size, sf::CopyHandle &&process_h); }; static_assert(ro::impl::IsIRoInterface); diff --git a/stratosphere/spl/source/spl_crypto_service.cpp b/stratosphere/spl/source/spl_crypto_service.cpp index c5a9915c6..a53cba991 100644 --- a/stratosphere/spl/source/spl_crypto_service.cpp +++ b/stratosphere/spl/source/spl_crypto_service.cpp @@ -57,7 +57,7 @@ namespace ams::spl { } Result CryptoService::GetAesKeySlotAvailableEvent(sf::OutCopyHandle out_hnd) { - out_hnd.SetValue(impl::GetAesKeySlotAvailableEventHandle()); + out_hnd.SetValue(impl::GetAesKeySlotAvailableEventHandle(), false); return ResultSuccess(); } diff --git a/stratosphere/spl/source/spl_deprecated_service.cpp b/stratosphere/spl/source/spl_deprecated_service.cpp index 3592f19ca..d344ac721 100644 --- a/stratosphere/spl/source/spl_deprecated_service.cpp +++ b/stratosphere/spl/source/spl_deprecated_service.cpp @@ -121,7 +121,7 @@ namespace ams::spl { } Result DeprecatedService::GetAesKeySlotAvailableEvent(sf::OutCopyHandle out_hnd) { - out_hnd.SetValue(impl::GetAesKeySlotAvailableEventHandle()); + out_hnd.SetValue(impl::GetAesKeySlotAvailableEventHandle(), false); return ResultSuccess(); }