From 3e4c962bbbe6d4aa4675bb6d74ba3f1a73d32265 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sat, 22 Feb 2020 15:38:31 -0800 Subject: [PATCH] kern: correct error in KUserPointer --- .../mesosphere/svc/kern_svc_k_user_pointer.hpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/libraries/libmesosphere/include/mesosphere/svc/kern_svc_k_user_pointer.hpp b/libraries/libmesosphere/include/mesosphere/svc/kern_svc_k_user_pointer.hpp index 35f290f37..fce28f594 100644 --- a/libraries/libmesosphere/include/mesosphere/svc/kern_svc_k_user_pointer.hpp +++ b/libraries/libmesosphere/include/mesosphere/svc/kern_svc_k_user_pointer.hpp @@ -116,9 +116,10 @@ namespace ams::kern::svc { private: using Traits = KUserPointerImplTraits<_T>; protected: - using T = typename std::remove_const::type>::type; + using CT = typename std::remove_pointer<_T>::type; + using T = typename std::remove_const::type; private: - _T *ptr; + CT *ptr; private: Result CopyToImpl(void *p, size_t size) const { return Traits::CopyFromUserspace(p, this->ptr, size); @@ -138,6 +139,8 @@ namespace ams::kern::svc { Result CopyArrayFrom(const T *arr, size_t count) const { return this->CopyFromImpl(arr, sizeof(*arr) * count); } constexpr bool IsNull() const { return this->ptr == nullptr; } + + constexpr CT *GetUnsafePointer() const { return this->ptr; } }; template<> @@ -145,7 +148,8 @@ namespace ams::kern::svc { private: using Traits = KUserPointerImplTraits; protected: - using T = char; + using CT = const char; + using T = char; private: const char *ptr; protected: @@ -160,6 +164,8 @@ namespace ams::kern::svc { } constexpr bool IsNull() const { return this->ptr == nullptr; } + + constexpr const char *GetUnsafePointer() const { return this->ptr; } }; } @@ -176,6 +182,8 @@ namespace ams::kern::svc { using impl::KUserPointerImpl::CopyArrayElementTo; using impl::KUserPointerImpl::CopyArrayTo; using impl::KUserPointerImpl::IsNull; + + using impl::KUserPointerImpl::GetUnsafePointer; }; template /* requires impl::NonConstPointer */ @@ -187,6 +195,8 @@ namespace ams::kern::svc { using impl::KUserPointerImpl::CopyArrayElementFrom; using impl::KUserPointerImpl::CopyArrayFrom; using impl::KUserPointerImpl::IsNull; + + using impl::KUserPointerImpl::GetUnsafePointer; }; template<> @@ -197,6 +207,8 @@ namespace ams::kern::svc { using impl::KUserPointerImpl::CopyStringTo; using impl::KUserPointerImpl::CopyArrayElementTo; using impl::KUserPointerImpl::IsNull; + + using impl::KUserPointerImpl::GetUnsafePointer; }; }