Thread Tools Display Modes
12-26-07, 10:09 AM   #1
Layrajha
A Frostmaul Preserver
 
Layrajha's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 275
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
  Reply With Quote
12-26-07, 10:21 AM   #2
Polarina
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 63
Code:
hooksecurefunc("GetItemInfo", function (...)
     ChatFrame1:AddMessage("GetItemInfo called, PANIC!")
end)
  Reply With Quote
12-26-07, 10:32 AM   #3
Layrajha
A Frostmaul Preserver
 
Layrajha's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 275
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
  Reply With Quote
12-26-07, 12:15 PM   #4
Layrajha
A Frostmaul Preserver
 
Layrajha's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 275
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?
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » GetItemInfo tainting secure cast functions?

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