maybe i'am so stupid?
there are no errors but it didn't works
here is the source:
.data

IPINFO struct
Ttl BYTE ?
Tos BYTE ?
IPFlags BYTE ?
OptSize BYTE ?
Options BYTE ?
IPINFO ends

ICMPECHO struct
Source DWORD ?
Status DWORD ?
RTTime DWORD ?
DataSize BYTE ?
Reserved BYTE ?
pData DWORD ?
ipInfo IPINFO <>
ICMPECHO ends

icmpEcho ICMPECHO <>
ipInfo IPINFO <>

HostIP db "192.168.11.20",0
hFile HANDLE ?
iaDest in_addr <>
pHost hostent <>
dwAddress DWORD ?
messcapt db "Message",0
mess db "Host is up and running",0
.code
Ping proc

invoke inet_addr,addr HostIP
mov iaDest.S_un.S_addr,eax

invoke gethostbyaddr,addr iaDest,sizeof in_addr,AF_INET

mov edx, (hostent ptr ).h_list
mov edx, dword ptr
mov eax, dword ptr

mov dwAddress,eax

invoke IcmpCreateFile

mov hFile,eax
mov ipInfo.Ttl, 255
mov ipInfo.Tos, 0
mov ipInfo.IPFlags,0
mov ipInfo.OptSize,0
mov ipInfo.Options,0
mov icmpEcho.Status,0

invoke IcmpSendEcho,hFile,addr dwAddress,0,0,addr ipInfo,addr icmpEcho,sizeof ICMPECHO,1000
mov iaDest.S_un.S_addr,offset icmpEcho.Source
.if icmpEcho.Status==TRUE
invoke MessageBox,NULL,addr mess ,addr messcapt,MB_OK
.endif
invoke IcmpCloseHandle,hFile
xor eax,eax
ret
Ping endp
please find here errors!
Posted on 2001-11-08 08:27:29 by Anorak
Do you own a debugger?

What are the return values of all the invokes? Are they what you would expect? If not how are they different.... WHERE IS YOUR CODE GOING WRONG?
If you want to pay me to debug a program for you, I'm more likely to respond, but to simply dump a whole load of code (repeatedly) on a message board and ask us to fix it is simply bad manners. If your code doesn't work, at least put the time and effort in yourself to find where it stops working. The fact it compiles means very little, I can write a whole lot of code that'll compile, whether or not it does what its supposed to is exactly what debugging is all about.
I myself am currently at work, and have better things to do with my time than to find all the coding mistakes you have made. I am however more than happy to suggest fixes for the problems you have found.

According to the documentation, you need to have made a successful call to WSAStartup before calling gethostbyaddr, have you done this? Is this even the function which fails?

Mirno
Posted on 2001-11-08 09:12:30 by Mirno
Any one can give me link for ping source on asm?
i'am already suffering one month!!!!
PLEASE HELP ME!!!!!
Posted on 2001-11-08 12:01:13 by Anorak
ICMPECHO struct
Source DWORD ?
Status DWORD ?
RTTime DWORD ?
DataSize BYTE ?
Reserved BYTE ?
pData DWORD ?
ipInfo IPINFO <>
data db 256 dup (?)
ICMPECHO ends
Posted on 2005-10-09 14:39:12 by Gary Miller
@Anorak
I think people are trying to help you m8 - if you will listen to the response above from Mirno , he is trying to help you too.

I'm new here I know, and please correct me if I'm wrong, but you should check for error responses from all invokes like gethostbyname (and even WSAStartup which you must succesfully call before using gethostbyname) and if these fail then you should deal with them in your code - or at least cause it to display some error message so you know things went wrong - you can't just trust the invoke to work and expect the returned value to be a good one.

Now I don't see any such error checking in the above code, it just blindly exects a windows API call to work - why is that?

I'm sure if you had programmed to expect Windows API's to fail at some time, then you would have sorted this problem some time ago. 

dicky
Posted on 2005-10-10 03:25:31 by dicky96

;@echo off
;goto make
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.586
.model flat,stdcall
option casemap:none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc
include \masm32\include\ws2_32.inc
include \masm32\include\icmp.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\ws2_32.lib
includelib \masm32\lib\icmp.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ICMP_ECHO_REPLYTA STRUCT
Address          DWORD      ?
Status          DWORD      ?
RoundTripTime    DWORD      ?
DataSize        WORD      ?
Reserved        WORD      ?
DataPointer      DWORD      ?
Options          ICMP_OPTIONS  <?>
zData            BYTE 250 dup (?)
ICMP_ECHO_REPLYTA ENDS
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data
AppName db "Ping Test With ICMP",13,10,0
Usage db "Usage: Ping <hostname/Ip>",13,10,13,10
CRLF db 13,10,0

Msg_Ping db 13,10,"Pinging %s With ICMP ......",0
Msg_Reply db 13,10,"Reply from %s Time: %d ms TTL: %d, Hops: %d",0
Msg_Timeout db 13,10,"Request Timed out",0
Err_Winsock db "Error loading winsock dll : %d",13,10,0
Err_NoHost db "Cannot find host: %s",13,10,0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data?
hIcmp HANDLE ?
hLib HANDLE ?
dwAddress DWORD ?
nHops DWORD ?

HostBuffer db 256 dup(?)
OutBuffer db 256 dup(?)

wsadata WSADATA <?>
icmpOptions ICMP_OPTIONS <?>
icmpReply ICMP_ECHO_REPLYTA <?>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
Start:
invoke WSAStartup,202h,ADDR wsadata
.if eax!=0
invoke wsprintf,ADDR OutBuffer,ADDR Err_Winsock,eax
invoke StdOut,ADDR OutBuffer
jmp @Exit
.endif
invoke GetCL,1,ADDR HostBuffer
.if (eax!=1)
invoke StdOut,ADDR Usage
jmp @Exit
.endif
invoke inet_addr,ADDR HostBuffer
.if eax==INADDR_NONE
invoke gethostbyname,ADDR HostBuffer
.if eax==0
invoke wsprintf,ADDR OutBuffer,ADDR Err_NoHost,ADDR HostBuffer
invoke StdOut,ADDR OutBuffer
jmp @Exit
.endif
mov eax,
mov eax,
mov eax,
.endif
mov dwAddress,eax
invoke IcmpCreateFile
mov hIcmp,eax

invoke wsprintf,ADDR OutBuffer,ADDR Msg_Ping,ADDR HostBuffer
invoke StdOut,ADDR CRLF
invoke StdOut,ADDR OutBuffer
invoke StdOut,ADDR CRLF

xor ebx,ebx
.WHILE ebx < 4
push ebx
mov icmpOptions.Ttl,255
mov icmpOptions.Tos,0
mov icmpOptions.Flags,0
mov icmpOptions.OptionsSize,0
mov icmpOptions.OptionsData,0

invoke IcmpSendEcho,hIcmp,dwAddress,0,0,ADDR icmpOptions,ADDR icmpReply,SIZEOF ICMP_ECHO_REPLYTA+SIZEOF ICMP_OPTIONS,5000
.if eax !=0
invoke inet_ntoa,icmpReply.Address
movzx ecx,icmpReply.Options.Ttl
mov nHops,256
sub nHops,ecx
mov edx,nHops
.if edx==192
mov nHops,1
.elseif edx==128
mov nHops,0
.endif
invoke wsprintf,ADDR OutBuffer,ADDR Msg_Reply,eax,icmpReply.RoundTripTime,ecx,nHops
invoke StdOut,ADDR OutBuffer
.else
invoke StdOut,ADDR Msg_Timeout
.endif
pop ebx
inc ebx
.ENDW
invoke StdOut,ADDR CRLF
invoke IcmpCloseHandle,hIcmp

@Exit:
invoke WSACleanup
invoke ExitProcess,0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

end Start

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
:make
set name=ping_2

    \masm32\bin\ml /c /coff %name%.bat
    \masm32\bin\Link /subsystem:CONSOLE %name%.obj
   
    if exist *.bak del *.bak
    if exist *.obj del *.obj
echo.
Posted on 2005-10-12 09:50:05 by dcskm4200
you forgot this
.386
INCLUDE FILE LIST HERE AND INCLUDE COMMANDS
Posted on 2006-06-12 20:02:28 by tjweb
I always wonder why nobody reads the dates of the posts for these things... this is a classic example -it's happened twice... 2001 was the first post and October 2005 was the most recent... do people do searches and then answer or something else?

Ossa
Posted on 2006-06-13 05:33:29 by Ossa