Thread Tools Display Modes
12-20-17, 10:43 AM   #1
tehmoku
A Fallenroot Satyr
Join Date: May 2007
Posts: 27
Moving BuffFrame securely

I use this script to move my BuffFrame closer to the center of the screen.

Code:
hooksecurefunc("BuffFrame_UpdateAllBuffAnchors", function()
	local b = _G["BuffFrame"]
	b:ClearAllPoints()
	b:SetPoint("CENTER", UIParent, "RIGHT", -500, 200)
end)
This causes taint when trying to right-click off the buffs because CancelUnitBuff() is secure. Since I don't want to create an entire buff addon, is there a way of simply changing the anchors of BuffFrame securely so I am able to right-click off my buffs in combat?
  Reply With Quote
12-20-17, 01:14 PM   #2
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Lua Code:
  1. -- Player buffs
  2. local b = _G.BuffFrame
  3. b:SetMovable(true)
  4. b:SetUserPlaced(true)
  5. b:ClearAllPoints()
  6. b:SetPoint("TopRight", UIParent, "TopRight", - 204, - 66)
  7. b:SetMovable(false)
  8.  
  9. local moving
  10. hooksecurefunc(BuffFrame, "SetPoint", function(self)
  11.     if moving then
  12.         return
  13.     end
  14.     moving = true
  15.     self:SetMovable(true)
  16.     self:SetUserPlaced(true)
  17.     self:ClearAllPoints()
  18.     self:SetPoint("TopRight", UIParent, "TopRight", - 204, - 66)
  19.     self:SetMovable(false)
  20.     moving = nil
  21. end)
  22.  
  23. -- Consolidated buffs
  24. --[[local c = _G["ConsolidatedBuffs"]
  25. c:ClearAllPoints()
  26. c:SetPoint("TopRight", UIParent, "TopRight", - 204, - 66)
  27. c:SetMovable(true)
  28. c:SetUserPlaced(true)
  29. c:SetMovable(false)
  30. if BuffFrame.numConsolidated == 0 then
  31.     c:Hide()
  32. end]]
  33.  
  34. -- Player debuffs
  35. if DebuffButton_UpdateAnchors then
  36.     hooksecurefunc("DebuffButton_UpdateAnchors", function()
  37.         local d = _G.DebuffButton1
  38.         if d then
  39.             d:SetMovable(true)
  40.             d:SetUserPlaced(true)
  41.             d:ClearAllPoints()
  42.             d:SetPoint("TopRight", BuffFrame, "TopRight", 0, - 180)
  43.             d:SetMovable(false)
  44.         end
  45.     end)
  46. end

Fill the anchors however you would like.
  Reply With Quote
12-20-17, 01:53 PM   #3
tehmoku
A Fallenroot Satyr
Join Date: May 2007
Posts: 27
So, that moves the buffframe how you would expect, and works fine with only my addon enabled. However, when using a different addon called EasyFrames, I get an error for a CancelUnitBuff() attempt in combat. Again, this doesn't happen when it's just my addon enabled--I am able to cancel buffs fine. (In fact, I could with the original code posted.)

I've been planning on writing my own unitframe mod anyway so disabling that addon is fine, but my noob question is this: Is that taint caused by my addon, and is EasyFrames is being blamed for it? From what I can tell, it doesn't handle playerbuffs in the buffframe in any capacity.

I just want to try and make sure my addon isn't the cause of rogue taint to mess up other things down the line.

Here's the error it throws out

Code:
9x [ADDON_ACTION_BLOCKED] AddOn 'EasyFrames' tried to call the protected function 'CancelUnitBuff()'.
!BugGrabber\BugGrabber.lua:573: in function <!BugGrabber\BugGrabber.lua:573>
[C]: in function `CancelUnitBuff'
FrameXML\BuffFrame.lua:280: in function `BuffButton_OnClick'
[string "*:OnClick"]:1: in function <[string "*:OnClick"]:1>

Locals:
InCombatSkipped
  Reply With Quote
12-20-17, 03:40 PM   #4
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,364
I don't really know, but I would say that you should (maybe) know how the taint system works - which, at best, is ... really wierd. You can't say, with any certainty (from what I understand), which addon really caused the taint. And THAT is really frustrating.

I could be totally wrong about this, and if I am, I apologise for putting this here.
__________________
Ahhhh, the vagueries of the aging mind. Wait.... What was I saying?


Carbonite <----- GitHub main module (Maps ONLY) download link. The other modules are also available on GitHub.
Carbonite-CLASSIC<----- GitHub link to Carbonite Classic. Thanks to ircdirk for this!

Last edited by jeffy162 : 12-20-17 at 03:56 PM. Reason: apologies, if I'm wrong!
  Reply With Quote
12-20-17, 04:04 PM   #5
tehmoku
A Fallenroot Satyr
Join Date: May 2007
Posts: 27
It seems extremely likely that the code posted is what caused the taint. The interesting thing here, though, is that I can run it without error unless I load the other addon. Functionality is restored completely when I remove my code.

I agree with you though, I need to learn more about the taint system. It's really wonky to me.
  Reply With Quote
12-20-17, 04:14 PM   #6
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,364
Originally Posted by tehmoku View Post
... the taint system. It's really wonky ...
I would say that that's putting it ... mildly.
__________________
Ahhhh, the vagueries of the aging mind. Wait.... What was I saying?


Carbonite <----- GitHub main module (Maps ONLY) download link. The other modules are also available on GitHub.
Carbonite-CLASSIC<----- GitHub link to Carbonite Classic. Thanks to ircdirk for this!
  Reply With Quote
12-20-17, 04:28 PM   #7
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by tehmoku View Post
It seems extremely likely that the code posted is what caused the taint. The interesting thing here, though, is that I can run it without error unless I load the other addon. Functionality is restored completely when I remove my code.

I agree with you though, I need to learn more about the taint system. It's really wonky to me.
There is no way that the code i posted would taint, if only run once: when your addon is loaeded.
  Reply With Quote
12-21-17, 09:26 AM   #8
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
Taint isn't hard to understand at all. It just means "addon code touched this, so we can't assume execution is safe from here on out". Taint usually spreads by replacing or calling UI functions (implemented in Lua) directly, instead of properly hooking on to functions when they execute instead.
Using widget meta functions (such as SetPoint) doesn't spread taint. E.g:

Lua Code:
  1. -- This will spread taint if BuffFrame:SetPoint() is called in a signed code scope.
  2. local realSetPoint = BuffFrame.SetPoint
  3. function BuffFrame:SetPoint()
  4.     realSetPoint(self, "CENTER", UIParent, "RIGHT", -500, 200)
  5. end
  6.  
  7. -- This will not spread taint at any time, ever.
  8. hooksecurefunc(BuffFrame, "SetPoint", function(self, pnt, relTo, relPnt, x, y)
  9.     if pnt ~= "CENTER" or relPnt ~= "RIGHT" or x ~= -500 then
  10.         self:SetPoint("CENTER", UIParent, "RIGHT", -500, 200)
  11.     end
  12. end)
__________________

Last edited by MunkDev : 12-21-17 at 09:34 AM.
  Reply With Quote
12-22-17, 07:47 AM   #9
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
That EasyFrames mod, is a totally non-secure unit frame addon, which spreading taint all over the place.
  Reply With Quote
01-05-18, 10:53 AM   #10
tehmoku
A Fallenroot Satyr
Join Date: May 2007
Posts: 27
Okay, good to know. Thanks for the replies. The code provided is working excellent.
  Reply With Quote
03-09-18, 02:57 AM   #11
Usoltsev
A Defias Bandit
AddOn Author - Click to view addons
Join Date: Feb 2017
Posts: 3
Hello everyone.

Thank you for response about Easy Frames and especially to MunkDev for feedback on the project page.

Version 2.5.0 of Easy Frames is released.

In this version all tainting code was removed.
I think, and I hope that we will never see a "[ADDON_ACTION_BLOCKED] AddOn 'EasyFrames'...." messages in the future.
  Reply With Quote
03-09-18, 06:31 AM   #12
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Usoltsev View Post
Hello everyone.

Thank you for response about Easy Frames and especially to MunkDev for feedback on the project page.

Version 2.5.0 of Easy Frames is released.

In this version all tainting code was removed.
I think, and I hope that we will never see a "[ADDON_ACTION_BLOCKED] AddOn 'EasyFrames'...." messages in the future.
I didn't mean to trash you project, i was just stating facts. You still have 1 leaking global at General.lua:192:mouseover.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Moving BuffFrame securely

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