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:
hidnplayr 2012-07-09 12:45:04 +00:00
parent fd138cc362
commit 08c92f8c50
9 changed files with 1180 additions and 1141 deletions

View File

@ -4,169 +4,152 @@
; hidnplayr@gmail.com
;
format binary as ""
use32
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd IM_END ; size of image
dd (I_END+0x100) ; memory for app
dd (I_END+0x100) ; esp
dd I_PARAM , 0x0 ; I_Param , I_Icon
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd IM_END ; size of image
dd (I_END+0x100) ; memory for app
dd (I_END+0x100) ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
__DEBUG__ equ 1
__DEBUG_LEVEL__ equ 1
include '../macros.inc'
purge mov, add, sub
include '../struct.inc'
include '../network.inc'
include '..\macros.inc'
include '..\debug-fdo.inc'
START:
START: ; start of execution
; TODO: check Parameters
redraw:
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 [last],0
mov cl, byte[arp_buf.IP+1]
add edx, 24 shl 16
mcall
.loop:
mcall 76, 0x06080003, [last],,,ARP_ENTRY
cmp eax, -1
je mainloop
mov cl, byte[arp_buf.IP+2]
add edx, 24 shl 16
mcall
mov cl, byte[arp_buf.IP+3]
add edx, 24 shl 16
mcall
mcall 4, edx, 0x80000000, str_entry
mov edx, ebx
mov ebx, 0x00020100
mov cl, byte[arp_buf.MAC+0]
add edx, 36 shl 16
mcall
mov eax, 47
mov ebx, 0x00030000
mov esi, 0x40000000
mov edi, 0x00bcbcbc
xor ecx, ecx
mov cl, byte[arp_buf.MAC+1]
add edx, 18 shl 16
mcall
mov cl, byte[ARP_ENTRY.IP+0]
mcall
mov cl, byte[arp_buf.MAC+2]
add edx, 18 shl 16
mcall
mov cl, byte[ARP_ENTRY.IP+1]
add edx, 24 shl 16
mcall
mov cl, byte[arp_buf.MAC+3]
add edx, 18 shl 16
mcall
mov cl, byte[ARP_ENTRY.IP+2]
add edx, 24 shl 16
mcall
mov cl, byte[arp_buf.MAC+4]
add edx, 18 shl 16
mcall
mov cl, byte[ARP_ENTRY.IP+3]
add edx, 24 shl 16
mcall
mov cl, byte[arp_buf.MAC+5]
add edx, 18 shl 16
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
mov cl, byte[ARP_ENTRY.MAC+0]
add edx, 36 shl 16
mcall
mainloop:
mov cl, byte[ARP_ENTRY.MAC+1]
add edx, 18 shl 16
mcall
mcall 23,50 ; wait for event with timeout (0,5 s)
mov cl, byte[ARP_ENTRY.MAC+2]
add edx, 18 shl 16
mcall
cmp eax, 1
je redraw
cmp eax, 2
je key
cmp eax, 3
je button
mov cl, byte[ARP_ENTRY.MAC+3]
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
jmp draw_stats
key:
mcall 2
jmp mainloop
key:
mcall 2
jmp mainloop
button: ; button
mcall 17 ; get id
cmp ah, 1
je close
jmp redraw
button: ; button
mcall 17 ; get id
cmp ah, 1
je exit
jmp redraw
close:
mcall -1
exit:
mcall -1
; DATA AREA
name db 'ARP manager',0
title db '# IP-address MAC-address Status TTL',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
str_name db 'ARP manager', 0
str_legend db '# IP-address MAC-address Status TTL', 0
str_entry db ' . . . - - - - - s', 0
IM_END:
I_PARAM rb 1024
last dd ?
arp_buf ARP_entry
I_END:

View File

@ -1,17 +1,20 @@
format binary as ""
use32
org 0x0
org 0x0
; standard header
db 'MENUET01' ; signature
dd 1 ; header version
dd start ; entry point
dd I_END ; initialized size
dd mem ; required memory
dd mem ; stack pointer
dd 0 ; parameters
dd 0 ; path
db 'MENUET01' ; signature
dd 1 ; header version
dd start ; entry point
dd I_END ; initialized size
dd mem ; required memory
dd mem ; stack pointer
dd 0 ; parameters
dd 0 ; path
BUFFERSIZE equ 1500
BUFFERSIZE equ 1500
; useful includes
include '../macros.inc'
purge mov,add,sub
@ -24,258 +27,258 @@ include '../network.inc'
; ICMP types & codes
ICMP_ECHOREPLY equ 0 ; echo reply message
ICMP_ECHOREPLY equ 0 ; echo reply message
ICMP_UNREACH equ 3
ICMP_UNREACH_NET equ 0 ; bad net
ICMP_UNREACH_HOST equ 1 ; bad host
ICMP_UNREACH_PROTOCOL equ 2 ; bad protocol
ICMP_UNREACH_PORT equ 3 ; bad port
ICMP_UNREACH_NEEDFRAG equ 4 ; IP_DF caused drop
ICMP_UNREACH_SRCFAIL equ 5 ; src route failed
ICMP_UNREACH_NET_UNKNOWN equ 6 ; unknown net
ICMP_UNREACH_HOST_UNKNOWN equ 7 ; unknown host
ICMP_UNREACH_ISOLATED equ 8 ; src host isolated
ICMP_UNREACH_NET_PROHIB equ 9 ; prohibited access
ICMP_UNREACH_HOST_PROHIB equ 10 ; ditto
ICMP_UNREACH_TOSNET equ 11 ; bad tos for net
ICMP_UNREACH_TOSHOST equ 12 ; bad tos for host
ICMP_UNREACH_FILTER_PROHIB equ 13 ; admin prohib
ICMP_UNREACH_HOST_PRECEDENCE equ 14 ; host prec vio.
ICMP_UNREACH_PRECEDENCE_CUTOFF equ 15 ; prec cutoff
ICMP_UNREACH equ 3
ICMP_UNREACH_NET equ 0 ; bad net
ICMP_UNREACH_HOST equ 1 ; bad host
ICMP_UNREACH_PROTOCOL equ 2 ; bad protocol
ICMP_UNREACH_PORT equ 3 ; bad port
ICMP_UNREACH_NEEDFRAG equ 4 ; IP_DF caused drop
ICMP_UNREACH_SRCFAIL equ 5 ; src route failed
ICMP_UNREACH_NET_UNKNOWN equ 6 ; unknown net
ICMP_UNREACH_HOST_UNKNOWN equ 7 ; unknown host
ICMP_UNREACH_ISOLATED equ 8 ; src host isolated
ICMP_UNREACH_NET_PROHIB equ 9 ; prohibited access
ICMP_UNREACH_HOST_PROHIB equ 10 ; ditto
ICMP_UNREACH_TOSNET equ 11 ; bad tos for net
ICMP_UNREACH_TOSHOST equ 12 ; bad tos for host
ICMP_UNREACH_FILTER_PROHIB equ 13 ; admin prohib
ICMP_UNREACH_HOST_PRECEDENCE equ 14 ; host prec vio.
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_NET equ 0 ; for network
ICMP_REDIRECT_HOST equ 1 ; for host
ICMP_REDIRECT_TOSNET equ 2 ; for tos and net
ICMP_REDIRECT_TOSHOST equ 3 ; for tos and host
ICMP_REDIRECT equ 5 ; shorter route, codes:
ICMP_REDIRECT_NET equ 0 ; for network
ICMP_REDIRECT_HOST equ 1 ; for host
ICMP_REDIRECT_TOSNET equ 2 ; for tos and net
ICMP_REDIRECT_TOSHOST equ 3 ; for tos and host
ICMP_ALTHOSTADDR equ 6 ; alternate host address
ICMP_ECHO equ 8 ; echo service
ICMP_ROUTERADVERT equ 9 ; router advertisement
ICMP_ROUTERADVERT_NORMAL equ 0 ; normal advertisement
ICMP_ROUTERADVERT_NOROUTE_COMMON equ 16 ; selective routing
ICMP_ALTHOSTADDR equ 6 ; alternate host address
ICMP_ECHO equ 8 ; echo service
ICMP_ROUTERADVERT equ 9 ; router advertisement
ICMP_ROUTERADVERT_NORMAL equ 0 ; normal advertisement
ICMP_ROUTERADVERT_NOROUTE_COMMON equ 16 ; selective routing
ICMP_ROUTERSOLICIT equ 10 ; router solicitation
ICMP_TIMXCEED equ 11 ; time exceeded, code:
ICMP_TIMXCEED_INTRANS equ 0 ; ttl==0 in transit
ICMP_TIMXCEED_REASS equ 1 ; ttl==0 in reass
ICMP_ROUTERSOLICIT equ 10 ; router solicitation
ICMP_TIMXCEED equ 11 ; time exceeded, code:
ICMP_TIMXCEED_INTRANS equ 0 ; ttl==0 in transit
ICMP_TIMXCEED_REASS equ 1 ; ttl==0 in reass
ICMP_PARAMPROB equ 12 ; ip header bad
ICMP_PARAMPROB_ERRATPTR equ 0 ; error at param ptr
ICMP_PARAMPROB_OPTABSENT equ 1 ; req. opt. absent
ICMP_PARAMPROB_LENGTH equ 2 ; bad length
ICMP_PARAMPROB equ 12 ; ip header bad
ICMP_PARAMPROB_ERRATPTR equ 0 ; error at param ptr
ICMP_PARAMPROB_OPTABSENT equ 1 ; req. opt. absent
ICMP_PARAMPROB_LENGTH equ 2 ; bad length
ICMP_TSTAMP equ 13 ; timestamp request
ICMP_TSTAMPREPLY equ 14 ; timestamp reply
ICMP_IREQ equ 15 ; information request
ICMP_IREQREPLY equ 16 ; information reply
ICMP_MASKREQ equ 17 ; address mask request
ICMP_MASKREPLY equ 18 ; address mask reply
ICMP_TRACEROUTE equ 30 ; traceroute
ICMP_DATACONVERR equ 31 ; data conversion error
ICMP_MOBILE_REDIRECT equ 32 ; mobile host redirect
ICMP_IPV6_WHEREAREYOU equ 33 ; IPv6 where-are-you
ICMP_IPV6_IAMHERE equ 34 ; IPv6 i-am-here
ICMP_MOBILE_REGREQUEST equ 35 ; mobile registration req
ICMP_MOBILE_REGREPLY equ 36 ; mobile registreation reply
ICMP_SKIP equ 39 ; SKIP
ICMP_TSTAMP equ 13 ; timestamp request
ICMP_TSTAMPREPLY equ 14 ; timestamp reply
ICMP_IREQ equ 15 ; information request
ICMP_IREQREPLY equ 16 ; information reply
ICMP_MASKREQ equ 17 ; address mask request
ICMP_MASKREPLY equ 18 ; address mask reply
ICMP_TRACEROUTE equ 30 ; traceroute
ICMP_DATACONVERR equ 31 ; data conversion error
ICMP_MOBILE_REDIRECT equ 32 ; mobile host redirect
ICMP_IPV6_WHEREAREYOU equ 33 ; IPv6 where-are-you
ICMP_IPV6_IAMHERE equ 34 ; IPv6 i-am-here
ICMP_MOBILE_REGREQUEST equ 35 ; mobile registration req
ICMP_MOBILE_REGREPLY equ 36 ; mobile registreation reply
ICMP_SKIP equ 39 ; SKIP
ICMP_PHOTURIS equ 40 ; Photuris
ICMP_PHOTURIS_UNKNOWN_INDEX equ 1 ; unknown sec index
ICMP_PHOTURIS_AUTH_FAILED equ 2 ; auth failed
ICMP_PHOTURIS_DECRYPT_FAILED equ 3 ; decrypt failed
ICMP_PHOTURIS equ 40 ; Photuris
ICMP_PHOTURIS_UNKNOWN_INDEX equ 1 ; unknown sec index
ICMP_PHOTURIS_AUTH_FAILED equ 2 ; auth failed
ICMP_PHOTURIS_DECRYPT_FAILED equ 3 ; decrypt failed
virtual at 0
ICMP_Packet:
.Type db ?
.Code db ?
.Checksum dw ?
.Identifier dw ?
.SequenceNumber dw ?
.Data:
ICMP_Packet:
.Type db ?
.Code db ?
.Checksum dw ?
.Identifier dw ?
.SequenceNumber dw ?
.Data:
end virtual
; entry point
start:
; load libraries
stdcall dll.Load, @IMPORT
test eax, eax
jnz exit
stdcall dll.Load, @IMPORT
test eax, eax
jnz exit
; initialize console
push 1
call [con_start]
push title
push 25
push 80
push 25
push 80
call [con_init]
push 1
call [con_start]
push title
push 25
push 80
push 25
push 80
call [con_init]
; main loop
push str1
call [con_write_asciiz]
push str1
call [con_write_asciiz]
main:
; write prompt
push str2
call [con_write_asciiz]
push str2
call [con_write_asciiz]
; read string
mov esi, s
push 256
push esi
call [con_gets]
mov esi, s
push 256
push esi
call [con_gets]
; check for exit
test eax, eax
jz done
cmp byte [esi], 10
jz done
test eax, eax
jz done
cmp byte [esi], 10
jz done
; delete terminating '\n'
push esi
push esi
@@:
lodsb
test al, al
jnz @b
mov byte [esi-2], al
pop esi
lodsb
test al, al
jnz @b
mov byte [esi-2], al
pop esi
; resolve name
push esp ; reserve stack place
push esp ; fourth parameter
push 0 ; third parameter
push 0 ; second parameter
push esi ; first parameter
call [getaddrinfo]
pop esi
push esp ; reserve stack place
push esp ; fourth parameter
push 0 ; third parameter
push 0 ; second parameter
push esi ; first parameter
call [getaddrinfo]
pop esi
; test for error
test eax, eax
jnz fail
test eax, eax
jnz fail
; convert IP address to decimal notation
mov eax, [esi+addrinfo.ai_addr]
mov eax, [eax+sockaddr_in.sin_addr]
mov [sockaddr1.ip], eax
push eax
call [inet_ntoa]
mov eax, [esi+addrinfo.ai_addr]
mov eax, [eax+sockaddr_in.sin_addr]
mov [sockaddr1.ip], eax
push eax
call [inet_ntoa]
; write result
mov [ip_ptr], eax
mov [ip_ptr], eax
push eax
push eax
; free allocated memory
push esi
call [freeaddrinfo]
push esi
call [freeaddrinfo]
push str4
call [con_write_asciiz]
push str4
call [con_write_asciiz]
mcall socket, AF_INET4, SOCK_RAW, IPPROTO_ICMP
cmp eax, -1
jz fail2
mov [socketnum], eax
mcall socket, AF_INET4, SOCK_RAW, IPPROTO_ICMP
cmp eax, -1
jz fail2
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]
mov [count], 4
mov [count], 4
mainloop:
push str3
call [con_write_asciiz]
push [ip_ptr]
call [con_write_asciiz]
push str3
call [con_write_asciiz]
push [ip_ptr]
call [con_write_asciiz]
mcall 26,9
mov [time_reference], eax
mcall send, [socketnum], icmp_packet, icmp_packet.length, 0
mcall 26,9
mov [time_reference], eax
mcall send, [socketnum], icmp_packet, icmp_packet.length, 0
mcall 23, 300 ; 3 seconds time-out
mcall 26,9
neg [time_reference]
add [time_reference], eax
mcall 23, 300 ; 3 seconds time-out
mcall 26,9
neg [time_reference]
add [time_reference], eax
mcall recv, [socketnum], buffer_ptr, BUFFERSIZE, 0
cmp eax, -1
je .no_response
mcall recv, [socketnum], buffer_ptr, BUFFERSIZE, 0
cmp eax, -1
je .no_response
; validate the packet
lea esi, [buffer_ptr + ICMP_Packet.Data]
mov edi, icmp_packet.data
mov ecx, 32/4
repe cmpsd
jne .miscomp
lea esi, [buffer_ptr + ICMP_Packet.Data]
mov edi, icmp_packet.data
mov ecx, 32/4
repe cmpsd
jne .miscomp
push [time_reference]
push str7
call [con_printf]
push [time_reference]
push str7
call [con_printf]
jmp continue
jmp continue
.miscomp:
sub edi, icmp_packet.data
push edi
push str9
call [con_printf]
jmp continue
sub edi, icmp_packet.data
push edi
push str9
call [con_printf]
jmp continue
.no_response:
push str8
call [con_write_asciiz]
push str8
call [con_write_asciiz]
continue:
dec [count]
jz done
mcall 5, 100 ; wait a second
inc [icmp_packet.id]
jmp mainloop
dec [count]
jz done
mcall 5, 100 ; wait a second
inc [icmp_packet.id]
jmp mainloop
done:
push str10
call [con_write_asciiz]
call [con_getch2]
push 1
call [con_exit]
push str10
call [con_write_asciiz]
call [con_getch2]
push 1
call [con_exit]
exit:
mcall -1
mcall -1
fail:
push str5
call [con_write_asciiz]
jmp done
push str5
call [con_write_asciiz]
jmp done
fail2:
push str6
call [con_write_asciiz]
jmp done
push str6
call [con_write_asciiz]
jmp done
; data
title db 'ICMP - test application',0
str1 db 'ICMP test application v0.1',10,' for KolibriOS # 1540 or later. ',10,10,0
str2 db '> ',0
str3 db 'Ping to: ',0
str4 db 10,0
str5 db 'Name resolution failed.',10,10,0
str6 db 'Could not open socket',10,10,0
str7 db ' time= %u0ms',10,0
str8 db ' timeout!',10,0
str9 db ' miscompare at offset %u',10,0
str10 db 10,10,'Press any key to exit',0
title db 'ICMP - test application',0
str1 db 'ICMP test application v0.1',10,' for KolibriOS # 1540 or later. ',10,10,0
str2 db '> ',0
str3 db 'Ping to: ',0
str4 db 10,0
str5 db 'Name resolution failed.',10,10,0
str6 db 'Could not open socket',10,10,0
str7 db ' time= %u0ms',10,0
str8 db ' timeout!',10,0
str9 db ' miscompare at offset %u',10,0
str10 db 10,10,'Press any key to exit',0
sockaddr1:
dw AF_INET4
.port dw 0
.ip dd 0
rb 10
dw AF_INET4
.port dw 0
.ip dd 0
rb 10
time_reference dd ?
ip_ptr dd ?
count dd ?
time_reference dd ?
ip_ptr dd ?
count dd ?
; import
@ -283,37 +286,37 @@ align 4
@IMPORT:
library network, 'network.obj', console, 'console.obj'
import network, \
getaddrinfo, 'getaddrinfo', \
freeaddrinfo, 'freeaddrinfo', \
inet_ntoa, 'inet_ntoa'
import network, \
getaddrinfo, 'getaddrinfo', \
freeaddrinfo, 'freeaddrinfo', \
inet_ntoa, 'inet_ntoa'
import console, \
con_start, 'START', \
con_init, 'con_init', \
con_write_asciiz, 'con_write_asciiz', \
con_printf, 'con_printf', \
con_exit, 'con_exit', \
con_gets, 'con_gets',\
con_cls, 'con_cls',\
con_getch2, 'con_getch2',\
con_set_cursor_pos, 'con_set_cursor_pos'
import console, \
con_start, 'START', \
con_init, 'con_init', \
con_write_asciiz, 'con_write_asciiz', \
con_printf, 'con_printf', \
con_exit, 'con_exit', \
con_gets, 'con_gets',\
con_cls, 'con_cls',\
con_getch2, 'con_getch2',\
con_set_cursor_pos, 'con_set_cursor_pos'
socketnum dd ?
socketnum dd ?
icmp_packet: db 8 ; type
db 0 ; code
dw 0 ;
.id dw 0x0000 ; identifier
.seq dw 0x0001 ; sequence number
.data db 'abcdefghijklmnopqrstuvwxyz012345678'
icmp_packet: db 8 ; type
db 0 ; code
dw 0 ;
.id dw 0x0000 ; identifier
.seq dw 0x0001 ; sequence number
.data db 'abcdefghijklmnopqrstuvwxyz012345678'
.length = $ - icmp_packet
I_END:
buffer_ptr rb BUFFERSIZE
buffer_ptr rb BUFFERSIZE
s rb 256
align 4
rb 4096 ; stack
s rb 256
align 4
rb 4096 ; stack
mem:

View File

@ -6,16 +6,18 @@
; By hidnplayr
;
use32
org 0x0
format binary as ""
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
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
use32
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
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
@ -24,170 +26,174 @@ include 'proc32.inc'
include 'struct.inc'
START:
; first, check boot parameters
; first, check boot parameters
cmp byte[param], 0
je .noparams
cmp byte[param], 0
je .noparams
mcall 40, 0
mcall 40, 0
push exit
cmp byte[param], 'A' ; A for All
je Get_PCI_Info
push .launch_zeroconf_exit
cmp byte[param], 'A' ; A for All
je Get_PCI_Info
cmp byte[param], 'F' ; F for First
je Get_PCI_Info
cmp byte[param], 'F' ; F for First
je Get_PCI_Info
ret
ret
.launch_zeroconf_exit:
mcall 70, zeroconf
mcall -1
.noparams:
call draw_window
call draw_window
still: mcall 10 ; wait here for event
dec eax ; redraw request ?
jz red
dec eax ; key in buffer ?
jz key
dec eax ; button in buffer ?
jz button
jmp still
still: mcall 10 ; wait here for event
dec eax ; redraw request ?
jz red
dec eax ; key in buffer ?
jz key
dec eax ; button in buffer ?
jz button
jmp still
red: ; redraw
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 [Form + 2], ax ; x start position
mov eax, [Proc_Info.box.top];
mov [Form + 6], ax ; ystart position
mov eax, [Proc_Info.box.width] ;
mov [Form], ax ; window width
mov eax, [Proc_Info.box.height] ;
mov [Form + 4] ,ax ; window height
call draw_window ; go redraw window now
jmp still
red: ; redraw
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 [Form + 2], ax ; x start position
mov eax, [Proc_Info.box.top];
mov [Form + 6], ax ; ystart position
mov eax, [Proc_Info.box.width] ;
mov [Form], ax ; window width
mov eax, [Proc_Info.box.height] ;
mov [Form + 4] ,ax ; window height
call draw_window ; go redraw window now
jmp still
key: ; key
mcall 2 ; just read it and ignore
jmp still
button: ; button
mcall 17 ; get id
key: ; key
mcall 2 ; just read it and ignore
jmp still
button: ; button
mcall 17 ; get id
cmp ah, 1 ; button id = 1 ?
jne @f
exit: mcall -1 ; close this program
cmp ah, 1 ; button id = 1 ?
jne @f
exit: mcall -1 ; close this program
@@:
cmp eax,0x0000ff00
jg load_drv
cmp eax,0x0000ff00
jg load_drv
cmp ah, 4
je hook
cmp ah, 4
je hook
cmp ah, 5
je reset
cmp ah, 5
je reset
cmp ah, 6
je unload
cmp ah, 6
je unload
jmp still
jmp still
load_drv:
shr eax, 16
mov word [selected], ax
shr eax, 16
mov word [selected], ax
mov bl , 6 ; get a dword
mov bh , ah ; bus
mov ch , al ; dev
mov cl , 0 ; offset to device/vendor id
mcall 62 ; get ID's
mov bl , 6 ; get a dword
mov bh , ah ; bus
mov ch , al ; dev
mov cl , 0 ; offset to device/vendor id
mcall 62 ; get ID's
mov word [PCI_Vendor], ax
shr eax, 16
mov word [PCI_Device], ax
call get_drv_ptr
mov word [PCI_Vendor], ax
shr eax, 16
mov word [PCI_Device], ax
call get_drv_ptr
mov ecx, eax
mcall 68, 16
mov ecx, eax
mcall 68, 16
mov [IOCTL.handle], eax
mov [IOCTL.handle], eax
call draw_window
call draw_window
cmp [IOCTL.handle], 0
jne still
cmp [IOCTL.handle], 0
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:
mov ax , [selected]
test ax , ax
jz still
mov ax , [selected]
test ax , ax
jz still
mov [hardwareinfo.pci_dev], al
mov [hardwareinfo.pci_bus], ah
mov [hardwareinfo.pci_dev], al
mov [hardwareinfo.pci_bus], ah
mov [IOCTL.io_code], 1 ; SRV_HOOK
mov [IOCTL.inp_size], 3
mov [IOCTL.input], hardwareinfo
mov [IOCTL.out_size], 0
mov [IOCTL.output], 0
mov [IOCTL.io_code], 1 ; SRV_HOOK
mov [IOCTL.inp_size], 3
mov [IOCTL.input], hardwareinfo
mov [IOCTL.out_size], 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:
movzx ebx, byte[drivernumber]
mcall 74,,2
movzx ebx, byte[drivernumber]
mcall 74,,2
jmp still
jmp still
unload:
movzx ebx, byte[drivernumber]
mcall 74,,3
movzx ebx, byte[drivernumber]
mcall 74,,3
jmp still
jmp still
draw_window:
mcall 12, 1 ; start of draw
mcall 0, dword [Form], dword [Form + 4], 0x13ffffff, 0x805080d0, title
mcall 12, 1 ; start of draw
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
je .nonefound
cmp edx, 20 shl 16 + 110
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
jz .done
cmp [IOCTL.handle] ,0
jz .done
cmp [selected], 0
jz .done
cmp [IOCTL.handle] ,0
jz .done
mcall 8, 18 shl 16 + 100, 35 shl 16 + 18, 4, 0x00007f00
mcall ,, 55 shl 16 + 18, 5, 0x0000007f
mcall ,, 75 shl 16 + 18, 6, 0x007f0000
mcall 8, 18 shl 16 + 100, 35 shl 16 + 18, 4, 0x00007f00
mcall ,, 55 shl 16 + 18, 5, 0x0000007f
mcall ,, 75 shl 16 + 18, 6, 0x007f0000
mcall 4, 33 shl 16 + 42, 1 shl 31 + 0x00ffffff , btn_start
mcall , 33 shl 16 + 62, , btn_reset
mcall , 36 shl 16 + 82, , btn_stop
mcall 4, 33 shl 16 + 42, 1 shl 31 + 0x00ffffff , btn_start
mcall , 33 shl 16 + 62, , btn_reset
mcall , 36 shl 16 + 82, , btn_stop
; mcall , 140 shl 16 + 62, 1 shl 31 + 0x00000000 , devicename
jmp .done
jmp .done
.nonefound:
mcall 4, 20 shl 16 + 30, 1 shl 31 + 0x00ff0000 , nonefound
mcall 4, 20 shl 16 + 30, 1 shl 31 + 0x00ff0000 , nonefound
.done:
mcall 12, 2 ; end of draw
ret
mcall 12, 2 ; end of draw
ret
@ -196,106 +202,106 @@ draw_window:
;------------------------------------------------------------------
;* Gets the PCI Version and Last Bus
Get_PCI_Info:
mcall 62, 0
mov word [PCI_Version], ax
mcall 62, 1
mov byte [PCI_LastBus], al
;----------------------------------------------------------
;* Get all devices on PCI Bus
mov edx, 20 shl 16 + 110 ; set start write position
cmp al , 0xff ; 0xFF means no pci bus found
jne Pci_Exists ;
ret ; if no bus then leave
mcall 62, 0
mov word [PCI_Version], ax
mcall 62, 1
mov byte [PCI_LastBus], al
;----------------------------------------------------------
;* Get all devices on PCI Bus
mov edx, 20 shl 16 + 110 ; set start write position
cmp al , 0xff ; 0xFF means no pci bus found
jne Pci_Exists ;
ret ; if no bus then leave
Pci_Exists:
mov byte [V_Bus], 0 ; reset varibles
mov byte [V_Dev], 0 ;
mov byte [V_Bus], 0 ; reset varibles
mov byte [V_Dev], 0 ;
Start_Enum:
mov bl , 6 ; get a dword
mov bh , byte [V_Bus] ; bus of pci device
mov ch , byte [V_Dev] ; device number/function
mov cl , 0 ; offset to device/vendor id
mcall 62 ; get ID's
mov bl , 6 ; get a dword
mov bh , byte [V_Bus] ; bus of pci device
mov ch , byte [V_Dev] ; device number/function
mov cl , 0 ; offset to device/vendor id
mcall 62 ; get ID's
cmp ax, 0 ; Vendor ID should not be 0 or 0xFFFF
je nextDev ; check next device if nothing exists here
cmp ax, 0xffff ;
je nextDev ;
cmp ax, 0 ; Vendor ID should not be 0 or 0xFFFF
je nextDev ; check next device if nothing exists here
cmp ax, 0xffff ;
je nextDev ;
mov word [PCI_Vendor], ax ; There is a device here, save the ID's
shr eax, 16 ;
mov word [PCI_Device], ax ;
mov bl , 4 ; Read config byte
mov bh , byte [V_Bus] ; Bus #
mov ch , byte [V_Dev] ; Device # on bus
mov cl , 0x08 ; Register to read (Get Revision)
mcall 62 ; Read it
mov byte [PCI_Rev], al ; Save it
mov cl , 0x0b ; Register to read (Get class)
mcall 62 ; Read it
mov byte [PCI_Class], al ; Save it
mov cl , 0x0a ; Register to read (Get Subclass)
mcall 62 ; Read it
mov byte [PCI_SubClass], al ; Save it
mov cl , 0x09 ; Register to read (Get Interface)
mcall 62 ; Read it
mov [PCI_Interface], al ; Save it
mov cl , 0x3c ; Register to read (Get IRQ)
@@: mcall 62 ; Read it
mov [PCI_IRQ], al ; Save it
mov word [PCI_Vendor], ax ; There is a device here, save the ID's
shr eax, 16 ;
mov word [PCI_Device], ax ;
mov bl , 4 ; Read config byte
mov bh , byte [V_Bus] ; Bus #
mov ch , byte [V_Dev] ; Device # on bus
mov cl , 0x08 ; Register to read (Get Revision)
mcall 62 ; Read it
mov byte [PCI_Rev], al ; Save it
mov cl , 0x0b ; Register to read (Get class)
mcall 62 ; Read it
mov byte [PCI_Class], al ; Save it
mov cl , 0x0a ; Register to read (Get Subclass)
mcall 62 ; Read it
mov byte [PCI_SubClass], al ; Save it
mov cl , 0x09 ; Register to read (Get Interface)
mcall 62 ; Read it
mov [PCI_Interface], al ; Save it
mov cl , 0x3c ; Register to read (Get IRQ)
@@: mcall 62 ; Read it
mov [PCI_IRQ], al ; Save it
;
; inc byte [total] ; one more device found
cmp byte [PCI_Class],2
jne nextDev
cmp byte [PCI_Class],2
jne nextDev
cmp byte[param], 0
jne load_and_start
cmp byte[param], 0
jne load_and_start
call Print_New_Device ; print device info to screen
call Print_New_Device ; print device info to screen
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
mov byte [V_Dev], 0 ; reset device number
inc byte [V_Bus] ; next bus
mov al , byte [PCI_LastBus] ; get last bus
cmp byte [V_Bus], al ; was it last bus
jbe Start_Enum ; if not jump to keep searching
ret
jnz Start_Enum ; jump until we reach zero
mov byte [V_Dev], 0 ; reset device number
inc byte [V_Bus] ; next bus
mov al , byte [PCI_LastBus] ; get last bus
cmp byte [V_Bus], al ; was it last bus
jbe Start_Enum ; if not jump to keep searching
ret
load_and_start:
call get_drv_ptr
cmp eax, lbl_none
je .next
call get_drv_ptr
cmp eax, lbl_none
je .next
mov ecx, eax
mcall 68, 16
test eax, eax
jz .next
mov [IOCTL.handle], eax
mov ecx, eax
mcall 68, 16
test eax, eax
jz .next
mov [IOCTL.handle], eax
mov al, [V_Dev]
mov [hardwareinfo.pci_dev], al
mov al, [V_Bus]
mov [hardwareinfo.pci_bus], al
mov al, [V_Dev]
mov [hardwareinfo.pci_dev], al
mov al, [V_Bus]
mov [hardwareinfo.pci_bus], al
mov [IOCTL.io_code], 1 ; SRV_HOOK
mov [IOCTL.inp_size], 3
mov [IOCTL.input], hardwareinfo
mov [IOCTL.out_size], 0
mov [IOCTL.output], 0
mov [IOCTL.io_code], 1 ; SRV_HOOK
mov [IOCTL.inp_size], 3
mov [IOCTL.input], hardwareinfo
mov [IOCTL.out_size], 0
mov [IOCTL.output], 0
mcall 68, 17, IOCTL
mcall 68, 17, IOCTL
.next:
cmp byte[param], 'A'
je nextDev
jmp exit
cmp byte[param], 'A'
je nextDev
jmp exit
@ -303,161 +309,161 @@ load_and_start:
;* Print device info to screen
Print_New_Device:
push edx ; Magic ! (to print a button...)
push edx ; Magic ! (to print a button...)
mov ebx, 18 shl 16
mov bx , [Form]
sub bx , 36
mov ebx, 18 shl 16
mov bx , [Form]
sub bx , 36
mov cx , dx
dec cx
shl ecx, 16
add ecx, 9
mov cx , dx
dec cx
shl ecx, 16
add ecx, 9
movzx edx, byte [V_Bus]
shl dx , 8
mov dl , byte [V_Dev]
movzx edx, byte [V_Bus]
shl dx , 8
mov dl , byte [V_Dev]
mov esi, 0x0000c0ff ; color: yellow if selected, blue otherwise
cmp word [selected], dx
jne @f
mov esi, 0x00c0c000
mov esi, 0x0000c0ff ; color: yellow if selected, blue otherwise
cmp word [selected], dx
jne @f
mov esi, 0x00c0c000
@@:
shl edx, 8
or dl , 0xff
shl edx, 8
or dl , 0xff
mcall 8
pop edx
mcall 8
pop edx
xor esi, esi ; Color of text
movzx ecx, word [PCI_Vendor] ; number to be written
mcall 47, 0x00040100 ; Write Vendor ID
xor esi, esi ; Color of text
movzx ecx, word [PCI_Vendor] ; number to be written
mcall 47, 0x00040100 ; Write Vendor ID
add edx, (4*6+18) shl 16
movzx ecx, word [PCI_Device] ; get Vendor ID
mcall ; Draw Vendor ID to Window
add edx, (4*6+18) shl 16
movzx ecx, word [PCI_Device] ; get Vendor ID
mcall ; Draw Vendor ID to Window
add edx, (4*6+18) shl 16
movzx ecx, byte [V_Bus] ; get bus number
mcall ,0x00020100 ; draw bus number to screen
add edx, (4*6+18) shl 16
movzx ecx, byte [V_Bus] ; get bus number
mcall ,0x00020100 ; draw bus number to screen
add edx, (2*6+18) shl 16
movzx ecx, byte [V_Dev] ; get device number
shr ecx, 3 ; device number is bits 3-7
mcall ; Draw device Number To Window
add edx, (2*6+18) shl 16
movzx ecx, byte [V_Dev] ; get device number
shr ecx, 3 ; device number is bits 3-7
mcall ; Draw device Number To Window
add edx, (2*6+18) shl 16
movzx ecx, byte [PCI_Rev] ; get revision number
mcall ; Draw Revision to screen
add edx, (2*6+18) shl 16
movzx ecx, byte [PCI_Rev] ; get revision number
mcall ; Draw Revision to screen
add edx, (2*6+18) shl 16
movzx ecx, [PCI_IRQ]
cmp cl , 0x0f ; IRQ must be between 0 and 15
ja @f
mcall
add edx, (2*6+18) shl 16
movzx ecx, [PCI_IRQ]
cmp cl , 0x0f ; IRQ must be between 0 and 15
ja @f
mcall
@@:
;
;Write Names
movzx ebx, dx ; Set y position
or ebx, 230 shl 16 ; set Xposition
;Write Names
movzx ebx, dx ; Set y position
or ebx, 230 shl 16 ; set Xposition
;------------------------------------------------------------------
; Prints the Vendor's Name based on Vendor ID
;------------------------------------------------------------------
mov edx, VendorsTab
mov cx , word[PCI_Vendor]
.fn: mov ax , [edx]
add edx, 6
test ax , ax
jz .find
cmp ax , cx
jne .fn
.find: mov edx, [edx - 4]
mcall 4,, 0x80000000 ; lets print the vendor Name
mov edx, VendorsTab
mov cx , word[PCI_Vendor]
.fn: mov ax , [edx]
add edx, 6
test ax , ax
jz .find
cmp ax , cx
jne .fn
.find: mov edx, [edx - 4]
mcall 4,, 0x80000000 ; lets print the vendor Name
;------------------------------------------------------------------
; Get description based on Class/Subclass
;------------------------------------------------------------------
mov eax, dword [PCI_Class]
and eax, 0xffffff
xor edx, edx
xor esi, esi
.fnc: inc esi
mov ecx, [Classes + esi * 8 - 8]
cmp cx , 0xffff
je .endfc
cmp cx , ax
jne .fnc
test ecx, 0xff000000
jz @f
mov edx, [Classes + esi * 8 - 4]
jmp .fnc
@@: cmp eax, ecx
jne .fnc
xor edx, edx
.endfc: test edx, edx
jnz @f
mov edx, [Classes + esi * 8 - 4]
@@:
add ebx, 288 shl 16
mcall 4,, 0x80000000,, 32 ; draw the text
movzx edx, bx ; get y coordinate
add edx, 0x0014000A ; add 10 to y coordinate and set x coordinate to 20
mov eax, dword [PCI_Class]
and eax, 0xffffff
xor edx, edx
xor esi, esi
.fnc: inc esi
mov ecx, [Classes + esi * 8 - 8]
cmp cx , 0xffff
je .endfc
cmp cx , ax
jne .fnc
test ecx, 0xff000000
jz @f
mov edx, [Classes + esi * 8 - 4]
jmp .fnc
@@: cmp eax, ecx
jne .fnc
xor edx, edx
.endfc: test edx, edx
jnz @f
mov edx, [Classes + esi * 8 - 4]
@@:
add ebx, 288 shl 16
mcall 4,, 0x80000000,, 32 ; draw the text
movzx edx, bx ; get y coordinate
add edx, 0x0014000A ; add 10 to y coordinate and set x coordinate to 20
;------------------------------------------------------------------
; Print Driver Name
;------------------------------------------------------------------
push edx
add ebx, 120 shl 16
push ebx
push edx
add ebx, 120 shl 16
push ebx
call get_drv_ptr
mov edx, eax
pop ebx
mcall 4,,0x80000000 ; lets print the vendor Name
pop edx
ret
call get_drv_ptr
mov edx, eax
pop ebx
mcall 4,,0x80000000 ; lets print the vendor Name
pop edx
ret
get_drv_ptr:
mov eax, driverlist ; eax will be the pointer to latest driver title
mov ebx, driverlist ; ebx is the current pointer
mov ecx, dword[PCI_Vendor] ; the device/vendor id of we want to find
mov eax, driverlist ; eax will be the pointer to latest driver title
mov ebx, driverlist ; ebx is the current pointer
mov ecx, dword[PCI_Vendor] ; the device/vendor id of we want to find
driverloop:
inc ebx
inc ebx
cmp byte[ebx],0
jne driverloop
cmp byte[ebx],0
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:
cmp dword[ebx],0
je nextdriver
cmp dword[ebx],0
je nextdriver
cmp dword[ebx],ecx
je driverfound
cmp dword[ebx],ecx
je driverfound
add ebx,4
jmp deviceloop
add ebx,4
jmp deviceloop
nextdriver:
add ebx,4
add ebx,4
cmp dword[ebx],0
je nodriver
cmp dword[ebx],0
je nodriver
mov eax,ebx
jmp driverloop
mov eax,ebx
jmp driverloop
nodriver:
mov eax, lbl_none ; lets print the vendor Name
ret
mov eax, lbl_none ; lets print the vendor Name
ret
driverfound:
ret
ret
include 'vendors.inc'
include 'drivers.inc'
@ -470,12 +476,12 @@ include 'drivers.inc'
DATA
Form: dw 800 ; window width (no more, special for 800x600)
dw 100 ; window x start
dw 220 ; window height
dw 100 ; window y start
Form: dw 800 ; window width (no more, special for 800x600)
dw 100 ; window x start
dw 220 ; window height
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
nonefound db 'No compatible devices were found!',0
@ -487,12 +493,20 @@ load_error db 'Could not load driver!',0
devicename db 'test'
rb 64
db 0
db 0
hardwareinfo:
.type db 1 ; pci
.pci_bus db ?
.pci_dev db ?
.type db 1 ; pci
.pci_bus 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:
@ -502,37 +516,37 @@ IM_END:
IOCTL:
.handle dd ?
.io_code dd ?
.input dd ?
.inp_size dd ?
.output dd ?
.out_size dd ?
.handle dd ?
.io_code dd ?
.input dd ?
.inp_size dd ?
.output dd ?
.out_size dd ?
drivernumber db ?
MAC dp ?
drivernumber db ?
MAC dp ?
type db ?
selected dw ?
V_Bus db ?
V_Dev db ?
PCI_Version dw ?
PCI_LastBus db ?
PCI_Vendor dw ?
PCI_Device dw ?
PCI_Bus db ?
PCI_Dev db ?
PCI_Rev db ?
type db ?
selected dw ?
V_Bus db ?
V_Dev db ?
PCI_Version dw ?
PCI_LastBus db ?
PCI_Vendor dw ?
PCI_Device dw ?
PCI_Bus db ?
PCI_Dev db ?
PCI_Rev db ?
; don`t change order!!!
PCI_Class db ?
PCI_SubClass db ?
PCI_Interface db ?
PCI_IRQ db ?
PCI_Class db ?
PCI_SubClass db ?
PCI_Interface db ?
PCI_IRQ db ?
Proc_Info process_information
Proc_Info process_information
param rb 1024
param rb 1024
I_END:

View File

@ -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
;
format binary as ""
use32
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd (I_END+0x100) ; memory for app
dd (I_END+0x100) ; esp
dd I_PARAM , 0x0 ; I_Param , I_Icon
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd (I_END+0x100) ; memory for app
dd (I_END+0x100) ; esp
dd I_PARAM , 0x0 ; I_Param , I_Icon
__DEBUG__ equ 1
__DEBUG_LEVEL__ equ 1
include '..\macros.inc'
include '..\debug-fdo.inc'
include '..\network.inc'
START: ; start of execution
START: ; start of execution
; TODO: check Parameters
DEBUGF 1, 'Netstat application loaded!\n'
@ -77,7 +83,7 @@ START: ; start of execution
mov edx, str_queue_out
mcall
mov ebx,1337 shl 16 + 4
mov ebx, API_ETH + 4
mov bh, [device]
mcall 76
push eax
@ -110,7 +116,7 @@ START: ; start of execution
mcall
mov ebx, 0 shl 16 + 8
mov ebx, API_IPv4 + 8
mov bh, [device]
mcall 76
push eax
@ -174,14 +180,14 @@ START: ; start of execution
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
je redraw
je redraw
cmp eax, 2
je key
je key
cmp eax, 3
je button
je button
@ -195,7 +201,7 @@ START: ; start of execution
cmp [mode], 101
jne not_101
mov ebx, 1337 shl 16 + 0
mov ebx, API_ETH
mov bh, [device]
@@:
push ebx
@ -206,8 +212,8 @@ START: ; start of execution
cmp bl, 3
jle @r
inc bl ;5
inc bl ;6
inc bl ;5
inc bl ;6
@@:
push ebx
@ -249,7 +255,7 @@ START: ; start of execution
cmp [mode], 102
jne not_102
mov ebx, 0 shl 16
mov ebx, API_IPv4
mov bh, [device]
push ebx
mcall 76
@ -281,7 +287,7 @@ START: ; start of execution
cmp [mode], 103
jne not_103
mov ebx, 0x0608 shl 16 + 0
mov ebx, API_ARP
mov bh, [device]
push ebx
mcall 76
@ -320,7 +326,7 @@ not_103:
cmp [mode], 104
jne not_104
mov ebx, 1 shl 16 + 0
mov ebx, API_ICMP
mov bh, [device]
push ebx
mcall 76
@ -351,7 +357,7 @@ not_104:
cmp [mode], 105
jne not_105
mov ebx, 17 shl 16 + 0
mov ebx, API_UDP
mov bh, [device]
push ebx
mcall 76
@ -382,7 +388,7 @@ not_105:
cmp [mode], 106
jne not_106
mov ebx, 6 shl 16 + 0
mov ebx, API_TCP
mov bh, [device]
push ebx
mcall 76
@ -417,102 +423,102 @@ not_106:
jmp mainloop
button: ; button
mcall 17 ; get id
button: ; button
mcall 17 ; get id
cmp ah, 1
je close
je exit
mov [mode], ah
jmp redraw
close:
exit:
mcall -1
draw_mac:
mov eax, 47
mov ebx, 0x00020100
mov esi, 0x40000000
mov edi, 0x00bcbcbc
mov eax, 47
mov ebx, 0x00020100
mov esi, 0x40000000
mov edi, 0x00bcbcbc
mov cl, [esp+4]
mcall
mov cl, [esp+4]
mcall
mov cl, [esp+4+1]
add edx, 15 shl 16
mcall
mov cl, [esp+4+1]
add edx, 15 shl 16
mcall
mov cl, [esp+4+2]
add edx, 15 shl 16
mcall
mov cl, [esp+4+2]
add edx, 15 shl 16
mcall
mov cl, [esp+4+3]
add edx, 15 shl 16
mcall
mov cl, [esp+4+3]
add edx, 15 shl 16
mcall
mov cl, [esp+4+4]
add edx, 15 shl 16
mcall
mov cl, [esp+4+4]
add edx, 15 shl 16
mcall
mov cl, [esp+4+5]
add edx, 15 shl 16
mcall
mov cl, [esp+4+5]
add edx, 15 shl 16
mcall
sub edx, 5*15 shl 16
sub edx, 5*15 shl 16
ret 6
ret 6
draw_ip:
mov eax, 47
mov ebx, 0x00030000
mov esi, 0x40000000
mov edi, 0x00bcbcbc
mov eax, 47
mov ebx, 0x00030000
mov esi, 0x40000000
mov edi, 0x00bcbcbc
xor ecx, ecx
xor ecx, ecx
mov cl, [esp+4]
mcall
mov cl, [esp+4]
mcall
mov cl, [esp+4+1]
add edx, 30 shl 16
mcall
mov cl, [esp+4+1]
add edx, 30 shl 16
mcall
mov cl, [esp+4+2]
add edx, 30 shl 16
mcall
mov cl, [esp+4+2]
add edx, 30 shl 16
mcall
mov cl, [esp+4+3]
add edx, 30 shl 16
mcall
mov cl, [esp+4+3]
add edx, 30 shl 16
mcall
sub edx, 3*30 shl 16
ret 4
sub edx, 3*30 shl 16
ret 4
; DATA AREA
name db 'Netstat',0
mode db 101
device db 0
modes db 'Ethernet IPv4 ARP ICMP UDP TCP',0
name db 'Netstat', 0
mode db 101
device db 0
modes db 'Ethernet IPv4 ARP ICMP UDP TCP', 0
str_packets_tx db 'Packets sent:',0
str_packets_rx db 'Packets received:',0
str_bytes_tx db 'Bytes sent:',0
str_bytes_rx db 'Bytes received:',0
str_MAC db 'MAC address:',0
str_queue_in db 'IN-queue size:',0
str_queue_out db 'OUT-queue size:',0
str_ip db 'IP address:',0
str_dns db 'DNS address:',0
str_subnet db 'Subnet mask:',0
str_gateway db 'Standard gateway:',0
str_arp db 'ARP entrys:',0
str_packets_tx db 'Packets sent:', 0
str_packets_rx db 'Packets received:', 0
str_bytes_tx db 'Bytes sent:', 0
str_bytes_rx db 'Bytes received:', 0
str_MAC db 'MAC address:', 0
str_queue_in db 'IN-queue size:', 0
str_queue_out db 'OUT-queue size:', 0
str_ip db 'IP address:', 0
str_dns db 'DNS address:', 0
str_subnet db 'Subnet mask:', 0
str_gateway db 'Standard gateway:', 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

View File

@ -1,72 +1,91 @@
; Socket types
SOCK_STREAM = 1
SOCK_DGRAM = 2
SOCK_RAW = 3 ; not supported by the kernel
SOCK_STREAM = 1
SOCK_DGRAM = 2
SOCK_RAW = 3
; IP protocols
IPPROTO_IP = 0
IPPROTO_ICMP = 1 ; not supported by the kernel
IPPROTO_TCP = 6
IPPROTO_UDP = 17
IPPROTO_IP = 0
IPPROTO_ICMP = 1
IPPROTO_TCP = 6
IPPROTO_UDP = 17
; Address families
AF_UNSPEC = 0
AF_UNIX = 1
AF_INET4 = 2 ; IPv4
;AF_INET6 = 28 ; IPv6 (not supported)
AF_UNSPEC = 0
AF_LOCAL = 1
AF_INET4 = 2 ; IPv4
;AF_INET6 = 28 ; IPv6 (not supported yet)
PF_UNSPEC = AF_UNSPEC
PF_UNIX = AF_UNIX
PF_INET4 = AF_INET4
;PF_INET6 = AF_INET6
PF_UNSPEC = AF_UNSPEC
PF_LOCAL = AF_LOCAL
PF_INET4 = AF_INET4
;PF_INET6 = AF_INET6
; Flags for addrinfo
AI_PASSIVE = 1
AI_CANONNAME = 2
AI_NUMERICHOST = 4
AI_NUMERICSERV = 8
AI_ADDRCONFIG = 0x400
AI_PASSIVE = 1
AI_CANONNAME = 2
AI_NUMERICHOST = 4
AI_NUMERICSERV = 8
AI_ADDRCONFIG = 0x400
; 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
sin_family dw ? ; sa_family_t
sin_port dw ? ; in_port_t
sin_addr dd ? ; struct in_addr
sin_zero rb 8 ; zero
sin_family dw ? ; sa_family_t
sin_port dw ? ; in_port_t
sin_addr dd ? ; struct in_addr
sin_zero rb 8 ; zero
ends
struct addrinfo
ai_flags dd ? ; bitmask of AI_*
ai_family dd ? ; PF_*
ai_socktype dd ? ; SOCK_*
ai_protocol dd ? ; 0 or IPPROTO_*
ai_addrlen dd ? ; length of ai_addr
ai_canonname dd ? ; char*
ai_addr dd ? ; struct sockaddr*
ai_next dd ? ; struct addrinfo*
ai_flags dd ? ; bitmask of AI_*
ai_family dd ? ; PF_*
ai_socktype dd ? ; SOCK_*
ai_protocol dd ? ; 0 or IPPROTO_*
ai_addrlen dd ? ; length of ai_addr
ai_canonname dd ? ; char*
ai_addr dd ? ; struct sockaddr*
ai_next dd ? ; struct addrinfo*
ends
EAI_ADDRFAMILY = 1
EAI_AGAIN = 2
EAI_BADFLAGS = 3
EAI_FAIL = 4
EAI_FAMILY = 5
EAI_MEMORY = 6
EAI_NONAME = 8
EAI_SERVICE = 9
EAI_SOCKTYPE = 10
EAI_BADHINTS = 12
EAI_PROTOCOL = 13
EAI_OVERFLOW = 14
EAI_ADDRFAMILY = 1
EAI_AGAIN = 2
EAI_BADFLAGS = 3
EAI_FAIL = 4
EAI_FAMILY = 5
EAI_MEMORY = 6
EAI_NONAME = 8
EAI_SERVICE = 9
EAI_SOCKTYPE = 10
EAI_BADHINTS = 12
EAI_PROTOCOL = 13
EAI_OVERFLOW = 14
socket fix 75, 0
close fix 75, 1
bind fix 75, 2
listen fix 75, 3
connect fix 75, 4
accept fix 75, 5
send fix 75, 6
recv fix 75, 7
socket fix 75, 0
close fix 75, 1
bind fix 75, 2
listen fix 75, 3
connect fix 75, 4
accept fix 75, 5
send fix 75, 6
recv fix 75, 7
setsockopt fix 75, 8
getsockopt fix 75, 9
struct ARP_entry
IP dd ?
MAC dp ?
status dw ?
TTL dw ?
ends

View File

@ -1,13 +1,15 @@
format binary as ""
use32
; standard header
db 'MENUET01' ; signature
dd 1 ; header version
dd start ; entry point
dd i_end ; initialized size
dd mem ; required memory
dd mem ; stack pointer
dd 0 ; parameters
dd 0 ; path
db 'MENUET01' ; signature
dd 1 ; header version
dd start ; entry point
dd i_end ; initialized size
dd mem ; required memory
dd mem ; stack pointer
dd 0 ; parameters
dd 0 ; path
; useful includes
include '../macros.inc'
@ -20,115 +22,115 @@ include '../network.inc'
; entry point
start:
; load libraries
stdcall dll.Load, @IMPORT
test eax, eax
jnz exit
stdcall dll.Load, @IMPORT
test eax, eax
jnz exit
; initialize console
push 1
call [con_start]
push title
push -1
push -1
push -1
push -1
call [con_init]
push 1
call [con_start]
push title
push -1
push -1
push -1
push -1
call [con_init]
; main loop
main:
; write prompt
push str1
call [con_write_asciiz]
push str1
call [con_write_asciiz]
; read string
mov esi, s
push 256
push esi
call [con_gets]
mov esi, s
push 256
push esi
call [con_gets]
; check for exit
test eax, eax
jz done
cmp byte [esi], 10
jz done
test eax, eax
jz done
cmp byte [esi], 10
jz done
; delete terminating '\n'
push esi
push esi
@@:
lodsb
test al, al
jnz @b
mov byte [esi-2], al
pop esi
lodsb
test al, al
jnz @b
mov byte [esi-2], al
pop esi
; resolve name
push esp ; reserve stack place
push esp ; fourth parameter
push 0 ; third parameter
push 0 ; second parameter
push esi ; first parameter
call [getaddrinfo]
pop esi
push esp ; reserve stack place
push esp ; fourth parameter
push 0 ; third parameter
push 0 ; second parameter
push esi ; first parameter
call [getaddrinfo]
pop esi
; test for error
test eax, eax
jnz fail
test eax, eax
jnz fail
; write results
push str2
call [con_write_asciiz]
mov edi, esi
push str2
call [con_write_asciiz]
mov edi, esi
addrloop:
; before all subsequent addresses print comma
cmp edi, esi
jz @f
push str3
call [con_write_asciiz]
cmp edi, esi
jz @f
push str3
call [con_write_asciiz]
@@:
; convert IP address to decimal notation
mov eax, [edi+addrinfo.ai_addr]
pushd [eax+sockaddr_in.sin_addr]
call [inet_ntoa]
mov eax, [edi+addrinfo.ai_addr]
pushd [eax+sockaddr_in.sin_addr]
call [inet_ntoa]
; write result
push eax
call [con_write_asciiz]
push eax
call [con_write_asciiz]
; advance to next item
mov edi, [edi+addrinfo.ai_next]
test edi, edi
jnz addrloop
mov edi, [edi+addrinfo.ai_next]
test edi, edi
jnz addrloop
; free allocated memory
push esi
call [freeaddrinfo]
push esi
call [freeaddrinfo]
; write newline and continue main loop
push str4
push str4
@@:
call [con_write_asciiz]
jmp main
call [con_write_asciiz]
jmp main
fail:
push str5
jmp @b
push str5
jmp @b
done:
push 1
call [con_exit]
push 1
call [con_exit]
exit:
mcall -1
mcall -1
; data
title db 'Names resolver',0
str1 db 'Host name to resolve: ',0
str2 db 'IP address(es): ',0
str3 db ', ',0
str4 db 10,0
str5 db 'Name resolution failed.',10,0
title db 'Names resolver',0
str1 db 'Host name to resolve: ',0
str2 db 'IP address(es): ',0
str3 db ', ',0
str4 db 10,0
str5 db 'Name resolution failed.',10,0
; import
align 4
@IMPORT:
library network, 'network.obj', console, 'console.obj'
import network, \
getaddrinfo, 'getaddrinfo', \
freeaddrinfo, 'freeaddrinfo', \
inet_ntoa, 'inet_ntoa'
import console, \
con_start, 'START', \
con_init, 'con_init', \
con_write_asciiz, 'con_write_asciiz', \
con_exit, 'con_exit', \
con_gets, 'con_gets'
import network, \
getaddrinfo, 'getaddrinfo', \
freeaddrinfo, 'freeaddrinfo', \
inet_ntoa, 'inet_ntoa'
import console, \
con_start, 'START', \
con_init, 'con_init', \
con_write_asciiz, 'con_write_asciiz', \
con_exit, 'con_exit', \
con_gets, 'con_gets'
i_end:
s rb 256
align 4
rb 4096 ; stack
s rb 256
align 4
rb 4096 ; stack
mem:

View File

@ -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 ;;
;; ;;
;; Synergyc.asm - Synergy client for KolibriOS ;;
@ -12,365 +12,373 @@
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
format binary as ""
use32
org 0x0
org 0x0
db 'MENUET01' ; signature
dd 1 ; header version
dd start ; entry point
dd i_end ; initialized size
dd mem ; required memory
dd mem ; stack pointer
dd 0 ; parameters
dd path ; path
db 'MENUET01' ; signature
dd 1 ; header version
dd start ; entry point
dd i_end ; initialized size
dd mem+0x1000 ; required memory
dd mem+0x1000 ; stack pointer
dd 0 ; parameters
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'
purge mov,add,sub
include '../debug-fdo.inc'
include '../proc32.inc'
include '../dll.inc'
include '../network.inc'
start:
cld
mov edi, path ; Calculate the length of zero-terminated string
xor al , al
mov ecx, 1024
repne scasb
dec edi
mov esi, filename
movsd
movsb
cld
mov edi, path ; Calculate the length of zero-terminated string
xor al, al
mov ecx, 1024
repne scasb
dec edi
mov esi, filename ; append the path with '.ini'
movsd
movsb
mcall 68, 11
mcall 68, 11
stdcall dll.Load, @IMPORT
test eax, eax
jnz exit
stdcall dll.Load, @IMPORT
test eax, eax
jnz exit
push 1
call [con_start]
push 1
call [con_start]
push title
push 25
push 80
push 25
push 80
call [con_init]
push title
push 25
push 80
push 25
push 80
call [con_init]
push path
call [con_write_asciiz]
push path
call [con_write_asciiz]
push newline
call [con_write_asciiz]
push newline
call [con_write_asciiz]
push newline
call [con_write_asciiz]
push newline
call [con_write_asciiz]
invoke ini.get_str, path, str_remote, str_ip, buffer_ptr, 16, 0
test eax, eax
jnz error
invoke ini.get_str, path, str_remote, str_ip, buffer_ptr, 16, 0
test eax, eax
jnz error
invoke ini.get_int, path, str_remote, str_port, 24800
mov [sockaddr1.port], ax
invoke ini.get_int, path, str_remote, str_port, 24800
mov [sockaddr1.port], ax
push str1
call [con_write_asciiz]
push str1
call [con_write_asciiz]
push buffer_ptr
call [con_write_asciiz]
push buffer_ptr
call [con_write_asciiz]
push newline
call [con_write_asciiz]
push newline
call [con_write_asciiz]
mcall socket, AF_INET4, SOCK_STREAM, 0
cmp eax, -1
je error
mcall socket, AF_INET4, SOCK_STREAM, 0
cmp eax, -1
je error
mov [socketnum], eax
mov [socketnum], eax
push buffer_ptr ; hostname
call [inet_addr]
cmp eax, -1
je error
mov [sockaddr1.ip], eax
push buffer_ptr ; hostname
call [inet_addr]
cmp eax, -1
je error
mov [sockaddr1.ip], eax
mcall connect, [socketnum], sockaddr1, 18
mcall connect, [socketnum], sockaddr1, 18
push str7
call [con_write_asciiz]
push str7
call [con_write_asciiz]
mcall 40, 1 shl 7; + 7
mcall 40, 1 shl 7; + 7
login:
call wait_for_data
call wait_for_data
push buffer_ptr + 4
call [con_write_asciiz]
push buffer_ptr + 4
call [con_write_asciiz]
cmp dword [buffer_ptr], 11 shl 24
jne login
cmp dword [buffer_ptr + 4], 'Syne'
jne login
cmp word [buffer_ptr + 8], 'rg'
jne login
cmp byte [buffer_ptr + 10], 'y'
jne login
cmp dword [buffer_ptr], 11 shl 24
jne login
cmp dword [buffer_ptr + 4], 'Syne'
jne login
cmp word [buffer_ptr + 8], 'rg'
jne login
cmp byte [buffer_ptr + 10], 'y'
jne login
push str2
call [con_write_asciiz]
push str2
call [con_write_asciiz]
lea edi, [buffer_ptr + 11 + 4 + 4]
invoke ini.get_str, path, str_local, str_name, edi, 255, 0
xor al , al
mov ecx, 256
repne scasb
sub edi, buffer_ptr + 1 + 4
mov esi, edi
bswap edi
mov dword [buffer_ptr], edi
mov edi, esi
sub edi, 11 + 4
bswap edi
mov dword [buffer_ptr + 11 + 4], edi
add esi, 4
lea edi, [buffer_ptr + 11 + 4 + 4]
invoke ini.get_str, path, str_local, str_name, edi, 255, 0
xor al , al
mov ecx, 256
repne scasb
sub edi, buffer_ptr + 1 + 4
mov esi, edi
bswap edi
mov dword [buffer_ptr], edi
mov edi, esi
sub edi, 11 + 4
bswap edi
mov dword [buffer_ptr + 11 + 4], edi
add esi, 4
mcall send, [socketnum], buffer_ptr, , 0
mcall send, [socketnum], buffer_ptr, , 0
mainloop:
call wait_for_data
mov edi, buffer_ptr
call wait_for_data
mov edi, buffer_ptr
.command:
push eax edi
push eax edi
cmp dword [edi + 4], 'QINF' ; query screen info
je .qinf
cmp dword [edi + 4], 'QINF' ; query screen info
je .qinf
cmp dword [edi + 4], 'CALV' ; alive ?
je .calv
cmp dword [edi + 4], 'CALV' ; alive ?
je .calv
cmp dword [edi + 4], 'CINN' ; mouse moved into screen
je .cinn
cmp dword [edi + 4], 'CINN' ; mouse moved into screen
je .cinn
cmp dword [edi + 4], 'DCLP' ; Clipboard event
je .dclp
cmp dword [edi + 4], 'DCLP' ; Clipboard event
je .dclp
cmp dword [edi + 4], 'DMMV' ; Mouse moved
je .dmmv
cmp dword [edi + 4], 'DMMV' ; Mouse moved
je .dmmv
cmp dword [edi + 4], 'COUT' ; leave screen
je .cout
cmp dword [edi + 4], 'COUT' ; leave screen
je .cout
cmp dword [edi + 4], 'DMDN' ; mouse button down
je .dmdn
cmp dword [edi + 4], 'DMDN' ; mouse button down
je .dmdn
cmp dword [edi + 4], 'DMUP' ; mouse button released
je .dmup
cmp dword [edi + 4], 'DMUP' ; mouse button released
je .dmup
cmp dword [edi + 4], 'CNOP' ; no operation
je .next
cmp dword [edi + 4], 'CNOP' ; no operation
je .next
cmp dword [edi + 4], 'CIAK' ; resolution changed?
je .ciak
cmp dword [edi + 4], 'CIAK' ; resolution changed?
je .ciak
push str3
call [con_write_asciiz]
push str3
call [con_write_asciiz]
mov byte[edi+8],0
add edi, 4
push edi
call [con_write_asciiz]
mov byte[edi+8],0
add edi, 4
push edi
call [con_write_asciiz]
push newline
call [con_write_asciiz]
push newline
call [con_write_asciiz]
.next:
pop edi eax
pop edi eax
mov ecx, dword [edi]
bswap ecx
add ecx, 4
sub eax, ecx
jle mainloop
add edi, ecx
jmp .command
mov ecx, dword [edi]
bswap ecx
add ecx, 4
sub eax, ecx
jle mainloop
add edi, ecx
jmp .command
.qinf:
mcall 14 ; get screen info
add eax, 0x00010001
bswap eax
mov dword [screeninfo.size], eax
mcall send, [socketnum], screeninfo, screeninfo.length, 0 ; send client name
jmp .next
mcall 14 ; get screen info
add eax, 0x00010001
bswap eax
mov dword [screeninfo.size], eax
mcall send, [socketnum], screeninfo, screeninfo.length, 0 ; send client name
jmp .next
.calv:
mcall send, [socketnum], calv, calv.length, 0 ; looks like ping-pong event
jmp .next
mcall send, [socketnum], calv, calv.length, 0 ; looks like ping-pong event
jmp .next
.cinn:
mov edx, [edi + 8]
bswap edx
mcall 18, 19, 4
; ignore sequence number and modify key mask for now
push str6
call [con_write_asciiz]
jmp .next
mov edx, [edi + 8]
bswap edx
mcall 18, 19, 4
; ignore sequence number and modify key mask for now
push str6
call [con_write_asciiz]
jmp .next
.dclp:
jmp .next
jmp .next
.dmmv:
mov edx, [edi + 8]
bswap edx
mcall 18, 19, 4
mcall send, [socketnum], cnop, cnop.length, 0 ; reply with NOP
push str4
call [con_write_asciiz]
jmp .next
mov edx, [edi + 8]
bswap edx
mcall 18, 19, 4
mcall send, [socketnum], cnop, cnop.length, 0 ; reply with NOP
push str4
call [con_write_asciiz]
jmp .next
.cout:
jmp .next
jmp .next
.dmdn:
movzx eax, byte [edi + 8]
or [mousestate], eax
mcall 18, 19, 5, [mousestate]
mcall send, [socketnum], cnop, cnop.length, 0 ; reply with NOP
push str5
call [con_write_asciiz]
jmp .next
movzx eax, byte [edi + 8]
or [mousestate], eax
mcall 18, 19, 5, [mousestate]
mcall send, [socketnum], cnop, cnop.length, 0 ; reply with NOP
push str5
call [con_write_asciiz]
jmp .next
.dmup:
movzx eax, byte [edi + 8]
not eax
and [mousestate], eax
mcall 18, 19, 5, [mousestate]
mcall send, [socketnum], cnop, cnop.length, 0 ; reply with NOP
push str5
call [con_write_asciiz]
jmp .next
movzx eax, byte [edi + 8]
not eax
and [mousestate], eax
mcall 18, 19, 5, [mousestate]
mcall send, [socketnum], cnop, cnop.length, 0 ; reply with NOP
push str5
call [con_write_asciiz]
jmp .next
.ciak:
jmp .next
jmp .next
error:
push str_err
call [con_write_asciiz]
push str_err
call [con_write_asciiz]
call [con_gets]
call [con_gets]
push 1
call [con_exit]
push 1
call [con_exit]
mcall close, [socketnum]
mcall close, [socketnum]
exit:
mcall -1
mcall -1
wait_for_data:
mcall 10 ; wait for data
mcall 10 ; wait for data
mcall recv, [socketnum], buffer_ptr, BUFFERSIZE, 0
cmp eax, -1
je wait_for_data
mcall recv, [socketnum], buffer_ptr, BUFFERSIZE, 0
cmp eax, -1
je wait_for_data
cmp eax, 8
jl wait_for_data
cmp eax, 8
jl wait_for_data
ret
ret
; data
title db 'Synergy client',0
str1 db 'Connecting to: ',0
str7 db 'Connected!',13,10,0
str2 db 13,10,'Handshake received',13,10,0
str3 db 'Unsupported command: ',0
newline db 13,10,0
str4 db 'mouse moved',13,10,0
str5 db 'mouse buttons changed',13,10,0
str6 db 'Enter screen',13,10,0
str_err db 'Error occured !',13,10,'Press any key to quit',0
title db 'Synergy client',0
str1 db 'Connecting to: ',0
str7 db 'Connected!',13,10,0
str2 db 13,10,'Handshake received',13,10,0
str3 db 'Unsupported command: ',0
newline db 13,10,0
str4 db 'mouse moved',13,10,0
str5 db 'mouse buttons changed',13,10,0
str6 db 'Enter screen',13,10,0
str_err db 'Error occured !',13,10,'Press any key to quit',0
screeninfo:
dd (screeninfo.length - 4) shl 24
db 'DINF'
dw 0 ; coordinate of leftmost pixel
dw 0 ; coordiante of topmost pixel
dd (screeninfo.length - 4) shl 24
db 'DINF'
dw 0 ; coordinate of leftmost pixel
dw 0 ; coordiante of topmost pixel
.size:
dw 0 ; width
dw 0 ; height
dw 0 ; width
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 0xbcfb ; y position of the mouse on the secondary screen
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
.length = $ - screeninfo
calv:
dd (4) shl 24
db 'CALV'
dd (4) shl 24
db 'CALV'
.length = $ - calv + 8 ; also send cnop
cnop:
dd (4) shl 24
db 'CNOP'
dd (4) shl 24
db 'CNOP'
.length = $ - cnop
mousestate dd 0
mousestate dd 0
sockaddr1:
dw AF_INET4
.port dw 24800
.ip dd 192 + 168 shl 8 + 1 shl 16 + 115 shl 24
rb 10
dw AF_INET4
.port dw 24800
.ip dd 192 + 168 shl 8 + 1 shl 16 + 115 shl 24
rb 10
filename db '.ini', 0
str_local db 'local', 0
str_name db 'name', 0
str_remote db 'remote', 0
str_port db 'port', 0
str_ip db 'ip', 0
filename db '.ini', 0
str_local db 'local', 0
str_name db 'name', 0
str_remote db 'remote', 0
str_port db 'port', 0
str_ip db 'ip', 0
; import
align 16
@IMPORT:
library console, 'console.obj',\
libini, 'libini.obj',\
network, 'network.obj'
library console, 'console.obj',\
network, 'network.obj',\
libini, 'libini.obj'
import network,\
inet_addr, 'inet_addr'
import network,\
inet_addr, 'inet_addr'
import console, \
con_start, 'START',\
con_init, 'con_init',\
con_write_asciiz, 'con_write_asciiz',\
con_exit, 'con_exit',\
con_gets, 'con_gets',\
con_cls, 'con_cls',\
con_getch2, 'con_getch2',\
con_set_cursor_pos, 'con_set_cursor_pos'
import console, \
con_start, 'START',\
con_init, 'con_init',\
con_write_asciiz, 'con_write_asciiz',\
con_exit, 'con_exit',\
con_gets, 'con_gets',\
con_cls, 'con_cls',\
con_getch2, 'con_getch2',\
con_set_cursor_pos, 'con_set_cursor_pos'
import libini,\
ini.get_str, 'ini_get_str',\
ini.get_int, 'ini_get_int'
import libini,\
ini.get_str, 'ini_get_str',\
ini.get_int, 'ini_get_int'
align 4
include_debug_strings
align 4
i_end:
socketnum dd ?
buffer_ptr rb BUFFERSIZE
path rb 4096 ; stack
socketnum dd ?
buffer_ptr rb BUFFERSIZE
path rb 4096 ; stack
mem:

View File

@ -1,3 +1,5 @@
format binary as ""
use32
; standard header
db 'MENUET01' ; signature

View File

@ -1,3 +1,5 @@
format binary as ""
use32
; standard header
db 'MENUET01' ; signature