Valhalla Legends Forums Archive | Battle.net Bot Development | What's wrong with the following VB code?

AuthorMessageTime
j0ned
[code]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[/code]

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.
July 23, 2004, 7:24 PM
j0ned
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
July 23, 2004, 8:11 PM
OnlyMeat
[quote author=j0ned link=board=17;threadid=7838;start=0#msg72082 date=1090613462]
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
[/quote]

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.
July 23, 2004, 8:40 PM
Twix
Next time u paste a code can u please use the code tags
July 23, 2004, 8:44 PM
j0ned
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...

[code]
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
[/code]

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

July 23, 2004, 8:51 PM
Maddox
Why do people do this
[code]
Dim Foo as String
Foo = Space(256)
[/code]

As opposed to
[code]
Dim Foo as String * 256
[/code]
July 24, 2004, 4:21 AM
Newby
[quote author=Maddox link=board=17;threadid=7838;start=0#msg72155 date=1090642919]
Why do people do this
[code]
Dim Foo as String
Foo = Space(256)
[/code]

As opposed to
[code]
Dim Foo as String * 256
[/code]
[/quote]
They take a source and don't correct it.

You could also do the following

[code]Dim Foo As String
Foo = String(256, vbNullChar) ' Chr(0) works I think[/code]
July 24, 2004, 4:26 AM
Lenny
[quote author=Maddox link=board=17;threadid=7838;start=0#msg72155 date=1090642919]
Why do people do this
[code]
Dim Foo as String
Foo = Space(256)
[/code]

As opposed to
[code]
Dim Foo as String * 256
[/code]
[/quote]

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.
July 24, 2004, 4:51 AM
ChR0NiC
Hence the use of the KillNull or NullTruncString Function :P
July 24, 2004, 5:01 AM
j0ned
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
July 24, 2004, 10:27 PM
ChR0NiC
[quote author=j0ned link=board=17;threadid=7838;start=0#msg72298 date=1090708065]
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
[/quote]

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

[code]
mpqname = Mid(Data, InStr(Data, "I"), 12)
[/code]

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.
July 25, 2004, 4:37 AM
Maddox
LEARN TO DEBUG.
July 25, 2004, 5:23 AM
St0rm.iD
$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.
July 25, 2004, 2:06 PM

Search