2011-10-14 23:38:50 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2016-07-13 03:01:16 +02:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
|
|
|
|
;; Distributed under terms of the GNU General Public License. ;;
|
2011-10-14 23:38:50 +02:00
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
$Revision$
|
|
|
|
|
2012-07-25 18:26:11 +02:00
|
|
|
ERROR_SUCCESS = 0
|
|
|
|
ERROR_DISK_BASE = 1
|
|
|
|
ERROR_UNSUPPORTED_FS = 2
|
|
|
|
ERROR_UNKNOWN_FS = 3
|
|
|
|
ERROR_PARTITION = 4
|
|
|
|
ERROR_FILE_NOT_FOUND = 5
|
|
|
|
ERROR_END_OF_FILE = 6
|
|
|
|
ERROR_MEMORY_POINTER = 7
|
|
|
|
ERROR_DISK_FULL = 8
|
|
|
|
ERROR_FS_FAIL = 9
|
|
|
|
ERROR_ACCESS_DENIED = 10
|
|
|
|
ERROR_DEVICE = 11
|
2015-12-21 12:47:21 +01:00
|
|
|
ERROR_OUT_OF_MEMORY = 12
|
2011-10-14 23:38:50 +02:00
|
|
|
|
2016-08-02 22:28:34 +02:00
|
|
|
maxPathLength = 1000h
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
image_of_eax EQU esp+32
|
|
|
|
image_of_ebx EQU esp+20
|
|
|
|
|
2016-07-29 13:12:13 +02:00
|
|
|
; System function 70
|
2013-02-28 23:03:45 +01:00
|
|
|
|
|
|
|
file_system_lfn_protected:
|
|
|
|
pushad
|
|
|
|
call protect_from_terminate
|
|
|
|
call file_system_lfn
|
|
|
|
call unprotect_from_terminate
|
|
|
|
popad
|
|
|
|
mov [image_of_eax], eax
|
|
|
|
mov [image_of_ebx], ebx
|
|
|
|
ret
|
|
|
|
|
2016-12-15 18:38:17 +01:00
|
|
|
fileSystemUnicode:
|
|
|
|
; in: ebx -> f.80 parameter structure
|
|
|
|
mov edi, [ebx+20]
|
|
|
|
mov esi, [ebx+24]
|
|
|
|
jmp @f
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
file_system_lfn:
|
2016-12-15 18:38:17 +01:00
|
|
|
; in: ebx -> f.70 parameter structure
|
|
|
|
xor edi, edi
|
|
|
|
lea esi, [ebx+20]
|
|
|
|
cmp byte [esi], 0
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz @f
|
2016-12-15 18:38:17 +01:00
|
|
|
mov esi, [ebx+21]
|
2016-08-25 21:30:08 +02:00
|
|
|
@@:
|
2016-12-15 18:38:17 +01:00
|
|
|
cmp word [esi], '/'
|
2016-08-25 21:30:08 +02:00
|
|
|
jnz @f
|
2016-12-15 18:38:17 +01:00
|
|
|
cmp edi, 2
|
2016-08-25 21:30:08 +02:00
|
|
|
jnz .rootdir
|
2016-12-15 18:38:17 +01:00
|
|
|
cmp dword[esi], '/'
|
2016-08-25 21:30:08 +02:00
|
|
|
jz .rootdir
|
2016-03-13 07:08:07 +01:00
|
|
|
@@:
|
2016-12-09 10:48:32 +01:00
|
|
|
stdcall kernel_alloc, maxPathLength
|
|
|
|
push eax ebx
|
|
|
|
xchg eax, edi
|
|
|
|
call getFullPath
|
|
|
|
pop ebx ebp
|
|
|
|
test eax, eax
|
|
|
|
jz .notfound
|
2016-07-29 13:12:13 +02:00
|
|
|
cmp dword[ebx], 7 ; start application
|
2016-08-25 21:30:08 +02:00
|
|
|
jnz @f
|
2016-03-13 07:08:07 +01:00
|
|
|
mov edx, [ebx+4]
|
2016-12-09 10:48:32 +01:00
|
|
|
mov ecx, [ebx+8]
|
|
|
|
mov ebx, ebp
|
|
|
|
call fs_execute
|
2016-03-13 07:08:07 +01:00
|
|
|
mov [image_of_eax], eax
|
|
|
|
ret
|
2016-07-29 13:12:13 +02:00
|
|
|
|
2016-08-15 18:55:03 +02:00
|
|
|
@@:
|
2016-08-25 21:30:08 +02:00
|
|
|
lea esi, [ebp+2]
|
|
|
|
mov ax, [esi]
|
2016-07-29 13:12:13 +02:00
|
|
|
or ax, 2020h
|
|
|
|
cmp ax, 'cd'
|
|
|
|
jz .CD
|
|
|
|
call dyndisk_handler ; not returns if success
|
|
|
|
.notfound:
|
2016-08-02 22:28:34 +02:00
|
|
|
stdcall kernel_free, ebp
|
2016-07-29 13:12:13 +02:00
|
|
|
mov dword[image_of_eax], ERROR_FILE_NOT_FOUND
|
|
|
|
ret
|
|
|
|
|
|
|
|
.CD:
|
|
|
|
add esi, 2
|
|
|
|
xor eax, eax
|
|
|
|
lodsb ; disk number
|
|
|
|
sub eax, '0'
|
|
|
|
cmp eax, 10
|
|
|
|
jnc .notfound
|
|
|
|
mov edi, eax
|
2011-10-14 23:38:50 +02:00
|
|
|
lodsb
|
2016-07-29 13:12:13 +02:00
|
|
|
test eax, eax
|
|
|
|
jz .maindir
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp al, '/'
|
2016-07-29 13:12:13 +02:00
|
|
|
jnz .notfound
|
|
|
|
lodsb ; partition number
|
|
|
|
test eax, eax
|
|
|
|
jz .maindir
|
|
|
|
cmp al, '1'
|
|
|
|
jnz .notfound
|
|
|
|
cmp byte [esi], '/'
|
|
|
|
jnz @f
|
|
|
|
inc esi
|
|
|
|
@@:
|
|
|
|
call reserve_cd
|
|
|
|
mov eax, edi
|
|
|
|
bt eax, 0
|
|
|
|
setc [DiskNumber]
|
|
|
|
bt eax, 1
|
|
|
|
setc [ChannelNumber]
|
|
|
|
inc [ChannelNumber]
|
|
|
|
inc eax
|
|
|
|
mov [cdpos], eax
|
|
|
|
call reserve_cd_channel
|
|
|
|
mov eax, edi
|
|
|
|
not eax
|
|
|
|
and eax, 3
|
|
|
|
shl eax, 1
|
|
|
|
inc eax
|
|
|
|
shr edi, 2
|
|
|
|
mov dword[image_of_eax], ERROR_FILE_NOT_FOUND
|
|
|
|
bt [edi*5+DRIVE_DATA+1], ax
|
|
|
|
jnc @f
|
|
|
|
mov ecx, [ebx+12]
|
|
|
|
mov edx, [ebx+16]
|
|
|
|
mov eax, [ebx]
|
|
|
|
mov dword[image_of_eax], ERROR_UNSUPPORTED_FS
|
|
|
|
cmp eax, fs_NumCdServices
|
|
|
|
jae @f
|
|
|
|
add ebx, 4
|
2016-10-20 16:28:34 +02:00
|
|
|
push ebp
|
2016-07-29 13:12:13 +02:00
|
|
|
call dword[fs_CdServices + eax*4]
|
2016-10-20 16:28:34 +02:00
|
|
|
pop ebp
|
2016-07-29 13:12:13 +02:00
|
|
|
mov [image_of_eax], eax
|
|
|
|
mov [image_of_ebx], ebx
|
|
|
|
@@:
|
|
|
|
call free_cd_channel
|
|
|
|
and [cd_status], 0
|
2016-08-02 22:28:34 +02:00
|
|
|
stdcall kernel_free, ebp
|
2016-07-29 13:12:13 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
.nextCD:
|
|
|
|
test eax, eax ; partition number
|
2017-03-06 14:45:37 +01:00
|
|
|
jnz @f
|
|
|
|
inc eax ; /cdX/1
|
|
|
|
ret
|
|
|
|
|
2016-07-29 13:12:13 +02:00
|
|
|
@@:
|
2017-03-06 14:45:37 +01:00
|
|
|
stc
|
2016-07-29 13:12:13 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
.maindir: ; list partitions
|
|
|
|
mov esi, .nextCD
|
2017-03-06 14:45:37 +01:00
|
|
|
xor ecx, ecx
|
2016-07-29 13:12:13 +02:00
|
|
|
.maindir_noesi: ; backjump from dyndisk_handler
|
2016-08-02 22:28:34 +02:00
|
|
|
push ebp
|
|
|
|
mov ebp, ecx
|
|
|
|
call kernel_free
|
2017-03-06 14:45:37 +01:00
|
|
|
mov edi, [ebx+16] ; buffer
|
|
|
|
cmp byte [ebx], 5
|
|
|
|
jz .deviceInfo
|
|
|
|
cmp byte [ebx], 1 ; read folder?
|
|
|
|
jnz .access_denied
|
2016-08-02 22:28:34 +02:00
|
|
|
push ebp
|
|
|
|
pushd [ebx+4] ; first block
|
2016-07-29 13:12:13 +02:00
|
|
|
mov ebp, [ebx+12] ; the number of blocks to read
|
|
|
|
mov ebx, [ebx+8] ; flags
|
2011-10-14 23:38:50 +02:00
|
|
|
mov ecx, 32/4
|
2017-03-06 14:45:37 +01:00
|
|
|
mov edx, edi
|
2016-07-29 13:12:13 +02:00
|
|
|
xor eax, eax
|
2011-10-14 23:38:50 +02:00
|
|
|
rep stosd
|
|
|
|
mov byte [edx], 1 ; version
|
|
|
|
.maindir_loop:
|
|
|
|
call esi
|
|
|
|
jc .maindir_done
|
2016-07-29 13:12:13 +02:00
|
|
|
inc dword[edx+8]
|
|
|
|
dec dword[esp]
|
2011-10-14 23:38:50 +02:00
|
|
|
jns .maindir_loop
|
|
|
|
dec ebp
|
|
|
|
js .maindir_loop
|
2016-07-29 13:12:13 +02:00
|
|
|
inc dword[edx+4]
|
|
|
|
mov dword[edi], 16 ; attributes: folder
|
|
|
|
mov dword[edi+4], ebx ; name encoding
|
2011-10-14 23:38:50 +02:00
|
|
|
push eax
|
2016-07-29 13:12:13 +02:00
|
|
|
mov ecx, 32/4
|
2011-10-14 23:38:50 +02:00
|
|
|
add edi, 8
|
2016-07-29 13:12:13 +02:00
|
|
|
xor eax, eax
|
2011-10-14 23:38:50 +02:00
|
|
|
rep stosd
|
|
|
|
pop eax
|
2016-07-29 13:12:13 +02:00
|
|
|
push eax edx edi
|
|
|
|
; convert number in eax to decimal string
|
2011-10-14 23:38:50 +02:00
|
|
|
push -'0'
|
|
|
|
mov ecx, 10
|
|
|
|
@@:
|
|
|
|
xor edx, edx
|
|
|
|
div ecx
|
|
|
|
push edx
|
|
|
|
test eax, eax
|
|
|
|
jnz @b
|
2017-03-06 14:45:37 +01:00
|
|
|
cmp ebx, 2
|
2016-07-29 13:12:13 +02:00
|
|
|
jz .uni
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
pop eax
|
2016-07-29 13:12:13 +02:00
|
|
|
add eax, '0'
|
2011-10-14 23:38:50 +02:00
|
|
|
stosb
|
2016-07-29 13:12:13 +02:00
|
|
|
test eax, eax
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz @b
|
2016-07-29 13:12:13 +02:00
|
|
|
pop edi edx eax
|
2017-03-06 14:45:37 +01:00
|
|
|
cmp ebx, 3
|
|
|
|
jz @f
|
2016-07-29 13:12:13 +02:00
|
|
|
add edi, 264
|
|
|
|
jmp .maindir_loop
|
|
|
|
|
|
|
|
.uni:
|
|
|
|
pop eax
|
|
|
|
add eax, '0'
|
|
|
|
stosw
|
|
|
|
test eax, eax
|
|
|
|
jnz .uni
|
|
|
|
pop edi edx eax
|
2017-03-06 14:45:37 +01:00
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
add edi, 520
|
|
|
|
jmp .maindir_loop
|
2016-07-29 13:12:13 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.maindir_done:
|
2016-07-29 13:12:13 +02:00
|
|
|
pop eax eax
|
2011-10-14 23:38:50 +02:00
|
|
|
mov ebx, [edx+4]
|
|
|
|
xor eax, eax
|
|
|
|
dec ebp
|
|
|
|
js @f
|
|
|
|
mov al, ERROR_END_OF_FILE
|
|
|
|
@@:
|
|
|
|
mov [image_of_eax], eax
|
|
|
|
mov [image_of_ebx], ebx
|
|
|
|
ret
|
2016-07-29 13:12:13 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.access_denied:
|
2016-07-29 13:12:13 +02:00
|
|
|
mov dword[image_of_eax], ERROR_ACCESS_DENIED
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
|
|
|
|
2017-03-06 14:45:37 +01:00
|
|
|
.deviceInfo:
|
|
|
|
test ebp, ebp
|
|
|
|
jz @f
|
|
|
|
mov eax, dword[ebp+DISK.MediaInfo.Capacity]
|
|
|
|
mov edx, dword[ebp+DISK.MediaInfo.Capacity+4]
|
|
|
|
shld edx, eax, 9
|
|
|
|
shl eax, 9
|
|
|
|
mov [edi+36], edx
|
|
|
|
mov [edi+32], eax
|
|
|
|
@@:
|
|
|
|
and dword[image_of_eax], 0
|
|
|
|
ret
|
|
|
|
|
2016-07-29 13:12:13 +02:00
|
|
|
.rootdir: ; / - virtual root folder
|
2017-03-06 14:45:37 +01:00
|
|
|
cmp byte [ebx], 5
|
|
|
|
jz @b
|
|
|
|
cmp byte [ebx], 1 ; read folder?
|
2016-07-29 13:12:13 +02:00
|
|
|
jnz .access_denied
|
|
|
|
mov ebp, [ebx+12] ; number of blocks
|
|
|
|
mov edx, [ebx+16] ; return area
|
|
|
|
push dword[ebx+4] ; first block
|
2011-10-14 23:38:50 +02:00
|
|
|
mov ebx, [ebx+8] ; flags
|
|
|
|
mov ecx, 32/4
|
2016-07-29 13:12:13 +02:00
|
|
|
mov edi, edx
|
|
|
|
xor eax, eax
|
2011-10-14 23:38:50 +02:00
|
|
|
rep stosd
|
|
|
|
mov byte [edx], 1 ; version
|
2013-11-22 12:31:36 +01:00
|
|
|
sub esp, 16
|
2016-07-29 13:12:13 +02:00
|
|
|
.rootdir_loop:
|
2013-11-22 12:31:36 +01:00
|
|
|
push edi
|
|
|
|
lea edi, [esp+4]
|
|
|
|
call dyndisk_enum_root
|
|
|
|
pop edi
|
|
|
|
test eax, eax
|
2016-07-29 13:12:13 +02:00
|
|
|
jz .rootdirCD
|
|
|
|
inc dword[edx+8]
|
|
|
|
dec dword[esp+16]
|
|
|
|
jns .rootdir_loop
|
2013-11-22 12:31:36 +01:00
|
|
|
dec ebp
|
2016-07-29 13:12:13 +02:00
|
|
|
js .rootdir_loop
|
|
|
|
inc dword[edx+4]
|
|
|
|
mov dword[edi], 16 ; attributes: folder
|
|
|
|
mov dword[edi+4], ebx ; name encoding
|
2013-11-22 12:31:36 +01:00
|
|
|
push eax
|
2016-07-29 13:12:13 +02:00
|
|
|
mov ecx, 32/4
|
2013-11-22 12:31:36 +01:00
|
|
|
add edi, 8
|
2016-07-29 13:12:13 +02:00
|
|
|
xor eax, eax
|
2013-11-22 12:31:36 +01:00
|
|
|
rep stosd
|
2016-08-02 22:28:34 +02:00
|
|
|
push edi
|
|
|
|
lea esi, [esp+8]
|
2017-03-06 14:45:37 +01:00
|
|
|
cmp ebx, 2
|
2016-07-29 13:12:13 +02:00
|
|
|
jz .uni2
|
2013-11-22 12:31:36 +01:00
|
|
|
@@:
|
|
|
|
lodsb
|
|
|
|
stosb
|
2016-07-29 13:12:13 +02:00
|
|
|
test eax, eax
|
2013-11-22 12:31:36 +01:00
|
|
|
jnz @b
|
2016-08-02 22:28:34 +02:00
|
|
|
pop edi eax
|
2017-03-06 14:45:37 +01:00
|
|
|
cmp ebx, 3
|
|
|
|
jz @f
|
2016-07-29 13:12:13 +02:00
|
|
|
add edi, 264
|
|
|
|
jmp .rootdir_loop
|
|
|
|
|
|
|
|
.uni2:
|
|
|
|
lodsb
|
|
|
|
stosw
|
|
|
|
test eax, eax
|
|
|
|
jnz .uni2
|
2016-08-02 22:28:34 +02:00
|
|
|
pop edi eax
|
2017-03-06 14:45:37 +01:00
|
|
|
@@:
|
2013-11-22 12:31:36 +01:00
|
|
|
add edi, 520
|
2016-07-29 13:12:13 +02:00
|
|
|
jmp .rootdir_loop
|
|
|
|
|
|
|
|
.rootdirCD:
|
2013-11-22 12:31:36 +01:00
|
|
|
add esp, 16
|
2016-07-29 13:12:13 +02:00
|
|
|
or esi, -1
|
|
|
|
.rootdirCD_loop:
|
|
|
|
inc esi
|
|
|
|
cmp esi, 10
|
|
|
|
jnc .rootdir_done
|
|
|
|
mov eax, esi
|
|
|
|
not eax
|
|
|
|
and eax, 3
|
|
|
|
shl eax, 1
|
|
|
|
inc eax
|
|
|
|
mov ecx, esi
|
|
|
|
shr ecx, 2
|
|
|
|
bt [ecx*5+DRIVE_DATA+1], ax
|
|
|
|
jnc .rootdirCD_loop
|
|
|
|
inc dword[edx+8]
|
|
|
|
dec dword[esp]
|
|
|
|
jns .rootdirCD_loop
|
2011-10-14 23:38:50 +02:00
|
|
|
dec ebp
|
2016-07-29 13:12:13 +02:00
|
|
|
js .rootdirCD_loop
|
|
|
|
inc dword[edx+4]
|
|
|
|
mov dword[edi], 16 ; attributes: folder
|
|
|
|
mov dword[edi+4], ebx ; name encoding
|
|
|
|
mov ecx, 32/4
|
2011-10-14 23:38:50 +02:00
|
|
|
add edi, 8
|
2016-07-29 13:12:13 +02:00
|
|
|
xor eax, eax
|
2011-10-14 23:38:50 +02:00
|
|
|
rep stosd
|
2016-07-29 13:12:13 +02:00
|
|
|
mov eax, esi
|
|
|
|
add eax, '0'
|
|
|
|
cmp ebx, 1
|
|
|
|
jz @f
|
|
|
|
mov word [edi], 'cd'
|
|
|
|
mov [edi+2], ax
|
|
|
|
add edi, 264
|
|
|
|
jmp .rootdirCD_loop
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
2016-07-29 13:12:13 +02:00
|
|
|
mov dword[edi], 640063h
|
|
|
|
mov [edi+4], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
add edi, 520
|
2016-07-29 13:12:13 +02:00
|
|
|
jmp .rootdirCD_loop
|
|
|
|
|
|
|
|
.rootdir_done:
|
2011-10-14 23:38:50 +02:00
|
|
|
pop eax
|
|
|
|
mov ebx, [edx+4]
|
|
|
|
xor eax, eax
|
|
|
|
dec ebp
|
|
|
|
js @f
|
|
|
|
mov al, ERROR_END_OF_FILE
|
|
|
|
@@:
|
|
|
|
mov [image_of_eax], eax
|
|
|
|
mov [image_of_ebx], ebx
|
|
|
|
ret
|
|
|
|
|
2014-03-27 21:44:32 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
process_replace_file_name:
|
2016-07-29 13:12:13 +02:00
|
|
|
; in: [esi] = virtual path
|
|
|
|
; out: [esi]+[ebp] = physical path
|
2013-06-20 02:33:36 +02:00
|
|
|
xor edi, edi
|
2016-08-15 18:55:03 +02:00
|
|
|
xor ebp, ebp
|
2011-10-14 23:38:50 +02:00
|
|
|
.loop:
|
2013-06-27 01:35:43 +02:00
|
|
|
cmp edi, [full_file_name_table.size]
|
2013-06-20 02:33:36 +02:00
|
|
|
jae .notfound
|
2011-10-14 23:38:50 +02:00
|
|
|
push esi edi
|
2016-07-29 13:12:13 +02:00
|
|
|
shl edi, 7
|
2016-08-15 18:55:03 +02:00
|
|
|
add edi, [full_file_name_table]
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
2016-07-29 13:12:13 +02:00
|
|
|
cmp byte [edi], 0
|
2011-10-14 23:38:50 +02:00
|
|
|
jz .dest_done
|
|
|
|
lodsb
|
|
|
|
test al, al
|
|
|
|
jz .cont
|
|
|
|
scasb
|
|
|
|
jz @b
|
2016-12-15 18:38:17 +01:00
|
|
|
or al, 20h
|
|
|
|
cmp [edi-1], al
|
|
|
|
jz @b
|
2016-07-29 13:12:13 +02:00
|
|
|
.cont:
|
|
|
|
pop edi esi
|
|
|
|
inc edi
|
|
|
|
jmp .loop
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.dest_done:
|
|
|
|
cmp byte [esi], 0
|
|
|
|
jz .found
|
|
|
|
cmp byte [esi], '/'
|
|
|
|
jnz .cont
|
|
|
|
.found:
|
|
|
|
pop edi eax
|
2016-07-29 13:12:13 +02:00
|
|
|
shl edi, 7
|
2016-08-15 18:55:03 +02:00
|
|
|
add edi, [full_file_name_table]
|
2011-10-14 23:38:50 +02:00
|
|
|
mov ebp, esi
|
|
|
|
lea esi, [edi+64]
|
|
|
|
.notfound:
|
|
|
|
ret
|
2016-07-29 13:12:13 +02:00
|
|
|
|
2013-06-20 02:33:36 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2013-06-15 23:17:06 +02:00
|
|
|
uglobal
|
2016-08-15 18:55:03 +02:00
|
|
|
addDirSeal db ?
|
2013-06-15 23:17:06 +02:00
|
|
|
endg
|
2016-03-13 11:30:38 +01:00
|
|
|
|
2016-07-29 13:12:13 +02:00
|
|
|
sys_current_directory: ; sysfunction 30
|
2011-10-14 23:38:50 +02:00
|
|
|
mov eax, [current_slot]
|
|
|
|
mov edi, [eax+APPDATA.cur_dir]
|
2016-12-15 18:38:17 +01:00
|
|
|
xor eax, eax
|
2011-10-14 23:38:50 +02:00
|
|
|
dec ebx
|
|
|
|
jz .set
|
|
|
|
dec ebx
|
|
|
|
jz .get
|
2013-06-15 23:17:06 +02:00
|
|
|
dec ebx
|
|
|
|
jz .mount_additional_directory
|
2016-12-15 18:38:17 +01:00
|
|
|
mov eax, edx
|
2016-08-15 18:55:03 +02:00
|
|
|
dec ebx
|
2016-12-15 18:38:17 +01:00
|
|
|
jz .set
|
|
|
|
mov eax, esi
|
|
|
|
dec ebx
|
|
|
|
jz .get
|
2016-08-15 18:55:03 +02:00
|
|
|
@@:
|
2013-06-15 23:17:06 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
.mount_additional_directory:
|
2016-07-29 13:12:13 +02:00
|
|
|
; in: ecx -> dir name+dir path (128)
|
2016-08-15 18:55:03 +02:00
|
|
|
mov al, 1
|
|
|
|
xchg [addDirSeal], al
|
|
|
|
test al, al
|
|
|
|
jnz @b
|
2013-06-15 23:17:06 +02:00
|
|
|
mov esi, ecx
|
|
|
|
mov edi, sysdir_name1
|
2016-12-15 18:38:17 +01:00
|
|
|
mov ecx, 64
|
2016-07-29 13:12:13 +02:00
|
|
|
rep movsb ; copying fake directory name
|
2016-12-15 18:38:17 +01:00
|
|
|
mov byte [edi-1], 0
|
2016-08-15 18:55:03 +02:00
|
|
|
mov cl, 63
|
|
|
|
call cp866toUTF8_string
|
|
|
|
mov byte [edi], 0
|
|
|
|
mov [full_file_name_table.size], 2
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
2016-03-13 11:30:38 +01:00
|
|
|
|
2016-12-15 18:38:17 +01:00
|
|
|
.get:
|
|
|
|
; in: ecx -> buffer, edx = length, eax = encoding
|
2021-04-22 22:56:05 +02:00
|
|
|
stdcall is_region_userspace, ecx, edx
|
|
|
|
jnz @f
|
|
|
|
|
|
|
|
; if illegal buffer given
|
|
|
|
xor edx, edx
|
|
|
|
jmp .ret
|
|
|
|
@@:
|
|
|
|
|
2016-08-15 18:55:03 +02:00
|
|
|
mov esi, edi
|
2016-09-26 19:14:06 +02:00
|
|
|
inc esi
|
2016-08-15 18:55:03 +02:00
|
|
|
mov edi, ecx
|
|
|
|
cmp edx, maxPathLength
|
|
|
|
jc @f
|
|
|
|
mov edx, maxPathLength
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
mov ecx, edx
|
2016-12-15 18:38:17 +01:00
|
|
|
jecxz .ret
|
|
|
|
cmp eax, 2
|
|
|
|
jz .get16
|
|
|
|
cmp eax, 3
|
|
|
|
jz .get8
|
2016-08-15 18:55:03 +02:00
|
|
|
@@:
|
|
|
|
dec ecx
|
|
|
|
js @f
|
|
|
|
call utf8to16
|
|
|
|
call uni2ansi_char
|
|
|
|
stosb
|
|
|
|
test al, al
|
|
|
|
jnz @b
|
|
|
|
sub edx, ecx
|
|
|
|
@@:
|
2016-12-15 18:38:17 +01:00
|
|
|
mov byte [edi-1], 0
|
|
|
|
.ret:
|
|
|
|
mov [esp+32], edx
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
|
|
|
|
2016-12-15 18:38:17 +01:00
|
|
|
.get8:
|
|
|
|
push edi
|
|
|
|
mov edi, esi
|
|
|
|
xor eax, eax
|
|
|
|
repnz scasb
|
|
|
|
sub edx, ecx
|
|
|
|
mov ecx, edx
|
|
|
|
pop edi
|
|
|
|
rep movsb
|
|
|
|
jmp @b
|
|
|
|
|
2016-08-15 18:55:03 +02:00
|
|
|
.get16:
|
2016-12-15 18:38:17 +01:00
|
|
|
shr ecx, 1
|
2016-08-15 18:55:03 +02:00
|
|
|
shr edx, 1
|
|
|
|
@@:
|
|
|
|
dec ecx
|
|
|
|
js @f
|
|
|
|
call utf8to16
|
|
|
|
stosw
|
|
|
|
test ax, ax
|
|
|
|
jnz @b
|
|
|
|
sub edx, ecx
|
|
|
|
@@:
|
2016-12-15 18:38:17 +01:00
|
|
|
shl edx, 1
|
|
|
|
mov word [edi-2], 0
|
|
|
|
jmp .ret
|
2016-07-29 13:12:13 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.set:
|
2016-12-09 10:48:32 +01:00
|
|
|
mov esi, ecx
|
|
|
|
getFullPath:
|
|
|
|
; in: esi -> file path, eax = string encoding, edi -> destination
|
|
|
|
; out: UTF-8 string (with marker), eax = length, 0 -> error
|
|
|
|
test eax, eax
|
|
|
|
jnz @f
|
|
|
|
cmp byte [esi], 4
|
2016-08-25 21:30:08 +02:00
|
|
|
jnc @f
|
2016-12-09 10:48:32 +01:00
|
|
|
cmp byte [esi], 0
|
|
|
|
jz @f
|
|
|
|
lodsb
|
2016-08-15 18:55:03 +02:00
|
|
|
@@:
|
|
|
|
cmp byte [esi], '/'
|
2016-12-09 10:48:32 +01:00
|
|
|
jnz .relative
|
|
|
|
cmp eax, 2
|
|
|
|
jnz @f
|
|
|
|
cmp word [esi], '/'
|
|
|
|
jnz .relative
|
2016-11-25 16:11:25 +01:00
|
|
|
inc esi
|
2016-08-15 18:55:03 +02:00
|
|
|
inc esi
|
2016-12-09 10:48:32 +01:00
|
|
|
jmp .start
|
|
|
|
|
2016-08-15 18:55:03 +02:00
|
|
|
@@:
|
2016-12-09 10:48:32 +01:00
|
|
|
inc esi
|
|
|
|
cmp byte [esi], 4
|
|
|
|
jnc .start
|
|
|
|
lodsb
|
|
|
|
cmp byte [esi], '/'
|
2016-11-25 16:11:25 +01:00
|
|
|
jnz .start
|
|
|
|
inc esi
|
|
|
|
.start:
|
2016-12-09 10:48:32 +01:00
|
|
|
push eax edi
|
2016-08-02 22:28:34 +02:00
|
|
|
call process_replace_file_name
|
2016-12-09 10:48:32 +01:00
|
|
|
mov edi, [esp]
|
|
|
|
mov ecx, maxPathLength
|
2016-08-25 21:30:08 +02:00
|
|
|
mov al, 3
|
|
|
|
mov ah, '/'
|
|
|
|
stosw
|
|
|
|
sub ecx, 2
|
2016-08-15 18:55:03 +02:00
|
|
|
test ebp, ebp
|
|
|
|
jz .absolute
|
|
|
|
@@:
|
2016-08-02 22:28:34 +02:00
|
|
|
lodsb
|
|
|
|
stosb
|
2016-08-15 18:55:03 +02:00
|
|
|
dec ecx
|
2016-08-02 22:28:34 +02:00
|
|
|
test al, al
|
2016-08-15 18:55:03 +02:00
|
|
|
jnz @b
|
|
|
|
mov esi, ebp
|
2016-08-02 22:28:34 +02:00
|
|
|
dec edi
|
2016-08-15 18:55:03 +02:00
|
|
|
.absolute:
|
2016-12-09 10:48:32 +01:00
|
|
|
cmp byte [esp+4], 2
|
2016-08-25 21:30:08 +02:00
|
|
|
jz .utf16
|
2016-12-09 10:48:32 +01:00
|
|
|
cmp byte [esp+4], 3
|
2016-08-25 21:30:08 +02:00
|
|
|
jz .utf8
|
2016-08-15 18:55:03 +02:00
|
|
|
call cp866toUTF8_string
|
2016-12-05 20:44:57 +01:00
|
|
|
jns .end
|
2016-08-15 18:55:03 +02:00
|
|
|
jmp .fail
|
|
|
|
|
2016-08-25 21:30:08 +02:00
|
|
|
.utf8:
|
|
|
|
dec ecx
|
|
|
|
js .fail
|
|
|
|
lodsb
|
|
|
|
stosb
|
|
|
|
test al, al
|
2016-12-05 20:44:57 +01:00
|
|
|
jz .end
|
2016-08-25 21:30:08 +02:00
|
|
|
jmp .utf8
|
|
|
|
|
|
|
|
.utf16:
|
2016-08-15 18:55:03 +02:00
|
|
|
call UTF16to8_string
|
2016-12-05 20:44:57 +01:00
|
|
|
jns .end
|
2016-08-02 22:28:34 +02:00
|
|
|
.fail:
|
|
|
|
mov byte [edi], 0
|
2016-12-09 10:48:32 +01:00
|
|
|
pop eax eax
|
2016-08-02 22:28:34 +02:00
|
|
|
xor eax, eax
|
2016-12-09 10:48:32 +01:00
|
|
|
ret
|
2016-08-02 22:28:34 +02:00
|
|
|
|
2016-12-09 10:48:32 +01:00
|
|
|
.relative:
|
|
|
|
push eax edi
|
|
|
|
mov ebx, esi
|
2016-08-02 22:28:34 +02:00
|
|
|
mov edi, [current_slot]
|
|
|
|
mov edi, [edi+APPDATA.cur_dir]
|
|
|
|
mov edx, edi
|
2016-12-09 10:48:32 +01:00
|
|
|
mov ecx, maxPathLength
|
2016-08-02 22:28:34 +02:00
|
|
|
xor eax, eax
|
|
|
|
repnz scasb
|
|
|
|
mov esi, edi
|
2016-12-09 10:48:32 +01:00
|
|
|
mov edi, [esp]
|
2016-08-02 22:28:34 +02:00
|
|
|
jecxz .fail
|
2016-08-25 21:30:08 +02:00
|
|
|
cmp byte [ebx], 0
|
|
|
|
jz .set_ok
|
2016-12-09 10:48:32 +01:00
|
|
|
dec esi
|
2016-08-15 18:55:03 +02:00
|
|
|
cmp edx, edi ; is destination equal to cur_dir?
|
|
|
|
mov edi, esi
|
|
|
|
jz @f
|
2016-12-09 10:48:32 +01:00
|
|
|
mov edi, [esp]
|
2011-10-14 23:38:50 +02:00
|
|
|
mov ecx, esi
|
2016-08-02 22:28:34 +02:00
|
|
|
sub ecx, edx
|
2011-10-14 23:38:50 +02:00
|
|
|
mov esi, edx
|
|
|
|
mov edx, edi
|
|
|
|
rep movsb
|
2016-08-15 18:55:03 +02:00
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
mov byte [edi], '/'
|
|
|
|
inc edi
|
2016-08-15 18:55:03 +02:00
|
|
|
mov esi, ebx
|
|
|
|
mov ecx, edx
|
2016-12-09 10:48:32 +01:00
|
|
|
add ecx, maxPathLength
|
2016-08-15 18:55:03 +02:00
|
|
|
sub ecx, edi
|
|
|
|
jmp .absolute
|
|
|
|
|
2016-12-05 20:44:57 +01:00
|
|
|
.set_ok:
|
|
|
|
cmp edx, edi ; is destination equal to cur_dir?
|
2016-08-15 18:55:03 +02:00
|
|
|
jz @f
|
2016-12-05 20:44:57 +01:00
|
|
|
mov ecx, esi
|
|
|
|
sub ecx, edx
|
|
|
|
mov esi, edx
|
|
|
|
rep movsb
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
2016-12-09 10:48:32 +01:00
|
|
|
pop eax
|
|
|
|
sub edi, eax
|
|
|
|
pop eax
|
|
|
|
mov eax, edi
|
|
|
|
ret
|
2016-12-05 20:44:57 +01:00
|
|
|
|
|
|
|
.end:
|
|
|
|
or ecx, -1
|
2016-12-09 10:48:32 +01:00
|
|
|
mov edi, [esp]
|
2016-12-05 20:44:57 +01:00
|
|
|
xor eax, eax
|
|
|
|
push edi
|
|
|
|
repnz scasb
|
|
|
|
not ecx
|
|
|
|
pop edi
|
|
|
|
.parse:
|
|
|
|
mov al, '/'
|
|
|
|
repnz scasb
|
|
|
|
jecxz @b
|
|
|
|
cmp byte [edi], '.'
|
|
|
|
jnz .parse
|
|
|
|
mov esi, edi
|
|
|
|
@@:
|
|
|
|
lodsw
|
|
|
|
sub ecx, 2
|
|
|
|
cmp ax, './'
|
|
|
|
jz @b
|
|
|
|
cmp ax, '..'
|
|
|
|
jnz @f
|
2016-08-15 18:55:03 +02:00
|
|
|
cmp byte [esi], '/'
|
2016-12-05 20:44:57 +01:00
|
|
|
jnz @f
|
|
|
|
mov edx, ecx
|
|
|
|
mov ecx, edi
|
2016-12-09 10:48:32 +01:00
|
|
|
sub ecx, [esp]
|
2016-12-05 20:44:57 +01:00
|
|
|
sub ecx, 2
|
|
|
|
jc .fail
|
|
|
|
sub edi, 2
|
|
|
|
lodsb
|
|
|
|
dec edx
|
|
|
|
std
|
|
|
|
repnz scasb
|
|
|
|
cld
|
|
|
|
add edi, 2
|
|
|
|
mov ecx, edx
|
|
|
|
jmp @b
|
|
|
|
|
|
|
|
@@:
|
|
|
|
sub esi, 2
|
|
|
|
add ecx, 2
|
|
|
|
cmp esi, edi
|
|
|
|
jz .parse
|
|
|
|
push edi ecx
|
|
|
|
rep movsb
|
|
|
|
pop ecx edi
|
|
|
|
jmp .parse
|
2016-07-29 13:12:13 +02:00
|
|
|
|
2016-07-13 03:01:16 +02:00
|
|
|
include "parse_fn.inc"
|
|
|
|
include "fs_common.inc"
|
|
|
|
include "iso9660.inc" ; read for CD filesystem
|
|
|
|
include "fat.inc"
|
|
|
|
include "ntfs.inc"
|
|
|
|
include "ext.inc"
|
2020-03-12 01:27:08 +01:00
|
|
|
include "xfs.asm"
|