VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "UDP"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Private buffer As String
Public Function InsertDWORDArray(Data() As Long)
    Dim I As Integer
    For I = LBound(Data) To UBound(Data) Step 1
        buffer = buffer & MakeDWORD(Data(I))
    Next I
End Function
Public Function InsertDWORD(Data As Long)
    buffer = buffer & MakeDWORD(Data)
End Function
Public Function InsertData(Data As String)
    buffer = buffer & Data
End Function
Public Function InsertWORD(Data As Integer)
    buffer = buffer & MakeWORD(Data)
End Function
Public Function InsertBYTE(Data As Integer)
    buffer = buffer & Chr(Data)
End Function
Public Sub InsertBytes(Data As String)
    Dim I As Long
    Dim enqueueer As String
    For I = 1 To Len(Data) Step 3
        enqueueer = enqueueer & Chr(Val("&h0" & Mid(Data, I, 2)))
    Next I
    buffer = buffer & enqueueer
End Sub
Public Function InsertNTString(Data As String)
    buffer = buffer & Data & Chr(0)
End Function
Public Function InsertNonNTString(Data As String)
    buffer = buffer & Data
End Function
Function MakeDWORD(Value As Long) As String
    Dim Result As String * 4
    CopyMemory ByVal Result, Value, 4
    MakeDWORD = Result
End Function
Function MakeWORD(Value As Integer) As String
    Dim Result As String * 2
    CopyMemory ByVal Result, Value, 2
    MakeWORD = Result
End Function
Public Function Clear()
    buffer = ""
End Function
Public Function SendPacket(PacketID As Byte)
If PacketScreen = True Then
    If Len(Hex(PacketID)) = 1 Then
        AddC True, Form8.TALK, vbRed, "[Battle.net (UDP)]: C => S: 0x0" & Hex(PacketID)
    Else
        AddC True, Form8.TALK, vbRed, "[Battle.net (UDP)]: C => S: 0x" & Hex(PacketID)
    End If
End If
Dim PacketData As String
Dim packet As String
If MDIForm1.Winsock.State <> sckConnected Then Exit Function
If MDIForm1.socketudp.State <> sckConnected Then Exit Function
buffer = Chr(PacketID) & buffer
MDIForm1.socketudp.SendData MakeWORD(Len(buffer) + 2) & buffer
BytesSent = BytesSent + Len(MakeWORD(Len(buffer) + 2) & buffer)
PacketsSent = PacketsSent + 1
Clear
End Function

