summaryrefslogtreecommitdiff
path: root/plugins/pe
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2021-04-06 22:55:54 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2021-04-06 22:55:54 (GMT)
commitc12d6a5d11bf9a2436ff78e393173ca59b6c9c46 (patch)
treeb579b642e301f5d6e6d88fb0213a54db6bf6fd38 /plugins/pe
parentc4d2e0fa48eab453d5c43a3c0938427617449a6a (diff)
Provide several kinds of hashes for binary files.
Diffstat (limited to 'plugins/pe')
-rw-r--r--plugins/pe/python/routine.c46
-rw-r--r--plugins/pe/routine.c31
-rw-r--r--plugins/pe/routine.h5
-rw-r--r--plugins/pe/symbols.c7
4 files changed, 82 insertions, 7 deletions
diff --git a/plugins/pe/python/routine.c b/plugins/pe/python/routine.c
index 89075ea..cebeb2a 100644
--- a/plugins/pe/python/routine.c
+++ b/plugins/pe/python/routine.c
@@ -62,6 +62,9 @@ static int py_pe_exported_routine_set_ordinal(PyObject *, PyObject *, void *);
" imported from other PE file symbol."
+/* Fournit la position du symbole dans les importations. */
+static PyObject *py_pe_imported_routine_get_index(PyObject *, void *);
+
/* Fournit le fichier DLL visé par une importation de format PE. */
static PyObject *py_pe_imported_routine_get_library(PyObject *, void *);
@@ -285,6 +288,44 @@ int convert_to_pe_exported_routine(PyObject *arg, void *dst)
* Paramètres : self = objet Python concerné par l'appel. *
* closure = non utilisé ici. *
* *
+* Description : Fournit la position du symbole dans les importations. *
+* *
+* Retour : Indice positif ou nul. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_pe_imported_routine_get_index(PyObject *self, void *closure)
+{
+ PyObject *result; /* Valeur à retourner */
+ GPeImportedRoutine *routine; /* Version native */
+ size_t index; /* Position dans les imports */
+
+#define PE_IMPORTED_ROUTINE_INDEX_ATTRIB PYTHON_GET_DEF_FULL \
+( \
+ index, py_pe_imported_routine, \
+ "Position of the symbol inside the importations table.\n" \
+ "\n" \
+ "The returned value is an integer." \
+)
+
+ routine = G_PE_IMPORTED_ROUTINE(pygobject_get(self));
+
+ index = g_pe_imported_routine_get_index(routine);
+
+ result = PyLong_FromSize_t(index);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = objet Python concerné par l'appel. *
+* closure = non utilisé ici. *
+* *
* Description : Fournit le fichier DLL visé par une importation de format PE.*
* *
* Retour : Désignation d'une bibliothèque Windows. *
@@ -299,7 +340,7 @@ static PyObject *py_pe_imported_routine_get_library(PyObject *self, void *closur
GPeImportedRoutine *routine; /* Version native */
const char *library; /* Nom de bibliothèque */
-#define PE_IMPORTED_ROUTINE_ORDINAL_ATTRIB PYTHON_GETSET_DEF_FULL \
+#define PE_IMPORTED_ROUTINE_LIBRARY_ATTRIB PYTHON_GETSET_DEF_FULL \
( \
library, py_pe_imported_routine, \
"Imported DLL's name for the symbol.\n" \
@@ -373,7 +414,8 @@ PyTypeObject *get_python_pe_imported_routine_type(void)
};
static PyGetSetDef py_pe_imported_routine_getseters[] = {
- PE_IMPORTED_ROUTINE_ORDINAL_ATTRIB,
+ PE_IMPORTED_ROUTINE_INDEX_ATTRIB,
+ PE_IMPORTED_ROUTINE_LIBRARY_ATTRIB,
{ NULL }
};
diff --git a/plugins/pe/routine.c b/plugins/pe/routine.c
index 3f2e5ba..5973487 100644
--- a/plugins/pe/routine.c
+++ b/plugins/pe/routine.c
@@ -72,6 +72,7 @@ struct _GPeImportedRoutine
GPeExportedRoutine parent; /* A laisser en premier */
char *library; /* Bibliothèque de rattachement*/
+ size_t index; /* Position dans les imports */
};
@@ -355,7 +356,8 @@ static void g_pe_imported_routine_finalize(GPeImportedRoutine *routine)
/******************************************************************************
* *
-* Paramètres : name = désignation humainement lisible. *
+* Paramètres : name = désignation humainement lisible. *
+* index = position du symbole dans les importations. *
* *
* Description : Crée une représentation de routine importée pour format PE. *
* *
@@ -365,7 +367,7 @@ static void g_pe_imported_routine_finalize(GPeImportedRoutine *routine)
* *
******************************************************************************/
-GPeImportedRoutine *g_pe_imported_routine_new(const char *name)
+GPeImportedRoutine *g_pe_imported_routine_new(const char *name, size_t index)
{
GPeImportedRoutine *result; /* Structure à retourner */
@@ -374,6 +376,31 @@ GPeImportedRoutine *g_pe_imported_routine_new(const char *name)
if (name != NULL)
g_binary_routine_set_name(G_BIN_ROUTINE(result), strdup(name));
+ result->index = index;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : routine = routine ayant pour origine un fichier PE. *
+* *
+* Description : Fournit la position du symbole dans les importations. *
+* *
+* Retour : Indice positif ou nul. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+size_t g_pe_imported_routine_get_index(const GPeImportedRoutine *routine)
+{
+ size_t result; /* Indice à retourner */
+
+ result = routine->index;
+
return result;
}
diff --git a/plugins/pe/routine.h b/plugins/pe/routine.h
index 62faaaa..f0ec71e 100644
--- a/plugins/pe/routine.h
+++ b/plugins/pe/routine.h
@@ -98,7 +98,10 @@ typedef struct _GPeImportedRoutineClass GPeImportedRoutineClass;
GType g_pe_imported_routine_get_type(void);
/* Crée une représentation de routine importée pour format PE. */
-GPeImportedRoutine *g_pe_imported_routine_new(const char *);
+GPeImportedRoutine *g_pe_imported_routine_new(const char *, size_t);
+
+/* Fournit la position du symbole dans les importations. */
+size_t g_pe_imported_routine_get_index(const GPeImportedRoutine *);
/* Définit le fichier DLL visé par une importation de format PE. */
void g_pe_imported_routine_set_library(GPeImportedRoutine *, const char *);
diff --git a/plugins/pe/symbols.c b/plugins/pe/symbols.c
index 9217466..94f97a8 100644
--- a/plugins/pe/symbols.c
+++ b/plugins/pe/symbols.c
@@ -196,6 +196,7 @@ static bool load_pe_imported_symbols(GPeFormat *format, wgroup_id_t gid, GtkStat
GBinFormat *base; /* Version basique du format */
GExeFormat *exe; /* Autre vision du format */
const GBinContent *content; /* Contenu binaire à lire */
+ size_t counter; /* Compteur d'importations */
image_import_descriptor *iter; /* Boucle de parcours */
vmpa2t dll; /* Nom de la DLL concernée */
bool ret; /* Bilan d'un traitement */
@@ -223,6 +224,8 @@ static bool load_pe_imported_symbols(GPeFormat *format, wgroup_id_t gid, GtkStat
content = G_KNOWN_FORMAT(format)->content;
+ counter = 0;
+
for (iter = imports; iter->original_first_thunk != 0; iter++)
{
/* Bibliothèque impactée */
@@ -262,7 +265,7 @@ static bool load_pe_imported_symbols(GPeFormat *format, wgroup_id_t gid, GtkStat
if (val64 & 0x8000000000000000)
{
- routine = g_pe_imported_routine_new(NULL);
+ routine = g_pe_imported_routine_new(NULL, counter++);
g_pe_exported_routine_set_ordinal(G_PE_EXPORTED_ROUTINE(routine), val64 & 0xffff);
@@ -280,7 +283,7 @@ static bool load_pe_imported_symbols(GPeFormat *format, wgroup_id_t gid, GtkStat
hint += 2;
//routine = g_binary_format_decode_routine(base, hint);
- routine = g_pe_imported_routine_new((char *)hint);
+ routine = g_pe_imported_routine_new((char *)hint, counter++);
}