Thread Tools Display Modes
04-06-07, 07:28 PM   #1
Fayren
A Murloc Raider
Join Date: Apr 2007
Posts: 4
Hooking Outgoing Chat Question

So... because of the new secure execution and tainting system, it's kind of hard to hook onto ChatEdit_SendText or ChatEdit_ParseText if you intend to call the old function after you do your work. You can without any problems unless somebody runs macro code which would have been tainted because it goes through your code first.

So... Here's my question.

I'm trying to fix an old mod that many in my guild enjoyed. It was called PirateSpeak. It would take text from the comand line, inject all kinds of fun pirate modifications to that text and then send it along it's way down the normal path. This is no longer possible though because of the secure path execution.

And post hooking using Blizzard's new hooksecurefunc(func, myfunc) won't work for this either because it throws away return values and from what I understand if I modify the vars passed in I taint them.

Is there any way to get around this?

I just want to my PirateSpeak back.
  Reply With Quote
04-06-07, 08:26 PM   #2
Fayren
A Murloc Raider
Join Date: Apr 2007
Posts: 4
So... here's an update.

I figured out a function that doesn't need to be secure to hook onto. I just decided to hook onto SendChatMessage.

And it works.

But... it seems to be getting called twice for every line. Sometimes three times. That's kinda creepy I think. Anybody know anything about this?
  Reply With Quote
04-06-07, 10:40 PM   #3
Shirik
Blasphemer!
Premium Member
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2007
Posts: 818
Originally Posted by Fayren
So... here's an update.

I figured out a function that doesn't need to be secure to hook onto. I just decided to hook onto SendChatMessage.

And it works.

But... it seems to be getting called twice for every line. Sometimes three times. That's kinda creepy I think. Anybody know anything about this?
Aye, you wanted to hook SendChatMessage(). But it should only be called once. Perhaps post your code so we can take a look at it? I have a feeling you hooked incorrectly.
  Reply With Quote
04-07-07, 01:24 AM   #4
Fayren
A Murloc Raider
Join Date: Apr 2007
Posts: 4
Here's how I hooked.


Code:
local oldSendChatMessage;
oldSendChatMessage = SendChatMessage;

Here's what my function does.


Code:
function SendChatMessage(text, type, language, target)
         if (pirate_talk_on == 1) then
            text = piratespeak(text);
         end
         oldSendChatMessage(text, type, language, target);
end
My code does not call oldSendChatMessage or SendChatMessage anywhere except what you see here. I know that it gets call multiple times though because I've looked at the output or I've done debug print outs.

Am I hooking wrong?

If it would help I can email the file or post it here if that's not considered rude. I know some forums look down on people posting whole files into posts.

Last edited by Fayren : 04-07-07 at 01:27 AM.
  Reply With Quote
04-07-07, 02:08 AM   #5
Shirik
Blasphemer!
Premium Member
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2007
Posts: 818
Originally Posted by Fayren
Here's how I hooked.


Code:
local oldSendChatMessage;
oldSendChatMessage = SendChatMessage;

Here's what my function does.


Code:
function SendChatMessage(text, type, language, target)
         if (pirate_talk_on == 1) then
            text = piratespeak(text);
         end
         oldSendChatMessage(text, type, language, target);
end
My code does not call oldSendChatMessage or SendChatMessage anywhere except what you see here. I know that it gets call multiple times though because I've looked at the output or I've done debug print outs.

Am I hooking wrong?

If it would help I can email the file or post it here if that's not considered rude. I know some forums look down on people posting whole files into posts.
It looks good to me, except for one little thing that you should do. Use this:
Code:
function SendChatMessage(text, type, language, target, ...)
         if (pirate_talk_on == 1) then
            text = piratespeak(text);
         end
         oldSendChatMessage(text, type, language, target, ...);
end
This way, if SendChatMessage() is ever changed to allow for additional parameters in the future, it will still be hooked correctly. In fact, in this sense, you could actually write the following, since you only care about "text" in your addon:

Code:
function SendChatMessage(text, ...)
         if (pirate_talk_on == 1) then
            text = piratespeak(text);
         end
         oldSendChatMessage(text, ...);
end
And it will function equivalently. But, is what you have "wrong?" No. How about you go to http://wowi.pastey.net and paste up your code there, and I'll try running it to see how it runs. Alternatively, you could zip up your addon (TOC and all) and attach it here so someone could take a look at it.
  Reply With Quote
04-07-07, 02:36 AM   #6
Fayren
A Murloc Raider
Join Date: Apr 2007
Posts: 4
Thanks a ton for replying. I've tried my luck at a few different forums and you're the first to respond.

Here's the link at pastey.net.

http://wowi.pastey.net/10850-41h3

I imagine that's what you meant for me to do. If I put debug information in the SendChatMessage call though, I find that it gets called multiple times. This can also be seen in the chat output because sometimes there are two appends or two prepends to a string of chat. (What I just said will make sense if you look at it.)
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Hooking Outgoing Chat Question


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