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.c110
1 files changed, 71 insertions, 39 deletions
diff --git a/src/format/executable.c b/src/format/executable.c
index 26c418e..187bd4e 100644
--- a/src/format/executable.c
+++ b/src/format/executable.c
@@ -25,6 +25,7 @@
#include <assert.h>
+/*
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
@@ -32,30 +33,31 @@
#include <i18n.h>
-
+*/
#include "executable-int.h"
+/*
#include "format.h"
#include "../core/logs.h"
#include "../plugins/pglist.h"
-
+*/
/* Initialise la classe des formats d'exécutables génériques. */
-static void g_executable_format_class_init(GExeFormatClass *);
+static void g_executable_format_class_init(GExecutableFormatClass *);
/* Initialise une instance de format d'exécutable générique. */
-static void g_executable_format_init(GExeFormat *);
+static void g_executable_format_init(GExecutableFormat *);
/* Supprime toutes les références externes. */
-static void g_executable_format_dispose(GExeFormat *);
+static void g_executable_format_dispose(GExecutableFormat *);
/* Procède à la libération totale de la mémoire. */
-static void g_executable_format_finalize(GExeFormat *);
+static void g_executable_format_finalize(GExecutableFormat *);
/* Indique le type défini pour un format d'exécutable générique. */
-G_DEFINE_TYPE(GExeFormat, g_executable_format, G_TYPE_BIN_FORMAT);
+G_DEFINE_TYPE(GExecutableFormat, g_executable_format, G_TYPE_PROGRAM_FORMAT);
/******************************************************************************
@@ -70,7 +72,7 @@ G_DEFINE_TYPE(GExeFormat, g_executable_format, G_TYPE_BIN_FORMAT);
* *
******************************************************************************/
-static void g_executable_format_class_init(GExeFormatClass *klass)
+static void g_executable_format_class_init(GExecutableFormatClass *klass)
{
GObjectClass *object; /* Autre version de la classe */
@@ -94,9 +96,9 @@ static void g_executable_format_class_init(GExeFormatClass *klass)
* *
******************************************************************************/
-static void g_executable_format_init(GExeFormat *format)
+static void g_executable_format_init(GExecutableFormat *format)
{
- g_mutex_init(&format->mutex);
+ //g_mutex_init(&format->mutex);
}
@@ -113,8 +115,10 @@ static void g_executable_format_init(GExeFormat *format)
* *
******************************************************************************/
-static void g_executable_format_dispose(GExeFormat *format)
+static void g_executable_format_dispose(GExecutableFormat *format)
{
+
+#if 0
size_t i; /* Boucle de parcours */
for (i = 0; i < format->debugs_count; i++)
@@ -127,6 +131,10 @@ static void g_executable_format_dispose(GExeFormat *format)
g_mutex_clear(&format->mutex);
+#endif
+
+
+
G_OBJECT_CLASS(g_executable_format_parent_class)->dispose(G_OBJECT(format));
}
@@ -144,19 +152,28 @@ static void g_executable_format_dispose(GExeFormat *format)
* *
******************************************************************************/
-static void g_executable_format_finalize(GExeFormat *format)
+static void g_executable_format_finalize(GExecutableFormat *format)
{
+#if 0
+
if (format->debugs != NULL)
free(format->debugs);
if (format->user_portions != NULL)
free(format->user_portions);
+#endif
+
+
+
G_OBJECT_CLASS(g_executable_format_parent_class)->finalize(G_OBJECT(format));
}
+
+#if 0
+
/******************************************************************************
* *
* Paramètres : format = informations chargées à compléter. *
@@ -170,7 +187,7 @@ static void g_executable_format_finalize(GExeFormat *format)
* *
******************************************************************************/
-void g_exe_format_add_debug_info(GExeFormat *format, GDbgFormat *info)
+void g_executable_format_add_debug_info(GExecutableFormat *format, GDbgFormat *info)
{
const char *desc; /* Description humaine associée*/
@@ -200,7 +217,7 @@ void g_exe_format_add_debug_info(GExeFormat *format, GDbgFormat *info)
* *
******************************************************************************/
-size_t g_exe_format_count_debug_info(const GExeFormat *format)
+size_t g_executable_format_count_debug_info(const GExecutableFormat *format)
{
return format->debugs_count;
@@ -220,7 +237,7 @@ size_t g_exe_format_count_debug_info(const GExeFormat *format)
* *
******************************************************************************/
-GDbgFormat *g_exe_format_get_debug_info(const GExeFormat *format, size_t index)
+GDbgFormat *g_executable_format_get_debug_info(const GExecutableFormat *format, size_t index)
{
GDbgFormat *result; /* Format à retourner */
@@ -237,10 +254,12 @@ GDbgFormat *g_exe_format_get_debug_info(const GExeFormat *format, size_t index)
}
+#endif
+
/******************************************************************************
* *
-* Paramètres : format = informations chargées à consulter. *
+* Paramètres : format = description du format exécutable à consulter. *
* *
* Description : Indique le type d'architecture visée par le format. *
* *
@@ -250,13 +269,24 @@ GDbgFormat *g_exe_format_get_debug_info(const GExeFormat *format, size_t index)
* *
******************************************************************************/
-const char *g_exe_format_get_target_machine(const GExeFormat *format)
+char *g_executable_format_get_target_machine(const GExecutableFormat *format)
{
- return G_EXE_FORMAT_GET_CLASS(format)->get_machine(format);
+ char *result; /* Désignation à retourner */
+ GExecutableFormatClass *class; /* Classe de l'instance */
+
+ class = G_EXECUTABLE_FORMAT_GET_CLASS(format);
+
+ result = class->get_machine(format);
+
+ //assert(result != NULL);
+
+ return result;
}
+#if 0
+
/******************************************************************************
* *
* Paramètres : format = description de l'exécutable à consulter. *
@@ -270,15 +300,15 @@ const char *g_exe_format_get_target_machine(const GExeFormat *format)
* *
******************************************************************************/
-bool g_exe_format_get_main_address(GExeFormat *format, vmpa2t *addr)
+bool g_executable_format_get_main_address(GExecutableFormat *format, vmpa2t *addr)
{
bool result; /* Bilan à retourner */
GBinFormat *base; /* Version d'instance parente */
result = false;
- if (G_EXE_FORMAT_GET_CLASS(format)->get_main_addr != NULL)
- result = G_EXE_FORMAT_GET_CLASS(format)->get_main_addr(format, addr);
+ if (G_EXECUTABLE_FORMAT_GET_CLASS(format)->get_main_addr != NULL)
+ result = G_EXECUTABLE_FORMAT_GET_CLASS(format)->get_main_addr(format, addr);
if (!result)
{
@@ -287,7 +317,7 @@ bool g_exe_format_get_main_address(GExeFormat *format, vmpa2t *addr)
g_rw_lock_reader_lock(&base->pt_lock);
if (base->pt_count[DPL_ENTRY_POINT] > 0)
- result = g_exe_format_translate_address_into_vmpa(format, base->start_points[DPL_ENTRY_POINT][0], addr);
+ result = g_executable_format_translate_address_into_vmpa(format, base->start_points[DPL_ENTRY_POINT][0], addr);
g_rw_lock_reader_unlock(&base->pt_lock);
@@ -311,11 +341,11 @@ bool g_exe_format_get_main_address(GExeFormat *format, vmpa2t *addr)
* *
******************************************************************************/
-void g_executable_format_setup_portions(GExeFormat *format, GtkStatusStack *status)
+void g_executable_format_setup_portions(GExecutableFormat *format, GtkStatusStack *status)
{
vmpa2t addr; /* Emplacement vide de sens */
phys_t length; /* Taille de portion globale */
- GExeFormatClass *class; /* Classe de l'instance */
+ GExecutableFormatClass *class; /* Classe de l'instance */
size_t i; /* Boucle de parcours */
/**
@@ -327,7 +357,7 @@ void g_executable_format_setup_portions(GExeFormat *format, GtkStatusStack *stat
format->portions = g_binary_portion_new(BPC_RAW, &addr, length);
- class = G_EXE_FORMAT_GET_CLASS(format);
+ class = G_EXECUTABLE_FORMAT_GET_CLASS(format);
if (class->refine_portions != NULL)
class->refine_portions(format);
@@ -335,7 +365,7 @@ void g_executable_format_setup_portions(GExeFormat *format, GtkStatusStack *stat
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);
+ g_executable_format_include_portion(format, format->user_portions[i], NULL);
}
}
@@ -355,7 +385,7 @@ void g_executable_format_setup_portions(GExeFormat *format, GtkStatusStack *stat
* *
******************************************************************************/
-bool g_executable_format_complete_loading(GExeFormat *format, wgroup_id_t gid, GtkStatusStack *status)
+bool g_executable_format_complete_loading(GExecutableFormat *format, wgroup_id_t gid, GtkStatusStack *status)
{
bool result; /* Bilan à faire remonter */
size_t count; /* Qté d'infos supplémentaires */
@@ -366,11 +396,11 @@ bool g_executable_format_complete_loading(GExeFormat *format, wgroup_id_t gid, G
attach_debug_format(format);
- count = g_exe_format_count_debug_info(format);
+ count = g_executable_format_count_debug_info(format);
for (i = 0; i < count && result; i++)
{
- dbg = g_exe_format_get_debug_info(format, i);
+ dbg = g_executable_format_get_debug_info(format, i);
result = g_known_format_analyze(G_KNOWN_FORMAT(dbg), gid, status);
@@ -396,7 +426,7 @@ bool g_executable_format_complete_loading(GExeFormat *format, wgroup_id_t gid, G
* *
******************************************************************************/
-void g_exe_format_register_user_portion(GExeFormat *format, GBinPortion *portion)
+void g_executable_format_register_user_portion(GExecutableFormat *format, GBinPortion *portion)
{
g_mutex_lock(&format->mutex);
@@ -423,7 +453,7 @@ void g_exe_format_register_user_portion(GExeFormat *format, GBinPortion *portion
* *
******************************************************************************/
-void g_exe_format_include_portion(GExeFormat *format, GBinPortion *portion, const vmpa2t *origin)
+void g_executable_format_include_portion(GExecutableFormat *format, GBinPortion *portion, const vmpa2t *origin)
{
phys_t available; /* Taille totale du bianire */
const mrange_t *range; /* Emplacement de la portion */
@@ -501,7 +531,7 @@ void g_exe_format_include_portion(GExeFormat *format, GBinPortion *portion, cons
* *
******************************************************************************/
-GBinPortion *g_exe_format_get_portions(GExeFormat *format)
+GBinPortion *g_executable_format_get_portions(GExecutableFormat *format)
{
GBinPortion *result; /* Instance à retourner */
@@ -533,11 +563,11 @@ GBinPortion *g_exe_format_get_portions(GExeFormat *format)
* *
******************************************************************************/
-bool g_exe_format_translate_offset_into_vmpa(GExeFormat *format, phys_t off, vmpa2t *pos)
+bool g_executable_format_translate_offset_into_vmpa(GExecutableFormat *format, phys_t off, vmpa2t *pos)
{
bool result; /* Bilan à retourner */
- result = G_EXE_FORMAT_GET_CLASS(format)->translate_phys(format, off, pos);
+ result = G_EXECUTABLE_FORMAT_GET_CLASS(format)->translate_phys(format, off, pos);
return result;
@@ -558,11 +588,11 @@ bool g_exe_format_translate_offset_into_vmpa(GExeFormat *format, phys_t off, vmp
* *
******************************************************************************/
-bool g_exe_format_translate_address_into_vmpa(GExeFormat *format, virt_t addr, vmpa2t *pos)
+bool g_executable_format_translate_address_into_vmpa(GExecutableFormat *format, virt_t addr, vmpa2t *pos)
{
bool result; /* Bilan à retourner */
- result = G_EXE_FORMAT_GET_CLASS(format)->translate_virt(format, addr, pos);
+ result = G_EXECUTABLE_FORMAT_GET_CLASS(format)->translate_virt(format, addr, pos);
return result;
@@ -583,12 +613,12 @@ bool g_exe_format_translate_address_into_vmpa(GExeFormat *format, virt_t addr, v
* *
******************************************************************************/
-bool g_exe_format_get_section_range_by_name(const GExeFormat *format, const char *name, mrange_t *range)
+bool g_executable_format_get_section_range_by_name(const GExecutableFormat *format, const char *name, mrange_t *range)
{
bool result; /* Bilan à retourner */
- GExeFormatClass *class; /* Classe de l'instance */
+ GExecutableFormatClass *class; /* Classe de l'instance */
- class = G_EXE_FORMAT_GET_CLASS(format);
+ class = G_EXECUTABLE_FORMAT_GET_CLASS(format);
if (class->get_range_by_name == NULL)
result = false;
@@ -599,3 +629,5 @@ bool g_exe_format_get_section_range_by_name(const GExeFormat *format, const char
return result;
}
+
+#endif