Reply
Thread Tools Display Modes
Unread 01-31-13, 04:02 PM   #1
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 123
Taint

Evening folks

I've said a few times before on these forums that I want to be absolutely certain that I'm not degrading the performance of the game because of a lack of knowledge on my part. I'm hooking the func 'UseContainerItem' so that I can add the optional ability for the user to right-click an item in their inventory (while the Auction House is open, regardless of which tab is being used) and that item will be put up for sale.

As it stands, if you're in the 'Bid' or 'Browse' tab, an unmodified right click will attempt to use or equip the item in question.

Here's the code which I have written to perform this:

Lua Code:
  1. M.HookFunc_UseContainerItem = function()
  2.  
  3.     local origUseContainerItem = UseContainerItem;
  4.  
  5.     UseContainerItem = function(...)
  6.  
  7.         if ( AuctionFrame:IsVisible() and ( not AuctionFrameAuctions:IsVisible() ) ) then
  8.             AuctionFrameTab_OnClick(AuctionFrameTab3);
  9.         end
  10.  
  11.         securecall(origUseContainerItem, ...);
  12.  
  13.     end
  14.  
  15. end

Although it works fine, my primary concern is that my hooking UseContainerItem will cause Blizz code to treat it as unsecure. After the user has sold whatever they're selling, they head out into combat and the problems start.

Although UseContainerItem works fine for me during combat, it appears that it may be tainting ArkInventory. I've not yet tested using ArkInventory, while in combat, without the function loaded though, to be honest.

I've played around with the idea of hooksecurefunc, but I'm not sure that that func can produce the desired result; by the time my post-hook is called, it's already going to be trying to equip the item.

If anyone could offer some advice on this, it would be very much appreciated.

Thanks in advance,


Aanson.
__________________
__________________
Aanson is offline   Reply With Quote
Unread 01-31-13, 04:59 PM   #2
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 766
Overriding API like this will result in taint that will break any secure environment it is used in, and you won't be able to use items in combat eventually, not if UseContainerItem is involved.

hooksecurefunc it if you want but you gotta think an alternative way to achieve what you wanna achieve.

securecall only works from Blizzards own code, as a mean to try execute stuff that might be tainted, so when you use it it has no effect, hehe. :P
__________________
Profile: Curse | Wowhead

Last edited by Vlad : 01-31-13 at 05:05 PM.
Vlad is offline   Reply With Quote
Unread 01-31-13, 05:17 PM   #3
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 123
Originally Posted by Vlad View Post
securecall only works from Blizzards own code, as a mean to try execute stuff that might be tainted, so when you use it it has no effect, hehe. :P
Yeah, I read that about securecall right enough. But it does have an effect alright.

- Before using securecall (ie just returning the function), I'd get an error when trying to remove something from an inventory slot.

- After adding the securecall function, the error was gone and the hooked UseContainerItem worked without any problem.

Originally Posted by Vlad View Post
Overriding API like this will result in taint that will break any secure environment it is used in, and you won't be able to use items in combat eventually, not if UseContainerItem is involved.

hooksecurefunc it if you want but you gotta think an alternative way to achieve what you wanna achieve.
That's what I was worried about. Thanks for confirming it. It's clearly better just left out entirely.

I was doing a bit of thinking after writing this post, and I'm playing with the idea of hooking the OnShow handler of StaticPopup frame instead to achieve the same result (without compromising the confirmation popups for buying something or cancelling an auction etc).

Thanks again
__________________
__________________
Aanson is offline   Reply With Quote
Unread 01-31-13, 05:48 PM   #4
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 766
Also if you run your function the hook will hook your last hook, i.e. cause a recursive effect. Just saying in case it might be triggered more than once each session.
__________________
Profile: Curse | Wowhead
Vlad is offline   Reply With Quote
Unread 01-31-13, 05:55 PM   #5
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 123
Originally Posted by Vlad View Post
Also if you run your function the hook will hook your last hook, i.e. cause a recursive effect. Just saying in case it might be triggered more than once each session.
Yeah, that's alright. The function which creates the hook only gets called once...

Lua Code:
  1. elseif ( (event == "ADDON_LOADED") and (... == "Blizzard_AuctionUI") ) then

Cheers.
__________________
__________________
Aanson is offline   Reply With Quote
Unread 01-31-13, 05:58 PM   #6
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 766
Just an idea, why not hook the onclick script on the buttons in the auction UI instead the API itself?

local onClick = obj:GetScript("OnClick") to store the real "OnClick" function then obj:SetScript(...) with your own code.
__________________
Profile: Curse | Wowhead
Vlad is offline   Reply With Quote
Unread 01-31-13, 06:35 PM   #7
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 123
Originally Posted by Vlad View Post
Just an idea, why not hook the onclick script on the buttons in the auction UI instead the API itself?
On that subject, I also wrote this script a couple of days ago, but I've not got round to trying it out yet:

Lua Code:
  1. M.SecureHookFunc_ContainerFrameItemButton_OnModifiedClick = function()
  2.  
  3.     SetModifiedClick("AUCTIONITEM", "LALT-BUTTON2"); -- << not sure yet if I can do this (add my own entry to their t)
  4.  
  5.     local ContainerFrameItemButton_OnModifiedClick_Hook = function(self, button)
  6.  
  7.         if ( ( button == "RightButton" ) and IsModifiedClick("AUCTIONITEM") ) then
  8.  
  9.             if ( AuctionFrame:IsVisible() and ( not AuctionFrameAuctions:IsVisible() ) ) then
  10.                 AuctionFrameTab_OnClick(AuctionFrameTab3);
  11.             end
  12.  
  13.         end
  14.  
  15.     end
  16.  
  17.     hooksecurefunc("ContainerFrameItemButton_OnModifiedClick", ContainerFrameItemButton_OnModifiedClick_Hook);
  18.  
  19. end

I'll need to check the XML to ensure that the hooksecurefunc line is accurate.

I thought about hooking to a AuctionUI button, but as far as I can work out, there isn't one that would do the job.

The user puts an item up for auction by right clicking the item in their bag. They wouldn't be using the AuctionUI at all to put the item up for sale unless they picked the item up and dragged / dropped it in the sell item box (or whatever it's called!), by which point it's already up for sale and there's no point of the hook!

Sorry if I've misunderstood btw... kinda a common thing with me lol.
__________________
__________________

Last edited by Aanson : 01-31-13 at 06:39 PM.
Aanson is offline   Reply With Quote
Unread 01-31-13, 06:47 PM   #8
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 4,751
Originally Posted by Aanson View Post
The user puts an item up for auction by right clicking the item in their bag.
Have you looked at other addons that already do this or similar things? For example, Tekkub has an addon that lets you right-click an item in your bag to add it to the trade window. There are also countless addons that let you right-click, shift-click, alt-click, shift-control-click, etc. to disenchant, mill, or prospect items in your bag.
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
Phanx is offline   Reply With Quote
Unread 01-31-13, 07:14 PM   #9
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 123
Originally Posted by Phanx View Post
Have you looked at other addons that already do this or similar things? For example, Tekkub has an addon that lets you right-click an item in your bag to add it to the trade window. There are also countless addons that let you right-click, shift-click, alt-click, shift-control-click, etc. to disenchant, mill, or prospect items in your bag.
Thanks very much, I'll have a look at something similar then to see what the trick of the trade is. In-fact, I have AuctionLite installed which should be a good example.
__________________
__________________
Aanson is offline   Reply With Quote
Unread 02-05-13, 10:54 AM   #10
ravagernl
Premium Member
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,156
Originally Posted by Phanx View Post
Have you looked at other addons that already do this or similar things? For example, Tekkub has an addon that lets you right-click an item in your bag to add it to the trade window. There are also countless addons that let you right-click, shift-click, alt-click, shift-control-click, etc. to disenchant, mill, or prospect items in your bag.
DayTrader is using ContainerFrameItemButton_OnModifiedClick, as far as I can tell from the function name this is called when the user holds alt/shift/ctrl when clicking on a stock blizzard bagframe. Not sure if this function gets called for other bag addons.

AuctionLite seems to be doing the same thing.
ravagernl is offline   Reply With Quote
Reply

Go BackWoWInterface » Developer Discussions » Lua/XML Help » Taint

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