• Welcome to Valhalla Legends Archive.
 

Viewing A Starcraft Profile

Started by QwertyMonster, April 25, 2005, 11:37 AM

Previous topic - Next topic

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.


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

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.

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.

QwertyMonster

#2
Sorry about the data. I forgot the top line.


Public Function ProfileDecode(data As String)


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


Recv:

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



VIEWING MY PROFILE.

Recv:

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


Send:

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

Hdx

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)~-~

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

QwertyMonster

Yes 0x26 is.


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


0x26.



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


0x27.



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


To decode it. Now when i tell it to display it (for tests), it comes as "". Ideas?

UserLoser.

Quote from: QwertyMonster on April 25, 2005, 01:23 PM

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


Um, wtf.  What you're doing before calling the Insert* functions seems kind of useless...

Adron

I think your packet log is wrong. Do it again, and snip out the header parts of the packets.

Ringo

#7
Send26 "RATS", "Username"

In a Modual..
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



For parseing:
   
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


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)

Spilled

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.

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.

Ringo

#10

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



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

In your parse under your case &H26:


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)


Probly a better way:
(Index ur objects)


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


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.

Archangel

Code don't help that much, but w/e.
I'm not an Addict.

Spilled

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.

QwertyMonster

#13
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!