Thread Tools Display Modes
11-22-18, 07:52 AM   #1
Ethly
A Fallenroot Satyr
Join Date: Mar 2018
Posts: 23
How to determine if it's safe to overwrite global Blizzard function

I want to rewrite global functions LocalizeFrames and CombatFeedback_OnCombatEvent. I can do just that:
Code:
function LocalizeFrames()
	...
end

function CombatFeedback_OnCombatEvent(self, event, flags, amount, type)
	...
end
And from quick testing it seems to work. However I've heard about concept of tainting. I can achieve the same result with hooksecurefunc, but it causes unnecessary code to run (I'll overwrite Blizzard code, but it'll be called anyway). I don't know exactly how tainting works. So the question is: is it safe to overwrite those functions and how can I tell in general, which functions are safe to overwrite and which functions must be hooked?
  Reply With Quote
11-22-18, 08:30 AM   #2
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
The reason you should never overwrite Blizzard functions is because any AddOn that depends on them to work a specific way suddenly won't work, or at the very least won't work as expected. Don't forget that the entire Blizzard UI is a series of AddOns. Almost every AddOn written by fans (ex: ElvUI, anything from Curseforge/Twitch, or Wowinterface) access the Blizzard AddOns for functions, global variables, and other things. Overwriting Blizzard's code will break everything, eventually.

Securely hooking a function allows the original function to work and run, then your secure copy runs second, preserving all expected results.

Tainting is unsecured code. Every AddOn not written by Blizzard is, by its existence, tainted. That's perfectly fine, but it gets messy when some author taints the code path with a stray global variable or a function that should have been hooked. The taint log is notoriously difficult to shift through to find the offending code. This is because of the order of things. I'm about to heavily generalize here, but it gets the point across:
  1. Blizzard secure code runs
  2. A bad AddOn does something it shouldn't
  3. A second AddOn calls the now unsecured code
  4. A third AddOn that might not even use the code is blamed because its instructions were next
Yes, that's right. When you see the error code in BugSack say that such and such AddOn caused an error, the chances are pretty good said AddOn actually had zero things to do with the problem.

I could elaborate more, as there is a great deal more to say on the matter, but the short version is: just because you don't see the problem doesn't mean the problem doesn't exist –– and eventually will cause failure.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How to determine if it's safe to overwrite global Blizzard function

Thread Tools
Display Modes

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