Jump to content
Sign in to follow this  
mmavipc

Anthrax Chat

Recommended Posts

mmavipc

Anthrax(not the deadly disease it's the name of a company me and my friend made pm me for the link) Chat is a autoit chat program which has/will have many features.

Current features are(- means sub feature)

Admin

-RAW2SERVER(send a message directly to the server)

-RAW2CLIENT(sends a message directly to the client)

-enable/disable connections

-change password

-Admin message(makes a msg form nick Admin)

-kick(kicks a nick)

Smiles(yes i know i spelllllllld the folder wrong)

Password(you can enable a pass needen to join the chatroom

Nicknames(basically your name while chatting)

ChatLog

And thats it for now.

ToDo:

improve message handling

Add a add admin function.

add encryption

I will post source. But once encryption is added i will not post the include for it. I'll also post compiled exes.

If you want ASock.au3 search for it on the forums. I did not create it

To enable admin type /adminenable in the client

chatclient.au3:

#include <GUIConstants.au3>
#include <misc.au3>
#include <GUIEdit.au3>
#include <ie.au3>
#include <String.au3>
TCPStartup()
Global $pass
global $nickid
global $adminenabled
global $supafastdebug
global $isadminbutenabled = 0
dim $dea
if FileRead("file.txt") = 1 Then
    $supafastdebug = 1
    FileWrite("file.txt","0")
EndIf
dim $ovr
dim $ie
$ie = _IECreateEmbedded ()
$s = TCPConnect(InputBox("Enter IP","Enter IP","72.197.230.199"),InputBox("Enter port","enter port",42775))
$nick =InputBox("Nick","Enter your nick","Anonymous" & random(100, 999, 1))
#Region ### START Koda GUI section ### Form=c:\users\maverick\documents\form1.kxf
$Form1_1 = GUICreate("Form1", 679, 568, 187, 140)
$Input1 = GUICtrlCreateInput("", 8, 456, 465, 21)
$Button1 = GUICtrlCreateButton("Send", 568, 456, 97, 25, 0)
GUICtrlCreateObj($ie, 8, 8, 665, 425)
$Button2 = GUICtrlCreateButton("Admin login", 16, 488, 105, 25, 0)
$Button3 = GUICtrlCreateButton("Clear", 480, 456, 81, 25, 0)
$Button4 = GUICtrlCreateButton("Admin Message", 136, 488, 105, 25, 0)
$Button5 = GUICtrlCreateButton("Raw2Client", 256, 488, 105, 25, 0)
$Button6 = GUICtrlCreateButton("Enable\Disable cons", 376, 488, 113, 25, 0)
$Button7 = GUICtrlCreateButton("Change password", 504, 488, 105, 25, 0)
$Checkbox1 = GUICtrlCreateCheckbox("Connections enabled/disabled", 8, 544, 161, 17)
$Button8 = GUICtrlCreateButton("Raw2Server", 16, 520, 105, 25, 0)
#EndRegion ### END Koda GUI section ###
hidec($Button2)
hidec($Button4)
hidec($Button5)
hidec($Button6)
hidec($Button7)
hidec($Button8)
hidec($Checkbox1)
GUISetState(@SW_SHOW)
_IENavigate($ie,"about:blank")
tcpsend($s,"constat")
$data = ""
do 
    $data = TCPRecv($s,2048)
until $data = "y" or $data = "n"
cwri("constat " &$data)
if $data = "n" then 
    Exit
EndIf
if $data = "y" then
    GUICtrlSetState($Checkbox1,$GUI_CHECKED)
EndIf
TCPSend($s,"reqpass")
$data = ""
Do
    $data = TCPRecv($s,2048)
    cwri($data)
until $data = "yes" or $data = "no"
if $data = "yes" then
    $pass = InputBox("password","enter password")
EndIf
TCPSend($s,"JOIN|" & $nick & "|" & $pass)
$data = ""
Do
    $data = TCPRecv($s,2048)
    cwri($data)
until $data <> ""
$nickid = $data
if $data = "INCPASS" then
    TCPCloseSocket($s)
    MsgBox(0,"Incorrect password","You entered a incorrect password")
    exit(6)
EndIf
GUISetState(@SW_SHOW)
While 1
    if $adminenabled = 1 and $isadminbutenabled = 0 Then
        showc($Button4)
        showc($Button5)
        showc($Button6)
        showc($Button7)
        showc($Button8)
        showc($Checkbox1,1)
        $isadminbutenabled = 1
    EndIf
     $iVisibleHeight = $IE.document.body.clientHeight
    $IE.document.parentwindow.scrollBy(0,$iVisibleHeight)
    if WinActive("Form1") Then
        HotKeySet("{enter}","_send")
    Else
        HotKeySet("{enter}")
    EndIf
    $data = ""
    $data = TCPRecv($s,2048)
    if @error then exit
    if $data <> "" Then
        cwri($data)
    EndIf
    if $data <> "" Then
        $data = StringSplit($data,@lf)
        cwri($data[0])
        for $i = 1 to $data[0]
            $temp = StringSplit($data[$i],"|")
            cwri("Data $i " & $data[$i])
            if $temp[0] > 1 then
                cwri($temp[1])
                if $temp[1] = "sendmsg" Then
                    out($temp[2] & " : " & $temp[3])
                elseif $temp[1] = "exit" and $temp[2] = $nick Then
                    TCPCloseSocket($s)
                    GUIDelete()
                    MsgBox(0,$temp[3],$temp[4])
                    exit(5)
                EndIf
            elseif $temp[1] = "condis" Then
                GUICtrlSetState($Checkbox1,$GUI_UNCHECKED)
            elseif $temp[1] = "conena" Then
                GUICtrlSetState($Checkbox1,$GUI_CHECKED)
            Else
                out($temp[1])
            EndIf
        Next
    EndIf
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $Button1
            _send()
        case $Button2
            $adminuser = InputBox("","USER")
            $adminpass = InputBox("","PASS")
            TCPSend($s,"adminlogin|" & $adminuser & "|" & $adminpass)
            Do
                $data = TCPRecv($s,2048)
            until $data <> ""
            msgbox(0,$data,$data)
            if $data = "yesadmin" Then
                $adminenabled = 1
            EndIf
        case $Button3
            $dea = ""
            _IEBodyWriteHTML($ie,"Nothing in console")
        Case $Button4
            $msgi = InputBox("Message","Enter admin message")
            TCPSend($s,"RAW|Admin : " & $msgi)
        case $Button5
            $raw = InputBox("RAW","RAW")
            TCPSend($s,"RAW|" & $raw)
        case $Button6
            tcpsend($s,"conendi")
        case $Button7
            $npass = InputBox("Password","Please enter the New password")
            TCPSend($s,"cpass|" & $npass)
        case $Button8
            $rawserver = InputBox("RAW","this will be send to the server raw.")
            tcpsend($s,$rawserver)
    EndSwitch
    $iVisibleHeight = $IE.document.body.clientHeight
    $IE.document.parentwindow.scrollBy(0,$iVisibleHeight)
WEnd
func out($input)
    $dea = $dea & "<br>" & $input
    $dea =  stringreplace($dea,":)",'<img src="' & @ScriptDir & '/smileys/1.gif"></img>')
    $dea =  stringreplace($dea,":(",'<img src="' & @ScriptDir & '/smileys/2.gif"></img>')
    $dea =  stringreplace($dea,";)",'<img src="' & @ScriptDir & '/smileys/3.gif"></img>')
    $dea =  stringreplace($dea,":D",'<img src="' & @ScriptDir & '/smileys/4.gif"></img>')
    $dea =  stringreplace($dea,"(:<",'<img src="' & @ScriptDir & 'smileys/5.gif"></img>')
    $dea =  stringreplace($dea,"<3",'<img src="' & @ScriptDir & '/smileys/6.gif"></img>')
    $dea =  stringreplace($dea,"B)",'<img src="' & @ScriptDir & '/smileys/7.gif"></img>')
    $dea =  stringreplace($dea,":o",'<img src="' & @ScriptDir & '/smileys/8.gif"></img>')
    $dea =  stringreplace($dea,"</3",'<img src="' & @ScriptDir & '/smileys/9.gif"></img>')
    $dea =  stringreplace($dea,":P",'<img src="' & @ScriptDir & '/smileys/10.gif"></img>')
    _IEBodyWriteHTML($ie,$dea)
    $iVisibleHeight = $IE.document.body.clientHeight
    $IE.document.parentwindow.scrollBy(0,$iVisibleHeight)
EndFunc
func _send($ovr = 0, $msg = 0)
    $read = GUICtrlRead($Input1)
    if GUICtrlRead($Input1) = "/adminenable" Then
        GUICtrlSetState($Button2,$GUI_show)
        GUICtrlSetState($Button2,$GUI_enable)
        GUICtrlSetData($Input1,"")
    elseif stringleft($read,5) = "/kick" and $adminenabled = 1 Then
        $lol = StringSplit($read,"\")
        TCPSend($s,"kick|" & $lol[2] & "|" & $lol[3] & "|" & $lol[4])
        GUICtrlSetData($Input1,"")
    ElseIf $ovr = 1 Then
        TCPSend($s,"SENDMSG|" & $msg)
    Else
        tcpsend($s,"SENDMSG|" & GUICtrlRead($Input1))
        GUICtrlSetData($Input1,"")
    EndIf
EndFunc
func cwri($w00t)
    ConsoleWrite($w00t & @lf)
EndFunc
func hidec($controlid)
    GUICtrlSetState($controlid,$GUI_hide)
    GUICtrlSetState($controlid,$GUI_disable)
EndFunc
func showc($controlid, $noenable = 0)
    if $noenable = 0 then
        GUICtrlSetState($controlid,$GUI_show)
        GUICtrlSetState($controlid,$GUI_enable)
    Else
        GUICtrlSetState($controlid,$GUI_show)
    EndIf
EndFunc

For the server's source look at attachments.

chatserver.exe

client.rar

chatserver.au3

Edited by mmavipc

[size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N

Share this post


Link to post
Share on other sites
ludocus

why is only the client open source?

can I see the server?

You know half of the people are not going to open an exe

Share this post


Link to post
Share on other sites
m4tek

I will post source. But once encryption is added i will not post the include for it. I'll also post compiled exes.

Read his post carefully :)

Seems nice! Good job.

Share this post


Link to post
Share on other sites
mmavipc

why is only the client open source?

can I see the server?

You know half of the people are not going to open an exe

oops sorry forgot to post that. The only thing that will be closed source will be my encryption method which is top secret and only Anthrax Interactive board members and lead devs get to see it

[size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N

Share this post


Link to post
Share on other sites
monoceres

oops sorry forgot to post that. The only thing that will be closed source will be my encryption method which is top secret and only Anthrax Interactive board members and lead devs get to see it

Then for your sake, you didn't write it autoit did you?

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
ludocus

He means that you wrote it in an other language... :)

Edited by ludocus

Share this post


Link to post
Share on other sites
mmavipc

He means that you wrote it in an other language... :)

oooh no. I wrote it in autoit if you search for my old acct which got hacked(mmavipc3) youll see encryption method. Thats an old version of it though

[size="10"]Pure Au3 crypt funcs(I'm currently also working on making a dll from this)[/size][Y] Be more active in the community[Y] Get 200 posts[N] Get 300 posts[N] Make a Topic in the example scripts forum with at least 50 replies.People who currently hate me:ValikSmOke_N

Share this post


Link to post
Share on other sites
genzzo

heres the code to the client.

you can always pm me :P

#RequireAdmin

Global Const $FD_READ = 1

Global Const $FD_WRITE = 2

Global Const $FD_OOB = 4

Global Const $FD_ACCEPT = 8

Global Const $FD_CONNECT = 16

Global Const $FD_CLOSE = 32

Local $HWS2_32 = -1

Func _ASOCKET($IADDRESSFAMILY = 2, $ITYPE = 1, $IPROTOCOL = 6)

If $HWS2_32 = -1 Then $HWS2_32 = DllOpen("Ws2_32.dll")

Local $HSOCKET = DllCall($HWS2_32, "uint", "socket", "int", $IADDRESSFAMILY, "int", $ITYPE, "int", $IPROTOCOL)

If @error Then

SetError(1, @error)

Return -1

EndIf

If $HSOCKET[0] = -1 Then

SetError(2, _WSAGETLASTERROR())

Return -1

EndIf

Return $HSOCKET[0]

EndFunc

Func _ASOCKSHUTDOWN($HSOCKET)

If $HWS2_32 = -1 Then $HWS2_32 = DllOpen("Ws2_32.dll")

Local $IRET = DllCall($HWS2_32, "int", "shutdown", "uint", $HSOCKET, "int", 2)

If @error Then

SetError(1, @error)

Return False

EndIf

If $IRET[0] <> 0 Then

SetError(2, _WSAGETLASTERROR())

Return False

EndIf

Return True

EndFunc

Func _ASOCKCLOSE($HSOCKET)

If $HWS2_32 = -1 Then $HWS2_32 = DllOpen("Ws2_32.dll")

Local $IRET = DllCall($HWS2_32, "int", "closesocket", "uint", $HSOCKET)

If @error Then

SetError(1, @error)

Return False

EndIf

If $IRET[0] <> 0 Then

SetError(2, _WSAGETLASTERROR())

Return False

EndIf

Return True

EndFunc

Func _ASOCKSELECT($HSOCKET, $HWND, $UIMSG, $IEVENT)

If $HWS2_32 = -1 Then $HWS2_32 = DllOpen("Ws2_32.dll")

Local $IRET = DllCall($HWS2_32, "int", "WSAAsyncSelect", "uint", $HSOCKET, "hwnd", $HWND, "uint", $UIMSG, "int", $IEVENT)

If @error Then

SetError(1, @error)

Return False

EndIf

If $IRET[0] <> 0 Then

SetError(2, _WSAGETLASTERROR())

Return False

EndIf

Return True

EndFunc

Func _ASOCKLISTEN($HSOCKET, $SIP, $UIPORT, $IMAXPENDING = 5)

Local $IRET

Local $STADDRESS

If $HWS2_32 = -1 Then $HWS2_32 = DllOpen("Ws2_32.dll")

$STADDRESS = __SOCKADDR($SIP, $UIPORT)

If @error Then

SetError(@error, @extended)

Return False

EndIf

$IRET = DllCall($HWS2_32, "int", "bind", "uint", $HSOCKET, "ptr", DllStructGetPtr($STADDRESS), "int", DllStructGetSize($STADDRESS))

If @error Then

SetError(3, @error)

Return False

EndIf

If $IRET[0] <> 0 Then

$STADDRESS = 0

SetError(4, _WSAGETLASTERROR())

Return False

EndIf

$IRET = DllCall($HWS2_32, "int", "listen", "uint", $HSOCKET, "int", $IMAXPENDING)

If @error Then

SetError(5, @error)

Return False

EndIf

If $IRET[0] <> 0 Then

$STADDRESS = 0

SetError(6, _WSAGETLASTERROR())

Return False

EndIf

Return True

EndFunc

Func _ASOCKCONNECT($HSOCKET, $SIP, $UIPORT)

Local $IRET

Local $STADDRESS

If $HWS2_32 = -1 Then $HWS2_32 = DllOpen("Ws2_32.dll")

$STADDRESS = __SOCKADDR($SIP, $UIPORT)

If @error Then

SetError(@error, @extended)

Return False

EndIf

$IRET = DllCall($HWS2_32, "int", "connect", "uint", $HSOCKET, "ptr", DllStructGetPtr($STADDRESS), "int", DllStructGetSize($STADDRESS))

If @error Then

SetError(3, @error)

Return False

EndIf

$IRET = _WSAGETLASTERROR()

If $IRET = 10035 Then

Return True

EndIf

SetExtended(1)

Return True

EndFunc

Func __SOCKADDR($SIP, $IPORT, $IADDRESSFAMILY = 2)

Local $IRET

Local $STADDRESS

If $HWS2_32 = -1 Then $HWS2_32 = DllOpen("Ws2_32.dll")

$STADDRESS = DllStructCreate("short; ushort; uint; char[8]")

If @error Then

SetError(1, @error)

Return False

EndIf

DllStructSetData($STADDRESS, 1, $IADDRESSFAMILY)

$IRET = DllCall($HWS2_32, "ushort", "htons", "ushort", $IPORT)

DllStructSetData($STADDRESS, 2, $IRET[0])

$IRET = DllCall($HWS2_32, "uint", "inet_addr", "str", $SIP)

If $IRET[0] = -1 Then

$STADDRESS = 0

SetError(2, _WSAGETLASTERROR())

Return False

EndIf

DllStructSetData($STADDRESS, 3, $IRET[0])

Return $STADDRESS

EndFunc

Func _WSAGETLASTERROR()

If $HWS2_32 = -1 Then $HWS2_32 = DllOpen("Ws2_32.dll")

Local $IRET = DllCall($HWS2_32, "int", "WSAGetLastError")

If @error Then

ConsoleWrite("+> _WSAGetLastError(): WSAGetLastError() failed. Script line number: " & @ScriptLineNumber & @CRLF)

SetExtended(1)

Return 0

EndIf

Return $IRET[0]

EndFunc

Func _MAKELONG($LOWORD, $HIWORD)

Return BitOR($HIWORD * 65536, BitAND($LOWORD, 65535))

EndFunc

Func _HIWORD($LONG)

Return BitShift($LONG, 16)

EndFunc

Func _LOWORD($LONG)

Return BitAND($LONG, 65535)

EndFunc

Global Const $WS_TILED = 0

Global Const $WS_OVERLAPPED = 0

Global Const $WS_MAXIMIZEBOX = 65536

Global Const $WS_MINIMIZEBOX = 131072

Global Const $WS_TABSTOP = 65536

Global Const $WS_GROUP = 131072

Global Const $WS_SIZEBOX = 262144

Global Const $WS_THICKFRAME = 262144

Global Const $WS_SYSMENU = 524288

Global Const $WS_HSCROLL = 1048576

Global Const $WS_VSCROLL = 2097152

Global Const $WS_DLGFRAME = 4194304

Global Const $WS_BORDER = 8388608

Global Const $WS_CAPTION = 12582912

Global Const $WS_OVERLAPPEDWINDOW = 13565952

Global Const $WS_TILEDWINDOW = 13565952

Global Const $WS_MAXIMIZE = 16777216

Global Const $WS_CLIPCHILDREN = 33554432

Global Const $WS_CLIPSIBLINGS = 67108864

Global Const $WS_DISABLED = 134217728

Global Const $WS_VISIBLE = 268435456

Global Const $WS_MINIMIZE = 536870912

Global Const $WS_CHILD = 1073741824

Global Const $WS_POPUP = -2147483648

Global Const $WS_POPUPWINDOW = -2138570752

Global Const $DS_MODALFRAME = 128

Global Const $DS_SETFOREGROUND = 512

Global Const $DS_CONTEXTHELP = 8192

Global Const $WS_EX_ACCEPTFILES = 16

Global Const $WS_EX_MDICHILD = 64

Global Const $WS_EX_APPWINDOW = 262144

Global Const $WS_EX_CLIENTEDGE = 512

Global Const $WS_EX_CONTEXTHELP = 1024

Global Const $WS_EX_DLGMODALFRAME = 1

Global Const $WS_EX_LEFTSCROLLBAR = 16384

Global Const $WS_EX_OVERLAPPEDWINDOW = 768

Global Const $WS_EX_RIGHT = 4096

Global Const $WS_EX_STATICEDGE = 131072

Global Const $WS_EX_TOOLWINDOW = 128

Global Const $WS_EX_TOPMOST = 8

Global Const $WS_EX_TRANSPARENT = 32

Global Const $WS_EX_WINDOWEDGE = 256

Global Const $WS_EX_LAYERED = 524288

Global Const $WS_EX_CONTROLPARENT = 65536

Global Const $WS_EX_LAYOUTRTL = 4194304

Global Const $WS_EX_RTLREADING = 8192

Global Const $WM_GETTEXTLENGTH = 14

Global Const $WM_GETTEXT = 13

Global Const $WM_SIZE = 5

Global Const $WM_SIZING = 532

Global Const $WM_USER = 1024

Global Const $WM_CREATE = 1

Global Const $WM_DESTROY = 2

Global Const $WM_MOVE = 3

Global Const $WM_ACTIVATE = 6

Global Const $WM_SETFOCUS = 7

Global Const $WM_KILLFOCUS = 8

Global Const $WM_ENABLE = 10

Global Const $WM_SETREDRAW = 11

Global Const $WM_SETTEXT = 12

Global Const $WM_PAINT = 15

Global Const $WM_CLOSE = 16

Global Const $WM_QUIT = 18

Global Const $WM_ERASEBKGND = 20

Global Const $WM_SYSCOLORCHANGE = 21

Global Const $WM_SHOWWINDOW = 24

Global Const $WM_WININICHANGE = 26

Global Const $WM_DEVMODECHANGE = 27

Global Const $WM_ACTIVATEAPP = 28

Global Const $WM_FONTCHANGE = 29

Global Const $WM_TIMECHANGE = 30

Global Const $WM_CANCELMODE = 31

Global Const $WM_SETCURSOR = 32

Global Const $WM_MOUSEACTIVATE = 33

Global Const $WM_CHILDACTIVATE = 34

Global Const $WM_QUEUESYNC = 35

Global Const $WM_GETMINMAXINFO = 36

Global Const $WM_PAINTICON = 38

Global Const $WM_ICONERASEBKGND = 39

Global Const $WM_NEXTDLGCTL = 40

Global Const $WM_SPOOLERSTATUS = 42

Global Const $WM_DRAWITEM = 43

Global Const $WM_MEASUREITEM = 44

Global Const $WM_DELETEITEM = 45

Global Const $WM_VKEYTOITEM = 46

Global Const $WM_CHARTOITEM = 47

Global Const $WM_SETFONT = 48

Global Const $WM_GETFONT = 49

Global Const $WM_SETHOTKEY = 50

Global Const $WM_GETHOTKEY = 51

Global Const $WM_QUERYDRAGICON = 55

Global Const $WM_COMPAREITEM = 57

Global Const $WM_GETOBJECT = 61

Global Const $WM_COMPACTING = 65

Global Const $WM_COMMNOTIFY = 68

Global Const $WM_WINDOWPOSCHANGING = 70

Global Const $WM_WINDOWPOSCHANGED = 71

Global Const $WM_POWER = 72

Global Const $WM_NOTIFY = 78

Global Const $WM_COPYDATA = 74

Global Const $WM_CANCELJOURNAL = 75

Global Const $WM_INPUTLANGCHANGEREQUEST = 80

Global Const $WM_INPUTLANGCHANGE = 81

Global Const $WM_TCARD = 82

Global Const $WM_HELP = 83

Global Const $WM_USERCHANGED = 84

Global Const $WM_NOTIFYFORMAT = 85

Global Const $WM_CUT = 768

Global Const $WM_COPY = 769

Global Const $WM_PASTE = 770

Global Const $WM_CLEAR = 771

Global Const $WM_UNDO = 772

Global Const $WM_CONTEXTMENU = 123

Global Const $WM_STYLECHANGING = 124

Global Const $WM_STYLECHANGED = 125

Global Const $WM_DISPLAYCHANGE = 126

Global Const $WM_GETICON = 127

Global Const $WM_SETICON = 128

Global Const $WM_NCCREATE = 129

Global Const $WM_NCDESTROY = 130

Global Const $WM_NCCALCSIZE = 131

Global Const $WM_NCHITTEST = 132

Global Const $WM_NCPAINT = 133

Global Const $WM_NCACTIVATE = 134

Global Const $WM_GETDLGCODE = 135

Global Const $WM_SYNCPAINT = 136

Global Const $WM_NCMOUSEMOVE = 160

Global Const $WM_NCLBUTTONDOWN = 161

Global Const $WM_NCLBUTTONUP = 162

Global Const $WM_NCLBUTTONDBLCLK = 163

Global Const $WM_NCRBUTTONDOWN = 164

Global Const $WM_NCRBUTTONUP = 165

Global Const $WM_NCRBUTTONDBLCLK = 166

Global Const $WM_NCMBUTTONDOWN = 167

Global Const $WM_NCMBUTTONUP = 168

Global Const $WM_NCMBUTTONDBLCLK = 169

Global Const $WM_KEYDOWN = 256

Global Const $WM_KEYUP = 257

Global Const $WM_CHAR = 258

Global Const $WM_DEADCHAR = 259

Global Const $WM_SYSKEYDOWN = 260

Global Const $WM_SYSKEYUP = 261

Global Const $WM_SYSCHAR = 262

Global Const $WM_SYSDEADCHAR = 263

Global Const $WM_INITDIALOG = 272

Global Const $WM_COMMAND = 273

Global Const $WM_SYSCOMMAND = 274

Global Const $WM_TIMER = 275

Global Const $WM_HSCROLL = 276

Global Const $WM_VSCROLL = 277

Global Const $WM_INITMENU = 278

Global Const $WM_INITMENUPOPUP = 279

Global Const $WM_MENUSELECT = 287

Global Const $WM_MENUCHAR = 288

Global Const $WM_ENTERIDLE = 289

Global Const $WM_MENURBUTTONUP = 290

Global Const $WM_MENUDRAG = 291

Global Const $WM_MENUGETOBJECT = 292

Global Const $WM_UNINITMENUPOPUP = 293

Global Const $WM_MENUCOMMAND = 294

Global Const $WM_CHANGEUISTATE = 295

Global Const $WM_UPDATEUISTATE = 296

Global Const $WM_QUERYUISTATE = 297

Global Const $WM_CTLCOLORMSGBOX = 306

Global Const $WM_CTLCOLOREDIT = 307

Global Const $WM_CTLCOLORLISTBOX = 308

Global Const $WM_CTLCOLORBTN = 309

Global Const $WM_CTLCOLORDLG = 310

Global Const $WM_CTLCOLORSCROLLBAR = 311

Global Const $WM_CTLCOLORSTATIC = 312

Global Const $WM_CTLCOLOR = 25

Global Const $MN_GETHMENU = 481

Global Const $NM_FIRST = 0

Global Const $NM_OUTOFMEMORY = $NM_FIRST - 1

Global Const $NM_CLICK = $NM_FIRST - 2

Global Const $NM_DBLCLK = $NM_FIRST - 3

Global Const $NM_RETURN = $NM_FIRST - 4

Global Const $NM_RCLICK = $NM_FIRST - 5

Global Const $NM_RDBLCLK = $NM_FIRST - 6

Global Const $NM_SETFOCUS = $NM_FIRST - 7

Global Const $NM_KILLFOCUS = $NM_FIRST - 8

Global Const $NM_CUSTOMDRAW = $NM_FIRST - 12

Global Const $NM_HOVER = $NM_FIRST - 13

Global Const $NM_NCHITTEST = $NM_FIRST - 14

Global Const $NM_KEYDOWN = $NM_FIRST - 15

Global Const $NM_RELEASEDCAPTURE = $NM_FIRST - 16

Global Const $NM_SETCURSOR = $NM_FIRST - 17

Global Const $NM_CHAR = $NM_FIRST - 18

Global Const $NM_TOOLTIPSCREATED = $NM_FIRST - 19

Global Const $NM_LDOWN = $NM_FIRST - 20

Global Const $NM_RDOWN = $NM_FIRST - 21

Global Const $NM_THEMECHANGED = $NM_FIRST - 22

Global Const $CCM_FIRST = 8192

Global Const $CCM_GETUNICODEFORMAT = ($CCM_FIRST + 6)

Global Const $CCM_SETUNICODEFORMAT = ($CCM_FIRST + 5)

Global Const $CCM_SETBKCOLOR = $CCM_FIRST + 1

Global Const $CCM_SETCOLORSCHEME = $CCM_FIRST + 2

Global Const $CCM_GETCOLORSCHEME = $CCM_FIRST + 3

Global Const $CCM_GETDROPTARGET = $CCM_FIRST + 4

Global Const $CCM_SETWINDOWTHEME = $CCM_FIRST + 11

Global Const $GA_PARENT = 1

Global Const $GA_ROOT = 2

Global Const $GA_ROOTOWNER = 3

Global Const $SM_CXSCREEN = 0

Global Const $SM_CYSCREEN = 1

Global Const $SM_CXVSCROLL = 2

Global Const $SM_CYHSCROLL = 3

Global Const $SM_CYCAPTION = 4

Global Const $SM_CXBORDER = 5

Global Const $SM_CYBORDER = 6

Global Const $SM_CXDLGFRAME = 7

Global Const $SM_CYDLGFRAME = 8

Global Const $SM_CYVTHUMB = 9

Global Const $SM_CXHTHUMB = 10

Global Const $SM_CXICON = 11

Global Const $SM_CYICON = 12

Global Const $SM_CXCURSOR = 13

Global Const $SM_CYCURSOR = 14

Global Const $SM_CYMENU = 15

Global Const $SM_CXFULLSCREEN = 16

Global Const $SM_CYFULLSCREEN = 17

Global Const $SM_CYKANJIWINDOW = 18

Global Const $SM_MOUSEPRESENT = 19

Global Const $SM_CYVSCROLL = 20

Global Const $SM_CXHSCROLL = 21

Global Const $SM_DEBUG = 22

Global Const $SM_SWAPBUTTON = 23

Global Const $SM_RESERVED1 = 24

Global Const $SM_RESERVED2 = 25

Global Const $SM_RESERVED3 = 26

Global Const $SM_RESERVED4 = 27

Global Const $SM_CXMIN = 28

Global Const $SM_CYMIN = 29

Global Const $SM_CXSIZE = 30

Global Const $SM_CYSIZE = 31

Global Const $SM_CXFRAME = 32

Global Const $SM_CYFRAME = 33

Global Const $SM_CXMINTRACK = 34

Global Const $SM_CYMINTRACK = 35

Global Const $SM_CXDOUBLECLK = 36

Global Const $SM_CYDOUBLECLK = 37

Global Const $SM_CXICONSPACING = 38

Global Const $SM_CYICONSPACING = 39

Global Const $SM_MENUDROPALIGNMENT = 40

Global Const $SM_PENWINDOWS = 41

Global Const $SM_DBCSENABLED = 42

Global Const $SM_CMOUSEBUTTONS = 43

Global Const $SM_SECURE = 44

Global Const $SM_CXEDGE = 45

Global Const $SM_CYEDGE = 46

Global Const $SM_CXMINSPACING = 47

Global Const $SM_CYMINSPACING = 48

Global Const $SM_CXSMICON = 49

Global Const $SM_CYSMICON = 50

Global Const $SM_CYSMCAPTION = 51

Global Const $SM_CXSMSIZE = 52

Global Const $SM_CYSMSIZE = 53

Global Const $SM_CXMENUSIZE = 54

Global Const $SM_CYMENUSIZE = 55

Global Const $SM_ARRANGE = 56

Global Const $SM_CXMINIMIZED = 57

Global Const $SM_CYMINIMIZED = 58

Global Const $SM_CXMAXTRACK = 59

Global Const $SM_CYMAXTRACK = 60

Global Const $SM_CXMAXIMIZED = 61

Global Const $SM_CYMAXIMIZED = 62

Global Const $SM_NETWORK = 63

Global Const $SM_CLEANBOOT = 67

Global Const $SM_CXDRAG = 68

Global Const $SM_CYDRAG = 69

Global Const $SM_SHOWSOUNDS = 70

Global Const $SM_CXMENUCHECK = 71

Global Const $SM_CYMENUCHECK = 72

Global Const $SM_SLOWMACHINE = 73

Global Const $SM_MIDEASTENABLED = 74

Global Const $SM_MOUSEWHEELPRESENT = 75

Global Const $SM_XVIRTUALSCREEN = 76

Global Const $SM_YVIRTUALSCREEN = 77

Global Const $SM_CXVIRTUALSCREEN = 78

Global Const $SM_CYVIRTUALSCREEN = 79

Global Const $SM_CMONITORS = 80

Global Const $SM_SAMEDISPLAYFORMAT = 81

Global Const $SM_IMMENABLED = 82

Global Const $SM_CXFOCUSBORDER = 83

Global Const $SM_CYFOCUSBORDER = 84

Global Const $SM_TABLETPC = 86

Global Const $SM_MEDIACENTER = 87

Global Const $SM_STARTER = 88

Global Const $SM_SERVERR2 = 89

Global Const $SM_CMETRICS = 90

Global Const $SM_REMOTESESSION = 4096

Global Const $SM_SHUTTINGDOWN = 8192

Global Const $SM_REMOTECONTROL = 8193

Global Const $SM_CARETBLINKINGENABLED = 8194

Global Const $SRCCOPY = 13369376

Global Const $SRCPAINT = 15597702

Global Const $SRCAND = 8913094

Global Const $SRCINVERT = 6684742

Global Const $SRCERASE = 4457256

Global Const $NOTSRCCOPY = 3342344

Global Const $NOTSRCERASE = 1114278

Global Const $MERGECOPY = 12583114

Global Const $MERGEPAINT = 12255782

Global Const $PATCOPY = 15728673

Global Const $PATPAINT = 16452105

Global Const $PATINVERT = 5898313

Global Const $DSTINVERT = 5570569

Global Const $BLACKNESS = 66

Global Const $WHITENESS = 16711778

Global Const $DT_TOP = 0

Global Const $DT_LEFT = 0

Global Const $DT_CENTER = 1

Global Const $DT_RIGHT = 2

Global Const $DT_VCENTER = 4

Global Const $DT_BOTTOM = 8

Global Const $DT_WORDBREAK = 16

Global Const $DT_SINGLELINE = 32

Global Const $DT_EXPANDTABS = 64

Global Const $DT_TABSTOP = 128

Global Const $DT_NOCLIP = 256

Global Const $DT_EXTERNALLEADING = 512

Global Const $DT_CALCRECT = 1024

Global Const $DT_NOPREFIX = 2048

Global Const $DT_INTERNAL = 4096

Global Const $RDW_INVALIDATE = 1

Global Const $RDW_INTERNALPAINT = 2

Global Const $RDW_ERASE = 4

Global Const $RDW_VALIDATE = 8

Global Const $RDW_NOINTERNALPAINT = 16

Global Const $RDW_NOERASE = 32

Global Const $RDW_NOCHILDREN = 64

Global Const $RDW_ALLCHILDREN = 128

Global Const $RDW_UPDATENOW = 256

Global Const $RDW_ERASENOW = 512

Global Const $RDW_FRAME = 1024

Global Const $RDW_NOFRAME = 2048

Global Const $WM_RENDERFORMAT = 773

Global Const $WM_RENDERALLFORMATS = 774

Global Const $WM_DESTROYCLIPBOARD = 775

Global Const $WM_DRAWCLIPBOARD = 776

Global Const $WM_PAINTCLIPBOARD = 777

Global Const $WM_VSCROLLCLIPBOARD = 778

Global Const $WM_SIZECLIPBOARD = 779

Global Const $WM_ASKCBFORMATNAME = 780

Global Const $WM_CHANGECBCHAIN = 781

Global Const $WM_HSCROLLCLIPBOARD = 782

Global Const $HTERROR = -2

Global Const $HTTRANSPARENT = -1

Global Const $HTNOWHERE = 0

Global Const $HTCLIENT = 1

Global Const $HTCAPTION = 2

Global Const $HTSYSMENU = 3

Global Const $HTGROWBOX = 4

Global Const $HTSIZE = $HTGROWBOX

Global Const $HTMENU = 5

Global Const $HTHSCROLL = 6

Global Const $HTVSCROLL = 7

Global Const $HTMINBUTTON = 8

Global Const $HTMAXBUTTON = 9

Global Const $HTLEFT = 10

Global Const $HTRIGHT = 11

Global Const $HTTOP = 12

Global Const $HTTOPLEFT = 13

Global Const $HTTOPRIGHT = 14

Global Const $HTBOTTOM = 15

Global Const $HTBOTTOMLEFT = 16

Global Const $HTBOTTOMRIGHT = 17

Global Const $HTBORDER = 18

Global Const $HTREDUCE = $HTMINBUTTON

Global Const $HTZOOM = $HTMAXBUTTON

Global Const $HTSIZEFIRST = $HTLEFT

Global Const $HTSIZELAST = $HTBOTTOMRIGHT

Global Const $HTOBJECT = 19

Global Const $HTCLOSE = 20

Global Const $HTHELP = 21

Global Const $COLOR_SCROLLBAR = 0

Global Const $COLOR_BACKGROUND = 1

Global Const $COLOR_ACTIVECAPTION = 2

Global Const $COLOR_INACTIVECAPTION = 3

Global Const $COLOR_MENU = 4

Global Const $COLOR_WINDOW = 5

Global Const $COLOR_WINDOWFRAME = 6

Global Const $COLOR_MENUTEXT = 7

Global Const $COLOR_WINDOWTEXT = 8

Global Const $COLOR_CAPTIONTEXT = 9

Global Const $COLOR_ACTIVEBORDER = 10

Global Const $COLOR_INACTIVEBORDER = 11

Global Const $COLOR_APPWORKSPACE = 12

Global Const $COLOR_HIGHLIGHT = 13

Global Const $COLOR_HIGHLIGHTTEXT = 14

Global Const $COLOR_BTNFACE = 15

Global Const $COLOR_BTNSHADOW = 16

Global Const $COLOR_GRAYTEXT = 17

Global Const $COLOR_BTNTEXT = 18

Global Const $COLOR_INACTIVECAPTIONTEXT = 19

Global Const $COLOR_BTNHIGHLIGHT = 20

Global Const $COLOR_3DDKSHADOW = 21

Global Const $COLOR_3DLIGHT = 22

Global Const $COLOR_INFOTEXT = 23

Global Const $COLOR_INFOBK = 24

Global Const $COLOR_HOTLIGHT = 26

Global Const $COLOR_GRADIENTACTIVECAPTION = 27

Global Const $COLOR_GRADIENTINACTIVECAPTION = 28

Global Const $COLOR_MENUHILIGHT = 29

Global Const $COLOR_MENUBAR = 30

Global Const $COLOR_DESKTOP = 1

Global Const $COLOR_3DFACE = 15

Global Const $COLOR_3DSHADOW = 16

Global Const $COLOR_3DHIGHLIGHT = 20

Global Const $COLOR_3DHILIGHT = 20

Global Const $COLOR_BTNHILIGHT = 20

Global Const $HINST_COMMCTRL = -1

Global Const $IDB_STD_SMALL_COLOR = 0

Global Const $IDB_STD_LARGE_COLOR = 1

Global Const $IDB_VIEW_SMALL_COLOR = 4

Global Const $IDB_VIEW_LARGE_COLOR = 5

Global Const $IDB_HIST_SMALL_COLOR = 8

Global Const $IDB_HIST_LARGE_COLOR = 9

Global Const $STARTF_FORCEOFFFEEDBACK = 128

Global Const $STARTF_FORCEONFEEDBACK = 64

Global Const $STARTF_RUNFULLSCREEN = 32

Global Const $STARTF_USECOUNTCHARS = 8

Global Const $STARTF_USEFILLATTRIBUTE = 16

Global Const $STARTF_USEHOTKEY = 512

Global Const $STARTF_USEPOSITION = 4

Global Const $STARTF_USESHOWWINDOW = 1

Global Const $STARTF_USESIZE = 2

Global Const $STARTF_USESTDHANDLES = 256

Global Const $OPT_COORDSRELATIVE = 0

Global Const $OPT_COORDSABSOLUTE = 1

Global Const $OPT_COORDSCLIENT = 2

Global Const $OPT_ERRORSILENT = 0

Global Const $OPT_ERRORFATAL = 1

Global Const $OPT_CAPSNOSTORE = 0

Global Const $OPT_CAPSSTORE = 1

Global Const $OPT_MATCHSTART = 1

Global Const $OPT_MATCHANY = 2

Global Const $OPT_MATCHEXACT = 3

Global Const $OPT_MATCHADVANCED = 4

Global Const $CCS_TOP = 1

Global Const $CCS_NOMOVEY = 2

Global Const $CCS_BOTTOM = 3

Global Const $CCS_NORESIZE = 4

Global Const $CCS_NOPARENTALIGN = 8

Global Const $CCS_NOHILITE = 16

Global Const $CCS_ADJUSTABLE = 32

Global Const $CCS_NODIVIDER = 64

Global Const $CCS_VERT = 128

Global Const $CCS_LEFT = 129

Global Const $CCS_NOMOVEX = 130

Global Const $CCS_RIGHT = 131

Global Const $DI_MASK = 1

Global Const $DI_IMAGE = 2

Global Const $DI_NORMAL = 3

Global Const $DI_COMPAT = 4

Global Const $DI_DEFAULTSIZE = 8

Global Const $DI_NOMIRROR = 16

Global Const $DISPLAY_DEVICE_ATTACHED_TO_DESKTOP = 1

Global Const $DISPLAY_DEVICE_MULTI_DRIVER = 2

Global Const $DISPLAY_DEVICE_PRIMARY_DEVICE = 4

Global Const $DISPLAY_DEVICE_MIRRORING_DRIVER = 8

Global Const $DISPLAY_DEVICE_VGA_COMPATIBLE = 16

Global Const $DISPLAY_DEVICE_REMOVABLE = 32

Global Const $DISPLAY_DEVICE_DISCONNECT = 33554432

Global Const $DISPLAY_DEVICE_REMOTE = 67108864

Global Const $DISPLAY_DEVICE_MODESPRUNED = 134217728

Global Const $EVENTLOG_SUCCESS = 0

Global Const $EVENTLOG_ERROR_TYPE = 1

Global Const $EVENTLOG_WARNING_TYPE = 2

Global Const $EVENTLOG_INFORMATION_TYPE = 4

Global Const $EVENTLOG_AUDIT_SUCCESS = 8

Global Const $EVENTLOG_AUDIT_FAILURE = 16

Global Const $EVENTLOG_SEQUENTIAL_READ = 1

Global Const $EVENTLOG_SEEK_READ = 2

Global Const $EVENTLOG_FORWARDS_READ = 4

Global Const $EVENTLOG_BACKWARDS_READ = 8

Global Const $DDL_ARCHIVE = 32

Global Const $DDL_DIRECTORY = 16

Global Const $DDL_DRIVES = 16384

Global Const $DDL_EXCLUSIVE = 32768

Global Const $DDL_HIDDEN = 2

Global Const $DDL_READONLY = 1

Global Const $DDL_READWRITE = 0

Global Const $DDL_SYSTEM = 4

Global Const $FC_NOOVERWRITE = 0

Global Const $FC_OVERWRITE = 1

Global Const $FT_MODIFIED = 0

Global Const $FT_CREATED = 1

Global Const $FT_ACCESSED = 2

Global Const $FO_READ = 0

Global Const $FO_APPEND = 1

Global Const $FO_OVERWRITE = 2

Global Const $FO_BINARY = 16

Global Const $FO_UNICODE = 32

Global Const $FO_UTF16_LE = 32

Global Const $FO_UTF16_BE = 64

Global Const $FO_UTF8 = 128

Global Const $EOF = -1

Global Const $FD_FILEMUSTEXIST = 1

Global Const $FD_PATHMUSTEXIST = 2

Global Const $FD_MULTISELECT = 4

Global Const $FD_PROMPTCREATENEW = 8

Global Const $FD_PROMPTOVERWRITE = 16

Global Const $CREATE_NEW = 1

Global Const $CREATE_ALWAYS = 2

Global Const $OPEN_EXISTING = 3

Global Const $OPEN_ALWAYS = 4

Global Const $TRUNCATE_EXISTING = 5

Global Const $FILE_ATTRIBUTE_READONLY = 1

Global Const $FILE_ATTRIBUTE_HIDDEN = 2

Global Const $FILE_ATTRIBUTE_SYSTEM = 4

Global Const $FILE_ATTRIBUTE_DIRECTORY = 16

Global Const $FILE_ATTRIBUTE_ARCHIVE = 32

Global Const $FILE_ATTRIBUTE_DEVICE = 64

Global Const $FILE_ATTRIBUTE_NORMAL = 128

Global Const $FILE_ATTRIBUTE_TEMPORARY = 256

Global Const $FILE_ATTRIBUTE_SPARSE_FILE = 512

Global Const $FILE_ATTRIBUTE_REPARSE_POINT = 1024

Global Const $FILE_ATTRIBUTE_COMPRESSED = 2048

Global Const $FILE_ATTRIBUTE_OFFLINE = 4096

Global Const $FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 8192

Global Const $FILE_ATTRIBUTE_ENCRYPTED = 16384

Global Const $FILE_SHARE_READ = 1

Global Const $FILE_SHARE_WRITE = 2

Global Const $FILE_SHARE_DELETE = 4

Global Const $GENERIC_ALL = 268435456

Global Const $GENERIC_EXECUTE = 536870912

Global Const $GENERIC_WRITE = 1073741824

Global Const $GENERIC_READ = -2147483648

Global Const $FLASHW_CAPTION = 1

Global Const $FLASHW_TRAY = 2

Global Const $FLASHW_TIMER = 4

Global Const $FLASHW_TIMERNOFG = 12

Global Const $FORMAT_MESSAGE_ALLOCATE_BUFFER = 256

Global Const $FORMAT_MESSAGE_IGNORE_INSERTS = 512

Global Const $FORMAT_MESSAGE_FROM_STRING = 1024

Global Const $FORMAT_MESSAGE_FROM_HMODULE = 2048

Global Const $FORMAT_MESSAGE_FROM_SYSTEM = 4096

Global Const $FORMAT_MESSAGE_ARGUMENT_ARRAY = 8192

Global Const $GW_HWNDFIRST = 0

Global Const $GW_HWNDLAST = 1

Global Const $GW_HWNDNEXT = 2

Global Const $GW_HWNDPREV = 3

Global Const $GW_OWNER = 4

Global Const $GW_CHILD = 5

Global Const $GWL_WNDPROC = -4

Global Const $GWL_HINSTANCE = -6

Global Const $GWL_HWNDPARENT = -8

Global Const $GWL_ID = -12

Global Const $GWL_STYLE = -16

Global Const $GWL_EXSTYLE = -20

Global Const $GWL_USERDATA = -21

Global Const $STD_CUT = 0

Global Const $STD_COPY = 1

Global Const $STD_PASTE = 2

Global Const $STD_UNDO = 3

Global Const $STD_REDOW = 4

Global Const $STD_DELETE = 5

Global Const $STD_FILENEW = 6

Global Const $STD_FILEOPEN = 7

Global Const $STD_FILESAVE = 8

Global Const $STD_PRINTPRE = 9

Global Const $STD_PROPERTIES = 10

Global Const $STD_HELP = 11

Global Const $STD_FIND = 12

Global Const $STD_REPLACE = 13

Global Const $STD_PRINT = 14

Global Const $LR_DEFAULTCOLOR = 0

Global Const $LR_MONOCHROME = 1

Global Const $LR_COLOR = 2

Global Const $LR_COPYRETURNORG = 4

Global Const $LR_COPYDELETEORG = 8

Global Const $LR_LOADFROMFILE = 16

Global Const $LR_LOADTRANSPARENT = 32

Global Const $LR_DEFAULTSIZE = 64

Global Const $LR_VGACOLOR = 128

Global Const $LR_LOADMAP3DCOLORS = 4096

Global Const $LR_CREATEDIBSECTION = 8192

Global Const $LR_COPYFROMRESOURCE = 16384

Global Const $LR_SHARED = 32768

Global Const $IMAGE_BITMAP = 0

Global Const $IMAGE_ICON = 1

Global Const $IMAGE_CURSOR = 2

Global Const $KB_SENDSPECIAL = 0

Global Const $KB_SENDRAW = 1

Global Const $KB_CAPSOFF = 0

Global Const $KB_CAPSON = 1

Global Const $DONT_RESOLVE_DLL_REFERENCES = 1

Global Const $LOAD_LIBRARY_AS_DATAFILE = 2

Global Const $LOAD_WITH_ALTERED_SEARCH_PATH = 8

Global Const $OBJID_WINDOW = 0

Global Const $OBJID_SYSMENU = -1

Global Const $OBJID_TITLEBAR = -2

Global Const $OBJID_MENU = -3

Global Const $OBJID_CLIENT = -4

Global Const $OBJID_VSCROLL = -5

Global Const $OBJID_HSCROLL = -6

Global Const $OBJID_SIZEGRIP = -7

Global Const $OBJID_CARET = -8

Global Const $OBJID_CURSOR = -9

Global Const $OBJID_ALERT = -10

Global Const $OBJID_SOUND = -11

Global Const $VK_DOWN = 40

Global Const $VK_END = 35

Global Const $VK_HOME = 36

Global Const $VK_LEFT = 37

Global Const $VK_NEXT = 34

Global Const $VK_PRIOR = 33

Global Const $VK_RIGHT = 39

Global Const $VK_UP = 38

Global Const $MB_OK = 0

Global Const $MB_OKCANCEL = 1

Global Const $MB_ABORTRETRYIGNORE = 2

Global Const $MB_YESNOCANCEL = 3

Global Const $MB_YESNO = 4

Global Const $MB_RETRYCANCEL = 5

Global Const $MB_ICONHAND = 16

Global Const $MB_ICONQUESTION = 32

Global Const $MB_ICONEXCLAMATION = 48

Global Const $MB_ICONASTERISK = 64

Global Const $MB_DEFBUTTON1 = 0

Global Const $MB_DEFBUTTON2 = 256

Global Const $MB_DEFBUTTON3 = 512

Global Const $MB_APPLMODAL = 0

Global Const $MB_SYSTEMMODAL = 4096

Global Const $MB_TASKMODAL = 8192

Global Const $MB_TOPMOST = 262144

Global Const $MB_RIGHTJUSTIFIED = 524288

Global Const $IDTIMEOUT = -1

Global Const $IDOK = 1

Global Const $IDCANCEL = 2

Global Const $IDABORT = 3

Global Const $IDRETRY = 4

Global Const $IDIGNORE = 5

Global Const $IDYES = 6

Global Const $IDNO = 7

Global Const $IDTRYAGAIN = 10

Global Const $IDCONTINUE = 11

Global Const $DLG_NOTITLE = 1

Global Const $DLG_NOTONTOP = 2

Global Const $DLG_TEXTLEFT = 4

Global Const $DLG_TEXTRIGHT = 8

Global Const $DLG_MOVEABLE = 16

Global Const $DLG_TEXTVCENTER = 32

Global Const $TIP_ICONNONE = 0

Global Const $TIP_ICONASTERISK = 1

Global Const $TIP_ICONEXCLAMATION = 2

Global Const $TIP_ICONHAND = 3

Global Const $TIP_NOSOUND = 16

Global Const $IDC_UNKNOWN = 0

Global Const $IDC_APPSTARTING = 1

Global Const $IDC_ARROW = 2

Global Const $IDC_CROSS = 3

Global Const $IDC_HELP = 4

Global Const $IDC_IBEAM = 5

Global Const $IDC_ICON = 6

Global Const $IDC_NO = 7

Global Const $IDC_SIZE = 8

Global Const $IDC_SIZEALL = 9

Global Const $IDC_SIZENESW = 10

Global Const $IDC_SIZENS = 11

Global Const $IDC_SIZENWSE = 12

Global Const $IDC_SIZEWE = 13

Global Const $IDC_UPARROW = 14

Global Const $IDC_WAIT = 15

Global Const $SD_LOGOFF = 0

Global Const $SD_SHUTDOWN = 1

Global Const $SD_REBOOT = 2

Global Const $SD_FORCE = 4

Global Const $SD_POWERDOWN = 8

Global Const $PROCESS_TERMINATE = 1

Global Const $PROCESS_CREATE_THREAD = 2

Global Const $PROCESS_SET_SESSIONID = 4

Global Const $PROCESS_VM_OPERATION = 8

Global Const $PROCESS_VM_READ = 16

Global Const $PROCESS_VM_WRITE = 32

Global Const $PROCESS_DUP_HANDLE = 64

Global Const $PROCESS_CREATE_PROCESS = 128

Global Const $PROCESS_SET_QUOTA = 256

Global Const $PROCESS_SET_INFORMATION = 512

Global Const $PROCESS_QUERY_INFORMATION = 1024

Global Const $PROCESS_SUSPEND_RESUME = 2048

Global Const $PROCESS_ALL_ACCESS = 2035711

Global Const $STR_NOCASESENSE = 0

Global Const $STR_CASESENSE = 1

Global Const $STR_STRIPLEADING = 1

Global Const $STR_STRIPTRAILING = 2

Global Const $STR_STRIPSPACES = 4

Global Const $STR_STRIPALL = 8

Global Const $TOKEN_ASSIGN_PRIMARY = 1

Global Const $TOKEN_DUPLICATE = 2

Global Const $TOKEN_IMPERSONATE = 4

Global Const $TOKEN_QUERY = 8

Global Const $TOKEN_QUERY_SOURCE = 16

Global Const $TOKEN_ADJUST_PRIVILEGES = 32

Global Const $TOKEN_ADJUST_GROUPS = 64

Global Const $TOKEN_ADJUST_DEFAULT = 128

Global Const $TOKEN_ADJUST_SESSIONID = 256

Global Const $TRAY_ITEM_EXIT = 3

Global Const $TRAY_ITEM_PAUSE = 4

Global Const $TRAY_ITEM_FIRST = 7

Global Const $TRAY_CHECKED = 1

Global Const $TRAY_UNCHECKED = 4

Global Const $TRAY_ENABLE = 64

Global Const $TRAY_DISABLE = 128

Global Const $TRAY_FOCUS = 256

Global Const $TRAY_DEFAULT = 512

Global Const $TRAY_EVENT_SHOWICON = -3

Global Const $TRAY_EVENT_HIDEICON = -4

Global Const $TRAY_EVENT_FLASHICON = -5

Global Const $TRAY_EVENT_NOFLASHICON = -6

Global Const $TRAY_EVENT_PRIMARYDOWN = -7

Global Const $TRAY_EVENT_PRIMARYUP = -8

Global Const $TRAY_EVENT_SECONDARYDOWN = -9

Global Const $TRAY_EVENT_SECONDARYUP = -10

Global Const $TRAY_EVENT_MOUSEOVER = -11

Global Const $TRAY_EVENT_MOUSEOUT = -12

Global Const $TRAY_EVENT_PRIMARYDOUBLE = -13

Global Const $TRAY_EVENT_SECONDARYDOUBLE = -14

Global Const $STDIN_CHILD = 1

Global Const $STDOUT_CHILD = 2

Global Const $STDERR_CHILD = 4

Global Const $COLOR_AQUA = 65535

Global Const $COLOR_BLACK = 0

Global Const $COLOR_BLUE = 255

Global Const $COLOR_CREAM = 16776176

Global Const $COLOR_FUCHSIA = 16711935

Global Const $COLOR_GRAY = 8421504

Global Const $COLOR_GREEN = 32768

Global Const $COLOR_LIME = 65280

Global Const $COLOR_MAROON = 9116770

Global Const $COLOR_MEDBLUE = 708

Global Const $COLOR_MEDGRAY = 10526884

Global Const $COLOR_MONEYGREEN = 12639424

Global Const $COLOR_NAVY = 128

Global Const $COLOR_OLIVE = 8421376

Global Const $COLOR_PURPLE = 8388736

Global Const $COLOR_RED = 16711680

Global Const $COLOR_SILVER = 12632256

Global Const $COLOR_SKYBLUE = 10930928

Global Const $COLOR_TEAL = 32896

Global Const $COLOR_WHITE = 16777215

Global Const $COLOR_YELLOW = 16776960

Global Const $CLR_NONE = -1

Global Const $CLR_AQUA = 16776960

Global Const $CLR_BLACK = 0

Global Const $CLR_BLUE = 16711680

Global Const $CLR_CREAM = 15793151

Global Const $CLR_DEFAULT = -16777216

Global Const $CLR_FUCHSIA = 16711935

Global Const $CLR_GRAY = 8421504

Global Const $CLR_GREEN = 32768

Global Const $CLR_LIME = 65280

Global Const $CLR_MAROON = 6429835

Global Const $CLR_MEDBLUE = 12845568

Global Const $CLR_MEDGRAY = 10789024

Global Const $CLR_MONEYGREEN = 12639424

Global Const $CLR_NAVY = 8388608

Global Const $CLR_OLIVE = 32896

Global Const $CLR_PURPLE = 8388736

Global Const $CLR_RED = 255

Global Const $CLR_SILVER = 12632256

Global Const $CLR_SKYBLUE = 15780518

Global Const $CLR_TEAL = 8421376

Global Const $CLR_WHITE = 16777215

Global Const $CLR_YELLOW = 65535

Global Const $CC_ANYCOLOR = 256

Global Const $CC_FULLOPEN = 2

Global Const $CC_RGBINIT = 1

Global Const $REG_NONE = 0

Global Const $REG_SZ = 1

Global Const $REG_EXPAND_SZ = 2

Global Const $REG_BINARY = 3

Global Const $REG_DWORD = 4

Global Const $REG_DWORD_BIG_ENDIAN = 5

Global Const $REG_LINK = 6

Global Const $REG_MULTI_SZ = 7

Global Const $REG_RESOURCE_LIST = 8

Global Const $REG_FULL_RESOURCE_DESCRIPTOR = 9

Global Const $REG_RESOURCE_REQUIREMENTS_LIST = 10

Global Const $SWP_NOSIZE = 1

Global Const $SWP_NOMOVE = 2

Global Const $SWP_NOZORDER = 4

Global Const $SWP_NOREDRAW = 8

Global Const $SWP_NOACTIVATE = 16

Global Const $SWP_FRAMECHANGED = 32

Global Const $SWP_DRAWFRAME = 32

Global Const $SWP_SHOWWINDOW = 64

Global Const $SWP_HIDEWINDOW = 128

Global Const $SWP_NOCOPYBITS = 256

Global Const $SWP_NOOWNERZORDER = 512

Global Const $SWP_NOREPOSITION = 512

Global Const $SWP_NOSENDCHANGING = 1024

Global Const $SWP_DEFERERASE = 8192

Global Const $SWP_ASYNCWINDOWPOS = 16384

Global Const $FW_DONTCARE = 0

Global Const $FW_THIN = 100

Global Const $FW_EXTRALIGHT = 200

Global Const $FW_ULTRALIGHT = 200

Global Const $FW_LIGHT = 300

Global Const $FW_NORMAL = 400

Global Const $FW_REGULAR = 400

Global Const $FW_MEDIUM = 500

Global Const $FW_SEMIBOLD = 600

Global Const $FW_DEMIBOLD = 600

Global Const $FW_BOLD = 700

Global Const $FW_EXTRABOLD = 800

Global Const $FW_ULTRABOLD = 800

Global Const $FW_HEAVY = 900

Global Const $FW_BLACK = 900

Global Const $PROOF_QUALITY = 2

Global Const $CF_EFFECTS = 256

Global Const $CF_PRINTERFONTS = 2

Global Const $CF_SCREENFONTS = 1

Global Const $CF_NOSCRIPTSEL = 8388608

Global Const $CF_INITTOLOGFONTSTRUCT = 64

Global Const $DEFAULT_PITCH = 0

Global Const $FF_DONTCARE = 0

Global Const $LOGPIXELSX = 88

Global Const $LOGPIXELSY = 90

Global Const $SB_THUMBPOSITION = 4

Global Const $SB_THUMBTRACK = 5

Global Const $LANG_AFRIKAANS = 54

Global Const $LANG_ALBANIAN = 28

Global Const $LANG_ARABIC = 1

Global Const $LANG_ARMENIAN = 43

Global Const $LANG_ASSAMESE = 77

Global Const $LANG_AZERI = 44

Global Const $LANG_BASQUE = 45

Global Const $LANG_BELARUSIAN = 35

Global Const $LANG_BENGALI = 69

Global Const $LANG_BULGARIAN = 2

Global Const $LANG_CATALAN = 3

Global Const $LANG_CHINESE = 4

Global Const $LANG_CROATIAN = 26

Global Const $LANG_CZECH = 5

Global Const $LANG_DANISH = 6

Global Const $LANG_DUTCH = 19

Global Const $LANG_ENGLISH = 9

Global Const $LANG_ESTONIAN = 37

Global Const $LANG_FAEROESE = 56

Global Const $LANG_FARSI = 41

Global Const $LANG_FINNISH = 11

Global Const $LANG_FRENCH = 12

Global Const $LANG_GEORGIAN = 55

Global Const $LANG_GERMAN = 7

Global Const $LANG_GREEK = 8

Global Const $LANG_GUJARATI = 71

Global Const $LANG_HEBREW = 13

Global Const $LANG_HINDI = 57

Global Const $LANG_HUNGARIAN = 14

Global Const $LANG_ICELANDIC = 15

Global Const $LANG_INDONESIAN = 33

Global Const $LANG_ITALIAN = 16

Global Const $LANG_JAPANESE = 17

Global Const $LANG_KANNADA = 75

Global Const $LANG_KASHMIRI = 96

Global Const $LANG_KAZAK = 63

Global Const $LANG_KONKANI = 87

Global Const $LANG_KOREAN = 18

Global Const $LANG_LATVIAN = 38

Global Const $LANG_LITHUANIAN = 39

Global Const $LANG_MACEDONIAN = 47

Global Const $LANG_MALAY = 62

Global Const $LANG_MALAYALAM = 76

Global Const $LANG_MANIPURI = 88

Global Const $LANG_MARATHI = 78

Global Const $LANG_NEPALI = 97

Global Const $LANG_NEUTRAL = 0

Global Const $LANG_NORWEGIAN = 20

Global Const $LANG_ORIYA = 72

Global Const $LANG_POLISH = 21

Global Const $LANG_PORTUGUESE = 22

Global Const $LANG_PUNJABI = 70

Global Const $LANG_ROMANIAN = 24

Global Const $LANG_RUSSIAN = 25

Global Const $LANG_SANSKRIT = 79

Global Const $LANG_SERBIAN = 26

Global Const $LANG_SINDHI = 89

Global Const $LANG_SLOVAK = 27

Global Const $LANG_SLOVENIAN = 36

Global Const $LANG_SPANISH = 10

Global Const $LANG_SWAHILI = 65

Global Const $LANG_SWEDISH = 29

Global Const $LANG_TAMIL = 73

Global Const $LANG_TATAR = 68

Global Const $LANG_TELUGU = 74

Global Const $LANG_THAI = 30

Global Const $LANG_TURKISH = 31

Global Const $LANG_UKRAINIAN = 34

Global Const $LANG_URDU = 32

Global Const $LANG_UZBEK = 67

Global Const $LANG_VIETNAMESE = 42

Global Const $SUBLANG_ARABIC_ALGERIA = 5

Global Const $SUBLANG_ARABIC_BAHRAIN = 15

Global Const $SUBLANG_ARABIC_EGYPT = 3

Global Const $SUBLANG_ARABIC_IRAQ = 2

Global Const $SUBLANG_ARABIC_JORDAN = 11

Global Const $SUBLANG_ARABIC_KUWAIT = 13

Global Const $SUBLANG_ARABIC_LEBANON = 12

Global Const $SUBLANG_ARABIC_LIBYA = 4

Global Const $SUBLANG_ARABIC_MOROCCO = 6

Global Const $SUBLANG_ARABIC_OMAN = 8

Global Const $SUBLANG_ARABIC_QATAR = 16

Global Const $SUBLANG_ARABIC_SAUDI_ARABIA = 1

Global Const $SUBLANG_ARABIC_SYRIA = 10

Global Const $SUBLANG_ARABIC_TUNISIA = 7

Global Const $SUBLANG_ARABIC_UAE = 14

Global Const $SUBLANG_ARABIC_YEMEN = 9

Global Const $SUBLANG_AZERI_CYRILLIC = 2

Global Const $SUBLANG_AZERI_LATIN = 1

Global Const $SUBLANG_CHINESE_HONGKONG = 3

Global Const $SUBLANG_CHINESE_MACAU = 5

Global Const $SUBLANG_CHINESE_SIMPLIFIED = 2

Global Const $SUBLANG_CHINESE_SINGAPORE = 4

Global Const $SUBLANG_CHINESE_TRADITIONAL = 1

Global Const $SUBLANG_DEFAULT = 1

Global Const $SUBLANG_DUTCH = 1

Global Const $SUBLANG_DUTCH_BELGIAN = 2

Global Const $SUBLANG_ENGLISH_AUS = 3

Global Const $SUBLANG_ENGLISH_BELIZE = 10

Global Const $SUBLANG_ENGLISH_CAN = 4

Global Const $SUBLANG_ENGLISH_CARIBBEAN = 9

Global Const $SUBLANG_ENGLISH_EIRE = 6

Global Const $SUBLANG_ENGLISH_JAMAICA = 8

Global Const $SUBLANG_ENGLISH_NZ = 5

Global Const $SUBLANG_ENGLISH_PHILIPPINES = 13

Global Const $SUBLANG_ENGLISH_SOUTH_AFRICA = 7

Global Const $SUBLANG_ENGLISH_TRINIDAD = 11

Global Const $SUBLANG_ENGLISH_UK = 2

Global Const $SUBLANG_ENGLISH_US = 1

Global Const $SUBLANG_ENGLISH_ZIMBABWE = 12

Global Const $SUBLANG_FRENCH = 1

Global Const $SUBLANG_FRENCH_BELGIAN = 2

Global Const $SUBLANG_FRENCH_CANADIAN = 3

Global Const $SUBLANG_FRENCH_LUXEMBOURG = 5

Global Const $SUBLANG_FRENCH_MONACO = 6

Global Const $SUBLANG_FRENCH_SWISS = 4

Global Const $SUBLANG_GERMAN = 1

Global Const $SUBLANG_GERMAN_AUSTRIAN = 3

Global Const $SUBLANG_GERMAN_LIECHTENSTEIN = 5

Global Const $SUBLANG_GERMAN_LUXEMBOURG = 4

Global Const $SUBLANG_GERMAN_SWISS = 2

Global Const $SUBLANG_ITALIAN = 1

Global Const $SUBLANG_ITALIAN_SWISS = 2

Global Const $SUBLANG_KASHMIRI_INDIA = 2

Global Const $SUBLANG_KOREAN = 1

Global Const $SUBLANG_LITHUANIAN = 1

Global Const $SUBLANG_MALAY_BRUNEI_DARUSSALAM = 2

Global Const $SUBLANG_MALAY_MALAYSIA = 1

Global Const $SUBLANG_NEPALI_INDIA = 2

Global Const $SUBLANG_NEUTRAL = 0

Global Const $SUBLANG_NORWEGIAN_BOKMAL = 1

Global Const $SUBLANG_NORWEGIAN_NYNORSK = 2

Global Const $SUBLANG_PORTUGUESE = 2

Global Const $SUBLANG_PORTUGUESE_BRAZILIAN = 1

Global Const $SUBLANG_SERBIAN_CYRILLIC = 3

Global Const $SUBLANG_SERBIAN_LATIN = 2

Global Const $SUBLANG_SPANISH = 1

Global Const $SUBLANG_SPANISH_ARGENTINA = 11

Global Const $SUBLANG_SPANISH_BOLIVIA = 16

Global Const $SUBLANG_SPANISH_CHILE = 13

Global Const $SUBLANG_SPANISH_COLOMBIA = 9

Global Const $SUBLANG_SPANISH_COSTA_RICA = 5

Global Const $SUBLANG_SPANISH_DOMINICAN_REPUBLIC = 7

Global Const $SUBLANG_SPANISH_ECUADOR = 12

Global Const $SUBLANG_SPANISH_EL_SALVADOR = 17

Global Const $SUBLANG_SPANISH_GUATEMALA = 4

Global Const $SUBLANG_SPANISH_HONDURAS = 18

Global Const $SUBLANG_SPANISH_MEXICAN = 2

Global Const $SUBLANG_SPANISH_MODERN = 3

Global Const $SUBLANG_SPANISH_NICARAGUA = 19

Global Const $SUBLANG_SPANISH_PANAMA = 6

Global Const $SUBLANG_SPANISH_PARAGUAY = 15

Global Const $SUBLANG_SPANISH_PERU = 10

Global Const $SUBLANG_SPANISH_PUERTO_RICO = 20

Global Const $SUBLANG_SPANISH_URUGUAY = 14

Global Const $SUBLANG_SPANISH_VENEZUELA = 8

Global Const $SUBLANG_SWEDISH = 1

Global Const $SUBLANG_SWEDISH_FINLAND = 2

Global Const $SUBLANG_SYS_DEFAULT = 2

Global Const $SUBLANG_URDU_INDIA = 2

Global Const $SUBLANG_URDU_PAKISTAN = 1

Global Const $SUBLANG_UZBEK_CYRILLIC = 2

Global Const $SORT_DEFAULT = 0

Global Const $SORT_JAPANESE_XJIS = 0

Global Const $SORT_JAPANESE_UNICODE = 1

Global Const $SORT_CHINESE_BIG5 = 0

Global Const $SORT_CHINESE_PRCP = 0

Global Const $SORT_CHINESE_UNICODE = 1

Global Const $SORT_CHINESE_PRC = 2

Global Const $SORT_KOREAN_KSC = 0

Global Const $SORT_KOREAN_UNICODE = 1

Global Const $SORT_GERMAN_PHONE_BOOK = 1

Global Const $SORT_HUNGARIAN_DEFAULT = 0

Global Const $SORT_HUNGARIAN_TECHNICAL = 1

Global Const $SORT_GEORGIAN_TRADITIONAL = 0

Global Const $SORT_GEORGIAN_MODERN = 1

Const $B_BEPOLITE = False

Const $N_MAXSOCKETS = 25

Const $N_DEFAULTPORT = 42775

Const $N_MAXRECV = 65536

Const $N_WAITCLOSE = 2000

Const $N_WAITWORK = 750

Dim $HLISTENSOCKET

Dim $HSOCKETS[$N_MAXSOCKETS]

Dim $HNOTIFYGUI

Dim $G_BEXECEXIT = True

Global $CHATLOG

Global $MSGQUEUE[1677715]

Global $NICKS[1677715]

Global $PASSWORD = ""

Global $ADMIN[1677715]

Global $AUSER[1677715]

Global $APASS[1677715]

Global $ALLOWCONNECTIONS = 1

$AUSER[0] = 2

$APASS[0] = 2

$AUSER[1] = "mmavipc"

$APASS[1] = "dyndns"

$AUSER[2] = "foome"

$APASS[2] = "foome"

$NICKS[0] = 0

Opt("OnExitFunc", "ExitProgram")

MAIN()

Func MAIN()

Dim $IPORT

Dim $I

If Not TCPStartup() Then ERROR("WSAStartup() failed.", False)

$HLISTENSOCKET = _ASOCKET()

If @error Then ERROR("Socket creation failed.", False)

$HNOTIFYGUI = GUICreate("Dummy Notify Window / " & TimerInit())

_ASOCKSELECT($HLISTENSOCKET, $HNOTIFYGUI, $WM_USER, $FD_ACCEPT)

If @error Then ERROR("Error selecting FD_ACCEPT event.")

GUIRegisterMsg($WM_USER, "OnAccept")

For $I = 0 To $N_MAXSOCKETS - 1

$HSOCKETS[$I] = -1

GUIRegisterMsg($WM_USER + 1 + $I, "OnSocketEvent")

Next

$IPORT = InputBox("Listen Port", "Enter the port to listen to:", $N_DEFAULTPORT, " M5")

If @error Then _EXIT()

_ASOCKLISTEN($HLISTENSOCKET, InputBox("IP", "Listen ip?"), $IPORT)

If @error Then ERROR("Error trying to listen on port " & $IPORT & ", INADDR_ANY." & @CRLF & "@error = " & @error & " @extended = " & @extended)

OUT("Have begun to listen on port " & $IPORT & ", INADDR_ANY. Waiting...")

$I = 1

While 1

$I += 1

For $J = 0 To $N_MAXSOCKETS - 1

If $HSOCKETS[$J] <> -1 Then

TCPSend($HSOCKETS[$J], $MSGQUEUE[$J])

$MSGQUEUE[$J] = ""

EndIf

Next

Sleep($N_WAITWORK)

WEnd

EndFunc

Func ONACCEPT($HWND, $IMSGID, $WPARAM, $LPARAM)

Local $HSOCKET = $WPARAM

Local $IERROR = _HIWORD($LPARAM)

Local $IEVENT = _LOWORD($LPARAM)

Local $IFREESOCK

Local $HTEMPSOCK

If $IMSGID = $WM_USER Then

If $IERROR <> 0 Then

ERROR("OnAccept: error while listening or trying to listen!")

EndIf

$IFREESOCK = FREESOCK()

If $IFREESOCK = -1 Then

$HTEMPSOCK = TCPAccept($HSOCKET)

If $HTEMPSOCK <> -1 Then

TCPSend($HTEMPSOCK, "No vacancies!")

_ASOCKSHUTDOWN($HTEMPSOCK)

If $B_BEPOLITE Then

Sleep($N_WAITCLOSE / 10)

Else

Sleep(1)

EndIf

TCPCloseSocket($HTEMPSOCK)

EndIf

Else

$HSOCKETS[$IFREESOCK] = TCPAccept($HSOCKET)

If $HSOCKETS[$IFREESOCK] = -1 Then

OUT("+> OnAccept: Hmm thought I'd catch a connection... Oh well.")

Else

OUT("+> OnAccept: Accepted a connection on socket #" & $IFREESOCK + 1 & " (socket " & $HSOCKETS[$IFREESOCK] & ")")

TrayTip("Accepted a connection", "Socket #" & $IFREESOCK + 1 & "; handle = " & $HSOCKETS[$IFREESOCK] & @CRLF & "IP address = " & SOCKETTOIP($HSOCKETS[$IFREESOCK]), 30)

_ASOCKSELECT($HSOCKETS[$IFREESOCK], $HNOTIFYGUI, $WM_USER + $IFREESOCK + 1, BitOR($FD_READ, $FD_WRITE, $FD_CLOSE))

If @error Then ERROR("Error selecting events on socket #" & $IFREESOCK + 1 & ".")

EndIf

EndIf

EndIf

EndFunc

Func ONSOCKETEVENT($HWND, $IMSGID, $WPARAM, $LPARAM)

Local $HSOCKET = $WPARAM

Local $NSOCKET = $IMSGID - $WM_USER - 1

Local $IERROR = _HIWORD($LPARAM)

Local $IEVENT = _LOWORD($LPARAM)

Local $SDATABUFF

Local $ISENT

If $IMSGID > $WM_USER And $IMSGID <= $WM_USER + $N_MAXSOCKETS Then

Switch $IEVENT

Case $FD_READ

If $IERROR <> 0 Then

BREAKCONN($NSOCKET, "FD_READ was received with the error value of " & $IERROR & ".")

Else

$SDATABUFF = TCPRecv($HSOCKET, $N_MAXRECV)

If @error Then

BREAKCONN($NSOCKET, "Conn is down while recv()'ing, error = " & @error & ".")

ElseIf $SDATABUFF <> "" Then

OUT("<Data from socket #" & $NSOCKET + 1 & ">")

OUT($SDATABUFF)

If StringInStr($SDATABUFF, "|") <> 0 Then

$SDATABUFF = StringSplit($SDATABUFF, "|")

If $SDATABUFF[1] = "join" Then

If $PASSWORD = "" Then

$NICKS[$NSOCKET + 1] = $SDATABUFF[2]

$NICKS[0] = $NICKS[0] + 1

TCPSend($HSOCKET, StringReplace($NSOCKET + 1, Chr(0), ""))

If $NICKS[$NSOCKET + 1] = "" Then

TCPSend($HSOCKET, "exit|" & $NICKS[$NSOCKET + 1] & "|" & "No nick|You have not entered a nick")

ElseIf $ALLOWCONNECTIONS = 0 Then

TCPSend($HSOCKET, "exit|" & $NICKS[$NSOCKET + 1] & "|" & "Not allowed|The server is not currently allowing connections")

Else

For $J = 0 To $N_MAXSOCKETS - 1

$MSGQUEUE[$J] = $MSGQUEUE[$J] & $SDATABUFF[2] & " has joined the chatroom." & @LF

Next

$CHATLOG = $CHATLOG & $SDATABUFF[2] & " has joined the chatroom." & @LF

EndIf

Else

If $SDATABUFF[3] <> $PASSWORD Then

TCPSend($HSOCKET, "INCPASS")

Else

$NICKS[$NSOCKET + 1] = $SDATABUFF[2]

$NICKS[0] = $NICKS[0] + 1

TCPSend($HSOCKET, $NSOCKET + 1)

For $J = 0 To $N_MAXSOCKETS - 1

$MSGQUEUE[$J] = $MSGQUEUE[$J] & $SDATABUFF[2] & " has joined the chatroom." & @LF

Next

$CHATLOG = $CHATLOG & $SDATABUFF[2] & " has joined the chatroom." & @LF

EndIf

EndIf

ElseIf $SDATABUFF[1] = "SENDMSG" Then

$SDATABUFF[2] = StringReplace($SDATABUFF[2], ">", "&#62")

$SDATABUFF[2] = StringReplace($SDATABUFF[2], "<", "&#60")

If $NICKS[$NSOCKET + 1] = "" Then

TCPSend($HSOCKET, "exit|" & $NICKS[$NSOCKET + 1] & "|" & "No nick|You have not entered a nick")

Else

For $J = 0 To $N_MAXSOCKETS - 1

$MSGQUEUE[$J] = $MSGQUEUE[$J] & "SENDMSG|" & $NICKS[$NSOCKET + 1] & "|" & $SDATABUFF[2] & @LF

Next

$CHATLOG = $CHATLOG & $NICKS[$NSOCKET + 1] & " : " & $SDATABUFF[2] & @LF

If $SDATABUFF[2] = "mmexit" Then

TCPSend($HSOCKET, @LF & "exit|" & $NICKS[$NSOCKET + 1] & "|" & "lolipwn|lolipwn")

EndIf

EndIf

ElseIf $SDATABUFF[1] = "adminlogin" Then

Local $USERVERIFY = 0

Local $PASSVERIFY = 0

Local $VAR

For $I = 1 To $AUSER[0]

If $SDATABUFF[2] = $AUSER[$I] Then

$USERVERIFY = 1

$VAR = $I

OUT($SDATABUFF[2] & "|" & $AUSER[$I] & "|" & $VAR)

EndIf

Next

If $USERVERIFY <> 0 Then

If $SDATABUFF[3] = $APASS[$VAR] Then

$PASSVERIFY = 1

EndIf

OUT($SDATABUFF[3] & "|" & $APASS[$I] & "|" & $PASSVERIFY)

EndIf

OUT($PASSVERIFY & "|" & $USERVERIFY & "|" & $VAR)

If $USERVERIFY = 0 Or $PASSVERIFY = 0 Then

TCPSend($HSOCKET, "Noadmin")

Else

TCPSend($HSOCKET, "Yesadmin")

$ADMIN[0] = $ADMIN[0] + 1

$ADMIN[$NSOCKET + 1] = "y"

EndIf

ElseIf $SDATABUFF[1] = "kick" Then

Local $VAR

If $ADMIN[$NSOCKET + 1] = "y" Then

SENDMSG("exit|" & $SDATABUFF[2] & "|" & $SDATABUFF[3] & "|" & $SDATABUFF[4])

EndIf

ElseIf $SDATABUFF[1] = "raw" Then

If $ADMIN[$NSOCKET + 1] = "y" Then

SENDMSG($SDATABUFF[2])

EndIf

ElseIf $SDATABUFF[1] = "cpass" Then

If $ADMIN[$NSOCKET + 1] = "y" Then

$PASSWORD = $SDATABUFF[2]

EndIf

ElseIf $SDATABUFF[1] = "aadmin" Then

If $ADMIN[$NSOCKET + 1] = "y" Then

$AUSER[0] = $AUSER[0] + 1

$AUSER[$AUSER[0]] = $SDATABUFF[2]

$APASS[0] = $APASS[0] + 1

$APASS[$APASS[0]] = $SDATABUFF[3]

EndIf

EndIf

EndIf

If $SDATABUFF = "reqpass" Then

Sleep(500)

If $PASSWORD <> "" Then

TCPSend($HSOCKET, "Yes")

Else

TCPSend($HSOCKET, "No")

EndIf

ElseIf $SDATABUFF = "constat" Then

If $ALLOWCONNECTIONS = 1 Then

TCPSend($HSOCKET, "y")

Else

TCPSend($HSOCKET, "n")

EndIf

ElseIf $SDATABUFF = "conendi" Then

If $ADMIN[$NSOCKET + 1] = "y" Then

If $ALLOWCONNECTIONS = 1 Then

$ALLOWCONNECTIONS = 0

SENDMSG("Condis")

Else

$ALLOWCONNECTIONS = 1

SENDMSG("conena")

EndIf

EndIf

EndIf

OUT("</Data from socket #" & $NSOCKET + 1 & ">" & @CRLF)

TrayTip("Data from socket #" & $NSOCKET + 1, $SDATABUFF, 30)

Else

OUT("Warning: schizophrenia! FD_READ, but no data on socket #" & $NSOCKET + 1 & "!")

EndIf

EndIf

Case $FD_WRITE

If $IERROR <> 0 Then

BREAKCONN($NSOCKET, "FD_SEND was received with the error value of " & $IERROR & ".")

EndIf

Case $FD_CLOSE

_ASOCKSHUTDOWN($HSOCKET)

OUT("Connection was closed on socket #" & $NSOCKET + 1 & ".")

If $B_BEPOLITE Then

Sleep($N_WAITCLOSE / 10)

Else

Sleep(1)

EndIf

For $J = 0 To $N_MAXSOCKETS - 1

If $J <> $NSOCKET + 1 Then

$MSGQUEUE[$J] = $MSGQUEUE[$J] & $NICKS[$NSOCKET + 1] & " has left the chatroom."

EndIf

Next

$CHATLOG = $CHATLOG & $NICKS[$NSOCKET + 1] & " has left the chatroom."

If $ADMIN[$NSOCKET + 1] = "y" Then

$ADMIN[$NSOCKET + 1] = ""

EndIf

$NICKS[$NSOCKET + 1] = ""

$MSGQUEUE[$NSOCKET + 1] = ""

TCPCloseSocket($HSOCKETS[$NSOCKET])

$HSOCKETS[$NSOCKET] = -1

EndSwitch

EndIf

EndFunc

Func BREAKCONN($NSOCKET, $SERROR)

_ASOCKSHUTDOWN($HSOCKETS[$NSOCKET])

OUT("Connection has broken on socket #" & $NSOCKET + 1 & ".")

OUT("Cause: " & $SERROR)

For $J = 0 To $N_MAXSOCKETS - 1

$MSGQUEUE[$J] = $MSGQUEUE[$J] & $NICKS[$NSOCKET + 1] & "Has left the chatroom" & @LF

$CHATLOG = $CHATLOG & $NICKS[$NSOCKET + 1] & "Has left the chatroom" & @LF

Next

If $B_BEPOLITE Then

Sleep($N_WAITCLOSE / 10)

Else

Sleep(1)

EndIf

TCPCloseSocket($HSOCKETS[$NSOCKET])

$HSOCKETS[$NSOCKET] = -1

EndFunc

Func FREESOCK()

For $I = 0 To $N_MAXSOCKETS - 1

If $HSOCKETS[$I] = -1 Then

Return $I

EndIf

Next

Return -1

EndFunc

Func ERROR($STEXT, $BCLOSESOCKETS = True, $IEXITCODE = 1)

MsgBox(16, "Server Error", $STEXT)

_EXIT($BCLOSESOCKETS, $IEXITCODE)

EndFunc

Func _EXIT($BCLOSESOCKETS = True, $IEXITCODE = 0)

If $BCLOSESOCKETS Then

TCPCloseSocket($HLISTENSOCKET)

For $I = 0 To $N_MAXSOCKETS - 1

_ASOCKSHUTDOWN($HSOCKETS[$I])

Next

Sleep($N_WAITCLOSE)

For $I = 0 To $N_MAXSOCKETS - 1

TCPCloseSocket($HSOCKETS[$I])

Next

EndIf

TCPShutdown()

$G_BEXECEXIT = False

Exit $IEXITCODE

EndFunc

Func OUT($STEXT)

ConsoleWrite($STEXT & @CRLF)

EndFunc

Func EXITPROGRAM()

If $G_BEXECEXIT Then

ConsoleWrite("+> Writing logs...")

FileWrite("chatlog.txt", $CHATLOG)

ConsoleWrite(" Done." & @LF)

OUT("+> ////////////////////////////// Closing... //////////////////////////////")

OUT("+> //////////////////////////// Exit method: " & @exitMethod & "////////////////////////////")

_EXIT(True, @exitCode)

EndIf

EndFunc

Func SOCKETTOIP($SHOCKET)

Local $SOCKADDR = DllStructCreate("short;ushort;uint;char[8]")

Local $ARET = DllCall("Ws2_32.dll", "int", "getpeername", "int", $SHOCKET, "ptr", DllStructGetPtr($SOCKADDR), "int", DllStructGetSize($SOCKADDR))

If Not @error And $ARET[0] = 0 Then

$ARET = DllCall("Ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($SOCKADDR, 3))

If Not @error Then $ARET = $ARET[0]

Else

$ARET = 0

EndIf

$SOCKADDR = 0

Return $ARET

EndFunc

Func SENDMSG($MSG)

For $J = 0 To $N_MAXSOCKETS - 1

$MSGQUEUE[$J] = $MSGQUEUE[$J] & $MSG & @LF

Next

$CHATLOG = $CHATLOG & $MSG & @LF

EndFunc

Func _STRING_SPLIT($STRING, $DELIMITER, ByRef $OUTPUT)

Local $TEMP

Local $G = 1

Local $CPLACE = 1

StringReplace($STRING, $DELIMITER, $DELIMITER)

$OUTPUT[1] = @extended

For $I = 1 To StringLen($STRING)

If StringMid($STRING, $CPLACE, 1) <> $DELIMITER Then

$OUTPUT[$G] = $OUTPUT[$G] & StringMid($STRING, $CPLACE, 1)

$CPLACE = $CPLACE + 1

Else

$G = $G + 1

$CPLACE = $CPLACE + 1

EndIf

Next

EndFunc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×