about summary refs log tree commit diff stats
path: root/miasm/tools
diff options
context:
space:
mode:
Diffstat (limited to 'miasm/tools')
-rw-r--r--miasm/tools/emul_lib/libcodenat.c4
-rw-r--r--miasm/tools/emul_lib/libcodenat_interface.c2
-rw-r--r--miasm/tools/to_c_helper.py9
3 files changed, 9 insertions, 6 deletions
diff --git a/miasm/tools/emul_lib/libcodenat.c b/miasm/tools/emul_lib/libcodenat.c
index 1ceb8712..97dedd7a 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("cannot find address!! %"PRIX64"\n", ad);
+	printf("ERROR: address 0x%"PRIX64" is not mapped in virtual memory:\n", ad);
 	dump_memory_page_pool();
 	dump_gpregs();
 	//exit(-1);
@@ -98,7 +98,7 @@ struct memory_page_node * get_memory_page_from_address(uint64_t ad)
 		if ((mpn->ad <= ad) && (ad < mpn->ad + mpn->size))
 			return mpn;
 	}
-	printf("cannot find address!! %X\n", ad);
+	printf("address %"PRIX64" is not mapped in virtual memory \n", ad);
 	dump_memory_page_pool();
 	dump_gpregs();
 	//exit(-1);
diff --git a/miasm/tools/emul_lib/libcodenat_interface.c b/miasm/tools/emul_lib/libcodenat_interface.c
index 5482d931..56284aa2 100644
--- a/miasm/tools/emul_lib/libcodenat_interface.c
+++ b/miasm/tools/emul_lib/libcodenat_interface.c
@@ -467,7 +467,7 @@ PyObject* _vm_get_str(PyObject *addr, PyObject *item_len)
     while (my_size){
 	    mpn = get_memory_page_from_address(buf_addr);
 	    if (!mpn){
-		    printf("cannot find page off %X\n", buf_addr);
+		    PyErr_SetString(PyExc_RuntimeError, "cannot find address");
 		    return 0;
 	    }
 
diff --git a/miasm/tools/to_c_helper.py b/miasm/tools/to_c_helper.py
index be19ee8c..9bbda006 100644
--- a/miasm/tools/to_c_helper.py
+++ b/miasm/tools/to_c_helper.py
@@ -598,9 +598,12 @@ 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)
-        
-    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)
+    
+    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))
 
     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)