Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 589 → Rev 529

/programs/fs/kfar/trunk/kfar.ini
File deleted
/programs/fs/kfar/trunk/kfar_arc/ppmd.inc
File deleted
/programs/fs/kfar/trunk/kfar_arc/7z.inc
File deleted
/programs/fs/kfar/trunk/kfar_arc/lang.inc
File deleted
\ No newline at end of file
/programs/fs/kfar/trunk/kfar_arc/lzma.inc
File deleted
/programs/fs/kfar/trunk/kfar_arc/crc.inc
File deleted
/programs/fs/kfar/trunk/kfar_arc/sha256.inc
File deleted
/programs/fs/kfar/trunk/kfar_arc/aes.inc
File deleted
/programs/fs/kfar/trunk/kfar_arc/7zaes.inc
File deleted
/programs/fs/kfar/trunk/kfar_arc/kglobals.inc
File deleted
/programs/fs/kfar/trunk/kfar_arc/7zbranch.inc
File deleted
/programs/fs/kfar/trunk/kfar_arc/kfar_arc.asm
File deleted
/programs/fs/kfar/trunk/api.txt
File deleted
/programs/fs/kfar/trunk/kfar.asm
7,9 → 7,6
dd stacktop
dd 0, app_path
 
version equ '0.4'
version_dword equ 0*10000h + 40
 
include 'lang.inc'
include 'font.inc'
include 'sort.inc'
84,18 → 81,10
jz exit
cmp [panel1_files], 0
jz exit
xor eax, eax
mov [panel1_hPlugin], eax
mov [panel1_parents], eax
mov [panel1_parents_sz], eax
mov [panel1_parents_alloc], eax
mov [panel2_hPlugin], eax
mov [panel2_parents], eax
mov [panel2_parents_sz], eax
mov [panel2_parents_alloc], eax
mov [panel1_sortmode], al ; sort by name
mov [panel2_sortmode], al
mov al, 2 ; "á।­¨©" ä®à¬ â
mov [panel1_sortmode], 0 ; sort by name
mov [panel2_sortmode], 0
push 2 ; "á।­¨©" ä®à¬ â
pop eax
mov [panel1_colmode], eax
mov [panel2_colmode], eax
mov [num_screens], 1
132,28 → 121,6
push dword app_path
call [ini.get_int]
mov [bConfirmDeleteIncomplete], al
push 2
push aLeftViewMode
push aPanels
push app_path
call [ini.get_int]
cmp eax, 1
jb @f
cmp eax, 4
ja @f
mov [panel1_colmode], eax
@@:
push 2
push aRightViewMode
push aPanels
push app_path
call [ini.get_int]
cmp eax, 1
jb @f
cmp eax, 4
ja @f
mov [panel2_colmode], eax
@@:
mov ecx, 0x1000
call xpgalloc
test eax, eax
235,11 → 202,6
@@:
loop .l3
.skip_shortcuts:
; load plugins
push enum_plugins_callback
push aPlugins
push app_path
call [ini.enum_keys]
.noini:
mov esi, def_left_dir
mov edi, panel1_dir
277,86 → 239,6
jz key
; button - we have only one button, close
exit:
; close all screens
@@:
mov ecx, [num_screens]
mov eax, [screens]
mov ebp, [eax+ecx*8-4]
mov eax, [eax+ecx*8-8]
push ebp
call [eax+screen_vtable.OnExit]
pop ecx
call pgfree
dec [num_screens]
jnz @b
; unload all plugins
mov ecx, [num_plugins]
imul esi, ecx, PluginInfo.size
add esi, [plugins]
.unload:
dec ecx
js .unload_done
sub esi, PluginInfo.size
push ecx esi
call [esi+PluginInfo.unload]
pop esi ecx
jmp .unload
.unload_done:
if 0 ; commented due to bug in libini
cmp [ini.set_int], aIniSetInt
jz .nosave
push [panel1_colmode]
push aLeftViewMode
push aPanels
push app_path
call [ini.set_int]
push [panel2_colmode]
push aRightViewMode
push aPanels
push app_path
call [ini.set_int]
.nosave:
end if
if CHECK_FOR_LEAKS
mov ecx, [panel1_files]
call pgfree
mov ecx, [panel2_files]
call pgfree
mov ecx, [screens]
call pgfree
mov ecx, [associations]
call pgfree
mov ecx, [console_data_ptr]
call pgfree
mov ecx, [MemForImage]
call pgfree
mov esi, FolderShortcuts
push 10
pop ecx
@@:
lodsd
test eax, eax
jnz @f
loop @b
jmp .nofreefs
@@:
mov ecx, eax
call pgfree
mov ecx, [plugins]
call pgfree
mov ecx, [panel1_parents]
call pgfree
mov ecx, [panel2_parents]
call pgfree
.nofreefs:
mov eax, [numallocatedregions]
test eax, eax
jz @f
mov edi, allocatedregions
int3
jmp $
@@:
end if
or eax, -1
int 40h
redraw:
758,182 → 640,6
xor eax, eax
ret 12
 
enum_plugins_callback:
; LongBool __stdcall callback(f_name,sec_name,key_name);
; [esp+4] = f_name, [esp+8] = sec_name, [esp+12] = key_name
push nullstr
push 1024
push saved_file_name
push dword [esp+12+12]
push dword [esp+16+8]
push dword [esp+20+4]
call [ini.get_str]
test eax, eax
jnz .ret
mov esi, saved_file_name
cmp byte [esi], '/'
jz .absolute
; convert path to absolute
mov edi, execdata
push esi
@@:
lodsb
stosb
test al, al
jnz @b
pop edi
mov esi, app_path
push esi
xor ecx, ecx
@@:
lodsb
test al, al
jz @f
cmp al, '/'
jnz @b
mov ecx, esi
jmp @b
@@:
pop esi
sub ecx, esi
rep movsb
mov esi, execdata
.z:
cmp word [esi], '.'
jz .ret
cmp word [esi], './'
jnz @f
add esi, 2
jmp .z
@@:
cmp word [esi], '..'
jnz .c
cmp byte [esi+2], 0
jz .ret
cmp byte [esi+2], '/'
jnz .c
add esi, 3
@@:
dec edi
cmp edi, saved_file_name
jbe .ret
cmp byte [edi-1], '/'
jnz @b
jmp .z
.c:
lodsb
stosb
test al, al
jz @f
cmp edi, saved_file_name+1024
jb .c
mov esi, execdata
call load_dll_and_import.big
.ret:
mov al, 1
ret 12
@@:
.absolute:
; allocate space for plugin info
mov eax, [num_plugins]
inc eax
mov [num_plugins], eax
imul ecx, eax, PluginInfo.size
cmp ecx, [alloc_plugins]
jbe .norealloc
mov edx, [plugins]
call xpgrealloc
test eax, eax
jnz @f
.dec_ret:
dec [num_plugins]
jmp .ret
@@:
mov [plugins], eax
lea eax, [ecx+0xFFF]
and eax, not 0xFFF
mov [alloc_plugins], eax
.norealloc:
mov esi, [plugins]
lea esi, [esi+ecx-PluginInfo.size]
; load plugin DLL
or ebp, -1
mov eax, saved_file_name
call load_dll_and_import.do
test eax, eax
jnz .dec_ret
; find exported functions
mov eax, aVersion
call load_dll_and_import.find_exported_function
jnc @f
xor eax, eax
@@:
MIN_INTERFACE_VER = 1
MAX_INTERFACE_VER = 1
cmp eax, MIN_INTERFACE_VER
jae @f
cmp eax, MAX_INTERFACE_VER
jbe @f
push aIncompatibleVersion
.cantload:
push saved_file_name
push aCannotLoadPlugin
mov eax, esp
push ContinueBtn
push 1
push eax
push 3
call SayErr
add esp, 12
jmp .dec_ret
@@:
mov edi, esi
mov esi, plugin_exported
.import:
lodsd
test eax, eax
jz .import_done
call load_dll_and_import.find_exported_function
jnc @f
mov eax, [esi-4+plugin_exported_default-plugin_exported]
@@:
stosd
jmp .import
.import_done:
; initialize plugin
mov eax, aPluginLoad
call load_dll_and_import.find_exported_function
jc .ok
push kfar_info
call eax
cmp eax, 1
jb .ok
ja .dec_ret
push aInitFailed
jmp .cantload
.ok:
mov al, 1
ret 12
 
plugin_unload_default:
ret
 
OpenFilePlugin_default:
GetFiles_default:
xor eax, eax
ret 20
 
ClosePlugin_default:
ret 4
 
GetOpenPluginInfo_default:
ret 8
 
SetFolder_default:
open_default:
xor eax, eax
ret 12
 
new_screen:
; in: ecx=sizeof(screen data), edx->vtable
; out: ebp=pointer or NULL, eax!=0 if successful
1261,152 → 967,6
call get_curfile_folder_entry
test byte [ecx], 10h
jnz .enter_folder
; todo: add <Enter> handling on plugin panel
cmp [ebp + panel1_hPlugin - panel1_data], 0
jnz .ret
; generate full file name
lea esi, [ebp + panel1_dir - panel1_data]
mov edi, execdata
@@:
lodsb
test al, al
jz @f
stosb
cmp edi, execdataend-1
jae .bigfilename
jmp @b
@@:
lea esi, [ecx+40]
mov al, '/'
stosb
@@:
lodsb
stosb
cmp edi, execdataend
ja .bigfilename
test al, al
jnz @b
; try to open file and look for all plugins
push O_READ
push execdata
call open
test eax, eax
jz .noplugins ; if can't open, just try to execute
mov esi, eax ; save handle
push filedata_buffer_size
push filedata_buffer
push esi
call read
mov edi, eax ; save size of read data
; test for Kolibri executable
cmp eax, 24h
jb .enter.noexec
cmp dword [filedata_buffer], 'MENU'
jnz @f
cmp word [filedata_buffer+4], 'ET'
jnz @f
.close_run:
push esi
call close
jmp .run_app
@@:
cmp dword [filedata_buffer], 'KPCK'
jnz @f
cmp dword [filedata_buffer+12], 0x26914601
jz .close_run
@@:
.enter.noexec:
mov ecx, [num_plugins]
mov edx, [plugins]
sub edx, PluginInfo.size
.plugloop:
add edx, PluginInfo.size
dec ecx
js .plugdone
pushad
push edi
push filedata_buffer
call get_curfile_folder_entry
push ecx
push execdata
push esi
call [edx+PluginInfo.OpenFilePlugin]
mov [esp+28], eax
popad
test eax, eax
jz .plugloop
cmp eax, -1
jnz .pluginok
push esi
call close
ret
.pluginok:
; save current directory and set root directory of hPlugin
mov edi, eax ; save handle
mov esi, execdata
@@:
lodsb
test al, al
jnz @b
sub esi, execdata-9
; allocate esi bytes in buffer 'parents'
mov ecx, [ebp + panel1_parents_sz - panel1_data]
add ecx, esi
cmp ecx, [ebp + panel1_parents_alloc - panel1_data]
jbe .enter.norealloc
push edx
mov edx, [ebp + panel1_parents - panel1_data]
call xpgrealloc
pop edx
test eax, eax
jnz @f
push edi
call [edx+PluginInfo.ClosePlugin]
ret
@@:
mov [ebp + panel1_parents - panel1_data], eax
.enter.norealloc:
mov [ebp + panel1_parents_sz - panel1_data], ecx
; save current state to the end of buffer
sub ecx, esi
add ecx, [ebp + panel1_parents - panel1_data]
xchg edx, [ebp + panel1_hPlugin - panel1_data]
mov [ecx], edx
xchg edi, [ebp + panel1_hFile - panel1_data]
mov [ecx+4], edi
mov byte [ecx+8], 0
lea edi, [ecx+9]
lea ecx, [esi-9]
mov esi, execdata
rep movsb
mov word [ebp + panel1_dir - panel1_data], '/'
mov eax, [ebp + panel1_hPlugin - panel1_data]
lea ebx, [ebp + panel1_plugin_info - panel1_data]
and dword [ebx], 0
push ebp
push ebx
push [ebp + panel1_hFile - panel1_data]
call [eax+PluginInfo.GetOpenPluginInfo]
pop ebp
call get_curfile_folder_entry
mov esi, ecx
mov edi, left_dotdot_entry
cmp ebp, panel1_data
jz @f
add edi, right_dotdot_entry-left_dotdot_entry
@@:
mov ecx, 10
rep movsd
mov byte [edi-40], 10h ; attributes: folder
mov eax, '..'
stosd
jmp .reread
.plugdone:
push esi
call close
.noplugins:
; run program or association
call get_curfile_folder_entry
call find_extension
jc .run_app
.run_association:
1436,6 → 996,27
mov [execptr], execdata
and [execparams], 0
.dorun:
lea esi, [ebp + panel1_dir - panel1_data]
mov edi, execdata
@@:
lodsb
test al, al
jz @f
stosb
cmp edi, execdataend-1
jae .bigfilename
jmp @b
@@:
lea esi, [ecx+40]
mov al, '/'
stosb
@@:
lodsb
stosb
cmp edi, execdataend
ja .bigfilename
test al, al
jnz @b
; for fasm call - special handling, because
; 1) fasm command line convention is different : fasm infile,outfile[,path] rather than tinypad infile
; 2) fasm will probably create new file in directory, so we want to reload panel data
1515,6 → 1096,9
push 1
push eax
push 2
push -1
push -1
push dword aError
call SayErr
pop eax
pop eax
1549,6 → 1133,9
push 1
push eax
push 1
push -1
push -1
push dword aError
call SayErr
pop eax
ret
1556,13 → 1143,7
mov eax, aCmdLineTooBig
jmp .l2
.bigfoldername2:
mov esi, prev_dir
lea edi, [ebp + panel1_dir - panel1_data]
@@:
lodsb
stosb
test al, al
jnz @b
mov byte [ecx], 0
.bigfoldername:
mov eax, aFolderNameTooBig
jmp .l2
1586,6 → 1167,7
cmp esi, edx
pop esi
jae .bigfoldername
mov ecx, edi
mov al, '/'
cmp [edi-1], al
jz @f
1597,28 → 1179,6
stosb
test al, al
jnz @b
mov eax, [ebp + panel1_hPlugin - panel1_data]
test eax, eax
jz .reread
push ebp
lea esi, [ebp + panel1_dir - panel1_data]
push esi
add ecx, 40
push ecx
push [ebp + panel1_hFile - panel1_data]
call [eax+PluginInfo.SetFolder]
pop ebp
test al, al
jnz .reread
mov esi, prev_dir
lea edi, [ebp + panel1_dir - panel1_data]
@@:
lodsb
stosb
test al, al
jnz @b
.retd:
ret
.reread:
call read_folder
.done_cmdbar:
1626,14 → 1186,6
jmp .done_redraw
.dotdot:
lea edi, [ebp + panel1_dir - panel1_data]
cmp word [edi], '/'
jnz .dotdot_noroot
cmp [ebp + panel1_hPlugin - panel1_data], 0
jz .retd
call close_plugin_panel
jmp .dotdot
.dotdot_noroot:
mov edx, edi
mov al, 0
or ecx, -1
repnz scasb
1643,37 → 1195,11
repnz scasb
cld
inc edi
cmp edi, edx
jnz @f
mov byte [edi], 0
inc edi
@@:
push dword [edi]
mov byte [edi], 0
push edi
mov eax, [ebp + panel1_hPlugin - panel1_data]
test eax, eax
jz .dotdot_native
push ebp
lea esi, [ebp + panel1_dir - panel1_data]
push esi
push aDotDot
push [ebp + panel1_hFile - panel1_data]
call [eax+PluginInfo.SetFolder]
pop ebp
test al, al
jnz .dotdot_native
pop edi
pop dword [edi]
ret
.dotdot_native:
call read_folder
pop edi
pop dword [edi]
push edi
cmp byte [edi], '/'
jnz @f
inc edi
@@:
mov edx, [ebp + panel1_files - panel1_data]
mov ecx, [ebp + panel1_numfiles - panel1_data]
.scanloop:
1702,8 → 1228,6
inc edx
mov [ebp + panel1_start - panel1_data], edx
.scandone:
pop edi
mov byte [edi], 0
jmp .done_cmdbar
.ctrl_f39:
sub al, 0x3D
1832,10 → 1356,6
@@:
mov ecx, edx
lea edi, [ebp + panel1_dir - panel1_data]
cmp [ebp + panel1_hPlugin - panel1_data], 0
jz .find_cur_drive_loop
mov edi, [ebp + panel1_parents - panel1_data]
add edi, 8
.find_cur_drive_loop:
push edi
lea esi, [ecx+8]
1871,22 → 1391,15
push [ebp + panel1_left - panel1_data]
call menu_centered_in
cmp eax, -1
jnz @f
mov ecx, edx
call pgfree
ret
@@:
push eax
call close_plugin_panels
jz .ret2
lea esi, [eax+8]
lea edi, [ebp + panel1_dir - panel1_data]
push edi
push ecx esi edi
mov esi, edi
mov edi, prev_dir
mov ecx, 1024/4
rep movsd
pop edi
pop esi
add esi, 8
pop edi esi ecx
@@:
lodsb
stosb
1897,11 → 1410,6
call read_folder
jmp .done_redraw
.shift_f5:
; todo: copy to plugin panel
cmp [ebp + panel1_hPlugin - panel1_data], 0
jz @f
ret
@@:
mov esi, ebp
cmp [ebp + panel1_selected_num - panel1_data], 0
jnz .f5_2
1921,23 → 1429,9
stosb
jmp @b
.f5:
; todo: copy to plugin panel
mov esi, ebp
xor esi, panel1_data xor panel2_data
cmp [esi + panel1_hPlugin - panel1_data], 0
jz .f5_2
ret
.f5_2:
mov eax, [ebp + panel1_hPlugin - panel1_data]
mov [source_hModule], eax
mov eax, [ebp + panel1_hFile - panel1_data]
mov [source_hPlugin], eax
mov eax, left_dotdot_entry
cmp ebp, panel1_data
jz @f
add eax, right_dotdot_entry-left_dotdot_entry
@@:
mov [default_attr], eax
add esi, panel1_dir - panel1_data
mov edi, CopyDestEditBuf
mov eax, CopyDestEditBuf.length
2205,6 → 1699,9
push 1
push eax
push 2
push -1
push -1
push aError
call SayErr
pop eax
pop eax
2270,9 → 1767,6
mov [bDestIsFolder], dl
mov [copy_bSkipAll], 0
mov [copy_bSkipAll2], 0
mov [copy_bSkipAll3], 0
test [ebp + panel1_plugin_flags - panel1_data], 2
jnz .copy_GetFiles
cmp [ebp + panel1_selected_num - panel1_data], 0
jnz .f5_selected3
call copy_file
2305,43 → 1799,6
loop .f5_selected_copyloop
.f5_multiple_cancel:
jmp .copydone
.copy_GetFiles:
mov ecx, [ebp + panel1_selected_num - panel1_data]
cmp ecx, 1
adc ecx, 0
shl ecx, 2
call xpgalloc
test eax, eax
jnz @f
ret
@@:
push ebp eax ; save
push copy_AddDir ; adddir
push copy_AddFile ; addfile
push eax ; items
shr ecx, 2
push ecx ; NumItems
push [ebp + panel1_hFile - panel1_data]
mov edi, eax
call get_curfile_folder_entry
mov [edi], ecx
cmp [ebp + panel1_selected_num - panel1_data], 0
jz .cgf1
mov esi, [ebp + panel1_files - panel1_data]
mov ecx, [ebp + panel1_numfiles - panel1_data]
.cgf0:
lodsd
test byte [eax+303], 1
jz @f
stosd
@@:
loop .cgf0
.cgf1:
mov eax, [ebp + panel1_hPlugin - panel1_data]
call [eax+PluginInfo.GetFiles]
pop ecx ebp
call pgfree
jmp .copydone
 
.f3:
call view_file
2392,6 → 1849,8
push 2
push eax
push 2
push -1
push -1
push aDeleteCaption
call Message
add esp, 8
2412,11 → 1871,6
.f8_multiple_cancel:
jmp .copydone
.f8:
; todo: delete files from plugin panel
cmp [ebp + panel1_hPlugin - panel1_data], 0
jz @f
ret
@@:
cmp [ebp + panel1_selected_num - panel1_data], 0
jnz .f8_has_selected
call get_curfile_folder_entry
2447,6 → 1901,8
push 2
push eax
push 2
push -1
push -1
push aDeleteCaption
call Message
add esp, 8
2519,11 → 1975,6
@@:
jmp .done_redraw
.menu:
; todo: context menu for plugin panel
cmp [ebp + panel1_hPlugin - panel1_data], 0
jz @f
ret
@@:
; display context menu
; ignore folders
call get_curfile_folder_entry
2802,10 → 2253,8
jnz @f
ret
@@:
push eax
call close_plugin_panels
lea esi, [ebp + panel1_dir - panel1_data]
push esi
push eax esi
mov edi, prev_dir
@@:
lodsb
2934,113 → 2383,6
.galoopdone:
jmp .done_redraw
 
@@:
call close_plugin_panel
close_plugin_panels:
cmp [ebp + panel1_hPlugin - panel1_data], 0
jnz @b
ret
 
close_plugin_panel:
; close plugin and restore old directory
mov esi, [ebp + panel1_parents - panel1_data]
add esi, [ebp + panel1_parents_sz - panel1_data]
@@:
dec esi
cmp byte [esi-1], 0
jnz @b
push esi
lea edi, [ebp + panel1_dir - panel1_data]
@@:
lodsb
stosb
test al, al
jnz @b
pop esi
sub esi, 9
mov edx, [esi] ; hPlugin
mov ebx, [esi+4] ; hFile
sub esi, [ebp + panel1_parents - panel1_data]
mov [ebp + panel1_parents_sz - panel1_data], esi
xchg edx, [ebp + panel1_hPlugin - panel1_data]
xchg ebx, [ebp + panel1_hFile - panel1_data]
push edx ebx
lea ebx, [ebp + panel1_plugin_info - panel1_data]
and dword [ebx], 0
mov eax, [ebp + panel1_hPlugin - panel1_data]
test eax, eax
jz @f
push ebp
push ebx
push [ebp + panel1_hFile - panel1_data]
call [eax+PluginInfo.GetOpenPluginInfo]
pop ebp
@@:
pop ebx edx
 
close_handle_if_unused:
; edx=hPlugin, ebx=hFile
push ebp
xor ecx, ecx
@@:
mov eax, [screens]
mov ebp, [eax+ecx*8+4]
mov eax, [eax+ecx*8]
call [eax+screen_vtable.IsHandleUsed]
jz .used
inc ecx
cmp ecx, [num_screens]
jb @b
push ebx
call [edx+PluginInfo.ClosePlugin]
.used:
pop ebp
ret
 
panels_IsHandleUsed:
; edx=hPlugin, ebx=hFile
mov ebp, panel1_data
call .1
jz .ret
mov ebp, panel2_data
 
.1:
cmp edx, [ebp+panel1_hPlugin-panel1_data]
jnz @f
cmp ebx, [ebp+panel1_hFile-panel1_data]
jz .ret
@@:
mov esi, [ebp + panel1_parents_sz - panel1_data]
test esi, esi
jnz @f
inc esi
.ret:
ret
@@:
add esi, [ebp + panel1_parents - panel1_data]
@@:
dec esi
cmp byte [esi-1], 0
jnz @b
sub esi, 9
cmp edx, [esi] ; hPlugin
jnz .no
mov ebx, [esi+4] ; hFile
jz .ret
.no:
cmp esi, [ebp + panel1_parents - panel1_data]
jnz @b
inc esi
ret
 
panels_OnExit:
; close plugin panels
mov ebp, panel1_data
call close_plugin_panels
mov ebp, panel2_data
call close_plugin_panels
ret
 
panels_OnRedraw:
call draw_cmdbar
mov ebp, panel1_data
3116,43 → 2458,12
end if
sub ecx, 13
mov ebp, [active_panel]
lea esi, [ebp + panel1_dir - panel1_data]
push 3
pop edx
cmp [ebp + panel1_hPlugin - panel1_data], 0
jz .native
mov esi, [ebp + panel1_parents - panel1_data]
add esi, [ebp + panel1_parents_sz - panel1_data]
@@:
dec esi
cmp byte [esi-1], 0
jz @f
cmp byte [esi-1], '/'
jnz @b
@@:
push ecx edi
shr ecx, 1
@@:
lodsb
test al, al
jz @f
stosb
loop @b
@@:
sub edi, [esp]
sub [esp+4], edi
add [esp], edi
pop edi ecx
lea esi, [ebp + panel1_dir - panel1_data]
cmp byte [esi+1], 0
jnz @f
inc esi
@@:
jmp .main
.native:
lea esi, [ebp + panel1_dir - panel1_data]
@@:
lodsb
stosb
dec ecx
test al, al
jz @f
3166,7 → 2477,6
dec esi
dec edi
@@:
.main:
push esi
@@:
lodsb
3208,11 → 2518,11
jz .nodir
cmp esi, [esp]
jae @b
mov esi, [esp+4]
mov al, '/'
stosb
dec ecx
jz .nodir
mov esi, [esp+4]
@@:
cmp esi, [esp+8]
jb .nodir
3748,44 → 3058,6
and dword [edi], 0
ret
 
GetPanelTitle_default:
mov edi, [esp+8]
mov ecx, 1024
mov esi, [esp+12]
test esi, esi
jz .nohost
mov edx, esi
@@:
lodsb
test al, al
jz @f
cmp al, '/'
jnz @b
mov edx, esi
jmp @b
@@:
mov esi, edx
@@:
lodsb
stosb
test al, al
loopnz @b
dec edi
inc ecx
.nohost:
mov esi, [esp+16]
cmp word [esi], '/'
jz .nodir
@@:
lodsb
stosb
test al, al
loopnz @b
dec edi
.nodir:
mov byte [edi], 0
ret 10h
 
draw_panel:
mov eax, [ebp + panel1_left - panel1_data]
mov edx, [ebp + panel1_top - panel1_data]
3910,24 → 3182,6
jnz .columns_loop
; ‡ £®«®¢®ª ¯ ­¥«¨ (⥪ãé ï ¯ ¯ª )
lea esi, [ebp + panel1_dir - panel1_data]
mov eax, [ebp + panel1_hPlugin - panel1_data]
test eax, eax
jz .native
push ebp
push esi
mov esi, [ebp + panel1_parents - panel1_data]
add esi, [ebp + panel1_parents_sz - panel1_data]
@@:
dec esi
cmp byte [esi-1], 0
jnz @b
push esi
push execdata
push [ebp + panel1_hFile - panel1_data]
call [eax+PluginInfo.GetPanelTitle]
pop ebp
mov esi, execdata
.native:
mov edi, cur_header
mov ecx, [ebp + panel1_width - panel1_data]
sub ecx, 7
4784,30 → 4038,10
mov dword [ebp + panel1_selected_size - panel1_data], eax
mov dword [ebp + panel1_selected_size+4 - panel1_data], eax
.retry:
mov eax, [ebp + panel1_hPlugin - panel1_data]
test eax, eax
jz .native
mov ecx, [dirinfo.size]
test [ebp + panel1_plugin_flags - panel1_data], 1
jz @f
dec ecx ; reserve one entry for '..'
@@:
push ebp
push [dirinfo.dirdata]
push ecx
push 0
push [ebp + panel1_hFile - panel1_data]
call [eax + PluginInfo.ReadFolder]
pop ebp
mov ebx, [dirinfo.dirdata]
mov ebx, [ebx+4]
jmp .read
.native:
push 70
pop eax
mov ebx, dirinfo
int 40h
.read:
test eax, eax
jz .ok
cmp eax, 6
4827,14 → 4061,14
push 2
push eax
push 3
push -1
push -1
push dword aError
call SayErr
add esp, 5*4
test eax, eax
jz .retry
.dont_notify:
; If not on plugin panel, try to return to previous directory
cmp [ebp + panel1_hPlugin - panel1_data], 0
jnz @f
mov esi, prev_dir
cmp byte [esi], 0
jz @f
4845,7 → 4079,6
ret
@@:
mov [bSilentFolderMode], 1 ; enter silent mode
; Try to read parent folder
mov esi, [dirinfo.name]
xor edx, edx
.up1:
4858,27 → 4091,11
lea edi, [esi-1]
jmp .up1
.up1done:
cmp [ebp + panel1_hPlugin - panel1_data], 0
jz .4
cmp edx, 1
ja .up
; ç⥭¨¥ á ¯ ­¥«¨ ¯« £¨­  ®¡«®¬ «®áì ¯® ¯®«­®©
; ¯à¨ í⮬ ¬ë 㦥 ¢ ª®à­¥
; ¤¥« ¥¬ ¢¨¤, çâ® äã­ªæ¨ï ç⥭¨ï ¢¥à­ã«  0 í«¥¬¥­â®¢
; (¥á«¨ ­ã¦¥­ ¢å®¤ "..", ®­ ¡ã¤¥â ¤®¡ ¢«¥­  ¢â®¬ â¨ç¥áª¨)
xor ebx, ebx ; 0 items read
mov eax, [dirinfo.dirdata]
mov [eax+8], ebx ; 0 items total
jmp .ok
.4:
cmp edx, 2
jbe .noup
.up:
stosb
jmp read_folder
.noup:
; There is no parent folder, and we are not on plugin panel
; Try to read ramdisk
mov esi, [dirinfo.name]
mov edi, esi
lodsd
4925,10 → 4142,9
mov [prev_dir], 0
jmp read_folder
.readdone:
xor edx, edx
mov [ebp + panel1_start - panel1_data], edx
mov [ebp + panel1_index - panel1_data], edx
mov [ebp + panel1_start - panel1_data], edx
and [ebp + panel1_start - panel1_data], 0
and [ebp + panel1_index - panel1_data], 0
and [ebp + panel1_start - panel1_data], 0
mov edi, [ebp + panel1_files - panel1_data]
mov eax, [ebp + panel1_nfa - panel1_data]
lea eax, [edi + eax*4 + 32]
4935,6 → 4151,7
mov ecx, [eax-32+4]
test ecx, ecx
jz .loopdone
xor edx, edx
; ˆ£­®à¨à㥬 ᯥ樠«ì­ë¥ ¢å®¤ë, ᮮ⢥âáâ¢ãî騥 ¯ ¯ª¥ '.' ¨ ¬¥âª¥ ⮬ 
.ptrinit:
cmp word [eax+40], '.'
4975,58 → 4192,6
.dotdot:
; ¯®¤á¢¥âª 
; call insert_last_dot
call highlight_init
; call delete_last_dot
.loopcont:
add eax, 304
dec ecx
jnz .ptrinit
.loopdone:
push edi
sub edi, [ebp + panel1_files - panel1_data]
shr edi, 2
mov [ebp + panel1_numfiles - panel1_data], edi
pop edi
test edx, edx
jnz @f
test [ebp + panel1_plugin_flags - panel1_data], 1
jz @f
mov ecx, [ebp + panel1_numfiles - panel1_data]
inc [ebp + panel1_numfiles - panel1_data]
lea esi, [edi-4]
std
rep movsd
cld
mov eax, left_dotdot_entry
cmp ebp, panel1_data
jz .zq
add eax, right_dotdot_entry-left_dotdot_entry
.zq:
stosd
call highlight_init
@@:
; ‘®àâ¨à®¢ª 
sort_files:
movzx eax, [ebp + panel1_sortmode - panel1_data]
mov ebx, [compare_fns + eax*4]
.mode:
mov edx, [ebp + panel1_files - panel1_data]
mov ecx, [ebp + panel1_numfiles - panel1_data]
jecxz .skip
mov eax, [edx]
cmp word [eax+40], '..'
jnz .nodotdot
cmp byte [eax+42], 0
jnz .nodotdot
dec ecx
add edx, 4
.nodotdot:
call sort
.skip:
mov [bSilentFolderMode], 0 ; leave silent mode
ret
 
highlight_init:
pushad
mov ebp, eax
lea esi, [ebp+40]
5091,7 → 4256,35
mov ah, [panel_selected_cursor_color]
mov [ebp+7], ah
.doname:
; call delete_last_dot
popad
.loopcont:
add eax, 304
dec ecx
jnz .ptrinit
.loopdone:
sub edi, [ebp + panel1_files - panel1_data]
shr edi, 2
mov [ebp + panel1_numfiles - panel1_data], edi
.done:
; ‘®àâ¨à®¢ª 
sort_files:
movzx eax, [ebp + panel1_sortmode - panel1_data]
mov ebx, [compare_fns + eax*4]
mov edx, [ebp + panel1_files - panel1_data]
mov ecx, [ebp + panel1_numfiles - panel1_data]
jecxz .skip
mov eax, [edx]
cmp word [eax+40], '..'
jnz .nodotdot
cmp byte [eax+42], 0
jnz .nodotdot
dec ecx
add edx, 4
.nodotdot:
call sort
.skip:
mov [bSilentFolderMode], 0 ; leave silent mode
ret
 
compare_name:
5496,12 → 4689,7
stc
ret
 
ReadFolder_default:
mov eax, 2
ret 10h
 
if 0
; Following subroutines work, but are slow
match_mask:
; in: esi->name, edi->mask
; out: CF clear <=> match
6085,7 → 5273,7
pop esi
ret
 
header db 'Kolibri Far ',version,0
header db 'Kolibri Far 0.35',0
 
nomem_draw db 'No memory for redraw.',0
.size = $ - nomem_draw
6515,8 → 5703,6
.OnKey dd ?
.keybar dd ?
.getname dd ?
.OnExit dd ?
.IsHandleUsed dd ?
end virtual
 
panels_vtable:
6524,8 → 5710,6
dd panels_OnKey
dd keybar_panels
dd panels_getname
dd panels_OnExit
dd panels_IsHandleUsed
 
viewer_vtable:
dd viewer_OnRedraw
6532,8 → 5716,6
dd viewer_OnKey
dd keybar_viewer
dd viewer_getname
dd viewer_OnExit
dd viewer_IsHandleUsed
 
; additions to this table require changes in tools.inc::get_error_msg
errors1:
7111,7 → 6293,6
ContinueBtn:
dd aContinue
 
aCannotOpenFile_ptr dd aCannotOpenFile
if lang eq ru
aDeleteCaption db '“¤ «¥­¨¥',0
aConfirmDeleteText db '‚ë å®â¨â¥ 㤠«¨âì',0
7173,7 → 6354,6
aDate db 4,'„ â '
aTime db 5,'∴•'
aCannotLoadDLL db '¥ ¬®£ã § £à㧨âì DLL',0
aCannotLoadPlugin db '¥ ¬®£ã § £à㧨âì ¯« £¨­',0
aInvalidDLL db '” ©« ­¥ ­ ©¤¥­ ¨«¨ ¨¬¥¥â ­¥¢¥à­ë© ä®à¬ â',0
aMissingExport db '¥®¡å®¤¨¬ ï äã­ªæ¨ï ­¥ ­ ©¤¥­ ',0
aInitFailed db 'Žè¨¡ª  ¯à¨ ¨­¨æ¨ «¨§ æ¨¨',0
7181,8 → 6361,6
aTables db '’ ¡«¨æë',0
aSelect db '®¬¥â¨âì',0
aDeselect db '‘­ïâì',0
aCannotOpenFile db 'Žè¨¡ª  ¯à¨ ®âªàë⨨ ä ©« ',0
aCannotSetFolder db '¥ ¬®£ã § ©â¨ ¢ ¯ ¯ªã',0
else
aDeleteCaption db 'Delete',0
aConfirmDeleteText db 'Do you wish to delete',0
7248,7 → 6426,6
aDate db 4,'Date'
aTime db 4,'Time'
aCannotLoadDLL db 'Cannot load DLL',0
aCannotLoadPlugin db 'Cannot load plugin',0
aInvalidDLL db 'File is not found or invalid',0
aMissingExport db 'Required function is not present',0
aInitFailed db 'Initialization failed',0
7256,15 → 6433,11
aTables db 'Tables',0
aSelect db 'Select',0
aDeselect db 'Deselect',0
aCannotOpenFile db 'Cannot open the file',0
aCannotSetFolder db 'Cannot enter to folder',0
end if
 
aOk db 'OK',0
aNoMemory db 'No memory!'
nullstr db 0
aUntitled db 'untitled',0
aDotDot db '..',0,0
standard_dll_path:
libini_name db '/sys/dll/'
standard_dll_path_size = $ - standard_dll_path
7274,33 → 6447,13
aVersion db 'version',0
aIniGetInt db 'ini.get_int',0
aIniGetStr db 'ini.get_str',0
aIniSetInt db 'ini.set_int',0
aIniEnumKeys db 'ini.enum_keys',0
aPluginLoad db 'plugin_load',0
aPluginUnload db 'plugin_unload',0
aGetattr db 'getattr',0
aOpen db 'open',0
aRead db 'read',0
aSetpos db 'setpos',0
aClose db 'close',0
aOpenFilePlugin db 'OpenFilePlugin',0
aClosePlugin db 'ClosePlugin',0
aReadFolder db 'ReadFolder',0
aSetFolder db 'SetFolder',0
aGetOpenPluginInfo db 'GetOpenPluginInfo',0
aGetPanelTitle db 'GetPanelTitle',0
aGetFiles db 'GetFiles',0
 
aConfirmations db 'Confirmations',0
aConfirmDelete db 'Delete',0
aConfirmDeleteIncomplete db 'DeleteIncomplete',0
 
aPanels db 'Panels',0
aLeftViewMode db 'LeftViewMode',0
aRightViewMode db 'RightViewMode',0
 
aAssociations db 'Associations',0
aPlugins db 'Plugins',0
aMenu db 'Menu',0
aFolderShortcuts db 'FolderShortcuts',0
aShortcut db 'Shortcut'
7311,87 → 6464,9
ini.get_int dd aIniGetInt
ini.get_str dd aIniGetStr
ini.enum_keys dd aIniEnumKeys
ini.set_int dd aIniSetInt
dd 0
 
plugin_exported:
dd aPluginUnload
dd aGetattr
dd aOpen
dd aRead
dd aSetpos
dd aClose
dd aOpenFilePlugin
dd aClosePlugin
dd aReadFolder
dd aSetFolder
dd aGetOpenPluginInfo
dd aGetPanelTitle
dd aGetFiles
dd 0
plugin_exported_default:
dd plugin_unload_default
dd getattr_default
dd open_default
dd read
dd setpos_default
dd close
dd OpenFilePlugin_default
dd ClosePlugin_default
dd ReadFolder_default
dd SetFolder_default
dd GetOpenPluginInfo_default
dd GetPanelTitle_default
dd GetFiles_default
 
kfar_info:
dd .size
dd version_dword
dd open
dd read
dd -1 ; write: to be implemented
dd seek
dd -1 ; flush: to be implemented
dd filesize
dd close
dd xpgalloc
dd xpgrealloc
dd pgfree
dd getfreemem
dd libini_alloc
dd libini_realloc
dd libini_free
dd menu
dd menu_centered_in
dd DialogBox
dd SayErr
dd Message
dd cur_width
.size = $ - kfar_info
 
plugins dd 0
num_plugins dd 0
alloc_plugins dd 0
 
virtual at 0
PluginInfo:
.unload dd ?
.getattr dd ?
.open dd ?
.read dd ?
.setpos dd ?
.close dd ?
.OpenFilePlugin dd ?
.ClosePlugin dd ?
.ReadFolder dd ?
.SetFolder dd ?
.GetOpenPluginInfo dd ?
.GetPanelTitle dd ?
.GetFiles dd ?
.size = $
end virtual
 
virtual at 0
PanelMode:
; up to 16 columns on one panel
.NumColumns dd ?
7517,11 → 6592,6
panel1_nfa dd ?
panel1_numfiles dd ?
panel1_files dd ?
panel1_hPlugin dd ?
panel1_hFile dd ?
panel1_parents dd ?
panel1_parents_sz dd ?
panel1_parents_alloc dd ?
panel1_colmode dd ?
panel1_colwidths rd 16+1
panel1_total_num dd ?
7528,8 → 6598,6
panel1_total_size dq ?
panel1_selected_num dd ?
panel1_selected_size dq ?
panel1_plugin_info:
panel1_plugin_flags dd ?
panel1_dir rb 1024
 
panel2_data:
7546,11 → 6614,6
panel2_nfa dd ?
panel2_numfiles dd ?
panel2_files dd ?
panel2_hPlugin dd ?
panel2_hFile dd ?
panel2_parents dd ?
panel2_parents_sz dd ?
panel2_parents_alloc dd ?
panel2_colmode dd ?
panel2_colwidths rd 16+1
panel2_total_num dd ?
7557,8 → 6620,6
panel2_total_size dq ?
panel2_selected_num dd ?
panel2_selected_size dq ?
panel2_plugin_info:
panel2_plugin_flags dd ?
panel2_dir rb 1024
 
;console_data rb max_width*max_height*2
7609,10 → 6670,6
active_screen_vtable dd ?
active_screen_data dd ?
 
default_attr dd ?
left_dotdot_entry rb 40+3 ; 40 bytes for attributes + '..'
right_dotdot_entry rb 40+3
 
aConfirmDeleteTextBuf rb aConfirmDeleteTextMax + 1
CopySourceTextBuf rb 512
CopyDestEditBuf rb 12+512+1
7629,12 → 6686,6
copy_buffer_size = 65536
copy_buffer rb copy_buffer_size
 
filedata_buffer_size = 1024
filedata_buffer rb filedata_buffer_size
 
source_hModule dd ?
source_hPlugin dd ?
source_hFile dd ?
; data for directory delete
; If directory nested level is >1024, then its full name is too big,
; so we see the overflow when creating full name (we check for this!)
7650,7 → 6701,6
del_bSkipAll db ? ; for directory errors
label copy_bSkipAll byte at del_bSkipAll
copy_bSkipAll2 db ? ; for file read/write errors
copy_bSkipAll3 db ? ; for SetFolder errors
 
bEndSlash db ?
bDestIsFolder db ?
7658,7 → 6708,7
 
; stack
align 4
rb 32768
rb 512
stacktop:
 
mem:
/programs/fs/kfar/trunk/dialogs.inc
320,7 → 320,8
jz .redraw
dec eax
jz .key
jmp exit
or eax, -1
int 40h
.redraw:
push ebx ebp
call draw_window
771,10 → 772,6
jz .pgdn
cmp al, 0x49
jz .pgup
cmp al, 0x52
jz .ins
cmp al, 0x53
jz .del
mov edx, [ebx+36]
@@:
cmp dword [edx+4], 0
861,28 → 858,6
.enter:
mov eax, [ebx+36]
ret 16
.ins:
push 5
pop edx
jmp @f
.del:
push 4
pop edx
@@:
mov eax, [ebx+36]
cmp byte [eax+8], '/'
jnz @f
cmp word [eax+9], 'cd'
jnz @f
movzx ecx, byte [eax+11]
sub ecx, '0'
push 24
pop eax
mov ebx, edx
int 40h
@@:
xor eax, eax
ret 16
 
.line_prev:
cmp eax, [ebx+44]
1041,7 → 1016,6
; 8 = í«¥¬¥­â ¬®¦¥â ¨¬¥âì 䮪ãá ¢¢®¤ 
; 10h: ¤«ï ª­®¯ª¨ = ª­®¯ª  ¯® 㬮«ç ­¨î (Enter ­  ­¥-ª­®¯ª¥)
; ¤«ï ¯®«ï ¢¢®¤  = ¤ ­­ë¥ ¡ë«¨ ¬®¤¨ä¨æ¨à®¢ ­ë
; 20h: ¤«ï ¯®«ï ¢¢®¤  = ­¥ ®â®¡à ¦ âì ¢¢®¤¨¬ë¥ ¤ ­­ë¥ (¯®ª §ë¢ âì '*')
.size = $
end virtual
; struct DLGDATA
1335,8 → 1309,7
draw_text_esi:
test esi, esi
jz .ret
push -1
pop ecx
or ecx, -1
@@:
inc ecx
cmp byte [ecx+esi], 0
1399,14 → 1372,6
sub esi, ecx
.text_copy:
jecxz .ret
; check for password editboxes
cmp [ebx+dlgitemtemplate.type], 3
jnz @f
test [ebx+dlgitemtemplate.flags], 20h
jz @f
mov al, '*'
rep stosw
jmp .ret
@@:
lodsb
stosw
1476,30 → 1441,31
call DialogBox
ret
 
; int __stdcall SayErr(int num_strings, const char* strings[],
; int __stdcall SayErr(const char* title, int x, int y,
; int num_strings, const char* strings[],
; int num_buttons, const char* buttons[]);
; may be x=-1 and/or y=-1
SayErr:
pop eax
push aError
push eax
push 2
jmp @f
 
; int __stdcall Message(const char* title,
; 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+8] = x
; [esp+12] = y
; [esp+16] = num_strings
; [esp+20] = strings
; [esp+24] = num_buttons
; [esp+28] = buttons
pop eax
; [esp+4] = title
; [esp+8] = num_strings
; [esp+12] = strings
; [esp+16] = num_buttons
; [esp+20] = buttons
pushad
mov ecx, [esp+32+8]
add ecx, [esp+32+16]
mov ecx, [esp+4+16]
add ecx, [esp+4+24]
imul ecx, dlgitemtemplate.size
add ecx, dlgtemplate.size+12
call xpgalloc
1513,12 → 1479,13
mov edi, eax
mov eax, [esp+28]
stosd ; dlgtemplate.flags
or eax, -1
mov eax, [esp+32+8]
stosd ; dlgtemplate.x
mov eax, [esp+32+12]
stosd ; dlgtemplate.y
; calculate width
mov ecx, [esp+32+8]
mov esi, [esp+32+12]
mov ecx, [esp+32+16]
mov esi, [esp+32+20]
xor edx, edx
.calcwidth:
lodsd
1533,8 → 1500,8
mov edx, eax
@@:
loop .calcwidth
mov ecx, [esp+32+16]
mov esi, [esp+32+20]
mov ecx, [esp+32+24]
mov esi, [esp+32+28]
xor ebp, ebp
.calcwidth2:
lodsd
1560,7 → 1527,7
@@:
mov eax, edx
stosd ; dlgtemplate.width
mov eax, [esp+32+8]
mov eax, [esp+32+16]
inc eax
stosd ; dlgtemplate.height
mov eax, 3
1573,12 → 1540,12
stosd ; (ignored)
stosd ; DlgProc
stosd ; userdata
mov eax, [esp+32+8]
add eax, [esp+32+16]
mov eax, [esp+32+16]
add eax, [esp+32+24]
stosd ; num_items
; fill strings
xor ecx, ecx
mov esi, [esp+32+12]
mov esi, [esp+32+20]
@@:
mov eax, 1
stosd ; dlgitemtemplate.type
1594,11 → 1561,11
mov eax, 1
stosd ; dlgitemtemplate.flags
inc ecx
cmp ecx, [esp+32+8]
cmp ecx, [esp+32+16]
jb @b
; fill buttons
mov ecx, [esp+32+16]
mov esi, [esp+32+20]
mov ecx, [esp+32+24]
mov esi, [esp+32+28]
sub edx, ebp
jc .big
shr edx, 1
1629,7 → 1596,7
mov eax, [esi-4]
stosd ; dlgitemtemplate.data
mov eax, 9
cmp ecx, [esp+32+16]
cmp ecx, [esp+32+24]
jnz @f
or al, 4
@@:
1644,10 → 1611,10
xor edx, edx
mov ecx, dlgitemtemplate.size
div ecx
sub eax, [esp+32+8]
sub eax, [esp+32+16]
@@:
mov [esp+28], eax
mov ecx, ebx
call pgfree
popad
ret 20
ret 28
/programs/fs/kfar/trunk/filetool.inc
29,6 → 29,9
push 4
push eax
push 3
push -1
push -1
push aError
call SayErr
add esp, 3*4
cmp al, -1
63,8 → 66,6
mov esi, [esp+28]
mov ecx, esi
add esi, 40
cmp byte [edi-1], '/'
jz .l1
mov al, '/'
stosb
.l1:
238,6 → 239,9
push dword [eax+16]
push eax
push 3
push -1
push -1
push dword aError
call SayErr
add esp, 3*4
test eax, eax
249,9 → 253,6
; in: execdata = source name, CopyDestEditBuf+12 = destination name, edx = BDFE block for source
; out: CF and ZF not set <=> cancel job ("ja cancel_label")
; destroys eax,esi,edi
lea edi, [edx+40]
and [source_hFile], 0
copy_file_worker2:
push CopyDestEditBuf+12+513
cmp [bDestIsFolder], 0
jz .noaddtoname
260,16 → 261,12
lodsb
test al, al
jnz @b
pop eax
dec esi
mov byte [esi-1], '/'
pop edi
push esi
cmp byte [esi-1], '/'
jz @f
mov byte [esi], '/'
inc esi
mov edi, esi
lea esi, [edx+40]
@@:
xchg esi, edi
@@:
cmp edi, CopyDestEditBuf+12+513
jae .overflow
lodsb
280,14 → 277,12
.overflow:
.ret_zf:
pop esi
and byte [esi], 0 ; ZF=1
and byte [esi-1], 0 ; ZF=1
ret
.noaddtoname:
; ¥«ì§ï ᪮¯¨à®¢ âì ä ©« ¯®¢¥àå á ¬®£® ᥡï!
; Íåëüçÿ ñêîïèðîâàòü ôàéë ïîâåðõ ñàìîãî ñåáÿ!
mov esi, execdata
mov edi, CopyDestEditBuf+12
cmp [source_hModule], 0
jnz @f
push esi edi
call strcmpi
pop edi esi
299,12 → 294,15
push 1
push eax
push 2
push -1
push -1
push aError
call SayErr
pop eax
pop eax
jmp .ret_zf
@@:
; ‘®¡á⢥­­®, ª®¯¨à㥬
; Ñîáñòâåííî, êîïèðóåì
; esi->source name, edi->destination name
push ebx
mov [writeinfo.code], 2
318,40 → 316,8
mov [ebx+readinfo.size-readinfo], copy_buffer_size
mov [ebx+readinfo.data-readinfo], copy_buffer
mov [ebx+readinfo.name-readinfo], esi
mov eax, [source_hFile]
push eax
test eax, eax
jnz .copyloop
.source_reopen:
mov eax, [source_hModule]
test eax, eax
jz .copyloop
pushad
push O_READ+O_SEQUENTIAL_ONLY
push esi
push [source_hPlugin]
call [eax+PluginInfo.open]
mov [source_hFile], eax
popad
.copyloop:
mov ebx, readinfo
mov eax, [source_hModule]
test eax, eax
jz .native
mov ecx, [source_hFile]
jecxz .readerr
pushad
push [ebx+readinfo.size-readinfo]
push [ebx+readinfo.data-readinfo]
push ecx
call [eax+PluginInfo.read]
mov [esp+28], eax
popad
cmp eax, -1
jz .readerr
mov ebx, eax
jmp .copyreadok
.native:
push 70
pop eax
int 0x40
359,7 → 325,6
jz .copyreadok
cmp eax, 6
jz .copyreadok
.readerr:
cmp [copy_bSkipAll2], 0
jnz .copyfailed_del2
push esi
371,15 → 336,14
push 4
push eax
push 3
push -1
push -1
push dword aError
call SayErr
add esp, 3*4
test eax, eax
jnz .copyfailed_parseuser
cmp [source_hModule], 0
jz .copyloop
cmp [source_hFile], 0
jz .source_reopen
jmp .copyloop
jmp .copyfailed_parseuser
.copyreadok:
add dword [readinfo.first], ebx
adc dword [readinfo.first+4], 0
406,6 → 370,9
push 4
push eax
push 3
push -1
push -1
push dword aError
call SayErr
add esp, 3*4
test eax, eax
427,19 → 394,6
cmp ecx, copy_buffer_size
jz .copyloop
.copydone:
pop ecx
test ecx, ecx
jnz @f
mov eax, [source_hModule]
test eax, eax
jz @f
mov ecx, [source_hFile]
jecxz @f
push edx
push ecx
call [eax+PluginInfo.close]
pop edx
@@:
; now try to set attributes from source, ignore errors
mov edi, attrinfo.attr
mov esi, edx
446,29 → 400,6
push 8
pop ecx
rep movsd
; replace zero dates with default values
mov eax, [default_attr]
cmp dword [edi-32+8], 0
jnz @f
mov ecx, [eax+8]
mov [edi-32+8], ecx
mov ecx, [eax+12]
mov [edi-32+12], ecx
@@:
cmp dword [edi-32+16], 0
jnz @f
mov ecx, [eax+16]
mov [edi-32+16], ecx
mov ecx, [eax+20]
mov [edi-32+20], ecx
@@:
cmp dword [edi-32+24], 0
jnz @f
mov ecx, [eax+24]
mov [edi-32+24], ecx
mov ecx, [eax+28]
mov [edi-32+28], ecx
@@:
mov ebx, attrinfo
mov [ebx+attrinfo.name-attrinfo], CopyDestEditBuf+12
inc dword [ebx]
482,23 → 413,12
.ret:
pop ebx
pop esi
mov byte [esi], 0
mov byte [esi-1], 0
ret
.copydone2:
popf
jmp .ret
.copyfailed:
pop ecx
test ecx, ecx
jnz @f
mov eax, [source_hModule]
test eax, eax
jz @f
mov ecx, [source_hFile]
jecxz @f
push ecx
call [eax+PluginInfo.close]
@@:
cmp [bConfirmDeleteIncomplete], 0
jz .copyfailed_del
cmp [writeinfo.code], 2
509,8 → 429,10
push 2
push eax
push 1
push -1
push -1
push dword aCopyCaption
call Message
call SayErr
add esp, 4
test eax, eax
jnz .copydone2
546,8 → 468,6
@@:
mov esi, [esp+28]
add esi, 40
cmp byte [edi-1], '/'
jz .l1
mov al, '/'
stosb
.l1:
555,7 → 475,6
cmp edi, execdataend
jb @f
call panels_OnKey.bigfilename
stc
popad
ret
@@:
585,12 → 504,7
lodsb
test al, al
jnz @b
dec esi
cmp byte [esi-1], '/'
jz @f
mov byte [esi], '/'
inc esi
@@:
mov byte [esi-1], '/'
mov edi, esi
lea esi, [edx+40]
@@:
613,44 → 527,8
@@:
cmp al, 1
jz .copy_dir_entry_done
jmp .cancel2
jmp .cancel
.target_created:
mov edx, [source_hModule]
test edx, edx
jz .nosetdir
mov esi, execdata
push esi ; absolute_path
@@:
lodsb
test al, al
jnz @b
@@:
dec esi
cmp byte [esi-1], '/'
jnz @b
push esi ; relative_path
push [source_hPlugin] ; hPlugin
call [edx+PluginInfo.SetFolder]
test al, al
jnz .nosetdir
cmp [copy_bSkipAll3], 0
jz .skip2
push execdata
push aCannotSetFolder
mov eax, esp
push DeleteErrorBtn
push 4
push eax
push 2
call SayErr
pop ecx ecx
test al, al
jz .target_created
cmp al, 2
setz [copy_bSkipAll3]
ja .cancel2
jmp .skip2
.nosetdir:
xor ebp, ebp ; ebp will contain number of copied items
.return_from_recursion:
.read_retry:
659,23 → 537,9
mov [ebx+dirinfo.size-dirinfo], copy_dir_query_size
mov [ebx+dirinfo.dirdata-dirinfo], copy_dir_query_area
mov [ebx+dirinfo.name-dirinfo], execdata
mov eax, [source_hModule]
test eax, eax
jz .readfolder_native
push ebp
push [ebx+dirinfo.dirdata-dirinfo]
push [ebx+dirinfo.size-dirinfo]
push [ebx+dirinfo.first-dirinfo]
push [source_hPlugin]
call [eax+PluginInfo.ReadFolder]
pop ebp
mov ebx, dword [copy_dir_query_area+4]
jmp @f
.readfolder_native:
push 70
pop eax
int 0x40
@@:
test eax, eax
jz .readok
cmp eax, 6
682,7 → 546,7
jz .readok
; read error
cmp [copy_bSkipAll], 0
jnz .skip1
jz .skip1
push execdata
push aCannotReadFolder
call get_error_msg
692,6 → 556,9
push 4
push eax
push 3
push -1
push -1
push aError
call SayErr
add esp, 3*4
test al, al
730,12 → 597,7
lodsb
test al, al
jnz @b
dec esi
cmp byte [esi-1], '/'
jz @f
mov byte [esi], '/'
inc esi
@@:
mov byte [esi-1], '/'
mov edi, esi
lea esi, [edx+40]
@@:
750,12 → 612,7
lodsb
test al, al
jnz @b
dec esi
cmp byte [esi-1], '/'
jz @f
mov byte [esi], '/'
inc esi
@@:
mov byte [esi-1], '/'
mov edi, esi
lea esi, [edx+40]
@@:
768,7 → 625,7
test byte [edx], 10h
jnz .entry_is_folder
call copy_file_worker
ja .cancel3
ja .cancel
jmp .restore_name
.entry_is_folder:
; allocate new item in directory stack
785,6 → 642,7
.fullname2_big:
mov esi, CopyDestEditBuf+12+512
jmp .restore_name2
.skip1:
.restore_name:
mov esi, CopyDestEditBuf+12
@@:
807,23 → 665,8
.copy_dir_entry_continue:
add edx, 304
jmp .copy_dir_entry_loop
.skip1:
.copy_dir_entry_done:
; return to previous directory
mov esi, execdata
call delete_last_name_from_end
mov eax, [source_hModule]
test eax, eax
jz @f
push execdata
push aDotDot
push [source_hPlugin]
call [eax+PluginInfo.SetFolder]
jmp @f
.skip2:
mov esi, execdata
call delete_last_name_from_end
@@:
; pop item from directory stack
mov ecx, [copy_dir_stack_ptr]
cmp ecx, copy_dir_stack
832,34 → 675,16
mov [copy_dir_stack_ptr], ecx
mov ebp, [ecx]
; restore prev directory name
mov esi, execdata
call delete_last_name_from_end
mov esi, CopyDestEditBuf+12
call delete_last_name_from_end
jmp .return_from_recursion
.done:
.cancel:
mov [dirinfo.first], 0 ; do not destroys flags
popad
ret
.cancel2:
sub [copy_dir_stack_ptr], 4
.cancel3:
mov esi, execdata
call delete_last_name_from_end
.cancel:
mov eax, [source_hModule]
test eax, eax
jz .cancel.ret
cmp [copy_dir_stack_ptr], copy_dir_stack
jb .cancel.ret
push execdata
push aDotDot
push [source_hPlugin]
call [eax+PluginInfo.SetFolder]
jmp .cancel2
.cancel.ret:
xor eax, eax
inc eax
popad
ret
 
delete_last_name_from_end:
lodsb
874,403 → 699,5
cmp al, '/'
jnz @b
cld
inc esi
cmp esi, execdata
jz @f
cmp esi, CopyDestEditBuf+12
jz @f
dec esi
@@:
mov byte [esi+1], 0
ret
 
copy_AddDir:
push 1
pop eax ; for "return true"
pushad
mov esi, CopyDestEditBuf+12
@@:
lodsb
test al, al
jnz @b
cmp byte [esi-2], '/'
jnz @f
dec esi
@@:
push dword [esi-1]
push esi
mov byte [esi-1], '/'
mov edi, esi
mov esi, [esp+28h+4]
.0:
lodsb
stosb
cmp edi, CopyDestEditBuf+12+512
jae .done
test al, al
jnz .0
push RetryOrCancelBtn
push 2
call makedir
jz .done
and dword [esp+8+1Ch], 0
.done:
pop esi
pop dword [esi-1]
popad
ret 8
 
copy_AddFile:
pushad
mov eax, [esp+20h+12]
mov [source_hFile], eax
mov edx, [esp+20h+8]
mov edi, [esp+20h+4]
call copy_file_worker2
popad
setna al
ret 12
 
virtual at 0
_FILE:
.pos dq ?
.bufpos dq ?
.bufsize dd ?
.mode dd ?
.hPlugin dd ?
.hFile dd ?
.fileinfo:
.fimode dd ?
.fioffset dq ?
.fisize dd ?
.fibuf dd ?
.finame rb 1024
.attr rb 40
align 512
.buf rb 2048
.size = $
end virtual
 
O_READ = 1 ; allows read from file
O_WRITE = 2 ; allows write to file
O_CREATE = 4 ; if file does not exist and this flag is set, create file;
; if file does not exist and this flag is not set, fail
O_TRUNCATE = 8 ; truncate file if it exists
O_SEQUENTIAL_ONLY = 10h ; there will be no 'seek'/'setpos' calls
 
; HANDLE __stdcall open(const char* name, int mode);
; Opens physical file
open:
pushad
mov ecx, _FILE.size
call xpgalloc
test eax, eax
jz .ret0z
mov [esp+28], eax
mov ecx, eax
mov esi, [esp+36]
lea edi, [eax+_FILE.finame]
lea edx, [eax+_FILE.finame+1024]
@@:
lodsb
stosb
test al, al
jz @f
cmp edi, edx
jb @b
.ret0:
call pgfree
.ret0z:
popad
xor eax, eax
ret 8
@@:
mov eax, [esp+40]
mov [ecx+_FILE.mode], eax
.getattr:
lea edi, [ecx+_FILE.fileinfo]
mov ebx, edi
push 5
pop eax
stosd
xor eax, eax
stosd
stosd
stosd
lea eax, [ecx+_FILE.attr]
stosd
push 70
pop eax
int 0x40
test eax, eax
jz .found
cmp eax, 5
jnz .ret0
; file does not exist
test [ecx+_FILE.mode], O_CREATE
jz .ret0z
.truncate:
lea ebx, [ecx+_FILE.fileinfo]
mov byte [ebx], 2
push 70
pop eax
int 0x40
test eax, eax
jz .getattr
jmp .ret0
.found:
test [ecx+_FILE.mode], O_TRUNCATE
jz @f
cmp dword [ecx+_FILE.attr+36], eax
jnz .truncate
cmp dword [ecx+_FILE.attr+32], eax
jnz .truncate
@@:
mov dword [ecx+_FILE.pos], eax
mov dword [ecx+_FILE.pos+4], eax
mov dword [ecx+_FILE.bufpos], eax
mov dword [ecx+_FILE.bufpos+4], eax
mov [ecx+_FILE.bufsize], eax
mov [ecx+_FILE.hPlugin], eax
mov [ecx+_FILE.hFile], eax
mov dword [ecx+_FILE.fioffset], eax
mov dword [ecx+_FILE.fioffset+4], eax
mov [esp+28], ecx
popad
ret 8
 
; unsigned __stdcall read(HANDLE hFile, void* buf, unsigned size);
read:
xor eax, eax
pushad
mov ecx, [esp+36]
test [ecx+_FILE.mode], O_READ
jnz @f
.ret:
popad
ret 12
@@:
cmp dword [esp+44], eax
jz .ret
mov [ecx+_FILE.fimode], eax
mov ebx, [ecx+_FILE.bufsize]
mov eax, dword [ecx+_FILE.pos]
and eax, 2047
sub ebx, eax
jbe .nobuf0
cmp ebx, [esp+44]
jbe @f
mov ebx, [esp+44]
@@:
push ecx
lea esi, [ecx+eax+_FILE.buf]
mov ecx, ebx
mov edi, [esp+44]
rep movsb
pop ecx
mov [esp+40], edi
add [esp+28], ebx
add dword [ecx+_FILE.pos], ebx
adc dword [ecx+_FILE.pos+4], 0
sub [esp+44], ebx
jz .ret
.nobuf0:
test dword [ecx+_FILE.pos], 2047
jz .aligned
cmp dword [ecx+_FILE.bufsize], 0
jnz .ret
lea ebx, [ecx+_FILE.fileinfo]
mov dword [ebx+12], 2048
lea eax, [ecx+_FILE.buf]
mov dword [ebx+16], eax
mov eax, dword [ecx+_FILE.fioffset]
mov dword [ecx+_FILE.bufpos], eax
mov eax, dword [ecx+_FILE.fioffset+4]
mov dword [ecx+_FILE.bufpos+4], eax
call .doread
test eax, eax
jnz .ret
mov [ecx+_FILE.bufsize], ebx
mov eax, dword [ecx+_FILE.pos]
and eax, 2047
sub ebx, eax
jbe .ret
cmp ebx, [esp+44]
jbe @f
mov ebx, [esp+44]
@@:
push ecx
lea esi, [ecx+eax+_FILE.buf]
mov ecx, ebx
mov edi, [esp+44]
rep movsb
pop ecx
add dword [ecx+_FILE.pos], ebx
adc dword [ecx+_FILE.pos+4], 0
mov [esp+40], edi
add [esp+28], ebx
sub [esp+44], ebx
jz .ret
test dword [ecx+_FILE.pos], 2047
jnz .ret
.aligned:
lea ebx, [ecx+_FILE.fileinfo]
mov eax, [esp+44]
and eax, not 2047
jz .finish
and [ecx+_FILE.bufsize], 0
mov [ebx+12], eax
mov eax, [esp+40]
mov [ebx+16], eax
call .doread
test eax, eax
jnz .ret
add dword [ecx+_FILE.pos], ebx
adc dword [ecx+_FILE.pos+4], 0
add [esp+28], ebx
add [esp+40], ebx
sub [esp+44], ebx
jz .ret
cmp ebx, [ecx+_FILE.fisize]
jb .ret
.finish:
lea ebx, [ecx+_FILE.fileinfo]
mov dword [ebx+12], 2048
lea eax, [ecx+_FILE.buf]
mov [ebx+16], eax
and [ecx+_FILE.bufsize], 0
mov eax, dword [ecx+_FILE.fioffset]
mov dword [ecx+_FILE.bufpos], eax
mov eax, dword [ecx+_FILE.fioffset+4]
mov dword [ecx+_FILE.bufpos+4], eax
call .doread
test eax, eax
jnz .ret
mov [ecx+_FILE.bufsize], ebx
cmp ebx, [esp+44]
jb @f
mov ebx, [esp+44]
@@:
add [esp+28], ebx
add dword [ecx+_FILE.pos], ebx
adc dword [ecx+_FILE.pos+4], 0
lea esi, [ecx+_FILE.buf]
mov edi, [esp+40]
mov ecx, ebx
rep movsb
popad
ret 12
.doread:
mov eax, [ecx+_FILE.hPlugin]
test eax, eax
jz .native
push ecx
push [ecx+_FILE.fisize]
push [ecx+_FILE.fibuf]
push [ecx+_FILE.hFile]
call [eax+PluginInfo.read]
pop ecx
cmp eax, -1
jz @f
mov ebx, eax
xor eax, eax
jmp .addpos
@@:
ret
.native:
push 70
pop eax
int 0x40
test eax, eax
jz .addpos
cmp eax, 6
jnz @b
xor eax, eax
.addpos:
add dword [ecx+_FILE.fioffset], ebx
adc dword [ecx+_FILE.fioffset+4], 0
ret
 
; void __stdcall seek(HANDLE hFile, int method, __int64 newpos);
seek:
pushad
mov ecx, [esp+36]
mov eax, [esp+44]
mov edx, [esp+48]
cmp dword [esp+40], 1
jb .set
ja .end
add eax, dword [ecx+_FILE.pos]
adc edx, dword [ecx+_FILE.pos+4]
jmp .set
.end:
add eax, dword [ecx+_FILE.attr+32]
adc edx, dword [ecx+_FILE.attr+36]
.set:
mov dword [ecx+_FILE.pos], eax
mov dword [ecx+_FILE.pos+4], edx
and eax, not 2047
cmp eax, dword [ecx+_FILE.bufpos]
jnz @f
cmp edx, dword [ecx+_FILE.bufpos+4]
jz .bufposok
@@:
and [ecx+_FILE.bufsize], 0
mov dword [ecx+_FILE.bufpos], eax
mov dword [ecx+_FILE.bufpos+4], edx
.bufposok:
cmp [ecx+_FILE.bufsize], 0
jnz .ret
cmp eax, dword [ecx+_FILE.fioffset]
jnz @f
cmp edx, dword [ecx+_FILE.fioffset+4]
jz .ret
@@:
mov dword [ecx+_FILE.fioffset], eax
mov dword [ecx+_FILE.fioffset+4], edx
mov eax, [ecx+_FILE.hPlugin]
test eax, eax
jz @f
push dword [ecx+_FILE.fioffset+4]
push dword [ecx+_FILE.fioffset]
push [ecx+_FILE.hFile]
call [eax+PluginInfo.setpos]
@@:
.ret:
popad
ret 16
 
setpos_default:
push dword [esp+12]
push dword [esp+12]
push 0
push dword [esp+16]
call seek
ret 12
 
; __int64 __stdcall filesize(HANDLE hFile);
filesize:
mov eax, [esp+4]
mov edx, dword [eax+_FILE.attr+36]
mov eax, dword [eax+_FILE.attr+32]
ret 4
 
; void __stdcall close(HANDLE hFile);
close:
pushad
mov ecx, [esp+24h]
mov eax, [ecx+_FILE.hPlugin]
test eax, eax
jz @f
push ecx
push [ecx+_FILE.hFile]
call [eax+PluginInfo.close]
pop ecx
@@:
call pgfree
popad
ret 4
 
getattr_default:
mov eax, 2
ret 12
/programs/fs/kfar/trunk/tools.inc
1,12 → 1,3
CHECK_FOR_LEAKS = 0
if CHECK_FOR_LEAKS
uglobal
allocatedregions rd 1024
endg
iglobal
numallocatedregions dd 0
endg
end if
pgalloc:
; in: ecx=size
; out: eax=pointer or NULL
16,20 → 7,6
push 12
pop ebx
int 0x40
if CHECK_FOR_LEAKS
test eax, eax
jz .no
.b:
mov ebx, [numallocatedregions]
cmp ebx, 1024
jb @f
int3
jmp $
@@:
mov [allocatedregions+ebx*4], eax
inc [numallocatedregions]
.no:
end if
pop ebx
ret
 
36,30 → 13,6
pgfree:
; in: ecx=pointer
; destroys eax
if CHECK_FOR_LEAKS
jecxz .no
mov eax, [numallocatedregions]
@@:
dec eax
js .a
cmp [allocatedregions+eax*4], ecx
jnz @b
jmp @f
.a:
int3
jmp $
@@:
dec [numallocatedregions]
@@:
cmp eax, [numallocatedregions]
jae @f
push [allocatedregions+eax*4+4]
pop [allocatedregions+eax*4]
inc eax
jmp @b
@@:
.no:
end if
push ebx
push 68
pop eax
78,29 → 31,6
push 20
pop ebx
int 0x40
if CHECK_FOR_LEAKS
test edx, edx
jz pgalloc.b
test eax, eax
jz .no
cmp eax, edx
jz .no
xor ebx, ebx
@@:
cmp ebx, [numallocatedregions]
jae .a
cmp [allocatedregions+ebx*4], edx
jz @f
inc ebx
jmp @b
@@:
mov [allocatedregions+ebx*4], eax
jmp .no
.a:
int3
jmp $
.no:
end if
pop ebx
ret
 
122,17 → 52,6
call pgrealloc
jmp xpgalloc.common
 
getfreemem:
; out: eax=size of free RAM in Kb
push ebx
push 18
pop eax
push 16
pop ebx
int 0x40
pop ebx
ret
 
get_error_msg:
; in: eax=error code
; out: eax=pointer to message (in static buffer)
166,7 → 85,6
test al, al
jnz @b
pop eax
dec edi
push edx ecx
test eax, eax
jns @f
244,8 → 162,7
pop eax
pop esi
jz .do
.big:
push esi
push eax
mov edi, aFileNameTooBig
.sayerr:
push dword aCannotLoadDLL
256,6 → 173,9
push 1
push eax
push 3
push -1
push -1
push dword aError
call SayErr
add esp, 16
xor eax, eax
272,15 → 192,9
mov edi, aInvalidDLL
test eax, eax
jz .sayerr
mov edx, eax
cmp ebp, -1
jnz @f
pop eax
xor eax, eax
ret
@@:
; initialize import
mov edi, aMissingExport
mov edx, eax
.import_loop:
lodsd
test eax, eax
/programs/fs/kfar/trunk/viewer.inc
6,9 → 6,6
.buf_pos dd ?
.buf_size dd ?
.col dq ?
.hPlugin dd ?
.hFile dd ?
.hWorkFile dd ?
.encoding db ?
.bEofReached db ?
.flags db ? ; & 1: hex mode
16,7 → 13,6
; & 4: big-endian unicode
rb 1
.filename rb 1024
.hostname rb 1024
.buf rb 16384
.size = $
end virtual
38,30 → 34,6
jnz @f
ret
@@:
mov eax, dword [esi+panel1_hPlugin-panel1_dir]
mov [ebp+viewer_data.hPlugin], eax
test eax, eax
jz .nocopyhostname
lea edi, [ebp+viewer_data.hostname]
push esi
mov eax, dword [esi+panel1_parents-panel1_dir]
mov esi, dword [esi+panel1_parents_sz-panel1_dir]
add esi, eax
@@:
dec esi
cmp byte [esi-1], 0
jz @f
cmp byte [esi-1], '/'
jnz @b
@@:
lodsb
stosb
test al, al
jnz @b
pop esi
.nocopyhostname:
mov eax, dword [esi+panel1_hFile-panel1_dir]
mov [ebp+viewer_data.hFile], eax
mov [ebp+viewer_data.encoding], encodings.cp866
mov [ebp+viewer_data.flags], 0
and dword [ebp+viewer_data.col], 0
76,8 → 48,6
jmp @b
@@:
lea esi, [ecx+40]
cmp byte [edi-1], '/'
jz @f
mov al, '/'
stosb
@@:
90,21 → 60,9
mov ebx, attrinfo
mov [ebx+21], eax
.attr_retry:
mov edx, [ebp+viewer_data.hPlugin]
test edx, edx
jz .attr_native
push ebp
push dword [ebx+16]
push eax
push [ebp+viewer_data.hFile]
call [edx+PluginInfo.getattr]
pop ebp
jmp .attr_common
.attr_native:
push 70
pop eax
int 40h
.attr_common:
test eax, eax
jz @f
lea ebx, [ebp+viewer_data.filename]
117,12 → 75,14
push 2
push eax
push 3
push -1
push -1
push aError
call SayErr
add esp, 3*4
mov ebx, attrinfo
test eax, eax
jz .attr_retry
pop eax
jmp delete_active_screen
@@:
mov eax, dword [attrinfo.attr+32]
142,40 → 102,7
mov [readinfo.data], eax
mov [ebp+viewer_data.buf_pos], eax
pop dword [readinfo.name]
mov eax, [ebp+viewer_data.hPlugin]
test eax, eax
jz .retry
push ebx ebp
push O_READ
push dword [readinfo.name]
push [ebp+viewer_data.hFile]
call [eax+PluginInfo.open]
pop ebp ebx
mov [ebp+viewer_data.hWorkFile], eax
test eax, eax
jnz .retry
push ContinueBtn
push 1
push aCannotOpenFile_ptr
push 1
call SayErr
jmp delete_active_screen
.retry:
mov eax, [ebp+viewer_data.hPlugin]
test eax, eax
jz .read_native
push ebp
push 16384
push [ebx+readinfo.data-readinfo]
push [ebp+viewer_data.hWorkFile]
call [eax+PluginInfo.read]
pop ebp
cmp eax, -1
jz .readok ; let's hope that plugin says error itself
mov [ebp+viewer_data.buf_size], eax
mov ebx, eax
jmp .readok
.read_native:
push 70
pop eax
int 40h
184,7 → 111,6
jz .readok
cmp eax, 6
jz .readok
.readerr:
lea ebx, [ebp+viewer_data.filename]
push ebx
push aCannotReadFile
195,6 → 121,9
push 2
push eax
push 3
push -1
push -1
push aError
call SayErr
add esp, 3*4
mov ebx, readinfo
265,21 → 194,6
mov [readinfo.name], eax
.readretry:
mov ebx, readinfo
mov eax, [ebp+viewer_data.hPlugin]
test eax, eax
jz .native
push ecx ebp
push 8192
push [ebx+readinfo.data-readinfo]
push [ebp+viewer_data.hWorkFile]
call [eax+PluginInfo.read]
pop ebp ecx
mov ebx, eax
cmp eax, -1
jnz .readok
xor ebx, ebx
jmp .readok
.native:
push 70
pop eax
int 40h
287,7 → 201,6
jz .readok
cmp eax, 6
jz .readok
.readerr:
call ask_retry_ignore
jz .readretry
.readok:
1063,7 → 976,16
mov [ebx+16], eax
lea eax, [ebp+viewer_data.filename]
mov [ebx+21], eax
call .q
push 70
pop eax
int 40h
test eax, eax
jz .readok
cmp eax, 6
jz .readok
call ask_retry_ignore
jz .doread
.readok:
cmp ebx, [readinfo.size]
jnz @f
add ebx, [ebp+viewer_data.buf_size]
1105,47 → 1027,22
mov [ebx+12], eax
lea eax, [ebp+viewer_data.filename]
mov [ebx+21], eax
call .q
sub ebx, [readinfo.size]
add ebx, 16384
jmp .ret
 
.q:
mov ebx, readinfo
mov eax, [ebp+viewer_data.hPlugin]
test eax, eax
jz .native
push ebp
push dword [ebx+12]
push dword [ebx+16]
push [ebp+viewer_data.hWorkFile]
push eax
push dword [ebx+8]
push dword [ebx+4]
push [ebp+viewer_data.hWorkFile]
call [eax+PluginInfo.setpos]
pop eax
call [eax+PluginInfo.read]
pop ebp
mov ebx, eax
cmp eax, -1
jnz @f
xor ebx, ebx
@@:
ret
.native:
push 70
pop eax
int 40h
test eax, eax
jz .readok
jz @f
cmp eax, 6
jz .readok
.readerr:
jz @f
call ask_retry_ignore
jz .q
.readok:
ret
jnz @f
mov ebx, readinfo
jmp @b
@@:
sub ebx, [readinfo.size]
add ebx, 16384
jmp .ret
 
ask_retry_ignore:
push esi
1159,6 → 1056,9
push 2
push eax
push 3
push -1
push -1
push aError
call SayErr
add esp, 3*4
pop esi
1368,33 → 1268,12
call viewer_draw_text
ret
 
viewer_OnExit:
mov edx, [ebp+viewer_data.hPlugin]
test edx, edx
jz @f
and [ebp+viewer_data.hPlugin], 0
push edx ebp
push [ebp+viewer_data.hWorkFile]
call [edx+PluginInfo.close]
pop ebp edx
mov ebx, [ebp+viewer_data.hFile]
call close_handle_if_unused
@@:
ret
 
viewer_IsHandleUsed:
cmp edx, [ebp+viewer_data.hPlugin]
jnz @f
cmp ebx, [ebp+viewer_data.hFile]
@@:
ret
 
viewer_OnKey:
mov esi, viewer_ctrlkeys
jmp process_ctrl_keys
.exit:
call viewer_OnExit
jmp delete_active_screen
call delete_active_screen
ret
.down:
cmp [ebp+viewer_data.bEofReached], 0
jnz .ret
1580,26 → 1459,7
stosb
end if
sub ecx, 13
cmp [ebp+viewer_data.hPlugin], 0
jz .native
lea esi, [ebp+viewer_data.hostname]
push ecx edi
shr ecx, 1
@@:
lodsb
test al, al
jz @f
stosb
loop @b
@@:
sub edi, [esp]
sub [esp+4], edi
add [esp], edi
pop edi ecx
lea esi, [ebp+viewer_data.filename]
jmp .main
.native:
lea esi, [ebp+viewer_data.filename]
push 3
pop edx
@@:
1606,13 → 1466,10
lodsb
stosb
dec ecx
test al, al
jz .ret
cmp al, '/'
jnz @b
dec edx
jnz @b
.main:
push esi
@@:
lodsb
1636,5 → 1493,4
stosb
test al, al
jnz @b
.ret:
ret