about summary refs log tree commit diff stats
path: root/miasm/tools/emul_lib/libcodenat_interface.c
diff options
context:
space:
mode:
authorserpilliere <devnull@localhost>2011-12-23 11:11:03 +0100
committerserpilliere <devnull@localhost>2011-12-23 11:11:03 +0100
commit18f20b328a4b72cfd80f8b0e64771ee032e8674e (patch)
treef6b4fb61d4c66c10a225b12365f87a31ef7a241d /miasm/tools/emul_lib/libcodenat_interface.c
parent880a2ead19d69a8dacfd88c00fd9d5f75dea3abf (diff)
downloadmiasm-18f20b328a4b72cfd80f8b0e64771ee032e8674e.tar.gz
miasm-18f20b328a4b72cfd80f8b0e64771ee032e8674e.zip
fix 16 bit bug
Diffstat (limited to '')
-rw-r--r--miasm/tools/emul_lib/libcodenat_interface.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/miasm/tools/emul_lib/libcodenat_interface.c b/miasm/tools/emul_lib/libcodenat_interface.c
index d43401dd..7348ff00 100644
--- a/miasm/tools/emul_lib/libcodenat_interface.c
+++ b/miasm/tools/emul_lib/libcodenat_interface.c
@@ -582,6 +582,26 @@ PyObject* _vm_pop_uint32_t(void)
     return PyInt_FromLong((long)val);;
 }
 
+PyObject* _vm_push_uint16_t(int val)
+{
+    vmcpu.esp-=2;
+    MEM_WRITE(16, vmcpu.esp, val);
+
+    return PyInt_FromLong((long)vmcpu.esp);
+}
+
+
+PyObject* _vm_pop_uint16_t(void)
+{
+    unsigned int val;
+
+    val = MEM_LOOKUP(16, vmcpu.esp);
+    vmcpu.esp+=2;
+
+    return PyInt_FromLong((long)val);;
+}
+
+
 PyObject* _vm_set_mem(PyObject *addr, PyObject *item_str)
 {
     unsigned int buf_size;
@@ -770,6 +790,24 @@ PyObject* vm_pop_uint32_t(PyObject* self, PyObject* args)
     return p;
 }
 
+PyObject* vm_push_uint16_t(PyObject* self, PyObject *args)
+{
+    PyObject* p;
+    int item;
+    if (!PyArg_ParseTuple(args, "I", &item))
+	    return NULL;
+    p = _vm_push_uint16_t(item);
+    return p;
+}
+
+
+PyObject* vm_pop_uint16_t(PyObject* self, PyObject* args)
+{
+    PyObject* p;
+    p = _vm_pop_uint16_t();
+    return p;
+}
+
 PyObject* vm_set_mem(PyObject* self, PyObject* args)
 {
     PyObject* p;
@@ -1248,6 +1286,10 @@ static PyMethodDef CodenatMethods[] = {
      "x"},
     {"vm_pop_uint32_t",vm_pop_uint32_t, METH_VARARGS,
      "X"},
+    {"vm_push_uint16_t", vm_push_uint16_t, METH_VARARGS,
+     "x"},
+    {"vm_pop_uint16_t",vm_pop_uint16_t, METH_VARARGS,
+     "X"},
     {"vm_get_gpreg", vm_get_gpreg, METH_VARARGS,
      "X"},
     {"vm_set_gpreg",vm_set_gpreg, METH_VARARGS,