Valhalla Legends Forums Archive | Battle.net Bot Development | Viewing A Starcraft Profile

AuthorMessageTime
QwertyMonster
Hey. I have just started to carry on with my bot. I can edit my profile, but i cant view it. I was told i have to parse the response, so i did that.

[code]
Dim Values(1 To 18) As String
KeyCount = Packet.GetDWORD(Mid(data, 9, 4))
asfrom = Mid(data, 1, 17)
For i = 1 To KeyCount - 1
    Values(i) = Mid(asfrom, 1, InStr(asfrom, Chr(0)) - 1)
    asfrom = Mid(asfrom, InStr(asfrom, Chr(0)) + 1)
  If i > 4 Then
      If Values(i) = "" Then Values(i) = 0
      End If
[/code]
It is coming back as "".            -->    <--

Well of course im doing something wrong, and im parseing something wrong. But i cant actually work out what. I got help on this by my friend and hes busy at the moment. So i come to valhallalegends.

All help is appreciated.
April 25, 2005, 4:37 PM
Adron
What's data? A hexdump of a sample data would be nice.

Setting asfrom to be the characters 1 to 17 or data doesn't make sense if data contains a profile packet. It won't have a fixed length.
April 25, 2005, 4:43 PM
QwertyMonster
Sorry about the data. I forgot the top line.

[code]
Public Function ProfileDecode(data As String)
[/code]

1 - 18* Is things for Last game, sex, location etc...

I will post a packet log of it in in 5 minutes.

Edit

The packet log has nothing in it. Just sending same thing and receiving. It appears no use to post it, or should i?

Edit 2
EDITTING PROFILE + VIEWING.
Send:
[code]0000  00 12 17 24 cd 86 00 40  2b 3f 7b 0b 08 00 45 00  ...$...@ +?{...E.
0010  00 28 64 0a 40 00 80 06  93 f3 c0 a8 01 65 d5 f8  .(d.@... .....e..
0020  6a cc 06 1a 17 e0 b2 c1  2b e2 55 e9 55 c1 50 11  j....... +.U.U.P.
0030  fe c0 05 f8 00 00                                  ......           
[/code]

Recv:

[code]0000  00 40 2b 3f 7b 0b 00 12  17 24 cd 86 08 00 45 00  .@+?{... .$....E.
0010  00 28 17 e4 00 00 73 06  2d 1a d5 f8 6a cc c0 a8  .(....s. -...j...
0020  01 65 17 e0 06 1a 55 e9  55 c1 b2 c1 2b e3 50 10  .e....U. U...+.P.
0030  fe ba 05 fe 00 00 00 00  17 6b 88 04              ........ .k..   
   
[/code]


VIEWING MY PROFILE.

Recv:

[code]0000  00 40 2b 3f 7b 0b 00 12  17 24 cd 86 08 00 45 00  .@+?{... .$....E.
0010  00 28 17 e5 00 00 73 06  2d 19 d5 f8 6a cc c0 a8  .(....s. -...j...
0020  01 65 17 e0 06 1a 55 e9  55 c1 b2 c1 2b e3 50 11  .e....U. U...+.P.
0030  fe ba 05 fd 00 00 00 00  e8 2b 8b c7              ........ .+..   
[/code]

Send:

[code]0000  00 12 17 24 cd 86 00 40  2b 3f 7b 0b 08 00 45 00  ...$...@ +?{...E.
0010  00 28 64 0b 40 00 80 06  93 f2 c0 a8 01 65 d5 f8  .(d.@... .....e..
0020  6a cc 06 1a 17 e0 b2 c1  2b e3 55 e9 55 c2 50 10  j....... +.U.U.P.
0030  fe c0 05 f7 00 00                                  ......         
[/code]
April 25, 2005, 4:51 PM
HdxBmx27
Isn't 0x26 used to request profile information? What packets are those? They don't have b.net's format.  If you need help in creating 0x26 i will help, but please tell me what the packets you are currently using are.
~-~(HDX)~-~
April 25, 2005, 6:18 PM
QwertyMonster
Yes 0x26 is.

[code]
Public Function GetProfile(Username As String)
Dim SplitProfile() As String
Dim profileend As String
SplitProfile = Split(profileend, Chr(0))
Packet.InsertDWORD 1
Packet.InsertDWORD 3
Packet.InsertDWORD &H26
Packet.InsertNTString Username
Packet.InsertNTString "profile\sex"
Packet.InsertNTString "profile\location"
Packet.InsertNTString "profile\description"
Packet.SendPacket frmMain.bnetsocket, &H26
End Function
[/code]

0x26.


[code]
Private Sub Option1_Click()
Dim Username As String
 
  With Packet
  .InsertDWORD 1
  .InsertDWORD 4
  .InsertNTString Username
  .InsertNTString "profile\sex"
  .InsertNTString "profile\age"
  .InsertNTString "profile\location"
  .InsertNTString "profile\description"
  .InsertNTString frmProfile.TXTSex.Text 'Sex
  .InsertNTString frmProfile.txtAge.Text 'Age
  .InsertNTString frmProfile.txtLocation.Text 'Location
  .InsertNTString frmProfile.txtDesc.Text 'Description
  .SendPacket frmMain.bnetsocket, &H27

Me.Hide
End With
End Sub
[/code]

0x27.


[code]
Public Function ProfileDecode(data As String)
Dim Values(1 To 18) As String
KeyCount = Packet.GetDWORD(Mid(data, 9, 4))
asfrom = Mid(data, 1, 17)
For i = 1 To KeyCount - 1
    Values(i) = Mid(asfrom, 1, InStr(asfrom, Chr(0)) - 1)
    asfrom = Mid(asfrom, InStr(asfrom, Chr(0)) + 1)
  If i > 4 Then
      If Values(i) = "" Then Values(i) = 0
      End If
[/code]

To decode it. Now when i tell it to display it (for tests), it comes as "". Ideas?
April 25, 2005, 6:23 PM
UserLoser.
[quote author=QwertyMonster link=topic=11387.msg109872#msg109872 date=1114453402]
[code]
Public Function GetProfile(Username As String)
Dim SplitProfile() As String
Dim profileend As String
SplitProfile = Split(profileend, Chr(0))
Packet.InsertDWORD 1
Packet.InsertDWORD 3
Packet.InsertDWORD &H26
Packet.InsertNTString Username
Packet.InsertNTString "profile\sex"
Packet.InsertNTString "profile\location"
Packet.InsertNTString "profile\description"
Packet.SendPacket frmMain.bnetsocket, &H26
End Function
[/code]
[/quote]

Um, wtf.  What you're doing before calling the Insert* functions seems kind of useless...
April 26, 2005, 2:10 AM
Adron
I think your packet log is wrong. Do it again, and snip out the header parts of the packets.
April 26, 2005, 10:38 AM
Ringo
Send26 "RATS", "Username"

In a Modual..
[code]Public Function Send26(Client As String, Name As String)
With Buffer
  .InsertDWORD &H1
  Select Case Client
    Case "RATS", "PXES", "RTSJ", "RHSS"
      .InsertDWORD &H13 'num of strings
      .InsertDWORD &H2 'Request ID
      .InsertNTString Name
      .InsertNTString GetPS
      .InsertNTString GetSS(Client, 0)
      .InsertNTString GetSS(Client, 1)
  End Select
  .InsertBYTE &H0
  .SendPacket &H26
End With
End Function

Public Function GetPS() As String
Dim PS As String
PS = "profile\"
GetPS = PS & "Sex" & Chr(0)
GetPS = GetPS & PS & "age" & Chr(0)
GetPS = GetPS & PS & "location" & Chr(0)
GetPS = GetPS & PS & "description"
End Function
Public Function GetSS(Client As String, StatValue As String) As String
Dim SS As String
SS = "Record\" & Client & "\" & StatValue & "\"
GetSS = SS & "wins" & Chr(0)
GetSS = GetSS & SS & "losses" & Chr(0)
GetSS = GetSS & SS & "disconnects" & Chr(0)
If StatValue = 1 Or StatValue = 3 Then '3 for W2BN
GetSS = GetSS & SS & "rating" & Chr(0)
GetSS = GetSS & SS & "high rating" & Chr(0)
GetSS = GetSS & "DynKey\" & Client & "\" & StatValue & "\" & "rank" & Chr(0)
GetSS = GetSS & SS & "high rank" & Chr(0)
End If
GetSS = GetSS & SS & "last game" & Chr(0)
GetSS = GetSS & SS & "last game result"
End Function
[/code]


For parseing:
[code]   
Case &H26
      Select Case Mid(data, 9, 1)
        Case Chr(2) 'Request ID
        'i think ur trying to do it like this:
        Dim Values(1 To 18) As String
        KeyCount = Buffer.GetDWORD(Mid(data, 9, 4))
        asfrom = Mid(data, 17)
        For i = 1 To KeyCount - 1
           Values(i) = Mid(asfrom, 1, InStr(asfrom, Chr(0)) - 1)
           asfrom = Mid(asfrom, InStr(asfrom, Chr(0)) + 1)
        Next i

MsgBox Values(1) & vbCrLf & Values(2) & vbCrLf & Values(3) & vbCrLf & Values(4) & vbCrLf & Values(5) & vbCrLf & Values(6) & vbCrLf & Values(7) & vbCrLf & Values(8) & vbCrLf & Values(9) & vbCrLf & Values(10) & vbCrLf & Values(11) & vbCrLf & Values(12) & vbCrLf & Values(13) & vbCrLf & Values(14) & vbCrLf & Values(15) & vbCrLf & Values(16) & vbCrLf & Values(17) & vbCrLf & Values(18)

      End Select
[/code]

There are much better ways of spliting the data, seems as the strings are returned in the order you requested them and split by null bytes, a simple Variant split would be best.

(Above code = untested)
April 26, 2005, 4:42 PM
Spilled[DW]
First off, as userloser said at the top of the sub what your doing is useless and show us a useful packetlog would make it much more likely in helping you find your problem.
April 26, 2005, 4:49 PM
QwertyMonster
Thanks Ringo for the code. But im more looking for it to do a 3 value. I've been having a go at it, im not asking for code so i can copy and paste, im just in a big muddle atm. Could you post some code for examples? All help is thanks.
April 26, 2005, 5:05 PM
Ringo
[code]
Command1_click()
Send26 "Username"
end sub



Public Function Send26(Name As String)
With Buffer
  .InsertDWORD &H1
  .InsertDWORD &H4 'num of strings
  .InsertDWORD &H2 'Request ID
  .InsertNTString Name 'name to view profile
  .InsertNTString GetPP 'see below
  .InsertBYTE &H0
  .SendPacket &H26
End With
End Function

Public Function GetPP() As String
Dim PP As String
PP = "profile\"
GetPP = PP & "Sex" & Chr(0)
GetPP = GetPP & PP & "location" & Chr(0)
GetPP = GetPP & PP & "description"
End Function
[/code]


Now the request has been sent to the server...

In your parse under your case &H26:

[code]
Case &H26
Dim Values(1 To 3) As String
KeyCount = Buffer.GetDWORD(Mid(data, 9, 4))
asfrom = Mid(data, 17)
For i = 1 To KeyCount - 1
    Values(i) = Mid(asfrom, 1, InStr(asfrom, Chr(0)) - 1)
    asfrom = Mid(asfrom, InStr(asfrom, Chr(0)) + 1)
Next i

txtsex.text = values(1)
txtlocation.text = values(2)
txtdescription.text = values(3)
[/code]

Probly a better way:
(Index ur objects)

[code]
Case &H26
Dim Values as variant
Dim i as Integer
asfrom = Mid(data, 17) 'start of strings
values = split(asfrom, chr(0)) 'split values from data
for i = Lbound(Values) to Ubound(Values)
  Objects(i).text = values(i)
next i
[/code]

Objects(i) would be in the order u sent* them.
(Say Objects was a text box)
textbot1(0).text will be sex
textbot1(1).text will be location
textbot1(2).text will be discription

Hope this helps.

Ringo.
April 26, 2005, 5:24 PM
Archangel
Code don't help that much, but w/e.
April 26, 2005, 5:29 PM
Spilled[DW]
Coding just adds to the source stealing community, try writing your own code if you really want to learn. Otherwise you will never understand what your working with, but meh your problem.
April 26, 2005, 5:34 PM
QwertyMonster
People think when code is posted, they will steal. Half the bots out there, actually MOST of them have atleast ONE copied and pasted bit of code. Im not actually copying and pasting, but i have used copied / pasted code, only once though, as far as i know.

@Ringo: Thanks for explaining how to do it. That code really explains to me how its used etc..

- Thanks Ringo.

Edit: Dont take this post as a bm post.

Edit 2: Ok after a few errors and ipbans :P i have finally got there! I havent copied / pasted his code *much*. But the parts i have, i have read through so i understand, so when i come to re-write things i will know how it works. Thanks to all who have helped!
April 26, 2005, 5:38 PM

Search