• Welcome to Valhalla Legends Archive.
 

[VB.NET] Packet Buffer Class?

Started by BaDDBLooD, June 17, 2004, 10:58 PM

Previous topic - Next topic

BaDDBLooD

Anyone have a Working Packetbuffer class.. i can't seem to get a old vb6 one working in vb.net

Or just a little help on what i need to convert, and maybe i can figure it out after a little bit of work ^_^

Thanks again

- BaDDBLooD
There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

MyndFyre

Quote from: BaDDBLooD on June 17, 2004, 10:58 PM
Anyone have a Working Packetbuffer class.. i can't seem to get a old vb6 one working in vb.net

Or just a little help on what i need to convert, and maybe i can figure it out after a little bit of work ^_^

Thanks again

- BaDDBLooD

Translate the class here to VB .NET:

http://forum.valhallalegends.com/phpbbs/index.php?board=17;action=display;threadid=4150;start=msg34300#msg34300
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

BaDDBLooD

There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

Stealth

- Stealth
Author of StealthBot

BaDDBLooD

.. i am still learning .net Commands =\
There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

MyndFyre

Quote from: BaDDBLooD on June 18, 2004, 08:29 AM
.. i am still learning .net Commands =\

Your VB .NET compiler command is:

vbc <arguments> <file-name>
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

BaDDBLooD

what does that have to do with converting the class?
There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

MyndFyre

Quote from: BaDDBLooD on June 18, 2004, 07:16 PM
what does that have to do with converting the class?

Absoultely nothing.  You said that you were still learning .net commands.  That's one of the basic ones.  -_-
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

BaDDBLooD

haha well

How would i go about Converting a vb packetbuffer, for convienence let's say Dark Minion.

What things am i going to need to convert
There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

BaDDBLooD

K, this is where i am ( Thanks to a Cooperative effort of me and my friend )



Imports System
Imports System.Collections
Imports System.Text

Namespace BaDDChaT

   Enum Medium
       BNLS
       BattleNet
       Realm
   End Enum

   Friend MustInherit Class Packet

       Protected alBuffer As ArrayList
       Protected m_packetId As Byte
       Protected m_medium As Medium

       Private Sub New()
           Me.alBuffer = New ArrayList(3)
       End Sub

       Protected Sub New(ByVal PacketID As Byte, ByVal ServerType As Medium)
           m_packetId = PacketID
           m_medium = ServerType
       End Sub

       Public ReadOnly Property ServerType() As Medium
           Get
               Return m_medium
           End Get
       End Property

       Public ReadOnly Property PacketID() As Byte
           Get
               Return m_packetId
           End Get
       End Property

       Public Overridable Sub InsertDWORDArray(ByVal DWORDList() As Integer)
           Dim i As Integer
           For Each i In DWORDList
               InsertDWORD(i)
           Next i
       End Sub

       Public Overridable Sub InsertDWORD(ByVal DWORD As Integer)
           InsertBYTEArray(BitConverter.GetBytes(DWORD))
       End Sub

       Public Overridable Sub InsertWORD(ByVal WORD As Short)
           InsertBYTEArray(BitConverter.GetBytes(WORD))
       End Sub

       Public Overridable Sub InsertWORDArray(ByVal WORDList() As Short)
           Dim s As Short
           For Each s In WORDList
               InsertWORD(s)
           Next s
       End Sub

       Public Overridable Sub InsertBYTE(ByVal [BYTE] As Byte)
           Me.alBuffer.Add([BYTE])
       End Sub

       Public Overridable Sub InsertBYTEArray(ByVal BYTEList() As Byte)
           Dim b As Byte
           For Each b In BYTEList
               InsertBYTE(b)
           Next b
       End Sub

       Public Overridable Sub InsertNTString(ByVal str As String)
           InsertBYTEArray(Encoding.ASCII.GetBytes(str))
           If CByte(Me.alBuffer((Me.alBuffer.Count - 1))) <> &HB Then
               InsertBYTE(0)
           End If
       End Sub

       Public Overridable Sub InsertNonNTString(ByVal str As String)
           Dim car(str.Length) As Char
           Dim i As Integer
           For i = 0 To str.Length - 1
               car(i) = i.ToString
           Next i
           InsertBYTEArray(Encoding.ASCII.GetBytes(car))
       End Sub


       Public Sub Clear()
           Me.alBuffer.Clear()
       End Sub

   Friend NotInheritable Class BNLSPacket

       Inherits Packet

       Public Sub New(ByVal PacketID As Byte)
           MyBase.New(PacketID, Medium.BNLS)
       End Sub

       Public ReadOnly Property Length() As Short
           Get
               Return CShort(Me.alBuffer.Count + 3)
           End Get
       End Property


       Public ReadOnly Property Data() As Byte()
           Get
               Return Me.ToSend()
           End Get
       End Property


       Private Function ToSend() As Byte()
           Dim al As New ArrayList(Me.alBuffer)
           al.InsertRange(0, BitConverter.GetBytes(Me.Length))
           al.Insert(2, Me.PacketID)

           Dim data(al.Count) As Byte
           al.CopyTo(0, data, 0, al.Count)

           Return data
       End Function


       Public Overrides Sub InsertNonNTString(ByVal str As String)
           Dim car(str.Length) As Char
           Dim i As Integer
           For i = 0 To str.Length - 1
               car(i) = i.ToString
           Next i
           InsertBYTEArray(Encoding.ASCII.GetBytes(car))
       End Sub


       Public Overrides Sub InsertNTString(ByVal str As String)
           InsertBYTEArray(Encoding.ASCII.GetBytes(str))
           If CByte(Me.alBuffer((Me.alBuffer.Count - 1))) <> &H0 Then
               InsertBYTE(0)
           End If
       End Sub
   End Class

   Friend NotInheritable Class BnetPacket
       Inherits Packet

       Public Sub New(ByVal PacketID As Byte)
           MyBase.New(PacketID, Medium.BattleNet)
       End Sub

       Public ReadOnly Property Data() As Byte()
           Get
               Return Me.ToSend()
           End Get
       End Property

       Public ReadOnly Property Length() As Short
           Get
               Return CShort(Me.alBuffer.Count + 4)
           End Get
       End Property


       Private Function ToSend() As Byte()
           Dim al As New ArrayList(Me.alBuffer)
           al.Insert(0, CByte(&HFF))
           al.Insert(1, Me.PacketID)
           al.InsertRange(2, BitConverter.GetBytes(Me.Length))
           Dim data(al.Count) As Byte
           al.CopyTo(0, data, 0, al.Count)

           Return data
       End Function

       Public Overrides Sub InsertNTString(ByVal str As String)
           InsertBYTEArray(Encoding.UTF8.GetBytes(str))
           If CByte(Me.alBuffer((Me.alBuffer.Count - 1))) <> &H0 Then
               InsertBYTE(0)
           End If
       End Sub

       Public Overrides Sub InsertNonNTString(ByVal str As String)
           Dim car(str.Length) As Char
           InsertBYTEArray(Encoding.UTF8.GetBytes(car))
       End Sub
   End Class
End Namespace



Where is "writepacket" ??

There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

Newby

Almost three topics down .. this? :/
- Newby

Quote[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

Quote<TehUser> Man, I can't get Xorg to work properly.  This sucks.
<torque> you should probably kill yourself
<TehUser> I think I will.  Thanks, torque.

BaDDBLooD

Quote from: Newby on June 25, 2004, 02:34 PM
Almost three topics down .. this? :/

If you try that, you'll realize it doesn't work.
There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.