preparation

git-svn-id: svn://kolibrios.org@6792 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
pathoswithin 2016-12-09 09:48:32 +00:00
parent 94e30f2af4
commit f9f1eb0d75
4 changed files with 85 additions and 102 deletions

View File

@ -899,7 +899,7 @@ coff_get_align:
ret ret
align 4 align 4
proc load_library stdcall, file_name:dword proc load_library stdcall, file_name:dword, encoding:dword
locals locals
fullname dd ? fullname dd ?
fileinfo rb 40 fileinfo rb 40
@ -910,8 +910,12 @@ proc load_library stdcall, file_name:dword
; resolve file name ; resolve file name
stdcall kernel_alloc, maxPathLength stdcall kernel_alloc, maxPathLength
mov [fullname], eax mov [fullname], eax
mov ebx, [file_name] mov edi, eax
stdcall get_full_file_name, eax, maxPathLength mov esi, [file_name]
mov eax, [encoding]
push ebp
call getFullPath
pop ebp
test eax, eax test eax, eax
jz .fail jz .fail
; scan for required DLL in list of already loaded for this process, ; scan for required DLL in list of already loaded for this process,

View File

@ -1101,13 +1101,11 @@ align 4
f68: f68:
cmp ebx, 4 cmp ebx, 4
jbe sys_sheduler jbe sys_sheduler
cmp ebx, 11 cmp ebx, 11
jb undefined_syscall jb undefined_syscall
cmp ebx, 27 cmp ebx, 27
ja undefined_syscall ja undefined_syscall
xor eax, eax
jmp dword [f68call+ebx*4-11*4] jmp dword [f68call+ebx*4-11*4]
.11: .11:
call init_heap call init_heap
@ -1143,7 +1141,7 @@ f68:
.19: .19:
cmp ecx, OS_BASE cmp ecx, OS_BASE
jae .fail jae .fail
stdcall load_library, ecx stdcall load_library, ecx, eax
mov [esp+SYSCALL_STACK._eax], eax mov [esp+SYSCALL_STACK._eax], eax
ret ret
.20: .20:
@ -1155,26 +1153,21 @@ f68:
.21: .21:
cmp ecx, OS_BASE cmp ecx, OS_BASE
jae .fail jae .fail
cmp edx, OS_BASE cmp edx, OS_BASE
jae .fail jae .fail
stdcall load_pe_driver, ecx, edx stdcall load_pe_driver, ecx, edx
mov [esp+SYSCALL_STACK._eax], eax mov [esp+SYSCALL_STACK._eax], eax
ret ret
.22: .22:
cmp ecx, OS_BASE cmp ecx, OS_BASE
jae .fail jae .fail
stdcall shmem_open, ecx, edx, esi stdcall shmem_open, ecx, edx, esi
mov [esp+SYSCALL_STACK._edx], edx mov [esp+SYSCALL_STACK._edx], edx
mov [esp+SYSCALL_STACK._eax], eax mov [esp+SYSCALL_STACK._eax], eax
ret ret
.23: .23:
cmp ecx, OS_BASE cmp ecx, OS_BASE
jae .fail jae .fail
stdcall shmem_close, ecx stdcall shmem_close, ecx
mov [esp+SYSCALL_STACK._eax], eax mov [esp+SYSCALL_STACK._eax], eax
ret ret
@ -1195,27 +1188,22 @@ f68:
bts [eax+APPDATA.except_mask], ecx bts [eax+APPDATA.except_mask], ecx
@@: @@:
ret ret
.26: .26:
stdcall user_unmap, ecx, edx, esi stdcall user_unmap, ecx, edx, esi
mov [esp+SYSCALL_STACK._eax], eax mov [esp+SYSCALL_STACK._eax], eax
ret ret
.27: .27:
cmp ecx, OS_BASE cmp ecx, OS_BASE
jae .fail jae .fail
stdcall load_file_umode, ecx stdcall load_file_umode, ecx
mov [esp+SYSCALL_STACK._edx], edx mov [esp+SYSCALL_STACK._edx], edx
mov [esp+SYSCALL_STACK._eax], eax mov [esp+SYSCALL_STACK._eax], eax
ret ret
.fail: .fail:
xor eax, eax
mov [esp+SYSCALL_STACK._eax], eax mov [esp+SYSCALL_STACK._eax], eax
ret ret
align 4 align 4
f68call: ; keep this table closer to main code f68call: ; keep this table closer to main code

View File

@ -66,11 +66,19 @@ _strnlen:
fs_execute_from_sysdir: fs_execute_from_sysdir:
xor ebx, ebx xor ebx, ebx
fs_execute_from_sysdir_param: fs_execute_from_sysdir_param:
stdcall kernel_alloc, maxPathLength
push eax ebx
mov esi, ebp
mov edi, eax
xor eax, eax
call getFullPath
pop ecx ebx
xor edx, edx xor edx, edx
proc fs_execute proc fs_execute
; ebx - cmdline ; edx = flags
; edx - flags ; ecx -> cmdline
; ebp - full filename ; ebx -> absolute file path
; eax = string length
locals locals
cmdline rd 1 cmdline rd 1
flags rd 1 flags rd 1
@ -91,16 +99,13 @@ proc fs_execute
endl endl
mov [flags], edx mov [flags], edx
mov [cmdline], ebx mov [cmdline], ecx
stdcall kernel_alloc, maxPathLength mov [path_string], ebx
mov [path_string], eax mov [filename_size], eax
mov ebx, [ebp] mov esi, -ERROR_FILE_NOT_FOUND
stdcall get_full_file_name, eax, maxPathLength
test eax, eax test eax, eax
jz .err_file jz .err_file
stdcall load_file, ebx
stdcall load_file, [path_string]
mov esi, -ERROR_FILE_NOT_FOUND
test eax, eax test eax, eax
jz .err_file jz .err_file
@ -141,7 +146,6 @@ proc fs_execute
jz @f jz @f
stosb stosb
loop @b loop @b
@@: @@:
mov edi, [cmdline] mov edi, [cmdline]
xor eax, eax xor eax, eax
@ -169,10 +173,6 @@ proc fs_execute
lea edx, [ebx+APPDATA.list] lea edx, [ebx+APPDATA.list]
lea ecx, [eax+PROC.thr_list] lea ecx, [eax+PROC.thr_list]
list_add_tail edx, ecx list_add_tail edx, ecx
mov edi, [path_string]
mov ecx, maxPathLength
call _strnlen
mov [filename_size], eax
mov eax, [cmdline_size] mov eax, [cmdline_size]
add eax, sizeof.APP_HDR add eax, sizeof.APP_HDR
stdcall kernel_alloc, eax stdcall kernel_alloc, eax

View File

@ -40,17 +40,6 @@ file_system_lfn_protected:
file_system_lfn: file_system_lfn:
; in: ebx -> parameter structure ; in: ebx -> parameter structure
; operation codes:
; 0 = read file
; 1 = read folder
; 2 = create/rewrite file
; 3 = write/append to file
; 4 = set file end
; 5 = get file info
; 6 = set file info
; start application
; 8 = delete file/folder
; 9 = create folder
lea ebp, [ebx+20] lea ebp, [ebx+20]
cmp byte [ebp], 0 cmp byte [ebp], 0
jnz @f jnz @f
@ -69,23 +58,25 @@ file_system_lfn:
cmp word [ebp+3], 0 cmp word [ebp+3], 0
jz .rootdir jz .rootdir
@@: @@:
stdcall kernel_alloc, maxPathLength
push eax ebx
xchg eax, edi
mov esi, ebp
xor eax, eax
call getFullPath
pop ebx ebp
test eax, eax
jz .notfound
cmp dword[ebx], 7 ; start application cmp dword[ebx], 7 ; start application
jnz @f jnz @f
mov edx, [ebx+4] mov edx, [ebx+4]
mov ebx, [ebx+8] mov ecx, [ebx+8]
call fs_execute ; ebp, ebx, edx mov ebx, ebp
call fs_execute
mov [image_of_eax], eax mov [image_of_eax], eax
ret ret
@@: @@:
stdcall kernel_alloc, maxPathLength
push ebx
mov ebx, ebp
mov ebp, eax
stdcall get_full_file_name, eax, maxPathLength
pop ebx
test eax, eax
jz .notfound
lea esi, [ebp+2] lea esi, [ebp+2]
mov ax, [esi] mov ax, [esi]
or ax, 2020h or ax, 2020h
@ -491,40 +482,42 @@ sys_current_directory: ; sysfunction 30
ret ret
.set: .set:
pop eax mov esi, ecx
push maxPathLength xor eax, eax
push edi getFullPath:
push eax ; in: esi -> file path, eax = string encoding, edi -> destination
mov ebx, ecx ; out: UTF-8 string (with marker), eax = length, 0 -> error
get_full_file_name: test eax, eax
; in: ebx -> file name, [esp+4] -> destination, [esp+8] = max length jnz @f
; 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], 4
jnc @f
inc esi
@@:
cmp byte [esi], '/'
jnz .set_relative
inc esi
cmp byte [esi], 4 cmp byte [esi], 4
jnc @f jnc @f
mov ebx, esi cmp byte [esi], 0
inc esi jz @f
cmp byte [esi], '/' lodsb
jnz .start
inc esi
@@: @@:
cmp byte [ebx], 2 cmp byte [esi], '/'
jnz .relative
cmp eax, 2
jnz @f
cmp word [esi], '/'
jnz .relative
inc esi
inc esi
jmp .start
@@:
inc esi
cmp byte [esi], 4
jnc .start
lodsb
cmp byte [esi], '/'
jnz .start jnz .start
inc esi inc esi
.start: .start:
push eax edi
call process_replace_file_name call process_replace_file_name
mov edi, [esp+12] mov edi, [esp]
mov ecx, [esp+16] mov ecx, maxPathLength
mov al, 3 mov al, 3
mov ah, '/' mov ah, '/'
stosw stosw
@ -540,9 +533,9 @@ get_full_file_name:
mov esi, ebp mov esi, ebp
dec edi dec edi
.absolute: .absolute:
cmp byte [ebx], 2 cmp byte [esp+4], 2
jz .utf16 jz .utf16
cmp byte [ebx], 3 cmp byte [esp+4], 3
jz .utf8 jz .utf8
call cp866toUTF8_string call cp866toUTF8_string
jns .end jns .end
@ -562,31 +555,29 @@ get_full_file_name:
jns .end jns .end
.fail: .fail:
mov byte [edi], 0 mov byte [edi], 0
pop eax eax
xor eax, eax xor eax, eax
pop ebx ebp ret
ret 8
.set_relative: .relative:
push eax edi
mov ebx, esi
mov edi, [current_slot] mov edi, [current_slot]
mov edi, [edi+APPDATA.cur_dir] mov edi, [edi+APPDATA.cur_dir]
mov edx, edi mov edx, edi
mov ecx, [esp+16] mov ecx, maxPathLength
xor eax, eax xor eax, eax
repnz scasb repnz scasb
mov esi, edi mov esi, edi
dec esi mov edi, [esp]
mov edi, [esp+12]
jecxz .fail jecxz .fail
cmp byte [ebx], 0 cmp byte [ebx], 0
jz .set_ok jz .set_ok
cmp byte [ebx], 4 dec esi
jnc @f
inc ebx
@@:
cmp edx, edi ; is destination equal to cur_dir? cmp edx, edi ; is destination equal to cur_dir?
mov edi, esi mov edi, esi
jz @f jz @f
mov edi, [esp+12] mov edi, [esp]
mov ecx, esi mov ecx, esi
sub ecx, edx sub ecx, edx
mov esi, edx mov esi, edx
@ -597,9 +588,8 @@ get_full_file_name:
inc edi inc edi
mov esi, ebx mov esi, ebx
mov ecx, edx mov ecx, edx
add ecx, [esp+16] add ecx, maxPathLength
sub ecx, edi sub ecx, edi
mov ebx, [esp]
jmp .absolute jmp .absolute
.set_ok: .set_ok:
@ -609,15 +599,16 @@ get_full_file_name:
sub ecx, edx sub ecx, edx
mov esi, edx mov esi, edx
rep movsb rep movsb
mov byte [edi], 0
@@: @@:
mov al, 1 pop eax
pop ebx ebp sub edi, eax
ret 8 pop eax
mov eax, edi
ret
.end: .end:
or ecx, -1 or ecx, -1
mov edi, [esp+12] mov edi, [esp]
xor eax, eax xor eax, eax
push edi push edi
repnz scasb repnz scasb
@ -641,7 +632,7 @@ get_full_file_name:
jnz @f jnz @f
mov edx, ecx mov edx, ecx
mov ecx, edi mov ecx, edi
sub ecx, [esp+12] sub ecx, [esp]
sub ecx, 2 sub ecx, 2
jc .fail jc .fail
sub edi, 2 sub edi, 2