• Welcome to Valhalla Legends Archive.
 

[C++] Trying to find source of invalid version in my code

Started by Okee, May 08, 2005, 11:53 PM

Previous topic - Next topic

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...:

        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);
}


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.

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.

Okee

Yeah. My bot connects and successfully logs in now. Thanks to userloser, shadypalm and everyone that helped point out problems.

MyndFyre

QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

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.

UserLoser.

Quote from: MyndFyre on May 09, 2005, 01:38 PM
Don't suppose you'd post the solution?

Quote from: UserLoser on May 09, 2005, 12:36 AM
Problem is fixed, resolved on AIM with him. He was using Storm.dll and Battle.snp as the network provider and general library, respectively.