Valhalla Legends Forums Archive | Battle.net Bot Development | [C++] Trying to find source of invalid version in my code

AuthorMessageTime
Okee
Well, I seem to be stuck on this task. I figured, if anything maybe somebody can check out my handling of 0x50, and building of 0x51, and possibly spot an error. Just incase - i'm getting an invalid version reply from 0x51, when loggin on via SEXP or D2DV.

The majority of my variables of character arrays obviously, and unsigned longs. I tried to port this from BNCSutil Test App as accuratly as I could.

Handling 0x50 and building 0x51...:
[code]
        case 0x50:
{
        print("Handling auth info...\n");
HandleAuthInfo((char *)buf);
break;
        }

    void HandleAuthInfo(char *buf) {
unsigned int mpqNumber;
unsigned long LogonType = *(unsigned long*)(buf + PACKET_HEAD);

switch(LogonType) {
case 0:
{
// Old Logon System
print("Using old logon system...\n");
UseNLS = false;
break;
}
case 1:
{
// WC3 Beta NLS
closesocket(s);
bnet.state = DISCONNECTED;
print("The NLS revision that the server has requested is not supported!\n");
break;
}
case 2:
{
// New Logon System
print("Using new logon system...\n");
UseNLS = true;
break;
}
default:
{
// Who knows?
closesocket(s);
bnet.state = DISCONNECTED;
print("Unsupported logon system!\n");
break;
}
}

ServerToken = *(unsigned long*)(buf + (PACKET_HEAD + 4));
strcpy(mpqName, (char *)buf + (PACKET_HEAD + 20));
mpqNumber = extractMPQNumber(mpqName);

if(mpqNumber < 0) {
closesocket(s);
bnet.state = DISCONNECTED;
print("Unrecognized MPQ number!\n");
}

char ChecksumFormula[256];
strcpy(ChecksumFormula, (char *)buf + (PACKET_HEAD + 33));

char ServerSignature[130];
if(UseNLS) {
// Don't intend on using NLS just yet.
//strncpy(ServerSignature, (char *)buf + (PACKET_HEAD + 33 + strlen(ChecksumFormula)), 128);
//if(!nls_check_signature((int)"0.0.0.0", ServerSignature)) {
// closesocket(s);
// bnet.state = DISCONNECTED;
// print("Server signature check failed!\n");
//}
}

const char* files[] = {exe, dll_one, dll_two};
unsigned long Checksum;
if(!checkRevision(ChecksumFormula, files, 3, mpqNumber, &Checksum)) {
closesocket(s);
bnet.state = DISCONNECTED;
print("Checkrevision failed!\n");
}

unsigned long EXEVersion;
unsigned int *Version;
char EXEInfo[300];
print("Extracting exe info...\n");
EXEVersion = getExeInfo(exe, EXEInfo, 256, Version, 0x1);
if(EXEVersion == 0) {
closesocket(0);
bnet.state = DISCONNECTED;
print("Failed to get executable hash file information!\n");
}

bufadd(ClientToken);
bufadd(EXEVersion);
bufadd(Checksum);


if(!strcmp(type, "PX2D") || !strcmp(type, "PX3W")) {
print("Expansion game detected...\n");
bufadd((int)0x02);
} else {
print("No expansion game detected...\n");
bufadd((int)0x01);
}

bufadd((int)0x00);

kd_init();
CDKeyDecoder decoder(cdkey, strlen(cdkey));
if(!decoder.isKeyValid()) {
closesocket(s);
bnet.state = DISCONNECTED;
print("The CD-key provided is not a valid CD-key!\n");
}

bufadd(strlen(cdkey));
bufadd(decoder.getProduct());
bufadd(decoder.getVal1());
bufadd((int)0x00);

int hashLength = decoder.calculateHash(ClientToken, ServerToken);
if(!hashLength) {
closesocket(s);
bnet.state = DISCONNECTED;
print("Failed to hash the CD-key!\n");
}

char KeyHash[64];
if(!decoder.getHash(KeyHash)) {
closesocket(s);
bnet.state = DISCONNECTED;
print("Could not retrieve CD-key hash!\n");
}

bufadd(KeyHash, strlen(KeyHash));

if(!strcmp(type, "PX2D") || !strcmp(type, "PX3W")) {
kd_init();
CDKeyDecoder expdecoder(expcdkey, strlen(expcdkey));
if(!expdecoder.isKeyValid()) {
closesocket(s);
bnet.state = DISCONNECTED;
print("The expansion CD-key provided is not a valid CD-key!\n");
}

bufadd(strlen(expcdkey));
bufadd(expdecoder.getProduct());
bufadd(expdecoder.getVal1());
bufadd((int)0x00);

int exphashLength = expdecoder.calculateHash(ClientToken, ServerToken);
if(!exphashLength) {
closesocket(s);
bnet.state = DISCONNECTED;
print("Failed to hash the expansion CD-key!\n");
}

char expKeyHash[64];
if(!expdecoder.getHash(expKeyHash)) {
closesocket(s);
bnet.state = DISCONNECTED;
print("Could not retrieve expansion CD-key hash!\n");
}

bufadd(expKeyHash, strlen(expKeyHash));
}

bufadd(EXEInfo);
bufadd(cdkeyname);
sendpacket(SID_AUTH_CHECK);
}
[/code]

That's a lot to look over, I know, but if anyone just notices something at a glance, I'd appriciate it.

Thanks in advance.
May 9, 2005, 4:53 AM
UserLoser.
Problem is fixed, resolved on AIM with him.  He was using Storm.dll and Battle.snp as the network provider and general library, respectively.
May 9, 2005, 5:36 AM
Okee
Yeah. My bot connects and successfully logs in now. Thanks to userloser, shadypalm and everyone that helped point out problems.
May 9, 2005, 3:32 PM
Myndfyr
Don't suppose you'd post the solution?
May 9, 2005, 6:38 PM
Okee
Sure thing.

It was a combination of two pretty dumb things. One, my Test BNCS server, that I was using to test my bot on, was not updated for the newest SC/BW patch. I tried to update it, but it's still not working apparantly. *shrug* So my bot would never pass the version check there. Two, my array containing the paths to the game files was a little out of order. I was passing the network provider and general library files to checkRevision() in the incorrect order. (I actually had an error in my simple config loading function. I saved the network provider file path in the variable that I had meant for the general library file path to be in.)

Anyways, two pretty dumb mistakes - sorry for all the posts about this. Thanks though for the help.
May 9, 2005, 6:55 PM
UserLoser.
[quote author=MyndFyre link=topic=11530.msg111719#msg111719 date=1115663925]
Don't suppose you'd post the solution?
[/quote]

[quote author=UserLoser link=topic=11530.msg111637#msg111637 date=1115617008]
Problem is fixed, resolved on AIM with him. He was using Storm.dll and Battle.snp as the network provider and general library, respectively.
[/quote]
May 10, 2005, 1:14 AM

Search