24 lines
766 B
C++
24 lines
766 B
C++
#ifdef _DEBUG
|
|
|
|
#include "Hooks/Context.hpp"
|
|
|
|
Context__requirePermission_t Context__requirePermission = (Context__requirePermission_t)ADDRESS_CONTEXT__REQUIREPERMISSION;
|
|
|
|
void __fastcall Context__requirePermission_hook(void* _this, void*, int permission, const char* operation)
|
|
{
|
|
int identity = ((int*)_this)[0];
|
|
|
|
if (!Context__isInRole(identity, permission))
|
|
{
|
|
if (operation != 0)
|
|
{
|
|
throw std::runtime_error("The current identity (" + std::to_string(identity) + ") cannot " + std::string(operation) + " (requires " + std::to_string(permission) + ")");
|
|
}
|
|
else
|
|
{
|
|
throw std::runtime_error("The current identity (" + std::to_string(identity) + ") cannot perform the requested operation (requires " + std::to_string(permission) + ")");
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif |