Go Back   BWHacks > Development > Reverse Engineering > Code Snippets and Tutorials

Code Snippets and Tutorials The place for open source releases, great information, and tutorials written by other members.

Reply
 
LinkBack Thread Tools

Old 04-13-2007, 05:53 PM   #1 (permalink)
Perma
rol 3905h, 8
Senior Member
Administrator

Saint
 
Perma's Avatar
 
Join Date: Jul 2004
Location: Canada
Posts: 5,384
Perma has disabled reputation
Default [WarCraft III] TextOut Function (v1.22)

Click here for an updated version for patch 1.22.

Thanks to Palomino's notes for clarifying what some parts of this are actually meant for.

Code:
.data

        WC3FXN_Text             dd 6F663740h
        WC3FXN_GlobalClass      dd 6F84CC20h

.code

Warcraft_TextOut proc           textloc:DWORD

        push eax
        push edx
        push ecx
        push 0FFFFFFFFh

        ;Get the pointer to Warcraft's global class.
        mov eax, WC3FXN_GlobalClass
        mov eax, dword ptr ds:[eax]

        ;Get the pointer to the output class.
        mov eax, dword ptr ds:[eax+3E0h]
        mov edx, dword ptr ds:[eax]
        push 0
        push 41200000h
        lea ecx, dword ptr ss:[esp+08h]
        push ecx

        ;Push the text address.
        mov ecx, textloc
        push ecx
        mov ecx, eax
        call dword ptr [WC3FXN_Text]
        pop ecx
        pop edx
        pop eax
        ret

Warcraft_TextOut endp

Last edited by Perma : 10-14-2008 at 04:03 AM.
Perma 15 0FF11|\|3   Reply With Quote
Advertisement
 
Advertisement
Advertisement Sponsored links


Old 04-14-2007, 02:54 AM   #2 (permalink)
K? Pŕo?ćtiόnŹ
=)
Senior Member
Retired Staff Member

Messiah
 
K? Pŕo?ćtiόnŹ's Avatar
 
Join Date: Oct 2004
Location: Okinawa
Posts: 9,300
K? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond repute
Send a message via AIM to K? Pŕo?ćtiόnŹ
Default

gj
__________________
K? Pŕo?ćtiόnŹ 15 0FF11|\|3   Reply With Quote

Old 04-16-2007, 01:49 AM   #3 (permalink)
bulk_4me
F7 F1EF
Senior Member
Retired Staff Member

Enlightened
 
bulk_4me's Avatar
 
Join Date: Jun 2004
Location: Torreón, Coah. México
Posts: 3,220
bulk_4me is a splendid one to beholdbulk_4me is a splendid one to beholdbulk_4me is a splendid one to beholdbulk_4me is a splendid one to beholdbulk_4me is a splendid one to beholdbulk_4me is a splendid one to behold
Default

nice.
__________________
bulk_4me 15 0FF11|\|3   Reply With Quote

Old 08-06-2007, 08:41 PM   #4 (permalink)
Perma
rol 3905h, 8
Senior Member
Administrator

Saint
 
Perma's Avatar
 
Join Date: Jul 2004
Location: Canada
Posts: 5,384
Perma has disabled reputation
Default

Moved to the Warcraft hacking related section.
Perma 15 0FF11|\|3   Reply With Quote

Old 08-20-2007, 08:48 AM   #5 (permalink)
topaz

Heretic
 
Join Date: Mar 2007
Posts: 36
topaz is on a distinguished road
Default

Is anyone willing to port this to C (or a language thats easily understandable)?
topaz 15 0FF11|\|3   Reply With Quote

Old 08-20-2007, 08:55 AM   #6 (permalink)
Perma
rol 3905h, 8
Senior Member
Administrator

Saint
 
Perma's Avatar
 
Join Date: Jul 2004
Location: Canada
Posts: 5,384
Perma has disabled reputation
Default

Code:
void Warcraft_TextOut(DWORD sText)
{
    static int WC3FXN_GlobalClass = 0x6F84CC20;
    static int WC3FXN_Text = 0x6F663740;
    __asm
    {       
        push eax
        push edx
        push ecx
        push 0x0FFFFFFFF
        mov eax, WC3FXN_GlobalClass
        mov eax, dword ptr ds:[eax]
        mov eax, dword ptr ds:[eax+0x3E0]
        mov edx, dword ptr ds:[eax]
        push 0
        push 0x41200000
        lea ecx, dword ptr ss:[esp+0x08]
        push ecx        
        mov ecx, sText
        push ecx
        mov ecx, eax
        call dword ptr [WC3FXN_Text]
        pop ecx
        pop edx
        pop eax
    }
}
That should work.
Perma 15 0FF11|\|3   Reply With Quote

Old 08-20-2007, 08:57 AM   #7 (permalink)
topaz

Heretic
 
Join Date: Mar 2007
Posts: 36
topaz is on a distinguished road
Default

Nice...
topaz 15 0FF11|\|3   Reply With Quote

Old 08-20-2007, 01:12 PM   #8 (permalink)
saren

Crusader
 
saren's Avatar
 
Join Date: Feb 2005
Location: Tucson, AZ
Posts: 3,327
saren has much to be proud ofsaren has much to be proud ofsaren has much to be proud ofsaren has much to be proud ofsaren has much to be proud ofsaren has much to be proud of
Default

Inline ASM is the devil.
__________________


Burn, baby, burn.
saren 15 0FF11|\|3   Reply With Quote

Old 10-13-2007, 10:42 AM   #9 (permalink)
Rufus

Disciple
 
Rufus's Avatar
 
Join Date: May 2007
Posts: 428
Rufus is on a distinguished road
Default

could u do an example in asm of how a "pressing Q (or any key) to show a certain message" would work :P?
Rufus 15 0FF11|\|3   Reply With Quote

Old 11-19-2007, 11:36 PM   #10 (permalink)
sharpz
Mortal
 
Join Date: Nov 2007
Posts: 6
sharpz is on a distinguished road
Default

I can't get this function to work. I've injected the hook successfully, and the function gets called, but there is simply no display. What exactly isthe global class and could the address have changed?
sharpz 15 0FF11|\|3   Reply With Quote

Old 01-16-2008, 05:38 PM   #11 (permalink)
BitSaber
Mortal
 
Join Date: Jan 2008
Posts: 4
BitSaber is on a distinguished road
Default

Quote:
Originally Posted by Perma View Post
That should work.
Code:
void Warcraft_TextOut(char *cText)
{
    static unsigned long WC3FXN_GlobalClass = 0x6F84CC20;
    static unsigned long WC3FXN_Text = 0x6F663740;

    __asm {       
        push 0FFFFFFFFh
        mov eax, WC3FXN_GlobalClass
        mov eax, dword ptr ds:[eax]
        mov eax, dword ptr ds:[eax+0x3E0]
        mov edx, dword ptr ds:[eax]
        push 0
        push 41200000h
        mov ecx, esp
        lea ecx, dword ptr ss:[ecx+0x08]
        push ecx        
        mov ecx, cText
        push ecx
        mov ecx, eax
        call dword ptr [WC3FXN_Text]
    }
}
BitSaber 15 0FF11|\|3   Reply With Quote

Old 01-21-2008, 10:09 PM   #12 (permalink)
BitSaber
Mortal
 
Join Date: Jan 2008
Posts: 4
BitSaber is on a distinguished road
Default

Code:
void Warcraft_TextOut(char *cText)
{
    static unsigned long WC3CLS_OutputClass = (*(int*)(*(int*)0x6F84CC20+0x3E0));
    static unsigned long WC3FXN_PrintText = 0x6F663740;

    __asm {       
        push -1
        push 0
        push 0x41200000
        lea ecx, dword ptr [esp+0x08]
        push ecx        
        push cText
        mov ecx, WC3CLS_OutputClass
        call dword ptr [WC3FXN_Text]
    }
}
For whatever reason, I wasn't able to just edit my above post.

I didn't do any work on Warcraft III yet, but this should work.
BitSaber 15 0FF11|\|3   Reply With Quote

Old 07-23-2008, 08:15 PM   #13 (permalink)
Phoenixs

Heretic
 
Phoenixs's Avatar
 
Join Date: Jul 2008
Posts: 29
Phoenixs is on a distinguished road
Default

Do I need some special compiler / library to compile ASM that is integrated to C++?

I wasn't able to compile this code with Dev-C++ 4.9.9.2 so..
Someone explain?
__________________
In a world without walls and fences, you don't need windows or gates.
Phoenixs 15 0FF11|\|3   Reply With Quote

Old 07-23-2008, 09:05 PM   #14 (permalink)
Shimano

Advocate
 
Shimano's Avatar
 
Join Date: Jan 2007
Location: Boise, ID
Posts: 258
Shimano is on a distinguished road
Send a message via MSN to Shimano
Default

Then use vc++
__________________

Shimano 15 0FF11|\|3   Reply With Quote

Old 07-24-2008, 04:44 AM   #15 (permalink)
Phoenixs

Heretic
 
Phoenixs's Avatar
 
Join Date: Jul 2008
Posts: 29
Phoenixs is on a distinguished road
Default

Quote:
Originally Posted by Shimano View Post
Then use vc++
Yea google up abit and many other recommend VC++ to compile inline asm too.

Somebody said that syntax of inline assembler in gcc is strange, too.

Well, gotta try with VC++ when I'm at home again.

Thanks
__________________
In a world without walls and fences, you don't need windows or gates.
Phoenixs 15 0FF11|\|3   Reply With Quote

Old 07-24-2008, 05:01 AM   #16 (permalink)
Dyndrilliac

Blessed
 
Dyndrilliac's Avatar
 
Join Date: Jun 2005
Location: Jacksonville, FL, USA
Posts: 2,504
Dyndrilliac has a brilliant futureDyndrilliac has a brilliant futureDyndrilliac has a brilliant futureDyndrilliac has a brilliant futureDyndrilliac has a brilliant futureDyndrilliac has a brilliant futureDyndrilliac has a brilliant future
Send a message via MSN to Dyndrilliac
Default

How do you guys think Inline ASM is accomplished? Inline ASM is possible only when the IDE makes use of an ASM compiler/linker. Inline ASM that uses MASM syntax therefore needs MASM compiling tools, which of course are built-in to Microsoft's Visual C++. To check to see if your IDE has the tools required to compile MASM code, search for the utility ml.exe (or ml64.exe for 64-bit compiling).
Dyndrilliac 15 0FF11|\|3   Reply With Quote

Old 10-14-2008, 04:02 AM   #17 (permalink)
Perma
rol 3905h, 8
Senior Member
Administrator

Saint
 
Perma's Avatar
 
Join Date: Jul 2004
Location: Canada
Posts: 5,384
Perma has disabled reputation
Default

Here is a different text function for the current patch.

Code:
Game_TextOut proc       szText:DWORD
   ;//Local text out function.

        .data
        WC3FXN_TextOut           dd 6F2F3130h

        .code
        push 0FF00FF00h
        push 41200000h
        push szText
        mov ecx, dword ptr ds:[6FAA1988h]
        call dword ptr [WC3FXN_TextOut]
        ret

Game_TextOut endp
This makes the text appear where other status messages appear (several indents to the right and lower than normal text messages). The first parameter is your default color (opacity, red value, green value, blue value), the next parameter is the timer, and the last is your text pointer.

Because you can change the color in the text string itself, the actual value of this color parameter is pretty much irrelevant. You can simplify your call parameters as I've shown above to save time.
Perma 15 0FF11|\|3   Reply With Quote

Old 10-14-2008, 11:08 PM   #18 (permalink)
Shimano

Advocate
 
Shimano's Avatar
 
Join Date: Jan 2007
Location: Boise, ID
Posts: 258