WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   GetItemInfo tainting secure cast functions? (https://www.wowinterface.com/forums/showthread.php?t=14218)

Layrajha 12-26-07 10:09 AM

GetItemInfo tainting secure cast functions?
 
Hello,

This request has also been posted on wow-europe's UI forums, but I'm not totally sure if many coders still read this forum (I haven't been there for a while). My problem is that it seems that the non secured function GetItemInfo taints secured functions if hooked.

Basically, with no addon up, if you execute this code...
Code:

oldGetItemInfo = GetItemInfo
GetItemInfo = function(...) return oldGetItemInfo(...) end

...then you cannot cast spells using keybindings or a "/cast blabla" command line. However, you can still use items by right-clicking them from your bags, or click action buttons on your bars.

My questions are:
- Why?
- Is there a way to hook GetItemInfo without screwing up the game?
- Else, is there any other way to modify the icon of a given number of items if I want my addon to remain independent from the action bar / bag addons? (else, I'll just code something that works with mine, but it would be annoying to change it every time I change my other addons, and not being able to make my friends or other randomly interested people profit from my work)

Thank you for reading,

-- Layrajha

Polarina 12-26-07 10:21 AM

Code:

hooksecurefunc("GetItemInfo", function (...)
    ChatFrame1:AddMessage("GetItemInfo called, PANIC!")
end)


Layrajha 12-26-07 10:32 AM

Yes, I would do that if I didn't want the returned value to actually change, which isn't possible through hooksecurefunction. Basically, I'm coding a small addon that is supposed to change the icons on the various [Major Combat Mana Potion], replacing them with modified versions that also include a text like "AV" or "WSG" to design the BG marks that were used to buy it.

Thus, my first idea to make it work not only on my ArkInventory / Bartender3, but on any bags / action bars addon, was to hook every function that returns an item's texture with something that looks like this (a bit more customized in the addon's code, but easier to understand here):

Code:

function GetItemInfo(item)   
    local itemName, itemLink, (((blablabla))), itemTexture = oldGetItemInfo(item)
   
        if itemLink then
                local new_texture = my_addon_table[string.match(itemLink,"Hitem:(%d-):")]
                if new_texture then
                        itemTexture = new_texture
                end
        end
       
        return itemName, itemLink, (((blablabla))), itemTexture
end


Layrajha 12-26-07 12:15 PM

As suggested on wow-europe's forums, I've checked the taint log. Basically, what gets tainted when I hook GetItemInfo is the "/cast" and "/castrandom" actions. In fact, their code is (I think this is the last live version, I haven't checked WDN for test updates though):

Code:

SecureCmdList["CAST"] = function(msg)
    local action, target = SecureCmdOptionParse(msg);
    if ( action ) then
                local name, bag, slot = SecureCmdItemParse(action);
                if ( slot or GetItemInfo(name) ) then
                        SecureCmdUseItem(name, bag, slot, target);
                else
                        CastSpellByName(action, target);
                end
    end
end
SecureCmdList["USE"] = SecureCmdList["CAST"];

and

Code:

SecureCmdList["CASTRANDOM"] = function(msg)
    local actions, target = SecureCmdOptionParse(msg);
        if ( actions ) then
                local action = strtrim(GetRandomArgument(strsplit(",", actions)));
                local name, bag, slot = SecureCmdItemParse(action);
                if ( slot or GetItemInfo(name) ) then
                        SecureCmdUseItem(name, bag, slot, target);
                else
                        CastSpellByName(action, target);
                end
        end
end
SecureCmdList["USERANDOM"] = SecureCmdList["CASTRANDOM"];



It is really disappointing. This function that returns 10 values is here used only to check if a string matches the name of an item in cache. Because of that, the function cannot be hooked.
Considering the cost of the addition of something like SecureItemExists and the replacement of the occurrences of GetItemInfo in ChatFrame.lua's secured cast functions, I wonder if I should post about this in the "Wish List" board. Do you think that it's worth it, and do you think that it could be applied? Or is there any drawback to this suggestion?


All times are GMT -6. The time now is 11:42 AM.

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