comparison pytouhou/formats/exe.py @ 298:92a6fd2632f1

Improve heuristic to filter out non-game exes (like custom.exe).
author Thibaut Girka <thib@sitedethib.com>
date Tue, 06 Mar 2012 18:58:41 +0100
parents 2876c267be00
children 5492472963b0
comparison
equal deleted inserted replaced
297:a09ac4650e0d 298:92a6fd2632f1
22 22
23 logger = get_logger(__name__) 23 logger = get_logger(__name__)
24 24
25 25
26 SQ2 = 2. ** 0.5 / 2. 26 SQ2 = 2. ** 0.5 / 2.
27
28
29 class InvalidExeException(Exception):
30 pass
27 31
28 32
29 class Shot(object): 33 class Shot(object):
30 def __init__(self): 34 def __init__(self):
31 self.interval = 0 35 self.interval = 0
139 data_va = pe_file.image_base + data_section.VirtualAddress 143 data_va = pe_file.image_base + data_section.VirtualAddress
140 data_size = data_section.SizeOfRawData 144 data_size = data_section.SizeOfRawData
141 text_va = pe_file.image_base + text_section.VirtualAddress 145 text_va = pe_file.image_base + text_section.VirtualAddress
142 text_size = text_section.SizeOfRawData 146 text_size = text_section.SizeOfRawData
143 147
144 character_records_va = list(cls.find_character_defs(pe_file))[0] 148 possible_character_records = list(cls.find_character_defs(pe_file))
149 if not possible_character_records:
150 raise InvalidExeException
151
152 character_records_va = possible_character_records[0]
145 153
146 characters = [] 154 characters = []
147 shots_offsets = {} 155 shots_offsets = {}
148 for character in xrange(4): 156 for character in xrange(4):
149 sht = cls() 157 sht = cls()