comparison pytouhou/formats/exe.py @ 367:2674c789e0c3

Various optimizations
author Thibaut Girka <thib@sitedethib.com>
date Tue, 10 Jul 2012 00:25:08 +0200
parents 5492472963b0
children b11953cf1d3b
comparison
equal deleted inserted replaced
366:7dc012f631dc 367:2674c789e0c3
139 data_section = [section for section in pe_file.sections 139 data_section = [section for section in pe_file.sections
140 if section.Name.startswith('.data')][0] 140 if section.Name.startswith('.data')][0]
141 data_va = pe_file.image_base + data_section.VirtualAddress 141 data_va = pe_file.image_base + data_section.VirtualAddress
142 data_size = data_section.SizeOfRawData 142 data_size = data_section.SizeOfRawData
143 143
144 possible_character_records = list(cls.find_character_defs(pe_file)) 144 try:
145 if not possible_character_records: 145 character_records_va = next(cls.find_character_defs(pe_file))
146 except StopIteration:
146 raise InvalidExeException 147 raise InvalidExeException
147
148 character_records_va = possible_character_records[0]
149 148
150 characters = [] 149 characters = []
151 shots_offsets = {} 150 shots_offsets = {}
152 for character in xrange(4): 151 for character in xrange(4):
153 sht = cls() 152 sht = cls()