summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/arch
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-11-26 18:16:01 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-11-26 18:16:01 (GMT)
commita5974124ce05dc7ee58a4e80809aa5e090692758 (patch)
treee786489ceb3e8a31c63d85906fb8e9678242e21c /plugins/pychrysalide/arch
parentcb07198d95b9fa84474f624af0eda8ae97960a70 (diff)
Updated the Python bindings printing memory ranges.
Diffstat (limited to 'plugins/pychrysalide/arch')
-rw-r--r--plugins/pychrysalide/arch/vmpa.c57
1 files changed, 43 insertions, 14 deletions
diff --git a/plugins/pychrysalide/arch/vmpa.c b/plugins/pychrysalide/arch/vmpa.c
index c226224..abca73f 100644
--- a/plugins/pychrysalide/arch/vmpa.c
+++ b/plugins/pychrysalide/arch/vmpa.c
@@ -165,29 +165,27 @@ static PyObject *py_vmpa_to_str(PyObject *obj)
PyObject *result; /* Chaîne à retourner */
vmpa2t *addr; /* Véritable adresse manipulée */
phys_t physical; /* Position physique */
- virt_t virtual; /* Adresse virtuelle */
VMPA_BUFFER(phys_str); /* Version humaine de position */
+ virt_t virtual; /* Adresse virtuelle */
VMPA_BUFFER(virt_str); /* Version humaine d'adresse */
addr = &((py_vmpa_t *)obj)->addr;
physical = get_phy_addr(addr);
- virtual = get_virt_addr(addr);
-
- vmpa2_phys_to_string(addr, MDS_UNDEFINED, phys_str, NULL);
- vmpa2_virt_to_string(addr, MDS_UNDEFINED, virt_str, NULL);
- if (physical == VMPA_NO_PHYSICAL && virtual == VMPA_NO_VIRTUAL)
- result = PyUnicode_FromFormat("<phy=None, virt=None>");
-
- else if (physical != VMPA_NO_PHYSICAL && virtual == VMPA_NO_VIRTUAL)
- result = PyUnicode_FromFormat("<phy=%s, virt=None>", phys_str);
+ if (physical == VMPA_NO_PHYSICAL)
+ strncpy(phys_str, _("None"), sizeof(phys_str) - 1);
+ else
+ vmpa2_phys_to_string(addr, MDS_UNDEFINED, phys_str, NULL);
- else if (physical == VMPA_NO_PHYSICAL && virtual != VMPA_NO_VIRTUAL)
- result = PyUnicode_FromFormat("<phy=None, virt=%s>", virt_str);
+ virtual = get_virt_addr(addr);
+ if (virtual == VMPA_NO_VIRTUAL)
+ strncpy(virt_str, _("None"), sizeof(virt_str) - 1);
else
- result = PyUnicode_FromFormat("<phy=%s, virt=%s>", phys_str, virt_str);
+ vmpa2_virt_to_string(addr, MDS_UNDEFINED, virt_str, NULL);
+
+ result = PyUnicode_FromFormat("<phy=%s, virt=%s>", phys_str, virt_str);
return result;
@@ -838,8 +836,39 @@ int convert_any_to_vmpa(PyObject *arg, void *dst)
static PyObject *py_mrange_to_str(PyObject *obj)
{
PyObject *result; /* Chaîne à retourner */
+ mrange_t *range; /* Espace mémoire à traiter */
+ vmpa2t *addr; /* Véritable adresse manipulée */
+ phys_t physical; /* Position physique */
+ VMPA_BUFFER(phys_str); /* Version humaine de position */
+ virt_t virtual; /* Adresse virtuelle */
+ VMPA_BUFFER(virt_str); /* Version humaine d'adresse */
+ vmpa2t length; /* Fausse taille physique */
+ VMPA_BUFFER(len_str); /* Version humaine de longueur */
+
+ range = get_internal_mrange(obj);
+ assert(range != NULL);
+
+ addr = get_mrange_addr(range);
+
+ physical = get_phy_addr(addr);
+
+ if (physical == VMPA_NO_PHYSICAL)
+ strncpy(phys_str, _("None"), sizeof(phys_str) - 1);
+ else
+ vmpa2_phys_to_string(addr, MDS_UNDEFINED, phys_str, NULL);
+
+ virtual = get_virt_addr(addr);
+
+ if (virtual == VMPA_NO_VIRTUAL)
+ strncpy(virt_str, _("None"), sizeof(virt_str) - 1);
+ else
+ vmpa2_virt_to_string(addr, MDS_UNDEFINED, virt_str, NULL);
+
+ init_vmpa(&length, get_mrange_length(range), VMPA_NO_VIRTUAL);
+
+ vmpa2_phys_to_string(&length, MDS_UNDEFINED, len_str, NULL);
- result = PyUnicode_FromFormat("<TODO!>");
+ result = PyUnicode_FromFormat("(<phy=%s, virt=%s>, +%s)", phys_str, virt_str, len_str);
return result;