Valhalla Legends Forums Archive | .NET Platform | [VB.NET] Packet Buffer Class?

AuthorMessageTime
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
June 18, 2004, 3:58 AM
Myndfyr
[quote author=BaDDBLooD link=board=37;threadid=7303;start=0#msg65803 date=1087531116]
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
[/quote]

Translate the class here to VB .NET:

https://davnit.net/bnet/vL/phpbbs/index.php?board=17;action=display;threadid=4150;start=msg34300#msg34300
June 18, 2004, 4:15 AM
BaDDBLooD
how :O
June 18, 2004, 4:19 AM
Stealth
Maybe by learning VB.NET? ;)
June 18, 2004, 5:41 AM
BaDDBLooD
.. i am still learning .net Commands =\
June 18, 2004, 1:29 PM
Myndfyr
[quote author=BaDDBLooD link=board=37;threadid=7303;start=0#msg65851 date=1087565351]
.. i am still learning .net Commands =\
[/quote]

Your VB .NET compiler command is:

vbc <arguments> <file-name>
June 19, 2004, 12:11 AM
BaDDBLooD
what does that have to do with converting the class?
June 19, 2004, 12:16 AM
Myndfyr
[quote author=BaDDBLooD link=board=37;threadid=7303;start=0#msg65952 date=1087604186]
what does that have to do with converting the class?
[/quote]

Absoultely nothing. You said that you were still learning .net commands. That's one of the basic ones. -_-
June 19, 2004, 9:03 AM
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
June 19, 2004, 2:00 PM
BaDDBLooD
K, this is where i am ( Thanks to a Cooperative effort of me and my friend )

[code]

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

[/code]

Where is "writepacket" ??

June 25, 2004, 1:54 PM
Newby
Almost three topics down .. this? :/
June 25, 2004, 7:34 PM
BaDDBLooD
[quote author=Newby link=board=37;threadid=7303;start=0#msg67175 date=1088192081]
Almost three topics down .. this? :/
[/quote]

If you try that, you'll realize it doesn't work.
June 26, 2004, 2:36 AM

Search