From 45dd841330a0692ad41277653f28c8aaa52bb3c3 Mon Sep 17 00:00:00 2001 From: Kyle Sanderson Date: Sun, 21 Jul 2019 08:32:13 -0700 Subject: [PATCH] Introduce GetHandleAccess to (I)HandleSys. --- core/logic/HandleSys.cpp | 13 +++++++++++++ core/logic/HandleSys.h | 2 ++ public/IHandleSys.h | 9 +++++++++ 3 files changed, 24 insertions(+) diff --git a/core/logic/HandleSys.cpp b/core/logic/HandleSys.cpp index ca48639c3..8a2f5d156 100644 --- a/core/logic/HandleSys.cpp +++ b/core/logic/HandleSys.cpp @@ -1169,3 +1169,16 @@ void HandleSystem::Dump(const HandleReporter &fn) rep(fn, "-- Approximately %d bytes of memory are in use by Handles.\n", total_size); } +HandleError HandleSystem::GetHandleAccess(Handle_t handle, HandleAccess &*pAccess) +{ + unsigned int index; + QHandle *pHandle; + HandleError err; + IdentityToken_t *ident = NULL; + + if ((err=GetHandle(handle, ident, &pHandle, &index)) != HandleError_None) + return err; + + pAccess = &(pHandle->sec); + return err; +} diff --git a/core/logic/HandleSys.h b/core/logic/HandleSys.h index 54e917514..1ca35d2b2 100644 --- a/core/logic/HandleSys.h +++ b/core/logic/HandleSys.h @@ -173,6 +173,8 @@ public: //IHandleSystem /* Bypasses security checks. */ Handle_t FastCloneHandle(Handle_t hndl); + + HandleError GetHandleAccess(Handle_t handle, HandleAccess &*pSecurity); protected: /** * Decodes a handle with sanity and security checking. diff --git a/public/IHandleSys.h b/public/IHandleSys.h index cd84192e9..9edcad769 100644 --- a/public/IHandleSys.h +++ b/public/IHandleSys.h @@ -375,6 +375,15 @@ namespace SourceMod * @return True if "given" is a subtype of "actual", false otherwise. */ virtual bool TypeCheck(HandleType_t given, HandleType_t actual) = 0; + + /** + * @brief Obtain the HandleAccess address from the passed in handle. + * + * @param handle Handle_t identifier to destroy. + * @param pAccess Access information struct. + * @return HandleError error code. + */ + virtual HandleError GetHandleAccess(Handle_t handle, HandleAccess &*pAccess) = 0; }; }