diff options
author | bloodstalker <thabogre@gmail.com> | 2019-06-13 10:38:59 +0000 |
---|---|---|
committer | bloodstalker <thabogre@gmail.com> | 2019-06-13 10:38:59 +0000 |
commit | 77103c2fad681c3d7a9d575181851117ea8da808 (patch) | |
tree | 9bbba58026f9114c73d0c42bcf58851148071a44 | |
parent | update (diff) | |
download | dwasm-77103c2fad681c3d7a9d575181851117ea8da808.tar.gz dwasm-77103c2fad681c3d7a9d575181851117ea8da808.zip |
fixed a bug where string dumps where out of order. custom sections are getting dumped correctly now.
-rwxr-xr-x | parse.py | 7 | ||||
-rw-r--r-- | utils.py | 20 |
2 files changed, 21 insertions, 6 deletions
@@ -125,12 +125,19 @@ def ReadWASM(file_path, endianness, is_extended_isa, dbg): name_len, offset, dummy = Read(temp_obj_file, offset, 'varuint32') name = temp_obj_file[offset : offset + name_len] offset += name_len + ''' + if type(name) == list: + print(''.join([chr(elem) for elem in name])) + name = ''.join([chr(elem) for elem in name]) + else: + print(name) if name.find("reloc", 0, 5) == 0: is_reloc_section = True reloc_entry_count = Read(temp_obj_file, offset, 'varuint32') for i in range(0, reloc_entry_count): reloc_entry, offset, dummy = Read(tmp_obj, offset, 'varuint32') reloc_entries.append(reloc_entry) + ''' else: is_custom_section = False name_len = 0 @@ -280,15 +280,23 @@ def dumpprettysections(sections_list, width, section_name): print(Colors.green + "length: " + Colors.blue + repr(section[2]) + Colors.ENDC) print(Colors.green + "is custom section: " + Colors.blue + repr(section[3]) + Colors.ENDC) print(Colors.green + "name length: " + Colors.blue + repr(section[4]) + Colors.ENDC) - print(Colors.green + "name: " + Colors.blue + section[5] + Colors.ENDC) + + #print(section[5]) + #print(''.join(chr(char) for char in section[5])) + #print( ''.join([chr(char) for char in section[5]])) + + if type(section[5]) == list: + print(Colors.green + "name: " + Colors.blue + ''.join([chr(char) for char in section[5]]) + Colors.ENDC) + else: + print(Colors.green + "name: " + Colors.blue + section[5] + Colors.ENDC) print("\t", end="") for offset in range(0, width): if offset <= 15: - print(Colors.yellow + hex(offset) + " " + Colors.ENDC, end="") + print(Colors.blue + hex(offset) + " " + Colors.ENDC, end="") else: - print(Colors.yellow + hex(offset) + " " + Colors.ENDC, end="") + print(Colors.blue + hex(offset) + " " + Colors.ENDC, end="") print() - print(Colors.yellow + Colors.BOLD + hex(section_offset) + "\t" + Colors.ENDC, end="") + print(Colors.blue + Colors.BOLD + hex(section_offset) + "\t" + Colors.ENDC, end="") for byte in section[6]: if line_counter == width: section_offset += width @@ -296,11 +304,11 @@ def dumpprettysections(sections_list, width, section_name): line_counter = 0 for char in str_list: print(Colors.green + "|" + Colors.ENDC, end="") - if ord(char) < 32: print(" ", end="") + if ord(char) < 32 or ord(char) > 127: print(" ", end="") else: print(char, end="") str_list = [] print() - print(Colors.yellow + Colors.BOLD + hex(section_offset) + "\t" + Colors.ENDC, end="") + print(Colors.blue + Colors.BOLD + hex(section_offset) + "\t" + Colors.ENDC, end="") print(format(byte, '02x') + " ", end="") str_list.append(chr(byte)) line_counter += 1 |