Even if it's really simple, it's not in the esoui files, so ..
Lua Code:
--[[
ZO_PreHookProtected is a rewrite of ZO_PreHook. It accepts Protected functions.
IsProtectedFunction(existingFunctionName) will still return true even if existingFunctionName is not called
Calling existingFunctionName() will work, it will call your function and depending on your code will run the prehooked function
Calling CallSecureProtected("existingFunctionName", arg1) will work, it will call the original function only. You won't be able to "fake" other addons if they're correctly written, but mainly ESOUI code.
Don't hook a non-protected function with this PreHook or game won't load
]]--
function ZO_PreHookProtected(objectTable, existingFunctionName, hookFunction)
if(type(objectTable) == "string") then
hookFunction = existingFunctionName
existingFunctionName = objectTable
objectTable = _G
end
local newFn = function(...)
if(not hookFunction(...)) then
if IsProtectedFunction(existingFunctionName) then
return CallSecureProtected(existingFunctionName, ...)
end
end
end
objectTable[existingFunctionName] = newFn
end
Doing this will mainly prehook ESOUI code and your own addon, so consider that the esoui code may not run because of another addon doing something else instead.