def read(vtl, size): ret = None while True: try: ret = execution_state.getMemoryService().read(vtl, size) break # jump out of the while-loop except DebugException: mmu.init_page_table() force_loading.force_loading(vtl, size) assert ret is not None return ret
def readMemory64(vtl): ret = None while True: try: ret = long(execution_state.getMemoryService().readMemory64(vtl)) & 0xffffffffffffffffL break # jump out of the while-loop except DebugException: mmu.init_page_table() force_loading.force_loading(vtl, 32) assert ret is not None return ret
def dump(file, format, vtl_start_address, vtl_end_address): suffix = 0 while os.path.exists(file): file = file + (".%#x" % suffix) suffix = suffix + 1 while True: try: execution_state.getMemoryService().dump(file, format, vtl_start_address, vtl_end_address) break # jump out of the while-loop except DebugException, e: mmu.init_page_table() force_loading.force_loading(vtl_start_address, (vtl_end_address - vtl_start_address) + 0x1)
def dump_library(file, format, vtl_start_address, vtl_end_address): # we split the entire library file into several 4k memory pages and dump them respectively to form the entire in-memory file file_size = vtl_end_address - vtl_start_address + 0x1 file_fragment_cnt = file_size / page_size for file_fragment_idx in range(file_fragment_cnt): cur_vtl_start_address = vtl_start_address + file_fragment_idx * page_size cur_vtl_end_address = cur_vtl_start_address + page_size - 0x1 if file_fragment_idx == 0: while True: try: execution_state.getMemoryService().dump(file, format, cur_vtl_start_address, cur_vtl_end_address) break # jump out of the while-loop except DebugException, e: mmu.init_page_table() force_loading.force_loading(cur_vtl_start_address, (cur_vtl_end_address - cur_vtl_start_address) + 0x1) else: while True: try: execution_state.getMemoryService().append(file, format, cur_vtl_start_address, cur_vtl_end_address) break # jump out of the while-loop except DebugException, e: mmu.init_page_table() force_loading.force_loading(cur_vtl_start_address, (cur_vtl_end_address - cur_vtl_start_address) + 0x1)
break # jump out of the while-loop except DebugException, e: mmu.init_page_table() force_loading.force_loading(cur_vtl_start_address, (cur_vtl_end_address - cur_vtl_start_address) + 0x1) file_size_remaining = file_size - file_fragment_cnt * page_size if file_size_remaining > 0: cur_vtl_start_address = vtl_start_address + file_fragment_cnt * page_size cur_vtl_end_address = vtl_end_address if file_fragment_cnt == 0: while True: try: execution_state.getMemoryService().dump(file, format, cur_vtl_start_address, cur_vtl_end_address) break # jump out of the while-loop except DebugException, e: mmu.init_page_table() force_loading.force_loading(cur_vtl_start_address, (cur_vtl_end_address - cur_vtl_start_address) + 0x1) else: while True: try: execution_state.getMemoryService().append(file, format, cur_vtl_start_address, cur_vtl_end_address) break # jump out of the while-loop except DebugException, e: mmu.init_page_table() force_loading.force_loading(cur_vtl_start_address, (cur_vtl_end_address - cur_vtl_start_address) + 0x1) # char array -> string def retrieve_char_array(vtl): char_array = "" char_offset = vtl single_char = readMemory8(char_offset)