Thread Tools Display Modes
01-16-18, 05:13 AM   #1
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Lombra View Post
Well of course if you explicitly do not use a pointer created before hooking it's going to work, but no, as I've recently learnt, hooksecurefunc actually replaces the function and there's no magic at all.

This does not print anything:
Code:
local SetCVar = SetCVar

hooksecurefunc("SetCVar", function(name, value)
    if name == "Sound_EnableMusic" then
        print(name, value)
    end
end)

SetCVar("Sound_EnableMusic", 1)
It makes no sense, you are saying this hook actually killing the functionality of the SetCVar calls? It also works as a described and prints the value regardless how and where do you upvalue it.
  Reply With Quote
01-16-18, 02:28 PM   #2
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Originally Posted by Resike View Post
It makes no sense, you are saying this hook actually killing the functionality of the SetCVar calls? It also works as a described and prints the value regardless how and where do you upvalue it.
No, I'm saying a new function is defined. You may verify using this:

Code:
/run local a = SetCVar hooksecurefunc("SetCVar", function(name, value) if name == "Sound_EnableMusic" then print(name, value) end end) print(a == SetCVar)
My code does not print anything on login for me, nor does this macro: (don't use together with the addon code as it will upvalue the already hooked function)

Code:
/run local a = SetCVar hooksecurefunc("SetCVar", function(name, value) if name == "Sound_EnableMusic" then print(name, value) end end) a("Sound_EnableMusic", 1)
And regardless, the point still stands for insecure hooks, and whether those are a good idea or not wasn't the point.
__________________
Grab your sword and fight the Horde!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » About add-ons optimization


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off