News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Check Outgoing connection

Started by Farabi, June 04, 2010, 01:25:42 AM

Previous topic - Next topic

Farabi

I want to check all of my active connection include the port used for all application that used internet connection like netstat.exe did. What function I should use?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Richard van Petrov


Farabi

Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Richard van Petrov

Try and run this code; it should work for you.

conoutmon.asm:

include \masm32\include\masm32rt.inc

include \masm32\include\iphlpapi.inc
includelib \masm32\lib\iphlpapi.lib

MIB_TCPSTATS struct
        dwRtoAlgorithm  DWORD ?
        dwRtoMin        DWORD ?
        dwRtoMax        DWORD ?
        dwMaxConn       DWORD ?
        dwActiveOpens   DWORD ?
        dwPassiveOpens  DWORD ?
        dwAttemptFails  DWORD ?
        dwEstabResets   DWORD ?
        dwCurrEstab     DWORD ?
        dwInSegs        DWORD ?
        dwOutSegs       DWORD ?
        dwRetransSegs   DWORD ?
        dwInErrs        DWORD ?
        dwOutRsts       DWORD ?
        dwNumConns      DWORD ?
MIB_TCPSTATS ends

.data

        tcpStats        MIB_TCPSTATS <>

        szTcpTotal      DB "Total # TCP Connections : ",0
        szTcpCap        DB "TCP Stats",0

.code

start:

INVOKE  GetTcpStatistics, OFFSET tcpStats
MOV     ESI, alloc(512)
MOV     EAX, tcpStats.dwNumConns
MOV     EAX, ustr$(EAX)
PUSH    EAX
XOR     EAX, add$(ESI, OFFSET szTcpTotal)
POP     EAX
XOR     EAX, add$(ESI, EAX)
INVOKE  MessageBox, 0, ESI, OFFSET szTcpCap, MB_OK or MB_ICONINFORMATION
INVOKE  ExitProcess, 0

end start

Farabi

Thanks for the Code I got it working anyway.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"