• Welcome to Valhalla Legends Archive.
 

[Solved] CheckRevision Failed

Started by Don Cullen, July 21, 2006, 12:05 PM

Previous topic - Next topic

Don Cullen

I decided to take a shot at coding my own OCX to streamline making bots. Ran into a problem that I haven't had before with my other bots. This is the output of my program:

[10:06:58 AM]    Initalizing Battle.net variables...
[10:06:58 AM]    Variables initalized.
[10:06:58 AM]    BNCSUtil.dll ver 1.2.0 loaded.
[10:06:58 AM]    BNET Ocx ready.
[10:06:59 AM]    Connecting to port 6112 at the uswest.battle.net server...
[10:06:59 AM]    Connecting...
[10:06:59 AM]    Generating 0x01 packet...
[10:06:59 AM]    Packet sent.
[10:06:59 AM]    Generating 0x50 packet...
[10:06:59 AM]    Packet sent.
[10:06:59 AM]    BNET: Pingback requested.
[10:06:59 AM]    Generating 0x25 packet...
[10:06:59 AM]    Packet sent.
[10:06:59 AM]    BNET: CDKey and game client verification requested.
[10:06:59 AM]    ChecksumFormula = A=35702347 B=330300289 C=892412739 4 A=A^S B=B^C C=C-A A=A^B
[10:06:59 AM]    Generating 0x51 packet...
[10:06:59 AM]    Verifying that CheckSumFormula exists: A=35702347 B=330300289 C=892412739 4 A=A^S B=B^C C=C-A A=A^B
[10:06:59 AM]    Accquiring data from registry...
[10:06:59 AM]    ProgHashPath: C:\Program Files\Starcraft
[10:06:59 AM]    ProgFileName: C:\Program Files\Starcraft\Starcraft.exe
[10:06:59 AM]    EXEPath: C:\Program Files\Starcraft\Starcraft.exe
[10:06:59 AM]    DLLPath: C:\Program Files\Starcraft\storm.dll
[10:06:59 AM]    ThirdPath: C:\Program Files\Starcraft\battle.snp
[10:06:59 AM]    Generating ClientToken...
[10:06:59 AM]    EXE/MPQ information extracted.
[10:06:59 AM]    Performing CheckRevision...
[10:06:59 AM]    ERROR: CheckRevision failed.
[10:06:59 AM]    Disconnected.


This is the CheckRevision code (in the 0x51 packet generator):

            Dim EXEVersion As Long
            Dim EXEHash As Long
            Dim NumberOfKeys As Long
            Dim KeyLen As Long
            Dim CDKeyProductValue As Long
            Dim CDKeyPublicValue As Long
            Dim HashedKeyData As Long
            Dim EXEInfo As String
            Dim CDKeyOwnerName As String, KeyHash As String
            Dim mpqNumber As Long, Checksum As Long
            Dim EXEPath As String, DLLPath As String, ThirdPath As String
           
            RaiseEvent OCXDebugger("Verifying that CheckSumFormula exists: " & ChecksumFormula)
           
            RaiseEvent OCXDebugger("Accquiring data from registry...")
           
            If (BNETGameClient = "SEXP") Or (BNETGameClient = "") Then   'SCBW
                'Accquire filepath
                ProgHashPath = GetSettingString(HKEY_LOCAL_MACHINE, "SOFTWARE\Blizzard Entertainment\Starcraft", "InstallPath")
                ProgFileName = GetSettingString(HKEY_LOCAL_MACHINE, "SOFTWARE\Blizzard Entertainment\Starcraft", "Program")

                RaiseEvent OCXDebugger("ProgHashPath: " & ProgHashPath)
                RaiseEvent OCXDebugger("ProgFileName: " & ProgFileName)
               
                'Process it
                EXEPath = ProgFileName
                DLLPath = ProgHashPath & "\" & "storm.dll"
                ThirdPath = ProgHashPath & "\" & "battle.snp"
               
                RaiseEvent OCXDebugger("EXEPath: " & EXEPath)
                RaiseEvent OCXDebugger("DLLPath: " & DLLPath)
                RaiseEvent OCXDebugger("ThirdPath: " & ThirdPath)
            Else
            End If
           
            RaiseEvent OCXDebugger("Generating ClientToken...")
           
            ClientToken = GetTickCount()
            EXEVersion = getExeInfo(EXEPath, EXEInfo)
            mpqNumber = extractMPQNumber(Ix86verfilename)
           
            RaiseEvent OCXDebugger("EXE/MPQ information extracted.")
           
            RaiseEvent OCXDebugger("Performing CheckRevision...")
               
            ' Perform revision check operations.
            If (checkRevision(ChecksumFormula, EXEPath, DLLPath, ThirdPath, mpqNumber, Checksum) = False) Then
                Winsock1.Close
                RaiseEvent BNETError(2, "CheckRevision failed.", True)
                Exit Sub
            End If
           
            RaiseEvent OCXDebugger("Decoding CDKey...")
           
            'Decode the main CD-key.
            decoder = kd_create(BNETCDKey, Len(BNETCDKey))
            If (decoder = -1) Then
                Winsock1.Close
                RaiseEvent BNETError(3, "Failed to decode your CD-key.", True)
                Exit Sub
            End If
           
            RaiseEvent OCXDebugger("Hashing CDKey...")
           
            ' Calculate key hash.
            HashLength = kd_calculateHash(decoder, ClientToken, ServerToken)
            If (HashLength = 0) Then
                Winsock1.Close
                RaiseEvent BNETError(4, "Failed to hash your CD-key.", True)
                Exit Sub
            End If
           
            ' Retrieve key hash.
            KeyHash = String$(HashLength, vbNullChar) ' Initialize buffer.
            Call kd_getHash(decoder, KeyHash)
           
            'Now data for the packet has been gathered,
            'begin assembling the packet
           
            RaiseEvent OCXDebugger("Assembling packet...")
       
            With PacketBuf
                .Clear
                .InsertDWORD ClientToken    'Client Token
                .InsertDWORD EXEVersion     'EXE Version
                .InsertDWORD Checksum       'EXE Hash
                .InsertDWORD &H1            'only one cdkey, if two cdkeys, &H2
                .InsertDWORD &H0            'Spawn = False
                .InsertDWORD Len(BNETCDKey)         'CDKey Length
                .InsertDWORD kd_product(decoder)    'CD key's product value
                .InsertDWORD kd_val1(decoder)       'CD key's public value
                .InsertDWORD &H0                      'Unknown, just put zero
                .InsertNonNTString KeyHash          'Hashed Key Data
                .InsertNTString EXEInfo               'EXE Info
                .InsertNTString "Sanity BNET OCX"          'CDKey owner.
                .SendPacket Winsock1, &H51       'Send 0x51 packet
                .Clear
            End With
           
            ' Release the key decoder.
            Call kd_free(decoder)


Tried using hashes in same folder, checked the paths, and so on. Even upgraded bncsutil.dll to latest version and updated bncsutil code. Can't figure out the problem. Any ideas? Thanks in advance for your help.
Regards,
Don
-------

Don't wonder why people suddenly are hostile when you treat them the way they shouldn't be- it's called 'Mutual Respect'.

PaiD

Do you have Stacraft Installed?

Don Cullen

#2
Yup.

Added one more line of debug code:

RaiseEvent OCXDebugger("mpqNumber = " & mpqNumber & " Checksum = " & Checksum)

Results in this:

[11:23:30 AM]    Generating ClientToken...
[11:23:30 AM]    EXE/MPQ information extracted.
[11:23:30 AM]    Performing CheckRevision...
[11:23:30 AM]    mpqNumber = -1 Checksum = 0
[11:23:30 AM]    ERROR: CheckRevision failed.


I'm not sure if mpqnumber should be -1 or Checksum should be 0, so I'm going to open up one of my bots and check to see if the results are the same. If you see any problems, point them out as I'm still trying to figure out what's wrong.

[Edited to avoid double posting]

Just checked my other bots. Got this:

mpqNumber = 0 Checksum = -1556711019


So I'm assuming there's something wrong with the mpqNumber and Checksum variables... But what exactly is causing the problem?

[Edit again]

Found out the problem. The problem was the Ix86verfilename variable. Basically, I had it declared as a public variable (wanted it to be a global so my packet generator could access the variable without having to have it passed along to it), but in the winsock incoming data parser sub, I had Ix86verfilename DIM'ed, which resulted in it becoming local, therefore inaccessible to the Packet Generator sub. I simply removed the DIM code from the parser, and the variable became global and the ocx worked perfectly. Here's the output:

[11:47:39 AM]    Initalizing Battle.net variables...
[11:47:39 AM]    Variables initalized.
[11:47:39 AM]    BNCSUtil.dll ver 1.2.0 loaded.
[11:47:39 AM]    BNET Ocx ready.
[11:47:42 AM]    Connecting to port 6112 at the uswest.battle.net server...
[11:47:42 AM]    Connecting...
[11:47:42 AM]    Generating 0x01 packet...
[11:47:42 AM]    Packet sent.
[11:47:42 AM]    Generating 0x50 packet...
[11:47:42 AM]    Packet sent.
[11:47:42 AM]    BNET: Pingback requested.
[11:47:42 AM]    Generating 0x25 packet...
[11:47:42 AM]    Packet sent.
[11:47:42 AM]    BNET: CDKey and game client verification requested.
[11:47:42 AM]    ChecksumFormula = A=836994914 B=734573732 C=588262910 4 A=A^S B=B^C C=C-A A=A-B
[11:47:42 AM]    Generating 0x51 packet...
[11:47:42 AM]    Verifying that CheckSumFormula exists: A=836994914 B=734573732 C=588262910 4 A=A^S B=B^C C=C-A A=A-B
[11:47:42 AM]    Accquiring data from registry...
[11:47:42 AM]    ProgHashPath: C:\Program Files\Starcraft
[11:47:42 AM]    ProgFileName: C:\Program Files\Starcraft\Starcraft.exe
[11:47:42 AM]    EXEPath: C:\Program Files\Starcraft\Starcraft.exe
[11:47:42 AM]    DLLPath: C:\Program Files\Starcraft\storm.dll
[11:47:42 AM]    ThirdPath: C:\Program Files\Starcraft\battle.snp
[11:47:42 AM]    Generating ClientToken...
[11:47:42 AM]    EXE/MPQ information extracted.
[11:47:42 AM]    Performing CheckRevision...
[11:47:42 AM]    Decoding CDKey...
[11:47:42 AM]    Hashing CDKey...
[11:47:42 AM]    Assembling packet...
[11:47:42 AM]    Packet sent.
[11:47:42 AM]    Got 0x51, parsing results of authenication...
[11:47:42 AM]    Authenication passed!
[11:47:42 AM]    Logging in...
[11:47:42 AM]    Generating 0x14 packet...
[11:47:42 AM]    Packet sent.
[11:47:42 AM]    Generating 0x29 packet...
[11:47:42 AM]    Packet sent.
[11:47:42 AM]    Got 0x29, parsing login response...
[11:47:42 AM]    Signed on Battle.net!
[11:47:42 AM]    Generating 0x0A packet...
[11:47:42 AM]    Packet sent.
[11:47:42 AM]    Joining channel elsewhere...
[11:47:42 AM]    SID_ENTERCHAT recieved.
[11:47:42 AM]    Now in channel elsewhere
[11:47:42 AM]    SID_ChatEvent recieved.
[11:47:42 AM]    SID_ChatEvent recieved.
[11:48:03 AM]    BNET: Pingback requested.
[11:48:03 AM]    Generating 0x25 packet...
[11:48:03 AM]    Packet sent.
[11:48:18 AM]    Signed off Battle.net!
[11:48:18 AM]    Disconnected.


Thanks for your help though, Savior.  :D
Regards,
Don
-------

Don't wonder why people suddenly are hostile when you treat them the way they shouldn't be- it's called 'Mutual Respect'.