Skip to content

Instantly share code, notes, and snippets.

@nl5887
Created August 29, 2014 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nl5887/9670b9af6ba5eef7839f to your computer and use it in GitHub Desktop.
Save nl5887/9670b9af6ba5eef7839f to your computer and use it in GitHub Desktop.
LZMA add uncompressed size
import mmap
import sys
with open(sys.argv[1], "r+b") as f:
# memory-map the file, size 0 means whole file
mm = mmap.mmap(f.fileno(), 0)
offset = int(sys.argv[2])
mm[offset:]
f2 = sys.stdout
f2.write(mm[offset:offset+5])
uncompressed_size = '\x00\x00\x00\x10\x00\x00\x00\x00'
f2.write(uncompressed_size)
f2.write(mm[offset+5:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment