News:

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

iphlpapi.lib and ws2_32.lib is broken

Started by Farabi, June 04, 2010, 07:09:25 AM

Previous topic - Next topic

Farabi

TCP_Info.obj : error LNK2001: unresolved external symbol _GetTcpTable@12
TCP_Info.obj : error LNK2001: unresolved external symbol _inet_ntoa@4

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

"Etos siperi elegi"

MichaelW

I didn't have time to work the code out very well, but I did verify that GetTcpTable and indirectly iphlpapi.lib at least appear to work OK under Windows 2000.

;=====================================================================
    include \masm32\include\masm32rt.inc
    include \masm32\include\iphlpapi.inc
    includelib \masm32\lib\iphlpapi.lib
;=====================================================================

MIB_TCPTABLE STRUCT
  dwNumEntries DWORD ?
  table        DWORD ?
MIB_TCPTABLE ENDS

MIB_TCPROW STRUCT
  dwState       DWORD ?
  dwLocalAddr   DWORD ?
  dwLocalPort   DWORD ?
  dwRemoteAddr  DWORD ?
  dwRemotePort  DWORD ?
MIB_TCPROW ENDS

MIB_TCP_STATE_CLOSED      equ 1
MIB_TCP_STATE_LISTEN      equ 2
MIB_TCP_STATE_SYN_SENT    equ 3
MIB_TCP_STATE_SYN_RCVD    equ 4
MIB_TCP_STATE_ESTAB       equ 5
MIB_TCP_STATE_FIN_WAIT1   equ 6
MIB_TCP_STATE_FIN_WAIT2   equ 7
MIB_TCP_STATE_CLOSE_WAIT  equ 8
MIB_TCP_STATE_CLOSING     equ 9
MIB_TCP_STATE_LAST_ACK    equ 10
MIB_TCP_STATE_TIME_WAIT   equ 11
MIB_TCP_STATE_DELETE_TCB  equ 12

;=====================================================================
    .data
        dwSize    dd 0
    .code
;=====================================================================
start:
;=====================================================================
    invoke GetTcpTable, NULL, ADDR dwSize, TRUE
    SWITCH eax
      CASE NO_ERROR
        print "NO_ERROR",13,10
      CASE ERROR_INSUFFICIENT_BUFFER
        print "ERROR_INSUFFICIENT_BUFFER",13,10
        jmp continue
      CASE ERROR_INVALID_PARAMETER
        print "ERROR_INVALID_PARAMETER",13,10
      CASE ERROR_NOT_SUPPORTED
        print "ERROR_NOT_SUPPORTED",13,10
      DEFAULT
        print LastError$(),13,10
    ENDSW
    inkey "Press any key to exit..."
    exit

  continue:

    print str$(dwSize),13,10
    mov edi, alloc(dwSize)
    invoke GetTcpTable, edi, ADDR dwSize, TRUE
    print str$(eax),13,10
    print str$(dwSize),13,10
    mov ebx, [edi].MIB_TCPTABLE.dwNumEntries
    print str$(ebx),13,10
    lea esi, [edi].MIB_TCPTABLE.table
    .REPEAT
      print str$([esi].MIB_TCPROW.dwState),13,10
      print hex$([esi].MIB_TCPROW.dwLocalAddr),13,10
      print hex$([esi].MIB_TCPROW.dwLocalPort),13,10
      print hex$([esi].MIB_TCPROW.dwRemoteAddr),13,10
      print hex$([esi].MIB_TCPROW.dwRemotePort),13,10
      add esi, SIZEOF MIB_TCPROW
      dec ebx
    .UNTIL ebx == 0

    inkey "Press any key to exit..."
    exit
;=====================================================================
end start

eschew obfuscation

oex

I tested this code on XP and it compiled and ran ok
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

Farabi

Michael:
If you tested it on WinXP and it works okay please tell me. I used the newer version from MASM10 and it still not work too.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

I found my mistake
it was because I should wrote it like this on RadAsm


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


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

"Etos siperi elegi"