hooksecurefunc() with local versions of functions?
I understood that it is considered a good habbit to declare local versions of global functions to make your code use less CPU cycles.
(See e.g. https://www.wowinterface.com/forums/...ad.php?t=57151) So I am particularly doing Code:
local SetCVar = _G.SetCVar But how can I now hook a function to SetCVar()? For _G.SetCVar I would have used: Code:
hooksecurefunc("SetCVar", MyPostSetCVar) whereas my code uses the local SetCVar. Do I need hooksecurefunc() at all to hook to my local SetCVar? Or what would the first argument of hooksecurefunc() have to be for a local function? Thanks! |
If I recall correctly, hook the function before you declare a local version. The hook propagates.
|
Quote:
PS: It worked by the way! Thanks! |
Functions are immutable. What hooksecurefunc() does is wrap the original function and your hook to run together from a new function, then overwrites the original with it. You can observe this by looking at the function pointer before and after hooking. They'll be different.
You can delay the hook and still have the local variable defined. You just need to update the pointer stored in the local after hooking. |
All times are GMT -6. The time now is 01:03 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI