Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: Abolition on September 24, 2006, 12:40 PM

Title: S -> C 0x50?
Post by: Abolition on September 24, 2006, 12:40 PM
Hey!
I've been learning for some time (Visual Basic) now and decided to make a bot some weeks ago.
I know how to read and send packets and etc.
My problem: I don't seem to receive 0x50 back from B.net.
I receive 0x25 but not 0x50.
Maybe packets are merging together or something is wrong?

Help would be appreciated.
Title: Re: S -> C 0x50?
Post by: Warrior on September 24, 2006, 12:41 PM
It's going to be difficult to help you out unless you atleast post what order you're sending your packets in.

Title: Re: S -> C 0x50?
Post by: Abolition on September 24, 2006, 12:43 PM
Quote from: Warrior on September 24, 2006, 12:41 PM
It's going to be difficult to help you out unless you atleast post what order you're sending your packets in.
I've connected to BNLS.
Sent 0x0E to BNLS.
Received a response.
I connected to Bnet..sent 0x01.
I then sent 0x50.
I received 0x25.
That's where I'm stuck.
Title: Re: S -> C 0x50?
Post by: l2k-Shadow on September 24, 2006, 01:03 PM
probably sending your 0x50 wrong then, showing the code would help us pinpoint the error.
Title: Re: S -> C 0x50?
Post by: Abolition on September 24, 2006, 01:12 PM
Quote from: l2k-Shadow on September 24, 2006, 01:03 PM
probably sending your 0x50 wrong then, showing the code would help us pinpoint the error.

PacketBuf.InsertDWORD &H0
PacketBuf.InsertDWORD &H49583836 'IX86
PacketBuf.InsertDWORD &H53455850 'SEXP
PacketBuf.InsertDWORD &HCF 'Verbyte
PacketBuf.InsertDWORD &H0
PacketBuf.InsertDWORD &H0
PacketBuf.InsertDWORD &H0
PacketBuf.InsertDWORD &H0
PacketBuf.InsertDWORD &H0
PacketBuf.InsertNTString "CAN" 'Country Abbr.
PacketBuf.InsertNTString "Canada" 'Country Name
PacketBuf.SendPacket Winsock2, &H50
AddChat vbYellow, "Sent: 0x50"

PacketBuf is my Packet Buffer.
Title: Re: S -> C 0x50?
Post by: Mystical on September 24, 2006, 02:00 PM
Winsock2 is your sck_BNET or sck_BNLS?
Title: Re: S -> C 0x50?
Post by: Abolition on September 24, 2006, 02:01 PM
Quote from: Mystical on September 24, 2006, 02:00 PM
Winsock2 is your sck_BNET or sck_BNLS?

Winsock2 is my winsock to BNET.
Title: Re: S -> C 0x50?
Post by: Mystical on September 24, 2006, 02:10 PM
maybe its in your packetbuffer.. :|
Title: Re: S -> C 0x50?
Post by: Abolition on September 24, 2006, 02:15 PM
I used DarkMinion's packet buffer   ???
Title: Re: S -> C 0x50?
Post by: Mystical on September 24, 2006, 02:17 PM
that's one old packetbuffer.. :P I don't remember if hmm, i forgot.. stupid moment.
Title: Re: S -> C 0x50?
Post by: l2k-Shadow on September 24, 2006, 02:39 PM
well your 0x50 looks correct, i think then that your error must be in your Winsock_DataArrival() sub. most likely not parsing clumped packets correctly.
Title: Re: S -> C 0x50?
Post by: Warrior on September 24, 2006, 02:53 PM
How can he get a clumped packet so early on?

You may be right about his DataArrival parsing being wrong however.
Title: Re: S -> C 0x50?
Post by: topaz on September 24, 2006, 03:17 PM
Are you sending the protocol byte?
Title: Re: S -> C 0x50?
Post by: l2k-Shadow on September 24, 2006, 03:40 PM
Quote from: Warrior on September 24, 2006, 02:53 PM
How can he get a clumped packet so early on?

You may be right about his DataArrival parsing being wrong however.

Well I sometimes get 0x25 and 0x50 clumped at the beginning, so it is a possibility. I don't think it's the protocol byte because then he wouldn't receive 0x25. So then it's either bad parsing or bad packet buffer.
Title: Re: S -> C 0x50?
Post by: Spilled on September 24, 2006, 05:22 PM
Your best bet is that they ARE being clumped as Shadow said, Please post your dataarrival and a packet log to help us find the solution
Title: Re: S -> C 0x50?
Post by: Abolition on September 24, 2006, 05:36 PM
Eh, I found that that was my Data_Arrival sub...

I got this(I found this sub on this forum):

Private Sub Winsock2_DataArrival(ByVal bytesTotal As Long)
    Static PktBuff As String 'Packet Buffer
    Dim Incoming As String
    Dim PacketLength As Long
    Winsock2.GetData Incoming, vbString, bytesTotal
    PktBuff = PktBuff & Incoming
   
    While Len(PktBuff) > 3
        PacketLength = GetWord(Mid$(PktBuff, 3, 2))
        If Len(PktBuff) < PacketLength Then Exit Sub
        ParseData Left(PktBuff, PacketLength))
        PktBuff = Mid(PktBuff, PacketLength + 1)
    Wend
End Sub


When I run it, I get a type mismatch error... it highlights this line:

ParseData Left(PktBuff, PacketLength))


ParseData is another sub that takes my packets and, like the name explains, parse packets.
Title: Re: S -> C 0x50?
Post by: l2k-Shadow on September 24, 2006, 05:38 PM
you have an extra ) at the end ::)
Title: Re: S -> C 0x50?
Post by: Abolition on September 24, 2006, 05:40 PM
Quote from: l2k-Shadow on September 24, 2006, 05:38 PM
you have an extra ) at the end ::)

Sorry, I made a mistake in my post. It was supposed be:

ParseData (Left(PktBuff, PacketLength))


I still get the same error.
Title: Re: S -> C 0x50?
Post by: l2k-Shadow on September 24, 2006, 05:43 PM
Then your ParseData is looking for something other than a string.
Title: Re: S -> C 0x50?
Post by: Abolition on September 24, 2006, 05:47 PM
Here is my ParseData sub.
It was just a test to see if I received the packets correctly.

Public Sub ParseData(PacketID As Long)
'Parsing
Select Case PacketID
Case &H25
AddChat vbYellow, "Received: 0x25"
Case &H50
AddChat vbYellow, "Received: 0x50"
End Select
End Sub
Title: Re: S -> C 0x50?
Post by: l2k-Shadow on September 24, 2006, 06:20 PM
Quote from: Abolition on September 24, 2006, 05:47 PM
Here is my ParseData sub.
It was just a test to see if I received the packets correctly.

Public Sub ParseData(PacketID As Long)
'Parsing
Select Case PacketID
Case &H25
AddChat vbYellow, "Received: 0x25"
Case &H50
AddChat vbYellow, "Received: 0x50"
End Select
End Sub


Exactly, your ParseData is expecting a Long, but Left$() returns a String.
Title: Re: S -> C 0x50?
Post by: Cat Food on September 24, 2006, 07:29 PM
Quote from: Abolition on September 24, 2006, 05:40 PM
Quote from: l2k-Shadow on September 24, 2006, 05:38 PM
you have an extra ) at the end ::)

Sorry, I made a mistake in my post. It was supposed be:

ParseData (Left(PktBuff, PacketLength))


I still get the same error.


Not exactly how I would do things but you can try
ParseData (Val#(Left$(PktBuff, PacketLength)))

But by the looks of this you arn't extracting the packet ID to begin with. So I have a feeling you are going to have a lot more problems in the future.
Title: Re: S -> C 0x50?
Post by: FrostWraith on September 24, 2006, 07:55 PM
Dear God, just post a packet log.
Title: Re: S -> C 0x50?
Post by: l2k-Shadow on September 24, 2006, 08:47 PM
Quote from: ImaWh0re on September 24, 2006, 07:29 PM
Quote from: Abolition on September 24, 2006, 05:40 PM
Quote from: l2k-Shadow on September 24, 2006, 05:38 PM
you have an extra ) at the end ::)

Sorry, I made a mistake in my post. It was supposed be:

ParseData (Left(PktBuff, PacketLength))


I still get the same error.


Not exactly how I would do things but you can try
ParseData (Val#(Left$(PktBuff, PacketLength)))

But by the looks of this you arn't extracting the packet ID to begin with. So I have a feeling you are going to have a lot more problems in the future.

Yes! Use Val#() on a string, excellent suggestion.
Title: Re: S -> C 0x50?
Post by: Eric on September 24, 2006, 09:13 PM
Click (http://www.amazon.com/Visual-Basic-6-Dummies-Windows/dp/0764503707/sr=8-2/qid=1159150390/ref=pd_bbs_2/102-4734669-2508922?ie=UTF8&s=books).
Title: Re: S -> C 0x50?
Post by: topaz on September 24, 2006, 09:18 PM
Quote from: Lord[nK] on September 24, 2006, 09:13 PM
Click (http://www.amazon.com/Visual-Basic-6-Dummies-Windows/dp/0764503707/sr=8-2/qid=1159150390/ref=pd_bbs_2/102-4734669-2508922?ie=UTF8&s=books).

I own a copy, I'll sell it for $15.
Title: Re: S -> C 0x50?
Post by: FrostWraith on September 24, 2006, 09:58 PM
I have it too lol. Not useful anymore. Il sell for $10.
Title: Re: S -> C 0x50?
Post by: Cat Food on September 24, 2006, 11:54 PM
Quote from: l2k-Shadow on September 24, 2006, 08:47 PM
Quote from: ImaWh0re on September 24, 2006, 07:29 PM
Quote from: Abolition on September 24, 2006, 05:40 PM
Quote from: l2k-Shadow on September 24, 2006, 05:38 PM
you have an extra ) at the end ::)

Sorry, I made a mistake in my post. It was supposed be:

ParseData (Left(PktBuff, PacketLength))


I still get the same error.


Not exactly how I would do things but you can try
ParseData (Val#(Left$(PktBuff, PacketLength)))

But by the looks of this you arn't extracting the packet ID to begin with. So I have a feeling you are going to have a lot more problems in the future.

Yes! Use Val#() on a string, excellent suggestion.

Dear MORON,
  Msgbox Val#("23")
Title: Re: S -> C 0x50?
Post by: Mystical on September 25, 2006, 12:04 AM
Quote from: Abolition on September 24, 2006, 05:47 PM
Here is my ParseData sub.
It was just a test to see if I received the packets correctly.

Public Sub ParseData(PacketID As Long)
'Parsing
Select Case PacketID
Case &H25
AddChat vbYellow, "Received: 0x25"
Case &H50
AddChat vbYellow, "Received: 0x50"
End Select
End Sub



maybe somthing like?

Public Sub ParseData(Data as String)

   Dim PacketID As Byte
       PacketID = Asc(Mid(Data, 2, 1))
   
          Select Case PacketID

                     Case &H25

                     Case &H50

                     Case &H51

           End Select

End Sub

Title: Re: S -> C 0x50?
Post by: l2k-Shadow on September 25, 2006, 12:08 AM
Quote from: ImaWh0re on September 24, 2006, 11:54 PM
Quote from: l2k-Shadow on September 24, 2006, 08:47 PM
Quote from: ImaWh0re on September 24, 2006, 07:29 PM
Quote from: Abolition on September 24, 2006, 05:40 PM
Quote from: l2k-Shadow on September 24, 2006, 05:38 PM
you have an extra ) at the end ::)

Sorry, I made a mistake in my post. It was supposed be:

ParseData (Left(PktBuff, PacketLength))


I still get the same error.


Not exactly how I would do things but you can try
ParseData (Val#(Left$(PktBuff, PacketLength)))

But by the looks of this you arn't extracting the packet ID to begin with. So I have a feeling you are going to have a lot more problems in the future.

Yes! Use Val#() on a string, excellent suggestion.

Dear MORON,
  Msgbox Val#("23")


Yes, however, Left$(PktBuff, PacketLength) does not return a number.
Title: Re: S -> C 0x50?
Post by: Cat Food on September 25, 2006, 12:16 AM
Quote from: l2k-Shadow on September 25, 2006, 12:08 AM
Yes, however, Left$(PktBuff, PacketLength) does not return a number.

Msgbox Val#(Left$("23",2))

Better? Comprende?
Title: Re: S -> C 0x50?
Post by: topaz on September 25, 2006, 12:31 AM
Quote from: ImaWh0re on September 25, 2006, 12:16 AM
Quote from: l2k-Shadow on September 25, 2006, 12:08 AM
Yes, however, Left$(PktBuff, PacketLength) does not return a number.

Msgbox Val#(Left$("23",2))

Better? Comprende?

The point is, you're not supposed to do it. Val# returns a Double (which is a float, iirc), whereas it expects a Long.
Title: Re: S -> C 0x50?
Post by: Spilled on September 25, 2006, 12:39 AM
Quote from: ImaWh0re on September 25, 2006, 12:16 AM
Quote from: l2k-Shadow on September 25, 2006, 12:08 AM
Yes, however, Left$(PktBuff, PacketLength) does not return a number.

Msgbox Val#(Left$("23",2))

Better? Comprende?

Val:
http://msdn2.microsoft.com/en-us/library/k7beh1x9.aspx

CLng:
http://msdn2.microsoft.com/en-us/library/ck4c5842.aspx

hrmm i wonder....
Title: Re: S -> C 0x50?
Post by: Cat Food on September 25, 2006, 03:07 AM
Quote from: topaz on September 25, 2006, 12:31 AM
Quote from: ImaWh0re on September 25, 2006, 12:16 AM
Quote from: l2k-Shadow on September 25, 2006, 12:08 AM
Yes, however, Left$(PktBuff, PacketLength) does not return a number.

Msgbox Val#(Left$("23",2))

Better? Comprende?

The point is, you're not supposed to do it. Val# returns a Double (which is a float, iirc), whereas it expects a Long.

That it does, I was just trying to state that it doesn't matter if you do that to a string. As I said before the coding was whacked. By the way, I find it very funny how you people look this up before saying something, it's like its battle of the wits after googling information. I'm not flaming any person when I say that either, just saying.


Although yes it should of been common sense on my part. I was wrong, I don't have a problem admitting to that unlike a lot of people.
Title: Re: S -> C 0x50?
Post by: topaz on September 25, 2006, 08:40 AM
Quote from: ImaWh0re on September 25, 2006, 03:07 AM
That it does, I was just trying to state that it doesn't matter if you do that to a string. As I said before the coding was whacked. By the way, I find it very funny how you people look this up before saying something, it's like its battle of the wits after googling information. I'm not flaming any person when I say that either, just saying.

Of course, we don't like making up stuff.