2007-03-21 23:58:33 +01:00
|
|
|
|
$Revision$
|
2007-03-26 14:18:08 +02:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
;; ;;
|
|
|
|
|
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
|
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
|
;; ;;
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
2007-05-11 21:38:23 +02:00
|
|
|
|
image_of_eax EQU esp+44 ;36
|
|
|
|
|
image_of_ebx EQU esp+32 ;24
|
|
|
|
|
|
2006-04-27 08:12:46 +02:00
|
|
|
|
; System function 70 - files with long names (LFN)
|
2006-04-24 16:28:05 +02:00
|
|
|
|
; diamond, 2006
|
|
|
|
|
|
|
|
|
|
iglobal
|
|
|
|
|
; in this table names must be in lowercase
|
|
|
|
|
rootdirs:
|
2006-05-05 14:40:02 +02:00
|
|
|
|
db 2,'rd'
|
|
|
|
|
dd fs_OnRamdisk
|
|
|
|
|
dd fs_NextRamdisk
|
|
|
|
|
db 7,'ramdisk'
|
|
|
|
|
dd fs_OnRamdisk
|
|
|
|
|
dd fs_NextRamdisk
|
|
|
|
|
db 2,'fd'
|
|
|
|
|
dd fs_OnFloppy
|
|
|
|
|
dd fs_NextFloppy
|
|
|
|
|
db 10,'floppydisk'
|
|
|
|
|
dd fs_OnFloppy
|
|
|
|
|
dd fs_NextFloppy
|
|
|
|
|
db 3,'hd0'
|
|
|
|
|
dd fs_OnHd0
|
|
|
|
|
dd fs_NextHd0
|
|
|
|
|
db 3,'hd1'
|
|
|
|
|
dd fs_OnHd1
|
|
|
|
|
dd fs_NextHd1
|
|
|
|
|
db 3,'hd2'
|
|
|
|
|
dd fs_OnHd2
|
|
|
|
|
dd fs_NextHd2
|
|
|
|
|
db 3,'hd3'
|
|
|
|
|
dd fs_OnHd3
|
|
|
|
|
dd fs_NextHd3
|
2006-06-18 18:42:03 +02:00
|
|
|
|
;**********************************************
|
|
|
|
|
db 3,'cd0'
|
|
|
|
|
dd fs_OnCd0
|
|
|
|
|
dd fs_NextCd
|
|
|
|
|
db 3,'cd1'
|
|
|
|
|
dd fs_OnCd1
|
|
|
|
|
dd fs_NextCd
|
|
|
|
|
db 3,'cd2'
|
|
|
|
|
dd fs_OnCd2
|
|
|
|
|
dd fs_NextCd
|
|
|
|
|
db 3,'cd3'
|
|
|
|
|
dd fs_OnCd3
|
|
|
|
|
dd fs_NextCd
|
2006-12-17 07:22:59 +01:00
|
|
|
|
;***********************************************
|
2006-05-05 14:40:02 +02:00
|
|
|
|
db 0
|
|
|
|
|
|
2006-06-18 18:42:03 +02:00
|
|
|
|
|
2006-05-05 14:40:02 +02:00
|
|
|
|
virtual_root_query:
|
|
|
|
|
dd fs_HasRamdisk
|
2006-05-12 14:47:52 +02:00
|
|
|
|
db 'rd',0
|
2006-05-05 14:40:02 +02:00
|
|
|
|
dd fs_HasFloppy
|
2006-05-12 14:47:52 +02:00
|
|
|
|
db 'fd',0
|
2006-05-05 14:40:02 +02:00
|
|
|
|
dd fs_HasHd0
|
2006-05-12 14:47:52 +02:00
|
|
|
|
db 'hd0',0
|
2006-05-05 14:40:02 +02:00
|
|
|
|
dd fs_HasHd1
|
2006-05-12 14:47:52 +02:00
|
|
|
|
db 'hd1',0
|
2006-05-05 14:40:02 +02:00
|
|
|
|
dd fs_HasHd2
|
2006-05-12 14:47:52 +02:00
|
|
|
|
db 'hd2',0
|
2006-05-05 14:40:02 +02:00
|
|
|
|
dd fs_HasHd3
|
2006-05-12 14:47:52 +02:00
|
|
|
|
db 'hd3',0
|
2006-06-18 18:42:03 +02:00
|
|
|
|
;**********************************************
|
|
|
|
|
dd fs_HasCd0
|
|
|
|
|
db 'cd0',0
|
|
|
|
|
dd fs_HasCd1
|
|
|
|
|
db 'cd1',0
|
|
|
|
|
dd fs_HasCd2
|
|
|
|
|
db 'cd2',0
|
|
|
|
|
dd fs_HasCd3
|
|
|
|
|
db 'cd3',0
|
|
|
|
|
;**********************************************
|
2006-05-05 14:40:02 +02:00
|
|
|
|
dd 0
|
2006-04-24 16:28:05 +02:00
|
|
|
|
endg
|
|
|
|
|
|
2007-05-11 21:38:23 +02:00
|
|
|
|
end_of_file_system_lfn:
|
|
|
|
|
pop edx
|
2007-05-24 09:36:48 +02:00
|
|
|
|
stdcall kernel_free, edx
|
2007-05-11 21:38:23 +02:00
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
2006-04-24 16:28:05 +02:00
|
|
|
|
file_system_lfn:
|
|
|
|
|
; in: eax->fileinfo block
|
|
|
|
|
; operation codes:
|
2006-04-27 08:12:46 +02:00
|
|
|
|
; 0 : read file
|
2006-05-05 14:40:02 +02:00
|
|
|
|
; 1 : read folder
|
2006-05-30 09:32:30 +02:00
|
|
|
|
; 2 : create/rewrite file
|
2006-08-21 15:06:02 +02:00
|
|
|
|
; 3 : write/append to file
|
|
|
|
|
; 4 : set end of file
|
2006-06-15 15:13:03 +02:00
|
|
|
|
; 5 : get file/directory attributes structure
|
|
|
|
|
; 6 : set file/directory attributes structure
|
2006-06-26 14:13:58 +02:00
|
|
|
|
; 7 : start application
|
2006-10-09 14:34:00 +02:00
|
|
|
|
; 8 : delete file
|
2007-02-05 15:20:36 +01:00
|
|
|
|
; 9 : create directory
|
2006-04-24 16:28:05 +02:00
|
|
|
|
|
2007-05-11 21:38:23 +02:00
|
|
|
|
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2007-05-24 09:36:48 +02:00
|
|
|
|
push eax
|
2007-05-11 21:38:23 +02:00
|
|
|
|
stdcall kernel_alloc, 200
|
2007-05-24 09:36:48 +02:00
|
|
|
|
mov edx,eax
|
|
|
|
|
pop eax
|
|
|
|
|
|
2007-05-11 21:38:23 +02:00
|
|
|
|
push edx
|
|
|
|
|
push end_of_file_system_lfn
|
2007-05-24 09:36:48 +02:00
|
|
|
|
mov ebx,edx
|
2007-05-11 21:38:23 +02:00
|
|
|
|
|
2007-05-24 09:36:48 +02:00
|
|
|
|
mov ecx, [eax]
|
|
|
|
|
mov [ebx],ecx
|
2007-05-11 21:38:23 +02:00
|
|
|
|
|
2007-05-24 09:36:48 +02:00
|
|
|
|
add ebx,4
|
|
|
|
|
mov ecx, [eax+4]
|
|
|
|
|
mov [ebx],ecx
|
2007-05-11 21:38:23 +02:00
|
|
|
|
|
2007-05-24 09:36:48 +02:00
|
|
|
|
add ebx,4
|
|
|
|
|
mov ecx, [eax+8]
|
|
|
|
|
mov [ebx],ecx
|
2007-05-11 21:38:23 +02:00
|
|
|
|
|
2007-05-24 09:36:48 +02:00
|
|
|
|
add ebx,4
|
|
|
|
|
mov ecx, [eax+12]
|
|
|
|
|
mov [ebx],ecx
|
2007-05-11 21:38:23 +02:00
|
|
|
|
|
2007-05-24 09:36:48 +02:00
|
|
|
|
add ebx,4
|
|
|
|
|
mov ecx, [eax+16]
|
|
|
|
|
mov [ebx],ecx
|
|
|
|
|
|
|
|
|
|
add ebx,4
|
2007-05-11 21:38:23 +02:00
|
|
|
|
push edx ; !!!!!!!!!!!!!!!!!!!
|
|
|
|
|
; eax - y<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
; edx - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2007-05-24 09:36:48 +02:00
|
|
|
|
; ebx - <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2007-05-11 21:38:23 +02:00
|
|
|
|
add eax,20
|
|
|
|
|
mov cl, [eax]
|
|
|
|
|
test cl,cl
|
|
|
|
|
jnz @f
|
|
|
|
|
mov eax,[eax+1]
|
|
|
|
|
@@:
|
|
|
|
|
stdcall full_file_name,eax,ebx
|
|
|
|
|
pop eax
|
2007-05-24 09:36:48 +02:00
|
|
|
|
|
2007-05-11 21:38:23 +02:00
|
|
|
|
|
|
|
|
|
|
2007-04-18 08:37:14 +02:00
|
|
|
|
; add eax, std_application_base_address
|
2006-04-24 16:28:05 +02:00
|
|
|
|
; parse file name
|
2006-05-05 14:40:02 +02:00
|
|
|
|
xchg ebx, eax
|
|
|
|
|
lea esi, [ebx+20]
|
2006-06-26 14:13:58 +02:00
|
|
|
|
mov ebp, esi ; for 'start app' function full path must be known
|
2006-05-05 14:40:02 +02:00
|
|
|
|
lodsb
|
2006-06-02 16:59:59 +02:00
|
|
|
|
test al, al
|
|
|
|
|
jnz @f
|
|
|
|
|
mov esi, [esi]
|
2007-04-18 08:37:14 +02:00
|
|
|
|
; add esi, std_application_base_address
|
2006-06-26 14:13:58 +02:00
|
|
|
|
mov ebp, esi
|
2006-06-02 16:59:59 +02:00
|
|
|
|
lodsb
|
2006-12-17 07:22:59 +01:00
|
|
|
|
@@:
|
|
|
|
|
cmp dword [ebx], 7
|
|
|
|
|
jne @F
|
|
|
|
|
mov edx, [ebx+4]
|
|
|
|
|
mov ebx, [ebx+8]
|
|
|
|
|
test ebx, ebx
|
|
|
|
|
jz .l1
|
2007-04-18 08:37:14 +02:00
|
|
|
|
; add ebx, new_app_base
|
2006-12-17 07:22:59 +01:00
|
|
|
|
.l1:
|
|
|
|
|
call fs_execute ; ebp, ebx, edx
|
2007-05-11 21:38:23 +02:00
|
|
|
|
mov [image_of_eax], eax
|
2006-12-17 07:22:59 +01:00
|
|
|
|
ret
|
2006-06-02 16:59:59 +02:00
|
|
|
|
@@:
|
2006-05-05 14:40:02 +02:00
|
|
|
|
cmp al, '/'
|
|
|
|
|
jz @f
|
2006-04-24 16:28:05 +02:00
|
|
|
|
.notfound:
|
2007-05-11 21:38:23 +02:00
|
|
|
|
mov dword [image_of_eax], 5 ; file not found
|
2006-05-05 14:40:02 +02:00
|
|
|
|
ret
|
2006-04-24 16:28:05 +02:00
|
|
|
|
@@:
|
2006-05-05 14:40:02 +02:00
|
|
|
|
cmp byte [esi], 0
|
|
|
|
|
jz .rootdir
|
|
|
|
|
mov edi, rootdirs-8
|
|
|
|
|
xor ecx, ecx
|
|
|
|
|
push esi
|
2006-04-24 16:28:05 +02:00
|
|
|
|
.scan1:
|
2006-05-05 14:40:02 +02:00
|
|
|
|
pop esi
|
|
|
|
|
add edi, ecx
|
|
|
|
|
scasd
|
|
|
|
|
scasd
|
|
|
|
|
mov cl, byte [edi]
|
|
|
|
|
jecxz .notfound
|
|
|
|
|
inc edi
|
|
|
|
|
push esi
|
2006-04-24 16:28:05 +02:00
|
|
|
|
@@:
|
2006-05-05 14:40:02 +02:00
|
|
|
|
lodsb
|
|
|
|
|
or al, 20h
|
|
|
|
|
scasb
|
|
|
|
|
loopz @b
|
|
|
|
|
jnz .scan1
|
|
|
|
|
lodsb
|
|
|
|
|
cmp al, '/'
|
|
|
|
|
jz .found1
|
|
|
|
|
test al, al
|
|
|
|
|
jnz .scan1
|
|
|
|
|
pop eax
|
2006-04-24 16:28:05 +02:00
|
|
|
|
; directory /xxx
|
|
|
|
|
.maindir:
|
2006-05-05 14:40:02 +02:00
|
|
|
|
cmp dword [ebx], 1
|
|
|
|
|
jnz .access_denied
|
|
|
|
|
xor eax, eax
|
|
|
|
|
mov ebp, [ebx+12]
|
|
|
|
|
mov edx, [ebx+16]
|
2007-04-18 08:37:14 +02:00
|
|
|
|
; add edx, std_application_base_address
|
2006-05-12 14:47:52 +02:00
|
|
|
|
push dword [ebx+4] ; first block
|
|
|
|
|
mov ebx, [ebx+8] ; flags
|
2006-05-05 14:40:02 +02:00
|
|
|
|
mov esi, [edi+4]
|
2006-05-12 14:47:52 +02:00
|
|
|
|
; ebx=flags, [esp]=first block, ebp=number of blocks, edx=return area, esi='Next' handler
|
2006-05-05 14:40:02 +02:00
|
|
|
|
mov edi, edx
|
|
|
|
|
mov ecx, 32/4
|
|
|
|
|
rep stosd
|
|
|
|
|
mov byte [edx], 1 ; version
|
|
|
|
|
.maindir_loop:
|
|
|
|
|
call esi
|
|
|
|
|
jc .maindir_done
|
|
|
|
|
inc dword [edx+8]
|
2006-05-12 14:47:52 +02:00
|
|
|
|
dec dword [esp]
|
2006-05-05 14:40:02 +02:00
|
|
|
|
jns .maindir_loop
|
|
|
|
|
dec ebp
|
|
|
|
|
js .maindir_loop
|
|
|
|
|
inc dword [edx+4]
|
|
|
|
|
mov dword [edi], 0x10 ; attributes: folder
|
|
|
|
|
mov dword [edi+4], 1 ; name type: UNICODE
|
|
|
|
|
push eax
|
|
|
|
|
xor eax, eax
|
|
|
|
|
add edi, 8
|
|
|
|
|
mov ecx, 40/4-2
|
|
|
|
|
rep stosd
|
|
|
|
|
pop eax
|
|
|
|
|
push eax edx
|
|
|
|
|
; convert number in eax to decimal UNICODE string
|
|
|
|
|
push edi
|
|
|
|
|
push -'0'
|
|
|
|
|
mov cl, 10
|
|
|
|
|
@@:
|
|
|
|
|
xor edx, edx
|
|
|
|
|
div ecx
|
|
|
|
|
push edx
|
|
|
|
|
test eax, eax
|
|
|
|
|
jnz @b
|
|
|
|
|
@@:
|
|
|
|
|
pop eax
|
|
|
|
|
add al, '0'
|
2006-05-12 14:47:52 +02:00
|
|
|
|
stosb
|
|
|
|
|
test bl, 1 ; UNICODE name?
|
|
|
|
|
jz .ansi2
|
|
|
|
|
mov byte [edi], 0
|
|
|
|
|
inc edi
|
|
|
|
|
.ansi2:
|
|
|
|
|
test al, al
|
2006-05-05 14:40:02 +02:00
|
|
|
|
jnz @b
|
|
|
|
|
mov byte [edi-1], 0
|
|
|
|
|
pop edi
|
2006-05-12 14:47:52 +02:00
|
|
|
|
; UNICODE name length is 520 bytes, ANSI - 264
|
2006-05-05 14:40:02 +02:00
|
|
|
|
add edi, 520
|
2006-05-12 14:47:52 +02:00
|
|
|
|
test bl, 1
|
|
|
|
|
jnz @f
|
|
|
|
|
sub edi, 520-264
|
|
|
|
|
@@:
|
2006-05-05 14:40:02 +02:00
|
|
|
|
pop edx eax
|
|
|
|
|
jmp .maindir_loop
|
|
|
|
|
.maindir_done:
|
2006-05-12 14:47:52 +02:00
|
|
|
|
pop eax
|
|
|
|
|
mov ebx, [edx+4]
|
2006-05-05 14:40:02 +02:00
|
|
|
|
xor eax, eax
|
|
|
|
|
dec ebp
|
|
|
|
|
js @f
|
|
|
|
|
mov al, ERROR_END_OF_FILE
|
|
|
|
|
@@:
|
2007-05-11 21:38:23 +02:00
|
|
|
|
mov [image_of_eax], eax
|
|
|
|
|
mov [image_of_ebx], ebx
|
2006-05-05 14:40:02 +02:00
|
|
|
|
ret
|
2006-04-24 16:28:05 +02:00
|
|
|
|
; directory /
|
|
|
|
|
.rootdir:
|
2006-05-05 14:40:02 +02:00
|
|
|
|
cmp dword [ebx], 1 ; read folder?
|
|
|
|
|
jz .readroot
|
|
|
|
|
.access_denied:
|
2007-05-11 21:38:23 +02:00
|
|
|
|
mov dword [image_of_eax], 10 ; access denied
|
2006-05-05 14:40:02 +02:00
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
.readroot:
|
|
|
|
|
; virtual root folder - special handler
|
|
|
|
|
mov esi, virtual_root_query
|
|
|
|
|
mov ebp, [ebx+12]
|
|
|
|
|
mov edx, [ebx+16]
|
2007-04-18 08:37:14 +02:00
|
|
|
|
; add edx, std_application_base_address
|
2006-05-12 14:47:52 +02:00
|
|
|
|
push dword [ebx+4] ; first block
|
|
|
|
|
mov ebx, [ebx+8] ; flags
|
2006-05-05 14:40:02 +02:00
|
|
|
|
xor eax, eax
|
2006-05-12 14:47:52 +02:00
|
|
|
|
; eax=0, [esp]=first block, ebx=flags, ebp=number of blocks, edx=return area
|
2006-05-05 14:40:02 +02:00
|
|
|
|
mov edi, edx
|
|
|
|
|
mov ecx, 32/4
|
|
|
|
|
rep stosd
|
|
|
|
|
mov byte [edx], 1 ; version
|
|
|
|
|
.readroot_loop:
|
|
|
|
|
cmp dword [esi], eax
|
|
|
|
|
jz .readroot_done
|
|
|
|
|
call dword [esi]
|
|
|
|
|
add esi, 4
|
|
|
|
|
test eax, eax
|
|
|
|
|
jnz @f
|
|
|
|
|
.readroot_next:
|
|
|
|
|
or ecx, -1
|
|
|
|
|
xchg esi, edi
|
2006-05-12 14:47:52 +02:00
|
|
|
|
repnz scasb
|
2006-05-05 14:40:02 +02:00
|
|
|
|
xchg esi, edi
|
|
|
|
|
jmp .readroot_loop
|
|
|
|
|
@@:
|
|
|
|
|
xor eax, eax
|
|
|
|
|
inc dword [edx+8]
|
2006-05-12 14:47:52 +02:00
|
|
|
|
dec dword [esp]
|
2006-05-05 14:40:02 +02:00
|
|
|
|
jns .readroot_next
|
|
|
|
|
dec ebp
|
|
|
|
|
js .readroot_next
|
|
|
|
|
inc dword [edx+4]
|
|
|
|
|
mov dword [edi], 0x10 ; attributes: folder
|
|
|
|
|
mov dword [edi+4], 1 ; name type: UNICODE
|
|
|
|
|
add edi, 8
|
|
|
|
|
mov ecx, 40/4-2
|
|
|
|
|
rep stosd
|
|
|
|
|
push edi
|
|
|
|
|
@@:
|
2006-05-12 14:47:52 +02:00
|
|
|
|
lodsb
|
|
|
|
|
stosb
|
|
|
|
|
test bl, 1
|
|
|
|
|
jz .ansi
|
|
|
|
|
mov byte [edi], 0
|
|
|
|
|
inc edi
|
|
|
|
|
.ansi:
|
2006-05-05 14:40:02 +02:00
|
|
|
|
test eax, eax
|
|
|
|
|
jnz @b
|
|
|
|
|
pop edi
|
|
|
|
|
add edi, 520
|
2006-05-12 14:47:52 +02:00
|
|
|
|
test bl, 1
|
|
|
|
|
jnz .readroot_loop
|
|
|
|
|
sub edi, 520-264
|
2006-05-05 14:40:02 +02:00
|
|
|
|
jmp .readroot_loop
|
|
|
|
|
.readroot_done:
|
2006-05-12 14:47:52 +02:00
|
|
|
|
pop eax
|
|
|
|
|
mov ebx, [edx+4]
|
2006-05-05 14:40:02 +02:00
|
|
|
|
xor eax, eax
|
|
|
|
|
dec ebp
|
|
|
|
|
js @f
|
|
|
|
|
mov al, ERROR_END_OF_FILE
|
|
|
|
|
@@:
|
2007-05-11 21:38:23 +02:00
|
|
|
|
mov [image_of_eax], eax
|
|
|
|
|
mov [image_of_ebx], ebx
|
2006-05-05 14:40:02 +02:00
|
|
|
|
ret
|
2006-04-24 16:28:05 +02:00
|
|
|
|
|
|
|
|
|
.found1:
|
2006-05-05 14:40:02 +02:00
|
|
|
|
pop eax
|
|
|
|
|
cmp byte [esi], 0
|
|
|
|
|
jz .maindir
|
2006-04-24 16:28:05 +02:00
|
|
|
|
; read partition number
|
2006-05-05 14:40:02 +02:00
|
|
|
|
xor ecx, ecx
|
|
|
|
|
xor eax, eax
|
2006-04-24 16:28:05 +02:00
|
|
|
|
@@:
|
2006-05-05 14:40:02 +02:00
|
|
|
|
lodsb
|
|
|
|
|
cmp al, '/'
|
|
|
|
|
jz .done1
|
|
|
|
|
test al, al
|
|
|
|
|
jz .done1
|
|
|
|
|
sub al, '0'
|
|
|
|
|
cmp al, 9
|
|
|
|
|
ja .notfound
|
|
|
|
|
imul ecx, 10
|
|
|
|
|
add ecx, eax
|
|
|
|
|
jmp @b
|
2006-04-24 16:28:05 +02:00
|
|
|
|
.done1:
|
2006-05-05 14:40:02 +02:00
|
|
|
|
test ecx, ecx
|
|
|
|
|
jz .notfound
|
|
|
|
|
test al, al
|
|
|
|
|
jnz @f
|
|
|
|
|
dec esi
|
2006-04-24 16:28:05 +02:00
|
|
|
|
@@:
|
2006-05-05 14:40:02 +02:00
|
|
|
|
; now [edi] contains handler address, ecx - partition number,
|
|
|
|
|
; esi points to ASCIIZ string - rest of name
|
|
|
|
|
jmp dword [edi]
|
2006-04-24 16:28:05 +02:00
|
|
|
|
|
|
|
|
|
; handlers for devices
|
2006-05-05 14:40:02 +02:00
|
|
|
|
; in: ecx = 0 => query virtual directory /xxx
|
2006-04-24 16:28:05 +02:00
|
|
|
|
; in: ecx = partition number
|
|
|
|
|
; esi -> relative (for device) name
|
|
|
|
|
; ebx -> fileinfo
|
2007-05-11 21:38:23 +02:00
|
|
|
|
; out: [image_of_eax]=image of eax, [image_of_ebx]=image of ebx
|
2006-04-24 16:28:05 +02:00
|
|
|
|
|
|
|
|
|
fs_OnRamdisk:
|
2006-05-05 14:40:02 +02:00
|
|
|
|
cmp ecx, 1
|
|
|
|
|
jnz file_system_lfn.notfound
|
|
|
|
|
mov eax, [ebx]
|
2006-05-30 09:32:30 +02:00
|
|
|
|
cmp eax, fs_NumRamdiskServices
|
|
|
|
|
jae .not_impl
|
2006-05-05 14:40:02 +02:00
|
|
|
|
mov ecx, [ebx+12]
|
|
|
|
|
mov edx, [ebx+16]
|
2007-04-18 08:37:14 +02:00
|
|
|
|
; add edx, std_application_base_address
|
2006-05-05 14:40:02 +02:00
|
|
|
|
add ebx, 4
|
|
|
|
|
call dword [fs_RamdiskServices + eax*4]
|
2007-05-11 21:38:23 +02:00
|
|
|
|
mov [image_of_eax], eax
|
|
|
|
|
mov [image_of_ebx], ebx
|
2006-05-05 14:40:02 +02:00
|
|
|
|
ret
|
2006-04-24 16:28:05 +02:00
|
|
|
|
.not_impl:
|
2007-05-11 21:38:23 +02:00
|
|
|
|
mov dword [image_of_eax], 2 ; not implemented
|
2006-05-05 14:40:02 +02:00
|
|
|
|
ret
|
2006-04-24 16:28:05 +02:00
|
|
|
|
|
2006-06-15 15:13:03 +02:00
|
|
|
|
fs_NotImplemented:
|
|
|
|
|
mov eax, 2
|
|
|
|
|
ret
|
|
|
|
|
|
2006-04-24 16:28:05 +02:00
|
|
|
|
fs_RamdiskServices:
|
2006-05-05 14:40:02 +02:00
|
|
|
|
dd fs_RamdiskRead
|
|
|
|
|
dd fs_RamdiskReadFolder
|
2006-05-30 09:32:30 +02:00
|
|
|
|
dd fs_RamdiskRewrite
|
2006-08-18 15:32:18 +02:00
|
|
|
|
dd fs_RamdiskWrite
|
2006-08-21 15:06:02 +02:00
|
|
|
|
dd fs_RamdiskSetFileEnd
|
2006-06-15 15:13:03 +02:00
|
|
|
|
dd fs_RamdiskGetFileInfo
|
|
|
|
|
dd fs_RamdiskSetFileInfo
|
2007-02-05 15:20:36 +01:00
|
|
|
|
dd 0 ;fs_RamdiskExecute
|
2006-10-09 14:34:00 +02:00
|
|
|
|
dd fs_RamdiskDelete
|
2007-02-05 15:20:36 +01:00
|
|
|
|
dd fs_RamdiskCreateFolder
|
2006-05-30 09:32:30 +02:00
|
|
|
|
fs_NumRamdiskServices = ($ - fs_RamdiskServices)/4
|
2006-04-24 16:28:05 +02:00
|
|
|
|
|
|
|
|
|
fs_OnFloppy:
|
2006-05-05 14:40:02 +02:00
|
|
|
|
cmp ecx, 2
|
|
|
|
|
ja file_system_lfn.notfound
|
|
|
|
|
mov eax, [ebx]
|
2006-05-30 09:32:30 +02:00
|
|
|
|
cmp eax, fs_NumFloppyServices
|
|
|
|
|
jae fs_OnRamdisk.not_impl
|
2006-05-05 14:40:02 +02:00
|
|
|
|
call reserve_flp
|
|
|
|
|
mov [flp_number], cl
|
|
|
|
|
mov ecx, [ebx+12]
|
|
|
|
|
mov edx, [ebx+16]
|
2007-04-18 08:37:14 +02:00
|
|
|
|
; add edx, std_application_base_address
|
2006-05-05 14:40:02 +02:00
|
|
|
|
add ebx, 4
|
|
|
|
|
call dword [fs_FloppyServices + eax*4]
|
|
|
|
|
and [flp_status], 0
|
2007-05-11 21:38:23 +02:00
|
|
|
|
mov [image_of_eax], eax
|
|
|
|
|
mov [image_of_ebx], ebx
|
2006-05-05 14:40:02 +02:00
|
|
|
|
ret
|
2006-04-24 16:28:05 +02:00
|
|
|
|
|
|
|
|
|
fs_FloppyServices:
|
2006-05-05 14:40:02 +02:00
|
|
|
|
dd fs_FloppyRead
|
|
|
|
|
dd fs_FloppyReadFolder
|
2006-05-30 09:32:30 +02:00
|
|
|
|
dd fs_FloppyRewrite
|
2006-08-18 15:32:18 +02:00
|
|
|
|
dd fs_FloppyWrite
|
2006-08-21 15:06:02 +02:00
|
|
|
|
dd fs_FloppySetFileEnd
|
2006-06-15 15:13:03 +02:00
|
|
|
|
dd fs_FloppyGetFileInfo
|
|
|
|
|
dd fs_FloppySetFileInfo
|
2007-02-05 15:20:36 +01:00
|
|
|
|
dd 0 ;fs_FloppyExecute
|
2006-10-09 14:34:00 +02:00
|
|
|
|
dd fs_FloppyDelete
|
2007-02-05 15:20:36 +01:00
|
|
|
|
dd fs_FloppyCreateFolder
|
2006-05-30 09:32:30 +02:00
|
|
|
|
fs_NumFloppyServices = ($ - fs_FloppyServices)/4
|
2006-04-24 16:28:05 +02:00
|
|
|
|
|
|
|
|
|
fs_OnHd0:
|
2006-05-05 14:40:02 +02:00
|
|
|
|
call reserve_hd1
|
|
|
|
|
mov [hdbase], 0x1F0
|
|
|
|
|
mov [hdid], 0
|
|
|
|
|
push 1
|
|
|
|
|
jmp fs_OnHd
|
2006-04-24 16:28:05 +02:00
|
|
|
|
fs_OnHd1:
|
2006-05-05 14:40:02 +02:00
|
|
|
|
call reserve_hd1
|
|
|
|
|
mov [hdbase], 0x1F0
|
|
|
|
|
mov [hdid], 0x10
|
|
|
|
|
push 2
|
|
|
|
|
jmp fs_OnHd
|
2006-04-24 16:28:05 +02:00
|
|
|
|
fs_OnHd2:
|
2006-05-05 14:40:02 +02:00
|
|
|
|
call reserve_hd1
|
|
|
|
|
mov [hdbase], 0x170
|
|
|
|
|
mov [hdid], 0
|
|
|
|
|
push 3
|
|
|
|
|
jmp fs_OnHd
|
2006-04-24 16:28:05 +02:00
|
|
|
|
fs_OnHd3:
|
2006-05-05 14:40:02 +02:00
|
|
|
|
call reserve_hd1
|
|
|
|
|
mov [hdbase], 0x170
|
|
|
|
|
mov [hdid], 0x10
|
|
|
|
|
push 4
|
2006-04-24 16:28:05 +02:00
|
|
|
|
fs_OnHd:
|
2006-07-05 18:54:34 +02:00
|
|
|
|
call reserve_hd_channel
|
2006-05-05 14:40:02 +02:00
|
|
|
|
pop eax
|
|
|
|
|
mov [hdpos], eax
|
|
|
|
|
cmp ecx, 0x100
|
|
|
|
|
jae .nf
|
2007-03-20 05:36:16 +01:00
|
|
|
|
cmp cl, [DRIVE_DATA+1+eax]
|
2006-05-05 14:40:02 +02:00
|
|
|
|
jbe @f
|
|
|
|
|
.nf:
|
2006-07-05 18:54:34 +02:00
|
|
|
|
call free_hd_channel
|
2006-05-05 14:40:02 +02:00
|
|
|
|
and [hd1_status], 0
|
2007-05-11 21:38:23 +02:00
|
|
|
|
mov dword [image_of_eax], 5 ; not found
|
2006-05-05 14:40:02 +02:00
|
|
|
|
ret
|
2006-04-24 16:28:05 +02:00
|
|
|
|
@@:
|
2006-05-05 14:40:02 +02:00
|
|
|
|
mov [fat32part], ecx
|
|
|
|
|
push ebx esi
|
|
|
|
|
call choice_necessity_partition_1
|
|
|
|
|
pop esi ebx
|
|
|
|
|
mov ecx, [ebx+12]
|
|
|
|
|
mov edx, [ebx+16]
|
2007-04-18 08:37:14 +02:00
|
|
|
|
; add edx, std_application_base_address
|
2006-05-05 14:40:02 +02:00
|
|
|
|
mov eax, [ebx]
|
2006-05-30 09:32:30 +02:00
|
|
|
|
cmp eax, fs_NumHdServices
|
|
|
|
|
jae .not_impl
|
2006-05-05 14:40:02 +02:00
|
|
|
|
add ebx, 4
|
|
|
|
|
call dword [fs_HdServices + eax*4]
|
2006-07-05 18:54:34 +02:00
|
|
|
|
call free_hd_channel
|
2006-05-05 14:40:02 +02:00
|
|
|
|
and [hd1_status], 0
|
2007-05-11 21:38:23 +02:00
|
|
|
|
mov [image_of_eax], eax
|
|
|
|
|
mov [image_of_ebx], ebx
|
2006-05-05 14:40:02 +02:00
|
|
|
|
ret
|
|
|
|
|
.not_impl:
|
2006-07-05 18:54:34 +02:00
|
|
|
|
call free_hd_channel
|
2006-05-05 14:40:02 +02:00
|
|
|
|
and [hd1_status], 0
|
2007-05-11 21:38:23 +02:00
|
|
|
|
mov dword [image_of_eax], 2 ; not implemented
|
2006-05-05 14:40:02 +02:00
|
|
|
|
ret
|
2006-04-24 16:28:05 +02:00
|
|
|
|
|
|
|
|
|
fs_HdServices:
|
2006-05-05 14:40:02 +02:00
|
|
|
|
dd fs_HdRead
|
|
|
|
|
dd fs_HdReadFolder
|
2006-05-30 09:32:30 +02:00
|
|
|
|
dd fs_HdRewrite
|
2006-08-18 15:32:18 +02:00
|
|
|
|
dd fs_HdWrite
|
2006-08-21 15:06:02 +02:00
|
|
|
|
dd fs_HdSetFileEnd
|
2006-06-15 15:13:03 +02:00
|
|
|
|
dd fs_HdGetFileInfo
|
|
|
|
|
dd fs_HdSetFileInfo
|
2006-12-29 16:42:36 +01:00
|
|
|
|
dd 0 ;fs_HdExecute
|
2006-10-09 14:34:00 +02:00
|
|
|
|
dd fs_HdDelete
|
2007-02-05 15:20:36 +01:00
|
|
|
|
dd fs_HdCreateFolder
|
2006-05-30 09:32:30 +02:00
|
|
|
|
fs_NumHdServices = ($ - fs_HdServices)/4
|
2006-05-05 14:40:02 +02:00
|
|
|
|
|
2006-06-18 18:42:03 +02:00
|
|
|
|
;*******************************************************
|
|
|
|
|
fs_OnCd0:
|
|
|
|
|
call reserve_cd
|
|
|
|
|
mov [ChannelNumber],1
|
|
|
|
|
mov [DiskNumber],0
|
|
|
|
|
push 6
|
|
|
|
|
jmp fs_OnCd
|
|
|
|
|
fs_OnCd1:
|
|
|
|
|
call reserve_cd
|
|
|
|
|
mov [ChannelNumber],1
|
|
|
|
|
mov [DiskNumber],1
|
|
|
|
|
push 4
|
|
|
|
|
jmp fs_OnCd
|
|
|
|
|
fs_OnCd2:
|
|
|
|
|
call reserve_cd
|
|
|
|
|
mov [ChannelNumber],2
|
|
|
|
|
mov [DiskNumber],0
|
|
|
|
|
push 2
|
|
|
|
|
jmp fs_OnCd
|
|
|
|
|
fs_OnCd3:
|
|
|
|
|
call reserve_cd
|
|
|
|
|
mov [ChannelNumber],2
|
|
|
|
|
mov [DiskNumber],1
|
|
|
|
|
push 0
|
|
|
|
|
fs_OnCd:
|
2006-07-05 18:54:34 +02:00
|
|
|
|
call reserve_cd_channel
|
2006-06-18 18:42:03 +02:00
|
|
|
|
pop eax
|
|
|
|
|
mov [hdpos], eax
|
|
|
|
|
cmp ecx, 0x100
|
|
|
|
|
jae .nf
|
2006-08-21 15:06:02 +02:00
|
|
|
|
push ecx ebx
|
2006-06-18 18:42:03 +02:00
|
|
|
|
mov cl,al
|
2007-03-05 22:37:28 +01:00
|
|
|
|
mov bl,[DRIVE_DATA+1]
|
2006-06-18 18:42:03 +02:00
|
|
|
|
shr bl,cl
|
|
|
|
|
test bl,2
|
2006-08-21 15:06:02 +02:00
|
|
|
|
pop ebx ecx
|
2006-06-18 18:42:03 +02:00
|
|
|
|
|
|
|
|
|
jnz @f
|
|
|
|
|
.nf:
|
2006-07-05 18:54:34 +02:00
|
|
|
|
call free_cd_channel
|
2006-06-18 18:42:03 +02:00
|
|
|
|
and [cd_status], 0
|
2007-05-11 21:38:23 +02:00
|
|
|
|
mov dword [image_of_eax], 5 ; not found
|
2006-06-18 18:42:03 +02:00
|
|
|
|
ret
|
|
|
|
|
@@:
|
|
|
|
|
mov ecx, [ebx+12]
|
|
|
|
|
mov edx, [ebx+16]
|
2007-04-18 08:37:14 +02:00
|
|
|
|
; add edx, std_application_base_address
|
2006-06-18 18:42:03 +02:00
|
|
|
|
mov eax, [ebx]
|
2006-06-25 21:28:15 +02:00
|
|
|
|
cmp eax,fs_NumCdServices
|
|
|
|
|
jae .not_impl
|
2006-06-18 18:42:03 +02:00
|
|
|
|
add ebx, 4
|
|
|
|
|
call dword [fs_CdServices + eax*4]
|
2006-07-05 18:54:34 +02:00
|
|
|
|
call free_cd_channel
|
2006-06-18 18:42:03 +02:00
|
|
|
|
and [cd_status], 0
|
2007-05-11 21:38:23 +02:00
|
|
|
|
mov [image_of_eax], eax
|
|
|
|
|
mov [image_of_ebx], ebx
|
2006-06-18 18:42:03 +02:00
|
|
|
|
ret
|
|
|
|
|
.not_impl:
|
2006-07-05 18:54:34 +02:00
|
|
|
|
call free_cd_channel
|
2006-06-22 13:22:22 +02:00
|
|
|
|
and [cd_status], 0
|
2007-05-11 21:38:23 +02:00
|
|
|
|
mov dword [image_of_eax], 2 ; not implemented
|
2006-06-18 18:42:03 +02:00
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
fs_CdServices:
|
|
|
|
|
dd fs_CdRead
|
|
|
|
|
dd fs_CdReadFolder
|
2006-06-25 21:28:15 +02:00
|
|
|
|
dd fs_NotImplemented
|
|
|
|
|
dd fs_NotImplemented
|
|
|
|
|
dd fs_NotImplemented
|
|
|
|
|
dd fs_CdGetFileInfo
|
|
|
|
|
dd fs_NotImplemented
|
2006-07-01 17:55:47 +02:00
|
|
|
|
dd fs_CdExecute
|
2006-06-25 21:28:15 +02:00
|
|
|
|
fs_NumCdServices = ($ - fs_CdServices)/4
|
|
|
|
|
|
2006-06-18 18:42:03 +02:00
|
|
|
|
;*******************************************************
|
|
|
|
|
|
2006-05-05 14:40:02 +02:00
|
|
|
|
fs_HasRamdisk:
|
|
|
|
|
mov al, 1 ; we always have ramdisk
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
fs_HasFloppy:
|
2007-03-01 21:32:19 +01:00
|
|
|
|
cmp byte [DRIVE_DATA], 0
|
2006-05-05 14:40:02 +02:00
|
|
|
|
setnz al
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
fs_HasHd0:
|
2007-03-01 21:32:19 +01:00
|
|
|
|
mov al, [DRIVE_DATA+1]
|
2006-05-05 14:40:02 +02:00
|
|
|
|
and al, 11000000b
|
|
|
|
|
cmp al, 01000000b
|
|
|
|
|
setz al
|
|
|
|
|
ret
|
|
|
|
|
fs_HasHd1:
|
2007-03-01 21:32:19 +01:00
|
|
|
|
mov al, [DRIVE_DATA+1]
|
2006-05-05 14:40:02 +02:00
|
|
|
|
and al, 00110000b
|
|
|
|
|
cmp al, 00010000b
|
|
|
|
|
setz al
|
|
|
|
|
ret
|
|
|
|
|
fs_HasHd2:
|
2007-03-01 21:32:19 +01:00
|
|
|
|
mov al, [DRIVE_DATA+1]
|
2006-05-05 14:40:02 +02:00
|
|
|
|
and al, 00001100b
|
|
|
|
|
cmp al, 00000100b
|
|
|
|
|
setz al
|
|
|
|
|
ret
|
|
|
|
|
fs_HasHd3:
|
2007-03-01 21:32:19 +01:00
|
|
|
|
mov al, [DRIVE_DATA+1]
|
2006-05-05 14:40:02 +02:00
|
|
|
|
and al, 00000011b
|
|
|
|
|
cmp al, 00000001b
|
|
|
|
|
setz al
|
|
|
|
|
ret
|
|
|
|
|
|
2006-06-18 18:42:03 +02:00
|
|
|
|
;*******************************************************
|
|
|
|
|
fs_HasCd0:
|
2007-03-01 21:32:19 +01:00
|
|
|
|
mov al, [DRIVE_DATA+1]
|
2006-06-18 18:42:03 +02:00
|
|
|
|
and al, 11000000b
|
|
|
|
|
cmp al, 10000000b
|
|
|
|
|
setz al
|
|
|
|
|
ret
|
|
|
|
|
fs_HasCd1:
|
2007-03-01 21:32:19 +01:00
|
|
|
|
mov al, [DRIVE_DATA+1]
|
2006-06-18 18:42:03 +02:00
|
|
|
|
and al, 00110000b
|
|
|
|
|
cmp al, 00100000b
|
|
|
|
|
setz al
|
|
|
|
|
ret
|
|
|
|
|
fs_HasCd2:
|
2007-03-01 21:32:19 +01:00
|
|
|
|
mov al, [DRIVE_DATA+1]
|
2006-06-18 18:42:03 +02:00
|
|
|
|
and al, 00001100b
|
|
|
|
|
cmp al, 00001000b
|
|
|
|
|
setz al
|
|
|
|
|
ret
|
|
|
|
|
fs_HasCd3:
|
2007-03-01 21:32:19 +01:00
|
|
|
|
mov al, [DRIVE_DATA+1]
|
2006-06-18 18:42:03 +02:00
|
|
|
|
and al, 00000011b
|
|
|
|
|
cmp al, 00000010b
|
|
|
|
|
setz al
|
|
|
|
|
ret
|
2006-12-17 07:22:59 +01:00
|
|
|
|
;*******************************************************
|
2006-06-18 18:42:03 +02:00
|
|
|
|
|
2006-05-05 14:40:02 +02:00
|
|
|
|
; fs_NextXXX functions:
|
|
|
|
|
; in: eax = partition number, from which start to scan
|
|
|
|
|
; out: CF=1 => no more partitions
|
|
|
|
|
; CF=0 => eax=next partition number
|
|
|
|
|
|
|
|
|
|
fs_NextRamdisk:
|
|
|
|
|
; we always have /rd/1
|
|
|
|
|
test eax, eax
|
|
|
|
|
stc
|
|
|
|
|
jnz @f
|
|
|
|
|
mov al, 1
|
|
|
|
|
clc
|
|
|
|
|
@@:
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
fs_NextFloppy:
|
2007-03-01 21:32:19 +01:00
|
|
|
|
; we have /fd/1 iff (([DRIVE_DATA] and 0xF0) != 0) and /fd/2 iff (([DRIVE_DATA] and 0x0F) != 0)
|
|
|
|
|
test byte [DRIVE_DATA], 0xF0
|
2006-05-05 14:40:02 +02:00
|
|
|
|
jz .no1
|
|
|
|
|
test eax, eax
|
|
|
|
|
jnz .no1
|
|
|
|
|
inc eax
|
|
|
|
|
ret ; CF cleared
|
|
|
|
|
.no1:
|
2007-03-01 21:32:19 +01:00
|
|
|
|
test byte [DRIVE_DATA], 0x0F
|
2006-05-05 14:40:02 +02:00
|
|
|
|
jz .no2
|
|
|
|
|
cmp al, 2
|
|
|
|
|
jae .no2
|
|
|
|
|
mov al, 2
|
|
|
|
|
clc
|
|
|
|
|
ret
|
|
|
|
|
.no2:
|
|
|
|
|
stc
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
; on hdx, we have partitions from 1 to [0x40002+x]
|
|
|
|
|
fs_NextHd0:
|
|
|
|
|
push 0
|
|
|
|
|
jmp fs_NextHd
|
|
|
|
|
fs_NextHd1:
|
|
|
|
|
push 1
|
|
|
|
|
jmp fs_NextHd
|
|
|
|
|
fs_NextHd2:
|
|
|
|
|
push 2
|
|
|
|
|
jmp fs_NextHd
|
|
|
|
|
fs_NextHd3:
|
|
|
|
|
push 3
|
|
|
|
|
fs_NextHd:
|
|
|
|
|
pop ecx
|
2007-03-01 21:32:19 +01:00
|
|
|
|
movzx ecx, byte [DRIVE_DATA+2+ecx]
|
2006-05-05 14:40:02 +02:00
|
|
|
|
cmp eax, ecx
|
|
|
|
|
jae fs_NextFloppy.no2
|
|
|
|
|
inc eax
|
|
|
|
|
clc
|
|
|
|
|
ret
|
2006-12-17 07:22:59 +01:00
|
|
|
|
|
2006-06-18 18:42:03 +02:00
|
|
|
|
;*******************************************************
|
|
|
|
|
fs_NextCd:
|
|
|
|
|
; we always have /cdX/1
|
|
|
|
|
test eax, eax
|
|
|
|
|
stc
|
|
|
|
|
jnz @f
|
|
|
|
|
mov al, 1
|
|
|
|
|
clc
|
|
|
|
|
@@:
|
|
|
|
|
ret
|
|
|
|
|
;*******************************************************
|
|
|
|
|
|