#!/usr/bin/env python3 """Extract bitmap images from .egf files (Win32 PE resource containers). EGF files are PE binaries whose images Resource Hacker shows as RT_BITMAP (type 2) resources, stored as raw DIBs (BITMAPINFOHEADER, no 14-byte BM file header). This walks the PE resource directory, pulls every bitmap, and writes a proper .bmp by prepending a reconstructed BITMAPFILEHEADER. Usage: python3 extract_egf.py [file_or_dir ...] No args -> all *.egf in current directory. """ import struct, sys, os, glob RT_BITMAP = 2 def u16(d, o): return struct.unpack_from(' %d images (%s)' % (f, n, outdir)) total += n print('TOTAL %d images' % total) if __name__ == '__main__': main()