summaryrefslogtreecommitdiff
path: root/src/format/executable.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/format/executable.c')
-rw-r--r--src/format/executable.c54
1 files changed, 50 insertions, 4 deletions
diff --git a/src/format/executable.c b/src/format/executable.c
index 1f21ca3..cda2e3a 100644
--- a/src/format/executable.c
+++ b/src/format/executable.c
@@ -118,10 +118,12 @@ static void g_executable_format_dispose(GExeFormat *format)
size_t i; /* Boucle de parcours */
for (i = 0; i < format->debugs_count; i++)
- g_object_unref(G_OBJECT(format->debugs[i]));
+ g_clear_object(&format->debugs[i]);
- if (format->portions != NULL)
- g_object_unref(G_OBJECT(format->portions));
+ for (i = 0; i < format->user_count; i++)
+ g_clear_object(&format->user_portions[i]);
+
+ g_clear_object(&format->portions);
g_mutex_clear(&format->mutex);
@@ -144,6 +146,12 @@ static void g_executable_format_dispose(GExeFormat *format)
static void g_executable_format_finalize(GExeFormat *format)
{
+ if (format->debugs != NULL)
+ free(format->debugs);
+
+ if (format->user_portions != NULL)
+ free(format->user_portions);
+
G_OBJECT_CLASS(g_executable_format_parent_class)->finalize(G_OBJECT(format));
}
@@ -310,6 +318,7 @@ void g_executable_format_setup_portions(GExeFormat *format, GtkStatusStack *stat
vmpa2t addr; /* Emplacement vide de sens */
phys_t length; /* Taille de portion globale */
GExeFormatClass *class; /* Classe de l'instance */
+ size_t i; /* Boucle de parcours */
base = G_BIN_FORMAT(format);
@@ -327,6 +336,12 @@ void g_executable_format_setup_portions(GExeFormat *format, GtkStatusStack *stat
if (class->refine_portions != NULL)
class->refine_portions(format);
+ for (i = 0; i < format->user_count; i++)
+ {
+ g_object_ref(G_OBJECT(format->user_portions[i]));
+ g_exe_format_include_portion(format, format->user_portions[i], NULL);
+ }
+
}
@@ -385,6 +400,32 @@ bool g_executable_format_complete_loading(GExeFormat *format, wgroup_id_t gid, G
* *
* Paramètres : format = description de l'exécutable à modifier. *
* portion = portion à inclure dans les définitions du format. *
+* *
+* Description : Enregistre une portion artificielle pour le format. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_exe_format_register_user_portion(GExeFormat *format, GBinPortion *portion)
+{
+ g_mutex_lock(&format->mutex);
+
+ format->user_portions = realloc(format->user_portions, ++format->user_count * sizeof(GBinPortion *));
+
+ format->user_portions[format->user_count - 1] = portion;
+
+ g_mutex_unlock(&format->mutex);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à modifier. *
+* portion = portion à inclure dans les définitions du format. *
* origin = source de définition de la portion fournie. *
* *
* Description : Procède à l'enregistrement d'une portion dans un format. *
@@ -400,6 +441,7 @@ void g_exe_format_include_portion(GExeFormat *format, GBinPortion *portion, cons
phys_t available; /* Taille totale du bianire */
const mrange_t *range; /* Emplacement de la portion */
phys_t start; /* Début de zone de la portion */
+ vmpa2t no_origin; /* Emplacement inconnu */
char *msg; /* Description d'une erreur */
phys_t remaining; /* Taille maximale envisageable*/
bool truncated; /* Modification faite ? */
@@ -421,7 +463,11 @@ void g_exe_format_include_portion(GExeFormat *format, GBinPortion *portion, cons
else if (start >= available)
{
- assert(origin != NULL);
+ if (origin == NULL)
+ {
+ init_vmpa(&no_origin, VMPA_NO_PHYSICAL, VMPA_NO_VIRTUAL);
+ origin = &no_origin;
+ }
asprintf(&msg, _("Defined binary portion '%s' is out of the file scope... Discarding!"),
g_binary_portion_get_desc(portion));