📄 telnet.asm
字号:
ret
connect:
pusha
mov ecx, 1000 ; local port starting at 1000
getlp:
inc ecx
push ecx
mov eax, 53
mov ebx, 9
int 0x40
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
int 0x40
mov [socket], eax
popa
ret
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
draw_window:
pusha
mov eax,12
mov ebx,1
int 0x40
mov eax,0 ; DRAW WINDOW
mov ebx,100*65536+491 + 8 +15
mov ecx,100*65536+270 + 20 ; 20 for status bar
mov edx,[wcolor]
add edx,0x04000000
mov esi,window_label
mov edi,0
int 0x40
mov eax,8 ; CLOSE BUTTON
mov ebx,(491 + 20 -19)*65536+12
mov ecx,5*65536+12
mov edx,1
mov esi,0x557799
int 0x40
; draw status bar
mov eax, 13
mov ebx, 4*65536+484 + 8 +15
mov ecx, 272*65536 + 1
mov edx, 0x305070
int 0x40
mov eax,8 ; BUTTON 2: SET IP
mov ebx,4*65536+70
mov ecx,273*65536+12
mov esi, 0x00557799
mov edx,2
int 0x40
mov eax,4 ; Button text
mov ebx,6*65536+276
mov ecx,0x00ffffff
mov edx,setipt
mov esi,setiplen-setipt
int 0x40
mov edi,ip_address ; display IP address
mov edx,78*65536+276
mov esi,0x00ffffff
mov ebx,3*65536
ipdisplay:
mov eax,47
movzx ecx,byte [edi]
int 0x40
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
int 0x40
mov eax,4 ; Button text
mov ebx,178*65536+276
mov ecx,0x00ffffff
mov edx,setportt
mov esi,setportlen-setportt
int 0x40
mov edx,216*65536+276 ; display port
mov esi,0x00ffffff
mov ebx,4*65536
mov eax,47
movzx ecx,word [port]
int 0x40
mov eax,8 ; BUTTON 4: Connect
mov ebx,250*65536+50
mov ecx,273*65536+12
mov esi, 0x00557799
mov edx,4
int 0x40
mov eax,4 ; Button text
mov ebx,255*65536+276
mov ecx,0x00ffffff
mov edx,cont
mov esi,conlen-cont
int 0x40
mov eax,8 ; BUTTON 5: disconnect
mov ebx,303*65536+70
mov ecx,273*65536+12
mov edx,5
mov esi, 0x00557799
int 0x40
mov eax,4 ; Button text
mov ebx,307*65536+276
mov ecx,0x00ffffff
mov edx,dist
mov esi,dislen-dist
int 0x40
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
int 0x40
mov eax,8 ; BUTTON 6: echo
mov ebx,460*65536+50
mov ecx,273*65536+12
mov edx,6
mov esi, 0x00557799
int 0x40
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
int 0x40
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
int 0x40
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
int 0x40
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
int 0x40
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
int 0x40
cmp eax,2
jne read_done
mov eax,2
int 0x40
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
int 0x40
mov eax,4
mov ebx,[string_x]
shl ebx,16
add ebx,[string_y]
mov ecx,0x00ffffff
mov edx,string
mov esi,[string_length]
int 0x40
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
window_label:
db 'TELNET',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:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -