Subversion Repositories Kolibri OS

Rev

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

Rev 257 Rev 262
Line 291... Line 291...
291
ntfs_attr_iRecord       dd      ?
291
ntfs_attr_iRecord       dd      ?
292
ntfs_attr_iBaseRecord   dd      ?
292
ntfs_attr_iBaseRecord   dd      ?
293
ntfs_attr_offs          dd      ?
293
ntfs_attr_offs          dd      ?
294
ntfs_attr_list          dd      ?
294
ntfs_attr_list          dd      ?
295
ntfs_attr_size          dq      ?
295
ntfs_attr_size          dq      ?
-
 
296
ntfs_cur_tail           dd      ?
296
endg
297
endg
Line 297... Line 298...
297
 
298
 
298
ntfs_read_attr:
299
ntfs_read_attr:
299
; in: global variables
300
; in: global variables
Line 432... Line 433...
432
.okattr:
433
.okattr:
433
        mov     [ntfs_attr_offs], eax
434
        mov     [ntfs_attr_offs], eax
434
.scancont:
435
.scancont:
435
        add     eax, [eax+4]
436
        add     eax, [eax+4]
436
        jmp     .scanattr
437
        jmp     .scanattr
-
 
438
.continue:
-
 
439
        pushad
-
 
440
        and     [ntfs_cur_read], 0
437
.scandone:
441
.scandone:
438
; c) Check for required offset and length
442
; c) Check for required offset and length
439
        mov     ecx, [ntfs_attr_offs]
443
        mov     ecx, [ntfs_attr_offs]
440
        jecxz   .noattr
444
        jecxz   .noattr
441
        call    .doreadattr
445
        call    .doreadattr
Line 664... Line 668...
664
.okret:
668
.okret:
665
        clc
669
        clc
666
        ret
670
        ret
667
@@:
671
@@:
668
; reduce read length
672
; reduce read length
-
 
673
        and     [ntfs_cur_tail], 0
669
        cmp     [ntfs_cur_size], eax
674
        cmp     [ntfs_cur_size], eax
670
        jb      @f
675
        jb      @f
671
        mov     [ntfs_cur_size], eax
676
        mov     [ntfs_cur_size], eax
-
 
677
        mov     eax, dword [ntfs_attr_size]
-
 
678
        and     eax, 0x1FF
-
 
679
        mov     [ntfs_cur_tail], eax
672
@@:
680
@@:
673
        cmp     [ntfs_cur_size], 0
681
        cmp     [ntfs_cur_size], 0
674
        jz      .okret
682
        jz      .okret
675
        mov     eax, [ntfs_cur_offs]
683
        mov     eax, [ntfs_cur_offs]
676
        xor     edx, edx
684
        xor     edx, edx
Line 717... Line 725...
717
        loop    @b
725
        loop    @b
718
        pop     ecx
726
        pop     ecx
719
        cmp     [ntfs_cur_size], 0
727
        cmp     [ntfs_cur_size], 0
720
        jnz     .readloop
728
        jnz     .readloop
721
        add     esp, 10h
729
        add     esp, 10h
-
 
730
        mov     eax, [ntfs_cur_tail]
-
 
731
        test    eax, eax
-
 
732
        jz      .okret
-
 
733
        sub     eax, 0x200
-
 
734
        add     [ntfs_cur_read], eax
722
        jmp     .okret
735
        jmp     .okret
723
.errread2:
736
.errread2:
724
        pop     ecx
737
        pop     ecx
725
        add     esp, 10h
738
        add     esp, 10h
726
        jmp     .errret
739
        jmp     .errret
Line 862... Line 875...
862
        ret
875
        ret
Line 863... Line 876...
863
 
876
 
864
ntfs_find_lfn:
877
ntfs_find_lfn:
865
; in: esi->name
878
; in: esi->name
866
; out: CF=1 - file not found
879
; out: CF=1 - file not found
867
;      else CF=0 and eax=ntfs_cur_iRecord valid
880
;      else CF=0, [ntfs_cur_iRecord] valid, eax->record in parent directory
868
        mov     [ntfs_cur_iRecord], 5   ; start parse from root cluster
881
        mov     [ntfs_cur_iRecord], 5   ; start parse from root cluster
869
.doit2:
882
.doit2:
870
        mov     [ntfs_cur_attr], 0x90   ; $INDEX_ROOT
883
        mov     [ntfs_cur_attr], 0x90   ; $INDEX_ROOT
871
        and     [ntfs_cur_offs], 0
884
        and     [ntfs_cur_offs], 0
Line 1006... Line 1019...
1006
.next:
1019
.next:
1007
        pop     esi
1020
        pop     esi
1008
        pop     esi
1021
        pop     esi
1009
        mov     eax, [esi]
1022
        mov     eax, [esi]
1010
        mov     [ntfs_cur_iRecord], eax
1023
        mov     [ntfs_cur_iRecord], eax
1011
        mov     [esp+1Ch], eax
1024
        mov     [esp+1Ch], esi
1012
        mov     [esp+4], edi
1025
        mov     [esp+4], edi
1013
        popad
1026
        popad
1014
        inc     esi
1027
        inc     esi
1015
        cmp     byte [esi-1], 0
1028
        cmp     byte [esi-1], 0
1016
        jnz     .doit2
1029
        jnz     .doit2
Line 1029... Line 1042...
1029
;  ret ebx = bytes read or 0xffffffff file not found
1042
;  ret ebx = bytes read or 0xffffffff file not found
1030
;      eax = 0 ok read or other = errormsg
1043
;      eax = 0 ok read or other = errormsg
1031
;
1044
;
1032
;--------------------------------------------------------------
1045
;--------------------------------------------------------------
1033
ntfs_HdRead:
1046
ntfs_HdRead:
-
 
1047
        cmp     byte [esi], 0
-
 
1048
        jnz     @f
1034
        or      ebx, -1
1049
        or      ebx, -1
-
 
1050
        push    ERROR_ACCESS_DENIED
-
 
1051
        pop     eax
-
 
1052
        ret
-
 
1053
@@:
-
 
1054
        call    ntfs_find_lfn
-
 
1055
        jnc     .found
-
 
1056
        or      ebx, -1
-
 
1057
        push    ERROR_FILE_NOT_FOUND
-
 
1058
        pop     eax
-
 
1059
        ret
-
 
1060
.found:
-
 
1061
        mov     [ntfs_cur_attr], 0x80   ; $DATA
-
 
1062
        and     [ntfs_cur_offs], 0
-
 
1063
        and     [ntfs_cur_size], 0
-
 
1064
        call    ntfs_read_attr
-
 
1065
        jnc     @f
-
 
1066
        or      ebx, -1
-
 
1067
        push    ERROR_ACCESS_DENIED
-
 
1068
        pop     eax
-
 
1069
        ret
-
 
1070
@@:
-
 
1071
        pushad
-
 
1072
        and     dword [esp+10h], 0
-
 
1073
        xor     eax, eax
-
 
1074
        test    ebx, ebx
-
 
1075
        jz      .zero1
-
 
1076
        cmp     dword [ebx+4], 0x200
-
 
1077
        jb      @f
-
 
1078
.eof0:
-
 
1079
        popad
-
 
1080
        xor     ebx, ebx
-
 
1081
.eof:
-
 
1082
        push    ERROR_END_OF_FILE
-
 
1083
        pop     eax
-
 
1084
        ret
-
 
1085
@@:
-
 
1086
        mov     eax, [ebx]
-
 
1087
        test    eax, 0x1FF
-
 
1088
        jz      .alignedstart
-
 
1089
        push    edx
-
 
1090
        mov     edx, [ebx+4]
-
 
1091
        shrd    eax, edx, 9
-
 
1092
        pop     edx
-
 
1093
        mov     [ntfs_cur_offs], eax
-
 
1094
        mov     [ntfs_cur_size], 1
-
 
1095
        mov     [ntfs_cur_buf], ntfs_bitmap_buf
-
 
1096
        call    ntfs_read_attr.continue
-
 
1097
        mov     eax, [ebx]
-
 
1098
        and     eax, 0x1FF
-
 
1099
        lea     esi, [ntfs_bitmap_buf+eax]
-
 
1100
        sub     eax, [ntfs_cur_read]
-
 
1101
        jae     .eof0
-
 
1102
        neg     eax
-
 
1103
        push    ecx
-
 
1104
        cmp     ecx, eax
-
 
1105
        jb      @f
-
 
1106
        mov     ecx, eax
-
 
1107
@@:
-
 
1108
        mov     [esp+10h+4], ecx
-
 
1109
        mov     edi, edx
-
 
1110
        rep     movsb
-
 
1111
        mov     edx, edi
-
 
1112
        pop     ecx
-
 
1113
        sub     ecx, [esp+10h]
-
 
1114
        jnz     @f
-
 
1115
.retok:
-
 
1116
        popad
-
 
1117
        xor     eax, eax
-
 
1118
        ret
-
 
1119
@@:
-
 
1120
        cmp     [ntfs_cur_read], 0x200
-
 
1121
        jz      .alignedstart
-
 
1122
.eof_ebx:
-
 
1123
        popad
-
 
1124
        jmp     .eof
-
 
1125
.alignedstart:
-
 
1126
        mov     eax, [ebx]
-
 
1127
        push    edx
-
 
1128
        mov     edx, [ebx+4]
-
 
1129
        add     eax, 511
-
 
1130
        adc     edx, 0
-
 
1131
        shrd    eax, edx, 9
-
 
1132
        pop     edx
-
 
1133
.zero1:
-
 
1134
        mov     [ntfs_cur_offs], eax
-
 
1135
        mov     [ntfs_cur_buf], edx
-
 
1136
        mov     eax, ecx
-
 
1137
        shr     eax, 9
-
 
1138
        mov     [ntfs_cur_size], eax
-
 
1139
        add     eax, [ntfs_cur_offs]
-
 
1140
        push    eax
-
 
1141
        call    ntfs_read_attr.continue
-
 
1142
        pop     [ntfs_cur_offs]
-
 
1143
        mov     eax, [ntfs_cur_read]
-
 
1144
        add     [esp+10h], eax
-
 
1145
        mov     eax, ecx
-
 
1146
        and     eax, not 0x1FF
-
 
1147
        cmp     [ntfs_cur_read], eax
-
 
1148
        jnz     .eof_ebx
-
 
1149
        and     ecx, 0x1FF
-
 
1150
        jz      .retok
-
 
1151
        add     edx, [ntfs_cur_read]
-
 
1152
        mov     [ntfs_cur_size], 1
-
 
1153
        mov     [ntfs_cur_buf], ntfs_bitmap_buf
-
 
1154
        call    ntfs_read_attr.continue
-
 
1155
        cmp     [ntfs_cur_read], ecx
-
 
1156
        jb      @f
-
 
1157
        mov     [ntfs_cur_read], ecx
-
 
1158
@@:
-
 
1159
        xchg    ecx, [ntfs_cur_read]
-
 
1160
        push    ecx
-
 
1161
        mov     edi, edx
-
 
1162
        mov     esi, ntfs_bitmap_buf
-
 
1163
        add     [esp+10h+4], ecx
-
 
1164
        rep     movsb
-
 
1165
        pop     ecx
-
 
1166
        xor     eax, eax
-
 
1167
        cmp     ecx, [ntfs_cur_read]
-
 
1168
        jz      @f
1035
        mov     eax, ERROR_UNSUPPORTED_FS
1169
        mov     al, ERROR_END_OF_FILE
-
 
1170
@@:
-
 
1171
        mov     [esp+1Ch], eax
-
 
1172
        popad
1036
        ret
1173
        ret
Line 1037... Line 1174...
1037
 
1174
 
1038
;----------------------------------------------------------------
1175
;----------------------------------------------------------------
1039
;
1176
;
Line 1342... Line 1479...
1342
        jns     .ret
1479
        jns     .ret
1343
        dec     ecx
1480
        dec     ecx
1344
        js      .ret
1481
        js      .ret
1345
        inc     dword [eax+4]   ; new file block copied
1482
        inc     dword [eax+4]   ; new file block copied
1346
        mov     eax, [edx+4]    ; flags
1483
        mov     eax, [edx+4]    ; flags
1347
 
-
 
1348
ntfs_direntry_to_bdfe:
-
 
1349
        mov     [edi+4], eax    ; ANSI/UNICODE name
-
 
1350
        mov     eax, [esi+48h]
-
 
1351
        test    eax, 0x10000000
-
 
1352
        jz      @f
-
 
1353
        and     eax, not 0x10000000
-
 
1354
        or      al, 0x10
-
 
1355
@@:
-
 
1356
        stosd
-
 
1357
        scasd
-
 
1358
        push    edx
-
 
1359
        mov     eax, [esi+0x18]
-
 
1360
        mov     edx, [esi+0x1C]
-
 
1361
        call    ntfs_datetime_to_bdfe
-
 
1362
        mov     eax, [esi+0x30]
-
 
1363
        mov     edx, [esi+0x34]
-
 
1364
        call    ntfs_datetime_to_bdfe
1484
        call    ntfs_direntry_to_bdfe
1365
        mov     eax, [esi+0x20]
-
 
1366
        mov     edx, [esi+0x24]
-
 
1367
        call    ntfs_datetime_to_bdfe
-
 
1368
        pop     edx
-
 
1369
        mov     eax, [esi+0x40]
-
 
1370
        stosd
-
 
1371
        mov     eax, [esi+0x44]
-
 
1372
        stosd
-
 
1373
        push    ecx esi edi
1485
        push    ecx esi edi
1374
        movzx   ecx, byte [esi+0x50]
1486
        movzx   ecx, byte [esi+0x50]
1375
        add     esi, 0x52
1487
        add     esi, 0x52
1376
        test    byte [edi-0x24], 1
1488
        test    byte [edi-0x24], 1
1377
        jz      .ansi
1489
        jz      .ansi
Line 1397... Line 1509...
1397
        pop     edi
1509
        pop     edi
1398
        add     edi, 264
1510
        add     edi, 264
1399
        pop     esi ecx
1511
        pop     esi ecx
1400
        ret
1512
        ret
Line -... Line 1513...
-
 
1513
 
-
 
1514
ntfs_direntry_to_bdfe:
-
 
1515
        mov     [edi+4], eax    ; ANSI/UNICODE name
-
 
1516
        mov     eax, [esi+48h]
-
 
1517
        test    eax, 0x10000000
-
 
1518
        jz      @f
-
 
1519
        and     eax, not 0x10000000
-
 
1520
        or      al, 0x10
-
 
1521
@@:
-
 
1522
        stosd
-
 
1523
        scasd
-
 
1524
        push    edx
-
 
1525
        mov     eax, [esi+0x18]
-
 
1526
        mov     edx, [esi+0x1C]
-
 
1527
        call    ntfs_datetime_to_bdfe
-
 
1528
        mov     eax, [esi+0x30]
-
 
1529
        mov     edx, [esi+0x34]
-
 
1530
        call    ntfs_datetime_to_bdfe
-
 
1531
        mov     eax, [esi+0x20]
-
 
1532
        mov     edx, [esi+0x24]
-
 
1533
        call    ntfs_datetime_to_bdfe
-
 
1534
        pop     edx
-
 
1535
        mov     eax, [esi+0x40]
-
 
1536
        stosd
-
 
1537
        mov     eax, [esi+0x44]
-
 
1538
        stosd
-
 
1539
        ret
1401
 
1540
 
1402
iglobal
1541
iglobal
1403
_24             dd      24
1542
_24             dd      24
1404
_60             dd      60
1543
_60             dd      60
1405
_10000000       dd      10000000
1544
_10000000       dd      10000000
Line 1568... Line 1707...
1568
ntfs_HdDelete:
1707
ntfs_HdDelete:
1569
        mov     eax, ERROR_UNSUPPORTED_FS
1708
        mov     eax, ERROR_UNSUPPORTED_FS
1570
        ret
1709
        ret
Line 1571... Line 1710...
1571
 
1710
 
-
 
1711
ntfs_HdGetFileInfo:
-
 
1712
        cmp     byte [esi], 0
-
 
1713
        jnz     @f
-
 
1714
        push    2
-
 
1715
        pop     eax
-
 
1716
        ret
-
 
1717
@@:
-
 
1718
        call    ntfs_find_lfn
1572
ntfs_HdGetFileInfo:
1719
        jnc     .doit
-
 
1720
        push    ERROR_FILE_NOT_FOUND
-
 
1721
        pop     eax
-
 
1722
        cmp     [hd_error], 0
-
 
1723
        jz      @f
-
 
1724
        mov     al, 11
-
 
1725
@@:
-
 
1726
        ret
-
 
1727
.doit:
-
 
1728
        push    esi edi
-
 
1729
        mov     esi, eax
-
 
1730
        mov     edi, edx
-
 
1731
        xor     eax, eax
-
 
1732
        call    ntfs_direntry_to_bdfe
-
 
1733
        pop     edi esi
1573
        mov     eax, ERROR_UNSUPPORTED_FS
1734
        xor     eax, eax
1574
        ret
-