Subversion Repositories Kolibri OS

Rev

Rev 1688 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;*********************************************************************
  2. unpack:
  3.         call    displogo_and_readfile
  4.         jnz     infileerr
  5.  
  6.         mov     ecx,[insize]
  7.         test    ecx,ecx
  8.         jz      infileerr
  9.  
  10.         mcall   68,12
  11.  
  12.         mov     [infile],eax
  13.  
  14.         mov     ebx,fn70block
  15.         mov     [ebx],byte 0
  16.         mov     [ebx+16],eax
  17.         mov     eax,[insize]
  18.         mov     [ebx+12],eax
  19.  
  20.         mcall   70
  21.         test    eax,eax
  22.         jnz     infileerr
  23.  
  24.         mov     eax,[infile]
  25.         cmp     [eax],dword 'KPCK'
  26.         jz      @f
  27. ;--------------------------------------
  28. unpack_err:
  29.         call    return_memory
  30.         mov     esi,notpacked_str
  31.         push    notpacked_len
  32.         pop     ecx
  33.         jmp     write_string
  34. ;---------------------------------------------------------------------
  35. @@:
  36.         mov     ecx,[eax+4]
  37.         add     ecx,[insize]
  38.  
  39.         mcall   68,20,,[infile]
  40.  
  41.         mov     [infile],eax
  42.         add     eax,[insize]
  43.         mov     [outfile],eax
  44.         mov     [outfilebest],eax
  45.  
  46.  
  47.         mov     esi,[infile]
  48.         mov     eax,[esi+8]
  49.         push    eax
  50.         and     al,0C0h
  51.         cmp     al,0C0h
  52.         pop     eax
  53.         jz      unpack_err
  54.  
  55.         and     al,not 0C0h
  56.         dec     eax
  57.         jnz     unpack_err
  58.  
  59.         mov     eax,[esi+4]
  60.         mov     [outsize],eax
  61.         push    eax
  62.         push    [outfile]
  63.         add     esi,11
  64.         push    esi
  65.         mov     eax,[esi+1]
  66.         xchg    al,ah
  67.         ror     eax,16
  68.         xchg    al,ah
  69.         mov     [esi+1],eax
  70.         call    lzma_decompress
  71.         mov     esi,[infile]
  72.         test    [esi+8],byte 80h
  73.         jnz     uctr1
  74.  
  75.         test    [esi+8],byte 40h
  76.         jz      udone
  77.  
  78.         add     esi,[insize]
  79.         sub     esi,5
  80.         lodsd
  81.         mov     ecx,eax
  82.         jecxz   udone
  83.  
  84.         mov     dl,[esi]
  85.         mov     esi,[outfile]
  86. ;--------------------------------------
  87. uc1:
  88.         lodsb
  89.         sub     al,0E8h
  90.         cmp     al,1
  91.         ja      uc1
  92.  
  93.         cmp     [esi],dl
  94.         jnz     uc1
  95.  
  96.         lodsd
  97.         shr     ax,8
  98.         ror     eax,16
  99.         xchg    al,ah
  100.         sub     eax,esi
  101.         add     eax,[outfile]
  102.         mov     [esi-4],eax
  103.         loop    uc1
  104.         jmp     udone
  105. ;---------------------------------------------------------------------
  106. uctr1:
  107.         add     esi,[insize]
  108.         sub     esi,5
  109.         lodsd
  110.         mov     ecx,eax
  111.         jecxz   udone
  112.  
  113.         mov     dl,[esi]
  114.         mov     esi,[outfile]
  115. ;--------------------------------------
  116. uc2:
  117.         lodsb
  118. ;--------------------------------------
  119. @@:
  120.         cmp     al,15
  121.         jnz     uf
  122.  
  123.         lodsb
  124.         cmp     al,80h
  125.         jb      @b
  126.  
  127.         cmp     al,90h
  128.         jb      @f
  129. ;--------------------------------------
  130. uf:
  131.         sub     al,0E8h
  132.         cmp     al,1
  133.         ja      uc2
  134. ;--------------------------------------
  135. @@:
  136.         cmp     [esi],dl
  137.         jnz     uc2
  138.  
  139.         lodsd
  140.         shr     ax,8
  141.         ror     eax,16
  142.         xchg    al,ah
  143.         sub     eax,esi
  144.         add     eax,[outfile]
  145.         mov     [esi-4],eax
  146.         loop    uc2
  147. ;--------------------------------------
  148. udone:
  149.         mov     esi,unpacked_ok
  150.         push    unpacked_len
  151.         pop     ecx
  152.         call    write_string
  153.         jmp     saveout
  154. ;*********************************************************************
  155. return_memory:
  156.         mov     ecx,[infile]
  157.         test    ecx,ecx
  158.         jz      @f
  159.         mcall   68,13,
  160.         xor     eax,eax
  161.         mov     [infile],eax
  162. @@:
  163.         ret
  164. ;*********************************************************************
  165. displogo_and_readfile:
  166.         call    clear_mess_and_displogo
  167. ; load input file
  168.         mov     esi,inname
  169.         call    get_full_name
  170.         mov     ebx,fn70block
  171.         mov     [ebx],dword 5
  172.         and     [ebx+4],dword 0
  173.         and     [ebx+8],dword 0
  174.         and     [ebx+12],dword 0
  175.         mov     [ebx+16],dword file_attr
  176.         mcall   70
  177.         test    eax,eax
  178.         ret
  179. ;*********************************************************************