Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: j0ned on July 23, 2004, 02:24 PM

Title: What's wrong with the following VB code?
Post by: j0ned on July 23, 2004, 02:24 PM
Case &H6


       d = Data
       mpqname = Mid(d, InStr(d, "I"), Len(d) - InStr(InStr(d, "I"), d, Chr(0)))
       mpqend = InStr(InStr(d, "I"), d, Chr(0))
       mpqname = Left(mpqname, InStr(mpqname, Chr(0)) - 1)
       hash = Mid(d, mpqend + 1, InStr(mpqend + 1, d, Chr(0)) - 1)
       hash = Left(hash, InStr(hash, Chr(0)) - 1)
       Dim version As Long
       Dim Checksum As Long
       Dim ExeInfo As String
       Dim Result As Long
       pbuffer.InsertNonNTString "68XI" & varProduct
       pbuffer.InsertDWORD "&H" & verByte
       ExeInfo = Space(256)
         If varProduct = "VD2D" Then
            Result = CheckRevision(varFiles & exeN & ".exe", varFiles & "bnclient.dll", varFiles & "d2client.dll", hash, version, Checksum, ExeInfo, mpqname)
         Else
            Result = CheckRevision(varFiles & exeN & ".exe", varFiles & "storm.dll", varFiles & "battle.snp", hash, version, Checksum, ExeInfo, mpqname)
         End If
       pbuffer.InsertDWORD version
       pbuffer.InsertDWORD Checksum
       NullTruncString ExeInfo
       pbuffer.InsertNTString ExeInfo
         If ExeInfo = Space(256) Then
            pbuffer.Clear
            AddChat vbRed, "BNET: Check Revisition Failed"
            Form1.sckbnet.Close
            Exit Sub
         End If
       pbuffer.sendPacket 7
       Dim strdata As String


Kp edit: added code tags, which the original poster should've taken care of for himself.  In particular, he could've edited the message instead of leaving it to a moderator to clean up.
Title: Re:What's wrong with the following VB code?
Post by: j0ned on July 23, 2004, 03:11 PM
When the program is loaded, the error Check Revision Failed is displayed in the text box.

It's as if the EXEInfo is not being loaded? The proper file(s) are in their correct directories. Why wouldn't the EXEINFO be loaded properly ?

Thanks guys
Title: Re:What's wrong with the following VB code?
Post by: OnlyMeat on July 23, 2004, 03:40 PM
Quote from: j0ned on July 23, 2004, 03:11 PM
When the program is loaded, the error Check Revision Failed is displayed in the text box.

It's as if the EXEInfo is not being loaded? The proper file(s) are in their correct directories. Why wouldn't the EXEINFO be loaded properly ?

Thanks guys

Are you sure the paths are correct that you are passing info the checkrevision?, maybe try and print out your paths first or breakpoint the checkrevision and look at the values.

debug.print varFiles & "bnclient.dll" should do it then just check the immediate window for the results.
Title: Re:What's wrong with the following VB code?
Post by: DeTaiLs on July 23, 2004, 03:44 PM
Next time u paste a code can u please use the code tags
Title: Re:What's wrong with the following VB code?
Post by: j0ned on July 23, 2004, 03:51 PM
I will use the code method next time, my apologies..

I'm sure the path is correct, and the hash files are not corrupt.

Notice the code uses...


         If varProduct = "VD2D" Then
            Result = CheckRevision(varFiles & exeN & ".exe", varFiles & "bnclient.dll", varFiles & "d2client.dll", hash, version, Checksum, ExeInfo, mpqname)
         Else
            Result = CheckRevision(varFiles & exeN & ".exe", varFiles & "storm.dll", varFiles & "battle.snp", hash, version, Checksum, ExeInfo, mpqname)
         End If


The product specified in the config file is SEXP, not VDV2.

Title: Re:What's wrong with the following VB code?
Post by: Maddox on July 23, 2004, 11:21 PM
Why do people do this

Dim Foo as String
Foo = Space(256)


As opposed to

Dim Foo as String * 256
Title: Re:What's wrong with the following VB code?
Post by: Newby on July 23, 2004, 11:26 PM
Quote from: Maddox on July 23, 2004, 11:21 PM
Why do people do this

Dim Foo as String
Foo = Space(256)


As opposed to

Dim Foo as String * 256

They take a source and don't correct it.

You could also do the following

Dim Foo As String
Foo = String(256, vbNullChar) ' Chr(0) works I think
Title: Re:What's wrong with the following VB code?
Post by: Lenny on July 23, 2004, 11:51 PM
Quote from: Maddox on July 23, 2004, 11:21 PM
Why do people do this

Dim Foo as String
Foo = Space(256)


As opposed to

Dim Foo as String * 256


Not necessarily true, Newby...

Because with the second method, if Foo isn't filled with 256 characters, the remaining space become spaces (0x20).  With Space() they do not...as long as Foo is filled with anything, the remaining unused space is truncated.
Title: Re:What's wrong with the following VB code?
Post by: ChR0NiC on July 24, 2004, 12:01 AM
Hence the use of the KillNull or NullTruncString Function :P
Title: Re:What's wrong with the following VB code?
Post by: j0ned on July 24, 2004, 05:27 PM
So I take it madd0x's code will not work?

Can anyone else see why this code wouldn't work?

Check Revision failed - why ?!

-j0ned
Title: Re:What's wrong with the following VB code?
Post by: ChR0NiC on July 24, 2004, 11:37 PM
Quote from: j0ned on July 24, 2004, 05:27 PM
So I take it madd0x's code will not work?

Can anyone else see why this code wouldn't work?

Check Revision failed - why ?!

-j0ned

Looks like you are missing the CDKey owner String.

Eeek, I've never seen this packet before, is it from an older logon sequence?

Also maybe try this for the MPQName


mpqname = Mid(Data, InStr(Data, "I"), 12)


Edit: now why is this important? each different MPQ has a different algorithm I believe, so if you are supplying an incorrect MPQName you may be receiving some incorrect data on your return.

Edit2: and if I am just talking about a bunch of nothing and making a total fool of myself, tell me please before I go too far.
Title: Re:What's wrong with the following VB code?
Post by: Maddox on July 25, 2004, 12:23 AM
LEARN TO DEBUG.
Title: Re:What's wrong with the following VB code?
Post by: Banana fanna fo fanna on July 25, 2004, 09:06 AM
$t0rm's guide to debugging in this situation:

- Packet log the game sending packet in question
- Packet log your bot sending packet in question
- Compare
- If everything matches except return values out of CheckRevision, you're passing bad values to CheckRevision.
- Otherwise, fix the problem.