Introduce GetHandleAccess to (I)HandleSys.

This commit is contained in:
Kyle Sanderson 2019-07-21 08:32:13 -07:00
parent b290099572
commit 45dd841330
3 changed files with 24 additions and 0 deletions

View File

@ -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;
}

View File

@ -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.

View File

@ -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;
};
}