Hello everybody,
Please can You show me how i get the Clients IP with my Code ?
mov eax,lparam_
cmp ax,008h ;FD_ACCEPT
jne go_on
shr eax,16
xor ebx,ebx
invoke CheckSocketList
invoke accept ,,0,0
inc Counter
mov ,eax
invoke wvsprintfA,addr Count,addr Hex2Dec,addr Counter
invoke SetDlgItemTextA,Hwnd,IDD_USER,addr Count
im very new to Masm and dont understand the Post i found by using the Search Function.
Many Thanks
A.Cruzmann
Please can You show me how i get the Clients IP with my Code ?
mov eax,lparam_
cmp ax,008h ;FD_ACCEPT
jne go_on
shr eax,16
xor ebx,ebx
invoke CheckSocketList
invoke accept ,,0,0
inc Counter
mov ,eax
invoke wvsprintfA,addr Count,addr Hex2Dec,addr Counter
invoke SetDlgItemTextA,Hwnd,IDD_USER,addr Count
im very new to Masm and dont understand the Post i found by using the Search Function.
Many Thanks
A.Cruzmann
Your problem is that you call accept without specifying a pointer to a sockaddr structure.
invoke accept ,,0,0
should be
invoke accept, listensock, addr client_addr, 0
where client_addr is a sockaddr_in struc. If you want to do it without relying on accept() then you can use getpeername(). The parameters are the same.
invoke accept ,,0,0
should be
invoke accept, listensock, addr client_addr, 0
where client_addr is a sockaddr_in struc. If you want to do it without relying on accept() then you can use getpeername(). The parameters are the same.
Hello,
after reading the post i try to get it working so i use
from my win32.inc the dword sin_addr
i call getpeername like this:
invoke getpeername, listensock, addr sin_addr, 0
but the result is allways empty.
cruzmann can you show me how do you get it working please ?
Thanks
after reading the post i try to get it working so i use
from my win32.inc the dword sin_addr
i call getpeername like this:
invoke getpeername, listensock, addr sin_addr, 0
but the result is allways empty.
cruzmann can you show me how do you get it working please ?
Thanks
Have you defiend your address structure somwwhere
.data?
client_addr sockaddr_in <?>
...
.code
...
invoke accept, listensock, addr client_addr, 0
;now convert the IP to doted format
invoke inet_ntoa, client_addr.sin_addr
.data?
client_addr sockaddr_in <?>
...
.code
...
invoke accept, listensock, addr client_addr, 0
;now convert the IP to doted format
invoke inet_ntoa, client_addr.sin_addr
Hello Kudos,
thanks for your quick help.
yes i use client_addr sockaddr_in <?>
also i wrote:
invoke accept ,,addr client_addr,0
invoke getpeername,,addr client_addr,0
invoke inet_ntoa,client_addr.sin_addr
lea ebx, ipbuff
invoke lstrcpy,addr remip,eax
but "remip" is allways 0.0.0.0
i connect to the portwatcher when im online and use ip 127.0.0.1
possible i have to wait for a connection from some other user ?
Thanks
thanks for your quick help.
yes i use client_addr sockaddr_in <?>
also i wrote:
invoke accept ,,addr client_addr,0
invoke getpeername,,addr client_addr,0
invoke inet_ntoa,client_addr.sin_addr
lea ebx, ipbuff
invoke lstrcpy,addr remip,eax
but "remip" is allways 0.0.0.0
i connect to the portwatcher when im online and use ip 127.0.0.1
possible i have to wait for a connection from some other user ?
Thanks
ups no use of getpeername :-)
now it works fine , thanks for the help.
socket_events:
mov eax,lparam_ ;FD_ACCEPT?
cmp ax,008h
jne go_on
shr eax,16
xor ebx,ebx
call CheckSocketList
call accept ,,offset client_addr,offset len ;Accept the connection
mov , eax ;get remote ip
mov eax, dword ptr
mov , eax
mov eax, offset LoggedUsers
sub eax, 16
mov ecx, 0
call inet_ntoa,
mov , eax
call lstrcpy,offset remip, ;copy remote ip to buffer
inc Connections
mov ,eax
call wvsprintfA,offset Connectionsstr,offset Hex2Dec,offset Connections
call SetDlgItemTextA,hwnd_,IDD_TOTUSER,offset Connectionsstr ; count connection
call lstrcpy,offset LOGTXT,offset INTRUDIN ; write to log
call WRITELOG
now it works fine , thanks for the help.
socket_events:
mov eax,lparam_ ;FD_ACCEPT?
cmp ax,008h
jne go_on
shr eax,16
xor ebx,ebx
call CheckSocketList
call accept ,,offset client_addr,offset len ;Accept the connection
mov , eax ;get remote ip
mov eax, dword ptr
mov , eax
mov eax, offset LoggedUsers
sub eax, 16
mov ecx, 0
call inet_ntoa,
mov , eax
call lstrcpy,offset remip, ;copy remote ip to buffer
inc Connections
mov ,eax
call wvsprintfA,offset Connectionsstr,offset Hex2Dec,offset Connections
call SetDlgItemTextA,hwnd_,IDD_TOTUSER,offset Connectionsstr ; count connection
call lstrcpy,offset LOGTXT,offset INTRUDIN ; write to log
call WRITELOG