Valhalla Legends Forums Archive | Battle.net Bot Development | [C++] War3 key algorithms

AuthorMessageTime
Eibro
C++ implementation of war3 key algorithms reversed from install.exe. This was an independant effort; it has nothing to do with the other war3 key code floating around. Email questions/comments to ebrooks@hfx.eastlink.ca

Get it at http://cs.smu.ca/~e_brooks/war3/
Future updates (if any) will be posted there.

The IDB is there for IDA 4.5 if anyone is interested in looking at the reversal. Also, an idc script (maketable.idc) is there that was used to format the key tables into an array.

November 18, 2004, 4:02 AM
Skywing
It's not really a C++ implementation if it's mostly inline assembler :p
November 18, 2004, 4:04 AM
Eibro
[quote author=Skywing link=topic=9593.msg89210#msg89210 date=1100750670]
It's not really a C++ implementation if it's mostly inline assembler :p
[/quote]Figured someone would say that. If I get some time (and interest) i'll convert the remaining parts (see the readme).
November 18, 2004, 4:06 AM
Skywing
[quote author=Eibro[yL] link=topic=9593.msg89211#msg89211 date=1100750813]
[quote author=Skywing link=topic=9593.msg89210#msg89210 date=1100750670]
It's not really a C++ implementation if it's mostly inline assembler :p
[/quote]Figured someone would say that. If I get some time (and interest) i'll convert the remaining parts (see the readme).
[/quote]
BTW, there are C++ equivalents for what you call multPass -- it's 64-bit math, though.
November 18, 2004, 5:52 AM
Eibro
[quote author=Skywing link=topic=9593.msg89224#msg89224 date=1100757129]
[quote author=Eibro[yL] link=topic=9593.msg89211#msg89211 date=1100750813]
[quote author=Skywing link=topic=9593.msg89210#msg89210 date=1100750670]
It's not really a C++ implementation if it's mostly inline assembler :p
[/quote]Figured someone would say that. If I get some time (and interest) i'll convert the remaining parts (see the readme).
[/quote]
BTW, there are C++ equivalents for what you call multPass -- it's 64-bit math, though.
[/quote]Yeah, I figured as much. Though I couldn't get the compiler to emit the correct instructons (see post in the assembly forum)
November 18, 2004, 12:11 PM
iago
when we did it, Maddox was stuck on that line for quite awhile.  __int64 or long long works in C++ (VS and gcc respectively), and long works in Java.
November 18, 2004, 5:55 PM
Arta
I used LARGE_INTEGER, which works quite nicely. Translates easily from the assembly. That is, if we're talking about the same bit :)
November 18, 2004, 8:45 PM
Eibro
Ah, that is how I did it the first time through, but it wasn't generating the correct instructions so I scrapped it. I guess now that that problem is solved I should roll back to my previous code.[code]union LargeInt {
struct {
unsigned long low;
unsigned long high;
};
int64 val;
};  */[/code]
BTW, we're talking about the code inside what I called 'tableMult' (.text:0041D050)
November 18, 2004, 10:32 PM
Arta
I can't find anything there in my notes, I may have used TFT though.
November 18, 2004, 11:01 PM
Maddox
[quote author=Skywing link=topic=9593.msg89210#msg89210 date=1100750670]
It's not really a C++ implementation if it's mostly inline assembler :p
[/quote]

Looks more like a C implementation.

This is the way I ended up doing that specific function.

[code]
#ifdef WIN32
typedef unsigned __int64 ULONGLONG;
#else
typedef unsigned long long ULONGLONG;
#endif

DWORD Mult(DWORD Rounds, DWORD Mul, DWORD* BufA, DWORD* BufB, DWORD DecodedByte)
{
while(Rounds--)
{
ULONGLONG edxeax = (ULONGLONG)BufA[Rounds] * (ULONGLONG)Mul;
BufB[Rounds] = DecodedByte + (DWORD)edxeax;
DecodedByte = (DWORD)(edxeax >> 32);
}

return DecodedByte;
}
[/code]
November 19, 2004, 1:49 AM
Skywing
Recommend looking at the UInt32x32To64 macro, and the code it generates (for future reference).
November 19, 2004, 4:46 AM
Maddox
[quote author=Skywing link=topic=9593.msg89340#msg89340 date=1100839612]
Recommend looking at the UInt32x32To64 macro, and the code it generates (for future reference).
[/quote]

Except that is native only to Windows.
November 19, 2004, 6:06 AM
Skywing
Yes.  However, you were reverse engineering a Windows program.
November 19, 2004, 6:20 AM
Zakath
Haha...this is what I wound up with when I did my port back to C++ of the code that iago released:

[code]void Mult( int nRounds, int nMulX, LPDWORD lpdwBufferA, LPDWORD lpdwBufferB, DWORD dwDecodedByte ) {
while ( nRounds ) {
unsigned __int64 edxeax = (unsigned __int64)((unsigned __int64)lpdwBufferA[ nRounds - 1 ] * (DWORD)nMulX);
lpdwBufferB[ --nRounds ] = dwDecodedByte + (DWORD)edxeax;
dwDecodedByte = (DWORD)(edxeax >> 32);
}
}[/code]

I would guess he called the function slightly differently than you do, since he's using different offsets into the buffers.
November 19, 2004, 6:34 AM
Eibro
[quote author=Maddox link=topic=9593.msg89320#msg89320 date=1100828983]
[quote author=Skywing link=topic=9593.msg89210#msg89210 date=1100750670]
It's not really a C++ implementation if it's mostly inline assembler :p
[/quote]

Looks more like a C implementation.

This is the way I ended up doing that specific function.

[code]
#ifdef WIN32
typedef unsigned __int64 ULONGLONG;
#else
typedef unsigned long long ULONGLONG;
#endif

DWORD Mult(DWORD Rounds, DWORD Mul, DWORD* BufA, DWORD* BufB, DWORD DecodedByte)
{
while(Rounds--)
{
ULONGLONG edxeax = (ULONGLONG)BufA[Rounds] * (ULONGLONG)Mul;
BufB[Rounds] = DecodedByte + (DWORD)edxeax;
DecodedByte = (DWORD)(edxeax >> 32);
}

return DecodedByte;
}
[/code]
[/quote]I tried to make it easy for C programmers to use.

[quote]I would guess he called the function slightly differently than you do, since he's using different offsets into the buffers.[/quote]No, look closer. He indexes the buffer by rounds - 1 (rounds--) while I index as buflen - i - 1 (i++)
November 19, 2004, 2:38 PM
Maddox
[quote author=Skywing link=topic=9593.msg89346#msg89346 date=1100845217]
Yes.  However, you were reverse engineering a Windows program.
[/quote]

And?
November 19, 2004, 10:46 PM
Skywing
[quote author=Maddox link=topic=9593.msg89414#msg89414 date=1100904377]
[quote author=Skywing link=topic=9593.msg89346#msg89346 date=1100845217]
Yes.  However, you were reverse engineering a Windows program.
[/quote]

And?
[/quote]
And it might be good to be familiar with the kinds of constructs that might appear in a Windows program if you're reversing Windows programs.
November 19, 2004, 11:47 PM
Maddox
[quote author=Skywing link=topic=9593.msg89418#msg89418 date=1100908021]
[quote author=Maddox link=topic=9593.msg89414#msg89414 date=1100904377]
[quote author=Skywing link=topic=9593.msg89346#msg89346 date=1100845217]
Yes.  However, you were reverse engineering a Windows program.
[/quote]

And?
[/quote]
And it might be good to be familiar with the kinds of constructs that might appear in a Windows program if you're reversing Windows programs.
[/quote]

Wouldn't it be better to learn what those constructs actually do, rather than just blindly using them because they're native to windows?
November 20, 2004, 4:10 AM
Skywing
[quote author=Maddox link=topic=9593.msg89454#msg89454 date=1100923800]
Wouldn't it be better to learn what those constructs actually do, rather than just blindly using them because they're native to windows?
[/quote]
Just to clarify, that was intended to be implied by "Recommend looking at the UInt32x32To64 macro, and the code it generates (for future reference)."
November 20, 2004, 5:06 AM
EpicOfTimeWasted
Am I to assume it's too much to ask why my post was deleted?  It's a topic regarding C++ Warcraft 3 cdkey algorithms, and I posted my C++ implementation.  You don't like my contribution, fine, it's your forum so I'm not going to argue.  Can I at least be told why the post was deleted though?
December 2, 2004, 8:33 PM
UserLoser.
[quote author=EpicOfTimeWasted link=topic=9593.msg90825#msg90825 date=1102019628]
Am I to assume it's too much to ask why my post was deleted?  It's a topic regarding C++ Warcraft 3 cdkey algorithms, and I posted my C++ implementation.  You don't like my contribution, fine, it's your forum so I'm not going to argue.  Can I at least be told why the post was deleted though?
[/quote]

I'm not a moderator, but I'm pretty sure nobody here wants the so-called "new logon system" account-related things to be posted, or have posts which contain links to websites which have them.
December 2, 2004, 11:39 PM
Adron
[quote author=UserLoser link=topic=9593.msg90842#msg90842 date=1102030752]
I'm not a moderator, but I'm pretty sure nobody here wants the so-called "new logon system" account-related things to be posted, or have posts which contain links to websites which have them.
[/quote]

I thought others had posted links to their codes for emulating it?
December 3, 2004, 7:20 PM
UserLoser.
[quote author=Adron link=topic=9593.msg90934#msg90934 date=1102101634]
[quote author=UserLoser link=topic=9593.msg90842#msg90842 date=1102030752]
I'm not a moderator, but I'm pretty sure nobody here wants the so-called "new logon system" account-related things to be posted, or have posts which contain links to websites which have them.
[/quote]

I thought others had posted links to their codes for emulating it?
[/quote]

As far as I know, they were removed.
December 3, 2004, 7:57 PM
Eibro
[quote author=EpicOfTimeWasted link=topic=9593.msg90825#msg90825 date=1102019628]
Am I to assume it's too much to ask why my post was deleted?  It's a topic regarding C++ Warcraft 3 cdkey algorithms, and I posted my C++ implementation.  You don't like my contribution, fine, it's your forum so I'm not going to argue.  Can I at least be told why the post was deleted though?
[/quote]That is interesting. I didn't see anything wrong with your post either. Oh well.
December 3, 2004, 10:07 PM
Adron
[quote author=UserLoser link=topic=9593.msg90942#msg90942 date=1102103821]
As far as I know, they were removed.
[/quote]

Even iago's?
December 3, 2004, 10:41 PM
UserLoser.
[quote author=Adron link=topic=9593.msg90955#msg90955 date=1102113663]
[quote author=UserLoser link=topic=9593.msg90942#msg90942 date=1102103821]
As far as I know, they were removed.
[/quote]

Even iago's?
[/quote]

No, pretty sure he only posted that in his forum, where he's the only moderator.
December 3, 2004, 10:47 PM

Search