diff options
| -rwxr-xr-x | example/emulx86_bin.py | 4 | ||||
| -rw-r--r-- | example/sandbox_elf.py | 1 | ||||
| -rw-r--r-- | example/sandbox_pe.py | 2 | ||||
| -rw-r--r-- | miasm/core/asmbloc.py | 10 | ||||
| -rw-r--r-- | miasm/tools/emul_lib/libcodenat.c | 2 | ||||
| -rw-r--r-- | miasm/tools/to_c_helper.py | 14 |
6 files changed, 20 insertions, 13 deletions
diff --git a/example/emulx86_bin.py b/example/emulx86_bin.py index 151370b4..eab57408 100755 --- a/example/emulx86_bin.py +++ b/example/emulx86_bin.py @@ -13,6 +13,9 @@ import sys if len(sys.argv) <3: print 'usage:' print "%s rawfile address_to_exec"%sys.argv[0] + print 'exemple:' + print "%s x86_sc.bin 0"%sys.argv[0] + sys.exit(0) data = open(sys.argv[1], 'rb').read() ad = sys.argv[2].lower() @@ -58,6 +61,7 @@ def run_bin(my_eip, known_blocs, code_blocs_mem_range): if not my_eip in known_blocs: updt_bloc_emul(known_blocs, in_str, my_eip, symbol_pool, code_blocs_mem_range, log_regs = log_regs, log_mn = log_mn) + vm_reset_exception() try: my_eip = vm_exec_blocs(my_eip, known_blocs) except KeyboardInterrupt: diff --git a/example/sandbox_elf.py b/example/sandbox_elf.py index 7550cb20..f8e308e2 100644 --- a/example/sandbox_elf.py +++ b/example/sandbox_elf.py @@ -96,6 +96,7 @@ def run_bin(my_eip, known_blocs, code_blocs_mem_range): last_blocs.pop(0) last_blocs.append(my_eip) updt_bloc_emul(known_blocs, in_str, my_eip, symbol_pool, code_blocs_mem_range, log_regs = log_regs, log_mn = log_mn) + vm_reset_exception() try: diff --git a/example/sandbox_pe.py b/example/sandbox_pe.py index 4c1e9b17..75e9b306 100644 --- a/example/sandbox_pe.py +++ b/example/sandbox_pe.py @@ -106,6 +106,8 @@ def run_bin(my_eip, known_blocs, code_blocs_mem_range): if not my_eip in known_blocs: updt_bloc_emul(known_blocs, in_str, my_eip, symbol_pool, code_blocs_mem_range, log_regs = log_regs, log_mn = log_mn) + vm_reset_exception() + try: my_eip = vm_exec_blocs(my_eip, known_blocs) except KeyboardInterrupt: diff --git a/miasm/core/asmbloc.py b/miasm/core/asmbloc.py index bdbd2f8e..f8846801 100644 --- a/miasm/core/asmbloc.py +++ b/miasm/core/asmbloc.py @@ -248,11 +248,13 @@ def dis_bloc(mnemo, pool_bin, cur_bloc, offset, job_done, symbol_pool, dont_dis log_asmbloc.warning( "bloc start with nul %X"%int(off_i)) break - instr = mnemo.dis(pool_bin, amode, sex) - - + try: + instr = mnemo.dis(pool_bin, amode, sex) + except: + instr = None + if instr == None: - log_asmbloc.warning( "cannot disasm at %X"%int(offset)) + log_asmbloc.warning( "cannot disasm at %X"%int(pool_bin.offset)) cur_bloc.bto = [] offsets_to_dis = [] break diff --git a/miasm/tools/emul_lib/libcodenat.c b/miasm/tools/emul_lib/libcodenat.c index 97dedd7a..2799c4e4 100644 --- a/miasm/tools/emul_lib/libcodenat.c +++ b/miasm/tools/emul_lib/libcodenat.c @@ -84,7 +84,7 @@ struct memory_page_node * get_memory_page_from_address(uint64_t ad) if ( mpn && (mpn->ad <= ad) && (ad < mpn->ad + mpn->size)) return mpn; - printf("ERROR: address 0x%"PRIX64" is not mapped in virtual memory:\n", ad); + printf("WARNING: address 0x%"PRIX64" is not mapped in virtual memory:\n", ad); dump_memory_page_pool(); dump_gpregs(); //exit(-1); diff --git a/miasm/tools/to_c_helper.py b/miasm/tools/to_c_helper.py index 9bbda006..df579749 100644 --- a/miasm/tools/to_c_helper.py +++ b/miasm/tools/to_c_helper.py @@ -598,13 +598,8 @@ def gen_C_from_asmbloc(in_str, offset, symbol_pool, dont_dis = [], job_done = No f_name = "bloc_%.16X"%(offset&mask_int) l = symbol_pool.getby_offset_create(offset) cur_bloc = asmbloc.asm_bloc(l) - - try: - asmbloc.dis_bloc(x86_mn, in_str, cur_bloc, offset, job_done, symbol_pool,[], - follow_call = False, patch_instr_symb = True, dontdis_retcall = False,lines_wd = None, amode=x86_afs.u32, sex=0) - except: - raise ValueError('cannot disasm at', hex(offset)) - + asmbloc.dis_bloc(x86_mn, in_str, cur_bloc, offset, job_done, symbol_pool,[], + follow_call = False, patch_instr_symb = True, dontdis_retcall = False,lines_wd = None, amode=x86_afs.u32, sex=0) f_dec, out = bloc_gen_C_func([cur_bloc], f_name, None, True, log_mn, log_reg, log_lbl, filtered_ad, tick_dbg) #print "\n".join(out) return f_name, f_dec, out, cur_bloc @@ -965,7 +960,10 @@ class bin_stream_vm(): self.offset = offset def readbs(self, l=1): - s = vm_get_str(self.offset, l) + try: + s = vm_get_str(self.offset, l) + except: + raise IOError('cannot get mem ad', hex(self.offset)) self.offset+=l return s |