• Welcome to Valhalla Legends Archive.
 

What's wrong with the following VB code?

Started by j0ned, July 23, 2004, 02:24 PM

Previous topic - Next topic

j0ned

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.

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

OnlyMeat

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.

DeTaiLs

Next time u paste a code can u please use the code tags



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


         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.


Maddox

Why do people do this

Dim Foo as String
Foo = Space(256)


As opposed to

Dim Foo as String * 256
asdf.

Newby

#6
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
- Newby

Quote[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

Quote<TehUser> Man, I can't get Xorg to work properly.  This sucks.
<torque> you should probably kill yourself
<TehUser> I think I will.  Thanks, torque.

Lenny

#7
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.
The Bovine Revolution
Something unimportant

Live Battle.net:

WARNING: The preceding message may have contained content unsuitable for young children.

ChR0NiC

#8
Hence the use of the KillNull or NullTruncString Function :P

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

ChR0NiC

#10
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.

Maddox

asdf.

Banana fanna fo fanna

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