Here I already left two times of the message, but to me and have not answered!!!!
Give me though any link!!!!
Any retrieval system can not find it(him)!!!
Please help me!!!!
Give me though any link!!!!
Any retrieval system can not find it(him)!!!
Please help me!!!!
There are two examples in C++ here:
http://tangentsoft.net/wskfaq/examples/dllping.html (ICMP)
http://tangentsoft.net/wskfaq/examples/rawping.html (raw sockets)
http://tangentsoft.net/wskfaq/examples/dllping.html (ICMP)
http://tangentsoft.net/wskfaq/examples/rawping.html (raw sockets)
Thanks but i already have a source of ping on C++
i have just one question :
how can i shove the return value of gethostbyaddr(gethostbyname)in variable of type hosten!
I can not find this source on asm anywhere!!!
please help me!!!
i have just one question :
how can i shove the return value of gethostbyaddr(gethostbyname)in variable of type hosten!
I can not find this source on asm anywhere!!!
please help me!!!
There was a good example at the old board but it seems to be down..
Well gethostbyaddr returns a hostent structure, which looks like this:
The h_addr_list member is a pointer to a list of pointers to addresses of length h_length....
h_addr_list is called h_list in the masm includes btw. So first you get the h_list member of the hostent structure.
Now you have a pointer to a list of pointers (terminated by a NULL pointer). Each pointer points to a host address, which is just the IP address in network byte order (1.2.3.4 = db 01, 02, 03, 04 in memory). You can simply get the first host like this:
To get the other IPs if there are any, the second line has to be changed to , , etc until you get a null-pointer.
Thomas
Well gethostbyaddr returns a hostent structure, which looks like this:
struct hostent {
char FAR * h_name;
char FAR * FAR * h_aliases;
short h_addrtype;
short h_length;
char FAR * FAR * h_addr_list;
};
The h_addr_list member is a pointer to a list of pointers to addresses of length h_length....
h_addr_list is called h_list in the masm includes btw. So first you get the h_list member of the hostent structure.
Now you have a pointer to a list of pointers (terminated by a NULL pointer). Each pointer points to a host address, which is just the IP address in network byte order (1.2.3.4 = db 01, 02, 03, 04 in memory). You can simply get the first host like this:
;assumes eax points to hostent struct
mov edx, (hostent ptr [eax]).h_list ;get list pointer
mov edx, dword ptr [edx] ; get first pointer from list
mov eax, dword ptr [edx] ; get the actual IP
; eax contains first IP address in list now
To get the other IPs if there are any, the second line has to be changed to , , etc until you get a null-pointer.
Thomas
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!
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!