2011-10-14 23:38:50 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2016-08-02 22:28:34 +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$
|
|
|
|
|
2016-08-02 22:28:34 +02:00
|
|
|
; CD external functions
|
|
|
|
; in:
|
2016-08-15 18:55:03 +02:00
|
|
|
; esi -> path string in UTF-8
|
2017-03-03 18:06:08 +01:00
|
|
|
; ebx -> parameter structure +4
|
2016-08-02 22:28:34 +02:00
|
|
|
; ecx = bytes to read
|
|
|
|
; edx -> buffer
|
|
|
|
; out:
|
|
|
|
; eax, ebx = return values for sysfunc 70
|
|
|
|
iglobal
|
|
|
|
align 4
|
|
|
|
fs_CdServices:
|
|
|
|
dd fs_CdRead
|
|
|
|
dd fs_CdReadFolder
|
|
|
|
dd fs_NotImplemented
|
|
|
|
dd fs_NotImplemented
|
|
|
|
dd fs_NotImplemented
|
|
|
|
dd fs_CdGetFileInfo
|
|
|
|
dd fs_NotImplemented
|
|
|
|
dd 0
|
|
|
|
dd fs_NotImplemented
|
|
|
|
dd fs_NotImplemented
|
|
|
|
fs_NumCdServices = ($ - fs_CdServices)/4
|
|
|
|
endg
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
uglobal
|
2016-08-02 22:28:34 +02:00
|
|
|
align 4
|
|
|
|
cd_current_pointer_of_input dd 0
|
|
|
|
cd_current_pointer_of_input_2 dd 0
|
|
|
|
cd_mem_location dd 0
|
|
|
|
cd_counter_block dd 0
|
|
|
|
cd_status dd 0
|
2011-10-14 23:38:50 +02:00
|
|
|
endg
|
2016-08-02 22:28:34 +02:00
|
|
|
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
fs_NotImplemented:
|
|
|
|
movi eax, ERROR_UNSUPPORTED_FS
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
reserve_cd:
|
|
|
|
cli
|
|
|
|
cmp [cd_status], 0
|
|
|
|
je reserve_ok2
|
|
|
|
|
|
|
|
sti
|
|
|
|
call change_task
|
|
|
|
jmp reserve_cd
|
2014-03-27 21:44:32 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
reserve_ok2:
|
2011-10-14 23:38:50 +02:00
|
|
|
push eax
|
2021-06-17 11:41:16 +02:00
|
|
|
mov eax, [current_slot_idx]
|
2011-10-14 23:38:50 +02:00
|
|
|
shl eax, 5
|
2021-06-17 11:41:16 +02:00
|
|
|
mov eax, [eax+TASK_TABLE+TASKDATA.pid]
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [cd_status], eax
|
|
|
|
pop eax
|
|
|
|
sti
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
reserve_cd_channel:
|
2013-07-01 18:29:16 +02:00
|
|
|
pushad
|
2014-03-27 21:44:32 +01:00
|
|
|
mov eax, [cdpos]
|
|
|
|
dec eax
|
|
|
|
shr eax, 2
|
|
|
|
|
|
|
|
test eax, eax
|
|
|
|
jnz .1
|
|
|
|
|
|
|
|
cmp [ChannelNumber], 1
|
|
|
|
jne @f
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
mov ecx, ide_channel1_mutex
|
2014-03-27 21:44:32 +01:00
|
|
|
jmp .mutex_lock
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
2013-07-01 18:29:16 +02:00
|
|
|
mov ecx, ide_channel2_mutex
|
2014-03-27 21:44:32 +01:00
|
|
|
jmp .mutex_lock
|
|
|
|
;--------------------------------------
|
|
|
|
.1:
|
|
|
|
dec eax
|
|
|
|
jnz .2
|
|
|
|
|
|
|
|
cmp [ChannelNumber], 1
|
|
|
|
jne @f
|
|
|
|
|
|
|
|
mov ecx, ide_channel3_mutex
|
|
|
|
jmp .mutex_lock
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
mov ecx, ide_channel4_mutex
|
|
|
|
jmp .mutex_lock
|
|
|
|
;--------------------------------------
|
|
|
|
.2:
|
|
|
|
cmp [ChannelNumber], 1
|
|
|
|
jne @f
|
|
|
|
|
|
|
|
mov ecx, ide_channel5_mutex
|
|
|
|
jmp .mutex_lock
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
mov ecx, ide_channel6_mutex
|
|
|
|
.mutex_lock:
|
2013-07-01 18:29:16 +02:00
|
|
|
call mutex_lock
|
|
|
|
popad
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
free_cd_channel:
|
2013-07-01 18:29:16 +02:00
|
|
|
pushad
|
2014-03-27 21:44:32 +01:00
|
|
|
mov eax, [cdpos]
|
|
|
|
dec eax
|
|
|
|
shr eax, 2
|
|
|
|
|
|
|
|
test eax, eax
|
|
|
|
jnz .1
|
|
|
|
|
|
|
|
cmp [ChannelNumber], 1
|
|
|
|
jne @f
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
mov ecx, ide_channel1_mutex
|
2014-03-27 21:44:32 +01:00
|
|
|
jmp .mutex_unlock
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
2013-07-01 18:29:16 +02:00
|
|
|
mov ecx, ide_channel2_mutex
|
2014-03-27 21:44:32 +01:00
|
|
|
jmp .mutex_unlock
|
|
|
|
;--------------------------------------
|
|
|
|
.1:
|
|
|
|
dec eax
|
|
|
|
jnz .2
|
|
|
|
|
|
|
|
cmp [ChannelNumber], 1
|
|
|
|
jne @f
|
|
|
|
|
|
|
|
mov ecx, ide_channel3_mutex
|
|
|
|
jmp .mutex_unlock
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
mov ecx, ide_channel4_mutex
|
|
|
|
jmp .mutex_unlock
|
|
|
|
;--------------------------------------
|
|
|
|
.2:
|
|
|
|
cmp [ChannelNumber], 1
|
|
|
|
jne @f
|
|
|
|
|
|
|
|
mov ecx, ide_channel5_mutex
|
|
|
|
jmp .mutex_unlock
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
mov ecx, ide_channel6_mutex
|
|
|
|
.mutex_unlock:
|
2013-07-01 18:29:16 +02:00
|
|
|
call mutex_unlock
|
|
|
|
popad
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
2016-08-02 22:28:34 +02:00
|
|
|
|
2014-03-27 21:44:32 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
fs_CdRead:
|
|
|
|
call cd_find_lfn
|
2017-01-22 17:19:39 +01:00
|
|
|
jc .notFound
|
2011-10-14 23:38:50 +02:00
|
|
|
mov edi, [cd_current_pointer_of_input]
|
2017-01-22 17:19:39 +01:00
|
|
|
test byte [edi+25], 10b ; do not allow read directories
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz .noaccess
|
|
|
|
test ebx, ebx
|
|
|
|
jz .l1
|
|
|
|
cmp dword [ebx+4], 0
|
|
|
|
jz @f
|
2017-01-22 17:19:39 +01:00
|
|
|
xor ebx, ebx
|
|
|
|
movi eax, ERROR_END_OF_FILE
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
|
2017-01-22 17:19:39 +01:00
|
|
|
.notFound:
|
|
|
|
cmp [DevErrorCode], 0
|
|
|
|
jne .noaccess
|
2011-10-14 23:38:50 +02:00
|
|
|
xor ebx, ebx
|
2017-01-22 17:19:39 +01:00
|
|
|
movi eax, ERROR_FILE_NOT_FOUND
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
2017-01-22 17:19:39 +01:00
|
|
|
|
|
|
|
.noaccess_3:
|
|
|
|
pop eax edx ecx
|
|
|
|
.noaccess:
|
|
|
|
xor ebx, ebx
|
|
|
|
movi eax, ERROR_ACCESS_DENIED
|
|
|
|
ret
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
mov ebx, [ebx]
|
|
|
|
.l1:
|
2017-01-22 17:19:39 +01:00
|
|
|
push ecx edx 0
|
|
|
|
mov eax, [edi+10] ; real size of the file section
|
2011-10-14 23:38:50 +02:00
|
|
|
sub eax, ebx
|
|
|
|
jb .eof
|
|
|
|
cmp eax, ecx
|
|
|
|
jae @f
|
|
|
|
mov ecx, eax
|
2017-01-22 17:19:39 +01:00
|
|
|
pop eax
|
|
|
|
push ERROR_END_OF_FILE
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
mov eax, [edi+2]
|
|
|
|
mov [CDSectorAddress], eax
|
|
|
|
; now eax=cluster, ebx=position, ecx=count, edx=buffer for data
|
|
|
|
.new_sector:
|
|
|
|
test ecx, ecx
|
|
|
|
jz .done
|
|
|
|
sub ebx, 2048
|
|
|
|
jae .next
|
|
|
|
add ebx, 2048
|
|
|
|
jnz .incomplete_sector
|
|
|
|
cmp ecx, 2048
|
|
|
|
jb .incomplete_sector
|
|
|
|
; we may read and memmove complete sector
|
|
|
|
mov [CDDataBuf_pointer], edx
|
2017-01-22 17:19:39 +01:00
|
|
|
call ReadCDWRetr
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp [DevErrorCode], 0
|
|
|
|
jne .noaccess_3
|
|
|
|
add edx, 2048
|
|
|
|
sub ecx, 2048
|
|
|
|
.next:
|
|
|
|
inc dword [CDSectorAddress]
|
|
|
|
jmp .new_sector
|
2017-01-22 17:19:39 +01:00
|
|
|
|
|
|
|
.eof:
|
|
|
|
pop eax
|
|
|
|
push ERROR_END_OF_FILE
|
|
|
|
.done:
|
|
|
|
mov ebx, edx
|
|
|
|
pop eax edx ecx
|
|
|
|
sub ebx, edx
|
|
|
|
ret
|
|
|
|
|
|
|
|
.incomplete_sector: ; we must read and memmove incomplete sector
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [CDDataBuf_pointer], CDDataBuf
|
2017-01-22 17:19:39 +01:00
|
|
|
call ReadCDWRetr
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp [DevErrorCode], 0
|
|
|
|
jne .noaccess_3
|
|
|
|
push ecx
|
|
|
|
add ecx, ebx
|
|
|
|
cmp ecx, 2048
|
|
|
|
jbe @f
|
|
|
|
mov ecx, 2048
|
|
|
|
@@:
|
|
|
|
sub ecx, ebx
|
|
|
|
push edi esi ecx
|
|
|
|
mov edi, edx
|
|
|
|
lea esi, [CDDataBuf + ebx]
|
|
|
|
cld
|
|
|
|
rep movsb
|
|
|
|
pop ecx esi edi
|
|
|
|
add edx, ecx
|
|
|
|
sub [esp], ecx
|
|
|
|
pop ecx
|
|
|
|
xor ebx, ebx
|
|
|
|
jmp .next
|
2016-08-02 22:28:34 +02:00
|
|
|
|
2014-03-27 21:44:32 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
fs_CdReadFolder:
|
|
|
|
push edi
|
|
|
|
call cd_find_lfn
|
|
|
|
jnc .found
|
|
|
|
pop edi
|
|
|
|
cmp [DevErrorCode], 0
|
|
|
|
jne .noaccess_1
|
2017-03-28 16:30:08 +02:00
|
|
|
xor ebx, ebx
|
2011-10-14 23:38:50 +02:00
|
|
|
mov eax, ERROR_FILE_NOT_FOUND
|
|
|
|
ret
|
2016-12-15 18:38:17 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.found:
|
|
|
|
mov edi, [cd_current_pointer_of_input]
|
|
|
|
test byte [edi+25], 10b ; do not allow read directories
|
|
|
|
jnz .found_dir
|
|
|
|
pop edi
|
|
|
|
.noaccess_1:
|
2017-03-28 16:30:08 +02:00
|
|
|
xor ebx, ebx
|
2011-10-14 23:38:50 +02:00
|
|
|
mov eax, ERROR_ACCESS_DENIED
|
|
|
|
ret
|
2016-12-15 18:38:17 +01:00
|
|
|
|
|
|
|
.end_buffer:
|
|
|
|
pop edx eax
|
|
|
|
sub eax, 2048 ; directory is over?
|
|
|
|
ja .read_to_buffer
|
|
|
|
mov eax, [cd_counter_block]
|
|
|
|
mov [edx+8], eax
|
|
|
|
mov eax, [ebx]
|
|
|
|
sub [edx+4], eax
|
|
|
|
xor eax, eax
|
|
|
|
dec ecx
|
|
|
|
js @f
|
|
|
|
mov al, ERROR_END_OF_FILE
|
|
|
|
@@:
|
|
|
|
pop ecx edi
|
|
|
|
mov ebx, [edx+4]
|
|
|
|
ret
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.found_dir:
|
|
|
|
mov eax, [edi+2] ; eax=cluster
|
|
|
|
mov [CDSectorAddress], eax
|
2014-03-27 21:44:32 +01:00
|
|
|
mov eax, [edi+10] ; directory size
|
2011-10-14 23:38:50 +02:00
|
|
|
push eax ecx
|
|
|
|
mov edi, edx
|
|
|
|
mov ecx, 32/4
|
|
|
|
xor eax, eax
|
|
|
|
rep stosd
|
|
|
|
pop ecx eax
|
|
|
|
mov byte [edx], 1 ; version
|
|
|
|
mov [cd_mem_location], edx
|
|
|
|
add [cd_mem_location], 32
|
|
|
|
mov [cd_counter_block], dword 0
|
|
|
|
dec dword [CDSectorAddress]
|
|
|
|
push ecx
|
|
|
|
.read_to_buffer:
|
|
|
|
inc dword [CDSectorAddress]
|
|
|
|
mov [CDDataBuf_pointer], CDDataBuf
|
2016-12-15 18:38:17 +01:00
|
|
|
call ReadCDWRetr ; read sector of directory
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp [DevErrorCode], 0
|
|
|
|
jne .noaccess_1
|
|
|
|
mov [cd_current_pointer_of_input_2], CDDataBuf
|
2016-12-15 18:38:17 +01:00
|
|
|
push eax edx
|
|
|
|
.get_names_from_buffer:
|
2011-10-14 23:38:50 +02:00
|
|
|
call cd_get_name
|
|
|
|
jc .end_buffer
|
|
|
|
inc dword [cd_counter_block]
|
|
|
|
mov eax, [cd_counter_block]
|
|
|
|
cmp [ebx], eax
|
2016-12-15 18:38:17 +01:00
|
|
|
jae .get_names_from_buffer
|
2011-10-14 23:38:50 +02:00
|
|
|
test ecx, ecx
|
2016-12-15 18:38:17 +01:00
|
|
|
jz .get_names_from_buffer
|
2011-10-14 23:38:50 +02:00
|
|
|
mov edi, [cd_counter_block]
|
|
|
|
mov [edx+4], edi
|
|
|
|
dec ecx
|
|
|
|
mov esi, ebp
|
2016-12-15 18:38:17 +01:00
|
|
|
call cd_get_parameters_of_file
|
2011-10-14 23:38:50 +02:00
|
|
|
add edi, 40
|
2016-12-15 18:38:17 +01:00
|
|
|
mov ax, '.'
|
|
|
|
cmp dword[ebx+4], 2
|
|
|
|
jz .utf16
|
|
|
|
cmp dword[ebx+4], 3
|
|
|
|
jz .utf8
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp [cd_counter_block], 2
|
2016-12-15 18:38:17 +01:00
|
|
|
jbe .parentDirectory
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
lodsw
|
|
|
|
xchg ah, al
|
|
|
|
call uni2ansi_char
|
|
|
|
stosb
|
2016-12-15 18:38:17 +01:00
|
|
|
call .checkForEnd
|
|
|
|
jc @b
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [edi], byte 0
|
|
|
|
add [cd_mem_location], 304
|
2016-12-15 18:38:17 +01:00
|
|
|
jmp .get_names_from_buffer
|
|
|
|
|
|
|
|
.parentDirectory:
|
|
|
|
stosb
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp [cd_counter_block], 2
|
2016-12-15 18:38:17 +01:00
|
|
|
jnz @b
|
|
|
|
stosb
|
|
|
|
jmp @b
|
2014-03-27 21:44:32 +01:00
|
|
|
|
2016-12-15 18:38:17 +01:00
|
|
|
.utf8:
|
|
|
|
add [cd_mem_location], 256
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp [cd_counter_block], 2
|
2016-12-15 18:38:17 +01:00
|
|
|
jbe .parentDirectory
|
|
|
|
push ecx
|
|
|
|
mov ecx, 519
|
|
|
|
@@:
|
|
|
|
lodsw
|
|
|
|
xchg ah, al
|
|
|
|
call UTF16to8
|
|
|
|
js @f
|
|
|
|
call .checkForEnd
|
|
|
|
jc @b
|
|
|
|
@@:
|
|
|
|
pop ecx
|
|
|
|
mov [edi], byte 0
|
|
|
|
add [cd_mem_location], 304
|
|
|
|
jmp .get_names_from_buffer
|
2014-03-27 21:44:32 +01:00
|
|
|
|
2016-12-15 18:38:17 +01:00
|
|
|
.checkForEnd:
|
2011-10-14 23:38:50 +02:00
|
|
|
mov ax, [esi]
|
2016-12-15 18:38:17 +01:00
|
|
|
cmp ax, 3B00h ; ';'
|
|
|
|
jz @f
|
2014-03-27 21:44:32 +01:00
|
|
|
; check for files not ending with separator
|
2011-10-14 23:38:50 +02:00
|
|
|
movzx eax, byte [ebp-33]
|
|
|
|
add eax, ebp
|
|
|
|
sub eax, 34
|
|
|
|
cmp esi, eax
|
2016-12-15 18:38:17 +01:00
|
|
|
jz @f
|
2014-03-27 21:44:32 +01:00
|
|
|
; check the end of the directory
|
2011-10-14 23:38:50 +02:00
|
|
|
movzx eax, byte [ebp-1]
|
|
|
|
add eax, ebp
|
|
|
|
cmp esi, eax
|
2016-12-15 18:38:17 +01:00
|
|
|
@@:
|
|
|
|
ret
|
|
|
|
|
|
|
|
.utf16:
|
|
|
|
cmp [cd_counter_block], 2
|
|
|
|
jbe .utf16ParentDirectory
|
|
|
|
@@:
|
|
|
|
lodsw
|
|
|
|
xchg ah, al
|
|
|
|
stosw
|
|
|
|
call .checkForEnd
|
|
|
|
jc @b
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [edi], word 0
|
|
|
|
add [cd_mem_location], 560
|
2016-12-15 18:38:17 +01:00
|
|
|
jmp .get_names_from_buffer
|
|
|
|
|
|
|
|
.utf16ParentDirectory:
|
|
|
|
stosw
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp [cd_counter_block], 2
|
2016-12-15 18:38:17 +01:00
|
|
|
jnz @b
|
|
|
|
stosw
|
|
|
|
jmp @b
|
2014-03-27 21:44:32 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
cd_get_parameters_of_file:
|
|
|
|
mov edi, [cd_mem_location]
|
|
|
|
cd_get_parameters_of_file_1:
|
2014-03-27 21:44:32 +01:00
|
|
|
; get file attributes
|
2011-10-14 23:38:50 +02:00
|
|
|
xor eax, eax
|
2014-03-27 21:44:32 +01:00
|
|
|
; file is not archived
|
2011-10-14 23:38:50 +02:00
|
|
|
inc eax
|
|
|
|
shl eax, 1
|
2014-03-27 21:44:32 +01:00
|
|
|
; is a directory?
|
2011-10-14 23:38:50 +02:00
|
|
|
test [ebp-8], byte 2
|
|
|
|
jz .file
|
|
|
|
inc eax
|
|
|
|
.file:
|
2014-03-27 21:44:32 +01:00
|
|
|
; not as a volume label in the FAT, in this form not available
|
|
|
|
; file is not a system
|
2011-10-14 23:38:50 +02:00
|
|
|
shl eax, 3
|
2014-03-27 21:44:32 +01:00
|
|
|
; file is hidden? (attribute of existence)
|
2011-10-14 23:38:50 +02:00
|
|
|
test [ebp-8], byte 1
|
|
|
|
jz .hidden
|
|
|
|
inc eax
|
|
|
|
.hidden:
|
|
|
|
shl eax, 1
|
2014-03-27 21:44:32 +01:00
|
|
|
; file is always read-only, as this CD
|
2011-10-14 23:38:50 +02:00
|
|
|
inc eax
|
|
|
|
mov [edi], eax
|
2016-12-15 18:38:17 +01:00
|
|
|
mov eax, [ebx+4]
|
|
|
|
mov [edi+4], eax
|
2014-03-27 21:44:32 +01:00
|
|
|
; get the time to file
|
|
|
|
; hour
|
2011-10-14 23:38:50 +02:00
|
|
|
movzx eax, byte [ebp-12]
|
|
|
|
shl eax, 8
|
2014-03-27 21:44:32 +01:00
|
|
|
; minute
|
2011-10-14 23:38:50 +02:00
|
|
|
mov al, [ebp-11]
|
|
|
|
shl eax, 8
|
2014-03-27 21:44:32 +01:00
|
|
|
; second
|
2011-10-14 23:38:50 +02:00
|
|
|
mov al, [ebp-10]
|
2014-03-27 21:44:32 +01:00
|
|
|
; file creation time
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [edi+8], eax
|
2014-03-27 21:44:32 +01:00
|
|
|
; last access time
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [edi+16], eax
|
2014-03-27 21:44:32 +01:00
|
|
|
; last write time
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [edi+24], eax
|
2014-03-27 21:44:32 +01:00
|
|
|
; get date for file
|
|
|
|
; year
|
2011-10-14 23:38:50 +02:00
|
|
|
movzx eax, byte [ebp-15]
|
|
|
|
add eax, 1900
|
|
|
|
shl eax, 8
|
2014-03-27 21:44:32 +01:00
|
|
|
; month
|
2011-10-14 23:38:50 +02:00
|
|
|
mov al, [ebp-14]
|
|
|
|
shl eax, 8
|
2014-03-27 21:44:32 +01:00
|
|
|
; day
|
2011-10-14 23:38:50 +02:00
|
|
|
mov al, [ebp-13]
|
2014-03-27 21:44:32 +01:00
|
|
|
; file creation date
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [edi+12], eax
|
2014-03-27 21:44:32 +01:00
|
|
|
; last access date
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [edi+20], eax
|
2016-08-02 22:28:34 +02:00
|
|
|
; last write date
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [edi+28], eax
|
2014-03-27 21:44:32 +01:00
|
|
|
; get the file size in bytes
|
2011-10-14 23:38:50 +02:00
|
|
|
xor eax, eax
|
|
|
|
mov [edi+32+4], eax
|
|
|
|
mov eax, [ebp-23]
|
|
|
|
mov [edi+32], eax
|
|
|
|
ret
|
2016-08-02 22:28:34 +02:00
|
|
|
|
2014-03-27 21:44:32 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
fs_CdGetFileInfo:
|
2017-03-03 18:06:08 +01:00
|
|
|
call cd_find_lfn
|
|
|
|
movi eax, ERROR_FILE_NOT_FOUND
|
|
|
|
jc @f
|
|
|
|
mov edi, edx
|
|
|
|
mov eax, [ebx+4]
|
|
|
|
mov [edx+4], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp byte [esi], 0
|
2017-03-03 18:06:08 +01:00
|
|
|
jz .volume
|
|
|
|
mov ebp, [cd_current_pointer_of_input]
|
|
|
|
add ebp, 33
|
|
|
|
call cd_get_parameters_of_file_1
|
|
|
|
xor eax, eax
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
|
2017-03-03 18:06:08 +01:00
|
|
|
.volume:
|
2017-03-07 17:28:02 +01:00
|
|
|
test eax, eax
|
|
|
|
jz .size
|
2017-03-03 18:06:08 +01:00
|
|
|
mov ecx, 16
|
|
|
|
mov esi, CDDataBuf+40
|
|
|
|
add edi, 40
|
|
|
|
cmp eax, 2
|
|
|
|
jz .utf16
|
|
|
|
cmp eax, 3
|
|
|
|
jz .utf8
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
2017-03-03 18:06:08 +01:00
|
|
|
lodsw
|
|
|
|
xchg al, ah
|
|
|
|
call uni2ansi_char
|
|
|
|
stosb
|
|
|
|
loop @b
|
|
|
|
jmp .size
|
2011-10-14 23:38:50 +02:00
|
|
|
|
2017-03-03 18:06:08 +01:00
|
|
|
.utf16:
|
|
|
|
lodsw
|
|
|
|
xchg al, ah
|
|
|
|
stosw
|
|
|
|
loop .utf16
|
|
|
|
jmp .size
|
|
|
|
|
|
|
|
.utf8:
|
|
|
|
mov ebx, ecx
|
|
|
|
shl ecx, 1
|
|
|
|
@@:
|
|
|
|
lodsw
|
|
|
|
xchg ah, al
|
|
|
|
call UTF16to8
|
|
|
|
dec ebx
|
|
|
|
jnz @b
|
|
|
|
.size:
|
|
|
|
mov eax, [CDDataBuf+80]
|
|
|
|
shl eax, 11
|
|
|
|
mov [edx+32], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
xor eax, eax
|
2017-03-03 18:06:08 +01:00
|
|
|
mov [edx+36], eax
|
|
|
|
stosw
|
2017-03-07 17:28:02 +01:00
|
|
|
mov byte [edx], 8
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
2017-03-03 18:06:08 +01:00
|
|
|
|
2014-03-27 21:44:32 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
cd_find_lfn:
|
|
|
|
mov [cd_appl_data], 0
|
2016-08-15 18:55:03 +02:00
|
|
|
; in: esi -> path string in UTF-8
|
|
|
|
; out: [cd_current_pointer_of_input] -> direntry, CF=1 -> file not found
|
2011-10-14 23:38:50 +02:00
|
|
|
push eax esi
|
2014-03-27 21:44:32 +01:00
|
|
|
; Sector 16 - start set of volume descriptors
|
2011-10-14 23:38:50 +02:00
|
|
|
call WaitUnitReady
|
|
|
|
cmp [DevErrorCode], 0
|
|
|
|
jne .access_denied
|
|
|
|
|
|
|
|
call prevent_medium_removal
|
2014-03-27 21:44:32 +01:00
|
|
|
; testing of reading
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [CDSectorAddress], dword 16
|
|
|
|
mov [CDDataBuf_pointer], CDDataBuf
|
|
|
|
call ReadCDWRetr;_1
|
|
|
|
cmp [DevErrorCode], 0
|
|
|
|
jne .access_denied
|
|
|
|
|
2014-03-27 21:44:32 +01:00
|
|
|
; calculation of the last session
|
2011-10-14 23:38:50 +02:00
|
|
|
call WaitUnitReady
|
|
|
|
cmp [DevErrorCode], 0
|
|
|
|
jne .access_denied
|
2014-03-27 21:44:32 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
call Read_TOC
|
|
|
|
mov ah, [CDDataBuf+4+4]
|
|
|
|
mov al, [CDDataBuf+4+5]
|
|
|
|
shl eax, 16
|
|
|
|
mov ah, [CDDataBuf+4+6]
|
|
|
|
mov al, [CDDataBuf+4+7]
|
|
|
|
add eax, 15
|
|
|
|
mov [CDSectorAddress], eax
|
|
|
|
; mov [CDSectorAddress],dword 15
|
|
|
|
mov [CDDataBuf_pointer], CDDataBuf
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
.start:
|
|
|
|
inc dword [CDSectorAddress]
|
|
|
|
call ReadCDWRetr;_1
|
|
|
|
cmp [DevErrorCode], 0
|
|
|
|
jne .access_denied
|
|
|
|
|
|
|
|
.start_check:
|
2014-03-27 21:44:32 +01:00
|
|
|
; checking for "lice"
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp [CDDataBuf+1], dword 'CD00'
|
|
|
|
jne .access_denied
|
2014-03-27 21:44:32 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp [CDDataBuf+5], byte '1'
|
|
|
|
jne .access_denied
|
2014-03-27 21:44:32 +01:00
|
|
|
; sector is the terminator of set of descriptors volumes?
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp [CDDataBuf], byte 0xff
|
|
|
|
je .access_denied
|
2014-03-27 21:44:32 +01:00
|
|
|
; sector is an additional and improved descriptor of volume?
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp [CDDataBuf], byte 0x2
|
|
|
|
jne .start
|
2014-03-27 21:44:32 +01:00
|
|
|
; sector is an additional descriptor of volume?
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp [CDDataBuf+6], byte 0x1
|
|
|
|
jne .start
|
|
|
|
|
2014-03-27 21:44:32 +01:00
|
|
|
; parameters of root directory
|
|
|
|
mov eax, [CDDataBuf+0x9c+2]; start of root directory
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [CDSectorAddress], eax
|
2014-03-27 21:44:32 +01:00
|
|
|
mov eax, [CDDataBuf+0x9c+10]; size of root directory
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp byte [esi], 0
|
|
|
|
jnz @f
|
2014-03-27 21:44:32 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [cd_current_pointer_of_input], CDDataBuf+0x9c
|
|
|
|
jmp .done
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
2014-03-27 21:44:32 +01:00
|
|
|
; start the search
|
2011-10-14 23:38:50 +02:00
|
|
|
.mainloop:
|
|
|
|
dec dword [CDSectorAddress]
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
.read_to_buffer:
|
|
|
|
inc dword [CDSectorAddress]
|
|
|
|
mov [CDDataBuf_pointer], CDDataBuf
|
2014-03-27 21:44:32 +01:00
|
|
|
call ReadCDWRetr ; read sector of directory
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp [DevErrorCode], 0
|
|
|
|
jne .access_denied
|
|
|
|
call cd_find_name_in_buffer
|
|
|
|
jnc .found
|
|
|
|
sub eax, 2048
|
2014-03-27 21:44:32 +01:00
|
|
|
; directory is over?
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp eax, 0
|
|
|
|
ja .read_to_buffer
|
2014-03-27 21:44:32 +01:00
|
|
|
; desired element of chain is not found
|
2011-10-14 23:38:50 +02:00
|
|
|
.access_denied:
|
|
|
|
pop esi eax
|
|
|
|
mov [cd_appl_data], 1
|
|
|
|
stc
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
|
|
|
; desired element of chain found
|
|
|
|
.found:
|
|
|
|
; the end of the file path
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp byte [esi-1], 0
|
|
|
|
jz .done
|
|
|
|
mov eax, [cd_current_pointer_of_input]
|
|
|
|
push dword [eax+2]
|
2014-03-27 21:44:32 +01:00
|
|
|
pop dword [CDSectorAddress] ; beginning of the directory
|
|
|
|
mov eax, [eax+2+8] ; size of directory
|
2011-10-14 23:38:50 +02:00
|
|
|
jmp .mainloop
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
|
|
|
; file pointer found
|
|
|
|
.done:
|
2011-10-14 23:38:50 +02:00
|
|
|
pop esi eax
|
|
|
|
mov [cd_appl_data], 1
|
|
|
|
clc
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
cd_find_name_in_buffer:
|
|
|
|
mov [cd_current_pointer_of_input_2], CDDataBuf
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
.start:
|
|
|
|
call cd_get_name
|
|
|
|
jc .not_found
|
2014-03-27 21:44:32 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
call cd_compare_name
|
|
|
|
jc .start
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
.found:
|
|
|
|
clc
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
.not_found:
|
|
|
|
stc
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
cd_get_name:
|
|
|
|
push eax
|
|
|
|
mov ebp, [cd_current_pointer_of_input_2]
|
|
|
|
mov [cd_current_pointer_of_input], ebp
|
|
|
|
mov eax, [ebp]
|
2014-03-27 21:44:32 +01:00
|
|
|
test eax, eax ; entry's is over?
|
2011-10-14 23:38:50 +02:00
|
|
|
jz .next_sector
|
2014-03-27 21:44:32 +01:00
|
|
|
|
|
|
|
cmp ebp, CDDataBuf+2048 ; buffer is over?
|
2011-10-14 23:38:50 +02:00
|
|
|
jae .next_sector
|
2014-03-27 21:44:32 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
movzx eax, byte [ebp]
|
2014-03-27 21:44:32 +01:00
|
|
|
add [cd_current_pointer_of_input_2], eax ; next entry of directory
|
|
|
|
add ebp, 33; pointer is set to the beginning of the name
|
2011-10-14 23:38:50 +02:00
|
|
|
pop eax
|
|
|
|
clc
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
.next_sector:
|
|
|
|
pop eax
|
|
|
|
stc
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
cd_compare_name:
|
2016-08-15 18:55:03 +02:00
|
|
|
; in: esi -> UTF-8 name, ebp -> UTF-16BE name
|
|
|
|
; out: CF=0 -> names match, esi -> next component of name
|
|
|
|
; CF=1 -> esi is not changed
|
|
|
|
push edx edi eax esi
|
2011-10-14 23:38:50 +02:00
|
|
|
mov edi, ebp
|
|
|
|
.loop:
|
2016-08-15 18:55:03 +02:00
|
|
|
call utf8to16
|
|
|
|
call utf16toUpper
|
|
|
|
mov edx, eax
|
|
|
|
mov ax, [edi]
|
|
|
|
xchg al, ah
|
|
|
|
call utf16toUpper
|
|
|
|
cmp ax, dx
|
2011-10-14 23:38:50 +02:00
|
|
|
jne .name_not_coincide
|
2016-08-15 18:55:03 +02:00
|
|
|
add edi, 2
|
2014-03-27 21:44:32 +01:00
|
|
|
cmp [esi], byte '/' ; path separator is end of current element
|
2011-10-14 23:38:50 +02:00
|
|
|
je .done
|
2014-03-27 21:44:32 +01:00
|
|
|
cmp [esi], byte 0 ; path separator end of name
|
2016-08-15 18:55:03 +02:00
|
|
|
jne .loop
|
2011-10-14 23:38:50 +02:00
|
|
|
.done:
|
2014-03-27 21:44:32 +01:00
|
|
|
; check end of file
|
|
|
|
cmp [edi], word 3B00h; separator end of file ';'
|
2011-10-14 23:38:50 +02:00
|
|
|
je .done_1
|
2014-03-27 21:44:32 +01:00
|
|
|
; check for files not ending with separator
|
2011-10-14 23:38:50 +02:00
|
|
|
movzx eax, byte [ebp-33]
|
|
|
|
add eax, ebp
|
|
|
|
sub eax, 34
|
|
|
|
cmp edi, eax
|
|
|
|
je .done_1
|
2014-03-27 21:44:32 +01:00
|
|
|
; check the end of directory
|
2011-10-14 23:38:50 +02:00
|
|
|
movzx eax, byte [ebp-1]
|
|
|
|
add eax, ebp
|
|
|
|
cmp edi, eax
|
|
|
|
jne .name_not_coincide
|
|
|
|
.done_1:
|
2016-08-15 18:55:03 +02:00
|
|
|
pop eax eax edi edx
|
2011-10-14 23:38:50 +02:00
|
|
|
inc esi
|
2016-08-15 18:55:03 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
.name_not_coincide:
|
|
|
|
pop esi eax edi edx
|
|
|
|
stc
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|