Skip to content

Commit

Permalink
inflate/pack_exe: Document and check the assumption that packed_entry…
Browse files Browse the repository at this point in the history
… is 24 bytes
  • Loading branch information
keirf committed Nov 30, 2023
1 parent 9477599 commit b09a395
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion inflate/depacker_main.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion inflate/pack_exe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit b09a395

Please sign in to comment.