Rev 3908 | Rev 4423 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3908 | Rev 4265 | ||
---|---|---|---|
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: 3908 $ |
8 | $Revision: 4265 $ |
9 | 9 | ||
Line 456... | Line 456... | ||
456 | 456 | ||
457 | push esi |
457 | push esi |
458 | push edi |
458 | push edi |
Line 459... | Line -... | ||
459 | push ebx |
- | |
460 | 459 | push ebx |
|
461 | 460 | ||
462 | lea eax, [attr] |
461 | lea eax, [attr] |
463 | stdcall get_fileinfo, [file_name], eax ;find file and get info |
462 | stdcall get_fileinfo, [file_name], eax ;find file and get info |
Line 482... | Line 481... | ||
482 | cmp dword [eax], 0x4B43504B ; check kpack signature |
481 | cmp dword [eax], 0x4B43504B ; check kpack signature |
483 | jne .raw_file |
482 | jne .raw_file |
Line 484... | Line 483... | ||
484 | 483 | ||
485 | mov ebx, [eax+4] ;get real size of file |
484 | mov ebx, [eax+4] ;get real size of file |
486 | mov [file_size], ebx |
485 | mov [file_size], ebx |
487 | stdcall user_alloc, ebx ;and allocate memory from user heap |
486 | stdcall user_alloc, ebx ;and allocate space from user heap |
488 | mov [um_file], eax |
487 | mov [um_file], eax |
489 | test eax, eax |
488 | test eax, eax |
Line -... | Line 489... | ||
- | 489 | jz .err_2 |
|
- | 490 | ||
- | 491 | mov edx, [file_size] ;preallocate page memory |
|
- | 492 | shr eax, 10 |
|
- | 493 | lea edi, [page_tabs+eax] |
|
- | 494 | add edx, 4095 |
|
- | 495 | shr edx, 12 |
|
- | 496 | @@: |
|
- | 497 | call alloc_page |
|
- | 498 | test eax, eax |
|
- | 499 | jz .err_3 |
|
- | 500 | ||
- | 501 | or eax, PG_UW |
|
- | 502 | stosd |
|
- | 503 | dec edx |
|
490 | jz .err_2 |
504 | jnz @B |
491 | 505 | ||
492 | pushad |
506 | pushad |
Line 493... | Line 507... | ||
493 | mov ecx, unpack_mutex |
507 | mov ecx, unpack_mutex |
Line 499... | Line 513... | ||
499 | call mutex_unlock |
513 | call mutex_unlock |
500 | popad |
514 | popad |
Line 501... | Line 515... | ||
501 | 515 | ||
502 | stdcall kernel_free, [km_file] ;we don't need packed file anymore |
516 | stdcall kernel_free, [km_file] ;we don't need packed file anymore |
- | 517 | .exit: |
|
- | 518 | ||
- | 519 | mov edi, [um_file] |
|
- | 520 | mov esi, [um_file] |
|
- | 521 | mov eax, [file_size] |
|
- | 522 | mov edx, eax |
|
- | 523 | ||
- | 524 | add edi, eax ;cleanup remain space |
|
- | 525 | mov ecx, 4096 ;from file end |
|
- | 526 | and eax, 4095 |
|
- | 527 | jz @f |
|
- | 528 | sub ecx, eax |
|
- | 529 | xor eax, eax |
|
- | 530 | cld |
|
- | 531 | rep stosb |
|
503 | .exit: |
532 | @@: |
504 | mov eax, [um_file] |
- | |
Line 505... | Line 533... | ||
505 | mov edx, [file_size] |
533 | mov eax, [um_file] |
506 | 534 | ||
507 | pop ebx |
535 | pop ebx |
508 | pop edi |
536 | pop edi |
Line 509... | Line -... | ||
509 | pop esi |
- | |
510 | ret |
537 | pop esi |
511 | 538 | ret |
|
512 | 539 | ||
Line 513... | Line 540... | ||
513 | .raw_file: ; sometimes we load unpacked file |
540 | .raw_file: ; sometimes we load unpacked file |
Line 531... | Line 558... | ||
531 | 558 | ||
532 | cld |
559 | cld |
533 | @@: |
560 | @@: |
534 | lodsd |
561 | lodsd |
535 | and eax, 0xFFFFF000 |
562 | and eax, 0xFFFFF000 |
536 | or eax, PG_USER |
563 | or eax, PG_UW |
537 | stosd |
564 | stosd |
Line 538... | Line 565... | ||
538 | loop @B |
565 | loop @B |
539 | 566 | ||
540 | stdcall free_kernel_space, [km_file] ; release allocated kernel space |
567 | stdcall free_kernel_space, [km_file] ; release allocated kernel space |
- | 568 | jmp .exit ; physical pages still in use |
|
541 | jmp .exit ; physical pages still in use |
569 | .err_3: |
542 | 570 | stdcall user_free, [um_file] |
|
543 | .err_2: |
571 | .err_2: |
544 | stdcall kernel_free, [km_file] |
572 | stdcall kernel_free, [km_file] |
545 | .err_1: |
573 | .err_1: |