?? https.asm
字號:
no_index:
cmp [edi-3],dword 'htm'+0
je htm_header
cmp [edi-3],dword 'HTM'+0
je htm_header
jmp no_htm_header
htm_header:
mov [file_type],htm
mov [type_len],html-htm
mov [filename+40*2+6],dword 'HTM '
jmp found_file_type
no_htm_header:
cmp [edi-3],dword 'png'+0
je png_header
cmp [edi-3],dword 'PNG'+0
je png_header
jmp no_png_header
png_header:
mov [file_type],png
mov [type_len],pngl-png
mov [filename+40*2+6],dword 'PNG '
jmp found_file_type
no_png_header:
cmp [edi-3],dword 'gif'+0
je gif_header
cmp [edi-3],dword 'GIF'+0
je gif_header
jmp no_gif_header
gif_header:
mov [file_type],gif
mov [type_len],gifl-gif
mov [filename+40*2+6],dword 'GIF '
jmp found_file_type
no_gif_header:
cmp [edi-3],dword 'jpg'+0
je jpg_header
cmp [edi-3],dword 'JPG'+0
je jpg_header
jmp no_jpg_header
jpg_header:
mov [file_type],jpg
mov [type_len],jpgl-jpg
mov [filename+40*2+6],dword 'JPG '
jmp found_file_type
no_jpg_header:
cmp [edi-3],dword 'asm'+0
je txt_header
cmp [edi-3],dword 'ASM'+0
je txt_header
cmp [edi-3],dword 'txt'+0
je txt_header
cmp [edi-3],dword 'TXT'+0
je txt_header
jmp no_txt_header
txt_header:
mov [file_type],txt
mov [type_len],txtl-txt
mov [filename+40*2+6],dword 'TXT '
jmp found_file_type
no_txt_header:
html_file:
found_file_type:
mov edi,getf
add edi,[getflen]
mov esi,wanted_file
mov ecx,40
cld
rep movsb
mov esi,getf
mov edi,filename
mov ecx,35
cld
rep movsb
mov [fileinfo+8],dword 1 ; file exists ?
mov eax,58
mov ebx,fileinfo
int 0x40
cmp eax,0 ; file not found - message
je file_found
mov edi,et
call set_time
mov edi,ed
call set_date
mov esi,fnf
mov edi,0x100000
mov ecx,fnfe-fnf
cld
rep movsb
mov ebx,fnfe-fnf
mov [file_type],htm
mov [type_len],html-htm
mov [filename+40*2+6],dword 'HTM '
jmp file_not_found
file_found:
mov [fileinfo+8],dword 0x2f0000 / 512 ; read all of file
mov eax,58
mov ebx,fileinfo
int 0x40
file_not_found:
file_loaded:
and ebx,0x3fffff
mov [filesize],ebx
mov [file_left],ebx
mov eax,ebx
mov edi,c_l+5
mov ebx,10
newl:
xor edx,edx
div ebx
mov ecx,edx
add cl,48
mov [edi],cl
dec edi
cmp edi,c_l
jge newl
mov esi,c_l
mov edi,filename+46
mov ecx,7
cld
rep movsb
inc [documents_served]
mov eax,[filesize]
add [bytes_transferred],eax
call draw_data
ret
set_value:
pusha
add edi,ecx
mov ebx,10
new_value:
xor edx,edx
div ebx
add dl,48
mov [edi],dl
dec edi
loop new_value
popa
ret
set_time:
pusha
mov eax,3
int 0x40
mov ecx,3
new_time_digit:
mov ebx,eax
and ebx,0xff
shl ebx,4
shr bl,4
add bx,48*256+48
mov [edi],bh
mov [edi+1],bl
add edi,3
shr eax,8
loop new_time_digit
popa
ret
set_date:
pusha
mov eax,29
int 0x40
mov ecx,3
add edi,6
new_date_digit:
mov ebx,eax
and ebx,0xff
shl ebx,4
shr bl,4
add bx,48*256+48
mov [edi],bh
mov [edi+1],bl
sub edi,3
shr eax,8
loop new_date_digit
popa
ret
check_for_incoming_data:
pusha
check:
mov eax, 53
mov ebx, 2
mov ecx, [socket]
int 0x40
cmp eax,0
je _ret_now
new_data:
mov eax,53
mov ebx,2
mov ecx,[socket]
int 0x40
cmp eax,0
je _ret
mov eax,53
mov ebx,3
mov ecx,[socket]
int 0x40
cmp bl,10
jne no_lf
inc [posy]
mov [posx],0
jmp new_data
no_lf:
cmp bl,20
jb new_data
inc [posx]
cmp [posy],20
jbe yok
mov [posy],1
yok:
mov eax,[posy]
imul eax,256
add eax,[posx]
mov [input_text+eax],bl
jmp new_data
_ret:
call draw_data
mov eax,5
mov ebx,1
cmp [input_text+256+1],dword 'POST'
jne no_ld
mov ebx,50
no_ld:
int 0x40
jmp check
_ret_now:
popa
ret
posy dd 1
posx dd 0
check_status:
pusha
mov eax,53
mov ebx,6
mov ecx,[socket]
int 0x40
cmp eax,[status]
je c_ret
mov [status],eax
add al,48
mov [text+12],al
call draw_data
c_ret:
popa
ret
addr dd 0x0
ya dd 0x0
filename2: times 100 db 32
read_string:
mov [addr],dword getf
mov [ya],dword 139
mov edi,[addr]
mov eax,0
mov ecx,30
cld
rep stosb
call print_text
mov edi,[addr]
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,[addr]
jz f11
sub edi,1
mov [edi],byte 32
call print_text
jmp f11
nobsl:
mov [edi],al
call print_text
add edi,1
mov esi,[addr]
add esi,30
cmp esi,edi
jnz f11
read_done:
push edi
mov ecx,40
mov eax,32
cld
rep stosb
call print_text
pop edi
sub edi,[addr]
mov [getflen],edi
mov esi,getf
mov edi,dirp+12
mov ecx,28
cld
rep movsb
jmp still
print_text:
pusha
mov eax,13
mov ebx,97*65536+23*6
mov ecx,[ya]
shl ecx,16
mov cx,9
mov edx,0xffffff
int 0x40
mov eax,4
mov edx,[addr]
mov ebx,97*65536
add ebx,[ya]
mov ecx,0x000000
mov esi,23
int 0x40
popa
ret
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
draw_window:
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,1 ; 1, start of draw
int 0x40
; DRAW WINDOW
mov eax,0 ; function 0 : define and draw window
mov ebx,100*65536+480 ; [x start] *65536 + [x size]
mov ecx,100*65536+215 ; [y start] *65536 + [y size]
mov edx,0x04ffffff ; color of work area RRGGBB
mov esi,window_label ; color of grab bar RRGGBB,8->co
mov edi,0 ; color of frames RRGGBB
int 0x40
mov eax,8 ; function 8 : define and draw button
mov ebx,(40)*65536+20 ; [x start] *65536 + [x size]
mov ecx,58*65536+11 ; [y start] *65536 + [y size]
mov edx,2 ; button id
mov esi,0x10000000 ; button color RRGGBB
mov edi,0
int 0x40
mov eax,8 ; function 8 : define and draw button
mov ebx,(40)*65536+20 ; [x start] *65536 + [x size]
mov ecx,71*65536+11 ; [y start] *65536 + [y size]
mov edx,4 ; button id
int 0x40
mov eax,8 ; Enter directory
mov ebx,(25)*65536+66
mov ecx,135*65536+15
mov edx,6
int 0x40
mov eax,38
mov ebx,240*65536+240
mov ecx,22*65536+210
mov edx,0x000000
int 0x40
call draw_data
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
ret
draw_data:
pusha
mov ebx,25*65536+35 ; draw info text with function 4
mov ecx,0x000000
mov edx,text
mov esi,35
newline:
pusha
cmp ebx,25*65536+61
je now
cmp ebx,25*65536+74
je now
cmp ebx,25*65536+74+13*5
je now
mov ecx,ebx
mov bx,35*6
shl ecx,16
mov cx,9
mov eax,13
mov edx,0xffffff
int 0x40
now:
popa
mov eax,4
int 0x40
add ebx,13
add edx,40
cmp [edx],byte 'x'
jnz newline
mov [input_text+0],dword 'RECE'
mov [input_text+4],dword 'IVED'
mov [input_text+8],dword ': '
mov ebx,255*65536+35 ; draw info text with function 4
mov ecx,0x000000
mov edx,input_text
mov esi,35
mov edi,17
newline2:
pusha
mov ecx,ebx
mov bx,35*6
shl ecx,16
mov cx,9
mov eax,13
mov edx,0xffffff
int 0x40
popa
mov eax,4
int 0x40
add ebx,10
add edx,256
dec edi
jnz newline2
popa
ret
; DATA AREA
status dd 0x0
text:
db 'TCB status: x '
db ' '
db ' Activate server '
db ' Stop server '
db ' '
db 'Requests: /TinyStat -statistics '
db ' /TinyBoard -message board '
db ' '
dirp:
db ' Files: /RD/1/ '
db ' '
filename:
db ' '
db 'Size: ------- '
db 'Type: --- '
db 'x <- END MARKER, DONT DELETE '
html_header:
db 'HTTP/1.0 200 OK',13,10
db 'Server: MenuetOS HTTP Server',13,10
db 'Content-Length: '
c_l: db '000000',13,10
h_len:
fnf:
db '<body>'
db '<pre>'
db "TinyServer v ",version," for MenuetOS",13,10,13,10
db "Error 404 - File not found.",13,10,13,10
db "For more info about server: request /TinyStat",13,10,13,10
et: db "xx:xx:xx",13,10
ed: db "xx.xx.xx",13,10
db "</pre></body>"
fnfe:
sm:
db '<body>'
db '<pre>'
db "TinyServer v ",version," for MenuetOS",13,10,13,10
db "Statistics: (before current request)",13,10,13,10
sms: db "- Documents served : xxxxxxxxx",13,10
smb: db "- Bytes transferred : xxxxxxxxx",13,10
db "- Location : <a href=/TinyStat>/TinyStat</a>",13,10,13,10
db "TinyBoard:",13,10,13,10
smm: db "- Messages : xxxxxxxxx",13,10
smz: db "- Size in bytes : xxxxxxxxx",13,10
db "- Location : <a href=/TinyBoard>/TinyBoard</a>",13,10,13,10
smt: db "xx:xx:xx",13,10
smd: db "xx.xx.xx",13,10
db '</pre></body>'
sme:
documents_served dd 0x0
bytes_transferred dd 0x0
file_type dd 0
type_len dd 0
htm: db 'Content-Type: text/html',13,10,13,10
html:
txt: db 'Content-Type: text/plain',13,10,13,10
txtl:
png: db 'Content-Type: image/png',13,10,13,10
pngl:
gif: db 'Content-Type: image/gif',13,10,13,10
gifl:
jpg: db 'Content-Type: image/jpeg',13,10,13,10
jpgl:
unk: db 'Content-Type: unknown/unknown',13,10,13,10
unkl:
window_label:
db 'Tiny HTTP server ',0;version
socket dd 0x0
server_active db 0x0
board:
db "<HTML><BODY BGCOLOR=#ffffff ALINK=black VLINK=black><br>",13,10
db "<center>",13,10
db "<TABLE CELLPADDING=10 CELLSPACING=0 BORDER=0 bgcolor=#ffffff width=600>"
db 13,10
db "<TR VALIGN=top><TD ALIGN=center bgcolor=f0f0f8>",13,10
db "<font size=3>Tinyserver Messageboard</TD></TR></TABLE><br>",13,10
db "<TABLE CELLPADDING=14 CELLSPACING=2 BORDER=0 bgcolor=#ffffff width=600>"
db 13,10,13,10
board1:
db "<TR VALIGN=top>",13,10
db "<TD ALIGN=left width=80 bgcolor=f0f0f8><P>",13,10
db "<font size=3>",13,10
board1e:
db "WebMaster",13,10
board2:
db "</font>",13,10
db "<br><br><br>",13,10
db "<br><br><br><br>",13,10
bsmt:
db "12.23.45<br>",13,10
bsmd:
db "02.05.03",13,10
db "</P></TD>",13,10
db "<TD bgcolor=f0f0f8><P>",13,10
board2e:
db "Assembly written messageboard from assembly written MenuetOS.<br>"
db 13,10
board3:
db "</P></TD></TR>",13,10,13,10
board3e:
boardadd:
db "</TABLE>",13,10
db "<br>",13,10
db "<TABLE CELLPADDING=14 CELLSPACING=3 BORDER=0 bgcolor=#ffffff width=600>"
db 13,10
db "<TR VALIGN=top>",13,10
db "<TD ALIGN=left bgcolor=f0f0f8><P>",13,10
db "<form method=Post Action=/TinyBoard>",13,10
db "Name: <br><input type=text name=from size=20 MAXLENGTH=20><br>",13,10
db "Message: <br><textarea cols=60 rows=6 name=message></textarea><br>",13,10
db "<input type=Submit Value=' Send Message '></form>",13,10
db "</TD></TR>",13,10
db "</TABLE>",13,10
db "</BODY>",13,10
db "</HTML>",13,10
board_end:
board_size dd 0x0
board_messages dd 0x0
input_text:
I_END:
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -