summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/format
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide/format')
-rw-r--r--plugins/pychrysalide/format/Makefile.am1
-rw-r--r--plugins/pychrysalide/format/constants.c71
-rw-r--r--plugins/pychrysalide/format/constants.h39
-rw-r--r--plugins/pychrysalide/format/symbol.c17
4 files changed, 123 insertions, 5 deletions
diff --git a/plugins/pychrysalide/format/Makefile.am b/plugins/pychrysalide/format/Makefile.am
index 6d50da7..24890ec 100644
--- a/plugins/pychrysalide/format/Makefile.am
+++ b/plugins/pychrysalide/format/Makefile.am
@@ -2,6 +2,7 @@
noinst_LTLIBRARIES = libpychrysaformat.la
libpychrysaformat_la_SOURCES = \
+ constants.h constants.c \
executable.h executable.c \
flat.h flat.c \
format.h format.c \
diff --git a/plugins/pychrysalide/format/constants.c b/plugins/pychrysalide/format/constants.c
new file mode 100644
index 0000000..9e63fdd
--- /dev/null
+++ b/plugins/pychrysalide/format/constants.c
@@ -0,0 +1,71 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * constants.c - équivalent Python partiel du fichier "plugins/dex/dex_def.h"
+ *
+ * Copyright (C) 2018 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "constants.h"
+
+
+#include <format/symbol.h>
+
+
+#include "../helpers.h"
+
+
+
+/******************************************************************************
+* *
+* Paramètres : type = type dont le dictionnaire est à compléter. *
+* *
+* Description : Définit les constantes pour le format Dex. *
+* *
+* Retour : true en cas de succès de l'opération, false sinon. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool define_binary_symbol_constants(PyTypeObject *type)
+{
+ bool result; /* Bilan à retourner */
+ PyObject *values; /* Groupe de valeurs à établir */
+
+ values = PyDict_New();
+
+ result = add_const_to_group(values, "INTERNAL", SSS_INTERNAL);
+ if (result) result = add_const_to_group(values, "EXPORTED", SSS_EXPORTED);
+ if (result) result = add_const_to_group(values, "IMPORTED", SSS_IMPORTED);
+ if (result) result = add_const_to_group(values, "DYNAMIC", SSS_DYNAMIC);
+
+ if (!result)
+ {
+ Py_DECREF(values);
+ goto exit;
+ }
+
+ result = attach_constants_group(type, false, "SymbolStatus", values, "Status of a symbol visibility.");
+
+ exit:
+
+ return result;
+
+}
diff --git a/plugins/pychrysalide/format/constants.h b/plugins/pychrysalide/format/constants.h
new file mode 100644
index 0000000..6515f35
--- /dev/null
+++ b/plugins/pychrysalide/format/constants.h
@@ -0,0 +1,39 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * constants.h - prototypes pour l'ajout des constantes liées aux formats
+ *
+ * Copyright (C) 2019 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _PLUGINS_PYCHRYSALIDE_FORMAT_CONSTANTS_H
+#define _PLUGINS_PYCHRYSALIDE_FORMAT_CONSTANTS_H
+
+
+#include <Python.h>
+#include <stdbool.h>
+
+
+
+/* Définit les constantes pour les symboles binaires. */
+bool define_binary_symbol_constants(PyTypeObject *);
+
+
+
+#endif /* _PLUGINS_PYCHRYSALIDE_FORMAT_CONSTANTS_H */
diff --git a/plugins/pychrysalide/format/symbol.c b/plugins/pychrysalide/format/symbol.c
index 3295e8c..af03473 100644
--- a/plugins/pychrysalide/format/symbol.c
+++ b/plugins/pychrysalide/format/symbol.c
@@ -36,6 +36,7 @@
#include <format/symbol.h>
+#include "constants.h"
#include "../access.h"
#include "../helpers.h"
#include "../analysis/routine.h"
@@ -349,10 +350,16 @@ static PyObject *py_binary_symbol_get_status(PyObject *self, void *closure)
GBinSymbol *symbol; /* Elément à consulter */
SymbolStatus status; /* Visibilité du symbole fourni*/
+#define BINARY_SYMBOL_STATUS_ATTRIB PYTHON_GET_DEF_FULL \
+( \
+ status, py_binary_symbol, \
+ "Status of the symbol's visibility." \
+)
+
symbol = G_BIN_SYMBOL(pygobject_get(self));
status = g_binary_symbol_get_status(symbol);
- result = PyLong_FromLong(status);
+ result = cast_with_constants_group(get_python_binary_symbol_type(), "SymbolStatus", status);
return result;
@@ -432,10 +439,7 @@ PyTypeObject *get_python_binary_symbol_type(void)
"range", py_binary_symbol_get_range, py_binary_symbol_set_range,
"Range covered by the symbol.", NULL
},
- {
- "status", py_binary_symbol_get_status, NULL,
- "Status of the symbol's visibility.", NULL
- },
+ BINARY_SYMBOL_STATUS_ATTRIB,
{ NULL }
};
@@ -498,6 +502,9 @@ bool ensure_python_binary_symbol_is_registered(void)
if (!py_binary_symbol_define_constants(type))
return false;
+ if (!define_binary_symbol_constants(type))
+ return false;
+
}
return true;