mirror of
https://github.com/alliedmodders/sourcemod.git
synced 2025-12-07 10:28:34 +00:00
Add AutoHandleIdentLocker to pub/internal API
This commit is contained in:
parent
45dd841330
commit
60841f42b7
@ -262,4 +262,43 @@ private:
|
||||
Handle_t hndl;
|
||||
};
|
||||
|
||||
struct AutoHandleIdentLocker
|
||||
{
|
||||
public:
|
||||
AutoHandleIdentLocker() : pSecurity(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
AutoHandleIdentLocker(Handle_t hndl) : pSecurity(nullptr)
|
||||
{
|
||||
if (hndl != BAD_HANDLE)
|
||||
{
|
||||
if (g_HandleSys.GetHandleAccess(hndl, this->pSecurity) == HandleError_None)
|
||||
{
|
||||
if ((this->pSecurity[HandleAccess_Delete] & HANDLE_RESTRICT_IDENTEXCLUSIVE) == HANDLE_RESTRICT_IDENTEXCLUSIVE)
|
||||
this->pSecurity = nullptr;
|
||||
else
|
||||
pSecurity->access[HandleAccess_Delete] |= HANDLE_RESTRICT_IDENTEXCLUSIVE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~AutoHandleIdentLocker()
|
||||
{
|
||||
if (this->pSecurity)
|
||||
this->pSecurity->access[HandleAccess_Delete] &= ~HANDLE_RESTRICT_IDENTEXCLUSIVE;
|
||||
|
||||
this->pSecurity = nullptr;
|
||||
}
|
||||
|
||||
public:
|
||||
AutoHandleIdentLocker &operator =(const AutoHandleIdentLocker &other)
|
||||
{
|
||||
~AutoHandleIdentLocker();
|
||||
this->pSecurity = other.pSecurity;
|
||||
}
|
||||
private:
|
||||
HandleAccess *pSecurity;
|
||||
}
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_HANDLESYSTEM_H_
|
||||
|
||||
@ -87,5 +87,44 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class AutoHandleIdentLocker
|
||||
{
|
||||
public:
|
||||
AutoHandleIdentLocker() : pSecurity(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
AutoHandleIdentLocker(Handle_t hndl) : pSecurity(nullptr)
|
||||
{
|
||||
if (hndl != BAD_HANDLE)
|
||||
{
|
||||
if (handlesys->GetHandleAccess(hndl, this->pSecurity) == HandleError_None)
|
||||
{
|
||||
if ((this->pSecurity[HandleAccess_Delete] & HANDLE_RESTRICT_IDENTEXCLUSIVE) == HANDLE_RESTRICT_IDENTEXCLUSIVE)
|
||||
this->pSecurity = nullptr;
|
||||
else
|
||||
pSecurity->access[HandleAccess_Delete] |= HANDLE_RESTRICT_IDENTEXCLUSIVE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~AutoHandleIdentLocker()
|
||||
{
|
||||
if (this->pSecurity)
|
||||
this->pSecurity->access[HandleAccess_Delete] &= ~HANDLE_RESTRICT_IDENTEXCLUSIVE;
|
||||
|
||||
this->pSecurity = nullptr;
|
||||
}
|
||||
|
||||
public:
|
||||
AutoHandleIdentLocker &operator =(const AutoHandleIdentLocker &other)
|
||||
{
|
||||
~AutoHandleIdentLocker();
|
||||
this->pSecurity = other.pSecurity;
|
||||
}
|
||||
private:
|
||||
HandleAccess *pSecurity;
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE_SOURCEMOD_AUTO_HANDLE_ROOTER_H_ */
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user