PDA

View Full Version : [Source] TextOut Function for Warcraft 3 v1.22



Perma
04-13-2007, 08:53 AM
Click here for an updated version for patch 1.22. (http://www.bwhacks.com/forums/641904-post18.html)

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


.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

K? Pŕo?ćtiόnŹ
04-13-2007, 05:54 PM
gj

bulk_4me
04-15-2007, 04:49 PM
nice.

Perma
08-06-2007, 11:41 AM
Moved to the Warcraft hacking related section.

topaz
08-19-2007, 11:48 PM
Is anyone willing to port this to C (or a language thats easily understandable)?

Perma
08-19-2007, 11:55 PM
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.

topaz
08-19-2007, 11:57 PM
Nice...

saren
08-20-2007, 04:12 AM
Inline ASM is the devil.

Rufus
10-13-2007, 01:42 AM
could u do an example in asm of how a "pressing Q (or any key) to show a certain message" would work :P?

sharpz
11-19-2007, 03:36 PM
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?

BitSaber
01-16-2008, 09:38 AM
That should work.


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
01-21-2008, 02:09 PM
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.

Phoenixs
07-23-2008, 11:15 AM
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? :)

Shimano
07-23-2008, 12:05 PM
Then use vc++

Phoenixs
07-23-2008, 07:44 PM
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 :)

Dyndrilliac
07-23-2008, 08:01 PM
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).

Perma
10-13-2008, 07:02 PM
Here is a different text function for the current patch.


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.

Shimano
10-14-2008, 02:08 PM
It'd be cool if it had x and y parameters so you can put the text anywhere you wanted

kolkoo
10-14-2008, 09:27 PM
Also in that post there is another one for 1.22 too.
http://www.bwhacks.com/forums/630176-post6.html

leonkiros2004
05-20-2009, 09:50 AM
what will the address be in wc1.20/1.20e? I really want to learn the code , to debug it , but my war3 program's version is 1.20e.