Free Web Hosting by Netfirms
Web Hosting by Netfirms | Free Domain Names by Netfirms

;-tcptable v0.3 ------------------------------------------------------------; ; x86 - Dos & Win32 - Assembly Language Programming ; ; ; ; Written by: John A Lyons (megablast) ; ; Email : asm@megablast.8k.com ; ; Page : http://asmsource.cjb.com/ ; ; Compiler : Masm32 v6.15 Microsoft Macro Assembler ; ; Date : 5-Aug-2002 ; ; Purpose : Simple program that displays all TCP connections ; ; and their states. ; ; ; ; v0.1: Displays TCP and UDP connections in a table, plus various ; ; statistics about them. ; ; Includes a simple help file. ; ; v0.2: Added names for certain ports. ; ; 6Aug02 Gets computer name and ip, and uses in list. ; ; Added throughput statistics. ; ; Added statistics about TCP,UDP,ICMP,IP. ; ; Added information about the various network adapters on the ; ; computer. Now displays a lot of information. ; ; ; ; ; ; ; ; Also thanks to Iczelion's Tutorial number 31, detailing how to do sorting ; ; in listviews. Extensively used this for my sorting routine. ; ; ; ; Thanks to Exagone [Thomas Bleeker] and his nettool program available at ; ; http://www.madwizard.org ; ; ; ; Most thanks goes to the assembly community for all their selfless ; ; assistance over the years. ; ; ; ; ------------------------------------------------------------------------; ;Distribution: You can freely use this code in your own applications, but ; ; you many not reproduce or publish this code on any web site, ; ; online service, or distribute as source on any media without ; ; express permission. For business or government use, you must ; ; contact the author at asm@megablast.8k.com. ; ;---------------------------------------------------------------------------; .386 .MODEL FLAT, STDCALL include windows.inc include user32.inc include kernel32.inc include comctl32.inc include gdi32.inc includelib kernel32.lib includelib user32.lib includelib comctl32.lib includelib gdi32.lib include shell32.inc includelib shell32.lib include advapi32.inc includelib advapi32.lib include iphlpapi.inc includelib iphlpapi.lib include wsock32.inc includelib wsock32.lib ;---------- procedures declared later HyperLinkWndProc PROTO :HWND, :DWORD, :DWORD, :DWORD regget proto regstring:DWORD regset proto regstring:DWORD,number:DWORD dofind proto searchstring:DWORD WinMain PROTO hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdShow:SDWORD CompareFunc proto lParam1:DWORD, lParam2:DWORD, SortType:DWORD CompareNum proto lParam1:DWORD, lParam2:DWORD, SortType:DWORD .CONST ;------------------------ Tabbed Stuff IDC_TAB1 EQU 1011 Child1Name DB "THROUGHPUTDLG",0 Child2Name DB "TCPDLG",0 Child3Name DB "UDPDLG",0 Child4Name DB "IPDLG",0 Child5Name db "ICMPDLG",0 Child6Name db "ICMPDLGOUT",0 TabTitle1 DB "Throughput",0 TabTitle2 DB "TCP Info",0 TabTitle3 DB "UDP Info",0 TabTitle4 DB "IP Info",0 TabTitle5 db "ICMP In Info",0 TabTitle6 db "ICMP Out Info",0 IDI_ICON1 equ 5 IDC_TAB1 EQU 1011 ;------------------------- buttons IDC_EXIT equ 3002 IDC_OPTIONS equ 3004 IDM_REFRESH equ 2 IDM_LIST equ 7 ;------------------------- menu IDM_EXIT equ 1 IDM_ABOUT equ 4 IDM_ONTOP equ 5 IDM_GRID equ 3 ;------------------------- About IDC_URL equ 9 IDI_CUR1 equ 101 IDI_BITMAP equ 102 ;------------------------- Search IDC_EDIT1 equ 1117 IDC_EDIT2 equ 1118 IDC_EDIT3 equ 1119 IDC_EDIT4 equ 1120 IDC_EDIT5 equ 1121 IDC_EDIT6 equ 1122 IDC_EDIT7 equ 1123 IDC_EDIT8 equ 1124 IDC_EDIT9 equ 1125 IDC_EDIT10 equ 1126 IDC_EDIT11 equ 1127 IDC_LIST equ 1014 IDC_REFRESH equ 1015 IDC_UPDATE equ 1016 IDD_LOAD equ 507 IDC_ABOUT equ 1011 IDM_HELP equ 1045 IDC_OK equ 3003 IDC_INFO equ 1019 IDC_IFLIST equ 1050 IDC_NAME equ 1000 IDC_ID equ 1001 IDC_PARENTO equ 1002 IDC_THREADS equ 1003 IDC_PRIORITY equ 1004 IDC_CREATED equ 1005 IDC_UPTIME equ 1006 IDC_VISIBLE equ 1017 IDC_ENABLE equ 1018 mrefresh db "Refresh",0 mkill db "Kill",0 mvariable db "Variable",0 LVM_SETEXTENDEDLISTVIEWSTYLE equ LVM_FIRST+54 LVS_EX_FULLROWSELECT equ 20h LVS_EX_GRIDLINES equ 1h WS_EX_LAYERED equ 80000 LWA_ALPHA equ 2 portno equ 10 porttable dw 80 db "Http",0 dw 445 db "Microsoft-DS",0 dw 7 db "Quote of the Day",0 dw 25 db "Simple Mail Transfer",0 dw 37 db "Time",0 dw 38 db "Route Access Protocol",0 dw 92 db "Network Printing Protocol",0 dw 109 db "PoP v2",0 dw 110 db "PoP v3",0 dw 115 db "Simple File Transfer Protocol",0 iftypeno equ 7 iftypetable db 1 ,"Other ",0 db 6 ,"Ethernet ",0 db 9 ,"TokenRing",0 db 15,"FDDI ",0 db 23,"PPP ",0 db 24,"LoopBack ",0 db 28,"SLIP ",0 mnotcpudp db "No Net Activity",0 .DATA ;------------------ Tabbed data hwndTab HANDLE ? Handles LABEL DWORD Child1hWnd HANDLE ? Child2hWnd HANDLE ? Child3hWnd HANDLE ? Child4hWnd HANDLE ? Child5hWnd HANDLE ? Child6hWnd HANDLE ? tabhandle dd ? lmenu dd ? wmenu dd ? mmenu dd ? sorted dd ? hwndcur HWND ? MainDlgName DB "MAINWINDOW",0 aboutdialog DB "ABOUTDIALOG",0 MenuName db "TheMenu",0 optionsdialog DB "OPTIONS",0 helpdialog DB "HELPD",0 statsdialog db "StatsTab",0 ifinfodialog db "IFINFO",0 mvar db "Variable",0 sortdir db 1 searchcount dd 0 num2 db "%lu",0 num3 db "(%lu,%lu)",0 hInstance HINSTANCE ? CommandLine LPSTR ? mem1 db "Load %%%lu",0 runcount1 db "Searches %lu",0 buff db 256 dup(?) menuhand DWORD ? first BOOL FALSE ;------------------------- Options windowmove BOOL TRUE ;------------------------- Popup Menu IDM_UPDATE equ 3 ontop db "Always On Top",0 grid db "Gridlines",0 about db "About",0 exit db "Exit",0 ;------------------------- About hover BOOL ? szOpen db "open",0 hFinger dd ? orgStatic dd ? optionshwnd dd ? tabwin dd ? memoryload dd ? mainhwnd HANDLE ? ifhwnd HANDLE ? wp WINDOWPLACEMENT ItemStruct TC_ITEM WhichTabChosen DWORD ? ;-------------------------------- Registry regstring2 db "SearchCount",0 regstring1 db "xpos",0 regstring3 db "ypos",0 regflags db "flags",0 sortflags db "sortflags",0 reglistflags db "listflags",0 subkeyname db "Software\TCPTable",0 xpos dd NULL ypos dd NULL flags dd 0 sortcol dd 0 tcphand dd 0 tcpmem dd 0 udpmem dd 0 ipmem dd 0 ifmem dd 0 IDB_MAIN equ 102 ;-------------------------------- List Box iflistview dd ? hlistview dd ? mtcp db "TCP",0 mudp db "UDP",0 mip db "IP",0 sztype db "Type",0,0,0,0,0,0,0,0,0,0,0,0 dw 50 szlocal db "Local IP",0,0,0,0,0,0,0,0 dw 150 szremote db "Remote IP",0,0,0,0,0,0,0 dw 150 szid db "State",0,0,0,0,0,0,0,0,0,0,0 dw 100 sztop db "(Left,Top)",0,0,0,0,0,0 dw 60 szbottom db "(Right,Bottom)",0,0 dw 40 szhandle db "Handle",0,0,0,0,0,0,0,0,0 dw 45 szdesc db "Description",0 szin db "Octets In",0 szout db "Octets Out",0 szphys db "Physical Address",0 szmtu db "MTU",0 tcpstate db "CLOSED ",0,"LISTEN ",0,"SYN_SENT ",0,"SYN_RCVD ",0,"ESTAB ",0,"FIN_WAIT1 ",0 db "FIN_WAIT2 ",0,"CLOSE_WAIT",0,"CLOSING ",0,"LAST_ACK ",0,"TIME_WAIT ",0,"DELETE_TCB",0 listflag dd 0 newflags dd 0 icc INITCOMMONCONTROLSEX iflistno dd ? listno dd ? totallist dd ? nohelpfile db "Can't find " ;error message, for no help file filename db "help.txt",0 ;name of help file ;--------------- TCP Stuff hostname db 128 dup(?) tcpstats dd 15 dup(0) udpstats dd 5 dup(0) ipstats dd 23 dup(0) icmpstats dd 13 dup(0) icmpstatsout dd 13 dup(0) myip dd 0 .CODE start: INVOKE GetModuleHandle, NULL MOV hInstance,EAX INVOKE WinMain, hInstance,NULL,SW_SHOWDEFAULT INVOKE ExitProcess,EAX WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdShow:SDWORD invoke InitCommonControlsEx, ADDR icc MOV EAX, OFFSET DlgProc INVOKE DialogBoxParam, hInst, OFFSET MainDlgName,NULL,EAX,NULL mov eax,hInst mov hInstance,eax RET WinMain endp HelpDlgProc PROC hWnd:HWND,iMsg:DWORD,wParam:WPARAM, lParam:LPARAM ;----------------help window LOCAL hhand : DWORD LOCAL hmem : DWORD LOCAL filebuff : OFSTRUCT LOCAL filesize : DWORD LOCAL filehand : DWORD mov eax,iMsg .if eax==WM_INITDIALOG invoke OpenFile, ADDR filename,ADDR filebuff,OF_READ cmp eax,-1 je notopen mov [filehand],eax invoke GetFileSize,filehand,addr buff mov [filesize],eax add eax,100 invoke GlobalAlloc,GMEM_MOVEABLE,eax cmp eax,NULL je enditall2 mov [hhand],eax invoke GlobalLock,eax cmp eax,NULL je enditall ;mov [hmem],eax push eax invoke ReadFile,filehand,eax,filesize,addr buff,NULL cmp eax,TRUE jne enditall pop edx add edx,22 invoke SendDlgItemMessage, hWnd, 1031, WM_SETTEXT, 0,edx enditall: invoke GlobalFree,hhand enditall2: xor eax,eax ret notopen: invoke SendDlgItemMessage,hWnd,1031,WM_SETTEXT,0,ADDR nohelpfile ret .elseif eax==WM_CLOSE aclose2: invoke GlobalFree,hhand invoke EndDialog,hWnd,NULL invoke DestroyWindow,hWnd .elseif eax==WM_COMMAND push edx mov eax,wParam mov edx,eax shr edx,16 .if ax==IDC_EXIT jmp aclose2 .endif pop edx .else mov eax,FALSE ret .endif mov eax,TRUE ret HelpDlgProc endp HyperLinkWndProc PROC uses ebx, hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD LOCAL tmpFont :LOGFONT LOCAL rect:RECT LOCAL pt:POINT LOCAL ps:PAINTSTRUCT mov eax,uMsg .IF eax==WM_NCHITTEST mov eax, 1 ret .ELSEIF eax == WM_CTLCOLORSTATIC push ebx push edx invoke SendMessage, hWnd, WM_GETFONT, 0, 0 mov edx,eax invoke GetObject, edx, sizeof LOGFONT, addr tmpFont mov tmpFont.lfUnderline, TRUE invoke CreateFontIndirect, addr tmpFont mov ebx,eax invoke SelectObject, wParam, ebx .if hover == FALSE invoke SetTextColor, wParam, Blue .else invoke SetTextColor, wParam,Red .endif invoke GetSysColor, COLOR_MENU invoke SetBkColor, wParam, eax invoke DeleteObject,ebx invoke GetStockObject, HOLLOW_BRUSH pop edx pop ebx ret .ELSEIF eax==WM_MOUSEMOVE invoke GetParent,hWnd push ebx mov ebx,eax invoke GetActiveWindow .if eax == ebx invoke GetCursorPos,addr pt invoke GetWindowRect,hWnd,addr rect invoke PtInRect,addr rect,pt.x,pt.y .if eax invoke GetCapture .if !eax invoke SetCapture,hWnd mov hover,TRUE invoke InvalidateRect,hWnd,FALSE,FALSE invoke SetCursor,hFinger .endif .else invoke GetCapture .if eax invoke ReleaseCapture mov hover,FALSE invoke InvalidateRect,hWnd,FALSE,FALSE .endif .endif .endif pop ebx xor eax,eax ret .ELSEIF eax==WM_LBUTTONDOWN invoke GetWindowText,hWnd,offset buff,sizeof buff invoke ShellExecute, NULL, offset szOpen, offset buff, NULL, NULL, SW_MAXIMIZE mov hover,FALSE invoke InvalidateRect,hWnd,FALSE,FALSE invoke SendMessage, hWnd, WM_GETFONT, 0, 0 mov edx,eax invoke GetObject, edx, sizeof LOGFONT, addr tmpFont mov tmpFont.lfUnderline, TRUE invoke CreateFontIndirect, addr tmpFont mov ebx,eax invoke SelectObject, wParam, ebx invoke SetTextColor, wParam, Blue xor eax,eax ret .ENDIF invoke CallWindowProc, orgStatic, hWnd, uMsg, wParam, lParam ret HyperLinkWndProc endp AboutDlgProc PROC hWnd:HWND,iMsg:DWORD,wParam:WPARAM, lParam:LPARAM LOCAL hdc:DWORD LOCAL ps:PAINTSTRUCT LOCAL rect:RECT mov eax,iMsg .if eax==WM_INITDIALOG invoke GetDlgItem, hWnd, IDC_URL invoke SetWindowLong, eax, GWL_WNDPROC, ADDR HyperLinkWndProc mov orgStatic,eax invoke LoadCursor,hInstance,IDI_CUR1 mov hFinger,eax push [searchcount] push offset runcount1 push offset buff call wsprintfA add esp,0ch invoke SendDlgItemMessage, hWnd, IDD_LOAD, WM_SETTEXT, 0,ADDR buff xor eax,eax ret .ELSEIF eax == WM_CTLCOLORSTATIC invoke SendMessage,lParam,iMsg,wParam,lParam ret .elseif eax==WM_CLOSE aclose: invoke EndDialog,hWnd,NULL invoke DestroyWindow,hWnd .elseif eax==WM_COMMAND push edx mov eax,wParam mov edx,eax shr edx,16 .if ax==IDC_EXIT jmp aclose .endif pop edx .else mov eax,FALSE ret .endif mov eax,TRUE ret AboutDlgProc endp AddCol proc hwndListView:DWORD, iColIndex:DWORD, iColMask:DWORD, iColFormat:DWORD, iColImage:DWORD, iColWidth:DWORD, pszColText:DWORD LOCAL lcNew:LVCOLUMN mov eax,[iColMask] mov [lcNew.imask],eax mov eax,[iColImage] mov [lcNew.iImage],eax mov eax,[iColFormat] mov [lcNew.fmt],eax mov eax,[iColWidth] mov [lcNew.lx],eax mov eax,[iColIndex] mov [lcNew.iSubItem],eax mov eax, [pszColText] mov [lcNew.pszText], eax invoke lstrlen, eax mov [lcNew.cchTextMax], eax and [lcNew.iOrder], 0 invoke SendMessage, [hwndListView], LVM_INSERTCOLUMN, [iColIndex], ADDR lcNew ret AddCol endp AddItem proc hwndListView:DWORD, iItemIndex:DWORD, iSubItemIndex:DWORD, iItemMask:DWORD, iItemImage:DWORD, iItemIndent:DWORD, lParam:DWORD, pszItemText:DWORD, lenItemText:DWORD, bAction:BYTE LOCAL liNew:LV_ITEM mov eax, [iItemMask] mov [liNew.imask],eax mov eax,[iItemIndex] mov [liNew.iItem],eax mov eax, [iSubItemIndex] mov [liNew.iSubItem],eax mov eax, [iItemImage] mov [liNew.iImage],eax mov eax,[lParam] mov [liNew.lParam],eax mov edx, [pszItemText] mov [liNew.pszText], edx mov eax, [lenItemText] mov [liNew.cchTextMax], eax .if !eax invoke lstrlen, edx mov [liNew.cchTextMax], eax .endif and [liNew.state], 0 and [liNew.stateMask], 0 .if ![bAction] invoke SendMessage, [hwndListView], LVM_INSERTITEM, 0, ADDR liNew .else invoke SendMessage, [hwndListView], LVM_SETITEM, 0, ADDR liNew .endif ret AddItem endp GetItem proc hwndListView:DWORD, iItemIndex:DWORD, iSubItemIndex:DWORD, iItemMask:DWORD, pItemImage:DWORD, pItemIndent:DWORD, lpParam:DWORD, pszItemText:DWORD, lenItemText:DWORD LOCAL liNew:LV_ITEM push [iItemMask] pop [liNew.imask] push [iItemIndex] pop [liNew.iItem] push [iSubItemIndex] pop [liNew.iSubItem] push [pszItemText] pop [liNew.pszText] push [lenItemText] pop [liNew.cchTextMax] invoke SendMessage, [hwndListView], LVM_GETITEM, 0, ADDR liNew ret GetItem endp DlgProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM LOCAL hdc:DWORD LOCAL rect:RECT LOCAL Disp :DWORD LOCAL pKey :DWORD LOCAL Temp :DWORD LOCAL item :LV_ITEM LOCAL windowp : WINDOWPLACEMENT LOCAL liNew:LV_ITEM LOCAL wsadata:WSADATA mov eax,uMsg .if ax==WM_CLOSE bigclose: invoke WSACleanup invoke GetWindowRect,hWnd,ADDR rect mov eax,rect.top mov eax,rect.left mov eax,[searchcount] invoke regset,ADDR regstring2,eax mov eax,xpos invoke regset,ADDR regstring1,eax mov eax,ypos invoke regset,ADDR regstring3,eax mov eax,[flags] invoke regset,ADDR regflags,eax xor eax,eax mov al,[sortdir] shl eax,8 add eax,[sortcol] invoke regset,ADDR sortflags,eax mov eax,[listflag] invoke regset,ADDR reglistflags,eax invoke GlobalFree,[tcphand] invoke DestroyMenu,[wmenu] invoke DestroyMenu,[lmenu] INVOKE ExitProcess,0 RET .ELSEIF ax==WM_SYSCOMMAND mov eax,[wParam] .IF ax==IDM_ABOUT lea eax,AboutDlgProc invoke CreateDialogParam,hInstance,addr aboutdialog,hWnd,eax,NULL .endif xor eax,eax ret .elseif ax==WM_MOVE mov eax,[lParam] push eax and eax,0ffffh mov [xpos],eax pop eax shr eax,16 mov [ypos],eax .elseif ax==WM_INITDIALOG mov eax,hWnd mov mainhwnd,eax invoke WSAStartup, 0101h, ADDR wsadata cmp eax,0 jne wsfail invoke gethostname, ADDR hostname, 128 cmp eax,0 jne cleanup invoke SendDlgItemMessage, mainhwnd, IDC_UPDATE, WM_SETTEXT, 0,ADDR hostname invoke gethostbyname, ADDR hostname ;get computer name cmp eax,NULL je cleanup mov ebx, eax ;getip assume ebx: ptr hostent mov eax, [ebx].h_list assume ebx: nothing mov ebx, eax mov eax,[ebx] mov eax,[eax] mov [myip],eax invoke inet_ntoa, eax lea edi,buff ;construct name:ip lea esi,hostname copyname4: mov ch,[esi] mov [edi],ch inc esi inc edi or ch,ch jnz copyname4 cmp eax,NULL je noip4 mov [edi-1],byte ptr ":" copyip4: mov ch,[eax] mov [edi],ch inc eax inc edi or ch,ch jnz copyip4 noip4: invoke SendDlgItemMessage, mainhwnd, IDC_UPDATE, WM_SETTEXT, 0,addr buff cleanup: wsfail: invoke GlobalAlloc,GMEM_MOVEABLE,20480 ;need some memory for the table mov [tcphand],eax invoke GlobalLock,eax mov [tcpmem],eax invoke LoadMenu,hInstance,OFFSET MenuName ;600 mov [mmenu],eax invoke SetMenu,hWnd,eax invoke LoadIcon, hInstance, IDI_ICON1 invoke SendMessage, hWnd, WM_SETICON, ICON_SMALL, eax invoke regget,ADDR regstring2 cmp eax,-1 je notrun invoke regget,ADDR sortflags push eax and eax,0ffh mov [sortcol],eax add eax,20 invoke CheckMenuItem,[mmenu],eax,MF_UNCHECKED pop eax shr eax,8 mov [sortdir],al xor [sortdir],1 call changedir mov [searchcount],eax invoke regget,ADDR regstring1 mov xpos,eax invoke regget,ADDR regstring3 mov ypos,eax invoke SetWindowPos,hWnd,NULL,xpos,ypos,0,0,SWP_NOSIZE+SWP_NOZORDER invoke regget,ADDR regflags mov [flags],eax invoke regget,ADDR reglistflags or eax,eax jz flagis0 cmp eax,-1 jne flagisok flagis0: mov eax,127 flagisok: mov [newflags],eax jmp isrun notrun: mov [newflags],127 isrun: ;invoke GetMenu,[hWnd] ;mov [mmenu],eax invoke CreatePopupMenu mov [wmenu],eax mov eax,[searchcount] push eax push offset runcount1 push offset buff call wsprintfA add esp,0ch invoke AppendMenu,wmenu,MF_STRING,IDM_GRID,ADDR grid invoke AppendMenu,wmenu,MF_STRING,IDM_ONTOP,ADDR ontop invoke AppendMenu,wmenu,MF_STRING,IDM_ABOUT,ADDR about invoke AppendMenu,wmenu,MF_SEPARATOR,0,0 invoke AppendMenu,wmenu,MF_STRING,IDM_EXIT,ADDR exit test [flags],4 jne notgrid invoke CheckMenuItem,wmenu,IDM_GRID,MF_CHECKED notgrid: ; test [flags],8 ; jne notontop ; invoke CheckMenuItem,wmenu,IDM_ONTOP,MF_CHECKED call doontop notontop: invoke CreatePopupMenu mov [lmenu],eax invoke AppendMenu,lmenu,MF_STRING,96,ADDR mrefresh invoke AppendMenu,lmenu,MF_SEPARATOR,0,0 invoke AppendMenu,lmenu,MF_STRING,99,ADDR mkill invoke GetSystemMenu,hWnd,FALSE invoke AppendMenu,eax,MF_STRING,IDM_ABOUT,ADDR about invoke GetWindowRect,mainhwnd,ADDR rect mov eax,rect.top mov ypos,eax mov eax,rect.left mov xpos,eax ;setup main list-tcp and udp entries invoke GetDlgItem, [hWnd],IDC_LIST mov [hlistview], eax invoke SendMessage, eax, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT + LVS_EX_GRIDLINES invoke AddCol, [hlistview], 0, LVCF_FMT OR LVCF_WIDTH OR LVCF_TEXT OR LVCF_SUBITEM, LVCFMT_LEFT, 0, 50,ADDR sztype invoke AddCol, [hlistview], 1, LVCF_FMT OR LVCF_WIDTH OR LVCF_TEXT OR LVCF_SUBITEM, LVCFMT_LEFT, 0, 150,ADDR szlocal invoke AddCol, [hlistview], 2, LVCF_FMT OR LVCF_WIDTH OR LVCF_TEXT OR LVCF_SUBITEM, LVCFMT_LEFT, 0, 150, ADDR szremote invoke AddCol, [hlistview], 3, LVCF_FMT OR LVCF_WIDTH OR LVCF_TEXT OR LVCF_SUBITEM, LVCFMT_LEFT, 0, 100, ADDR szid ;invoke AddCol, [hlistview], 4, LVCF_FMT OR LVCF_WIDTH OR LVCF_TEXT OR LVCF_SUBITEM, LVCFMT_LEFT, 0, 60, ADDR sztop ;invoke AddCol, [hlistview], 5, LVCF_FMT OR LVCF_WIDTH OR LVCF_TEXT OR LVCF_SUBITEM, LVCFMT_LEFT, 0, 20, ADDR szbottom ;invoke AddCol, [hlistview], 6, LVCF_FMT OR LVCF_WIDTH OR LVCF_TEXT OR LVCF_SUBITEM, LVCFMT_LEFT, 0, 45, ADDR szhandle mov [listflag],15 call setupcolumns ;invoke gethostname,addr buff,256 ;invoke SendDlgItemMessage, mainhwnd, IDC_UPDATE, WM_SETTEXT, 0,ADDR buff invoke GetTcpStatistics, addr tcpstats invoke GetUdpStatistics, addr udpstats invoke GetIpStatistics, addr ipstats invoke GetIcmpStatistics,addr icmpstats call showstats call windowscan RET .ELSEIF ax==WM_COMMAND mov eax,wParam .IF lParam==0 .IF ax==IDM_REFRESH refresh: invoke GetTcpStatistics, addr tcpstats invoke GetUdpStatistics, addr udpstats invoke GetIpStatistics, addr ipstats call showstats invoke SendMessage, [hlistview], LVM_DELETEALLITEMS, 0, 0 call windowscan xor eax,eax ret .ELSEIF ax==IDM_UPDATE xor windowmove,1 cmp windowmove,TRUE je setupdate invoke CheckMenuItem,wmenu,IDM_UPDATE,MF_UNCHECKED jmp noupdate1 setupdate: invoke CheckMenuItem,wmenu,IDM_UPDATE,MF_CHECKED noupdate1: .ELSEIF ax==IDM_ABOUT bigabout: lea eax,AboutDlgProc invoke CreateDialogParam,hInstance,addr aboutdialog,hWnd,eax,NULL xor eax,eax ret .ELSEIF ax==IDM_HELP ;help window lea eax,HelpDlgProc invoke CreateDialogParam,hInstance,addr helpdialog,hWnd,eax,NULL xor eax,eax ret .ELSEIF ax==IDM_GRID invoke SendMessage, [hlistview], LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT+1 ret .ELSEIF ax==IDM_LIST gooptions: mov eax,[listflag] mov [newflags],eax lea eax,OptionsDlgProc invoke CreateDialogParam,hInstance,addr optionsdialog,hWnd,eax,NULL mov [optionshwnd],eax xor eax,eax ret .ELSEIF ax==IDM_ONTOP xor [flags],8 call doontop xor eax,eax ret .ELSEIF ax==98 .ELSEIF ax==40 mov [sortdir],1 changedir3: call changedir mov eax,[sortcol] add eax,20 call gosortit ret .ELSEIF ax==41 mov [sortdir],0 jmp changedir3 .elseif ax==96 jmp refresh .ELSEIF ax==99 mov eax,[listno] mov esi,[tcpmem] xor edx,edx mov ecx,20 mul ecx add eax,4 add esi,eax mov [esi],dword ptr 12 ;MIB_TCP_STATE_DELETE_TCB invoke SetTcpEntry, esi jmp refresh xor eax,eax ret .ELSEIF ax==IDM_EXIT jmp bigclose .endif cmp eax,20 jb notsort cmp eax,27 ja notsort cmp eax,20 jne nonone call gosortit jmp refresh nonone: call gosortit notsort: ret .ENDIF mov eax,wParam mov edx,eax shr edx,16 .IF ax==IDC_REFRESH lea eax,StatsDlgProc invoke CreateDialogParam,hInstance,addr statsdialog,hWnd,eax,NULL ret .elseif ax==IDC_INFO lea eax,IfDlgProc invoke CreateDialogParam,hInstance,addr ifinfodialog,hWnd,eax,NULL ret .elseif ax==IDC_OPTIONS jmp gooptions .ELSEIF ax==IDC_EXIT jmp bigclose .ELSEIF ax==IDC_ABOUT jmp bigabout .ENDIF xor eax,eax ret .elseif ax==WM_NOTIFY mov edi, [lParam] mov eax, (NMHDR ptr [edi]).hwndFrom .if eax==hlistview mov eax, (NMHDR ptr [edi]).code .if eax==LVN_ITEMCHANGED mov eax, (NMLISTVIEW ptr [edi]).iItem mov [listno],eax ret .elseif eax==NM_RCLICK ;pnmh = (NMHDR FAR *) lParam; push ebx mov edi,[lParam] mov ebx, (NMLISTVIEW ptr [edi]).ptAction.x add ebx,xpos mov ecx, (NMLISTVIEW ptr [edi]).ptAction.y add ecx,ypos invoke TrackPopupMenu,lmenu,TPM_CENTERALIGN +TPM_LEFTBUTTON,ebx,ecx,0,hWnd,NULL pop ebx xor eax,eax ret .elseif eax==NM_DBLCLK invoke FlashWindow,[hwndcur],TRUE xor eax,eax ret .endif .endif .ELSEIF ax==WM_RBUTTONDOWN push ebx mov ebx,lParam mov ecx,ebx and ebx,0ffffh shr ecx,16 add ebx,xpos add ecx,ypos add ecx,20 invoke TrackPopupMenu,wmenu,TPM_CENTERALIGN +TPM_LEFTBUTTON,ebx,ecx,0,hWnd,NULL pop ebx ret .endif xor EAX,EAX RET DlgProc endp changedir proc push eax xor eax,eax mov al,[sortdir] add eax,40 invoke CheckMenuItem,[mmenu],eax,MF_UNCHECKED xor [sortdir],1 xor eax,eax mov al,[sortdir] add eax,40 invoke CheckMenuItem,[mmenu],eax,MF_CHECKED pop eax ret changedir endp gosortit proc push eax mov eax,[sortcol] add eax,20 invoke CheckMenuItem,[mmenu],eax,MF_UNCHECKED pop eax push eax invoke CheckMenuItem,[mmenu],eax,MF_CHECKED pop eax sub eax,20 mov [sortcol],eax or eax,eax jz nonosort4 ;call changedir dec eax ;cmp eax,3 ;je numsort ;cmp eax,6 ;je numsort lea edi,CompareFunc jmp gogosort numsort: lea edi,CompareNum gogosort: invoke SendMessage,[hlistview],LVM_SORTITEMS,eax,edi call updatelist nonosort4: xor eax,eax ret gosortit endp binary proc push ecx lea edi,buff mov ecx,32 reset1: mov dl,'0' shl eax,1 jnc set1 inc dl set1: mov [edi],dl inc edi loop reset1 mov [edi],byte ptr 0 pop ecx ret binary endp doontop proc test [flags],8 je notontop2 mov ecx,HWND_NOTOPMOST mov eax,MF_UNCHECKED jmp gotop notontop2: mov ecx,HWND_TOPMOST mov eax,MF_CHECKED gotop: push ecx push eax invoke CheckMenuItem,[wmenu],IDM_ONTOP,eax pop eax invoke CheckMenuItem,[mmenu],IDM_ONTOP,eax pop ecx invoke SetWindowPos,[mainhwnd],ecx,0,0,0,0,SWP_NOMOVE+SWP_NOSIZE+SWP_SHOWWINDOW ret doontop endp regget proc regstring:DWORD LOCAL number:DWORD LOCAL Disp :DWORD LOCAL pKey :DWORD LOCAL Temp :DWORD mov Temp,4 invoke RegCreateKeyEx, HKEY_LOCAL_MACHINE,ADDR subkeyname, NULL, NULL,REG_OPTION_NON_VOLATILE,KEY_READ, NULL,addr pKey, addr Disp cmp eax,ERROR_SUCCESS jne regok1 invoke RegQueryValueEx, pKey, regstring,NULL, ADDR Disp, ADDR number, ADDR Temp cmp eax,ERROR_SUCCESS jne regok1 invoke RegCloseKey, pKey mov eax,number ret regok1: mov eax,-1 ret regget endp regset proc regstring:DWORD,number:DWORD LOCAL Disp :DWORD LOCAL pKey :DWORD LOCAL Temp :DWORD mov Temp,4 invoke RegCreateKeyEx, HKEY_LOCAL_MACHINE,ADDR subkeyname, NULL, NULL,REG_OPTION_NON_VOLATILE,KEY_WRITE, NULL, addr pKey, addr Disp cmp eax,ERROR_SUCCESS jne regok2 invoke RegSetValueEx, pKey, regstring,NULL, REG_DWORD_LITTLE_ENDIAN,ADDR number, Temp invoke RegCloseKey, pKey regok2: ret regset endp windowscan proc LOCAL winrect : RECT LOCAL tcpsize : DWORD LOCAL named : BOOL local tcprows : dword local base : dword local portno2 : dword mov [tcpsize],10240 push ebx mov [listno],0 invoke GetTcpTable,[tcpmem],addr tcpsize,FALSE mov esi,[tcpmem] cmp eax,NO_ERROR jne tcperror mov eax,[esi] mov [tcprows],eax mov [totallist],eax or eax,eax jz tcperror add esi,4 ;typedef struct _MIB_TCPROW { ; DWORD dwState; // state of the connection ; DWORD dwLocalAddr; // address on local computer ; DWORD dwLocalPort; // port number on local computer ; DWORD dwRemoteAddr; // address on remote computer ; DWORD dwRemotePort; // port number on remote computer ;} MIB_TCPROW, *PMIB_TCPROW; ;assume esi:ptr MIB_TCPROW xor ecx,ecx ;fill in rows of table morerows: push ecx invoke AddItem, [hlistview], [listno], 0, LVIF_TEXT OR LVIF_PARAM, 0, 0, [listno], addr mtcp, 100, 0 mov [base],1 mov ecx,2 test [listflag],ecx jz dontshow1 push ecx mov eax,[esi+4] ;local IP mov ebx,[esi+8] call combineip mov [portno2],ebx push esi invoke AddItem, [hlistview], [listno], [base], LVIF_TEXT, 0, 0, [listno], ADDR buff, 1, 1 pop esi inc [base] pop ecx dontshow1: inc ecx test [listflag],ecx jz dontshow2 push ecx mov eax,[esi+12] ;remote IP mov ebx,[esi+16] call combineip push esi invoke AddItem, [hlistview], [listno], [base], LVIF_TEXT, 0, 0, [listno], ADDR buff, 1, 1 pop esi pop ecx inc [base] dontshow2: inc ecx test [listflag],ecx jz dontshow3 mov eax,[esi] dec eax xor edx,edx mov ebx,11 mul ebx lea edi,tcpstate add edi,eax ;push [esi] ;push offset num2 ;push offset buff ;call wsprintfA ;add esp,12 push esi invoke AddItem, [hlistview], [listno], [base], LVIF_TEXT, 0, 0, [listno], edi, 1, 1 pop esi dontshow3: pop ecx inc [listno] add esi,20 ;cmp ecx,[tcprows] inc ecx cmp ecx,[tcprows] jb morerows mov eax,[tcpsize] add eax,[tcpmem] sub eax,esi mov [tcpsize],eax mov eax,[tcprows] call printeax invoke SendDlgItemMessage, mainhwnd, IDC_EDIT1, WM_SETTEXT, 0,ADDR buff invoke getservbyport,[portno2],NULL cmp eax,NULL je noportinfo mov edi,[eax] invoke SendDlgItemMessage, mainhwnd, IDC_EDIT1, WM_SETTEXT, 0,edi noportinfo: tcperror: mov [udpmem],esi ;udp stuff invoke GetUdpTable,esi,addr tcpsize,FALSE cmp eax,NO_ERROR jne udperror mov esi,[udpmem] mov eax,[esi] mov [tcprows],eax add [totallist],eax or eax,eax jz udperror add esi,4 xor ecx,ecx ;fill in rows of table morerows2: push ecx push esi invoke AddItem, [hlistview], [listno], 0, LVIF_TEXT OR LVIF_PARAM, 0, 0, [listno], addr mudp, 100, 0 pop esi mov [base],1 mov eax,[esi] ;local IP\ mov ebx,[esi+4] call combineip push esi invoke AddItem, [hlistview], [listno], [base], LVIF_TEXT, 0, 0, [listno], ADDR buff, 1, 1 pop esi pop ecx inc [listno] add esi,8 inc ecx cmp ecx,[tcprows] jb morerows2 udperror: push esi mov eax,[tcprows] or eax,eax jnz wehavesome invoke AddItem, [hlistview], [listno], 0, LVIF_TEXT OR LVIF_PARAM, 0, 0, [listno], addr mnotcpudp, 1, 0 xor eax,eax wehavesome: call printeax invoke SendDlgItemMessage, mainhwnd, IDC_EDIT10, WM_SETTEXT, 0,ADDR buff pop esi mov [ipmem],esi ;IP stuff invoke GetIpNetTable,esi,addr tcpsize,FALSE cmp eax,NO_ERROR je noiperror ;FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, Error, LANG_SYSTEM_DEFAULT, BufErr, 80, NULL); ;invoke FormatMessage,FORMAT_MESSAGE_FROM_SYSTEM,NULL,eax,0,addr buff,80,NULL ;invoke AddItem, [hlistview], [listno], 0, LVIF_TEXT OR LVIF_PARAM, 0, 0, [listno], addr buff, 100, 0 jmp iperror noiperror: mov esi,[ipmem] mov eax,[esi] mov [tcprows],eax add [totallist],eax add esi,4 xor ecx,ecx ;fill in rows of table morerows3a: push ecx push esi invoke AddItem, [hlistview], [listno], 0, LVIF_TEXT OR LVIF_PARAM, 0, 0, [listno], addr mip, 100, 0 pop esi mov [base],1 ;mov eax,[esi] ;local IP\ ;mov ebx,[esi+4] ;call combineip ;push esi ; invoke AddItem, [hlistview], [listno], [base], LVIF_TEXT, 0, 0, [listno], ADDR buff, 1, 1 ;pop esi pop ecx inc [listno] add esi,8 inc ecx cmp ecx,[tcprows] jb morerows3a iperror: pop ebx mov [ifmem],esi mov eax,[tcprows] call printeax invoke SendDlgItemMessage, mainhwnd, IDC_EDIT10, WM_SETTEXT, 0,ADDR buff ;invoke AddItem, [hlistview], [listno], 0, LVIF_TEXT OR LVIF_PARAM, 0, 0, [listno], ADDR buff, 100, 0 ret windowscan endp combineip proc ;combine ip(eax) and port number(ebx) local temp:dword or eax,eax jz isme2 cmp eax,[myip] jne findip isme2: lea edi,buff lea eax,hostname jmp movenet1 findip: invoke inet_ntoa,eax lea edi,buff movenet1: mov ch,[eax] mov [edi],ch inc edi inc eax or ch,ch jnz movenet1 mov [edi-1],byte ptr ":" mov edx, ebx shr edx, 8 shl bx, 8 or ebx, edx call isitgood or eax,eax jz wasgood push ebx push ebx push offset num2 push edi call wsprintfA add esp,12 pop ebx wasgood: ret combineip endp isitgood proc mov ecx,portno push esi lea esi,porttable findportno: cmp bx,[esi] je gotportno add esi,2 notzero2: inc esi cmp [esi],byte ptr 0 jne notzero2 inc esi loop findportno pop esi mov eax,-1 ret gotportno: add esi,2 moveportno: mov ah,[esi] mov [edi],ah inc esi inc edi or ah,ah jnz moveportno pop esi xor eax,eax ret isitgood endp updatelist proc LOCAL lvi:LV_ITEM mov ecx,[totallist] mov lvi.imask,LVIF_PARAM mov lvi.iSubItem,0 mov lvi.iItem,0 listloop: push ecx push lvi.iItem pop lvi.lParam invoke SendMessage,[hlistview], LVM_SETITEM,0,addr lvi inc lvi.iItem pop ecx loop listloop ret updatelist endp CompareFunc proc lParam1:DWORD, lParam2:DWORD, SortType:DWORD invoke GetItem, [hlistview], [lParam1], [SortType], LVIF_TEXT OR LVIF_PARAM, 0, 0, [mainhwnd], ADDR buff, 99 invoke GetItem, [hlistview], [lParam2], [SortType], LVIF_TEXT OR LVIF_PARAM, 0, 0, [mainhwnd], ADDR buff+100, 99 lea esi,buff mov ecx,99 cmp [sortdir],0 je sortfor comp1: mov ah,[esi] cmp ah,[esi+100] ja goneg jb gopos inc esi loop comp1 xor eax,eax ret gopos: mov eax,1 ret goneg: mov eax,-1 ret sortfor: comp1a: mov ah,[esi] cmp ah,[esi+100] ja gopos jb goneg inc esi loop comp1a goeven: xor eax,eax ret CompareFunc endp CompareNum proc lParam1:DWORD, lParam2:DWORD, SortType:DWORD invoke GetItem, [hlistview], [lParam1], [SortType], LVIF_TEXT OR LVIF_PARAM, 0, 0, [mainhwnd], ADDR buff, 99 invoke GetItem, [hlistview], [lParam2], [SortType], LVIF_TEXT OR LVIF_PARAM, 0, 0, [mainhwnd], ADDR buff+100, 99 lea esi,buff call getnum push eax lea esi,buff+100 call getnum pop ecx cmp [sortdir],1 je numfor xchg eax,ecx numfor: sub eax,ecx ret CompareNum endp getnum proc push ebx push ecx xor eax,eax xor ecx,ecx mov ebx,10 renum: mov cl,[esi] cmp cl,0 je endnum sub cl,"0" mul ebx add eax,ecx inc esi jmp renum endnum: pop ecx pop ebx ret getnum endp OptionsDlgProc PROC hWnd:HWND,iMsg:DWORD,wParam:WPARAM, lParam:LPARAM LOCAL hdc:DWORD LOCAL ps:PAINTSTRUCT LOCAL rect:RECT mov eax,iMsg .if eax==WM_INITDIALOG invoke GetDlgItem, hWnd, IDC_URL invoke SetWindowLong, eax, GWL_WNDPROC, ADDR HyperLinkWndProc mov orgStatic,eax invoke LoadCursor,hInstance,IDI_CUR1 mov hFinger,eax invoke SendDlgItemMessage, hWnd, IDD_LOAD, WM_SETTEXT, 0,ADDR buff push ebx mov ecx,7 mov eax,[listflag] mov edx,IDC_NAME checkall: xor ebx,ebx rcr eax,1 jnc notcheck1 mov ebx,BST_CHECKED notcheck1: push edx push ecx push eax invoke CheckDlgButton,[hWnd],edx,ebx pop eax pop ecx pop edx inc edx loop checkall pop ebx xor eax,eax ret .elseif eax==WM_CLOSE aclose: ;invoke MessageBox,hWnd,addr buff,addr buff+50,MB_OK aclose2: invoke EndDialog,hWnd,NULL invoke DestroyWindow,hWnd .elseif eax==WM_COMMAND mov eax,wParam .if ax==IDC_EXIT ;press CANCEL button ;invoke SendMessage,[hlistview],LVM_DELETECOLUMN,0,0 jmp aclose2 .elseif ax==IDC_OK ;press OK button invoke SendMessage, [hlistview], LVM_DELETEALLITEMS, 0, 0 call setupcolumns call windowscan jmp aclose .elseif ax==IDC_NAME xor [newflags],1 .elseif ax==IDC_ID xor [newflags],2 .elseif ax==IDC_PARENTO xor [newflags],4 .elseif ax==IDC_THREADS xor [newflags],8 .elseif ax==IDC_PRIORITY xor [newflags],16 .elseif ax==IDC_CREATED xor [newflags],32 .elseif ax==IDC_UPTIME xor [newflags],64 ;invoke SendMessage,[hlistview],LVM_DELETECOLUMN,0,0 .elseif ax==1001 ;invoke SendMessage,[hlistview],LVM_DELETECOLUMN,0,0 .endif ;pop edx .else mov eax,FALSE ret .endif mov eax,TRUE ret OptionsDlgProc endp setupcolumns proc ;adds or deletes columns, depending on options change(or initial change) LOCAL lcNew:LVCOLUMN local goodbit:DWORD local count:WORD local colend:WORD push ebx push [listflag] push offset num2 push offset buff call wsprintfA add esp,12 push [newflags] push offset num2 push offset buff+50 call wsprintfA add esp,12 lea esi,szid mov [goodbit],8 mov eax,[listflag] ;old flags mov ebx,1 xor ecx,ecx checksetf: test eax,ebx jz notsetf inc cx xor eax,ebx notsetf: shl ebx,1 or eax,eax jnz checksetf dec cx mov [colend],cx;6 mov [count],4 changecols: mov eax,[newflags] mov ebx,[listflag] xor ecx,ecx and eax,[goodbit] and ebx,[goodbit] cmp eax,ebx je bitssame or eax,eax jnz addcolumn1 mov cx,[colend] invoke SendMessage,[hlistview],LVM_DELETECOLUMN,ecx,0 dec [colend] jmp bitssame2 addcolumn1: ;invoke AddCol, [hlistview], 0, LVCF_FMT OR LVCF_WIDTH OR LVCF_TEXT OR LVCF_SUBITEM, LVCFMT_LEFT, 0, 208,ADDR sztype xor ecx,ecx mov [lcNew.imask],LVCF_FMT OR LVCF_WIDTH OR LVCF_TEXT OR LVCF_SUBITEM mov [lcNew.fmt],LVCFMT_LEFT mov cx,[esi+16] mov [lcNew.lx],ecx mov [lcNew.pszText],esi mov cx,[colend] mov [lcNew.iSubItem],ecx inc ecx invoke SendMessage,[hlistview],LVM_INSERTCOLUMN,ecx,ADDR lcNew inc [colend] bitssame: or eax,eax jz bitssame2 dec [colend] bitssame2: dec [count] sub esi,18 shr [goodbit],1 cmp [count],0 ja changecols jjj: mov eax,[newflags] mov [listflag],eax pop ebx ret setupcolumns endp showstats proc mov eax,[tcpstats+12];12 ;max connections cmp eax,-1 jne shownum invoke SendDlgItemMessage, mainhwnd, IDC_EDIT7,WM_SETTEXT, 0,ADDR mvar jmp shownumno shownum: call printeax invoke SendDlgItemMessage, mainhwnd, IDC_EDIT7,WM_SETTEXT, 0,ADDR buff shownumno: mov eax,[tcpstats+32] ;current connections call printeax invoke SendDlgItemMessage, mainhwnd, IDC_EDIT2,WM_SETTEXT, 0,ADDR buff mov eax,[tcpstats+36] ;segs in call printeax invoke SendDlgItemMessage, mainhwnd, IDC_EDIT3,WM_SETTEXT, 0,ADDR buff mov eax,[tcpstats+40] ;segs out call printeax invoke SendDlgItemMessage, mainhwnd, IDC_EDIT4,WM_SETTEXT, 0,ADDR buff mov eax,[tcpstats+44] ;errors call printeax invoke SendDlgItemMessage, mainhwnd, IDC_EDIT8,WM_SETTEXT, 0,ADDR buff mov eax,[udpstats] ;in segs call printeax invoke SendDlgItemMessage, mainhwnd, IDC_EDIT5,WM_SETTEXT, 0,ADDR buff mov eax,[udpstats+12] ;out segs call printeax invoke SendDlgItemMessage, mainhwnd, IDC_EDIT6,WM_SETTEXT, 0,ADDR buff mov eax,[udpstats+8] ;retransmitted segs call printeax invoke SendDlgItemMessage, mainhwnd, IDC_EDIT9,WM_SETTEXT, 0,ADDR buff ret showstats endp printeax proc ; prints the value in eax into the buff. push edx push eax push offset num2 push offset buff call wsprintfA add esp,0ch pop edx ret printeax endp ThroughputDlgProc PROC hWnd:HWND,iMsg:DWORD,wParam:WPARAM, lParam:LPARAM ;----------------stats window mov eax,iMsg .if eax==WM_INITDIALOG ;invoke GetIpStatistics,addr ipstats mov eax,[tcpstats+36] ;segs in call printeax invoke SendDlgItemMessage, hWnd, IDC_EDIT5,WM_SETTEXT, 0,ADDR buff mov eax,[tcpstats+40] ;segs out call printeax invoke SendDlgItemMessage, hWnd, IDC_EDIT6,WM_SETTEXT, 0,ADDR buff mov eax,[tcpstats+44] ;errors call printeax invoke SendDlgItemMessage, hWnd, IDC_EDIT9,WM_SETTEXT, 0,ADDR buff mov eax,[udpstats] ;in segs call printeax invoke SendDlgItemMessage, hWnd, IDC_EDIT7,WM_SETTEXT, 0,ADDR buff mov eax,[udpstats+12] ;out segs call printeax invoke SendDlgItemMessage, hWnd, IDC_EDIT8,WM_SETTEXT, 0,ADDR buff mov eax,[udpstats+8] ;retransmitted segs call printeax invoke SendDlgItemMessage, hWnd, IDC_EDIT10,WM_SETTEXT, 0,ADDR buff mov eax,[ipstats+8] ;segs in call printeax invoke SendDlgItemMessage, hWnd, IDC_EDIT1,WM_SETTEXT, 0,ADDR buff mov eax,[ipstats+36] ;segs in call printeax invoke SendDlgItemMessage, hWnd, IDC_EDIT2,WM_SETTEXT, 0,ADDR buff mov eax,[ipstats+28] ;error call printeax invoke SendDlgItemMessage, hWnd, IDC_EDIT3,WM_SETTEXT, 0,ADDR buff mov eax,[icmpstats] ;total icmp in call printeax invoke SendDlgItemMessage, hWnd, IDC_EDIT4,WM_SETTEXT, 0,ADDR buff mov eax,[icmpstatsout] ;total icmp out call printeax invoke SendDlgItemMessage, hWnd, IDC_EDIT11,WM_SETTEXT, 0,ADDR buff mov eax,[icmpstatsout+4] ;icmp errors add eax,[icmpstats+4] call printeax invoke SendDlgItemMessage, hWnd, IDC_EDIT11+1,WM_SETTEXT, 0,ADDR buff ret .elseif eax==WM_CLOSE aclose2: invoke EndDialog,[tabhandle],NULL invoke DestroyWindow,[tabhandle] .elseif eax==WM_COMMAND push edx mov eax,wParam mov edx,eax shr edx,16 .if ax==IDC_OK jmp aclose2 .endif pop edx .else mov eax,FALSE ret .endif mov eax,TRUE ret ThroughputDlgProc endp StatsDlgProc PROC hWnd:HWND,iMsg:DWORD,wParam:WPARAM, lParam:LPARAM ;----------------stats window mov eax,iMsg .if eax==WM_INITDIALOG mov eax,[hWnd] mov [tabhandle],eax INVOKE InitCommonControls INVOKE GetDlgItem,hWnd,IDC_TAB1 MOV hwndTab,EAX MOV ItemStruct.imask,TCIF_TEXT MOV ItemStruct.lpReserved1,0 MOV ItemStruct.lpReserved2,0 MOV ItemStruct.pszText,OFFSET TabTitle1 MOV ItemStruct.cchTextMax,sizeof TabTitle1 MOV ItemStruct.iImage,0 MOV ItemStruct.lParam,0 INVOKE SendMessage,hwndTab,TCM_INSERTITEM,0,OFFSET ItemStruct MOV ItemStruct.pszText,OFFSET TabTitle2 MOV ItemStruct.cchTextMax,sizeof TabTitle2 INVOKE SendMessage,hwndTab,TCM_INSERTITEM,1,OFFSET ItemStruct MOV ItemStruct.pszText,OFFSET TabTitle3 MOV ItemStruct.cchTextMax,sizeof TabTitle3 INVOKE SendMessage,hwndTab,TCM_INSERTITEM,2,OFFSET ItemStruct MOV ItemStruct.pszText,OFFSET TabTitle4 MOV ItemStruct.cchTextMax,sizeof TabTitle4 INVOKE SendMessage,hwndTab,TCM_INSERTITEM,3,OFFSET ItemStruct MOV ItemStruct.pszText,OFFSET TabTitle5 MOV ItemStruct.cchTextMax,sizeof TabTitle5 INVOKE SendMessage,hwndTab,TCM_INSERTITEM,4,OFFSET ItemStruct MOV ItemStruct.pszText,OFFSET TabTitle6 MOV ItemStruct.cchTextMax,sizeof TabTitle6 INVOKE SendMessage,hwndTab,TCM_INSERTITEM,5,OFFSET ItemStruct MOV EAX,OFFSET ThroughputDlgProc INVOKE CreateDialogParam,hInstance,OFFSET Child1Name,hwndTab,EAX,0 MOV Child1hWnd,EAX MOV EAX,OFFSET TcpDlgProc INVOKE CreateDialogParam,hInstance,OFFSET Child2Name,hwndTab,EAX,0 MOV Child2hWnd,EAX MOV EAX,OFFSET UdpDlgProc INVOKE CreateDialogParam,hInstance,OFFSET Child3Name,hwndTab,EAX,0 MOV Child3hWnd,EAX MOV EAX,OFFSET IpDlgProc INVOKE CreateDialogParam,hInstance,OFFSET Child4Name,hwndTab,EAX,0 MOV Child4hWnd,EAX MOV EAX,OFFSET IcmpDlgProc INVOKE CreateDialogParam,hInstance,OFFSET Child5Name,hwndTab,EAX,0 MOV Child5hWnd,EAX MOV EAX,OFFSET IcmpDlgProcOut INVOKE CreateDialogParam,hInstance,OFFSET Child6Name,hwndTab,EAX,0 MOV Child6hWnd,EAX MOV WhichTabChosen,0 INVOKE ShowWindow,Child1hWnd,SW_SHOWDEFAULT ret .elseif eax==WM_NOTIFY push ebx MOV EAX,lParam MOV EAX, (NMHDR PTR [eax]).code CMP EAX, TCN_SELCHANGE JZ ChangingTab jmp endnotify ChangingTab: MOV EBX,WhichTabChosen MOV EAX,[Handles+EBX*4] INVOKE ShowWindow,EAX,SW_HIDE INVOKE SendMessage,hwndTab,TCM_GETCURSEL,0,0 ; Ok which one is BEING chosen right now? MOV WhichTabChosen,EAX MOV EBX,[Handles+EAX*4] mov tabwin,ebx INVOKE ShowWindow,EBX,SW_SHOWDEFAULT endnotify: pop ebx xor eax,eax ret .elseif eax==WM_CLOSE aclose2: invoke EndDialog,hWnd,NULL invoke DestroyWindow,hWnd .elseif eax==WM_COMMAND push edx mov eax,wParam mov edx,eax shr edx,16 .if ax==IDC_OK jmp aclose2 .endif pop edx .else mov eax,FALSE ret .endif mov eax,TRUE ret StatsDlgProc endp TcpDlgProc PROC hWnd:HWND,iMsg:DWORD,wParam:WPARAM, lParam:LPARAM ;----------------TCP Window ;typedef struct _MIB_TCPSTATS { ;1 DWORD dwRtoAlgorithm; // time-out algorithm ;2 DWORD dwRtoMin; // minimum time-out ;3 DWORD dwRtoMax; // maximum time-out ;4 DWORD dwMaxConn; // maximum connections ;5 DWORD dwActiveOpens; // active opens ;6 DWORD dwPassiveOpens; // passive opens ;7 DWORD dwAttemptFails; // failed attempts ;8 DWORD dwEstabResets; // established connections reset ;9 DWORD dwCurrEstab; // established connections ;10 DWORD dwInSegs; // segments received ;11 DWORD dwOutSegs; // segment sent ;12 DWORD dwRetransSegs; // segments retransmitted ;13 DWORD dwInErrs; // incoming errors ;14 DWORD dwOutRsts; // outgoing resets ;15 DWORD dwNumConns; // cumulative connections ;} mov eax,iMsg .if eax==WM_INITDIALOG lea esi,tcpstats mov edx,IDC_EDIT1 mov ecx,15 fillintcp: push ecx push edx mov eax,[esi] call printeax invoke SendDlgItemMessage, hWnd, edx,WM_SETTEXT, 0,ADDR buff pop edx pop ecx add esi,4 inc edx loop fillintcp mov eax,[tcpstats+16] ;cmp eax,-1 ;jne maxisok invoke SendDlgItemMessage, hWnd, IDC_EDIT4,WM_SETTEXT, 0,ADDR mvariable maxisok: ;mov eax,[tcpstats+36] ;segs in ;call printeax ;invoke SendDlgItemMessage, hWnd, IDC_EDIT1,WM_SETTEXT, 0,ADDR buff ;mov eax,[tcpstats+40] ;segs out ;call printeax ;invoke SendDlgItemMessage, hWnd, IDC_EDIT2,WM_SETTEXT, 0,ADDR buff ;mov eax,[tcpstats+44] ;errors ;call printeax ;invoke SendDlgItemMessage, hWnd, IDC_EDIT3,WM_SETTEXT, 0,ADDR buff ret .elseif eax==WM_CLOSE aclose2: invoke EndDialog,[tabhandle],NULL invoke DestroyWindow,[tabhandle] .elseif eax==WM_COMMAND mov eax,wParam .if ax==IDC_OK jmp aclose2 .endif .else mov eax,FALSE ret .endif mov eax,TRUE ret TcpDlgProc endp IpDlgProc PROC hWnd:HWND,iMsg:DWORD,wParam:WPARAM, lParam:LPARAM ;----------------IP Window ;typedef struct _MIB_IPSTATS { ; 1 DWORD 0 dwForwarding; // IP forwarding enabled or disabled ; 2 DWORD 4 dwDefaultTTL; // default time-to-live ; 3 DWORD 8 dwInReceives; // datagrams received ; 4 DWORD 12 dwInHdrErrors; // received header errors ; 5 DWORD 16 dwInAddrErrors; // received address errors ; 6 DWORD 20 dwForwDatagrams; // datagrams forwarded ; 7 DWORD 24 dwInUnknownProtos; // datagrams with unknown protocol ; 8 DWORD 28 dwInDiscards; // received datagrams discarded ; 9 DWORD 32 dwInDelivers; // received datagrams delivered ;10 DWORD 36 dwOutRequests; // ;11 DWORD 40 dwRoutingDiscards; // ;12 DWORD 44 dwOutDiscards; // sent datagrams discarded ;13 DWORD 48 dwOutNoRoutes; // datagrams for which no route exists ;14 DWORD 52 dwReasmTimeout; // datagrams for which all -14 ; // frags did not arrive ;15 DWORD dwReasmReqds; // datagrams requiring re-assembly ;16 DWORD dwReasmOks; // successful re-assemblies ;17 DWORD dwReasmFails; // failed re-assemblies ;18 DWORD dwFragOks; // successful fragmentations ;19 DWORD dwFragFails; // failed fragmentations ;20 DWORD dwFragCreates; // datagrams fragmented ;21 DWORD dwNumIf; // number of interfaces on computer ;22 DWORD dwNumAddr; // number of IP address on computer ;23 DWORD dwNumRoutes; // number of routes in routing table ;} MIB_IPSTATS, *PMIB_IPSTATS; - 23 dwords long mov eax,iMsg .if eax==WM_INITDIALOG lea esi,ipstats mov edx,IDC_EDIT1 mov ecx,23 fillintcp: push ecx push edx mov eax,[esi] call printeax invoke SendDlgItemMessage, hWnd, edx,WM_SETTEXT, 0,ADDR buff pop edx pop ecx add esi,4 inc edx loop fillintcp ret .elseif eax==WM_CLOSE aclose2: invoke EndDialog,[tabhandle],NULL invoke DestroyWindow,[tabhandle] .elseif eax==WM_COMMAND mov eax,wParam .if ax==IDC_OK jmp aclose2 .endif .else mov eax,FALSE ret .endif mov eax,TRUE ret IpDlgProc endp UdpDlgProc PROC hWnd:HWND,iMsg:DWORD,wParam:WPARAM, lParam:LPARAM ;----------------UDP Window ;MIB_UDPSTATS { ; DWORD dwInDatagrams; // received datagrams ; DWORD dwNoPorts; // datagrams for which no port exists ; DWORD dwInErrors; // errors on received datagrams ; DWORD dwOutDatagrams; // sent datagrams ; DWORD dwNumAddrs; // number of entries in ; // UDP listener table ;} MIB_UDPSTATS,*PMIB_UDPSTATS mov eax,iMsg .if eax==WM_INITDIALOG lea esi,udpstats mov edx,IDC_EDIT1 mov ecx,5 fillintcp: push ecx push edx mov eax,[esi] call printeax invoke SendDlgItemMessage, hWnd, edx,WM_SETTEXT, 0,ADDR buff pop edx pop ecx add esi,4 inc edx loop fillintcp ret .elseif eax==WM_CLOSE aclose2: invoke EndDialog,[tabhandle],NULL invoke DestroyWindow,[tabhandle] .elseif eax==WM_COMMAND mov eax,wParam .if ax==IDC_OK jmp aclose2 .endif .else mov eax,FALSE ret .endif mov eax,TRUE ret UdpDlgProc endp IcmpDlgProc PROC hWnd:HWND,iMsg:DWORD,wParam:WPARAM, lParam:LPARAM ;----------------ICMP Window ;typedef struct _MIBICMPSTATS { ; 1 DWORD dwMsgs; // number of messages ; 2 DWORD dwErrors; // number of errors ; 3 DWORD dwDestUnreachs; // destination unreachable messages ; 4 DWORD dwTimeExcds; // time-to-live exceeded messages ; 5 DWORD dwParmProbs; // parameter problem messages ; 6 DWORD dwSrcQuenchs; // source quench messages ; 7 DWORD dwRedirects; // redirection messages ; 8 DWORD dwEchos; // echo requests ; 9 DWORD dwEchoReps; // echo replies ;10 DWORD dwTimestamps; // time-stamp requests ;11 DWORD dwTimestampReps; // time-stamp replies ;12 DWORD dwAddrMasks; // address mask requests ;13 DWORD dwAddrMaskReps; // address mask replies ;} MIBICMPSTATS; mov eax,iMsg .if eax==WM_INITDIALOG lea esi,icmpstats mov edx,IDC_EDIT1 mov ecx,13 fillintcp: push ecx push edx mov eax,[esi] call printeax invoke SendDlgItemMessage, hWnd, edx,WM_SETTEXT, 0,ADDR buff pop edx pop ecx add esi,4 inc edx loop fillintcp ret .elseif eax==WM_CLOSE aclose2: invoke EndDialog,[tabhandle],NULL invoke DestroyWindow,[tabhandle] .elseif eax==WM_COMMAND mov eax,wParam .if ax==IDC_OK jmp aclose2 .endif .else mov eax,FALSE ret .endif mov eax,TRUE ret IcmpDlgProc endp IcmpDlgProcOut PROC hWnd:HWND,iMsg:DWORD,wParam:WPARAM, lParam:LPARAM ;----------------ICMP Window mov eax,iMsg .if eax==WM_INITDIALOG lea esi,icmpstatsout mov edx,IDC_EDIT1 mov ecx,13 fillintcp: push ecx push edx mov eax,[esi] call printeax invoke SendDlgItemMessage, hWnd, edx,WM_SETTEXT, 0,ADDR buff pop edx pop ecx add esi,4 inc edx loop fillintcp ret .elseif eax==WM_CLOSE aclose2: invoke EndDialog,[tabhandle],NULL invoke DestroyWindow,[tabhandle] .elseif eax==WM_COMMAND mov eax,wParam .if ax==IDC_OK jmp aclose2 .endif .else mov eax,FALSE ret .endif mov eax,TRUE ret IcmpDlgProcOut endp IfDlgProc PROC hWnd:HWND,iMsg:DWORD,wParam:WPARAM, lParam:LPARAM ;----------------IP Window mov eax,iMsg .if eax==WM_INITDIALOG mov eax,[hWnd] mov [ifhwnd],eax ;setup interface list invoke GetDlgItem, [hWnd],IDC_IFLIST mov [iflistview], eax invoke SendMessage, eax, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT + LVS_EX_GRIDLINES invoke AddCol, [iflistview], 0, LVCF_FMT OR LVCF_WIDTH OR LVCF_TEXT OR LVCF_SUBITEM, LVCFMT_LEFT, 0, 80,ADDR sztype invoke AddCol, [iflistview], 1, LVCF_FMT OR LVCF_WIDTH OR LVCF_TEXT OR LVCF_SUBITEM, LVCFMT_LEFT, 0, 150,ADDR szdesc invoke AddCol, [iflistview], 2, LVCF_FMT OR LVCF_WIDTH OR LVCF_TEXT OR LVCF_SUBITEM, LVCFMT_RIGHT, 0, 70, ADDR szin invoke AddCol, [iflistview], 3, LVCF_FMT OR LVCF_WIDTH OR LVCF_TEXT OR LVCF_SUBITEM, LVCFMT_RIGHT, 0, 70, ADDR szout invoke AddCol, [iflistview], 4, LVCF_FMT OR LVCF_WIDTH OR LVCF_TEXT OR LVCF_SUBITEM, LVCFMT_RIGHT, 0, 70, ADDR szmtu invoke AddCol, [iflistview], 5, LVCF_FMT OR LVCF_WIDTH OR LVCF_TEXT OR LVCF_SUBITEM, LVCFMT_LEFT, 0, 150, ADDR szphys ;invoke GetIfTable,[tcpmem],10240,0 call ifscan mov esi,[tcpmem] add esi,4 call ifshow ret .elseif eax==WM_CLOSE aclose2: invoke EndDialog,[hWnd],NULL invoke DestroyWindow,[hWnd] .elseif eax==WM_COMMAND mov eax,wParam .if ax==IDC_OK jmp aclose2 .endif .elseif ax==WM_NOTIFY mov edi, [lParam] mov eax, (NMHDR ptr [edi]).hwndFrom .if eax==iflistview mov eax, (NMHDR ptr [edi]).code .if eax==LVN_ITEMCHANGED mov eax, (NMLISTVIEW ptr [edi]).iItem mov [iflistno],eax call printeax invoke SendDlgItemMessage, hWnd, IDC_EDIT1, WM_SETTEXT, 0,ADDR buff mov eax,[iflistno] mov ecx,860 mul ecx mov esi,[tcpmem] add esi,4 add esi,eax ; mov eax,[esi+520]; ; call printeax ; invoke SendDlgItemMessage, hWnd, IDC_EDIT2, WM_SETTEXT, 0,ADDR buff ;lea esi,icmpstatsout call ifshow ret .endif .endif .else mov eax,FALSE ret .endif mov eax,TRUE ret IfDlgProc endp hex4 proc mov [edi],byte ptr 0 and ecx,0fh or ecx,ecx jz nosize goagain: mov al,[esi] mov ah,al shr ah,4 cmp ah,10 jb isanum add ah,"A"-"0"-10 isanum: add ah,"0" mov [edi],byte ptr ah inc edi and al,0fh cmp al,10 jb isanum2 add al,"A"-"0"-10 isanum2: add al,"0" mov [edi],byte ptr al inc edi mov [edi],byte ptr "-" inc edi inc esi loop goagain dec edi mov [edi],byte ptr 0 nosize: ret hex4 endp ifshow proc push esi add esi,512 mov edx,IDC_EDIT1 mov ecx,21 fillintcp: push ecx push edx mov eax,[esi] call printeax invoke SendDlgItemMessage, [ifhwnd], edx,WM_SETTEXT, 0,ADDR buff pop edx pop ecx add esi,4 inc edx loop fillintcp pop esi push edi mov edi,offset buff mov ecx,[esi+528] add esi,532 call hex4 ;mov eax,[esi+528] ;call printeax invoke SendDlgItemMessage, [ifhwnd], IDC_EDIT2,WM_SETTEXT, 0,ADDR buff pop edi ret ifshow endp ifscan proc ;typedef struct _MIB_IFROW { ; 0 WCHAR wszName[MAX_INTERFACE_NAME_LEN]; ;512 DWORD dwIndex; // index of the interface ;516 DWORD dwType; // type of interface ;520 DWORD dwMtu; // max transmission unit ;524 DWORD dwSpeed; // speed of the interface ;528 DWORD dwPhysAddrLen; // length of physical address ;532 BYTE bPhysAddr[MAXLEN_PHYSADDR]; // physical address of adapter ;540 DWORD dwAdminStatus; // administrative status ;544 DWORD dwOperStatus; // operational status ;548 DWORD dwLastChange; // last time operational status changed ;552 DWORD dwInOctets; // octets received ;556 DWORD dwInUcastPkts; // unicast packets received ;560 DWORD dwInNUcastPkts; // non-unicast packets received ;564 DWORD dwInDiscards; // received packets discarded ;568 DWORD dwInErrors; // erroneous packets received ;572 DWORD dwInUnknownProtos; // unknown protocol packets received ;576 DWORD dwOutOctets; // octets sent ;580 DWORD dwOutUcastPkts; // unicast packets sent ;584 DWORD dwOutNUcastPkts; // non-unicast packets sent ;588 DWORD dwOutDiscards; // outgoing packets discarded ;592 DWORD dwOutErrors; // erroneous packets sent ;596 DWORD dwOutQLen; // output queue length ;600 DWORD dwDescrLen; // length of bDescr member ;604 BYTE bDescr[MAXLEN_IFDESCR]; // interface description end - 644 ;} MIB_IFROW,*PMIB_IFROW;; local reqsize:DWORD local ifcount:DWORD mov [reqsize],20240 mov esi,[tcpmem] invoke GetIfTable,esi,addr reqsize,FALSE cmp eax,NO_ERROR jne iferror1 mov esi,[tcpmem] mov eax,[esi] mov [ifcount],eax ;mov eax,[reqsize] ;call printeax mov [listno],0 ;invoke AddItem, [iflistview], [listno], 0, LVIF_TEXT OR LVIF_PARAM, 0, 0, [listno], addr buff, 1,0 mov esi,[tcpmem] add esi,4 mov ecx,[ifcount] loopif: push esi push ecx lea edi,iftypetable ;find Interfacse type from table mov ecx,iftypeno mov eax,[esi+516] findiftype: cmp al,[edi] je gottype add edi,11 loop findiftype call printeax mov edi,offset buff jmp showtype gottype: inc edi showtype: invoke AddItem, [iflistview], [listno], 0, LVIF_TEXT OR LVIF_PARAM, 0, 0, [listno], edi, 1,0 mov eax,[esi+552] ;show bytes in call printeax invoke AddItem, [iflistview], [listno], 2, LVIF_TEXT, 0, 0, [listno], addr buff, 1, 1 mov eax,[esi+576] ;show bytes out call printeax invoke AddItem, [iflistview], [listno], 3, LVIF_TEXT, 0, 0, [listno], addr buff, 1, 1 mov eax,[esi+520] ;show mtu call printeax invoke AddItem, [iflistview], [listno], 4, LVIF_TEXT, 0, 0, [listno], addr buff, 1, 1 push esi ;display mac address mov edi,offset buff mov ecx,[esi+528] add esi,532 call hex4 invoke AddItem, [iflistview], [listno], 5, LVIF_TEXT, 0, 0, [listno], addr buff, 1, 1 pop esi add esi,604 invoke AddItem, [iflistview], [listno], 1, LVIF_TEXT, 0, 0, [listno], esi, 1, 1 pop ecx pop esi add esi,604+256 inc [listno] dec ecx jz endloop1 jmp loopif endloop1: ret iferror1: invoke FormatMessage,FORMAT_MESSAGE_FROM_SYSTEM,NULL,eax,0,addr buff,80,NULL invoke AddItem, [iflistview], 0, 0, LVIF_TEXT OR LVIF_PARAM, 0, 0, 0, addr buff, 1,0 ret ifscan endp END start