WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Taint (https://www.wowinterface.com/forums/showthread.php?t=45765)

Aanson 01-31-13 04:02 PM

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.

Vlad 01-31-13 04:59 PM

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

Aanson 01-31-13 05:17 PM

Quote:

Originally Posted by Vlad (Post 272635)
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.

Quote:

Originally Posted by Vlad (Post 272635)
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 :)

Vlad 01-31-13 05:48 PM

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. ;)

Aanson 01-31-13 05:55 PM

Quote:

Originally Posted by Vlad (Post 272641)
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.

Vlad 01-31-13 05:58 PM

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.

Aanson 01-31-13 06:35 PM

Quote:

Originally Posted by Vlad (Post 272643)
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.

Phanx 01-31-13 06:47 PM

Quote:

Originally Posted by Aanson (Post 272645)
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.

Aanson 01-31-13 07:14 PM

Quote:

Originally Posted by Phanx (Post 272646)
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.

ravagernl 02-05-13 10:54 AM

Quote:

Originally Posted by Phanx (Post 272646)
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.


All times are GMT -6. The time now is 02:11 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI