mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-09 22:56:35 +00:00
strat: use sf::NativeHandle for ipc templating
This commit is contained in:
parent
d97e97258e
commit
69777cf792
41 changed files with 447 additions and 454 deletions
|
@ -20,7 +20,7 @@
|
|||
#include <stratosphere/sf.hpp>
|
||||
|
||||
#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<ldr::ProgramInfo> out_program_info, const ncm::ProgramLocation &loc), (out_program_info, loc)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 2, Result, PinProgram, (sf::Out<ldr::PinId> out_id, const ncm::ProgramLocation &loc), (out_id, loc)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 3, Result, UnpinProgram, (ldr::PinId id), (id)) \
|
||||
|
|
|
@ -46,9 +46,12 @@ namespace ams::pgl {
|
|||
explicit EventObserverByCmif(ams::sf::SharedPointer<pgl::sf::IEventObserver> 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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <stratosphere/sf/sf_service_object.hpp>
|
||||
#include <stratosphere/sf/sf_out.hpp>
|
||||
#include <stratosphere/sf/sf_buffers.hpp>
|
||||
#include <stratosphere/sf/sf_handles.hpp>
|
||||
#include <stratosphere/sf/sf_native_handle.hpp>
|
||||
#include <stratosphere/sf/cmif/sf_cmif_pointer_and_size.hpp>
|
||||
#include <stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp>
|
||||
#include <stratosphere/sf/cmif/sf_cmif_service_object_holder.hpp>
|
||||
|
@ -199,15 +199,18 @@ namespace ams::sf::impl {
|
|||
|
||||
template<typename T>
|
||||
constexpr inline ArgumentType GetArgumentType = [] {
|
||||
static_assert(!std::same_as<T, sf::NativeHandle>);
|
||||
static_assert(!std::same_as<T, sf::Out<sf::NativeHandle>>);
|
||||
|
||||
if constexpr (sf::IsBuffer<T>) {
|
||||
return ArgumentType::Buffer;
|
||||
} else if constexpr (IsInObject<T>::value) {
|
||||
return ArgumentType::InObject;
|
||||
} else if constexpr (std::is_base_of<sf::impl::OutObjectTag, T>::value) {
|
||||
return ArgumentType::OutObject;
|
||||
} else if constexpr (std::is_base_of<sf::impl::InHandleTag, T>::value) {
|
||||
} else if constexpr (std::same_as<T, sf::CopyHandle> || std::same_as<T, sf::MoveHandle>) {
|
||||
return ArgumentType::InHandle;
|
||||
} else if constexpr (std::is_base_of<sf::impl::OutHandleTag, T>::value) {
|
||||
} else if constexpr (std::same_as<T, sf::OutCopyHandle> || std::same_as<T, sf::OutMoveHandle>) {
|
||||
return ArgumentType::OutHandle;
|
||||
} else if constexpr (std::is_base_of<sf::impl::OutBaseTag, T>::value) {
|
||||
return ArgumentType::OutData;
|
||||
|
@ -413,7 +416,7 @@ namespace ams::sf::impl {
|
|||
};
|
||||
|
||||
template<typename T>
|
||||
using DecayForCommandMetaArguments = typename std::conditional<sf::IsLargeData<typename std::decay<T>::type> && !std::is_base_of<impl::OutBaseTag, typename std::decay<T>::type>::value, T, typename std::decay<T>::type>::type;
|
||||
using DecayForCommandMetaArguments = typename std::conditional<(sf::IsLargeData<typename std::decay<T>::type> && !std::is_base_of<impl::OutBaseTag, typename std::decay<T>::type>::value), T, typename std::conditional<(std::same_as<T, sf::MoveHandle &&> || std::same_as<T, sf::CopyHandle &&>), typename std::decay<T>::type &, typename std::decay<T>::type>::type>::type;
|
||||
|
||||
template<typename... Arguments>
|
||||
struct CommandMetaInfo {
|
||||
|
@ -625,38 +628,57 @@ namespace ams::sf::impl {
|
|||
};
|
||||
|
||||
template<size_t _NumMove, size_t _NumCopy>
|
||||
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<size_t Index>
|
||||
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<size_t Index>
|
||||
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<size_t _NumMove, size_t _NumCopy>
|
||||
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<size_t Index>
|
||||
constexpr inline NativeHandle *GetMoveHandlePointer() {
|
||||
static_assert(Index < NumMove, "Index < NumMove");
|
||||
return &move_handles[Index];
|
||||
return move_handles + Index;
|
||||
}
|
||||
|
||||
template<size_t Index>
|
||||
constexpr inline CopyHandle *GetCopyHandlePointer() {
|
||||
constexpr inline NativeHandle *GetCopyHandlePointer() {
|
||||
static_assert(Index < NumCopy, "Index < NumCopy");
|
||||
return ©_handles[Index];
|
||||
}
|
||||
|
||||
template<size_t Index>
|
||||
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<cmif::PointerAndSize, CommandMeta::NumBuffers>;
|
||||
using OutRawHolderType = OutRawHolder<CommandMeta::OutDataSize, CommandMeta::OutDataAlign>;
|
||||
using InHandleHolderType = InHandleHolder<CommandMeta::NumInMoveHandles, CommandMeta::NumInCopyHandles>;
|
||||
using OutHandleHolderType = OutHandleHolder<CommandMeta::NumOutMoveHandles, CommandMeta::NumOutCopyHandles>;
|
||||
using InOutObjectHolderType = InOutObjectHolder<CommandMeta::NumInObjects, CommandMeta::NumOutObjects>;
|
||||
|
||||
|
@ -1014,7 +1037,7 @@ namespace ams::sf::impl {
|
|||
/* Argument deserialization. */
|
||||
private:
|
||||
template<size_t Index, typename T = typename std::tuple_element<Index, ArgsType>::type>
|
||||
NX_CONSTEXPR typename std::tuple_element<Index, ArgsTypeForInvoke>::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<Index, ArgsTypeForInvoke>::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<Offset, T::TypeSize>());
|
||||
} else if constexpr (Info.arg_type == ArgumentType::InHandle) {
|
||||
/* New InHandle. */
|
||||
using InvokeType = typename std::tuple_element<Index, ArgsTypeForInvoke>::type;
|
||||
if constexpr (std::is_same<T, sf::MoveHandle>::value) {
|
||||
return T(ctx.request.data.move_handles[Info.in_move_handle_index]);
|
||||
static_assert(std::same_as<InvokeType, sf::MoveHandle &>);
|
||||
return in_handles_holder.template SetMoveHandle<Info.in_move_handle_index>(ctx.request.data.move_handles[Info.in_move_handle_index]);
|
||||
} else if constexpr (std::is_same<T, sf::CopyHandle>::value) {
|
||||
return T(ctx.request.data.copy_handles[Info.in_copy_handle_index]);
|
||||
static_assert(std::same_as<InvokeType, sf::CopyHandle &>);
|
||||
return in_handles_holder.template SetCopyHandle<Info.in_copy_handle_index>(ctx.request.data.copy_handles[Info.in_copy_handle_index]);
|
||||
} else {
|
||||
static_assert(!std::is_same<T, T>::value, "Invalid InHandle kind");
|
||||
}
|
||||
} else if constexpr (Info.arg_type == ArgumentType::OutHandle) {
|
||||
/* New OutHandle. */
|
||||
if constexpr (std::is_same<T, sf::Out<sf::MoveHandle>>::value) {
|
||||
if constexpr (std::is_same<T, sf::OutMoveHandle>::value) {
|
||||
return T(out_handles_holder.template GetMoveHandlePointer<Info.out_move_handle_index>());
|
||||
} else if constexpr (std::is_same<T, sf::Out<sf::CopyHandle>>::value) {
|
||||
return T(out_handles_holder.template GetCopyHandlePointer<Info.out_copy_handle_index>(), out_handles_holder.template GetCopyHandleManagedPointer<Info.out_copy_handle_index>());
|
||||
} else if constexpr (std::is_same<T, sf::OutCopyHandle>::value) {
|
||||
return T(out_handles_holder.template GetCopyHandlePointer<Info.out_copy_handle_index>());
|
||||
} else {
|
||||
static_assert(!std::is_same<T, T>::value, "Invalid OutHandle kind");
|
||||
}
|
||||
|
@ -1078,12 +1104,12 @@ namespace ams::sf::impl {
|
|||
}
|
||||
|
||||
template<size_t... Is>
|
||||
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<Is...>) {
|
||||
return ArgsTypeForInvoke { DeserializeArgumentImpl<Is>(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<Is...>) {
|
||||
return ArgsTypeForInvoke { DeserializeArgumentImpl<Is>(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<std::tuple_size<ArgsTypeForInvoke>::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<std::tuple_size<ArgsTypeForInvoke>::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<CommandMeta>;
|
||||
using BufferArrayType = std::array<cmif::PointerAndSize, CommandMeta::NumBuffers>;
|
||||
using InHandleHolderType = InHandleHolder<CommandMeta::NumInMoveHandles, CommandMeta::NumInCopyHandles>;
|
||||
using OutHandleHolderType = OutHandleHolder<CommandMeta::NumOutMoveHandles, CommandMeta::NumOutCopyHandles>;
|
||||
using OutRawHolderType = OutRawHolder<CommandMeta::OutDataSize, CommandMeta::OutDataAlign>;
|
||||
using InOutObjectHolderType = InOutObjectHolder<CommandMeta::NumInObjects, CommandMeta::NumOutObjects>;
|
||||
|
@ -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<typename CommandMeta::ArgsTypeForInvoke>::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<ArgsTypeForInvoke>::value) { \
|
||||
if constexpr (CommandMeta::template IsInProcessIdHolderIndex<n>) { \
|
||||
R_TRY(MarshalProcessId(std::get<n>(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<typename CommandMeta::ArgsTypeForInvoke>::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<ArgsTypeForInvoke>::value) { \
|
||||
if constexpr (CommandMeta::template IsInProcessIdHolderIndex<n>) { \
|
||||
R_TRY(MarshalProcessId(std::get<n>(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<Arguments...>;
|
||||
|
||||
sf::IServiceObject * const this_ptr = ctx.srv_obj;
|
||||
command_result = [this_ptr, invoke_impl, &args_tuple]<size_t ...Ix>(std::index_sequence<Ix...>) ALWAYS_INLINE_LAMBDA {
|
||||
return invoke_impl(this_ptr, std::forward<typename std::tuple_element<Ix, TrueArgumentsTuple>::type>(std::get<Ix>(args_tuple))...);
|
||||
}(std::make_index_sequence<std::tuple_size<typename CommandMeta::ArgsTypeForInvoke>::value>());
|
||||
}
|
||||
|
||||
using TrueArgumentsTuple = std::tuple<Arguments...>;
|
||||
|
||||
sf::IServiceObject * const this_ptr = ctx.srv_obj;
|
||||
const auto command_result = [this_ptr, invoke_impl, &args_tuple]<size_t ...Ix>(std::index_sequence<Ix...>) ALWAYS_INLINE_LAMBDA {
|
||||
return invoke_impl(this_ptr, std::forward<typename std::tuple_element<Ix, TrueArgumentsTuple>::type>(std::get<Ix>(args_tuple))...);
|
||||
}(std::make_index_sequence<std::tuple_size<typename CommandMeta::ArgsTypeForInvoke>::value>());
|
||||
|
||||
if (R_FAILED(command_result)) {
|
||||
cmif::PointerAndSize out_raw_data;
|
||||
ctx.processor->PrepareForErrorReply(ctx, out_raw_data, runtime_metadata);
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <stratosphere/sf/sf_common.hpp>
|
||||
#include <stratosphere/sf/sf_out.hpp>
|
||||
#include <stratosphere/sf/cmif/sf_cmif_pointer_and_size.hpp>
|
||||
|
||||
namespace ams::sf {
|
||||
|
||||
namespace impl {
|
||||
|
||||
struct InHandleTag{};
|
||||
struct OutHandleTag{};
|
||||
|
||||
template<u32 Attribute>
|
||||
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<typename T>
|
||||
class OutHandleImpl : public OutHandleTag {
|
||||
static_assert(std::is_base_of<InHandleTag, T>::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<SfOutHandleAttr_HipcMove>;
|
||||
using CopyHandle = typename impl::InHandle<SfOutHandleAttr_HipcCopy>;
|
||||
|
||||
static_assert(sizeof(MoveHandle) == sizeof(os::NativeHandle), "sizeof(MoveHandle)");
|
||||
static_assert(sizeof(CopyHandle) == sizeof(os::NativeHandle), "sizeof(CopyHandle)");
|
||||
|
||||
template<>
|
||||
class IsOutForceEnabled<MoveHandle> : public std::true_type{};
|
||||
template<>
|
||||
class IsOutForceEnabled<CopyHandle> : public std::true_type{};
|
||||
|
||||
template<>
|
||||
class Out<MoveHandle> : public impl::OutHandleImpl<MoveHandle> {
|
||||
private:
|
||||
using T = MoveHandle;
|
||||
using Base = impl::OutHandleImpl<T>;
|
||||
public:
|
||||
constexpr Out<T>(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<CopyHandle> : public impl::OutHandleImpl<CopyHandle> {
|
||||
private:
|
||||
using T = CopyHandle;
|
||||
using Base = impl::OutHandleImpl<T>;
|
||||
private:
|
||||
bool *m_managed;
|
||||
public:
|
||||
constexpr Out<T>(T *p) : Base(p), m_managed(nullptr) { /* ... */ }
|
||||
constexpr Out<T>(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<sf::MoveHandle>;
|
||||
using OutCopyHandle = sf::Out<sf::CopyHandle>;
|
||||
|
||||
}
|
|
@ -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<NativeHandle> {
|
||||
class Out<CopyHandle> {
|
||||
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<MoveHandle> {
|
||||
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<CopyHandle>;
|
||||
using OutMoveHandle = Out<MoveHandle>;
|
||||
|
||||
}
|
|
@ -20,31 +20,31 @@
|
|||
#include <stratosphere/tma/tma_i_socket.hpp>
|
||||
|
||||
/* 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<s32> out_err, sf::Out<s32> out_res), (out_err, out_res)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 1, Result, Connect, (sf::Out<s32> out_err, sf::Out<s32> out_res, const htcs::SockAddrHtcs &address), (out_err, out_res, address)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 2, Result, Bind, (sf::Out<s32> out_err, sf::Out<s32> out_res, const htcs::SockAddrHtcs &address), (out_err, out_res, address)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 3, Result, Listen, (sf::Out<s32> out_err, sf::Out<s32> out_res, s32 backlog_count), (out_err, out_res, backlog_count)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 4, Result, Accept, (sf::Out<s32> out_err, sf::Out<sf::SharedPointer<tma::ISocket>> out, sf::Out<htcs::SockAddrHtcs> out_address), (out_err, out, out_address)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 5, Result, Recv, (sf::Out<s32> out_err, sf::Out<s64> 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<s32> out_err, sf::Out<s64> 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<s32> out_err, sf::Out<s32> out_res, s32 how), (out_err, out_res, how)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 8, Result, Fcntl, (sf::Out<s32> out_err, sf::Out<s32> out_res, s32 command, s32 value), (out_err, out_res, command, value)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 9, Result, AcceptStart, (sf::Out<u32> out_task_id, sf::OutCopyHandle out_event), (out_task_id, out_event)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 10, Result, AcceptResults, (sf::Out<s32> out_err, sf::Out<sf::SharedPointer<tma::ISocket>> out, sf::Out<htcs::SockAddrHtcs> out_address, u32 task_id), (out_err, out, out_address, task_id)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 11, Result, RecvStart, (sf::Out<u32> 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<s32> out_err, sf::Out<s64> 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<u32> 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<u32> 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<u32> 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<s32> out_err, sf::Out<s64> out_size, u32 task_id), (out_err, out_size, task_id)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 17, Result, StartSend, (sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, sf::Out<s64> 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<s64> out_size, sf::Out<bool> 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<s32> out_err, sf::Out<s64> out_size, u32 task_id), (out_err, out_size, task_id)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 20, Result, StartRecv, (sf::Out<u32> 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<s32> out_err, sf::Out<s64> 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<u32> 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<s64> out_size, sf::Out<bool> 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<s32> out_err, sf::Out<s32> out_res), (out_err, out_res)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 1, Result, Connect, (sf::Out<s32> out_err, sf::Out<s32> out_res, const htcs::SockAddrHtcs &address), (out_err, out_res, address)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 2, Result, Bind, (sf::Out<s32> out_err, sf::Out<s32> out_res, const htcs::SockAddrHtcs &address), (out_err, out_res, address)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 3, Result, Listen, (sf::Out<s32> out_err, sf::Out<s32> out_res, s32 backlog_count), (out_err, out_res, backlog_count)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 4, Result, Accept, (sf::Out<s32> out_err, sf::Out<sf::SharedPointer<tma::ISocket>> out, sf::Out<htcs::SockAddrHtcs> out_address), (out_err, out, out_address)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 5, Result, Recv, (sf::Out<s32> out_err, sf::Out<s64> 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<s32> out_err, sf::Out<s64> 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<s32> out_err, sf::Out<s32> out_res, s32 how), (out_err, out_res, how)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 8, Result, Fcntl, (sf::Out<s32> out_err, sf::Out<s32> out_res, s32 command, s32 value), (out_err, out_res, command, value)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 9, Result, AcceptStart, (sf::Out<u32> out_task_id, sf::OutCopyHandle out_event), (out_task_id, out_event)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 10, Result, AcceptResults, (sf::Out<s32> out_err, sf::Out<sf::SharedPointer<tma::ISocket>> out, sf::Out<htcs::SockAddrHtcs> out_address, u32 task_id), (out_err, out, out_address, task_id)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 11, Result, RecvStart, (sf::Out<u32> 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<s32> out_err, sf::Out<s64> 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<u32> 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<u32> 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<u32> 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<s32> out_err, sf::Out<s64> out_size, u32 task_id), (out_err, out_size, task_id)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 17, Result, StartSend, (sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, sf::Out<s64> 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<s64> out_size, sf::Out<bool> 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<s32> out_err, sf::Out<s64> out_size, u32 task_id), (out_err, out_size, task_id)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 20, Result, StartRecv, (sf::Out<u32> 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<s32> out_err, sf::Out<s64> 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<u32> 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<s64> out_size, sf::Out<bool> 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<s32> out), (out))
|
||||
|
||||
AMS_SF_DEFINE_INTERFACE(ams::tma, ISocket, AMS_TMA_I_SOCKET_INTERFACE_INFO)
|
||||
|
|
|
@ -20,17 +20,17 @@
|
|||
#include <stratosphere/usb/usb_device_types.hpp>
|
||||
#include <stratosphere/usb/ds/usb_i_ds_interface.hpp>
|
||||
|
||||
#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<sf::SharedPointer<usb::ds::IDsInterface>> 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<usb::UsbState> out), (out)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 4, Result, ClearDeviceData, (), ()) \
|
||||
AMS_SF_METHOD_INFO(C, H, 5, Result, AddUsbStringDescriptor, (sf::Out<u8> 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<sf::SharedPointer<usb::ds::IDsInterface>> 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<usb::UsbState> out), (out)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 4, Result, ClearDeviceData, (), ()) \
|
||||
AMS_SF_METHOD_INFO(C, H, 5, Result, AddUsbStringDescriptor, (sf::Out<u8> 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? */
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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<u32> 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<const char *>(args.GetPointer()), args.GetSize()));
|
||||
os::NativeHandle event_handle;
|
||||
R_TRY(m_misc_impl.RunOnHostBegin(out_id.GetPointer(), std::addressof(event_handle), reinterpret_cast<const char *>(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();
|
||||
}
|
||||
|
||||
|
|
|
@ -51,9 +51,9 @@ namespace ams::htcs::client {
|
|||
Result Accept(sf::Out<s32> out_err, sf::Out<sf::SharedPointer<tma::ISocket>> out, sf::Out<htcs::SockAddrHtcs> out_address) { AMS_ABORT("Not Implemented"); }
|
||||
Result Recv(sf::Out<s32> out_err, sf::Out<s64> out_size, const sf::OutAutoSelectBuffer &buffer, s32 flags) { AMS_ABORT("Not Implemented"); }
|
||||
Result Send(sf::Out<s32> out_err, sf::Out<s64> out_size, const sf::InAutoSelectBuffer &buffer, s32 flags) { AMS_ABORT("Not Implemented"); }
|
||||
Result RecvLargeStart(sf::Out<u32> 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<u32> 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<u32> out_task_id, sf::OutCopyHandle out_event, const sf::InAutoSelectBuffer &buffer, s32 flags) { AMS_ABORT("Not Implemented"); }
|
||||
Result SendLargeStart(sf::Out<u32> 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<u32> 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<s64> out_size, sf::Out<bool> out_wait, const sf::InAutoSelectBuffer &buffer, u32 task_id) { AMS_ABORT("Not Implemented"); }
|
||||
|
||||
Result Close(sf::Out<s32> out_err, sf::Out<s32> out_res);
|
||||
|
@ -138,7 +138,11 @@ namespace ams::htcs::client {
|
|||
}
|
||||
|
||||
Result RemoteManager::StartSelect(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, const sf::InMapAliasArray<s32> &read_handles, const sf::InMapAliasArray<s32> &write_handles, const sf::InMapAliasArray<s32> &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<s32> out_err, sf::Out<s32> out_count, const sf::OutMapAliasArray<s32> &read_handles, const sf::OutMapAliasArray<s32> &write_handles, const sf::OutMapAliasArray<s32> &exception_handles, u32 task_id) {
|
||||
|
@ -172,7 +176,11 @@ namespace ams::htcs::client {
|
|||
}
|
||||
|
||||
Result RemoteSocket::AcceptStart(sf::Out<u32> 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<s32> out_err, sf::Out<sf::SharedPointer<tma::ISocket>> out, sf::Out<htcs::SockAddrHtcs> out_address, u32 task_id) {
|
||||
|
@ -187,7 +195,11 @@ namespace ams::htcs::client {
|
|||
}
|
||||
|
||||
Result RemoteSocket::RecvStart(sf::Out<u32> 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<s32> out_err, sf::Out<s64> out_size, const sf::OutAutoSelectBuffer &buffer, u32 task_id) {
|
||||
|
@ -195,7 +207,11 @@ namespace ams::htcs::client {
|
|||
}
|
||||
|
||||
Result RemoteSocket::SendStart(sf::Out<u32> 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<s32> out_err, sf::Out<s64> out_size, u32 task_id) {
|
||||
|
@ -203,7 +219,11 @@ namespace ams::htcs::client {
|
|||
}
|
||||
|
||||
Result RemoteSocket::StartSend(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, sf::Out<s64> 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<s64> out_size, sf::Out<bool> out_wait, const sf::InNonSecureAutoSelectBuffer &buffer, u32 task_id) {
|
||||
|
@ -215,7 +235,11 @@ namespace ams::htcs::client {
|
|||
}
|
||||
|
||||
Result RemoteSocket::StartRecv(sf::Out<u32> 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<s32> out_err, sf::Out<s64> out_size, const sf::OutAutoSelectBuffer &buffer, u32 task_id) {
|
||||
|
|
|
@ -496,11 +496,12 @@ namespace ams::htcs {
|
|||
/* Begin the accept. */
|
||||
sf::SharedPointer<tma::ISocket> 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<s64>(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<s64>(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<s32>(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)); };
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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<u32> 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<u32> 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<size_t>(aligned_size), htcs::ResultInvalidSize());
|
||||
|
||||
/* Attach the transfer memory. */
|
||||
os::TransferMemoryType tmem;
|
||||
os::AttachTransferMemory(std::addressof(tmem), static_cast<size_t>(aligned_size), mem_handle.GetValue(), true);
|
||||
os::AttachTransferMemory(std::addressof(tmem), static_cast<size_t>(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<u32> 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<u32> 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<s64>(start_buffer.GetSize()), htcs::ResultInvalidSize());
|
||||
R_UNLESS(util::IsIntValueRepresentable<s64>(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<size_t>(aligned_size), mem_handle.GetValue(), true);
|
||||
os::AttachTransferMemory(std::addressof(tmem), static_cast<size_t>(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<const char *>(start_buffer.GetPointer()), static_cast<const char *>(address), reinterpret_cast<const char *>(end_buffer.GetPointer()) };
|
||||
s64 sizes[NumBuffers] = { static_cast<s64>(start_buffer.GetSize()), aligned_size, static_cast<s64>(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<const char *>(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<const char *>(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();
|
||||
}
|
||||
|
||||
|
|
|
@ -40,9 +40,9 @@ namespace ams::htcs::server {
|
|||
Result AcceptResults(sf::Out<s32> out_err, sf::Out<sf::SharedPointer<tma::ISocket>> out, sf::Out<htcs::SockAddrHtcs> out_address, u32 task_id);
|
||||
Result RecvStart(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, s32 mem_size, s32 flags);
|
||||
Result RecvResults(sf::Out<s32> out_err, sf::Out<s64> out_size, const sf::OutAutoSelectBuffer &buffer, u32 task_id);
|
||||
Result RecvLargeStart(sf::Out<u32> 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<u32> 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<u32> out_task_id, sf::OutCopyHandle out_event, const sf::InAutoSelectBuffer &buffer, s32 flags);
|
||||
Result SendLargeStart(sf::Out<u32> 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<u32> 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<s32> out_err, sf::Out<s64> out_size, u32 task_id);
|
||||
Result StartSend(sf::Out<u32> out_task_id, sf::OutCopyHandle out_event, sf::Out<s64> out_max_size, s64 size, s32 flags);
|
||||
Result ContinueSendOld(sf::Out<s64> out_size, sf::Out<bool> out_wait, const sf::InAutoSelectBuffer &buffer, u32 task_id);
|
||||
|
|
|
@ -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<pm::ProcessEventInfo> 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) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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<u16> 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<HipcManagerImpl>);
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<usb::UrbReport> out) {
|
||||
|
|
|
@ -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<usb::UrbReport> 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<usb::UrbReport> out) {
|
||||
|
|
|
@ -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<usb::UsbState> out) {
|
||||
|
|
|
@ -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<sf::SharedPointer<usb::ds::IDsInterface>> out, u8 bInterfaceNumber);
|
||||
Result GetStateChangeEvent(sf::OutCopyHandle out);
|
||||
Result GetState(sf::Out<usb::UsbState> out);
|
||||
|
|
|
@ -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<sf::SharedPointer<ns::impl::IAsyncResult>> 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<size_t>(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));
|
||||
|
|
|
@ -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<mitm::sysupdater::UpdateInformation> out, const ncm::Path &path), (out, path)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 1, Result, ValidateUpdate, (sf::Out<Result> out_validate_result, sf::Out<Result> out_validate_exfat_result, sf::Out<mitm::sysupdater::UpdateValidationInfo> 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<sf::SharedPointer<ns::impl::IAsyncResult>> out_async), (out_event_handle, out_async)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 5, Result, GetPrepareUpdateProgress, (sf::Out<mitm::sysupdater::SystemUpdateProgress> out), (out)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 6, Result, HasPreparedUpdate, (sf::Out<bool> out), (out)) \
|
||||
#define AMS_SYSUPDATER_SYSTEM_UPDATE_INTERFACE_INFO(C, H) \
|
||||
AMS_SF_METHOD_INFO(C, H, 0, Result, GetUpdateInformation, (sf::Out<mitm::sysupdater::UpdateInformation> out, const ncm::Path &path), (out, path)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 1, Result, ValidateUpdate, (sf::Out<Result> out_validate_result, sf::Out<Result> out_validate_exfat_result, sf::Out<mitm::sysupdater::UpdateValidationInfo> 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<sf::SharedPointer<ns::impl::IAsyncResult>> out_async), (out_event_handle, out_async)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 5, Result, GetPrepareUpdateProgress, (sf::Out<mitm::sysupdater::SystemUpdateProgress> out), (out)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 6, Result, HasPreparedUpdate, (sf::Out<bool> 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<UpdateInformation> out, const ncm::Path &path);
|
||||
Result ValidateUpdate(sf::Out<Result> out_validate_result, sf::Out<Result> out_validate_exfat_result, sf::Out<UpdateValidationInfo> 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<sf::SharedPointer<ns::impl::IAsyncResult>> out_async);
|
||||
Result GetPrepareUpdateProgress(sf::Out<SystemUpdateProgress> out);
|
||||
Result HasPreparedUpdate(sf::Out<bool> out);
|
||||
|
|
|
@ -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<CheatProcessMetadata> out_metadata) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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<ProgramInfo> 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) {
|
||||
|
|
|
@ -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<ProgramInfo> out_program_info, const ncm::ProgramLocation &loc);
|
||||
Result PinProgram(sf::Out<PinId> out_id, const ncm::ProgramLocation &loc);
|
||||
Result UnpinProgram(PinId id);
|
||||
|
|
|
@ -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<os::ProcessId> 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<ncm::ProgramLocation> out_loc, sf::Out<cfg::OverrideStatus> 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<s64> out_cur_val, sf::Out<s64> out_lim_val, u32 group, u32 resource) {
|
||||
|
|
|
@ -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<ProcessEventInfo> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<RoService>);
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue