about summary refs log tree commit diff stats
path: root/miasm2/jitter/vm_mngr_py.c
diff options
context:
space:
mode:
authorajax <devnull@localhost>2014-06-16 17:29:41 +0200
committerajax <devnull@localhost>2014-06-16 17:29:41 +0200
commite21a663409b525fe4c720717a3681ba88795556e (patch)
tree19f45ff6bdcfcdf9d9299f64f990291ec0a1b0ce /miasm2/jitter/vm_mngr_py.c
parentc7165bd6bc403676d5fb6d1822776b69f0b1217e (diff)
downloadmiasm-e21a663409b525fe4c720717a3681ba88795556e.tar.gz
miasm-e21a663409b525fe4c720717a3681ba88795556e.zip
Jitter: VmMngr: Avoid code duplication && set exceptions flags on "vm_set_mem"
Diffstat (limited to 'miasm2/jitter/vm_mngr_py.c')
-rw-r--r--miasm2/jitter/vm_mngr_py.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/miasm2/jitter/vm_mngr_py.c b/miasm2/jitter/vm_mngr_py.c
index a99890fd..19686930 100644
--- a/miasm2/jitter/vm_mngr_py.c
+++ b/miasm2/jitter/vm_mngr_py.c
@@ -163,9 +163,6 @@ PyObject* vm_set_mem(VmMngr* self, PyObject* args)
 	Py_ssize_t length;
 	int ret = 0x1337;
 	uint64_t val;
-	uint64_t l;
-
-	struct memory_page_node * mpn;
 
 	if (!PyArg_ParseTuple(args, "OO", &addr, &item_str))
 		return NULL;
@@ -178,18 +175,12 @@ PyObject* vm_set_mem(VmMngr* self, PyObject* args)
 	buf_size = PyString_Size(item_str);
 	PyString_AsStringAndSize(item_str, &buf_data, &length);
 
-	/* read is multiple page wide */
+	/* write is multiple page wide */
 	while (buf_size){
-		mpn = get_memory_page_from_address(&self->vm_mngr, val);
-		if (!mpn){
-			PyErr_SetString(PyExc_RuntimeError, "cannot find address");
-			return 0;
-		}
-		l = MIN(buf_size, mpn->size - (val-mpn->ad));
-		memcpy(mpn->ad_hp + (val-mpn->ad), buf_data, l);
-		buf_data += l;
-		val += l;
-		buf_size -= l;
+		MEM_WRITE_08(&self->vm_mngr, val, (char) *(buf_data));
+		buf_data += 1;
+		val += 1;
+		buf_size -= 1;
 	}
 
 	return PyLong_FromUnsignedLongLong((uint64_t)ret);