WinPcap.au3 Problem/Hilfe

  • Hallo,
    ich möchte einen Chat vom Spiel überwachen bzw. mitlesen auch wenn es Minimiert ist.
    Das abfangen der Packete mit der WinPcap UDF klapt ja.
    Jetzt habe ich versucht was zurück zu senden also zu Antworten, aber das läst mein mein PC abstürtzen (blue Screen xD)

    Spoiler anzeigen
    [autoit]

    #include <Array.au3>
    #include <Winpcap.au3>
    $filter = "tcp port 4002"

    [/autoit] [autoit][/autoit] [autoit]

    $winpcap = _PcapSetup() ; initialize winpcap
    If ($winpcap = -1) Then
    MsgBox(16, "Pcap error !", "WinPcap not found !")
    Exit
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $pcap_devices = _PcapGetDeviceList() ; get devices list
    If ($pcap_devices = -1) Then
    MsgBox(16, "Pcap error !", _PcapGetLastError())
    Exit
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $int = $pcap_devices[5][0]

    [/autoit] [autoit][/autoit] [autoit]

    $pcap = _PcapStartCapture($int, $filter, 0);start capture
    If ($pcap = -1) Then
    MsgBox(16, "Pcap error !", _PcapGetLastError())
    EndIf
    Local $counterabc = 1
    While 1
    If IsPtr($pcap) Then
    $time0 = TimerInit()
    While (TimerDiff($time0) < 500) ; Retrieve packets from queue for maximum 500ms before returning to main loop, not to "hang" the window for user
    $packet = _PcapGetPacket($pcap)
    If IsInt($packet) Then ExitLoop
    $sniff = sniff($packet[3])
    If $counterabc <> 5 Then
    If $sniff <> False Then
    ConsoleWrite($sniff & @CRLF)
    $counterabc += 1
    ToolTip ($counterabc,0,0)
    EndIf
    Else
    $in = InputBox("", "")
    _PcapSendPacket($pcap, $in)
    EndIf
    WEnd
    EndIf
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    _PcapFree() ; close winpcap

    [/autoit] [autoit][/autoit] [autoit]

    Func sniff($data)
    Local $ipheaderlen = BitAND(_PcapBinaryGetVal($data, 15, 1), 0xF) * 4
    Local $tcpoffset = $ipheaderlen + 14
    Local $tcplen = _PcapBinaryGetVal($data, 17, 2) - $ipheaderlen ; ip total len - ip header len
    Local $tcpheaderlen = BitShift(_PcapBinaryGetVal($data, $tcpoffset + 13, 1), 4) * 4
    Local $tcpsrcport = _PcapBinaryGetVal($data, $tcpoffset + 1, 2)
    Local $tcpdstport = _PcapBinaryGetVal($data, $tcpoffset + 3, 2)
    Local $tcpsequence = _PcapBinaryGetVal($data, $tcpoffset + 5, 4)
    Local $tcpflags = _PcapBinaryGetVal($data, $tcpoffset + 14, 1)
    Local $httpoffset = $tcpoffset + $tcpheaderlen + 1
    Local $httplen = $tcplen - $tcpheaderlen
    $sniff_packet = BinaryMid($data, $httpoffset)

    [/autoit] [autoit][/autoit] [autoit]

    If $httplen = 0 Then Return False ; empty tcp packet

    [/autoit] [autoit][/autoit] [autoit]

    If $tcpsrcport = 4002 Then
    ;Return ">IN:" & $sniff_packet ; server ==> client
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    If $tcpdstport = 4002 Then
    Return "-OUT:" & $sniff_packet ; client ==> server
    EndIf
    EndFunc ;==>sniff

    [/autoit]

    Was mache ich falsch ?