More lzma updates - win32/pe + lzma seems to work.

This commit is contained in:
Markus F.X.J. Oberhumer
2006-06-19 22:08:06 +02:00
parent 28f019d672
commit 0b685d11c9
14 changed files with 3825 additions and 3826 deletions
+5 -5
View File
@@ -214,14 +214,14 @@ void Packer::patchDecompressor(void *loader, int lsize)
{ {
const lzma_compress_result_t *res = &ph.compress_result.result_lzma; const lzma_compress_result_t *res = &ph.compress_result.result_lzma;
// FIXME - this is for i386 only // FIXME - this is for i386 only
patch_le32(loader, lsize, "UPXd", ph.c_len - 1); unsigned properties = // lc, lp, pb, dummy
patch_le32(loader, lsize, "UPXc", ph.u_len);
unsigned p = // lc, lp, pb, dummy
(res->lit_context_bits << 0) | (res->lit_context_bits << 0) |
(res->lit_pos_bits << 8) | (res->lit_pos_bits << 8) |
(res->pos_bits << 16); (res->pos_bits << 16);
patch_le32(loader, lsize, "UPXb", p); patch_le32(loader, lsize, "UPXd", properties);
unsigned stack = 8 + 8 + 2 * res->num_probs; patch_le32(loader, lsize, "UPXc", ph.c_len - 1);
patch_le32(loader, lsize, "UPXb", ph.u_len);
unsigned stack = 8 + 4 + ALIGN_UP(2 * res->num_probs, 4);
stack = ALIGN_UP(stack, 16); stack = ALIGN_UP(stack, 16);
patch_le32(loader, lsize, "UPXa", 0u - stack); patch_le32(loader, lsize, "UPXa", 0u - stack);
} }
File diff suppressed because it is too large Load Diff
+516 -516
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+571 -572
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -22,12 +22,14 @@ lzma_d_cs.ash : tc_list = i386-lzma i386-linux.elf i386 default
tc.i386-lzma.gcc = $(tc.i386-linux.elf.gcc) tc.i386-lzma.gcc = $(tc.i386-linux.elf.gcc)
tc.i386-lzma.gcc += -ffunction-sections tc.i386-lzma.gcc += -ffunction-sections
tc.i386-lzma.gcc += -I$(UPX_LZMADIR) tc.i386-lzma.gcc += -I$(UPX_LZMADIR)
tc.i386-lzma.objdump = objdump
lzma_d_c%.ash : lzma_d_c.c lzma_d_c%.ash : lzma_d_c.c
$(call tc,gcc) $(PP_FLAGS) -c $< -o tmp/$T.o $(call tc,gcc) $(PP_FLAGS) -c $< -o tmp/$T.o
$(call tc,objstrip) tmp/$T.o $(call tc,objstrip) tmp/$T.o
$(call tc,objcopy) --only-section .text.LzmaDecode -O binary tmp/$T.o tmp/$T.bin $(call tc,objcopy) --only-section .text.LzmaDecode -O binary tmp/$T.o tmp/$T.bin
head -c-1 tmp/$T.bin > tmp/$T.out head -c-1 tmp/$T.bin > tmp/$T.out
$(call tc,objdump) -b binary -m i386 -D tmp/$T.out > tmp/$T.out.lst
$(call tc,bin2h) --mode=nasm tmp/$T.out $@ $(call tc,bin2h) --mode=nasm tmp/$T.out $@
lzma_d_cf.ash : PP_FLAGS = -DFAST lzma_d_cf.ash : PP_FLAGS = -DFAST
+14 -17
View File
@@ -62,22 +62,20 @@
cmp esp, ecx cmp esp, ecx
jnz .clearstack1 jnz .clearstack1
; LzmaDecodeProperties()
inc esi inc esi
lea edx, [ecx + 8]
mov dword [edx], 'UPXb' ; lc, lp, pb, dummy
lea eax, [ecx + 16]
mov dword [edx+4], eax ; Probs
push ecx ; outSizeProcessed * push ecx ; &outSizeProcessed
push 'UPXc' ; outSize push 'UPXb' ; outSize
push edi ; out push edi ; out
lea eax, [ecx + 4] add ecx, 4
push eax ; inSizeProcessed * push ecx ; &inSizeProcessed
push 'UPXd' ; inSize push 'UPXc' ; inSize
push esi ; in push esi ; in
push edx ; CLzmaDecoderState * add ecx, 4
push ecx ; &CLzmaDecoderState
push eax ; dummy for call
mov dword [ecx], 'UPXd' ; lc, lp, pb, dummy
; __LZMA_DEC10__ ; __LZMA_DEC10__
@@ -92,19 +90,18 @@
; __LZMA_DEC30__ ; __LZMA_DEC30__
; ;
add esi, [esp + 12] add esi, [esp + 32 + 4]
add edi, [esp + 24] add edi, [esp + 32 + 0]
mov esp, ebp ; restore stack
xor eax, eax xor eax, eax
lea ecx, [esp - 1024] lea ecx, [esp - 1024]
mov esp, ebp ; restore stack
.clearstack2: .clearstack2:
push eax push eax
cmp esp, ecx cmp esp, ecx
jnz .clearstack2 jnz .clearstack2
mov esp, ebp ; restore stack
mov esp, ebp ; restore stack
xor ecx, ecx xor ecx, ecx
+3 -2
View File
@@ -53,9 +53,10 @@ ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(CLzmaDecoderState) == 16)
#undef LzmaDecode #undef LzmaDecode
typedef struct { typedef struct {
struct { unsigned char lc, lp, pb, dummy; } Properties; struct { unsigned char lc, lp, pb, dummy; } Properties;
CProb *Probs; CProb Probs[];
// CProb *Probs;
} CLzmaDecoderState; } CLzmaDecoderState;
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(CLzmaDecoderState) == 8) ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(CLzmaDecoderState) == 4)
#define CLzmaDecoderState const CLzmaDecoderState #define CLzmaDecoderState const CLzmaDecoderState
#include "C/7zip/Compress/LZMA_C/LzmaDecode.c" #include "C/7zip/Compress/LZMA_C/LzmaDecode.c"
+1 -1
View File
@@ -1,6 +1,6 @@
db 85, 87, 86, 83,131,236,124,139,148, 36,144, 0, 0, 0,199, 68 ; 0x0000 db 85, 87, 86, 83,131,236,124,139,148, 36,144, 0, 0, 0,199, 68 ; 0x0000
db 36,116, 0, 0, 0, 0,198, 68, 36,115, 0,139,172, 36,156, 0 ; 0x0010 db 36,116, 0, 0, 0, 0,198, 68, 36,115, 0,139,172, 36,156, 0 ; 0x0010
db 0, 0,139, 66, 4,137, 68, 36,120,184, 1, 0, 0, 0, 15,182 ; 0x0020 db 0, 0,141, 66, 4,137, 68, 36,120,184, 1, 0, 0, 0, 15,182 ; 0x0020
db 74, 2,137,195,211,227,137,217, 73,137, 76, 36,108, 15,182, 74 ; 0x0030 db 74, 2,137,195,211,227,137,217, 73,137, 76, 36,108, 15,182, 74 ; 0x0030
db 1,211,224, 72,137, 68, 36,104,139,132, 36,168, 0, 0, 0, 15 ; 0x0040 db 1,211,224, 72,137, 68, 36,104,139,132, 36,168, 0, 0, 0, 15 ; 0x0040
db 182, 50,199, 69, 0, 0, 0, 0, 0,199, 68, 36, 96, 0, 0, 0 ; 0x0050 db 182, 50,199, 69, 0, 0, 0, 0, 0,199, 68, 36, 96, 0, 0, 0 ; 0x0050
+1 -1
View File
@@ -1,6 +1,6 @@
db 85, 87, 86, 83,131,236,124,139,148, 36,144, 0, 0, 0,199, 68 ; 0x0000 db 85, 87, 86, 83,131,236,124,139,148, 36,144, 0, 0, 0,199, 68 ; 0x0000
db 36,116, 0, 0, 0, 0,198, 68, 36,115, 0,139,172, 36,156, 0 ; 0x0010 db 36,116, 0, 0, 0, 0,198, 68, 36,115, 0,139,172, 36,156, 0 ; 0x0010
db 0, 0,139, 66, 4,137, 68, 36,120,184, 1, 0, 0, 0, 15,182 ; 0x0020 db 0, 0,141, 66, 4,137, 68, 36,120,184, 1, 0, 0, 0, 15,182 ; 0x0020
db 74, 2,137,195,211,227,137,217, 73,137, 76, 36,108, 15,182, 74 ; 0x0030 db 74, 2,137,195,211,227,137,217, 73,137, 76, 36,108, 15,182, 74 ; 0x0030
db 1,211,224, 72,137, 68, 36,104,139,132, 36,168, 0, 0, 0, 15 ; 0x0040 db 1,211,224, 72,137, 68, 36,104,139,132, 36,168, 0, 0, 0, 15 ; 0x0040
db 182, 50,199, 69, 0, 0, 0, 0, 0,199, 68, 36, 96, 0, 0, 0 ; 0x0050 db 182, 50,199, 69, 0, 0, 0, 0, 0,199, 68, 36, 96, 0, 0, 0 ; 0x0050
+2
View File
@@ -375,6 +375,8 @@ bool set_method_name(char *buf, size_t size, int method, int level)
alg = "NRV2D"; alg = "NRV2D";
else if (M_IS_NRV2E(method)) else if (M_IS_NRV2E(method))
alg = "NRV2E"; alg = "NRV2E";
else if (M_IS_LZMA(method))
alg = "LZMA";
else else
{ {
alg = "???"; alg = "???";