Subversion Repositories Kolibri OS

Rev

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

Rev 6824 Rev 6845
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: 6824 $
8
$Revision: 6845 $
9
 
9
 
10
; NTFS external functions
10
; NTFS external functions
11
;   in:
11
;   in:
Line 1318... Line 1318...
1318
        pop     eax
1318
        pop     eax
1319
        jmp     .doit2
1319
        jmp     .doit2
Line 1320... Line 1320...
1320
 
1320
 
1321
;----------------------------------------------------------------
1321
;----------------------------------------------------------------
1322
ntfs_ReadFile:
-
 
1323
        cmp     byte [esi], 0
-
 
1324
        jnz     @f
-
 
1325
        or      ebx, -1
-
 
1326
        movi    eax, ERROR_ACCESS_DENIED
-
 
1327
        ret
-
 
1328
 
-
 
1329
@@:
1322
ntfs_ReadFile:
1330
        call    ntfs_lock
1323
        call    ntfs_lock
1331
        call    ntfs_find_lfn
1324
        call    ntfs_find_lfn
1332
        jnc     .found
-
 
1333
        call    ntfs_unlock
-
 
1334
        or      ebx, -1
-
 
1335
        movi    eax, ERROR_FILE_NOT_FOUND
-
 
1336
        ret
-
 
1337
 
-
 
1338
.found:
1325
        jc      ntfsNotFound
1339
        mov     [ebp+NTFS.cur_attr], 0x80   ; $DATA
1326
        mov     [ebp+NTFS.cur_attr], 0x80   ; $DATA
1340
        and     [ebp+NTFS.cur_offs], 0
1327
        and     [ebp+NTFS.cur_offs], 0
1341
        and     [ebp+NTFS.cur_size], 0
1328
        and     [ebp+NTFS.cur_size], 0
1342
        call    ntfs_read_attr
-
 
1343
        jnc     @f
1329
        call    ntfs_read_attr
1344
        call    ntfs_unlock
-
 
1345
        or      ebx, -1
-
 
1346
        movi    eax, ERROR_ACCESS_DENIED
-
 
1347
        ret
-
 
1348
 
-
 
1349
@@:
-
 
1350
        pushad
-
 
1351
        and     dword [esp+10h], 0
1330
        jc      ntfsDenied
-
 
1331
        xor     eax, eax
1352
        xor     eax, eax
1332
        push    eax
1353
        cmp     dword [ebx+8], 0x200
1333
        cmp     dword [ebx+8], 0x200
1354
        jb      @f
-
 
1355
.eof0:
-
 
1356
        popad
-
 
1357
        xor     ebx, ebx
-
 
1358
.eof:
-
 
1359
        call    ntfs_unlock
-
 
1360
        movi    eax, ERROR_END_OF_FILE
-
 
1361
        ret
-
 
1362
 
-
 
1363
@@:
1334
        jnc     .eof
1364
        mov     ecx, [ebx+12]
1335
        mov     ecx, [ebx+12]
1365
        mov     edx, [ebx+16]
1336
        mov     edx, [ebx+16]
1366
        mov     eax, [ebx+4]
1337
        mov     eax, [ebx+4]
1367
        test    eax, 0x1FF
1338
        test    eax, 0x1FF
Line 1377... Line 1348...
1377
        call    ntfs_read_attr.continue
1348
        call    ntfs_read_attr.continue
1378
        mov     eax, [ebx+4]
1349
        mov     eax, [ebx+4]
1379
        and     eax, 0x1FF
1350
        and     eax, 0x1FF
1380
        lea     esi, [ebp+NTFS.bitmap_buf+eax]
1351
        lea     esi, [ebp+NTFS.bitmap_buf+eax]
1381
        sub     eax, [ebp+NTFS.cur_read]
1352
        sub     eax, [ebp+NTFS.cur_read]
1382
        jae     .eof0
1353
        jae     .eof
1383
        neg     eax
1354
        neg     eax
1384
        push    ecx
1355
        push    ecx
1385
        cmp     ecx, eax
1356
        cmp     ecx, eax
1386
        jb      @f
1357
        jb      @f
1387
        mov     ecx, eax
1358
        mov     ecx, eax
1388
@@:
1359
@@:
1389
        mov     [esp+10h+4], ecx
1360
        mov     [esp+4], ecx
1390
        mov     edi, edx
1361
        mov     edi, edx
1391
        rep movsb
1362
        rep movsb
1392
        mov     edx, edi
1363
        mov     edx, edi
1393
        pop     ecx
1364
        pop     ecx
1394
        sub     ecx, [esp+10h]
1365
        sub     ecx, [esp]
1395
        jnz     @f
1366
        jz      .retok
1396
.retok:
-
 
1397
        popad
-
 
1398
        call    ntfs_unlock
-
 
1399
        xor     eax, eax
-
 
1400
        ret
-
 
1401
 
-
 
1402
@@:
-
 
1403
        cmp     [ebp+NTFS.cur_read], 0x200
1367
        cmp     [ebp+NTFS.cur_read], 0x200
1404
        jz      .alignedstart
-
 
1405
.eof_ebx:
-
 
1406
        popad
-
 
1407
        jmp     .eof
1368
        jnz     .eof
1408
 
-
 
1409
.alignedstart:
1369
.alignedstart:
1410
        mov     eax, [ebx+4]
1370
        mov     eax, [ebx+4]
1411
        push    edx
1371
        push    edx
1412
        mov     edx, [ebx+8]
1372
        mov     edx, [ebx+8]
1413
        add     eax, 511
1373
        add     eax, 511
Line 1422... Line 1382...
1422
        add     eax, [ebp+NTFS.cur_offs]
1382
        add     eax, [ebp+NTFS.cur_offs]
1423
        push    eax
1383
        push    eax
1424
        call    ntfs_read_attr.continue
1384
        call    ntfs_read_attr.continue
1425
        pop     [ebp+NTFS.cur_offs]
1385
        pop     [ebp+NTFS.cur_offs]
1426
        mov     eax, [ebp+NTFS.cur_read]
1386
        mov     eax, [ebp+NTFS.cur_read]
1427
        add     [esp+10h], eax
1387
        add     [esp], eax
1428
        mov     eax, ecx
1388
        mov     eax, ecx
1429
        and     eax, not 0x1FF
1389
        and     eax, not 0x1FF
1430
        cmp     [ebp+NTFS.cur_read], eax
1390
        cmp     [ebp+NTFS.cur_read], eax
1431
        jnz     .eof_ebx
1391
        jnz     .eof
1432
        and     ecx, 0x1FF
1392
        and     ecx, 0x1FF
1433
        jz      .retok
1393
        jz      .retok
1434
        add     edx, [ebp+NTFS.cur_read]
1394
        add     edx, [ebp+NTFS.cur_read]
1435
        mov     [ebp+NTFS.cur_size], 1
1395
        mov     [ebp+NTFS.cur_size], 1
1436
        lea     eax, [ebp+NTFS.bitmap_buf]
1396
        lea     eax, [ebp+NTFS.bitmap_buf]
Line 1442... Line 1402...
1442
@@:
1402
@@:
1443
        xchg    ecx, [ebp+NTFS.cur_read]
1403
        xchg    ecx, [ebp+NTFS.cur_read]
1444
        push    ecx
1404
        push    ecx
1445
        mov     edi, edx
1405
        mov     edi, edx
1446
        lea     esi, [ebp+NTFS.bitmap_buf]
1406
        lea     esi, [ebp+NTFS.bitmap_buf]
1447
        add     [esp+10h+4], ecx
1407
        add     [esp+4], ecx
1448
        rep movsb
1408
        rep movsb
1449
        pop     ecx
1409
        pop     ecx
1450
        xor     eax, eax
-
 
1451
        cmp     ecx, [ebp+NTFS.cur_read]
1410
        cmp     ecx, [ebp+NTFS.cur_read]
1452
        jz      @f
1411
        jnz     .eof
-
 
1412
.retok:
1453
        mov     al, ERROR_END_OF_FILE
1413
        pushd   0
1454
@@:
1414
.ret:
1455
        mov     [esp+1Ch], eax
-
 
1456
        call    ntfs_unlock
1415
        call    ntfs_unlock
1457
        popad
1416
        pop     eax ebx
1458
        ret
1417
        ret
Line -... Line 1418...
-
 
1418
 
-
 
1419
.eof:
-
 
1420
        push    ERROR_END_OF_FILE
-
 
1421
        jmp     .ret
1459
 
1422
 
1460
;----------------------------------------------------------------
1423
;----------------------------------------------------------------
1461
ntfs_ReadFolder:
1424
ntfs_ReadFolder:
1462
        call    ntfs_lock
1425
        call    ntfs_lock
1463
        mov     [ebp+NTFS.cur_iRecord], 5   ; root directory
1426
        mov     [ebp+NTFS.cur_iRecord], 5   ; root directory
Line 1852... Line 1815...
1852
        mov     [ebp+NTFS.bFolder], 1
1815
        mov     [ebp+NTFS.bFolder], 1
1853
        jmp     @f
1816
        jmp     @f
Line 1854... Line 1817...
1854
 
1817
 
1855
ntfs_CreateFile:
1818
ntfs_CreateFile:
1856
        mov     [ebp+NTFS.bFolder], 0
-
 
1857
@@:
-
 
1858
        cmp     byte [esi], 0
-
 
1859
        jnz     @f
-
 
1860
        xor     ebx, ebx
-
 
1861
        movi    eax, ERROR_ACCESS_DENIED
-
 
1862
        ret
-
 
1863
 
1819
        mov     [ebp+NTFS.bFolder], 0
1864
@@: ; 1. Search file
1820
@@: ; 1. Search file
1865
        call    ntfs_lock
1821
        call    ntfs_lock
1866
        call    ntfs_find_lfn
1822
        call    ntfs_find_lfn
1867
        jc      .notFound
1823
        jc      .notFound
Line 3481... Line 3437...
3481
        stc
3437
        stc
3482
        ret
3438
        ret
Line 3483... Line 3439...
3483
 
3439
 
3484
;----------------------------------------------------------------
3440
;----------------------------------------------------------------
3485
ntfs_WriteFile:
-
 
3486
        cmp     byte [esi], 0
-
 
3487
        jnz     @f
-
 
3488
        xor     ebx, ebx
-
 
3489
        movi    eax, ERROR_ACCESS_DENIED
-
 
3490
        ret
-
 
3491
@@:
3441
ntfs_WriteFile:
3492
        call    ntfs_lock
3442
        call    ntfs_lock
3493
        call    ntfs_find_lfn
3443
        call    ntfs_find_lfn
3494
        jc      ntfsNotFound
3444
        jc      ntfsNotFound
3495
        cmp     [ebp+NTFS.cur_iRecord], 16
3445
        cmp     [ebp+NTFS.cur_iRecord], 16
Line 3660... Line 3610...
3660
        mov     ebx, [ebx+12]
3610
        mov     ebx, [ebx+12]
3661
        jmp     ntfsDone
3611
        jmp     ntfsDone
Line 3662... Line 3612...
3662
 
3612
 
3663
;----------------------------------------------------------------
3613
;----------------------------------------------------------------
3664
ntfs_Delete:
-
 
3665
        cmp     byte [esi], 0
-
 
3666
        jnz     @f
-
 
3667
        xor     ebx, ebx
-
 
3668
        movi    eax, ERROR_ACCESS_DENIED
-
 
3669
        ret
-
 
3670
 
-
 
3671
@@:
3614
ntfs_Delete:
3672
        call    ntfs_lock
3615
        call    ntfs_lock
3673
        call    ntfs_find_lfn
3616
        call    ntfs_find_lfn
3674
        jc      ntfsNotFound
3617
        jc      ntfsNotFound
3675
        cmp     [ebp+NTFS.cur_iRecord], 16
3618
        cmp     [ebp+NTFS.cur_iRecord], 16
Line 3979... Line 3922...
3979
        xor     esi, esi
3922
        xor     esi, esi
3980
        ret
3923
        ret
Line 3981... Line 3924...
3981
 
3924
 
3982
;----------------------------------------------------------------
3925
;----------------------------------------------------------------
3983
ntfs_SetFileEnd:
-
 
3984
        cmp     byte [esi], 0
-
 
3985
        jnz     @f
-
 
3986
        xor     ebx, ebx
-
 
3987
        movi    eax, ERROR_ACCESS_DENIED
-
 
3988
        ret
-
 
3989
@@:
3926
ntfs_SetFileEnd:
3990
        call    ntfs_lock
3927
        call    ntfs_lock
3991
        call    ntfs_find_lfn
3928
        call    ntfs_find_lfn
3992
        jc      ntfsNotFound
3929
        jc      ntfsNotFound
3993
        cmp     [ebp+NTFS.cur_iRecord], 16
3930
        cmp     [ebp+NTFS.cur_iRecord], 16
Line 4114... Line 4051...
4114
        adc     edx, 29389701
4051
        adc     edx, 29389701
4115
        ret
4052
        ret
Line 4116... Line 4053...
4116
 
4053
 
4117
;----------------------------------------------------------------
4054
;----------------------------------------------------------------
4118
ntfs_SetFileInfo:
-
 
4119
        cmp     byte [esi], 0
-
 
4120
        jnz     @f
-
 
4121
        movi    eax, ERROR_UNSUPPORTED_FS
-
 
4122
        ret
-
 
4123
@@:
4055
ntfs_SetFileInfo:
4124
        call    ntfs_lock
4056
        call    ntfs_lock
4125
        call    ntfs_find_lfn
4057
        call    ntfs_find_lfn
4126
        jnc     @f
4058
        jnc     @f
4127
        test    eax, eax
4059
        test    eax, eax