2011-10-14 23:38:50 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2016-01-19 20:45:51 +01:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
|
2011-10-14 23:38:50 +02:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
$Revision$
|
|
|
|
|
2015-12-10 11:45:32 +01:00
|
|
|
; NTFS driver
|
|
|
|
|
|
|
|
; Basic concepts:
|
|
|
|
; File is a FileRecord in the $MFT.
|
|
|
|
; $MFT is a file, that consists of FileRecords and starts with FileRecord of itself.
|
|
|
|
; FileRecord (FILE) consists of a header and attributes.
|
|
|
|
; Attribute consists of a header and a body.
|
|
|
|
; Attribute's body can be inside (resident) or outside of FileRecord.
|
|
|
|
; File's data is a body of $Data (80h) attribute.
|
|
|
|
; FileRecords is a data of the $MFT file.
|
|
|
|
; Directory is a file, that consists of index nodes.
|
|
|
|
; Resident index node is always located in a body of $IndexRoot (90h) attribute.
|
|
|
|
; Body of $IndexAllocation (A0h) attribute is always non resident
|
|
|
|
; and consists of IndexRecords.
|
|
|
|
; IndexRecord (INDX) consists of a header and an index node.
|
|
|
|
; Index node consists of a header and indexes.
|
|
|
|
; Index consists of a header and a copy of indexed attribute's body.
|
|
|
|
; Directories index $Filename (30h) attribute of all existing files.
|
|
|
|
; $IndexRoot and $IndexAllocation attributes of a directory has a name — $I30.
|
|
|
|
|
|
|
|
; Offsets:
|
|
|
|
; record header
|
2016-02-21 03:13:21 +01:00
|
|
|
magic = 0
|
2015-12-10 11:45:32 +01:00
|
|
|
updateSequenceOffset = 4
|
|
|
|
updateSequenceSize = 6
|
2016-02-21 03:13:21 +01:00
|
|
|
; FileRecord header
|
2015-12-10 11:45:32 +01:00
|
|
|
reuseCounter = 16
|
|
|
|
hardLinkCounter = 12h
|
|
|
|
attributeOffset = 14h
|
|
|
|
recordFlags = 16h
|
|
|
|
recordRealSize = 18h
|
|
|
|
recordAllocatedSize = 1ch
|
2015-12-21 12:47:21 +01:00
|
|
|
baseRecordReference = 20h ; for auxiliary records
|
|
|
|
baseRecordReuse = 26h
|
2015-12-10 11:45:32 +01:00
|
|
|
newAttributeID = 28h
|
|
|
|
; attribute header
|
|
|
|
attributeType = 0
|
|
|
|
sizeWithHeader = 4
|
|
|
|
nonResidentFlag = 8
|
|
|
|
nameLength = 9
|
|
|
|
nameOffset = 10
|
2015-12-31 18:29:37 +01:00
|
|
|
attributeFlags = 12
|
2015-12-10 11:45:32 +01:00
|
|
|
attributeID = 14
|
2016-01-19 20:45:51 +01:00
|
|
|
; resident attribute header
|
|
|
|
sizeWithoutHeader = 10h
|
2016-02-21 03:13:21 +01:00
|
|
|
attributeOffset = 14h
|
2015-12-31 18:29:37 +01:00
|
|
|
indexedFlag = 16h
|
2015-12-10 11:45:32 +01:00
|
|
|
; non resident attribute header
|
2016-01-19 20:45:51 +01:00
|
|
|
firstVCN = 10h
|
2015-12-10 11:45:32 +01:00
|
|
|
lastVCN = 18h
|
|
|
|
dataRunsOffset = 20h
|
|
|
|
attributeAllocatedSize = 28h
|
|
|
|
attributeRealSize = 30h
|
|
|
|
initialDataSize = 38h
|
|
|
|
; $IndexRoot
|
2016-02-21 03:13:21 +01:00
|
|
|
indexedAttributesType = 0
|
2015-12-10 11:45:32 +01:00
|
|
|
collationRule = 4
|
|
|
|
indexRecordSize = 8
|
2016-03-15 07:18:38 +01:00
|
|
|
indexRecordSizeClus = 12 ; in sectors if less than one cluster
|
2016-02-21 03:13:21 +01:00
|
|
|
rootNode = 16
|
|
|
|
; IndexRecord header
|
|
|
|
recordVCN = 16
|
|
|
|
recordNode = 18h
|
2015-12-10 11:45:32 +01:00
|
|
|
; node header
|
|
|
|
indexOffset = 0
|
|
|
|
nodeRealSize = 4
|
|
|
|
nodeAllocatedSize = 8
|
2016-02-21 03:13:21 +01:00
|
|
|
nonLeafFlag = 12
|
2015-12-10 11:45:32 +01:00
|
|
|
; $Filename index
|
|
|
|
fileRecordReference = 0
|
|
|
|
fileReferenceReuse = 6
|
|
|
|
indexAllocatedSize = 8
|
|
|
|
indexRawSize = 10
|
|
|
|
indexFlags = 12
|
|
|
|
directoryRecordReference = 16
|
|
|
|
directoryReferenceReuse = 16h
|
2016-02-29 11:15:30 +01:00
|
|
|
fileCreated = 18h
|
|
|
|
fileModified = 20h
|
|
|
|
recordModified = 28h
|
|
|
|
fileAccessed = 30h
|
2015-12-10 11:45:32 +01:00
|
|
|
fileAllocatedSize = 38h
|
|
|
|
fileRealSize = 40h
|
|
|
|
fileFlags = 48h
|
|
|
|
fileNameLength = 50h
|
2016-02-29 11:15:30 +01:00
|
|
|
namespace = 51h
|
|
|
|
fileName = 52h
|
2015-12-10 11:45:32 +01:00
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
struct NTFS PARTITION
|
2016-02-21 03:13:21 +01:00
|
|
|
Lock MUTEX ? ; Currently operations with one partition
|
2015-12-10 11:45:32 +01:00
|
|
|
; can not be executed in parallel since the legacy code is not ready.
|
2016-02-21 03:13:21 +01:00
|
|
|
sectors_per_cluster dd ?
|
|
|
|
mft_cluster dd ? ; location
|
|
|
|
mftmirr_cluster dd ? ; location
|
|
|
|
frs_size dd ? ; in bytes
|
|
|
|
frs_buffer dd ? ; MFT fileRecord buffer
|
|
|
|
mft_retrieval_end dd ?
|
2016-04-21 19:41:56 +02:00
|
|
|
mftSize dd ? ; in sectors
|
2016-02-21 03:13:21 +01:00
|
|
|
cur_index_size dd ? ; in sectors
|
|
|
|
cur_index_buf dd ? ; index node buffer
|
2016-03-15 07:18:38 +01:00
|
|
|
secondIndexBuffer dd ?
|
2016-02-21 03:13:21 +01:00
|
|
|
BitmapBuffer dd ?
|
|
|
|
BitmapTotalSize dd ? ; bytes reserved
|
|
|
|
BitmapSize dd ? ; bytes readen
|
|
|
|
BitmapLocation dd ? ; starting sector
|
|
|
|
BitmapStart dd ? ; first byte after area, reserved for MFT
|
|
|
|
mftBitmapBuffer dd ? ; one cluster
|
|
|
|
mftBitmapSize dd ? ; bytes readen
|
|
|
|
mftBitmapLocation dd ? ; starting sector
|
|
|
|
|
2016-04-21 19:41:56 +02:00
|
|
|
attr_size dq ?
|
|
|
|
attr_offs dd ?
|
|
|
|
attr_list dd ?
|
|
|
|
attr_iBaseRecord dd ?
|
2016-02-21 03:13:21 +01:00
|
|
|
cur_attr dd ? ; attribute type
|
|
|
|
cur_iRecord dd ? ; number of fileRecord in MFT
|
|
|
|
cur_offs dd ? ; attribute VCN in sectors
|
|
|
|
cur_size dd ? ; max sectors to read
|
|
|
|
cur_buf dd ?
|
|
|
|
cur_read dd ? ; bytes readen
|
2016-04-21 19:41:56 +02:00
|
|
|
cur_tail dd ?
|
|
|
|
cur_subnode_size dd ?
|
2016-02-21 03:13:21 +01:00
|
|
|
LastRead dd ? ; last readen block of sectors
|
2016-04-27 10:48:17 +02:00
|
|
|
mftLastRead dd ?
|
2016-03-15 07:18:38 +01:00
|
|
|
rootLastRead dd ?
|
|
|
|
nodeLastRead dd ?
|
|
|
|
indexRoot dd ?
|
2016-04-21 19:41:56 +02:00
|
|
|
indexPointer dd ?
|
2016-03-15 07:18:38 +01:00
|
|
|
newRecord dd ?
|
2016-02-21 03:13:21 +01:00
|
|
|
fileDataStart dd ? ; starting cluster
|
|
|
|
fileDataSize dd ? ; in clusters
|
2016-02-25 18:10:35 +01:00
|
|
|
fileDataBuffer dd ?
|
2016-02-21 03:13:21 +01:00
|
|
|
fileRealSize dd ? ; in bytes
|
|
|
|
fragmentCount db ?
|
|
|
|
bCanContinue db ?
|
|
|
|
bFolder db ?
|
|
|
|
bWriteAttr db ? ; Warning: Don't forget to turn off!!!
|
|
|
|
|
2016-04-21 19:41:56 +02:00
|
|
|
align 256
|
|
|
|
mft_retrieval rb 768
|
|
|
|
attrlist_buf rb 1024
|
|
|
|
attrlist_mft_buf rb 1024
|
|
|
|
bitmap_buf rb 1024
|
2013-07-01 18:29:16 +02:00
|
|
|
ends
|
|
|
|
|
2015-12-10 11:45:32 +01:00
|
|
|
; NTFS external functions
|
|
|
|
; in:
|
|
|
|
; ebx -> parameter structure of sysfunc 70
|
|
|
|
; ebp -> NTFS structure
|
|
|
|
; [esi]+[esp+4] = name
|
|
|
|
; out:
|
|
|
|
; eax, ebx = return values for sysfunc 70
|
2013-07-01 18:29:16 +02:00
|
|
|
iglobal
|
|
|
|
align 4
|
|
|
|
ntfs_user_functions:
|
|
|
|
dd ntfs_free
|
|
|
|
dd (ntfs_user_functions_end - ntfs_user_functions - 4) / 4
|
2015-12-10 11:45:32 +01:00
|
|
|
dd ntfs_ReadFile
|
2013-07-01 18:29:16 +02:00
|
|
|
dd ntfs_ReadFolder
|
2015-12-10 11:45:32 +01:00
|
|
|
dd ntfs_CreateFile
|
2015-12-21 12:47:21 +01:00
|
|
|
dd ntfs_WriteFile
|
2013-07-01 18:29:16 +02:00
|
|
|
dd ntfs_SetFileEnd
|
|
|
|
dd ntfs_GetFileInfo
|
|
|
|
dd ntfs_SetFileInfo
|
|
|
|
dd 0
|
|
|
|
dd ntfs_Delete
|
|
|
|
dd ntfs_CreateFolder
|
|
|
|
ntfs_user_functions_end:
|
|
|
|
endg
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
ntfs_test_bootsec:
|
2015-12-10 11:45:32 +01:00
|
|
|
; in: ebx -> buffer, edx = size of partition
|
|
|
|
; out: CF=1 -> invalid
|
2011-10-14 23:38:50 +02:00
|
|
|
; 1. Name=='NTFS '
|
|
|
|
cmp dword [ebx+3], 'NTFS'
|
|
|
|
jnz .no
|
|
|
|
cmp dword [ebx+7], ' '
|
|
|
|
jnz .no
|
|
|
|
; 2. Number of bytes per sector is the same as for physical device
|
|
|
|
; (that is, 0x200 for hard disk)
|
|
|
|
cmp word [ebx+11], 0x200
|
|
|
|
jnz .no
|
|
|
|
; 3. Number of sectors per cluster must be power of 2
|
|
|
|
movzx eax, byte [ebx+13]
|
|
|
|
dec eax
|
|
|
|
js .no
|
|
|
|
test al, [ebx+13]
|
|
|
|
jnz .no
|
|
|
|
; 4. FAT parameters must be zero
|
|
|
|
cmp word [ebx+14], 0
|
|
|
|
jnz .no
|
|
|
|
cmp dword [ebx+16], 0
|
|
|
|
jnz .no
|
|
|
|
cmp byte [ebx+20], 0
|
|
|
|
jnz .no
|
|
|
|
cmp word [ebx+22], 0
|
|
|
|
jnz .no
|
|
|
|
cmp dword [ebx+32], 0
|
|
|
|
jnz .no
|
|
|
|
; 5. Number of sectors <= partition size
|
|
|
|
cmp dword [ebx+0x2C], 0
|
|
|
|
ja .no
|
|
|
|
cmp [ebx+0x28], edx
|
|
|
|
ja .no
|
|
|
|
; 6. $MFT and $MFTMirr clusters must be within partition
|
|
|
|
cmp dword [ebx+0x34], 0
|
|
|
|
ja .no
|
|
|
|
push edx
|
|
|
|
movzx eax, byte [ebx+13]
|
|
|
|
mul dword [ebx+0x30]
|
|
|
|
test edx, edx
|
|
|
|
pop edx
|
|
|
|
jnz .no
|
|
|
|
cmp eax, edx
|
|
|
|
ja .no
|
|
|
|
cmp dword [ebx+0x3C], 0
|
|
|
|
ja .no
|
|
|
|
push edx
|
|
|
|
movzx eax, byte [ebx+13]
|
|
|
|
mul dword [ebx+0x38]
|
|
|
|
test edx, edx
|
|
|
|
pop edx
|
|
|
|
jnz .no
|
|
|
|
cmp eax, edx
|
|
|
|
ja .no
|
2015-12-10 11:45:32 +01:00
|
|
|
; 7. Clusters per FRS must be either power of 2 or between -31 and -9
|
2011-10-14 23:38:50 +02:00
|
|
|
movsx eax, byte [ebx+0x40]
|
|
|
|
cmp al, -31
|
|
|
|
jl .no
|
|
|
|
cmp al, -9
|
|
|
|
jle @f
|
|
|
|
dec eax
|
|
|
|
js .no
|
|
|
|
test [ebx+0x40], al
|
|
|
|
jnz .no
|
2015-12-10 11:45:32 +01:00
|
|
|
@@: ; 8. Same for clusters per IndexAllocationBuffer
|
2011-10-14 23:38:50 +02:00
|
|
|
movsx eax, byte [ebx+0x44]
|
|
|
|
cmp al, -31
|
|
|
|
jl .no
|
|
|
|
cmp al, -9
|
|
|
|
jle @f
|
|
|
|
dec eax
|
|
|
|
js .no
|
|
|
|
test [ebx+0x44], al
|
|
|
|
jnz .no
|
2015-12-10 11:45:32 +01:00
|
|
|
@@: ; OK, this is correct NTFS bootsector
|
2011-10-14 23:38:50 +02:00
|
|
|
clc
|
|
|
|
ret
|
2015-12-10 11:45:32 +01:00
|
|
|
.no: ; No, this bootsector isn't NTFS
|
2011-10-14 23:38:50 +02:00
|
|
|
stc
|
|
|
|
ret
|
|
|
|
|
2015-12-10 11:45:32 +01:00
|
|
|
ntfs_create_partition:
|
2014-09-03 14:11:19 +02:00
|
|
|
cmp dword [esi+DISK.MediaInfo.SectorSize], 512
|
|
|
|
jnz .nope
|
2013-07-01 18:29:16 +02:00
|
|
|
mov edx, dword [ebp+PARTITION.Length]
|
|
|
|
cmp dword [esp+4], 0
|
|
|
|
jz .boot_read_ok
|
|
|
|
add ebx, 512
|
|
|
|
lea eax, [edx-1]
|
|
|
|
call fs_read32_sys
|
|
|
|
test eax, eax
|
|
|
|
jnz @f
|
|
|
|
call ntfs_test_bootsec
|
|
|
|
jnc .ntfs_setup
|
|
|
|
@@:
|
|
|
|
mov eax, edx
|
|
|
|
shr eax, 1
|
|
|
|
call fs_read32_sys
|
|
|
|
test eax, eax
|
2015-12-10 11:45:32 +01:00
|
|
|
jnz .nope
|
2013-07-01 18:29:16 +02:00
|
|
|
.boot_read_ok:
|
|
|
|
call ntfs_test_bootsec
|
|
|
|
jnc .ntfs_setup
|
|
|
|
.nope:
|
|
|
|
xor eax, eax
|
|
|
|
jmp .exit
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2016-04-21 19:41:56 +02:00
|
|
|
.ntfs_setup: ; By given bootsector, initialize some NTFS variables
|
|
|
|
stdcall kernel_alloc, 1000h
|
2013-07-01 18:29:16 +02:00
|
|
|
test eax, eax
|
|
|
|
jz .exit
|
|
|
|
mov ecx, dword [ebp+PARTITION.FirstSector]
|
|
|
|
mov dword [eax+NTFS.FirstSector], ecx
|
|
|
|
mov ecx, dword [ebp+PARTITION.FirstSector+4]
|
|
|
|
mov dword [eax+NTFS.FirstSector+4], ecx
|
|
|
|
mov ecx, [ebp+PARTITION.Disk]
|
|
|
|
mov [eax+NTFS.Disk], ecx
|
|
|
|
mov [eax+NTFS.FSUserFunctions], ntfs_user_functions
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [eax+NTFS.bWriteAttr], 0
|
2015-12-10 11:45:32 +01:00
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
push ebx ebp esi
|
|
|
|
mov ebp, eax
|
|
|
|
lea ecx, [ebp+NTFS.Lock]
|
|
|
|
call mutex_init
|
2011-10-14 23:38:50 +02:00
|
|
|
movzx eax, byte [ebx+13]
|
2013-07-01 18:29:16 +02:00
|
|
|
mov [ebp+NTFS.sectors_per_cluster], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
mov eax, [ebx+0x28]
|
2013-07-01 18:29:16 +02:00
|
|
|
mov dword [ebp+NTFS.Length], eax
|
|
|
|
and dword [ebp+NTFS.Length+4], 0
|
2011-10-14 23:38:50 +02:00
|
|
|
mov eax, [ebx+0x30]
|
2013-07-01 18:29:16 +02:00
|
|
|
mov [ebp+NTFS.mft_cluster], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
mov eax, [ebx+0x38]
|
2013-07-01 18:29:16 +02:00
|
|
|
mov [ebp+NTFS.mftmirr_cluster], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
movsx eax, byte [ebx+0x40]
|
|
|
|
test eax, eax
|
2015-12-10 11:45:32 +01:00
|
|
|
js @f
|
2013-07-01 18:29:16 +02:00
|
|
|
mul [ebp+NTFS.sectors_per_cluster]
|
2011-10-14 23:38:50 +02:00
|
|
|
shl eax, 9
|
2015-12-10 11:45:32 +01:00
|
|
|
jmp .1
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2015-12-10 11:45:32 +01:00
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
neg eax
|
|
|
|
mov ecx, eax
|
|
|
|
mov eax, 1
|
|
|
|
shl eax, cl
|
2015-12-10 11:45:32 +01:00
|
|
|
.1:
|
2013-07-01 18:29:16 +02:00
|
|
|
mov [ebp+NTFS.frs_size], eax
|
2015-12-10 11:45:32 +01:00
|
|
|
stdcall kernel_alloc, eax
|
2011-10-14 23:38:50 +02:00
|
|
|
test eax, eax
|
2013-07-01 18:29:16 +02:00
|
|
|
jz .fail_free
|
|
|
|
mov [ebp+NTFS.frs_buffer], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
; read $MFT disposition
|
2013-07-01 18:29:16 +02:00
|
|
|
mov eax, [ebp+NTFS.mft_cluster]
|
|
|
|
mul [ebp+NTFS.sectors_per_cluster]
|
2016-04-21 19:41:56 +02:00
|
|
|
mov ecx, [ebp+NTFS.frs_size]
|
|
|
|
shr ecx, 9
|
|
|
|
mov ebx, [ebp+NTFS.frs_buffer]
|
|
|
|
call fs_read64_sys
|
2013-07-01 18:29:16 +02:00
|
|
|
test eax, eax
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz .usemirr
|
|
|
|
cmp dword [ebx], 'FILE'
|
|
|
|
jnz .usemirr
|
|
|
|
call ntfs_restore_usa_frs
|
|
|
|
jnc .mftok
|
|
|
|
.usemirr:
|
2013-07-01 18:29:16 +02:00
|
|
|
mov eax, [ebp+NTFS.mftmirr_cluster]
|
|
|
|
mul [ebp+NTFS.sectors_per_cluster]
|
2016-04-21 19:41:56 +02:00
|
|
|
mov ecx, [ebp+NTFS.frs_size]
|
|
|
|
shr ecx, 9
|
|
|
|
mov ebx, [ebp+NTFS.frs_buffer]
|
|
|
|
call fs_read64_sys
|
2013-07-01 18:29:16 +02:00
|
|
|
test eax, eax
|
2015-12-10 11:45:32 +01:00
|
|
|
jnz .fail_free_frs
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp dword [ebx], 'FILE'
|
2015-12-10 11:45:32 +01:00
|
|
|
jnz .fail_free_frs
|
2011-10-14 23:38:50 +02:00
|
|
|
call ntfs_restore_usa_frs
|
2015-12-10 11:45:32 +01:00
|
|
|
jc .fail_free_frs
|
2016-04-21 19:41:56 +02:00
|
|
|
.mftok: ; prepare $MFT retrieval information
|
|
|
|
; search for unnamed non-resident $DATA attribute
|
|
|
|
movzx eax, word [ebx+attributeOffset]
|
2011-10-14 23:38:50 +02:00
|
|
|
add eax, ebx
|
|
|
|
.scandata:
|
|
|
|
cmp dword [eax], -1
|
2016-04-21 19:41:56 +02:00
|
|
|
jz .fail_free_frs
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp dword [eax], 0x80
|
|
|
|
jnz @f
|
2016-04-21 19:41:56 +02:00
|
|
|
cmp byte [eax+nameLength], 0
|
2011-10-14 23:38:50 +02:00
|
|
|
jz .founddata
|
|
|
|
@@:
|
2016-04-21 19:41:56 +02:00
|
|
|
add eax, [eax+sizeWithHeader]
|
2011-10-14 23:38:50 +02:00
|
|
|
jmp .scandata
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.founddata:
|
2016-04-21 19:41:56 +02:00
|
|
|
cmp byte [eax+nonResidentFlag], 0
|
|
|
|
jz .fail_free_frs
|
|
|
|
movzx esi, word [eax+dataRunsOffset]
|
2011-10-14 23:38:50 +02:00
|
|
|
add esi, eax
|
2016-04-21 19:41:56 +02:00
|
|
|
mov edx, [eax+attributeAllocatedSize+4]
|
|
|
|
mov eax, [eax+attributeAllocatedSize]
|
|
|
|
shrd eax, edx, 9
|
|
|
|
mov [ebp+NTFS.mftSize], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
sub esp, 10h
|
2016-04-21 19:41:56 +02:00
|
|
|
lea ecx, [ebp+NTFS.mft_retrieval]
|
|
|
|
xor edx, edx
|
|
|
|
.scanmcb: ; load descriptions of fragments
|
2011-10-14 23:38:50 +02:00
|
|
|
call ntfs_decode_mcb_entry
|
|
|
|
jnc .scanmcbend
|
2016-04-21 19:41:56 +02:00
|
|
|
mov eax, [esp] ; block length
|
|
|
|
mov [ecx], eax
|
|
|
|
add edx, [esp+8] ; block addr
|
|
|
|
mov [ecx+4], edx
|
|
|
|
add ecx, 8
|
2011-10-14 23:38:50 +02:00
|
|
|
jmp .scanmcb
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.scanmcbend:
|
|
|
|
add esp, 10h
|
2016-04-21 19:41:56 +02:00
|
|
|
lea eax, [ebp+NTFS.attrlist_buf]
|
|
|
|
cmp eax, ecx
|
|
|
|
jc @f
|
|
|
|
mov eax, ecx
|
|
|
|
@@:
|
|
|
|
mov [ebp+NTFS.mft_retrieval_end], eax
|
|
|
|
; allocate index buffers
|
2016-03-15 07:18:38 +01:00
|
|
|
stdcall kernel_alloc, 2000h
|
2011-10-14 23:38:50 +02:00
|
|
|
test eax, eax
|
2016-04-21 19:41:56 +02:00
|
|
|
jz .fail_free_frs
|
2013-07-01 18:29:16 +02:00
|
|
|
mov [ebp+NTFS.cur_index_buf], eax
|
2016-03-15 07:18:38 +01:00
|
|
|
add eax, 1000h
|
|
|
|
mov [ebp+NTFS.secondIndexBuffer], eax
|
|
|
|
mov [ebp+NTFS.cur_index_size], 8
|
2015-12-10 11:45:32 +01:00
|
|
|
; reserve adress space for bitmap buffer and load some part of bitmap
|
|
|
|
mov eax, dword [ebp+NTFS.Length]
|
|
|
|
xor edx, edx
|
|
|
|
div [ebp+NTFS.sectors_per_cluster]
|
|
|
|
shr eax, 3
|
|
|
|
mov [ebp+NTFS.BitmapTotalSize], eax
|
|
|
|
add eax, 7FFFh
|
|
|
|
and eax, not 7FFFh
|
|
|
|
push eax
|
|
|
|
call alloc_kernel_space
|
|
|
|
test eax, eax
|
|
|
|
jz .failFreeIndex
|
|
|
|
mov [ebp+NTFS.BitmapBuffer], eax
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_buf], eax
|
2015-12-10 11:45:32 +01:00
|
|
|
mov eax, [ebp+NTFS.BitmapTotalSize]
|
|
|
|
add eax, [ebp+NTFS.mft_cluster]
|
|
|
|
shr eax, 3+2 ; reserve 1/8 of partition for $MFT
|
|
|
|
shl eax, 2
|
|
|
|
mov [ebp+NTFS.BitmapStart], eax
|
|
|
|
shr eax, 15
|
|
|
|
inc eax
|
|
|
|
shl eax, 3
|
|
|
|
push eax
|
|
|
|
push eax
|
|
|
|
shl eax, 3
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_size], eax
|
2015-12-10 11:45:32 +01:00
|
|
|
call alloc_pages
|
|
|
|
test eax, eax
|
|
|
|
pop ecx
|
|
|
|
jz .failFreeBitmap
|
|
|
|
add eax, 3
|
|
|
|
mov ebx, [ebp+NTFS.BitmapBuffer]
|
|
|
|
call commit_pages
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_iRecord], 6
|
|
|
|
mov [ebp+NTFS.cur_attr], 0x80
|
|
|
|
mov [ebp+NTFS.cur_offs], 0
|
2015-12-10 11:45:32 +01:00
|
|
|
call ntfs_read_attr
|
|
|
|
jc .failFreeBitmap
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, [ebp+NTFS.cur_read]
|
2015-12-10 11:45:32 +01:00
|
|
|
mov [ebp+NTFS.BitmapSize], eax
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, [ebp+NTFS.LastRead]
|
2015-12-10 11:45:32 +01:00
|
|
|
mov [ebp+NTFS.BitmapLocation], eax
|
|
|
|
; read MFT $BITMAP attribute
|
|
|
|
mov eax, [ebp+NTFS.sectors_per_cluster]
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_size], eax
|
2015-12-10 11:45:32 +01:00
|
|
|
shl eax, 9
|
|
|
|
stdcall kernel_alloc, eax
|
|
|
|
test eax, eax
|
|
|
|
jz .failFreeBitmap
|
|
|
|
mov [ebp+NTFS.mftBitmapBuffer], eax
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_buf], eax
|
|
|
|
mov [ebp+NTFS.cur_iRecord], 0
|
|
|
|
mov [ebp+NTFS.cur_attr], 0xB0
|
|
|
|
mov [ebp+NTFS.cur_offs], 0
|
2015-12-10 11:45:32 +01:00
|
|
|
call ntfs_read_attr
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, [ebp+NTFS.cur_read]
|
2015-12-10 11:45:32 +01:00
|
|
|
cmp eax, 4
|
|
|
|
jc .failFreeBitmapMFT
|
2016-02-21 03:13:21 +01:00
|
|
|
mov ecx, [ebp+NTFS.attr_offs]
|
2016-01-28 00:48:14 +01:00
|
|
|
cmp byte [ecx+nonResidentFlag], 1
|
|
|
|
jnz .failFreeBitmapMFT
|
2015-12-10 11:45:32 +01:00
|
|
|
mov [ebp+NTFS.mftBitmapSize], eax
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, [ebp+NTFS.LastRead]
|
2015-12-10 11:45:32 +01:00
|
|
|
mov [ebp+NTFS.mftBitmapLocation], eax
|
|
|
|
|
|
|
|
mov eax, ebp
|
|
|
|
.pop_exit:
|
|
|
|
pop esi ebp ebx
|
|
|
|
.exit:
|
|
|
|
cmp dword [esp+4], 0
|
|
|
|
jz @f
|
|
|
|
sub ebx, 512
|
|
|
|
@@:
|
|
|
|
ret
|
2011-10-14 23:38:50 +02:00
|
|
|
|
2015-12-10 11:45:32 +01:00
|
|
|
.failFreeBitmapMFT:
|
2016-04-21 19:41:56 +02:00
|
|
|
stdcall kernel_free, [ebp+NTFS.mftBitmapBuffer]
|
2015-12-10 11:45:32 +01:00
|
|
|
.failFreeBitmap:
|
2016-04-21 19:41:56 +02:00
|
|
|
stdcall kernel_free, [ebp+NTFS.BitmapBuffer]
|
2015-12-10 11:45:32 +01:00
|
|
|
.failFreeIndex:
|
2016-04-21 19:41:56 +02:00
|
|
|
mov eax, [ebp+NTFS.cur_index_buf]
|
|
|
|
cmp eax, [ebp+NTFS.secondIndexBuffer]
|
|
|
|
jc @f
|
|
|
|
mov eax, [ebp+NTFS.secondIndexBuffer]
|
|
|
|
@@:
|
|
|
|
stdcall kernel_free, eax
|
2015-12-10 11:45:32 +01:00
|
|
|
.fail_free_frs:
|
|
|
|
stdcall kernel_free, [ebp+NTFS.frs_buffer]
|
|
|
|
.fail_free:
|
2016-04-21 19:41:56 +02:00
|
|
|
stdcall kernel_free, ebp
|
2015-12-10 11:45:32 +01:00
|
|
|
xor eax, eax
|
2013-07-01 18:29:16 +02:00
|
|
|
jmp .pop_exit
|
2011-10-14 23:38:50 +02:00
|
|
|
|
2015-12-10 11:45:32 +01:00
|
|
|
ntfs_free:
|
2013-07-01 18:29:16 +02:00
|
|
|
push ebx
|
2015-12-10 11:45:32 +01:00
|
|
|
mov ebx, eax
|
2013-07-01 18:29:16 +02:00
|
|
|
stdcall kernel_free, [ebx+NTFS.frs_buffer]
|
2015-12-10 11:45:32 +01:00
|
|
|
stdcall kernel_free, [ebx+NTFS.mftBitmapBuffer]
|
|
|
|
stdcall kernel_free, [ebx+NTFS.BitmapBuffer]
|
2016-04-21 19:41:56 +02:00
|
|
|
mov eax, [ebx+NTFS.cur_index_buf]
|
|
|
|
cmp eax, [ebx+NTFS.secondIndexBuffer]
|
|
|
|
jc @f
|
|
|
|
mov eax, [ebx+NTFS.secondIndexBuffer]
|
|
|
|
@@:
|
|
|
|
stdcall kernel_free, eax
|
|
|
|
stdcall kernel_free, ebx
|
2013-07-01 18:29:16 +02:00
|
|
|
pop ebx
|
2016-04-21 19:41:56 +02:00
|
|
|
ret
|
2013-07-01 18:29:16 +02:00
|
|
|
|
2015-12-10 11:45:32 +01:00
|
|
|
ntfs_lock:
|
2013-07-01 18:29:16 +02:00
|
|
|
lea ecx, [ebp+NTFS.Lock]
|
|
|
|
jmp mutex_lock
|
|
|
|
|
2015-12-10 11:45:32 +01:00
|
|
|
ntfs_unlock:
|
2013-07-01 18:29:16 +02:00
|
|
|
lea ecx, [ebp+NTFS.Lock]
|
|
|
|
jmp mutex_unlock
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
ntfs_read_attr:
|
2016-02-21 03:13:21 +01:00
|
|
|
; [ebp+NTFS.bWriteAttr]=1 -> write attribute
|
2015-12-10 11:45:32 +01:00
|
|
|
; in:
|
2016-02-21 03:13:21 +01:00
|
|
|
; [ebp+NTFS.cur_iRecord] = number of fileRecord
|
|
|
|
; [ebp+NTFS.cur_attr] = attribute type
|
|
|
|
; [ebp+NTFS.cur_offs] = attribute VCN in sectors
|
|
|
|
; [ebp+NTFS.cur_buf] -> buffer for data
|
|
|
|
; [ebp+NTFS.cur_size] = max sectors to read
|
2015-12-10 11:45:32 +01:00
|
|
|
; out:
|
2016-02-21 03:13:21 +01:00
|
|
|
; [ebp+NTFS.cur_read] = bytes readen
|
2015-12-10 11:45:32 +01:00
|
|
|
; CF=1 -> failed, eax = disk error code, eax=0 -> something with FS
|
2013-07-01 18:29:16 +02:00
|
|
|
xor eax, eax
|
2011-10-14 23:38:50 +02:00
|
|
|
pushad
|
2016-02-21 03:13:21 +01:00
|
|
|
and [ebp+NTFS.cur_read], 0
|
|
|
|
cmp [ebp+NTFS.cur_iRecord], 0
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz .nomft
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.cur_attr], 0x80
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz .nomft
|
|
|
|
; precalculated part of $Mft $DATA
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, [ebp+NTFS.cur_offs]
|
2011-10-14 23:38:50 +02:00
|
|
|
xor edx, edx
|
2013-07-01 18:29:16 +02:00
|
|
|
div [ebp+NTFS.sectors_per_cluster]
|
2016-04-21 19:41:56 +02:00
|
|
|
mov ebx, edx
|
2016-05-04 19:36:09 +02:00
|
|
|
mov [ebp+NTFS.fragmentCount], 0
|
2016-04-21 19:41:56 +02:00
|
|
|
; eax = VCN, ebx = offset in sectors from beginning of cluster
|
|
|
|
lea esi, [ebp+NTFS.mft_retrieval]
|
|
|
|
sub esi, 8
|
2011-10-14 23:38:50 +02:00
|
|
|
.mftscan:
|
|
|
|
add esi, 8
|
2016-04-21 19:41:56 +02:00
|
|
|
cmp esi, [ebp+NTFS.mft_retrieval_end]
|
|
|
|
jz .nomft
|
|
|
|
mov ecx, [esi+4]
|
|
|
|
sub eax, [esi]
|
|
|
|
jnc .mftscan
|
2011-10-14 23:38:50 +02:00
|
|
|
add ecx, eax
|
|
|
|
add ecx, [esi]
|
2016-04-21 19:41:56 +02:00
|
|
|
neg eax
|
|
|
|
mul [ebp+NTFS.sectors_per_cluster]
|
|
|
|
xchg eax, ecx
|
|
|
|
mul [ebp+NTFS.sectors_per_cluster]
|
|
|
|
sub ecx, ebx
|
|
|
|
add eax, ebx
|
2016-02-21 03:13:21 +01:00
|
|
|
mov ebx, [ebp+NTFS.cur_buf]
|
|
|
|
cmp ecx, [ebp+NTFS.cur_size]
|
2011-10-14 23:38:50 +02:00
|
|
|
jb @f
|
2016-02-21 03:13:21 +01:00
|
|
|
mov ecx, [ebp+NTFS.cur_size]
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
2016-04-21 19:41:56 +02:00
|
|
|
mov [ebp+NTFS.LastRead], eax
|
|
|
|
mov edi, ecx
|
|
|
|
call fs_read64_sys
|
2013-07-01 18:29:16 +02:00
|
|
|
test eax, eax
|
2016-04-21 19:41:56 +02:00
|
|
|
jnz .errret
|
|
|
|
sub [ebp+NTFS.cur_size], edi
|
|
|
|
add [ebp+NTFS.cur_offs], edi
|
|
|
|
shl edi, 9
|
|
|
|
add [ebp+NTFS.cur_read], edi
|
|
|
|
add [ebp+NTFS.cur_buf], edi
|
2016-05-04 19:36:09 +02:00
|
|
|
inc [ebp+NTFS.fragmentCount]
|
2011-10-14 23:38:50 +02:00
|
|
|
xor eax, eax
|
2016-04-21 19:41:56 +02:00
|
|
|
xor ebx, ebx
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.cur_size], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
jz @f
|
|
|
|
jmp .mftscan
|
2016-02-29 11:15:30 +01:00
|
|
|
|
|
|
|
.errret2_pop:
|
|
|
|
xor eax, eax
|
|
|
|
.errret_pop:
|
|
|
|
pop ecx
|
2011-10-14 23:38:50 +02:00
|
|
|
pop ecx
|
|
|
|
.errret:
|
2013-07-01 18:29:16 +02:00
|
|
|
mov [esp+28], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
stc
|
2016-02-29 11:15:30 +01:00
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
popad
|
|
|
|
ret
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.nomft:
|
|
|
|
; 1. Read file record.
|
|
|
|
; N.B. This will do recursive call of read_attr for $MFT::$Data.
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, [ebp+NTFS.cur_iRecord]
|
|
|
|
and [ebp+NTFS.attr_list], 0
|
|
|
|
or dword [ebp+NTFS.attr_size+4], -1
|
|
|
|
or [ebp+NTFS.attr_iBaseRecord], -1
|
2011-10-14 23:38:50 +02:00
|
|
|
call ntfs_read_file_record
|
2013-07-01 18:29:16 +02:00
|
|
|
jc .errret
|
2011-10-14 23:38:50 +02:00
|
|
|
; 2. Find required attribute.
|
2013-07-01 18:29:16 +02:00
|
|
|
mov eax, [ebp+NTFS.frs_buffer]
|
2016-01-28 00:48:14 +01:00
|
|
|
; a) For auxiliary records, read base record.
|
|
|
|
; If base record is present, base iRecord may be 0 (for $Mft),
|
|
|
|
; but SequenceNumber is nonzero.
|
2016-02-29 11:15:30 +01:00
|
|
|
cmp word [eax+baseRecordReuse], 0
|
2011-10-14 23:38:50 +02:00
|
|
|
jz @f
|
2016-02-29 11:15:30 +01:00
|
|
|
mov eax, [eax+baseRecordReference]
|
2011-10-14 23:38:50 +02:00
|
|
|
.beginfindattr:
|
|
|
|
call ntfs_read_file_record
|
2013-07-01 18:29:16 +02:00
|
|
|
jc .errret
|
2016-01-28 00:48:14 +01:00
|
|
|
jmp @f
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2016-01-28 00:48:14 +01:00
|
|
|
.newAttribute:
|
|
|
|
pushad
|
2016-02-29 11:15:30 +01:00
|
|
|
and [ebp+NTFS.cur_read], 0
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
; b) Scan for required attribute and for $ATTR_LIST
|
2013-07-01 18:29:16 +02:00
|
|
|
mov eax, [ebp+NTFS.frs_buffer]
|
2016-02-29 11:15:30 +01:00
|
|
|
movzx ecx, word [eax+attributeOffset]
|
2011-10-14 23:38:50 +02:00
|
|
|
add eax, ecx
|
2016-02-21 03:13:21 +01:00
|
|
|
mov ecx, [ebp+NTFS.cur_attr]
|
|
|
|
and [ebp+NTFS.attr_offs], 0
|
2011-10-14 23:38:50 +02:00
|
|
|
.scanattr:
|
|
|
|
cmp dword [eax], -1
|
|
|
|
jz .scandone
|
|
|
|
cmp dword [eax], ecx
|
|
|
|
jz .okattr
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.attr_iBaseRecord], -1
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz .scancont
|
|
|
|
cmp dword [eax], 0x20 ; $ATTR_LIST
|
|
|
|
jnz .scancont
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.attr_list], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
jmp .scancont
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.okattr:
|
|
|
|
; ignore named $DATA attributes (aka NTFS streams)
|
|
|
|
cmp ecx, 0x80
|
|
|
|
jnz @f
|
2016-02-29 11:15:30 +01:00
|
|
|
cmp byte [eax+nameLength], 0
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz .scancont
|
|
|
|
@@:
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.attr_offs], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
.scancont:
|
2016-02-29 11:15:30 +01:00
|
|
|
add eax, [eax+sizeWithHeader]
|
2011-10-14 23:38:50 +02:00
|
|
|
jmp .scanattr
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.continue:
|
|
|
|
pushad
|
2016-02-21 03:13:21 +01:00
|
|
|
and [ebp+NTFS.cur_read], 0
|
2011-10-14 23:38:50 +02:00
|
|
|
.scandone:
|
|
|
|
; c) Check for required offset and length
|
2016-02-21 03:13:21 +01:00
|
|
|
mov ecx, [ebp+NTFS.attr_offs]
|
2011-10-14 23:38:50 +02:00
|
|
|
jecxz .noattr
|
2016-02-21 03:13:21 +01:00
|
|
|
push [ebp+NTFS.cur_size]
|
|
|
|
push [ebp+NTFS.cur_read]
|
2011-10-14 23:38:50 +02:00
|
|
|
call .doreadattr
|
|
|
|
pop edx
|
2013-07-01 18:29:16 +02:00
|
|
|
pop ecx
|
2016-02-29 11:15:30 +01:00
|
|
|
jc .ret
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.bCanContinue], 0
|
2016-02-29 11:15:30 +01:00
|
|
|
jz .ret
|
2016-02-21 03:13:21 +01:00
|
|
|
sub edx, [ebp+NTFS.cur_read]
|
2011-10-14 23:38:50 +02:00
|
|
|
neg edx
|
|
|
|
shr edx, 9
|
2013-07-01 18:29:16 +02:00
|
|
|
sub ecx, edx
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_size], ecx
|
2016-02-29 11:15:30 +01:00
|
|
|
jz .ret
|
2011-10-14 23:38:50 +02:00
|
|
|
.noattr:
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.cur_attr], 0x20
|
2011-10-14 23:38:50 +02:00
|
|
|
jz @f
|
2016-02-21 03:13:21 +01:00
|
|
|
mov ecx, [ebp+NTFS.attr_list]
|
2011-10-14 23:38:50 +02:00
|
|
|
test ecx, ecx
|
|
|
|
jnz .lookattr
|
2013-07-01 18:29:16 +02:00
|
|
|
and dword [esp+28], 0
|
2016-02-29 11:15:30 +01:00
|
|
|
cmp [ebp+NTFS.attr_offs], 1 ; define CF
|
|
|
|
.ret:
|
2011-10-14 23:38:50 +02:00
|
|
|
popad
|
|
|
|
ret
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.lookattr:
|
|
|
|
; required attribute or required offset was not found in base record;
|
|
|
|
; it may be present in auxiliary records;
|
|
|
|
; scan $ATTR_LIST
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, [ebp+NTFS.attr_iBaseRecord]
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp eax, -1
|
|
|
|
jz @f
|
|
|
|
call ntfs_read_file_record
|
2013-07-01 18:29:16 +02:00
|
|
|
jc .errret
|
2016-02-21 03:13:21 +01:00
|
|
|
or [ebp+NTFS.attr_iBaseRecord], -1
|
|
|
|
@@:
|
|
|
|
push [ebp+NTFS.cur_offs]
|
|
|
|
push [ebp+NTFS.cur_size]
|
|
|
|
push [ebp+NTFS.cur_read]
|
|
|
|
push [ebp+NTFS.cur_buf]
|
|
|
|
push dword [ebp+NTFS.attr_size]
|
|
|
|
push dword [ebp+NTFS.attr_size+4]
|
|
|
|
or dword [ebp+NTFS.attr_size+4], -1
|
|
|
|
and [ebp+NTFS.cur_offs], 0
|
|
|
|
mov [ebp+NTFS.cur_size], 2
|
|
|
|
and [ebp+NTFS.cur_read], 0
|
|
|
|
lea eax, [ebp+NTFS.attrlist_buf]
|
|
|
|
cmp [ebp+NTFS.cur_iRecord], 0
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz @f
|
2016-02-21 03:13:21 +01:00
|
|
|
lea eax, [ebp+NTFS.attrlist_mft_buf]
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_buf], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
push eax
|
|
|
|
call .doreadattr
|
|
|
|
pop esi
|
|
|
|
mov edx, 1
|
2016-02-21 03:13:21 +01:00
|
|
|
pop dword [ebp+NTFS.attr_size+4]
|
|
|
|
pop dword [ebp+NTFS.attr_size]
|
|
|
|
mov ecx, [ebp+NTFS.cur_read]
|
|
|
|
pop [ebp+NTFS.cur_buf]
|
|
|
|
pop [ebp+NTFS.cur_read]
|
|
|
|
pop [ebp+NTFS.cur_size]
|
|
|
|
pop [ebp+NTFS.cur_offs]
|
2011-10-14 23:38:50 +02:00
|
|
|
jc .errret
|
|
|
|
or edi, -1
|
2013-07-01 18:29:16 +02:00
|
|
|
lea ecx, [ecx+esi-1Ah]
|
2011-10-14 23:38:50 +02:00
|
|
|
.scanliststart:
|
2013-07-01 18:29:16 +02:00
|
|
|
push ecx
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, [ebp+NTFS.cur_attr]
|
2011-10-14 23:38:50 +02:00
|
|
|
.scanlist:
|
2013-07-01 18:29:16 +02:00
|
|
|
cmp esi, [esp]
|
2011-10-14 23:38:50 +02:00
|
|
|
jae .scanlistdone
|
|
|
|
cmp eax, [esi]
|
|
|
|
jz @f
|
|
|
|
.scanlistcont:
|
|
|
|
movzx ecx, word [esi+4]
|
|
|
|
add esi, ecx
|
|
|
|
jmp .scanlist
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
; ignore named $DATA attributes (aka NTFS streams)
|
|
|
|
cmp eax, 0x80
|
|
|
|
jnz @f
|
|
|
|
cmp byte [esi+6], 0
|
|
|
|
jnz .scanlistcont
|
|
|
|
@@:
|
|
|
|
push eax
|
|
|
|
mov eax, [esi+8]
|
|
|
|
test eax, eax
|
|
|
|
jnz .testf
|
2016-04-26 02:41:42 +02:00
|
|
|
cmp dword [ebp+NTFS.attr_size+4], -1
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz .testfz
|
|
|
|
; if attribute is in auxiliary records, its size is defined only in first
|
|
|
|
mov eax, [esi+10h]
|
|
|
|
call ntfs_read_file_record
|
2016-02-29 11:15:30 +01:00
|
|
|
jc .errret_pop
|
2013-07-01 18:29:16 +02:00
|
|
|
mov eax, [ebp+NTFS.frs_buffer]
|
2011-10-14 23:38:50 +02:00
|
|
|
movzx ecx, word [eax+14h]
|
|
|
|
add eax, ecx
|
2016-02-21 03:13:21 +01:00
|
|
|
mov ecx, [ebp+NTFS.cur_attr]
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
cmp dword [eax], -1
|
2013-07-01 18:29:16 +02:00
|
|
|
jz .errret2_pop
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp dword [eax], ecx
|
|
|
|
jz @f
|
|
|
|
.l1:
|
|
|
|
add eax, [eax+4]
|
|
|
|
jmp @b
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
cmp eax, 0x80
|
|
|
|
jnz @f
|
|
|
|
cmp byte [eax+9], 0
|
|
|
|
jnz .l1
|
|
|
|
@@:
|
|
|
|
cmp byte [eax+8], 0
|
|
|
|
jnz .sdnores
|
|
|
|
mov eax, [eax+10h]
|
2016-02-21 03:13:21 +01:00
|
|
|
mov dword [ebp+NTFS.attr_size], eax
|
|
|
|
and dword [ebp+NTFS.attr_size+4], 0
|
2011-10-14 23:38:50 +02:00
|
|
|
jmp .testfz
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.sdnores:
|
|
|
|
mov ecx, [eax+30h]
|
2016-02-21 03:13:21 +01:00
|
|
|
mov dword [ebp+NTFS.attr_size], ecx
|
2011-10-14 23:38:50 +02:00
|
|
|
mov ecx, [eax+34h]
|
2016-02-21 03:13:21 +01:00
|
|
|
mov dword [ebp+NTFS.attr_size+4], ecx
|
2011-10-14 23:38:50 +02:00
|
|
|
.testfz:
|
|
|
|
xor eax, eax
|
|
|
|
.testf:
|
2013-07-01 18:29:16 +02:00
|
|
|
imul eax, [ebp+NTFS.sectors_per_cluster]
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp eax, [ebp+NTFS.cur_offs]
|
2011-10-14 23:38:50 +02:00
|
|
|
pop eax
|
|
|
|
ja @f
|
|
|
|
mov edi, [esi+10h] ; keep previous iRecord
|
|
|
|
jmp .scanlistcont
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
2013-07-01 18:29:16 +02:00
|
|
|
pop ecx
|
2011-10-14 23:38:50 +02:00
|
|
|
.scanlistfound:
|
|
|
|
cmp edi, -1
|
2016-02-29 11:15:30 +01:00
|
|
|
jz .ret
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, [ebp+NTFS.cur_iRecord]
|
|
|
|
mov [ebp+NTFS.attr_iBaseRecord], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
mov eax, edi
|
|
|
|
jmp .beginfindattr
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.scanlistdone:
|
2013-07-01 18:29:16 +02:00
|
|
|
pop ecx
|
|
|
|
sub ecx, ebp
|
2016-02-21 03:13:21 +01:00
|
|
|
sub ecx, NTFS.attrlist_buf-1Ah
|
|
|
|
cmp [ebp+NTFS.cur_iRecord], 0
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz @f
|
2016-02-21 03:13:21 +01:00
|
|
|
sub ecx, NTFS.attrlist_mft_buf-NTFS.attrlist_buf
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
2013-07-01 18:29:16 +02:00
|
|
|
cmp ecx, 0x400
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz .scanlistfound
|
|
|
|
inc edx
|
|
|
|
push esi edi
|
2016-02-21 03:13:21 +01:00
|
|
|
lea esi, [ebp+NTFS.attrlist_buf+0x200]
|
|
|
|
lea edi, [ebp+NTFS.attrlist_buf]
|
|
|
|
cmp [ebp+NTFS.cur_iRecord], 0
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz @f
|
2016-02-21 03:13:21 +01:00
|
|
|
lea esi, [ebp+NTFS.attrlist_mft_buf+0x200]
|
|
|
|
lea edi, [ebp+NTFS.attrlist_mft_buf]
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
mov ecx, 0x200/4
|
|
|
|
rep movsd
|
|
|
|
mov eax, edi
|
|
|
|
pop edi esi
|
|
|
|
sub esi, 0x200
|
2016-02-21 03:13:21 +01:00
|
|
|
push [ebp+NTFS.cur_offs]
|
|
|
|
push [ebp+NTFS.cur_size]
|
|
|
|
push [ebp+NTFS.cur_read]
|
|
|
|
push [ebp+NTFS.cur_buf]
|
|
|
|
push dword [ebp+NTFS.attr_size]
|
|
|
|
push dword [ebp+NTFS.attr_size+4]
|
|
|
|
or dword [ebp+NTFS.attr_size+4], -1
|
|
|
|
mov [ebp+NTFS.cur_offs], edx
|
|
|
|
mov [ebp+NTFS.cur_size], 1
|
|
|
|
and [ebp+NTFS.cur_read], 0
|
|
|
|
mov [ebp+NTFS.cur_buf], eax
|
|
|
|
mov ecx, [ebp+NTFS.attr_list]
|
2013-07-01 18:29:16 +02:00
|
|
|
push esi edx edi
|
2011-10-14 23:38:50 +02:00
|
|
|
call .doreadattr
|
2013-07-01 18:29:16 +02:00
|
|
|
pop edi edx esi
|
2016-02-21 03:13:21 +01:00
|
|
|
mov ecx, [ebp+NTFS.cur_read]
|
|
|
|
pop dword [ebp+NTFS.attr_size+4]
|
|
|
|
pop dword [ebp+NTFS.attr_size]
|
|
|
|
pop [ebp+NTFS.cur_buf]
|
|
|
|
pop [ebp+NTFS.cur_read]
|
|
|
|
pop [ebp+NTFS.cur_size]
|
|
|
|
pop [ebp+NTFS.cur_offs]
|
2011-10-14 23:38:50 +02:00
|
|
|
jc .errret
|
2016-02-21 03:13:21 +01:00
|
|
|
lea ecx, [ecx+ebp+NTFS.attrlist_buf+0x200-0x1A]
|
|
|
|
cmp [ebp+NTFS.cur_iRecord], 0
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz .scanliststart
|
2016-02-21 03:13:21 +01:00
|
|
|
add ecx, NTFS.attrlist_mft_buf-NTFS.attrlist_buf
|
2011-10-14 23:38:50 +02:00
|
|
|
jmp .scanliststart
|
|
|
|
|
|
|
|
.doreadattr:
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.bCanContinue], 0
|
2016-02-29 11:15:30 +01:00
|
|
|
cmp byte [ecx+nonResidentFlag], 0
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz .nonresident
|
2016-02-29 11:15:30 +01:00
|
|
|
mov eax, [ecx+sizeWithoutHeader]
|
2011-10-14 23:38:50 +02:00
|
|
|
mov esi, eax
|
2016-02-21 03:13:21 +01:00
|
|
|
mov edx, [ebp+NTFS.cur_offs]
|
2011-10-14 23:38:50 +02:00
|
|
|
shr eax, 9
|
|
|
|
cmp eax, edx
|
|
|
|
jb .okret
|
|
|
|
shl edx, 9
|
|
|
|
sub esi, edx
|
2016-02-29 11:15:30 +01:00
|
|
|
movzx eax, word [ecx+attributeOffset]
|
2011-10-14 23:38:50 +02:00
|
|
|
add edx, eax
|
|
|
|
add edx, ecx ; edx -> data
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, [ebp+NTFS.cur_size]
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp eax, (0xFFFFFFFF shr 9)+1
|
|
|
|
jbe @f
|
|
|
|
mov eax, (0xFFFFFFFF shr 9)+1
|
|
|
|
@@:
|
|
|
|
shl eax, 9
|
|
|
|
cmp eax, esi
|
|
|
|
jbe @f
|
|
|
|
mov eax, esi
|
|
|
|
@@:
|
|
|
|
; eax = length, edx -> data
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_read], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
mov ecx, eax
|
|
|
|
mov eax, edx
|
2016-02-21 03:13:21 +01:00
|
|
|
mov ebx, [ebp+NTFS.cur_buf]
|
2011-10-14 23:38:50 +02:00
|
|
|
call memmove
|
2016-02-21 03:13:21 +01:00
|
|
|
and [ebp+NTFS.cur_size], 0 ; CF=0
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.nonresident:
|
|
|
|
; Not all auxiliary records contain correct FileSize info
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, dword [ebp+NTFS.attr_size]
|
|
|
|
mov edx, dword [ebp+NTFS.attr_size+4]
|
2016-04-26 02:41:42 +02:00
|
|
|
cmp edx, -1
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz @f
|
2016-02-29 11:15:30 +01:00
|
|
|
mov eax, [ecx+attributeRealSize]
|
|
|
|
mov edx, [ecx+attributeRealSize+4]
|
2016-02-21 03:13:21 +01:00
|
|
|
mov dword [ebp+NTFS.attr_size], eax
|
|
|
|
mov dword [ebp+NTFS.attr_size+4], edx
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
add eax, 0x1FF
|
|
|
|
adc edx, 0
|
|
|
|
shrd eax, edx, 9
|
2016-02-21 03:13:21 +01:00
|
|
|
sub eax, [ebp+NTFS.cur_offs]
|
2011-10-14 23:38:50 +02:00
|
|
|
ja @f
|
|
|
|
; return with nothing read
|
2016-02-21 03:13:21 +01:00
|
|
|
and [ebp+NTFS.cur_size], 0
|
2011-10-14 23:38:50 +02:00
|
|
|
.okret:
|
|
|
|
clc
|
|
|
|
ret
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
; reduce read length
|
2016-02-21 03:13:21 +01:00
|
|
|
and [ebp+NTFS.cur_tail], 0
|
|
|
|
cmp [ebp+NTFS.cur_size], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
jb @f
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_size], eax
|
|
|
|
mov eax, dword [ebp+NTFS.attr_size]
|
2011-10-14 23:38:50 +02:00
|
|
|
and eax, 0x1FF
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_tail], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, [ebp+NTFS.cur_offs]
|
2011-10-14 23:38:50 +02:00
|
|
|
xor edx, edx
|
2013-07-01 18:29:16 +02:00
|
|
|
div [ebp+NTFS.sectors_per_cluster]
|
2016-02-29 11:15:30 +01:00
|
|
|
sub eax, [ecx+firstVCN]
|
2011-10-14 23:38:50 +02:00
|
|
|
jb .okret
|
2016-04-21 19:41:56 +02:00
|
|
|
mov ebx, edx
|
|
|
|
; eax = starting cluster, ebx = sector in the cluster
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.cur_attr], 0x80
|
2015-12-21 12:47:21 +01:00
|
|
|
jnz .sys
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.cur_iRecord], 0
|
2015-12-21 12:47:21 +01:00
|
|
|
jz .sys
|
|
|
|
push fs_read64_app
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.bWriteAttr], 1
|
2015-12-21 12:47:21 +01:00
|
|
|
jnz @f
|
|
|
|
mov dword[esp], fs_write64_app
|
|
|
|
jmp @f
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2015-12-21 12:47:21 +01:00
|
|
|
.sys:
|
|
|
|
push fs_read64_sys
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
sub esp, 10h
|
2016-02-29 11:15:30 +01:00
|
|
|
movzx esi, word [ecx+dataRunsOffset]
|
2011-10-14 23:38:50 +02:00
|
|
|
add esi, ecx
|
2013-07-01 18:29:16 +02:00
|
|
|
xor edi, edi
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.fragmentCount], 0
|
2011-10-14 23:38:50 +02:00
|
|
|
.readloop:
|
|
|
|
call ntfs_decode_mcb_entry
|
|
|
|
jnc .break
|
2013-07-01 18:29:16 +02:00
|
|
|
add edi, [esp+8]
|
2011-10-14 23:38:50 +02:00
|
|
|
sub eax, [esp]
|
|
|
|
jae .readloop
|
2016-04-21 19:41:56 +02:00
|
|
|
mov ecx, edi
|
|
|
|
add ecx, eax
|
|
|
|
add ecx, [esp]
|
|
|
|
neg eax
|
|
|
|
mul [ebp+NTFS.sectors_per_cluster]
|
|
|
|
xchg eax, ecx
|
|
|
|
mul [ebp+NTFS.sectors_per_cluster]
|
|
|
|
sub ecx, ebx
|
|
|
|
add eax, ebx
|
|
|
|
mov ebx, [ebp+NTFS.cur_buf]
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp ecx, [ebp+NTFS.cur_size]
|
2011-10-14 23:38:50 +02:00
|
|
|
jb @f
|
2016-02-21 03:13:21 +01:00
|
|
|
mov ecx, [ebp+NTFS.cur_size]
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.LastRead], eax
|
2015-12-10 11:45:32 +01:00
|
|
|
push ecx
|
2016-04-21 19:41:56 +02:00
|
|
|
call dword[esp+14h]
|
2015-12-10 11:45:32 +01:00
|
|
|
pop ecx
|
2013-07-01 18:29:16 +02:00
|
|
|
test eax, eax
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz .errread2
|
2016-02-21 03:13:21 +01:00
|
|
|
sub [ebp+NTFS.cur_size], ecx
|
|
|
|
add [ebp+NTFS.cur_offs], ecx
|
2015-12-10 11:45:32 +01:00
|
|
|
shl ecx, 9
|
2016-02-21 03:13:21 +01:00
|
|
|
add [ebp+NTFS.cur_read], ecx
|
|
|
|
add [ebp+NTFS.cur_buf], ecx
|
|
|
|
inc [ebp+NTFS.fragmentCount]
|
2011-10-14 23:38:50 +02:00
|
|
|
xor eax, eax
|
2016-04-21 19:41:56 +02:00
|
|
|
xor ebx, ebx
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.cur_size], 0
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz .readloop
|
2015-12-21 12:47:21 +01:00
|
|
|
add esp, 14h
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, [ebp+NTFS.cur_tail]
|
2011-10-14 23:38:50 +02:00
|
|
|
test eax, eax
|
|
|
|
jz @f
|
|
|
|
sub eax, 0x200
|
2016-02-21 03:13:21 +01:00
|
|
|
add [ebp+NTFS.cur_read], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
clc
|
|
|
|
ret
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.errread2:
|
2015-12-21 12:47:21 +01:00
|
|
|
add esp, 14h
|
2011-10-14 23:38:50 +02:00
|
|
|
stc
|
|
|
|
ret
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.break:
|
2015-12-21 12:47:21 +01:00
|
|
|
add esp, 14h ; CF=0
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.bCanContinue], 1
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
ntfs_read_file_record:
|
2015-12-10 11:45:32 +01:00
|
|
|
; in: eax = iRecord
|
2016-01-19 20:45:51 +01:00
|
|
|
; out: [ebp+NTFS.frs_buffer] -> file record
|
2015-12-10 11:45:32 +01:00
|
|
|
; CF=1 -> failed, eax = disk error code, eax=0 -> something with FS
|
|
|
|
; Read attr $DATA of $Mft, starting from eax*[ebp+NTFS.frs_size]
|
2011-10-14 23:38:50 +02:00
|
|
|
push ecx edx
|
2013-07-01 18:29:16 +02:00
|
|
|
mov ecx, [ebp+NTFS.frs_size]
|
2011-10-14 23:38:50 +02:00
|
|
|
mul ecx
|
|
|
|
shrd eax, edx, 9
|
|
|
|
shr edx, 9
|
2013-07-01 18:29:16 +02:00
|
|
|
jnz .errret
|
2016-02-21 03:13:21 +01:00
|
|
|
push [ebp+NTFS.attr_iBaseRecord]
|
|
|
|
push [ebp+NTFS.attr_offs]
|
|
|
|
push [ebp+NTFS.attr_list]
|
|
|
|
push dword [ebp+NTFS.attr_size+4]
|
|
|
|
push dword [ebp+NTFS.attr_size]
|
|
|
|
push [ebp+NTFS.cur_iRecord]
|
|
|
|
push [ebp+NTFS.cur_attr]
|
|
|
|
push [ebp+NTFS.cur_offs]
|
|
|
|
push [ebp+NTFS.cur_size]
|
|
|
|
push [ebp+NTFS.cur_buf]
|
|
|
|
push [ebp+NTFS.cur_read]
|
|
|
|
mov [ebp+NTFS.cur_attr], 0x80 ; $DATA
|
|
|
|
and [ebp+NTFS.cur_iRecord], 0 ; $Mft
|
|
|
|
mov [ebp+NTFS.cur_offs], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
shr ecx, 9
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_size], ecx
|
2013-07-01 18:29:16 +02:00
|
|
|
mov eax, [ebp+NTFS.frs_buffer]
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_buf], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
call ntfs_read_attr
|
2016-02-21 03:13:21 +01:00
|
|
|
mov edx, [ebp+NTFS.cur_read]
|
|
|
|
pop [ebp+NTFS.cur_read]
|
|
|
|
pop [ebp+NTFS.cur_buf]
|
|
|
|
pop [ebp+NTFS.cur_size]
|
|
|
|
pop [ebp+NTFS.cur_offs]
|
|
|
|
pop [ebp+NTFS.cur_attr]
|
|
|
|
pop [ebp+NTFS.cur_iRecord]
|
|
|
|
pop dword [ebp+NTFS.attr_size]
|
|
|
|
pop dword [ebp+NTFS.attr_size+4]
|
|
|
|
pop [ebp+NTFS.attr_list]
|
|
|
|
pop [ebp+NTFS.attr_offs]
|
|
|
|
pop [ebp+NTFS.attr_iBaseRecord]
|
2013-07-01 18:29:16 +02:00
|
|
|
jc .ret
|
|
|
|
cmp edx, [ebp+NTFS.frs_size]
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz .errret
|
2016-04-27 10:48:17 +02:00
|
|
|
mov eax, [ebp+NTFS.LastRead]
|
|
|
|
mov [ebp+NTFS.mftLastRead], eax
|
2013-07-01 18:29:16 +02:00
|
|
|
mov eax, [ebp+NTFS.frs_buffer]
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp dword [eax], 'FILE'
|
|
|
|
jnz .errret
|
|
|
|
push ebx
|
|
|
|
mov ebx, eax
|
|
|
|
call ntfs_restore_usa_frs
|
|
|
|
pop ebx
|
2013-07-01 18:29:16 +02:00
|
|
|
jc .errret
|
2011-10-14 23:38:50 +02:00
|
|
|
.ret:
|
|
|
|
pop edx ecx
|
2013-07-01 18:29:16 +02:00
|
|
|
ret
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.errret:
|
2013-07-01 18:29:16 +02:00
|
|
|
pop edx ecx
|
2011-10-14 23:38:50 +02:00
|
|
|
xor eax, eax
|
2013-07-01 18:29:16 +02:00
|
|
|
stc
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
ntfs_restore_usa_frs:
|
2013-07-01 18:29:16 +02:00
|
|
|
mov eax, [ebp+NTFS.frs_size]
|
2011-10-14 23:38:50 +02:00
|
|
|
ntfs_restore_usa:
|
2016-01-19 20:45:51 +01:00
|
|
|
; in:
|
|
|
|
; ebx -> record
|
|
|
|
; eax = size in bytes
|
2011-10-14 23:38:50 +02:00
|
|
|
pushad
|
|
|
|
shr eax, 9
|
|
|
|
mov ecx, eax
|
|
|
|
inc eax
|
2016-02-29 11:15:30 +01:00
|
|
|
cmp [ebx+updateSequenceSize], ax
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz .err
|
2016-02-29 11:15:30 +01:00
|
|
|
movzx eax, word [ebx+updateSequenceOffset]
|
2011-10-14 23:38:50 +02:00
|
|
|
lea esi, [eax+ebx]
|
|
|
|
lodsw
|
|
|
|
mov edx, eax
|
|
|
|
lea edi, [ebx+0x1FE]
|
|
|
|
@@:
|
|
|
|
cmp [edi], dx
|
|
|
|
jnz .err
|
|
|
|
lodsw
|
|
|
|
stosw
|
|
|
|
add edi, 0x1FE
|
|
|
|
loop @b
|
|
|
|
popad
|
|
|
|
clc
|
|
|
|
ret
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.err:
|
|
|
|
popad
|
|
|
|
stc
|
|
|
|
ret
|
|
|
|
|
|
|
|
ntfs_decode_mcb_entry:
|
2015-12-31 18:29:37 +01:00
|
|
|
; in:
|
2016-01-19 20:45:51 +01:00
|
|
|
; esi -> MCB entry
|
2015-12-31 18:29:37 +01:00
|
|
|
; esp -> buffer (16 bytes)
|
|
|
|
; out:
|
2016-01-19 20:45:51 +01:00
|
|
|
; esi -> next MCB entry
|
2015-12-31 18:29:37 +01:00
|
|
|
; esp -> data run size
|
|
|
|
; esp+8 -> cluster (delta)
|
2016-01-19 20:45:51 +01:00
|
|
|
; CF=0 -> MCB end
|
2011-10-14 23:38:50 +02:00
|
|
|
push eax ecx edi
|
|
|
|
lea edi, [esp+16]
|
|
|
|
xor eax, eax
|
|
|
|
lodsb
|
|
|
|
test al, al
|
|
|
|
jz .end
|
|
|
|
mov ecx, eax
|
|
|
|
and ecx, 0xF
|
|
|
|
cmp ecx, 8
|
|
|
|
ja .end
|
|
|
|
push ecx
|
|
|
|
rep movsb
|
|
|
|
pop ecx
|
|
|
|
sub ecx, 8
|
|
|
|
neg ecx
|
|
|
|
cmp byte [esi-1], 80h
|
|
|
|
jae .end
|
|
|
|
push eax
|
|
|
|
xor eax, eax
|
|
|
|
rep stosb
|
|
|
|
pop ecx
|
|
|
|
shr ecx, 4
|
|
|
|
cmp ecx, 8
|
|
|
|
ja .end
|
|
|
|
push ecx
|
|
|
|
rep movsb
|
|
|
|
pop ecx
|
|
|
|
sub ecx, 8
|
|
|
|
neg ecx
|
|
|
|
cmp byte [esi-1], 80h
|
|
|
|
cmc
|
|
|
|
sbb eax, eax
|
|
|
|
rep stosb
|
|
|
|
stc
|
|
|
|
.end:
|
|
|
|
pop edi ecx eax
|
|
|
|
ret
|
|
|
|
|
|
|
|
unichar_toupper:
|
|
|
|
push eax
|
|
|
|
call uni2ansi_char
|
|
|
|
cmp al, '_'
|
|
|
|
jz .unk
|
|
|
|
add esp, 4
|
2010-06-24 00:18:42 +02:00
|
|
|
call char_toupper
|
|
|
|
jmp ansi2uni_char
|
|
|
|
.unk:
|
|
|
|
pop eax
|
|
|
|
ret
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
ntfs_find_lfn:
|
2015-12-10 11:45:32 +01:00
|
|
|
; in: [esi]+[esp+4] = name
|
|
|
|
; out:
|
2016-04-21 19:41:56 +02:00
|
|
|
; [ebp+NTFS.cur_iRecord] = target fileRecord
|
2016-04-30 08:52:50 +02:00
|
|
|
; eax -> target index in the node
|
|
|
|
; [ebp+NTFS.LastRead] = target node location
|
2016-04-21 19:41:56 +02:00
|
|
|
; [ebp+NTFS.indexPointer] -> index, that points the target subnode
|
2016-04-30 08:52:50 +02:00
|
|
|
; [ebp+NTFS.nodeLastRead] = branch node location
|
2016-04-21 19:41:56 +02:00
|
|
|
; [ebp+NTFS.indexRoot] -> attribute
|
2016-04-30 08:52:50 +02:00
|
|
|
; [ebp+NTFS.rootLastRead] = directory fileRecord location
|
2016-04-21 19:41:56 +02:00
|
|
|
; [ebp+NTFS.cur_size] = index record size in sectors
|
|
|
|
; [ebp+NTFS.cur_subnode_size] = index record size in clusters or sectors
|
2015-12-21 12:47:21 +01:00
|
|
|
; CF=1 -> file not found, eax=0 -> error
|
2016-02-29 11:15:30 +01:00
|
|
|
mov [ebp+NTFS.cur_iRecord], 5 ; start from root directory
|
2011-10-14 23:38:50 +02:00
|
|
|
.doit2:
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_attr], 0x90 ; $INDEX_ROOT
|
|
|
|
and [ebp+NTFS.cur_offs], 0
|
2013-07-01 18:29:16 +02:00
|
|
|
mov eax, [ebp+NTFS.cur_index_size]
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_size], eax
|
2013-07-01 18:29:16 +02:00
|
|
|
mov eax, [ebp+NTFS.cur_index_buf]
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_buf], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
call ntfs_read_attr
|
2015-12-21 12:47:21 +01:00
|
|
|
mov eax, 0
|
2016-02-29 11:15:30 +01:00
|
|
|
jc .ret
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.cur_read], 0x20
|
2011-10-14 23:38:50 +02:00
|
|
|
jc .ret
|
2016-05-04 19:36:09 +02:00
|
|
|
push esi
|
2011-10-14 23:38:50 +02:00
|
|
|
pushad
|
2013-07-01 18:29:16 +02:00
|
|
|
mov esi, [ebp+NTFS.cur_index_buf]
|
2016-03-15 07:18:38 +01:00
|
|
|
mov eax, [esi+indexRecordSize]
|
|
|
|
shr eax, 9
|
|
|
|
cmp [ebp+NTFS.cur_index_size], eax
|
2016-02-29 11:15:30 +01:00
|
|
|
jc .realloc
|
2016-03-15 07:18:38 +01:00
|
|
|
mov [ebp+NTFS.cur_size], eax
|
|
|
|
mov al, [esi+indexRecordSizeClus]
|
|
|
|
mov [ebp+NTFS.cur_subnode_size], eax
|
2016-02-29 11:15:30 +01:00
|
|
|
add esi, rootNode
|
|
|
|
mov eax, [esi+nodeRealSize]
|
|
|
|
add eax, rootNode
|
|
|
|
cmp [ebp+NTFS.cur_read], eax
|
|
|
|
jc .err
|
2011-10-14 23:38:50 +02:00
|
|
|
mov edi, [esp+4]
|
2016-04-27 10:48:17 +02:00
|
|
|
mov eax, [ebp+NTFS.mftLastRead]
|
2016-03-15 07:18:38 +01:00
|
|
|
mov [ebp+NTFS.rootLastRead], eax
|
|
|
|
mov eax, [ebp+NTFS.attr_offs]
|
|
|
|
mov [ebp+NTFS.indexRoot], eax
|
|
|
|
; edi -> name, esi -> current index node
|
2011-10-14 23:38:50 +02:00
|
|
|
.scanloop:
|
2016-02-29 11:15:30 +01:00
|
|
|
add esi, [esi+indexOffset]
|
2011-10-14 23:38:50 +02:00
|
|
|
.scanloopint:
|
2016-02-29 11:15:30 +01:00
|
|
|
test byte [esi+indexFlags], 2
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz .subnode
|
|
|
|
push esi
|
2016-02-29 11:15:30 +01:00
|
|
|
movzx ecx, byte [esi+fileNameLength]
|
|
|
|
add esi, fileName
|
2011-10-14 23:38:50 +02:00
|
|
|
push edi
|
|
|
|
@@:
|
|
|
|
lodsw
|
|
|
|
call unichar_toupper
|
|
|
|
push eax
|
|
|
|
mov al, [edi]
|
|
|
|
inc edi
|
|
|
|
cmp al, '/'
|
|
|
|
jz .slash
|
|
|
|
call char_toupper
|
|
|
|
call ansi2uni_char
|
|
|
|
cmp ax, [esp]
|
|
|
|
pop eax
|
|
|
|
loopz @b
|
|
|
|
jz .found
|
|
|
|
pop edi
|
|
|
|
pop esi
|
|
|
|
jb .subnode
|
|
|
|
.scanloopcont:
|
2016-02-29 11:15:30 +01:00
|
|
|
movzx eax, word [esi+indexAllocatedSize]
|
2011-10-14 23:38:50 +02:00
|
|
|
add esi, eax
|
|
|
|
jmp .scanloopint
|
2016-02-29 11:15:30 +01:00
|
|
|
|
|
|
|
.realloc:
|
2016-03-15 07:18:38 +01:00
|
|
|
mov edi, eax
|
|
|
|
mov eax, [esi+indexRecordSize]
|
|
|
|
shl eax, 1
|
|
|
|
stdcall kernel_alloc, eax
|
2016-02-29 11:15:30 +01:00
|
|
|
test eax, eax
|
|
|
|
jz .err
|
2016-04-21 19:41:56 +02:00
|
|
|
mov edx, [ebp+NTFS.cur_index_buf]
|
|
|
|
cmp edx, [ebp+NTFS.secondIndexBuffer]
|
|
|
|
jc @f
|
|
|
|
mov edx, [ebp+NTFS.secondIndexBuffer]
|
|
|
|
@@:
|
2016-02-29 11:15:30 +01:00
|
|
|
mov [ebp+NTFS.cur_index_buf], eax
|
2016-03-15 07:18:38 +01:00
|
|
|
add eax, [esi+indexRecordSize]
|
|
|
|
mov [ebp+NTFS.secondIndexBuffer], eax
|
2016-02-29 11:15:30 +01:00
|
|
|
mov [ebp+NTFS.cur_index_size], edi
|
2016-04-21 19:41:56 +02:00
|
|
|
stdcall kernel_free, edx
|
2016-02-29 11:15:30 +01:00
|
|
|
popad
|
2016-05-04 19:36:09 +02:00
|
|
|
pop eax
|
2016-02-29 11:15:30 +01:00
|
|
|
jmp .doit2
|
|
|
|
|
|
|
|
.notfound:
|
|
|
|
mov [esp+1Ch], esi
|
|
|
|
.err:
|
|
|
|
popad
|
|
|
|
stc
|
2016-05-04 19:36:09 +02:00
|
|
|
.ret2:
|
|
|
|
pop esi
|
2016-02-29 11:15:30 +01:00
|
|
|
.ret:
|
|
|
|
ret 4
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.slash:
|
|
|
|
pop eax
|
|
|
|
pop edi
|
|
|
|
pop esi
|
|
|
|
.subnode:
|
2016-02-29 11:15:30 +01:00
|
|
|
test byte [esi+indexFlags], 1
|
2011-10-14 23:38:50 +02:00
|
|
|
jz .notfound
|
2016-04-30 08:52:50 +02:00
|
|
|
mov eax, [ebp+NTFS.LastRead]
|
|
|
|
mov [ebp+NTFS.nodeLastRead], eax
|
|
|
|
mov [ebp+NTFS.indexPointer], esi
|
2016-02-29 11:15:30 +01:00
|
|
|
movzx eax, word [esi+indexAllocatedSize]
|
2011-10-14 23:38:50 +02:00
|
|
|
mov eax, [esi+eax-8]
|
2016-03-15 07:18:38 +01:00
|
|
|
mov edx, [ebp+NTFS.cur_size]
|
|
|
|
push edx
|
|
|
|
cmp edx, [ebp+NTFS.cur_subnode_size]
|
|
|
|
jz @f
|
|
|
|
mul [ebp+NTFS.sectors_per_cluster]
|
|
|
|
@@:
|
|
|
|
mov esi, [ebp+NTFS.cur_index_buf]
|
|
|
|
xchg [ebp+NTFS.secondIndexBuffer], esi
|
|
|
|
mov [ebp+NTFS.cur_index_buf], esi
|
|
|
|
mov [ebp+NTFS.cur_buf], esi
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_attr], 0xA0 ; $INDEX_ALLOCATION
|
2016-03-15 07:18:38 +01:00
|
|
|
mov [ebp+NTFS.cur_offs], eax
|
2016-02-29 11:15:30 +01:00
|
|
|
call ntfs_read_attr.newAttribute
|
2016-03-15 07:18:38 +01:00
|
|
|
pop eax
|
|
|
|
mov [ebp+NTFS.cur_size], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
shl eax, 9
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.cur_read], eax
|
2015-12-10 11:45:32 +01:00
|
|
|
jnz .err
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp dword [esi], 'INDX'
|
2015-12-10 11:45:32 +01:00
|
|
|
jnz .err
|
2011-10-14 23:38:50 +02:00
|
|
|
mov ebx, esi
|
|
|
|
call ntfs_restore_usa
|
2015-12-10 11:45:32 +01:00
|
|
|
jc .err
|
2016-02-29 11:15:30 +01:00
|
|
|
add esi, recordNode
|
2011-10-14 23:38:50 +02:00
|
|
|
jmp .scanloop
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.found:
|
|
|
|
cmp byte [edi], 0
|
2016-05-04 19:36:09 +02:00
|
|
|
jz @f
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp byte [edi], '/'
|
2016-05-04 19:36:09 +02:00
|
|
|
jz @f
|
2011-10-14 23:38:50 +02:00
|
|
|
pop edi
|
|
|
|
pop esi
|
|
|
|
jmp .scanloopcont
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2016-05-04 19:36:09 +02:00
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
pop esi
|
|
|
|
pop esi
|
|
|
|
mov eax, [esi]
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_iRecord], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [esp+1Ch], esi
|
|
|
|
mov [esp+4], edi
|
|
|
|
popad
|
|
|
|
inc esi
|
|
|
|
cmp byte [esi-1], 0
|
2016-05-04 19:36:09 +02:00
|
|
|
jnz @f
|
|
|
|
cmp dword [esp+8], 0
|
|
|
|
jz .ret2
|
|
|
|
mov esi, [esp+8]
|
|
|
|
mov dword [esp+8], 0
|
|
|
|
@@:
|
|
|
|
pop eax
|
2011-10-14 23:38:50 +02:00
|
|
|
jmp .doit2
|
|
|
|
|
|
|
|
;----------------------------------------------------------------
|
2015-12-10 11:45:32 +01:00
|
|
|
ntfs_ReadFile:
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp byte [esi], 0
|
|
|
|
jnz @f
|
|
|
|
or ebx, -1
|
2013-06-04 13:14:37 +02:00
|
|
|
movi eax, ERROR_ACCESS_DENIED
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
2013-07-01 18:29:16 +02:00
|
|
|
call ntfs_lock
|
|
|
|
stdcall ntfs_find_lfn, [esp+4]
|
2011-10-14 23:38:50 +02:00
|
|
|
jnc .found
|
2013-07-01 18:29:16 +02:00
|
|
|
call ntfs_unlock
|
2011-10-14 23:38:50 +02:00
|
|
|
or ebx, -1
|
2013-06-04 13:14:37 +02:00
|
|
|
movi eax, ERROR_FILE_NOT_FOUND
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.found:
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_attr], 0x80 ; $DATA
|
|
|
|
and [ebp+NTFS.cur_offs], 0
|
|
|
|
and [ebp+NTFS.cur_size], 0
|
2011-10-14 23:38:50 +02:00
|
|
|
call ntfs_read_attr
|
|
|
|
jnc @f
|
2013-07-01 18:29:16 +02:00
|
|
|
call ntfs_unlock
|
2011-10-14 23:38:50 +02:00
|
|
|
or ebx, -1
|
2013-06-04 13:14:37 +02:00
|
|
|
movi eax, ERROR_ACCESS_DENIED
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
pushad
|
|
|
|
and dword [esp+10h], 0
|
|
|
|
xor eax, eax
|
2013-07-01 18:29:16 +02:00
|
|
|
cmp dword [ebx+8], 0x200
|
2011-10-14 23:38:50 +02:00
|
|
|
jb @f
|
|
|
|
.eof0:
|
|
|
|
popad
|
|
|
|
xor ebx, ebx
|
|
|
|
.eof:
|
2013-07-01 18:29:16 +02:00
|
|
|
call ntfs_unlock
|
2016-02-29 11:15:30 +01:00
|
|
|
movi eax, ERROR_END_OF_FILE
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
2013-07-01 18:29:16 +02:00
|
|
|
mov ecx, [ebx+12]
|
|
|
|
mov edx, [ebx+16]
|
|
|
|
mov eax, [ebx+4]
|
2011-10-14 23:38:50 +02:00
|
|
|
test eax, 0x1FF
|
|
|
|
jz .alignedstart
|
|
|
|
push edx
|
2013-07-01 18:29:16 +02:00
|
|
|
mov edx, [ebx+8]
|
2011-10-14 23:38:50 +02:00
|
|
|
shrd eax, edx, 9
|
|
|
|
pop edx
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_offs], eax
|
|
|
|
mov [ebp+NTFS.cur_size], 1
|
|
|
|
lea eax, [ebp+NTFS.bitmap_buf]
|
|
|
|
mov [ebp+NTFS.cur_buf], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
call ntfs_read_attr.continue
|
2013-07-01 18:29:16 +02:00
|
|
|
mov eax, [ebx+4]
|
2011-10-14 23:38:50 +02:00
|
|
|
and eax, 0x1FF
|
2016-02-21 03:13:21 +01:00
|
|
|
lea esi, [ebp+NTFS.bitmap_buf+eax]
|
|
|
|
sub eax, [ebp+NTFS.cur_read]
|
2011-10-14 23:38:50 +02:00
|
|
|
jae .eof0
|
|
|
|
neg eax
|
|
|
|
push ecx
|
|
|
|
cmp ecx, eax
|
|
|
|
jb @f
|
|
|
|
mov ecx, eax
|
|
|
|
@@:
|
|
|
|
mov [esp+10h+4], ecx
|
|
|
|
mov edi, edx
|
|
|
|
rep movsb
|
|
|
|
mov edx, edi
|
|
|
|
pop ecx
|
|
|
|
sub ecx, [esp+10h]
|
|
|
|
jnz @f
|
|
|
|
.retok:
|
|
|
|
popad
|
2013-07-01 18:29:16 +02:00
|
|
|
call ntfs_unlock
|
2011-10-14 23:38:50 +02:00
|
|
|
xor eax, eax
|
|
|
|
ret
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.cur_read], 0x200
|
2011-10-14 23:38:50 +02:00
|
|
|
jz .alignedstart
|
|
|
|
.eof_ebx:
|
|
|
|
popad
|
|
|
|
jmp .eof
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.alignedstart:
|
2013-07-01 18:29:16 +02:00
|
|
|
mov eax, [ebx+4]
|
2011-10-14 23:38:50 +02:00
|
|
|
push edx
|
2013-07-01 18:29:16 +02:00
|
|
|
mov edx, [ebx+8]
|
2011-10-14 23:38:50 +02:00
|
|
|
add eax, 511
|
|
|
|
adc edx, 0
|
|
|
|
shrd eax, edx, 9
|
|
|
|
pop edx
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_offs], eax
|
|
|
|
mov [ebp+NTFS.cur_buf], edx
|
2011-10-14 23:38:50 +02:00
|
|
|
mov eax, ecx
|
|
|
|
shr eax, 9
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_size], eax
|
|
|
|
add eax, [ebp+NTFS.cur_offs]
|
2011-10-14 23:38:50 +02:00
|
|
|
push eax
|
|
|
|
call ntfs_read_attr.continue
|
2016-02-21 03:13:21 +01:00
|
|
|
pop [ebp+NTFS.cur_offs]
|
|
|
|
mov eax, [ebp+NTFS.cur_read]
|
2011-10-14 23:38:50 +02:00
|
|
|
add [esp+10h], eax
|
|
|
|
mov eax, ecx
|
|
|
|
and eax, not 0x1FF
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.cur_read], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz .eof_ebx
|
|
|
|
and ecx, 0x1FF
|
|
|
|
jz .retok
|
2016-02-21 03:13:21 +01:00
|
|
|
add edx, [ebp+NTFS.cur_read]
|
|
|
|
mov [ebp+NTFS.cur_size], 1
|
|
|
|
lea eax, [ebp+NTFS.bitmap_buf]
|
|
|
|
mov [ebp+NTFS.cur_buf], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
call ntfs_read_attr.continue
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.cur_read], ecx
|
2011-10-14 23:38:50 +02:00
|
|
|
jb @f
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_read], ecx
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
2016-02-21 03:13:21 +01:00
|
|
|
xchg ecx, [ebp+NTFS.cur_read]
|
2011-10-14 23:38:50 +02:00
|
|
|
push ecx
|
|
|
|
mov edi, edx
|
2016-02-21 03:13:21 +01:00
|
|
|
lea esi, [ebp+NTFS.bitmap_buf]
|
2011-10-14 23:38:50 +02:00
|
|
|
add [esp+10h+4], ecx
|
|
|
|
rep movsb
|
|
|
|
pop ecx
|
|
|
|
xor eax, eax
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp ecx, [ebp+NTFS.cur_read]
|
2011-10-14 23:38:50 +02:00
|
|
|
jz @f
|
|
|
|
mov al, ERROR_END_OF_FILE
|
|
|
|
@@:
|
|
|
|
mov [esp+1Ch], eax
|
2013-07-01 18:29:16 +02:00
|
|
|
call ntfs_unlock
|
2011-10-14 23:38:50 +02:00
|
|
|
popad
|
|
|
|
ret
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
;----------------------------------------------------------------
|
|
|
|
ntfs_ReadFolder:
|
|
|
|
call ntfs_lock
|
2016-02-29 11:15:30 +01:00
|
|
|
mov [ebp+NTFS.cur_iRecord], 5 ; root directory
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp byte [esi], 0
|
2016-02-29 11:15:30 +01:00
|
|
|
jz @f
|
2013-07-01 18:29:16 +02:00
|
|
|
stdcall ntfs_find_lfn, [esp+4]
|
2016-02-29 11:15:30 +01:00
|
|
|
jc ntfsNotFound
|
|
|
|
@@:
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_attr], 0x10 ; $STANDARD_INFORMATION
|
|
|
|
and [ebp+NTFS.cur_offs], 0
|
|
|
|
mov [ebp+NTFS.cur_size], 1
|
|
|
|
lea eax, [ebp+NTFS.bitmap_buf]
|
|
|
|
mov [ebp+NTFS.cur_buf], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
call ntfs_read_attr
|
2016-02-29 11:15:30 +01:00
|
|
|
jc ntfsFail
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_attr], 0x90 ; $INDEX_ROOT
|
2016-02-29 11:15:30 +01:00
|
|
|
.doit:
|
2013-07-01 18:29:16 +02:00
|
|
|
mov eax, [ebp+NTFS.cur_index_size]
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_size], eax
|
2013-07-01 18:29:16 +02:00
|
|
|
mov eax, [ebp+NTFS.cur_index_buf]
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_buf], eax
|
2016-02-29 11:15:30 +01:00
|
|
|
call ntfs_read_attr.newAttribute
|
|
|
|
jc ntfsFail
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.cur_read], 0x20
|
2016-02-29 11:15:30 +01:00
|
|
|
jc ntfsFail
|
2013-07-01 18:29:16 +02:00
|
|
|
mov esi, [ebp+NTFS.cur_index_buf]
|
2016-03-15 07:18:38 +01:00
|
|
|
mov eax, [esi+indexRecordSize]
|
|
|
|
shr eax, 9
|
|
|
|
cmp [ebp+NTFS.cur_index_size], eax
|
2016-02-29 11:15:30 +01:00
|
|
|
jc .realloc
|
2016-03-15 07:18:38 +01:00
|
|
|
mov [ebp+NTFS.cur_subnode_size], eax
|
2016-02-29 11:15:30 +01:00
|
|
|
add esi, rootNode
|
|
|
|
mov eax, [esi+nodeRealSize]
|
|
|
|
add eax, rootNode
|
|
|
|
cmp [ebp+NTFS.cur_read], eax
|
2016-04-27 10:48:17 +02:00
|
|
|
jc ntfsFail
|
|
|
|
mov edi, [ebx+16]
|
2013-07-01 18:29:16 +02:00
|
|
|
mov ecx, [ebx+12]
|
2016-04-27 10:48:17 +02:00
|
|
|
pushd [ebx]
|
|
|
|
pushd [ebx+8] ; read ANSI/UNICODE name
|
|
|
|
push edi
|
2011-10-14 23:38:50 +02:00
|
|
|
mov edx, esp
|
2016-04-27 10:48:17 +02:00
|
|
|
mov ebx, [ebx+4]
|
|
|
|
; init header
|
|
|
|
xor eax, eax
|
|
|
|
mov [edi+8], eax
|
|
|
|
mov [edi+4], eax
|
|
|
|
inc eax
|
|
|
|
mov [edi], eax ; version
|
|
|
|
add edi, 32
|
2013-07-01 18:29:16 +02:00
|
|
|
; edi -> BDFE, esi -> current index data, ebx = first wanted block,
|
2011-10-14 23:38:50 +02:00
|
|
|
; ecx = number of blocks to read
|
|
|
|
; edx -> parameters block: dd <output>, dd <flags>
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.cur_iRecord], 5
|
2011-10-14 23:38:50 +02:00
|
|
|
jz .skip_specials
|
|
|
|
; dot and dotdot entries
|
|
|
|
push esi
|
|
|
|
xor esi, esi
|
|
|
|
call .add_special_entry
|
|
|
|
inc esi
|
|
|
|
call .add_special_entry
|
|
|
|
pop esi
|
|
|
|
.skip_specials:
|
|
|
|
; at first, dump index root
|
2016-02-29 11:15:30 +01:00
|
|
|
add esi, [esi+indexOffset]
|
2011-10-14 23:38:50 +02:00
|
|
|
.dump_root:
|
2016-02-29 11:15:30 +01:00
|
|
|
test byte [esi+indexFlags], 2
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz .dump_root_done
|
|
|
|
call .add_entry
|
2016-02-29 11:15:30 +01:00
|
|
|
movzx eax, word [esi+indexAllocatedSize]
|
2011-10-14 23:38:50 +02:00
|
|
|
add esi, eax
|
|
|
|
jmp .dump_root
|
2016-02-29 11:15:30 +01:00
|
|
|
|
|
|
|
.realloc:
|
2016-03-15 07:18:38 +01:00
|
|
|
mov edi, eax
|
|
|
|
mov eax, [esi+indexRecordSize]
|
|
|
|
shl eax, 1
|
|
|
|
stdcall kernel_alloc, eax
|
2016-02-29 11:15:30 +01:00
|
|
|
test eax, eax
|
2016-04-27 10:48:17 +02:00
|
|
|
jz ntfsFail
|
2016-04-21 19:41:56 +02:00
|
|
|
mov edx, [ebp+NTFS.cur_index_buf]
|
|
|
|
cmp edx, [ebp+NTFS.secondIndexBuffer]
|
|
|
|
jc @f
|
|
|
|
mov edx, [ebp+NTFS.secondIndexBuffer]
|
|
|
|
@@:
|
2016-02-29 11:15:30 +01:00
|
|
|
mov [ebp+NTFS.cur_index_buf], eax
|
2016-03-15 07:18:38 +01:00
|
|
|
add eax, [esi+indexRecordSize]
|
|
|
|
mov [ebp+NTFS.secondIndexBuffer], eax
|
2016-02-29 11:15:30 +01:00
|
|
|
mov [ebp+NTFS.cur_index_size], edi
|
2016-04-21 19:41:56 +02:00
|
|
|
stdcall kernel_free, edx
|
2016-02-29 11:15:30 +01:00
|
|
|
jmp .doit
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.dump_root_done:
|
|
|
|
; now dump all subnodes
|
|
|
|
push ecx edi
|
2016-02-21 03:13:21 +01:00
|
|
|
lea edi, [ebp+NTFS.bitmap_buf]
|
|
|
|
mov [ebp+NTFS.cur_buf], edi
|
2011-10-14 23:38:50 +02:00
|
|
|
mov ecx, 0x400/4
|
|
|
|
xor eax, eax
|
|
|
|
rep stosd
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_attr], 0xB0 ; $BITMAP
|
|
|
|
and [ebp+NTFS.cur_offs], 0
|
|
|
|
mov [ebp+NTFS.cur_size], 2
|
2016-02-29 11:15:30 +01:00
|
|
|
call ntfs_read_attr.newAttribute
|
2011-10-14 23:38:50 +02:00
|
|
|
pop edi ecx
|
|
|
|
push 0 ; save offset in $BITMAP attribute
|
2016-02-21 03:13:21 +01:00
|
|
|
and [ebp+NTFS.cur_offs], 0
|
2011-10-14 23:38:50 +02:00
|
|
|
.dumploop:
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_attr], 0xA0
|
2013-07-01 18:29:16 +02:00
|
|
|
mov eax, [ebp+NTFS.cur_subnode_size]
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_size], eax
|
2016-02-29 11:15:30 +01:00
|
|
|
mov esi, [ebp+NTFS.cur_index_buf]
|
|
|
|
mov [ebp+NTFS.cur_buf], esi
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, [ebp+NTFS.cur_offs]
|
2016-02-29 11:15:30 +01:00
|
|
|
push eax
|
2013-07-01 18:29:16 +02:00
|
|
|
imul eax, [ebp+NTFS.cur_subnode_size]
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_offs], eax
|
2016-02-29 11:15:30 +01:00
|
|
|
call ntfs_read_attr.newAttribute
|
2016-02-21 03:13:21 +01:00
|
|
|
pop [ebp+NTFS.cur_offs]
|
2013-07-01 18:29:16 +02:00
|
|
|
mov eax, [ebp+NTFS.cur_subnode_size]
|
2011-10-14 23:38:50 +02:00
|
|
|
shl eax, 9
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.cur_read], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz .done
|
|
|
|
push eax
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, [ebp+NTFS.cur_offs]
|
2011-10-14 23:38:50 +02:00
|
|
|
and eax, 0x400*8-1
|
2016-02-21 03:13:21 +01:00
|
|
|
bt dword [ebp+NTFS.bitmap_buf], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
pop eax
|
|
|
|
jnc .dump_subnode_done
|
|
|
|
cmp dword [esi], 'INDX'
|
|
|
|
jnz .dump_subnode_done
|
|
|
|
push ebx
|
|
|
|
mov ebx, esi
|
|
|
|
call ntfs_restore_usa
|
|
|
|
pop ebx
|
|
|
|
jc .dump_subnode_done
|
2016-02-29 11:15:30 +01:00
|
|
|
add esi, recordNode
|
|
|
|
add esi, [esi+indexOffset]
|
2011-10-14 23:38:50 +02:00
|
|
|
.dump_subnode:
|
2016-02-29 11:15:30 +01:00
|
|
|
test byte [esi+indexFlags], 2
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz .dump_subnode_done
|
|
|
|
call .add_entry
|
2016-02-29 11:15:30 +01:00
|
|
|
movzx eax, word [esi+indexAllocatedSize]
|
2011-10-14 23:38:50 +02:00
|
|
|
add esi, eax
|
|
|
|
jmp .dump_subnode
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.dump_subnode_done:
|
2016-02-21 03:13:21 +01:00
|
|
|
inc [ebp+NTFS.cur_offs]
|
|
|
|
test [ebp+NTFS.cur_offs], 0x400*8-1
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz .dumploop
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_attr], 0xB0
|
2011-10-14 23:38:50 +02:00
|
|
|
push ecx edi
|
2016-02-21 03:13:21 +01:00
|
|
|
lea edi, [ebp+NTFS.bitmap_buf]
|
|
|
|
mov [ebp+NTFS.cur_buf], edi
|
2011-10-14 23:38:50 +02:00
|
|
|
mov ecx, 0x400/4
|
|
|
|
xor eax, eax
|
|
|
|
rep stosd
|
|
|
|
pop edi ecx
|
|
|
|
pop eax
|
2016-02-21 03:13:21 +01:00
|
|
|
push [ebp+NTFS.cur_offs]
|
2011-10-14 23:38:50 +02:00
|
|
|
inc eax
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_offs], eax
|
|
|
|
mov [ebp+NTFS.cur_size], 2
|
2011-10-14 23:38:50 +02:00
|
|
|
push eax
|
2016-02-29 11:15:30 +01:00
|
|
|
call ntfs_read_attr.newAttribute
|
2011-10-14 23:38:50 +02:00
|
|
|
pop eax
|
2016-02-21 03:13:21 +01:00
|
|
|
pop [ebp+NTFS.cur_offs]
|
2011-10-14 23:38:50 +02:00
|
|
|
push eax
|
|
|
|
jmp .dumploop
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.done:
|
|
|
|
pop eax
|
2016-04-27 10:48:17 +02:00
|
|
|
pop eax
|
|
|
|
mov ebx, [eax+4]
|
|
|
|
pop eax
|
|
|
|
pop eax
|
|
|
|
test eax, eax
|
|
|
|
jz .ret
|
2011-10-14 23:38:50 +02:00
|
|
|
xor eax, eax
|
|
|
|
dec ecx
|
|
|
|
js @f
|
|
|
|
mov al, ERROR_END_OF_FILE
|
|
|
|
@@:
|
2016-04-27 10:48:17 +02:00
|
|
|
push eax
|
2013-07-01 18:29:16 +02:00
|
|
|
call ntfs_unlock
|
2016-04-27 10:48:17 +02:00
|
|
|
pop eax
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
.add_special_entry:
|
|
|
|
mov eax, [edx]
|
|
|
|
inc dword [eax+8] ; new file found
|
|
|
|
dec ebx
|
|
|
|
jns .ret
|
|
|
|
dec ecx
|
|
|
|
js .ret
|
|
|
|
inc dword [eax+4] ; new file block copied
|
|
|
|
mov eax, [edx+4]
|
|
|
|
mov [edi+4], eax
|
|
|
|
mov eax, 0x10
|
|
|
|
stosd
|
|
|
|
scasd
|
|
|
|
push edx
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, dword [ebp+NTFS.bitmap_buf]
|
|
|
|
mov edx, dword [ebp+NTFS.bitmap_buf+4]
|
2011-10-14 23:38:50 +02:00
|
|
|
call ntfs_datetime_to_bdfe
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, dword [ebp+NTFS.bitmap_buf+0x18]
|
|
|
|
mov edx, dword [ebp+NTFS.bitmap_buf+0x1C]
|
2011-10-14 23:38:50 +02:00
|
|
|
call ntfs_datetime_to_bdfe
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, dword [ebp+NTFS.bitmap_buf+8]
|
|
|
|
mov edx, dword [ebp+NTFS.bitmap_buf+0xC]
|
2011-10-14 23:38:50 +02:00
|
|
|
call ntfs_datetime_to_bdfe
|
|
|
|
pop edx
|
|
|
|
xor eax, eax
|
|
|
|
stosd
|
|
|
|
stosd
|
|
|
|
mov al, '.'
|
|
|
|
push edi ecx
|
|
|
|
lea ecx, [esi+1]
|
|
|
|
test byte [edi-0x24], 1
|
|
|
|
jz @f
|
|
|
|
rep stosw
|
|
|
|
pop ecx
|
|
|
|
xor eax, eax
|
|
|
|
stosw
|
|
|
|
pop edi
|
|
|
|
add edi, 520
|
|
|
|
ret
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
rep stosb
|
|
|
|
pop ecx
|
|
|
|
xor eax, eax
|
|
|
|
stosb
|
|
|
|
pop edi
|
|
|
|
add edi, 264
|
|
|
|
.ret:
|
|
|
|
ret
|
|
|
|
|
|
|
|
.add_entry:
|
|
|
|
; do not return DOS 8.3 names
|
2016-02-29 11:15:30 +01:00
|
|
|
cmp byte [esi+namespace], 2
|
2011-10-14 23:38:50 +02:00
|
|
|
jz .ret
|
|
|
|
; do not return system files
|
|
|
|
; ... note that there will be no bad effects if system files also were reported ...
|
2016-02-29 11:15:30 +01:00
|
|
|
cmp dword [esi+fileRecordReference], 0x10
|
2011-10-14 23:38:50 +02:00
|
|
|
jb .ret
|
|
|
|
mov eax, [edx]
|
|
|
|
inc dword [eax+8] ; new file found
|
|
|
|
dec ebx
|
|
|
|
jns .ret
|
|
|
|
dec ecx
|
|
|
|
js .ret
|
|
|
|
inc dword [eax+4] ; new file block copied
|
|
|
|
mov eax, [edx+4] ; flags
|
|
|
|
call ntfs_direntry_to_bdfe
|
|
|
|
push ecx esi edi
|
2016-02-29 11:15:30 +01:00
|
|
|
movzx ecx, byte [esi+fileNameLength]
|
|
|
|
add esi, fileName
|
2011-10-14 23:38:50 +02:00
|
|
|
test byte [edi-0x24], 1
|
|
|
|
jz .ansi
|
|
|
|
shr ecx, 1
|
|
|
|
rep movsd
|
|
|
|
adc ecx, ecx
|
|
|
|
rep movsw
|
|
|
|
and word [edi], 0
|
|
|
|
pop edi
|
|
|
|
add edi, 520
|
|
|
|
pop esi ecx
|
|
|
|
ret
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
.ansi:
|
|
|
|
jecxz .skip
|
|
|
|
@@:
|
|
|
|
lodsw
|
|
|
|
call uni2ansi_char
|
|
|
|
stosb
|
|
|
|
loop @b
|
|
|
|
.skip:
|
|
|
|
xor al, al
|
|
|
|
stosb
|
|
|
|
pop edi
|
|
|
|
add edi, 264
|
|
|
|
pop esi ecx
|
|
|
|
ret
|
|
|
|
|
|
|
|
ntfs_direntry_to_bdfe:
|
|
|
|
mov [edi+4], eax ; ANSI/UNICODE name
|
2016-02-29 11:15:30 +01:00
|
|
|
mov eax, [esi+fileFlags]
|
2011-10-14 23:38:50 +02:00
|
|
|
test eax, 0x10000000
|
|
|
|
jz @f
|
|
|
|
and eax, not 0x10000000
|
|
|
|
or al, 0x10
|
|
|
|
@@:
|
|
|
|
stosd
|
|
|
|
scasd
|
|
|
|
push edx
|
2016-02-29 11:15:30 +01:00
|
|
|
mov eax, [esi+fileCreated]
|
|
|
|
mov edx, [esi+fileCreated+4]
|
2011-10-14 23:38:50 +02:00
|
|
|
call ntfs_datetime_to_bdfe
|
2016-02-29 11:15:30 +01:00
|
|
|
mov eax, [esi+fileAccessed]
|
|
|
|
mov edx, [esi+fileAccessed+4]
|
2011-10-14 23:38:50 +02:00
|
|
|
call ntfs_datetime_to_bdfe
|
2016-02-29 11:15:30 +01:00
|
|
|
mov eax, [esi+fileModified]
|
|
|
|
mov edx, [esi+fileModified+4]
|
2011-10-14 23:38:50 +02:00
|
|
|
call ntfs_datetime_to_bdfe
|
|
|
|
pop edx
|
2016-02-29 11:15:30 +01:00
|
|
|
mov eax, [esi+fileRealSize]
|
2011-10-14 23:38:50 +02:00
|
|
|
stosd
|
2016-02-29 11:15:30 +01:00
|
|
|
mov eax, [esi+fileRealSize+4]
|
2011-10-14 23:38:50 +02:00
|
|
|
stosd
|
|
|
|
ret
|
|
|
|
|
|
|
|
iglobal
|
2016-02-29 11:15:30 +01:00
|
|
|
months db 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
|
|
|
|
months2 db 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
|
2011-10-14 23:38:50 +02:00
|
|
|
endg
|
|
|
|
|
|
|
|
ntfs_datetime_to_bdfe:
|
|
|
|
; edx:eax = number of 100-nanosecond intervals since January 1, 1601, in UTC
|
2016-02-29 11:15:30 +01:00
|
|
|
push ebx ecx
|
|
|
|
mov ebx, eax
|
2011-10-14 23:38:50 +02:00
|
|
|
mov eax, edx
|
|
|
|
xor edx, edx
|
2016-02-29 11:15:30 +01:00
|
|
|
mov ecx, 10000000
|
|
|
|
div ecx
|
|
|
|
xchg eax, ebx
|
|
|
|
div ecx
|
|
|
|
.forEXT:
|
|
|
|
xchg eax, ebx
|
2011-10-14 23:38:50 +02:00
|
|
|
xor edx, edx
|
2016-02-29 11:15:30 +01:00
|
|
|
mov ecx, 60
|
|
|
|
div ecx
|
|
|
|
xchg eax, ebx
|
|
|
|
div ecx
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [edi], dl
|
2016-02-29 11:15:30 +01:00
|
|
|
mov edx, ebx
|
2011-10-14 23:38:50 +02:00
|
|
|
; edx:eax = number of minutes
|
2016-02-29 11:15:30 +01:00
|
|
|
div ecx
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [edi+1], dl
|
2016-02-29 11:15:30 +01:00
|
|
|
; eax = number of hours
|
2011-10-14 23:38:50 +02:00
|
|
|
xor edx, edx
|
2016-02-29 11:15:30 +01:00
|
|
|
mov cl, 24
|
|
|
|
div ecx
|
|
|
|
mov [edi+2], dx
|
2011-10-14 23:38:50 +02:00
|
|
|
; eax = number of days since January 1, 1601
|
|
|
|
xor edx, edx
|
2016-02-29 11:15:30 +01:00
|
|
|
mov cx, 365
|
|
|
|
div ecx
|
|
|
|
mov ebx, eax
|
|
|
|
add ebx, 1601
|
|
|
|
shr eax, 2
|
|
|
|
sub edx, eax
|
|
|
|
mov cl, 25
|
|
|
|
div cl
|
|
|
|
xor ah, ah
|
|
|
|
add edx, eax
|
|
|
|
shr eax, 2
|
|
|
|
sub edx, eax
|
|
|
|
jns @f
|
|
|
|
dec ebx
|
|
|
|
add edx, 365
|
|
|
|
test bl, 3
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz @f
|
2016-02-29 11:15:30 +01:00
|
|
|
inc edx
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
|
|
|
xor eax, eax
|
2016-02-29 11:15:30 +01:00
|
|
|
mov ecx, months-1
|
|
|
|
test bl, 3
|
|
|
|
jnz @f
|
|
|
|
add ecx, 12
|
2011-10-14 23:38:50 +02:00
|
|
|
@@:
|
2016-02-29 11:15:30 +01:00
|
|
|
inc ecx
|
2011-10-14 23:38:50 +02:00
|
|
|
inc eax
|
2016-02-29 11:15:30 +01:00
|
|
|
sub dl, [ecx]
|
|
|
|
jnc @b
|
|
|
|
dec dh
|
|
|
|
jns @b
|
|
|
|
add dl, [ecx]
|
2011-10-14 23:38:50 +02:00
|
|
|
inc edx
|
|
|
|
mov [edi+4], dl
|
|
|
|
mov [edi+5], al
|
2016-02-29 11:15:30 +01:00
|
|
|
mov [edi+6], bx
|
2011-10-14 23:38:50 +02:00
|
|
|
add edi, 8
|
2016-02-29 11:15:30 +01:00
|
|
|
pop ecx ebx
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
|
|
|
|
2016-02-29 11:15:30 +01:00
|
|
|
.sec:
|
|
|
|
push ebx ecx
|
|
|
|
mov ebx, edx
|
|
|
|
jmp .forEXT
|
|
|
|
|
2016-05-08 00:26:48 +02:00
|
|
|
;----------------------------------------------------------------
|
|
|
|
ntfs_GetFileInfo:
|
|
|
|
cmp byte [esi], 0
|
|
|
|
jnz @f
|
|
|
|
movi eax, ERROR_UNSUPPORTED_FS
|
|
|
|
ret
|
|
|
|
@@:
|
|
|
|
call ntfs_lock
|
|
|
|
stdcall ntfs_find_lfn, [esp+4]
|
|
|
|
jnc .found
|
|
|
|
test eax, eax
|
|
|
|
jz ntfsFail
|
|
|
|
jmp ntfsNotFound
|
|
|
|
|
|
|
|
.found:
|
|
|
|
push esi edi
|
|
|
|
mov esi, eax
|
|
|
|
mov edi, [ebx+16]
|
|
|
|
xor eax, eax
|
|
|
|
call ntfs_direntry_to_bdfe
|
|
|
|
pop edi esi
|
|
|
|
call ntfs_unlock
|
|
|
|
xor eax, eax
|
|
|
|
ret
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
;----------------------------------------------------------------
|
2013-07-01 18:29:16 +02:00
|
|
|
ntfs_CreateFolder:
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.bFolder], 1
|
2015-12-10 11:45:32 +01:00
|
|
|
jmp @f
|
2015-12-21 12:47:21 +01:00
|
|
|
|
2015-12-10 11:45:32 +01:00
|
|
|
ntfs_CreateFile:
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.bFolder], 0
|
2015-12-10 11:45:32 +01:00
|
|
|
@@:
|
|
|
|
cmp byte [esi], 0
|
|
|
|
jnz @f
|
2011-10-14 23:38:50 +02:00
|
|
|
xor ebx, ebx
|
2015-12-31 18:29:37 +01:00
|
|
|
movi eax, ERROR_ACCESS_DENIED
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
2016-02-29 11:15:30 +01:00
|
|
|
|
2015-12-10 11:45:32 +01:00
|
|
|
@@: ; 1. Search file
|
|
|
|
call ntfs_lock
|
|
|
|
stdcall ntfs_find_lfn, [esp+4]
|
2016-01-19 20:45:51 +01:00
|
|
|
jc .notFound
|
|
|
|
; found, rewrite
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.cur_iRecord], 16
|
2015-12-31 18:29:37 +01:00
|
|
|
jc ntfsDenied
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.bFolder], 1
|
2016-01-19 20:45:51 +01:00
|
|
|
jz .folder
|
2016-05-08 00:26:48 +02:00
|
|
|
test byte [eax+fileFlags], 1
|
|
|
|
jnz ntfsDenied
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.fragmentCount], 1
|
2016-01-19 20:45:51 +01:00
|
|
|
jnz ntfsUnsupported ; record fragmented
|
2016-02-06 18:50:04 +01:00
|
|
|
; edit directory node
|
2016-01-19 20:45:51 +01:00
|
|
|
mov edi, [ebp+NTFS.cur_index_buf]
|
|
|
|
cmp dword [edi], 'INDX'
|
|
|
|
jz @f
|
|
|
|
mov esi, [ebp+NTFS.frs_buffer]
|
|
|
|
mov ecx, [esi+recordRealSize]
|
|
|
|
shr ecx, 2
|
|
|
|
rep movsd
|
2016-02-21 03:13:21 +01:00
|
|
|
mov esi, [ebp+NTFS.attr_offs]
|
2016-01-19 20:45:51 +01:00
|
|
|
mov cl, [esi+attributeOffset]
|
|
|
|
sub esi, [ebp+NTFS.frs_buffer]
|
|
|
|
add eax, ecx
|
|
|
|
add eax, esi
|
|
|
|
@@:
|
2016-05-08 00:26:48 +02:00
|
|
|
mov edi, eax
|
|
|
|
mov eax, [ebx+12]
|
|
|
|
mov [edi+fileRealSize], eax
|
|
|
|
mov dword [edi+fileRealSize+4], 0
|
|
|
|
push ebx eax
|
|
|
|
call ntfsGetTime
|
|
|
|
mov [edi+fileModified], eax
|
|
|
|
mov [edi+fileModified+4], edx
|
|
|
|
mov [edi+recordModified], eax
|
|
|
|
mov [edi+recordModified+4], edx
|
|
|
|
mov [edi+fileAccessed], eax
|
|
|
|
mov [edi+fileAccessed+4], edx
|
|
|
|
pop edx ebx
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, [ebp+NTFS.LastRead]
|
2016-01-19 20:45:51 +01:00
|
|
|
mov [ebp+NTFS.nodeLastRead], eax
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_attr], 0x80
|
|
|
|
mov [ebp+NTFS.cur_offs], 0
|
|
|
|
mov [ebp+NTFS.cur_size], 0
|
2015-12-21 12:47:21 +01:00
|
|
|
call ntfs_read_attr
|
2016-01-19 20:45:51 +01:00
|
|
|
jc ntfsFail
|
2016-05-08 00:26:48 +02:00
|
|
|
mov esi, edi
|
|
|
|
mov edi, [ebp+NTFS.frs_buffer]
|
|
|
|
cmp word [edi+baseRecordReuse], 0
|
|
|
|
jnz ntfsUnsupported ; auxiliary record
|
|
|
|
mov al, [edi+attributeOffset]
|
|
|
|
add edi, eax
|
|
|
|
mov al, [edi+attributeOffset]
|
|
|
|
add edi, eax
|
|
|
|
mov ecx, 6
|
|
|
|
add esi, fileModified
|
|
|
|
add edi, 8
|
|
|
|
rep movsd
|
2016-01-19 20:45:51 +01:00
|
|
|
mov eax, edx
|
|
|
|
xor edx, edx
|
2016-02-21 03:13:21 +01:00
|
|
|
mov ecx, [ebp+NTFS.attr_offs]
|
2016-02-06 18:50:04 +01:00
|
|
|
cmp word [ecx+attributeFlags], 0
|
|
|
|
jnz ntfsUnsupported
|
|
|
|
push ebx
|
|
|
|
cmp byte [ecx+nonResidentFlag], 0
|
|
|
|
jz @f
|
2016-01-19 20:45:51 +01:00
|
|
|
cmp [ecx+attributeRealSize+4], edx
|
|
|
|
jnz @f
|
2015-12-21 12:47:21 +01:00
|
|
|
cmp [ecx+attributeRealSize], eax
|
2016-01-19 20:45:51 +01:00
|
|
|
jz ntfs_WriteFile.writeNode
|
|
|
|
@@:
|
|
|
|
jmp ntfs_WriteFile.resizeAttribute
|
2015-12-21 12:47:21 +01:00
|
|
|
|
2016-01-19 20:45:51 +01:00
|
|
|
.folder:
|
|
|
|
bt dword [eax+fileFlags], 28
|
|
|
|
jnc ntfsDenied
|
|
|
|
push 0
|
|
|
|
jmp ntfsOut
|
|
|
|
|
|
|
|
.notFound: ; create
|
|
|
|
test eax, eax
|
|
|
|
jz ntfsFail
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.fragmentCount], 1
|
2016-01-19 20:45:51 +01:00
|
|
|
jnz ntfsUnsupported ; record fragmented
|
2015-12-31 18:29:37 +01:00
|
|
|
; 2. Prepare directory record
|
2015-12-10 11:45:32 +01:00
|
|
|
mov ecx, esi
|
|
|
|
@@: ; count characters
|
|
|
|
inc ecx
|
|
|
|
cmp byte [ecx], '/'
|
2016-01-19 20:45:51 +01:00
|
|
|
jz ntfsNotFound ; path folder not found
|
2015-12-10 11:45:32 +01:00
|
|
|
cmp byte [ecx], 0
|
|
|
|
jnz @b
|
|
|
|
sub ecx, esi
|
2016-02-29 11:15:30 +01:00
|
|
|
push ecx ; name length
|
|
|
|
shl ecx, 1
|
|
|
|
add ecx, fileName+7
|
|
|
|
and ecx, not 7
|
2015-12-10 11:45:32 +01:00
|
|
|
mov edi, [ebp+NTFS.cur_index_buf]
|
2016-02-25 18:10:35 +01:00
|
|
|
mov edx, [ebx+12]
|
|
|
|
mov [ebp+NTFS.fileRealSize], edx
|
|
|
|
mov edx, [ebx+16]
|
|
|
|
mov [ebp+NTFS.fileDataBuffer], edx
|
2016-02-29 11:15:30 +01:00
|
|
|
push esi
|
|
|
|
push ecx ; index length
|
2016-02-25 18:10:35 +01:00
|
|
|
mov edx, ecx
|
2015-12-31 18:29:37 +01:00
|
|
|
cmp dword [edi], 'INDX'
|
2015-12-10 11:45:32 +01:00
|
|
|
jz .indexRecord
|
2015-12-31 18:29:37 +01:00
|
|
|
mov esi, [ebp+NTFS.frs_buffer] ; indexRoot
|
2016-02-25 18:10:35 +01:00
|
|
|
mov ecx, [esi+recordRealSize]
|
2015-12-10 11:45:32 +01:00
|
|
|
add edx, ecx
|
|
|
|
cmp [esi+recordAllocatedSize], edx
|
2016-02-25 18:10:35 +01:00
|
|
|
jc .growTree
|
2015-12-10 11:45:32 +01:00
|
|
|
mov [esi+recordRealSize], edx
|
|
|
|
shr ecx, 2
|
|
|
|
rep movsd
|
2016-04-26 02:41:42 +02:00
|
|
|
mov edi, [ebp+NTFS.indexRoot]
|
2015-12-10 11:45:32 +01:00
|
|
|
sub edi, [ebp+NTFS.frs_buffer]
|
|
|
|
add edi, [ebp+NTFS.cur_index_buf]
|
|
|
|
mov esi, [esp]
|
|
|
|
add [edi+sizeWithHeader], esi
|
|
|
|
add [edi+sizeWithoutHeader], esi
|
2015-12-31 18:29:37 +01:00
|
|
|
mov cl, [edi+attributeOffset]
|
2015-12-10 11:45:32 +01:00
|
|
|
add edi, ecx
|
2016-02-21 03:13:21 +01:00
|
|
|
add [edi+rootNode+nodeRealSize], esi
|
|
|
|
add [edi+rootNode+nodeAllocatedSize], esi
|
2015-12-10 11:45:32 +01:00
|
|
|
sub eax, [ebp+NTFS.cur_index_buf]
|
|
|
|
add eax, edi
|
|
|
|
mov edi, [ebp+NTFS.cur_index_buf]
|
|
|
|
jmp .common
|
|
|
|
|
2016-04-30 08:52:50 +02:00
|
|
|
.growTree: ; create indexRecord
|
|
|
|
mov edi, [ebp+NTFS.cur_index_buf]
|
2016-02-25 18:10:35 +01:00
|
|
|
mov ecx, 10
|
|
|
|
xor eax, eax
|
|
|
|
rep stosd
|
2016-04-26 02:41:42 +02:00
|
|
|
mov esi, [ebp+NTFS.indexRoot]
|
2016-03-15 07:18:38 +01:00
|
|
|
mov al, [esi+attributeOffset]
|
|
|
|
add esi, eax
|
|
|
|
rdtsc
|
|
|
|
stosw
|
2016-02-25 18:10:35 +01:00
|
|
|
mov eax, [esi+indexRecordSize]
|
|
|
|
cmp eax, [ebp+NTFS.frs_size]
|
2016-04-26 02:41:42 +02:00
|
|
|
jc .errorPop3
|
2016-02-25 18:10:35 +01:00
|
|
|
shr eax, 9
|
|
|
|
inc eax
|
|
|
|
mov edi, [ebp+NTFS.cur_index_buf]
|
|
|
|
mov dword[edi], 'INDX'
|
|
|
|
mov byte [edi+updateSequenceOffset], 28h
|
|
|
|
mov [edi+updateSequenceSize], al
|
|
|
|
add edi, recordNode
|
|
|
|
shl eax, 1
|
|
|
|
add eax, 28h-recordNode+7
|
|
|
|
and eax, not 7
|
|
|
|
mov [edi+indexOffset], eax
|
|
|
|
mov ecx, [esi+indexRecordSize]
|
|
|
|
sub ecx, recordNode
|
|
|
|
mov [edi+nodeAllocatedSize], ecx
|
|
|
|
add esi, rootNode
|
|
|
|
push esi
|
|
|
|
mov ecx, [esi+nodeRealSize]
|
|
|
|
sub ecx, [esi+indexOffset]
|
|
|
|
add eax, ecx
|
|
|
|
mov [edi+nodeRealSize], eax
|
2016-04-30 08:52:50 +02:00
|
|
|
mov eax, [esi+nonLeafFlag]
|
|
|
|
mov [edi+nonLeafFlag], eax
|
2016-02-25 18:10:35 +01:00
|
|
|
shr ecx, 2
|
|
|
|
add esi, [esi+indexOffset]
|
|
|
|
add edi, [edi+indexOffset]
|
|
|
|
rep movsd ; copy root indexes
|
|
|
|
; clear root node
|
|
|
|
mov cl, 10
|
|
|
|
mov edi, [esp]
|
|
|
|
xor eax, eax
|
|
|
|
rep stosd
|
|
|
|
pop edi
|
|
|
|
mov byte [edi+indexOffset], 16
|
|
|
|
mov byte [edi+nodeRealSize], 28h
|
|
|
|
mov byte [edi+nodeAllocatedSize], 28h
|
|
|
|
mov byte [edi+nonLeafFlag], 1
|
|
|
|
mov byte [edi+16+indexAllocatedSize], 18h
|
|
|
|
mov byte [edi+16+indexFlags], 3
|
2016-04-26 02:41:42 +02:00
|
|
|
mov esi, [ebp+NTFS.indexRoot]
|
2016-02-25 18:10:35 +01:00
|
|
|
add edi, 28h
|
|
|
|
mov eax, edi
|
|
|
|
sub eax, esi
|
|
|
|
mov word [esi+sizeWithoutHeader], 38h
|
|
|
|
xchg [esi+sizeWithHeader], eax
|
2016-04-26 02:41:42 +02:00
|
|
|
add esi, eax
|
|
|
|
mov [ebp+NTFS.attr_offs], edi
|
|
|
|
cmp byte [esi], 0xA0
|
|
|
|
jnz @f
|
|
|
|
cmp dword [esi+attributeAllocatedSize], 0
|
|
|
|
jz @f
|
|
|
|
mov eax, [ebp+NTFS.frs_buffer]
|
|
|
|
mov ecx, eax
|
|
|
|
add ecx, [eax+recordRealSize]
|
|
|
|
sub ecx, esi
|
|
|
|
shr ecx, 2
|
|
|
|
rep movsd
|
|
|
|
sub edi, eax
|
|
|
|
mov [eax+recordRealSize], edi
|
|
|
|
call .ntfsNodeAlloc
|
|
|
|
jc ntfsErrorPop3
|
|
|
|
mov eax, [ebp+NTFS.newRecord]
|
|
|
|
mov edi, [ebp+NTFS.cur_index_buf]
|
|
|
|
mov [edi+recordVCN], eax
|
|
|
|
mov edi, [ebp+NTFS.attr_offs]
|
|
|
|
mov [edi-8], eax
|
|
|
|
jmp .refresh
|
|
|
|
|
|
|
|
@@:
|
2016-02-25 18:10:35 +01:00
|
|
|
mov cl, 32
|
|
|
|
xor eax, eax
|
|
|
|
rep stosd
|
2016-04-26 02:41:42 +02:00
|
|
|
mov eax, [ebp+NTFS.cur_subnode_size]
|
|
|
|
cmp eax, [ebp+NTFS.cur_size]
|
|
|
|
jnz @f
|
|
|
|
mov al, 1
|
|
|
|
@@:
|
|
|
|
mov [ebp+NTFS.fileDataSize], eax
|
2016-02-25 18:10:35 +01:00
|
|
|
mov edi, [ebp+NTFS.BitmapStart]
|
|
|
|
call ntfsSpaceAlloc
|
2016-04-26 02:41:42 +02:00
|
|
|
movi eax, ERROR_DISK_FULL
|
|
|
|
jc ntfsErrorPop3
|
|
|
|
; create $IndexAllocation
|
|
|
|
mov edi, [ebp+NTFS.attr_offs]
|
2016-02-25 18:10:35 +01:00
|
|
|
mov byte [edi+attributeType], 0xA0
|
|
|
|
mov byte [edi+nonResidentFlag], 1
|
|
|
|
mov byte [edi+nameLength], 4
|
|
|
|
mov byte [edi+nameOffset], 40h
|
|
|
|
mov byte [edi+dataRunsOffset], 48h
|
|
|
|
mov byte [edi+sizeWithHeader], 50h
|
|
|
|
mov eax, [ebp+NTFS.fileDataSize]
|
|
|
|
dec eax
|
|
|
|
mov [edi+lastVCN], eax
|
|
|
|
inc eax
|
|
|
|
mul [ebp+NTFS.sectors_per_cluster]
|
|
|
|
shl eax, 9
|
|
|
|
mov [edi+attributeAllocatedSize], eax
|
|
|
|
mov [edi+attributeRealSize], eax
|
|
|
|
mov [edi+initialDataSize], eax
|
|
|
|
mov dword[edi+40h], 490024h ; unicode $I30
|
|
|
|
mov dword[edi+40h+4], 300033h
|
|
|
|
push edi
|
|
|
|
mov esi, edi
|
|
|
|
add edi, 48h
|
|
|
|
call createMcbEntry
|
|
|
|
mov esi, [ebp+NTFS.frs_buffer]
|
|
|
|
pop edi
|
|
|
|
mov al, [esi+newAttributeID]
|
|
|
|
mov [edi+attributeID], al
|
|
|
|
add edi, 50h
|
|
|
|
inc eax
|
|
|
|
; create $Bitmap
|
|
|
|
mov [edi+attributeID], al
|
|
|
|
inc eax
|
|
|
|
mov [esi+newAttributeID], al
|
|
|
|
mov byte [edi+attributeType], 0xB0
|
|
|
|
mov byte [edi+nameLength], 4
|
|
|
|
mov byte [edi+nameOffset], 18h
|
|
|
|
mov byte [edi+attributeOffset], 20h
|
|
|
|
mov byte [edi+sizeWithoutHeader], 8
|
|
|
|
mov byte [edi+sizeWithHeader], 28h
|
|
|
|
mov dword[edi+18h], 490024h ; unicode $I30
|
|
|
|
mov dword[edi+18h+4], 300033h
|
|
|
|
mov byte [edi+20h], 1
|
|
|
|
mov dword[edi+28h], -1
|
|
|
|
add edi, 30h
|
|
|
|
sub edi, esi
|
|
|
|
mov [esi+recordRealSize], edi
|
|
|
|
mov eax, [ebp+NTFS.fileDataStart]
|
|
|
|
mul [ebp+NTFS.sectors_per_cluster]
|
2016-04-27 10:48:17 +02:00
|
|
|
mov edx, eax
|
2016-04-26 02:41:42 +02:00
|
|
|
jmp @f
|
|
|
|
|
|
|
|
.refresh:
|
|
|
|
mov [ebp+NTFS.cur_size], 0
|
|
|
|
call ntfs_read_attr.continue
|
|
|
|
movi eax, ERROR_FS_FAIL
|
|
|
|
jc ntfsErrorPop3
|
2016-04-27 10:48:17 +02:00
|
|
|
mov edx, [ebp+NTFS.LastRead]
|
2016-04-26 02:41:42 +02:00
|
|
|
@@:
|
2016-04-27 10:48:17 +02:00
|
|
|
mov ebx, [ebp+NTFS.cur_index_buf]
|
2016-04-26 02:41:42 +02:00
|
|
|
call writeRecord
|
2016-04-27 10:48:17 +02:00
|
|
|
mov ebx, [ebp+NTFS.frs_buffer]
|
|
|
|
mov edx, [ebp+NTFS.rootLastRead]
|
2016-04-26 02:41:42 +02:00
|
|
|
call writeRecord
|
|
|
|
mov esi, [esp+4]
|
|
|
|
stdcall ntfs_find_lfn.doit2, 0
|
|
|
|
test eax, eax
|
|
|
|
jz .errorPop3
|
2016-02-25 18:10:35 +01:00
|
|
|
mov edi, [ebp+NTFS.cur_index_buf]
|
|
|
|
mov edx, [esp]
|
2015-12-10 11:45:32 +01:00
|
|
|
.indexRecord:
|
2016-02-21 03:13:21 +01:00
|
|
|
add edi, recordNode
|
2016-02-25 18:10:35 +01:00
|
|
|
add edx, [edi+nodeRealSize]
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [edi+nodeAllocatedSize], edx
|
2016-03-15 07:18:38 +01:00
|
|
|
jc .arborizeTree
|
|
|
|
mov [edi+nodeRealSize], edx
|
|
|
|
jmp .common
|
|
|
|
|
|
|
|
.errorPop3:
|
2015-12-10 11:45:32 +01:00
|
|
|
add esp, 12
|
2016-03-15 07:18:38 +01:00
|
|
|
jmp ntfsUnsupported
|
|
|
|
|
2016-04-26 02:41:42 +02:00
|
|
|
.ntfsNodeAlloc:
|
|
|
|
; in: [ebp+NTFS.attr_offs] -> $IndexAllocation
|
|
|
|
; out:
|
|
|
|
; [ebp+NTFS.newRecord] = node VCN
|
|
|
|
; [ebp+NTFS.cur_offs]
|
|
|
|
; CF=1 -> eax = error code
|
2016-03-15 07:18:38 +01:00
|
|
|
mov esi, [ebp+NTFS.attr_offs]
|
|
|
|
add esi, [esi+sizeWithHeader]
|
|
|
|
cmp byte [esi], 0xB0
|
2016-04-26 02:41:42 +02:00
|
|
|
jnz .ret
|
2016-05-02 08:02:41 +02:00
|
|
|
movzx ecx, word [esi+sizeWithoutHeader]
|
|
|
|
shr ecx, 2
|
|
|
|
movzx edi, byte [esi+attributeOffset]
|
|
|
|
add edi, esi
|
|
|
|
mov edx, edi
|
|
|
|
or eax, -1
|
|
|
|
repz scasd
|
|
|
|
jnz @f
|
|
|
|
cmp [edi], eax
|
|
|
|
jnz .ret
|
|
|
|
; extend folder $Bitmap
|
|
|
|
add word [esi+sizeWithHeader], 8
|
|
|
|
add word [esi+sizeWithoutHeader], 8
|
|
|
|
mov esi, [ebp+NTFS.frs_buffer]
|
|
|
|
mov eax, [esi+recordRealSize]
|
|
|
|
add eax, 8
|
|
|
|
cmp [esi+recordAllocatedSize], eax
|
|
|
|
jc .ret
|
|
|
|
mov [esi+recordRealSize], eax
|
|
|
|
xor eax, eax
|
|
|
|
stosd
|
|
|
|
mov [edi], eax
|
|
|
|
mov [edi+8], eax
|
|
|
|
dec eax
|
|
|
|
mov [edi+4], eax
|
|
|
|
@@:
|
|
|
|
sub edi, 4
|
|
|
|
mov eax, [edi]
|
2016-03-15 07:18:38 +01:00
|
|
|
not eax
|
|
|
|
bsf eax, eax
|
2016-05-02 08:02:41 +02:00
|
|
|
bts [edi], eax
|
|
|
|
sub edi, edx
|
|
|
|
shl edi, 3
|
|
|
|
add eax, edi
|
2016-03-15 07:18:38 +01:00
|
|
|
mul [ebp+NTFS.cur_subnode_size]
|
|
|
|
mov [ebp+NTFS.newRecord], eax
|
2016-04-26 02:41:42 +02:00
|
|
|
mov ecx, [ebp+NTFS.cur_size]
|
|
|
|
cmp ecx, [ebp+NTFS.cur_subnode_size]
|
|
|
|
jz @f
|
|
|
|
mul [ebp+NTFS.sectors_per_cluster]
|
|
|
|
@@:
|
|
|
|
mov [ebp+NTFS.cur_offs], eax
|
|
|
|
add eax, ecx
|
|
|
|
shl eax, 9
|
|
|
|
mov esi, [ebp+NTFS.attr_offs]
|
|
|
|
cmp [esi+attributeAllocatedSize], eax
|
|
|
|
jnc @f
|
|
|
|
xor edx, edx
|
|
|
|
jmp resizeAttribute
|
|
|
|
|
|
|
|
.ret:
|
|
|
|
movi eax, ERROR_UNSUPPORTED_FS
|
|
|
|
stc
|
|
|
|
@@:
|
|
|
|
ret
|
|
|
|
|
|
|
|
.arborizeTree: ; find median index
|
2016-03-15 07:18:38 +01:00
|
|
|
mov ecx, [edi+nodeRealSize]
|
|
|
|
sub ecx, [edi+indexOffset]
|
|
|
|
shr ecx, 1
|
|
|
|
add edi, [edi+indexOffset]
|
|
|
|
xor eax, eax
|
|
|
|
@@:
|
|
|
|
add edi, eax
|
|
|
|
mov ax, [edi+indexAllocatedSize]
|
|
|
|
sub ecx, eax
|
|
|
|
jnc @b
|
2016-04-26 02:41:42 +02:00
|
|
|
add eax, 8
|
2016-03-15 07:18:38 +01:00
|
|
|
mov esi, [ebp+NTFS.secondIndexBuffer]
|
|
|
|
cmp dword [esi], 'INDX'
|
2016-04-30 08:52:50 +02:00
|
|
|
jz @f
|
2016-03-15 07:18:38 +01:00
|
|
|
; move index to the root node
|
|
|
|
mov esi, [ebp+NTFS.frs_buffer]
|
2016-04-26 02:41:42 +02:00
|
|
|
mov ecx, eax
|
|
|
|
add ecx, 8
|
|
|
|
add ecx, [esi+recordRealSize]
|
2016-03-15 07:18:38 +01:00
|
|
|
cmp [esi+recordAllocatedSize], ecx
|
2016-04-30 08:52:50 +02:00
|
|
|
jc .growTree
|
2016-04-27 12:33:01 +02:00
|
|
|
push edi eax
|
2016-04-26 02:41:42 +02:00
|
|
|
call .ntfsNodeAlloc
|
2016-05-02 08:02:41 +02:00
|
|
|
jc ntfsErrorPop5
|
|
|
|
pop eax
|
2016-03-15 07:18:38 +01:00
|
|
|
mov edi, [ebp+NTFS.indexRoot]
|
|
|
|
add [ebp+NTFS.attr_offs], eax
|
|
|
|
add [edi+sizeWithHeader], eax
|
|
|
|
add [edi+sizeWithoutHeader], eax
|
|
|
|
movzx ecx, byte [edi+attributeOffset]
|
|
|
|
add ecx, edi
|
|
|
|
add [ecx+rootNode+nodeRealSize], eax
|
|
|
|
add [ecx+rootNode+nodeAllocatedSize], eax
|
2016-04-21 19:41:56 +02:00
|
|
|
add ecx, [ebp+NTFS.indexPointer]
|
2016-03-15 07:18:38 +01:00
|
|
|
sub ecx, [ebp+NTFS.secondIndexBuffer]
|
2016-04-27 12:33:01 +02:00
|
|
|
mov esi, [ebp+NTFS.frs_buffer]
|
|
|
|
add [esi+recordRealSize], eax
|
|
|
|
add esi, [esi+recordRealSize]
|
2016-03-15 07:18:38 +01:00
|
|
|
mov edi, esi
|
|
|
|
sub esi, eax
|
|
|
|
neg ecx
|
|
|
|
add ecx, esi
|
|
|
|
shr ecx, 2
|
|
|
|
sub esi, 4
|
|
|
|
sub edi, 4
|
|
|
|
std
|
|
|
|
rep movsd ; make space
|
|
|
|
mov [edi], ecx
|
|
|
|
mov edi, esi
|
|
|
|
add edi, 4
|
|
|
|
mov esi, [esp]
|
|
|
|
add word [esi+indexAllocatedSize], 8
|
|
|
|
mov byte [esi+indexFlags], 1
|
|
|
|
mov ecx, eax
|
|
|
|
sub ecx, 8
|
|
|
|
shr ecx, 2
|
|
|
|
cld
|
|
|
|
rep movsd ; insert index
|
|
|
|
mov eax, [ebp+NTFS.newRecord]
|
|
|
|
stosd
|
2016-04-30 08:52:50 +02:00
|
|
|
jmp .splitNode
|
|
|
|
|
2016-05-02 08:02:41 +02:00
|
|
|
.growBranch: ; move node and replace it with empty one
|
|
|
|
mov esi, [ebp+NTFS.cur_index_buf]
|
|
|
|
mov edi, [ebp+NTFS.secondIndexBuffer]
|
|
|
|
mov eax, [esi+recordVCN]
|
|
|
|
mov [edi+recordVCN], eax
|
|
|
|
add edi, recordNode
|
|
|
|
mov eax, [edi+indexOffset]
|
|
|
|
add eax, 18h
|
|
|
|
mov [edi+nodeRealSize], eax
|
|
|
|
add edi, [edi+indexOffset]
|
|
|
|
mov ecx, 6
|
|
|
|
xor eax, eax
|
|
|
|
mov [ebp+NTFS.indexPointer], edi
|
|
|
|
push edi
|
|
|
|
rep stosd
|
|
|
|
pop edi
|
|
|
|
mov eax, [ebp+NTFS.newRecord]
|
|
|
|
mov byte [edi+indexAllocatedSize], 18h
|
|
|
|
mov byte [edi+indexFlags], 3
|
|
|
|
mov [edi+16], eax
|
|
|
|
mov [esi+recordVCN], eax
|
|
|
|
mov eax, [ebp+NTFS.LastRead]
|
|
|
|
mov [ebp+NTFS.nodeLastRead], eax
|
|
|
|
push [ebp+NTFS.cur_size]
|
|
|
|
mov [ebp+NTFS.cur_size], 0
|
|
|
|
call ntfs_read_attr.continue
|
|
|
|
pop [ebp+NTFS.cur_size]
|
|
|
|
movi eax, ERROR_FS_FAIL
|
|
|
|
jc ntfsErrorPop5
|
|
|
|
pop eax edi
|
2016-04-30 08:52:50 +02:00
|
|
|
@@: ; move index to the branch node
|
2016-05-02 08:02:41 +02:00
|
|
|
push edi eax
|
|
|
|
call .ntfsNodeAlloc
|
|
|
|
jc ntfsErrorPop5
|
|
|
|
mov eax, [esp]
|
|
|
|
mov esi, [ebp+NTFS.secondIndexBuffer]
|
2016-04-30 08:52:50 +02:00
|
|
|
add esi, recordNode
|
|
|
|
mov ecx, [esi+nodeRealSize]
|
|
|
|
add eax, ecx
|
|
|
|
cmp [esi+nodeAllocatedSize], eax
|
2016-05-02 08:02:41 +02:00
|
|
|
jc .growBranch
|
2016-04-30 08:52:50 +02:00
|
|
|
mov [esi+nodeRealSize], eax
|
|
|
|
lea edi, [esi+eax-4]
|
|
|
|
add esi, ecx
|
|
|
|
mov ecx, esi
|
|
|
|
sub ecx, [ebp+NTFS.indexPointer]
|
|
|
|
shr ecx, 2
|
|
|
|
sub esi, 4
|
|
|
|
std
|
|
|
|
rep movsd ; make space
|
|
|
|
mov [edi], ecx
|
2016-05-02 08:02:41 +02:00
|
|
|
pop ecx
|
|
|
|
sub ecx, 8
|
|
|
|
shr ecx, 2
|
2016-04-30 08:52:50 +02:00
|
|
|
mov edi, esi
|
|
|
|
add edi, 4
|
|
|
|
mov esi, [esp]
|
|
|
|
add word [esi+indexAllocatedSize], 8
|
|
|
|
mov byte [esi+indexFlags], 1
|
|
|
|
cld
|
|
|
|
rep movsd ; insert index
|
|
|
|
mov eax, [ebp+NTFS.newRecord]
|
|
|
|
stosd
|
|
|
|
mov ebx, [ebp+NTFS.secondIndexBuffer]
|
|
|
|
mov edx, [ebp+NTFS.nodeLastRead]
|
|
|
|
push esi
|
|
|
|
call writeRecord
|
|
|
|
pop esi
|
|
|
|
.splitNode:
|
2016-03-15 07:18:38 +01:00
|
|
|
mov edi, [ebp+NTFS.cur_index_buf]
|
|
|
|
mov eax, edi
|
|
|
|
add eax, recordNode
|
|
|
|
add eax, [edi+recordNode+nodeRealSize]
|
|
|
|
sub eax, esi
|
|
|
|
push eax
|
|
|
|
mov ecx, [edi+recordNode+indexOffset]
|
|
|
|
add eax, ecx
|
|
|
|
add ecx, recordNode
|
|
|
|
shr ecx, 2
|
|
|
|
push esi
|
|
|
|
mov esi, edi
|
|
|
|
mov edi, [ebp+NTFS.secondIndexBuffer]
|
|
|
|
rep movsd
|
|
|
|
pop esi
|
|
|
|
pop ecx
|
|
|
|
shr ecx, 2
|
|
|
|
rep movsd
|
|
|
|
mov edi, [ebp+NTFS.secondIndexBuffer]
|
|
|
|
mov [edi+recordNode+nodeRealSize], eax
|
|
|
|
pop edi
|
|
|
|
mov cl, 4
|
|
|
|
xor eax, eax
|
|
|
|
mov esi, edi
|
|
|
|
rep stosd
|
|
|
|
mov byte [esi+indexAllocatedSize], 16
|
|
|
|
mov byte [esi+indexFlags], 2
|
|
|
|
mov esi, [ebp+NTFS.cur_index_buf]
|
|
|
|
mov eax, [ebp+NTFS.newRecord]
|
|
|
|
mov [esi+recordVCN], eax
|
|
|
|
add esi, recordNode
|
|
|
|
sub edi, esi
|
|
|
|
mov [esi+nodeRealSize], edi
|
2016-04-27 10:48:17 +02:00
|
|
|
mov ebx, [ebp+NTFS.secondIndexBuffer]
|
|
|
|
mov edx, [ebp+NTFS.LastRead]
|
2016-03-15 07:18:38 +01:00
|
|
|
call writeRecord
|
2016-04-26 02:41:42 +02:00
|
|
|
jmp .refresh
|
2016-02-25 18:10:35 +01:00
|
|
|
|
|
|
|
.common:
|
2016-02-21 03:13:21 +01:00
|
|
|
add edi, edx
|
|
|
|
sub edi, 4
|
2015-12-10 11:45:32 +01:00
|
|
|
mov esi, edi
|
|
|
|
sub esi, [esp]
|
|
|
|
mov ecx, esi
|
2016-02-25 18:10:35 +01:00
|
|
|
sub ecx, eax ; eax = pointer in the record
|
2015-12-10 11:45:32 +01:00
|
|
|
shr ecx, 2
|
|
|
|
inc ecx
|
|
|
|
std
|
|
|
|
rep movsd ; move forward, make space
|
|
|
|
mov ecx, [esp]
|
|
|
|
shr ecx, 2
|
|
|
|
xor eax, eax
|
|
|
|
rep stosd
|
|
|
|
cld
|
|
|
|
add edi, 4
|
2016-05-08 00:26:48 +02:00
|
|
|
call ntfsGetTime
|
|
|
|
mov [edi+fileCreated], eax
|
|
|
|
mov [edi+fileCreated+4], edx
|
|
|
|
mov [edi+fileModified], eax
|
|
|
|
mov [edi+fileModified+4], edx
|
|
|
|
mov [edi+recordModified], eax
|
|
|
|
mov [edi+recordModified+4], edx
|
|
|
|
mov [edi+fileAccessed], eax
|
|
|
|
mov [edi+fileAccessed+4], edx
|
2016-02-06 18:50:04 +01:00
|
|
|
pop ecx
|
2015-12-10 11:45:32 +01:00
|
|
|
pop esi
|
2016-02-06 18:50:04 +01:00
|
|
|
mov [edi+indexAllocatedSize], cx ; fill index with data
|
2015-12-10 11:45:32 +01:00
|
|
|
mov eax, [esp]
|
2016-01-19 20:45:51 +01:00
|
|
|
shl eax, 1
|
|
|
|
add eax, 42h
|
2015-12-10 11:45:32 +01:00
|
|
|
mov [edi+indexRawSize], ax
|
2016-05-04 19:36:09 +02:00
|
|
|
mov eax, [ebp+NTFS.cur_iRecord]
|
2015-12-10 11:45:32 +01:00
|
|
|
mov [edi+directoryRecordReference], eax
|
|
|
|
mov eax, [ebp+NTFS.frs_buffer]
|
|
|
|
mov eax, [eax+reuseCounter]
|
|
|
|
mov [edi+directoryReferenceReuse], ax
|
2016-02-25 18:10:35 +01:00
|
|
|
mov eax, [ebp+NTFS.frs_size]
|
|
|
|
shr eax, 8
|
2016-02-06 18:50:04 +01:00
|
|
|
add ecx, 30h+48h+8+18h+8
|
|
|
|
add ecx, eax
|
2016-02-25 18:10:35 +01:00
|
|
|
mov eax, [ebp+NTFS.fileRealSize]
|
|
|
|
add ecx, eax
|
2015-12-10 11:45:32 +01:00
|
|
|
mov [edi+fileRealSize], eax
|
2016-02-06 18:50:04 +01:00
|
|
|
cmp [ebp+NTFS.frs_size], ecx
|
|
|
|
jc @f
|
|
|
|
xor eax, eax
|
|
|
|
@@:
|
2015-12-10 11:45:32 +01:00
|
|
|
mov ecx, [ebp+NTFS.sectors_per_cluster]
|
|
|
|
shl ecx, 9
|
|
|
|
add eax, ecx
|
|
|
|
dec eax
|
|
|
|
xor edx, edx
|
|
|
|
div ecx
|
|
|
|
mov [ebp+NTFS.fileDataSize], eax
|
|
|
|
mul ecx
|
|
|
|
mov [edi+fileAllocatedSize], eax
|
|
|
|
pop ecx
|
2016-04-21 19:41:56 +02:00
|
|
|
mov [ebp+NTFS.indexPointer], edi
|
2015-12-10 11:45:32 +01:00
|
|
|
mov [edi+fileNameLength], cl
|
2016-02-29 11:15:30 +01:00
|
|
|
add edi, fileName
|
2015-12-10 11:45:32 +01:00
|
|
|
@@: ; record filename
|
|
|
|
lodsb
|
|
|
|
call ansi2uni_char
|
|
|
|
stosw
|
|
|
|
dec ecx
|
|
|
|
jnz @b
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, [ebp+NTFS.LastRead]
|
2015-12-10 11:45:32 +01:00
|
|
|
mov [ebp+NTFS.nodeLastRead], eax
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.bFolder], 0
|
2015-12-10 11:45:32 +01:00
|
|
|
jz @f
|
2016-04-21 19:41:56 +02:00
|
|
|
mov edi, [ebp+NTFS.indexPointer]
|
2016-01-19 20:45:51 +01:00
|
|
|
bts dword [edi+fileFlags], 28
|
2015-12-10 11:45:32 +01:00
|
|
|
jmp .mftBitmap
|
|
|
|
|
|
|
|
@@: ; 3. File data
|
2016-02-06 18:50:04 +01:00
|
|
|
cmp [ebp+NTFS.fileDataSize], 0
|
2015-12-10 11:45:32 +01:00
|
|
|
jz .mftBitmap
|
2016-01-19 20:45:51 +01:00
|
|
|
mov edi, [ebp+NTFS.BitmapStart]
|
|
|
|
call ntfsSpaceAlloc
|
|
|
|
jc ntfsDiskFull
|
2016-02-25 18:10:35 +01:00
|
|
|
mov eax, [ebp+NTFS.fileDataStart]
|
2015-12-10 11:45:32 +01:00
|
|
|
mul [ebp+NTFS.sectors_per_cluster]
|
|
|
|
mov ecx, [ebp+NTFS.fileRealSize]
|
|
|
|
add ecx, 511
|
|
|
|
shr ecx, 9
|
2016-02-25 18:10:35 +01:00
|
|
|
mov ebx, [ebp+NTFS.fileDataBuffer]
|
2015-12-10 11:45:32 +01:00
|
|
|
call fs_write64_app
|
|
|
|
test eax, eax
|
2015-12-31 18:29:37 +01:00
|
|
|
jnz ntfsDevice
|
2015-12-10 11:45:32 +01:00
|
|
|
; 4. MFT record
|
|
|
|
.mftBitmap: ; search for free record
|
|
|
|
mov edi, [ebp+NTFS.mftBitmapBuffer]
|
|
|
|
mov ecx, [ebp+NTFS.mftBitmapSize]
|
|
|
|
mov al, -1
|
|
|
|
add edi, 3
|
|
|
|
sub ecx, 3
|
|
|
|
repz scasb
|
|
|
|
dec edi
|
|
|
|
movzx eax, byte [edi]
|
|
|
|
not al
|
|
|
|
bsf ecx, eax
|
2016-01-28 00:48:14 +01:00
|
|
|
jz .extendBitmapMFT ; no free records
|
2015-12-31 18:29:37 +01:00
|
|
|
bts [edi], ecx
|
|
|
|
; get record location
|
2015-12-10 11:45:32 +01:00
|
|
|
sub edi, [ebp+NTFS.mftBitmapBuffer]
|
|
|
|
shl edi, 3
|
|
|
|
add edi, ecx
|
2016-03-15 07:18:38 +01:00
|
|
|
mov [ebp+NTFS.newRecord], edi
|
2015-12-10 11:45:32 +01:00
|
|
|
mov eax, [ebp+NTFS.frs_size]
|
|
|
|
shr eax, 9
|
|
|
|
mul edi
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_iRecord], 0
|
|
|
|
mov [ebp+NTFS.cur_attr], 0x80
|
|
|
|
mov [ebp+NTFS.cur_offs], eax
|
2016-04-21 19:41:56 +02:00
|
|
|
push eax
|
|
|
|
mov [ebp+NTFS.cur_size], 0
|
2015-12-10 11:45:32 +01:00
|
|
|
mov eax, [ebp+NTFS.frs_buffer]
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_buf], eax
|
2015-12-10 11:45:32 +01:00
|
|
|
call ntfs_read_attr
|
2016-04-21 19:41:56 +02:00
|
|
|
pop eax
|
|
|
|
jc ntfsFail
|
|
|
|
cmp eax, [ebp+NTFS.mftSize]
|
|
|
|
jnc .extendMFT
|
2016-01-28 00:48:14 +01:00
|
|
|
jmp .mftRecord
|
|
|
|
|
|
|
|
.extendBitmapMFT:
|
|
|
|
mov eax, [ebp+NTFS.sectors_per_cluster]
|
2016-04-21 19:41:56 +02:00
|
|
|
mov [ebp+NTFS.cur_offs], eax
|
2016-01-28 00:48:14 +01:00
|
|
|
shl eax, 9
|
|
|
|
cmp [ebp+NTFS.mftBitmapSize], eax
|
|
|
|
jnc ntfsUnsupported
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_iRecord], 0
|
|
|
|
mov [ebp+NTFS.cur_attr], 0xB0
|
|
|
|
mov [ebp+NTFS.cur_size], 0
|
2016-01-28 00:48:14 +01:00
|
|
|
call ntfs_read_attr
|
|
|
|
jc ntfsFail
|
2015-12-10 11:45:32 +01:00
|
|
|
mov eax, [ebp+NTFS.mft_cluster]
|
|
|
|
mul [ebp+NTFS.sectors_per_cluster]
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp eax, [ebp+NTFS.LastRead]
|
2015-12-31 18:29:37 +01:00
|
|
|
jnz ntfsUnsupported ; auxiliary record
|
2016-01-28 00:48:14 +01:00
|
|
|
mov edi, [ebp+NTFS.mftBitmapBuffer]
|
|
|
|
mov ecx, [ebp+NTFS.mftBitmapSize]
|
|
|
|
add edi, ecx
|
|
|
|
mov eax, ecx
|
2016-02-21 03:13:21 +01:00
|
|
|
mov edx, [ebp+NTFS.attr_offs]
|
2016-01-28 00:48:14 +01:00
|
|
|
add ecx, 8
|
|
|
|
mov [edx+attributeRealSize], ecx
|
|
|
|
mov [edx+initialDataSize], ecx
|
|
|
|
shl eax, 3
|
2016-03-15 07:18:38 +01:00
|
|
|
mov [ebp+NTFS.newRecord], eax
|
2016-01-28 00:48:14 +01:00
|
|
|
mov dword [edi], 1
|
|
|
|
mov dword [edi+4], 0
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_attr], 0x80
|
2016-04-21 19:41:56 +02:00
|
|
|
mov [ebp+NTFS.cur_offs], 0
|
2016-01-28 00:48:14 +01:00
|
|
|
call ntfs_read_attr.newAttribute
|
|
|
|
jc ntfsFail
|
|
|
|
mov [ebp+NTFS.mftBitmapSize], ecx
|
|
|
|
.extendMFT:
|
|
|
|
mov eax, [ebp+NTFS.mft_cluster]
|
2015-12-10 11:45:32 +01:00
|
|
|
mul [ebp+NTFS.sectors_per_cluster]
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp eax, [ebp+NTFS.LastRead]
|
2016-01-28 00:48:14 +01:00
|
|
|
jnz ntfsUnsupported ; auxiliary record
|
2016-02-21 03:13:21 +01:00
|
|
|
mov ecx, [ebp+NTFS.attr_offs]
|
2016-01-28 00:48:14 +01:00
|
|
|
mov eax, [ecx+attributeRealSize]
|
|
|
|
mov edx, [ecx+attributeRealSize+4]
|
|
|
|
xor ax, ax
|
|
|
|
add eax, 10000h
|
|
|
|
adc edx, 0
|
|
|
|
push [ebp+NTFS.fileDataStart]
|
|
|
|
push [ebp+NTFS.fileDataSize]
|
|
|
|
call resizeAttribute
|
|
|
|
jc ntfsErrorPop2
|
2016-04-27 10:48:17 +02:00
|
|
|
mov ebx, [ebp+NTFS.frs_buffer]
|
|
|
|
mov edx, [ebp+NTFS.LastRead]
|
2015-12-10 11:45:32 +01:00
|
|
|
call writeRecord ; $MFT
|
|
|
|
mov eax, [ebp+NTFS.mftmirr_cluster]
|
|
|
|
mul [ebp+NTFS.sectors_per_cluster]
|
2016-04-27 10:48:17 +02:00
|
|
|
mov ecx, [ebp+NTFS.frs_size]
|
|
|
|
shr ecx, 9
|
2015-12-10 11:45:32 +01:00
|
|
|
call fs_write64_sys ; $MFTMirr
|
2016-04-21 19:41:56 +02:00
|
|
|
; update $MFT retrieval information
|
|
|
|
mov edi, [ebp+NTFS.mft_retrieval_end]
|
|
|
|
mov eax, [edi-4]
|
|
|
|
add eax, [edi-8]
|
|
|
|
mov edx, [ebp+NTFS.fileDataSize]
|
|
|
|
cmp eax, [ebp+NTFS.fileDataStart]
|
|
|
|
jnz .newFragment
|
|
|
|
add [edi-8], edx
|
|
|
|
jmp @f
|
|
|
|
.newFragment:
|
|
|
|
lea eax, [ebp+NTFS.attrlist_buf]
|
|
|
|
cmp eax, edi
|
|
|
|
jz @f
|
|
|
|
mov [edi], edx
|
|
|
|
mov eax, [ebp+NTFS.fileDataStart]
|
|
|
|
mov [edi+4], eax
|
|
|
|
add [ebp+NTFS.mft_retrieval_end], 8
|
|
|
|
@@:
|
|
|
|
mov eax, [ebp+NTFS.fileDataSize]
|
|
|
|
mul [ebp+NTFS.sectors_per_cluster]
|
|
|
|
add [ebp+NTFS.mftSize], eax
|
2016-01-28 00:48:14 +01:00
|
|
|
call ntfsSpaceClean
|
|
|
|
pop [ebp+NTFS.fileDataSize]
|
|
|
|
pop [ebp+NTFS.fileDataStart]
|
2015-12-10 11:45:32 +01:00
|
|
|
.mftRecord:
|
2016-02-06 18:50:04 +01:00
|
|
|
mov ecx, [ebp+NTFS.frs_size]
|
|
|
|
shr ecx, 2
|
2015-12-10 11:45:32 +01:00
|
|
|
mov edi, [ebp+NTFS.frs_buffer]
|
|
|
|
xor eax, eax
|
|
|
|
rep stosd
|
2016-05-04 19:36:09 +02:00
|
|
|
mov esi, [ebp+NTFS.indexPointer]
|
|
|
|
mov eax, [ebp+NTFS.newRecord]
|
|
|
|
mov [esi+fileRecordReference], eax
|
|
|
|
rdtsc
|
|
|
|
mov [esi+fileReferenceReuse], ax
|
2015-12-10 11:45:32 +01:00
|
|
|
mov edi, [ebp+NTFS.frs_buffer]
|
2015-12-31 18:29:37 +01:00
|
|
|
; record header
|
2016-05-04 19:36:09 +02:00
|
|
|
mov [edi+reuseCounter], ax
|
2016-02-25 18:10:35 +01:00
|
|
|
mov [edi+2ah], ax
|
2016-02-06 18:50:04 +01:00
|
|
|
mov eax, [ebp+NTFS.frs_size]
|
|
|
|
mov [edi+recordAllocatedSize], eax
|
|
|
|
shr eax, 9
|
|
|
|
inc eax
|
|
|
|
mov [edi+updateSequenceSize], al
|
2016-02-25 18:10:35 +01:00
|
|
|
shl eax, 1
|
|
|
|
add eax, 2ah+7
|
|
|
|
and eax, not 7
|
2015-12-10 11:45:32 +01:00
|
|
|
mov dword[edi], 'FILE'
|
|
|
|
mov byte [edi+updateSequenceOffset], 2ah
|
|
|
|
mov byte [edi+hardLinkCounter], 1
|
|
|
|
mov byte [edi+newAttributeID], 3
|
2016-02-25 18:10:35 +01:00
|
|
|
mov [edi+attributeOffset], al
|
|
|
|
add edi, eax
|
2015-12-31 18:29:37 +01:00
|
|
|
; $StandardInformation
|
2015-12-10 11:45:32 +01:00
|
|
|
mov byte [edi+attributeType], 10h
|
|
|
|
mov byte [edi+sizeWithHeader], 48h
|
|
|
|
mov byte [edi+sizeWithoutHeader], 30h
|
|
|
|
mov byte [edi+attributeOffset], 18h
|
2016-05-08 00:26:48 +02:00
|
|
|
mov cl, 8
|
|
|
|
add esi, fileCreated
|
|
|
|
add edi, 18h
|
|
|
|
rep movsd
|
|
|
|
add edi, 16
|
|
|
|
mov esi, [ebp+NTFS.indexPointer]
|
2015-12-31 18:29:37 +01:00
|
|
|
; $FileName
|
2015-12-10 11:45:32 +01:00
|
|
|
mov byte [edi+attributeType], 30h
|
|
|
|
mov byte [edi+attributeID], 1
|
2016-02-06 18:50:04 +01:00
|
|
|
mov byte [edi+attributeOffset], 18h
|
|
|
|
mov byte [edi+indexedFlag], 1
|
2015-12-10 11:45:32 +01:00
|
|
|
mov cx, [esi+indexRawSize]
|
|
|
|
mov [edi+sizeWithoutHeader], ecx
|
|
|
|
mov cx, [esi+indexAllocatedSize]
|
|
|
|
add ecx, 8
|
|
|
|
mov [edi+sizeWithHeader], ecx
|
|
|
|
add edi, 18h
|
|
|
|
add esi, 16
|
|
|
|
sub ecx, 18h
|
|
|
|
shr ecx, 2
|
|
|
|
rep movsd
|
2016-01-19 20:45:51 +01:00
|
|
|
mov byte [edi+sizeWithHeader], 50h
|
|
|
|
mov byte [edi+attributeID], 2
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.bFolder], 1
|
2016-02-06 18:50:04 +01:00
|
|
|
jz .indexRoot
|
2015-12-31 18:29:37 +01:00
|
|
|
; $Data
|
2015-12-10 11:45:32 +01:00
|
|
|
mov byte [edi+attributeType], 80h
|
2016-01-19 20:45:51 +01:00
|
|
|
mov eax, [ebp+NTFS.fileDataSize]
|
2016-02-06 18:50:04 +01:00
|
|
|
test eax, eax
|
|
|
|
jz .resident
|
2016-04-21 19:41:56 +02:00
|
|
|
mov esi, [ebp+NTFS.indexPointer]
|
2016-01-19 20:45:51 +01:00
|
|
|
dec eax
|
|
|
|
mov [edi+lastVCN], eax
|
2015-12-10 11:45:32 +01:00
|
|
|
mov byte [edi+nonResidentFlag], 1
|
|
|
|
mov byte [edi+dataRunsOffset], 40h
|
|
|
|
mov eax, [esi+fileAllocatedSize]
|
|
|
|
mov [edi+attributeAllocatedSize], eax
|
|
|
|
mov eax, [esi+fileRealSize]
|
|
|
|
mov [edi+attributeRealSize], eax
|
|
|
|
mov [edi+initialDataSize], eax
|
2016-02-06 18:50:04 +01:00
|
|
|
push edi
|
2016-01-19 20:45:51 +01:00
|
|
|
mov esi, edi
|
|
|
|
add edi, 40h
|
|
|
|
call createMcbEntry
|
2016-02-06 18:50:04 +01:00
|
|
|
inc edi
|
|
|
|
jmp @f
|
2015-12-10 11:45:32 +01:00
|
|
|
|
2016-02-06 18:50:04 +01:00
|
|
|
.resident:
|
|
|
|
mov ecx, [ebp+NTFS.fileRealSize]
|
|
|
|
mov [edi+sizeWithoutHeader], ecx
|
2015-12-10 11:45:32 +01:00
|
|
|
mov byte [edi+attributeOffset], 18h
|
2016-02-06 18:50:04 +01:00
|
|
|
push edi
|
2016-02-25 18:10:35 +01:00
|
|
|
mov esi, [ebp+NTFS.fileDataBuffer]
|
2016-02-06 18:50:04 +01:00
|
|
|
add edi, 18h
|
|
|
|
rep movsb
|
|
|
|
@@:
|
|
|
|
mov eax, edi
|
|
|
|
pop edi
|
|
|
|
sub eax, edi
|
|
|
|
add eax, 7
|
|
|
|
and eax, not 7
|
|
|
|
mov [edi+sizeWithHeader], eax
|
|
|
|
add edi, eax
|
2015-12-10 11:45:32 +01:00
|
|
|
mov al, 1
|
2016-02-25 18:10:35 +01:00
|
|
|
jmp .end
|
2015-12-10 11:45:32 +01:00
|
|
|
|
2016-02-06 18:50:04 +01:00
|
|
|
.indexRoot:
|
2015-12-10 11:45:32 +01:00
|
|
|
mov byte [edi+attributeType], 90h
|
|
|
|
mov byte [edi+nameLength], 4
|
|
|
|
mov byte [edi+nameOffset], 18h
|
|
|
|
mov byte [edi+sizeWithoutHeader], 30h
|
|
|
|
mov byte [edi+attributeOffset], 20h
|
|
|
|
mov dword[edi+18h], 490024h ; unicode $I30
|
|
|
|
mov dword[edi+18h+4], 300033h
|
2016-02-21 03:13:21 +01:00
|
|
|
mov byte [edi+20h+indexedAttributesType], 30h
|
2015-12-31 18:29:37 +01:00
|
|
|
mov byte [edi+20h+collationRule], 1
|
2015-12-10 11:45:32 +01:00
|
|
|
mov eax, [ebp+NTFS.sectors_per_cluster]
|
2016-02-25 18:10:35 +01:00
|
|
|
mov dl, 1
|
|
|
|
shl eax, 8
|
|
|
|
@@:
|
|
|
|
shl eax, 1
|
|
|
|
shl edx, 1
|
|
|
|
cmp eax, [ebp+NTFS.frs_size]
|
|
|
|
jc @b
|
|
|
|
shr edx, 1
|
2015-12-31 18:29:37 +01:00
|
|
|
mov [edi+20h+indexRecordSize], eax
|
2016-02-25 18:10:35 +01:00
|
|
|
mov [edi+20h+indexRecordSizeClus], dl
|
2015-12-31 18:29:37 +01:00
|
|
|
mov byte [edi+30h+indexOffset], 16
|
|
|
|
mov byte [edi+30h+nodeRealSize], 32
|
|
|
|
mov byte [edi+30h+nodeAllocatedSize], 32
|
|
|
|
mov byte [edi+40h+indexAllocatedSize], 16
|
|
|
|
mov byte [edi+40h+indexFlags], 2
|
2016-02-06 18:50:04 +01:00
|
|
|
add edi, 50h
|
2015-12-10 11:45:32 +01:00
|
|
|
mov al, 3
|
2016-02-25 18:10:35 +01:00
|
|
|
.end:
|
2016-04-27 10:48:17 +02:00
|
|
|
mov ebx, [ebp+NTFS.frs_buffer]
|
2016-02-06 18:50:04 +01:00
|
|
|
mov dword [edi], -1
|
|
|
|
mov dword [edi+4], 0
|
|
|
|
add edi, 8
|
2016-04-27 10:48:17 +02:00
|
|
|
sub edi, ebx
|
|
|
|
mov [ebx+recordFlags], al
|
|
|
|
mov [ebx+recordRealSize], edi
|
|
|
|
mov edx, [ebp+NTFS.LastRead]
|
2015-12-10 11:45:32 +01:00
|
|
|
call writeRecord
|
2015-12-31 18:29:37 +01:00
|
|
|
; write MFT bitmap
|
2016-03-15 07:18:38 +01:00
|
|
|
mov eax, [ebp+NTFS.newRecord]
|
2015-12-10 11:45:32 +01:00
|
|
|
shr eax, 3+9
|
|
|
|
mov ebx, eax
|
|
|
|
shl ebx, 9
|
|
|
|
add eax, [ebp+NTFS.mftBitmapLocation]
|
|
|
|
add ebx, [ebp+NTFS.mftBitmapBuffer]
|
|
|
|
mov ecx, 1
|
|
|
|
xor edx, edx
|
|
|
|
call fs_write64_sys
|
2016-02-25 18:10:35 +01:00
|
|
|
; 5. Write directory node
|
2016-04-27 10:48:17 +02:00
|
|
|
mov ebx, [ebp+NTFS.cur_index_buf]
|
|
|
|
mov edx, [ebp+NTFS.nodeLastRead]
|
2015-12-10 11:45:32 +01:00
|
|
|
call writeRecord
|
2015-12-31 18:29:37 +01:00
|
|
|
mov ebx, [ebp+NTFS.fileRealSize]
|
|
|
|
ntfsDone:
|
2015-12-10 11:45:32 +01:00
|
|
|
mov esi, [ebp+PARTITION.Disk]
|
|
|
|
call disk_sync
|
|
|
|
call ntfs_unlock
|
2015-12-31 18:29:37 +01:00
|
|
|
xor eax, eax
|
2015-12-10 11:45:32 +01:00
|
|
|
ret
|
|
|
|
|
|
|
|
writeRecord:
|
2016-01-19 20:45:51 +01:00
|
|
|
; make updateSequence and write to disk
|
2015-12-10 11:45:32 +01:00
|
|
|
; in:
|
2016-04-27 10:48:17 +02:00
|
|
|
; ebx -> record
|
|
|
|
; edx = partition sector
|
|
|
|
mov esi, ebx
|
|
|
|
mov edi, ebx
|
2015-12-10 11:45:32 +01:00
|
|
|
movzx ecx, word [esi+updateSequenceOffset]
|
|
|
|
add edi, ecx
|
|
|
|
mov ax, [edi]
|
2016-01-19 20:45:51 +01:00
|
|
|
inc ax
|
|
|
|
stosw
|
2015-12-10 11:45:32 +01:00
|
|
|
mov cx, [esi+updateSequenceSize]
|
|
|
|
dec ecx
|
|
|
|
push ecx
|
|
|
|
@@:
|
|
|
|
add esi, 510
|
|
|
|
movsw
|
|
|
|
mov [esi-2], ax
|
|
|
|
dec ecx
|
|
|
|
jnz @b
|
2016-04-27 10:48:17 +02:00
|
|
|
mov eax, edx
|
2015-12-10 11:45:32 +01:00
|
|
|
xor edx, edx
|
2016-04-27 10:48:17 +02:00
|
|
|
pop ecx
|
2015-12-10 11:45:32 +01:00
|
|
|
jmp fs_write64_sys
|
|
|
|
|
2016-01-19 20:45:51 +01:00
|
|
|
createMcbEntry:
|
|
|
|
; in:
|
|
|
|
; [ebp+NTFS.fileDataStart] = position value
|
|
|
|
; [ebp+NTFS.fileDataSize] = size value
|
|
|
|
; edi -> destination
|
|
|
|
; esi -> attribute header
|
|
|
|
mov eax, [ebp+NTFS.fileDataStart]
|
2015-12-10 11:45:32 +01:00
|
|
|
xor edx, edx
|
2016-01-19 20:45:51 +01:00
|
|
|
shl eax, 1
|
2015-12-10 11:45:32 +01:00
|
|
|
jnc @f
|
2016-01-19 20:45:51 +01:00
|
|
|
not eax
|
|
|
|
@@:
|
|
|
|
inc edx
|
|
|
|
shr eax, 8
|
|
|
|
jnz @b
|
|
|
|
mov eax, [ebp+NTFS.fileDataSize]
|
|
|
|
shl eax, 1
|
|
|
|
xor ecx, ecx
|
2015-12-10 11:45:32 +01:00
|
|
|
@@:
|
2016-01-19 20:45:51 +01:00
|
|
|
inc ecx
|
|
|
|
shr eax, 8
|
|
|
|
jnz @b
|
|
|
|
lea eax, [edi+edx+1]
|
|
|
|
add eax, ecx
|
|
|
|
sub eax, esi
|
2016-02-06 18:50:04 +01:00
|
|
|
sub eax, [esi+sizeWithHeader]
|
2016-01-19 20:45:51 +01:00
|
|
|
jc @f
|
|
|
|
add word [esi+sizeWithHeader], 8 ; extend attribute
|
|
|
|
mov esi, [ebp+NTFS.frs_buffer]
|
|
|
|
mov eax, [esi+recordRealSize]
|
|
|
|
add eax, 8
|
|
|
|
cmp [esi+recordAllocatedSize], eax
|
|
|
|
jc .end ; no space in the record
|
|
|
|
mov [esi+recordRealSize], eax
|
|
|
|
push ecx edi
|
|
|
|
add esi, eax
|
|
|
|
mov ecx, esi
|
2015-12-31 18:29:37 +01:00
|
|
|
sub ecx, edi
|
2016-01-19 20:45:51 +01:00
|
|
|
sub ecx, 8
|
|
|
|
shr ecx, 2
|
|
|
|
mov edi, esi
|
|
|
|
sub edi, 4
|
|
|
|
sub esi, 12
|
|
|
|
std
|
|
|
|
rep movsd
|
|
|
|
cld
|
|
|
|
pop edi ecx
|
|
|
|
@@:
|
|
|
|
mov eax, edx
|
|
|
|
shl eax, 4
|
|
|
|
add eax, ecx
|
|
|
|
stosb
|
|
|
|
lea esi, [ebp+NTFS.fileDataSize]
|
|
|
|
rep movsb
|
|
|
|
lea esi, [ebp+NTFS.fileDataStart]
|
|
|
|
mov ecx, edx
|
|
|
|
rep movsb
|
2016-02-06 18:50:04 +01:00
|
|
|
mov [edi], cl
|
2016-01-19 20:45:51 +01:00
|
|
|
.end:
|
|
|
|
ret
|
|
|
|
|
|
|
|
resizeAttribute:
|
|
|
|
; in:
|
|
|
|
; [ebp+NTFS.frs_buffer] -> file record
|
2016-02-21 03:13:21 +01:00
|
|
|
; [ebp+NTFS.attr_offs] -> attribute
|
2016-01-19 20:45:51 +01:00
|
|
|
; edx:eax = new size
|
|
|
|
; out:
|
2016-01-28 00:48:14 +01:00
|
|
|
; [ebp+NTFS.fileDataSize] = clusters added (positive)
|
|
|
|
; [ebp+NTFS.fileDataStart] = added block
|
2016-01-19 20:45:51 +01:00
|
|
|
; CF=1 -> eax = error code
|
2016-02-21 03:13:21 +01:00
|
|
|
mov esi, [ebp+NTFS.attr_offs]
|
|
|
|
mov dword [ebp+NTFS.attr_size], eax
|
|
|
|
mov dword [ebp+NTFS.attr_size+4], edx
|
2016-02-06 18:50:04 +01:00
|
|
|
cmp byte [esi+nonResidentFlag], 0
|
|
|
|
jz .resident
|
|
|
|
mov ecx, [ebp+NTFS.sectors_per_cluster]
|
|
|
|
shl ecx, 9
|
2016-01-19 20:45:51 +01:00
|
|
|
mov [esi+attributeRealSize], eax
|
|
|
|
mov [esi+attributeRealSize+4], edx
|
|
|
|
mov [esi+initialDataSize], eax
|
|
|
|
mov [esi+initialDataSize+4], edx
|
|
|
|
sub eax, 1
|
|
|
|
sbb edx, 0
|
2016-02-06 18:50:04 +01:00
|
|
|
jc .makeResident
|
2016-01-19 20:45:51 +01:00
|
|
|
div ecx
|
|
|
|
mov edi, eax
|
|
|
|
inc eax
|
|
|
|
mul ecx
|
|
|
|
mov [esi+attributeAllocatedSize], eax
|
|
|
|
mov [esi+attributeAllocatedSize+4], edx
|
|
|
|
mov ecx, [esi+lastVCN]
|
|
|
|
mov [esi+lastVCN], edi
|
|
|
|
movzx eax, byte [esi+dataRunsOffset]
|
|
|
|
sub edi, ecx
|
2016-01-28 00:48:14 +01:00
|
|
|
mov [ebp+NTFS.fileDataSize], edi
|
2016-01-19 20:45:51 +01:00
|
|
|
jz .done
|
|
|
|
jc .shrinkAttribute
|
|
|
|
; extend attribute
|
|
|
|
xor edi, edi
|
|
|
|
add esi, eax
|
|
|
|
push edi edi edi edi
|
|
|
|
@@:
|
|
|
|
mov edx, eax
|
|
|
|
mov eax, esi
|
|
|
|
add edi, [esp+8]
|
|
|
|
call ntfs_decode_mcb_entry
|
|
|
|
jc @b
|
|
|
|
mov [esp+4], edx
|
|
|
|
mov [esp+12], edi
|
|
|
|
add edi, [esp]
|
|
|
|
push edi
|
|
|
|
shr edi, 5
|
|
|
|
shl edi, 2
|
|
|
|
push eax
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.cur_iRecord], 0
|
2016-01-28 00:48:14 +01:00
|
|
|
jz @f
|
2016-01-19 20:45:51 +01:00
|
|
|
cmp edi, [ebp+NTFS.BitmapStart]
|
|
|
|
jc .err1
|
2016-01-28 00:48:14 +01:00
|
|
|
@@:
|
2016-01-19 20:45:51 +01:00
|
|
|
call ntfsSpaceAlloc
|
|
|
|
jc .err1
|
2016-02-25 18:10:35 +01:00
|
|
|
mov eax, [ebp+NTFS.fileDataStart]
|
2016-01-19 20:45:51 +01:00
|
|
|
pop edi
|
|
|
|
pop edx
|
|
|
|
cmp edx, eax
|
|
|
|
jnz .newEntry
|
|
|
|
pop edx
|
|
|
|
pop edi
|
|
|
|
pop [ebp+NTFS.fileDataStart]
|
|
|
|
mov [esp], eax
|
|
|
|
push [ebp+NTFS.fileDataSize]
|
|
|
|
add [ebp+NTFS.fileDataSize], edx
|
|
|
|
jmp @f
|
|
|
|
|
|
|
|
.newEntry:
|
|
|
|
add esp, 12
|
|
|
|
pop edx
|
|
|
|
push eax
|
|
|
|
push [ebp+NTFS.fileDataSize]
|
|
|
|
sub eax, edx
|
|
|
|
mov [ebp+NTFS.fileDataStart], eax
|
|
|
|
@@:
|
2016-02-21 03:13:21 +01:00
|
|
|
mov esi, [ebp+NTFS.attr_offs]
|
2016-01-19 20:45:51 +01:00
|
|
|
call createMcbEntry
|
2016-02-25 18:10:35 +01:00
|
|
|
pop [ebp+NTFS.fileDataSize]
|
|
|
|
pop [ebp+NTFS.fileDataStart]
|
|
|
|
movi eax, ERROR_UNSUPPORTED_FS
|
2016-02-06 18:50:04 +01:00
|
|
|
.done:
|
|
|
|
ret
|
|
|
|
|
2016-01-19 20:45:51 +01:00
|
|
|
.err1:
|
|
|
|
add esp, 24
|
|
|
|
stc
|
2016-02-25 18:10:35 +01:00
|
|
|
.err2:
|
2016-02-06 18:50:04 +01:00
|
|
|
movi eax, ERROR_DISK_FULL
|
2016-01-19 20:45:51 +01:00
|
|
|
ret
|
|
|
|
|
2016-02-25 18:10:35 +01:00
|
|
|
.err3:
|
|
|
|
movi eax, ERROR_FS_FAIL
|
|
|
|
add esp, 20
|
|
|
|
stc
|
2016-01-19 20:45:51 +01:00
|
|
|
ret
|
|
|
|
|
|
|
|
.shrinkAttribute:
|
|
|
|
add ecx, edi
|
|
|
|
inc ecx
|
|
|
|
add esi, eax
|
|
|
|
xor edi, edi
|
|
|
|
sub esp, 20
|
|
|
|
@@:
|
|
|
|
mov [esp+16], esi
|
|
|
|
call ntfs_decode_mcb_entry
|
|
|
|
jnc .err3
|
|
|
|
add edi, [esp+8]
|
|
|
|
sub ecx, [esp]
|
|
|
|
jnc @b
|
|
|
|
mov ebx, ecx
|
|
|
|
add ecx, [esp]
|
|
|
|
mov eax, [esp+8]
|
|
|
|
mov [ebp+NTFS.fileDataSize], ecx
|
|
|
|
mov [ebp+NTFS.fileDataStart], eax
|
|
|
|
push edi
|
|
|
|
add edi, ecx
|
|
|
|
neg ebx
|
|
|
|
call ntfsSpaceFree
|
|
|
|
pop edi
|
|
|
|
jc .end
|
|
|
|
@@:
|
|
|
|
call ntfs_decode_mcb_entry
|
|
|
|
jnc .end
|
|
|
|
cmp dword[esp+8], 0
|
|
|
|
jz @b
|
|
|
|
add edi, [esp+8]
|
|
|
|
mov ebx, [esp]
|
|
|
|
call ntfsSpaceFree
|
|
|
|
jnc @b
|
|
|
|
.end:
|
|
|
|
add esp, 16
|
|
|
|
pop edi
|
|
|
|
cmp [ebp+NTFS.fileDataSize], 0
|
|
|
|
jz @f
|
2016-02-21 03:13:21 +01:00
|
|
|
mov esi, [ebp+NTFS.attr_offs]
|
2016-01-19 20:45:51 +01:00
|
|
|
call createMcbEntry
|
2016-01-28 00:48:14 +01:00
|
|
|
mov [ebp+NTFS.fileDataSize], 0
|
2016-01-19 20:45:51 +01:00
|
|
|
@@:
|
|
|
|
ret
|
|
|
|
|
2016-02-06 18:50:04 +01:00
|
|
|
.resident:
|
|
|
|
test edx, edx
|
|
|
|
jnz .nonResident
|
|
|
|
cmp eax, 8000h
|
|
|
|
jnc .nonResident
|
|
|
|
add ax, [esi+attributeOffset]
|
|
|
|
sub eax, [esi+sizeWithHeader]
|
|
|
|
jc @f
|
|
|
|
mov edi, [ebp+NTFS.frs_buffer]
|
|
|
|
mov ecx, eax
|
|
|
|
add ecx, [edi+recordRealSize]
|
|
|
|
cmp [edi+recordAllocatedSize], ecx
|
|
|
|
jc .nonResident
|
|
|
|
add eax, 7
|
|
|
|
and eax, not 7
|
|
|
|
add [edi+recordRealSize], eax
|
|
|
|
add edi, [edi+recordRealSize]
|
|
|
|
add [esi+sizeWithHeader], eax
|
|
|
|
add esi, [esi+sizeWithHeader]
|
|
|
|
mov ecx, edi
|
|
|
|
sub ecx, esi
|
|
|
|
shr ecx, 2
|
|
|
|
sub edi, 4
|
|
|
|
mov esi, edi
|
|
|
|
sub esi, eax
|
|
|
|
std
|
|
|
|
rep movsd
|
|
|
|
mov ecx, eax
|
|
|
|
shr ecx, 2
|
|
|
|
xor eax, eax
|
|
|
|
rep stosd
|
|
|
|
cld
|
2016-02-21 03:13:21 +01:00
|
|
|
mov esi, [ebp+NTFS.attr_offs]
|
2016-02-06 18:50:04 +01:00
|
|
|
@@:
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, dword [ebp+NTFS.attr_size]
|
2016-02-06 18:50:04 +01:00
|
|
|
mov [esi+sizeWithoutHeader], eax
|
|
|
|
mov [ebp+NTFS.fileDataSize], 0
|
|
|
|
clc
|
|
|
|
ret
|
|
|
|
|
|
|
|
.nonResident: ; convert resident to non-resident
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, dword [ebp+NTFS.attr_size]
|
2016-02-06 18:50:04 +01:00
|
|
|
sub eax, 1
|
|
|
|
sbb edx, 0
|
|
|
|
mov ecx, [ebp+NTFS.sectors_per_cluster]
|
|
|
|
shl ecx, 9
|
|
|
|
div ecx
|
|
|
|
inc eax
|
|
|
|
mov [ebp+NTFS.fileDataSize], eax
|
|
|
|
mov edi, [ebp+NTFS.BitmapStart]
|
|
|
|
push ecx
|
|
|
|
call ntfsSpaceAlloc
|
|
|
|
pop ecx
|
2016-02-25 18:10:35 +01:00
|
|
|
jc .err2
|
2016-02-21 03:13:21 +01:00
|
|
|
mov esi, [ebp+NTFS.attr_offs]
|
2016-02-06 18:50:04 +01:00
|
|
|
xor eax, eax
|
|
|
|
xor edx, edx
|
|
|
|
@@:
|
|
|
|
add eax, ecx
|
|
|
|
inc edx
|
|
|
|
cmp eax, [esi+sizeWithoutHeader]
|
|
|
|
jc @b
|
|
|
|
push edx
|
|
|
|
push eax
|
|
|
|
stdcall kernel_alloc, eax
|
|
|
|
mov ecx, [esp]
|
|
|
|
shr ecx, 2
|
|
|
|
mov edi, eax
|
|
|
|
mov ebx, eax
|
|
|
|
xor eax, eax
|
|
|
|
rep stosd
|
|
|
|
mov al, [esi+attributeOffset]
|
|
|
|
mov ecx, [esi+sizeWithoutHeader]
|
|
|
|
add esi, eax
|
|
|
|
mov edi, ebx
|
|
|
|
rep movsb
|
|
|
|
mov eax, [ebp+NTFS.fileDataStart]
|
|
|
|
mul [ebp+NTFS.sectors_per_cluster]
|
|
|
|
pop ecx
|
|
|
|
shr ecx, 9
|
|
|
|
call fs_write64_app
|
2016-02-25 18:10:35 +01:00
|
|
|
stdcall kernel_free, ebx
|
2016-02-21 03:13:21 +01:00
|
|
|
mov esi, [ebp+NTFS.attr_offs]
|
2016-02-06 18:50:04 +01:00
|
|
|
add esi, [esi+sizeWithHeader]
|
|
|
|
mov ecx, [ebp+NTFS.frs_buffer]
|
|
|
|
add ecx, [ecx+recordRealSize]
|
|
|
|
sub ecx, esi
|
|
|
|
shr ecx, 2
|
2016-02-21 03:13:21 +01:00
|
|
|
lea edi, [ebp+NTFS.bitmap_buf]
|
2016-02-06 18:50:04 +01:00
|
|
|
push ecx
|
|
|
|
rep movsd
|
2016-02-21 03:13:21 +01:00
|
|
|
mov edi, [ebp+NTFS.attr_offs]
|
2016-02-06 18:50:04 +01:00
|
|
|
add edi, 16
|
|
|
|
mov cl, 6
|
|
|
|
xor eax, eax
|
|
|
|
rep stosd
|
2016-02-21 03:13:21 +01:00
|
|
|
mov edi, [ebp+NTFS.attr_offs]
|
2016-02-06 18:50:04 +01:00
|
|
|
mov eax, [ebp+NTFS.fileDataSize]
|
|
|
|
dec eax
|
|
|
|
mov [edi+lastVCN], eax
|
|
|
|
inc eax
|
|
|
|
mov ecx, [ebp+NTFS.sectors_per_cluster]
|
|
|
|
shl ecx, 9
|
|
|
|
mul ecx
|
|
|
|
mov byte [edi+sizeWithHeader], 50h
|
|
|
|
mov byte [edi+nonResidentFlag], 1
|
|
|
|
mov byte [edi+dataRunsOffset], 40h
|
|
|
|
mov [edi+attributeAllocatedSize], eax
|
|
|
|
mov [edi+attributeAllocatedSize+4], edx
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, dword [ebp+NTFS.attr_size]
|
|
|
|
mov edx, dword [ebp+NTFS.attr_size+4]
|
2016-02-06 18:50:04 +01:00
|
|
|
mov [edi+attributeRealSize], eax
|
|
|
|
mov [edi+attributeRealSize+4], edx
|
|
|
|
mov [edi+initialDataSize], eax
|
|
|
|
mov [edi+initialDataSize+4], edx
|
|
|
|
mov esi, edi
|
|
|
|
add edi, 40h
|
|
|
|
call createMcbEntry
|
|
|
|
mov eax, edi
|
2016-02-21 03:13:21 +01:00
|
|
|
mov edi, [ebp+NTFS.attr_offs]
|
2016-02-06 18:50:04 +01:00
|
|
|
sub eax, edi
|
|
|
|
add eax, 8
|
|
|
|
and eax, not 7
|
|
|
|
mov [edi+sizeWithHeader], eax
|
|
|
|
pop ecx
|
2016-02-21 03:13:21 +01:00
|
|
|
lea esi, [ebp+NTFS.bitmap_buf]
|
2016-02-06 18:50:04 +01:00
|
|
|
add edi, eax
|
|
|
|
rep movsd
|
|
|
|
mov esi, [ebp+NTFS.frs_buffer]
|
|
|
|
sub edi, esi
|
|
|
|
mov [esi+recordRealSize], edi
|
|
|
|
pop edx
|
|
|
|
sub [ebp+NTFS.fileDataSize], edx
|
|
|
|
add [ebp+NTFS.fileDataStart], edx
|
2016-02-25 18:10:35 +01:00
|
|
|
ret
|
2016-02-06 18:50:04 +01:00
|
|
|
|
|
|
|
.makeResident: ; convert non-resident to empty resident
|
|
|
|
movzx eax, byte [esi+dataRunsOffset]
|
|
|
|
mov byte [esi+nonResidentFlag], 0
|
|
|
|
mov dword [esi+sizeWithoutHeader], 0
|
|
|
|
mov dword [esi+attributeOffset], 18h
|
|
|
|
add esi, eax
|
|
|
|
xor edi, edi
|
|
|
|
sub esp, 16
|
|
|
|
@@:
|
|
|
|
call ntfs_decode_mcb_entry
|
|
|
|
jnc @f
|
|
|
|
cmp dword[esp+8], 0
|
|
|
|
jz @b
|
|
|
|
add edi, [esp+8]
|
|
|
|
mov ebx, [esp]
|
|
|
|
call ntfsSpaceFree
|
|
|
|
jnc @b
|
|
|
|
@@:
|
|
|
|
add esp, 16
|
|
|
|
mov [ebp+NTFS.fileDataSize], 0
|
|
|
|
ret
|
|
|
|
|
2016-01-28 00:48:14 +01:00
|
|
|
ntfsSpaceClean:
|
|
|
|
; clean up to 16 Mb of disk space
|
|
|
|
; in:
|
|
|
|
; [ebp+NTFS.fileDataStart] = block to clean
|
|
|
|
; [ebp+NTFS.fileDataSize] = block size
|
|
|
|
mov eax, [ebp+NTFS.fileDataSize]
|
|
|
|
test eax, eax
|
|
|
|
jz @f
|
|
|
|
mul [ebp+NTFS.sectors_per_cluster]
|
|
|
|
cmp eax, 8001h
|
|
|
|
jnc @f
|
|
|
|
push eax
|
|
|
|
shl eax, 9
|
|
|
|
stdcall kernel_alloc, eax
|
|
|
|
pop ecx
|
|
|
|
test eax, eax
|
|
|
|
jz @f
|
|
|
|
push ecx
|
|
|
|
shl ecx, 7
|
|
|
|
mov edi, eax
|
|
|
|
mov ebx, eax
|
|
|
|
xor eax, eax
|
|
|
|
rep stosd
|
|
|
|
mov eax, [ebp+NTFS.fileDataStart]
|
|
|
|
mul [ebp+NTFS.sectors_per_cluster]
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.LastRead], eax
|
2016-01-28 00:48:14 +01:00
|
|
|
pop ecx
|
|
|
|
call fs_write64_app
|
|
|
|
stdcall kernel_free, ebx
|
|
|
|
@@:
|
|
|
|
ret
|
|
|
|
|
2016-01-19 20:45:51 +01:00
|
|
|
ntfsSpaceAlloc:
|
2016-02-25 18:10:35 +01:00
|
|
|
; allocate disk space
|
2016-01-19 20:45:51 +01:00
|
|
|
; in:
|
|
|
|
; edi = offset in bitmap to start search from
|
|
|
|
; [ebp+NTFS.fileDataSize] = block size in clusters
|
|
|
|
; out:
|
2016-02-25 18:10:35 +01:00
|
|
|
; [ebp+NTFS.fileDataStart] = allocated block starting cluster
|
2016-01-19 20:45:51 +01:00
|
|
|
; CF=1 -> disk full
|
2016-02-25 18:10:35 +01:00
|
|
|
push eax
|
2016-01-19 20:45:51 +01:00
|
|
|
mov ecx, [ebp+NTFS.BitmapBuffer]
|
|
|
|
add edi, ecx
|
|
|
|
add ecx, [ebp+NTFS.BitmapSize]
|
|
|
|
sub ecx, edi
|
|
|
|
jnc @f
|
|
|
|
call bitmapBuffering
|
|
|
|
shl ecx, 2
|
|
|
|
@@:
|
|
|
|
shr ecx, 2
|
|
|
|
mov eax, [ebp+NTFS.fileDataSize]
|
|
|
|
shr eax, 5
|
|
|
|
jz .small
|
2016-02-25 18:10:35 +01:00
|
|
|
mov ebx, eax ; bitmap dwords
|
2016-01-19 20:45:51 +01:00
|
|
|
.start:
|
|
|
|
mov ecx, [ebp+NTFS.BitmapBuffer]
|
|
|
|
add ecx, [ebp+NTFS.BitmapSize]
|
|
|
|
sub ecx, edi
|
|
|
|
shr ecx, 2
|
|
|
|
@@:
|
|
|
|
xor eax, eax
|
|
|
|
repnz scasd ; search for empty dword
|
|
|
|
jz @f
|
|
|
|
call bitmapBuffering
|
|
|
|
jmp @b
|
|
|
|
@@:
|
2016-02-25 18:10:35 +01:00
|
|
|
cmp ecx, ebx
|
2016-01-19 20:45:51 +01:00
|
|
|
jnc @f
|
|
|
|
call bitmapBuffering
|
|
|
|
jmp @b
|
|
|
|
@@:
|
|
|
|
sub edi, 4
|
2016-02-25 18:10:35 +01:00
|
|
|
mov ecx, ebx
|
2016-01-19 20:45:51 +01:00
|
|
|
mov esi, edi
|
|
|
|
xor eax, eax
|
|
|
|
repz scasd ; check following dwords
|
|
|
|
jnz .start
|
|
|
|
sub esi, 4
|
|
|
|
mov eax, [esi]
|
|
|
|
xor edx, edx
|
|
|
|
bsr edx, eax
|
|
|
|
inc edx
|
|
|
|
push edx ; starting bit
|
|
|
|
push esi ; starting dword
|
|
|
|
add esi, 4
|
|
|
|
neg edx
|
|
|
|
add edx, 32
|
|
|
|
mov eax, [ebp+NTFS.fileDataSize]
|
|
|
|
sub eax, edx
|
|
|
|
mov edx, eax
|
|
|
|
shr eax, 5
|
|
|
|
shl eax, 2
|
|
|
|
add esi, eax
|
|
|
|
mov eax, [esi]
|
|
|
|
bsf ecx, eax ; check last dword
|
|
|
|
jz .done
|
|
|
|
and edx, 31
|
|
|
|
cmp ecx, edx
|
|
|
|
jnc .done
|
|
|
|
add esp, 8
|
|
|
|
jmp .start
|
|
|
|
|
|
|
|
.small: ; less than 32 clusters
|
|
|
|
mov eax, -1
|
|
|
|
repz scasd ; search for zero bits
|
|
|
|
test ecx, ecx
|
|
|
|
jnz @f
|
|
|
|
call bitmapBuffering
|
|
|
|
jmp .small
|
|
|
|
@@:
|
|
|
|
sub edi, 4
|
|
|
|
mov eax, [edi]
|
|
|
|
not eax
|
|
|
|
@@:
|
2016-02-25 18:10:35 +01:00
|
|
|
bsf ebx, eax ; first 0
|
2016-01-19 20:45:51 +01:00
|
|
|
jz .again
|
|
|
|
not eax
|
|
|
|
shr eax, cl
|
|
|
|
shl eax, cl
|
|
|
|
bsf edx, eax ; next 1
|
|
|
|
jz @f
|
2016-02-25 18:10:35 +01:00
|
|
|
sub edx, ebx
|
2016-01-19 20:45:51 +01:00
|
|
|
cmp edx, [ebp+NTFS.fileDataSize]
|
|
|
|
jnc .got ; fits inside
|
2016-02-25 18:10:35 +01:00
|
|
|
bsf ebx, eax
|
2016-01-19 20:45:51 +01:00
|
|
|
not eax
|
|
|
|
shr eax, cl
|
|
|
|
shl eax, cl
|
|
|
|
jmp @b
|
|
|
|
@@: ; next dword
|
|
|
|
mov eax, [edi+4]
|
|
|
|
bsf edx, eax
|
|
|
|
jz .got ; empty
|
|
|
|
add edx, 32
|
2016-02-25 18:10:35 +01:00
|
|
|
sub edx, ebx
|
2016-01-19 20:45:51 +01:00
|
|
|
cmp edx, [ebp+NTFS.fileDataSize]
|
|
|
|
jnc .got ; share between dwords
|
|
|
|
.again:
|
|
|
|
add edi, 4
|
|
|
|
jmp .small
|
|
|
|
|
|
|
|
.got:
|
2016-02-25 18:10:35 +01:00
|
|
|
push ebx ; starting bit
|
2016-01-19 20:45:51 +01:00
|
|
|
push edi ; starting dword
|
|
|
|
.done: ; mark space
|
|
|
|
mov ecx, [esp+4]
|
|
|
|
cmp ecx, 32
|
|
|
|
jc @f
|
|
|
|
xor ecx, ecx
|
|
|
|
add dword [esp], 4
|
|
|
|
mov [esp+4], ecx
|
|
|
|
@@:
|
|
|
|
mov edi, [esp]
|
|
|
|
xor eax, eax
|
|
|
|
dec eax
|
|
|
|
shr eax, cl
|
|
|
|
shl eax, cl
|
|
|
|
neg ecx
|
|
|
|
add ecx, 32
|
|
|
|
sub ecx, [ebp+NTFS.fileDataSize]
|
|
|
|
jc @f
|
|
|
|
shl eax, cl ; fits inside dword
|
|
|
|
shr eax, cl
|
|
|
|
or [edi], eax
|
|
|
|
jmp .end
|
|
|
|
|
|
|
|
@@:
|
|
|
|
or [edi], eax
|
|
|
|
neg ecx
|
|
|
|
push ecx
|
|
|
|
shr ecx, 5
|
|
|
|
add edi, 4
|
|
|
|
xor eax, eax
|
|
|
|
dec eax
|
|
|
|
rep stosd
|
|
|
|
pop ecx
|
|
|
|
and ecx, 31
|
|
|
|
shr eax, cl
|
|
|
|
shl eax, cl
|
|
|
|
not eax
|
|
|
|
or [edi], eax
|
|
|
|
.end:
|
|
|
|
pop eax
|
2016-02-25 18:10:35 +01:00
|
|
|
pop ecx
|
2016-01-19 20:45:51 +01:00
|
|
|
sub eax, [ebp+NTFS.BitmapBuffer]
|
|
|
|
shl eax, 3
|
2016-02-25 18:10:35 +01:00
|
|
|
add eax, ecx
|
|
|
|
pop ecx
|
|
|
|
mov ecx, [ebp+NTFS.fileDataSize]
|
|
|
|
mov [ebp+NTFS.fileDataStart], eax
|
|
|
|
add ecx, eax
|
|
|
|
add ecx, 4095
|
|
|
|
shr ecx, 3+9
|
|
|
|
shr eax, 3+9
|
|
|
|
sub ecx, eax
|
|
|
|
mov ebx, eax
|
|
|
|
shl ebx, 9
|
|
|
|
add eax, [ebp+NTFS.BitmapLocation]
|
|
|
|
add ebx, [ebp+NTFS.BitmapBuffer]
|
|
|
|
xor edx, edx
|
|
|
|
jmp fs_write64_app
|
2016-01-19 20:45:51 +01:00
|
|
|
|
|
|
|
ntfsSpaceFree:
|
|
|
|
; free disk space
|
|
|
|
; in:
|
|
|
|
; edi = starting cluster
|
|
|
|
; ebx = size in clusters
|
|
|
|
mov eax, edi
|
|
|
|
add eax, ebx
|
|
|
|
shr eax, 3
|
|
|
|
inc eax
|
|
|
|
cmp eax, [ebp+NTFS.BitmapSize]
|
|
|
|
jc @f
|
|
|
|
add eax, [ebp+NTFS.BitmapBuffer]
|
|
|
|
push edi
|
|
|
|
mov edi, eax
|
|
|
|
call bitmapBuffering
|
|
|
|
pop edi
|
|
|
|
@@:
|
|
|
|
push edi
|
|
|
|
mov ecx, edi
|
|
|
|
shr edi, 5
|
|
|
|
shl edi, 2
|
|
|
|
add edi, [ebp+NTFS.BitmapBuffer]
|
|
|
|
and ecx, 31
|
|
|
|
xor eax, eax
|
|
|
|
dec eax
|
|
|
|
shr eax, cl
|
|
|
|
shl eax, cl
|
|
|
|
neg ecx
|
|
|
|
add ecx, 32
|
|
|
|
sub ecx, ebx
|
|
|
|
jc @f
|
|
|
|
shl eax, cl ; fits inside dword
|
|
|
|
shr eax, cl
|
|
|
|
not eax
|
|
|
|
and [edi], eax
|
|
|
|
jmp .writeBitmap
|
|
|
|
|
|
|
|
@@:
|
|
|
|
not eax
|
|
|
|
and [edi], eax
|
|
|
|
neg ecx
|
|
|
|
push ecx
|
|
|
|
shr ecx, 5
|
|
|
|
add edi, 4
|
|
|
|
xor eax, eax
|
|
|
|
rep stosd
|
|
|
|
pop ecx
|
|
|
|
and ecx, 31
|
|
|
|
dec eax
|
|
|
|
shr eax, cl
|
|
|
|
shl eax, cl
|
|
|
|
and [edi], eax
|
|
|
|
.writeBitmap:
|
|
|
|
pop eax
|
|
|
|
mov edi, eax
|
|
|
|
lea ecx, [eax+ebx+4095]
|
|
|
|
shr eax, 3+9
|
|
|
|
shr ecx, 3+9
|
|
|
|
sub ecx, eax
|
|
|
|
mov ebx, eax
|
|
|
|
shl ebx, 9
|
|
|
|
add eax, [ebp+NTFS.BitmapLocation]
|
|
|
|
add ebx, [ebp+NTFS.BitmapBuffer]
|
|
|
|
xor edx, edx
|
|
|
|
jmp fs_write64_app
|
|
|
|
|
|
|
|
bitmapBuffering:
|
|
|
|
; Extend BitmapBuffer and read next 32kb of bitmap
|
|
|
|
; Warning: $Bitmap fragmentation is not foreseen
|
|
|
|
; in: edi -> position in bitmap buffer
|
|
|
|
; out: ecx = number of buffered dwords left
|
|
|
|
push ebx
|
|
|
|
mov eax, [ebp+NTFS.BitmapTotalSize]
|
|
|
|
cmp eax, [ebp+NTFS.BitmapSize]
|
|
|
|
jz .end
|
|
|
|
stdcall alloc_pages, 8
|
|
|
|
test eax, eax
|
|
|
|
jz .end
|
|
|
|
add eax, 3
|
|
|
|
mov ebx, [ebp+NTFS.BitmapBuffer]
|
|
|
|
add ebx, [ebp+NTFS.BitmapSize]
|
|
|
|
push ebx
|
|
|
|
mov ecx, 8
|
|
|
|
call commit_pages
|
|
|
|
mov eax, [ebp+NTFS.BitmapSize]
|
|
|
|
shr eax, 9
|
|
|
|
add eax, [ebp+NTFS.BitmapLocation]
|
|
|
|
pop ebx
|
|
|
|
mov ecx, 64
|
|
|
|
xor edx, edx
|
|
|
|
call fs_read64_app
|
|
|
|
test eax, eax
|
|
|
|
jnz .err
|
|
|
|
add [ebp+NTFS.BitmapSize], 8000h
|
|
|
|
mov eax, [ebp+NTFS.BitmapTotalSize]
|
|
|
|
cmp eax, [ebp+NTFS.BitmapSize]
|
|
|
|
jnc @f
|
|
|
|
mov [ebp+NTFS.BitmapSize], eax
|
|
|
|
@@:
|
|
|
|
pop ebx
|
|
|
|
mov ecx, [ebp+NTFS.BitmapBuffer]
|
|
|
|
add ecx, [ebp+NTFS.BitmapSize]
|
|
|
|
sub ecx, edi
|
|
|
|
jc bitmapBuffering
|
2015-12-10 11:45:32 +01:00
|
|
|
shr ecx, 2
|
|
|
|
ret
|
|
|
|
|
|
|
|
.err:
|
|
|
|
mov eax, [ebp+NTFS.BitmapBuffer]
|
|
|
|
add eax, [ebp+NTFS.BitmapSize]
|
|
|
|
mov ecx, 8
|
|
|
|
call release_pages
|
|
|
|
.end:
|
2016-02-25 18:10:35 +01:00
|
|
|
add esp, 12 ; ret
|
2016-01-19 20:45:51 +01:00
|
|
|
stc
|
|
|
|
ret
|
2011-10-14 23:38:50 +02:00
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
;----------------------------------------------------------------
|
2015-12-21 12:47:21 +01:00
|
|
|
ntfs_WriteFile:
|
|
|
|
cmp byte [esi], 0
|
|
|
|
jnz @f
|
2011-10-14 23:38:50 +02:00
|
|
|
xor ebx, ebx
|
2015-12-21 12:47:21 +01:00
|
|
|
movi eax, ERROR_ACCESS_DENIED
|
|
|
|
ret
|
|
|
|
@@:
|
|
|
|
call ntfs_lock
|
|
|
|
stdcall ntfs_find_lfn, [esp+4]
|
2015-12-31 18:29:37 +01:00
|
|
|
jc ntfsNotFound
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.cur_iRecord], 16
|
2015-12-31 18:29:37 +01:00
|
|
|
jc ntfsDenied
|
2016-05-08 00:26:48 +02:00
|
|
|
test dword [eax+fileFlags], 10000001h
|
|
|
|
jnz ntfsDenied
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.fragmentCount], 1
|
2016-01-19 20:45:51 +01:00
|
|
|
jnz ntfsUnsupported ; record fragmented
|
2016-02-06 18:50:04 +01:00
|
|
|
; edit directory node
|
2016-01-19 20:45:51 +01:00
|
|
|
mov edi, [ebp+NTFS.cur_index_buf]
|
|
|
|
cmp dword [edi], 'INDX'
|
|
|
|
jz @f
|
|
|
|
mov esi, [ebp+NTFS.frs_buffer]
|
|
|
|
mov ecx, [esi+recordRealSize]
|
|
|
|
shr ecx, 2
|
|
|
|
rep movsd
|
2016-02-21 03:13:21 +01:00
|
|
|
mov esi, [ebp+NTFS.attr_offs]
|
2016-01-19 20:45:51 +01:00
|
|
|
mov cl, [esi+attributeOffset]
|
|
|
|
sub esi, [ebp+NTFS.frs_buffer]
|
2016-02-06 18:50:04 +01:00
|
|
|
add eax, ecx
|
|
|
|
add eax, esi
|
2016-01-19 20:45:51 +01:00
|
|
|
@@:
|
2016-05-08 00:26:48 +02:00
|
|
|
mov edi, eax
|
|
|
|
mov eax, [ebx+4]
|
2016-02-06 18:50:04 +01:00
|
|
|
mov edx, [ebx+8]
|
2016-05-08 00:26:48 +02:00
|
|
|
add eax, [ebx+12]
|
2016-02-06 18:50:04 +01:00
|
|
|
adc edx, 0
|
2016-05-08 00:26:48 +02:00
|
|
|
mov [edi+fileRealSize], eax
|
|
|
|
mov [edi+fileRealSize+4], edx
|
|
|
|
push edx eax ebx
|
|
|
|
call ntfsGetTime
|
|
|
|
mov [edi+fileModified], eax
|
|
|
|
mov [edi+fileModified+4], edx
|
|
|
|
mov [edi+recordModified], eax
|
|
|
|
mov [edi+recordModified+4], edx
|
|
|
|
mov [edi+fileAccessed], eax
|
|
|
|
mov [edi+fileAccessed+4], edx
|
|
|
|
pop ebx ecx edx
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, [ebp+NTFS.LastRead]
|
2016-02-06 18:50:04 +01:00
|
|
|
mov [ebp+NTFS.nodeLastRead], eax
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_attr], 0x80
|
|
|
|
mov [ebp+NTFS.cur_offs], 0
|
|
|
|
mov [ebp+NTFS.cur_size], 0
|
2015-12-21 12:47:21 +01:00
|
|
|
call ntfs_read_attr
|
2016-01-19 20:45:51 +01:00
|
|
|
jc ntfsFail
|
2016-05-08 00:26:48 +02:00
|
|
|
mov esi, edi
|
|
|
|
mov edi, [ebp+NTFS.frs_buffer]
|
|
|
|
cmp word [edi+baseRecordReuse], 0
|
2015-12-31 18:29:37 +01:00
|
|
|
jnz ntfsUnsupported ; auxiliary record
|
2016-05-08 00:26:48 +02:00
|
|
|
mov al, [edi+attributeOffset]
|
|
|
|
add edi, eax
|
|
|
|
mov al, [edi+attributeOffset]
|
|
|
|
add edi, eax
|
|
|
|
mov eax, ecx
|
|
|
|
mov ecx, 6
|
|
|
|
add esi, fileModified
|
|
|
|
add edi, 8
|
|
|
|
rep movsd
|
2016-02-21 03:13:21 +01:00
|
|
|
mov ecx, [ebp+NTFS.attr_offs]
|
2016-02-06 18:50:04 +01:00
|
|
|
cmp word [ecx+attributeFlags], 0
|
|
|
|
jnz ntfsUnsupported
|
|
|
|
push ebx
|
|
|
|
cmp byte [ecx+nonResidentFlag], 0
|
|
|
|
jz .resizeAttribute
|
2015-12-21 12:47:21 +01:00
|
|
|
cmp edx, [ecx+attributeRealSize+4]
|
2016-01-19 20:45:51 +01:00
|
|
|
jc .writeNode
|
|
|
|
jnz .resizeAttribute
|
2015-12-21 12:47:21 +01:00
|
|
|
cmp [ecx+attributeRealSize], eax
|
2016-01-19 20:45:51 +01:00
|
|
|
jnc .writeNode
|
|
|
|
.resizeAttribute:
|
|
|
|
call resizeAttribute
|
2016-01-28 00:48:14 +01:00
|
|
|
jc ntfsErrorPop
|
2016-02-21 03:13:21 +01:00
|
|
|
mov ecx, [ebp+NTFS.attr_offs]
|
2016-02-06 18:50:04 +01:00
|
|
|
cmp byte [ecx+nonResidentFlag], 1
|
|
|
|
jz @f
|
|
|
|
mov ebx, [esp]
|
|
|
|
movzx edi, byte [ecx+attributeOffset]
|
|
|
|
add edi, ecx
|
|
|
|
add edi, [ebx+4]
|
|
|
|
mov ecx, [ebx+12]
|
|
|
|
mov esi, [ebx+16]
|
|
|
|
rep movsb
|
|
|
|
@@:
|
2016-01-19 20:45:51 +01:00
|
|
|
mov ebx, [ebp+NTFS.frs_buffer]
|
2016-04-27 10:48:17 +02:00
|
|
|
mov edx, [ebp+NTFS.mftLastRead]
|
|
|
|
call writeRecord ; file
|
2016-01-19 20:45:51 +01:00
|
|
|
call ntfs_restore_usa_frs
|
|
|
|
.writeNode:
|
2016-04-27 10:48:17 +02:00
|
|
|
mov ebx, [ebp+NTFS.cur_index_buf]
|
|
|
|
mov edx, [ebp+NTFS.nodeLastRead]
|
2016-01-19 20:45:51 +01:00
|
|
|
call writeRecord ; directory
|
|
|
|
pop ebx
|
2016-02-21 03:13:21 +01:00
|
|
|
mov ecx, [ebp+NTFS.attr_offs]
|
2016-02-06 18:50:04 +01:00
|
|
|
cmp byte [ecx+nonResidentFlag], 0
|
|
|
|
jz .done
|
|
|
|
mov ecx, [ebx+12]
|
|
|
|
test ecx, ecx
|
|
|
|
jz .done
|
2015-12-21 12:47:21 +01:00
|
|
|
mov eax, [ebx+4]
|
|
|
|
mov edx, [ebx+8]
|
|
|
|
mov esi, [ebx+16]
|
|
|
|
shrd eax, edx, 9
|
|
|
|
test dword[ebx+4], 1FFh
|
|
|
|
jz .aligned
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_offs], eax
|
|
|
|
mov [ebp+NTFS.cur_size], 1
|
|
|
|
lea edi, [ebp+NTFS.bitmap_buf]
|
|
|
|
mov [ebp+NTFS.cur_buf], edi
|
2015-12-21 12:47:21 +01:00
|
|
|
call ntfs_read_attr.continue
|
2015-12-31 18:29:37 +01:00
|
|
|
jc ntfsDevice
|
2015-12-21 12:47:21 +01:00
|
|
|
mov eax, [ebx+4]
|
|
|
|
and eax, 1FFh
|
|
|
|
add edi, eax
|
2016-02-21 03:13:21 +01:00
|
|
|
sub eax, [ebp+NTFS.cur_read]
|
2015-12-21 12:47:21 +01:00
|
|
|
neg eax
|
|
|
|
push ecx
|
|
|
|
cmp ecx, eax
|
|
|
|
jb @f
|
|
|
|
mov ecx, eax
|
|
|
|
@@:
|
|
|
|
sub [esp], ecx
|
|
|
|
rep movsb
|
|
|
|
push ebx
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, [ebp+NTFS.LastRead]
|
|
|
|
lea ebx, [ebp+NTFS.bitmap_buf]
|
2015-12-21 12:47:21 +01:00
|
|
|
mov ecx, 1
|
|
|
|
xor edx, edx
|
|
|
|
call fs_write64_app
|
|
|
|
pop ebx
|
|
|
|
pop ecx
|
|
|
|
test ecx, ecx
|
2016-02-06 18:50:04 +01:00
|
|
|
jz .done
|
2015-12-21 12:47:21 +01:00
|
|
|
mov eax, [ebx+4]
|
|
|
|
mov edx, [ebx+8]
|
|
|
|
shrd eax, edx, 9
|
|
|
|
inc eax
|
|
|
|
.aligned:
|
|
|
|
push ecx
|
|
|
|
shr ecx, 9
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_offs], eax
|
|
|
|
mov [ebp+NTFS.cur_size], ecx
|
|
|
|
mov [ebp+NTFS.cur_buf], esi
|
2015-12-21 12:47:21 +01:00
|
|
|
add eax, ecx
|
|
|
|
push eax
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.bWriteAttr], 1
|
2015-12-21 12:47:21 +01:00
|
|
|
call ntfs_read_attr.continue
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.bWriteAttr], 0
|
|
|
|
pop [ebp+NTFS.cur_offs]
|
2015-12-21 12:47:21 +01:00
|
|
|
pop ecx
|
2015-12-31 18:29:37 +01:00
|
|
|
jc ntfsDevice
|
2015-12-21 12:47:21 +01:00
|
|
|
and ecx, 1FFh
|
2016-02-06 18:50:04 +01:00
|
|
|
jz .done
|
2016-02-21 03:13:21 +01:00
|
|
|
add esi, [ebp+NTFS.cur_read]
|
|
|
|
mov [ebp+NTFS.cur_size], 1
|
|
|
|
lea edi, [ebp+NTFS.bitmap_buf]
|
|
|
|
mov [ebp+NTFS.cur_buf], edi
|
2015-12-21 12:47:21 +01:00
|
|
|
call ntfs_read_attr.continue
|
2015-12-31 18:29:37 +01:00
|
|
|
jc ntfsDevice
|
2015-12-21 12:47:21 +01:00
|
|
|
rep movsb
|
|
|
|
push ebx
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, [ebp+NTFS.LastRead]
|
|
|
|
lea ebx, [ebp+NTFS.bitmap_buf]
|
2015-12-21 12:47:21 +01:00
|
|
|
mov ecx, 1
|
|
|
|
xor edx, edx
|
|
|
|
call fs_write64_app
|
|
|
|
pop ebx
|
2016-02-06 18:50:04 +01:00
|
|
|
.done:
|
2015-12-21 12:47:21 +01:00
|
|
|
mov ebx, [ebx+12]
|
2015-12-31 18:29:37 +01:00
|
|
|
jmp ntfsDone
|
|
|
|
|
|
|
|
;----------------------------------------------------------------
|
|
|
|
ntfs_Delete:
|
|
|
|
cmp byte [esi], 0
|
|
|
|
jnz @f
|
2016-05-04 19:36:09 +02:00
|
|
|
xor ebx, ebx
|
2015-12-31 18:29:37 +01:00
|
|
|
movi eax, ERROR_ACCESS_DENIED
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
2016-04-14 18:29:04 +02:00
|
|
|
|
2015-12-31 18:29:37 +01:00
|
|
|
@@:
|
|
|
|
call ntfs_lock
|
|
|
|
stdcall ntfs_find_lfn, [esp+4]
|
|
|
|
jc ntfsNotFound
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.cur_iRecord], 16
|
2015-12-31 18:29:37 +01:00
|
|
|
jc ntfsDenied
|
2016-05-08 00:26:48 +02:00
|
|
|
test byte [eax+fileFlags], 1
|
|
|
|
jnz ntfsDenied
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.fragmentCount], 1
|
2015-12-31 18:29:37 +01:00
|
|
|
jnz ntfsUnsupported ; record fragmented
|
2016-05-04 19:36:09 +02:00
|
|
|
mov ebx, [eax+directoryRecordReference]
|
|
|
|
mov [ebp+NTFS.newRecord], ebx
|
|
|
|
mov bx, [eax+fileReferenceReuse]
|
|
|
|
mov [ebp+NTFS.indexPointer], esi
|
|
|
|
mov eax, [ebp+NTFS.cur_iRecord]
|
|
|
|
shr eax, 3
|
|
|
|
cmp eax, [ebp+NTFS.mftBitmapSize]
|
2015-12-31 18:29:37 +01:00
|
|
|
jnc ntfsUnsupported
|
2016-05-04 19:36:09 +02:00
|
|
|
; examine file record
|
|
|
|
mov [ebp+NTFS.cur_attr], 0x80 ; file?
|
|
|
|
mov [ebp+NTFS.cur_offs], 0
|
|
|
|
mov [ebp+NTFS.cur_size], 0
|
|
|
|
call ntfs_read_attr
|
|
|
|
jnc @f
|
|
|
|
xor eax, eax
|
|
|
|
push ebx eax eax eax eax
|
|
|
|
mov [esp+12], esp
|
2016-04-14 18:29:04 +02:00
|
|
|
push eax
|
2016-05-04 19:36:09 +02:00
|
|
|
mov ebx, esp
|
|
|
|
mov [ebp+NTFS.cur_attr], 0x90 ; folder?
|
|
|
|
call ntfs_ReadFolder.doit
|
|
|
|
mov edx, [esp+12]
|
|
|
|
add esp, 20
|
|
|
|
pop ebx
|
|
|
|
test eax, eax
|
|
|
|
jnz .ret
|
|
|
|
cmp edx, 2
|
|
|
|
jnz ntfsDenied ; folder is not empty
|
|
|
|
mov [ebp+NTFS.cur_attr], 0xA0
|
|
|
|
mov [ebp+NTFS.cur_offs], 0
|
|
|
|
mov [ebp+NTFS.cur_size], 0
|
2016-04-14 18:29:04 +02:00
|
|
|
call ntfs_read_attr.newAttribute
|
2016-05-04 19:36:09 +02:00
|
|
|
jc .deleteFileRecord
|
2016-04-14 18:29:04 +02:00
|
|
|
@@:
|
2016-05-04 19:36:09 +02:00
|
|
|
mov esi, [ebp+NTFS.frs_buffer]
|
|
|
|
cmp word [esi+baseRecordReuse], 0
|
|
|
|
jnz ntfsUnsupported ; auxiliary record
|
|
|
|
cmp word [esi+reuseCounter], bx
|
|
|
|
jnz .backToIndex ; broken index
|
2016-05-08 00:26:48 +02:00
|
|
|
test byte [esi+recordFlags], 1
|
2016-05-04 19:36:09 +02:00
|
|
|
jz .writeBitmapMFT ; record deleted
|
|
|
|
cmp byte [esi+hardLinkCounter], 3
|
|
|
|
jnc ntfsUnsupported
|
|
|
|
mov esi, [ebp+NTFS.attr_offs]
|
|
|
|
cmp byte [esi+nonResidentFlag], 0
|
|
|
|
jz .deleteFileRecord
|
|
|
|
movzx eax, byte [esi+dataRunsOffset]
|
2016-04-14 18:29:04 +02:00
|
|
|
add esi, eax
|
2016-05-04 19:36:09 +02:00
|
|
|
xor edi, edi
|
|
|
|
sub esp, 16
|
|
|
|
@@:
|
|
|
|
call ntfs_decode_mcb_entry
|
|
|
|
jnc @f
|
|
|
|
cmp dword[esp+8], 0
|
2016-04-14 18:29:04 +02:00
|
|
|
jz @b
|
2016-05-04 19:36:09 +02:00
|
|
|
add edi, [esp+8]
|
|
|
|
mov ebx, [esp]
|
|
|
|
call ntfsSpaceFree
|
|
|
|
jnc @b
|
|
|
|
@@:
|
|
|
|
add esp, 16
|
|
|
|
.deleteFileRecord:
|
|
|
|
mov ebx, [ebp+NTFS.frs_buffer]
|
|
|
|
mov byte [ebx+recordFlags], 0
|
|
|
|
mov edx, [ebp+NTFS.mftLastRead]
|
|
|
|
call writeRecord
|
|
|
|
.writeBitmapMFT:
|
|
|
|
mov eax, [ebp+NTFS.cur_iRecord]
|
|
|
|
mov ecx, eax
|
|
|
|
shr eax, 3
|
|
|
|
and ecx, 7
|
|
|
|
mov edi, [ebp+NTFS.mftBitmapBuffer]
|
|
|
|
btr [edi+eax], ecx
|
|
|
|
shr eax, 9
|
|
|
|
mov ebx, eax
|
|
|
|
shl ebx, 9
|
|
|
|
add eax, [ebp+NTFS.mftBitmapLocation]
|
|
|
|
add ebx, edi
|
|
|
|
mov ecx, 1
|
|
|
|
xor edx, edx
|
|
|
|
call fs_write64_sys
|
|
|
|
.backToIndex:
|
|
|
|
mov eax, [ebp+NTFS.newRecord]
|
|
|
|
mov [ebp+NTFS.cur_iRecord], eax
|
|
|
|
mov esi, [ebp+NTFS.indexPointer]
|
|
|
|
stdcall ntfs_find_lfn.doit2, 0
|
|
|
|
jc ntfsFail
|
|
|
|
mov ebx, [ebp+NTFS.secondIndexBuffer]
|
|
|
|
mov byte [ebx], 0
|
|
|
|
mov ebx, [ebp+NTFS.LastRead]
|
|
|
|
mov [ebp+NTFS.nodeLastRead], ebx
|
|
|
|
xor ebx, ebx
|
|
|
|
test byte [eax+indexFlags], 1
|
|
|
|
jz .deleteIndex ; no subnode
|
|
|
|
mov edi, eax
|
|
|
|
call .findSubindex
|
|
|
|
jc ntfsFail
|
2016-04-14 18:29:04 +02:00
|
|
|
movzx edx, word [edi+indexAllocatedSize]
|
2016-05-04 19:36:09 +02:00
|
|
|
test esi, esi
|
|
|
|
jz @f
|
2016-04-14 18:29:04 +02:00
|
|
|
sub edx, eax
|
|
|
|
sub edx, 8
|
2016-05-04 19:36:09 +02:00
|
|
|
@@:
|
2016-04-14 18:29:04 +02:00
|
|
|
mov eax, edi
|
2016-05-04 19:36:09 +02:00
|
|
|
mov ebx, esi
|
2016-04-14 18:29:04 +02:00
|
|
|
jmp @f
|
|
|
|
|
|
|
|
.deleteIndex:
|
2015-12-31 18:29:37 +01:00
|
|
|
movzx edx, word [eax+indexAllocatedSize]
|
2016-01-28 00:48:14 +01:00
|
|
|
mov ecx, [eax+fileRecordReference]
|
|
|
|
cmp [eax+edx+fileRecordReference], ecx
|
|
|
|
jnz @f
|
|
|
|
add dx, [eax+edx+indexAllocatedSize]
|
|
|
|
@@:
|
2015-12-31 18:29:37 +01:00
|
|
|
mov edi, [ebp+NTFS.cur_index_buf]
|
|
|
|
cmp dword [edi], 'INDX'
|
|
|
|
jz .indexRecord
|
2016-05-04 19:36:09 +02:00
|
|
|
sub eax, edi
|
2016-04-14 18:29:04 +02:00
|
|
|
mov edi, [ebp+NTFS.indexRoot]
|
2015-12-31 18:29:37 +01:00
|
|
|
sub [edi+sizeWithHeader], edx
|
|
|
|
sub [edi+sizeWithoutHeader], edx
|
2016-05-04 19:36:09 +02:00
|
|
|
movzx ecx, byte [edi+attributeOffset]
|
2015-12-31 18:29:37 +01:00
|
|
|
add edi, ecx
|
2016-05-04 19:36:09 +02:00
|
|
|
add eax, edi
|
2016-02-21 03:13:21 +01:00
|
|
|
sub [edi+rootNode+nodeRealSize], edx
|
|
|
|
sub [edi+rootNode+nodeAllocatedSize], edx
|
2016-05-04 19:36:09 +02:00
|
|
|
mov edi, [ebp+NTFS.frs_buffer]
|
|
|
|
sub [edi+recordRealSize], edx
|
|
|
|
mov ecx, [edi+recordRealSize]
|
|
|
|
cmp [edi+recordAllocatedSize], ecx
|
2015-12-31 18:29:37 +01:00
|
|
|
jmp @f
|
|
|
|
|
|
|
|
.indexRecord:
|
2016-04-14 18:29:04 +02:00
|
|
|
add edi, recordNode
|
|
|
|
sub [edi+nodeRealSize], edx
|
|
|
|
mov ecx, [edi+nodeRealSize]
|
|
|
|
cmp [edi+nodeAllocatedSize], ecx
|
2015-12-31 18:29:37 +01:00
|
|
|
@@:
|
2016-05-04 19:36:09 +02:00
|
|
|
jc ntfsUnsupported
|
|
|
|
add ecx, edi
|
2015-12-31 18:29:37 +01:00
|
|
|
sub ecx, eax
|
|
|
|
mov esi, eax
|
|
|
|
add esi, edx
|
|
|
|
mov edi, eax
|
2016-04-14 18:29:04 +02:00
|
|
|
test edx, edx
|
|
|
|
jns @f
|
|
|
|
neg edx
|
|
|
|
add edx, ecx
|
|
|
|
sub edx, 4
|
|
|
|
add esi, edx
|
|
|
|
add edi, edx
|
|
|
|
std
|
|
|
|
@@:
|
|
|
|
jz @f
|
|
|
|
shr ecx, 2
|
|
|
|
rep movsd
|
|
|
|
cld
|
|
|
|
@@:
|
|
|
|
test ebx, ebx
|
2016-05-04 19:36:09 +02:00
|
|
|
jz .done
|
2016-04-14 18:29:04 +02:00
|
|
|
; copy index from the subnode to replace deleted pointing index
|
|
|
|
movzx ecx, word [ebx+indexAllocatedSize]
|
|
|
|
mov edx, ecx
|
2016-05-04 19:36:09 +02:00
|
|
|
test byte [ebx+indexFlags], 1
|
|
|
|
jz @f
|
|
|
|
sub ecx, 8
|
|
|
|
movzx edi, word [ebx+edx+indexAllocatedSize]
|
|
|
|
add edi, edx
|
|
|
|
mov esi, [ebx+ecx]
|
|
|
|
mov [ebx+edi-8], esi
|
|
|
|
mov [ebx+indexAllocatedSize], cx
|
|
|
|
@@:
|
2016-04-14 18:29:04 +02:00
|
|
|
shr ecx, 2
|
|
|
|
mov esi, ebx
|
|
|
|
mov edi, eax
|
2015-12-31 18:29:37 +01:00
|
|
|
rep movsd
|
2016-04-14 18:29:04 +02:00
|
|
|
add word [eax+indexAllocatedSize], 8
|
|
|
|
mov byte [eax+indexFlags], 1
|
2016-05-04 19:36:09 +02:00
|
|
|
mov edi, [ebp+NTFS.secondIndexBuffer]
|
2016-04-14 18:29:04 +02:00
|
|
|
mov eax, ebx
|
|
|
|
xor ebx, ebx
|
|
|
|
jmp .indexRecord
|
|
|
|
|
2016-05-04 19:36:09 +02:00
|
|
|
.done:
|
2016-04-27 10:48:17 +02:00
|
|
|
mov ebx, [ebp+NTFS.frs_buffer]
|
2016-05-04 19:36:09 +02:00
|
|
|
mov edx, [ebp+NTFS.rootLastRead]
|
2015-12-31 18:29:37 +01:00
|
|
|
call writeRecord
|
2016-04-27 10:48:17 +02:00
|
|
|
mov ebx, [ebp+NTFS.cur_index_buf]
|
2016-05-04 19:36:09 +02:00
|
|
|
cmp dword [ebx], 'INDX'
|
|
|
|
jnz @f
|
2016-04-27 10:48:17 +02:00
|
|
|
mov edx, [ebp+NTFS.nodeLastRead]
|
2016-04-14 18:29:04 +02:00
|
|
|
call writeRecord
|
2016-05-04 19:36:09 +02:00
|
|
|
@@:
|
2016-04-27 10:48:17 +02:00
|
|
|
mov ebx, [ebp+NTFS.secondIndexBuffer]
|
|
|
|
cmp byte [ebx], 0
|
2016-04-14 18:29:04 +02:00
|
|
|
jz ntfsDone
|
2016-05-04 19:36:09 +02:00
|
|
|
mov edx, [ebp+NTFS.LastRead]
|
2015-12-31 18:29:37 +01:00
|
|
|
call writeRecord
|
2016-01-19 20:45:51 +01:00
|
|
|
jmp ntfsDone
|
2011-10-14 23:38:50 +02:00
|
|
|
|
2016-05-04 19:36:09 +02:00
|
|
|
.findSubindex:
|
|
|
|
; in: eax -> index
|
|
|
|
; out:
|
|
|
|
; CF=1 -> error
|
|
|
|
; esi=0 -> subnode deleted
|
|
|
|
; esi -> replacement index
|
|
|
|
; eax = index effective size
|
|
|
|
movzx edx, word [eax+indexAllocatedSize]
|
|
|
|
mov eax, [eax+edx-8]
|
|
|
|
mov edx, [ebp+NTFS.cur_size]
|
|
|
|
push edx
|
|
|
|
cmp edx, [ebp+NTFS.cur_subnode_size]
|
|
|
|
jz @f
|
|
|
|
mul [ebp+NTFS.sectors_per_cluster]
|
|
|
|
@@:
|
|
|
|
mov [ebp+NTFS.cur_attr], 0xA0
|
|
|
|
mov [ebp+NTFS.cur_offs], eax
|
|
|
|
push eax
|
|
|
|
mov ebx, [ebp+NTFS.secondIndexBuffer]
|
|
|
|
mov esi, ebx
|
|
|
|
mov [ebp+NTFS.cur_buf], ebx
|
|
|
|
call ntfs_read_attr.newAttribute
|
|
|
|
pop [ebp+NTFS.cur_offs]
|
|
|
|
pop eax
|
|
|
|
jc .ret
|
|
|
|
cmp dword [esi], 'INDX'
|
|
|
|
stc
|
|
|
|
jnz .ret
|
|
|
|
mov [ebp+NTFS.cur_size], eax
|
|
|
|
shl eax, 9
|
|
|
|
call ntfs_restore_usa
|
|
|
|
jc .ret
|
|
|
|
add esi, recordNode
|
|
|
|
add esi, [esi+indexOffset]
|
|
|
|
test byte [esi+indexFlags], 2
|
|
|
|
jnz .emptyNode
|
|
|
|
cmp [ebp+NTFS.fragmentCount], 1
|
|
|
|
stc
|
|
|
|
jnz .ret ; record fragmented
|
|
|
|
xor eax, eax
|
|
|
|
@@:
|
|
|
|
add esi, eax
|
|
|
|
mov ax, [esi+indexAllocatedSize]
|
|
|
|
test byte [esi+eax+indexFlags], 2
|
|
|
|
jz @b
|
|
|
|
test byte [esi+indexFlags], 1
|
|
|
|
jz .ret
|
|
|
|
add eax, esi
|
|
|
|
push esi
|
|
|
|
push [ebp+NTFS.cur_offs]
|
|
|
|
call .findSubindex
|
|
|
|
pop [ebp+NTFS.cur_offs]
|
|
|
|
pop edx
|
|
|
|
jc .ret
|
|
|
|
test esi, esi
|
|
|
|
jnz .ret
|
|
|
|
mov esi, edx
|
|
|
|
mov ebx, [ebp+NTFS.secondIndexBuffer]
|
|
|
|
mov [ebp+NTFS.cur_buf], ebx
|
|
|
|
push [ebp+NTFS.cur_size]
|
|
|
|
call ntfs_read_attr.continue
|
|
|
|
pop eax
|
|
|
|
jc .ret
|
|
|
|
shl eax, 9
|
|
|
|
call ntfs_restore_usa
|
|
|
|
jc .ret
|
|
|
|
movzx eax, word [esi+indexAllocatedSize]
|
|
|
|
sub eax, 8
|
|
|
|
.ret:
|
|
|
|
ret
|
|
|
|
|
|
|
|
.emptyNode:
|
|
|
|
test byte [esi+indexFlags], 1
|
|
|
|
jz @f
|
|
|
|
mov eax, esi
|
|
|
|
push [ebp+NTFS.cur_offs]
|
|
|
|
call .findSubindex
|
|
|
|
pop [ebp+NTFS.cur_offs]
|
|
|
|
jc .ret
|
|
|
|
test esi, esi
|
|
|
|
jnz .ret
|
|
|
|
@@: ; delete node
|
|
|
|
mov esi, [ebp+NTFS.attr_offs]
|
|
|
|
add esi, [esi+sizeWithHeader]
|
|
|
|
cmp byte [esi], 0xB0
|
|
|
|
stc
|
|
|
|
jnz .ret
|
|
|
|
movzx eax, byte [esi+attributeOffset]
|
|
|
|
add esi, eax
|
|
|
|
mov eax, [ebp+NTFS.cur_offs]
|
|
|
|
xor edx, edx
|
|
|
|
div [ebp+NTFS.cur_size]
|
|
|
|
mov edx, eax
|
|
|
|
shr eax, 3
|
|
|
|
and edx, 7
|
|
|
|
btr [esi+eax], edx
|
|
|
|
mov esi, [ebp+NTFS.secondIndexBuffer]
|
|
|
|
mov byte [esi], 0
|
|
|
|
xor esi, esi
|
|
|
|
ret
|
|
|
|
|
2015-12-10 11:45:32 +01:00
|
|
|
;----------------------------------------------------------------
|
2013-07-01 18:29:16 +02:00
|
|
|
ntfs_SetFileEnd:
|
2016-01-28 00:48:14 +01:00
|
|
|
cmp byte [esi], 0
|
|
|
|
jnz @f
|
|
|
|
xor ebx, ebx
|
|
|
|
movi eax, ERROR_ACCESS_DENIED
|
|
|
|
ret
|
|
|
|
@@:
|
|
|
|
call ntfs_lock
|
|
|
|
stdcall ntfs_find_lfn, [esp+4]
|
|
|
|
jc ntfsNotFound
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.cur_iRecord], 16
|
2016-01-28 00:48:14 +01:00
|
|
|
jc ntfsDenied
|
2016-05-08 00:26:48 +02:00
|
|
|
test dword [eax+fileFlags], 10000001h
|
|
|
|
jnz ntfsDenied
|
2016-02-21 03:13:21 +01:00
|
|
|
cmp [ebp+NTFS.fragmentCount], 1
|
2016-01-28 00:48:14 +01:00
|
|
|
jnz ntfsUnsupported ; record fragmented
|
2016-02-06 18:50:04 +01:00
|
|
|
; edit directory node
|
2016-01-28 00:48:14 +01:00
|
|
|
mov edi, [ebp+NTFS.cur_index_buf]
|
|
|
|
cmp dword [edi], 'INDX'
|
|
|
|
jz @f
|
|
|
|
mov esi, [ebp+NTFS.frs_buffer]
|
|
|
|
mov ecx, [esi+recordRealSize]
|
|
|
|
shr ecx, 2
|
|
|
|
rep movsd
|
2016-02-21 03:13:21 +01:00
|
|
|
mov esi, [ebp+NTFS.attr_offs]
|
2016-01-28 00:48:14 +01:00
|
|
|
mov cl, [esi+attributeOffset]
|
|
|
|
sub esi, [ebp+NTFS.frs_buffer]
|
|
|
|
add eax, ecx
|
|
|
|
add eax, esi
|
|
|
|
@@:
|
2016-05-08 00:26:48 +02:00
|
|
|
mov edi, eax
|
|
|
|
mov eax, [ebx+4]
|
2016-01-28 00:48:14 +01:00
|
|
|
mov edx, [ebx+8]
|
2016-05-08 00:26:48 +02:00
|
|
|
mov [edi+fileRealSize], eax
|
|
|
|
mov [edi+fileRealSize+4], edx
|
|
|
|
push edx eax ebx
|
|
|
|
call ntfsGetTime
|
|
|
|
mov [edi+fileModified], eax
|
|
|
|
mov [edi+fileModified+4], edx
|
|
|
|
mov [edi+recordModified], eax
|
|
|
|
mov [edi+recordModified+4], edx
|
|
|
|
mov [edi+fileAccessed], eax
|
|
|
|
mov [edi+fileAccessed+4], edx
|
|
|
|
pop ebx ecx edx
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, [ebp+NTFS.LastRead]
|
2016-01-28 00:48:14 +01:00
|
|
|
mov [ebp+NTFS.nodeLastRead], eax
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_attr], 0x80
|
|
|
|
mov [ebp+NTFS.cur_offs], 0
|
|
|
|
mov [ebp+NTFS.cur_size], 0
|
2016-01-28 00:48:14 +01:00
|
|
|
call ntfs_read_attr
|
|
|
|
jc ntfsFail
|
2016-05-08 00:26:48 +02:00
|
|
|
mov esi, edi
|
|
|
|
mov edi, [ebp+NTFS.frs_buffer]
|
|
|
|
cmp word [edi+baseRecordReuse], 0
|
2016-01-28 00:48:14 +01:00
|
|
|
jnz ntfsUnsupported ; auxiliary record
|
2016-05-08 00:26:48 +02:00
|
|
|
mov al, [edi+attributeOffset]
|
|
|
|
add edi, eax
|
|
|
|
mov al, [edi+attributeOffset]
|
|
|
|
add edi, eax
|
|
|
|
mov eax, ecx
|
|
|
|
mov ecx, 6
|
|
|
|
add esi, fileModified
|
|
|
|
add edi, 8
|
|
|
|
rep movsd
|
2016-02-21 03:13:21 +01:00
|
|
|
mov ecx, [ebp+NTFS.attr_offs]
|
2016-02-06 18:50:04 +01:00
|
|
|
cmp word [ecx+attributeFlags], 0
|
|
|
|
jnz ntfsUnsupported
|
|
|
|
cmp byte [ecx+nonResidentFlag], 0
|
|
|
|
jz .resizeAttribute
|
2016-01-28 00:48:14 +01:00
|
|
|
cmp [ecx+attributeRealSize+4], edx
|
|
|
|
jnz .resizeAttribute
|
|
|
|
cmp [ecx+attributeRealSize], eax
|
|
|
|
jnc .resizeAttribute
|
|
|
|
mov eax, [ecx+attributeRealSize]
|
|
|
|
mov ecx, [ebp+NTFS.sectors_per_cluster]
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_size], ecx
|
2016-01-28 00:48:14 +01:00
|
|
|
shl ecx, 9
|
|
|
|
div ecx
|
|
|
|
test edx, edx
|
|
|
|
jz .aligned
|
|
|
|
push edx
|
|
|
|
push ecx
|
|
|
|
mul [ebp+NTFS.sectors_per_cluster]
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_offs], eax
|
2016-01-28 00:48:14 +01:00
|
|
|
stdcall kernel_alloc, ecx
|
|
|
|
pop ecx
|
|
|
|
pop edi
|
2016-04-21 19:41:56 +02:00
|
|
|
mov esi, eax
|
2016-01-28 00:48:14 +01:00
|
|
|
sub ecx, edi
|
|
|
|
add edi, eax
|
2016-02-21 03:13:21 +01:00
|
|
|
mov [ebp+NTFS.cur_buf], eax
|
2016-01-28 00:48:14 +01:00
|
|
|
call ntfs_read_attr.continue
|
|
|
|
jc @f
|
|
|
|
xor eax, eax
|
|
|
|
rep stosb
|
|
|
|
push ebx
|
2016-02-21 03:13:21 +01:00
|
|
|
mov eax, [ebp+NTFS.LastRead]
|
2016-04-21 19:41:56 +02:00
|
|
|
mov ebx, esi
|
2016-01-28 00:48:14 +01:00
|
|
|
mov ecx, [ebp+NTFS.sectors_per_cluster]
|
|
|
|
xor edx, edx
|
|
|
|
call fs_write64_app
|
|
|
|
pop ebx
|
|
|
|
@@:
|
2016-04-21 19:41:56 +02:00
|
|
|
stdcall kernel_free, esi
|
2016-01-28 00:48:14 +01:00
|
|
|
.aligned:
|
|
|
|
mov eax, [ebx+4]
|
|
|
|
mov edx, [ebx+8]
|
|
|
|
.resizeAttribute:
|
|
|
|
call resizeAttribute
|
|
|
|
jc ntfsError
|
2016-04-27 10:48:17 +02:00
|
|
|
mov ebx, [ebp+NTFS.frs_buffer]
|
|
|
|
mov edx, [ebp+NTFS.mftLastRead]
|
2016-01-28 00:48:14 +01:00
|
|
|
call writeRecord ; file
|
2016-04-27 10:48:17 +02:00
|
|
|
mov ebx, [ebp+NTFS.cur_index_buf]
|
|
|
|
mov edx, [ebp+NTFS.nodeLastRead]
|
2016-01-28 00:48:14 +01:00
|
|
|
call writeRecord ; directory
|
|
|
|
call ntfsSpaceClean
|
|
|
|
jmp ntfsDone
|
|
|
|
|
2016-05-08 00:26:48 +02:00
|
|
|
ntfsReadCMOS:
|
|
|
|
out 70h, al
|
|
|
|
in al, 71h
|
|
|
|
xor ah, ah
|
|
|
|
shl ax, 4
|
|
|
|
shr al, 4
|
|
|
|
aad
|
|
|
|
ret
|
|
|
|
|
|
|
|
ntfsGetTime:
|
|
|
|
mov al, 7
|
|
|
|
call ntfsReadCMOS
|
|
|
|
ror eax, 8
|
|
|
|
mov al, 8
|
|
|
|
call ntfsReadCMOS
|
|
|
|
ror eax, 8
|
|
|
|
mov al, 9
|
|
|
|
call ntfsReadCMOS
|
|
|
|
add eax, 2000
|
|
|
|
ror eax, 16
|
|
|
|
push eax
|
|
|
|
xor eax, eax
|
|
|
|
call ntfsReadCMOS
|
|
|
|
ror eax, 8
|
|
|
|
mov al, 2
|
|
|
|
call ntfsReadCMOS
|
|
|
|
ror eax, 8
|
|
|
|
mov al, 4
|
|
|
|
call ntfsReadCMOS
|
|
|
|
ror eax, 16
|
|
|
|
push eax
|
|
|
|
mov esi, esp
|
|
|
|
add esp, 8
|
|
|
|
ntfsCalculateTime:
|
|
|
|
; in: esi -> data block
|
|
|
|
; out: edx:eax = time
|
|
|
|
movzx eax, word [esi+6]
|
|
|
|
sub eax, 2001
|
|
|
|
jnc @f
|
|
|
|
xor eax, eax
|
|
|
|
@@:
|
|
|
|
mov edx, months
|
|
|
|
mov ebx, eax
|
|
|
|
inc eax
|
|
|
|
test eax, 3
|
|
|
|
jnz @f
|
|
|
|
add edx, 12
|
|
|
|
@@:
|
|
|
|
movzx eax, byte [esi+5]
|
|
|
|
dec eax
|
|
|
|
xor ecx, ecx
|
|
|
|
@@:
|
|
|
|
dec eax
|
|
|
|
js @f
|
|
|
|
add cl, [edx+eax]
|
|
|
|
adc ch, 0
|
|
|
|
jmp @b
|
|
|
|
@@:
|
|
|
|
mov eax, ebx
|
|
|
|
mov edx, 365
|
|
|
|
mul edx
|
|
|
|
shr ebx, 2
|
|
|
|
add eax, ebx
|
|
|
|
add eax, ecx
|
|
|
|
mov bl, [esi+4]
|
|
|
|
add eax, ebx
|
|
|
|
add eax, 400*365+100-4
|
|
|
|
mov dl, 24
|
|
|
|
mul edx
|
|
|
|
mov bl, [esi+2]
|
|
|
|
add eax, ebx
|
|
|
|
mov ecx, 60
|
|
|
|
mul ecx
|
|
|
|
mov bl, [esi+1]
|
|
|
|
add eax, ebx
|
|
|
|
mul ecx
|
|
|
|
mov bl, [esi]
|
|
|
|
add ebx, eax
|
|
|
|
mov eax, edx
|
|
|
|
mov ecx, 10000000
|
|
|
|
mul ecx
|
|
|
|
xchg eax, ebx
|
|
|
|
mul ecx
|
|
|
|
add edx, ebx
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
;----------------------------------------------------------------
|
2016-05-08 00:26:48 +02:00
|
|
|
ntfs_SetFileInfo:
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp byte [esi], 0
|
|
|
|
jnz @f
|
2015-12-21 12:47:21 +01:00
|
|
|
movi eax, ERROR_UNSUPPORTED_FS
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
|
|
|
@@:
|
2013-07-01 18:29:16 +02:00
|
|
|
call ntfs_lock
|
|
|
|
stdcall ntfs_find_lfn, [esp+4]
|
2016-05-08 00:26:48 +02:00
|
|
|
jnc @f
|
2015-12-21 12:47:21 +01:00
|
|
|
test eax, eax
|
2015-12-31 18:29:37 +01:00
|
|
|
jz ntfsFail
|
|
|
|
jmp ntfsNotFound
|
2016-05-08 00:26:48 +02:00
|
|
|
|
|
|
|
@@:
|
|
|
|
cmp [ebp+NTFS.fragmentCount], 1
|
|
|
|
jnz ntfsUnsupported ; record fragmented
|
|
|
|
mov esi, [ebp+NTFS.cur_index_buf]
|
|
|
|
cmp dword [esi], 'INDX'
|
|
|
|
jz @f
|
|
|
|
sub eax, esi
|
|
|
|
mov esi, [ebp+NTFS.indexRoot]
|
|
|
|
movzx edx, byte [esi+attributeOffset]
|
|
|
|
add eax, esi
|
|
|
|
add eax, edx
|
|
|
|
@@:
|
|
|
|
mov esi, [ebx+16]
|
|
|
|
mov edi, eax
|
|
|
|
mov eax, [esi]
|
|
|
|
and eax, 27h
|
|
|
|
and byte [edi+fileFlags], -28h
|
|
|
|
or [edi+fileFlags], al
|
|
|
|
add esi, 8
|
|
|
|
call ntfsCalculateTime
|
|
|
|
mov [edi+fileCreated], eax
|
|
|
|
mov [edi+fileCreated+4], edx
|
|
|
|
add esi, 8
|
|
|
|
call ntfsCalculateTime
|
|
|
|
mov [edi+fileAccessed], eax
|
|
|
|
mov [edi+fileAccessed+4], edx
|
|
|
|
add esi, 8
|
|
|
|
call ntfsCalculateTime
|
|
|
|
mov [edi+fileModified], eax
|
|
|
|
mov [edi+fileModified+4], edx
|
|
|
|
mov ebx, [ebp+NTFS.cur_index_buf]
|
|
|
|
cmp dword [ebx], 'INDX'
|
|
|
|
jz @f
|
|
|
|
mov ebx, [ebp+NTFS.frs_buffer]
|
|
|
|
@@:
|
|
|
|
mov edx, [ebp+NTFS.LastRead]
|
|
|
|
call writeRecord
|
|
|
|
jmp ntfsDone
|
2010-02-09 15:17:26 +01:00
|
|
|
|
2015-12-31 18:29:37 +01:00
|
|
|
ntfsUnsupported:
|
|
|
|
push ERROR_UNSUPPORTED_FS
|
2016-01-19 20:45:51 +01:00
|
|
|
jmp ntfsOut
|
2015-12-31 18:29:37 +01:00
|
|
|
ntfsDevice:
|
|
|
|
push ERROR_DEVICE
|
|
|
|
jmp ntfsOut
|
|
|
|
ntfsNotFound:
|
|
|
|
push ERROR_FILE_NOT_FOUND
|
|
|
|
jmp ntfsOut
|
|
|
|
ntfsDenied:
|
|
|
|
push ERROR_ACCESS_DENIED
|
|
|
|
jmp ntfsOut
|
|
|
|
ntfsFail:
|
|
|
|
push ERROR_FS_FAIL
|
|
|
|
jmp ntfsOut
|
2016-01-19 20:45:51 +01:00
|
|
|
ntfsDiskFull:
|
|
|
|
push ERROR_DISK_FULL
|
|
|
|
jmp ntfsOut
|
2016-05-02 08:02:41 +02:00
|
|
|
ntfsErrorPop5:
|
|
|
|
pop ebx
|
|
|
|
pop ebx
|
2016-03-15 07:18:38 +01:00
|
|
|
ntfsErrorPop3:
|
|
|
|
pop ebx
|
2016-01-28 00:48:14 +01:00
|
|
|
ntfsErrorPop2:
|
|
|
|
pop ebx
|
|
|
|
ntfsErrorPop:
|
2016-01-19 20:45:51 +01:00
|
|
|
pop ebx
|
2016-01-28 00:48:14 +01:00
|
|
|
ntfsError:
|
2016-01-19 20:45:51 +01:00
|
|
|
push eax
|
|
|
|
ntfsOut:
|
|
|
|
call ntfs_unlock
|
|
|
|
xor ebx, ebx
|
|
|
|
pop eax
|
|
|
|
ret
|