Skip to content

Commit

Permalink
extracticon.py: better decoding of NE icons
Browse files Browse the repository at this point in the history
  • Loading branch information
miniupnp committed May 11, 2019
1 parent 1fd5581 commit 3cdc8e1
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tools/extracticon.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,18 @@ def decode_rsrc_dir(virtual_address, rsrc, offset=0, level=0, rtype=0, rsid=0):
offset = offset + 12
realoffset = rnOffset << rscAlignShift
reallen = rnLength << rscAlignShift
print ' offset=0x%06x (0x%04x) len=%d (0x%04x) flags=%04x ID=%04x' % (realoffset, rnOffset, reallen, rnLength, rnFlags, rnID)
print ' offset=0x%06x (0x%04x) len=%d (0x%04x) flags=%04x ID=%04x Handle=%04x Usage=%04x' % (realoffset, rnOffset, reallen, rnLength, rnFlags, rnID, rnHandle, rnUsage)
if rtTypeID == 0x800e:
icon_header[rnID] = content[realoffset:realoffset+18] + '\x16\x00\x00\x00'
Res, Type, Count = unpack_from('<HHH', content, realoffset)
print " ", Res, Type, Count
Offset = 6 + 16 * Count
header = content[realoffset:realoffset+6]
for i in range(0, Count):
Width, Height, Ncolor, Res, Planes, Bpp, ByteCount, icon_id = unpack_from('<BBBBHHIH', content, realoffset+6+i*14)
print ' #%02d %03dx%03d %dcols %dx%dbpp %d bytes at 0x%06x %d' % (i, Width, Height, Ncolor, Planes, Bpp, ByteCount, Offset, icon_id)
header = header + content[realoffset+6+i*14:realoffset+6+i*14+12] + pack('<I', Offset)
Offset = Offset + ByteCount
icon_header[rnID] = header
elif rtTypeID == 0x8003:
icon_data[rnID] = content[realoffset:realoffset+reallen]

Expand Down

0 comments on commit 3cdc8e1

Please sign in to comment.