[HELP] Makeing a hax for a game useing packets/sockets

10/20/2009 08:00 Qvintus#1
Hello you might have seen my other post, where i was trying to finde out how to use packets/sockets.
Anyways i think i'm almost there, and now i need some once help to fix a few errors. Please look at this peace of code =)

Imports:
Code:
Imports System.IO
Imports System.Net
Imports System.Net.Sockets
Imports System.Threading
Imports Microsoft.VisualBasic
Imports System.Text
Imports System.Runtime.InteropServices
Work space:
Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Public Sub Connect( _
     ByVal host As String, _
     ByVal port As Integer _
 )

    End Sub

Public Function Send( _
        ByVal buffer As Byte(), _
        ByVal offset As Integer, _
        ByVal size As Integer, _
        ByVal socketFlags As SocketFlags, _
        <OutAttribute()> ByRef errorCode As SocketError _
    ) As Integer


    End Function
    Public Shared Function hotkeySend1(ByVal Pro As Socket) As Integer
        Dim msg As Byte() = Encoding.ASCII.GetBytes("00 0C 00 23 62 65 61 6D 20 6D 65 20 75 70")
        Dim bytes(4) As Byte
        Try
            Dim byteCount As Integer = Pro.Send(msg, 0, msg.Length, SocketFlags.None)
            byteCount = Pro.Receive(bytes, 0, Pro.Available, SocketFlags.None)
        Catch e As SocketException
            Return e.ErrorCode

        End Try
        Return 0
    End Function

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim Pro As Socket = 
        Dim host As String
        Dim port As Integer
        Dim msg As Byte() = Encoding.ASCII.GetBytes("00 0C 00 23 62 65 61 6D 20 6D 65 20 75 70")
        Dim bytes(4) As Byte
        Dim hotkey1 As Boolean
        Dim hotkey2 As Boolean
        Dim hotkey3 As Boolean
        Dim hotkey4 As Boolean

        hotkey1 = GetAsyncKeyState(Keys.NumPad1)
        hotkey2 = GetAsyncKeyState(Keys.NumPad2)
        hotkey3 = GetAsyncKeyState(Keys.NumPad3)
        hotkey4 = GetAsyncKeyState(Keys.NumPad5)
        host = ("213.152.3.5")
        port = 2000
        If hotkey1 = True Then
            Pro.Connect(host, port)
            Pro.Send(msg, 0, msg.Length, SocketFlags.None)

        End If
    End Sub
Error: (When "Timer1_Tick" don't have "ByVal Pro As Socket" is indicated)
Code:
Error    1    Expression expected.    C:\Documents and Settings\Qvintus\Skrivebord\VB\EL\EL Fruit Master\EL Fruit Master\Form1.vb    75    27    EL Fruit Master
Error    2    Name 'Pro' is not declared.    C:\Documents and Settings\Qvintus\Skrivebord\VB\EL\EL Fruit Master\EL Fruit Master\Form1.vb    92    13    EL Fruit Master
Error    3    Name 'Pro' is not declared.    C:\Documents and Settings\Qvintus\Skrivebord\VB\EL\EL Fruit Master\EL Fruit Master\Form1.vb    93    13    EL Fruit Master
Error: (When "Timer1_Tick" have "ByVal Pro As Socket" indicated, and deleted "Dim Pro As Socket")
Code:
Error    1    Method 'Private Sub Timer1_Tick(Pro As System.Net.Sockets.Socket, sender As Object, e As System.EventArgs)' cannot handle event 'Public Event Tick(sender As Object, e As System.EventArgs)' because they do not have a compatible signature.    C:\Documents and Settings\Qvintus\Skrivebord\VB\EL\EL Fruit Master\EL Fruit Master\Form1.vb    74    125    EL Fruit Master
Please help me out if you know what i'm doing wrong. :handsdown:
10/23/2009 23:15 Qvintus#2
I remade the program, as it seemed to suck :(.. anyways i came up with some new code please look at it =)

The UDP Version

Code:
[COLOR="Blue"]Imports[/COLOR] System.Net.Sockets
[COLOR="Blue"]Imports[/COLOR] System.IO
[COLOR="Blue"]Imports[/COLOR] System.Threading
[COLOR="Blue"]Imports[/COLOR] System.Net
[COLOR="Blue"]Imports[/COLOR] System.Text
Code:
[COLOR="Blue"]Public Class[/COLOR] Form1
    [COLOR="Blue"]Private Declare Function[/COLOR] GetAsyncKeyState [COLOR="Blue"]Lib[/COLOR] "user32" ([COLOR="Blue"]ByVal[/COLOR] vkey [COLOR="Blue"]As[/COLOR] Long) [COLOR="Blue"]As[/COLOR] Integer
    [COLOR="Blue"]Dim[/COLOR] client [COLOR="Blue"]As[/COLOR] UdpClient
    [COLOR="Blue"]Dim[/COLOR] receivePoint [COLOR="Blue"]As[/COLOR] IPEndPoint

    [COLOR="Blue"]Private Sub[/COLOR] Form1_Load([COLOR="Blue"]ByVal[/COLOR] sender [COLOR="Blue"]As[/COLOR] System.Object, [COLOR="Blue"]ByVal[/COLOR] e [COLOR="Blue"]As[/COLOR] System.EventArgs) [COLOR="Blue"]Handles MyBase[/COLOR].Load
    [COLOR="Blue"]End Sub[/COLOR]

    [COLOR="Blue"]Private Sub[/COLOR] Timer1_Tick([COLOR="Blue"]ByVal[/COLOR] sender [COLOR="Blue"]As[/COLOR] System.Object, [COLOR="Blue"]ByVal[/COLOR] e [COLOR="Blue"]As[/COLOR] System.EventArgs) [COLOR="Blue"]Handles[/COLOR] Timer1.Tick
        [COLOR="Blue"]Dim[/COLOR] hotkey1 [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]Boolean[/COLOR] = GetAsyncKeyState(Keys.NumPad1)
        [COLOR="Blue"]Dim[/COLOR] hotkey2 [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]Boolean[/COLOR] = GetAsyncKeyState(Keys.NumPad2)
        [COLOR="Blue"]Dim[/COLOR] hotkey3 [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]Boolean[/COLOR] = GetAsyncKeyState(Keys.NumPad3)
        [COLOR="Blue"]Dim[/COLOR] hotkey4 [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]Boolean[/COLOR] = GetAsyncKeyState(Keys.NumPad5)
        [COLOR="Blue"]If [/COLOR]hotkey1 = [COLOR="Blue"]True Then[/COLOR]
            [COLOR="Blue"]Dim[/COLOR] data [COLOR="Blue"]As[/COLOR] Byte() = System.Text.Encoding.ASCII.GetBytes([COLOR="DarkRed"]"...#beam me up"[/COLOR])
            client.Send(data, data.Length, "213.152.3.5", 2000)
      [COLOR="Blue"]End If
    End Sub[/COLOR]

    [COLOR="Blue"]Private Sub[/COLOR] Button1_Click([COLOR="Blue"]ByVal[/COLOR] sender [COLOR="Blue"]As[/COLOR] System.Object, [COLOR="Blue"]ByVal[/COLOR] e [COLOR="Blue"]As[/COLOR] System.EventArgs) [COLOR="Blue"]Handles[/COLOR] Button1.Click
        [COLOR="Blue"]Dim[/COLOR] data [COLOR="Blue"]As[/COLOR] Byte() = System.Text.Encoding.ASCII.GetBytes([COLOR="DarkRed"]"...#beam me up"[/COLOR])
        client.Send(data, data.Length, "213.152.3.5", 2000)
    [COLOR="Blue"]End Sub
End Class[/COLOR]
The TCP Version

Code:
[COLOR="Blue"]Imports[/COLOR] System.Net.Sockets
[COLOR="Blue"]Imports[/COLOR] System.IO
[COLOR="Blue"]Imports[/COLOR] System.Net
[COLOR="Blue"]Imports[/COLOR] System.Text
Code:
[COLOR="Blue"]Public Class[/COLOR] Form1
    [COLOR="Blue"]Private Declare Function[/COLOR] GetAsyncKeyState [COLOR="Blue"]Lib[/COLOR] "user32" ([COLOR="Blue"]ByVal[/COLOR] vkey [COLOR="Blue"]As[/COLOR] Long) [COLOR="Blue"]As Integer[/COLOR]
    [COLOR="Blue"]Dim[/COLOR] clientSocket [COLOR="Blue"]As[/COLOR] New System.Net.Sockets.TcpClient()
   [COLOR="Blue"]Dim[/COLOR] serverStream [COLOR="Blue"]As[/COLOR] NetworkStream
    [COLOR="Blue"]Private Sub[/COLOR] Form1_Load([COLOR="Blue"]ByVal[/COLOR] sender [COLOR="Blue"]As[/COLOR] System.Object, [COLOR="Blue"]ByVal[/COLOR] e [COLOR="Blue"]As[/COLOR] System.EventArgs) [COLOR="Blue"]Handles MyBase[/COLOR].Load
        clientSocket.Connect("213.152.3.5", 2000)
   [COLOR="Blue"]End Sub[/COLOR]

    [COLOR="Blue"]Private Sub[/COLOR] Timer1_Tick([COLOR="Blue"]ByVal[/COLOR] sender [COLOR="Blue"]As[/COLOR] System.Object, [COLOR="Blue"]ByVal[/COLOR] e [COLOR="Blue"]As[/COLOR] System.EventArgs) [COLOR="Blue"]Handles[/COLOR] Timer1.Tick
        [COLOR="Blue"]Dim[/COLOR] hotkey1 [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]Boolean[/COLOR] = GetAsyncKeyState(Keys.NumPad1)
        [COLOR="Blue"]Dim[/COLOR] hotkey2 [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]Boolean[/COLOR] = GetAsyncKeyState(Keys.NumPad2)
        [COLOR="Blue"]Dim[/COLOR] hotkey3 [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]Boolean[/COLOR] = GetAsyncKeyState(Keys.NumPad3)
        [COLOR="Blue"]Dim[/COLOR] hotkey4 [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]Boolean[/COLOR] = GetAsyncKeyState(Keys.NumPad5)
        [COLOR="Blue"]Dim[/COLOR] serverStream [COLOR="Blue"]As[/COLOR] NetworkStream = clientSocket.GetStream()
        [COLOR="Blue"]Dim[/COLOR] outStream [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]Byte[/COLOR]()

        [COLOR="Blue"]If[/COLOR] hotkey1 = [COLOR="Blue"]True Then[/COLOR]
            outStream = System.Text.Encoding.ASCII.GetBytes([COLOR="DarkRed"]"...#beam me up"[/COLOR])
            serverStream.Write(outStream, 0, outStream.Length)
            serverStream.Flush()
        [COLOR="Blue"]End If
    End Sub[/COLOR]

    [COLOR="Blue"]Private Sub[/COLOR] Button1_Click([COLOR="Blue"]ByVal[/COLOR] sender [COLOR="Blue"]As[/COLOR] System.Object, [COLOR="Blue"]ByVal[/COLOR] e [COLOR="Blue"]As[/COLOR] System.EventArgs) [COLOR="Blue"]Handles[/COLOR] Button1.Click
       [COLOR="Blue"]Dim[/COLOR] serverStream [COLOR="Blue"]As[/COLOR] NetworkStream = clientSocket.GetStream()
        [COLOR="Blue"]Dim[/COLOR] outStream [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]Byte[/COLOR]()
        outStream = System.Text.Encoding.ASCII.GetBytes([COLOR="DarkRed"]"...#beam me up"[/COLOR])
        serverStream.Write(outStream, 0, outStream.Length)
        serverStream.Flush()
   [COLOR="Blue"]End Sub
End Class[/COLOR]
Problem ain't errors anymore, but... :S It just won't work :( please help me out.

Is my problem that i haven't injected the program to the game i won't to use this program on?