'This parses a .rsrc section for quick modification'

def parse_rsrc(self):

    self.rsrc_structure = {}
    def parse_header():
        return {'Characteristics': struct.unpack('<I', self.binary.read(4))[0], 'TimeDataStamp': struct.unpack('<I', self.binary.read(4))[0], 'MajorVersion': struct.unpack('<H', self.binary.read(2))[0], 'MinorVersion': struct.unpack('<H', self.binary.read(2))[0], 'NumberOfNamedEntries': struct.unpack('<H', self.binary.read(2))[0], 'NumberofIDEntries': struct.unpack('<H', self.binary.read(2))[0]}
    def merge_two_dicts(x, y):
        'Given    two    dicts,    merge    them    into    a    new    dict    as    a    shallow    copy.'
        z = x.copy()
        z.update(y)
        return z
    def parse_data_entry():
        return {'WriteME': self.binary.tell(), 'RVA    of    Data': struct.unpack('<I', self.binary.read(4))[0], 'Size': struct.unpack('<I', self.binary.read(4))[0], 'CodePage': struct.unpack('<I', self.binary.read(4))[0], 'Reserved': struct.unpack('<I', self.binary.read(4))[0]}
    def parse_ID(number):
        temp = {}
        for i in range(0, number):
            _tempid = struct.unpack('<I', self.binary.read(4))[0]
            temp[_tempid] = struct.unpack('<I', self.binary.read(4))[0]
        return temp
    if ('rsrcPointerToRawData' not in self.flItms):
        return False
    self.binary.seek(self.flItms['rsrcPointerToRawData'], 0)
    self.rsrc_structure['Typeheader'] = parse_header()
    self.rsrc_structure['Typeheader']['NameEntries'] = {}
    self.rsrc_structure['Typeheader']['IDentries'] = {}
    if self.rsrc_structure['Typeheader']['NumberofIDEntries']:
        self.rsrc_structure['Typeheader']['IDentries'] = parse_ID(self.rsrc_structure['Typeheader']['NumberofIDEntries'])
    if self.rsrc_structure['Typeheader']['NumberOfNamedEntries']:
        self.rsrc_structure['Typeheader']['NameEntries'] = parse_ID(self.rsrc_structure['Typeheader']['NumberOfNamedEntries'])
    self.rsrc_structure['Typeheader']['Entries'] = merge_two_dicts(self.rsrc_structure['Typeheader']['IDentries'], self.rsrc_structure['Typeheader']['NameEntries'])
    for (entry, value) in self.rsrc_structure['Typeheader']['Entries'].iteritems():
        if (entry == 24):
            self.binary.seek((self.flItms['rsrcPointerToRawData'] + (value & 16777215)), 0)
            self.rsrc_structure[entry] = parse_header()
            self.rsrc_structure[entry]['IDs'] = {}
            self.rsrc_structure[entry]['Names'] = {}
            if self.rsrc_structure[entry]['NumberofIDEntries']:
                self.rsrc_structure[entry]['IDs'] = parse_ID(self.rsrc_structure[entry]['NumberofIDEntries'])
            if self.rsrc_structure[entry]['NumberOfNamedEntries']:
                self.rsrc_structure[entry]['Names'] = parse_ID(self.rsrc_structure[entry]['NumberOfNamedEntries'])
            self.rsrc_structure[entry]['NameIDs'] = merge_two_dicts(self.rsrc_structure[entry]['IDs'], self.rsrc_structure[entry]['Names'])
            for (name_id, offset) in self.rsrc_structure[entry]['NameIDs'].iteritems():
                self.binary.seek((self.flItms['rsrcPointerToRawData'] + (offset & 16777215)), 0)
                self.rsrc_structure[name_id] = parse_header()
                self.rsrc_structure[name_id]['IDs'] = {}
                self.rsrc_structure[name_id]['Names'] = {}
                if self.rsrc_structure[name_id]['NumberofIDEntries']:
                    self.rsrc_structure[name_id]['IDs'] = parse_ID(self.rsrc_structure[name_id]['NumberofIDEntries'])
                if self.rsrc_structure[name_id]['NumberOfNamedEntries']:
                    self.rsrc_structure[name_id]['Names'] = parse_ID(self.rsrc_structure[name_id]['NumberOfNamedEntries'])
                self.rsrc_structure[name_id]['language'] = merge_two_dicts(self.rsrc_structure[name_id]['IDs'], self.rsrc_structure[name_id]['Names'])
                for (lanID, offsetDataEntry) in self.rsrc_structure[name_id]['language'].iteritems():
                    self.binary.seek((self.flItms['rsrcPointerToRawData'] + (offsetDataEntry & 16777215)), 0)
                    self.rsrc_structure[lanID] = parse_data_entry()
                self.flItms['manifestLOC'] = (self.flItms['rsrcPointerToRawData'] + (self.rsrc_structure[lanID]['RVA    of    Data'] - self.flItms['rsrcVirtualAddress']))
                return True
    return False
