* KFar 0.32.

* smtps modified to use function 70 and standard header in function 0.

git-svn-id: svn://kolibrios.org@474 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Evgeny Grechnikov (Diamond) 2007-05-02 12:19:54 +00:00
parent 441fcf143a
commit 06a1a8f6a3
8 changed files with 2765 additions and 1350 deletions

View File

@ -27,6 +27,8 @@ GenericBox:
pushad pushad
mov ebx, [esp+20h+4] mov ebx, [esp+20h+4]
; center window if required ; center window if required
push [ebx+dlgtemplate.x]
push [ebx+dlgtemplate.y]
cmp [ebx+dlgtemplate.x], -1 cmp [ebx+dlgtemplate.x], -1
jnz @f jnz @f
mov eax, [cur_width] mov eax, [cur_width]
@ -59,6 +61,8 @@ GenericBox:
cmp [ebx+dlgtemplate.border_size_y], 1 cmp [ebx+dlgtemplate.border_size_y], 1
jge .sizeok jge .sizeok
.sizeerr: .sizeerr:
pop [ebx+dlgtemplate.y]
pop [ebx+dlgtemplate.x]
popad popad
or eax, -1 or eax, -1
ret 8 ret 8
@ -73,11 +77,11 @@ GenericBox:
jz @f jz @f
mov edi, warning_colors mov edi, warning_colors
.setcolor: .setcolor:
mov al, [dialog_main_color-dialog_colors+edi] mov al, [edi + dialog_main_color-dialog_colors]
mov [ebx+dlgtemplate.main_color], al mov [ebx+dlgtemplate.main_color], al
mov al, [dialog_border_color-dialog_colors+edi] mov al, [edi + dialog_border_color-dialog_colors]
mov [ebx+dlgtemplate.border_color], al mov [ebx+dlgtemplate.border_color], al
mov al, [dialog_header_color-dialog_colors+edi] mov al, [edi + dialog_header_color-dialog_colors]
mov [ebx+dlgtemplate.header_color], al mov [ebx+dlgtemplate.header_color], al
@@: @@:
; allocate memory for data under dialog ; allocate memory for data under dialog
@ -95,10 +99,12 @@ GenericBox:
add edx, [ebx+dlgtemplate.border_size_y] add edx, [ebx+dlgtemplate.border_size_y]
inc edx inc edx
mul edx mul edx
add eax, eax lea ecx, [eax*2]
call mf_alloc call xpgalloc
test eax, eax test eax, eax
jnz @f jnz @f
pop [ebx+dlgtemplate.y]
pop [ebx+dlgtemplate.x]
popad popad
or eax, -1 or eax, -1
ret 8 ret 8
@ -296,7 +302,7 @@ GenericBox:
dec edx dec edx
jnz @b jnz @b
; send redraw message ; send redraw message
mov eax, [esp+20h+8] mov eax, [esp+28h+8]
push ebx ebp push ebx ebp
push 0 push 0
push 0 push 0
@ -347,7 +353,7 @@ GenericBox:
jz .alt_down jz .alt_down
cmp al, 0xB8 cmp al, 0xB8
jz .alt_up jz .alt_up
mov ecx, [esp+20h+8] mov ecx, [esp+28h+8]
push ebx ebp push ebx ebp
push 0 push 0
push eax push eax
@ -357,7 +363,7 @@ GenericBox:
pop ebp ebx pop ebp ebx
test eax, eax test eax, eax
jz .event jz .event
mov [esp+28], eax mov [esp+8+28], eax
jmp .exit jmp .exit
.ctrl_down: .ctrl_down:
test ah, ah test ah, ah
@ -430,9 +436,11 @@ GenericBox:
call draw_keybar call draw_keybar
cmp ebx, nomem_dlgdata cmp ebx, nomem_dlgdata
jz @f jz @f
mov eax, ebp mov ecx, ebp
call mf_free call pgfree
@@: @@:
pop [ebx+dlgtemplate.y]
pop [ebx+dlgtemplate.x]
or [cursor_x], -1 or [cursor_x], -1
or [cursor_y], -1 or [cursor_y], -1
call draw_image call draw_image
@ -548,14 +556,14 @@ menu:
; void* variants, const char* title, unsigned flags); ; void* variants, const char* title, unsigned flags);
menu_centered_in: menu_centered_in:
pushad pushad
mov eax, 56 mov ecx, 56
; 36 bytes for dlgtemplate + additional: ; 36 bytes for dlgtemplate + additional:
; +36: dd cur_variant ; +36: dd cur_variant
; +40: dd num_variants ; +40: dd num_variants
; +44: dd begin_variant ; +44: dd begin_variant
; +48: dd end_variant ; +48: dd end_variant
; +52: dd cur_variant_idx ; +52: dd cur_variant_idx
call xmalloc call xpgalloc
test eax, eax test eax, eax
jnz @f jnz @f
.ret_bad: .ret_bad:
@ -700,8 +708,8 @@ menu_centered_in:
push ebx push ebx
call GenericBox call GenericBox
mov [esp+28], eax mov [esp+28], eax
mov eax, ebx mov ecx, ebx
call mf_free call pgfree
popad popad
ret 28 ret 28
@ -715,6 +723,33 @@ MenuDlgProc:
.draw: .draw:
call .dodraw call .dodraw
ret 16 ret 16
.prev:
mov eax, [ebx+36]
cmp dword [eax+4], 0
jz .end
call .line_prev
.posret:
mov [ebx+36], eax
.redraw:
call .dodraw
call draw_image
xor eax, eax
ret 16
.next:
mov eax, [ebx+36]
cmp dword [eax], 0
jz .home
call .line_next
jmp .posret
.pgdn:
mov eax, [ebx+36]
mov ecx, [ebx+dlgtemplate.height]
.pgdnl:
cmp dword [eax], 0
jz .posret
call .line_next
loop .pgdnl
jmp .posret
.key: .key:
mov al, [esp+12] mov al, [esp+12]
cmp al, 0x48 cmp al, 0x48
@ -773,33 +808,6 @@ MenuDlgProc:
call .line_prev call .line_prev
loop .pgupl loop .pgupl
jmp .posret jmp .posret
.prev:
mov eax, [ebx+36]
cmp dword [eax+4], 0
jz .end
call .line_prev
.posret:
mov [ebx+36], eax
.redraw:
call .dodraw
call draw_image
xor eax, eax
ret 16
.next:
mov eax, [ebx+36]
cmp dword [eax], 0
jz .home
call .line_next
jmp .posret
.pgdn:
mov eax, [ebx+36]
mov ecx, [ebx+dlgtemplate.height]
.pgdnl:
cmp dword [eax], 0
jz .posret
call .line_next
loop .pgdnl
jmp .posret
.home: .home:
mov eax, [ebx+36] mov eax, [ebx+36]
@@: @@:
@ -1083,6 +1091,7 @@ ManagerDlgProc:
ret 16 ret 16
@@: @@:
lea ebx, [ebp+dlgtemplate.size+12] lea ebx, [ebp+dlgtemplate.size+12]
mov ecx, [ebx-4]
.enter_find: .enter_find:
cmp [ebx+dlgitemtemplate.type], 2 cmp [ebx+dlgitemtemplate.type], 2
jnz @f jnz @f
@ -1090,7 +1099,8 @@ ManagerDlgProc:
jnz .enter_found jnz .enter_found
@@: @@:
add ebx, dlgitemtemplate.size add ebx, dlgitemtemplate.size
jmp .enter_find loop .enter_find
jmp .enter_found
.tab: .tab:
test [ctrlstate], 3 test [ctrlstate], 3
jnz .shift_tab jnz .shift_tab
@ -1159,46 +1169,14 @@ ManagerDlgProc:
cmp al, 0x0E cmp al, 0x0E
jz .editor_backspace jz .editor_backspace
cmp al, 0x53 cmp al, 0x53
jz .editor_del jnz .editor_char
test [ctrlstate], 0x3C .editor_del:
jnz .ret_draw mov ecx, [edx+4]
; query keyboard layout lea edi, [ecx+edx+12]
pushad lea esi, [edi+1]
push 26 cmp byte [edi], 0
pop eax jz .ret_test
push 2 jmp .copy_and_ret_test
pop ebx
xor ecx, ecx
cmp [ctrlstate], 1
sbb ecx, -2
mov edx, layout
int 0x40
popad
; translate scancode to ASCII
movzx eax, al
movzx eax, byte [layout+eax]
push eax
; insert entered symbol
xor eax, eax
lea edi, [edx+12]
or ecx, -1
repnz scasb
not ecx
pop eax
cmp ecx, [edx]
ja .ret_test ; buffer capacity exceeded
lea edi, [edx+ecx+12-1]
mov esi, [edx+4]
lea esi, [edx+esi+12]
@@:
mov cl, [edi]
mov [edi+1], cl
dec edi
cmp edi, esi
jae @b
mov [esi], al
inc dword [edx+4]
@@: jmp .ret_test
.editor_left: .editor_left:
mov ecx, [edx+4] mov ecx, [edx+4]
jecxz @f jecxz @f
@ -1248,13 +1226,46 @@ ManagerDlgProc:
test al, al test al, al
jnz @b jnz @b
jmp .ret_test jmp .ret_test
.editor_del: .editor_char:
mov ecx, [edx+4] test [ctrlstate], 0x3C
lea edi, [ecx+edx+12] jnz .ret_draw
lea esi, [edi+1] ; query keyboard layout
cmp byte [edi], 0 pushad
jz .ret_test push 26
jmp .copy_and_ret_test pop eax
push 2
pop ebx
xor ecx, ecx
cmp [ctrlstate], 1
sbb ecx, -2
mov edx, layout
int 0x40
popad
; translate scancode to ASCII
movzx eax, al
movzx eax, byte [layout+eax]
push eax
; insert entered symbol
xor eax, eax
lea edi, [edx+12]
or ecx, -1
repnz scasb
not ecx
pop eax
cmp ecx, [edx]
ja .ret_test ; buffer capacity exceeded
lea edi, [edx+ecx+12-1]
mov esi, [edx+4]
lea esi, [edx+esi+12]
@@:
mov cl, [edi]
mov [edi+1], cl
dec edi
cmp edi, esi
jae @b
mov [esi], al
inc dword [edx+4]
@@: jmp .ret_test
.dodraw: .dodraw:
or [cursor_x], -1 or [cursor_x], -1
@ -1434,6 +1445,16 @@ SayNoMem:
; int num_strings, const char* strings[], ; int num_strings, const char* strings[],
; int num_buttons, const char* buttons[]); ; int num_buttons, const char* buttons[]);
; may be x=-1 and/or y=-1 ; may be x=-1 and/or y=-1
SayErr:
push 2
jmp @f
; int __stdcall Message(const char* title, int x, int y,
; int num_strings, const char* strings[],
; int num_buttons, const char* buttons[]);
Message:
push 1
@@:
; [esp+4] = title ; [esp+4] = title
; [esp+8] = x ; [esp+8] = x
; [esp+12] = y ; [esp+12] = y
@ -1441,21 +1462,22 @@ SayNoMem:
; [esp+20] = strings ; [esp+20] = strings
; [esp+24] = num_buttons ; [esp+24] = num_buttons
; [esp+28] = buttons ; [esp+28] = buttons
SayErr: pop eax
mov eax, [esp+16] pushad
add eax, [esp+24] mov ecx, [esp+4+16]
imul eax, dlgitemtemplate.size add ecx, [esp+4+24]
add eax, dlgtemplate.size+12 imul ecx, dlgitemtemplate.size
call xmalloc add ecx, dlgtemplate.size+12
call xpgalloc
test eax, eax test eax, eax
jnz @f jnz @f
popad
or eax, -1 or eax, -1
ret 28 ret 28
@@: @@:
pushad
mov ebx, eax mov ebx, eax
mov edi, eax mov edi, eax
mov eax, 2 mov eax, [esp+28]
stosd ; dlgtemplate.flags stosd ; dlgtemplate.flags
mov eax, [esp+32+8] mov eax, [esp+32+8]
stosd ; dlgtemplate.x stosd ; dlgtemplate.x
@ -1592,7 +1614,7 @@ SayErr:
sub eax, [esp+32+16] sub eax, [esp+32+16]
@@: @@:
mov [esp+28], eax mov [esp+28], eax
mov eax, ebx mov ecx, ebx
call mf_free call pgfree
popad popad
ret 28 ret 28

View File

@ -0,0 +1,226 @@
delete_file_worker:
; in: ecx=flags: 1=deleting directory
; out: eax=0 - OK, eax=1 - retry, eax=2 - skip, eax=-1 - cancel,
; PF, ZF, CF and SF set accordingly to 'cmp eax,2' (or 'cmp al,2')
push ebx
push 70
pop eax
mov ebx, delinfo
int 0x40
pop ebx
test eax, eax
jz .ret
cmp [del_bSkipAll], 0
jz @f
push 2
pop eax
jmp .ret
@@:
push execdata
push aCannotDeleteFolder
test cl, 1
jnz @f
mov dword [esp], aCannotDeleteFile
@@:
call get_error_msg
push eax
mov eax, esp
push DeleteErrorBtn
push 4
push eax
push 3
push -1
push -1
push aError
call SayErr
add esp, 3*4
cmp al, -1
jz @f
inc eax
cmp al, 4 ; "cancel" button
jnz @f
or eax, -1
@@:
cmp al, 3 ; "skip all" button
jnz .ret
mov [del_bSkipAll], 1
dec eax
.ret:
cmp al, 2
ret
delete_file:
; in: eax->BDFE block
; out: CF and ZF not set <=> cancel job ("ja cancel_label")
pushad
mov [del_dir_stack_ptr], del_dir_stack
lea esi, [ebp + panel1_dir - panel1_data]
mov edi, execdata
@@:
lodsb
test al, al
jz @f
stosb
jmp @b
@@:
mov esi, [esp+28]
mov ecx, esi
add esi, 40
mov al, '/'
stosb
.l1:
lodsb
cmp edi, execdataend
jb @f
call panels_OnKey.bigfilename
popad
ret
@@:
stosb
test al, al
jnz .l1
mov ecx, [esp+28]
test byte [ecx], 10h
jnz .delete_dir
.retrydel:
xor ecx, ecx
call delete_file_worker
jae @f
jp .retrydel
@@:
popad
ret
.delete_dir:
; recursive delete of directory
xor ebp, ebp ; ebp will contain number of undeletable items
.return_from_recursion:
mov ebx, dirinfo
mov [ebx+dirinfo.first-dirinfo], ebp
mov [ebx+dirinfo.size-dirinfo], del_dir_query_size
mov [ebx+dirinfo.dirdata-dirinfo], del_dir_query_area
mov [ebx+dirinfo.name-dirinfo], execdata
push 70
pop eax
int 0x40
; if we get read error, the best available action is try to delete directory itself
test eax, eax
jz @f
cmp eax, 6
jnz .do_delete_dir
@@:
; loop through a directory and delete items
mov edx, del_dir_query_area+32
imul ebx, 304
add ebx, edx
.delete_dir_entry_loop:
cmp edx, ebx
jae .delete_dir_entry_done
; ignore special entries "." and ".."
inc ebp
cmp word [edx+40], '.'
jz .delete_dir_entry_continue
cmp word [edx+40], '..'
jnz @f
cmp byte [edx+42], 0
jz .delete_dir_entry_continue
@@:
dec ebp
mov esi, execdata
@@:
lodsb
test al, al
jnz @b
mov byte [esi-1], '/'
mov edi, esi
lea esi, [edx+40]
@@:
cmp edi, execdataend
jae .fullname_big
lodsb
stosb
test al, al
jnz @b
test byte [edx], 10h
jnz .entry_is_folder
.retry2:
xor ecx, ecx
call delete_file_worker
ja .cancel
jz .skip
jp .retry2
jmp .restore_name
.entry_is_folder:
; allocate new item in directory stack
mov eax, [del_dir_stack_ptr]
mov [eax], ebp
add eax, 4
mov [del_dir_stack_ptr], eax
; do recursive deleting
jmp .delete_dir
.fullname_big:
; we will just ignore such files and continue - in real life this situation can not happen
inc ebp
mov esi, execdataend-1
jmp .do_restore_name
.skip:
inc ebp
.restore_name:
mov esi, execdata
@@:
lodsb
test al, al
jnz @b
dec esi
dec esi
.do_restore_name:
std
@@:
lodsb
cmp al, '/'
jnz @b
cld
mov byte [esi+1], 0
.delete_dir_entry_continue:
add edx, 304
jmp .delete_dir_entry_loop
.delete_dir_entry_done:
.do_delete_dir:
mov cl, 1
call delete_file_worker
ja .cancel
jz @f
jp .delete_dir
@@:
; al=0 - OK, al=2 - skip this directory
; return to previous directory
; pop item from directory stack
mov ecx, [del_dir_stack_ptr]
cmp ecx, del_dir_stack
jbe .done
sub ecx, 4
mov [del_dir_stack_ptr], ecx
mov ebp, [ecx]
cmp al, 2
sbb ebp, -1
; restore prev directory name
mov esi, execdata
@@:
lodsb
test al, al
jnz @b
dec esi
dec esi
std
@@:
lodsb
cmp al, '/'
jnz @b
cld
mov byte [esi+1], 0
jmp .return_from_recursion
.done:
.cancel:
mov [dirinfo.first], 0 ; do not destroys flags
popad
ret

View File

@ -22,27 +22,111 @@ end if
end virtual end virtual
font: font:
macro set_name_test a,b
{
if %=a
font_data_#a = b
end if
}
macro set_name b
{
set_name_test 1,b
set_name_test 2,b
set_name_test 3,b
set_name_test 4,b
set_name_test 5,b
set_name_test 6,b
set_name_test 7,b
set_name_test 8,b
set_name_test 9,b
set_name_test 10,b
set_name_test 11,b
set_name_test 12,b
set_name_test 13,b
set_name_test 14,b
set_name_test 15,b
set_name_test 16,b
}
macro db_name_test a
{
if %=a
db font_data_#a
end if
}
macro db_name
{
db_name_test 1
db_name_test 2
db_name_test 3
db_name_test 4
db_name_test 5
db_name_test 6
db_name_test 7
db_name_test 8
db_name_test 9
db_name_test 10
db_name_test 11
db_name_test 12
db_name_test 13
db_name_test 14
db_name_test 15
db_name_test 16
}
macro dw_name_test a
{
if %=a
dw font_data_#a
end if
}
macro dw_name
{
dw_name_test 1
dw_name_test 2
dw_name_test 3
dw_name_test 4
dw_name_test 5
dw_name_test 6
dw_name_test 7
dw_name_test 8
dw_name_test 9
dw_name_test 10
dw_name_test 11
dw_name_test 12
dw_name_test 13
dw_name_test 14
dw_name_test 15
dw_name_test 16
}
repeat font_height repeat font_height
cur_scan = % cur_scan = %
repeat 256 repeat 16
virtual at 0 virtual at 0
a2 = (font_width+14) shr 3 file fontname:3Eh + font_bmp_scanline*(font_height*(17-%)-cur_scan), font_width*2
if cur_scan=1 & %=0x10
a2 = (font_width+7) shr 3
end if
file fontname:3Eh + font_bmp_scanline*(font_height*(16-((%-1) shr 4))-cur_scan) + ((((%-1) and 0xF)*font_width) shr 3), a2
dd 0 dd 0
load a1 dword from 0 repeat 16
a1 = ((a1 and 0x55555555) shl 1) or ((a1 and 0xAAAAAAAA) shr 1) load a1 dword from ((%-1)*font_width) shr 3
a1 = ((a1 and 0x33333333) shl 2) or ((a1 and 0xCCCCCCCC) shr 2) a1 = ((a1 and 0x55555555) shl 1) or ((a1 and 0xAAAAAAAA) shr 1)
a1 = ((a1 and 0x0F0F0F0F) shl 4) or ((a1 and 0xF0F0F0F0) shr 4) a1 = ((a1 and 0x33333333) shl 2) or ((a1 and 0xCCCCCCCC) shr 2)
a1 = ((a1 and 0x0F0F0F0F) shl 4) or ((a1 and 0xF0F0F0F0) shr 4)
a1 = (a1 shr (((%-1)*font_width) and 7)) and ((1 shl font_width) - 1)
a1 = a1 xor ((1 shl font_width) - 1)
set_name a1
end repeat
end virtual end virtual
a1 = (a1 shr (((%-1)*font_width) and 7)) and ((1 shl font_width) - 1)
a1 = a1 xor ((1 shl font_width) - 1)
if font_width > 8 if font_width > 8
dw a1 repeat 16
dw_name
end repeat
else else
db a1 repeat 16
db_name
end repeat
end if end if
end repeat end repeat
end repeat end repeat
purge set_name_test
purge db_name_test
purge dw_name_test
purge set_name
purge db_name
purge dw_name

File diff suppressed because it is too large Load Diff

View File

@ -1,517 +0,0 @@
if ~ used memalloc_inc
memalloc_inc_fix:
memalloc_inc fix memalloc_inc_fix
;kglobals.inc required.
;multithread: ;uncomment this for thread-safe version
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Memory allocator for MenuetOS ;;
;; Halyavin Andrey halyavin@land.ru, 2006 ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; allocated mem block structure ;;
;; +0: bit 0 - used flag ;;
;; bits 31..1 - block size ;;
;; +4: address of prev block ;;
;; +8 .. +(blocksize) - allocated memory ;;
;; +(blocksize) - next block ;;
;; ;;
;; free mem block structure ;;
;; +0: bit 0 - used flag ;;
;; bits 31..1 - block size ;;
;; +4: address of prev block ;;
;; +8: prev free block ;;
;; +12: next free block ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
memblock.size=0
memblock.prevblock=4
memblock.prevfreeblock=8
memblock.nextfreeblock=12
uglobal
heapsmallblocks rd 1
heapstart rd 1
heapend rd 1
heapfreelist rd 1
heapmutex rd 1
heaplastblock rd 1
endg
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; mf_init ;;
;; Initialize memory map for dynamic use ;;
;; input: eax: starting address or 0 ;;
;; output: none ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mf_init:
push ebx
push ecx
test eax,eax
jnz .noautodet
sub esp,1024
mov ebx,esp
mov ecx,-1
mov eax,9
int 0x40
mov eax,[esp+26]
add esp,1024
.noautodet:
add eax,15
and eax,not 15
mov [heapsmallblocks],eax
add eax,2048
mov [heapstart],eax
mov [heapfreelist],eax
mov [heaplastblock],eax
mov ecx,eax
if defined heapstartsize
add ecx,heapstartsize
else
add ecx,4096
end if
add ecx,4095
and ecx,not 4095
push eax
mov eax,64
mov ebx,1
int 0x40
pop eax
mov [eax+memblock.prevblock],dword 0
mov [heapend],ecx
mov [eax+memblock.size],ecx
sub [eax+memblock.size],eax
xor ebx,ebx
mov dword [eax+memblock.prevfreeblock],heapfreelist-memblock.nextfreeblock
mov [eax+memblock.nextfreeblock],ebx
mov [heapmutex],ebx
push edi
mov edi,[heapsmallblocks]
mov ecx,512
xor eax,eax
rep stosd
pop edi
pop ecx
pop ebx
ret
if defined multithread
heaplock:
push eax
push ebx
mov eax,68
mov ebx,1
.loop:
xchg eax,[heapmutex]
test eax,eax
jz .endloop
int 0x40 ;change task
jmp .loop
.endloop:
pop ebx
pop eax
ret
heapunlock:
mov [heapmutex],dword 0
ret
end if
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; heap_split_block ;;
;; Split free block to allocated block and free one. ;;
;; input: ;;
;; eax - size of allocated block ;;
;; ebx - block ;;
;; output: ;;
;; eax - real size of allocated block ;;
;; ebx - pointer to new block ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
heap_split_block:
push ecx
mov ecx,[ebx+memblock.size]
sub ecx,16
cmp ecx,eax
jge .norm
inc dword [ebx+memblock.size]
mov eax,ecx
xor ebx,ebx
pop ecx
ret
.norm:
add ecx,16
mov [ebx+memblock.size],eax
inc dword [ebx+memblock.size]
mov [ebx+eax+memblock.prevblock],ebx
add ebx,eax
sub ecx,eax
mov [ebx+memblock.size],ecx
mov ecx,eax
mov eax,ebx
call heap_fix_right
mov eax,ecx
pop ecx
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; heap_add_free_block ;;
;; Add free block to one of free block lists. ;;
;; input: ;;
;; eax - address of free block ;;
;; output: ;;
;; none ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
heap_add_free_block:
cmp dword [eax+memblock.size],4096
push ebx
jge .bigblock
mov ebx,[eax+memblock.size]
shr ebx,1
add ebx,[heapsmallblocks]
push dword [ebx]
pop dword [eax+memblock.nextfreeblock]
mov [ebx],eax
mov dword [eax+memblock.prevfreeblock],ebx
sub dword [eax+memblock.prevfreeblock],memblock.nextfreeblock
mov ebx,[eax+memblock.nextfreeblock]
test ebx,ebx
jz .no_next_block
mov [ebx+memblock.prevfreeblock],eax
.no_next_block:
pop ebx
ret
.bigblock:
mov ebx,[heapfreelist]
mov [eax+memblock.nextfreeblock],ebx
mov [heapfreelist],eax
mov dword [eax+memblock.prevfreeblock],heapfreelist-memblock.nextfreeblock
; mov ebx,[eax+memblock.nextfreeblock]
test ebx,ebx
jz .no_next_big_block
mov [ebx+memblock.prevfreeblock],eax
.no_next_big_block:
pop ebx
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; heap_remove_block ;;
;; Remove free block from the list of free blocks. ;;
;; input: ;;
;; eax - free block ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
heap_remove_block:
push ebx
push ecx
mov ecx,[eax+memblock.prevfreeblock]
mov ebx,[eax+memblock.nextfreeblock]
mov [ecx+memblock.nextfreeblock],ebx
test ebx,ebx
jz .no_next_block
mov [ebx+memblock.prevfreeblock],ecx
.no_next_block:
pop ecx
pop ebx
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; mf_alloc
;; allocates a block of memory in heap
;; intput: eax: size of block
;; output: eax: address of allocated memory block or 0 if there's no mem.
;; allocator will not create new nodes that contain less that 8b of space,
;; and minimal allocation is actually 16 bytes - 8 for node and 8 for user.
;; allocator will never create non-aligned memory blocks.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mf_alloc:
test eax,eax
jg .not_null ; test that we are not allocating null size block
xor eax,eax
ret
.not_null:
if defined multithread
call heaplock
end if
push edi
; push edx
push ecx
push ebx
add eax,7
and eax,not 7 ; make sure that block size is aligned
lea edi,[eax+8] ; desired block size
cmp edi,4096
jge .general_cycle
mov ebx,[heapsmallblocks]
xor ecx,ecx
shr edi,1
.smallloop:
cmp [ebx+edi],ecx
jnz .smallblockfound
add edi,4
cmp edi,2048
jl .smallloop
lea edi,[eax+8]
jmp .general_cycle
.smallblockfound:
lea ecx,[eax+8]
mov eax,[ebx+edi]
call heap_remove_block
mov ebx,eax
xchg eax,ecx
call heap_split_block
test ebx,ebx
jz .perfect_small_block
mov eax,ebx
call heap_add_free_block
.perfect_small_block:
lea eax,[ecx+8]
jmp .ret
.general_cycle:
;edi - size needed
mov eax,[heapfreelist]
.loop:
test eax,eax
jz .new_mem
cmp [eax+memblock.size],edi
jge .blockfound
mov eax,[eax+memblock.nextfreeblock]
jmp .loop
.blockfound:
call heap_remove_block
mov ebx,eax
mov ecx,eax
mov eax,edi
call heap_split_block
test ebx,ebx
jz .perfect_block
mov eax,ebx
call heap_add_free_block
.perfect_block:
lea eax,[ecx+8]
.ret:
if defined multithread
call heapunlock
end if
pop ebx
pop ecx
; pop edx
pop edi
ret
.new_mem:
mov eax,edi
add eax,4095
and eax,not 4095
mov ecx,[heapend]
add [heapend],eax
push eax
mov eax,64
push ebx
push ecx
mov ecx,[heapend]
mov ebx,1
int 0x40
pop ecx
pop ebx
pop eax
mov [ecx+memblock.size],eax
mov eax,[heaplastblock]
mov [ecx+memblock.prevblock],eax
mov [heaplastblock],ecx
mov eax,ecx
call heap_add_free_block
jmp .general_cycle
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; heap_fix_right ;;
;; input: ;;
;; eax - pointer to free block ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
heap_fix_right:
push ebx
mov ebx,eax
add ebx,[eax+memblock.size]
cmp ebx,[heapend]
jz .endblock
mov [ebx+memblock.prevblock],eax
pop ebx
ret
.endblock:
mov [heaplastblock],eax
pop ebx
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; heap_merge_left ;;
;; input: ;;
;; eax - pointer to free block ;;
;; output: ;;
;; eax - pointer to merged block ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
heap_merge_left:
push ebx
mov ebx,[eax+memblock.prevblock]
test ebx,ebx
jz .ret
test byte [ebx+memblock.size],1
jnz .ret
xchg eax,ebx
call heap_remove_block
mov ebx,[ebx+memblock.size]
add [eax+memblock.size],ebx
call heap_fix_right
.ret:
pop ebx
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; heap_merge_right ;;
;; input: ;;
;; eax - pointer to free block ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
heap_merge_right:
push ebx
mov ebx,eax
add ebx,[eax+memblock.size]
cmp ebx,[heapend]
jz .ret
test byte [ebx+memblock.size],1
jnz .ret
xchg eax,ebx
call heap_remove_block
xchg eax,ebx
mov ebx,[ebx+memblock.size]
add [eax+memblock.size],ebx
call heap_fix_right
.ret:
pop ebx
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; mf_free ;;
;; input: ;;
;; eax - pointer ;;
;; output: ;;
;; eax=1 - ok ;;
;; eax=0 - failed ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mf_free:
test eax,eax
jnz .no_null
inc eax
ret
.no_null:
if defined multithread
call heaplock
end if
sub eax,8
dec dword [eax+memblock.size]
call heap_merge_left
call heap_merge_right
call heap_add_free_block
.ret:
if defined multithread
call heapunlock
end if
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; heap_try_reloc
;; input:
;; eax - address
;; ebx - new size
;; output:
;; ebx=1 - ok
;; ebx=0 - failed
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
heap_try_reloc:
push eax
sub eax,8
add ebx,15
dec dword [eax+memblock.size]
and ebx,not 7
cmp [eax+memblock.size],ebx
jge .truncate
push ebx
mov ebx,eax
add ebx,[eax+memblock.size]
cmp ebx,[heapend]
jz .fail ;todo: we can allocate new mem here
test [ebx+memblock.size],byte 1
jnz .fail
xchg eax,ebx
call heap_remove_block
mov eax,[eax+memblock.size]
add [ebx+memblock.size],eax
mov eax,ebx
call heap_fix_right
pop ebx
.truncate:
xchg eax,ebx
call heap_split_block
test ebx,ebx
jz .no_last_block
mov eax,ebx
call heap_add_free_block
call heap_merge_right
.no_last_block:
xor ebx,ebx
pop eax
inc ebx
ret
.fail:
pop ebx
xor ebx,ebx
pop eax
inc dword [eax-8+memblock.size]
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; mf_realloc
;; input:
;; eax - pointer
;; ebx - new size
;; output:
;; eax - new pointer
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mf_realloc:
push ebx
if defined multithread
call heaplock
end if
call heap_try_reloc
test ebx,ebx
jnz .ret
;allocate new memory
push eax
mov eax,[esp+4]
call mf_alloc
test eax,eax
jz .fail
push esi
push edi
push ecx
mov edi,eax
mov esi,[esp+12]
mov ecx,[esi-8+memblock.size]
shr ecx,2
rep movsd
pop ecx
pop edi
pop esi
xchg eax,[esp]
call mf_free
.fail:
pop eax
.ret:
if defined multithread
call heapunlock
end if
pop ebx
ret
end if

View File

@ -1,7 +1,43 @@
xmalloc: pgalloc:
; in: eax=size ; in: ecx=size
; out: eax=pointer or NULL ; out: eax=pointer or NULL
call mf_alloc push ebx
push 68
pop eax
push 12
pop ebx
int 0x40
pop ebx
ret
pgfree:
; in: ecx=pointer
; destroys eax
push ebx
push 68
pop eax
push 13
pop ebx
int 0x40
pop ebx
ret
pgrealloc:
; in: ecx=size, edx=pointer
; out: eax=pointer
push ebx
push 68
pop eax
push 20
pop ebx
int 0x40
pop ebx
ret
xpgalloc:
; in: ecx=size
; out: eax=pointer or NULL
call pgalloc
.common: .common:
test eax, eax test eax, eax
jnz @f jnz @f
@ -10,11 +46,11 @@ xmalloc:
@@: @@:
ret ret
xrealloc: xpgrealloc:
; in: eax=pointer, ebx=new size ; in: edx=pointer, ecx=new size
; out: eax=pointer or NULL ; out: eax=pointer or NULL
call mf_realloc call pgrealloc
jmp xmalloc.common jmp xpgalloc.common
get_error_msg: get_error_msg:
; in: eax=error code ; in: eax=error code
@ -67,3 +103,171 @@ get_error_msg:
pop ecx edx pop ecx edx
stosb stosb
jmp .ret jmp .ret
libini_alloc:
push ecx
mov ecx, [esp+8]
call xpgalloc
pop ecx
ret 4
libini_free:
push ecx
mov ecx, [esp+8]
call pgfree
pop ecx
ret 4
libini_realloc:
push ecx edx
mov edx, [esp+8+4]
mov ecx, [esp+8+8]
call xpgrealloc
pop edx ecx
ret 8
libini_dllload:
push esi
mov esi, [esp+8]
.lib:
lodsd
test eax, eax
jz .ret
push eax
lodsd
xchg esi, [esp]
xor ebp, ebp ; no version control
call load_dll_and_import
pop esi
test eax, eax
jz .lib
.ret:
pop esi
ret 4
load_dll_and_import:
cmp byte [eax], '/'
jz .do
push esi
mov edi, saved_file_name
push edi
mov esi, standard_dll_path
mov ecx, standard_dll_path_size
rep movsb
mov esi, eax
mov ecx, 1024-standard_dll_path_size
@@:
lodsb
stosb
test al, al
loopnz @b
pop eax
pop esi
jz .do
push eax
mov edi, aFileNameTooBig
.sayerr:
push dword aCannotLoadDLL
push edi
mov eax, esp
push dword aOk
push esp
push 1
push eax
push 3
push -1
push -1
push dword aError
call SayErr
add esp, 16
xor eax, eax
inc eax
ret
.do:
push eax
mov ecx, eax
push 68
pop eax
push 19
pop ebx
int 0x40
mov edi, aInvalidDLL
test eax, eax
jz .sayerr
; initialize import
mov edi, aMissingExport
mov edx, eax
.import_loop:
lodsd
test eax, eax
jz .import_done
call .find_exported_function
jc .sayerr
mov [esi-4], eax
jmp .import_loop
.import_done:
; check version
test ebp, ebp
jz .version_ok
mov edi, aIncompatibleVersion
mov eax, aVersion
call .find_exported_function
jc .sayerr
cmp ax, bp
jb .sayerr
shr eax, 16
cmp eax, ebp
ja .sayerr
.version_ok:
; initialize library
mov eax, aStart
call .find_exported_function
jc @f
push 1 ; DLL_ENTRY
call eax
.ret0:
pop eax
xor eax, eax
ret
@@:
mov eax, aLibInit
call .find_exported_function
jc .ret0
mov esi, eax
mov eax, libini_alloc
mov ebx, libini_free
mov ecx, libini_realloc
mov edx, libini_dllload
call esi
mov edi, aInitFailed
test eax, eax
jnz .sayerr
jmp .ret0
.find_exported_function:
push edx
.import_loop_i:
mov ebx, [edx]
test ebx, ebx
jz .import_notfound
push eax
@@:
mov cl, [eax]
cmp cl, [ebx]
jnz .import_find_next
test cl, cl
jz .import_found
inc eax
inc ebx
jmp @b
.import_find_next:
pop eax
add edx, 8
jmp .import_loop_i
.import_found:
pop eax
mov eax, [edx+4]
pop edx
ret
.import_notfound:
pop edx
stc
ret

View File

@ -10,6 +10,7 @@ viewer_data:
.bEofReached db ? .bEofReached db ?
.flags db ? ; & 1: hex mode .flags db ? ; & 1: hex mode
; & 2: unwrap ; & 2: unwrap
; & 4: big-endian unicode
rb 1 rb 1
.filename rb 1024 .filename rb 1024
.buf rb 16384 .buf rb 16384
@ -24,9 +25,11 @@ view_file:
ret ret
.file: .file:
lea esi, [ebp + panel1_dir - panel1_data] lea esi, [ebp + panel1_dir - panel1_data]
mov eax, viewer_data.size push ecx
mov ecx, viewer_data.size
mov edx, viewer_vtable mov edx, viewer_vtable
call new_screen call new_screen
pop ecx
test eax, eax test eax, eax
jnz @f jnz @f
ret ret
@ -128,12 +131,40 @@ view_file:
jz .attr_retry jz .attr_retry
jmp delete_active_screen jmp delete_active_screen
.readok: .readok:
cmp ebx, 2
jb .nounicode
cmp word [ebp+viewer_data.buf], 0xFEFF
jz @f
cmp word [ebp+viewer_data.buf], 0xFFFE
jnz .nounicode
or byte [ebp+viewer_data.flags], 4
@@:
mov [ebp+viewer_data.encoding], encodings.unicode
.nounicode:
call viewer_set_keybar call viewer_set_keybar
call viewer_draw_text call viewer_draw_text
ret ret
viewer_get_next_char: viewer_get_next_char:
pusha pusha
cmp [ebp+viewer_data.encoding], encodings.unicode
jnz @f
cmp [bForHex], 0
jnz @f
cmp dword [ebp+viewer_data.buf_start], 0
jnz @f
cmp dword [ebp+viewer_data.buf_start+4], 0
jnz @f
lea eax, [ebp+viewer_data.buf]
cmp eax, [ebp+viewer_data.buf_pos]
jnz @f
cmp word [eax], 0xFFFE
jz .skip
cmp word [eax], 0xFEFF
jnz @f
.skip:
add [ebp+viewer_data.buf_pos], 2
@@:
mov eax, [ebp+viewer_data.buf_pos] mov eax, [ebp+viewer_data.buf_pos]
lea ecx, [ebp+viewer_data.buf] lea ecx, [ebp+viewer_data.buf]
add ecx, [ebp+viewer_data.buf_size] add ecx, [ebp+viewer_data.buf_size]
@ -184,6 +215,8 @@ viewer_get_next_char:
popa popa
ret ret
.buffered: .buffered:
cmp [ebp+viewer_data.encoding], encodings.unicode
jz .unicode
mov al, [eax] mov al, [eax]
.done: .done:
mov [esp+28], al mov [esp+28], al
@ -192,6 +225,17 @@ viewer_get_next_char:
popa popa
ret ret
.unicode:
inc [ebp+viewer_data.buf_pos]
cmp [bForHex], 0
jnz @f
call read_unicode_char
jmp .done
@@:
mov ax, [eax]
mov [esp+29], ah
jmp .done
viewer_get_prev_char: viewer_get_prev_char:
pusha pusha
lea ecx, [ebp+viewer_data.buf] lea ecx, [ebp+viewer_data.buf]
@ -217,14 +261,61 @@ viewer_get_prev_char:
.buffered: .buffered:
mov eax, [ebp+viewer_data.buf_pos] mov eax, [ebp+viewer_data.buf_pos]
dec eax dec eax
cmp [ebp+viewer_data.encoding], encodings.unicode
jz .unicode
mov [ebp+viewer_data.buf_pos], eax mov [ebp+viewer_data.buf_pos], eax
mov al, [eax] mov al, [eax]
mov [esp+28], al mov [esp+28], al
.done:
clc clc
.ret: .ret:
popa popa
ret ret
.unicode:
dec eax
mov [ebp+viewer_data.buf_pos], eax
call read_unicode_char
jmp .done
read_unicode_char:
mov ax, [eax]
uni2ansi_char:
test [ebp+viewer_data.flags], 4
jz @f
xchg al, ah
@@:
cmp ax, 0x80
jb .ret
cmp ax, 0x401
jz .yo1
cmp ax, 0x451
jz .yo2
cmp ax, 0x410
jb .unk
cmp ax, 0x440
jb .rus1
cmp ax, 0x450
jb .rus2
.unk:
mov al, ' '
.ret:
ret
.yo1:
mov al, 'ð'
ret
.yo2:
mov al, 'ñ'
ret
.rus1:
; 0x410-0x43F -> 0x80-0xAF
add al, 0x70
ret
.rus2:
; 0x440-0x44F -> 0xE0-0xEF
add al, 0xA0
ret
fld_uint64: fld_uint64:
fild qword [eax] fild qword [eax]
test byte [eax+7], 80h test byte [eax+7], 80h
@ -508,6 +599,8 @@ end if
test al, al test al, al
jns @f jns @f
movzx esi, [ebp+viewer_data.encoding] movzx esi, [ebp+viewer_data.encoding]
cmp esi, encodings.unicode
jz @f
shl esi, 7 shl esi, 7
movzx eax, al movzx eax, al
mov al, [encodings.tables-80h+esi+eax] mov al, [encodings.tables-80h+esi+eax]
@ -609,12 +702,15 @@ end if
rep stosw rep stosw
mov ebx, edi mov ebx, edi
pop edi pop edi
mov [bForHex], 1
call viewer_get_next_char call viewer_get_next_char
mov [bForHex], 0
jc .hexdone jc .hexdone
push eax push eax
push edi push edi
add edi, 36*2 add edi, 36*2
mov al, 0xB3 mov al, 0xB3
mov ah, [view_normal_color]
call .safechar call .safechar
pop edi pop edi
mov eax, dword [ebp+viewer_data.cur_pos] mov eax, dword [ebp+viewer_data.cur_pos]
@ -655,9 +751,13 @@ end if
pop eax pop eax
jmp @f jmp @f
.hexchar: .hexchar:
mov [bForHex], 1
call viewer_get_next_char call viewer_get_next_char
mov [bForHex], 0
jc .hexdone jc .hexdone
@@: @@:
cmp [ebp+viewer_data.encoding], encodings.unicode
jz .hexchar_unicode
push eax push eax
shr al, 4 shr al, 4
call .hex_digit call .hex_digit
@ -698,6 +798,53 @@ end if
@@: @@:
cmp ecx, 16 cmp ecx, 16
jnz .hexchar jnz .hexchar
jmp .hexchar_nextline
.hexchar_unicode:
push eax
shr eax, 12
call .hex_digit
pop eax
push eax
shr eax, 8
and al, 0xF
call .hex_digit
pop eax
push eax
shr al, 4
call .hex_digit
pop eax
push eax
and al, 0xF
call .hex_digit
mov al, ' '
mov ah, [view_normal_color]
call .safechar
pop eax
push edi
add edi, 38*2
push ecx
shl ecx, 3
sub edi, ecx
pop ecx
cmp ecx, 4
jb @f
sub edi, 4
@@:
call uni2ansi_char
mov ah, [view_normal_color]
call .safechar
pop edi
inc ecx
cmp ecx, 4
jnz @f
mov al, 0xB3
call .safechar
mov al, ' '
call .safechar
@@:
cmp ecx, 8
jnz .hexchar
.hexchar_nextline:
mov edi, ebx mov edi, ebx
add esi, 3 add esi, 3
mov edx, esi mov edx, esi
@ -932,8 +1079,11 @@ viewer_set_curpos:
viewer_next_newline: viewer_next_newline:
test [ebp+viewer_data.flags], 1 test [ebp+viewer_data.flags], 1
jz .nohex jz .nohex
push 10h push 8
pop ecx pop ecx
cmp [ebp+viewer_data.encoding], encodings.unicode
jz @f
add ecx, ecx
@@: @@:
call viewer_get_next_char call viewer_get_next_char
jc @f jc @f
@ -978,6 +1128,9 @@ viewer_next_newline:
cmp cl, 0xD xor 0xA cmp cl, 0xD xor 0xA
jz .2 jz .2
dec [ebp+viewer_data.buf_pos] dec [ebp+viewer_data.buf_pos]
cmp [ebp+viewer_data.encoding], encodings.unicode
jnz .2
dec [ebp+viewer_data.buf_pos]
.2: .2:
.ret: .ret:
call viewer_set_curpos call viewer_set_curpos
@ -986,8 +1139,11 @@ viewer_next_newline:
viewer_prev_newline: viewer_prev_newline:
test [ebp+viewer_data.flags], 1 test [ebp+viewer_data.flags], 1
jz .nohex jz .nohex
push 10h push 8
pop ecx pop ecx
cmp [ebp+viewer_data.encoding], encodings.unicode
jz @f
add ecx, ecx
@@: @@:
call viewer_get_prev_char call viewer_get_prev_char
jc @f jc @f
@ -1096,7 +1252,11 @@ else
@@: @@:
end if end if
movzx esi, [ebp+viewer_data.encoding] movzx esi, [ebp+viewer_data.encoding]
xor esi, 1 dec esi
jz @f
push 1
pop esi
@@:
lea esi, [encodings.names+esi*8] lea esi, [encodings.names+esi*8]
lea edi, [eax+keybar_cp-keybar_viewer] lea edi, [eax+keybar_cp-keybar_viewer]
movsd movsd
@ -1154,11 +1314,13 @@ viewer_OnKey:
ret ret
.f8: .f8:
movzx esi, [ebp+viewer_data.encoding] movzx esi, [ebp+viewer_data.encoding]
xor [ebp+viewer_data.encoding], 1 dec [ebp+viewer_data.encoding]
call viewer_set_keybar jz .done_redraw_keybar
jmp .done_redraw mov [ebp+viewer_data.encoding], 1
jmp .done_redraw_keybar
.f2: .f2:
xor [ebp+viewer_data.flags], 2 xor [ebp+viewer_data.flags], 2
.done_redraw_keybar:
call viewer_set_keybar call viewer_set_keybar
jmp .done_redraw jmp .done_redraw
.f4: .f4:
@ -1167,7 +1329,13 @@ viewer_OnKey:
call viewer_set_keybar call viewer_set_keybar
popf popf
jnz .tohex jnz .tohex
add dword [ebp+viewer_data.cur_pos], 1 push 1
pop eax
cmp [ebp+viewer_data.encoding], encodings.unicode
jnz @f
add eax, eax
@@:
add dword [ebp+viewer_data.cur_pos], eax
adc dword [ebp+viewer_data.cur_pos+4], 0 adc dword [ebp+viewer_data.cur_pos+4], 0
call viewer_seek_to_current call viewer_seek_to_current
call viewer_prev_newline call viewer_prev_newline
@ -1249,6 +1417,29 @@ viewer_OnKey:
mov dword [ebp+viewer_data.col], eax mov dword [ebp+viewer_data.col], eax
mov dword [ebp+viewer_data.col+4], edx mov dword [ebp+viewer_data.col+4], edx
jmp .done_redraw jmp .done_redraw
.shift_f8:
mov ecx, encodings.menu.1
mov al, [ebp+viewer_data.encoding]
@@:
cmp byte [ecx-1], al
jz @f
mov ecx, [ecx]
jmp @b
@@:
push 1
push aTables
push ecx
call menu
cmp eax, -1
jz .ret
mov al, [eax-1]
mov [ebp+viewer_data.encoding], al
cmp al, encodings.unicode
jnz .done_redraw_keybar
add dword [ebp+viewer_data.cur_pos], 1
adc dword [ebp+viewer_data.cur_pos+4], 0
and dword [ebp+viewer_data.cur_pos], not 1
jmp .done_redraw_keybar
viewer_getname: viewer_getname:
if lang eq ru if lang eq ru

View File

@ -8,7 +8,7 @@
;; Compile with FASM for Menuet ;; ;; Compile with FASM for Menuet ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
include 'lang.inc'
version equ '0.1' version equ '0.1'
use32 use32
@ -23,26 +23,22 @@ use32
dd 0xffff0 dd 0xffff0
dd 0,0 dd 0,0
include 'macros.inc'
save_file: save_file:
pusha ; cmp [file_start],0x100000+10
; jbe nosub
cmp [file_start],0x100000+10 ; sub [file_start],8
jbe nosub ; nosub:
sub [file_start],8
nosub:
mov edi,[file_start]
mov eax,[file_start] mov eax,[file_start]
sub eax,0x100000 sub eax,0x100000
mov [files+8],eax
mov eax,58
mov ebx,files mov ebx,files
int 0x40 mov [ebx+12],eax
popa mov eax,70
int 0x40
ret ret
@ -51,19 +47,22 @@ START: ; start of execution
mov [file_start],0x100000 mov [file_start],0x100000
mov eax,58 mov eax,70
mov ebx,filel mov ebx,filel
int 0x40 int 0x40
cmp eax,0 test eax,eax
jne notfound jz @f
cmp eax,6
jnz notfound
@@:
add [file_start],ebx add [file_start],ebx
notfound: notfound:
mov edi,I_END mov edi,I_END
mov ecx,60*120 mov ecx,60*120
mov eax,32 mov al,32
cld cld
rep stosb rep stosb
@ -630,17 +629,8 @@ draw_window:
mov eax,0 ; draw window mov eax,0 ; draw window
mov ebx,5*65536+400 mov ebx,5*65536+400
mov ecx,5*65536+200 mov ecx,5*65536+200
mov edx,[wcolor] mov edx,0x13ffffff
add edx,0x03ffffff mov edi,labelt
mov esi,0x80555599
mov edi,0x00ffffff
int 0x40
mov eax,4 ; label
mov ebx,9*65536+8
mov ecx,0x10ffffff
mov edx,labelt
mov esi,labellen-labelt
int 0x40 int 0x40
mov eax,8 ; button: open socket mov eax,8 ; button: open socket
@ -746,7 +736,7 @@ db ' Timeout is set to 15 seconds. '
db ' ' db ' '
db ' Open SMTP server port 25 Close SMTP ' db ' Open SMTP server port 25 Close SMTP '
db 'x <- END MARKER, DONT DELETE ' db 'x' ; <- END MARKER, DONT DELETE
irc_server_ip db 192,168,1,1 irc_server_ip db 192,168,1,1
@ -754,10 +744,10 @@ irc_server_ip db 192,168,1,1
file_start dd 0x100000 file_start dd 0x100000
files: files:
dd 1,0,0,0x100000,0xd0000 dd 2,0,0,?,0x100000
db '/rd/1/smtps.txt',0 db '/rd/1/smtps.txt',0
filel: filel:
dd 0,0,10000/512,0x100000,0xd0000 dd 0,0,0,0x100000,0x100000
db '/rd/1/smtps.txt',0 db '/rd/1/smtps.txt',0
@ -840,10 +830,6 @@ scroll dd 1
numtext db ' ' numtext db ' '
wcolor dd 0x000000 labelt db 'Tiny SMTP email server v ',version,0
labelt db 'Tiny SMTP email server v ',version
labellen:
I_END: I_END: