UTF-8 file path input, unicode names for apps and libs

git-svn-id: svn://kolibrios.org@6502 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
pathoswithin 2016-08-25 19:30:08 +00:00
parent 5f44c836b1
commit 31fad3ee4a
9 changed files with 331 additions and 390 deletions

View File

@ -1,7 +1,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License. ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -900,27 +900,25 @@ coff_get_align:
align 4
proc load_library stdcall, file_name:dword
locals
fullname rb 260
fileinfo rb 40
coff dd ?
img_base dd ?
endl
locals
fullname dd ?
fileinfo rb 40
coff dd ?
img_base dd ?
endl
; resolve file name
stdcall kernel_alloc, maxPathLength
mov [fullname], eax
mov ebx, [file_name]
lea edi, [fullname+1]
mov byte [edi-1], '/'
stdcall get_full_file_name, edi, 259
test al, al
stdcall get_full_file_name, eax, maxPathLength
test eax, eax
jz .fail
; scan for required DLL in list of already loaded for this process,
; ignore timestamp
cli
mov esi, [current_process]
lea edi, [fullname]
mov edi, [fullname]
mov ebx, [esi+PROC.dlls_list_ptr]
test ebx, ebx
jz .not_in_process
@ -942,12 +940,16 @@ proc load_library stdcall, file_name:dword
sub eax, [ecx+DLLDESCR.defaultbase]
add eax, [esi+HDLL.base]
sti
push eax
stdcall kernel_free, [fullname]
pop eax
ret
.next_in_process:
mov esi, [esi+HDLL.fd]
jmp .scan_in_process
.not_in_process:
.not_in_process:
; scan in full list, compare timestamp
sti
lea eax, [fileinfo]
@ -1182,11 +1184,11 @@ proc load_library stdcall, file_name:dword
mov [esi+DLLDESCR.bk], eax
mov [eax+DLLDESCR.fd], esi
.dll_already_loaded:
stdcall kernel_free, [fullname]
inc [esi+DLLDESCR.refcount]
push esi
call init_heap
pop esi
mov edi, [esi+DLLDESCR.size]
stdcall user_alloc_at, [esi+DLLDESCR.defaultbase], edi
test eax, eax
@ -1255,6 +1257,7 @@ proc load_library stdcall, file_name:dword
add eax, [img_base]
sti
ret
.fail_and_free_data:
stdcall kernel_free, [esi+DLLDESCR.data]
.fail_and_free_dll:
@ -1263,8 +1266,10 @@ proc load_library stdcall, file_name:dword
.fail_and_free_coff:
stdcall kernel_free, [coff]
.fail:
stdcall kernel_free, [fullname]
xor eax, eax
ret
.fail_and_free_user:
stdcall user_free, [img_base]
.fail_and_dereference:

View File

@ -5,17 +5,22 @@
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;============================================================================
;
; External kernel dependencies (libraries) loading
;
;============================================================================
; External kernel dependencies (libraries) loading.
; The code currently does not work, requires correcting dll.inc.
$Revision$
if 0
; The code currently does not work. Kill "if 0/end if" only after correcting
; to current kernel (dll.inc).
iglobal
tmp_file_name_size dd 1
endg
uglobal
tmp_file_name_table dd ?
s_libname rb 64
def_val_1 db ?
endg
macro library [name,fname]
{
forward
@ -327,7 +332,145 @@ proc mem.Free mptr ;//////////////////////////////////////////////////////////
ret
endp
uglobal
s_libname db 64 dup (0)
endg
proc load_file_parse_table
stdcall kernel_alloc, 0x1000
mov [tmp_file_name_table], eax
mov edi, eax
mov esi, sysdir_name
mov ecx, 128/4
rep movsd
invoke ini.enum_keys, conf_fname, conf_path_sect, get_every_key
mov eax, [tmp_file_name_table]
mov [full_file_name_table], eax
mov eax, [tmp_file_name_size]
mov [full_file_name_table.size], eax
ret
endp
proc get_every_key stdcall, f_name, sec_name, key_name
mov esi, [key_name]
mov ecx, esi
cmp byte [esi], '/'
jnz @f
inc esi
@@:
mov edi, [tmp_file_name_size]
shl edi, 7
cmp edi, 0x1000
jae .stop_parse
add edi, [tmp_file_name_table]
lea ebx, [edi+64]
@@:
cmp edi, ebx
jae .skip_this_key
lodsb
test al, al
jz @f
or al, 20h
stosb
jmp @b
.stop_parse:
xor eax, eax
ret
@@:
stosb
invoke ini.get_str, [f_name], [sec_name], ecx, ebx, 64, def_val_1
cmp byte [ebx], '/'
jnz @f
lea esi, [ebx+1]
mov edi, ebx
mov ecx, 63
rep movsb
@@:
push ebp
mov ebp, [tmp_file_name_table]
mov ecx, [tmp_file_name_size]
jecxz .noreplace
mov eax, ecx
dec eax
shl eax, 7
add ebp, eax
.replace_loop:
mov edi, ebx
mov esi, ebp
@@:
lodsb
test al, al
jz .doreplace
mov dl, [edi]
inc edi
test dl, dl
jz .replace_loop_cont
or dl, 20h
cmp al, dl
jz @b
jmp .replace_loop_cont
.doreplace:
cmp byte [edi], 0
jz @f
cmp byte [edi], '/'
jnz .replace_loop_cont
@@:
lea esi, [ebp+64]
call .replace
jc .skip_this_key2
.replace_loop_cont:
sub ebp, 128
loop .replace_loop
.noreplace:
pop ebp
inc [tmp_file_name_size]
.skip_this_key:
xor eax, eax
inc eax
ret
.skip_this_key2:
pop ebp
jmp .skip_this_key
endp
proc get_every_key.replace
; in: ebx->destination, esi->first part of name, edi->second part of name
; maximum length is 64 bytes
; out: CF=1 <=> overflow
sub esp, 64 ; allocate temporary buffer in stack
push esi
lea esi, [esp+4] ; esi->tmp buffer
xchg esi, edi ; edi->tmp buffer, esi->source
@@: ; save second part of name to temporary buffer
lodsb
stosb
test al, al
jnz @b
pop esi
mov edi, ebx
@@: ; copy first part of name to destination
lodsb
test al, al
jz @f
stosb
jmp @b
@@: ; restore second part of name from temporary buffer to destination
lea edx, [ebx+64] ; limit of destination
mov esi, esp
@@:
cmp edi, edx
jae .overflow
lodsb
stosb
test al, al
jnz @b
add esp, 64 ; CF is cleared
ret
.overflow: ; name is too long
add esp, 64
stc
ret
endp
end if

View File

@ -1,7 +1,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License. ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -41,6 +41,7 @@ struct APP_HDR
img_size rd 1
filename_size rd 1
cmdline_size rd 1
path_string rd 1
ends
macro _clear_ op
@ -66,50 +67,45 @@ fs_execute_from_sysdir:
xor ebx, ebx
fs_execute_from_sysdir_param:
xor edx, edx
align 4
proc fs_execute
; ebx - cmdline
; edx - flags
; ebp - full filename
locals
cmdline rd 1
flags rd 1
slot rd 1
slot_base rd 1
; app header data
hdr_cmdline rd 1
hdr_path rd 1
hdr_eip rd 1
hdr_esp rd 1
hdr_edata rd 1
hdr_emem rd 1
file_base rd 1
file_size rd 1
filename_size rd 1
cmdline_size rd 1
path_string rd 1
endl
locals
filename rd 1
cmdline rd 1
flags rd 1
slot rd 1
slot_base rd 1
;app header data
hdr_cmdline rd 1 ;0x00
hdr_path rd 1 ;0x04
hdr_eip rd 1 ;0x08
hdr_esp rd 1 ;0x0C
hdr_edata rd 1 ;0x10
hdr_emem rd 1 ;0x14
file_base rd 1 ;0x18
file_size rd 1 ;0x1c
filename_size rd 1 ;0x20
cmdline_size rd 1 ;0x24
endl
mov eax, [ebp]
mov [flags], edx
mov [cmdline], ebx
mov [filename], eax
stdcall kernel_alloc, maxPathLength
mov [path_string], eax
mov ebx, [ebp]
stdcall get_full_file_name, eax, maxPathLength
test eax, eax
jz .err_file
mov eax, [filename]
stdcall load_file, eax
stdcall load_file, [path_string]
mov esi, -ERROR_FILE_NOT_FOUND
test eax, eax
jz .err_file
mov [file_base], eax
mov [file_size], ebx
lea ebx, [hdr_cmdline]
call test_app_header
mov esi, -0x1F
@ -117,9 +113,8 @@ proc fs_execute
jz .err_hdr
call lock_application_table
call alloc_thread_slot
mov esi, -0x20 ; too many processes
mov esi, -0x20 ; too many processes
test eax, eax
jz .err_0
@ -127,103 +122,80 @@ proc fs_execute
shl eax, 8
lea edi, [SLOT_BASE+eax]
mov [slot_base], edi
;clean extended information about process
; clean extended information about process
mov ecx, 256/4
xor eax, eax
cld
rep stosd
; write application name
stdcall strrchr, [filename], '/' ; now eax points to name without path
lea esi, [eax+1]
test eax, eax
jnz @F
mov esi, [filename]
@@:
mov ecx, 11 ; 11 chars for name! 8 - is old value!
stdcall strrchr, [path_string], '/'
lea esi, [eax+1] ; -> name without path
mov ecx, 11
mov edi, [slot_base]
.copy_process_name_loop:
lodsb
@@:
call utf8to16
call uni2ansi_char
cmp al, '.'
jz .copy_process_name_done
jz @f
test al, al
jz .copy_process_name_done
jz @f
stosb
loop .copy_process_name_loop
.copy_process_name_done:
loop @b
@@:
mov edi, [cmdline]
xor eax, eax
test edi, edi
jz @F
jz @f
mov ecx, 65535
call _strnlen
cmp eax, 256
jb @F
jb @f
lea ebx, [eax+1]
add [hdr_emem], ebx
@@:
mov [cmdline_size], eax
stdcall create_process, [hdr_emem]
mov esi, -30; no memory
mov esi, -30 ; no memory
test eax, eax
jz .err_hdr
mov ebx, [sys_proc+LHEAD.prev]
__list_add eax, ebx, sys_proc
mov ebx, [hdr_emem]
mov [eax+PROC.mem_used], ebx
mov ebx, [slot_base]
mov [ebx+APPDATA.process], eax
lea edx, [ebx+APPDATA.list]
lea ecx, [eax+PROC.thr_list]
list_add_tail edx, ecx
mov esi, sizeof.APP_HDR
add esi, [cmdline_size]
mov edi, [filename]
mov ecx, 1023
mov edi, [path_string]
mov ecx, maxPathLength
call _strnlen
add esi, eax
mov [filename_size], eax
stdcall kernel_alloc, esi
mov eax, [cmdline_size]
add eax, sizeof.APP_HDR
stdcall kernel_alloc, eax
mov [ebx+APPDATA.exec_params], eax
mov edi, eax
lea esi, [hdr_cmdline]
mov ecx, sizeof.APP_HDR/4
rep movsd
mov esi, [filename]
mov ecx, [filename_size]
rep movsb
mov ecx, [cmdline_size]
mov esi, [cmdline]
rep movsb
lea eax, [hdr_cmdline]
stdcall set_app_params , [slot], eax, [flags]
mov eax, [process_number] ;set result
mov eax, [process_number] ;set result
call unlock_application_table
ret
.err_0:
call unlock_application_table
.err_hdr:
stdcall kernel_free, [file_base]
.err_file:
stdcall kernel_free, [path_string]
mov eax, esi
ret
endp
@ -848,96 +820,48 @@ endp
align 4
common_app_entry:
mov ebp, [current_slot]
mov ebp, [ebp+APPDATA.exec_params]
test ebp, ebp
jz .exit
stdcall map_process_image, [ebp+APP_HDR._emem],\
[ebp+APP_HDR.img_base], [ebp+APP_HDR.img_size]
xor eax, eax
mov esi, [ebp+APP_HDR.path_string]
mov edi, [ebp+APP_HDR.path]
lea esi, [ebp+sizeof.APP_HDR]
mov ecx, [ebp+APP_HDR.filename_size]
push esi
test edi, edi
jnz .copy_filename
add esi, ecx
jmp .check_cmdline
.copy_full_path:
mov esi, [current_slot]
mov esi, [esi+APPDATA.cur_dir]
mov ebx, 1023
mov al, '/'
stosb
.copy_path:
dec ebx
jz .finish_path
lodsb
stosb
test al, al
jnz .copy_path
mov byte [edi-1], '/'
cmp ecx, ebx
jbe @F
mov ecx, ebx
jz @f
mov ecx, [ebp+APP_HDR.filename_size]
rep movsb
mov byte [edi], 0
@@:
lea esi, [ebp+sizeof.APP_HDR]
xor eax, eax
rep movsb
stosb
jmp .check_cmdline
.finish_path:
xor eax, eax
stosb
jmp .check_cmdline
.copy_filename:
cmp byte [esi], '/'
jne .copy_full_path
rep movsb
stosb
.check_cmdline:
call kernel_free
mov edi, [ebp+APP_HDR.cmdline]
mov ecx, [ebp+APP_HDR.cmdline_size]
test edi, edi
jz .check_tls_header
lea esi, [ebp+sizeof.APP_HDR]
mov ecx, [ebp+APP_HDR.cmdline_size]
cmp ecx, 256
jb .copy_cmdline
mov edi, [ebp+APP_HDR._emem]
add edi, 4095
and edi, -4096
sub edi, ecx
dec edi
cmp word [6], '00'
jne @F
jne @f
mov [APP_HEADER_00_.i_param], edi
jmp .copy_cmdline
@@:
mov [APP_HEADER_01_.i_param], edi
.copy_cmdline:
rep movsb
stosb
mov byte [edi], 0
.check_tls_header:
cmp word [6], '02'
jne .cleanup
call init_heap
stdcall user_alloc, 4096
mov edx, [current_slot]
mov [edx+APPDATA.tls_base], eax
mov [tls_data_l+2], ax
@ -946,11 +870,9 @@ common_app_entry:
mov [tls_data_l+7], ah
mov dx, app_tls
mov fs, dx
.cleanup:
stdcall free_kernel_space, [ebp+APP_HDR.img_base]
stdcall kernel_free, ebp
mov ebx, [current_slot]
cmp [ebx+APPDATA.debugger_slot], 0
je .exit
@ -1018,11 +940,11 @@ proc set_app_params stdcall,slot:dword, params:dword, flags:dword
mov [SLOT_BASE+APPDATA.saved_esp0+ebx], eax
push ebx
stdcall kernel_alloc, 0x1000
stdcall kernel_alloc, maxPathLength
pop ebx
mov esi, [current_slot]
mov esi, [esi+APPDATA.cur_dir]
mov ecx, 0x1000/4
mov ecx, maxPathLength/4
mov edi, eax
mov [ebx+SLOT_BASE+APPDATA.cur_dir], eax
rep movsd

View File

@ -3385,7 +3385,8 @@ Architecture Software Developer's Manual, Volume 3, Appendix B);
Параметры:
* eax = 68 - номер функции
* ebx = 19 - номер подфункции
* ecx = указатель на ASCIIZ-строку с полным путём к DLL
* ecx = указатель на строку с путём к DLL,
правила формирования строки указаны в описании функции 70.
Возвращаемое значение:
* eax = 0 - неудача
* иначе eax = указатель на таблицу экспорта DLL
@ -3894,12 +3895,15 @@ Architecture Software Developer's Manual, Volume 3, Appendix B);
* +12 = +0xC: dword: размер
* +16 = +0x10: dword: указатель на данные
* +20 = +0x14: ?: текстовая строка - путь к файлу, заканчивается нулём
или
или
* +20 = +0x14: byte: 0
* +21 = +0x15: dword: указатель на строку
Для ввода текста в кодировке UTF-16LE нужно расположить в начале строки
байт со значением 2, иначе будет использоваться кодировка cp866.
Чувствительность к регистру букв зависит от файловой системы.
Можно указать кодировку, поместив в начале строки байт со значениями:
* 1 = cp866
* 2 = UTF-16LE
* 3 = UTF-8
иначе будет использоваться кодировка cp866.
Формат строки:
/base/number/dir1/dir2/.../dirn/file,
где base/number идентифицирует устройство, на котором ищется файл:

View File

@ -3348,7 +3348,8 @@ Remarks:
Parameters:
* eax = 68 - function number
* ebx = 19 - subfunction number
* ecx = pointer to ASCIIZ-string with the full path to DLL
* ecx = pointer to the string with path to DLL,
rules of path forming can be found in function 70 description.
Returned value:
* eax = 0 - failed
* otherwise eax = pointer to DLL export table
@ -3849,11 +3850,15 @@ General format of the information structure:
* +12 = +0xC: dword: size
* +16 = +0x10: dword: pointer to data
* +20 = +0x14: ?: path - zero terminated string
or
or
* +20 = +0x14: byte: 0
* +21 = +0x15: dword: pointer to string
You may set encoding to UTF-16LE by starting the string with a byte with value 2,
otherwise will be used cp866. Case sensitivity depends on filesystem.
Case sensitivity depends on filesystem.
To set the encoding, put at the start of the string a byte with next values:
* 1 = cp866
* 2 = UTF-16LE
* 3 = UTF-8
otherwise will be used cp866.
Format of filename:
/base/number/dir1/dir2/.../dirn/file,
where base/number identifies device, on which file is located:

View File

@ -55,35 +55,39 @@ file_system_lfn:
cmp byte [ebp], 0
jnz @f
mov ebp, [ebx+21]
@@:
cmp word [ebp], '/'
jz .rootdir
cmp byte [ebp], 4
jnc @f
cmp byte [ebp], 0
jz @f
cmp word [ebp+1], '/'
jnz @f
cmp byte [ebp], 2
jnz .rootdir
cmp word [ebp+3], 0
jz .rootdir
@@:
cmp dword[ebx], 7 ; start application
jne @f
jnz @f
mov edx, [ebx+4]
mov ebx, [ebx+8]
call fs_execute ; ebp, ebx, edx
mov [image_of_eax], eax
ret
@@:
cmp word [ebp], '/'
jz .rootdir
cmp byte [ebp], 2
jnz @f
cmp dword[ebp+1], '/'
jz .rootdir
@@:
stdcall kernel_alloc, maxPathLength
push ebx
mov ebx, ebp
mov ebp, eax
push maxPathLength
push eax
call get_full_file_name
stdcall get_full_file_name, eax, maxPathLength
pop ebx
test eax, eax
jz .notfound
mov esi, ebp
mov ax, [ebp]
lea esi, [ebp+2]
mov ax, [esi]
or ax, 2020h
cmp ax, 'cd'
jz .CD
@ -496,11 +500,13 @@ sys_current_directory: ; sysfunction 30
mov ebx, ecx
get_full_file_name:
; in: ebx -> file name, [esp+4] -> destination, [esp+8] = max length
; out: eax=0 -> out of length
; out: UTF-8 string, eax=0 -> out of length
push ebp ebx
cmp byte [ebx], 0
jz .set_relative
mov esi, ebx
cmp byte [ebx], 2
jnz @f
cmp byte [ebx], 4
jnc @f
inc esi
@@:
cmp byte [esi], '/'
@ -513,6 +519,10 @@ get_full_file_name:
call process_replace_file_name
mov edi, [esp+12]
mov ecx, [esp+16]
mov al, 3
mov ah, '/'
stosw
sub ecx, 2
test ebp, ebp
jz .absolute
@@:
@ -525,12 +535,23 @@ get_full_file_name:
dec edi
.absolute:
cmp byte [ebx], 2
jz @f
jz .utf16
cmp byte [ebx], 3
jz .utf8
call cp866toUTF8_string
jns .ret
jmp .fail
@@:
.utf8:
dec ecx
js .fail
lodsb
stosb
test al, al
jz .ret
jmp .utf8
.utf16:
call UTF16to8_string
jns .ret
.fail:
@ -550,7 +571,12 @@ get_full_file_name:
dec esi
mov edi, [esp+12]
jecxz .fail
cmp byte [ebx], 2
cmp byte [ebx], 0
jz .set_ok
cmp byte [ebx], 4
jnc .relative
inc ebx
cmp byte [ebx-1], 2
jz .relative16
.relative:
cmp byte [ebx], 0

View File

@ -7,54 +7,43 @@
$Revision$
iglobal
; pointer to memory for path replace table,
; size of one record is 128 bytes: 64 bytes for search pattern + 64 bytes for replace string
; start with one entry: sys -> <sysdir>
full_file_name_table dd sysdir_name
.size dd 1
tmp_file_name_size dd 1
full_file_name_table dd sysdir_name
.size dd 1
endg
uglobal
; Parser_params will initialize: sysdir_name = "sys", sysdir_path = <sysdir>
sysdir_name rb 64
sysdir_path rb 64
sysdir_name1 rb 64
sysdir_path1 rb 64
; for example:
;dir_name1 db 'KolibriOS',0
; rb 64-8
;dir_path1 db 'HD0/1',0
; rb 64-6
sysdir_name rb 64 ; 'sys',0
sysdir_path rb 64
sysdir_name1 rb 64
sysdir_path1 rb 64
endg
; Example:
; align 64
; sysdir_name1 db 'KolibriOS',0
; align 64
; sysdir_path1 db 'HD0/1',0
uglobal
tmp_file_name_table dd ?
endg
; use bx_from_load and init system directory /sys
proc Parser_params
locals
buff db 4 dup(?) ; for test cd
endl
locals
buff rb 4 ; for test cd
endl
mov eax, [OS_BASE+0x10000+bx_from_load]
mov ecx, sysdir_path
mov [ecx-64], dword 'sys'
cmp al, 'r'; if ram disk
mov [ecx-2], byte 3
mov [ecx-1], byte '/'
cmp al, 'r' ; ram disk
jnz @f
mov [ecx], dword 'RD/?'
mov [ecx+3], byte ah
mov [ecx+4], byte 0
ret
@@:
cmp al, 'm'; if ram disk
jnz @f
mov [ecx], dword 'CD?/'; if cd disk {m}
cmp al, 'm'
jnz .hard_disk
mov [ecx], dword 'CD?/'
mov [ecx+4], byte '1'
mov [ecx+5], dword '/KOL'
mov [ecx+9], dword 'IBRI'
@ -63,177 +52,24 @@ endl
mov [ecx+2], byte ah
inc ah
cmp ah, '5'
je .not_found_cd
je @f
lea edx, [buff]
pushad
stdcall read_file, read_firstapp, edx, 0, 4
popad
cmp [edx], dword 'MENU'
jne .next_cd
jmp .ok
@@:
sub al, 49
mov [ecx], dword 'HD?/'; if hard disk
ret
.hard_disk:
sub al, '1'
mov [ecx], dword 'HD?/'
mov [ecx+2], byte al
mov [ecx+4], byte ah
mov [ecx+5], dword '/KOL'
mov [ecx+9], dword 'IBRI'
mov [ecx+13], byte 0
.ok:
.not_found_cd:
ret
endp
proc load_file_parse_table
stdcall kernel_alloc, 0x1000
mov [tmp_file_name_table], eax
mov edi, eax
mov esi, sysdir_name
mov ecx, 128/4
rep movsd
invoke ini.enum_keys, conf_fname, conf_path_sect, get_every_key
mov eax, [tmp_file_name_table]
mov [full_file_name_table], eax
mov eax, [tmp_file_name_size]
mov [full_file_name_table.size], eax
ret
endp
uglobal
def_val_1 db 0
endg
proc get_every_key stdcall, f_name, sec_name, key_name
mov esi, [key_name]
mov ecx, esi
cmp byte [esi], '/'
jnz @f
inc esi
@@:
mov edi, [tmp_file_name_size]
shl edi, 7
cmp edi, 0x1000
jae .stop_parse
add edi, [tmp_file_name_table]
lea ebx, [edi+64]
@@:
cmp edi, ebx
jae .skip_this_key
lodsb
test al, al
jz @f
or al, 20h
stosb
jmp @b
@@:
stosb
invoke ini.get_str, [f_name], [sec_name], ecx, ebx, 64, def_val_1
cmp byte [ebx], '/'
jnz @f
lea esi, [ebx+1]
mov edi, ebx
mov ecx, 63
rep movsb
@@:
push ebp
mov ebp, [tmp_file_name_table]
mov ecx, [tmp_file_name_size]
jecxz .noreplace
mov eax, ecx
dec eax
shl eax, 7
add ebp, eax
.replace_loop:
mov edi, ebx
mov esi, ebp
@@:
lodsb
test al, al
jz .doreplace
mov dl, [edi]
inc edi
test dl, dl
jz .replace_loop_cont
or dl, 20h
cmp al, dl
jz @b
jmp .replace_loop_cont
.doreplace:
cmp byte [edi], 0
jz @f
cmp byte [edi], '/'
jnz .replace_loop_cont
@@:
lea esi, [ebp+64]
call .replace
jc .skip_this_key2
.replace_loop_cont:
sub ebp, 128
loop .replace_loop
.noreplace:
pop ebp
inc [tmp_file_name_size]
.skip_this_key:
xor eax, eax
inc eax
ret
.skip_this_key2:
pop ebp
jmp .skip_this_key
.stop_parse:
xor eax, eax
ret
endp
proc get_every_key.replace
; in: ebx->destination, esi->first part of name, edi->second part of name
; maximum length is 64 bytes
; out: CF=1 <=> overflow
; 1) allocate temporary buffer in stack
sub esp, 64
; 2) save second part of name to temporary buffer
push esi
lea esi, [esp+4] ; esi->tmp buffer
xchg esi, edi ; edi->tmp buffer, esi->source
@@:
lodsb
stosb
test al, al
jnz @b
; 3) copy first part of name to destination
pop esi
mov edi, ebx
@@:
lodsb
test al, al
jz @f
stosb
jmp @b
@@:
; 4) restore second part of name from temporary buffer to destination
; (may cause overflow)
lea edx, [ebx+64] ; limit of destination
mov esi, esp
@@:
cmp edi, edx
jae .overflow
lodsb
stosb
test al, al
jnz @b
; all is OK
add esp, 64 ; CF is cleared
ret
.overflow:
; name is too long
add esp, 64
stc
ret
endp

View File

@ -1198,7 +1198,7 @@ proc setup_os_slot
mov dword [edx+APPDATA.fd_obj], eax
mov dword [edx+APPDATA.bk_obj], eax
mov dword [edx+APPDATA.cur_dir], sysdir_path
mov dword [edx+APPDATA.cur_dir], sysdir_path-2
mov [edx + APPDATA.process], sys_proc

View File

@ -26,8 +26,6 @@ include "core/irq.inc" ; interrupt handling functions
include "core/apic.inc"
include "core/timers.inc"
include "core/clipboard.inc"
include "core/conf_lib.inc"
include "core/ext_lib.inc" ; load external library
include "boot/shutdown.inc" ; kernel shutdown
@ -67,4 +65,6 @@ include "fs/fs_lfn.inc" ; sysfunction 70
include "network/stack.inc"
include "imports.inc" ; list of external functions
; include "imports.inc"
; include "core/ext_lib.inc"
; include "core/conf_lib.inc"