Loader bug fix
This commit is contained in:
parent
2fba10ed1b
commit
c22fd5e30e
|
@ -1,46 +1,48 @@
|
||||||
doc = Document.getCurrentDocument()
|
doc = Document.getCurrentDocument()
|
||||||
file_path = Document.askFile('Select Object File', None, False)
|
file_path = Document.askFile('Select Objects File', None, False)
|
||||||
if file_path is not None:
|
if file_path is not None:
|
||||||
with open(file_path, 'r') as file:
|
with open(file_path, 'r') as file:
|
||||||
while True:
|
while True:
|
||||||
l = file.readline()
|
l = file.readline()
|
||||||
if l is None:
|
if not l:
|
||||||
break
|
break
|
||||||
parts = l.split(' ', 3)
|
parts = l.split(' ', 3)
|
||||||
address = int(parts[0], 16)
|
address = int(parts[0], 16)
|
||||||
segment = doc.getSegmentAtAddress(address)
|
segment = doc.getSegmentAtAddress(address)
|
||||||
if segment is None:
|
if segment is None:
|
||||||
continue
|
continue
|
||||||
|
arr_count = int(parts[2], 10)
|
||||||
if parts[1] == 'FUNC':
|
if parts[1] == 'FUNC':
|
||||||
segment.markAsProcedure(address)
|
if segment.getTypeAtAddress(address) != Segment.TYPE_PROCEDURE:
|
||||||
|
segment.markAsProcedure(address)
|
||||||
elif parts[1] == 'STR':
|
elif parts[1] == 'STR':
|
||||||
segment.setTypeAtAddress(address, parts[2], Segment.TYPE_ASCII)
|
segment.setTypeAtAddress(address, arr_count, Segment.TYPE_ASCII)
|
||||||
elif parts[1] == 'WSTR':
|
elif parts[1] == 'WSTR':
|
||||||
segment.setTypeAtAddress(address, parts[2], Segment.TYPE_UNICODE)
|
segment.setTypeAtAddress(address, arr_count, Segment.TYPE_UNICODE)
|
||||||
elif parts[1] == 'BYTE':
|
elif parts[1] == 'BYTE':
|
||||||
if parts[2]:
|
if arr_count:
|
||||||
segment.setTypeAtAddress(address, parts[2], Segment.TYPE_INT8)
|
segment.setTypeAtAddress(address, arr_count, Segment.TYPE_INT8)
|
||||||
else:
|
else:
|
||||||
segment.setTypeAtAddress(address, 1, Segment.TYPE_INT8)
|
segment.setTypeAtAddress(address, 1, Segment.TYPE_INT8)
|
||||||
elif parts[1] == 'WORD':
|
elif parts[1] == 'WORD':
|
||||||
if parts[2]:
|
if arr_count:
|
||||||
segment.setTypeAtAddress(address, parts[2], Segment.TYPE_INT16)
|
segment.setTypeAtAddress(address, arr_count, Segment.TYPE_INT16)
|
||||||
else:
|
else:
|
||||||
segment.setTypeAtAddress(address, 2, Segment.TYPE_INT16)
|
segment.setTypeAtAddress(address, 2, Segment.TYPE_INT16)
|
||||||
elif parts[1] == 'DWORD':
|
elif parts[1] == 'DWORD':
|
||||||
if parts[2]:
|
if arr_count:
|
||||||
segment.setTypeAtAddress(address, parts[2], Segment.TYPE_INT32)
|
segment.setTypeAtAddress(address, arr_count, Segment.TYPE_INT32)
|
||||||
else:
|
else:
|
||||||
segment.setTypeAtAddress(address, 4, Segment.TYPE_INT32)
|
segment.setTypeAtAddress(address, 4, Segment.TYPE_INT32)
|
||||||
elif parts[1] == 'FLOAT':
|
elif parts[1] == 'FLOAT':
|
||||||
if parts[2]:
|
if arr_count:
|
||||||
segment.setTypeAtAddress(address, parts[2], Segment.TYPE_INT32)
|
segment.setTypeAtAddress(address, arr_count, Segment.TYPE_INT32)
|
||||||
else:
|
else:
|
||||||
segment.setTypeAtAddress(address, 4, Segment.TYPE_INT32)
|
segment.setTypeAtAddress(address, 4, Segment.TYPE_INT32)
|
||||||
doc.setOperandFormat(address, 0, Document.FORMAT_FLOAT)
|
doc.setOperandFormat(address, 0, Document.FORMAT_FLOAT)
|
||||||
elif parts[1] == 'DOUBLE':
|
elif parts[1] == 'DOUBLE':
|
||||||
if parts[2]:
|
if arr_count:
|
||||||
segment.setTypeAtAddress(address, parts[2], Segment.TYPE_INT64)
|
segment.setTypeAtAddress(address, arr_count, Segment.TYPE_INT64)
|
||||||
else:
|
else:
|
||||||
segment.setTypeAtAddress(address, 8, Segment.TYPE_INT64)
|
segment.setTypeAtAddress(address, 8, Segment.TYPE_INT64)
|
||||||
doc.setOperandFormat(address, 0, Document.FORMAT_FLOAT)
|
doc.setOperandFormat(address, 0, Document.FORMAT_FLOAT)
|
||||||
|
|
Loading…
Reference in New Issue