about summary refs log tree commit diff stats
path: root/miasm2/jitter/vm_mngr_py.c
diff options
context:
space:
mode:
authorserpilliere <devnull@localhost>2014-06-17 13:09:31 +0200
committerserpilliere <devnull@localhost>2014-06-17 13:09:31 +0200
commit180b3907cdfcda2e8f3bd719b1d3531ba2e32a5f (patch)
treec91a5e6564ac6579f0a97d9a913540708464f8c3 /miasm2/jitter/vm_mngr_py.c
parent1a1f8fb1bf35def45e651452eb5db27d36486dda (diff)
parentb4672a0881de3a62d6ea711603870db9a28f6cce (diff)
downloadmiasm-180b3907cdfcda2e8f3bd719b1d3531ba2e32a5f.tar.gz
miasm-180b3907cdfcda2e8f3bd719b1d3531ba2e32a5f.zip
merge
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);