fs: prevalidation for root folder, code despaghettizing

git-svn-id: svn://kolibrios.org@6845 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
pathoswithin 2017-01-22 16:19:39 +00:00
parent e828b2c8b5
commit 201a5bf041
5 changed files with 193 additions and 347 deletions

View File

@ -1393,10 +1393,16 @@ dyndisk_handler:
; 11c. Let the procedure from fs_lfn.inc do the job. ; 11c. Let the procedure from fs_lfn.inc do the job.
jmp file_system_lfn.maindir_noesi jmp file_system_lfn.maindir_noesi
.root:
pop ecx edx
xor eax, eax
cmp byte [ebx], 9
jz .cleanup_ecx
.access_denied: .access_denied:
mov dword [esp+32], ERROR_ACCESS_DENIED movi eax, ERROR_ACCESS_DENIED
.cleanup_ecx:
mov [esp+32], eax
mov esi, ecx ; disk*dereference assume that esi points to DISK mov esi, ecx ; disk*dereference assume that esi points to DISK
.cleanup_esi:
test edx, edx ; if there are no media, we didn't reference it test edx, edx ; if there are no media, we didn't reference it
jz @f jz @f
call disk_media_dereference call disk_media_dereference
@ -1406,15 +1412,13 @@ dyndisk_handler:
ret ret
.dyndisk_cleanup: .dyndisk_cleanup:
pop esi pop ecx edx
pop edx movi eax, ERROR_FILE_NOT_FOUND
mov dword [esp+32], ERROR_FILE_NOT_FOUND jmp .cleanup_ecx
jmp .cleanup_esi
.haspartition: .haspartition:
; 12. The fs operation has specified some partition. ; 12. The fs operation has specified some partition.
push edx push edx ecx
push ecx
xor eax, eax xor eax, eax
lodsb lodsb
sub eax, '0' sub eax, '0'
@ -1428,6 +1432,13 @@ dyndisk_handler:
test eax, eax test eax, eax
jnz .dyndisk_cleanup jnz .dyndisk_cleanup
dec esi dec esi
@@:
cmp byte [esi], 0
jnz @f
cmp byte [ebx], 1
jz @f
cmp byte [ebx], 5
jnz .root
@@: @@:
dec ecx ; convert to zero-based partition index dec ecx ; convert to zero-based partition index
pop edx ; edx = pointer to DISK, dword [esp] = NULL or edx pop edx ; edx = pointer to DISK, dword [esp] = NULL or edx
@ -1479,9 +1490,9 @@ dyndisk_handler:
call dword [edi+8+ecx*4] call dword [edi+8+ecx*4]
pop ebp pop ebp
pop edx pop edx
mov dword [esp+32], eax
mov dword [esp+20], ebx mov dword [esp+20], ebx
.cleanup: .cleanup:
mov dword [esp+32], eax
mov esi, edx mov esi, edx
call disk_media_dereference call disk_media_dereference
@@: @@:
@ -1490,14 +1501,14 @@ dyndisk_handler:
ret ret
.unsupported: .unsupported:
mov dword [esp+32], ERROR_UNKNOWN_FS movi eax, ERROR_UNKNOWN_FS
cmp edi, default_fs_functions cmp edi, default_fs_functions
jz .cleanup jz .cleanup
mov dword [esp+32], ERROR_UNSUPPORTED_FS movi eax, ERROR_UNSUPPORTED_FS
jmp .cleanup jmp .cleanup
.notfound2: .notfound2:
mov dword [esp+32], ERROR_FILE_NOT_FOUND movi eax, ERROR_FILE_NOT_FOUND
jmp .cleanup jmp .cleanup
.nomedia: .nomedia:

View File

@ -1753,9 +1753,6 @@ writeSuperblock:
ret ret
extfsWritingInit: extfsWritingInit:
movi eax, ERROR_ACCESS_DENIED
cmp byte [esi], 0
jz @f
movi eax, ERROR_UNSUPPORTED_FS movi eax, ERROR_UNSUPPORTED_FS
test [ebp+EXTFS.mountType], READ_ONLY test [ebp+EXTFS.mountType], READ_ONLY
jnz @f jnz @f
@ -1987,10 +1984,7 @@ ext_ReadFolder:
;---------------------------------------------------------------- ;----------------------------------------------------------------
ext_ReadFile: ext_ReadFile:
call ext_lock call ext_lock
pushd 0 ERROR_ACCESS_DENIED pushd 0 ebx
cmp byte [esi], 0
jz .ret ; root
mov [esp], ebx
call findInode call findInode
pop ebx pop ebx
push eax push eax

View File

@ -1525,34 +1525,12 @@ hd_find_lfn:
fat_Read: fat_Read:
call fat_lock call fat_lock
push edi push edi
cmp byte [esi], 0
jnz @f
.noaccess:
pop edi
call fat_unlock
or ebx, -1
mov eax, ERROR_ACCESS_DENIED
ret
@@:
call hd_find_lfn call hd_find_lfn
jnc .found jc .notFound
pop edi
push eax
call fat_unlock
pop eax
or ebx, -1
ret
.found:
test byte [edi+11], 0x10 ; do not allow read directories test byte [edi+11], 0x10 ; do not allow read directories
jnz .noaccess jnz .noaccess
cmp dword [ebx+8], 0 cmp dword [ebx+8], 0
jz @f jnz .endOfFile
xor ebx, ebx
call fat_unlock
mov eax, ERROR_END_OF_FILE
pop edi
ret
@@:
mov edx, [ebx+4] ; file offset mov edx, [ebx+4] ; file offset
mov ecx, [ebx+12] ; size mov ecx, [ebx+12] ; size
mov ebx, [ebx+16] ; buffer mov ebx, [ebx+16] ; buffer
@ -1583,6 +1561,23 @@ fat_Read:
call get_FAT call get_FAT
jc .noaccess2 jc .noaccess2
jmp @b jmp @b
.notFound:
push eax
jmp .ret
.noaccess:
push ERROR_ACCESS_DENIED
jmp .ret
.endOfFile:
push ERROR_END_OF_FILE
.ret:
call fat_unlock
pop eax edi
xor ebx, ebx
ret
@@: @@:
mov esi, eax mov esi, eax
dec eax dec eax
@ -1674,6 +1669,7 @@ fat_Read:
xor edx, edx xor edx, edx
jecxz .done jecxz .done
jmp .alignedCluster jmp .alignedCluster
.readEnd: .readEnd:
add ecx, edi add ecx, edi
mov edi, ecx mov edi, ecx
@ -1688,6 +1684,7 @@ fat_Read:
push eax push eax
mov ecx, eax mov ecx, eax
jmp .readFragment jmp .readFragment
.noaccess3: .noaccess3:
pop eax pop eax
.noaccess2: .noaccess2:
@ -1697,12 +1694,15 @@ fat_Read:
pop eax edx edi pop eax edx edi
sub ebx, edx sub ebx, edx
ret ret
.fileEnd: .fileEnd:
mov byte [esp], ERROR_END_OF_FILE mov byte [esp], ERROR_END_OF_FILE
jmp .done jmp .done
.noaccess4: .noaccess4:
mov byte [esp], ERROR_DEVICE mov byte [esp], ERROR_DEVICE
jmp @f jmp @f
.fileEnd2: .fileEnd2:
mov byte [esp], ERROR_END_OF_FILE mov byte [esp], ERROR_END_OF_FILE
@@: @@:
@ -2101,12 +2101,6 @@ fat_get_sector:
pop ecx pop ecx
ret ret
fshrad:
call fat_unlock
mov eax, ERROR_ACCESS_DENIED
xor ebx, ebx
ret
;---------------------------------------------------------------- ;----------------------------------------------------------------
fat_CreateFolder: fat_CreateFolder:
push 1 push 1
@ -2117,8 +2111,6 @@ fat_CreateFile:
@@: @@:
call fat_lock call fat_lock
pop eax pop eax
cmp byte [esi], 0
jz fshrad
mov ecx, [ebx+12] mov ecx, [ebx+12]
mov edx, [ebx+16] mov edx, [ebx+16]
pushad pushad
@ -2661,33 +2653,12 @@ fat_read_symbols:
;---------------------------------------------------------------- ;----------------------------------------------------------------
fat_Write: fat_Write:
cmp byte [esi], 0
jz .access_denied
call fat_lock call fat_lock
push edi push edi
call hd_find_lfn call hd_find_lfn
jnc .found jc .error
pop edi
push eax
call fat_unlock
.ret0:
pop eax
xor ebx, ebx
ret
.access_denied:
push ERROR_ACCESS_DENIED
jmp .ret0
.found: ; FAT does not support files larger than 4GB
cmp dword [ebx+8], 0 cmp dword [ebx+8], 0
jz @f jnz .eof ; FAT does not support files larger than 4GB
.eof:
pop edi
push ERROR_END_OF_FILE
call fat_unlock
jmp .ret0
@@:
mov ecx, [ebx+12] mov ecx, [ebx+12]
mov edx, [ebx+16] mov edx, [ebx+16]
mov ebx, [ebx+4] mov ebx, [ebx+4]
@ -2715,16 +2686,7 @@ fat_Write:
; hd_extend_file can return three error codes: FAT table error, device error or disk full. ; hd_extend_file can return three error codes: FAT table error, device error or disk full.
; First two cases are fatal errors, in third case we may write some data ; First two cases are fatal errors, in third case we may write some data
cmp al, ERROR_DISK_FULL cmp al, ERROR_DISK_FULL
jz .disk_full jnz @f
call fat_unlock
pop eax
pop eax
pop ecx
pop edx
pop edi
xor ebx, ebx
ret
.disk_full:
; correct number of bytes to write ; correct number of bytes to write
mov ecx, [edi+28] mov ecx, [edi+28]
cmp ecx, ebx cmp ecx, ebx
@ -2738,14 +2700,30 @@ fat_Write:
test eax, eax test eax, eax
jz @f jz @f
mov byte [esp+4], ERROR_DEVICE mov byte [esp+4], ERROR_DEVICE
@@:
pop eax eax ecx edx
.error:
push eax
@@: @@:
call fat_unlock call fat_unlock
pop eax pop eax edi
pop eax xor ebx, ebx
pop ecx
pop edx
pop edi
ret ret
.eof:
push ERROR_END_OF_FILE
jmp @b
.device_err2:
pop ecx
.device_err:
mov byte [esp+8], ERROR_DEVICE
jmp .ret
.fat_err:
mov byte [esp+8], ERROR_FS_FAIL
jmp .ret
.length_ok: .length_ok:
mov esi, [edi+28] mov esi, [edi+28]
mov eax, [edi+20-2] mov eax, [edi+20-2]
@ -2759,15 +2737,7 @@ fat_Write:
call fs_write32_sys call fs_write32_sys
pop ebx pop ebx
test eax, eax test eax, eax
jz @f jnz .device_err
.device_err:
mov byte [esp+8], ERROR_DEVICE
jmp .ret
.fat_err:
mov byte [esp+8], ERROR_FS_FAIL
jmp .ret
@@:
; now ebx=start pos, ecx=end pos, both lie inside file ; now ebx=start pos, ecx=end pos, both lie inside file
sub ecx, ebx sub ecx, ebx
jz .ret jz .ret
@ -2811,11 +2781,7 @@ fat_Write:
call fs_read32_app call fs_read32_app
test eax, eax test eax, eax
pop ebx eax pop ebx eax
jz @f jnz .device_err2
.device_err2:
pop ecx
jmp .device_err
@@:
.noread: .noread:
; zero uninitialized data if file was extended (because hd_extend_file does not this) ; zero uninitialized data if file was extended (because hd_extend_file does not this)
push eax ecx edi push eax ecx edi
@ -2996,31 +2962,14 @@ fat_update_datetime:
fat_SetFileEnd: fat_SetFileEnd:
call fat_lock call fat_lock
push edi push edi
cmp byte [esi], 0
jnz @f
.access_denied:
push ERROR_ACCESS_DENIED
.ret:
call fat_unlock
pop eax
pop edi
ret
@@:
call hd_find_lfn call hd_find_lfn
jnc @f jc .reteax
.reteax:
push eax
jmp .ret
@@:
; must not be directory ; must not be directory
test byte [edi+11], 10h test byte [edi+11], 10h
jnz .access_denied jnz .access_denied
; file size must not exceed 4 Gb ; file size must not exceed 4 Gb
cmp dword [ebx+8], 0 cmp dword [ebx+8], 0
jz @f jnz .endOfFile
push ERROR_END_OF_FILE
jmp .ret
@@:
push eax ; save directory sector push eax ; save directory sector
; set file modification date/time to current ; set file modification date/time to current
call fat_update_datetime call fat_update_datetime
@ -3032,12 +2981,22 @@ fat_SetFileEnd:
lea ebx, [ebp+FAT.buffer] lea ebx, [ebp+FAT.buffer]
call fs_write32_sys call fs_write32_sys
test eax, eax test eax, eax
jz @f jnz .errorDevice
push ERROR_DEVICE
jmp .ret
@@:
push 0 push 0
jmp .ret jmp .ret
.access_denied:
push ERROR_ACCESS_DENIED
jmp .ret
.endOfFile:
push ERROR_END_OF_FILE
jmp .ret
.errorDevice:
push ERROR_DEVICE
jmp .ret
.expand: .expand:
push ebx ebp ecx push ebx ebp ecx
push dword [edi+28] ; save old size push dword [edi+28] ; save old size
@ -3046,14 +3005,8 @@ fat_SetFileEnd:
push eax ; return code push eax ; return code
jnc .expand_ok jnc .expand_ok
cmp al, ERROR_DISK_FULL cmp al, ERROR_DISK_FULL
jz .disk_full jnz .pop_ret
.pop_ret: .expand_ok: ; save directory
call update_disk
pop eax ecx ecx ebp ebx ecx
jmp .reteax
.expand_ok:
.disk_full:
; save directory
mov eax, [edi+28] mov eax, [edi+28]
xchg eax, [esp+20] xchg eax, [esp+20]
lea ebx, [ebp+FAT.buffer] lea ebx, [ebp+FAT.buffer]
@ -3062,11 +3015,7 @@ fat_SetFileEnd:
mov eax, [edi+20-2] mov eax, [edi+20-2]
mov ax, [edi+26] mov ax, [edi+26]
mov edi, eax mov edi, eax
jz @f jnz .pop_ret11
.pop_ret11:
mov byte [esp], ERROR_DEVICE
jmp .pop_ret
@@:
test edi, edi test edi, edi
jz .pop_ret jz .pop_ret
; now zero new data ; now zero new data
@ -3123,7 +3072,29 @@ fat_SetFileEnd:
mov edi, eax mov edi, eax
jnc .zero_loop jnc .zero_loop
pop eax pop eax
jmp .pop_ret11 .pop_ret11:
mov byte [esp], ERROR_DEVICE
.pop_ret:
call update_disk
pop eax ecx ecx ebp ebx ecx
.reteax:
push eax
.ret:
call fat_unlock
pop eax edi
ret
.error_fat:
pop eax
mov byte [esp], ERROR_FS_FAIL
jmp .pop_ret
.error_fat2:
pop eax ecx eax
call update_disk
push ERROR_FS_FAIL
jmp .ret
.truncate: .truncate:
mov [edi+28], eax mov [edi+28], eax
push ecx push ecx
@ -3132,8 +3103,7 @@ fat_SetFileEnd:
push eax push eax
test eax, eax test eax, eax
jz .zero_size jz .zero_size
; find new last cluster @@: ; find new last cluster
@@:
cmp ecx, 2 cmp ecx, 2
jb .error_fat2 jb .error_fat2
cmp ecx, [ebp+FAT.fatRESERVED] cmp ecx, [ebp+FAT.fatRESERVED]
@ -3147,11 +3117,11 @@ fat_SetFileEnd:
mov ecx, eax mov ecx, eax
jnc @b jnc @b
.device_err3: .device_err3:
pop eax ecx eax edi pop eax ecx eax
call update_disk call update_disk
call fat_unlock push ERROR_DEVICE
movi eax, ERROR_DEVICE jmp .ret
ret
@@: @@:
; we will zero data at the end of last sector - remember it ; we will zero data at the end of last sector - remember it
push ecx push ecx
@ -3166,6 +3136,7 @@ fat_SetFileEnd:
.device_err4: .device_err4:
pop ecx pop ecx
jmp .device_err3 jmp .device_err3
.zero_size: .zero_size:
and word [edi+20], 0 and word [edi+20], 0
and word [edi+26], 0 and word [edi+26], 0
@ -3215,16 +3186,6 @@ fat_SetFileEnd:
call fat_unlock call fat_unlock
xor eax, eax xor eax, eax
ret ret
.error_fat:
pop eax
mov byte [esp], ERROR_FS_FAIL
jmp .pop_ret
.error_fat2:
pop eax ecx eax edi
call update_disk
call fat_unlock
movi eax, ERROR_FS_FAIL
ret
;---------------------------------------------------------------- ;----------------------------------------------------------------
fat_GetFileInfo: fat_GetFileInfo:
@ -3256,11 +3217,6 @@ fat_GetFileInfo:
;---------------------------------------------------------------- ;----------------------------------------------------------------
fat_SetFileInfo: fat_SetFileInfo:
cmp byte [esi], 0
jnz @f
mov eax, 2
ret
@@:
push edi push edi
call fat_lock call fat_lock
call hd_find_lfn call hd_find_lfn
@ -3286,26 +3242,11 @@ fat_SetFileInfo:
;---------------------------------------------------------------- ;----------------------------------------------------------------
fat_Delete: fat_Delete:
call fat_lock call fat_lock
cmp byte [esi], 0
jnz @f
; cannot delete root!
.access_denied:
push ERROR_ACCESS_DENIED
.pop_ret:
call fat_unlock
pop eax
xor ebx, ebx
ret
@@:
and [ebp+FAT.longname_sec1], 0 and [ebp+FAT.longname_sec1], 0
and [ebp+FAT.longname_sec2], 0 and [ebp+FAT.longname_sec2], 0
push edi push edi
call hd_find_lfn call hd_find_lfn
jnc .found jc .notFound
pop edi
push ERROR_FILE_NOT_FOUND
jmp .pop_ret
.found:
cmp dword [edi], '. ' cmp dword [edi], '. '
jz .access_denied2 jz .access_denied2
cmp dword [edi], '.. ' cmp dword [edi], '.. '
@ -3359,23 +3300,27 @@ fat_Delete:
.err1: .err1:
popad popad
.err2: .err2:
pop edi push ERROR_DEVICE
.ret:
call fat_unlock call fat_unlock
movi eax, ERROR_DEVICE pop eax edi
ret ret
.notFound:
push ERROR_FILE_NOT_FOUND
jmp .ret
.error_fat: .error_fat:
popad popad
pop edi push ERROR_FS_FAIL
call fat_unlock jmp .ret
movi eax, ERROR_FS_FAIL
ret
.notempty: .notempty:
popad popad
.access_denied2: .access_denied2:
pop edi push ERROR_ACCESS_DENIED
call fat_unlock jmp .ret
movi eax, ERROR_ACCESS_DENIED
ret
.empty: .empty:
popad popad
push eax ebx push eax ebx

View File

@ -160,112 +160,88 @@ free_cd_channel:
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
fs_CdRead: fs_CdRead:
push edi
cmp byte [esi], 0
jnz @f
;--------------------------------------
.noaccess:
pop edi
;--------------------------------------
.noaccess_2:
or ebx, -1
mov eax, ERROR_ACCESS_DENIED
ret
;--------------------------------------
.noaccess_3:
pop eax edx ecx edi
jmp .noaccess_2
;--------------------------------------
@@:
call cd_find_lfn call cd_find_lfn
jnc .found jc .notFound
pop edi
cmp [DevErrorCode], 0
jne .noaccess_2
or ebx, -1
mov eax, ERROR_FILE_NOT_FOUND
ret
;--------------------------------------
.found:
mov edi, [cd_current_pointer_of_input] mov edi, [cd_current_pointer_of_input]
test byte [edi+25], 10b; do not allow read directories test byte [edi+25], 10b ; do not allow read directories
jnz .noaccess jnz .noaccess
test ebx, ebx test ebx, ebx
jz .l1 jz .l1
cmp dword [ebx+4], 0 cmp dword [ebx+4], 0
jz @f jz @f
xor ebx, ebx xor ebx, ebx
;-------------------------------------- movi eax, ERROR_END_OF_FILE
.reteof:
mov eax, 6; end of file
pop edi
ret ret
;--------------------------------------
.notFound:
cmp [DevErrorCode], 0
jne .noaccess
xor ebx, ebx
movi eax, ERROR_FILE_NOT_FOUND
ret
.noaccess_3:
pop eax edx ecx
.noaccess:
xor ebx, ebx
movi eax, ERROR_ACCESS_DENIED
ret
@@: @@:
mov ebx, [ebx] mov ebx, [ebx]
;--------------------------------------
.l1: .l1:
push ecx edx push ecx edx 0
push 0
mov eax, [edi+10] ; real size of the file section mov eax, [edi+10] ; real size of the file section
sub eax, ebx sub eax, ebx
jb .eof jb .eof
cmp eax, ecx cmp eax, ecx
jae @f jae @f
mov ecx, eax mov ecx, eax
mov byte [esp], 6 pop eax
;-------------------------------------- push ERROR_END_OF_FILE
@@: @@:
mov eax, [edi+2] mov eax, [edi+2]
mov [CDSectorAddress], eax mov [CDSectorAddress], eax
;--------------------------------------
; now eax=cluster, ebx=position, ecx=count, edx=buffer for data ; now eax=cluster, ebx=position, ecx=count, edx=buffer for data
.new_sector: .new_sector:
test ecx, ecx test ecx, ecx
jz .done jz .done
sub ebx, 2048 sub ebx, 2048
jae .next jae .next
add ebx, 2048 add ebx, 2048
jnz .incomplete_sector jnz .incomplete_sector
cmp ecx, 2048 cmp ecx, 2048
jb .incomplete_sector jb .incomplete_sector
; we may read and memmove complete sector ; we may read and memmove complete sector
mov [CDDataBuf_pointer], edx mov [CDDataBuf_pointer], edx
call ReadCDWRetr ; read sector of file call ReadCDWRetr
cmp [DevErrorCode], 0 cmp [DevErrorCode], 0
jne .noaccess_3 jne .noaccess_3
add edx, 2048 add edx, 2048
sub ecx, 2048 sub ecx, 2048
;--------------------------------------
.next: .next:
inc dword [CDSectorAddress] inc dword [CDSectorAddress]
jmp .new_sector jmp .new_sector
;--------------------------------------
.incomplete_sector: .eof:
; we must read and memmove incomplete sector 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
mov [CDDataBuf_pointer], CDDataBuf mov [CDDataBuf_pointer], CDDataBuf
call ReadCDWRetr ; read sector of file call ReadCDWRetr
cmp [DevErrorCode], 0 cmp [DevErrorCode], 0
jne .noaccess_3 jne .noaccess_3
push ecx push ecx
add ecx, ebx add ecx, ebx
cmp ecx, 2048 cmp ecx, 2048
jbe @f jbe @f
mov ecx, 2048 mov ecx, 2048
;--------------------------------------
@@: @@:
sub ecx, ebx sub ecx, ebx
push edi esi ecx push edi esi ecx
@ -279,18 +255,6 @@ fs_CdRead:
pop ecx pop ecx
xor ebx, ebx xor ebx, ebx
jmp .next jmp .next
;--------------------------------------
.done:
mov ebx, edx
pop eax edx ecx edi
sub ebx, edx
ret
;--------------------------------------
.eof:
mov ebx, edx
pop eax edx ecx
sub ebx, edx
jmp .reteof
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
fs_CdReadFolder: fs_CdReadFolder:

View File

@ -1320,47 +1320,18 @@ ntfs_find_lfn:
;---------------------------------------------------------------- ;----------------------------------------------------------------
ntfs_ReadFile: ntfs_ReadFile:
cmp byte [esi], 0
jnz @f
or ebx, -1
movi eax, ERROR_ACCESS_DENIED
ret
@@:
call ntfs_lock call ntfs_lock
call ntfs_find_lfn call ntfs_find_lfn
jnc .found jc ntfsNotFound
call ntfs_unlock
or ebx, -1
movi eax, ERROR_FILE_NOT_FOUND
ret
.found:
mov [ebp+NTFS.cur_attr], 0x80 ; $DATA mov [ebp+NTFS.cur_attr], 0x80 ; $DATA
and [ebp+NTFS.cur_offs], 0 and [ebp+NTFS.cur_offs], 0
and [ebp+NTFS.cur_size], 0 and [ebp+NTFS.cur_size], 0
call ntfs_read_attr call ntfs_read_attr
jnc @f jc ntfsDenied
call ntfs_unlock
or ebx, -1
movi eax, ERROR_ACCESS_DENIED
ret
@@:
pushad
and dword [esp+10h], 0
xor eax, eax xor eax, eax
push eax
cmp dword [ebx+8], 0x200 cmp dword [ebx+8], 0x200
jb @f jnc .eof
.eof0:
popad
xor ebx, ebx
.eof:
call ntfs_unlock
movi eax, ERROR_END_OF_FILE
ret
@@:
mov ecx, [ebx+12] mov ecx, [ebx+12]
mov edx, [ebx+16] mov edx, [ebx+16]
mov eax, [ebx+4] mov eax, [ebx+4]
@ -1379,33 +1350,22 @@ ntfs_ReadFile:
and eax, 0x1FF and eax, 0x1FF
lea esi, [ebp+NTFS.bitmap_buf+eax] lea esi, [ebp+NTFS.bitmap_buf+eax]
sub eax, [ebp+NTFS.cur_read] sub eax, [ebp+NTFS.cur_read]
jae .eof0 jae .eof
neg eax neg eax
push ecx push ecx
cmp ecx, eax cmp ecx, eax
jb @f jb @f
mov ecx, eax mov ecx, eax
@@: @@:
mov [esp+10h+4], ecx mov [esp+4], ecx
mov edi, edx mov edi, edx
rep movsb rep movsb
mov edx, edi mov edx, edi
pop ecx pop ecx
sub ecx, [esp+10h] sub ecx, [esp]
jnz @f jz .retok
.retok:
popad
call ntfs_unlock
xor eax, eax
ret
@@:
cmp [ebp+NTFS.cur_read], 0x200 cmp [ebp+NTFS.cur_read], 0x200
jz .alignedstart jnz .eof
.eof_ebx:
popad
jmp .eof
.alignedstart: .alignedstart:
mov eax, [ebx+4] mov eax, [ebx+4]
push edx push edx
@ -1424,11 +1384,11 @@ ntfs_ReadFile:
call ntfs_read_attr.continue call ntfs_read_attr.continue
pop [ebp+NTFS.cur_offs] pop [ebp+NTFS.cur_offs]
mov eax, [ebp+NTFS.cur_read] mov eax, [ebp+NTFS.cur_read]
add [esp+10h], eax add [esp], eax
mov eax, ecx mov eax, ecx
and eax, not 0x1FF and eax, not 0x1FF
cmp [ebp+NTFS.cur_read], eax cmp [ebp+NTFS.cur_read], eax
jnz .eof_ebx jnz .eof
and ecx, 0x1FF and ecx, 0x1FF
jz .retok jz .retok
add edx, [ebp+NTFS.cur_read] add edx, [ebp+NTFS.cur_read]
@ -1444,19 +1404,22 @@ ntfs_ReadFile:
push ecx push ecx
mov edi, edx mov edi, edx
lea esi, [ebp+NTFS.bitmap_buf] lea esi, [ebp+NTFS.bitmap_buf]
add [esp+10h+4], ecx add [esp+4], ecx
rep movsb rep movsb
pop ecx pop ecx
xor eax, eax
cmp ecx, [ebp+NTFS.cur_read] cmp ecx, [ebp+NTFS.cur_read]
jz @f jnz .eof
mov al, ERROR_END_OF_FILE .retok:
@@: pushd 0
mov [esp+1Ch], eax .ret:
call ntfs_unlock call ntfs_unlock
popad pop eax ebx
ret ret
.eof:
push ERROR_END_OF_FILE
jmp .ret
;---------------------------------------------------------------- ;----------------------------------------------------------------
ntfs_ReadFolder: ntfs_ReadFolder:
call ntfs_lock call ntfs_lock
@ -1854,13 +1817,6 @@ ntfs_CreateFolder:
ntfs_CreateFile: ntfs_CreateFile:
mov [ebp+NTFS.bFolder], 0 mov [ebp+NTFS.bFolder], 0
@@:
cmp byte [esi], 0
jnz @f
xor ebx, ebx
movi eax, ERROR_ACCESS_DENIED
ret
@@: ; 1. Search file @@: ; 1. Search file
call ntfs_lock call ntfs_lock
call ntfs_find_lfn call ntfs_find_lfn
@ -3483,12 +3439,6 @@ bitmapBuffering:
;---------------------------------------------------------------- ;----------------------------------------------------------------
ntfs_WriteFile: ntfs_WriteFile:
cmp byte [esi], 0
jnz @f
xor ebx, ebx
movi eax, ERROR_ACCESS_DENIED
ret
@@:
call ntfs_lock call ntfs_lock
call ntfs_find_lfn call ntfs_find_lfn
jc ntfsNotFound jc ntfsNotFound
@ -3662,13 +3612,6 @@ ntfs_WriteFile:
;---------------------------------------------------------------- ;----------------------------------------------------------------
ntfs_Delete: ntfs_Delete:
cmp byte [esi], 0
jnz @f
xor ebx, ebx
movi eax, ERROR_ACCESS_DENIED
ret
@@:
call ntfs_lock call ntfs_lock
call ntfs_find_lfn call ntfs_find_lfn
jc ntfsNotFound jc ntfsNotFound
@ -3981,12 +3924,6 @@ ntfs_Delete:
;---------------------------------------------------------------- ;----------------------------------------------------------------
ntfs_SetFileEnd: ntfs_SetFileEnd:
cmp byte [esi], 0
jnz @f
xor ebx, ebx
movi eax, ERROR_ACCESS_DENIED
ret
@@:
call ntfs_lock call ntfs_lock
call ntfs_find_lfn call ntfs_find_lfn
jc ntfsNotFound jc ntfsNotFound
@ -4116,11 +4053,6 @@ ntfsCalculateTime:
;---------------------------------------------------------------- ;----------------------------------------------------------------
ntfs_SetFileInfo: ntfs_SetFileInfo:
cmp byte [esi], 0
jnz @f
movi eax, ERROR_UNSUPPORTED_FS
ret
@@:
call ntfs_lock call ntfs_lock
call ntfs_find_lfn call ntfs_find_lfn
jnc @f jnc @f