summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/analysis/db
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-09-11 21:25:13 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-09-11 21:25:13 (GMT)
commit83faef9c8f78b20cb031af686f763cfb215cf9d7 (patch)
treeea95f741855044f4473573726804c6c2bcac5db1 /plugins/pychrysalide/analysis/db
parent3e1347d378e7ff0e21fb53b61e0317b8dfe52fc9 (diff)
Reactivated bookmarks for disassembled code.
Diffstat (limited to 'plugins/pychrysalide/analysis/db')
-rw-r--r--plugins/pychrysalide/analysis/db/constants.c38
-rw-r--r--plugins/pychrysalide/analysis/db/constants.h3
-rw-r--r--plugins/pychrysalide/analysis/db/item.c137
-rw-r--r--plugins/pychrysalide/analysis/db/items/bookmark.c7
4 files changed, 182 insertions, 3 deletions
diff --git a/plugins/pychrysalide/analysis/db/constants.c b/plugins/pychrysalide/analysis/db/constants.c
index 9685ba6..fb30c7e 100644
--- a/plugins/pychrysalide/analysis/db/constants.c
+++ b/plugins/pychrysalide/analysis/db/constants.c
@@ -25,6 +25,7 @@
#include "constants.h"
+#include <analysis/db/item.h>
#include <analysis/db/server.h>
@@ -36,6 +37,43 @@
* *
* Paramètres : type = type dont le dictionnaire est à compléter. *
* *
+* Description : Définit les constantes pour les éléments de base de données. *
+* *
+* Retour : true en cas de succès de l'opération, false sinon. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool define_db_item_constants(PyTypeObject *type)
+{
+ bool result; /* Bilan à retourner */
+ PyObject *values; /* Groupe de valeurs à établir */
+
+ values = PyDict_New();
+
+ result = add_const_to_group(values, "NONE", DIF_NONE);
+ if (result) result = add_const_to_group(values, "ERASER", DIF_ERASER);
+
+ if (!result)
+ {
+ Py_DECREF(values);
+ goto exit;
+ }
+
+ result = attach_constants_group(type, true, "DbItemFlags", values, "Properties of a database item.");
+
+ exit:
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : type = type dont le dictionnaire est à compléter. *
+* *
* Description : Définit les constantes pour les serveurs de données. *
* *
* Retour : true en cas de succès de l'opération, false sinon. *
diff --git a/plugins/pychrysalide/analysis/db/constants.h b/plugins/pychrysalide/analysis/db/constants.h
index a2fc49e..cb7edf4 100644
--- a/plugins/pychrysalide/analysis/db/constants.h
+++ b/plugins/pychrysalide/analysis/db/constants.h
@@ -31,6 +31,9 @@
+/* Définit les constantes pour les éléments de base de données. */
+bool define_db_item_constants(PyTypeObject *);
+
/* Définit les constantes pour les serveurs de données. */
bool define_hub_server_constants(PyTypeObject *);
diff --git a/plugins/pychrysalide/analysis/db/item.c b/plugins/pychrysalide/analysis/db/item.c
index 981e0c0..bbaa21b 100644
--- a/plugins/pychrysalide/analysis/db/item.c
+++ b/plugins/pychrysalide/analysis/db/item.c
@@ -32,17 +32,109 @@
#include <analysis/db/item.h>
+#include "constants.h"
#include "../../access.h"
#include "../../helpers.h"
+/* Ajoute une propriété à un élément de base de données. */
+static PyObject *py_db_item_add_flag(PyObject *, PyObject *);
+
+/* Retire une propriété à un élément de base de données. */
+static PyObject *py_db_item_remove_flag(PyObject *, PyObject *);
+
/* Indique si l'élément contient des données à oublier ou non. */
static PyObject *py_db_item_get_volatile(PyObject *, void *);
/* Définit si l'élément contient des données à oublier ou non. */
static int py_db_item_set_volatile(PyObject *, PyObject *, void *);
+/* Indique les propriétés particulières appliquées à l'élément. */
+static PyObject *py_db_item_get_flags(PyObject *, void *);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : self = serveur à manipuler. *
+* args = arguments d'appel non utilisés ici. *
+* *
+* Description : Ajoute une propriété à un élément de base de données. *
+* *
+* Retour : None. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_db_item_add_flag(PyObject *self, PyObject *args)
+{
+ unsigned int flag; /* Propriété à traiter */
+ int ret; /* Bilan de lecture des args. */
+ GDbItem *item; /* Elément à manipuler */
+
+#define DB_ITEM_ADD_FLAG_METHOD PYTHON_METHOD_DEF \
+( \
+ add_flag, "$self, flag, /", \
+ METH_VARARGS, py_db_item, \
+ "Add a property to a database item." \
+ "\n" \
+ "This property is one of the values listed in the" \
+ " of pychrysalide.analysis.db.DbItem.DbItemFlags enumeration." \
+)
+
+ ret = PyArg_ParseTuple(args, "I", &flag);
+ if (!ret) return NULL;
+
+ item = G_DB_ITEM(pygobject_get(self));
+
+ g_db_item_add_flag(item, flag);
+
+ Py_RETURN_NONE;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = serveur à manipuler. *
+* args = arguments d'appel non utilisés ici. *
+* *
+* Description : Retire une propriété à un élément de base de données. *
+* *
+* Retour : None. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_db_item_remove_flag(PyObject *self, PyObject *args)
+{
+ unsigned int flag; /* Propriété à traiter */
+ int ret; /* Bilan de lecture des args. */
+ GDbItem *item; /* Elément à manipuler */
+
+#define DB_ITEM_REMOVE_FLAG_METHOD PYTHON_METHOD_DEF \
+( \
+ remove_flag, "$self, flag, /", \
+ METH_VARARGS, py_db_item, \
+ "Remove a property from a database item." \
+ "\n" \
+ "This property is one of the values listed in the" \
+ " of pychrysalide.analysis.db.DbItem.DbItemFlags enumeration." \
+)
+
+ ret = PyArg_ParseTuple(args, "I", &flag);
+ if (!ret) return NULL;
+
+ item = G_DB_ITEM(pygobject_get(self));
+
+ g_db_item_remove_flag(item, flag);
+
+ Py_RETURN_NONE;
+
+}
/******************************************************************************
@@ -107,6 +199,43 @@ static int py_db_item_set_volatile(PyObject *self, PyObject *value, void *closur
/******************************************************************************
* *
+* Paramètres : self = objet Python concerné par l'appel. *
+* closure = non utilisé ici. *
+* *
+* Description : Indique les propriétés particulières appliquées à l'élément. *
+* *
+* Retour : Propriétés actives de l'élément. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_db_item_get_flags(PyObject *self, void *closure)
+{
+ PyObject *result; /* Valeur à retourner */
+ GDbItem *item; /* Elément à consulter */
+ DbItemFlags flags; /* Propriétés de l'élément */
+
+#define DB_ITEM_FLAGS_ATTRIB PYTHON_GET_DEF_FULL \
+( \
+ flags, py_db_item, \
+ "Properties of the database item, provided as a mask" \
+ " of pychrysalide.analysis.db.DbItem.DbItemFlags values." \
+)
+
+ item = G_DB_ITEM(pygobject_get(self));
+
+ flags = g_db_item_get_flags(item);
+
+ result = cast_with_constants_group(get_python_db_item_type(), "DbItemFlags", flags);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : - *
* *
* Description : Fournit un accès à une définition de type à diffuser. *
@@ -120,17 +249,18 @@ static int py_db_item_set_volatile(PyObject *self, PyObject *value, void *closur
PyTypeObject *get_python_db_item_type(void)
{
static PyMethodDef py_db_item_methods[] = {
+ DB_ITEM_ADD_FLAG_METHOD,
+ DB_ITEM_REMOVE_FLAG_METHOD,
{ NULL }
};
static PyGetSetDef py_db_item_getseters[] = {
-
{
"volatile", py_db_item_get_volatile, py_db_item_set_volatile,
"Define if a Database item can be forgotten.", NULL
},
+ DB_ITEM_FLAGS_ATTRIB,
{ NULL }
-
};
static PyTypeObject py_db_item_type = {
@@ -183,6 +313,9 @@ bool ensure_python_db_item_is_registered(void)
if (!register_class_for_pygobject(dict, G_TYPE_DB_ITEM, type, &PyGObject_Type))
return false;
+ if (!define_db_item_constants(type))
+ return false;
+
}
return true;
diff --git a/plugins/pychrysalide/analysis/db/items/bookmark.c b/plugins/pychrysalide/analysis/db/items/bookmark.c
index 8a33357..783efa6 100644
--- a/plugins/pychrysalide/analysis/db/items/bookmark.c
+++ b/plugins/pychrysalide/analysis/db/items/bookmark.c
@@ -147,7 +147,12 @@ static int py_db_bookmark_init(PyObject *self, PyObject *args, PyObject *kwds)
" DbBookmark(addr, comment=None)" \
"\n" \
"Where addr is a location of type pychrysalide.arch.vmpa and" \
- " comment is a string or None."
+ " comment is a string or None.\n" \
+ "\n" \
+ "An empty comment is not enough to delete a bookmark for a given address;" \
+ " the *ERASER* flag from the pychrysalide.analysis.db.DbItem.DbItemFlags" \
+ " enumeration must be explicitly add to the item by a call to the" \
+ " pychrysalide.analysis.db.DbItem.add_flag() function."
result = -1;