Valhalla Legends Forums Archive | Battle.net Bot Development | [RESOLVED] kd_create kills VB?

AuthorMessageTime
JoeTheOdd
Yeah, I've tried everything, and I still get a messagebox that says "Visual Basic has encountered a problem and needs to close."

[tt]Public Sub Send0x51()
    Dim InfoString As String, Decoder As Long, HashLength As Long, HashedKey As String, Checksum As Long, EXEVersion As Long
   
    Call checkRevision(modVariables.ChecksumForumula, App.Path & "\STAR\StarCraft.exe", App.Path & "\STAR\storm.dll", App.Path & "\STAR\battle.snp", modVariables.MPQNum, Checksum)
    Debug.Print "CR"
    EXEVersion = modBNCSutil.getExeInfo(App.Path & "\STAR\StarCraft.exe", InfoString)
    Debug.Print "EV"
    Decoder = kd_create(getCDKey, Len(getCDKey))
    Debug.Print "KDC"
    HashLength = kd_calculateHash(Decoder, modVariables.ClientKey, modVariables.ServerKey)
    Debug.Print "HL"
    HashedKey = String$(HashLength, vbNullChar)
    Debug.Print "HK"
    Call kd_getHash(Decoder, HashedKey)
   
    With PBuffer
        .InsertDWORD modVariables.ClientKey        '(DWORD)      Client Token
        .InsertDWORD EXEVersion                    '(DWORD)      EXE Version
        .InsertDWORD Checksum                      '(DWORD)      EXE Hash
        .InsertDWORD 1                              '(DWORD)      Number of keys in this packet
        .InsertDWORD 0                              '(BOOLEAN)    Using Spawn (32-bit)
        .InsertDWORD Len(modConfig.getCDKey)        '(DWORD)      Key Length
        .InsertDWORD kd_product(Decoder)            '(DWORD)      CD key's product value
        .InsertDWORD kd_val1(Decoder)              '(DWORD)      CD key's public value
        .InsertDWORD 0                              '(DWORD)      Unknown (0)
        .InsertNonNTString HashedKey                '(DWORD[5])  Hashed Key Data
        .InsertNTString InfoString                  '(STRING)    Exe Information
        .InsertNTString "JBBE"                      '(STRING)    CD Key owner name
        .PushBNCSPacket &H51
        .SendData
    End With
End Sub[/tt]

The debug.print messages are showing where it dies, which is right before kd_create is fired.


EDIT -
Remember to init your kd's children!
November 19, 2005, 5:12 AM
shadypalm88
As an aside, you might want to look into kd_quick.  It does the decoding and hashing and returns the necessary variables in one function call and doesn't require the use of kd_init.  It is available since BNCSutil 1.1.0.  Here are its signatures:

[code]// C:
/**
* Decodes a CD-key, retrieves its relevant values, and calculates a hash
* suitable for SID_AUTH_CHECK (0x51) in one function call.  Returns 1 on
* success or 0 on failure.  A call to kd_init does NOT need to be made before
* calling this function.  Available since BNCSutil 1.1.0.
*/
int kd_quick(const char* cd_key, uint32_t client_token,
    uint32_t server_token, uint32_t* public_value,
    uint32_t* product, char* hash_buffer, size_t buffer_len);

' Visual Basic:
Public Declare Function kd_quick Lib "bncsutil.dll" _
    (ByVal CDKey As String, ByVal ClientToken As Long, _
    ByVal ServerToken As Long, PublicValue As Long, _
    Product As Long, ByVal HashBuffer As String, _
    ByVal BufferLen As Long) As Long
[/code]

From Visual Basic, you would call it something like this: (note: untested example code)
[code]
Dim PublicValue As Long, Product As Long
Dim HashBuffer As String * 20 ' note the * 20, creates a fixed-length string 20 bytes long

' CDKey, ClientToken, and ServerToken are declared elsewhere and their
' values obviously must have already been filled.
If kd_quick(CDKey, ClientToken, ServerToken, PublicValue, Product, HashBuffer, 20) = 0 Then
    ' decode failed; handle the error
    Exit Sub
End If
' decode was successful
' PublicValue, Product, and HashBuffer now contain their respective values
' and can be used to generate and send SID_AUTH_CHECK (0x51).[/code]
November 19, 2005, 4:38 PM

Search