2010-10-24 16:19:44 +04:00
|
|
|
;* Call: ***************************************************************
|
|
|
|
lzma_decompress:
|
|
|
|
push esi
|
|
|
|
push edi
|
|
|
|
push ebx
|
|
|
|
push ebp
|
2010-10-31 14:06:54 +03:00
|
|
|
mov esi,[esp+20]
|
2010-10-24 16:19:44 +04:00
|
|
|
xor ebp,ebp
|
2010-10-31 14:06:54 +03:00
|
|
|
mov edi,unpack.code_
|
2010-10-24 16:19:44 +04:00
|
|
|
inc esi
|
|
|
|
lodsd
|
|
|
|
bswap eax
|
|
|
|
stosd
|
|
|
|
xor eax,eax
|
|
|
|
dec eax
|
|
|
|
stosd
|
|
|
|
stosd
|
|
|
|
stosd
|
|
|
|
stosd
|
|
|
|
xchg esi,eax
|
|
|
|
stosd
|
|
|
|
mov ecx,0x1F36
|
2010-10-31 14:06:54 +03:00
|
|
|
mov eax,1024
|
|
|
|
mov edi,unpack.p
|
2010-10-24 16:19:44 +04:00
|
|
|
rep stosd
|
2010-10-31 14:06:54 +03:00
|
|
|
mov edi,[esp+24]
|
2010-10-24 16:19:44 +04:00
|
|
|
mov ebx, edi
|
2010-10-31 14:06:54 +03:00
|
|
|
add ebx,[esp+28]
|
2010-10-24 16:19:44 +04:00
|
|
|
;--------------------------------------------------------------------
|
2010-10-31 14:06:54 +03:00
|
|
|
.main_loop:
|
2010-10-24 16:19:44 +04:00
|
|
|
cmp edi,ebx
|
2010-10-31 14:06:54 +03:00
|
|
|
jnb .main_loop_done
|
|
|
|
|
2010-10-24 16:19:44 +04:00
|
|
|
mov edx,edi
|
|
|
|
and edx,3
|
|
|
|
push eax
|
|
|
|
mov eax,ebp
|
|
|
|
shl eax,6
|
2010-10-31 14:06:54 +03:00
|
|
|
lea eax,[eax+edx*4+unpack.p]
|
|
|
|
call RangeDecoderBitDecode
|
2010-10-24 16:19:44 +04:00
|
|
|
pop eax
|
|
|
|
jb .labl_06
|
2010-10-31 14:06:54 +03:00
|
|
|
|
2010-10-24 16:19:44 +04:00
|
|
|
movzx eax,al
|
|
|
|
shr eax,5
|
2010-10-31 14:06:54 +03:00
|
|
|
imul eax,eax,3072
|
|
|
|
add eax,unpack.p+0x1CD8
|
2010-10-24 16:19:44 +04:00
|
|
|
mov cl,1
|
|
|
|
cmp ebp,7
|
|
|
|
jb .labl_02
|
2010-10-31 14:06:54 +03:00
|
|
|
|
2010-10-24 16:19:44 +04:00
|
|
|
mov dl,[edi+esi]
|
|
|
|
;--------------------------------------------------------------------
|
|
|
|
.labl_01:
|
|
|
|
add dl,dl
|
|
|
|
setb ch
|
|
|
|
push eax
|
2010-10-31 14:06:54 +03:00
|
|
|
lea eax,[eax+ecx*4+1024]
|
|
|
|
call RangeDecoderBitDecode
|
2010-10-24 16:19:44 +04:00
|
|
|
pop eax
|
|
|
|
adc cl,cl
|
|
|
|
jb .labl_03
|
2010-10-31 14:06:54 +03:00
|
|
|
|
2010-10-24 16:19:44 +04:00
|
|
|
xor ch,cl
|
|
|
|
test ch,1
|
|
|
|
mov ch,0
|
|
|
|
je .labl_01
|
|
|
|
;--------------------------------------------------------------------
|
|
|
|
.labl_02:
|
|
|
|
push eax
|
|
|
|
lea eax,[eax+ecx*4]
|
2010-10-31 14:06:54 +03:00
|
|
|
call RangeDecoderBitDecode
|
2010-10-24 16:19:44 +04:00
|
|
|
pop eax
|
|
|
|
adc cl,cl
|
|
|
|
jnb .labl_02
|
|
|
|
;--------------------------------------------------------------------
|
|
|
|
.labl_03:
|
|
|
|
mov eax,ebp
|
|
|
|
cmp al,4
|
|
|
|
jb .labl_04
|
2010-10-31 14:06:54 +03:00
|
|
|
|
|
|
|
cmp al,10
|
2010-10-24 16:19:44 +04:00
|
|
|
mov al,3
|
|
|
|
jb .labl_04
|
2010-10-31 14:06:54 +03:00
|
|
|
|
2010-10-24 16:19:44 +04:00
|
|
|
mov al,6
|
|
|
|
;--------------------------------------------------------------------
|
|
|
|
.labl_04:
|
|
|
|
sub ebp,eax
|
|
|
|
xchg ecx,eax
|
|
|
|
;--------------------------------------------------------------------
|
2010-10-31 14:06:54 +03:00
|
|
|
.main_loop_1:
|
2010-10-24 16:19:44 +04:00
|
|
|
stosb
|
2010-10-31 14:06:54 +03:00
|
|
|
jmp .main_loop
|
2010-10-24 16:19:44 +04:00
|
|
|
;--------------------------------------------------------------------
|
|
|
|
.labl_06:
|
2010-10-31 14:06:54 +03:00
|
|
|
lea eax,[unpack.p+768+ebp*4]
|
|
|
|
call RangeDecoderBitDecode
|
2010-10-24 16:19:44 +04:00
|
|
|
jnb .labl_09
|
2010-10-31 14:06:54 +03:00
|
|
|
|
|
|
|
add eax,48
|
|
|
|
call RangeDecoderBitDecode
|
2010-10-24 16:19:44 +04:00
|
|
|
jb .labl_07
|
2010-10-31 14:06:54 +03:00
|
|
|
|
2010-10-24 16:19:44 +04:00
|
|
|
mov eax, ebp
|
|
|
|
shl eax,6
|
2010-10-31 14:06:54 +03:00
|
|
|
lea eax,[eax+edx*4+unpack.p+0x3C0]
|
|
|
|
call RangeDecoderBitDecode
|
2010-10-24 16:19:44 +04:00
|
|
|
jb .labl_08
|
2010-10-31 14:06:54 +03:00
|
|
|
|
2010-10-24 16:19:44 +04:00
|
|
|
cmp ebp,7
|
|
|
|
sbb ebp,ebp
|
2010-10-31 14:06:54 +03:00
|
|
|
lea ebp,[ebp+ebp+11]
|
2010-10-24 16:19:44 +04:00
|
|
|
mov al,[edi+esi]
|
2010-10-31 14:06:54 +03:00
|
|
|
jmp .main_loop_1
|
2010-10-24 16:19:44 +04:00
|
|
|
;--------------------------------------------------------------------
|
|
|
|
.labl_07:
|
2010-10-31 14:06:54 +03:00
|
|
|
add eax,48
|
|
|
|
call RangeDecoderBitDecode
|
|
|
|
xchg esi,[unpack.rep0]
|
2010-10-24 16:19:44 +04:00
|
|
|
jnb .labl_08
|
2010-10-31 14:06:54 +03:00
|
|
|
|
|
|
|
add eax,48
|
|
|
|
call RangeDecoderBitDecode
|
|
|
|
xchg esi,[unpack.rep1]
|
2010-10-24 16:19:44 +04:00
|
|
|
jnb .labl_08
|
2010-10-31 14:06:54 +03:00
|
|
|
|
|
|
|
xchg esi,[unpack.rep2]
|
2010-10-24 16:19:44 +04:00
|
|
|
;--------------------------------------------------------------------
|
|
|
|
.labl_08:
|
2010-10-31 14:06:54 +03:00
|
|
|
mov eax,unpack.p+0x14D0
|
|
|
|
call LzmaLenDecode
|
2010-10-24 16:19:44 +04:00
|
|
|
push 8
|
|
|
|
jmp .labl_17
|
|
|
|
;--------------------------------------------------------------------
|
|
|
|
.labl_09:
|
2010-10-31 14:06:54 +03:00
|
|
|
xchg esi,[unpack.rep0]
|
|
|
|
xchg esi,[unpack.rep1]
|
|
|
|
mov [unpack.rep2],esi
|
|
|
|
mov eax,unpack.p+0xCC8
|
|
|
|
call LzmaLenDecode
|
2010-10-24 16:19:44 +04:00
|
|
|
push 3
|
|
|
|
pop eax
|
|
|
|
cmp eax,ecx
|
|
|
|
jb .labl_10
|
2010-10-31 14:06:54 +03:00
|
|
|
|
2010-10-24 16:19:44 +04:00
|
|
|
mov eax,ecx
|
|
|
|
;--------------------------------------------------------------------
|
|
|
|
.labl_10:
|
|
|
|
push ecx
|
|
|
|
push 6
|
|
|
|
pop ecx
|
|
|
|
shl eax,cl
|
|
|
|
shl eax,2
|
2010-10-31 14:06:54 +03:00
|
|
|
add eax,unpack.p+0x6C0
|
|
|
|
call RangeDecoderBitTreeDecode
|
2010-10-24 16:19:44 +04:00
|
|
|
mov esi,ecx
|
|
|
|
cmp ecx,4
|
|
|
|
jb .labl_16
|
2010-10-31 14:06:54 +03:00
|
|
|
|
2010-10-24 16:19:44 +04:00
|
|
|
push ecx
|
|
|
|
xor eax,eax
|
|
|
|
inc eax
|
|
|
|
shr ecx,1
|
|
|
|
adc al,al
|
|
|
|
dec ecx
|
|
|
|
shl eax,cl
|
|
|
|
mov esi, eax
|
|
|
|
pop edx
|
2010-10-31 14:06:54 +03:00
|
|
|
cmp edx,14
|
2010-10-24 16:19:44 +04:00
|
|
|
jnb .labl_11
|
2010-10-31 14:06:54 +03:00
|
|
|
|
2010-10-24 16:19:44 +04:00
|
|
|
sub eax,edx
|
|
|
|
shl eax,2
|
2010-10-31 14:06:54 +03:00
|
|
|
add eax,unpack.p+0xABC
|
2010-10-24 16:19:44 +04:00
|
|
|
jmp .labl_14
|
|
|
|
;--------------------------------------------------------------------
|
|
|
|
.labl_11:
|
|
|
|
sub ecx,4
|
|
|
|
xor eax,eax
|
|
|
|
;--------------------------------------------------------------------
|
|
|
|
.labl_12:
|
2010-10-31 14:06:54 +03:00
|
|
|
shr dword [unpack.range],1
|
2010-10-24 16:19:44 +04:00
|
|
|
add eax, eax
|
2010-10-31 14:06:54 +03:00
|
|
|
mov edx,[unpack.code_]
|
|
|
|
sub edx,[unpack.range]
|
2010-10-24 16:19:44 +04:00
|
|
|
jb .labl_13
|
2010-10-31 14:06:54 +03:00
|
|
|
|
|
|
|
mov [unpack.code_],edx
|
2010-10-24 16:19:44 +04:00
|
|
|
inc eax
|
|
|
|
;--------------------------------------------------------------------
|
|
|
|
.labl_13:
|
2010-10-31 14:06:54 +03:00
|
|
|
call RangeDecoderBitDecode_1
|
2010-10-24 16:19:44 +04:00
|
|
|
loop .labl_12
|
|
|
|
mov cl,4
|
|
|
|
shl eax,cl
|
|
|
|
add esi,eax
|
2010-10-31 14:06:54 +03:00
|
|
|
mov eax,unpack.p+0xC88
|
2010-10-24 16:19:44 +04:00
|
|
|
;--------------------------------------------------------------------
|
|
|
|
.labl_14:
|
|
|
|
push edi
|
|
|
|
push ecx
|
|
|
|
xor edx,edx
|
|
|
|
inc edx
|
|
|
|
xor edi,edi
|
|
|
|
;--------------------------------------------------------------------
|
|
|
|
.labl_15:
|
|
|
|
push eax
|
|
|
|
lea eax,[eax+edx*4]
|
2010-10-31 14:06:54 +03:00
|
|
|
call RangeDecoderBitDecode
|
2010-10-24 16:19:44 +04:00
|
|
|
lahf
|
|
|
|
adc edx,edx
|
|
|
|
sahf
|
|
|
|
rcr edi,1
|
|
|
|
pop eax
|
|
|
|
loop .labl_15
|
|
|
|
pop ecx
|
|
|
|
rol edi,cl
|
|
|
|
add esi,edi
|
|
|
|
pop edi
|
|
|
|
;--------------------------------------------------------------------
|
|
|
|
.labl_16:
|
|
|
|
pop ecx
|
|
|
|
not esi
|
|
|
|
push 7
|
|
|
|
;--------------------------------------------------------------------
|
|
|
|
.labl_17:
|
|
|
|
cmp ebp,7
|
|
|
|
pop ebp
|
|
|
|
jb .labl_18
|
2010-10-31 14:06:54 +03:00
|
|
|
|
2010-10-24 16:19:44 +04:00
|
|
|
inc ebp
|
|
|
|
inc ebp
|
|
|
|
inc ebp
|
|
|
|
;--------------------------------------------------------------------
|
|
|
|
.labl_18:
|
|
|
|
inc ecx
|
|
|
|
push esi
|
|
|
|
add esi,edi
|
|
|
|
rep movsb
|
|
|
|
lodsb
|
|
|
|
pop esi
|
2010-10-31 14:06:54 +03:00
|
|
|
jmp .main_loop_1
|
2010-10-24 16:19:44 +04:00
|
|
|
;--------------------------------------------------------------------
|
2010-10-31 14:06:54 +03:00
|
|
|
.main_loop_done:
|
2010-10-24 16:19:44 +04:00
|
|
|
pop ebp
|
|
|
|
pop ebx
|
|
|
|
pop edi
|
|
|
|
pop esi
|
2010-10-31 14:06:54 +03:00
|
|
|
ret 12
|
2010-10-24 16:19:44 +04:00
|
|
|
;*****************************************************************************
|
|
|
|
|
|
|
|
;* Call: ***************************************************************
|
2010-10-31 14:06:54 +03:00
|
|
|
RangeDecoderBitDecode:
|
|
|
|
; in: eax->prob
|
|
|
|
; out: CF=bit; destroys eax
|
2010-10-24 16:19:44 +04:00
|
|
|
push edx
|
2010-10-31 14:06:54 +03:00
|
|
|
mov edx,[unpack.range]
|
|
|
|
shr edx,11
|
2010-10-24 16:19:44 +04:00
|
|
|
imul edx,[eax]
|
2010-10-31 14:06:54 +03:00
|
|
|
cmp [unpack.code_],edx
|
|
|
|
jnb .2
|
|
|
|
|
|
|
|
mov [unpack.range],edx
|
|
|
|
mov edx,2048
|
2010-10-24 16:19:44 +04:00
|
|
|
sub edx,[eax]
|
|
|
|
shr edx,5
|
|
|
|
add [eax],edx
|
|
|
|
;--------------------------------------------------------------------
|
2010-10-31 14:06:54 +03:00
|
|
|
.1:
|
2010-10-24 16:19:44 +04:00
|
|
|
pushfd
|
2010-10-31 14:06:54 +03:00
|
|
|
call RangeDecoderBitDecode_1
|
2010-10-24 16:19:44 +04:00
|
|
|
popfd
|
|
|
|
pop edx
|
|
|
|
ret
|
|
|
|
;--------------------------------------------------------------------
|
2010-10-31 14:06:54 +03:00
|
|
|
.2:
|
|
|
|
sub [unpack.range],edx
|
|
|
|
sub [unpack.code_],edx
|
2010-10-24 16:19:44 +04:00
|
|
|
mov edx,[eax]
|
|
|
|
shr edx,5
|
|
|
|
sub [eax],edx
|
|
|
|
stc
|
2010-10-31 14:06:54 +03:00
|
|
|
jmp .1
|
2010-10-24 16:19:44 +04:00
|
|
|
;***********************************************************************
|
|
|
|
|
|
|
|
;* Call: ***************************************************************
|
2010-10-31 14:06:54 +03:00
|
|
|
RangeDecoderBitDecode_1:
|
|
|
|
cmp byte [unpack.range+3],0
|
|
|
|
jne @f
|
|
|
|
|
|
|
|
shl dword [unpack.range],8
|
|
|
|
shl dword [unpack.code_],8
|
2010-10-24 16:19:44 +04:00
|
|
|
push eax
|
2010-10-31 14:06:54 +03:00
|
|
|
mov eax,[unpack.rep3]
|
2010-10-24 16:19:44 +04:00
|
|
|
mov al,[eax]
|
2010-10-31 14:06:54 +03:00
|
|
|
inc dword [unpack.rep3]
|
|
|
|
mov [unpack.code_],al
|
2010-10-24 16:19:44 +04:00
|
|
|
pop eax
|
|
|
|
;--------------------------------------------------------------------
|
2010-10-31 14:06:54 +03:00
|
|
|
@@:
|
2010-10-24 16:19:44 +04:00
|
|
|
ret
|
|
|
|
;***********************************************************************
|
|
|
|
|
|
|
|
;* Call: ***************************************************************
|
2010-10-31 14:06:54 +03:00
|
|
|
LzmaLenDecode:
|
|
|
|
; in: eax->prob, edx=posState
|
|
|
|
; out: ecx=len
|
|
|
|
call RangeDecoderBitDecode
|
|
|
|
jnb .2
|
|
|
|
|
2010-10-24 16:19:44 +04:00
|
|
|
add eax,4
|
2010-10-31 14:06:54 +03:00
|
|
|
call RangeDecoderBitDecode
|
|
|
|
jb .1
|
|
|
|
|
2010-10-24 16:19:44 +04:00
|
|
|
mov cl,3
|
|
|
|
shl edx,cl
|
2010-10-31 14:06:54 +03:00
|
|
|
lea eax,[eax+edx*4+516]
|
|
|
|
call RangeDecoderBitTreeDecode
|
2010-10-24 16:19:44 +04:00
|
|
|
add ecx,8
|
|
|
|
ret
|
|
|
|
;--------------------------------------------------------------------
|
2010-10-31 14:06:54 +03:00
|
|
|
.1:
|
|
|
|
add eax,1028
|
2010-10-24 16:19:44 +04:00
|
|
|
mov cl,8
|
2010-10-31 14:06:54 +03:00
|
|
|
call RangeDecoderBitTreeDecode
|
|
|
|
add ecx,16
|
2010-10-24 16:19:44 +04:00
|
|
|
ret
|
|
|
|
;--------------------------------------------------------------------
|
2010-10-31 14:06:54 +03:00
|
|
|
.2:
|
2010-10-24 16:19:44 +04:00
|
|
|
mov cl,3
|
|
|
|
shl edx,cl
|
|
|
|
lea eax,[eax+edx*4+8]
|
|
|
|
;***********************************************************************
|
|
|
|
|
|
|
|
;* Call: ***************************************************************
|
2010-10-31 14:06:54 +03:00
|
|
|
RangeDecoderBitTreeDecode:
|
|
|
|
; in: eax->probs,ecx=numLevels
|
|
|
|
; out: ecx=length; destroys edx
|
2010-10-24 16:19:44 +04:00
|
|
|
push edi
|
|
|
|
xor edx,edx
|
|
|
|
inc edx
|
|
|
|
mov edi,edx
|
|
|
|
xchg edi, eax
|
|
|
|
;--------------------------------------------------------------------
|
2010-10-31 14:06:54 +03:00
|
|
|
@@:
|
2010-10-24 16:19:44 +04:00
|
|
|
push eax
|
|
|
|
lea eax,[edi+edx*4]
|
2010-10-31 14:06:54 +03:00
|
|
|
call RangeDecoderBitDecode
|
2010-10-24 16:19:44 +04:00
|
|
|
pop eax
|
|
|
|
adc dl,dl
|
|
|
|
add al,al
|
2010-10-31 14:06:54 +03:00
|
|
|
loop @b
|
2010-10-24 16:19:44 +04:00
|
|
|
sub dl,al
|
|
|
|
pop edi
|
|
|
|
mov ecx,edx
|
|
|
|
ret
|
|
|
|
;***********************************************************************
|
|
|
|
|