mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-12-28 09:19:41 +03:00
Updated network programs to use new network function numbers from network.inc
git-svn-id: svn://kolibrios.org@2853 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
fd138cc362
commit
08c92f8c50
@ -4,169 +4,152 @@
|
|||||||
; hidnplayr@gmail.com
|
; hidnplayr@gmail.com
|
||||||
;
|
;
|
||||||
|
|
||||||
|
format binary as ""
|
||||||
|
|
||||||
use32
|
use32
|
||||||
|
|
||||||
org 0x0
|
org 0x0
|
||||||
|
|
||||||
db 'MENUET01' ; 8 byte id
|
db 'MENUET01' ; 8 byte id
|
||||||
dd 0x01 ; header version
|
dd 0x01 ; header version
|
||||||
dd START ; start of code
|
dd START ; start of code
|
||||||
dd IM_END ; size of image
|
dd IM_END ; size of image
|
||||||
dd (I_END+0x100) ; memory for app
|
dd (I_END+0x100) ; memory for app
|
||||||
dd (I_END+0x100) ; esp
|
dd (I_END+0x100) ; esp
|
||||||
dd I_PARAM , 0x0 ; I_Param , I_Icon
|
dd 0x0 , 0x0 ; I_Param , I_Icon
|
||||||
|
|
||||||
__DEBUG__ equ 1
|
include '../macros.inc'
|
||||||
__DEBUG_LEVEL__ equ 1
|
purge mov, add, sub
|
||||||
|
include '../struct.inc'
|
||||||
|
include '../network.inc'
|
||||||
|
|
||||||
include '..\macros.inc'
|
START:
|
||||||
include '..\debug-fdo.inc'
|
|
||||||
|
|
||||||
START: ; start of execution
|
redraw:
|
||||||
; TODO: check Parameters
|
|
||||||
|
|
||||||
DEBUGF 1, 'Hello!\n'
|
mcall 12, 1
|
||||||
|
mcall 0, 100 shl 16 + 520, 100 shl 16 + 240, 0x34bcbcbc, , str_name
|
||||||
|
mcall 4, 25 shl 16 + 31, 0x80000000, str_legend
|
||||||
|
mcall 12, 2
|
||||||
|
|
||||||
redraw:
|
draw_stats:
|
||||||
|
|
||||||
mcall 12, 1
|
mov edx, 50 shl 16 + 50
|
||||||
|
mov [last], 0
|
||||||
|
|
||||||
mcall 0, 100 shl 16 + 520, 100 shl 16 + 240, 0x34bcbcbc, ,name
|
.loop:
|
||||||
|
mcall 76, API_ARP + 3, [last],,, arp_buf
|
||||||
|
cmp eax, -1
|
||||||
|
je mainloop
|
||||||
|
|
||||||
mcall 4, 25 shl 16 + 31, 0x80000000, title
|
mcall 4, edx, 0x80000000, str_entry
|
||||||
|
mov edx, ebx
|
||||||
|
|
||||||
mcall 12, 2
|
mov eax, 47
|
||||||
|
mov ebx, 0x00030000
|
||||||
|
mov esi, 0x40000000
|
||||||
|
mov edi, 0x00bcbcbc
|
||||||
|
xor ecx, ecx
|
||||||
|
|
||||||
draw_stats:
|
mov cl, byte[arp_buf.IP+0]
|
||||||
|
mcall
|
||||||
|
|
||||||
mov edx, 50 shl 16 + 50
|
mov cl, byte[arp_buf.IP+1]
|
||||||
mov [last],0
|
add edx, 24 shl 16
|
||||||
|
mcall
|
||||||
|
|
||||||
.loop:
|
mov cl, byte[arp_buf.IP+2]
|
||||||
mcall 76, 0x06080003, [last],,,ARP_ENTRY
|
add edx, 24 shl 16
|
||||||
cmp eax, -1
|
mcall
|
||||||
je mainloop
|
|
||||||
|
mov cl, byte[arp_buf.IP+3]
|
||||||
|
add edx, 24 shl 16
|
||||||
|
mcall
|
||||||
|
|
||||||
|
|
||||||
mcall 4, edx, 0x80000000, str_entry
|
mov ebx, 0x00020100
|
||||||
mov edx, ebx
|
mov cl, byte[arp_buf.MAC+0]
|
||||||
|
add edx, 36 shl 16
|
||||||
|
mcall
|
||||||
|
|
||||||
mov eax, 47
|
mov cl, byte[arp_buf.MAC+1]
|
||||||
mov ebx, 0x00030000
|
add edx, 18 shl 16
|
||||||
mov esi, 0x40000000
|
mcall
|
||||||
mov edi, 0x00bcbcbc
|
|
||||||
xor ecx, ecx
|
|
||||||
|
|
||||||
mov cl, byte[ARP_ENTRY.IP+0]
|
mov cl, byte[arp_buf.MAC+2]
|
||||||
mcall
|
add edx, 18 shl 16
|
||||||
|
mcall
|
||||||
|
|
||||||
mov cl, byte[ARP_ENTRY.IP+1]
|
mov cl, byte[arp_buf.MAC+3]
|
||||||
add edx, 24 shl 16
|
add edx, 18 shl 16
|
||||||
mcall
|
mcall
|
||||||
|
|
||||||
mov cl, byte[ARP_ENTRY.IP+2]
|
mov cl, byte[arp_buf.MAC+4]
|
||||||
add edx, 24 shl 16
|
add edx, 18 shl 16
|
||||||
mcall
|
mcall
|
||||||
|
|
||||||
mov cl, byte[ARP_ENTRY.IP+3]
|
mov cl, byte[arp_buf.MAC+5]
|
||||||
add edx, 24 shl 16
|
add edx, 18 shl 16
|
||||||
mcall
|
mcall
|
||||||
|
|
||||||
|
mov ebx, 0x00040000
|
||||||
|
mov cx, [arp_buf.status]
|
||||||
|
add edx, 30 shl 16
|
||||||
|
mcall
|
||||||
|
|
||||||
|
mov cx, [arp_buf.TTL]
|
||||||
|
add edx, 60 shl 16
|
||||||
|
mcall
|
||||||
|
|
||||||
|
add dx, 20
|
||||||
|
rol edx, 16
|
||||||
|
mov dx, 50
|
||||||
|
rol edx, 16
|
||||||
|
inc [last]
|
||||||
|
|
||||||
|
jmp .loop
|
||||||
|
|
||||||
|
|
||||||
mov ebx, 0x00020100
|
mainloop:
|
||||||
mov cl, byte[ARP_ENTRY.MAC+0]
|
|
||||||
add edx, 36 shl 16
|
|
||||||
mcall
|
|
||||||
|
|
||||||
mov cl, byte[ARP_ENTRY.MAC+1]
|
mcall 23,50 ; wait for event with timeout (0,5 s)
|
||||||
add edx, 18 shl 16
|
|
||||||
mcall
|
|
||||||
|
|
||||||
mov cl, byte[ARP_ENTRY.MAC+2]
|
cmp eax, 1
|
||||||
add edx, 18 shl 16
|
je redraw
|
||||||
mcall
|
cmp eax, 2
|
||||||
|
je key
|
||||||
|
cmp eax, 3
|
||||||
|
je button
|
||||||
|
|
||||||
mov cl, byte[ARP_ENTRY.MAC+3]
|
jmp draw_stats
|
||||||
add edx, 18 shl 16
|
|
||||||
mcall
|
|
||||||
|
|
||||||
mov cl, byte[ARP_ENTRY.MAC+4]
|
|
||||||
add edx, 18 shl 16
|
|
||||||
mcall
|
|
||||||
|
|
||||||
mov cl, byte[ARP_ENTRY.MAC+5]
|
|
||||||
add edx, 18 shl 16
|
|
||||||
mcall
|
|
||||||
|
|
||||||
mov ebx, 0x00040000
|
|
||||||
mov cx, [ARP_ENTRY.Status]
|
|
||||||
add edx, 30 shl 16
|
|
||||||
mcall
|
|
||||||
|
|
||||||
mov cx, [ARP_ENTRY.TTL]
|
|
||||||
add edx, 60 shl 16
|
|
||||||
mcall
|
|
||||||
|
|
||||||
add dx, 20
|
|
||||||
rol edx, 16
|
|
||||||
mov dx, 50
|
|
||||||
rol edx, 16
|
|
||||||
inc [last]
|
|
||||||
|
|
||||||
jmp .loop
|
|
||||||
|
|
||||||
mainloop:
|
|
||||||
|
|
||||||
mcall 23,50 ; wait for event with timeout (0,5 s)
|
|
||||||
|
|
||||||
cmp eax, 1
|
|
||||||
je redraw
|
|
||||||
cmp eax, 2
|
|
||||||
je key
|
|
||||||
cmp eax, 3
|
|
||||||
je button
|
|
||||||
|
|
||||||
jmp draw_stats
|
|
||||||
|
|
||||||
|
|
||||||
key:
|
key:
|
||||||
mcall 2
|
mcall 2
|
||||||
jmp mainloop
|
jmp mainloop
|
||||||
|
|
||||||
|
|
||||||
button: ; button
|
button: ; button
|
||||||
mcall 17 ; get id
|
mcall 17 ; get id
|
||||||
cmp ah, 1
|
cmp ah, 1
|
||||||
je close
|
je exit
|
||||||
jmp redraw
|
jmp redraw
|
||||||
|
|
||||||
close:
|
exit:
|
||||||
mcall -1
|
mcall -1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; DATA AREA
|
; DATA AREA
|
||||||
|
|
||||||
name db 'ARP manager',0
|
str_name db 'ARP manager', 0
|
||||||
|
str_legend db '# IP-address MAC-address Status TTL', 0
|
||||||
title db '# IP-address MAC-address Status TTL',0
|
str_entry db ' . . . - - - - - s', 0
|
||||||
str_entry db ' . . . - - - - - s',0
|
|
||||||
|
|
||||||
last dd 0
|
|
||||||
|
|
||||||
|
|
||||||
ARP_ENTRY:
|
|
||||||
.IP dd 192 shl 0 + 168 shl 8 + 1 shl 16 + 1 shl 24
|
|
||||||
.MAC dp 0xdeadbeef1337
|
|
||||||
.Status dw 0x0300
|
|
||||||
.TTL dw 37
|
|
||||||
.size:
|
|
||||||
|
|
||||||
include_debug_strings ; ALWAYS present in data section
|
|
||||||
|
|
||||||
IM_END:
|
IM_END:
|
||||||
|
|
||||||
I_PARAM rb 1024
|
last dd ?
|
||||||
|
arp_buf ARP_entry
|
||||||
|
|
||||||
I_END:
|
I_END:
|
||||||
|
|
||||||
|
@ -1,17 +1,20 @@
|
|||||||
|
|
||||||
|
format binary as ""
|
||||||
|
|
||||||
use32
|
use32
|
||||||
org 0x0
|
org 0x0
|
||||||
; standard header
|
; standard header
|
||||||
db 'MENUET01' ; signature
|
db 'MENUET01' ; signature
|
||||||
dd 1 ; header version
|
dd 1 ; header version
|
||||||
dd start ; entry point
|
dd start ; entry point
|
||||||
dd I_END ; initialized size
|
dd I_END ; initialized size
|
||||||
dd mem ; required memory
|
dd mem ; required memory
|
||||||
dd mem ; stack pointer
|
dd mem ; stack pointer
|
||||||
dd 0 ; parameters
|
dd 0 ; parameters
|
||||||
dd 0 ; path
|
dd 0 ; path
|
||||||
|
|
||||||
|
|
||||||
BUFFERSIZE equ 1500
|
BUFFERSIZE equ 1500
|
||||||
; useful includes
|
; useful includes
|
||||||
include '../macros.inc'
|
include '../macros.inc'
|
||||||
purge mov,add,sub
|
purge mov,add,sub
|
||||||
@ -24,258 +27,258 @@ include '../network.inc'
|
|||||||
|
|
||||||
; ICMP types & codes
|
; ICMP types & codes
|
||||||
|
|
||||||
ICMP_ECHOREPLY equ 0 ; echo reply message
|
ICMP_ECHOREPLY equ 0 ; echo reply message
|
||||||
|
|
||||||
ICMP_UNREACH equ 3
|
ICMP_UNREACH equ 3
|
||||||
ICMP_UNREACH_NET equ 0 ; bad net
|
ICMP_UNREACH_NET equ 0 ; bad net
|
||||||
ICMP_UNREACH_HOST equ 1 ; bad host
|
ICMP_UNREACH_HOST equ 1 ; bad host
|
||||||
ICMP_UNREACH_PROTOCOL equ 2 ; bad protocol
|
ICMP_UNREACH_PROTOCOL equ 2 ; bad protocol
|
||||||
ICMP_UNREACH_PORT equ 3 ; bad port
|
ICMP_UNREACH_PORT equ 3 ; bad port
|
||||||
ICMP_UNREACH_NEEDFRAG equ 4 ; IP_DF caused drop
|
ICMP_UNREACH_NEEDFRAG equ 4 ; IP_DF caused drop
|
||||||
ICMP_UNREACH_SRCFAIL equ 5 ; src route failed
|
ICMP_UNREACH_SRCFAIL equ 5 ; src route failed
|
||||||
ICMP_UNREACH_NET_UNKNOWN equ 6 ; unknown net
|
ICMP_UNREACH_NET_UNKNOWN equ 6 ; unknown net
|
||||||
ICMP_UNREACH_HOST_UNKNOWN equ 7 ; unknown host
|
ICMP_UNREACH_HOST_UNKNOWN equ 7 ; unknown host
|
||||||
ICMP_UNREACH_ISOLATED equ 8 ; src host isolated
|
ICMP_UNREACH_ISOLATED equ 8 ; src host isolated
|
||||||
ICMP_UNREACH_NET_PROHIB equ 9 ; prohibited access
|
ICMP_UNREACH_NET_PROHIB equ 9 ; prohibited access
|
||||||
ICMP_UNREACH_HOST_PROHIB equ 10 ; ditto
|
ICMP_UNREACH_HOST_PROHIB equ 10 ; ditto
|
||||||
ICMP_UNREACH_TOSNET equ 11 ; bad tos for net
|
ICMP_UNREACH_TOSNET equ 11 ; bad tos for net
|
||||||
ICMP_UNREACH_TOSHOST equ 12 ; bad tos for host
|
ICMP_UNREACH_TOSHOST equ 12 ; bad tos for host
|
||||||
ICMP_UNREACH_FILTER_PROHIB equ 13 ; admin prohib
|
ICMP_UNREACH_FILTER_PROHIB equ 13 ; admin prohib
|
||||||
ICMP_UNREACH_HOST_PRECEDENCE equ 14 ; host prec vio.
|
ICMP_UNREACH_HOST_PRECEDENCE equ 14 ; host prec vio.
|
||||||
ICMP_UNREACH_PRECEDENCE_CUTOFF equ 15 ; prec cutoff
|
ICMP_UNREACH_PRECEDENCE_CUTOFF equ 15 ; prec cutoff
|
||||||
|
|
||||||
ICMP_SOURCEQUENCH equ 4 ; Packet lost, slow down
|
ICMP_SOURCEQUENCH equ 4 ; Packet lost, slow down
|
||||||
|
|
||||||
ICMP_REDIRECT equ 5 ; shorter route, codes:
|
ICMP_REDIRECT equ 5 ; shorter route, codes:
|
||||||
ICMP_REDIRECT_NET equ 0 ; for network
|
ICMP_REDIRECT_NET equ 0 ; for network
|
||||||
ICMP_REDIRECT_HOST equ 1 ; for host
|
ICMP_REDIRECT_HOST equ 1 ; for host
|
||||||
ICMP_REDIRECT_TOSNET equ 2 ; for tos and net
|
ICMP_REDIRECT_TOSNET equ 2 ; for tos and net
|
||||||
ICMP_REDIRECT_TOSHOST equ 3 ; for tos and host
|
ICMP_REDIRECT_TOSHOST equ 3 ; for tos and host
|
||||||
|
|
||||||
ICMP_ALTHOSTADDR equ 6 ; alternate host address
|
ICMP_ALTHOSTADDR equ 6 ; alternate host address
|
||||||
ICMP_ECHO equ 8 ; echo service
|
ICMP_ECHO equ 8 ; echo service
|
||||||
ICMP_ROUTERADVERT equ 9 ; router advertisement
|
ICMP_ROUTERADVERT equ 9 ; router advertisement
|
||||||
ICMP_ROUTERADVERT_NORMAL equ 0 ; normal advertisement
|
ICMP_ROUTERADVERT_NORMAL equ 0 ; normal advertisement
|
||||||
ICMP_ROUTERADVERT_NOROUTE_COMMON equ 16 ; selective routing
|
ICMP_ROUTERADVERT_NOROUTE_COMMON equ 16 ; selective routing
|
||||||
|
|
||||||
ICMP_ROUTERSOLICIT equ 10 ; router solicitation
|
ICMP_ROUTERSOLICIT equ 10 ; router solicitation
|
||||||
ICMP_TIMXCEED equ 11 ; time exceeded, code:
|
ICMP_TIMXCEED equ 11 ; time exceeded, code:
|
||||||
ICMP_TIMXCEED_INTRANS equ 0 ; ttl==0 in transit
|
ICMP_TIMXCEED_INTRANS equ 0 ; ttl==0 in transit
|
||||||
ICMP_TIMXCEED_REASS equ 1 ; ttl==0 in reass
|
ICMP_TIMXCEED_REASS equ 1 ; ttl==0 in reass
|
||||||
|
|
||||||
ICMP_PARAMPROB equ 12 ; ip header bad
|
ICMP_PARAMPROB equ 12 ; ip header bad
|
||||||
ICMP_PARAMPROB_ERRATPTR equ 0 ; error at param ptr
|
ICMP_PARAMPROB_ERRATPTR equ 0 ; error at param ptr
|
||||||
ICMP_PARAMPROB_OPTABSENT equ 1 ; req. opt. absent
|
ICMP_PARAMPROB_OPTABSENT equ 1 ; req. opt. absent
|
||||||
ICMP_PARAMPROB_LENGTH equ 2 ; bad length
|
ICMP_PARAMPROB_LENGTH equ 2 ; bad length
|
||||||
|
|
||||||
ICMP_TSTAMP equ 13 ; timestamp request
|
ICMP_TSTAMP equ 13 ; timestamp request
|
||||||
ICMP_TSTAMPREPLY equ 14 ; timestamp reply
|
ICMP_TSTAMPREPLY equ 14 ; timestamp reply
|
||||||
ICMP_IREQ equ 15 ; information request
|
ICMP_IREQ equ 15 ; information request
|
||||||
ICMP_IREQREPLY equ 16 ; information reply
|
ICMP_IREQREPLY equ 16 ; information reply
|
||||||
ICMP_MASKREQ equ 17 ; address mask request
|
ICMP_MASKREQ equ 17 ; address mask request
|
||||||
ICMP_MASKREPLY equ 18 ; address mask reply
|
ICMP_MASKREPLY equ 18 ; address mask reply
|
||||||
ICMP_TRACEROUTE equ 30 ; traceroute
|
ICMP_TRACEROUTE equ 30 ; traceroute
|
||||||
ICMP_DATACONVERR equ 31 ; data conversion error
|
ICMP_DATACONVERR equ 31 ; data conversion error
|
||||||
ICMP_MOBILE_REDIRECT equ 32 ; mobile host redirect
|
ICMP_MOBILE_REDIRECT equ 32 ; mobile host redirect
|
||||||
ICMP_IPV6_WHEREAREYOU equ 33 ; IPv6 where-are-you
|
ICMP_IPV6_WHEREAREYOU equ 33 ; IPv6 where-are-you
|
||||||
ICMP_IPV6_IAMHERE equ 34 ; IPv6 i-am-here
|
ICMP_IPV6_IAMHERE equ 34 ; IPv6 i-am-here
|
||||||
ICMP_MOBILE_REGREQUEST equ 35 ; mobile registration req
|
ICMP_MOBILE_REGREQUEST equ 35 ; mobile registration req
|
||||||
ICMP_MOBILE_REGREPLY equ 36 ; mobile registreation reply
|
ICMP_MOBILE_REGREPLY equ 36 ; mobile registreation reply
|
||||||
ICMP_SKIP equ 39 ; SKIP
|
ICMP_SKIP equ 39 ; SKIP
|
||||||
|
|
||||||
ICMP_PHOTURIS equ 40 ; Photuris
|
ICMP_PHOTURIS equ 40 ; Photuris
|
||||||
ICMP_PHOTURIS_UNKNOWN_INDEX equ 1 ; unknown sec index
|
ICMP_PHOTURIS_UNKNOWN_INDEX equ 1 ; unknown sec index
|
||||||
ICMP_PHOTURIS_AUTH_FAILED equ 2 ; auth failed
|
ICMP_PHOTURIS_AUTH_FAILED equ 2 ; auth failed
|
||||||
ICMP_PHOTURIS_DECRYPT_FAILED equ 3 ; decrypt failed
|
ICMP_PHOTURIS_DECRYPT_FAILED equ 3 ; decrypt failed
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
virtual at 0
|
virtual at 0
|
||||||
ICMP_Packet:
|
ICMP_Packet:
|
||||||
.Type db ?
|
.Type db ?
|
||||||
.Code db ?
|
.Code db ?
|
||||||
.Checksum dw ?
|
.Checksum dw ?
|
||||||
.Identifier dw ?
|
.Identifier dw ?
|
||||||
.SequenceNumber dw ?
|
.SequenceNumber dw ?
|
||||||
.Data:
|
.Data:
|
||||||
end virtual
|
end virtual
|
||||||
|
|
||||||
|
|
||||||
; entry point
|
; entry point
|
||||||
start:
|
start:
|
||||||
; load libraries
|
; load libraries
|
||||||
stdcall dll.Load, @IMPORT
|
stdcall dll.Load, @IMPORT
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jnz exit
|
jnz exit
|
||||||
; initialize console
|
; initialize console
|
||||||
push 1
|
push 1
|
||||||
call [con_start]
|
call [con_start]
|
||||||
push title
|
push title
|
||||||
push 25
|
push 25
|
||||||
push 80
|
push 80
|
||||||
push 25
|
push 25
|
||||||
push 80
|
push 80
|
||||||
call [con_init]
|
call [con_init]
|
||||||
; main loop
|
; main loop
|
||||||
push str1
|
push str1
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
main:
|
main:
|
||||||
; write prompt
|
; write prompt
|
||||||
push str2
|
push str2
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
; read string
|
; read string
|
||||||
mov esi, s
|
mov esi, s
|
||||||
push 256
|
push 256
|
||||||
push esi
|
push esi
|
||||||
call [con_gets]
|
call [con_gets]
|
||||||
; check for exit
|
; check for exit
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz done
|
jz done
|
||||||
cmp byte [esi], 10
|
cmp byte [esi], 10
|
||||||
jz done
|
jz done
|
||||||
; delete terminating '\n'
|
; delete terminating '\n'
|
||||||
push esi
|
push esi
|
||||||
@@:
|
@@:
|
||||||
lodsb
|
lodsb
|
||||||
test al, al
|
test al, al
|
||||||
jnz @b
|
jnz @b
|
||||||
mov byte [esi-2], al
|
mov byte [esi-2], al
|
||||||
pop esi
|
pop esi
|
||||||
; resolve name
|
; resolve name
|
||||||
push esp ; reserve stack place
|
push esp ; reserve stack place
|
||||||
push esp ; fourth parameter
|
push esp ; fourth parameter
|
||||||
push 0 ; third parameter
|
push 0 ; third parameter
|
||||||
push 0 ; second parameter
|
push 0 ; second parameter
|
||||||
push esi ; first parameter
|
push esi ; first parameter
|
||||||
call [getaddrinfo]
|
call [getaddrinfo]
|
||||||
pop esi
|
pop esi
|
||||||
; test for error
|
; test for error
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jnz fail
|
jnz fail
|
||||||
|
|
||||||
; convert IP address to decimal notation
|
; convert IP address to decimal notation
|
||||||
mov eax, [esi+addrinfo.ai_addr]
|
mov eax, [esi+addrinfo.ai_addr]
|
||||||
mov eax, [eax+sockaddr_in.sin_addr]
|
mov eax, [eax+sockaddr_in.sin_addr]
|
||||||
mov [sockaddr1.ip], eax
|
mov [sockaddr1.ip], eax
|
||||||
push eax
|
push eax
|
||||||
call [inet_ntoa]
|
call [inet_ntoa]
|
||||||
; write result
|
; write result
|
||||||
mov [ip_ptr], eax
|
mov [ip_ptr], eax
|
||||||
|
|
||||||
push eax
|
push eax
|
||||||
|
|
||||||
; free allocated memory
|
; free allocated memory
|
||||||
push esi
|
push esi
|
||||||
call [freeaddrinfo]
|
call [freeaddrinfo]
|
||||||
|
|
||||||
push str4
|
push str4
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
|
|
||||||
mcall socket, AF_INET4, SOCK_RAW, IPPROTO_ICMP
|
mcall socket, AF_INET4, SOCK_RAW, IPPROTO_ICMP
|
||||||
cmp eax, -1
|
cmp eax, -1
|
||||||
jz fail2
|
jz fail2
|
||||||
mov [socketnum], eax
|
mov [socketnum], eax
|
||||||
|
|
||||||
mcall connect, [socketnum], sockaddr1, 18
|
mcall connect, [socketnum], sockaddr1, 18
|
||||||
|
|
||||||
mcall 40, 1 shl 7 ; + 7
|
mcall 40, 1 shl 7 ; + 7
|
||||||
; call [con_cls]
|
; call [con_cls]
|
||||||
|
|
||||||
mov [count], 4
|
mov [count], 4
|
||||||
|
|
||||||
mainloop:
|
mainloop:
|
||||||
push str3
|
push str3
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
push [ip_ptr]
|
push [ip_ptr]
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
|
|
||||||
mcall 26,9
|
mcall 26,9
|
||||||
mov [time_reference], eax
|
mov [time_reference], eax
|
||||||
mcall send, [socketnum], icmp_packet, icmp_packet.length, 0
|
mcall send, [socketnum], icmp_packet, icmp_packet.length, 0
|
||||||
|
|
||||||
mcall 23, 300 ; 3 seconds time-out
|
mcall 23, 300 ; 3 seconds time-out
|
||||||
mcall 26,9
|
mcall 26,9
|
||||||
neg [time_reference]
|
neg [time_reference]
|
||||||
add [time_reference], eax
|
add [time_reference], eax
|
||||||
|
|
||||||
mcall recv, [socketnum], buffer_ptr, BUFFERSIZE, 0
|
mcall recv, [socketnum], buffer_ptr, BUFFERSIZE, 0
|
||||||
cmp eax, -1
|
cmp eax, -1
|
||||||
je .no_response
|
je .no_response
|
||||||
|
|
||||||
; validate the packet
|
; validate the packet
|
||||||
lea esi, [buffer_ptr + ICMP_Packet.Data]
|
lea esi, [buffer_ptr + ICMP_Packet.Data]
|
||||||
mov edi, icmp_packet.data
|
mov edi, icmp_packet.data
|
||||||
mov ecx, 32/4
|
mov ecx, 32/4
|
||||||
repe cmpsd
|
repe cmpsd
|
||||||
jne .miscomp
|
jne .miscomp
|
||||||
|
|
||||||
push [time_reference]
|
push [time_reference]
|
||||||
push str7
|
push str7
|
||||||
call [con_printf]
|
call [con_printf]
|
||||||
|
|
||||||
jmp continue
|
jmp continue
|
||||||
|
|
||||||
.miscomp:
|
.miscomp:
|
||||||
sub edi, icmp_packet.data
|
sub edi, icmp_packet.data
|
||||||
push edi
|
push edi
|
||||||
push str9
|
push str9
|
||||||
call [con_printf]
|
call [con_printf]
|
||||||
jmp continue
|
jmp continue
|
||||||
|
|
||||||
.no_response:
|
.no_response:
|
||||||
push str8
|
push str8
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
|
|
||||||
continue:
|
continue:
|
||||||
dec [count]
|
dec [count]
|
||||||
jz done
|
jz done
|
||||||
mcall 5, 100 ; wait a second
|
mcall 5, 100 ; wait a second
|
||||||
inc [icmp_packet.id]
|
inc [icmp_packet.id]
|
||||||
jmp mainloop
|
jmp mainloop
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
push str10
|
push str10
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
call [con_getch2]
|
call [con_getch2]
|
||||||
push 1
|
push 1
|
||||||
call [con_exit]
|
call [con_exit]
|
||||||
exit:
|
exit:
|
||||||
mcall -1
|
mcall -1
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
push str5
|
push str5
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
jmp done
|
jmp done
|
||||||
fail2:
|
fail2:
|
||||||
push str6
|
push str6
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
jmp done
|
jmp done
|
||||||
|
|
||||||
|
|
||||||
; data
|
; data
|
||||||
title db 'ICMP - test application',0
|
title db 'ICMP - test application',0
|
||||||
str1 db 'ICMP test application v0.1',10,' for KolibriOS # 1540 or later. ',10,10,0
|
str1 db 'ICMP test application v0.1',10,' for KolibriOS # 1540 or later. ',10,10,0
|
||||||
str2 db '> ',0
|
str2 db '> ',0
|
||||||
str3 db 'Ping to: ',0
|
str3 db 'Ping to: ',0
|
||||||
str4 db 10,0
|
str4 db 10,0
|
||||||
str5 db 'Name resolution failed.',10,10,0
|
str5 db 'Name resolution failed.',10,10,0
|
||||||
str6 db 'Could not open socket',10,10,0
|
str6 db 'Could not open socket',10,10,0
|
||||||
str7 db ' time= %u0ms',10,0
|
str7 db ' time= %u0ms',10,0
|
||||||
str8 db ' timeout!',10,0
|
str8 db ' timeout!',10,0
|
||||||
str9 db ' miscompare at offset %u',10,0
|
str9 db ' miscompare at offset %u',10,0
|
||||||
str10 db 10,10,'Press any key to exit',0
|
str10 db 10,10,'Press any key to exit',0
|
||||||
|
|
||||||
sockaddr1:
|
sockaddr1:
|
||||||
dw AF_INET4
|
dw AF_INET4
|
||||||
.port dw 0
|
.port dw 0
|
||||||
.ip dd 0
|
.ip dd 0
|
||||||
rb 10
|
rb 10
|
||||||
|
|
||||||
time_reference dd ?
|
time_reference dd ?
|
||||||
ip_ptr dd ?
|
ip_ptr dd ?
|
||||||
count dd ?
|
count dd ?
|
||||||
|
|
||||||
|
|
||||||
; import
|
; import
|
||||||
@ -283,37 +286,37 @@ align 4
|
|||||||
@IMPORT:
|
@IMPORT:
|
||||||
|
|
||||||
library network, 'network.obj', console, 'console.obj'
|
library network, 'network.obj', console, 'console.obj'
|
||||||
import network, \
|
import network, \
|
||||||
getaddrinfo, 'getaddrinfo', \
|
getaddrinfo, 'getaddrinfo', \
|
||||||
freeaddrinfo, 'freeaddrinfo', \
|
freeaddrinfo, 'freeaddrinfo', \
|
||||||
inet_ntoa, 'inet_ntoa'
|
inet_ntoa, 'inet_ntoa'
|
||||||
|
|
||||||
import console, \
|
import console, \
|
||||||
con_start, 'START', \
|
con_start, 'START', \
|
||||||
con_init, 'con_init', \
|
con_init, 'con_init', \
|
||||||
con_write_asciiz, 'con_write_asciiz', \
|
con_write_asciiz, 'con_write_asciiz', \
|
||||||
con_printf, 'con_printf', \
|
con_printf, 'con_printf', \
|
||||||
con_exit, 'con_exit', \
|
con_exit, 'con_exit', \
|
||||||
con_gets, 'con_gets',\
|
con_gets, 'con_gets',\
|
||||||
con_cls, 'con_cls',\
|
con_cls, 'con_cls',\
|
||||||
con_getch2, 'con_getch2',\
|
con_getch2, 'con_getch2',\
|
||||||
con_set_cursor_pos, 'con_set_cursor_pos'
|
con_set_cursor_pos, 'con_set_cursor_pos'
|
||||||
|
|
||||||
socketnum dd ?
|
socketnum dd ?
|
||||||
|
|
||||||
icmp_packet: db 8 ; type
|
icmp_packet: db 8 ; type
|
||||||
db 0 ; code
|
db 0 ; code
|
||||||
dw 0 ;
|
dw 0 ;
|
||||||
.id dw 0x0000 ; identifier
|
.id dw 0x0000 ; identifier
|
||||||
.seq dw 0x0001 ; sequence number
|
.seq dw 0x0001 ; sequence number
|
||||||
.data db 'abcdefghijklmnopqrstuvwxyz012345678'
|
.data db 'abcdefghijklmnopqrstuvwxyz012345678'
|
||||||
.length = $ - icmp_packet
|
.length = $ - icmp_packet
|
||||||
|
|
||||||
I_END:
|
I_END:
|
||||||
|
|
||||||
buffer_ptr rb BUFFERSIZE
|
buffer_ptr rb BUFFERSIZE
|
||||||
|
|
||||||
s rb 256
|
s rb 256
|
||||||
align 4
|
align 4
|
||||||
rb 4096 ; stack
|
rb 4096 ; stack
|
||||||
mem:
|
mem:
|
||||||
|
@ -6,16 +6,18 @@
|
|||||||
; By hidnplayr
|
; By hidnplayr
|
||||||
;
|
;
|
||||||
|
|
||||||
use32
|
format binary as ""
|
||||||
org 0x0
|
|
||||||
|
|
||||||
db 'MENUET01' ; 8 byte id
|
use32
|
||||||
dd 0x01 ; header version
|
org 0x0
|
||||||
dd START ; start of code
|
|
||||||
dd IM_END ; size of image
|
db 'MENUET01' ; 8 byte id
|
||||||
dd (I_END+0x100) ; memory for app
|
dd 0x01 ; header version
|
||||||
dd (I_END+0x100) ; esp
|
dd START ; start of code
|
||||||
dd param, 0x0 ; I_Param , I_Icon
|
dd IM_END ; size of image
|
||||||
|
dd (I_END+0x100) ; memory for app
|
||||||
|
dd (I_END+0x100) ; esp
|
||||||
|
dd param, 0x0 ; I_Param , I_Icon
|
||||||
|
|
||||||
type_ethernet equ 1
|
type_ethernet equ 1
|
||||||
|
|
||||||
@ -24,170 +26,174 @@ include 'proc32.inc'
|
|||||||
include 'struct.inc'
|
include 'struct.inc'
|
||||||
|
|
||||||
START:
|
START:
|
||||||
; first, check boot parameters
|
; first, check boot parameters
|
||||||
|
|
||||||
cmp byte[param], 0
|
cmp byte[param], 0
|
||||||
je .noparams
|
je .noparams
|
||||||
|
|
||||||
mcall 40, 0
|
mcall 40, 0
|
||||||
|
|
||||||
|
|
||||||
push exit
|
push .launch_zeroconf_exit
|
||||||
cmp byte[param], 'A' ; A for All
|
cmp byte[param], 'A' ; A for All
|
||||||
je Get_PCI_Info
|
je Get_PCI_Info
|
||||||
|
|
||||||
cmp byte[param], 'F' ; F for First
|
cmp byte[param], 'F' ; F for First
|
||||||
je Get_PCI_Info
|
je Get_PCI_Info
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
.launch_zeroconf_exit:
|
||||||
|
mcall 70, zeroconf
|
||||||
|
mcall -1
|
||||||
|
|
||||||
.noparams:
|
.noparams:
|
||||||
call draw_window
|
call draw_window
|
||||||
|
|
||||||
still: mcall 10 ; wait here for event
|
still: mcall 10 ; wait here for event
|
||||||
dec eax ; redraw request ?
|
dec eax ; redraw request ?
|
||||||
jz red
|
jz red
|
||||||
dec eax ; key in buffer ?
|
dec eax ; key in buffer ?
|
||||||
jz key
|
jz key
|
||||||
dec eax ; button in buffer ?
|
dec eax ; button in buffer ?
|
||||||
jz button
|
jz button
|
||||||
jmp still
|
jmp still
|
||||||
|
|
||||||
red: ; redraw
|
red: ; redraw
|
||||||
mcall 9, Proc_Info, -1 ; window redraw requested so get new window coordinates and size
|
mcall 9, Proc_Info, -1 ; window redraw requested so get new window coordinates and size
|
||||||
mov eax, [Proc_Info.box.left]; store the window coordinates into the Form Structure
|
mov eax, [Proc_Info.box.left]; store the window coordinates into the Form Structure
|
||||||
mov [Form + 2], ax ; x start position
|
mov [Form + 2], ax ; x start position
|
||||||
mov eax, [Proc_Info.box.top];
|
mov eax, [Proc_Info.box.top];
|
||||||
mov [Form + 6], ax ; ystart position
|
mov [Form + 6], ax ; ystart position
|
||||||
mov eax, [Proc_Info.box.width] ;
|
mov eax, [Proc_Info.box.width] ;
|
||||||
mov [Form], ax ; window width
|
mov [Form], ax ; window width
|
||||||
mov eax, [Proc_Info.box.height] ;
|
mov eax, [Proc_Info.box.height] ;
|
||||||
mov [Form + 4] ,ax ; window height
|
mov [Form + 4] ,ax ; window height
|
||||||
call draw_window ; go redraw window now
|
call draw_window ; go redraw window now
|
||||||
jmp still
|
jmp still
|
||||||
|
|
||||||
key: ; key
|
key: ; key
|
||||||
mcall 2 ; just read it and ignore
|
mcall 2 ; just read it and ignore
|
||||||
jmp still
|
jmp still
|
||||||
button: ; button
|
button: ; button
|
||||||
mcall 17 ; get id
|
mcall 17 ; get id
|
||||||
|
|
||||||
cmp ah, 1 ; button id = 1 ?
|
cmp ah, 1 ; button id = 1 ?
|
||||||
jne @f
|
jne @f
|
||||||
exit: mcall -1 ; close this program
|
exit: mcall -1 ; close this program
|
||||||
@@:
|
@@:
|
||||||
cmp eax,0x0000ff00
|
cmp eax,0x0000ff00
|
||||||
jg load_drv
|
jg load_drv
|
||||||
|
|
||||||
cmp ah, 4
|
cmp ah, 4
|
||||||
je hook
|
je hook
|
||||||
|
|
||||||
cmp ah, 5
|
cmp ah, 5
|
||||||
je reset
|
je reset
|
||||||
|
|
||||||
cmp ah, 6
|
cmp ah, 6
|
||||||
je unload
|
je unload
|
||||||
|
|
||||||
jmp still
|
jmp still
|
||||||
|
|
||||||
|
|
||||||
load_drv:
|
load_drv:
|
||||||
shr eax, 16
|
shr eax, 16
|
||||||
mov word [selected], ax
|
mov word [selected], ax
|
||||||
|
|
||||||
mov bl , 6 ; get a dword
|
mov bl , 6 ; get a dword
|
||||||
mov bh , ah ; bus
|
mov bh , ah ; bus
|
||||||
mov ch , al ; dev
|
mov ch , al ; dev
|
||||||
mov cl , 0 ; offset to device/vendor id
|
mov cl , 0 ; offset to device/vendor id
|
||||||
mcall 62 ; get ID's
|
mcall 62 ; get ID's
|
||||||
|
|
||||||
mov word [PCI_Vendor], ax
|
mov word [PCI_Vendor], ax
|
||||||
shr eax, 16
|
shr eax, 16
|
||||||
mov word [PCI_Device], ax
|
mov word [PCI_Device], ax
|
||||||
call get_drv_ptr
|
call get_drv_ptr
|
||||||
|
|
||||||
mov ecx, eax
|
mov ecx, eax
|
||||||
mcall 68, 16
|
mcall 68, 16
|
||||||
|
|
||||||
mov [IOCTL.handle], eax
|
mov [IOCTL.handle], eax
|
||||||
|
|
||||||
call draw_window
|
call draw_window
|
||||||
|
|
||||||
cmp [IOCTL.handle], 0
|
cmp [IOCTL.handle], 0
|
||||||
jne still
|
jne still
|
||||||
|
|
||||||
mcall 4, 20 shl 16 + 30, 1 shl 31 + 0x00ff0000 , load_error
|
mcall 4, 20 shl 16 + 30, 1 shl 31 + 0x00ff0000 , load_error
|
||||||
|
|
||||||
jmp still
|
jmp still
|
||||||
|
|
||||||
|
|
||||||
hook:
|
hook:
|
||||||
mov ax , [selected]
|
mov ax , [selected]
|
||||||
test ax , ax
|
test ax , ax
|
||||||
jz still
|
jz still
|
||||||
|
|
||||||
mov [hardwareinfo.pci_dev], al
|
mov [hardwareinfo.pci_dev], al
|
||||||
mov [hardwareinfo.pci_bus], ah
|
mov [hardwareinfo.pci_bus], ah
|
||||||
|
|
||||||
mov [IOCTL.io_code], 1 ; SRV_HOOK
|
mov [IOCTL.io_code], 1 ; SRV_HOOK
|
||||||
mov [IOCTL.inp_size], 3
|
mov [IOCTL.inp_size], 3
|
||||||
mov [IOCTL.input], hardwareinfo
|
mov [IOCTL.input], hardwareinfo
|
||||||
mov [IOCTL.out_size], 0
|
mov [IOCTL.out_size], 0
|
||||||
mov [IOCTL.output], 0
|
mov [IOCTL.output], 0
|
||||||
|
|
||||||
mcall 68, 17, IOCTL
|
mcall 68, 17, IOCTL
|
||||||
|
|
||||||
mov byte[drivernumber], al
|
mov byte[drivernumber], al
|
||||||
|
|
||||||
jmp still
|
jmp still
|
||||||
|
|
||||||
reset:
|
reset:
|
||||||
movzx ebx, byte[drivernumber]
|
movzx ebx, byte[drivernumber]
|
||||||
mcall 74,,2
|
mcall 74,,2
|
||||||
|
|
||||||
jmp still
|
jmp still
|
||||||
|
|
||||||
unload:
|
unload:
|
||||||
movzx ebx, byte[drivernumber]
|
movzx ebx, byte[drivernumber]
|
||||||
mcall 74,,3
|
mcall 74,,3
|
||||||
|
|
||||||
jmp still
|
jmp still
|
||||||
|
|
||||||
draw_window:
|
draw_window:
|
||||||
mcall 12, 1 ; start of draw
|
mcall 12, 1 ; start of draw
|
||||||
mcall 0, dword [Form], dword [Form + 4], 0x13ffffff, 0x805080d0, title
|
mcall 0, dword [Form], dword [Form + 4], 0x13ffffff, 0x805080d0, title
|
||||||
|
|
||||||
mcall 8, 136 shl 16 + 100, 35 shl 16 + 18, 4, 0x00007f00 ; SLIP
|
mcall 8, 136 shl 16 + 100, 35 shl 16 + 18, 4, 0x00007f00 ; SLIP
|
||||||
|
|
||||||
call Get_PCI_Info ; get pci version and last bus, scan for and draw each pci device
|
call Get_PCI_Info ; get pci version and last bus, scan for and draw each pci device
|
||||||
|
|
||||||
cmp edx, 20 shl 16 + 110
|
cmp edx, 20 shl 16 + 110
|
||||||
je .nonefound
|
je .nonefound
|
||||||
|
|
||||||
mcall 4, 20 shl 16 + 100, 1 shl 31 + 0x00000000 , caption
|
mcall 4, 20 shl 16 + 100, 1 shl 31 + 0x00000000 , caption
|
||||||
|
|
||||||
cmp [selected], 0
|
cmp [selected], 0
|
||||||
jz .done
|
jz .done
|
||||||
cmp [IOCTL.handle] ,0
|
cmp [IOCTL.handle] ,0
|
||||||
jz .done
|
jz .done
|
||||||
|
|
||||||
mcall 8, 18 shl 16 + 100, 35 shl 16 + 18, 4, 0x00007f00
|
mcall 8, 18 shl 16 + 100, 35 shl 16 + 18, 4, 0x00007f00
|
||||||
mcall ,, 55 shl 16 + 18, 5, 0x0000007f
|
mcall ,, 55 shl 16 + 18, 5, 0x0000007f
|
||||||
mcall ,, 75 shl 16 + 18, 6, 0x007f0000
|
mcall ,, 75 shl 16 + 18, 6, 0x007f0000
|
||||||
|
|
||||||
mcall 4, 33 shl 16 + 42, 1 shl 31 + 0x00ffffff , btn_start
|
mcall 4, 33 shl 16 + 42, 1 shl 31 + 0x00ffffff , btn_start
|
||||||
mcall , 33 shl 16 + 62, , btn_reset
|
mcall , 33 shl 16 + 62, , btn_reset
|
||||||
mcall , 36 shl 16 + 82, , btn_stop
|
mcall , 36 shl 16 + 82, , btn_stop
|
||||||
|
|
||||||
; mcall , 140 shl 16 + 62, 1 shl 31 + 0x00000000 , devicename
|
; mcall , 140 shl 16 + 62, 1 shl 31 + 0x00000000 , devicename
|
||||||
|
|
||||||
jmp .done
|
jmp .done
|
||||||
|
|
||||||
.nonefound:
|
.nonefound:
|
||||||
mcall 4, 20 shl 16 + 30, 1 shl 31 + 0x00ff0000 , nonefound
|
mcall 4, 20 shl 16 + 30, 1 shl 31 + 0x00ff0000 , nonefound
|
||||||
.done:
|
.done:
|
||||||
mcall 12, 2 ; end of draw
|
mcall 12, 2 ; end of draw
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -196,106 +202,106 @@ draw_window:
|
|||||||
;------------------------------------------------------------------
|
;------------------------------------------------------------------
|
||||||
;* Gets the PCI Version and Last Bus
|
;* Gets the PCI Version and Last Bus
|
||||||
Get_PCI_Info:
|
Get_PCI_Info:
|
||||||
mcall 62, 0
|
mcall 62, 0
|
||||||
mov word [PCI_Version], ax
|
mov word [PCI_Version], ax
|
||||||
mcall 62, 1
|
mcall 62, 1
|
||||||
mov byte [PCI_LastBus], al
|
mov byte [PCI_LastBus], al
|
||||||
;----------------------------------------------------------
|
;----------------------------------------------------------
|
||||||
;* Get all devices on PCI Bus
|
;* Get all devices on PCI Bus
|
||||||
mov edx, 20 shl 16 + 110 ; set start write position
|
mov edx, 20 shl 16 + 110 ; set start write position
|
||||||
cmp al , 0xff ; 0xFF means no pci bus found
|
cmp al , 0xff ; 0xFF means no pci bus found
|
||||||
jne Pci_Exists ;
|
jne Pci_Exists ;
|
||||||
ret ; if no bus then leave
|
ret ; if no bus then leave
|
||||||
Pci_Exists:
|
Pci_Exists:
|
||||||
mov byte [V_Bus], 0 ; reset varibles
|
mov byte [V_Bus], 0 ; reset varibles
|
||||||
mov byte [V_Dev], 0 ;
|
mov byte [V_Dev], 0 ;
|
||||||
Start_Enum:
|
Start_Enum:
|
||||||
mov bl , 6 ; get a dword
|
mov bl , 6 ; get a dword
|
||||||
mov bh , byte [V_Bus] ; bus of pci device
|
mov bh , byte [V_Bus] ; bus of pci device
|
||||||
mov ch , byte [V_Dev] ; device number/function
|
mov ch , byte [V_Dev] ; device number/function
|
||||||
mov cl , 0 ; offset to device/vendor id
|
mov cl , 0 ; offset to device/vendor id
|
||||||
mcall 62 ; get ID's
|
mcall 62 ; get ID's
|
||||||
|
|
||||||
cmp ax, 0 ; Vendor ID should not be 0 or 0xFFFF
|
cmp ax, 0 ; Vendor ID should not be 0 or 0xFFFF
|
||||||
je nextDev ; check next device if nothing exists here
|
je nextDev ; check next device if nothing exists here
|
||||||
cmp ax, 0xffff ;
|
cmp ax, 0xffff ;
|
||||||
je nextDev ;
|
je nextDev ;
|
||||||
|
|
||||||
mov word [PCI_Vendor], ax ; There is a device here, save the ID's
|
mov word [PCI_Vendor], ax ; There is a device here, save the ID's
|
||||||
shr eax, 16 ;
|
shr eax, 16 ;
|
||||||
mov word [PCI_Device], ax ;
|
mov word [PCI_Device], ax ;
|
||||||
mov bl , 4 ; Read config byte
|
mov bl , 4 ; Read config byte
|
||||||
mov bh , byte [V_Bus] ; Bus #
|
mov bh , byte [V_Bus] ; Bus #
|
||||||
mov ch , byte [V_Dev] ; Device # on bus
|
mov ch , byte [V_Dev] ; Device # on bus
|
||||||
mov cl , 0x08 ; Register to read (Get Revision)
|
mov cl , 0x08 ; Register to read (Get Revision)
|
||||||
mcall 62 ; Read it
|
mcall 62 ; Read it
|
||||||
mov byte [PCI_Rev], al ; Save it
|
mov byte [PCI_Rev], al ; Save it
|
||||||
mov cl , 0x0b ; Register to read (Get class)
|
mov cl , 0x0b ; Register to read (Get class)
|
||||||
mcall 62 ; Read it
|
mcall 62 ; Read it
|
||||||
|
|
||||||
mov byte [PCI_Class], al ; Save it
|
mov byte [PCI_Class], al ; Save it
|
||||||
mov cl , 0x0a ; Register to read (Get Subclass)
|
mov cl , 0x0a ; Register to read (Get Subclass)
|
||||||
mcall 62 ; Read it
|
mcall 62 ; Read it
|
||||||
mov byte [PCI_SubClass], al ; Save it
|
mov byte [PCI_SubClass], al ; Save it
|
||||||
mov cl , 0x09 ; Register to read (Get Interface)
|
mov cl , 0x09 ; Register to read (Get Interface)
|
||||||
mcall 62 ; Read it
|
mcall 62 ; Read it
|
||||||
mov [PCI_Interface], al ; Save it
|
mov [PCI_Interface], al ; Save it
|
||||||
mov cl , 0x3c ; Register to read (Get IRQ)
|
mov cl , 0x3c ; Register to read (Get IRQ)
|
||||||
@@: mcall 62 ; Read it
|
@@: mcall 62 ; Read it
|
||||||
mov [PCI_IRQ], al ; Save it
|
mov [PCI_IRQ], al ; Save it
|
||||||
;
|
;
|
||||||
; inc byte [total] ; one more device found
|
; inc byte [total] ; one more device found
|
||||||
|
|
||||||
cmp byte [PCI_Class],2
|
cmp byte [PCI_Class],2
|
||||||
jne nextDev
|
jne nextDev
|
||||||
|
|
||||||
cmp byte[param], 0
|
cmp byte[param], 0
|
||||||
jne load_and_start
|
jne load_and_start
|
||||||
|
|
||||||
call Print_New_Device ; print device info to screen
|
call Print_New_Device ; print device info to screen
|
||||||
|
|
||||||
nextDev:
|
nextDev:
|
||||||
add byte [V_Dev], 8 ; lower 3 bits are the function number
|
add byte [V_Dev], 8 ; lower 3 bits are the function number
|
||||||
|
|
||||||
jnz Start_Enum ; jump until we reach zero
|
jnz Start_Enum ; jump until we reach zero
|
||||||
mov byte [V_Dev], 0 ; reset device number
|
mov byte [V_Dev], 0 ; reset device number
|
||||||
inc byte [V_Bus] ; next bus
|
inc byte [V_Bus] ; next bus
|
||||||
mov al , byte [PCI_LastBus] ; get last bus
|
mov al , byte [PCI_LastBus] ; get last bus
|
||||||
cmp byte [V_Bus], al ; was it last bus
|
cmp byte [V_Bus], al ; was it last bus
|
||||||
jbe Start_Enum ; if not jump to keep searching
|
jbe Start_Enum ; if not jump to keep searching
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
load_and_start:
|
load_and_start:
|
||||||
|
|
||||||
call get_drv_ptr
|
call get_drv_ptr
|
||||||
cmp eax, lbl_none
|
cmp eax, lbl_none
|
||||||
je .next
|
je .next
|
||||||
|
|
||||||
mov ecx, eax
|
mov ecx, eax
|
||||||
mcall 68, 16
|
mcall 68, 16
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .next
|
jz .next
|
||||||
mov [IOCTL.handle], eax
|
mov [IOCTL.handle], eax
|
||||||
|
|
||||||
mov al, [V_Dev]
|
mov al, [V_Dev]
|
||||||
mov [hardwareinfo.pci_dev], al
|
mov [hardwareinfo.pci_dev], al
|
||||||
mov al, [V_Bus]
|
mov al, [V_Bus]
|
||||||
mov [hardwareinfo.pci_bus], al
|
mov [hardwareinfo.pci_bus], al
|
||||||
|
|
||||||
mov [IOCTL.io_code], 1 ; SRV_HOOK
|
mov [IOCTL.io_code], 1 ; SRV_HOOK
|
||||||
mov [IOCTL.inp_size], 3
|
mov [IOCTL.inp_size], 3
|
||||||
mov [IOCTL.input], hardwareinfo
|
mov [IOCTL.input], hardwareinfo
|
||||||
mov [IOCTL.out_size], 0
|
mov [IOCTL.out_size], 0
|
||||||
mov [IOCTL.output], 0
|
mov [IOCTL.output], 0
|
||||||
|
|
||||||
mcall 68, 17, IOCTL
|
mcall 68, 17, IOCTL
|
||||||
|
|
||||||
.next:
|
.next:
|
||||||
cmp byte[param], 'A'
|
cmp byte[param], 'A'
|
||||||
je nextDev
|
je nextDev
|
||||||
jmp exit
|
jmp exit
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -303,161 +309,161 @@ load_and_start:
|
|||||||
;* Print device info to screen
|
;* Print device info to screen
|
||||||
Print_New_Device:
|
Print_New_Device:
|
||||||
|
|
||||||
push edx ; Magic ! (to print a button...)
|
push edx ; Magic ! (to print a button...)
|
||||||
|
|
||||||
mov ebx, 18 shl 16
|
mov ebx, 18 shl 16
|
||||||
mov bx , [Form]
|
mov bx , [Form]
|
||||||
sub bx , 36
|
sub bx , 36
|
||||||
|
|
||||||
mov cx , dx
|
mov cx , dx
|
||||||
dec cx
|
dec cx
|
||||||
shl ecx, 16
|
shl ecx, 16
|
||||||
add ecx, 9
|
add ecx, 9
|
||||||
|
|
||||||
movzx edx, byte [V_Bus]
|
movzx edx, byte [V_Bus]
|
||||||
shl dx , 8
|
shl dx , 8
|
||||||
mov dl , byte [V_Dev]
|
mov dl , byte [V_Dev]
|
||||||
|
|
||||||
mov esi, 0x0000c0ff ; color: yellow if selected, blue otherwise
|
mov esi, 0x0000c0ff ; color: yellow if selected, blue otherwise
|
||||||
cmp word [selected], dx
|
cmp word [selected], dx
|
||||||
jne @f
|
jne @f
|
||||||
mov esi, 0x00c0c000
|
mov esi, 0x00c0c000
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
shl edx, 8
|
shl edx, 8
|
||||||
or dl , 0xff
|
or dl , 0xff
|
||||||
|
|
||||||
mcall 8
|
mcall 8
|
||||||
pop edx
|
pop edx
|
||||||
|
|
||||||
xor esi, esi ; Color of text
|
xor esi, esi ; Color of text
|
||||||
movzx ecx, word [PCI_Vendor] ; number to be written
|
movzx ecx, word [PCI_Vendor] ; number to be written
|
||||||
mcall 47, 0x00040100 ; Write Vendor ID
|
mcall 47, 0x00040100 ; Write Vendor ID
|
||||||
|
|
||||||
add edx, (4*6+18) shl 16
|
add edx, (4*6+18) shl 16
|
||||||
movzx ecx, word [PCI_Device] ; get Vendor ID
|
movzx ecx, word [PCI_Device] ; get Vendor ID
|
||||||
mcall ; Draw Vendor ID to Window
|
mcall ; Draw Vendor ID to Window
|
||||||
|
|
||||||
add edx, (4*6+18) shl 16
|
add edx, (4*6+18) shl 16
|
||||||
movzx ecx, byte [V_Bus] ; get bus number
|
movzx ecx, byte [V_Bus] ; get bus number
|
||||||
mcall ,0x00020100 ; draw bus number to screen
|
mcall ,0x00020100 ; draw bus number to screen
|
||||||
|
|
||||||
add edx, (2*6+18) shl 16
|
add edx, (2*6+18) shl 16
|
||||||
movzx ecx, byte [V_Dev] ; get device number
|
movzx ecx, byte [V_Dev] ; get device number
|
||||||
shr ecx, 3 ; device number is bits 3-7
|
shr ecx, 3 ; device number is bits 3-7
|
||||||
mcall ; Draw device Number To Window
|
mcall ; Draw device Number To Window
|
||||||
|
|
||||||
add edx, (2*6+18) shl 16
|
add edx, (2*6+18) shl 16
|
||||||
movzx ecx, byte [PCI_Rev] ; get revision number
|
movzx ecx, byte [PCI_Rev] ; get revision number
|
||||||
mcall ; Draw Revision to screen
|
mcall ; Draw Revision to screen
|
||||||
|
|
||||||
add edx, (2*6+18) shl 16
|
add edx, (2*6+18) shl 16
|
||||||
movzx ecx, [PCI_IRQ]
|
movzx ecx, [PCI_IRQ]
|
||||||
cmp cl , 0x0f ; IRQ must be between 0 and 15
|
cmp cl , 0x0f ; IRQ must be between 0 and 15
|
||||||
ja @f
|
ja @f
|
||||||
mcall
|
mcall
|
||||||
@@:
|
@@:
|
||||||
;
|
;
|
||||||
;Write Names
|
;Write Names
|
||||||
movzx ebx, dx ; Set y position
|
movzx ebx, dx ; Set y position
|
||||||
or ebx, 230 shl 16 ; set Xposition
|
or ebx, 230 shl 16 ; set Xposition
|
||||||
|
|
||||||
;------------------------------------------------------------------
|
;------------------------------------------------------------------
|
||||||
; Prints the Vendor's Name based on Vendor ID
|
; Prints the Vendor's Name based on Vendor ID
|
||||||
;------------------------------------------------------------------
|
;------------------------------------------------------------------
|
||||||
mov edx, VendorsTab
|
mov edx, VendorsTab
|
||||||
mov cx , word[PCI_Vendor]
|
mov cx , word[PCI_Vendor]
|
||||||
|
|
||||||
.fn: mov ax , [edx]
|
.fn: mov ax , [edx]
|
||||||
add edx, 6
|
add edx, 6
|
||||||
test ax , ax
|
test ax , ax
|
||||||
jz .find
|
jz .find
|
||||||
cmp ax , cx
|
cmp ax , cx
|
||||||
jne .fn
|
jne .fn
|
||||||
.find: mov edx, [edx - 4]
|
.find: mov edx, [edx - 4]
|
||||||
mcall 4,, 0x80000000 ; lets print the vendor Name
|
mcall 4,, 0x80000000 ; lets print the vendor Name
|
||||||
|
|
||||||
;------------------------------------------------------------------
|
;------------------------------------------------------------------
|
||||||
; Get description based on Class/Subclass
|
; Get description based on Class/Subclass
|
||||||
;------------------------------------------------------------------
|
;------------------------------------------------------------------
|
||||||
mov eax, dword [PCI_Class]
|
mov eax, dword [PCI_Class]
|
||||||
and eax, 0xffffff
|
and eax, 0xffffff
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
xor esi, esi
|
xor esi, esi
|
||||||
.fnc: inc esi
|
.fnc: inc esi
|
||||||
mov ecx, [Classes + esi * 8 - 8]
|
mov ecx, [Classes + esi * 8 - 8]
|
||||||
cmp cx , 0xffff
|
cmp cx , 0xffff
|
||||||
je .endfc
|
je .endfc
|
||||||
cmp cx , ax
|
cmp cx , ax
|
||||||
jne .fnc
|
jne .fnc
|
||||||
test ecx, 0xff000000
|
test ecx, 0xff000000
|
||||||
jz @f
|
jz @f
|
||||||
mov edx, [Classes + esi * 8 - 4]
|
mov edx, [Classes + esi * 8 - 4]
|
||||||
jmp .fnc
|
jmp .fnc
|
||||||
@@: cmp eax, ecx
|
@@: cmp eax, ecx
|
||||||
jne .fnc
|
jne .fnc
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
.endfc: test edx, edx
|
.endfc: test edx, edx
|
||||||
jnz @f
|
jnz @f
|
||||||
mov edx, [Classes + esi * 8 - 4]
|
mov edx, [Classes + esi * 8 - 4]
|
||||||
@@:
|
@@:
|
||||||
add ebx, 288 shl 16
|
add ebx, 288 shl 16
|
||||||
mcall 4,, 0x80000000,, 32 ; draw the text
|
mcall 4,, 0x80000000,, 32 ; draw the text
|
||||||
movzx edx, bx ; get y coordinate
|
movzx edx, bx ; get y coordinate
|
||||||
add edx, 0x0014000A ; add 10 to y coordinate and set x coordinate to 20
|
add edx, 0x0014000A ; add 10 to y coordinate and set x coordinate to 20
|
||||||
|
|
||||||
;------------------------------------------------------------------
|
;------------------------------------------------------------------
|
||||||
; Print Driver Name
|
; Print Driver Name
|
||||||
;------------------------------------------------------------------
|
;------------------------------------------------------------------
|
||||||
push edx
|
push edx
|
||||||
add ebx, 120 shl 16
|
add ebx, 120 shl 16
|
||||||
push ebx
|
push ebx
|
||||||
|
|
||||||
call get_drv_ptr
|
call get_drv_ptr
|
||||||
mov edx, eax
|
mov edx, eax
|
||||||
pop ebx
|
pop ebx
|
||||||
mcall 4,,0x80000000 ; lets print the vendor Name
|
mcall 4,,0x80000000 ; lets print the vendor Name
|
||||||
pop edx
|
pop edx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
get_drv_ptr:
|
get_drv_ptr:
|
||||||
mov eax, driverlist ; eax will be the pointer to latest driver title
|
mov eax, driverlist ; eax will be the pointer to latest driver title
|
||||||
mov ebx, driverlist ; ebx is the current pointer
|
mov ebx, driverlist ; ebx is the current pointer
|
||||||
mov ecx, dword[PCI_Vendor] ; the device/vendor id of we want to find
|
mov ecx, dword[PCI_Vendor] ; the device/vendor id of we want to find
|
||||||
|
|
||||||
driverloop:
|
driverloop:
|
||||||
inc ebx
|
inc ebx
|
||||||
|
|
||||||
cmp byte[ebx],0
|
cmp byte[ebx],0
|
||||||
jne driverloop
|
jne driverloop
|
||||||
|
|
||||||
inc ebx ; the device/vendor id list for the driver eax is pointing to starts here.
|
inc ebx ; the device/vendor id list for the driver eax is pointing to starts here.
|
||||||
|
|
||||||
deviceloop:
|
deviceloop:
|
||||||
cmp dword[ebx],0
|
cmp dword[ebx],0
|
||||||
je nextdriver
|
je nextdriver
|
||||||
|
|
||||||
cmp dword[ebx],ecx
|
cmp dword[ebx],ecx
|
||||||
je driverfound
|
je driverfound
|
||||||
|
|
||||||
add ebx,4
|
add ebx,4
|
||||||
jmp deviceloop
|
jmp deviceloop
|
||||||
|
|
||||||
nextdriver:
|
nextdriver:
|
||||||
add ebx,4
|
add ebx,4
|
||||||
|
|
||||||
cmp dword[ebx],0
|
cmp dword[ebx],0
|
||||||
je nodriver
|
je nodriver
|
||||||
|
|
||||||
mov eax,ebx
|
mov eax,ebx
|
||||||
jmp driverloop
|
jmp driverloop
|
||||||
|
|
||||||
nodriver:
|
nodriver:
|
||||||
mov eax, lbl_none ; lets print the vendor Name
|
mov eax, lbl_none ; lets print the vendor Name
|
||||||
ret
|
ret
|
||||||
|
|
||||||
driverfound:
|
driverfound:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
include 'vendors.inc'
|
include 'vendors.inc'
|
||||||
include 'drivers.inc'
|
include 'drivers.inc'
|
||||||
@ -470,12 +476,12 @@ include 'drivers.inc'
|
|||||||
DATA
|
DATA
|
||||||
|
|
||||||
|
|
||||||
Form: dw 800 ; window width (no more, special for 800x600)
|
Form: dw 800 ; window width (no more, special for 800x600)
|
||||||
dw 100 ; window x start
|
dw 100 ; window x start
|
||||||
dw 220 ; window height
|
dw 220 ; window height
|
||||||
dw 100 ; window y start
|
dw 100 ; window y start
|
||||||
|
|
||||||
title db 'Network Driver Control Center', 0
|
title db 'Network Driver Control Center', 0
|
||||||
|
|
||||||
caption db 'Vendor Device Bus Dev Rev IRQ Company Description DRIVER',0
|
caption db 'Vendor Device Bus Dev Rev IRQ Company Description DRIVER',0
|
||||||
nonefound db 'No compatible devices were found!',0
|
nonefound db 'No compatible devices were found!',0
|
||||||
@ -487,12 +493,20 @@ load_error db 'Could not load driver!',0
|
|||||||
|
|
||||||
devicename db 'test'
|
devicename db 'test'
|
||||||
rb 64
|
rb 64
|
||||||
db 0
|
db 0
|
||||||
|
|
||||||
hardwareinfo:
|
hardwareinfo:
|
||||||
.type db 1 ; pci
|
.type db 1 ; pci
|
||||||
.pci_bus db ?
|
.pci_bus db ?
|
||||||
.pci_dev db ?
|
.pci_dev db ?
|
||||||
|
|
||||||
|
zeroconf:
|
||||||
|
dd 7 ; launch app
|
||||||
|
dd 0 ; no flags
|
||||||
|
dd 0 ; no parameters
|
||||||
|
dd 0 ; reserved
|
||||||
|
dd 0 ; reserved
|
||||||
|
db "/sys/network/zeroconf", 0
|
||||||
|
|
||||||
|
|
||||||
IM_END:
|
IM_END:
|
||||||
@ -502,37 +516,37 @@ IM_END:
|
|||||||
|
|
||||||
|
|
||||||
IOCTL:
|
IOCTL:
|
||||||
.handle dd ?
|
.handle dd ?
|
||||||
.io_code dd ?
|
.io_code dd ?
|
||||||
.input dd ?
|
.input dd ?
|
||||||
.inp_size dd ?
|
.inp_size dd ?
|
||||||
.output dd ?
|
.output dd ?
|
||||||
.out_size dd ?
|
.out_size dd ?
|
||||||
|
|
||||||
drivernumber db ?
|
drivernumber db ?
|
||||||
MAC dp ?
|
MAC dp ?
|
||||||
|
|
||||||
|
|
||||||
type db ?
|
type db ?
|
||||||
selected dw ?
|
selected dw ?
|
||||||
V_Bus db ?
|
V_Bus db ?
|
||||||
V_Dev db ?
|
V_Dev db ?
|
||||||
PCI_Version dw ?
|
PCI_Version dw ?
|
||||||
PCI_LastBus db ?
|
PCI_LastBus db ?
|
||||||
PCI_Vendor dw ?
|
PCI_Vendor dw ?
|
||||||
PCI_Device dw ?
|
PCI_Device dw ?
|
||||||
PCI_Bus db ?
|
PCI_Bus db ?
|
||||||
PCI_Dev db ?
|
PCI_Dev db ?
|
||||||
PCI_Rev db ?
|
PCI_Rev db ?
|
||||||
; don`t change order!!!
|
; don`t change order!!!
|
||||||
PCI_Class db ?
|
PCI_Class db ?
|
||||||
PCI_SubClass db ?
|
PCI_SubClass db ?
|
||||||
PCI_Interface db ?
|
PCI_Interface db ?
|
||||||
PCI_IRQ db ?
|
PCI_IRQ db ?
|
||||||
|
|
||||||
Proc_Info process_information
|
Proc_Info process_information
|
||||||
|
|
||||||
param rb 1024
|
param rb 1024
|
||||||
|
|
||||||
|
|
||||||
I_END:
|
I_END:
|
@ -1,28 +1,34 @@
|
|||||||
;
|
;
|
||||||
; Netstat for KolibriOS v0.1 (still alpha version)
|
; Netstat for KolibriOS v0.2
|
||||||
|
;
|
||||||
|
; 0.1 - 22 sept 2009 - initial release
|
||||||
|
; 0.2 - 9 july 2012 - converted to new sysfunc numbers
|
||||||
;
|
;
|
||||||
; hidnplayr@gmail.com
|
; hidnplayr@gmail.com
|
||||||
;
|
;
|
||||||
|
|
||||||
|
format binary as ""
|
||||||
|
|
||||||
use32
|
use32
|
||||||
|
|
||||||
org 0x0
|
org 0x0
|
||||||
|
|
||||||
db 'MENUET01' ; 8 byte id
|
db 'MENUET01' ; 8 byte id
|
||||||
dd 0x01 ; header version
|
dd 0x01 ; header version
|
||||||
dd START ; start of code
|
dd START ; start of code
|
||||||
dd I_END ; size of image
|
dd I_END ; size of image
|
||||||
dd (I_END+0x100) ; memory for app
|
dd (I_END+0x100) ; memory for app
|
||||||
dd (I_END+0x100) ; esp
|
dd (I_END+0x100) ; esp
|
||||||
dd I_PARAM , 0x0 ; I_Param , I_Icon
|
dd I_PARAM , 0x0 ; I_Param , I_Icon
|
||||||
|
|
||||||
__DEBUG__ equ 1
|
__DEBUG__ equ 1
|
||||||
__DEBUG_LEVEL__ equ 1
|
__DEBUG_LEVEL__ equ 1
|
||||||
|
|
||||||
include '..\macros.inc'
|
include '..\macros.inc'
|
||||||
include '..\debug-fdo.inc'
|
include '..\debug-fdo.inc'
|
||||||
|
include '..\network.inc'
|
||||||
|
|
||||||
START: ; start of execution
|
START: ; start of execution
|
||||||
; TODO: check Parameters
|
; TODO: check Parameters
|
||||||
|
|
||||||
DEBUGF 1, 'Netstat application loaded!\n'
|
DEBUGF 1, 'Netstat application loaded!\n'
|
||||||
@ -77,7 +83,7 @@ START: ; start of execution
|
|||||||
mov edx, str_queue_out
|
mov edx, str_queue_out
|
||||||
mcall
|
mcall
|
||||||
|
|
||||||
mov ebx,1337 shl 16 + 4
|
mov ebx, API_ETH + 4
|
||||||
mov bh, [device]
|
mov bh, [device]
|
||||||
mcall 76
|
mcall 76
|
||||||
push eax
|
push eax
|
||||||
@ -110,7 +116,7 @@ START: ; start of execution
|
|||||||
mcall
|
mcall
|
||||||
|
|
||||||
|
|
||||||
mov ebx, 0 shl 16 + 8
|
mov ebx, API_IPv4 + 8
|
||||||
mov bh, [device]
|
mov bh, [device]
|
||||||
mcall 76
|
mcall 76
|
||||||
push eax
|
push eax
|
||||||
@ -174,14 +180,14 @@ START: ; start of execution
|
|||||||
|
|
||||||
mainloop:
|
mainloop:
|
||||||
|
|
||||||
mcall 23,500 ; wait for event with timeout (0,5 s)
|
mcall 23,500 ; wait for event with timeout (0,5 s)
|
||||||
|
|
||||||
cmp eax, 1
|
cmp eax, 1
|
||||||
je redraw
|
je redraw
|
||||||
cmp eax, 2
|
cmp eax, 2
|
||||||
je key
|
je key
|
||||||
cmp eax, 3
|
cmp eax, 3
|
||||||
je button
|
je button
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -195,7 +201,7 @@ START: ; start of execution
|
|||||||
cmp [mode], 101
|
cmp [mode], 101
|
||||||
jne not_101
|
jne not_101
|
||||||
|
|
||||||
mov ebx, 1337 shl 16 + 0
|
mov ebx, API_ETH
|
||||||
mov bh, [device]
|
mov bh, [device]
|
||||||
@@:
|
@@:
|
||||||
push ebx
|
push ebx
|
||||||
@ -206,8 +212,8 @@ START: ; start of execution
|
|||||||
cmp bl, 3
|
cmp bl, 3
|
||||||
jle @r
|
jle @r
|
||||||
|
|
||||||
inc bl ;5
|
inc bl ;5
|
||||||
inc bl ;6
|
inc bl ;6
|
||||||
|
|
||||||
@@:
|
@@:
|
||||||
push ebx
|
push ebx
|
||||||
@ -249,7 +255,7 @@ START: ; start of execution
|
|||||||
cmp [mode], 102
|
cmp [mode], 102
|
||||||
jne not_102
|
jne not_102
|
||||||
|
|
||||||
mov ebx, 0 shl 16
|
mov ebx, API_IPv4
|
||||||
mov bh, [device]
|
mov bh, [device]
|
||||||
push ebx
|
push ebx
|
||||||
mcall 76
|
mcall 76
|
||||||
@ -281,7 +287,7 @@ START: ; start of execution
|
|||||||
cmp [mode], 103
|
cmp [mode], 103
|
||||||
jne not_103
|
jne not_103
|
||||||
|
|
||||||
mov ebx, 0x0608 shl 16 + 0
|
mov ebx, API_ARP
|
||||||
mov bh, [device]
|
mov bh, [device]
|
||||||
push ebx
|
push ebx
|
||||||
mcall 76
|
mcall 76
|
||||||
@ -320,7 +326,7 @@ not_103:
|
|||||||
cmp [mode], 104
|
cmp [mode], 104
|
||||||
jne not_104
|
jne not_104
|
||||||
|
|
||||||
mov ebx, 1 shl 16 + 0
|
mov ebx, API_ICMP
|
||||||
mov bh, [device]
|
mov bh, [device]
|
||||||
push ebx
|
push ebx
|
||||||
mcall 76
|
mcall 76
|
||||||
@ -351,7 +357,7 @@ not_104:
|
|||||||
cmp [mode], 105
|
cmp [mode], 105
|
||||||
jne not_105
|
jne not_105
|
||||||
|
|
||||||
mov ebx, 17 shl 16 + 0
|
mov ebx, API_UDP
|
||||||
mov bh, [device]
|
mov bh, [device]
|
||||||
push ebx
|
push ebx
|
||||||
mcall 76
|
mcall 76
|
||||||
@ -382,7 +388,7 @@ not_105:
|
|||||||
cmp [mode], 106
|
cmp [mode], 106
|
||||||
jne not_106
|
jne not_106
|
||||||
|
|
||||||
mov ebx, 6 shl 16 + 0
|
mov ebx, API_TCP
|
||||||
mov bh, [device]
|
mov bh, [device]
|
||||||
push ebx
|
push ebx
|
||||||
mcall 76
|
mcall 76
|
||||||
@ -417,102 +423,102 @@ not_106:
|
|||||||
jmp mainloop
|
jmp mainloop
|
||||||
|
|
||||||
|
|
||||||
button: ; button
|
button: ; button
|
||||||
mcall 17 ; get id
|
mcall 17 ; get id
|
||||||
cmp ah, 1
|
cmp ah, 1
|
||||||
je close
|
je exit
|
||||||
mov [mode], ah
|
mov [mode], ah
|
||||||
jmp redraw
|
jmp redraw
|
||||||
|
|
||||||
close:
|
exit:
|
||||||
mcall -1
|
mcall -1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
draw_mac:
|
draw_mac:
|
||||||
|
|
||||||
mov eax, 47
|
mov eax, 47
|
||||||
mov ebx, 0x00020100
|
mov ebx, 0x00020100
|
||||||
mov esi, 0x40000000
|
mov esi, 0x40000000
|
||||||
mov edi, 0x00bcbcbc
|
mov edi, 0x00bcbcbc
|
||||||
|
|
||||||
mov cl, [esp+4]
|
mov cl, [esp+4]
|
||||||
mcall
|
mcall
|
||||||
|
|
||||||
mov cl, [esp+4+1]
|
mov cl, [esp+4+1]
|
||||||
add edx, 15 shl 16
|
add edx, 15 shl 16
|
||||||
mcall
|
mcall
|
||||||
|
|
||||||
mov cl, [esp+4+2]
|
mov cl, [esp+4+2]
|
||||||
add edx, 15 shl 16
|
add edx, 15 shl 16
|
||||||
mcall
|
mcall
|
||||||
|
|
||||||
mov cl, [esp+4+3]
|
mov cl, [esp+4+3]
|
||||||
add edx, 15 shl 16
|
add edx, 15 shl 16
|
||||||
mcall
|
mcall
|
||||||
|
|
||||||
mov cl, [esp+4+4]
|
mov cl, [esp+4+4]
|
||||||
add edx, 15 shl 16
|
add edx, 15 shl 16
|
||||||
mcall
|
mcall
|
||||||
|
|
||||||
mov cl, [esp+4+5]
|
mov cl, [esp+4+5]
|
||||||
add edx, 15 shl 16
|
add edx, 15 shl 16
|
||||||
mcall
|
mcall
|
||||||
|
|
||||||
sub edx, 5*15 shl 16
|
sub edx, 5*15 shl 16
|
||||||
|
|
||||||
ret 6
|
ret 6
|
||||||
|
|
||||||
|
|
||||||
draw_ip:
|
draw_ip:
|
||||||
|
|
||||||
mov eax, 47
|
mov eax, 47
|
||||||
mov ebx, 0x00030000
|
mov ebx, 0x00030000
|
||||||
mov esi, 0x40000000
|
mov esi, 0x40000000
|
||||||
mov edi, 0x00bcbcbc
|
mov edi, 0x00bcbcbc
|
||||||
|
|
||||||
xor ecx, ecx
|
xor ecx, ecx
|
||||||
|
|
||||||
mov cl, [esp+4]
|
mov cl, [esp+4]
|
||||||
mcall
|
mcall
|
||||||
|
|
||||||
mov cl, [esp+4+1]
|
mov cl, [esp+4+1]
|
||||||
add edx, 30 shl 16
|
add edx, 30 shl 16
|
||||||
mcall
|
mcall
|
||||||
|
|
||||||
mov cl, [esp+4+2]
|
mov cl, [esp+4+2]
|
||||||
add edx, 30 shl 16
|
add edx, 30 shl 16
|
||||||
mcall
|
mcall
|
||||||
|
|
||||||
mov cl, [esp+4+3]
|
mov cl, [esp+4+3]
|
||||||
add edx, 30 shl 16
|
add edx, 30 shl 16
|
||||||
mcall
|
mcall
|
||||||
|
|
||||||
sub edx, 3*30 shl 16
|
sub edx, 3*30 shl 16
|
||||||
ret 4
|
ret 4
|
||||||
|
|
||||||
|
|
||||||
; DATA AREA
|
; DATA AREA
|
||||||
|
|
||||||
name db 'Netstat',0
|
name db 'Netstat', 0
|
||||||
mode db 101
|
mode db 101
|
||||||
device db 0
|
device db 0
|
||||||
modes db 'Ethernet IPv4 ARP ICMP UDP TCP',0
|
modes db 'Ethernet IPv4 ARP ICMP UDP TCP', 0
|
||||||
|
|
||||||
str_packets_tx db 'Packets sent:',0
|
str_packets_tx db 'Packets sent:', 0
|
||||||
str_packets_rx db 'Packets received:',0
|
str_packets_rx db 'Packets received:', 0
|
||||||
str_bytes_tx db 'Bytes sent:',0
|
str_bytes_tx db 'Bytes sent:', 0
|
||||||
str_bytes_rx db 'Bytes received:',0
|
str_bytes_rx db 'Bytes received:', 0
|
||||||
str_MAC db 'MAC address:',0
|
str_MAC db 'MAC address:', 0
|
||||||
str_queue_in db 'IN-queue size:',0
|
str_queue_in db 'IN-queue size:', 0
|
||||||
str_queue_out db 'OUT-queue size:',0
|
str_queue_out db 'OUT-queue size:', 0
|
||||||
str_ip db 'IP address:',0
|
str_ip db 'IP address:', 0
|
||||||
str_dns db 'DNS address:',0
|
str_dns db 'DNS address:', 0
|
||||||
str_subnet db 'Subnet mask:',0
|
str_subnet db 'Subnet mask:', 0
|
||||||
str_gateway db 'Standard gateway:',0
|
str_gateway db 'Standard gateway:', 0
|
||||||
str_arp db 'ARP entrys:',0
|
str_arp db 'ARP entrys:', 0
|
||||||
|
|
||||||
include_debug_strings ; ALWAYS present in data section
|
include_debug_strings ; ALWAYS present in data section
|
||||||
|
|
||||||
I_PARAM rb 1024
|
I_PARAM rb 1024
|
||||||
|
|
||||||
|
@ -1,72 +1,91 @@
|
|||||||
; Socket types
|
; Socket types
|
||||||
SOCK_STREAM = 1
|
SOCK_STREAM = 1
|
||||||
SOCK_DGRAM = 2
|
SOCK_DGRAM = 2
|
||||||
SOCK_RAW = 3 ; not supported by the kernel
|
SOCK_RAW = 3
|
||||||
|
|
||||||
; IP protocols
|
; IP protocols
|
||||||
IPPROTO_IP = 0
|
IPPROTO_IP = 0
|
||||||
IPPROTO_ICMP = 1 ; not supported by the kernel
|
IPPROTO_ICMP = 1
|
||||||
IPPROTO_TCP = 6
|
IPPROTO_TCP = 6
|
||||||
IPPROTO_UDP = 17
|
IPPROTO_UDP = 17
|
||||||
|
|
||||||
; Address families
|
; Address families
|
||||||
AF_UNSPEC = 0
|
AF_UNSPEC = 0
|
||||||
AF_UNIX = 1
|
AF_LOCAL = 1
|
||||||
AF_INET4 = 2 ; IPv4
|
AF_INET4 = 2 ; IPv4
|
||||||
;AF_INET6 = 28 ; IPv6 (not supported)
|
;AF_INET6 = 28 ; IPv6 (not supported yet)
|
||||||
|
|
||||||
PF_UNSPEC = AF_UNSPEC
|
PF_UNSPEC = AF_UNSPEC
|
||||||
PF_UNIX = AF_UNIX
|
PF_LOCAL = AF_LOCAL
|
||||||
PF_INET4 = AF_INET4
|
PF_INET4 = AF_INET4
|
||||||
;PF_INET6 = AF_INET6
|
;PF_INET6 = AF_INET6
|
||||||
|
|
||||||
; Flags for addrinfo
|
; Flags for addrinfo
|
||||||
AI_PASSIVE = 1
|
AI_PASSIVE = 1
|
||||||
AI_CANONNAME = 2
|
AI_CANONNAME = 2
|
||||||
AI_NUMERICHOST = 4
|
AI_NUMERICHOST = 4
|
||||||
AI_NUMERICSERV = 8
|
AI_NUMERICSERV = 8
|
||||||
AI_ADDRCONFIG = 0x400
|
AI_ADDRCONFIG = 0x400
|
||||||
|
|
||||||
; internal definition
|
; internal definition
|
||||||
AI_SUPPORTED = 0x40F
|
AI_SUPPORTED = 0x40F
|
||||||
|
|
||||||
|
; for system function 76
|
||||||
|
API_ETH = 0 shl 16
|
||||||
|
API_IPv4 = 1 shl 16
|
||||||
|
API_ICMP = 2 shl 16
|
||||||
|
API_UDP = 3 shl 16
|
||||||
|
API_TCP = 4 shl 16
|
||||||
|
API_ARP = 5 shl 16
|
||||||
|
API_PPPOE = 6 shl 16
|
||||||
|
|
||||||
struct sockaddr_in
|
struct sockaddr_in
|
||||||
sin_family dw ? ; sa_family_t
|
sin_family dw ? ; sa_family_t
|
||||||
sin_port dw ? ; in_port_t
|
sin_port dw ? ; in_port_t
|
||||||
sin_addr dd ? ; struct in_addr
|
sin_addr dd ? ; struct in_addr
|
||||||
sin_zero rb 8 ; zero
|
sin_zero rb 8 ; zero
|
||||||
ends
|
ends
|
||||||
|
|
||||||
struct addrinfo
|
struct addrinfo
|
||||||
ai_flags dd ? ; bitmask of AI_*
|
ai_flags dd ? ; bitmask of AI_*
|
||||||
ai_family dd ? ; PF_*
|
ai_family dd ? ; PF_*
|
||||||
ai_socktype dd ? ; SOCK_*
|
ai_socktype dd ? ; SOCK_*
|
||||||
ai_protocol dd ? ; 0 or IPPROTO_*
|
ai_protocol dd ? ; 0 or IPPROTO_*
|
||||||
ai_addrlen dd ? ; length of ai_addr
|
ai_addrlen dd ? ; length of ai_addr
|
||||||
ai_canonname dd ? ; char*
|
ai_canonname dd ? ; char*
|
||||||
ai_addr dd ? ; struct sockaddr*
|
ai_addr dd ? ; struct sockaddr*
|
||||||
ai_next dd ? ; struct addrinfo*
|
ai_next dd ? ; struct addrinfo*
|
||||||
ends
|
ends
|
||||||
|
|
||||||
EAI_ADDRFAMILY = 1
|
EAI_ADDRFAMILY = 1
|
||||||
EAI_AGAIN = 2
|
EAI_AGAIN = 2
|
||||||
EAI_BADFLAGS = 3
|
EAI_BADFLAGS = 3
|
||||||
EAI_FAIL = 4
|
EAI_FAIL = 4
|
||||||
EAI_FAMILY = 5
|
EAI_FAMILY = 5
|
||||||
EAI_MEMORY = 6
|
EAI_MEMORY = 6
|
||||||
EAI_NONAME = 8
|
EAI_NONAME = 8
|
||||||
EAI_SERVICE = 9
|
EAI_SERVICE = 9
|
||||||
EAI_SOCKTYPE = 10
|
EAI_SOCKTYPE = 10
|
||||||
EAI_BADHINTS = 12
|
EAI_BADHINTS = 12
|
||||||
EAI_PROTOCOL = 13
|
EAI_PROTOCOL = 13
|
||||||
EAI_OVERFLOW = 14
|
EAI_OVERFLOW = 14
|
||||||
|
|
||||||
socket fix 75, 0
|
socket fix 75, 0
|
||||||
close fix 75, 1
|
close fix 75, 1
|
||||||
bind fix 75, 2
|
bind fix 75, 2
|
||||||
listen fix 75, 3
|
listen fix 75, 3
|
||||||
connect fix 75, 4
|
connect fix 75, 4
|
||||||
accept fix 75, 5
|
accept fix 75, 5
|
||||||
send fix 75, 6
|
send fix 75, 6
|
||||||
recv fix 75, 7
|
recv fix 75, 7
|
||||||
|
setsockopt fix 75, 8
|
||||||
|
getsockopt fix 75, 9
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct ARP_entry
|
||||||
|
IP dd ?
|
||||||
|
MAC dp ?
|
||||||
|
status dw ?
|
||||||
|
TTL dw ?
|
||||||
|
ends
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
|
format binary as ""
|
||||||
|
|
||||||
use32
|
use32
|
||||||
; standard header
|
; standard header
|
||||||
db 'MENUET01' ; signature
|
db 'MENUET01' ; signature
|
||||||
dd 1 ; header version
|
dd 1 ; header version
|
||||||
dd start ; entry point
|
dd start ; entry point
|
||||||
dd i_end ; initialized size
|
dd i_end ; initialized size
|
||||||
dd mem ; required memory
|
dd mem ; required memory
|
||||||
dd mem ; stack pointer
|
dd mem ; stack pointer
|
||||||
dd 0 ; parameters
|
dd 0 ; parameters
|
||||||
dd 0 ; path
|
dd 0 ; path
|
||||||
|
|
||||||
; useful includes
|
; useful includes
|
||||||
include '../macros.inc'
|
include '../macros.inc'
|
||||||
@ -20,115 +22,115 @@ include '../network.inc'
|
|||||||
; entry point
|
; entry point
|
||||||
start:
|
start:
|
||||||
; load libraries
|
; load libraries
|
||||||
stdcall dll.Load, @IMPORT
|
stdcall dll.Load, @IMPORT
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jnz exit
|
jnz exit
|
||||||
; initialize console
|
; initialize console
|
||||||
push 1
|
push 1
|
||||||
call [con_start]
|
call [con_start]
|
||||||
push title
|
push title
|
||||||
push -1
|
push -1
|
||||||
push -1
|
push -1
|
||||||
push -1
|
push -1
|
||||||
push -1
|
push -1
|
||||||
call [con_init]
|
call [con_init]
|
||||||
; main loop
|
; main loop
|
||||||
main:
|
main:
|
||||||
; write prompt
|
; write prompt
|
||||||
push str1
|
push str1
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
; read string
|
; read string
|
||||||
mov esi, s
|
mov esi, s
|
||||||
push 256
|
push 256
|
||||||
push esi
|
push esi
|
||||||
call [con_gets]
|
call [con_gets]
|
||||||
; check for exit
|
; check for exit
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz done
|
jz done
|
||||||
cmp byte [esi], 10
|
cmp byte [esi], 10
|
||||||
jz done
|
jz done
|
||||||
; delete terminating '\n'
|
; delete terminating '\n'
|
||||||
push esi
|
push esi
|
||||||
@@:
|
@@:
|
||||||
lodsb
|
lodsb
|
||||||
test al, al
|
test al, al
|
||||||
jnz @b
|
jnz @b
|
||||||
mov byte [esi-2], al
|
mov byte [esi-2], al
|
||||||
pop esi
|
pop esi
|
||||||
; resolve name
|
; resolve name
|
||||||
push esp ; reserve stack place
|
push esp ; reserve stack place
|
||||||
push esp ; fourth parameter
|
push esp ; fourth parameter
|
||||||
push 0 ; third parameter
|
push 0 ; third parameter
|
||||||
push 0 ; second parameter
|
push 0 ; second parameter
|
||||||
push esi ; first parameter
|
push esi ; first parameter
|
||||||
call [getaddrinfo]
|
call [getaddrinfo]
|
||||||
pop esi
|
pop esi
|
||||||
; test for error
|
; test for error
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jnz fail
|
jnz fail
|
||||||
; write results
|
; write results
|
||||||
push str2
|
push str2
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
mov edi, esi
|
mov edi, esi
|
||||||
addrloop:
|
addrloop:
|
||||||
; before all subsequent addresses print comma
|
; before all subsequent addresses print comma
|
||||||
cmp edi, esi
|
cmp edi, esi
|
||||||
jz @f
|
jz @f
|
||||||
push str3
|
push str3
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
@@:
|
@@:
|
||||||
; convert IP address to decimal notation
|
; convert IP address to decimal notation
|
||||||
mov eax, [edi+addrinfo.ai_addr]
|
mov eax, [edi+addrinfo.ai_addr]
|
||||||
pushd [eax+sockaddr_in.sin_addr]
|
pushd [eax+sockaddr_in.sin_addr]
|
||||||
call [inet_ntoa]
|
call [inet_ntoa]
|
||||||
; write result
|
; write result
|
||||||
push eax
|
push eax
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
; advance to next item
|
; advance to next item
|
||||||
mov edi, [edi+addrinfo.ai_next]
|
mov edi, [edi+addrinfo.ai_next]
|
||||||
test edi, edi
|
test edi, edi
|
||||||
jnz addrloop
|
jnz addrloop
|
||||||
; free allocated memory
|
; free allocated memory
|
||||||
push esi
|
push esi
|
||||||
call [freeaddrinfo]
|
call [freeaddrinfo]
|
||||||
; write newline and continue main loop
|
; write newline and continue main loop
|
||||||
push str4
|
push str4
|
||||||
@@:
|
@@:
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
jmp main
|
jmp main
|
||||||
fail:
|
fail:
|
||||||
push str5
|
push str5
|
||||||
jmp @b
|
jmp @b
|
||||||
done:
|
done:
|
||||||
push 1
|
push 1
|
||||||
call [con_exit]
|
call [con_exit]
|
||||||
exit:
|
exit:
|
||||||
mcall -1
|
mcall -1
|
||||||
|
|
||||||
; data
|
; data
|
||||||
title db 'Names resolver',0
|
title db 'Names resolver',0
|
||||||
str1 db 'Host name to resolve: ',0
|
str1 db 'Host name to resolve: ',0
|
||||||
str2 db 'IP address(es): ',0
|
str2 db 'IP address(es): ',0
|
||||||
str3 db ', ',0
|
str3 db ', ',0
|
||||||
str4 db 10,0
|
str4 db 10,0
|
||||||
str5 db 'Name resolution failed.',10,0
|
str5 db 'Name resolution failed.',10,0
|
||||||
; import
|
; import
|
||||||
align 4
|
align 4
|
||||||
@IMPORT:
|
@IMPORT:
|
||||||
|
|
||||||
library network, 'network.obj', console, 'console.obj'
|
library network, 'network.obj', console, 'console.obj'
|
||||||
import network, \
|
import network, \
|
||||||
getaddrinfo, 'getaddrinfo', \
|
getaddrinfo, 'getaddrinfo', \
|
||||||
freeaddrinfo, 'freeaddrinfo', \
|
freeaddrinfo, 'freeaddrinfo', \
|
||||||
inet_ntoa, 'inet_ntoa'
|
inet_ntoa, 'inet_ntoa'
|
||||||
import console, \
|
import console, \
|
||||||
con_start, 'START', \
|
con_start, 'START', \
|
||||||
con_init, 'con_init', \
|
con_init, 'con_init', \
|
||||||
con_write_asciiz, 'con_write_asciiz', \
|
con_write_asciiz, 'con_write_asciiz', \
|
||||||
con_exit, 'con_exit', \
|
con_exit, 'con_exit', \
|
||||||
con_gets, 'con_gets'
|
con_gets, 'con_gets'
|
||||||
i_end:
|
i_end:
|
||||||
s rb 256
|
s rb 256
|
||||||
align 4
|
align 4
|
||||||
rb 4096 ; stack
|
rb 4096 ; stack
|
||||||
mem:
|
mem:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Copyright (C) KolibriOS team 2010. All rights reserved. ;;
|
;; Copyright (C) KolibriOS team 2010-2012. All rights reserved. ;;
|
||||||
;; Distributed under terms of the GNU General Public License ;;
|
;; Distributed under terms of the GNU General Public License ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Synergyc.asm - Synergy client for KolibriOS ;;
|
;; Synergyc.asm - Synergy client for KolibriOS ;;
|
||||||
@ -12,365 +12,373 @@
|
|||||||
;; ;;
|
;; ;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
format binary as ""
|
||||||
|
|
||||||
use32
|
use32
|
||||||
org 0x0
|
org 0x0
|
||||||
|
|
||||||
db 'MENUET01' ; signature
|
db 'MENUET01' ; signature
|
||||||
dd 1 ; header version
|
dd 1 ; header version
|
||||||
dd start ; entry point
|
dd start ; entry point
|
||||||
dd i_end ; initialized size
|
dd i_end ; initialized size
|
||||||
dd mem ; required memory
|
dd mem+0x1000 ; required memory
|
||||||
dd mem ; stack pointer
|
dd mem+0x1000 ; stack pointer
|
||||||
dd 0 ; parameters
|
dd 0 ; parameters
|
||||||
dd path ; path
|
dd path ; path
|
||||||
|
|
||||||
BUFFERSIZE equ 1024
|
__DEBUG__ equ 1 ; enable/disable
|
||||||
|
__DEBUG_LEVEL__ equ 1 ; 1 = all, 2 = errors
|
||||||
|
|
||||||
|
BUFFERSIZE equ 1024
|
||||||
|
|
||||||
include '../proc32.inc'
|
|
||||||
include '../macros.inc'
|
include '../macros.inc'
|
||||||
purge mov,add,sub
|
purge mov,add,sub
|
||||||
|
include '../debug-fdo.inc'
|
||||||
|
include '../proc32.inc'
|
||||||
include '../dll.inc'
|
include '../dll.inc'
|
||||||
|
|
||||||
include '../network.inc'
|
include '../network.inc'
|
||||||
|
|
||||||
start:
|
start:
|
||||||
|
|
||||||
cld
|
cld
|
||||||
mov edi, path ; Calculate the length of zero-terminated string
|
mov edi, path ; Calculate the length of zero-terminated string
|
||||||
xor al , al
|
xor al, al
|
||||||
mov ecx, 1024
|
mov ecx, 1024
|
||||||
repne scasb
|
repne scasb
|
||||||
dec edi
|
dec edi
|
||||||
mov esi, filename
|
mov esi, filename ; append the path with '.ini'
|
||||||
movsd
|
movsd
|
||||||
movsb
|
movsb
|
||||||
|
|
||||||
mcall 68, 11
|
mcall 68, 11
|
||||||
|
|
||||||
stdcall dll.Load, @IMPORT
|
stdcall dll.Load, @IMPORT
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jnz exit
|
jnz exit
|
||||||
|
|
||||||
push 1
|
push 1
|
||||||
call [con_start]
|
call [con_start]
|
||||||
|
|
||||||
push title
|
push title
|
||||||
push 25
|
push 25
|
||||||
push 80
|
push 80
|
||||||
push 25
|
push 25
|
||||||
push 80
|
push 80
|
||||||
call [con_init]
|
call [con_init]
|
||||||
|
|
||||||
push path
|
push path
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
|
|
||||||
push newline
|
push newline
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
|
|
||||||
push newline
|
push newline
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
|
|
||||||
invoke ini.get_str, path, str_remote, str_ip, buffer_ptr, 16, 0
|
invoke ini.get_str, path, str_remote, str_ip, buffer_ptr, 16, 0
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jnz error
|
jnz error
|
||||||
|
|
||||||
invoke ini.get_int, path, str_remote, str_port, 24800
|
invoke ini.get_int, path, str_remote, str_port, 24800
|
||||||
mov [sockaddr1.port], ax
|
mov [sockaddr1.port], ax
|
||||||
|
|
||||||
push str1
|
push str1
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
|
|
||||||
push buffer_ptr
|
push buffer_ptr
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
|
|
||||||
push newline
|
push newline
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
|
|
||||||
mcall socket, AF_INET4, SOCK_STREAM, 0
|
mcall socket, AF_INET4, SOCK_STREAM, 0
|
||||||
cmp eax, -1
|
cmp eax, -1
|
||||||
je error
|
je error
|
||||||
|
|
||||||
mov [socketnum], eax
|
mov [socketnum], eax
|
||||||
|
|
||||||
push buffer_ptr ; hostname
|
push buffer_ptr ; hostname
|
||||||
call [inet_addr]
|
call [inet_addr]
|
||||||
cmp eax, -1
|
cmp eax, -1
|
||||||
je error
|
je error
|
||||||
mov [sockaddr1.ip], eax
|
mov [sockaddr1.ip], eax
|
||||||
|
|
||||||
mcall connect, [socketnum], sockaddr1, 18
|
mcall connect, [socketnum], sockaddr1, 18
|
||||||
|
|
||||||
push str7
|
push str7
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
|
|
||||||
mcall 40, 1 shl 7; + 7
|
mcall 40, 1 shl 7; + 7
|
||||||
|
|
||||||
login:
|
login:
|
||||||
call wait_for_data
|
call wait_for_data
|
||||||
|
|
||||||
push buffer_ptr + 4
|
push buffer_ptr + 4
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
|
|
||||||
cmp dword [buffer_ptr], 11 shl 24
|
cmp dword [buffer_ptr], 11 shl 24
|
||||||
jne login
|
jne login
|
||||||
cmp dword [buffer_ptr + 4], 'Syne'
|
cmp dword [buffer_ptr + 4], 'Syne'
|
||||||
jne login
|
jne login
|
||||||
cmp word [buffer_ptr + 8], 'rg'
|
cmp word [buffer_ptr + 8], 'rg'
|
||||||
jne login
|
jne login
|
||||||
cmp byte [buffer_ptr + 10], 'y'
|
cmp byte [buffer_ptr + 10], 'y'
|
||||||
jne login
|
jne login
|
||||||
|
|
||||||
push str2
|
push str2
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
|
|
||||||
lea edi, [buffer_ptr + 11 + 4 + 4]
|
lea edi, [buffer_ptr + 11 + 4 + 4]
|
||||||
invoke ini.get_str, path, str_local, str_name, edi, 255, 0
|
invoke ini.get_str, path, str_local, str_name, edi, 255, 0
|
||||||
xor al , al
|
xor al , al
|
||||||
mov ecx, 256
|
mov ecx, 256
|
||||||
repne scasb
|
repne scasb
|
||||||
sub edi, buffer_ptr + 1 + 4
|
sub edi, buffer_ptr + 1 + 4
|
||||||
mov esi, edi
|
mov esi, edi
|
||||||
bswap edi
|
bswap edi
|
||||||
mov dword [buffer_ptr], edi
|
mov dword [buffer_ptr], edi
|
||||||
mov edi, esi
|
mov edi, esi
|
||||||
sub edi, 11 + 4
|
sub edi, 11 + 4
|
||||||
bswap edi
|
bswap edi
|
||||||
mov dword [buffer_ptr + 11 + 4], edi
|
mov dword [buffer_ptr + 11 + 4], edi
|
||||||
add esi, 4
|
add esi, 4
|
||||||
|
|
||||||
mcall send, [socketnum], buffer_ptr, , 0
|
mcall send, [socketnum], buffer_ptr, , 0
|
||||||
|
|
||||||
mainloop:
|
mainloop:
|
||||||
call wait_for_data
|
call wait_for_data
|
||||||
mov edi, buffer_ptr
|
mov edi, buffer_ptr
|
||||||
|
|
||||||
.command:
|
.command:
|
||||||
push eax edi
|
push eax edi
|
||||||
|
|
||||||
cmp dword [edi + 4], 'QINF' ; query screen info
|
cmp dword [edi + 4], 'QINF' ; query screen info
|
||||||
je .qinf
|
je .qinf
|
||||||
|
|
||||||
cmp dword [edi + 4], 'CALV' ; alive ?
|
cmp dword [edi + 4], 'CALV' ; alive ?
|
||||||
je .calv
|
je .calv
|
||||||
|
|
||||||
cmp dword [edi + 4], 'CINN' ; mouse moved into screen
|
cmp dword [edi + 4], 'CINN' ; mouse moved into screen
|
||||||
je .cinn
|
je .cinn
|
||||||
|
|
||||||
cmp dword [edi + 4], 'DCLP' ; Clipboard event
|
cmp dword [edi + 4], 'DCLP' ; Clipboard event
|
||||||
je .dclp
|
je .dclp
|
||||||
|
|
||||||
cmp dword [edi + 4], 'DMMV' ; Mouse moved
|
cmp dword [edi + 4], 'DMMV' ; Mouse moved
|
||||||
je .dmmv
|
je .dmmv
|
||||||
|
|
||||||
cmp dword [edi + 4], 'COUT' ; leave screen
|
cmp dword [edi + 4], 'COUT' ; leave screen
|
||||||
je .cout
|
je .cout
|
||||||
|
|
||||||
cmp dword [edi + 4], 'DMDN' ; mouse button down
|
cmp dword [edi + 4], 'DMDN' ; mouse button down
|
||||||
je .dmdn
|
je .dmdn
|
||||||
|
|
||||||
cmp dword [edi + 4], 'DMUP' ; mouse button released
|
cmp dword [edi + 4], 'DMUP' ; mouse button released
|
||||||
je .dmup
|
je .dmup
|
||||||
|
|
||||||
cmp dword [edi + 4], 'CNOP' ; no operation
|
cmp dword [edi + 4], 'CNOP' ; no operation
|
||||||
je .next
|
je .next
|
||||||
|
|
||||||
cmp dword [edi + 4], 'CIAK' ; resolution changed?
|
cmp dword [edi + 4], 'CIAK' ; resolution changed?
|
||||||
je .ciak
|
je .ciak
|
||||||
|
|
||||||
push str3
|
push str3
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
|
|
||||||
mov byte[edi+8],0
|
mov byte[edi+8],0
|
||||||
add edi, 4
|
add edi, 4
|
||||||
push edi
|
push edi
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
|
|
||||||
push newline
|
push newline
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
|
|
||||||
.next:
|
.next:
|
||||||
pop edi eax
|
pop edi eax
|
||||||
|
|
||||||
mov ecx, dword [edi]
|
mov ecx, dword [edi]
|
||||||
bswap ecx
|
bswap ecx
|
||||||
add ecx, 4
|
add ecx, 4
|
||||||
sub eax, ecx
|
sub eax, ecx
|
||||||
jle mainloop
|
jle mainloop
|
||||||
add edi, ecx
|
add edi, ecx
|
||||||
jmp .command
|
jmp .command
|
||||||
|
|
||||||
|
|
||||||
.qinf:
|
.qinf:
|
||||||
mcall 14 ; get screen info
|
mcall 14 ; get screen info
|
||||||
add eax, 0x00010001
|
add eax, 0x00010001
|
||||||
bswap eax
|
bswap eax
|
||||||
mov dword [screeninfo.size], eax
|
mov dword [screeninfo.size], eax
|
||||||
mcall send, [socketnum], screeninfo, screeninfo.length, 0 ; send client name
|
mcall send, [socketnum], screeninfo, screeninfo.length, 0 ; send client name
|
||||||
jmp .next
|
jmp .next
|
||||||
|
|
||||||
|
|
||||||
.calv:
|
.calv:
|
||||||
mcall send, [socketnum], calv, calv.length, 0 ; looks like ping-pong event
|
mcall send, [socketnum], calv, calv.length, 0 ; looks like ping-pong event
|
||||||
jmp .next
|
jmp .next
|
||||||
|
|
||||||
|
|
||||||
.cinn:
|
.cinn:
|
||||||
mov edx, [edi + 8]
|
mov edx, [edi + 8]
|
||||||
bswap edx
|
bswap edx
|
||||||
mcall 18, 19, 4
|
mcall 18, 19, 4
|
||||||
; ignore sequence number and modify key mask for now
|
; ignore sequence number and modify key mask for now
|
||||||
push str6
|
push str6
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
jmp .next
|
jmp .next
|
||||||
|
|
||||||
.dclp:
|
.dclp:
|
||||||
|
|
||||||
jmp .next
|
jmp .next
|
||||||
|
|
||||||
.dmmv:
|
.dmmv:
|
||||||
mov edx, [edi + 8]
|
mov edx, [edi + 8]
|
||||||
bswap edx
|
bswap edx
|
||||||
mcall 18, 19, 4
|
mcall 18, 19, 4
|
||||||
mcall send, [socketnum], cnop, cnop.length, 0 ; reply with NOP
|
mcall send, [socketnum], cnop, cnop.length, 0 ; reply with NOP
|
||||||
push str4
|
push str4
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
jmp .next
|
jmp .next
|
||||||
|
|
||||||
.cout:
|
.cout:
|
||||||
jmp .next
|
jmp .next
|
||||||
|
|
||||||
.dmdn:
|
.dmdn:
|
||||||
movzx eax, byte [edi + 8]
|
movzx eax, byte [edi + 8]
|
||||||
or [mousestate], eax
|
or [mousestate], eax
|
||||||
mcall 18, 19, 5, [mousestate]
|
mcall 18, 19, 5, [mousestate]
|
||||||
mcall send, [socketnum], cnop, cnop.length, 0 ; reply with NOP
|
mcall send, [socketnum], cnop, cnop.length, 0 ; reply with NOP
|
||||||
push str5
|
push str5
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
jmp .next
|
jmp .next
|
||||||
|
|
||||||
.dmup:
|
.dmup:
|
||||||
movzx eax, byte [edi + 8]
|
movzx eax, byte [edi + 8]
|
||||||
not eax
|
not eax
|
||||||
and [mousestate], eax
|
and [mousestate], eax
|
||||||
mcall 18, 19, 5, [mousestate]
|
mcall 18, 19, 5, [mousestate]
|
||||||
mcall send, [socketnum], cnop, cnop.length, 0 ; reply with NOP
|
mcall send, [socketnum], cnop, cnop.length, 0 ; reply with NOP
|
||||||
push str5
|
push str5
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
jmp .next
|
jmp .next
|
||||||
|
|
||||||
.ciak:
|
.ciak:
|
||||||
jmp .next
|
jmp .next
|
||||||
|
|
||||||
error:
|
error:
|
||||||
push str_err
|
push str_err
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
|
|
||||||
call [con_gets]
|
call [con_gets]
|
||||||
|
|
||||||
push 1
|
push 1
|
||||||
call [con_exit]
|
call [con_exit]
|
||||||
|
|
||||||
mcall close, [socketnum]
|
mcall close, [socketnum]
|
||||||
exit:
|
exit:
|
||||||
|
|
||||||
mcall -1
|
mcall -1
|
||||||
|
|
||||||
|
|
||||||
wait_for_data:
|
wait_for_data:
|
||||||
mcall 10 ; wait for data
|
mcall 10 ; wait for data
|
||||||
|
|
||||||
mcall recv, [socketnum], buffer_ptr, BUFFERSIZE, 0
|
mcall recv, [socketnum], buffer_ptr, BUFFERSIZE, 0
|
||||||
cmp eax, -1
|
cmp eax, -1
|
||||||
je wait_for_data
|
je wait_for_data
|
||||||
|
|
||||||
cmp eax, 8
|
cmp eax, 8
|
||||||
jl wait_for_data
|
jl wait_for_data
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; data
|
; data
|
||||||
title db 'Synergy client',0
|
title db 'Synergy client',0
|
||||||
str1 db 'Connecting to: ',0
|
str1 db 'Connecting to: ',0
|
||||||
str7 db 'Connected!',13,10,0
|
str7 db 'Connected!',13,10,0
|
||||||
str2 db 13,10,'Handshake received',13,10,0
|
str2 db 13,10,'Handshake received',13,10,0
|
||||||
str3 db 'Unsupported command: ',0
|
str3 db 'Unsupported command: ',0
|
||||||
newline db 13,10,0
|
newline db 13,10,0
|
||||||
str4 db 'mouse moved',13,10,0
|
str4 db 'mouse moved',13,10,0
|
||||||
str5 db 'mouse buttons changed',13,10,0
|
str5 db 'mouse buttons changed',13,10,0
|
||||||
str6 db 'Enter screen',13,10,0
|
str6 db 'Enter screen',13,10,0
|
||||||
str_err db 'Error occured !',13,10,'Press any key to quit',0
|
str_err db 'Error occured !',13,10,'Press any key to quit',0
|
||||||
|
|
||||||
screeninfo:
|
screeninfo:
|
||||||
dd (screeninfo.length - 4) shl 24
|
dd (screeninfo.length - 4) shl 24
|
||||||
db 'DINF'
|
db 'DINF'
|
||||||
dw 0 ; coordinate of leftmost pixel
|
dw 0 ; coordinate of leftmost pixel
|
||||||
dw 0 ; coordiante of topmost pixel
|
dw 0 ; coordiante of topmost pixel
|
||||||
.size:
|
.size:
|
||||||
dw 0 ; width
|
dw 0 ; width
|
||||||
dw 0 ; height
|
dw 0 ; height
|
||||||
|
|
||||||
dw 0 ; size of warp zone
|
dw 0 ; size of warp zone
|
||||||
|
|
||||||
dw 0xb88b ; x position of the mouse on the secondary screen (no idea what it means)
|
dw 0xb88b ; x position of the mouse on the secondary screen (no idea what it means)
|
||||||
dw 0xbcfb ; y position of the mouse on the secondary screen
|
dw 0xbcfb ; y position of the mouse on the secondary screen
|
||||||
.length = $ - screeninfo
|
.length = $ - screeninfo
|
||||||
|
|
||||||
calv:
|
calv:
|
||||||
dd (4) shl 24
|
dd (4) shl 24
|
||||||
db 'CALV'
|
db 'CALV'
|
||||||
.length = $ - calv + 8 ; also send cnop
|
.length = $ - calv + 8 ; also send cnop
|
||||||
|
|
||||||
cnop:
|
cnop:
|
||||||
dd (4) shl 24
|
dd (4) shl 24
|
||||||
db 'CNOP'
|
db 'CNOP'
|
||||||
.length = $ - cnop
|
.length = $ - cnop
|
||||||
|
|
||||||
mousestate dd 0
|
mousestate dd 0
|
||||||
|
|
||||||
|
|
||||||
sockaddr1:
|
sockaddr1:
|
||||||
dw AF_INET4
|
dw AF_INET4
|
||||||
.port dw 24800
|
.port dw 24800
|
||||||
.ip dd 192 + 168 shl 8 + 1 shl 16 + 115 shl 24
|
.ip dd 192 + 168 shl 8 + 1 shl 16 + 115 shl 24
|
||||||
rb 10
|
rb 10
|
||||||
|
|
||||||
filename db '.ini', 0
|
filename db '.ini', 0
|
||||||
str_local db 'local', 0
|
str_local db 'local', 0
|
||||||
str_name db 'name', 0
|
str_name db 'name', 0
|
||||||
str_remote db 'remote', 0
|
str_remote db 'remote', 0
|
||||||
str_port db 'port', 0
|
str_port db 'port', 0
|
||||||
str_ip db 'ip', 0
|
str_ip db 'ip', 0
|
||||||
|
|
||||||
; import
|
; import
|
||||||
align 16
|
align 16
|
||||||
@IMPORT:
|
@IMPORT:
|
||||||
|
|
||||||
library console, 'console.obj',\
|
library console, 'console.obj',\
|
||||||
libini, 'libini.obj',\
|
network, 'network.obj',\
|
||||||
network, 'network.obj'
|
libini, 'libini.obj'
|
||||||
|
|
||||||
import network,\
|
import network,\
|
||||||
inet_addr, 'inet_addr'
|
inet_addr, 'inet_addr'
|
||||||
|
|
||||||
import console, \
|
import console, \
|
||||||
con_start, 'START',\
|
con_start, 'START',\
|
||||||
con_init, 'con_init',\
|
con_init, 'con_init',\
|
||||||
con_write_asciiz, 'con_write_asciiz',\
|
con_write_asciiz, 'con_write_asciiz',\
|
||||||
con_exit, 'con_exit',\
|
con_exit, 'con_exit',\
|
||||||
con_gets, 'con_gets',\
|
con_gets, 'con_gets',\
|
||||||
con_cls, 'con_cls',\
|
con_cls, 'con_cls',\
|
||||||
con_getch2, 'con_getch2',\
|
con_getch2, 'con_getch2',\
|
||||||
con_set_cursor_pos, 'con_set_cursor_pos'
|
con_set_cursor_pos, 'con_set_cursor_pos'
|
||||||
|
|
||||||
import libini,\
|
import libini,\
|
||||||
ini.get_str, 'ini_get_str',\
|
ini.get_str, 'ini_get_str',\
|
||||||
ini.get_int, 'ini_get_int'
|
ini.get_int, 'ini_get_int'
|
||||||
|
|
||||||
align 4
|
include_debug_strings
|
||||||
|
|
||||||
|
align 4
|
||||||
i_end:
|
i_end:
|
||||||
socketnum dd ?
|
socketnum dd ?
|
||||||
buffer_ptr rb BUFFERSIZE
|
buffer_ptr rb BUFFERSIZE
|
||||||
path rb 4096 ; stack
|
path rb 4096 ; stack
|
||||||
mem:
|
mem:
|
@ -1,3 +1,5 @@
|
|||||||
|
format binary as ""
|
||||||
|
|
||||||
use32
|
use32
|
||||||
; standard header
|
; standard header
|
||||||
db 'MENUET01' ; signature
|
db 'MENUET01' ; signature
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
format binary as ""
|
||||||
|
|
||||||
use32
|
use32
|
||||||
; standard header
|
; standard header
|
||||||
db 'MENUET01' ; signature
|
db 'MENUET01' ; signature
|
||||||
|
Loading…
Reference in New Issue
Block a user