Rev 3827 | Rev 5039 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3827 | Rev 4237 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | ;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2012. 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: 3827 $ |
8 | $Revision: 4237 $ |
9 | 9 | ||
Line 542... | Line 542... | ||
542 | 542 | ||
543 | push esi |
543 | push esi |
544 | push edi |
544 | push edi |
Line 545... | Line -... | ||
545 | push ebx |
- | |
546 | 545 | push ebx |
|
547 | 546 | ||
548 | lea eax, [attr] |
547 | lea eax, [attr] |
549 | stdcall get_fileinfo, [file_name], eax ;find file and get info |
548 | stdcall get_fileinfo, [file_name], eax ;find file and get info |
Line 568... | Line 567... | ||
568 | cmp dword [eax], 0x4B43504B ; check kpack signature |
567 | cmp dword [eax], 0x4B43504B ; check kpack signature |
569 | jne .raw_file |
568 | jne .raw_file |
Line 570... | Line 569... | ||
570 | 569 | ||
571 | mov ebx, [eax+4] ;get real size of file |
570 | mov ebx, [eax+4] ;get real size of file |
572 | mov [file_size], ebx |
571 | mov [file_size], ebx |
573 | stdcall user_alloc, ebx ;and allocate memory from user heap |
572 | stdcall user_alloc, ebx ;and allocate space from user heap |
574 | mov [um_file], eax |
573 | mov [um_file], eax |
575 | test eax, eax |
574 | test eax, eax |
Line -... | Line 575... | ||
- | 575 | jz .err_2 |
|
- | 576 | ||
- | 577 | mov edx, [file_size] ;preallocate page memory |
|
- | 578 | shr eax, 10 |
|
- | 579 | lea edi, [page_tabs+eax] |
|
- | 580 | add edx, 4095 |
|
- | 581 | shr edx, 12 |
|
- | 582 | @@: |
|
- | 583 | call alloc_page |
|
- | 584 | test eax, eax |
|
- | 585 | jz .err_3 |
|
- | 586 | ||
- | 587 | or eax, PG_UW |
|
- | 588 | stosd |
|
- | 589 | dec edx |
|
576 | jz .err_2 |
590 | jnz @B |
577 | 591 | ||
578 | pushad |
592 | pushad |
Line 579... | Line 593... | ||
579 | mov ecx, unpack_mutex |
593 | mov ecx, unpack_mutex |
Line 585... | Line 599... | ||
585 | call mutex_unlock |
599 | call mutex_unlock |
586 | popad |
600 | popad |
Line 587... | Line 601... | ||
587 | 601 | ||
588 | stdcall kernel_free, [km_file] ;we don't need packed file anymore |
602 | stdcall kernel_free, [km_file] ;we don't need packed file anymore |
- | 603 | .exit: |
|
- | 604 | ||
- | 605 | mov edi, [um_file] |
|
- | 606 | mov esi, [um_file] |
|
- | 607 | mov eax, [file_size] |
|
- | 608 | mov edx, eax |
|
- | 609 | ||
- | 610 | add edi, eax ;cleanup remain space |
|
- | 611 | mov ecx, 4096 ;from file end |
|
- | 612 | and eax, 4095 |
|
- | 613 | jz @f |
|
- | 614 | sub ecx, eax |
|
- | 615 | xor eax, eax |
|
- | 616 | cld |
|
- | 617 | rep stosb |
|
589 | .exit: |
618 | @@: |
590 | mov eax, [um_file] |
- | |
Line 591... | Line 619... | ||
591 | mov edx, [file_size] |
619 | mov eax, [um_file] |
592 | 620 | ||
593 | pop ebx |
621 | pop ebx |
594 | pop edi |
622 | pop edi |
Line 595... | Line -... | ||
595 | pop esi |
- | |
596 | ret |
623 | pop esi |
597 | 624 | ret |
|
598 | 625 | ||
Line 599... | Line 626... | ||
599 | .raw_file: ; sometimes we load unpacked file |
626 | .raw_file: ; sometimes we load unpacked file |
Line 617... | Line 644... | ||
617 | 644 | ||
618 | cld |
645 | cld |
619 | @@: |
646 | @@: |
620 | lodsd |
647 | lodsd |
621 | and eax, 0xFFFFF000 |
648 | and eax, 0xFFFFF000 |
622 | or eax, PG_USER |
649 | or eax, PG_UW |
623 | stosd |
650 | stosd |
Line 624... | Line 651... | ||
624 | loop @B |
651 | loop @B |
625 | 652 | ||
626 | stdcall free_kernel_space, [km_file] ; release allocated kernel space |
653 | stdcall free_kernel_space, [km_file] ; release allocated kernel space |
- | 654 | jmp .exit ; physical pages still in use |
|
627 | jmp .exit ; physical pages still in use |
655 | .err_3: |
628 | 656 | stdcall user_free, [um_file] |
|
629 | .err_2: |
657 | .err_2: |
630 | stdcall kernel_free, [km_file] |
658 | stdcall kernel_free, [km_file] |
631 | .err_1: |
659 | .err_1: |