DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Counting Number Of Bitmaps In An Mbm File

  • submit to reddit
        I continue <a href=>my hacking</a> on symbian mbm(multi-bitmap) format.
# a helping function
from struct import unpack
def readL(f, pos=None):
    if pos is not None:
    return unpack('L',[0]

# the real counting function
def mbm_count(mbm_file):
    f = open(mbm_file, 'rb')
    mbm_type = readL(f)
    if mbm_type == 0x10000041:  # mbm on ROM (Z:)
        return readL(f) 
    elif mbm_type == 0x10000037L:  # mbm on file (normal)
        return readL(f, readL(f, 16)) # read at trailer
    else:       # what type is it?
        return None
For example (you may try this on your phone)
>>> mbm_count('z:\\system\\data\\avkon.mbm')
>>> mbm_count('E:\\system\\apps\\FExplorer\\FExplorer.mbm')