Subversion Repositories Kolibri OS

Rev

Rev 6407 | Rev 6409 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6407 Rev 6408
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 7... Line 7...
7
 
7
 
Line 8... Line 8...
8
$Revision: 6407 $
8
$Revision: 6408 $
Line 9... Line 9...
9
 
9
 
10
; NTFS driver
10
; NTFS driver
Line 128... Line 128...
128
cur_buf             dd  ?
128
cur_buf             dd  ?
129
cur_read            dd  ?   ; bytes readen
129
cur_read            dd  ?   ; bytes readen
130
cur_tail            dd  ?
130
cur_tail            dd  ?
131
cur_subnode_size    dd  ?
131
cur_subnode_size    dd  ?
132
LastRead            dd  ?   ; last readen block of sectors
132
LastRead            dd  ?   ; last readen block of sectors
-
 
133
mftLastRead         dd  ?
133
rootLastRead        dd  ?
134
rootLastRead        dd  ?
134
nodeLastRead        dd  ?
135
nodeLastRead        dd  ?
135
indexRoot           dd  ?
136
indexRoot           dd  ?
136
indexPointer        dd  ?
137
indexPointer        dd  ?
137
newRecord           dd  ?
138
newRecord           dd  ?
Line 1056... Line 1057...
1056
        pop     [ebp+NTFS.attr_iBaseRecord]
1057
        pop     [ebp+NTFS.attr_iBaseRecord]
1057
        pop     [ebp+NTFS.attr_iRecord]
1058
        pop     [ebp+NTFS.attr_iRecord]
1058
        jc      .ret
1059
        jc      .ret
1059
        cmp     edx, [ebp+NTFS.frs_size]
1060
        cmp     edx, [ebp+NTFS.frs_size]
1060
        jnz     .errret
1061
        jnz     .errret
-
 
1062
        mov     eax, [ebp+NTFS.LastRead]
-
 
1063
        mov     [ebp+NTFS.mftLastRead], eax
1061
        mov     eax, [ebp+NTFS.frs_buffer]
1064
        mov     eax, [ebp+NTFS.frs_buffer]
1062
        cmp     dword [eax], 'FILE'
1065
        cmp     dword [eax], 'FILE'
1063
        jnz     .errret
1066
        jnz     .errret
1064
        push    ebx
1067
        push    ebx
1065
        mov     ebx, eax
1068
        mov     ebx, eax
Line 1205... Line 1208...
1205
        mov     eax, [esi+nodeRealSize]
1208
        mov     eax, [esi+nodeRealSize]
1206
        add     eax, rootNode
1209
        add     eax, rootNode
1207
        cmp     [ebp+NTFS.cur_read], eax
1210
        cmp     [ebp+NTFS.cur_read], eax
1208
        jc      .err
1211
        jc      .err
1209
        mov     edi, [esp+4]
1212
        mov     edi, [esp+4]
1210
        mov     eax, [ebp+NTFS.LastRead]
1213
        mov     eax, [ebp+NTFS.mftLastRead]
1211
        mov     [ebp+NTFS.rootLastRead], eax
1214
        mov     [ebp+NTFS.rootLastRead], eax
1212
        mov     eax, [ebp+NTFS.attr_offs]
1215
        mov     eax, [ebp+NTFS.attr_offs]
1213
        mov     [ebp+NTFS.indexRoot], eax
1216
        mov     [ebp+NTFS.indexRoot], eax
1214
; edi -> name, esi -> current index node
1217
; edi -> name, esi -> current index node
1215
.scanloop:
1218
.scanloop:
Line 1497... Line 1500...
1497
        mov     [ebp+NTFS.cur_buf], eax
1500
        mov     [ebp+NTFS.cur_buf], eax
1498
        call    ntfs_read_attr.newAttribute
1501
        call    ntfs_read_attr.newAttribute
1499
        jc      ntfsFail
1502
        jc      ntfsFail
1500
        cmp     [ebp+NTFS.cur_read], 0x20
1503
        cmp     [ebp+NTFS.cur_read], 0x20
1501
        jc      ntfsFail
1504
        jc      ntfsFail
1502
        pushad
-
 
1503
        mov     esi, [ebp+NTFS.cur_index_buf]
1505
        mov     esi, [ebp+NTFS.cur_index_buf]
1504
        mov     eax, [esi+indexRecordSize]
1506
        mov     eax, [esi+indexRecordSize]
1505
        shr     eax, 9
1507
        shr     eax, 9
1506
        cmp     [ebp+NTFS.cur_index_size], eax
1508
        cmp     [ebp+NTFS.cur_index_size], eax
1507
        jc      .realloc
1509
        jc      .realloc
1508
        mov     [ebp+NTFS.cur_subnode_size], eax
1510
        mov     [ebp+NTFS.cur_subnode_size], eax
1509
        add     esi, rootNode
1511
        add     esi, rootNode
1510
        mov     eax, [esi+nodeRealSize]
1512
        mov     eax, [esi+nodeRealSize]
1511
        add     eax, rootNode
1513
        add     eax, rootNode
1512
        cmp     [ebp+NTFS.cur_read], eax
1514
        cmp     [ebp+NTFS.cur_read], eax
1513
        jc      .err
1515
        jc      ntfsFail
1514
        mov     edx, [ebx+16]
1516
        mov     edi, [ebx+16]
1515
        push    dword [ebx+8]   ; read ANSI/UNICODE name
-
 
1516
; init header
-
 
1517
        mov     edi, edx
-
 
1518
        mov     ecx, 32/4
-
 
1519
        xor     eax, eax
-
 
1520
        rep stosd
-
 
1521
        mov     byte [edx], 1   ; version
-
 
1522
        mov     ecx, [ebx+12]
1517
        mov     ecx, [ebx+12]
1523
        mov     ebx, [ebx+4]
1518
        pushd   [ebx]
-
 
1519
        pushd   [ebx+8]     ; read ANSI/UNICODE name
1524
        push    edx
1520
        push    edi
1525
        mov     edx, esp
1521
        mov     edx, esp
-
 
1522
        mov     ebx, [ebx+4]
-
 
1523
; init header
-
 
1524
        xor     eax, eax
-
 
1525
        mov     [edi+8], eax
-
 
1526
        mov     [edi+4], eax
-
 
1527
        inc     eax
-
 
1528
        mov     [edi], eax      ; version
-
 
1529
        add     edi, 32
1526
; edi -> BDFE, esi -> current index data, ebx = first wanted block,
1530
; edi -> BDFE, esi -> current index data, ebx = first wanted block,
1527
; ecx = number of blocks to read
1531
; ecx = number of blocks to read
1528
; edx -> parameters block: dd , dd 
1532
; edx -> parameters block: dd , dd 
1529
        cmp     [ebp+NTFS.cur_iRecord], 5
1533
        cmp     [ebp+NTFS.cur_iRecord], 5
1530
        jz      .skip_specials
1534
        jz      .skip_specials
Line 1550... Line 1554...
1550
        mov     edi, eax
1554
        mov     edi, eax
1551
        mov     eax, [esi+indexRecordSize]
1555
        mov     eax, [esi+indexRecordSize]
1552
        shl     eax, 1
1556
        shl     eax, 1
1553
        stdcall kernel_alloc, eax
1557
        stdcall kernel_alloc, eax
1554
        test    eax, eax
1558
        test    eax, eax
1555
        jz      .err
1559
        jz      ntfsFail
1556
        mov     edx, [ebp+NTFS.cur_index_buf]
1560
        mov     edx, [ebp+NTFS.cur_index_buf]
1557
        cmp     edx, [ebp+NTFS.secondIndexBuffer]
1561
        cmp     edx, [ebp+NTFS.secondIndexBuffer]
1558
        jc      @f
1562
        jc      @f
1559
        mov     edx, [ebp+NTFS.secondIndexBuffer]
1563
        mov     edx, [ebp+NTFS.secondIndexBuffer]
1560
@@:
1564
@@:
1561
        mov     [ebp+NTFS.cur_index_buf], eax
1565
        mov     [ebp+NTFS.cur_index_buf], eax
1562
        add     eax, [esi+indexRecordSize]
1566
        add     eax, [esi+indexRecordSize]
1563
        mov     [ebp+NTFS.secondIndexBuffer], eax
1567
        mov     [ebp+NTFS.secondIndexBuffer], eax
1564
        mov     [ebp+NTFS.cur_index_size], edi
1568
        mov     [ebp+NTFS.cur_index_size], edi
1565
        stdcall kernel_free, edx
1569
        stdcall kernel_free, edx
1566
        popad
-
 
1567
        jmp     .doit
1570
        jmp     .doit
Line 1568... Line -...
1568
 
-
 
1569
.err:
-
 
1570
        popad
-
 
1571
        jmp     ntfsFail
-
 
1572
 
1571
 
1573
.dump_root_done:
1572
.dump_root_done:
1574
; now dump all subnodes
1573
; now dump all subnodes
1575
        push    ecx edi
1574
        push    ecx edi
1576
        lea     edi, [ebp+NTFS.bitmap_buf]
1575
        lea     edi, [ebp+NTFS.bitmap_buf]
Line 1648... Line 1647...
1648
        push    eax
1647
        push    eax
1649
        jmp     .dumploop
1648
        jmp     .dumploop
Line 1650... Line 1649...
1650
 
1649
 
1651
.done:
1650
.done:
1652
        pop     eax
1651
        pop     eax
1653
        pop     edx
1652
        pop     eax
-
 
1653
        mov     ebx, [eax+4]
1654
        mov     ebx, [edx+4]
1654
        pop     eax
-
 
1655
        pop     eax
-
 
1656
        test    eax, eax
1655
        pop     edx
1657
        jz      .ret
1656
        xor     eax, eax
1658
        xor     eax, eax
1657
        dec     ecx
1659
        dec     ecx
1658
        js      @f
1660
        js      @f
1659
        mov     al, ERROR_END_OF_FILE
1661
        mov     al, ERROR_END_OF_FILE
1660
@@:
1662
@@:
1661
        mov     [esp+1Ch], eax
-
 
1662
        mov     [esp+10h], ebx
1663
        push    eax
1663
        call    ntfs_unlock
1664
        call    ntfs_unlock
1664
        popad
1665
        pop     eax
Line 1665... Line 1666...
1665
        ret
1666
        ret
1666
 
1667
 
1667
.add_special_entry:
1668
.add_special_entry:
Line 2131... Line 2132...
2131
        add     edi, 30h
2132
        add     edi, 30h
2132
        sub     edi, esi
2133
        sub     edi, esi
2133
        mov     [esi+recordRealSize], edi
2134
        mov     [esi+recordRealSize], edi
2134
        mov     eax, [ebp+NTFS.fileDataStart]
2135
        mov     eax, [ebp+NTFS.fileDataStart]
2135
        mul     [ebp+NTFS.sectors_per_cluster]
2136
        mul     [ebp+NTFS.sectors_per_cluster]
2136
        mov     [ebp+NTFS.LastRead], eax
2137
        mov     edx, eax
2137
        jmp     @f
2138
        jmp     @f
Line 2138... Line 2139...
2138
 
2139
 
2139
.refresh:
2140
.refresh:
2140
        mov     [ebp+NTFS.cur_size], 0
-
 
2141
        mov     dword [ebp+NTFS.attr_size+4], -1
2141
        mov     [ebp+NTFS.cur_size], 0
2142
        call    ntfs_read_attr.continue
2142
        call    ntfs_read_attr.continue
2143
        movi    eax, ERROR_FS_FAIL
2143
        movi    eax, ERROR_FS_FAIL
-
 
2144
        jc      ntfsErrorPop3
2144
        jc      ntfsErrorPop3
2145
        mov     edx, [ebp+NTFS.LastRead]
2145
@@:
2146
@@:
2146
        mov     eax, [ebp+NTFS.cur_index_buf]
-
 
2147
        mov     [ebp+NTFS.cur_buf], eax
2147
        mov     ebx, [ebp+NTFS.cur_index_buf]
2148
        call    writeRecord
-
 
2149
        mov     eax, [ebp+NTFS.rootLastRead]
-
 
2150
        mov     [ebp+NTFS.LastRead], eax
2148
        call    writeRecord
2151
        mov     eax, [ebp+NTFS.frs_buffer]
2149
        mov     ebx, [ebp+NTFS.frs_buffer]
2152
        mov     [ebp+NTFS.cur_buf], eax
2150
        mov     edx, [ebp+NTFS.rootLastRead]
2153
        call    writeRecord
2151
        call    writeRecord
2154
        mov     esi, [esp+4]
2152
        mov     esi, [esp+4]
2155
        stdcall ntfs_find_lfn.doit2, 0
2153
        stdcall ntfs_find_lfn.doit2, 0
2156
        test    eax, eax
2154
        test    eax, eax
Line 2302... Line 2300...
2302
        mov     eax, [ebp+NTFS.newRecord]
2300
        mov     eax, [ebp+NTFS.newRecord]
2303
        mov     [esi+recordVCN], eax
2301
        mov     [esi+recordVCN], eax
2304
        add     esi, recordNode
2302
        add     esi, recordNode
2305
        sub     edi, esi
2303
        sub     edi, esi
2306
        mov     [esi+nodeRealSize], edi
2304
        mov     [esi+nodeRealSize], edi
2307
        mov     eax, [ebp+NTFS.secondIndexBuffer]
2305
        mov     ebx, [ebp+NTFS.secondIndexBuffer]
2308
        mov     [ebp+NTFS.cur_buf], eax
2306
        mov     edx, [ebp+NTFS.LastRead]
2309
        call    writeRecord
2307
        call    writeRecord
2310
        jmp     .refresh
2308
        jmp     .refresh
Line 2311... Line 2309...
2311
 
2309
 
2312
.common:
2310
.common:
Line 2472... Line 2470...
2472
        adc     edx, 0
2470
        adc     edx, 0
2473
        push    [ebp+NTFS.fileDataStart]
2471
        push    [ebp+NTFS.fileDataStart]
2474
        push    [ebp+NTFS.fileDataSize]
2472
        push    [ebp+NTFS.fileDataSize]
2475
        call    resizeAttribute
2473
        call    resizeAttribute
2476
        jc      ntfsErrorPop2
2474
        jc      ntfsErrorPop2
2477
        mov     eax, [ebp+NTFS.frs_buffer]
2475
        mov     ebx, [ebp+NTFS.frs_buffer]
2478
        mov     [ebp+NTFS.cur_buf], eax
2476
        mov     edx, [ebp+NTFS.LastRead]
2479
        call    writeRecord     ; $MFT
2477
        call    writeRecord     ; $MFT
2480
        mov     eax, [ebp+NTFS.mftmirr_cluster]
2478
        mov     eax, [ebp+NTFS.mftmirr_cluster]
2481
        mul     [ebp+NTFS.sectors_per_cluster]
2479
        mul     [ebp+NTFS.sectors_per_cluster]
2482
        mov     ebx, [ebp+NTFS.frs_buffer]
2480
        mov     ecx, [ebp+NTFS.frs_size]
2483
        movzx   ecx, word [ebx+updateSequenceSize]
-
 
2484
        dec     ecx
2481
        shr     ecx, 9
2485
        call    fs_write64_sys  ; $MFTMirr
2482
        call    fs_write64_sys  ; $MFTMirr
2486
; update $MFT retrieval information
2483
; update $MFT retrieval information
2487
        mov     edi, [ebp+NTFS.mft_retrieval_end]
2484
        mov     edi, [ebp+NTFS.mft_retrieval_end]
2488
        mov     eax, [edi-4]
2485
        mov     eax, [edi-4]
2489
        add     eax, [edi-8]
2486
        add     eax, [edi-8]
Line 2625... Line 2622...
2625
        mov     byte [edi+40h+indexAllocatedSize], 16
2622
        mov     byte [edi+40h+indexAllocatedSize], 16
2626
        mov     byte [edi+40h+indexFlags], 2
2623
        mov     byte [edi+40h+indexFlags], 2
2627
        add     edi, 50h
2624
        add     edi, 50h
2628
        mov     al, 3
2625
        mov     al, 3
2629
.end:
2626
.end:
2630
        mov     esi, [ebp+NTFS.frs_buffer]
2627
        mov     ebx, [ebp+NTFS.frs_buffer]
2631
        mov     dword [edi], -1
2628
        mov     dword [edi], -1
2632
        mov     dword [edi+4], 0
2629
        mov     dword [edi+4], 0
2633
        add     edi, 8
2630
        add     edi, 8
2634
        sub     edi, esi
2631
        sub     edi, ebx
2635
        mov     [ebp+NTFS.cur_buf], esi
2632
        mov     [ebx+recordFlags], al
2636
        mov     [esi+recordFlags], al
2633
        mov     [ebx+recordRealSize], edi
2637
        mov     [esi+recordRealSize], edi
2634
        mov     edx, [ebp+NTFS.LastRead]
2638
        call    writeRecord
2635
        call    writeRecord
2639
; write MFT bitmap
2636
; write MFT bitmap
2640
        mov     eax, [ebp+NTFS.newRecord]
2637
        mov     eax, [ebp+NTFS.newRecord]
2641
        shr     eax, 3+9
2638
        shr     eax, 3+9
2642
        mov     ebx, eax
2639
        mov     ebx, eax
Line 2648... Line 2645...
2648
        call    fs_write64_sys
2645
        call    fs_write64_sys
2649
        mov     edi, [ebp+NTFS.indexPointer]
2646
        mov     edi, [ebp+NTFS.indexPointer]
2650
        mov     eax, [ebp+NTFS.newRecord]
2647
        mov     eax, [ebp+NTFS.newRecord]
2651
        mov     [edi+fileRecordReference], eax
2648
        mov     [edi+fileRecordReference], eax
2652
; 5. Write directory node
2649
; 5. Write directory node
2653
        mov     eax, [ebp+NTFS.nodeLastRead]
-
 
2654
        mov     [ebp+NTFS.LastRead], eax
-
 
2655
        mov     eax, [ebp+NTFS.cur_index_buf]
2650
        mov     ebx, [ebp+NTFS.cur_index_buf]
2656
        mov     [ebp+NTFS.cur_buf], eax
2651
        mov     edx, [ebp+NTFS.nodeLastRead]
2657
        call    writeRecord
2652
        call    writeRecord
2658
        mov     ebx, [ebp+NTFS.fileRealSize]
2653
        mov     ebx, [ebp+NTFS.fileRealSize]
2659
ntfsDone:
2654
ntfsDone:
2660
        mov     esi, [ebp+PARTITION.Disk]
2655
        mov     esi, [ebp+PARTITION.Disk]
2661
        call    disk_sync
2656
        call    disk_sync
Line 2664... Line 2659...
2664
        ret
2659
        ret
Line 2665... Line 2660...
2665
 
2660
 
2666
writeRecord:
2661
writeRecord:
2667
; make updateSequence and write to disk
2662
; make updateSequence and write to disk
2668
;   in:
2663
;   in:
2669
; [ebp+NTFS.cur_buf] -> record
2664
; ebx -> record
2670
; [ebp+NTFS.LastRead] = partition sector
2665
; edx = partition sector
2671
        mov     esi, [ebp+NTFS.cur_buf]
2666
        mov     esi, ebx
2672
        mov     edi, esi
2667
        mov     edi, ebx
2673
        movzx   ecx, word [esi+updateSequenceOffset]
2668
        movzx   ecx, word [esi+updateSequenceOffset]
2674
        add     edi, ecx
2669
        add     edi, ecx
2675
        mov     ax, [edi]
2670
        mov     ax, [edi]
2676
        inc     ax
2671
        inc     ax
Line 2682... Line 2677...
2682
        add     esi, 510
2677
        add     esi, 510
2683
        movsw
2678
        movsw
2684
        mov     [esi-2], ax
2679
        mov     [esi-2], ax
2685
        dec     ecx
2680
        dec     ecx
2686
        jnz     @b
2681
        jnz     @b
2687
        mov     eax, [ebp+NTFS.LastRead]
-
 
2688
        mov     ebx, [ebp+NTFS.cur_buf]
-
 
2689
        pop     ecx
2682
        mov     eax, edx
2690
        xor     edx, edx
2683
        xor     edx, edx
-
 
2684
        pop     ecx
2691
        jmp     fs_write64_sys
2685
        jmp     fs_write64_sys
Line 2692... Line 2686...
2692
 
2686
 
2693
createMcbEntry:
2687
createMcbEntry:
2694
;   in:
2688
;   in:
Line 3445... Line 3439...
3445
        add     edi, [ebx+4]
3439
        add     edi, [ebx+4]
3446
        mov     ecx, [ebx+12]
3440
        mov     ecx, [ebx+12]
3447
        mov     esi, [ebx+16]
3441
        mov     esi, [ebx+16]
3448
        rep movsb
3442
        rep movsb
3449
@@:
3443
@@:
3450
        mov     eax, [ebp+NTFS.frs_buffer]
-
 
3451
        mov     [ebp+NTFS.cur_buf], eax
-
 
3452
        call    writeRecord     ; file
-
 
3453
        mov     ebx, [ebp+NTFS.frs_buffer]
3444
        mov     ebx, [ebp+NTFS.frs_buffer]
-
 
3445
        mov     edx, [ebp+NTFS.mftLastRead]
-
 
3446
        call    writeRecord     ; file
3454
        call    ntfs_restore_usa_frs
3447
        call    ntfs_restore_usa_frs
3455
.writeNode:
3448
.writeNode:
3456
        mov     eax, [ebp+NTFS.nodeLastRead]
-
 
3457
        mov     [ebp+NTFS.LastRead], eax
-
 
3458
        mov     eax, [ebp+NTFS.cur_index_buf]
3449
        mov     ebx, [ebp+NTFS.cur_index_buf]
3459
        mov     [ebp+NTFS.cur_buf], eax
3450
        mov     edx, [ebp+NTFS.nodeLastRead]
3460
        call    writeRecord     ; directory
3451
        call    writeRecord     ; directory
3461
        pop     ebx
3452
        pop     ebx
3462
        mov     ecx, [ebp+NTFS.attr_offs]
3453
        mov     ecx, [ebp+NTFS.attr_offs]
3463
        cmp     byte [ecx+nonResidentFlag], 0
3454
        cmp     byte [ecx+nonResidentFlag], 0
3464
        jz      .done
3455
        jz      .done
Line 3713... Line 3704...
3713
        mov     [ebp+NTFS.rootLastRead], eax
3704
        mov     [ebp+NTFS.rootLastRead], eax
3714
        mov     eax, ebx
3705
        mov     eax, ebx
3715
        xor     ebx, ebx
3706
        xor     ebx, ebx
3716
        jmp     .indexRecord
3707
        jmp     .indexRecord
Line -... Line 3708...
-
 
3708
 
-
 
3709
.ret:
-
 
3710
        ret
3717
 
3711
 
3718
@@:         ; examine file record
3712
@@:         ; examine file record
3719
        mov     [ebp+NTFS.cur_attr], 0x80
3713
        mov     [ebp+NTFS.cur_attr], 0x80   ; file?
3720
        mov     [ebp+NTFS.cur_offs], 0
3714
        mov     [ebp+NTFS.cur_offs], 0
3721
        mov     [ebp+NTFS.cur_size], 0
3715
        mov     [ebp+NTFS.cur_size], 0
-
 
3716
        call    ntfs_read_attr
-
 
3717
        jnc     @f
-
 
3718
        mov     eax, [ebp+NTFS.cur_index_size]
-
 
3719
        shl     eax, 9
-
 
3720
        stdcall kernel_alloc, eax
-
 
3721
        test    eax, eax
-
 
3722
        jz      ntfsFail
-
 
3723
        push    [ebp+NTFS.cur_index_buf]
-
 
3724
        push    [ebp+NTFS.secondIndexBuffer]
-
 
3725
        push    [ebp+NTFS.cur_index_size]
-
 
3726
        mov     [ebp+NTFS.cur_index_buf], eax
-
 
3727
        mov     [ebp+NTFS.secondIndexBuffer], eax
-
 
3728
        xor     eax, eax
-
 
3729
        push    eax eax eax eax
-
 
3730
        mov     [esp+12], esp
-
 
3731
        push    eax
-
 
3732
        mov     ebx, esp
-
 
3733
        mov     [ebp+NTFS.cur_attr], 0x90   ; folder?
-
 
3734
        call    ntfs_ReadFolder.doit
-
 
3735
        push    eax
-
 
3736
        stdcall kernel_free, [ebp+NTFS.cur_index_buf]
-
 
3737
        pop     eax
-
 
3738
        mov     edx, [esp+12]
-
 
3739
        add     esp, 20
-
 
3740
        pop     [ebp+NTFS.cur_index_size]
-
 
3741
        pop     [ebp+NTFS.secondIndexBuffer]
-
 
3742
        pop     [ebp+NTFS.cur_index_buf]
3722
        call    ntfs_read_attr
3743
        test    eax, eax
-
 
3744
        jnz     .ret
-
 
3745
        cmp     edx, 2
-
 
3746
        jnz     ntfsDenied      ; folder is not empty
-
 
3747
        mov     [ebp+NTFS.cur_attr], 0xA0
-
 
3748
        mov     [ebp+NTFS.cur_offs], 0
-
 
3749
        mov     [ebp+NTFS.cur_size], 0
-
 
3750
        call    ntfs_read_attr.newAttribute
-
 
3751
        jc      .writeBitmapMFT
3723
        jc      .folder
3752
@@:
3724
        mov     esi, [ebp+NTFS.frs_buffer]
3753
        mov     esi, [ebp+NTFS.frs_buffer]
3725
        cmp     word [esi+baseRecordReuse], 0
3754
        cmp     word [esi+baseRecordReuse], 0
3726
        jnz     ntfsUnsupported     ; auxiliary record
3755
        jnz     ntfsUnsupported     ; auxiliary record
3727
        mov     esi, [ebp+NTFS.attr_offs]
3756
        mov     esi, [ebp+NTFS.attr_offs]
3728
        cmp     byte [esi+nonResidentFlag], 0
3757
        cmp     byte [esi+nonResidentFlag], 0
3729
        jz      .writeBitmapMFT
3758
        jz      .writeBitmapMFT
3730
        movzx   eax, byte [esi+dataRunsOffset]
3759
        movzx   eax, byte [esi+dataRunsOffset]
3731
        add     esi, eax
3760
        add     esi, eax
3732
        xor     edi, edi
3761
        xor     edi, edi
3733
        sub     esp, 16
3762
        sub     esp, 16
3734
@@:         ; "delete" file data
3763
@@:
3735
        call    ntfs_decode_mcb_entry
3764
        call    ntfs_decode_mcb_entry
3736
        jnc     @f
3765
        jnc     @f
3737
        cmp     dword[esp+8], 0
3766
        cmp     dword[esp+8], 0
3738
        jz      @b
3767
        jz      @b
3739
        add     edi, [esp+8]
3768
        add     edi, [esp+8]
3740
        mov     ebx, [esp]
3769
        mov     ebx, [esp]
3741
        call    ntfsSpaceFree
3770
        call    ntfsSpaceFree
3742
        jnc     @b
3771
        jnc     @b
3743
@@:
3772
@@:
3744
        add     esp, 16
-
 
3745
        jmp     .writeBitmapMFT
-
 
3746
 
-
 
3747
.folder:    ; empty?
-
 
3748
        lea     esi, [ebp+NTFS.bitmap_buf]
-
 
3749
        mov     [ebp+NTFS.cur_buf], esi
-
 
3750
        mov     [ebp+NTFS.cur_attr], 0x90
-
 
3751
        mov     [ebp+NTFS.cur_offs], 0
-
 
3752
        mov     [ebp+NTFS.cur_size], 1
-
 
3753
        call    ntfs_read_attr
-
 
3754
        cmp     [ebp+NTFS.cur_read], 48
-
 
3755
        jnz     ntfsDenied
-
 
3756
        test    byte [esi+32+indexFlags], 1
-
 
3757
        jnz     ntfsDenied
3773
        add     esp, 16
3758
.writeBitmapMFT:    ; "delete" file record
3774
.writeBitmapMFT:    ; "delete" file record
3759
        mov     eax, [ebp+NTFS.cur_iRecord]
3775
        mov     eax, [ebp+NTFS.cur_iRecord]
3760
        mov     ecx, eax
3776
        mov     ecx, eax
3761
        shr     eax, 3
3777
        shr     eax, 3
Line 3768... Line 3784...
3768
        add     eax, [ebp+NTFS.mftBitmapLocation]
3784
        add     eax, [ebp+NTFS.mftBitmapLocation]
3769
        add     ebx, edi
3785
        add     ebx, edi
3770
        mov     ecx, 1
3786
        mov     ecx, 1
3771
        xor     edx, edx
3787
        xor     edx, edx
3772
        call    fs_write64_sys
3788
        call    fs_write64_sys
3773
        mov     esi, [ebp+NTFS.frs_buffer]
3789
        mov     ebx, [ebp+NTFS.frs_buffer]
3774
        mov     [ebp+NTFS.cur_buf], esi
3790
        mov     byte [ebx+recordFlags], 0
3775
        mov     byte [esi+recordFlags], 0
3791
        mov     edx, [ebp+NTFS.mftLastRead]
3776
        call    writeRecord
3792
        call    writeRecord
3777
; write directory node
3793
; write directory node
3778
        mov     eax, [ebp+NTFS.cur_index_buf]
3794
        mov     ebx, [ebp+NTFS.cur_index_buf]
3779
        mov     [ebp+NTFS.cur_buf], eax
-
 
3780
        mov     eax, [ebp+NTFS.nodeLastRead]
3795
        mov     edx, [ebp+NTFS.nodeLastRead]
3781
        mov     [ebp+NTFS.LastRead], eax
-
 
3782
        call    writeRecord
3796
        call    writeRecord
3783
        mov     eax, [ebp+NTFS.secondIndexBuffer]
3797
        mov     ebx, [ebp+NTFS.secondIndexBuffer]
3784
        cmp     byte [eax], 0
3798
        cmp     byte [ebx], 0
3785
        jz      ntfsDone
3799
        jz      ntfsDone
3786
        mov     [ebp+NTFS.cur_buf], eax
-
 
3787
        mov     eax, [ebp+NTFS.rootLastRead]
3800
        mov     edx, [ebp+NTFS.rootLastRead]
3788
        mov     [ebp+NTFS.LastRead], eax
-
 
3789
        call    writeRecord
3801
        call    writeRecord
3790
        jmp     ntfsDone
3802
        jmp     ntfsDone
Line 3791... Line 3803...
3791
 
3803
 
3792
;----------------------------------------------------------------
3804
;----------------------------------------------------------------
Line 3860... Line 3872...
3860
        pop     edi
3872
        pop     edi
3861
        mov     esi, eax
3873
        mov     esi, eax
3862
        sub     ecx, edi
3874
        sub     ecx, edi
3863
        add     edi, eax
3875
        add     edi, eax
3864
        mov     [ebp+NTFS.cur_buf], eax
3876
        mov     [ebp+NTFS.cur_buf], eax
3865
        push    [ebp+NTFS.LastRead]
-
 
3866
        call    ntfs_read_attr.continue
3877
        call    ntfs_read_attr.continue
3867
        jc      @f
3878
        jc      @f
3868
        xor     eax, eax
3879
        xor     eax, eax
3869
        rep stosb
3880
        rep stosb
3870
        push    ebx
3881
        push    ebx
Line 3873... Line 3884...
3873
        mov     ecx, [ebp+NTFS.sectors_per_cluster]
3884
        mov     ecx, [ebp+NTFS.sectors_per_cluster]
3874
        xor     edx, edx
3885
        xor     edx, edx
3875
        call    fs_write64_app
3886
        call    fs_write64_app
3876
        pop     ebx
3887
        pop     ebx
3877
@@:
3888
@@:
3878
        pop     [ebp+NTFS.LastRead]
-
 
3879
        stdcall kernel_free, esi
3889
        stdcall kernel_free, esi
3880
.aligned:
3890
.aligned:
3881
        mov     eax, [ebx+4]
3891
        mov     eax, [ebx+4]
3882
        mov     edx, [ebx+8]
3892
        mov     edx, [ebx+8]
3883
.resizeAttribute:
3893
.resizeAttribute:
3884
        call    resizeAttribute
3894
        call    resizeAttribute
3885
        jc      ntfsError
3895
        jc      ntfsError
3886
        mov     eax, [ebp+NTFS.frs_buffer]
3896
        mov     ebx, [ebp+NTFS.frs_buffer]
3887
        mov     [ebp+NTFS.cur_buf], eax
3897
        mov     edx, [ebp+NTFS.mftLastRead]
3888
        call    writeRecord     ; file
3898
        call    writeRecord     ; file
3889
        mov     eax, [ebp+NTFS.nodeLastRead]
-
 
3890
        mov     [ebp+NTFS.LastRead], eax
-
 
3891
        mov     eax, [ebp+NTFS.cur_index_buf]
3899
        mov     ebx, [ebp+NTFS.cur_index_buf]
3892
        mov     [ebp+NTFS.cur_buf], eax
3900
        mov     edx, [ebp+NTFS.nodeLastRead]
3893
        call    writeRecord     ; directory
3901
        call    writeRecord     ; directory
3894
        call    ntfsSpaceClean
3902
        call    ntfsSpaceClean
3895
        jmp     ntfsDone
3903
        jmp     ntfsDone
Line 3896... Line 3904...
3896
 
3904