Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: vuther.de on March 07, 2005, 10:06 PM

Title: 0x82 (SID_CLANMEMBERINFO)
Post by: vuther.de on March 07, 2005, 10:06 PM
I've been trying to parse this packet and it has been a big hassle, i've asked like 2/3 people have none of them could figure this out. The status always returns 0, the rank works, clan works, and date joined doesn't really work.
Here's my code for my parsing:
       
Case &H82
Dim strClanName As String, intPosition As Integer, bytRank As Byte, strDateJoined As String
   
    intPosition = 9

'status
bytStatus = Asc(Mid(strData, intPosition, 1))
    intPosition = intPosition + Len(bytStatus)

'clan name
strClanName = KillNull(Mid(strData, intPosition, InStr(intPosition, strData, Chr(0)) - 1))
    intPosition = intPosition + Len(strClanName) + 1

'rank
bytRank = Asc(Mid(strData, intPosition, 1))
    intPosition = intPosition + Len(bytRank)

'date joined
strDateJoined = Asc(Mid(strData, intPosition, 8))
    intPosition = intPosition + Len(strDateJoined)

AddChat vbBlue, "Status: " & GetStatus(bytStatus)
AddChat vbBlue, "Clan name: " & strClanName
AddChat vbBlue, "Rank: " & GetRankName(bytRank)

FT = StringToFileTime(strDateJoined)
Call FileTimeToSystemTime(FT, ST)
AddChat vbBlue, "Date joined: " & ST.wMonth & "/" & ST.wDay & "/" & ST.wYear & " @ " & Format(ST.wHour & ":" & ST.w
Minute & ":" & ST.wSecond, "HH:MM:SS ampm")

Title: Re: 0x82 (SID_CLANMEMBERINFO)
Post by: UserLoser. on March 07, 2005, 10:08 PM
What does it output?  Supply packet logs, too
Title: Re: 0x82 (SID_CLANMEMBERINFO)
Post by: vuther.de on March 07, 2005, 10:32 PM
[11:33:59 PM] Status: 0
[11:33:59 PM] Clan name: Dark Council
[11:33:59 PM] Rank: Grunt
[11:33:59 PM] Date joined: 1/1/1601 @ 11:27:11 AM


[11:31:44 PM] BNET: Packet sent: 0x82
[11:31:44 PM] Output dump: 0000:  00 00 00 00 00 00 43 44 6D 65 63 63 61 5B 44 43   ......CDmecca[DC
0010:  5D 00                                             ]...............
[11:31:45 PM] BNET: Packet received: 0x82
[11:31:45 PM] Output dump: 0000:  FF 82 1F 00 00 00 00 00 00 44 61 72 6B 20 43 6F   ÿ,......Dark Co
0010:  75 6E 63 69 6C 00 02 60 38 8D 0B AD 1B C5 01      uncil.`8? ­Å.
Title: Re: 0x82 (SID_CLANMEMBERINFO)
Post by: UserLoser. on March 07, 2005, 11:12 PM
I don't think Asc(Mid(strData, intPosition, 8)) is correct
Title: Re: 0x82 (SID_CLANMEMBERINFO)
Post by: vuther.de on March 08, 2005, 12:09 AM
Why? What's wrong with it?
Title: Re: 0x82 (SID_CLANMEMBERINFO)
Post by: UserLoser. on March 08, 2005, 07:44 AM
Quote from: inner. on March 08, 2005, 12:09 AM
Why? What's wrong with it?

For one it's a filetime struct, not a string.  Secondly, Asc() cannot return anything larger than an 8-bit value, and a filetime struct consists of two 32-bit values
Title: Re: 0x82 (SID_CLANMEMBERINFO)
Post by: vuther.de on March 08, 2005, 11:37 AM
So what should I do?
Title: Re: 0x82 (SID_CLANMEMBERINFO)
Post by: CrAz3D on March 08, 2005, 04:36 PM
mid(data,position,8)
give that a whirley do
Title: Re: 0x82 (SID_CLANMEMBERINFO)
Post by: Kp on March 08, 2005, 04:38 PM
Cast it to a FILETIME struct? :P
Title: Re: 0x82 (SID_CLANMEMBERINFO)
Post by: CrAz3D on March 08, 2005, 04:48 PM
Why would he do that? ::)
Title: Re: 0x82 (SID_CLANMEMBERINFO)
Post by: MyndFyre on March 08, 2005, 05:42 PM
Quote from: CrAz3D on March 08, 2005, 04:48 PM
Why would he do that? ::)

Because that's what it is?  ::)
Title: Re: 0x82 (SID_CLANMEMBERINFO)
Post by: vuther.de on March 08, 2005, 06:16 PM
Craz3d, that doesn't work.
Title: Re: 0x82 (SID_CLANMEMBERINFO)
Post by: CrAz3D on March 08, 2005, 06:53 PM
Quote from: MyndFyre on March 08, 2005, 05:42 PM
Quote from: CrAz3D on March 08, 2005, 04:48 PM
Why would he do that? ::)

Because that's what it is?  ::)
My eyes were misread I guess,
Quote from: CrAz3D on March 08, 2005, 04:48 PM
was meant as sarcasm as he already knew it was a FileTime
Title: Re: 0x82 (SID_CLANMEMBERINFO)
Post by: vuther.de on March 08, 2005, 09:04 PM
Ok well, I still cannot get this to work, pissing the hell out of me :'(
Title: Re: 0x82 (SID_CLANMEMBERINFO)
Post by: CrAz3D on March 08, 2005, 09:34 PM
Quote[8:34:17 PM] Status: 0
[8:34:17 PM] Clan name: Dark Council
[8:34:17 PM] Rank: 2
[8:34:17 PM] Date joined: 3/8/2005 @ 08:31:56 PM
Silly Inner, you must be requesting something wrong?

Is the 'DateJoinned' supposed to be the date the user joinned the channel?
Title: Re: 0x82 (SID_CLANMEMBERINFO)
Post by: vuther.de on March 08, 2005, 09:50 PM
What have I been requesting wrong?
Here's what I've been sending:

Select Case Len(strTag)
    Case 2: strTag = strTag & vbNullChar & vbNullChar
    Case 3: strTag = strTag & vbNullChar
    End Select
   
    With pbuffer
    .InsertDWORD &H0
    .InsertNonNTString StrReverse(strTag)
    .InsertNTString strMember
    .sendPacket &H82
    End With
Title: Re: 0x82 (SID_CLANMEMBERINFO)
Post by: MyndFyre on March 08, 2005, 09:51 PM
Quote from: CrAz3D on March 08, 2005, 09:34 PM
Quote[8:34:17 PM] Status: 0
[8:34:17 PM] Clan name: Dark Council
[8:34:17 PM] Rank: 2
[8:34:17 PM] Date joined: 3/8/2005 @ 08:31:56 PM
Silly Inner, you must be requesting something wrong?

Is the 'DateJoinned' supposed to be the date the user joinned the channel?
No, the date the user joined the clan.
Title: Re: 0x82 (SID_CLANMEMBERINFO)
Post by: CrAz3D on March 08, 2005, 09:54 PM
Quote from: inner. on March 08, 2005, 09:50 PM
What have I been requesting wrong?
Here's what I've been sending:

Select Case Len(strTag)
    Case 2: strTag = strTag & vbNullChar & vbNullChar
    Case 3: strTag = strTag & vbNullChar
    End Select
   
    With pbuffer
    .InsertDWORD &H0
    .InsertNonNTString StrReverse(strTag)
    .InsertNTString strMember
    .sendPacket &H82
    End With

Any idea, MyndFyre, what is wrong then?
Title: Re: 0x82 (SID_CLANMEMBERINFO)
Post by: UserLoser. on March 08, 2005, 10:43 PM
Quote from: CrAz3D on March 08, 2005, 09:54 PM
Quote from: inner. on March 08, 2005, 09:50 PM
What have I been requesting wrong?
Here's what I've been sending:

Select Case Len(strTag)
    Case 2: strTag = strTag & vbNullChar & vbNullChar
    Case 3: strTag = strTag & vbNullChar
    End Select
   
    With pbuffer
    .InsertDWORD &H0
    .InsertNonNTString StrReverse(strTag)
    .InsertNTString strMember
    .sendPacket &H82
    End With

Any idea, MyndFyre, what is wrong then?

I'll just reply because I've been asked enough on AIM about this from somebody here..

First of all, do it properly, don't be lazy and write crappy stuff.  Why not use CopyMemory?


The way I'd do it (this isn't my actual code I use, but it'd be something similar):


Function ExtractLong() As Long
    'Make sure we can advance in the buffer before doing this...
    Call CopyMemory(ExtractLong, ByVal Mid$(m_Buffer, m_Position, 4), 4)
End Function

Function OnGetClanMemberInfo(<params>) As PacketVerificationCode
    ' <Check packet size here, make sure it's valid>

    If (packet is valid length) Then
        Dim Cookie As Long
        Dim Status As Byte, Rank As Byte
        Dim ClanName As String
        Dim DateJoined as FILETIME
       
        Cookie = m_Parse.ExtractLong()
        Status = m_Parse.ExtractByte()
        ClanName = m_Parse.ExtractString()
        Rank = m_Parse.ExtractByte()
       
        'Now here we could do this two ways, but I'll show you one which I'd think is easier for you to comprehend (and don't take that the wrong way..)
        DateJoined.dwHighPart = m_Parse.ExtractLong()
        DateJoined.dwLowPart = m_Parse.ExtractLong()
       
        'Here we convert the FILETIME struct to a SYSTEMTIME struct, handle, get username based off of cookie, display, do whatever, etc.
    End If

End Function


As far as m_Parse class functions, you should be able to replicate them pretty easy.  Remember, this is off the top of my head, so I don't recall exactly if dwHighPart comes first or not in the struct
Title: Re: 0x82 (SID_CLANMEMBERINFO)
Post by: vuther.de on March 08, 2005, 11:03 PM
Here's what I've got from what you've said:

         Case &H82
Dim lngCookie As Long
Dim bytRank As Byte
Dim intPosition As Integer
Dim ftDateJoined As FILETIME
Dim strClanName As String
   
intPosition = 9
pbuffer.SetBuffer strData, Len(strData)

'cookie
lngCookie = pbuffer.GetDWORD(strData)

'status
bytStatus = Asc(Mid(strData, intPosition, 1))
    intPosition = intPosition + Len(bytStatus)

'clan name
strClanName = KillNull(Mid(strData, intPosition, InStr(intPosition, strData, Chr(0)) - 1))
    intPosition = intPosition + Len(strClanName) + 1

'rank
bytRank = Asc(Mid(strData, intPosition, 1))
    intPosition = intPosition + Len(bytRank)

'date joined
ftDateJoined.dwHighDateTime = pbuffer.ExtractLong()
ftDateJoined.dwLowDateTime = pbuffer.ExtractLong()

AddChat vbBlue, "Status: " & bytStatus
AddChat vbBlue, "Clan name: " & strClanName
AddChat vbBlue, "Rank: " & bytRank

Call FileTimeToLocalFileTime(ftDateJoined, ftDateJoined)
Call FileTimeToSystemTime(ftDateJoined, ST)
AddChat vbBlue, "Date joined: " & ST.wMonth & "/" & ST.wDay & "/" & ST.wYear & " @ " & Format(ST.wHour & ":" & ST.wMinute & ":" & ST.wSecond, "HH:MM:SS ampm")


Here is my SetBuffer sub:

Public Sub SetBuffer(ByVal strNewBuffer As String, ByVal lngLength As Long)
m_Buffer = strNewBuffer
m_Size = lngLength
m_Position = 1
End Sub


Here is my ExtractLong function:

Public Function ExtractLong() As Long
Call CopyMemory(ExtractLong, ByVal Mid$(m_Buffer, m_Position, 4), 4)
End Function


Here is what it outputs:
Quote
[12:53:56 AM] Status: 0
[12:53:56 AM] Clan name: Dark Council
[12:53:56 AM] Rank: 1
[12:53:56 AM] Date joined: 2/8/1629 @ 05:06:40 PM
It gives the same Date Joined for everyone I request.
Everything works except status and Date joined. But for now I want to worry about Date joined.
Anyone know what's wrong?
Title: Re: 0x82 (SID_CLANMEMBERINFO)
Post by: vuther.de on March 10, 2005, 12:20 AM
I've fixed it, thanks for helping me.
Title: Re: 0x82 (SID_CLANMEMBERINFO)
Post by: MyndFyre on March 10, 2005, 01:27 AM
Quote from: inner. on March 10, 2005, 12:20 AM
I've fixed it, thanks for helping me.
Would you PLEASE post HOW you fixed it?
Title: Re: 0x82 (SID_CLANMEMBERINFO)
Post by: vuther.de on March 10, 2005, 02:33 PM
Sure, as UserLoser told me on AIM, I was getting the filetime wrong. Here's what i was doing wrong:

ftDateJoined.dwLowDateTime = pbuffer.extractlong
ftDateJoined.dwHighDateTime = pbuffer.extractlong


Here's what I should of had:

ftDateJoined.dwLowDateTime = MakeLong(Mid(LastBytes, 1, 4))
ftDateJoined.dwHighDateTime = MakeLong(Mid(LastBytes, 5, 4))
Title: Re: 0x82 (SID_CLANMEMBERINFO)
Post by: NetNX on March 16, 2005, 09:31 AM
From one newb to another ~_^ Try an incoming packet buffer they work wonders! from what i hear that mid() shit isn't too great.
Title: Re: 0x82 (SID_CLANMEMBERINFO)
Post by: QwertyMonster on March 16, 2005, 09:38 AM
Quote from: inner. on March 10, 2005, 12:20 AM
I've fixed it, thanks for helping me.

So it was an easy mistake, reading what was wrong. Try to keep checking your work, and not always rely on other people to find your mistakes. This isnt a flame btw.
Title: Re: 0x82 (SID_CLANMEMBERINFO)
Post by: NetNX on March 16, 2005, 09:41 AM
Quote from: QwertyMonster on March 16, 2005, 09:38 AM
Quote from: inner. on March 10, 2005, 12:20 AM
I've fixed it, thanks for helping me.

So it was an easy mistake, reading what was wrong. Try to keep checking your work, and not always rely on other people to find your mistakes. This isnt a flame btw.

agreed