summaryrefslogtreecommitdiff
path: root/plugins/pychrysa
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-12-30 10:38:52 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-12-30 10:38:52 (GMT)
commit932ea7c83c07d3982fee605c6dd9895fd2753874 (patch)
tree766ad53bab9e3e3005334c30e823493de8e84168 /plugins/pychrysa
parent1b5d39bfbc48c33a0ea0924b60e48448c8b45dd4 (diff)
Rewritten the line buffers using generators and on-demand building to save memory.
Diffstat (limited to 'plugins/pychrysa')
-rw-r--r--plugins/pychrysa/analysis/binary.c16
-rw-r--r--plugins/pychrysa/glibext/Makefile.am2
-rw-r--r--plugins/pychrysa/glibext/buffercache.c (renamed from plugins/pychrysa/glibext/codebuffer.c)40
-rw-r--r--plugins/pychrysa/glibext/buffercache.h (renamed from plugins/pychrysa/glibext/codebuffer.h)12
-rw-r--r--plugins/pychrysa/glibext/module.c4
-rw-r--r--plugins/pychrysa/gtkext/Makefile.am4
-rw-r--r--plugins/pychrysa/gtkext/blockdisplay.c (renamed from plugins/pychrysa/gtkext/blockview.c)37
-rw-r--r--plugins/pychrysa/gtkext/blockdisplay.h (renamed from plugins/pychrysa/gtkext/bufferview.h)14
-rw-r--r--plugins/pychrysa/gtkext/bufferdisplay.c (renamed from plugins/pychrysa/gtkext/bufferview.c)35
-rw-r--r--plugins/pychrysa/gtkext/bufferdisplay.h (renamed from plugins/pychrysa/gtkext/blockview.h)14
-rw-r--r--plugins/pychrysa/gtkext/module.c8
11 files changed, 97 insertions, 89 deletions
diff --git a/plugins/pychrysa/analysis/binary.c b/plugins/pychrysa/analysis/binary.c
index 32e4a71..5b857d5 100644
--- a/plugins/pychrysa/analysis/binary.c
+++ b/plugins/pychrysa/analysis/binary.c
@@ -55,7 +55,7 @@ static PyObject *py_loaded_binary_get_format(PyObject *, void *);
static PyObject *py_loaded_binary_get_processor(PyObject *, void *);
/* Fournit le tampon associé au contenu assembleur d'un binaire. */
-static PyObject *py_loaded_binary_get_disassembled_buffer(PyObject *, void *);
+static PyObject *py_loaded_binary_get_disassembled_cache(PyObject *, void *);
@@ -234,16 +234,18 @@ static PyObject *py_loaded_binary_get_processor(PyObject *self, void *closure)
* *
******************************************************************************/
-static PyObject *py_loaded_binary_get_disassembled_buffer(PyObject *self, void *closure)
+static PyObject *py_loaded_binary_get_disassembled_cache(PyObject *self, void *closure)
{
PyObject *result; /* Trouvailles à retourner */
GLoadedBinary *binary; /* Version native */
- GCodeBuffer *buffer; /* Tampon à récupérer */
+ GBufferCache *cache; /* Tampon à récupérer */
binary = G_LOADED_BINARY(pygobject_get(self));
- buffer = g_loaded_binary_get_disassembled_buffer(binary);
+ cache = g_loaded_binary_get_disassembled_cache(binary);
- result = pygobject_new(G_OBJECT(buffer));
+ result = pygobject_new(G_OBJECT(cache));
+
+ g_object_unref(G_OBJECT(cache));
return result;
@@ -288,8 +290,8 @@ PyTypeObject *get_python_loaded_binary_type(void)
"Handler for the current binary processor.", NULL
},
{
- "disassembled_buffer", py_loaded_binary_get_disassembled_buffer, NULL,
- "Disassembled code buffer.", NULL
+ "disassembled_cache", py_loaded_binary_get_disassembled_cache, NULL,
+ "Disassembled buffer cache.", NULL
},
{ NULL }
};
diff --git a/plugins/pychrysa/glibext/Makefile.am b/plugins/pychrysa/glibext/Makefile.am
index 74def8a..b53f4b0 100644
--- a/plugins/pychrysa/glibext/Makefile.am
+++ b/plugins/pychrysa/glibext/Makefile.am
@@ -2,8 +2,8 @@
noinst_LTLIBRARIES = libpychrysaglibext.la
libpychrysaglibext_la_SOURCES = \
+ buffercache.h buffercache.c \
bufferline.h bufferline.c \
- codebuffer.h codebuffer.c \
configuration.h configuration.c \
module.h module.c
diff --git a/plugins/pychrysa/glibext/codebuffer.c b/plugins/pychrysa/glibext/buffercache.c
index 7ca9435..c79fda2 100644
--- a/plugins/pychrysa/glibext/codebuffer.c
+++ b/plugins/pychrysa/glibext/buffercache.c
@@ -1,6 +1,6 @@
/* Chrysalide - Outil d'analyse de fichiers binaires
- * codebuffer.c - équivalent Python du fichier "glibext/gcodebuffer.h"
+ * buffercache.c - équivalent Python du fichier "glibext/gbuffercache.h"
*
* Copyright (C) 2012 Cyrille Bagard
*
@@ -22,13 +22,13 @@
*/
-#include "codebuffer.h"
+#include "buffercache.h"
#include <pygobject.h>
-#include <glibext/gcodebuffer.h>
+#include <glibext/gbuffercache.h>
#include "../arch/vmpa.h"
@@ -36,6 +36,7 @@
+#if 0
/* Retrouve une ligne au sein d'un tampon avec une adresse. */
static PyObject *py_code_buffer_find_line_by_addr(PyObject *, PyObject *);
@@ -60,7 +61,7 @@ static PyObject *py_code_buffer_find_line_by_addr(PyObject *self, PyObject *args
PyObject *py_vmpa; /* Localisation version Python */
int ret; /* Bilan de lecture des args. */
vmpa2t *addr; /* Adresse visée par l'opérat° */
- GCodeBuffer *buffer; /* Version native */
+ GBuffercache *buffer; /* Version native */
GBufferLine *line; /* Ligne trouvée */
ret = PyArg_ParseTuple(args, "O", &py_vmpa);
@@ -82,6 +83,7 @@ static PyObject *py_code_buffer_find_line_by_addr(PyObject *self, PyObject *args
return result;
}
+#endif
/******************************************************************************
@@ -96,38 +98,40 @@ static PyObject *py_code_buffer_find_line_by_addr(PyObject *self, PyObject *args
* *
******************************************************************************/
-PyTypeObject *get_python_code_buffer_type(void)
+PyTypeObject *get_python_buffer_cache_type(void)
{
- static PyMethodDef py_code_buffer_methods[] = {
+ static PyMethodDef py_buffer_cache_methods[] = {
+#if 0
{
- "find_line_by_addr", (PyCFunction)py_code_buffer_find_line_by_addr,
+ "find_line_by_addr", (PyCFunction)py_buffer_cache_find_line_by_addr,
METH_VARARGS,
"find_line_by_addr($self, addr, /)\n--\n\nFind a buffer line with a given address."
},
+#endif
{ NULL }
};
- static PyGetSetDef py_code_buffer_getseters[] = {
+ static PyGetSetDef py_buffer_cache_getseters[] = {
{ NULL }
};
- static PyTypeObject py_code_buffer_type = {
+ static PyTypeObject py_buffer_cache_type = {
PyVarObject_HEAD_INIT(NULL, 0)
- .tp_name = "pychrysalide.glibext.CodeBuffer",
+ .tp_name = "pychrysalide.glibext.Buffercache",
.tp_basicsize = sizeof(PyGObject),
.tp_flags = Py_TPFLAGS_DEFAULT,
.tp_doc = "PyChrysalide code buffer",
- .tp_methods = py_code_buffer_methods,
- .tp_getset = py_code_buffer_getseters,
+ .tp_methods = py_buffer_cache_methods,
+ .tp_getset = py_buffer_cache_getseters,
};
- return &py_code_buffer_type;
+ return &py_buffer_cache_type;
}
@@ -136,7 +140,7 @@ PyTypeObject *get_python_code_buffer_type(void)
* *
* Paramètres : module = module dont la définition est à compléter. *
* *
-* Description : Prend en charge l'objet 'pychrysalide.glibext.CodeBuffer'. *
+* Description : Prend en charge l'objet 'pychrysalide.glibext.BufferCache'. *
* *
* Retour : Bilan de l'opération. *
* *
@@ -144,16 +148,16 @@ PyTypeObject *get_python_code_buffer_type(void)
* *
******************************************************************************/
-bool register_python_code_buffer(PyObject *module)
+bool register_python_buffer_cache(PyObject *module)
{
- PyTypeObject *py_code_buffer_type; /* Type Python 'CodeBuffer' */
+ PyTypeObject *py_buffer_cache_type; /* Type Python 'BufferCache' */
PyObject *dict; /* Dictionnaire du module */
- py_code_buffer_type = get_python_code_buffer_type();
+ py_buffer_cache_type = get_python_buffer_cache_type();
dict = PyModule_GetDict(module);
- if (!register_class_for_pygobject(dict, G_TYPE_CODE_BUFFER, py_code_buffer_type, &PyGObject_Type))
+ if (!register_class_for_pygobject(dict, G_TYPE_BUFFER_CACHE, py_buffer_cache_type, &PyGObject_Type))
return false;
return true;
diff --git a/plugins/pychrysa/glibext/codebuffer.h b/plugins/pychrysa/glibext/buffercache.h
index e806e36..6476f5f 100644
--- a/plugins/pychrysa/glibext/codebuffer.h
+++ b/plugins/pychrysa/glibext/buffercache.h
@@ -1,6 +1,6 @@
/* Chrysalide - Outil d'analyse de fichiers binaires
- * codebuffer.h - prototypes pour l'équivalent Python du fichier "glibext/codebuffer.h"
+ * buffercache.h - prototypes pour l'équivalent Python du fichier "glibext/buffercache.h"
*
* Copyright (C) 2012 Cyrille Bagard
*
@@ -22,8 +22,8 @@
*/
-#ifndef _PLUGINS_PYCHRYSA_GLIBEXT_CODEBUFFER_H
-#define _PLUGINS_PYCHRYSA_GLIBEXT_CODEBUFFER_H
+#ifndef _PLUGINS_PYCHRYSA_GLIBEXT_BUFFERCACHE_H
+#define _PLUGINS_PYCHRYSA_GLIBEXT_BUFFERCACHE_H
#include <Python.h>
@@ -32,11 +32,11 @@
/* Fournit un accès à une définition de type à diffuser. */
-PyTypeObject *get_python_code_buffer_type(void);
+PyTypeObject *get_python_buffer_cache_type(void);
/* Prend en charge l'objet 'pychrysalide.glibext.CodeBuffer'. */
-bool register_python_code_buffer(PyObject *);
+bool register_python_buffer_cache(PyObject *);
-#endif /* _PLUGINS_PYCHRYSA_GLIBEXT_CODEBUFFER_H */
+#endif /* _PLUGINS_PYCHRYSA_GLIBEXT_BUFFERCACHE_H */
diff --git a/plugins/pychrysa/glibext/module.c b/plugins/pychrysa/glibext/module.c
index 2306c44..847e6d6 100644
--- a/plugins/pychrysa/glibext/module.c
+++ b/plugins/pychrysa/glibext/module.c
@@ -28,8 +28,8 @@
#include <assert.h>
+#include "buffercache.h"
#include "bufferline.h"
-#include "codebuffer.h"
#include "configuration.h"
@@ -80,8 +80,8 @@ bool add_glibext_module_to_python_module(PyObject *super)
result = true;
+ result &= register_python_buffer_cache(module);
result &= register_python_buffer_line(module);
- result &= register_python_code_buffer(module);
result &= register_python_config_param(module);
result &= register_python_config_param_iterator(module);
result &= register_python_generic_config(module);
diff --git a/plugins/pychrysa/gtkext/Makefile.am b/plugins/pychrysa/gtkext/Makefile.am
index e7303e8..fee2032 100644
--- a/plugins/pychrysa/gtkext/Makefile.am
+++ b/plugins/pychrysa/gtkext/Makefile.am
@@ -2,8 +2,8 @@
noinst_LTLIBRARIES = libpychrysagtkext.la
libpychrysagtkext_la_SOURCES = \
- blockview.h blockview.c \
- bufferview.h bufferview.c \
+ blockdisplay.h blockdisplay.c \
+ bufferdisplay.h bufferdisplay.c \
displaypanel.h displaypanel.c \
module.h module.c
diff --git a/plugins/pychrysa/gtkext/blockview.c b/plugins/pychrysa/gtkext/blockdisplay.c
index 73095b2..8262aa7 100644
--- a/plugins/pychrysa/gtkext/blockview.c
+++ b/plugins/pychrysa/gtkext/blockdisplay.c
@@ -1,6 +1,6 @@
/* Chrysalide - Outil d'analyse de fichiers binaires
- * blockview.c - prototypes pour l'équivalent Python du fichier "gtkext/gtkblockview.c"
+ * blockdisplay.c - prototypes pour l'équivalent Python du fichier "gtkext/gtkblockdisplay.c"
*
* Copyright (C) 2012 Cyrille Bagard
*
@@ -22,16 +22,16 @@
*/
-#include "blockview.h"
+#include "blockdisplay.h"
#include <pygobject.h>
-#include <gtkext/gtkblockview.h>
+#include <gtkext/gtkblockdisplay.h>
-#include "bufferview.h"
+#include "bufferdisplay.h"
#include "../helpers.h"
@@ -48,33 +48,33 @@
* *
******************************************************************************/
-PyTypeObject *get_python_block_view_type(void)
+PyTypeObject *get_python_block_display_type(void)
{
- static PyMethodDef py_block_view_methods[] = {
+ static PyMethodDef py_block_display_methods[] = {
{ NULL }
};
- static PyGetSetDef py_block_view_getseters[] = {
+ static PyGetSetDef py_block_display_getseters[] = {
{ NULL }
};
- static PyTypeObject py_block_view_type = {
+ static PyTypeObject py_block_display_type = {
PyVarObject_HEAD_INIT(NULL, 0)
- .tp_name = "pychrysalide.gtkext.BlockView",
+ .tp_name = "pychrysalide.gtkext.BlockDisplay",
.tp_basicsize = sizeof(PyGObject),
.tp_flags = Py_TPFLAGS_DEFAULT,
- .tp_doc = "PyChrysalide block view.",
+ .tp_doc = "PyChrysalide block display.",
- .tp_methods = py_block_view_methods,
- .tp_getset = py_block_view_getseters
+ .tp_methods = py_block_display_methods,
+ .tp_getset = py_block_display_getseters
};
- return &py_block_view_type;
+ return &py_block_display_type;
}
@@ -83,7 +83,7 @@ PyTypeObject *get_python_block_view_type(void)
* *
* Paramètres : module = module dont la définition est à compléter. *
* *
-* Description : Prend en charge l'objet 'pychrysalide.gtkext.BlockView'. *
+* Description : Prend en charge l'objet 'pychrysalide.gtkext.BlockDisplay'. *
* *
* Retour : Bilan de l'opération. *
* *
@@ -91,16 +91,17 @@ PyTypeObject *get_python_block_view_type(void)
* *
******************************************************************************/
-bool register_python_block_view(PyObject *module)
+bool register_python_block_display(PyObject *module)
{
- PyTypeObject *py_block_view_type; /* Type Python 'BlockView' */
+ PyTypeObject *py_block_display_type; /* Type Python 'BlockDisplay' */
PyObject *dict; /* Dictionnaire du module */
- py_block_view_type = get_python_block_view_type();
+ py_block_display_type = get_python_block_display_type();
dict = PyModule_GetDict(module);
- if (!register_class_for_pygobject(dict, GTK_TYPE_BLOCK_VIEW, py_block_view_type, get_python_buffer_view_type()))
+ if (!register_class_for_pygobject(dict, GTK_TYPE_BLOCK_DISPLAY,
+ py_block_display_type, get_python_buffer_display_type()))
return false;
return true;
diff --git a/plugins/pychrysa/gtkext/bufferview.h b/plugins/pychrysa/gtkext/blockdisplay.h
index d4a1581..1a45e15 100644
--- a/plugins/pychrysa/gtkext/bufferview.h
+++ b/plugins/pychrysa/gtkext/blockdisplay.h
@@ -1,6 +1,6 @@
/* Chrysalide - Outil d'analyse de fichiers binaires
- * bufferview.h - prototypes pour l'équivalent Python du fichier "gtkext/gtkbufferview.h"
+ * blockdisplay.h - prototypes pour l'équivalent Python du fichier "gtkext/gtkblockdisplay.h"
*
* Copyright (C) 2012 Cyrille Bagard
*
@@ -22,8 +22,8 @@
*/
-#ifndef _PLUGINS_PYCHRYSA_GTKEXT_BUFFERVIEW_H
-#define _PLUGINS_PYCHRYSA_GTKEXT_BUFFERVIEW_H
+#ifndef _PLUGINS_PYCHRYSA_GTKEXT_BLOCKDISPLAY_H
+#define _PLUGINS_PYCHRYSA_GTKEXT_BLOCKDISPLAY_H
#include <Python.h>
@@ -32,11 +32,11 @@
/* Fournit un accès à une définition de type à diffuser. */
-PyTypeObject *get_python_buffer_view_type(void);
+PyTypeObject *get_python_block_display_type(void);
-/* Prend en charge l'objet 'pychrysalide.gtkext.Bufferview'. */
-bool register_python_buffer_view(PyObject *module);
+/* Prend en charge l'objet 'pychrysalide.gtkext.BlockDisplay'. */
+bool register_python_block_display(PyObject *module);
-#endif /* _PLUGINS_PYCHRYSA_GTKEXT_BUFFERVIEW_H */
+#endif /* _PLUGINS_PYCHRYSA_GTKEXT_BLOCKDISPLAY_H */
diff --git a/plugins/pychrysa/gtkext/bufferview.c b/plugins/pychrysa/gtkext/bufferdisplay.c
index 3be54fd..d26d9d9 100644
--- a/plugins/pychrysa/gtkext/bufferview.c
+++ b/plugins/pychrysa/gtkext/bufferdisplay.c
@@ -1,6 +1,6 @@
/* Chrysalide - Outil d'analyse de fichiers binaires
- * bufferview.c - prototypes pour l'équivalent Python du fichier "gtkext/gtkbufferview.c"
+ * bufferdisplay.c - prototypes pour l'équivalent Python du fichier "gtkext/gtkbufferdisplay.c"
*
* Copyright (C) 2012 Cyrille Bagard
*
@@ -22,13 +22,13 @@
*/
-#include "bufferview.h"
+#include "bufferdisplay.h"
#include <pygobject.h>
-#include <gtkext/gtkbufferview.h>
+#include <gtkext/gtkbufferdisplay.h>
#include "displaypanel.h"
@@ -48,33 +48,33 @@
* *
******************************************************************************/
-PyTypeObject *get_python_buffer_view_type(void)
+PyTypeObject *get_python_buffer_display_type(void)
{
- static PyMethodDef py_buffer_view_methods[] = {
+ static PyMethodDef py_buffer_display_methods[] = {
{ NULL }
};
- static PyGetSetDef py_buffer_view_getseters[] = {
+ static PyGetSetDef py_buffer_display_getseters[] = {
{ NULL }
};
- static PyTypeObject py_buffer_view_type = {
+ static PyTypeObject py_buffer_display_type = {
PyVarObject_HEAD_INIT(NULL, 0)
- .tp_name = "pychrysalide.gtkext.Bufferview",
+ .tp_name = "pychrysalide.gtkext.BufferDisplay",
.tp_basicsize = sizeof(PyGObject),
.tp_flags = Py_TPFLAGS_DEFAULT,
- .tp_doc = "PyChrysalide buffer view.",
+ .tp_doc = "PyChrysalide buffer display.",
- .tp_methods = py_buffer_view_methods,
- .tp_getset = py_buffer_view_getseters
+ .tp_methods = py_buffer_display_methods,
+ .tp_getset = py_buffer_display_getseters
};
- return &py_buffer_view_type;
+ return &py_buffer_display_type;
}
@@ -83,7 +83,7 @@ PyTypeObject *get_python_buffer_view_type(void)
* *
* Paramètres : module = module dont la définition est à compléter. *
* *
-* Description : Prend en charge l'objet 'pychrysalide.gtkext.Bufferview'. *
+* Description : Prend en charge l'objet 'pychrysalide.gtkext.Bufferdisplay'. *
* *
* Retour : Bilan de l'opération. *
* *
@@ -91,16 +91,17 @@ PyTypeObject *get_python_buffer_view_type(void)
* *
******************************************************************************/
-bool register_python_buffer_view(PyObject *module)
+bool register_python_buffer_display(PyObject *module)
{
- PyTypeObject *py_buffer_view_type; /* Type Python 'Bufferview' */
+ PyTypeObject *py_buffer_display_type; /* Type Python 'Bufferdisplay' */
PyObject *dict; /* Dictionnaire du module */
- py_buffer_view_type = get_python_buffer_view_type();
+ py_buffer_display_type = get_python_buffer_display_type();
dict = PyModule_GetDict(module);
- if (!register_class_for_pygobject(dict, GTK_TYPE_BUFFER_VIEW, py_buffer_view_type, get_python_display_panel_type()))
+ if (!register_class_for_pygobject(dict, GTK_TYPE_BUFFER_DISPLAY,
+ py_buffer_display_type, get_python_display_panel_type()))
return false;
return true;
diff --git a/plugins/pychrysa/gtkext/blockview.h b/plugins/pychrysa/gtkext/bufferdisplay.h
index acb97a9..332f402 100644
--- a/plugins/pychrysa/gtkext/blockview.h
+++ b/plugins/pychrysa/gtkext/bufferdisplay.h
@@ -1,6 +1,6 @@
/* Chrysalide - Outil d'analyse de fichiers binaires
- * blockview.h - prototypes pour l'équivalent Python du fichier "gtkext/gtkblockview.h"
+ * bufferdisplay.h - prototypes pour l'équivalent Python du fichier "gtkext/gtkbufferdisplay.h"
*
* Copyright (C) 2012 Cyrille Bagard
*
@@ -22,8 +22,8 @@
*/
-#ifndef _PLUGINS_PYCHRYSA_GTKEXT_BLOCKVIEW_H
-#define _PLUGINS_PYCHRYSA_GTKEXT_BLOCKVIEW_H
+#ifndef _PLUGINS_PYCHRYSA_GTKEXT_BUFFERDISPLAY_H
+#define _PLUGINS_PYCHRYSA_GTKEXT_BUFFERDISPLAY_H
#include <Python.h>
@@ -32,11 +32,11 @@
/* Fournit un accès à une définition de type à diffuser. */
-PyTypeObject *get_python_block_view_type(void);
+PyTypeObject *get_python_buffer_display_type(void);
-/* Prend en charge l'objet 'pychrysalide.gtkext.BlockView'. */
-bool register_python_block_view(PyObject *module);
+/* Prend en charge l'objet 'pychrysalide.gtkext.BufferDisplay'. */
+bool register_python_buffer_display(PyObject *module);
-#endif /* _PLUGINS_PYCHRYSA_GTKEXT_BLOCKVIEW_H */
+#endif /* _PLUGINS_PYCHRYSA_GTKEXT_BUFFERDISPLAY_H */
diff --git a/plugins/pychrysa/gtkext/module.c b/plugins/pychrysa/gtkext/module.c
index 2230ed0..d826814 100644
--- a/plugins/pychrysa/gtkext/module.c
+++ b/plugins/pychrysa/gtkext/module.c
@@ -28,8 +28,8 @@
#include <assert.h>
-#include "blockview.h"
-#include "bufferview.h"
+#include "blockdisplay.h"
+#include "bufferdisplay.h"
#include "displaypanel.h"
@@ -81,8 +81,8 @@ bool add_gtkext_module_to_python_module(PyObject *super)
result = true;
result &= register_python_display_panel(module);
- result &= register_python_buffer_view(module);
- result &= register_python_block_view(module);
+ result &= register_python_buffer_display(module);
+ result &= register_python_block_display(module);
agmtpm_exit: