forked from KolibriOS/kolibrios
Deleted old network programs that have been replaced.
git-svn-id: svn://kolibrios.org@4151 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
98812b6173
commit
659d2fcc62
File diff suppressed because it is too large
Load Diff
@ -1,5 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix en >lang.inc
|
||||
@fasm airc.asm airc
|
||||
@erase lang.inc
|
||||
@pause
|
@ -1,5 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix ru >lang.inc
|
||||
@fasm airc.asm airc
|
||||
@erase lang.inc
|
||||
@pause
|
@ -1,670 +0,0 @@
|
||||
;
|
||||
; ETH.INC
|
||||
;
|
||||
; made by hidnplayr (hidnplayr@gmail.com) for KolibriOS and DEX4U
|
||||
;
|
||||
; The given code before every macro is only a simple example
|
||||
;
|
||||
; Change the OS value to DEX4U or MEOS
|
||||
;
|
||||
; HISTORY
|
||||
;
|
||||
; v1.0: 18 august 2006
|
||||
;
|
||||
|
||||
MEOS equ 1 ; Dont change these !
|
||||
DEX4U equ 2 ;
|
||||
|
||||
OS equ MEOS ; Change these instead ;)
|
||||
TIMEOUT equ 60 ; timeout for DNS request
|
||||
BUFFER equ 512 ; Buffer size for DNS
|
||||
|
||||
macro int1 {
|
||||
if OS eq MEOS
|
||||
mcall
|
||||
else if OS eq DEX4U
|
||||
int 0x52
|
||||
end if
|
||||
}
|
||||
|
||||
macro int2 {
|
||||
if OS eq MEOS
|
||||
mcall
|
||||
else if OS eq DEX4U
|
||||
int 0x53
|
||||
end if
|
||||
}
|
||||
|
||||
macro mov arg1,arg2 {
|
||||
|
||||
if arg1 eq arg2
|
||||
else
|
||||
mov arg1,arg2
|
||||
end if
|
||||
|
||||
}
|
||||
|
||||
; eth.get_IP eax
|
||||
;
|
||||
; gets the current IP that is defined in Stack (return in eax in this example)
|
||||
macro eth.get_IP IP {
|
||||
if OS eq MEOS
|
||||
mov eax,52
|
||||
end if
|
||||
mov ebx,1
|
||||
int1
|
||||
|
||||
mov IP ,eax
|
||||
}
|
||||
|
||||
; eth.get_GATEWAY eax
|
||||
;
|
||||
; gets the current GATEWAY that is defined in Stack (return in eax in this example)
|
||||
macro eth.get_GATEWAY GATEWAY {
|
||||
if OS eq MEOS
|
||||
mov eax,52
|
||||
end if
|
||||
mov ebx,9
|
||||
int1
|
||||
move GATEWAY ,eax
|
||||
}
|
||||
|
||||
; eth.get_SUBNET eax
|
||||
;
|
||||
; gets the current SUBNET that is defined in Stack (return in eax in this example)
|
||||
macro eth.get_SUBNET SUBNET {
|
||||
if OS eq MEOS
|
||||
mov eax,52
|
||||
end if
|
||||
mov ebx,10
|
||||
int1
|
||||
mov SUBNET ,eax
|
||||
}
|
||||
|
||||
; eth.get_DNS eax
|
||||
;
|
||||
; gets the current DNS that is defined in Stack (return in eax in this example)
|
||||
macro eth.get_DNS DNS {
|
||||
if OS eq MEOS
|
||||
mov eax,52
|
||||
end if
|
||||
mov ebx,13
|
||||
int1
|
||||
mov DNS ,eax
|
||||
}
|
||||
|
||||
; eth.set_IP eax
|
||||
;
|
||||
; set a new IP in stack (input in eax in this example)
|
||||
macro eth.set_IP IP {
|
||||
mov ecx,IP
|
||||
if OS eq MEOS
|
||||
mov eax,52
|
||||
end if
|
||||
mov ebx,3
|
||||
int1
|
||||
}
|
||||
|
||||
; eth.set_GATEWAY eax
|
||||
;
|
||||
; set a new GATEWAY in stack (input in eax in this example)
|
||||
macro eth.set_GATEWAY GATEWAY {
|
||||
mov ecx,GATEWAY
|
||||
if OS eq MEOS
|
||||
mov eax,52
|
||||
end if
|
||||
mov ebx,11
|
||||
int1
|
||||
}
|
||||
|
||||
; eth.set_SUBNET eax
|
||||
;
|
||||
; set a new SUBNET in stack (input in eax in this example)
|
||||
macro eth.set_SUBNET SUBNET {
|
||||
mov ecx,SUBNET
|
||||
if OS eq MEOS
|
||||
mov eax,52
|
||||
end if
|
||||
mov ebx,12
|
||||
int1
|
||||
}
|
||||
|
||||
; eth.set_DNS eax
|
||||
;
|
||||
; set a new DNS in stack (input in eax in this example)
|
||||
macro eth.set_DNS DNS {
|
||||
mov ecx,DNS
|
||||
if OS eq MEOS
|
||||
mov eax,52
|
||||
end if
|
||||
mov ebx,14
|
||||
int1
|
||||
}
|
||||
|
||||
; eth.open eax,80,ebx,[socket]
|
||||
;
|
||||
; open a socket on local port in eax to port 80 on server on ebx
|
||||
; the socketnumber will be returned in [socket] (dword)
|
||||
macro eth.open local,remote,ip,socket {
|
||||
mov ecx, local
|
||||
mov edx, remote
|
||||
mov esi, ip
|
||||
if OS eq MEOS
|
||||
mov eax,53
|
||||
end if
|
||||
mov ebx, 0
|
||||
int2
|
||||
|
||||
mov socket,eax
|
||||
}
|
||||
|
||||
; eth.close [socket]
|
||||
;
|
||||
; closes socket on socketnumber [socket]
|
||||
macro eth.close socket {
|
||||
mov ecx, socket
|
||||
if OS eq MEOS
|
||||
mov eax,53
|
||||
end if
|
||||
mov ebx, 1
|
||||
int2
|
||||
}
|
||||
|
||||
; eth.poll [socket],eax
|
||||
;
|
||||
; polls [socket] for data
|
||||
; eax = 0 when there is data
|
||||
macro eth.poll socket,result {
|
||||
mov ecx, socket
|
||||
if OS eq MEOS
|
||||
mov eax,53
|
||||
end if
|
||||
mov ebx, 2
|
||||
int2
|
||||
|
||||
mov result, eax
|
||||
}
|
||||
|
||||
; eth.read_byte [socket], bl
|
||||
;
|
||||
; reads a byte from the socket and returns in bl
|
||||
macro eth.read_byte socket, result {
|
||||
mov ecx, socket
|
||||
if OS eq MEOS
|
||||
mov eax,53
|
||||
end if
|
||||
mov ebx, 3
|
||||
int2
|
||||
|
||||
mov result,bl
|
||||
}
|
||||
|
||||
; eth.write [socket],12,msg
|
||||
; msg db 'hello world!'
|
||||
;
|
||||
; send message msg to socket
|
||||
macro eth.write socket,length,msg {
|
||||
mov ecx, socket
|
||||
mov edx, length
|
||||
mov esi, msg
|
||||
if OS eq MEOS
|
||||
mov eax,53
|
||||
end if
|
||||
mov ebx, 4
|
||||
int2
|
||||
}
|
||||
|
||||
; eth.open_tcp 80,80,eax,0,[socket]
|
||||
;
|
||||
; opens a tcp socket on port 80 to port 80 on IP eax with passive open
|
||||
; returns socket number in eax
|
||||
macro eth.open_tcp local,remote,ip,passive,socket {
|
||||
|
||||
pusha
|
||||
mov ecx, local
|
||||
mov edx, remote
|
||||
mov esi, ip
|
||||
mov edi, passive ; 0 = PASSIVE open
|
||||
if OS eq MEOS
|
||||
mov eax,53
|
||||
end if
|
||||
mov ebx, 5
|
||||
int2
|
||||
popa
|
||||
|
||||
mov socket,eax
|
||||
}
|
||||
|
||||
; eth.socket_status [socket],eax
|
||||
;
|
||||
; returns socket status in eax
|
||||
macro eth.socket_status socket,result {
|
||||
mov ecx, socket
|
||||
if OS eq MEOS
|
||||
mov eax,53
|
||||
end if
|
||||
mov ebx, 6
|
||||
int2
|
||||
|
||||
mov result,eax
|
||||
}
|
||||
|
||||
; eth.write_tcp [socket],12,msg
|
||||
;
|
||||
; msg db 'hello world!'
|
||||
;
|
||||
; send message to TCP socket
|
||||
macro eth.write_tcp socket,length,msg {
|
||||
mov ecx, socket
|
||||
mov edx, length
|
||||
mov esi, msg
|
||||
if OS eq MEOS
|
||||
mov eax,53
|
||||
end if
|
||||
mov ebx, 7
|
||||
int2
|
||||
}
|
||||
|
||||
; eth.close_tcp [socket]
|
||||
;
|
||||
; closes tcp socket [socket]
|
||||
macro eth.close_tcp socket {
|
||||
mov ecx, socket
|
||||
if OS eq MEOS
|
||||
mov eax,53
|
||||
end if
|
||||
mov ebx, 8
|
||||
int2
|
||||
}
|
||||
|
||||
; eth.check_port 165,eax
|
||||
;
|
||||
; checks if port 165 is used
|
||||
; return is 0 when port is free
|
||||
macro eth.check_port port,result {
|
||||
if OS eq MEOS
|
||||
mov eax,53
|
||||
end if
|
||||
mov ebx, 9
|
||||
mov ecx, port
|
||||
int2
|
||||
|
||||
mov result,eax
|
||||
}
|
||||
|
||||
; eth.status eax
|
||||
;
|
||||
; returns socket status in eax
|
||||
macro eth.status status {
|
||||
if OS eq MEOS
|
||||
mov eax,53
|
||||
end if
|
||||
mov ebx, 255
|
||||
mov ecx, 6
|
||||
int2
|
||||
|
||||
mov status,eax
|
||||
}
|
||||
|
||||
; eth.search 165,edx
|
||||
;
|
||||
; searches a free local port starting from 166 (165 + 1 !)
|
||||
; returns in edx
|
||||
macro eth.search_port port,result {
|
||||
mov edx,port
|
||||
@@:
|
||||
inc edx
|
||||
eth.check_port edx,eax
|
||||
cmp eax,0
|
||||
je @r
|
||||
mov result,edx
|
||||
}
|
||||
|
||||
; eth.read_data [socket],buffer,512
|
||||
; buffer rb 512
|
||||
; socket dd ?
|
||||
;
|
||||
; reads data from socket into a buffer, stops when there is no more data or buffer is full.
|
||||
macro eth.read_data socket,dest,endptr,bufferl {
|
||||
|
||||
mov eax, dest
|
||||
mov endptr, eax
|
||||
|
||||
; we have data - this will be the response
|
||||
@@:
|
||||
mov eax,endptr
|
||||
cmp eax,bufferl
|
||||
jg @f
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 3
|
||||
mov ecx, socket
|
||||
mcall ; read byte - block (high byte)
|
||||
|
||||
; Store the data in the response buffer
|
||||
mov eax, endptr
|
||||
mov [eax], bl
|
||||
inc dword endptr
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 2
|
||||
mov ecx, socket
|
||||
mcall ; any more data?
|
||||
|
||||
cmp eax, 0
|
||||
jne @r ; yes, so get it
|
||||
@@:
|
||||
|
||||
}
|
||||
|
||||
; eth.wait_for_data [socket],60,abort
|
||||
; eth.read_data ....
|
||||
; abort:
|
||||
;
|
||||
; Waits for data with timeout
|
||||
|
||||
macro eth.wait_for_data socket,TIMEOUT,abort {
|
||||
|
||||
mov edx,TIMEOUT
|
||||
|
||||
@@:
|
||||
eth.poll socket,eax
|
||||
|
||||
cmp eax,0
|
||||
jne @f
|
||||
|
||||
dec edx
|
||||
jz abort
|
||||
|
||||
if OS eq MEOS
|
||||
mov eax,5 ; wait here for event
|
||||
mov ebx,100
|
||||
mcall
|
||||
else if OS eq DEX4U
|
||||
mov ax,18
|
||||
call [SetDelay]
|
||||
call dword[stack_handler]
|
||||
end if
|
||||
|
||||
jmp @r
|
||||
@@:
|
||||
|
||||
}
|
||||
|
||||
|
||||
; The function 'resolve' resolves the address in edx and puts the resulting IP in eax.
|
||||
; When the input is an IP-adress, the function will output this IP in eax.
|
||||
; If something goes wrong, the result in eax should be 0
|
||||
;
|
||||
; example:
|
||||
;
|
||||
; resolve query1,IP
|
||||
; resolve '192.168.0.1',IP
|
||||
; resolve query2,IP
|
||||
;
|
||||
; query1 db 'www.google.com',0
|
||||
; query2 db '49.78.84.45',0
|
||||
; IP dd ?
|
||||
|
||||
macro resolve query,result {
|
||||
|
||||
if query eqtype 0
|
||||
mov edx,query
|
||||
else
|
||||
local ..string, ..label
|
||||
jmp ..label
|
||||
..string db query,0
|
||||
..label:
|
||||
mov edx,..string
|
||||
end if
|
||||
|
||||
call __resolve
|
||||
|
||||
mov result,eax
|
||||
|
||||
}
|
||||
|
||||
if used __resolve
|
||||
|
||||
__resolve:
|
||||
|
||||
;DEBUGF 1,'Resolving started\n'
|
||||
|
||||
|
||||
; This code validates if the query is an IP containing 4 numbers and 3 dots
|
||||
|
||||
|
||||
push edx ; push edx (query address) onto stack
|
||||
xor al, al ; make al (dot count) zero
|
||||
|
||||
@@:
|
||||
cmp byte[edx],'0' ; check if this byte is a number, if not jump to no_IP
|
||||
jl no_IP ;
|
||||
cmp byte[edx],'9' ;
|
||||
jg no_IP ;
|
||||
|
||||
inc edx ; the byte was a number, so lets check the next byte
|
||||
|
||||
cmp byte[edx],0 ; is this byte zero? (have we reached end of query?)
|
||||
jz @f ; jump to next @@ then
|
||||
|
||||
cmp byte[edx],'.' ; is this byte a dot?
|
||||
jne @r ; if not, jump to previous @@
|
||||
|
||||
inc al ; the byte was a dot so increment al(dot count)
|
||||
inc edx ; next byte
|
||||
jmp @r ; lets check for numbers again (jump to previous @@)
|
||||
|
||||
@@: ; we reach this when end of query reached
|
||||
cmp al,3 ; check if there where 3 dots
|
||||
jnz no_IP ; if not, jump to no_IP (this is where the DNS will take over)
|
||||
|
||||
; The following code should convert this IP into a dword and output it in eax
|
||||
|
||||
pop esi ; edx (query address) was pushed onto stack and is now popped in esi
|
||||
|
||||
xor edx, edx ; result
|
||||
xor eax, eax ; current character
|
||||
xor ebx, ebx ; current byte
|
||||
|
||||
.outer_loop:
|
||||
shl edx, 8
|
||||
add edx, ebx
|
||||
xor ebx, ebx
|
||||
.inner_loop:
|
||||
lodsb
|
||||
test eax, eax
|
||||
jz .finish
|
||||
cmp al, '.'
|
||||
jz .outer_loop
|
||||
sub eax, '0'
|
||||
imul ebx, 10
|
||||
add ebx, eax
|
||||
jmp .inner_loop
|
||||
.finish:
|
||||
shl edx, 8
|
||||
add edx, ebx
|
||||
|
||||
bswap edx
|
||||
mov eax, edx
|
||||
|
||||
;DEBUGF 1,'The query was an IP: %x.%x.%x.%x\n',dh,dl,al,ah
|
||||
|
||||
ret
|
||||
|
||||
|
||||
no_IP:
|
||||
|
||||
pop edx
|
||||
|
||||
; The query is not an IP address, we will send the query to a DNS server and hope for answer ;)
|
||||
|
||||
;DEBUGF 1,'The query is no ip, Building request string from:%u\n',edx
|
||||
|
||||
; Build the request string
|
||||
mov eax, 0x00010100
|
||||
mov [dnsMsg], eax
|
||||
mov eax, 0x00000100
|
||||
mov [dnsMsg+4], eax
|
||||
mov eax, 0x00000000
|
||||
mov [dnsMsg+8], eax
|
||||
|
||||
; domain name goes in at dnsMsg+12
|
||||
mov esi, dnsMsg + 12 ; location of label length
|
||||
mov edi, dnsMsg + 13 ; label start
|
||||
mov ecx, 12 ; total string length so far
|
||||
|
||||
td002:
|
||||
mov [esi], byte 0
|
||||
inc ecx
|
||||
|
||||
td0021:
|
||||
mov al, [edx]
|
||||
|
||||
cmp al, 0
|
||||
je td001 ; we have finished the string translation
|
||||
|
||||
cmp al, '.'
|
||||
je td004 ; we have finished the label
|
||||
|
||||
inc byte [esi]
|
||||
inc ecx
|
||||
mov [edi], al
|
||||
inc edi
|
||||
inc edx
|
||||
jmp td0021
|
||||
|
||||
td004:
|
||||
mov esi, edi
|
||||
inc edi
|
||||
inc edx
|
||||
jmp td002
|
||||
|
||||
; write label len + label text
|
||||
td001:
|
||||
mov [edi], byte 0
|
||||
inc ecx
|
||||
inc edi
|
||||
mov [edi], dword 0x01000100
|
||||
add ecx, 4
|
||||
|
||||
mov [dnsMsgLen], ecx ; We'll need the length of the message when we send it
|
||||
; Now, lets send this and wait for an answer
|
||||
|
||||
eth.search_port 1024,edx ; Find a free port starting from 1025 and store in edx
|
||||
eth.get_DNS esi ; Read DNS IP from stack into esi
|
||||
eth.open edx,53,esi,[socketNum] ; First, open socket
|
||||
; DEBUGF 1,'Socket opened: %u (port %u)\n',[socketNum],ecx
|
||||
eth.write [socketNum],[dnsMsgLen],dnsMsg ; Write to socket ( request DNS lookup )
|
||||
; DEBUGF 1,'Data written, length:%u offset:%u\n',[dnsMsgLen],dnsMsg
|
||||
; DEBUGF 1,'Waiting for data: (timeout is %us)\n',TIMEOUT
|
||||
eth.wait_for_data [socketNum],TIMEOUT,no_data; Now, we wait for data from remote
|
||||
eth.read_data [socketNum],dnsMsg,[dnsMsgLen],dnsMsg+BUFFER ; Read the data into the buffer
|
||||
; DEBUGF 1,'Data received, offset:%u buffer size:%u length:%u\n',dnsMsg,BUFFER,esi-dnsMsg
|
||||
eth.close [socketNum] ; We're done, close the socket
|
||||
; DEBUGF 1,'Closed Socket\n'
|
||||
|
||||
; Now parse the message to get the host IP. Man, this is complicated. It's described in RFC 1035
|
||||
; 1) Validate that we have an answer with > 0 responses
|
||||
; 2) Find the answer record with TYPE 0001 ( host IP )
|
||||
; 3) Finally, copy the IP address to the display
|
||||
; Note: The response is in dnsMsg, the end of the buffer is pointed to by [dnsMsgLen]
|
||||
|
||||
mov esi, dnsMsg
|
||||
|
||||
mov al, [esi+2] ; Is this a response to my question?
|
||||
and al, 0x80
|
||||
cmp al, 0x80
|
||||
jne abort
|
||||
|
||||
;DEBUGF 1,'It was a response to my question\n'
|
||||
|
||||
mov al, [esi+3] ; Were there any errors?
|
||||
and al, 0x0F
|
||||
cmp al, 0x00
|
||||
jne abort
|
||||
|
||||
;DEBUGF 1,'There were no errorst\n'
|
||||
|
||||
mov ax, [esi+6] ; Is there ( at least 1 ) answer?
|
||||
cmp ax, 0x00
|
||||
je abort
|
||||
|
||||
; Header validated. Scan through and get my answer
|
||||
add esi, 12 ; Skip to the question field
|
||||
call skipName ; Skip through the question field
|
||||
add esi, 4 ; skip past the questions qtype, qclass
|
||||
|
||||
ctr002z:
|
||||
; Now at the answer. There may be several answers, find the right one ( TYPE = 0x0001 )
|
||||
call skipName
|
||||
mov ax, [esi]
|
||||
cmp ax, 0x0100 ; Is this the IP address answer?
|
||||
jne ctr002c
|
||||
add esi, 10 ; Yes! Point eax to the first byte of the IP address
|
||||
mov eax,[esi]
|
||||
|
||||
;DEBUGF 1,'Found First Byte of IP\n'
|
||||
|
||||
ret
|
||||
|
||||
|
||||
ctr002c: ; Skip through the answer, move to the next
|
||||
add esi, 8
|
||||
movzx eax, byte [esi+1]
|
||||
mov ah, [esi]
|
||||
add esi, eax
|
||||
add esi, 2
|
||||
|
||||
cmp esi, [dnsMsgLen] ; Have we reached the end of the msg? This is an error condition, should not happen
|
||||
jl ctr002z ; Check next answer
|
||||
|
||||
abort:
|
||||
;DEBUGF 1,'Something went wrong, aborting\n'
|
||||
xor eax,eax
|
||||
|
||||
ret
|
||||
|
||||
|
||||
skipName:
|
||||
; Increment esi to the first byte past the name field
|
||||
; Names may use compressed labels. Normally do.
|
||||
; RFC 1035 page 30 gives details
|
||||
mov al, [esi]
|
||||
cmp al, 0
|
||||
je sn_exit
|
||||
and al, 0xc0
|
||||
cmp al, 0xc0
|
||||
je sn001
|
||||
|
||||
movzx eax, byte [esi]
|
||||
inc eax
|
||||
add esi, eax
|
||||
jmp skipName
|
||||
|
||||
sn001:
|
||||
add esi, 2 ; A pointer is always at the end
|
||||
ret
|
||||
|
||||
sn_exit:
|
||||
inc esi
|
||||
ret
|
||||
|
||||
no_data:
|
||||
eth.close [socketNum]
|
||||
xor eax,eax
|
||||
|
||||
ret
|
||||
|
||||
dnsMsgLen: dd 0
|
||||
socketNum: dd 0xFFFF
|
||||
|
||||
if ~defined dnsMsg
|
||||
dnsMsg: rb BUFFER
|
||||
end if
|
||||
|
||||
end if
|
||||
|
||||
|
||||
|
||||
|
@ -1,343 +0,0 @@
|
||||
;
|
||||
; Formatted Debug Output (FDO)
|
||||
; Copyright (c) 2005-2006, mike.dld
|
||||
; Created: 2005-01-29, Changed: 2006-07-20
|
||||
;
|
||||
; For questions and bug reports, mail to mike.dld@gmail.com
|
||||
;
|
||||
; Available format specifiers are: %s, %d, %u, %x (with partial width support)
|
||||
;
|
||||
|
||||
; to be defined:
|
||||
; __DEBUG__ equ 1
|
||||
; __DEBUG_LEVEL__ equ 5
|
||||
|
||||
macro debug_func name {
|
||||
if used name
|
||||
name@of@func equ name
|
||||
}
|
||||
|
||||
macro debug_beginf {
|
||||
align 4
|
||||
name@of@func:
|
||||
}
|
||||
|
||||
debug_endf fix end if
|
||||
|
||||
macro DEBUGS _sign,[_str] {
|
||||
common
|
||||
pushf
|
||||
pushad
|
||||
local ..str,..label,is_str
|
||||
is_str = 0
|
||||
forward
|
||||
if _str eqtype ''
|
||||
is_str = 1
|
||||
end if
|
||||
common
|
||||
if is_str = 1
|
||||
jmp ..label
|
||||
..str db _str,0
|
||||
..label:
|
||||
add esp,4*8+4
|
||||
mov edx,..str
|
||||
sub esp,4*8+4
|
||||
call fdo_debug_outstr
|
||||
else
|
||||
mov edx,_str
|
||||
call fdo_debug_outstr
|
||||
end if
|
||||
popad
|
||||
popf
|
||||
}
|
||||
|
||||
macro DEBUGD _sign,_dec {
|
||||
pushf
|
||||
pushad
|
||||
if _dec eqtype eax
|
||||
if _dec in <ebx,ecx,edx,esi,edi,ebp,esp>
|
||||
mov eax,_dec
|
||||
else if ~_dec eq eax
|
||||
if _sign = 1
|
||||
movsx eax,_dec
|
||||
else
|
||||
movzx eax,_dec
|
||||
end if
|
||||
end if
|
||||
else if _dec eqtype 0
|
||||
mov eax,_dec
|
||||
else
|
||||
add esp,4*8+4
|
||||
local tp
|
||||
tp equ 0
|
||||
match _num[_arg],_dec \{
|
||||
if _num = 1
|
||||
if _sign = 1
|
||||
movsx eax,byte[_arg]
|
||||
else
|
||||
movzx eax,byte[_arg]
|
||||
end if
|
||||
else if _num = 2
|
||||
if _sign = 1
|
||||
movsx eax,word[_arg]
|
||||
else
|
||||
movzx eax,word[_arg]
|
||||
end if
|
||||
else
|
||||
mov eax,dword[_arg]
|
||||
end if
|
||||
tp equ 1
|
||||
\}
|
||||
match =0 [_arg],tp _dec \{
|
||||
mov eax,dword[_arg]
|
||||
\}
|
||||
sub esp,4*8+4
|
||||
end if
|
||||
mov cl,_sign
|
||||
call fdo_debug_outdec
|
||||
popad
|
||||
popf
|
||||
}
|
||||
|
||||
macro DEBUGH _sign,_hex {
|
||||
pushf
|
||||
pushad
|
||||
if _hex eqtype eax
|
||||
if _hex in <eax,ebx,ecx,edx,esi,edi,ebp,esp>
|
||||
if ~_hex eq eax
|
||||
mov eax,_hex
|
||||
end if
|
||||
mov edx,8
|
||||
else if _hex in <ax,bx,cx,dx,si,di,bp,sp>
|
||||
if ~_hex eq ax
|
||||
movzx eax,_hex
|
||||
end if
|
||||
shl eax,16
|
||||
mov edx,4
|
||||
else if _hex in <al,ah,bl,bh,cl,ch,dl,dh>
|
||||
if ~_hex eq al
|
||||
movzx eax,_hex
|
||||
end if
|
||||
shl eax,24
|
||||
mov edx,2
|
||||
end if
|
||||
else if _hex eqtype 0
|
||||
mov eax,_hex
|
||||
mov edx,8
|
||||
else
|
||||
add esp,4*8+4
|
||||
local tp
|
||||
tp equ 0
|
||||
match _num[_arg],_hex \{
|
||||
mov eax,dword[_arg]
|
||||
mov edx,_num
|
||||
tp equ 1
|
||||
\}
|
||||
match =0 [_arg],tp _hex \{
|
||||
mov eax,dword[_arg]
|
||||
mov edx,8
|
||||
\}
|
||||
sub esp,4*8+4
|
||||
end if
|
||||
call fdo_debug_outhex
|
||||
popad
|
||||
popf
|
||||
}
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
debug_func fdo_debug_outchar
|
||||
debug_beginf
|
||||
pushad
|
||||
mov cl,al
|
||||
mov ebx,1
|
||||
mov eax,63
|
||||
mcall
|
||||
popad
|
||||
ret
|
||||
debug_endf
|
||||
|
||||
debug_func fdo_debug_outstr
|
||||
debug_beginf
|
||||
mov eax,63
|
||||
mov ebx,1
|
||||
.l1: mov cl,[edx]
|
||||
or cl,cl
|
||||
jz .l2
|
||||
mcall
|
||||
inc edx
|
||||
jmp .l1
|
||||
.l2: ret
|
||||
debug_endf
|
||||
|
||||
debug_func fdo_debug_outdec
|
||||
debug_beginf
|
||||
or cl,cl
|
||||
jz @f
|
||||
or eax,eax
|
||||
jns @f
|
||||
neg eax
|
||||
push eax
|
||||
mov al,'-'
|
||||
call fdo_debug_outchar
|
||||
pop eax
|
||||
@@: push 10
|
||||
pop ecx
|
||||
push -'0'
|
||||
.l1: xor edx,edx
|
||||
div ecx
|
||||
push edx
|
||||
test eax,eax
|
||||
jnz .l1
|
||||
.l2: pop eax
|
||||
add al,'0'
|
||||
jz .l3
|
||||
call fdo_debug_outchar
|
||||
jmp .l2
|
||||
.l3: ret
|
||||
debug_endf
|
||||
|
||||
debug_func fdo_debug_outhex
|
||||
__fdo_hexdigits db '0123456789ABCDEF'
|
||||
debug_beginf
|
||||
mov cl,dl
|
||||
neg cl
|
||||
add cl,8
|
||||
shl cl,2
|
||||
rol eax,cl
|
||||
.l1: rol eax,4
|
||||
push eax
|
||||
and eax,0x0000000F
|
||||
mov al,[__fdo_hexdigits+eax]
|
||||
call fdo_debug_outchar
|
||||
pop eax
|
||||
dec edx
|
||||
jnz .l1
|
||||
ret
|
||||
debug_endf
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
|
||||
macro DEBUGF _level,_format,[_arg] {
|
||||
common
|
||||
if __DEBUG__ = 1 & _level >= __DEBUG_LEVEL__
|
||||
local ..f1,f2,a1,a2,c1,c2,c3,..lbl
|
||||
_debug_str_ equ __debug_str_ # a1
|
||||
a1 = 0
|
||||
c2 = 0
|
||||
c3 = 0
|
||||
f2 = 0
|
||||
repeat ..lbl-..f1
|
||||
virtual at 0
|
||||
db _format,0,0
|
||||
load c1 word from %-1
|
||||
end virtual
|
||||
if c1 = '%s'
|
||||
virtual at 0
|
||||
db _format,0,0
|
||||
store word 0 at %-1
|
||||
load c1 from f2-c2
|
||||
end virtual
|
||||
if c1 <> 0
|
||||
DEBUGS 0,_debug_str_+f2-c2
|
||||
end if
|
||||
c2 = c2 + 1
|
||||
f2 = %+1
|
||||
DEBUGF_HELPER S,a1,0,_arg
|
||||
else if c1 = '%x'
|
||||
virtual at 0
|
||||
db _format,0,0
|
||||
store word 0 at %-1
|
||||
load c1 from f2-c2
|
||||
end virtual
|
||||
if c1 <> 0
|
||||
DEBUGS 0,_debug_str_+f2-c2
|
||||
end if
|
||||
c2 = c2 + 1
|
||||
f2 = %+1
|
||||
DEBUGF_HELPER H,a1,0,_arg
|
||||
else if c1 = '%d' | c1 = '%u'
|
||||
local c4
|
||||
if c1 = '%d'
|
||||
c4 = 1
|
||||
else
|
||||
c4 = 0
|
||||
end if
|
||||
virtual at 0
|
||||
db _format,0,0
|
||||
store word 0 at %-1
|
||||
load c1 from f2-c2
|
||||
end virtual
|
||||
if c1 <> 0
|
||||
DEBUGS 0,_debug_str_+f2-c2
|
||||
end if
|
||||
c2 = c2 + 1
|
||||
f2 = %+1
|
||||
DEBUGF_HELPER D,a1,c4,_arg
|
||||
else if c1 = '\n'
|
||||
c3 = c3 + 1
|
||||
end if
|
||||
end repeat
|
||||
virtual at 0
|
||||
db _format,0,0
|
||||
load c1 from f2-c2
|
||||
end virtual
|
||||
if (c1<>0)&(f2<>..lbl-..f1-1)
|
||||
DEBUGS 0,_debug_str_+f2-c2
|
||||
end if
|
||||
virtual at 0
|
||||
..f1 db _format,0
|
||||
..lbl:
|
||||
__debug_strings equ __debug_strings,_debug_str_,<_format>,..lbl-..f1-1-c2-c3
|
||||
end virtual
|
||||
end if
|
||||
}
|
||||
|
||||
macro __include_debug_strings dummy,[_id,_fmt,_len] {
|
||||
common
|
||||
local c1,a1,a2
|
||||
forward
|
||||
if defined _len & ~_len eq
|
||||
_id:
|
||||
a1 = 0
|
||||
a2 = 0
|
||||
repeat _len
|
||||
virtual at 0
|
||||
db _fmt,0,0
|
||||
load c1 word from %+a2-1
|
||||
end virtual
|
||||
if (c1='%s')|(c1='%x')|(c1='%d')|(c1='%u')
|
||||
db 0
|
||||
a2 = a2 + 1
|
||||
else if (c1='\n')
|
||||
dw $0A0D
|
||||
a1 = a1 + 1
|
||||
a2 = a2 + 1
|
||||
else
|
||||
db c1 and 0x0FF
|
||||
end if
|
||||
end repeat
|
||||
db 0
|
||||
end if
|
||||
}
|
||||
|
||||
macro DEBUGF_HELPER _letter,_num,_sign,[_arg] {
|
||||
common
|
||||
local num
|
||||
num = 0
|
||||
forward
|
||||
if num = _num
|
||||
DEBUG#_letter _sign,_arg
|
||||
end if
|
||||
num = num+1
|
||||
common
|
||||
_num = _num+1
|
||||
}
|
||||
|
||||
macro include_debug_strings {
|
||||
if __DEBUG__ = 1
|
||||
match dbg_str,__debug_strings \{
|
||||
__include_debug_strings dbg_str
|
||||
\}
|
||||
end if
|
||||
}
|
@ -1,416 +0,0 @@
|
||||
;
|
||||
; ARP Status Monitor
|
||||
;
|
||||
; Compile with FASM for Menuet
|
||||
;
|
||||
; This program displays the ARP table, and it's settings
|
||||
|
||||
use32
|
||||
|
||||
org 0x0
|
||||
|
||||
db 'MENUET00' ; 8 byte id
|
||||
dd 38 ; required os
|
||||
dd START ; program start
|
||||
dd I_END ; program image size
|
||||
dd 0x100000 ; required amount of memory
|
||||
dd 0x00000000 ; reserved=no extended header
|
||||
include 'lang.inc'
|
||||
include '..\..\..\macros.inc'
|
||||
purge mov ; decrease kpack'ed size
|
||||
|
||||
START: ; start of execution
|
||||
call draw_window ; at first, draw the window
|
||||
|
||||
still:
|
||||
mov eax,23 ; wait here for event
|
||||
mov ebx,200 ; Time out after 2s
|
||||
mcall
|
||||
|
||||
cmp eax,1 ; redraw request ?
|
||||
jz red
|
||||
cmp eax,2 ; key in buffer ?
|
||||
jz key
|
||||
cmp eax,3 ; button in buffer ?
|
||||
jz button
|
||||
|
||||
; read the stack status data, and write it to the screen buffer
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 255
|
||||
mov ecx, 200
|
||||
mcall
|
||||
|
||||
push eax
|
||||
mov ebx, text + 24
|
||||
call printhex
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 255
|
||||
mov ecx, 201
|
||||
mcall
|
||||
|
||||
mov ebx, text + 64
|
||||
call printhex
|
||||
|
||||
|
||||
; Fill the table with blanks
|
||||
mov edi, text + 160
|
||||
doBlank:
|
||||
mov esi, blank
|
||||
mov ecx, 40
|
||||
rep movsb
|
||||
|
||||
cmp edi, text + 560
|
||||
jne doBlank
|
||||
|
||||
pop ecx ; The number of entries
|
||||
|
||||
mov ebx, text+ 160 +1 ; the position for the first IP address line
|
||||
|
||||
xor edx, edx ; edx is index into the ARP table
|
||||
|
||||
cmp ecx, 10
|
||||
jle show_entries
|
||||
mov ecx, 10
|
||||
|
||||
|
||||
; The following code is not very efficient; Sorry about that.
|
||||
; ARPSTAT is a debugging tool, so I didn't want to put much effort in
|
||||
show_entries:
|
||||
; Ecx now holds the number of entries to populate.
|
||||
; Ebx holds the place to put the data
|
||||
; edx is a counter
|
||||
cmp ecx, 0
|
||||
je red
|
||||
|
||||
push ecx
|
||||
push edx
|
||||
push ebx
|
||||
|
||||
|
||||
; select the arp table entry (in edx)
|
||||
mov eax, 53
|
||||
mov ebx, 255
|
||||
mov ecx, 202
|
||||
mcall
|
||||
|
||||
; Read the IP address
|
||||
mov eax, 53
|
||||
mov ebx, 255
|
||||
mov ecx, 203
|
||||
mcall
|
||||
|
||||
; IP in eax. Get the address to put it back
|
||||
pop ebx
|
||||
push ebx
|
||||
|
||||
call writeDecimal ; Extract 1 byte from eax, store it in string
|
||||
add ebx, 4
|
||||
shr eax, 8
|
||||
call writeDecimal ; Extract 1 byte from eax, store it in string
|
||||
add ebx, 4
|
||||
shr eax, 8
|
||||
call writeDecimal ; Extract 1 byte from eax, store it in string
|
||||
add ebx, 4
|
||||
shr eax, 8
|
||||
call writeDecimal ; Extract 1 byte from eax, store it in string
|
||||
|
||||
add ebx, 4
|
||||
|
||||
; Now display the 6 byte MAC
|
||||
push ebx
|
||||
mov eax, 53
|
||||
mov ebx, 255
|
||||
mov ecx, 204
|
||||
mcall
|
||||
pop ebx
|
||||
|
||||
mov ecx, eax
|
||||
|
||||
shr eax, 4
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
shr eax, 12
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
shr eax, 8
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
shr eax, 20
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
shr eax, 16
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
shr eax, 28
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
shr eax, 24
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
|
||||
push ebx
|
||||
mov eax, 53
|
||||
mov ebx, 255
|
||||
mov ecx, 205
|
||||
mcall
|
||||
pop ebx
|
||||
|
||||
mov ecx, eax
|
||||
|
||||
shr eax, 4
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
shr eax, 12
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
shr eax, 8
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
|
||||
; Now display the stat field
|
||||
inc ebx
|
||||
inc ebx
|
||||
push ebx
|
||||
mov eax, 53
|
||||
mov ebx, 255
|
||||
mov ecx, 206
|
||||
mcall
|
||||
pop ebx
|
||||
|
||||
mov ecx, eax
|
||||
|
||||
shr eax, 4
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
shr eax, 12
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
shr eax, 8
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
|
||||
; Now display the TTL field (this is intel word format)
|
||||
inc ebx
|
||||
inc ebx
|
||||
push ebx
|
||||
mov eax, 53
|
||||
mov ebx, 255
|
||||
mov ecx, 207
|
||||
mcall
|
||||
pop ebx
|
||||
|
||||
mov ecx, eax
|
||||
|
||||
shr eax, 12
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
shr eax, 8
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
shr eax, 4
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
and eax, 0x0f
|
||||
mov al, [eax + hextable]
|
||||
mov [ebx], al
|
||||
|
||||
|
||||
pop ebx
|
||||
add ebx, 40
|
||||
pop edx
|
||||
inc edx
|
||||
pop ecx
|
||||
dec ecx
|
||||
jmp show_entries
|
||||
|
||||
red: ; redraw
|
||||
call draw_window
|
||||
jmp still
|
||||
|
||||
key: ; Keys are not valid at this part of the
|
||||
mov eax,2 ; loop. Just read it and ignore
|
||||
mcall
|
||||
jmp still
|
||||
|
||||
button: ; button
|
||||
mov eax,17 ; get id
|
||||
mcall
|
||||
|
||||
cmp ah,1 ; button id=1 ?
|
||||
jnz still
|
||||
|
||||
mov eax,0xffffffff ; close this program
|
||||
mcall
|
||||
|
||||
|
||||
writeDecimal:
|
||||
pusha
|
||||
and eax, 0xff
|
||||
mov dl, 100
|
||||
div dl
|
||||
movzx ecx, ah
|
||||
add al, '0'
|
||||
mov [ebx], al
|
||||
inc ebx
|
||||
mov eax, ecx
|
||||
mov dl, 10
|
||||
div dl
|
||||
add ax, '00'
|
||||
mov [ebx], ax
|
||||
popa
|
||||
ret
|
||||
|
||||
|
||||
; *********************************************
|
||||
; ******* WINDOW DEFINITIONS AND DRAW ********
|
||||
; *********************************************
|
||||
|
||||
|
||||
draw_window:
|
||||
|
||||
mov eax,12 ; function 12:tell os about windowdraw
|
||||
mov ebx,1 ; 1, start of draw
|
||||
mcall
|
||||
|
||||
; DRAW WINDOW
|
||||
mov eax,0 ; function 0 : define and draw window
|
||||
mov ebx,100*65536+280 ; [x start] *65536 + [x size]
|
||||
mov ecx,100*65536+270 ; [y start] *65536 + [y size]
|
||||
mov edx,0x14224466 ; color of work area RRGGBB
|
||||
mov edi,title ; WINDOW LABEL
|
||||
mcall
|
||||
|
||||
|
||||
; Re-draw the screen text
|
||||
cld
|
||||
mov eax,4
|
||||
mov ebx,25*65536+35 ; draw info text with function 4
|
||||
mov ecx,0xffffff
|
||||
mov edx,text
|
||||
mov esi,40
|
||||
newline:
|
||||
mcall
|
||||
add ebx,16
|
||||
add edx,esi
|
||||
cmp [edx],byte 'x'
|
||||
jnz newline
|
||||
|
||||
|
||||
mov eax,12 ; function 12:tell os about windowdraw
|
||||
mov ebx,2 ; 2, end of draw
|
||||
mcall
|
||||
|
||||
ret
|
||||
|
||||
; Taken from PS.ASM
|
||||
printhex:
|
||||
; number in eax
|
||||
; print to ebx
|
||||
; xlat from hextable
|
||||
pusha
|
||||
mov esi, ebx
|
||||
add esi, 8
|
||||
mov ebx, hextable
|
||||
mov ecx, 8
|
||||
phex_loop:
|
||||
mov edx, eax
|
||||
and eax, 15
|
||||
xlatb
|
||||
mov [esi], al
|
||||
mov eax, edx
|
||||
shr eax, 4
|
||||
dec esi
|
||||
loop phex_loop
|
||||
popa
|
||||
ret
|
||||
|
||||
|
||||
; DATA AREA
|
||||
|
||||
text:
|
||||
db ' Number of ARP entries: xxxxxxxx '
|
||||
db ' Maximum # of entries : xxxxxxxx '
|
||||
db ' '
|
||||
db ' IP Address MAC Stat TTL '
|
||||
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx '
|
||||
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx '
|
||||
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx '
|
||||
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx '
|
||||
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx '
|
||||
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx '
|
||||
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx '
|
||||
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx '
|
||||
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx '
|
||||
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx '
|
||||
db 'x' ; <- END MARKER, DONT DELETE
|
||||
|
||||
|
||||
blank:
|
||||
db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx '
|
||||
|
||||
|
||||
title db 'ARP Table ( First 10 Entries )',0
|
||||
|
||||
hextable db '0123456789ABCDEF'
|
||||
|
||||
|
||||
I_END:
|
@ -1,5 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix en >lang.inc
|
||||
@fasm arpstat.asm arpstat
|
||||
@erase lang.inc
|
||||
@pause
|
@ -1,5 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix ru >lang.inc
|
||||
@fasm arpstat.asm arpstat
|
||||
@erase lang.inc
|
||||
@pause
|
@ -1,5 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix en >lang.inc
|
||||
@fasm dhcp.asm dhcp
|
||||
@erase lang.inc
|
||||
@pause
|
@ -1,5 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix ru >lang.inc
|
||||
@fasm dhcp.asm dhcp
|
||||
@erase lang.inc
|
||||
@pause
|
@ -1,582 +0,0 @@
|
||||
;
|
||||
; DHCP Client
|
||||
;
|
||||
; Compile with FASM for Menuet
|
||||
;
|
||||
|
||||
include 'lang.inc'
|
||||
include '..\..\..\macros.inc'
|
||||
|
||||
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+0x8000 ; memory for app
|
||||
dd I_END+0x8000 ; esp
|
||||
dd 0x0 , 0x0 ; I_Param , I_Icon
|
||||
|
||||
|
||||
START: ; start of execution
|
||||
mov eax,40 ; Report events
|
||||
mov ebx,10000111b ; Stack 8 + defaults
|
||||
int 0x40
|
||||
|
||||
red: ; redraw
|
||||
call draw_window ; at first, draw the window
|
||||
|
||||
still:
|
||||
mov eax,10 ; wait here for event
|
||||
mcall
|
||||
|
||||
cmp eax,1 ; redraw request ?
|
||||
jz red
|
||||
cmp eax,2 ; key in buffer ?
|
||||
jz key
|
||||
cmp eax,3 ; button in buffer ?
|
||||
jz button
|
||||
|
||||
jmp still
|
||||
key: ; Keys are not valid at this part of the
|
||||
mov eax,2 ; loop. Just read it and ignore
|
||||
mcall
|
||||
jmp still
|
||||
|
||||
button: ; button
|
||||
mov eax,17 ; get id
|
||||
mcall
|
||||
|
||||
cmp ah,1 ; button id=1 ?
|
||||
jnz noclose
|
||||
|
||||
; close socket before exiting
|
||||
mov eax, 53
|
||||
mov ebx, 1
|
||||
mov ecx, [socketNum]
|
||||
mcall
|
||||
|
||||
mov eax,0xffffffff ; close this program
|
||||
mcall
|
||||
|
||||
noclose:
|
||||
cmp ah,3 ; Resolve address?
|
||||
jnz still
|
||||
|
||||
call draw_window
|
||||
|
||||
call contactDHCPServer
|
||||
|
||||
jmp still
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
; Function
|
||||
; parseResponse
|
||||
;
|
||||
; Description
|
||||
; extracts the fields ( client IP address and options ) from
|
||||
; a DHCP response
|
||||
; The values go into
|
||||
; dhcpMsgType,dhcpLease,dhcpClientIP,dhcpServerIP,
|
||||
; dhcpDNSIP, dhcpSubnet
|
||||
; The message is stored in dhcpMsg
|
||||
;
|
||||
;***************************************************************************
|
||||
parseResponse:
|
||||
mov edx, dhcpMsg
|
||||
|
||||
mov eax, [edx+16]
|
||||
mov [dhcpClientIP], eax
|
||||
|
||||
; Scan options
|
||||
|
||||
add edx, 240 ; Point to first option
|
||||
|
||||
pr001:
|
||||
; Get option id
|
||||
mov al, [edx]
|
||||
cmp al, 0xff ; End of options?
|
||||
je pr_exit
|
||||
|
||||
cmp al, 53 ; Msg type is a single byte option
|
||||
jne pr002
|
||||
|
||||
mov al, [edx+2]
|
||||
mov [dhcpMsgType], al
|
||||
add edx, 3
|
||||
jmp pr001 ; Get next option
|
||||
|
||||
pr002:
|
||||
; All other (accepted) options are 4 bytes in length
|
||||
inc edx
|
||||
movzx ecx, byte [edx]
|
||||
inc edx ; point to data
|
||||
|
||||
cmp al, 54 ; server id
|
||||
jne pr0021
|
||||
mov eax, [edx] ; All options are 4 bytes, so get it
|
||||
mov [dhcpServerIP], eax
|
||||
jmp pr003
|
||||
|
||||
pr0021:
|
||||
cmp al, 51 ; lease
|
||||
jne pr0022
|
||||
mov eax, [edx] ; All options are 4 bytes, so get it
|
||||
mov [dhcpLease], eax
|
||||
jmp pr003
|
||||
|
||||
pr0022:
|
||||
cmp al, 1 ; subnet mask
|
||||
jne pr0023
|
||||
mov eax, [edx] ; All options are 4 bytes, so get it
|
||||
mov [dhcpSubnet], eax
|
||||
jmp pr003
|
||||
|
||||
pr0023:
|
||||
cmp al, 6 ; dns ip
|
||||
jne pr0024
|
||||
mov eax, [edx] ; All options are 4 bytes, so get it
|
||||
mov [dhcpDNSIP], eax
|
||||
|
||||
pr0024:
|
||||
cmp al, 3 ; gateway ip
|
||||
jne pr003
|
||||
mov eax, [edx] ; All options are 4 bytes, so get it
|
||||
mov [dhcpGateway], eax
|
||||
|
||||
pr003:
|
||||
add edx, ecx
|
||||
jmp pr001
|
||||
|
||||
pr_exit:
|
||||
ret
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
; Function
|
||||
; buildRequest
|
||||
;
|
||||
; Description
|
||||
; Creates a DHCP request packet.
|
||||
;
|
||||
;***************************************************************************
|
||||
buildRequest:
|
||||
; Clear dhcpMsg to all zeros
|
||||
xor eax,eax
|
||||
mov edi,dhcpMsg
|
||||
mov ecx,512
|
||||
cld
|
||||
rep stosb
|
||||
|
||||
mov edx, dhcpMsg
|
||||
|
||||
mov [edx], byte 0x01 ; Boot request
|
||||
mov [edx+1], byte 0x01 ; Ethernet
|
||||
mov [edx+2], byte 0x06 ; Ethernet h/w len
|
||||
mov [edx+4], dword 0x11223344 ; xid
|
||||
mov [edx+10], byte 0x80 ; broadcast flag set
|
||||
mov [edx+236], dword 0x63538263 ; magic number
|
||||
|
||||
; option DHCP msg type
|
||||
mov [edx+240], word 0x0135
|
||||
mov al, [dhcpMsgType]
|
||||
mov [edx+240+2], al
|
||||
|
||||
; option Lease time = infinity
|
||||
mov [edx+240+3], word 0x0433
|
||||
mov eax, [dhcpLease]
|
||||
mov [edx+240+5], eax
|
||||
|
||||
; option requested IP address
|
||||
mov [edx+240+9], word 0x0432
|
||||
mov eax, [dhcpClientIP]
|
||||
mov [edx+240+11], eax
|
||||
|
||||
; option request list
|
||||
mov [edx+240+15], word 0x0437
|
||||
mov [edx+240+17], dword 0x0f060301
|
||||
|
||||
; Check which msg we are sending
|
||||
cmp [dhcpMsgType], byte 0x01
|
||||
jne br001
|
||||
|
||||
; "Discover" options
|
||||
; end of options marker
|
||||
mov [edx+240+21], byte 0xff
|
||||
|
||||
mov [dhcpMsgLen], dword 262
|
||||
jmp br_exit
|
||||
|
||||
br001:
|
||||
; "Request" options
|
||||
|
||||
; server IP
|
||||
mov [edx+240+21], word 0x0436
|
||||
mov eax, [dhcpServerIP]
|
||||
mov [edx+240+23], eax
|
||||
|
||||
; end of options marker
|
||||
mov [edx+240+27], byte 0xff
|
||||
|
||||
mov [dhcpMsgLen], dword 268
|
||||
|
||||
br_exit:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
; Function
|
||||
; contactDHCPServer
|
||||
;
|
||||
; Description
|
||||
; negotiates settings with a DHCP server
|
||||
;
|
||||
;***************************************************************************
|
||||
contactDHCPServer:
|
||||
; First, open socket
|
||||
mov eax, 53
|
||||
mov ebx, 0
|
||||
mov ecx, 68 ; local port dhcp client
|
||||
mov edx, 67 ; remote port - dhcp server
|
||||
mov esi, 0xffffffff ; broadcast
|
||||
mcall
|
||||
|
||||
mov [socketNum], eax
|
||||
|
||||
; Setup the first msg we will send
|
||||
mov [dhcpMsgType], byte 0x01 ; DHCP discover
|
||||
mov [dhcpLease], dword 0xffffffff
|
||||
mov [dhcpClientIP], dword 0
|
||||
mov [dhcpServerIP], dword 0
|
||||
|
||||
call buildRequest
|
||||
|
||||
ctr000:
|
||||
; write to socket ( send broadcast request )
|
||||
mov eax, 53
|
||||
mov ebx, 4
|
||||
mov ecx, [socketNum]
|
||||
mov edx, [dhcpMsgLen]
|
||||
mov esi, dhcpMsg
|
||||
mcall
|
||||
|
||||
; Setup the DHCP buffer to receive response
|
||||
|
||||
mov eax, dhcpMsg
|
||||
mov [dhcpMsgLen], eax ; Used as a pointer to the data
|
||||
|
||||
; now, we wait for
|
||||
; UI redraw
|
||||
; UI close
|
||||
; or data from remote
|
||||
|
||||
ctr001:
|
||||
mov eax,10 ; wait here for event
|
||||
mcall
|
||||
|
||||
cmp eax,1 ; redraw request ?
|
||||
je ctr003
|
||||
cmp eax,2 ; key in buffer ?
|
||||
je ctr004
|
||||
cmp eax,3 ; button in buffer ?
|
||||
je ctr005
|
||||
|
||||
|
||||
; Any data in the UDP receive buffer?
|
||||
mov eax, 53
|
||||
mov ebx, 2
|
||||
mov ecx, [socketNum]
|
||||
mcall
|
||||
|
||||
cmp eax, 0
|
||||
je ctr001
|
||||
|
||||
; we have data - this will be the response
|
||||
ctr002:
|
||||
mov eax, 53
|
||||
mov ebx, 3
|
||||
mov ecx, [socketNum]
|
||||
mcall ; read byte - block (high byte)
|
||||
|
||||
; Store the data in the response buffer
|
||||
mov eax, [dhcpMsgLen]
|
||||
mov [eax], bl
|
||||
inc dword [dhcpMsgLen]
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 2
|
||||
mov ecx, [socketNum]
|
||||
mcall ; any more data?
|
||||
|
||||
cmp eax, 0
|
||||
jne ctr002 ; yes, so get it
|
||||
|
||||
; depending on which msg we sent, handle the response
|
||||
; accordingly.
|
||||
; If the response is to a dhcp discover, then:
|
||||
; 1) If response is DHCP OFFER then
|
||||
; 1.1) record server IP, lease time & IP address.
|
||||
; 1.2) send a request packet
|
||||
; 2) else exit ( display error )
|
||||
; If the response is to a dhcp request, then:
|
||||
; 1) If the response is DHCP ACK then
|
||||
; 1.1) extract the DNS & subnet fields. Set them in the stack
|
||||
; 2) else exit ( display error )
|
||||
|
||||
|
||||
cmp [dhcpMsgType], byte 0x01 ; did we send a discover?
|
||||
je ctr007
|
||||
cmp [dhcpMsgType], byte 0x03 ; did we send a request?
|
||||
je ctr008
|
||||
|
||||
; should never get here - we only send discover or request
|
||||
jmp ctr006
|
||||
|
||||
ctr007:
|
||||
call parseResponse
|
||||
|
||||
; Was the response an offer? It should be
|
||||
cmp [dhcpMsgType], byte 0x02
|
||||
jne ctr006 ; NO - so quit
|
||||
|
||||
; send request
|
||||
mov [dhcpMsgType], byte 0x03 ; DHCP request
|
||||
call buildRequest
|
||||
jmp ctr000
|
||||
|
||||
ctr008:
|
||||
call parseResponse
|
||||
|
||||
; Was the response an ACK? It should be
|
||||
cmp [dhcpMsgType], byte 0x05
|
||||
jne ctr006 ; NO - so quit
|
||||
|
||||
; Set or display addresses here...
|
||||
|
||||
ctr006:
|
||||
; close socket
|
||||
mov eax, 53
|
||||
mov ebx, 1
|
||||
mov ecx, [socketNum]
|
||||
mcall
|
||||
|
||||
mov [socketNum], dword 0xFFFF
|
||||
|
||||
call draw_window
|
||||
|
||||
jmp ctr001
|
||||
|
||||
ctr003: ; redraw
|
||||
call draw_window
|
||||
jmp ctr001
|
||||
|
||||
ctr004: ; key
|
||||
mov eax,2 ; just read it and ignore
|
||||
mcall
|
||||
jmp ctr001
|
||||
|
||||
ctr005: ; button
|
||||
mov eax,17 ; get id
|
||||
mcall
|
||||
|
||||
; close socket
|
||||
mov eax, 53
|
||||
mov ebx, 1
|
||||
mov ecx, [socketNum]
|
||||
mcall
|
||||
|
||||
mov [socketNum], dword 0xFFFF
|
||||
|
||||
call draw_window ; at first, draw the window
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
; *********************************************
|
||||
; ******* WINDOW DEFINITIONS AND DRAW ********
|
||||
; *********************************************
|
||||
|
||||
|
||||
; Pass in the IP address in edi
|
||||
; row to display in [ya]
|
||||
drawIP:
|
||||
; mov edi,hostIP
|
||||
mov ecx, edi
|
||||
add ecx, 4
|
||||
mov edx,[ya]
|
||||
add edx, 97*65536
|
||||
mov esi,0x00ffffff
|
||||
mov ebx,3*65536
|
||||
|
||||
ipdisplay:
|
||||
mov eax,47
|
||||
push ecx
|
||||
movzx ecx,byte [edi]
|
||||
mcall
|
||||
pop ecx
|
||||
add edx,6*4*65536
|
||||
inc edi
|
||||
cmp edi,ecx
|
||||
jb ipdisplay
|
||||
ret
|
||||
|
||||
|
||||
drawDHMS:
|
||||
|
||||
mov eax,[edi]
|
||||
bswap eax
|
||||
|
||||
mov esi,dhms
|
||||
mov ecx,16
|
||||
mov edi,text+40*4+12
|
||||
cmp eax,0xffffffff
|
||||
jne nforever
|
||||
mov esi,forever
|
||||
cld
|
||||
rep movsb
|
||||
ret
|
||||
nforever:
|
||||
cld
|
||||
rep movsb
|
||||
|
||||
mov ecx,28
|
||||
xor edx,edx
|
||||
mov ebx,60
|
||||
div ebx
|
||||
call displayDHMS
|
||||
xor edx,edx
|
||||
div ebx
|
||||
call displayDHMS
|
||||
xor edx,edx
|
||||
mov ebx,24
|
||||
div ebx
|
||||
call displayDHMS
|
||||
mov edx,eax
|
||||
call displayDHMS
|
||||
|
||||
ret
|
||||
|
||||
|
||||
displayDHMS:
|
||||
|
||||
pusha
|
||||
mov eax,47
|
||||
mov ebx,3*65536
|
||||
mov edx,ecx
|
||||
imul edx,6
|
||||
shl edx,16
|
||||
add edx,1*65536+99
|
||||
mov ecx,[esp+20]
|
||||
mov esi,0xffffff
|
||||
mcall
|
||||
popa
|
||||
sub ecx,4
|
||||
ret
|
||||
|
||||
|
||||
draw_window:
|
||||
|
||||
mov eax,12 ; function 12:tell os about windowdraw
|
||||
mov ebx,1 ; 1, start of draw
|
||||
mcall
|
||||
; DRAW WINDOW
|
||||
mov eax,0 ; function 0 : define and draw window
|
||||
mov ebx,100*65536+300 ; [x start] *65536 + [x size]
|
||||
mov ecx,100*65536+156 ; [y start] *65536 + [y size]
|
||||
mov edx,0x14224466 ; color of work area RRGGBB
|
||||
mov edi,title ; WINDOW LABEL
|
||||
mcall
|
||||
|
||||
mov eax,8 ; Resolve
|
||||
mov ebx,20*65536+90
|
||||
mov ecx,127*65536+15
|
||||
mov edx,3
|
||||
mov esi,0x557799
|
||||
mcall
|
||||
|
||||
; Pass in the IP address in edi
|
||||
; row to display in [ya]
|
||||
mov edi, dhcpClientIP
|
||||
mov eax, 35
|
||||
mov [ya], eax
|
||||
call drawIP
|
||||
mov edi, dhcpGateway
|
||||
mov eax, 35 + 16
|
||||
mov [ya], eax
|
||||
call drawIP
|
||||
mov edi, dhcpSubnet
|
||||
mov eax, 35 + 32
|
||||
mov [ya], eax
|
||||
call drawIP
|
||||
mov edi, dhcpDNSIP
|
||||
mov eax, 35 + 48
|
||||
mov [ya], eax
|
||||
call drawIP
|
||||
mov edi, dhcpLease
|
||||
call drawDHMS
|
||||
|
||||
; Re-draw the screen text
|
||||
cld
|
||||
mov eax,4
|
||||
mov ebx,25*65536+35 ; draw info text with function 4
|
||||
mov ecx,0xffffff
|
||||
mov edx,text
|
||||
mov esi,40
|
||||
newline:
|
||||
mcall
|
||||
add ebx,16
|
||||
add edx,40
|
||||
cmp [edx],byte 'x'
|
||||
jnz newline
|
||||
|
||||
|
||||
mov eax,12 ; function 12:tell os about windowdraw
|
||||
mov ebx,2 ; 2, end of draw
|
||||
mcall
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; DATA AREA
|
||||
|
||||
ya dd 0x0
|
||||
|
||||
text:
|
||||
db 'Client IP : . . . '
|
||||
db 'Gateway IP: . . . '
|
||||
db 'Subnet : . . . '
|
||||
db 'DNS IP : . . . '
|
||||
db 'Lease Time: d h m s '
|
||||
db ' '
|
||||
db ' SEND REQUEST '
|
||||
db 'x <- END MARKER, DONT DELETE '
|
||||
|
||||
|
||||
dhms db ' d h m s'
|
||||
forever db 'Forever '
|
||||
|
||||
title db 'DHCP Client Test',0
|
||||
|
||||
dhcpMsgType: db 0
|
||||
dhcpLease: dd 0
|
||||
dhcpClientIP: dd 0
|
||||
dhcpServerIP: dd 0
|
||||
dhcpDNSIP: dd 0
|
||||
dhcpSubnet: dd 0
|
||||
dhcpGateway: dd 0
|
||||
|
||||
dhcpMsgLen: dd 0
|
||||
socketNum: dd 0xFFFF
|
||||
dhcpMsg:
|
||||
I_END:
|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix en >lang.inc
|
||||
@fasm dnsr.asm dnsr
|
||||
@erase lang.inc
|
||||
@pause
|
@ -1,5 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix ru >lang.inc
|
||||
@fasm dnsr.asm dnsr
|
||||
@erase lang.inc
|
||||
@pause
|
@ -1,785 +0,0 @@
|
||||
;
|
||||
; DNS Domain name -> IP lookup
|
||||
;
|
||||
; Compile with FASM for Menuet
|
||||
;
|
||||
|
||||
|
||||
; If you like, you camd change the DNS server default by changing the
|
||||
; IP address in the dnsServer string.
|
||||
|
||||
|
||||
; Enabling debugging puts the received response to the
|
||||
; debug board
|
||||
DEBUGGING_ENABLED equ 1
|
||||
DEBUGGING_DISABLED equ 0
|
||||
DEBUGGING_STATE equ DEBUGGING_DISABLED
|
||||
|
||||
|
||||
use32
|
||||
org 0x0
|
||||
db 'MENUET01' ; header
|
||||
dd 0x01 ; header version
|
||||
dd START ; entry point
|
||||
dd I_END ; image size
|
||||
dd I_END+0x10000 ; required memory
|
||||
dd I_END+0x10000 ; esp
|
||||
dd 0x0 , 0x0 ; I_Param , I_Path
|
||||
|
||||
include 'lang.inc'
|
||||
include 'macros.inc'
|
||||
|
||||
START: ; start of execution
|
||||
mov eax,40 ; Report events
|
||||
mov ebx,10000111b ; Stack 8 + defaults
|
||||
int 0x40
|
||||
|
||||
mov dword [prompt], p1
|
||||
mov dword [promptlen], p1len - p1 ; 'waiting for command'
|
||||
|
||||
red:
|
||||
call draw_window ; at first, draw the window
|
||||
|
||||
still:
|
||||
mov eax,10 ; wait here for event
|
||||
mcall
|
||||
|
||||
cmp eax,1 ; redraw request ?
|
||||
jz red
|
||||
cmp eax,2 ; key in buffer ?
|
||||
jz key
|
||||
cmp eax,3 ; button in buffer ?
|
||||
jz button
|
||||
|
||||
jmp still
|
||||
key: ; Keys are not valid at this part of the
|
||||
mov eax,2 ; loop. Just read it and ignore
|
||||
mcall
|
||||
jmp still
|
||||
|
||||
button: ; button
|
||||
mov eax,17 ; get id
|
||||
mcall
|
||||
|
||||
cmp ah,1 ; button id=1 ?
|
||||
jnz noclose
|
||||
|
||||
; close socket before exiting
|
||||
mov eax, 53
|
||||
mov ebx, 1
|
||||
mov ecx, [socketNum]
|
||||
mcall
|
||||
|
||||
mov eax,0xffffffff ; close this program
|
||||
mcall
|
||||
|
||||
noclose:
|
||||
cmp ah,3 ; Resolve address?
|
||||
jnz noresolve
|
||||
|
||||
mov dword [prompt], p5
|
||||
mov dword [promptlen], p5len - p5 ; display 'Resolving'
|
||||
call draw_window
|
||||
|
||||
call translateData ; Convert domain & DNS IP address
|
||||
|
||||
call resolveDomain
|
||||
|
||||
jmp still
|
||||
|
||||
|
||||
noresolve:
|
||||
cmp ah,4
|
||||
jz f1 ; Enter domain name
|
||||
cmp ah,5
|
||||
jz f2 ; enter DNS Server IP
|
||||
jmp still
|
||||
|
||||
|
||||
f1:
|
||||
mov [addr],dword query
|
||||
mov [ya],dword 35
|
||||
jmp rk
|
||||
|
||||
f2:
|
||||
mov [addr],dword dnsServer
|
||||
mov [ya],dword 35+16
|
||||
|
||||
rk:
|
||||
mov ecx,26
|
||||
mov edi,[addr]
|
||||
mov al,' '
|
||||
rep stosb
|
||||
|
||||
call print_text
|
||||
|
||||
mov edi,[addr]
|
||||
|
||||
f11:
|
||||
mov eax,10
|
||||
mcall
|
||||
cmp eax,2
|
||||
jz fbu
|
||||
jmp still
|
||||
|
||||
fbu:
|
||||
mov eax,2
|
||||
mcall ; get key
|
||||
shr eax,8
|
||||
cmp eax,8
|
||||
jnz nobs
|
||||
cmp edi,[addr]
|
||||
jz f11
|
||||
sub edi,1
|
||||
mov [edi],byte ' '
|
||||
call print_text
|
||||
jmp f11
|
||||
|
||||
nobs:
|
||||
cmp eax,dword 31
|
||||
jbe f11
|
||||
cmp eax,dword 95
|
||||
jb keyok
|
||||
sub eax,32
|
||||
|
||||
keyok:
|
||||
mov [edi],al
|
||||
|
||||
call print_text
|
||||
|
||||
add edi,1
|
||||
mov esi,[addr]
|
||||
add esi,26
|
||||
cmp esi,edi
|
||||
jnz f11
|
||||
|
||||
jmp still
|
||||
|
||||
|
||||
|
||||
print_text:
|
||||
mov eax,13
|
||||
mov ebx,103*65536+26*6
|
||||
mov ecx,[ya]
|
||||
shl ecx,16
|
||||
mov cx,8
|
||||
mov edx,0x224466
|
||||
mcall
|
||||
|
||||
mov eax,4
|
||||
mov ebx,103*65536
|
||||
add ebx,[ya]
|
||||
mov ecx,0xffffff
|
||||
mov edx,[addr]
|
||||
mov esi,26
|
||||
mcall
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
; Function
|
||||
; translateData
|
||||
;
|
||||
; Description
|
||||
; Coverts the domain name and DNS IP address typed in by the user into
|
||||
; a format suitable for the IP layer.
|
||||
;
|
||||
; The ename, in query, is converted and stored in dnsMsg
|
||||
; The DNS ip, in dnsServer, is converted and stored in dnsIP
|
||||
;
|
||||
;***************************************************************************
|
||||
translateData:
|
||||
|
||||
; first, get the IP address of the DNS server
|
||||
; Then, build up the request string.
|
||||
|
||||
xor eax, eax
|
||||
mov dh, 10
|
||||
mov dl, al
|
||||
mov [dnsIP], eax
|
||||
|
||||
mov esi, dnsServer
|
||||
mov edi, dnsIP
|
||||
|
||||
mov ecx, 4
|
||||
|
||||
td003:
|
||||
lodsb
|
||||
sub al, '0'
|
||||
add dl, al
|
||||
lodsb
|
||||
cmp al, '.'
|
||||
je ipNext
|
||||
cmp al, ' '
|
||||
je ipNext
|
||||
mov dh, al
|
||||
sub dh, '0'
|
||||
mov al, 10
|
||||
mul dl
|
||||
add al, dh
|
||||
mov dl, al
|
||||
lodsb
|
||||
cmp al, '.'
|
||||
je ipNext
|
||||
cmp al, ' '
|
||||
je ipNext
|
||||
mov dh, al
|
||||
sub dh, '0'
|
||||
mov al, 10
|
||||
mul dl
|
||||
add al, dh
|
||||
mov dl, al
|
||||
lodsb
|
||||
|
||||
ipNext:
|
||||
mov [edi], dl
|
||||
inc edi
|
||||
mov dl, 0
|
||||
loop td003
|
||||
|
||||
; Build the request string
|
||||
|
||||
|
||||
mov eax, 0x00010100
|
||||
mov [dnsMsg], eax
|
||||
mov eax, 0x00000100
|
||||
mov [dnsMsg+4], eax
|
||||
mov eax, 0x00000000
|
||||
mov [dnsMsg+8], eax
|
||||
|
||||
; domain name goes in at dnsMsg+12
|
||||
mov esi, dnsMsg + 12 ; location of label length
|
||||
mov edi, dnsMsg + 13 ; label start
|
||||
mov edx, query
|
||||
mov ecx, 12 ; total string length so far
|
||||
|
||||
td002:
|
||||
mov [esi], byte 0
|
||||
inc ecx
|
||||
|
||||
td0021:
|
||||
mov al, [edx]
|
||||
cmp al, ' '
|
||||
je td001 ; we have finished the string translation
|
||||
cmp al, '.' ; we have finished the label
|
||||
je td004
|
||||
|
||||
inc byte [esi]
|
||||
inc ecx
|
||||
mov [edi], al
|
||||
inc edi
|
||||
inc edx
|
||||
jmp td0021
|
||||
|
||||
td004:
|
||||
mov esi, edi
|
||||
inc edi
|
||||
inc edx
|
||||
jmp td002
|
||||
|
||||
|
||||
|
||||
; write label len + label text
|
||||
|
||||
td001:
|
||||
mov [edi], byte 0
|
||||
inc ecx
|
||||
inc edi
|
||||
mov [edi], dword 0x01000100
|
||||
add ecx, 4
|
||||
|
||||
mov [dnsMsgLen], ecx
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
; Function
|
||||
; resolveDomain
|
||||
;
|
||||
; Description
|
||||
; Sends a question to the dns server
|
||||
; works out the IP address from the response from the DNS server
|
||||
;
|
||||
;***************************************************************************
|
||||
resolveDomain:
|
||||
; Get a free port number
|
||||
mov ecx, 1000 ; local port starting at 1000
|
||||
getlp:
|
||||
inc ecx
|
||||
push ecx
|
||||
mov eax, 53
|
||||
mov ebx, 9
|
||||
mcall
|
||||
pop ecx
|
||||
cmp eax, 0 ; is this local port in use?
|
||||
jz getlp ; yes - so try next
|
||||
|
||||
; First, open socket
|
||||
mov eax, 53
|
||||
mov ebx, 0
|
||||
mov edx, 53 ; remote port - dns
|
||||
mov esi, [dnsIP]
|
||||
mcall
|
||||
|
||||
mov [socketNum], eax
|
||||
|
||||
; write to socket ( request DNS lookup )
|
||||
mov eax, 53
|
||||
mov ebx, 4
|
||||
mov ecx, [socketNum]
|
||||
mov edx, [dnsMsgLen]
|
||||
mov esi, dnsMsg
|
||||
mcall
|
||||
|
||||
; Setup the DNS response buffer
|
||||
|
||||
mov eax, dnsMsg
|
||||
mov [dnsMsgLen], eax
|
||||
|
||||
; now, we wait for
|
||||
; UI redraw
|
||||
; UI close
|
||||
; or data from remote
|
||||
|
||||
ctr001:
|
||||
mov eax,10 ; wait here for event
|
||||
mcall
|
||||
|
||||
cmp eax,1 ; redraw request ?
|
||||
je ctr003
|
||||
cmp eax,2 ; key in buffer ?
|
||||
je ctr004
|
||||
cmp eax,3 ; button in buffer ?
|
||||
je ctr005
|
||||
|
||||
|
||||
; Any data in the UDP receive buffer?
|
||||
mov eax, 53
|
||||
mov ebx, 2
|
||||
mov ecx, [socketNum]
|
||||
mcall
|
||||
|
||||
cmp eax, 0
|
||||
je ctr001
|
||||
|
||||
; we have data - this will be the response
|
||||
ctr002:
|
||||
mov eax, 53
|
||||
mov ebx, 3
|
||||
mov ecx, [socketNum]
|
||||
mcall ; read byte - block (high byte)
|
||||
|
||||
; Store the data in the response buffer
|
||||
mov eax, [dnsMsgLen]
|
||||
mov [eax], bl
|
||||
inc dword [dnsMsgLen]
|
||||
|
||||
|
||||
if DEBUGGING_STATE = DEBUGGING_ENABLED
|
||||
call debug_print_rx_ip
|
||||
end if
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 2
|
||||
mov ecx, [socketNum]
|
||||
mcall ; any more data?
|
||||
|
||||
cmp eax, 0
|
||||
jne ctr002 ; yes, so get it
|
||||
|
||||
; close socket
|
||||
mov eax, 53
|
||||
mov ebx, 1
|
||||
mov ecx, [socketNum]
|
||||
mcall
|
||||
|
||||
mov [socketNum], dword 0xFFFF
|
||||
|
||||
; Now parse the message to get the host IP
|
||||
; Man, this is complicated. It's described in
|
||||
; RFC 1035
|
||||
|
||||
; 1) Validate that we have an answer with > 0 responses
|
||||
; 2) Find the answer record with TYPE 0001 ( host IP )
|
||||
; 3) Finally, copy the IP address to the display
|
||||
; Note: The response is in dnsMsg
|
||||
; The end of the buffer is pointed to by [dnsMsgLen]
|
||||
|
||||
; Clear the IP address text
|
||||
mov [hostIP], dword 0
|
||||
|
||||
mov esi, dnsMsg
|
||||
|
||||
; Is this a response to my question?
|
||||
mov al, [esi+2]
|
||||
and al, 0x80
|
||||
cmp al, 0x80
|
||||
jne ctr002a
|
||||
|
||||
; Were there any errors?
|
||||
mov al, [esi+3]
|
||||
and al, 0x0F
|
||||
cmp al, 0x00
|
||||
jne ctr002a
|
||||
|
||||
; Is there ( at least 1 ) answer?
|
||||
mov ax, [esi+6]
|
||||
cmp ax, 0x00
|
||||
je ctr002a
|
||||
|
||||
; Header validated. Scan through and get my answer
|
||||
|
||||
add esi, 12 ; Skip to the question field
|
||||
|
||||
; Skip through the question field
|
||||
call skipName
|
||||
add esi, 4 ; skip past the questions qtype, qclass
|
||||
|
||||
ctr002z:
|
||||
; Now at the answer. There may be several answers,
|
||||
; find the right one ( TYPE = 0x0001 )
|
||||
call skipName
|
||||
mov ax, [esi]
|
||||
cmp ax, 0x0100 ; Is this the IP address answer?
|
||||
jne ctr002c
|
||||
|
||||
; Yes! Point esi to the first byte of the IP address
|
||||
add esi, 10
|
||||
|
||||
mov eax, [esi]
|
||||
mov [hostIP], eax
|
||||
jmp ctr002a ; And exit...
|
||||
|
||||
|
||||
ctr002c: ; Skip through the answer, move to the next
|
||||
add esi, 8
|
||||
movzx eax, byte [esi+1]
|
||||
mov ah, [esi]
|
||||
add esi, eax
|
||||
add esi, 2
|
||||
|
||||
; Have we reached the end of the msg?
|
||||
; This is an error condition, should not happen
|
||||
cmp esi, [dnsMsgLen]
|
||||
jl ctr002z ; Check next answer
|
||||
jmp ctr002a ; abort
|
||||
|
||||
|
||||
ctr002a:
|
||||
mov dword [prompt], p4 ; Display IP address
|
||||
mov dword [promptlen], p4len - p4
|
||||
call draw_window
|
||||
|
||||
jmp ctr001
|
||||
|
||||
ctr003: ; redraw
|
||||
call draw_window
|
||||
jmp ctr001
|
||||
|
||||
ctr004: ; key
|
||||
mov eax,2 ; just read it and ignore
|
||||
mcall
|
||||
jmp ctr001
|
||||
|
||||
ctr005: ; button
|
||||
mov eax,17 ; get id
|
||||
mcall
|
||||
|
||||
; close socket
|
||||
mov eax, 53
|
||||
mov ebx, 1
|
||||
mov ecx, [socketNum]
|
||||
mcall
|
||||
|
||||
mov [socketNum], dword 0xFFFF
|
||||
mov [hostIP], dword 0
|
||||
|
||||
mov dword [prompt], p1
|
||||
mov dword [promptlen], p1len - p1 ; 'waiting for command'
|
||||
|
||||
call draw_window ; at first, draw the window
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
; Function
|
||||
; skipName
|
||||
;
|
||||
; Description
|
||||
; Increment esi to the first byte past the name field
|
||||
; Names may use compressed labels. Normally do.
|
||||
; RFC 1035 page 30 gives details
|
||||
;
|
||||
;***************************************************************************
|
||||
skipName:
|
||||
mov al, [esi]
|
||||
cmp al, 0
|
||||
je sn_exit
|
||||
and al, 0xc0
|
||||
cmp al, 0xc0
|
||||
je sn001
|
||||
|
||||
movzx eax, byte [esi]
|
||||
inc eax
|
||||
add esi, eax
|
||||
jmp skipName
|
||||
|
||||
sn001:
|
||||
add esi, 2 ; A pointer is always at the end
|
||||
ret
|
||||
|
||||
sn_exit:
|
||||
inc esi
|
||||
ret
|
||||
|
||||
|
||||
; *********************************************
|
||||
; ******* WINDOW DEFINITIONS AND DRAW ********
|
||||
; *********************************************
|
||||
|
||||
|
||||
draw_window:
|
||||
mov eax,12 ; function 12:tell os about windowdraw
|
||||
mov ebx,1 ; 1, start of draw
|
||||
mcall
|
||||
; DRAW WINDOW
|
||||
mov eax,0 ; function 0 : define and draw window
|
||||
mov ebx,100*65536+300 ; [x start] *65536 + [x size]
|
||||
mov ecx,100*65536+140 ; [y start] *65536 + [y size]
|
||||
mov edx,0x14224466 ; color of work area RRGGBB
|
||||
mov edi,title ; WINDOW LABEL;
|
||||
mcall
|
||||
|
||||
mov eax,8 ; Resolve
|
||||
mov ebx,20*65536+190
|
||||
mov ecx,79*65536+15
|
||||
mov edx,3
|
||||
mov esi,0x557799
|
||||
mcall
|
||||
|
||||
;mov eax,8
|
||||
mov ebx,270*65536+10
|
||||
mov ecx,34*65536+10
|
||||
inc edx
|
||||
mcall
|
||||
|
||||
;mov eax,8
|
||||
mov ebx,270*65536+10
|
||||
mov ecx,50*65536+10
|
||||
inc edx
|
||||
mcall
|
||||
|
||||
; Copy the file name to the screen buffer
|
||||
; file name is same length as IP address, to
|
||||
; make the math easier later.
|
||||
cld
|
||||
mov esi,query
|
||||
mov edi,text+13
|
||||
mov ecx,26
|
||||
rep movsb
|
||||
|
||||
|
||||
; copy the IP address to the screen buffer
|
||||
mov esi,dnsServer
|
||||
mov edi,text+40+13
|
||||
mov ecx,26
|
||||
rep movsb
|
||||
|
||||
; copy the prompt to the screen buffer
|
||||
mov esi,[prompt]
|
||||
mov edi,text+200
|
||||
mov ecx,[promptlen]
|
||||
rep movsb
|
||||
|
||||
; Re-draw the screen text
|
||||
cld
|
||||
mov eax,4
|
||||
mov ebx,25*65536+35 ; draw info text with function 4
|
||||
mov ecx,0xffffff
|
||||
mov edx,text
|
||||
mov esi,40
|
||||
newline:
|
||||
mcall
|
||||
add ebx,16
|
||||
add edx,40
|
||||
cmp [edx],byte 'x'
|
||||
jnz newline
|
||||
|
||||
|
||||
; Write the host IP, if we have one
|
||||
mov eax, [hostIP]
|
||||
cmp eax, 0
|
||||
je dw001
|
||||
|
||||
; We have an IP address... display it
|
||||
mov edi,hostIP
|
||||
mov edx,97*65536+115
|
||||
mov esi,0x00ffffff
|
||||
mov ebx,3*65536
|
||||
|
||||
ipdisplay:
|
||||
mov eax,47
|
||||
movzx ecx,byte [edi]
|
||||
mcall
|
||||
add edx,6*4*65536
|
||||
inc edi
|
||||
cmp edi,hostIP+4
|
||||
jb ipdisplay
|
||||
|
||||
dw001:
|
||||
mov eax,12 ; function 12:tell os about windowdraw
|
||||
mov ebx,2 ; 2, end of draw
|
||||
mcall
|
||||
|
||||
ret
|
||||
|
||||
|
||||
if DEBUGGING_STATE = DEBUGGING_ENABLED
|
||||
;****************************************************************************
|
||||
; Function
|
||||
; debug_print_string
|
||||
;
|
||||
; Description
|
||||
; prints a string to the debug board
|
||||
;
|
||||
; esi holds ptr to msg to display
|
||||
;
|
||||
; Nothing preserved; I'm assuming a pusha/popa is done before calling
|
||||
;
|
||||
;****************************************************************************
|
||||
debug_print_string:
|
||||
mov cl, [esi]
|
||||
cmp cl, 0
|
||||
jnz dps_001
|
||||
ret
|
||||
|
||||
dps_001:
|
||||
mov eax,63
|
||||
mov ebx, 1
|
||||
push esi
|
||||
mcall
|
||||
|
||||
inc word [ind]
|
||||
mov ax, [ind]
|
||||
and ax, 0x1f
|
||||
cmp ax, 0
|
||||
jne ds1
|
||||
|
||||
mov cl, 13
|
||||
mov eax,63
|
||||
mov ebx, 1
|
||||
mcall
|
||||
mov cl, 10
|
||||
mov eax,63
|
||||
mov ebx, 1
|
||||
mcall
|
||||
|
||||
|
||||
ds1:
|
||||
pop esi
|
||||
inc esi
|
||||
jmp debug_print_string
|
||||
|
||||
|
||||
ind: dw 0
|
||||
; This is used for translating hex to ASCII for display or output
|
||||
hexchars db '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
|
||||
IP_STR db 'xx',0
|
||||
|
||||
|
||||
debug_print_rx_ip:
|
||||
pusha
|
||||
mov edi, IP_STR
|
||||
|
||||
xor eax, eax
|
||||
mov al, bl
|
||||
shr al, 4
|
||||
mov ah, [eax + hexchars]
|
||||
mov [edi], ah
|
||||
inc edi
|
||||
|
||||
xor eax, eax
|
||||
mov al, bl
|
||||
and al, 0x0f
|
||||
mov ah, [eax + hexchars]
|
||||
mov [edi], ah
|
||||
mov esi, IP_STR
|
||||
|
||||
call debug_print_string
|
||||
popa
|
||||
ret
|
||||
end if
|
||||
|
||||
|
||||
; DATA AREA
|
||||
|
||||
addr dd 0x0
|
||||
ya dd 0x0
|
||||
|
||||
text:
|
||||
|
||||
if lang eq ru
|
||||
db 'ˆ¬ï å®áâ : xxxxxxxxxxxxxxx '
|
||||
db 'DNS á¥à¢¥à : xxx.xxx.xxx.xxx '
|
||||
db ' '
|
||||
db ' <20>®«ãç¨âì ¤à¥á '
|
||||
db ' '
|
||||
db ' '
|
||||
db 'x <- END MARKER, DONT DELETE '
|
||||
|
||||
else
|
||||
db 'Host name : xxxxxxxxxxxxxxx '
|
||||
db 'DNS server : xxx.xxx.xxx.xxx '
|
||||
db ' '
|
||||
db ' RESOLVE ADDRESS '
|
||||
db ' '
|
||||
db ' '
|
||||
db 'x <- END MARKER, DONT DELETE '
|
||||
end if
|
||||
|
||||
if lang eq ru
|
||||
title db 'DNS Š«¨¥â',0
|
||||
|
||||
else
|
||||
title db 'DNS Client',0
|
||||
end if
|
||||
|
||||
|
||||
prompt: dd 0
|
||||
promptlen: dd 0
|
||||
|
||||
|
||||
if lang eq ru
|
||||
p1: db '†¤ã ª®¬ ¤ë '
|
||||
p1len:
|
||||
|
||||
|
||||
else
|
||||
p1: db 'Waiting for Command '
|
||||
p1len:
|
||||
end if
|
||||
|
||||
p4: db 'IP Address: . . . '
|
||||
p4len:
|
||||
|
||||
p5: db 'Resolving... '
|
||||
p5len:
|
||||
|
||||
|
||||
dnsServer db '194.145.128.1 ' ; iolfree.ie DNS
|
||||
query db 'WWW.MENUETOS.NET '
|
||||
|
||||
hostIP: dd 0
|
||||
dnsIP: dd 0
|
||||
dnsMsgLen: dd 0
|
||||
socketNum: dd 0xFFFF
|
||||
dnsMsg:
|
||||
I_END:
|
@ -1,4 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix en >lang.inc
|
||||
@fasm ethstat.asm ethstat
|
||||
@pause
|
@ -1,4 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix ru >lang.inc
|
||||
@fasm ethstat.asm ethstat
|
||||
@pause
|
@ -1,218 +0,0 @@
|
||||
;
|
||||
; Stack Status Monitor
|
||||
;
|
||||
; Compile with FASM for Menuet
|
||||
;
|
||||
|
||||
use32
|
||||
org 0x0
|
||||
db 'MENUET01' ; header
|
||||
dd 0x01 ; header version
|
||||
dd START ; entry point
|
||||
dd I_END ; image size
|
||||
dd I_END+0x10000 ; required memory
|
||||
dd I_END+0x10000 ; esp
|
||||
dd 0x0 , 0x0 ; I_Param , I_Path
|
||||
|
||||
include 'lang.inc'
|
||||
include '..\..\..\macros.inc'
|
||||
|
||||
START: ; start of execution
|
||||
|
||||
call draw_window ; at first, draw the window
|
||||
|
||||
still:
|
||||
mov eax,23 ; wait here for event
|
||||
mov ebx,200 ; Time out after 2s
|
||||
mcall
|
||||
|
||||
cmp eax,1 ; redraw request ?
|
||||
jz red
|
||||
cmp eax,2 ; key in buffer ?
|
||||
jz key
|
||||
cmp eax,3 ; button in buffer ?
|
||||
jz button
|
||||
|
||||
; read the stack status data, and write it to the screen buffer
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 255
|
||||
mov ecx, 6
|
||||
mcall
|
||||
|
||||
mov ebx, text + 24
|
||||
call printhex
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 255
|
||||
mov ecx, 2
|
||||
mcall
|
||||
|
||||
mov ebx, text + 107
|
||||
call printhex
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 255
|
||||
mov ecx, 5
|
||||
mcall
|
||||
|
||||
mov ebx, text + 107 + 40
|
||||
call printhex
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 255
|
||||
mov ecx, 4
|
||||
mcall
|
||||
|
||||
mov ebx, text + 107 + 80
|
||||
call printhex
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 255
|
||||
mov ecx, 100
|
||||
mcall
|
||||
|
||||
mov ebx, text + 258
|
||||
call printhex
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 255
|
||||
mov ecx, 101
|
||||
mcall
|
||||
|
||||
mov ebx, text + 258 + 40
|
||||
call printhex
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 255
|
||||
mov ecx, 102
|
||||
mcall
|
||||
|
||||
mov ebx, text + 258 + 80
|
||||
call printhex
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 255
|
||||
mov ecx, 103
|
||||
mcall
|
||||
|
||||
mov ebx, text + 258 + 120
|
||||
call printhex
|
||||
|
||||
red: ; redraw
|
||||
call draw_window
|
||||
jmp still
|
||||
|
||||
key: ; Keys are not valid at this part of the
|
||||
mov eax,2 ; loop. Just read it and ignore
|
||||
mcall
|
||||
jmp still
|
||||
|
||||
button: ; button
|
||||
mov eax,17 ; get id
|
||||
mcall
|
||||
|
||||
cmp ah,1 ; button id=1 ?
|
||||
jnz still
|
||||
|
||||
or eax,-1 ; close this program
|
||||
mcall
|
||||
|
||||
jmp still
|
||||
|
||||
|
||||
|
||||
|
||||
; *********************************************
|
||||
; ******* WINDOW DEFINITIONS AND DRAW ********
|
||||
; *********************************************
|
||||
|
||||
|
||||
draw_window:
|
||||
|
||||
mov eax,12 ; function 12:tell os about windowdraw
|
||||
mov ebx,1 ; 1, start of draw
|
||||
mcall
|
||||
|
||||
; DRAW WINDOW
|
||||
xor eax,eax ; function 0 : define and draw window
|
||||
mov ebx,100*65536+260 ; [x start] *65536 + [x size]
|
||||
mov ecx,100*65536+205 ; [y start] *65536 + [y size]
|
||||
mov edx,0x14224466 ; color of work area RRGGBB
|
||||
mov edi,title ; WINDOW LABEL
|
||||
mcall
|
||||
|
||||
|
||||
; Re-draw the screen text
|
||||
cld
|
||||
mov eax,4
|
||||
mov ebx,25*65536+35 ; draw info text with function 4
|
||||
mov ecx,0xffffff
|
||||
mov edx,text
|
||||
mov esi,40
|
||||
newline:
|
||||
mcall
|
||||
add ebx,16
|
||||
add edx,40
|
||||
cmp [edx],byte 'x'
|
||||
jnz newline
|
||||
|
||||
|
||||
mov eax,12 ; function 12:tell os about windowdraw
|
||||
mov ebx,2 ; 2, end of draw
|
||||
mcall
|
||||
|
||||
ret
|
||||
|
||||
; Taken from PS.ASM
|
||||
printhex:
|
||||
; number in eax
|
||||
; print to ebx
|
||||
; xlat from hextable
|
||||
pusha
|
||||
mov esi, ebx
|
||||
add esi, 8
|
||||
mov ebx, hextable
|
||||
mov ecx, 8
|
||||
phex_loop:
|
||||
mov edx, eax
|
||||
and eax, 15
|
||||
xlatb
|
||||
mov [esi], al
|
||||
mov eax, edx
|
||||
shr eax, 4
|
||||
dec esi
|
||||
loop phex_loop
|
||||
popa
|
||||
ret
|
||||
|
||||
|
||||
; DATA AREA
|
||||
|
||||
text:
|
||||
db ' Ethernet card status : xxxxxxxx '
|
||||
db ' '
|
||||
db ' IP packets received : xxxxxxxx '
|
||||
db ' ARP packets received : xxxxxxxx '
|
||||
db ' Dumped received packets : xxxxxxxx '
|
||||
db ' '
|
||||
db ' EMPTY QUEUE : xxxxxxxx '
|
||||
db ' IPOUT QUEUE : xxxxxxxx '
|
||||
db ' IPIN QUEUE : xxxxxxxx '
|
||||
db ' NET1OUT QUEUE : xxxxxxxx '
|
||||
db 'x <- END MARKER, DONT DELETE '
|
||||
|
||||
|
||||
title db 'Stack Status',0
|
||||
|
||||
hextable db '0123456789ABCDEF'
|
||||
|
||||
|
||||
I_END:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,2 +0,0 @@
|
||||
@fasm ftps.asm ftps
|
||||
@pause
|
@ -1,5 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix en >lang.inc
|
||||
@fasm popc.asm popc
|
||||
@erase lang.inc
|
||||
@pause
|
@ -1,5 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix ru >lang.inc
|
||||
@fasm popc.asm popc
|
||||
@erase lang.inc
|
||||
@pause
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix en >lang.inc
|
||||
@fasm stackcfg.asm stackcfg
|
||||
@erase lang.inc
|
||||
@pause
|
@ -1,5 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix ru >lang.inc
|
||||
@fasm stackcfg.asm stackcfg
|
||||
@erase lang.inc
|
||||
@pause
|
@ -1,11 +0,0 @@
|
||||
Программа для настройк сетевых параметров
|
||||
28.10.06 Heavyiron
|
||||
Добавлен параметр BOOT
|
||||
Теперь можно в исходник вбить нужные IP, маску, шлюз и DNS, перекомпиллировать программу и закинуть ее в автозагрузку. Следовательно эти настройки не придется каждый раз вбивать вручную.
|
||||
В autorun.dat необходимо поместить,например, такую строку:
|
||||
/sys/stackcfg BOOT 30 # Set yor network settings,
|
||||
не забыв при этом увеличить количество запускаемых программ на одну
|
||||
в самом начале файла autorun.dat.
|
||||
|
||||
TODO:
|
||||
сделать чтение настроек из файла network.dat, чтобы не требовалась перекомпилляция для изменения настроек.
|
@ -1,701 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; ;
|
||||
; Stack Configuration Tool ;
|
||||
; ;
|
||||
; Compile with FASM for Menuet ;
|
||||
; ;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
memsize = 100000h
|
||||
org 0
|
||||
PARAMS = memsize - 1024
|
||||
|
||||
use32
|
||||
|
||||
db 'MENUET01' ; 8 byte id
|
||||
dd 0x01 ; header version
|
||||
dd START ; start of code
|
||||
dd I_END ; size of image
|
||||
dd memsize ; memory for app
|
||||
dd memsize - 1024 ; esp
|
||||
dd PARAMS , 0x0 ; I_Param , I_Icon
|
||||
|
||||
include 'lang.inc'
|
||||
include '../../../macros.inc'
|
||||
|
||||
START: ; start of execution
|
||||
|
||||
read_stack_setup:
|
||||
|
||||
mov eax,52
|
||||
mov ebx,0
|
||||
mcall
|
||||
mov [config],eax
|
||||
|
||||
mov eax,52
|
||||
mov ebx,1
|
||||
mcall
|
||||
mov dword [ip_address],eax
|
||||
|
||||
mov eax,52
|
||||
mov ebx,9
|
||||
mcall
|
||||
mov dword [gateway_ip],eax
|
||||
|
||||
mov eax,52
|
||||
mov ebx,10
|
||||
mcall
|
||||
mov dword [subnet_mask],eax
|
||||
|
||||
mov eax,52
|
||||
mov ebx,13
|
||||
mcall
|
||||
mov dword [dns_ip],eax
|
||||
|
||||
mov eax,[config] ; unwrap com IRQ
|
||||
shr eax,8
|
||||
and eax,0xf
|
||||
mov [com_irq],eax
|
||||
|
||||
mov eax,[config] ; unwrap com PORT
|
||||
shr eax,16
|
||||
and eax,0xfff
|
||||
mov [com_add],eax
|
||||
|
||||
mov eax,[config] ; unwrap IRQ
|
||||
and eax,0xf
|
||||
mov [interface],eax
|
||||
|
||||
mov eax,[config] ; unwrap com PORT
|
||||
shr eax,7
|
||||
and eax,1
|
||||
mov [assigned],eax
|
||||
|
||||
red:
|
||||
call draw_window ; at first, draw the window
|
||||
|
||||
still:
|
||||
|
||||
mov eax,10 ; wait here for event
|
||||
mcall
|
||||
|
||||
cmp eax,1 ; redraw request ?
|
||||
jz red
|
||||
cmp eax,2 ; key in buffer ?
|
||||
jnz button
|
||||
|
||||
key: ; key
|
||||
; mov al,2 ; just read it and ignore
|
||||
mcall
|
||||
jmp still
|
||||
|
||||
button: ; button
|
||||
mov al,17 ; get id
|
||||
mcall
|
||||
|
||||
shr eax,8
|
||||
|
||||
dec eax ; button id=1 ?
|
||||
jne noclose
|
||||
or eax,-1 ; close this program
|
||||
mcall
|
||||
noclose:
|
||||
|
||||
dec eax
|
||||
je read_stack_setup
|
||||
|
||||
dec eax
|
||||
jne no_apply_stack_setup
|
||||
call apply_stack_setup
|
||||
jmp still
|
||||
|
||||
no_apply_stack_setup:
|
||||
dec eax ; GET COM PORT
|
||||
dec eax
|
||||
jne no_read_comport
|
||||
mov [string_x],272
|
||||
mov [string_y],40
|
||||
mov [string_length],3
|
||||
call read_string
|
||||
movzx eax,byte [string]
|
||||
cmp eax,'A'
|
||||
jb gcp1
|
||||
sub eax,'A'-'9'-1
|
||||
gcp1:
|
||||
sub eax,48
|
||||
shl eax,8
|
||||
mov ebx,eax
|
||||
movzx eax,byte [string+1]
|
||||
cmp eax,'A'
|
||||
jb gcp2
|
||||
sub eax,'A'-'9'-1
|
||||
gcp2:
|
||||
sub eax,48
|
||||
shl eax,4
|
||||
add ebx,eax
|
||||
movzx eax,byte [string+2]
|
||||
cmp eax,'A'
|
||||
jb gcp3
|
||||
sub eax,'A'-'9'-1
|
||||
gcp3:
|
||||
sub eax,48
|
||||
add ebx,eax
|
||||
mov [com_add],ebx
|
||||
jmp red
|
||||
no_read_comport:
|
||||
|
||||
dec eax ; GET COM IRQ
|
||||
jne no_read_comirq
|
||||
mov [string_x],284
|
||||
mov [string_y],50
|
||||
mov [string_length],1
|
||||
call read_string
|
||||
movzx eax,byte [string]
|
||||
cmp eax,'A'
|
||||
jb gci1
|
||||
sub eax,'A'-'9'-1
|
||||
gci1:
|
||||
sub eax,48
|
||||
mov [com_irq],eax
|
||||
jmp red
|
||||
no_read_comirq:
|
||||
|
||||
dec eax ; GET IP
|
||||
jne no_read_ip
|
||||
mov [string_x],205
|
||||
mov [string_y],80
|
||||
mov [string_length],15
|
||||
call read_string
|
||||
mov esi,string-1
|
||||
mov edi,ip_address
|
||||
ip0:
|
||||
xor eax,eax
|
||||
ip1:
|
||||
inc esi
|
||||
cmp [esi],byte '0'
|
||||
jb ip2
|
||||
cmp [esi],byte '9'
|
||||
jg ip2
|
||||
imul eax,10
|
||||
movzx ebx,byte [esi]
|
||||
sub ebx,48
|
||||
add eax,ebx
|
||||
jmp ip1
|
||||
ip2:
|
||||
stosb
|
||||
cmp edi,ip_address+3
|
||||
jbe ip0
|
||||
jmp red
|
||||
no_read_ip:
|
||||
|
||||
dec eax ; set gateway ip
|
||||
jne no_set_gateway
|
||||
|
||||
mov [string_x],205
|
||||
mov [string_y],90
|
||||
mov [string_length],15
|
||||
call read_string
|
||||
mov esi,string-1
|
||||
mov edi,gateway_ip
|
||||
gip0:
|
||||
xor eax,eax
|
||||
gip1:
|
||||
inc esi
|
||||
cmp [esi],byte '0'
|
||||
jb gip2
|
||||
cmp [esi],byte '9'
|
||||
jg gip2
|
||||
imul eax,10
|
||||
movzx ebx,byte [esi]
|
||||
sub ebx,48
|
||||
add eax,ebx
|
||||
jmp gip1
|
||||
gip2:
|
||||
stosb
|
||||
cmp edi,gateway_ip+3
|
||||
jbe gip0
|
||||
jmp red
|
||||
|
||||
no_set_gateway:
|
||||
|
||||
dec eax
|
||||
jne no_set_subnet
|
||||
|
||||
mov [string_x],205
|
||||
mov [string_y],100
|
||||
mov [string_length],15
|
||||
call read_string
|
||||
mov esi,string-1
|
||||
mov edi,subnet_mask
|
||||
sip0:
|
||||
xor eax,eax
|
||||
sip1:
|
||||
inc esi
|
||||
cmp [esi],byte '0'
|
||||
jb sip2
|
||||
cmp [esi],byte '9'
|
||||
jg sip2
|
||||
imul eax,10
|
||||
movzx ebx,byte [esi]
|
||||
sub ebx,48
|
||||
add eax,ebx
|
||||
jmp sip1
|
||||
sip2:
|
||||
stosb
|
||||
cmp edi,subnet_mask+3
|
||||
jbe sip0
|
||||
jmp red
|
||||
|
||||
no_set_subnet:
|
||||
dec eax
|
||||
jne no_set_dns
|
||||
|
||||
mov [string_x],205
|
||||
mov [string_y],110
|
||||
mov [string_length],15
|
||||
call read_string
|
||||
mov esi,string-1
|
||||
mov edi,dns_ip
|
||||
dip0:
|
||||
xor eax,eax
|
||||
dip1:
|
||||
inc esi
|
||||
cmp [esi],byte '0'
|
||||
jb dip2
|
||||
cmp [esi],byte '9'
|
||||
jg dip2
|
||||
imul eax,10
|
||||
movzx ebx,byte [esi]
|
||||
sub ebx,48
|
||||
add eax,ebx
|
||||
jmp dip1
|
||||
dip2:
|
||||
stosb
|
||||
cmp edi,dns_ip+3
|
||||
jbe dip0
|
||||
jmp red
|
||||
|
||||
no_set_dns:
|
||||
|
||||
dec eax
|
||||
jb no_set_interface
|
||||
cmp eax,14-11
|
||||
ja no_set_interface
|
||||
mov [interface],eax
|
||||
jmp red
|
||||
no_set_interface:
|
||||
|
||||
sub eax,21-11
|
||||
jb no_ip_sf
|
||||
cmp eax,22-21
|
||||
ja no_ip_sf
|
||||
xor eax,1
|
||||
mov [assigned],eax
|
||||
jmp red
|
||||
no_ip_sf:
|
||||
jmp still
|
||||
|
||||
apply_stack_setup:
|
||||
|
||||
mov eax,[com_irq]
|
||||
shl eax,8
|
||||
mov ebx,[com_add]
|
||||
shl ebx,16
|
||||
add eax,ebx
|
||||
add eax,[interface]
|
||||
mov ebx,[assigned]
|
||||
shl ebx,7
|
||||
add eax,ebx
|
||||
mov [config],eax
|
||||
|
||||
mov eax,52
|
||||
mov ebx,3
|
||||
mov ecx,dword [ip_address]
|
||||
mcall
|
||||
|
||||
mov eax,52
|
||||
mov ebx,11
|
||||
mov ecx,dword [gateway_ip]
|
||||
mcall
|
||||
|
||||
mov eax,52
|
||||
mov ebx,12
|
||||
mov ecx,dword [subnet_mask]
|
||||
mcall
|
||||
|
||||
mov eax,52
|
||||
mov ebx,14
|
||||
mov ecx,dword [dns_ip]
|
||||
mcall
|
||||
|
||||
mov eax,52
|
||||
mov ebx,2
|
||||
mov ecx,[config]
|
||||
mcall
|
||||
|
||||
ret
|
||||
|
||||
|
||||
string_length dd 16
|
||||
string_x dd 200
|
||||
string_y dd 60
|
||||
|
||||
string db '________________'
|
||||
|
||||
|
||||
read_string:
|
||||
|
||||
mov edi,string
|
||||
mov eax,'_'
|
||||
mov ecx,[string_length]
|
||||
cld
|
||||
rep stosb
|
||||
call print_text
|
||||
|
||||
mov edi,string
|
||||
f11:
|
||||
mov eax,10
|
||||
mcall
|
||||
cmp eax,2
|
||||
jne read_done
|
||||
; mov eax,2
|
||||
mcall
|
||||
shr eax,8
|
||||
cmp eax,13
|
||||
je read_done
|
||||
cmp eax,8
|
||||
jnz nobsl
|
||||
cmp edi,string
|
||||
jz f11
|
||||
sub edi,1
|
||||
mov [edi],byte '_'
|
||||
call print_text
|
||||
jmp f11
|
||||
nobsl:
|
||||
cmp eax,dword 31
|
||||
jbe f11
|
||||
cmp eax,dword 95
|
||||
jb keyok
|
||||
sub eax,32
|
||||
keyok:
|
||||
mov [edi],al
|
||||
call print_text
|
||||
|
||||
inc edi
|
||||
mov esi,string
|
||||
add esi,[string_length]
|
||||
cmp esi,edi
|
||||
jnz f11
|
||||
|
||||
read_done:
|
||||
|
||||
print_text:
|
||||
|
||||
pusha
|
||||
|
||||
mov eax,13
|
||||
mov ebx,[string_x]
|
||||
shl ebx,16
|
||||
add ebx,[string_length]
|
||||
imul bx,6
|
||||
mov ecx,[string_y]
|
||||
shl ecx,16
|
||||
mov cx,8
|
||||
mov edx,0xffffff
|
||||
mcall
|
||||
|
||||
mov eax,4
|
||||
mov ebx,[string_x]
|
||||
shl ebx,16
|
||||
add ebx,[string_y]
|
||||
mov ecx,0x000000
|
||||
mov edx,string
|
||||
mov esi,[string_length]
|
||||
mcall
|
||||
|
||||
popa
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; *********************************************
|
||||
; ******* WINDOW DEFINITIONS AND DRAW ********
|
||||
; *********************************************
|
||||
|
||||
|
||||
draw_window:
|
||||
|
||||
mov eax,12 ; function 12:tell os about windowdraw
|
||||
mov ebx,1 ; 1, start of draw
|
||||
mcall
|
||||
|
||||
; DRAW WINDOW
|
||||
mov eax,0 ; function 0 : define and draw window
|
||||
mov ebx,100*65536+330 ; [x start] *65536 + [x size]
|
||||
mov ecx,100*65536+157 ; [y start] *65536 + [y size]
|
||||
mov edx,0x14ffffff ; color of work area RRGGBB,8->color gl
|
||||
mov edi,title ; WINDOW LABEL
|
||||
mcall
|
||||
|
||||
|
||||
mov eax,8 ; BUTTON : READ SETUP
|
||||
mov ebx,90*65536+65
|
||||
mov ecx,127*65536+12
|
||||
mov edx,2
|
||||
mov esi,[button_color]
|
||||
mcall
|
||||
|
||||
;mov eax,8 ; BUTTON : APPLY SETUP
|
||||
mov ebx,163*65536+65
|
||||
mov ecx,127*65536+12
|
||||
mov edx,3
|
||||
mcall
|
||||
|
||||
;mov eax,8 ; BUTTONS 11-14 : SELECT INTERFACE
|
||||
mov ebx,29*65536+8
|
||||
mov ecx,39*65536+8
|
||||
mov edx,11
|
||||
interface_select:
|
||||
mcall
|
||||
add ecx,10*65536
|
||||
inc edx
|
||||
cmp edx,11+4
|
||||
jb interface_select
|
||||
|
||||
mov ebx,[interface] ; PRINT SELECTED INTERFACE 'X'
|
||||
imul ebx,10
|
||||
add ebx,31*65536+39
|
||||
mov eax,4
|
||||
mov ecx,0xffffff
|
||||
mov edx,xx
|
||||
mov esi,1
|
||||
mcall
|
||||
|
||||
mov eax,8 ; BUTTONS 21-22 : SERVER / MANUAL IP
|
||||
mov ebx,143*65536+8
|
||||
mov ecx,69*65536+8
|
||||
mov edx,21
|
||||
mov esi,[button_color]
|
||||
mcall
|
||||
;mov eax,8
|
||||
mov ebx,143*65536+8
|
||||
mov ecx,79*65536+8
|
||||
mov edx,22
|
||||
mcall
|
||||
mov ebx,[assigned] ; PRINT SELECTED SERVER/MANUAL 'X'
|
||||
not ebx
|
||||
and ebx,1
|
||||
imul ebx,10
|
||||
add ebx,145*65536+69
|
||||
mov eax,4
|
||||
mov ecx,0xffffff
|
||||
mov edx,xx
|
||||
mov esi,1
|
||||
mcall
|
||||
|
||||
mov eax,47 ; COM ADDRESS
|
||||
mov ebx,3*65536+1*256
|
||||
mov ecx,[com_add]
|
||||
mov edx,272*65536+40
|
||||
mov esi,0x000000
|
||||
mcall
|
||||
|
||||
;mov eax,47 ; COM IRQ
|
||||
mov ebx,1*65536+1*256
|
||||
mov ecx,[com_irq]
|
||||
mov edx,(266+3*6)*65536+50
|
||||
mov esi,0x000000
|
||||
mcall
|
||||
|
||||
mov edi,ip_address
|
||||
mov edx,205*65536+80
|
||||
mov esi,0x000000
|
||||
mov ebx,3*65536
|
||||
ipdisplay:
|
||||
;mov eax,47
|
||||
movzx ecx,byte [edi]
|
||||
mcall
|
||||
add edx,6*4*65536
|
||||
inc edi
|
||||
cmp edi,ip_address+4
|
||||
jb ipdisplay
|
||||
|
||||
mov edi,gateway_ip
|
||||
mov edx,205*65536+90
|
||||
mov esi,0x000000
|
||||
mov ebx,3*65536
|
||||
gipdisplay:
|
||||
;mov eax,47
|
||||
movzx ecx,byte [edi]
|
||||
mcall
|
||||
add edx,6*4*65536
|
||||
inc edi
|
||||
cmp edi,gateway_ip+4
|
||||
jb gipdisplay
|
||||
|
||||
mov edi,subnet_mask
|
||||
mov edx,205*65536+100
|
||||
mov esi,0x000000
|
||||
mov ebx,3*65536
|
||||
sipdisplay:
|
||||
;mov eax,47
|
||||
movzx ecx,byte [edi]
|
||||
mcall
|
||||
add edx,6*4*65536
|
||||
inc edi
|
||||
cmp edi,subnet_mask+4
|
||||
jb sipdisplay
|
||||
|
||||
mov edi,dns_ip
|
||||
mov edx,205*65536+110
|
||||
mov esi,0x000000
|
||||
mov ebx,3*65536
|
||||
dipdisplay:
|
||||
;mov eax,47
|
||||
movzx ecx,byte [edi]
|
||||
mcall
|
||||
add edx,6*4*65536
|
||||
inc edi
|
||||
cmp edi,dns_ip+4
|
||||
jb dipdisplay
|
||||
|
||||
|
||||
mov eax,8 ; BUTTON 5 : SET PORT
|
||||
mov ebx,299*65536+8
|
||||
mov ecx,39*65536+8
|
||||
mov edx,5
|
||||
mov esi,[button_color]
|
||||
mcall
|
||||
;mov eax,8 ; BUTTON 6 : SET IRQ
|
||||
mov ecx,49*65536+8
|
||||
inc edx
|
||||
mcall
|
||||
;mov eax,8 ; BUTTON 7 : SET IP
|
||||
mov ecx,79*65536+8
|
||||
inc edx
|
||||
mcall
|
||||
|
||||
;mov eax,8 ; BUTTON 8 : SET gateway IP
|
||||
mov ebx,299*65536+8
|
||||
mov ecx,89*65536+8
|
||||
inc edx
|
||||
mcall
|
||||
|
||||
;mov eax,8 ; BUTTON 9 : SET subnet
|
||||
mov ecx,99*65536+8
|
||||
inc edx
|
||||
mcall
|
||||
|
||||
;mov eax,8 ; BUTTON 10 : SET dns ip
|
||||
mov ecx,109*65536+8
|
||||
inc edx
|
||||
mcall
|
||||
|
||||
mov ebx,31*65536+40 ; draw info text with function 4
|
||||
mov edx,text
|
||||
mov esi,49
|
||||
mov eax,4
|
||||
newline:
|
||||
mov ecx,0x224466
|
||||
cmp [edx],byte 'w'
|
||||
jne nowhite
|
||||
mov ecx,0xeeeeee
|
||||
nowhite:
|
||||
inc edx
|
||||
mcall
|
||||
add ebx,10
|
||||
add edx,49
|
||||
cmp [edx],byte 'x'
|
||||
jne newline
|
||||
|
||||
mov eax,12 ; function 12:tell os about windowdraw
|
||||
mov ebx,2 ; 2, end of draw
|
||||
mcall
|
||||
|
||||
ret
|
||||
|
||||
|
||||
; DATA AREA
|
||||
|
||||
if lang eq ru
|
||||
title db '<27> áâனª á¥â¥¢®£® á⥪ ',0
|
||||
text:
|
||||
db ' <20>¥ ªâ¨¢ë© Œ®¤¥¬ Com-¯®àâã: 0x < '
|
||||
db ' Slip <20>à¥àë¢ ¨¥ ¬®¤¥¬ : 0x < '
|
||||
db ' PPP '
|
||||
db ' „à ©¢¥à ¯ ª¥â®¢ IP § ç ¥âáï á¥à¢¥à®¬ '
|
||||
db ' (Ethernet) ”¨ªá.: . . . < '
|
||||
db ' ˜«î§: . . . < '
|
||||
db ' <20>®¤á¥âì: . . . < '
|
||||
db ' DNS IP: . . . < '
|
||||
db ' '
|
||||
db 'w —¨â âì <20>ਬ¥¨âì '
|
||||
|
||||
else if lang eq nl
|
||||
title db 'Netwerk configuratie',0
|
||||
text:
|
||||
db ' Niet actief Modem Com Poort: 0x < '
|
||||
db ' Slip Modem Com Irq: 0x < '
|
||||
db ' PPP '
|
||||
db ' Pakket Driver Door IP-server toegekend '
|
||||
db ' (Ethernet) Vast IP: . . . < '
|
||||
db ' Gateway: . . . < '
|
||||
db ' Subnet: . . . < '
|
||||
db ' DNS IP: . . . < '
|
||||
db ' '
|
||||
db 'w Vernieuw Toepassen '
|
||||
|
||||
else if lang eq ua
|
||||
title db '<27> « èâã¢ ï ¬¥à¥¦i'
|
||||
text:
|
||||
db ' <20>¥ ªâ¨¢¨© Œ®¤¥¬ Com-¯®àâã 0x < '
|
||||
db ' Slip Com-¯®àâ ¬®¤¥¬ : 0x < '
|
||||
db ' PPP '
|
||||
db ' „à ©¢¥à ¯ ª¥âi¢ IP ¯à¨§ ç óâìáï á¥à¢¥à®¬ '
|
||||
db ' (Ethernet) ”iªá.: . . . < '
|
||||
db ' Œ àèàãâ: . . . < '
|
||||
db ' Œ ᪠: . . . < '
|
||||
db ' DNS IP . . . < '
|
||||
db ' '
|
||||
db 'w <20>à®ç¨â ⨠‡ áâ®á㢠⨠'
|
||||
|
||||
else
|
||||
title db 'Stack configuration',0
|
||||
text:
|
||||
db ' Not active Modem Com Port: 0x < '
|
||||
db ' Slip Modem Com Irq: 0x < '
|
||||
db ' PPP '
|
||||
db ' Packet Driver IP server assigned '
|
||||
db ' (Ethernet) Fixed: . . . < '
|
||||
db ' Gateway: . . . < '
|
||||
db ' Subnet: . . . < '
|
||||
db ' DNS IP: . . . < '
|
||||
db ' '
|
||||
db 'w READ APPLY '
|
||||
end if
|
||||
|
||||
xx: db 'x' ;<- END MARKER, DONT DELETE
|
||||
|
||||
button_color dd 0x2254b9
|
||||
|
||||
|
||||
|
||||
ip_address dd ?
|
||||
gateway_ip dd ?
|
||||
subnet_mask dd ?
|
||||
dns_ip dd ?
|
||||
|
||||
|
||||
com_irq dd ? ; irq for slip/ppp
|
||||
com_add dd ? ; com port address for slip/ppp
|
||||
interface dd ? ; not active,slip,ppp,packet driver
|
||||
assigned dd ? ; get ip from server
|
||||
|
||||
config dd ?
|
||||
|
||||
I_END:
|
@ -1,5 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix en >lang.inc
|
||||
@fasm telnet.asm telnet
|
||||
@erase lang.inc
|
||||
@pause
|
@ -1,5 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix ru >lang.inc
|
||||
@fasm telnet.asm telnet
|
||||
@erase lang.inc
|
||||
@pause
|
@ -1,793 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;
|
||||
; TERMINAL
|
||||
;
|
||||
; Compile with FASM for Menuet
|
||||
;
|
||||
|
||||
use32
|
||||
org 0x0
|
||||
db 'MENUET01' ; header
|
||||
dd 0x01 ; header version
|
||||
dd START ; entry point
|
||||
dd I_END ; image size
|
||||
dd I_END+0x10000 ; required memory
|
||||
dd I_END+0x10000 ; esp
|
||||
dd 0x0 , 0x0 ; I_Param , I_Path
|
||||
|
||||
|
||||
include 'lang.inc'
|
||||
include 'macros.inc'
|
||||
|
||||
START: ; start of execution
|
||||
|
||||
; Clear the screen memory
|
||||
mov eax, ' '
|
||||
mov edi,text
|
||||
mov ecx,80*30 /4
|
||||
cld
|
||||
rep stosd
|
||||
|
||||
|
||||
call draw_window
|
||||
|
||||
|
||||
still:
|
||||
; check connection status
|
||||
mov eax,53
|
||||
mov ebx,6
|
||||
mov ecx,[socket]
|
||||
mcall
|
||||
|
||||
mov ebx, [socket_status]
|
||||
mov [socket_status], eax
|
||||
|
||||
cmp eax, ebx
|
||||
je waitev
|
||||
|
||||
red:
|
||||
call draw_window
|
||||
|
||||
waitev:
|
||||
mov eax,23 ; wait here for event
|
||||
mov ebx,20
|
||||
mcall
|
||||
|
||||
cmp eax,1 ; redraw request ?
|
||||
je red
|
||||
cmp eax,2 ; key in buffer ?
|
||||
je key
|
||||
cmp eax,3 ; button in buffer ?
|
||||
je button
|
||||
|
||||
; any data from the socket?
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 2
|
||||
mov ecx, [socket]
|
||||
mcall
|
||||
cmp eax, 0
|
||||
jne read_input
|
||||
|
||||
jmp still
|
||||
|
||||
|
||||
read_input:
|
||||
|
||||
push ecx
|
||||
mov eax, 53
|
||||
mov ebx, 3
|
||||
mov ecx, [socket]
|
||||
mcall
|
||||
pop ecx
|
||||
|
||||
call handle_data
|
||||
|
||||
push ecx
|
||||
mov eax, 53
|
||||
mov ebx, 2
|
||||
mov ecx, [socket]
|
||||
mcall
|
||||
pop ecx
|
||||
cmp eax, 0
|
||||
|
||||
|
||||
jne read_input
|
||||
call draw_text
|
||||
jmp still
|
||||
|
||||
|
||||
|
||||
handle_data:
|
||||
; Telnet servers will want to negotiate options about our terminal window
|
||||
; just reject them all.
|
||||
; Telnet options start with the byte 0xff and are 3 bytes long.
|
||||
|
||||
mov al, [telnetstate]
|
||||
cmp al, 0
|
||||
je state0
|
||||
cmp al, 1
|
||||
je state1
|
||||
cmp al, 2
|
||||
je state2
|
||||
jmp hd001
|
||||
|
||||
state0:
|
||||
cmp bl, 255
|
||||
jne hd001
|
||||
mov al, 1
|
||||
mov [telnetstate], al
|
||||
ret
|
||||
|
||||
state1:
|
||||
mov al, 2
|
||||
mov [telnetstate], al
|
||||
ret
|
||||
|
||||
state2:
|
||||
mov al, 0
|
||||
mov [telnetstate], al
|
||||
mov [telnetrep+2], bl
|
||||
|
||||
mov edx, 3
|
||||
mov eax,53
|
||||
mov ebx,7
|
||||
mov ecx,[socket]
|
||||
mov esi, telnetrep
|
||||
mcall
|
||||
ret
|
||||
|
||||
hd001:
|
||||
cmp bl,13 ; BEGINNING OF LINE
|
||||
jne nobol
|
||||
mov ecx,[pos]
|
||||
add ecx,1
|
||||
boll1:
|
||||
sub ecx,1
|
||||
mov eax,ecx
|
||||
xor edx,edx
|
||||
mov ebx,80
|
||||
div ebx
|
||||
cmp edx,0
|
||||
jne boll1
|
||||
mov [pos],ecx
|
||||
jmp newdata
|
||||
nobol:
|
||||
|
||||
cmp bl,10 ; LINE DOWN
|
||||
jne nolf
|
||||
addx1:
|
||||
add [pos],dword 1
|
||||
mov eax,[pos]
|
||||
xor edx,edx
|
||||
mov ecx,80
|
||||
div ecx
|
||||
cmp edx,0
|
||||
jnz addx1
|
||||
mov eax,[pos]
|
||||
jmp cm1
|
||||
nolf:
|
||||
|
||||
cmp bl,8 ; BACKSPACE
|
||||
jne nobasp
|
||||
mov eax,[pos]
|
||||
dec eax
|
||||
mov [pos],eax
|
||||
mov [eax+text],byte 32
|
||||
mov [eax+text+60*80],byte 0
|
||||
jmp newdata
|
||||
nobasp:
|
||||
|
||||
cmp bl,15 ; CHARACTER
|
||||
jbe newdata
|
||||
mov eax,[pos]
|
||||
mov [eax+text],bl
|
||||
mov eax,[pos]
|
||||
add eax,1
|
||||
cm1:
|
||||
mov ebx,[scroll+4]
|
||||
imul ebx,80
|
||||
cmp eax,ebx
|
||||
jb noeaxz
|
||||
mov esi,text+80
|
||||
mov edi,text
|
||||
mov ecx,ebx
|
||||
cld
|
||||
rep movsb
|
||||
mov eax,ebx
|
||||
sub eax,80
|
||||
noeaxz:
|
||||
mov [pos],eax
|
||||
newdata:
|
||||
ret
|
||||
|
||||
key: ; KEY
|
||||
mov eax,2 ; send to modem
|
||||
mcall
|
||||
|
||||
mov ebx, [socket_status]
|
||||
cmp ebx, 4 ; connection open?
|
||||
jne still ; no, so ignore key
|
||||
|
||||
shr eax,8
|
||||
cmp eax,178 ; ARROW KEYS
|
||||
jne noaup
|
||||
mov al,'A'
|
||||
call arrow
|
||||
jmp still
|
||||
noaup:
|
||||
cmp eax,177
|
||||
jne noadown
|
||||
mov al,'B'
|
||||
call arrow
|
||||
jmp still
|
||||
noadown:
|
||||
cmp eax,179
|
||||
jne noaright
|
||||
mov al,'C'
|
||||
call arrow
|
||||
jmp still
|
||||
noaright:
|
||||
cmp eax,176
|
||||
jne noaleft
|
||||
mov al,'D'
|
||||
call arrow
|
||||
jmp still
|
||||
noaleft:
|
||||
modem_out:
|
||||
|
||||
call to_modem
|
||||
|
||||
jmp still
|
||||
|
||||
button: ; BUTTON
|
||||
mov eax,17
|
||||
mcall
|
||||
cmp ah,1 ; CLOSE PROGRAM
|
||||
jne noclose
|
||||
|
||||
mov eax,53
|
||||
mov ebx,8
|
||||
mov ecx,[socket]
|
||||
mcall
|
||||
|
||||
or eax,-1
|
||||
mcall
|
||||
noclose:
|
||||
cmp ah, 2 ; Set IP
|
||||
jne notip
|
||||
|
||||
mov [string_x], dword 78
|
||||
mov [string_y], dword 276
|
||||
mov [string_length], dword 15
|
||||
call read_string
|
||||
mov esi,string-1
|
||||
mov edi,ip_address
|
||||
xor eax,eax
|
||||
ip1:
|
||||
inc esi
|
||||
cmp [esi],byte '0'
|
||||
jb ip2
|
||||
cmp [esi],byte '9'
|
||||
jg ip2
|
||||
imul eax,10
|
||||
movzx ebx,byte [esi]
|
||||
sub ebx,48
|
||||
add eax,ebx
|
||||
jmp ip1
|
||||
ip2:
|
||||
mov [edi],al
|
||||
xor eax,eax
|
||||
inc edi
|
||||
cmp edi,ip_address+3
|
||||
jbe ip1
|
||||
call draw_window
|
||||
|
||||
|
||||
jmp still
|
||||
|
||||
notip:
|
||||
cmp ah, 3 ; set port
|
||||
jne notport
|
||||
|
||||
mov [string_x], dword 215
|
||||
mov [string_y], dword 276
|
||||
mov [string_length], dword 4
|
||||
call read_string
|
||||
mov esi,string-1
|
||||
mov edi,port
|
||||
xor eax,eax
|
||||
ip11:
|
||||
inc esi
|
||||
cmp [esi],byte '0'
|
||||
jb ip21
|
||||
cmp [esi],byte '9'
|
||||
jg ip21
|
||||
imul eax,10
|
||||
movzx ebx,byte [esi]
|
||||
sub ebx,48
|
||||
add eax,ebx
|
||||
jmp ip11
|
||||
ip21:
|
||||
mov [edi],al
|
||||
inc edi
|
||||
mov [edi],ah
|
||||
call draw_window
|
||||
|
||||
|
||||
jmp still
|
||||
|
||||
notport:
|
||||
cmp ah, 4 ; connect
|
||||
jne notcon
|
||||
|
||||
mov eax, [socket_status]
|
||||
cmp eax, 4
|
||||
je still
|
||||
call connect
|
||||
|
||||
jmp still
|
||||
|
||||
notcon:
|
||||
cmp ah,5 ; disconnect
|
||||
jne notdiscon
|
||||
|
||||
call disconnect
|
||||
jmp still
|
||||
|
||||
notdiscon: ; Echo Toggle
|
||||
cmp ah, 6
|
||||
jne still
|
||||
|
||||
mov al, [echo]
|
||||
not al
|
||||
mov [echo], al
|
||||
|
||||
call draw_window
|
||||
jmp still
|
||||
|
||||
arrow:
|
||||
|
||||
push eax
|
||||
mov al,27
|
||||
call to_modem
|
||||
mov al,'['
|
||||
call to_modem
|
||||
pop eax
|
||||
call to_modem
|
||||
|
||||
ret
|
||||
|
||||
|
||||
to_modem:
|
||||
pusha
|
||||
push ax
|
||||
mov [tx_buff], al
|
||||
mov edx, 1
|
||||
cmp al, 13
|
||||
jne tm_000
|
||||
mov edx, 2
|
||||
tm_000:
|
||||
mov eax,53
|
||||
mov ebx,7
|
||||
mov ecx,[socket]
|
||||
mov esi, tx_buff
|
||||
mcall
|
||||
pop bx
|
||||
mov al, [echo]
|
||||
cmp al, 0
|
||||
je tm_001
|
||||
|
||||
push bx
|
||||
call handle_data
|
||||
pop bx
|
||||
|
||||
cmp bl, 13
|
||||
jne tm_002
|
||||
|
||||
mov bl, 10
|
||||
call handle_data
|
||||
|
||||
tm_002:
|
||||
call draw_text
|
||||
|
||||
tm_001:
|
||||
popa
|
||||
ret
|
||||
|
||||
|
||||
|
||||
disconnect:
|
||||
mov eax,53
|
||||
mov ebx,8
|
||||
mov ecx,[socket]
|
||||
mcall
|
||||
ret
|
||||
|
||||
|
||||
|
||||
connect:
|
||||
pusha
|
||||
|
||||
mov ecx, 1000 ; local port starting at 1000
|
||||
|
||||
getlp:
|
||||
inc ecx
|
||||
push ecx
|
||||
mov eax, 53
|
||||
mov ebx, 9
|
||||
mcall
|
||||
pop ecx
|
||||
cmp eax, 0 ; is this local port in use?
|
||||
jz getlp ; yes - so try next
|
||||
|
||||
mov eax,53
|
||||
mov ebx,5
|
||||
mov dl, [ip_address + 3]
|
||||
shl edx, 8
|
||||
mov dl, [ip_address + 2]
|
||||
shl edx, 8
|
||||
mov dl, [ip_address + 1]
|
||||
shl edx, 8
|
||||
mov dl, [ip_address]
|
||||
mov esi, edx
|
||||
movzx edx, word [port] ; telnet port id
|
||||
mov edi,1 ; active open
|
||||
mcall
|
||||
mov [socket], eax
|
||||
|
||||
popa
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; *********************************************
|
||||
; ******* WINDOW DEFINITIONS AND DRAW ********
|
||||
; *********************************************
|
||||
|
||||
|
||||
draw_window:
|
||||
|
||||
pusha
|
||||
|
||||
mov eax,12
|
||||
mov ebx,1
|
||||
mcall
|
||||
|
||||
xor eax,eax ; DRAW WINDOW
|
||||
mov ebx,100*65536+491 + 8 +15
|
||||
mov ecx,100*65536+270 + 20 ; 20 for status bar
|
||||
mov edx,0x14000000
|
||||
mov edi,title
|
||||
mcall
|
||||
|
||||
; draw status bar
|
||||
mov eax, 13
|
||||
mov ebx, 4*65536+484 + 8 +15
|
||||
mov ecx, 270*65536 + 3
|
||||
mov edx, 0x00557799
|
||||
mcall
|
||||
|
||||
mov eax,8 ; BUTTON 2: SET IP
|
||||
mov ebx,4*65536+70
|
||||
mov ecx,273*65536+12
|
||||
mov esi, 0x00557799
|
||||
mov edx,2
|
||||
mcall
|
||||
|
||||
mov eax,4 ; Button text
|
||||
mov ebx,6*65536+276
|
||||
mov ecx,0x00ffffff
|
||||
mov edx,setipt
|
||||
mov esi,setiplen-setipt
|
||||
mcall
|
||||
|
||||
|
||||
mov eax,47
|
||||
mov edi,ip_address ; display IP address
|
||||
mov edx,78*65536+276
|
||||
mov esi,0x00ffffff
|
||||
mov ebx,3*65536
|
||||
ipdisplay:
|
||||
movzx ecx,byte [edi]
|
||||
mcall
|
||||
add edx,6*4*65536
|
||||
inc edi
|
||||
cmp edi,ip_address+4
|
||||
jb ipdisplay
|
||||
|
||||
mov eax,8 ; BUTTON 3: SET PORT
|
||||
mov ebx,173*65536+38
|
||||
mov ecx,273*65536+12
|
||||
mov edx,3
|
||||
mov esi, 0x00557799
|
||||
mcall
|
||||
|
||||
mov eax,4 ; Button text
|
||||
mov ebx,178*65536+276
|
||||
mov ecx,0x00ffffff
|
||||
mov edx,setportt
|
||||
mov esi,setportlen-setportt
|
||||
mcall
|
||||
|
||||
|
||||
mov edx,216*65536+276 ; display port
|
||||
mov esi,0x00ffffff
|
||||
mov ebx,4*65536
|
||||
mov eax,47
|
||||
movzx ecx,word [port]
|
||||
mcall
|
||||
|
||||
mov eax,8 ; BUTTON 4: Connect
|
||||
mov ebx,250*65536+50
|
||||
mov ecx,273*65536+12
|
||||
mov esi, 0x00557799
|
||||
mov edx,4
|
||||
mcall
|
||||
|
||||
mov eax,4 ; Button text
|
||||
mov ebx,255*65536+276
|
||||
mov ecx,0x00ffffff
|
||||
mov edx,cont
|
||||
mov esi,conlen-cont
|
||||
mcall
|
||||
|
||||
|
||||
mov eax,8 ; BUTTON 5: disconnect
|
||||
mov ebx,303*65536+70
|
||||
mov ecx,273*65536+12
|
||||
mov edx,5
|
||||
mov esi, 0x00557799
|
||||
mcall
|
||||
|
||||
|
||||
mov eax,4 ; Button text
|
||||
mov ebx,307*65536+276
|
||||
mov ecx,0x00ffffff
|
||||
mov edx,dist
|
||||
mov esi,dislen-dist
|
||||
mcall
|
||||
|
||||
|
||||
mov esi,contlen-contt ; display connected status
|
||||
mov edx, contt
|
||||
mov eax, [socket_status]
|
||||
cmp eax, 4 ; 4 is connected
|
||||
je pcon
|
||||
mov esi,discontlen-discontt
|
||||
mov edx, discontt
|
||||
pcon:
|
||||
|
||||
mov eax,4 ; status text
|
||||
mov ebx,380*65536+276
|
||||
mov ecx,0x00ffffff
|
||||
mcall
|
||||
|
||||
|
||||
mov eax,8 ; BUTTON 6: echo
|
||||
mov ebx,460*65536+50
|
||||
mov ecx,273*65536+12
|
||||
mov edx,6
|
||||
mov esi, 0x00557799
|
||||
mcall
|
||||
|
||||
mov edx,echot
|
||||
mov esi,echolen-echot
|
||||
mov al, [echo]
|
||||
cmp al, 0
|
||||
jne peo
|
||||
mov edx,echoot
|
||||
mov esi,echoolen-echoot
|
||||
|
||||
peo:
|
||||
mov eax,4 ; Button text
|
||||
mov ebx,463*65536+276
|
||||
mov ecx,0x00ffffff
|
||||
mcall
|
||||
|
||||
|
||||
xor eax,eax
|
||||
mov edi,text+80*30
|
||||
mov ecx,80*30 /4
|
||||
cld
|
||||
rep stosd
|
||||
|
||||
call draw_text
|
||||
|
||||
mov eax,12
|
||||
mov ebx,2
|
||||
mcall
|
||||
|
||||
popa
|
||||
|
||||
ret
|
||||
|
||||
|
||||
draw_text:
|
||||
|
||||
pusha
|
||||
|
||||
mov esi,text
|
||||
mov eax,0
|
||||
mov ebx,0
|
||||
newletter:
|
||||
mov cl,[esi]
|
||||
cmp cl,[esi+30*80]
|
||||
jne yesletter
|
||||
jmp noletter
|
||||
yesletter:
|
||||
mov [esi+30*80],cl
|
||||
|
||||
; erase character
|
||||
|
||||
pusha
|
||||
mov edx, 0 ; bg colour
|
||||
mov ecx, ebx
|
||||
add ecx, 26
|
||||
shl ecx, 16
|
||||
mov cx, 9
|
||||
mov ebx, eax
|
||||
add ebx, 6
|
||||
shl ebx, 16
|
||||
mov bx, 6
|
||||
mov eax, 13
|
||||
mcall
|
||||
popa
|
||||
|
||||
; draw character
|
||||
|
||||
pusha
|
||||
mov ecx, 0x00ffffff
|
||||
push bx
|
||||
mov ebx,eax
|
||||
add ebx,6
|
||||
shl ebx,16
|
||||
pop bx
|
||||
add bx,26
|
||||
mov eax,4
|
||||
mov edx,esi
|
||||
mov esi,1
|
||||
mcall
|
||||
popa
|
||||
|
||||
noletter:
|
||||
|
||||
add esi,1
|
||||
add eax,6
|
||||
cmp eax,80*6
|
||||
jb newletter
|
||||
mov eax,0
|
||||
add ebx,10
|
||||
cmp ebx,24*10
|
||||
jb newletter
|
||||
|
||||
popa
|
||||
ret
|
||||
|
||||
|
||||
read_string:
|
||||
|
||||
mov edi,string
|
||||
mov eax,'_'
|
||||
mov ecx,[string_length]
|
||||
inc ecx
|
||||
cld
|
||||
rep stosb
|
||||
call print_text
|
||||
|
||||
mov edi,string
|
||||
f11:
|
||||
mov eax,10
|
||||
mcall
|
||||
cmp eax,2
|
||||
jne read_done
|
||||
mov eax,2
|
||||
mcall
|
||||
shr eax,8
|
||||
cmp eax,13
|
||||
je read_done
|
||||
cmp eax,8
|
||||
jnz nobsl
|
||||
cmp edi,string
|
||||
jz f11
|
||||
sub edi,1
|
||||
mov [edi],byte '_'
|
||||
call print_text
|
||||
jmp f11
|
||||
nobsl:
|
||||
cmp eax,dword 31
|
||||
jbe f11
|
||||
cmp eax,dword 95
|
||||
jb keyok
|
||||
sub eax,32
|
||||
keyok:
|
||||
mov [edi],al
|
||||
call print_text
|
||||
|
||||
inc edi
|
||||
mov esi,string
|
||||
add esi,[string_length]
|
||||
cmp esi,edi
|
||||
jnz f11
|
||||
|
||||
read_done:
|
||||
|
||||
call print_text
|
||||
|
||||
ret
|
||||
|
||||
|
||||
print_text:
|
||||
|
||||
pusha
|
||||
|
||||
mov eax,13
|
||||
mov ebx,[string_x]
|
||||
shl ebx,16
|
||||
add ebx,[string_length]
|
||||
imul bx,6
|
||||
mov ecx,[string_y]
|
||||
shl ecx,16
|
||||
mov cx,8
|
||||
mov edx,0x00000000
|
||||
mcall
|
||||
|
||||
mov eax,4
|
||||
mov ebx,[string_x]
|
||||
shl ebx,16
|
||||
add ebx,[string_y]
|
||||
mov ecx,0x00ffffff
|
||||
mov edx,string
|
||||
mov esi,[string_length]
|
||||
mcall
|
||||
|
||||
popa
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
; DATA AREA
|
||||
|
||||
telnetrep db 0xff,0xfc,0x00
|
||||
telnetstate db 0
|
||||
|
||||
string_length dd 16
|
||||
string_x dd 200
|
||||
string_y dd 60
|
||||
|
||||
string db '________________'
|
||||
|
||||
tx_buff db 0, 10
|
||||
ip_address db 001,002,003,004
|
||||
port db 0,0
|
||||
echo db 0
|
||||
socket dd 0x0
|
||||
socket_status dd 0x0
|
||||
pos dd 80 * 1
|
||||
scroll dd 1
|
||||
dd 24
|
||||
wcolor dd 0x000000
|
||||
title db 'Telnet v0.1',0
|
||||
setipt db 'IP Address: . . .'
|
||||
setiplen:
|
||||
setportt db 'Port:'
|
||||
setportlen:
|
||||
cont db 'Connect'
|
||||
conlen:
|
||||
dist db 'Disconnect'
|
||||
dislen:
|
||||
contt db 'Connected'
|
||||
contlen:
|
||||
discontt db 'Disconnected'
|
||||
discontlen:
|
||||
echot db 'Echo On'
|
||||
echolen:
|
||||
echoot db 'Echo Off'
|
||||
echoolen:
|
||||
|
||||
|
||||
|
||||
text:
|
||||
I_END:
|
@ -1,5 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix en >lang.inc
|
||||
@fasm terminal.asm terminal
|
||||
@erase lang.inc
|
||||
@pause
|
@ -1,5 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix ru >lang.inc
|
||||
@fasm terminal.asm terminal
|
||||
@erase lang.inc
|
||||
@pause
|
@ -1,727 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;
|
||||
; TERMINAL
|
||||
|
||||
use32
|
||||
org 0x0
|
||||
db 'MENUET01' ; header
|
||||
dd 0x01 ; header version
|
||||
dd START ; entry point
|
||||
dd I_END ; image size
|
||||
dd I_END+0x10000 ; required memory
|
||||
dd I_END+0x10000 ; esp
|
||||
dd 0x0 , 0x0 ; I_Param , I_Path
|
||||
|
||||
include 'lang.inc'
|
||||
include '..\..\..\macros.inc'
|
||||
|
||||
|
||||
START: ; start of execution
|
||||
|
||||
call draw_window
|
||||
|
||||
call set_variables
|
||||
|
||||
still:
|
||||
|
||||
mov eax,23 ; wait here for event
|
||||
mov ebx,20
|
||||
mcall
|
||||
|
||||
cmp eax,1 ; redraw request ?
|
||||
je red
|
||||
cmp eax,2 ; key in buffer ?
|
||||
je key
|
||||
cmp eax,3 ; button in buffer ?
|
||||
je button
|
||||
cmp eax,16+4
|
||||
je read_input
|
||||
|
||||
jmp still
|
||||
|
||||
|
||||
read_input:
|
||||
mcall 42,4,text+120*80
|
||||
test eax, eax
|
||||
jle still
|
||||
|
||||
read_input_loop:
|
||||
mov bl,[ecx]
|
||||
inc ecx
|
||||
push eax ecx
|
||||
cmp bl,27 ; ESCAPE COMMAND
|
||||
jne no_esc
|
||||
call esc_command
|
||||
jmp newdata
|
||||
no_esc:
|
||||
|
||||
cmp bl,13 ; BEGINNING OF LINE
|
||||
jne nobol
|
||||
mov ecx,[pos]
|
||||
add ecx,1
|
||||
boll1:
|
||||
sub ecx,1
|
||||
mov eax,ecx
|
||||
xor edx,edx
|
||||
mov ebx,80
|
||||
div ebx
|
||||
cmp edx,0
|
||||
jne boll1
|
||||
mov [pos],ecx
|
||||
jmp newdata
|
||||
nobol:
|
||||
|
||||
cmp bl,10 ; LINE DOWN
|
||||
jne nolf
|
||||
addx1:
|
||||
add [pos],dword 1
|
||||
mov eax,[pos]
|
||||
xor edx,edx
|
||||
mov ecx,80
|
||||
div ecx
|
||||
cmp edx,0
|
||||
jnz addx1
|
||||
mov eax,[pos]
|
||||
jmp cm1
|
||||
nolf:
|
||||
|
||||
cmp bl,8 ; BACKSPACE
|
||||
jne nobasp
|
||||
mov eax,[pos]
|
||||
dec eax
|
||||
mov [pos],eax
|
||||
mov [eax+text],byte 32
|
||||
mov [eax+text+60*80],byte 0
|
||||
jmp newdata
|
||||
nobasp:
|
||||
|
||||
cmp bl,15 ; CHARACTER
|
||||
jbe newdata
|
||||
mov eax,[pos]
|
||||
call draw_data
|
||||
mov eax,[pos]
|
||||
add eax,1
|
||||
cm1:
|
||||
mov ebx,[scroll+4]
|
||||
imul ebx,80
|
||||
cmp eax,ebx
|
||||
jb noeaxz
|
||||
mov esi,text+80
|
||||
mov edi,text
|
||||
mov ecx,ebx
|
||||
cld
|
||||
rep movsb
|
||||
mov esi,text+80+60*80
|
||||
mov edi,text+60*80
|
||||
mov ecx,ebx
|
||||
cld
|
||||
rep movsb
|
||||
mov eax,ebx
|
||||
sub eax,80
|
||||
noeaxz:
|
||||
mov [pos],eax
|
||||
newdata:
|
||||
pop ecx eax
|
||||
dec eax
|
||||
jnz read_input_loop
|
||||
call draw_text
|
||||
jmp still
|
||||
|
||||
|
||||
red: ; REDRAW WINDOW
|
||||
call draw_window
|
||||
jmp still
|
||||
|
||||
key: ; KEY
|
||||
mov eax,2 ; send to modem
|
||||
mcall
|
||||
shr eax,8
|
||||
cmp eax,178 ; ARROW KEYS
|
||||
jne noaup
|
||||
mov al,'A'
|
||||
call arrow
|
||||
jmp still
|
||||
noaup:
|
||||
cmp eax,177
|
||||
jne noadown
|
||||
mov al,'B'
|
||||
call arrow
|
||||
jmp still
|
||||
noadown:
|
||||
cmp eax,179
|
||||
jne noaright
|
||||
mov al,'C'
|
||||
call arrow
|
||||
jmp still
|
||||
noaright:
|
||||
cmp eax,176
|
||||
jne noaleft
|
||||
mov al,'D'
|
||||
call arrow
|
||||
jmp still
|
||||
noaleft:
|
||||
modem_out:
|
||||
mov dx,0x3f8
|
||||
out dx,al
|
||||
jmp still
|
||||
|
||||
button: ; BUTTON
|
||||
mov eax,17
|
||||
mcall
|
||||
cmp ah,1 ; CLOSE PROGRAM
|
||||
jne noclose
|
||||
mov eax,45 ; FREE IRQ
|
||||
mov ebx,1
|
||||
mov ecx,4
|
||||
mcall
|
||||
mov eax,46
|
||||
mov ebx,1
|
||||
mov ecx,0x3f0
|
||||
mov edx,0x3ff
|
||||
mcall
|
||||
or eax,-1
|
||||
mcall
|
||||
noclose:
|
||||
|
||||
jmp still
|
||||
|
||||
|
||||
arrow:
|
||||
|
||||
push eax
|
||||
mov al,27
|
||||
call to_modem
|
||||
mov al,'['
|
||||
call to_modem
|
||||
pop eax
|
||||
call to_modem
|
||||
|
||||
ret
|
||||
|
||||
|
||||
to_modem:
|
||||
|
||||
pusha
|
||||
|
||||
mov dx,0x3f8
|
||||
out dx,al
|
||||
mov eax,5
|
||||
mov ebx,5
|
||||
mcall
|
||||
|
||||
popa
|
||||
ret
|
||||
|
||||
|
||||
draw_data:
|
||||
|
||||
pusha
|
||||
|
||||
cmp bl,0xe4 ; Á
|
||||
jne noe4
|
||||
mov bl,0xc1
|
||||
noe4:
|
||||
cmp bl,0xc4 ; É
|
||||
jne noc4
|
||||
mov bl,0xc9
|
||||
noc4:
|
||||
mov [eax+text],bl
|
||||
mov bl,byte [attribute]
|
||||
mov [eax+text+60*80],bl
|
||||
|
||||
popa
|
||||
ret
|
||||
|
||||
|
||||
irqtable:
|
||||
|
||||
dd 0x3f8 + 0x01000000 ; read port 0x3f8, byte
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
dd 0
|
||||
|
||||
|
||||
|
||||
|
||||
set_variables:
|
||||
|
||||
pusha
|
||||
|
||||
mov eax,46
|
||||
mov ebx,0
|
||||
mov ecx,0x3f0
|
||||
mov edx,0x3ff
|
||||
mcall
|
||||
|
||||
mov eax,45 ; reserve irq 4
|
||||
mov ebx,0
|
||||
mov ecx,4
|
||||
mcall
|
||||
|
||||
mov eax,44
|
||||
mov ebx,irqtable
|
||||
mov ecx,4
|
||||
mcall
|
||||
|
||||
; jmp noportint
|
||||
|
||||
mov dx,0x3f8+3
|
||||
mov al,0x80
|
||||
out dx,al
|
||||
|
||||
mov dx,0x3f8+1
|
||||
mov al,0
|
||||
out dx,al
|
||||
|
||||
mov dx,0x3f8+0
|
||||
mov al,0x30 / 16
|
||||
out dx,al
|
||||
|
||||
mov dx,0x3f8+3
|
||||
mov al,3
|
||||
out dx,al
|
||||
|
||||
mov dx,0x3f8+4
|
||||
mov al,0xB
|
||||
out dx,al
|
||||
|
||||
mov dx,0x3f8+1
|
||||
mov al,1
|
||||
out dx,al
|
||||
|
||||
noportint:
|
||||
|
||||
mov eax,40
|
||||
mov ebx,0000000000010000b shl 16 + 111b
|
||||
mcall
|
||||
|
||||
popa
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; *********************************************
|
||||
; ******* WINDOW DEFINITIONS AND DRAW ********
|
||||
; *********************************************
|
||||
|
||||
|
||||
draw_window:
|
||||
|
||||
pusha
|
||||
|
||||
mov eax,12
|
||||
mov ebx,1
|
||||
mcall
|
||||
|
||||
mov eax,0 ; DRAW WINDOW
|
||||
mov ebx,100*65536+491
|
||||
mov ecx,100*65536+270
|
||||
mov edx,0x13000000
|
||||
mov edi,title
|
||||
mcall
|
||||
|
||||
xor eax,eax
|
||||
mov edi,text+80*30
|
||||
mov ecx,80*30 /4
|
||||
cld
|
||||
rep stosd
|
||||
|
||||
call draw_text
|
||||
|
||||
mov eax,12
|
||||
mov ebx,2
|
||||
mcall
|
||||
|
||||
popa
|
||||
|
||||
ret
|
||||
|
||||
|
||||
bgc dd 0x000000
|
||||
dd 0x000000
|
||||
dd 0x00ff00
|
||||
dd 0x0000ff
|
||||
dd 0x005500
|
||||
dd 0xff00ff
|
||||
dd 0x00ffff
|
||||
dd 0x770077
|
||||
|
||||
tc dd 0xffffff
|
||||
dd 0xff00ff
|
||||
dd 0xffffff
|
||||
dd 0xffffff
|
||||
dd 0xffffff
|
||||
dd 0xffffff
|
||||
dd 0xffffff
|
||||
dd 0xffffff
|
||||
|
||||
|
||||
draw_text:
|
||||
|
||||
pusha
|
||||
|
||||
mov esi,text
|
||||
mov eax,0
|
||||
mov ebx,0
|
||||
newletter:
|
||||
mov cl,[esi]
|
||||
mov dl,[esi+60*80]
|
||||
cmp cl,[esi+30*80]
|
||||
jne yesletter
|
||||
cmp dl,[esi+90*80]
|
||||
jne yesletter
|
||||
jmp noletter
|
||||
yesletter:
|
||||
mov [esi+30*80],cl
|
||||
mov [esi+90*80],dl
|
||||
|
||||
pusha
|
||||
and edx,0xff
|
||||
shl edx,2
|
||||
add edx,bgc
|
||||
mov edx,[edx]
|
||||
mov ecx,ebx
|
||||
add ecx,26
|
||||
shl ecx,16
|
||||
mov cx,9
|
||||
mov ebx,eax
|
||||
add ebx,6
|
||||
shl ebx,16
|
||||
mov bx,6
|
||||
mov eax,13
|
||||
mcall
|
||||
popa
|
||||
|
||||
pusha
|
||||
and edx,0xff
|
||||
shl edx,2
|
||||
add edx,tc
|
||||
mov ecx,[edx]
|
||||
push bx
|
||||
mov ebx,eax
|
||||
add ebx,6
|
||||
shl ebx,16
|
||||
pop bx
|
||||
add bx,26
|
||||
mov eax,4
|
||||
mov edx,esi
|
||||
mov esi,1
|
||||
mcall
|
||||
popa
|
||||
|
||||
noletter:
|
||||
|
||||
add esi,1
|
||||
add eax,6
|
||||
cmp eax,80*6
|
||||
jb newletter
|
||||
mov eax,0
|
||||
add ebx,10
|
||||
cmp ebx,24*10
|
||||
jb newletter
|
||||
|
||||
popa
|
||||
ret
|
||||
|
||||
|
||||
esc_command:
|
||||
|
||||
mov eax,32
|
||||
mov edi,esccmd
|
||||
mov ecx,10
|
||||
cld
|
||||
rep stosb
|
||||
mov edi,esccmd
|
||||
newescc:
|
||||
mov eax,42
|
||||
mov ebx,4
|
||||
mcall
|
||||
cmp ecx,0
|
||||
je escok
|
||||
mov eax,5
|
||||
mov ebx,1
|
||||
mcall
|
||||
jmp newescc
|
||||
escok:
|
||||
mov [edi],bl
|
||||
add edi,1
|
||||
cmp edi,esccmd+20
|
||||
je dontunderstand
|
||||
mov esi,escend
|
||||
nec:
|
||||
cmp bl,[esi]
|
||||
jz com_ok
|
||||
add esi,1
|
||||
cmp [esi],byte 0
|
||||
je newescc
|
||||
jmp nec
|
||||
com_ok:
|
||||
|
||||
call get_numbers
|
||||
|
||||
cmp bl,'H' ; SET CURSOR POSITION
|
||||
jne no_cursor_position
|
||||
cmp [escnumbers],0
|
||||
jne ncp1
|
||||
mov [pos],dword 0
|
||||
jmp cmd_done
|
||||
ncp1:
|
||||
mov eax,[escnumbers]
|
||||
dec eax
|
||||
imul eax,80
|
||||
add eax,[escnumbers+4]
|
||||
dec eax
|
||||
mov [pos],eax
|
||||
jmp cmd_done
|
||||
no_cursor_position:
|
||||
|
||||
cmp bl,'K' ; ERASE LINE
|
||||
jne no_erase_end_of_line
|
||||
cmp [escnumbers],0
|
||||
jne no_end_line
|
||||
mov ecx,[pos]
|
||||
eeol:
|
||||
mov [ecx+text],byte ' '
|
||||
mov [ecx+text+60*80],byte 0
|
||||
add ecx,1
|
||||
xor edx,edx
|
||||
mov eax,ecx
|
||||
mov ebx,80
|
||||
div ebx
|
||||
cmp edx,0
|
||||
jne eeol
|
||||
jmp cmd_done
|
||||
no_end_line:
|
||||
cmp [escnumbers],1 ; BEGINNING OF LINE
|
||||
jne no_beg_line
|
||||
mov ecx,[pos]
|
||||
ebol:
|
||||
mov [ecx+text],byte ' '
|
||||
mov [ecx+text+60*80],byte 0
|
||||
sub ecx,1
|
||||
xor edx,edx
|
||||
mov eax,ecx
|
||||
mov ebx,80
|
||||
div ebx
|
||||
cmp edx,0
|
||||
jne ebol
|
||||
mov [pos],ecx
|
||||
jmp cmd_done
|
||||
no_beg_line:
|
||||
no_erase_end_of_line:
|
||||
|
||||
cmp bl,'J' ; ERASE TO END OF SCREEN
|
||||
jne no_erase_to_end_of_screen
|
||||
cmp [escnumbers],dword 0
|
||||
jne no_erase_to_end_of_screen
|
||||
mov ecx,[pos]
|
||||
eteos:
|
||||
mov [ecx+text],byte ' '
|
||||
mov [ecx+text+60*80],byte 0
|
||||
add ecx,1
|
||||
cmp ecx,80*24+1
|
||||
jb eteos
|
||||
jmp cmd_done
|
||||
no_erase_to_end_of_screen:
|
||||
|
||||
cmp bl,'r' ; SET SCROLL REGION
|
||||
jne no_scroll_region
|
||||
mov eax,[escnumbers]
|
||||
dec eax
|
||||
mov [scroll+0],eax
|
||||
mov eax,[escnumbers+4]
|
||||
mov [scroll+4],eax
|
||||
jmp cmd_done
|
||||
no_scroll_region:
|
||||
|
||||
cmp bl,'A' ; CURSOR UP
|
||||
jne no_cursor_up
|
||||
mov eax,[pos]
|
||||
sub eax,80
|
||||
mov [pos],eax
|
||||
jmp cmd_done
|
||||
no_cursor_up:
|
||||
|
||||
cmp bl,'C' ; CURSOR LEFT
|
||||
jne no_cursor_left
|
||||
mov eax,[pos]
|
||||
mov ebx,[escnumbers]
|
||||
sub eax,ebx
|
||||
mov [pos],eax
|
||||
call cmd_done
|
||||
no_cursor_left:
|
||||
|
||||
cmp bl,'m' ; CHARACTER ATTRIBUTE
|
||||
jne no_char_attribute
|
||||
mov eax,[escnumbers]
|
||||
mov [attribute],eax
|
||||
jmp cmd_done
|
||||
no_char_attribute:
|
||||
|
||||
cmp bl,'Z' ; TERMINAL TYPE
|
||||
jne no_terminal_type
|
||||
mov al,27
|
||||
call to_modem
|
||||
mov al,'?'
|
||||
call to_modem
|
||||
mov al,'1'
|
||||
call to_modem
|
||||
mov al,';'
|
||||
call to_modem
|
||||
mov al,'0'
|
||||
call to_modem
|
||||
mov al,'c'
|
||||
call to_modem
|
||||
jmp cmd_done
|
||||
no_terminal_type:
|
||||
|
||||
dontunderstand:
|
||||
|
||||
cmd_done:
|
||||
|
||||
ret
|
||||
|
||||
|
||||
draw_numbers:
|
||||
|
||||
pusha
|
||||
|
||||
mov eax,13
|
||||
mov ebx,250*65536+100
|
||||
mov ecx,8*65536+8
|
||||
mov edx,0x000000
|
||||
mcall
|
||||
|
||||
mov eax,[escnumbers]
|
||||
xor edx,edx
|
||||
mov ebx,10
|
||||
div ebx
|
||||
add eax,48
|
||||
add edx,48
|
||||
mov byte [numtext+0],al
|
||||
mov byte [numtext+1],dl
|
||||
|
||||
mov eax,[escnumbers+4]
|
||||
xor edx,edx
|
||||
mov ebx,10
|
||||
div ebx
|
||||
add eax,48
|
||||
add edx,48
|
||||
mov [numtext+3],al
|
||||
mov [numtext+4],dl
|
||||
|
||||
mov eax,4
|
||||
mov ebx,250*65536+8
|
||||
mov ecx,0xffffff
|
||||
mov edx,numtext
|
||||
mov esi,10
|
||||
mcall
|
||||
|
||||
popa
|
||||
|
||||
ret
|
||||
|
||||
draw_event:
|
||||
|
||||
pusha
|
||||
|
||||
mov eax,13
|
||||
mov ebx,150*65536+100
|
||||
mov ecx,8*65536+8
|
||||
mov edx,0xffffff
|
||||
mcall
|
||||
|
||||
mov eax,4
|
||||
mov ebx,150*65536+8
|
||||
mov ecx,0x000000
|
||||
mov edx,esccmd
|
||||
mov esi,20
|
||||
mcall
|
||||
|
||||
popa
|
||||
ret
|
||||
|
||||
|
||||
get_numbers:
|
||||
|
||||
pusha
|
||||
|
||||
mov [escnumbers+0],0
|
||||
mov [escnumbers+4],0
|
||||
mov [escnumbers+8],0
|
||||
mov ecx,esccmd
|
||||
cmp [ecx+1],byte '0'
|
||||
jb gn_over
|
||||
cmp [ecx+1],byte '9'
|
||||
jg gn_over
|
||||
mov edi,escnumbers
|
||||
gn_new:
|
||||
add ecx,1
|
||||
movzx eax,byte [ecx]
|
||||
sub eax,48
|
||||
add ecx,1
|
||||
cmp [ecx],byte '0'
|
||||
jb gnl1
|
||||
cmp [ecx],byte '9'
|
||||
jg gnl1
|
||||
mov ebx,10
|
||||
xor edx,edx
|
||||
mul ebx
|
||||
movzx ebx,byte[ecx]
|
||||
add eax,ebx
|
||||
sub eax,48
|
||||
add ecx,1
|
||||
gnl1:
|
||||
mov [edi],eax
|
||||
add edi,4
|
||||
cmp [ecx],byte ';'
|
||||
je gn_new
|
||||
gn_over:
|
||||
popa
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
; DATA AREA
|
||||
|
||||
|
||||
pos dd 80*10
|
||||
irc_data dd 0x0
|
||||
print db 0x0
|
||||
attribute dd 0
|
||||
scroll dd 1
|
||||
dd 24
|
||||
numtext db ' '
|
||||
esccmd dd 0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
escend db 'ZrhlABCDHfDME=>NmKJgincoyq',0
|
||||
escnumbers dd 0,0,0,0,0
|
||||
wcolor dd 0x000000
|
||||
title db 'TERMINAL FOR MODEM IN COM1 0.03',0
|
||||
|
||||
text:
|
||||
db ' '
|
||||
db ' '
|
||||
db '*** A TELNET APPLICATION FOR HAYES COMPATIBLE MODEMS IN COM1 '
|
||||
db ' '
|
||||
db '*** USE HAYES COMMANDS TO CONNECT TO A SERVER '
|
||||
db ' '
|
||||
db '*** ATDT (PHONENUMBER) '
|
||||
db ' '
|
||||
db ' '
|
||||
db ' '
|
||||
|
||||
I_END:
|
@ -1,5 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix en >lang.inc
|
||||
@fasm tftpc.asm tftpc
|
||||
@erase lang.inc
|
||||
@pause
|
@ -1,5 +0,0 @@
|
||||
@erase lang.inc
|
||||
@echo lang fix ru >lang.inc
|
||||
@fasm tftpc.asm tftpc
|
||||
@erase lang.inc
|
||||
@pause
|
@ -1,977 +0,0 @@
|
||||
;
|
||||
; TFTP Client
|
||||
|
||||
use32
|
||||
org 0x0
|
||||
db 'MENUET01' ; header
|
||||
dd 0x01 ; header version
|
||||
dd START ; entry point
|
||||
dd I_END ; image size
|
||||
dd I_END+0x10000 ; required memory
|
||||
dd I_END+0x10000 ; esp
|
||||
dd 0x0 , 0x0 ; I_Param , I_Path
|
||||
|
||||
include 'lang.inc'
|
||||
include '..\..\..\macros.inc'
|
||||
|
||||
START: ; start of execution
|
||||
mov eax,40 ; Report events
|
||||
mov ebx,10000111b ; Stack 8 + defaults
|
||||
mcall
|
||||
|
||||
mov dword [prompt], p1
|
||||
mov dword [promptlen], p1len - p1
|
||||
|
||||
red:
|
||||
call draw_window ; at first, draw the window
|
||||
|
||||
still:
|
||||
mov eax,10 ; wait here for event
|
||||
mcall
|
||||
|
||||
cmp eax,1 ; redraw request ?
|
||||
jz red
|
||||
cmp eax,2 ; key in buffer ?
|
||||
jz key
|
||||
cmp eax,3 ; button in buffer ?
|
||||
jz button
|
||||
|
||||
jmp still
|
||||
|
||||
key: ; Keys are not valid at this part of the
|
||||
mov eax,2 ; loop. Just read it and ignore
|
||||
mcall
|
||||
jmp still
|
||||
|
||||
button: ; button
|
||||
mov eax,17 ; get id
|
||||
mcall
|
||||
|
||||
cmp ah,1 ; button id=1 ?
|
||||
jnz noclose
|
||||
|
||||
|
||||
; close socket before exiting
|
||||
mov eax, 53
|
||||
mov ebx, 1
|
||||
mov ecx, [socketNum]
|
||||
int 0x40
|
||||
|
||||
mov [socketNum], dword 0
|
||||
|
||||
|
||||
or eax,-1 ; close this program
|
||||
mcall
|
||||
|
||||
noclose:
|
||||
cmp ah,2 ; copy file to local machine?
|
||||
jnz nocopyl
|
||||
|
||||
mov dword [prompt], p5
|
||||
mov dword [promptlen], p5len - p5
|
||||
call draw_window ;
|
||||
|
||||
; Copy File from Remote Host to this machine
|
||||
call translateData ; Convert Filename & IP address
|
||||
mov edi, tftp_filename + 1
|
||||
mov [edi], byte 0x01 ; setup tftp msg
|
||||
call copyFromRemote
|
||||
|
||||
jmp still
|
||||
|
||||
nocopyl:
|
||||
|
||||
cmp ah,3 ; Copy file to host?
|
||||
jnz nocopyh
|
||||
|
||||
mov dword [prompt], p5
|
||||
mov dword [promptlen], p5len - p5
|
||||
call draw_window ;
|
||||
|
||||
; Copy File from this machine to Remote Host
|
||||
call translateData ; Convert Filename & IP address
|
||||
mov edi, tftp_filename + 1
|
||||
mov [edi], byte 0x02 ; setup tftp msg
|
||||
call copyToRemote
|
||||
|
||||
jmp still
|
||||
|
||||
nocopyh:
|
||||
cmp ah,4
|
||||
jz f1
|
||||
cmp ah,5
|
||||
jz f2
|
||||
jmp nof12
|
||||
|
||||
f1:
|
||||
mov [addr],dword source
|
||||
mov [ya],dword 35
|
||||
jmp rk
|
||||
|
||||
f2:
|
||||
mov [addr],dword destination
|
||||
mov [ya],dword 35+16
|
||||
|
||||
rk:
|
||||
mov ecx,15
|
||||
mov edi,[addr]
|
||||
mov al,' '
|
||||
rep stosb
|
||||
|
||||
call print_text
|
||||
|
||||
mov edi,[addr]
|
||||
|
||||
f11:
|
||||
mov eax,10
|
||||
mcall
|
||||
cmp eax,2
|
||||
jz fbu
|
||||
jmp still
|
||||
fbu:
|
||||
mov eax,2
|
||||
mcall ; get key
|
||||
shr eax,8
|
||||
cmp eax,8
|
||||
jnz nobs
|
||||
cmp edi,[addr]
|
||||
jz f11
|
||||
sub edi,1
|
||||
mov [edi],byte ' '
|
||||
call print_text
|
||||
jmp f11
|
||||
nobs:
|
||||
cmp eax,dword 31
|
||||
jbe f11
|
||||
cmp eax,dword 95
|
||||
jb keyok
|
||||
sub eax,32
|
||||
keyok:
|
||||
mov [edi],al
|
||||
|
||||
call print_text
|
||||
|
||||
add edi,1
|
||||
mov esi,[addr]
|
||||
add esi,15
|
||||
cmp esi,edi
|
||||
jnz f11
|
||||
|
||||
jmp still
|
||||
|
||||
print_text:
|
||||
|
||||
mov eax,13
|
||||
mov ebx,103*65536+15*6
|
||||
mov ecx,[ya]
|
||||
shl ecx,16
|
||||
mov cx,8
|
||||
mov edx,0x224466
|
||||
mcall
|
||||
|
||||
mov eax,4
|
||||
mov ebx,103*65536
|
||||
add ebx,[ya]
|
||||
mov ecx,0xffffff
|
||||
mov edx,[addr]
|
||||
mov esi,15
|
||||
mcall
|
||||
|
||||
ret
|
||||
|
||||
|
||||
nof12:
|
||||
jmp still
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
; Function
|
||||
; translateData
|
||||
;
|
||||
; Description
|
||||
; Coverts the filename and IP address typed in by the user into
|
||||
; a format suitable for the IP layer.
|
||||
;
|
||||
; The filename, in source, is converted and stored in tftp_filename
|
||||
; The host ip, in destination, is converted and stored in tftp_IP
|
||||
;
|
||||
;***************************************************************************
|
||||
translateData:
|
||||
|
||||
; first, build up the tftp command string. This includes the filename
|
||||
; and the transfer protocol
|
||||
|
||||
|
||||
; First, write 0,0
|
||||
mov al, 0
|
||||
mov edi, tftp_filename
|
||||
mov [edi], al
|
||||
inc edi
|
||||
mov [edi], al
|
||||
inc edi
|
||||
|
||||
; Now, write the file name itself, and null terminate it
|
||||
mov ecx, 15
|
||||
mov ah, ' '
|
||||
mov esi, source
|
||||
|
||||
td001:
|
||||
lodsb
|
||||
stosb
|
||||
cmp al, ah
|
||||
loopnz td001
|
||||
|
||||
cmp al,ah ; Was the entire buffer full of characters?
|
||||
jne td002
|
||||
dec edi ; No - so remove ' ' character
|
||||
|
||||
td002:
|
||||
mov [edi], byte 0
|
||||
inc edi
|
||||
mov [edi], byte 'O'
|
||||
inc edi
|
||||
mov [edi], byte 'C'
|
||||
inc edi
|
||||
mov [edi], byte 'T'
|
||||
inc edi
|
||||
mov [edi], byte 'E'
|
||||
inc edi
|
||||
mov [edi], byte 'T'
|
||||
inc edi
|
||||
mov [edi], byte 0
|
||||
|
||||
mov esi, tftp_filename
|
||||
sub edi, esi
|
||||
mov [tftp_len], edi
|
||||
|
||||
|
||||
; Now, convert the typed IP address into a real address
|
||||
; No validation is done on the number entered
|
||||
; ip addresses must be typed in normally, eg
|
||||
; 192.1.45.24
|
||||
|
||||
xor eax, eax
|
||||
mov dh, 10
|
||||
mov dl, al
|
||||
mov [tftp_IP], eax
|
||||
|
||||
; 192.168.24.1 1.1.1.1 1. 9.2.3.
|
||||
|
||||
mov esi, destination
|
||||
mov edi, tftp_IP
|
||||
|
||||
mov ecx, 4
|
||||
|
||||
td003:
|
||||
lodsb
|
||||
sub al, '0'
|
||||
add dl, al
|
||||
lodsb
|
||||
cmp al, '.'
|
||||
je ipNext
|
||||
cmp al, ' '
|
||||
je ipNext
|
||||
mov dh, al
|
||||
sub dh, '0'
|
||||
mov al, 10
|
||||
mul dl
|
||||
add al, dh
|
||||
mov dl, al
|
||||
lodsb
|
||||
cmp al, '.'
|
||||
je ipNext
|
||||
cmp al, ' '
|
||||
je ipNext
|
||||
mov dh, al
|
||||
sub dh, '0'
|
||||
mov al, 10
|
||||
mul dl
|
||||
add al, dh
|
||||
mov dl, al
|
||||
lodsb
|
||||
|
||||
ipNext:
|
||||
mov [edi], dl
|
||||
inc edi
|
||||
mov dl, 0
|
||||
loop td003
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
; Function
|
||||
; copyFromRemote
|
||||
;
|
||||
; Description
|
||||
;
|
||||
;***************************************************************************
|
||||
copyFromRemote:
|
||||
xor eax, eax
|
||||
mov [filesize], eax
|
||||
mov eax, I_END + 512 ; This is the point where the file buffer is
|
||||
mov [fileposition], eax
|
||||
|
||||
; Get a random # for the local socket port #
|
||||
mov eax, 3
|
||||
int 0x40
|
||||
mov ecx, eax
|
||||
shr ecx, 8 ; Set up the local port # with a random #
|
||||
|
||||
; open socket
|
||||
mov eax, 53
|
||||
mov ebx, 0
|
||||
mov edx, 69 ; remote port
|
||||
mov esi, [tftp_IP] ; remote IP ( in intenet format )
|
||||
int 0x40
|
||||
|
||||
mov [socketNum], eax
|
||||
|
||||
; make sure there is no data in the socket - there shouldn't be..
|
||||
|
||||
cfr001:
|
||||
mov eax, 53
|
||||
mov ebx, 3
|
||||
mov ecx, [socketNum]
|
||||
int 0x40 ; read byte
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 2
|
||||
mov ecx, [socketNum]
|
||||
int 0x40 ; any more data?
|
||||
|
||||
cmp eax, 0
|
||||
jne cfr001 ; yes, so get it
|
||||
|
||||
; Now, request the file
|
||||
mov eax, 53
|
||||
mov ebx, 4
|
||||
mov ecx, [socketNum]
|
||||
mov edx, [tftp_len]
|
||||
mov esi, tftp_filename
|
||||
int 0x40
|
||||
|
||||
cfr002:
|
||||
mov eax,10 ; wait here for event
|
||||
mcall
|
||||
|
||||
cmp eax,1 ; redraw request ?
|
||||
je cfr003
|
||||
cmp eax,2 ; key in buffer ?
|
||||
je cfr004
|
||||
cmp eax,3 ; button in buffer ?
|
||||
je cfr005
|
||||
|
||||
; Any data to fetch?
|
||||
mov eax, 53
|
||||
mov ebx, 2
|
||||
mov ecx, [socketNum]
|
||||
int 0x40
|
||||
|
||||
cmp eax, 0
|
||||
je cfr002
|
||||
|
||||
push eax ; eax holds # chars
|
||||
|
||||
; Update the text on the display - once
|
||||
mov eax, [prompt]
|
||||
cmp eax, p3
|
||||
je cfr008
|
||||
mov dword [prompt], p3
|
||||
mov dword [promptlen], p3len - p3
|
||||
call draw_window ;
|
||||
|
||||
cfr008:
|
||||
; we have data - this will be a tftp frame
|
||||
|
||||
; read first two bytes - opcode
|
||||
mov eax, 53
|
||||
mov ebx, 3
|
||||
mov ecx, [socketNum]
|
||||
int 0x40 ; read byte
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 3
|
||||
mov ecx, [socketNum]
|
||||
int 0x40 ; read byte
|
||||
|
||||
pop eax
|
||||
; bl holds tftp opcode. Can only be 3 (data) or 5 ( error )
|
||||
|
||||
cmp bl, 3
|
||||
jne cfrerr
|
||||
|
||||
push eax
|
||||
|
||||
; do data stuff. Read block #. Read data. Send Ack.
|
||||
mov eax, 53
|
||||
mov ebx, 3
|
||||
mov ecx, [socketNum]
|
||||
int 0x40 ; read byte
|
||||
|
||||
mov [blockNumber], bl
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 3
|
||||
mov ecx, [socketNum]
|
||||
int 0x40 ; read byte
|
||||
|
||||
mov [blockNumber+1], bl
|
||||
|
||||
cfr007:
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 2
|
||||
mov ecx, [socketNum]
|
||||
mcall ; any more data?
|
||||
|
||||
cmp eax, 0
|
||||
je no_more_data ; no
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 3
|
||||
mov ecx, [socketNum]
|
||||
mcall ; read byte
|
||||
|
||||
mov esi, [fileposition]
|
||||
mov [esi], bl
|
||||
inc dword [fileposition]
|
||||
inc dword [filesize]
|
||||
|
||||
jmp cfr007
|
||||
|
||||
no_more_data:
|
||||
|
||||
; write the block number into the ack
|
||||
mov al, [blockNumber]
|
||||
mov [ack + 2], al
|
||||
|
||||
mov al, [blockNumber+1]
|
||||
mov [ack + 3], al
|
||||
|
||||
; send an 'ack'
|
||||
mov eax, 53
|
||||
mov ebx, 4
|
||||
mov ecx, [socketNum]
|
||||
mov edx, ackLen - ack
|
||||
mov esi, ack
|
||||
int 0x40
|
||||
|
||||
; If # of chars in the frame is less that 516,
|
||||
; this frame is the last
|
||||
pop eax
|
||||
cmp eax, 516
|
||||
je cfr002
|
||||
|
||||
; Write the file
|
||||
mov ebx, writeinfo
|
||||
lea esi, [ebx + 20]
|
||||
@@:
|
||||
lodsb
|
||||
test al, al
|
||||
jnz @b
|
||||
@@:
|
||||
dec esi
|
||||
cmp byte [esi-1], ' '
|
||||
jnz @b
|
||||
mov byte [esi], 0
|
||||
mcall 70, writeinfo
|
||||
mov byte [esi], ' '
|
||||
|
||||
jmp cfrexit
|
||||
|
||||
cfrerr:
|
||||
; simple implementation on error - just read all data, and return
|
||||
mov eax, 53
|
||||
mov ebx, 3
|
||||
mov ecx, [socketNum]
|
||||
int 0x40 ; read byte
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 2
|
||||
mov ecx, [socketNum]
|
||||
int 0x40 ; any more data?
|
||||
|
||||
cmp eax, 0
|
||||
jne cfrerr ; yes, so get it
|
||||
|
||||
jmp cfr006 ; close socket and close app
|
||||
|
||||
cfr003: ; redraw request
|
||||
call draw_window
|
||||
jmp cfr002
|
||||
|
||||
cfr004: ; key pressed
|
||||
mov eax,2 ; just read it and ignore
|
||||
mcall
|
||||
jmp cfr002
|
||||
|
||||
cfr005: ; button
|
||||
mov eax,17 ; get id
|
||||
mcall
|
||||
|
||||
cmp ah,1 ; button id=1 ?
|
||||
jne cfr002 ; If not, ignore.
|
||||
|
||||
cfr006:
|
||||
; close socket
|
||||
mov eax, 53
|
||||
mov ebx, 1
|
||||
mov ecx, [socketNum]
|
||||
int 0x40
|
||||
|
||||
mov [socketNum], dword 0
|
||||
|
||||
mov eax,-1 ; close this program
|
||||
mcall
|
||||
|
||||
jmp $
|
||||
|
||||
cfrexit:
|
||||
; close socket
|
||||
mov eax, 53
|
||||
mov ebx, 1
|
||||
mov ecx, [socketNum]
|
||||
int 0x40
|
||||
|
||||
mov [socketNum], dword 0
|
||||
|
||||
mov dword [prompt], p4
|
||||
mov dword [promptlen], p4len - p4
|
||||
call draw_window ;
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
;***************************************************************************
|
||||
; Function
|
||||
; copyToRemote
|
||||
;
|
||||
; Description
|
||||
;
|
||||
;***************************************************************************
|
||||
copyToRemote:
|
||||
mov eax,6 ; Read file from floppy (image)
|
||||
mov ebx,source
|
||||
mov ecx,0
|
||||
mov edx,0xffffffff
|
||||
mov esi,I_END + 512
|
||||
int 0x40
|
||||
|
||||
cmp eax,0xffffffff
|
||||
jnz filefound
|
||||
|
||||
mov dword [prompt], p6
|
||||
mov dword [promptlen], p6len - p6
|
||||
call draw_window ;
|
||||
jmp ctr_exit
|
||||
|
||||
filefound:
|
||||
mov [filesize], eax
|
||||
|
||||
; First, set up the file pointers
|
||||
mov eax, 0x01000300
|
||||
mov [blockBuffer], eax ; This makes sure our TFTP header is valid
|
||||
|
||||
mov eax, I_END + 512 ; This is the point where the file buffer is
|
||||
mov [fileposition], eax
|
||||
|
||||
mov eax, [filesize]
|
||||
cmp eax, 512
|
||||
jb ctr000
|
||||
mov eax, 512
|
||||
ctr000:
|
||||
mov [fileblocksize], ax
|
||||
|
||||
; Get a random # for the local socket port #
|
||||
mov eax, 3
|
||||
int 0x40
|
||||
mov ecx, eax
|
||||
shr ecx, 8 ; Set up the local port # with a random #
|
||||
|
||||
; First, open socket
|
||||
mov eax, 53
|
||||
mov ebx, 0
|
||||
mov edx, 69 ; remote port
|
||||
mov esi, [tftp_IP]
|
||||
int 0x40
|
||||
|
||||
mov [socketNum], eax
|
||||
|
||||
; write to socket ( request write file )
|
||||
mov eax, 53
|
||||
mov ebx, 4
|
||||
mov ecx, [socketNum]
|
||||
mov edx, [tftp_len]
|
||||
mov esi, tftp_filename
|
||||
int 0x40
|
||||
|
||||
; now, we wait for
|
||||
; UI redraw
|
||||
; UI close
|
||||
; or data from remote
|
||||
|
||||
ctr001:
|
||||
mov eax,10 ; wait here for event
|
||||
int 0x40
|
||||
|
||||
cmp eax,1 ; redraw request ?
|
||||
je ctr003
|
||||
cmp eax,2 ; key in buffer ?
|
||||
je ctr004
|
||||
cmp eax,3 ; button in buffer ?
|
||||
je ctr005
|
||||
|
||||
|
||||
; Any data in the UDP receive buffer?
|
||||
mov eax, 53
|
||||
mov ebx, 2
|
||||
mov ecx, [socketNum]
|
||||
int 0x40
|
||||
|
||||
cmp eax, 0
|
||||
je ctr001
|
||||
|
||||
; Update the text on the display - once
|
||||
mov eax, [prompt]
|
||||
cmp eax, p2
|
||||
je ctr002
|
||||
|
||||
mov dword [prompt], p2
|
||||
mov dword [promptlen], p2len - p2
|
||||
call draw_window ;
|
||||
|
||||
; we have data - this will be the ack
|
||||
ctr002:
|
||||
mov eax, 53
|
||||
mov ebx, 3
|
||||
mov ecx, [socketNum]
|
||||
int 0x40 ; read byte - opcode
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 3
|
||||
mov ecx, [socketNum]
|
||||
int 0x40 ; read byte - opcode
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 3
|
||||
mov ecx, [socketNum]
|
||||
int 0x40 ; read byte - block (high byte)
|
||||
|
||||
mov [blockNumber], bl
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 3
|
||||
mov ecx, [socketNum]
|
||||
int 0x40 ; read byte - block (low byte )
|
||||
|
||||
mov [blockNumber+1], bl
|
||||
|
||||
ctr0022:
|
||||
mov eax, 53
|
||||
mov ebx, 3
|
||||
mov ecx, [socketNum]
|
||||
int 0x40 ; read byte (shouldn't have worked)
|
||||
|
||||
|
||||
mov eax, 53
|
||||
mov ebx, 2
|
||||
mov ecx, [socketNum]
|
||||
int 0x40 ; any more data?
|
||||
|
||||
cmp eax, 0
|
||||
jne ctr0022 ; yes, so get it, and dump it
|
||||
|
||||
; If the ack is 0, it is to the request
|
||||
|
||||
mov bx, [blockNumber]
|
||||
cmp bx, 0
|
||||
je txd
|
||||
|
||||
; now, the ack should be one more than the current field - otherwise, resend
|
||||
|
||||
cmp bx, [blockBuffer+2]
|
||||
jne txre ; not the same, so send again
|
||||
|
||||
; update the block number
|
||||
mov esi, blockBuffer + 3
|
||||
mov al, [esi]
|
||||
inc al
|
||||
mov [esi], al
|
||||
cmp al, 0
|
||||
jne ctr008
|
||||
dec esi
|
||||
inc byte [esi]
|
||||
|
||||
ctr008:
|
||||
; Move forward through the file
|
||||
mov eax, [fileposition]
|
||||
movzx ebx, word [fileblocksize]
|
||||
add eax, ebx
|
||||
mov [fileposition], eax
|
||||
|
||||
; new ..
|
||||
; fs = 0 , fbs = 512 -> send with fbs = 0
|
||||
|
||||
cmp [filesize],0
|
||||
jne no_special_end
|
||||
cmp [fileblocksize],512
|
||||
jne no_special_end
|
||||
mov ax,0
|
||||
jmp ctr006
|
||||
no_special_end:
|
||||
|
||||
mov eax, [filesize]
|
||||
cmp eax, 0
|
||||
je ctr009
|
||||
cmp eax, 512
|
||||
jb ctr006
|
||||
mov eax, 512
|
||||
ctr006:
|
||||
mov [fileblocksize], ax
|
||||
|
||||
|
||||
txd:
|
||||
; Readjust the file size variable ( before sending )
|
||||
mov eax, [filesize]
|
||||
movzx ebx, word [fileblocksize]
|
||||
sub eax, ebx
|
||||
mov [filesize], eax
|
||||
|
||||
txre:
|
||||
; Copy the fragment of the file to the block buffer
|
||||
movzx ecx, word [fileblocksize]
|
||||
mov esi, [fileposition]
|
||||
mov edi, I_END
|
||||
cld
|
||||
rep movsb
|
||||
|
||||
; send the file data
|
||||
mov eax, 53
|
||||
mov ebx, 4
|
||||
mov ecx, [socketNum]
|
||||
movzx edx, word [fileblocksize]
|
||||
add edx, 4
|
||||
mov esi, blockBuffer
|
||||
int 0x40
|
||||
|
||||
jmp ctr001
|
||||
|
||||
ctr003: ; redraw
|
||||
call draw_window
|
||||
jmp ctr001
|
||||
|
||||
ctr004: ; key
|
||||
mov eax,2 ; just read it and ignore
|
||||
int 0x40
|
||||
jmp ctr001
|
||||
|
||||
ctr005: ; button
|
||||
mov eax,17 ; get id
|
||||
int 0x40
|
||||
|
||||
cmp ah,1 ; button id=1 ?
|
||||
jne ctr001
|
||||
|
||||
; close socket
|
||||
mov eax, 53
|
||||
mov ebx, 1
|
||||
mov ecx, [socketNum]
|
||||
int 0x40
|
||||
|
||||
mov [socketNum], dword 0
|
||||
|
||||
mov eax,-1 ; close this program
|
||||
int 0x40
|
||||
jmp $
|
||||
|
||||
ctr009:
|
||||
; close socket
|
||||
mov eax, 53
|
||||
mov ebx, 1
|
||||
mov ecx, [socketNum]
|
||||
int 0x40
|
||||
|
||||
mov dword [prompt], p4
|
||||
mov dword [promptlen], p4len - p4
|
||||
call draw_window ;
|
||||
|
||||
ctr_exit:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
; *********************************************
|
||||
; ******* WINDOW DEFINITIONS AND DRAW ********
|
||||
; *********************************************
|
||||
|
||||
|
||||
draw_window:
|
||||
|
||||
mov eax,12 ; function 12:tell os about windowdraw
|
||||
mov ebx,1 ; 1, start of draw
|
||||
mcall
|
||||
|
||||
; DRAW WINDOW
|
||||
mov eax,0 ; function 0 : define and draw window
|
||||
mov ebx,100*65536+230 ; [x start] *65536 + [x size]
|
||||
mov ecx,100*65536+170 ; [y start] *65536 + [y size]
|
||||
mov edx,0x14224466 ; color of work area RRGGBB
|
||||
mov edi,title
|
||||
mcall
|
||||
|
||||
mov eax,8 ; COPY BUTTON
|
||||
mov ebx,20*65536+190
|
||||
mov ecx,79*65536+15
|
||||
mov edx,2
|
||||
mov esi,0x557799
|
||||
mcall
|
||||
|
||||
; mov eax,8 ; DELETE BUTTON
|
||||
mov ebx,20*65536+190
|
||||
mov ecx,111*65536+15
|
||||
mov edx,3
|
||||
mcall
|
||||
|
||||
; mov eax,8
|
||||
; mov ebx,200*65536+10
|
||||
mov ecx,34*65536+10
|
||||
mov edx,4
|
||||
mcall
|
||||
|
||||
; mov eax,8
|
||||
; mov ebx,200*65536+10
|
||||
mov ecx,50*65536+10
|
||||
mov edx,5
|
||||
mcall
|
||||
|
||||
|
||||
; Copy the file name to the screen buffer
|
||||
; file name is same length as IP address, to
|
||||
; make the math easier later.
|
||||
cld
|
||||
mov esi,source
|
||||
mov edi,text+13
|
||||
mov ecx,15
|
||||
rep movsb
|
||||
|
||||
|
||||
; copy the IP address to the screen buffer
|
||||
mov esi,destination
|
||||
mov edi,text+40+13
|
||||
mov ecx,15
|
||||
rep movsb
|
||||
|
||||
; copy the prompt to the screen buffer
|
||||
mov esi,[prompt]
|
||||
mov edi,text+280
|
||||
mov ecx,[promptlen]
|
||||
rep movsb
|
||||
|
||||
; Re-draw the screen text
|
||||
cld
|
||||
mov eax,4
|
||||
mov ebx,25*65536+35 ; draw info text with function 4
|
||||
mov ecx,0xffffff
|
||||
mov edx,text
|
||||
mov esi,40
|
||||
newline:
|
||||
mcall
|
||||
add ebx,16
|
||||
add edx,40
|
||||
cmp [edx],byte 'x'
|
||||
jnz newline
|
||||
|
||||
|
||||
mov eax,12 ; function 12:tell os about windowdraw
|
||||
mov ebx,2 ; 2, end of draw
|
||||
mcall
|
||||
|
||||
ret
|
||||
|
||||
|
||||
; DATA AREA
|
||||
; file name: source
|
||||
; file data: I_END + 512
|
||||
; file size: [filesize]
|
||||
writeinfo:
|
||||
dd 2
|
||||
dd 0
|
||||
dd 0
|
||||
filesize dd 0 ; The number of bytes written / left to write
|
||||
dd I_END + 512
|
||||
source db 'KERNEL.ASM ',0
|
||||
destination db '192.168.1.23 '
|
||||
|
||||
|
||||
tftp_filename: times 15 + 9 db 0
|
||||
tftp_IP: dd 0
|
||||
tftp_len: dd 0
|
||||
|
||||
addr dd 0x0
|
||||
ya dd 0x0
|
||||
|
||||
fileposition dd 0 ; Points to the current point in the file
|
||||
fileblocksize dw 0 ; The number of bytes to send in this frame
|
||||
|
||||
text:
|
||||
db 'SOURCE FILE: xxxxxxxxxxxxxxx '
|
||||
db 'HOST IP ADD: xxx.xxx.xxx.xxx '
|
||||
db ' '
|
||||
db ' COPY HOST -> LOCAL '
|
||||
db ' '
|
||||
db ' COPY LOCAL -> HOST '
|
||||
db ' '
|
||||
db ' '
|
||||
db 'x' ; <- END MARKER, DONT DELETE
|
||||
|
||||
|
||||
title db 'TFTP Client',0
|
||||
|
||||
prompt: dd 0
|
||||
promptlen: dd 0
|
||||
|
||||
|
||||
p1: db 'Waiting for Command'
|
||||
p1len:
|
||||
|
||||
p2: db 'Sending File '
|
||||
p2len:
|
||||
|
||||
p3: db 'Receiving File '
|
||||
p3len:
|
||||
|
||||
p4: db 'Tranfer Complete '
|
||||
p4len:
|
||||
|
||||
p5: db 'Contacting Host... '
|
||||
p5len:
|
||||
|
||||
p6: db 'File not found. '
|
||||
p6len:
|
||||
|
||||
ack:
|
||||
db 00,04,0,1
|
||||
ackLen:
|
||||
|
||||
socketNum:
|
||||
dd 0
|
||||
|
||||
blockNumber:
|
||||
dw 0
|
||||
|
||||
; This must be the last part of the file, because the blockBuffer
|
||||
; continues at I_END.
|
||||
blockBuffer:
|
||||
db 00, 03, 00, 01
|
||||
I_END:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user