The syntax is
hooksecurefunc([table,]index,function). If
table is omitted,
_G is assumed. The entire design of the function is to hook another function stored in
index of
table. This means it has to be accessible from the global namespace or a provided table.
hooksecurefunc() doesn't operate on locals and trying to use it on a frame won't necessarily work unless someone is dumb enough to have a dynamic function like this:
frame:SetScript("OnUpdate",function(self) self:OnUpdate(); end).
In addition, if any function is directly assigned as a handler, changing it in any way outside of
Frame:HookScript() won't update the function pointer used. Meaning the original function as defined would be updated, but the reference given to the frame to use for a handler will still point to the old function instead of your hook.
For example:
Code:
function A() print("A"); end
function B() print("B"); end
local frame=CreateFrame("Frame");
frame:SetScript("OnUpdate",A);
hooksecurefunc("A",B);
From your logic, you're thinking it would print
A and
B on alternating lines, but you'll only see
A bring printed. What
hooksecurefunc() is doing in this case is dynamicly creating a 3rd function that runs function
A and
B, passing the returns along from the first. The pointer to this new function then overwrites the old pointer in the global namespace. The pointer given to the frame for its handler remains unchanged.
The end result is, if you need to hook a script handler, use
Frame:HookScript(), that's what it's there for.