diff --git a/inflate/depacker_main.S b/inflate/depacker_main.S index 5d5b64f..db7d357 100644 --- a/inflate/depacker_main.S +++ b/inflate/depacker_main.S @@ -46,7 +46,7 @@ unpack_next_seg: lsr.l #2,d0 cmp.l (sp),a3 /* First segment?... */ jne 1f - subq.l #6,d0 /* ...Then adjust for depacker_entry */ + subq.l #6,d0 /* ...Then clip depacker_entry (24 bytes) */ 1: move.l -(a0),-(a5) subq.l #1,d0 jne 1b diff --git a/inflate/pack_exe.py b/inflate/pack_exe.py index 35970a2..d755235 100644 --- a/inflate/pack_exe.py +++ b/inflate/pack_exe.py @@ -154,7 +154,11 @@ def process_hunk(f, i): if i == 0: # First hunk must be code: we inject our entry/exit code assert id == HUNK_CODE - packed = get_code('depacker_entry') + packed + # Prepend the depacker entry code. This must be exactly + # 24 bytes in size, as this is assumed by depacker_main. + depacker_entry = get_code('depacker_entry') + assert len(depacker_entry) == 24 + packed = depacker_entry + packed # Allocate explicit extra space for the final exit code # This must always extend the allocation as these bytes # will not be zeroed before we jump to the original exe.