From 8d326041a0379b87e54be44506d544367567e89b Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Mon, 9 Feb 2015 20:15:52 +0000 Subject: Registered all the supported processors in the system code. git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@467 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a --- ChangeLog | 67 ++++++++++ configure.ac | 3 + plugins/pychrysa/pychrysa.c | 144 +++++++++++++++++++-- src/analysis/binaries/file.c | 39 +++--- src/analysis/binary.c | 27 ++++ src/analysis/binary.h | 3 + src/analysis/decomp/decompiler.c | 2 +- src/analysis/disass/area.c | 10 +- src/analysis/disass/disassembler.c | 5 +- src/analysis/disass/fetch.c | 13 +- src/analysis/disass/output.c | 6 +- src/analysis/disass/output.h | 3 +- src/analysis/roptions.c | 2 +- src/arch/processor.c | 114 ----------------- src/arch/processor.h | 30 +---- src/core/Makefile.am | 3 +- src/core/core.c | 22 +++- src/core/processors.c | 254 +++++++++++++++++++++++++++++++++++++ src/core/processors.h | 53 ++++++++ src/format/dex/dex.c | 6 +- src/format/elf/elf.c | 14 +- src/format/elf/helper_arm.c | 2 +- src/format/elf/helper_x86.c | 2 +- src/format/elf/symbols.c | 6 +- src/format/executable-int.h | 2 +- src/format/executable.c | 2 +- src/format/executable.h | 18 +-- src/format/format.c | 15 +-- src/format/format.h | 2 +- src/format/java/java.c | 29 +---- src/format/pe/pe.c | 29 +---- src/gui/panels/bookmarks.c | 6 +- src/gui/panels/symbols.c | 10 +- src/gui/status.c | 10 +- src/main.c | 2 +- src/panels/breaks.c | 3 +- src/plugins/plugin-int.h | 1 + 37 files changed, 651 insertions(+), 308 deletions(-) create mode 100644 src/core/processors.c create mode 100644 src/core/processors.h diff --git a/ChangeLog b/ChangeLog index 20e3074..9b3fccd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,70 @@ +15-02-09 Cyrille Bagard + + * configure.ac: + Put the Python library ABI flags into LIBPYTHON_ABI_FLAGS. + + * plugins/pychrysa/pychrysa.c: + Update the code. Check if the ABI flags of the current interpreter match + the ones of the Python library used during the module compilation. + + * src/analysis/binaries/file.c: + Update code when dealing with processors. + + * src/analysis/binary.c: + * src/analysis/binary.h: + Provide one processor instance by loaded binary. + + * src/analysis/decomp/decompiler.c: + * src/analysis/disass/area.c: + * src/analysis/disass/disassembler.c: + * src/analysis/disass/fetch.c: + * src/analysis/disass/output.c: + * src/analysis/disass/output.h: + * src/analysis/roptions.c: + Update code when dealing with processors. + + * src/arch/processor.c: + * src/arch/processor.h: + Remove old code loading existing processors. + + * src/arch/processor.c: + * src/arch/processor.h: + New entries: load hardcoded defined architectures. + + * src/core/core.c: + Register all the supported processors in the system code. + + * src/core/Makefile.am: + Add the 'processors.[ch]' files to libcore_la_SOURCES. + + * src/format/dex/dex.c: + * src/format/elf/elf.c: + * src/format/elf/helper_arm.c: + * src/format/elf/helper_x86.c: + * src/format/elf/symbols.c: + Update code when dealing with processors. + + * src/format/executable.c: + * src/format/executable.h: + * src/format/executable-int.h: + Request the required linked processor by a keyword. + + * src/format/format.c: + * src/format/format.h: + Update a disassembling context only: do not create it anymore. + + * src/format/java/java.c: + * src/format/pe/pe.c: + * src/gui/panels/bookmarks.c: + * src/gui/panels/symbols.c: + * src/gui/status.c: + * src/main.c: + * src/panels/breaks.c: + Update code when dealing with processors. + + * src/plugins/plugin-int.h: + Include a missing 'plugin.h' header. + 15-02-04 Cyrille Bagard * tools/d2c/d2c_genmakefile.sh: diff --git a/configure.ac b/configure.ac index fa7246b..b8fb1e9 100644 --- a/configure.ac +++ b/configure.ac @@ -221,13 +221,16 @@ AC_SUBST(LIBSQLITE_LIBS) if test "x$enable_debug" = "xyes"; then LIBPYTHON_CFLAGS=`python3-dbg-config --cflags` LIBPYTHON_LIBS=`python3-dbg-config --libs` + LIBPYTHON_ABI_FLAGS=`python3-dbg-config --abiflags` else LIBPYTHON_CFLAGS=`python3-config --cflags` LIBPYTHON_LIBS=`python3-config --libs` + LIBPYTHON_ABI_FLAGS=`python3-config --abiflags` fi AC_SUBST(LIBPYTHON_CFLAGS) AC_SUBST(LIBPYTHON_LIBS) +AC_DEFINE_UNQUOTED(LIBPYTHON_ABI_FLAGS, "${LIBPYTHON_ABI_FLAGS}", [ABI flags of the linked Python library]) #--- Checks for pygobject-3.0 diff --git a/plugins/pychrysa/pychrysa.c b/plugins/pychrysa/pychrysa.c index 1835b18..2b8202e 100644 --- a/plugins/pychrysa/pychrysa.c +++ b/plugins/pychrysa/pychrysa.c @@ -347,7 +347,6 @@ PyMODINIT_FUNC initpychrysa(void) #include -#include "../../revision.h" @@ -368,9 +367,45 @@ PyMODINIT_FUNC initpychrysa(void) + + + + + +/////////////////////////// + + +#include +#include +#include +#include + + +#include +#include +#include + + +#include "../../revision.h" + + + + + + +DEFINE_CHRYSALIDE_ACTIVE_PLUGIN("PyChrysalide", "Provides bindings to Python", "0.1.0", PGA_ALL); + + /* Fournit la version du programme global. */ static PyObject *py_chrysalide_version(PyObject *, PyObject *); +/* Fournit la version du greffon pour Python. */ +static PyObject *py_chrysalide_mod_version(PyObject *, PyObject *); + +/* Détermine si l'interpréteur lancé est celui pris en compte. */ +static bool is_current_abi_suitable(void); + + @@ -405,9 +440,90 @@ static PyObject *py_chrysalide_version(PyObject *self, PyObject *args) } +/****************************************************************************** +* * +* Paramètres : self = NULL car méthode statique. * +* args = non utilisé ici. * +* * +* Description : Fournit la version du greffon pour Python. * +* * +* Retour : Numéro de révision. * +* * +* Remarques : - * +* * +******************************************************************************/ +static PyObject *py_chrysalide_mod_version(PyObject *self, PyObject *args) +{ + char version[16]; + snprintf(version, sizeof(version), "%s", _chrysalide_plugin.version); + return PyUnicode_FromString(version); + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Détermine si l'interpréteur lancé est celui pris en compte. * +* * +* Retour : true si l'exécution peut se poursuivre, false sinon. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool is_current_abi_suitable(void) +{ + bool result; + int fds[2]; + int ret; + char cmds[128]; + char content[64]; + ssize_t got; + +#define GRAB_ABI_FLAGS_IN_PYTHON \ + "import sys" "\n" \ + "import os" "\n" \ + "os.write(%d, bytes(sys.abiflags, 'UTF-8'))" "\n" + + result = false; + + ret = pipe(fds); + if (ret == -1) + { + perror("pipe()"); + return false; + } + + snprintf(cmds, sizeof(cmds), GRAB_ABI_FLAGS_IN_PYTHON, fds[1]); + + ret = PyRun_SimpleString(cmds); + if (ret != 0) goto icas_exit; + + got = read(fds[0], content, sizeof(content)); + if (got < 0) + { + perror("read()"); + goto icas_exit; + } + + content[got] = '\0'; + + result = (strcmp(content, LIBPYTHON_ABI_FLAGS) == 0); + + icas_exit: + + if (!result) + PyErr_SetString(PyExc_SystemError, "the ABI flags of the current interpreter do not match " \ + "the ones of the Python library used during the module compilation."); + + return result; + +} /****************************************************************************** @@ -434,7 +550,7 @@ PyMODINIT_FUNC PyInit_pychrysalide(void) METH_NOARGS, "Provide the revision number of Chrysalide." }, - { "python", py_chrysalide_version, + { "mod_version", py_chrysalide_mod_version, METH_NOARGS, "Provide the revision number of Chrysalide module for Python." }, @@ -457,18 +573,24 @@ PyMODINIT_FUNC PyInit_pychrysalide(void) // TODO : à bouger ! - init_all_processors(); - init_all_formats(); + //init_all_processors(); + //init_all_formats(); + if (!is_current_abi_suitable()) + return NULL; + if (pygobject_init(-1, -1, -1) == NULL) + { + PyErr_SetString(PyExc_SystemError, "unable to init GObject in Python."); return NULL; + } if (!load_all_basic_components()) + { + PyErr_SetString(PyExc_SystemError, "unable to load all basic components."); return NULL; - - - + } /** * Pour une raison non identifiée, si le module n'est pas préchargé, @@ -487,9 +609,11 @@ PyMODINIT_FUNC PyInit_pychrysalide(void) status &= add_core_module_to_python_module(result); status &= add_glibext_module_to_python_module(result); - printf("status :: %d\n", status); - - /* TODO : if !status... */ + if (!status) + { + PyErr_SetString(PyExc_SystemError, "fail to load all PyChrysalide components."); + return NULL; + } return result; diff --git a/src/analysis/binaries/file.c b/src/analysis/binaries/file.c index d833828..a724cb7 100644 --- a/src/analysis/binaries/file.c +++ b/src/analysis/binaries/file.c @@ -33,6 +33,7 @@ #include "../binary-int.h" #include "../../common/extstr.h" +#include "../../core/processors.h" #include "../../gui/panels/log.h" @@ -164,6 +165,8 @@ GLoadedBinary *g_file_binary_new_from_file(const char *filename) struct stat info; /* Informations sur le fichier */ int ret; /* Bilan d'un appel */ void *content; /* Contenu brut du fichier */ + const char *target; /* Architecture requise */ + const char *desc; /* Description humaine associée*/ result = g_object_new(G_TYPE_FILE_BINARY, NULL); loaded = G_LOADED_BINARY(result); @@ -216,30 +219,24 @@ GLoadedBinary *g_file_binary_new_from_file(const char *filename) goto lbf_error; } - switch (g_exe_format_get_target_machine(loaded->format)) + target = g_exe_format_get_target_machine(loaded->format); + desc = get_arch_processor_name(target); + + if (desc == NULL) { - case FTM_ARM: - log_simple_message(LMT_INFO, _("Detected architecture: ARM")); - break; - case FTM_DALVIK: - log_simple_message(LMT_INFO, _("Detected architecture: Dalvik Virtual Machine")); - break; - case FTM_JVM: - log_simple_message(LMT_INFO, _("Detected architecture: Java Virtual Machine")); - break; - case FTM_MIPS: - log_simple_message(LMT_INFO, _("Detected architecture: Microprocessor without Interlocked Pipeline Stages")); - break; - case FTM_386: - log_simple_message(LMT_INFO, _("Detected architecture: i386")); - break; - default: - log_simple_message(LMT_INFO, _("Unknown architecture")); - goto lbf_error; - break; + log_simple_message(LMT_INFO, _("Unknown architecture")); + goto lbf_error; } + else + log_variadic_message(LMT_INFO, _("Detected architecture: %s"), desc); + + loaded->proc = get_arch_processor_for_type(target); - loaded->proc = get_arch_processor_from_format(loaded->format); + if (loaded->proc == NULL) + { + log_simple_message(LMT_ERROR, _("Unable to load the required processor")); + goto lbf_error; + } return G_LOADED_BINARY(result); diff --git a/src/analysis/binary.c b/src/analysis/binary.c index 35f7acd..55b984a 100644 --- a/src/analysis/binary.c +++ b/src/analysis/binary.c @@ -962,6 +962,8 @@ bin_t *g_loaded_binary_get_data(const GLoadedBinary *binary, off_t *length) GExeFormat *g_loaded_binary_get_format(const GLoadedBinary *binary) { + /* TODO : inc ref ! */ + return binary->format; } @@ -971,6 +973,31 @@ GExeFormat *g_loaded_binary_get_format(const GLoadedBinary *binary) * * * Paramètres : binary = élément binaire à consulter. * * * +* Description : Fournit le processeur de l'architecture liée au binaire. * +* * +* Retour : Adresse du processeur associé. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchProcessor *g_loaded_binary_get_processor(const GLoadedBinary *binary) +{ + GArchProcessor *result; /* Instance à retourner */ + + result = binary->proc; + + g_object_ref(G_OBJECT(result)); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : binary = élément binaire à consulter. * +* * * Description : Fournit les instructions issues du désassemblage. * * * * Retour : Instructions issues du désassemblage. * diff --git a/src/analysis/binary.h b/src/analysis/binary.h index 8ce64cb..625ff4a 100644 --- a/src/analysis/binary.h +++ b/src/analysis/binary.h @@ -156,6 +156,9 @@ bin_t *g_loaded_binary_get_data(const GLoadedBinary *, off_t *); /* Fournit le format de fichier reconnu dans le contenu binaire. */ GExeFormat *g_loaded_binary_get_format(const GLoadedBinary *); +/* Fournit le processeur de l'architecture liée au binaire. */ +GArchProcessor *g_loaded_binary_get_processor(const GLoadedBinary *); + /* Fournit les instructions issues du désassemblage. */ GArchInstruction *g_loaded_binary_get_instructions(const GLoadedBinary *); diff --git a/src/analysis/decomp/decompiler.c b/src/analysis/decomp/decompiler.c index aa2fc84..150f03c 100644 --- a/src/analysis/decomp/decompiler.c +++ b/src/analysis/decomp/decompiler.c @@ -149,7 +149,7 @@ static void prepare_all_routines_for_decomp(const GLoadedBinary *binary, const c //vmpa_t max; /* Première adresse à écarter */ format = g_loaded_binary_get_format(binary); - proc = get_arch_processor_from_format(G_EXE_FORMAT(format)); + proc = NULL;//get_arch_processor_from_format(G_EXE_FORMAT(format)); routines = g_binary_format_get_routines(G_BIN_FORMAT(format), &count); diff --git a/src/analysis/disass/area.c b/src/analysis/disass/area.c index 17df2af..a6e58cd 100644 --- a/src/analysis/disass/area.c +++ b/src/analysis/disass/area.c @@ -440,7 +440,7 @@ void load_code_from_mem_area(mem_area **list, size_t *count, size_t *index, cons /* Récupération des informations de base */ format = G_BIN_FORMAT(g_loaded_binary_get_format(binary)); - proc = get_arch_processor_from_format(G_EXE_FORMAT(format)); + proc = g_loaded_binary_get_processor(binary); bin_data = g_loaded_binary_get_data(binary, &bin_length); area = (*list) + *index; @@ -581,6 +581,9 @@ void load_code_from_mem_area(mem_area **list, size_t *count, size_t *index, cons printf("\n"); + g_object_unref(G_OBJECT(proc)); + + } @@ -626,8 +629,11 @@ static void load_data_from_mem_area(mem_area *area, mem_area *list, size_t count /* Récupération des informations de base */ format = G_BIN_FORMAT(g_loaded_binary_get_format(binary)); - proc = get_arch_processor_from_format(G_EXE_FORMAT(format)); + + proc = g_loaded_binary_get_processor(binary); endianness = g_arch_processor_get_endianness(proc); + g_object_unref(G_OBJECT(proc)); + bin_data = g_loaded_binary_get_data(binary, &bin_length); diff = compute_vmpa_diff(get_mrange_addr(&area->range), start); diff --git a/src/analysis/disass/disassembler.c b/src/analysis/disass/disassembler.c index ac6eb5b..c39073c 100644 --- a/src/analysis/disass/disassembler.c +++ b/src/analysis/disass/disassembler.c @@ -199,6 +199,7 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkExtSta bstatus_id_t id; /* Identifiant de statut */ + GArchProcessor *proc; /* Architecture du binaire */ @@ -268,10 +269,12 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkExtSta qsort(routines, routines_count, sizeof(GBinRoutine *), (__compar_fn_t)g_binary_routine_compare); + proc = g_loaded_binary_get_processor(disass->binary); - print_disassembled_instructions(disass->buffer, disass->format, *disass->instrs, + print_disassembled_instructions(disass->buffer, disass->format, proc, *disass->instrs, routines, routines_count, statusbar, id); + g_object_unref(G_OBJECT(proc)); diff --git a/src/analysis/disass/fetch.c b/src/analysis/disass/fetch.c index b912ff2..16b81c8 100644 --- a/src/analysis/disass/fetch.c +++ b/src/analysis/disass/fetch.c @@ -143,7 +143,7 @@ GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, GtkExt { GArchInstruction *result; /* Instruction désassemblées */ GBinFormat *format; /* Format du fichier binaire */ - //GArchProcessor *proc; /* Architecture du binaire */ + GArchProcessor *proc; /* Architecture du binaire */ GProcContext *ctx; /* Contexte de désassemblage */ off_t length; /* Taille des données à lire */ mem_area *areas; /* Zone de productions */ @@ -158,15 +158,10 @@ GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, GtkExt double done; /* Portion de travail accompli */ format = G_BIN_FORMAT(g_loaded_binary_get_format(binary)); - - /* - proc = get_arch_processor_from_format(G_EXE_FORMAT(format)); + proc = g_loaded_binary_get_processor(binary); ctx = g_arch_processor_get_context(proc); - */ - - ctx = g_binary_format_get_disassembling_context(format); - + g_binary_format_setup_disassembling_context(format, ctx); /* Définition à la découpe des parties à traiter */ @@ -234,6 +229,8 @@ GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, GtkExt /* free */ + g_object_unref(G_OBJECT(proc)); + return result; } diff --git a/src/analysis/disass/output.c b/src/analysis/disass/output.c index 87d0407..2ecb5f4 100644 --- a/src/analysis/disass/output.c +++ b/src/analysis/disass/output.c @@ -49,10 +49,10 @@ * * ******************************************************************************/ -void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *format, const GArchInstruction *instrs, GBinRoutine * const *routines, size_t count, GtkExtStatusBar *statusbar, bstatus_id_t id) +void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *format, GArchProcessor *proc, const GArchInstruction *instrs, GBinRoutine * const *routines, size_t count, GtkExtStatusBar *statusbar, bstatus_id_t id) { GLangOutput *output; /* Modèle de sortie adéquat */ - GArchProcessor *proc; /* Architecture du binaire */ + //GArchProcessor *proc; /* Architecture du binaire */ MemoryDataSize msize; /* Taille du bus d'adresses */ const bin_t *content; /* Contenu binaire global */ @@ -121,7 +121,7 @@ void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *form - proc = get_arch_processor_from_format(format); + //proc = get_arch_processor_from_format(format); msize = g_arch_processor_get_memory_size(proc); content = g_binary_format_get_content(G_BIN_FORMAT(format), NULL); diff --git a/src/analysis/disass/output.h b/src/analysis/disass/output.h index 04cb643..549fa23 100644 --- a/src/analysis/disass/output.h +++ b/src/analysis/disass/output.h @@ -27,13 +27,14 @@ #include "../routine.h" #include "../../arch/instruction.h" +#include "../../arch/processor.h" #include "../../glibext/gcodebuffer.h" #include "../../gtkext/gtkextstatusbar.h" /* Transcrit du code désassemblé en texte humainement lisible. */ -void print_disassembled_instructions(GCodeBuffer *, const GExeFormat *, const GArchInstruction *, GBinRoutine * const *, size_t, GtkExtStatusBar *, bstatus_id_t); +void print_disassembled_instructions(GCodeBuffer *, const GExeFormat *, GArchProcessor *, const GArchInstruction *, GBinRoutine * const *, size_t, GtkExtStatusBar *, bstatus_id_t); diff --git a/src/analysis/roptions.c b/src/analysis/roptions.c index 896a2e1..8da348f 100644 --- a/src/analysis/roptions.c +++ b/src/analysis/roptions.c @@ -113,7 +113,7 @@ GRenderingOptions *g_rendering_options_new(GExeFormat *format) result = g_object_new(G_TYPE_RENDERING_OPTIONS, NULL); result->format = format; - result->proc = get_arch_processor_from_format(format); + result->proc = NULL;//get_arch_processor_from_format(format); return result; diff --git a/src/arch/processor.c b/src/arch/processor.c index 2e678f6..0b33552 100644 --- a/src/arch/processor.c +++ b/src/arch/processor.c @@ -42,11 +42,6 @@ #include "artificial.h" -#include "arm/processor.h" -#include "dalvik/processor.h" -#include "jvm/processor.h" -#include "mips/processor.h" -#include "x86/processor.h" @@ -62,12 +57,6 @@ static void g_arch_processor_init(GArchProcessor *); -/* ------------------------ ARCHITECTURES DANS LEUR ENSEMBLE ------------------------ */ - - -static GArchProcessor *_processors_list[APT_COUNT]; - - @@ -305,106 +294,3 @@ GArchInstruction *g_arch_processor_disassemble(const GArchProcessor *proc, GProc return result; } - - - - - - - -/* ---------------------------------------------------------------------------------- */ -/* ARCHITECTURES DANS LEUR ENSEMBLE */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -* * -* Paramètres : - * -* * -* Description : Procède au chargement des différentes architectures. * -* * -* Retour : Toujours true. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool init_all_processors(void) -{ - _processors_list[APT_ARM] = g_armv7_processor_new(); - _processors_list[APT_DALVIK] = g_dalvik_processor_new(); - //_processors_list[APT_JVM] = g_jvm_processor_new(); - //_processors_list[APT_MIPS] = g_mips_processor_new(); - //_processors_list[APT_386] = g_x86_processor_new(); - - return true; - -} - - -/****************************************************************************** -* * -* Paramètres : type = sorte de processeur recherché. * -* * -* Description : Fournit le processeur d'architecture correspondant à un type.* -* * -* Retour : Processeur d'architecture trouvé. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchProcessor *get_arch_processor_for_type(ArchProcessorType type) -{ - return _processors_list[type]; - -} - - -/****************************************************************************** -* * -* Paramètres : format = exécutable d'origine. * -* * -* Description : Fournit le processeur d'architecture lié à un format. * -* * -* Retour : Processeur d'architecture trouvé. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchProcessor *get_arch_processor_from_format(const GExeFormat *format) -{ - GArchProcessor *result; /* Conversion à retourner */ - - switch (g_exe_format_get_target_machine(format)) - { - case FTM_ARM: - result = get_arch_processor_for_type(APT_ARM); - break; - - case FTM_DALVIK: - result = get_arch_processor_for_type(APT_DALVIK); - break; - - case FTM_JVM: - result = get_arch_processor_for_type(APT_JVM); - break; - - case FTM_MIPS: - result = get_arch_processor_for_type(APT_MIPS); - break; - - case FTM_386: - result = get_arch_processor_for_type(APT_386); - break; - - default: - result = NULL; - break; - - } - - return result; - -} diff --git a/src/arch/processor.h b/src/arch/processor.h index ac5d811..725307f 100644 --- a/src/arch/processor.h +++ b/src/arch/processor.h @@ -32,7 +32,7 @@ #include "instruction.h" #include "../common/endianness.h" #include "../decomp/context.h" -#include "../format/format.h" +#include "../format/format.h" ////////////////// utile ? @@ -78,32 +78,4 @@ GArchInstruction *g_arch_processor_disassemble(const GArchProcessor *, GProcCont -/* ------------------------ ARCHITECTURES DANS LEUR ENSEMBLE ------------------------ */ - - -/* Type de processeurs disponibles */ -typedef enum _ArchProcessorType -{ - APT_ARM, /* ARM vX */ - APT_DALVIK, /* Dalvik Virtual Machine */ - APT_JVM, /* Java Virtual Machine */ - APT_MIPS, /* Mips 32 ou 64 bits */ - APT_386, /* Intel 80386 */ - - APT_COUNT - -} ArchProcessorType; - - -/* Procède au chargement des différentes architectures. */ -bool init_all_processors(void); - -/* Fournit le processeur d'architecture correspondant à un type. */ -GArchProcessor *get_arch_processor_for_type(ArchProcessorType); - -/* Fournit le processeur d'architecture lié à un format. */ -GArchProcessor *get_arch_processor_from_format(const GExeFormat *); - - - #endif /* _ARCH_PROCESSOR_H */ diff --git a/src/core/Makefile.am b/src/core/Makefile.am index 02b6877..0d6d754 100755 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -4,7 +4,8 @@ noinst_LTLIBRARIES = libcore.la libcore_la_SOURCES = \ collections.h collections.c \ core.h core.c \ - params.h params.c + params.h params.c \ + processors.h processors.c libcore_la_LDFLAGS = $(LIBGTK_LIBS) $(LIBXML_LIBS) diff --git a/src/core/core.c b/src/core/core.c index d7e7755..36428d7 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -26,6 +26,7 @@ #include "collections.h" #include "params.h" +#include "processors.h" @@ -43,15 +44,24 @@ bool load_all_basic_components(void) { - bool result; /* Bilan à retourner */ + static bool result = false; /* Bilan à retourner */ - result = true; + /** + * On mémorise les passages réussis. + */ + if (!result) + { + result = true; - result &= load_main_config_parameters(); + result &= load_main_config_parameters(); - result &= g_generic_config_read(get_main_configuration()); + result &= g_generic_config_read(get_main_configuration()); - result &= load_hard_coded_collection_definitions(); + result &= load_hard_coded_processors_definitions(); + + result &= load_hard_coded_collection_definitions(); + + } return result; @@ -74,6 +84,8 @@ void unload_all_basic_components(void) { unload_collection_definitions(); + unload_processors_definitions(); + g_generic_config_write(get_main_configuration()); unload_main_config_parameters(); diff --git a/src/core/processors.c b/src/core/processors.c new file mode 100644 index 0000000..7489614 --- /dev/null +++ b/src/core/processors.c @@ -0,0 +1,254 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * processors.c - enregistrement et fourniture des architectures supportées + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * OpenIDA 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. + * + * OpenIDA 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 Foobar. If not, see . + */ + + +#include "processors.h" + + +#include +#include +#include + + +#include "../arch/arm/v7/processor.h" +#include "../arch/dalvik/processor.h" +#include "../arch/jvm/processor.h" + + + +/* Caractéristiques d'un processeur */ +typedef struct _proc_t +{ + char *key; /* Clef pour un accès rapide */ + char *name; /* Désignation humaine */ + GType instance; /* Type à manipuler en interne */ + +} proc_t; + + +/* Mémorisation des types de processeurs enregistrés */ +static proc_t *_processors_definitions = NULL; +static size_t _processors_definitions_count = 0; + +/* Verrou pour des accès atomiques */ +/* ... */ + + +/* Retrouve l'enregistrement correspondant à une architecture. */ +static proc_t *find_processor_by_key(const char *); + + + +/****************************************************************************** +* * +* Paramètres : key = désignation rapide et interne d'un processeur. * +* name = désignation humaine de l'architecture. * +* instance = type GLib représentant le type à instancier. * +* * +* Description : Enregistre un processeur pour une architecture donnée. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool register_processor_type(const char *key, const char *name, GType instance) +{ + proc_t *new; /* Nouvel élément à définir */ + + /* TODO : if find()... -> unref(), ret false */ + + /* TODO : lock */ + + _processors_definitions = (proc_t *)realloc(_processors_definitions, + ++_processors_definitions_count * sizeof(proc_t)); + + new = &_processors_definitions[_processors_definitions_count - 1]; + + new->key = strdup(key); + new->name = strdup(name); + new->instance = instance; + + /* TODO : unlock */ + + return true; + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Charge les définitions de processeurs "natifs". * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool load_hard_coded_processors_definitions(void) +{ + bool result; /* Bilan à retourner */ + + result = true; + + result &= register_processor_type("armv7", "ARM v7", G_TYPE_ARMV7_PROCESSOR); + + result &= register_processor_type("dalvik", "Dalvik Virtual Machine", G_TYPE_DALVIK_PROCESSOR); + + //result &= register_processor_type("jvm", "Java Virtual Machine", G_TYPE_JVM_PROCESSOR); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Décharge toutes les définitions de processeurs. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void unload_processors_definitions(void) +{ + size_t i; /* Boucle de parcours */ + + for (i = 0; i < _processors_definitions_count; i++) + { + free(_processors_definitions[i].key); + free(_processors_definitions[i].name); + } + + if (_processors_definitions != NULL) + free(_processors_definitions); + + _processors_definitions = NULL; + _processors_definitions_count = 0; + +} + + +/****************************************************************************** +* * +* Paramètres : key = nom technique du processeur recherché. * +* * +* Description : Retrouve l'enregistrement correspondant à une architecture. * +* * +* Retour : Définition trouvée ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static proc_t *find_processor_by_key(const char *key) +{ + proc_t *result; /* Trouvaille à retourner */ + size_t i; /* Boucle de parcours */ + + /** + * Le verrou d'accès global doit être posé ! + */ + + result = NULL; + + for (i = 0; i < _processors_definitions_count; i++) + if (strcmp(_processors_definitions[i].key, key) == 0) + result = &_processors_definitions[i]; + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : key = nom technique du processeur recherché. * +* * +* Description : Fournit le nom humain de l'architecture visée. * +* * +* Retour : Désignation humaine trouvée ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +const char *get_arch_processor_name(const char *key) +{ + const char *result; /* Description à retourner */ + proc_t *def; /* Définition d'architecture */ + + /* TODO : lock */ + + def = find_processor_by_key(key); + + if (def == NULL) + result = NULL; + else + result = def->name; + + /* TODO : unlock */ + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : key = nom technique du processeur recherché. * +* * +* Description : Fournit le processeur d'architecture correspondant à un type.* +* * +* Retour : Processeur d'architecture trouvé. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchProcessor *get_arch_processor_for_type(const char *key) +{ + GArchProcessor *result; /* Instance à retourner */ + proc_t *def; /* Définition d'architecture */ + + /* TODO : lock */ + + def = find_processor_by_key(key); + + if (def == NULL) + result = NULL; + else + result = g_object_new(def->instance, NULL); + + /* TODO : unlock */ + + return result; + +} diff --git a/src/core/processors.h b/src/core/processors.h new file mode 100644 index 0000000..f25a8a3 --- /dev/null +++ b/src/core/processors.h @@ -0,0 +1,53 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * processors.h - prototypes pour l'enregistrement et la fourniture des architectures supportées + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * OpenIDA 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. + * + * OpenIDA 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 Foobar. If not, see . + */ + + +#ifndef _CORE_PROCESSORS_H +#define _CORE_PROCESSORS_H + + +#include +#include + + +#include "../arch/processor.h" + + + +/* Enregistre un processeur pour une architecture donnée. */ +bool register_processor_type(const char *, const char *, GType); + +/* Charge les définitions de processeurs "natifs". */ +bool load_hard_coded_processors_definitions(void); + +/* Décharge toutes les définitions de processeurs. */ +void unload_processors_definitions(void); + +/* Fournit le nom humain de l'architecture visée. */ +const char *get_arch_processor_name(const char *); + +/* Fournit le processeur d'architecture correspondant à un type. */ +GArchProcessor *get_arch_processor_for_type(const char *); + + + +#endif /* _ANALYSIS_DB_COLLECTION_H */ diff --git a/src/format/dex/dex.c b/src/format/dex/dex.c index f66f056..c5271e0 100755 --- a/src/format/dex/dex.c +++ b/src/format/dex/dex.c @@ -52,7 +52,7 @@ static void g_dex_format_find_all_sources(GDexFormat *); static void g_dex_format_decompile(const GDexFormat *, GCodeBuffer *, const char *); /* Indique le type d'architecture visée par le format. */ -static FormatTargetMachine g_dex_format_get_target_machine(const GDexFormat *); +static const char *g_dex_format_get_target_machine(const GDexFormat *); /* Fournit les références aux zones binaires à analyser. */ //static GBinPart **g_dex_format_get_parts(const GDexFormat *, size_t *); @@ -342,9 +342,9 @@ char *_g_data_type_to_string(const GDataType *type, bool simple) * * ******************************************************************************/ -static FormatTargetMachine g_dex_format_get_target_machine(const GDexFormat *format) +static const char *g_dex_format_get_target_machine(const GDexFormat *format) { - return FTM_DALVIK; + return "dalvik"; } diff --git a/src/format/elf/elf.c b/src/format/elf/elf.c index b659dd7..cc84335 100644 --- a/src/format/elf/elf.c +++ b/src/format/elf/elf.c @@ -57,7 +57,7 @@ static void g_elf_format_class_init(GElfFormatClass *); static void g_elf_format_init(GElfFormat *); /* Indique le type d'architecture visée par le format. */ -static FormatTargetMachine g_elf_format_get_target_machine(const GElfFormat *); +static const char *g_elf_format_get_target_machine(const GElfFormat *); /* Etend la définition des portions au sein d'un binaire. */ static void g_elf_format_refine_portions(const GElfFormat *, GBinPortion *); @@ -239,27 +239,27 @@ GBinFormat *g_elf_format_new(const bin_t *content, off_t length) * * ******************************************************************************/ -static FormatTargetMachine g_elf_format_get_target_machine(const GElfFormat *format) +static const char *g_elf_format_get_target_machine(const GElfFormat *format) { - FormatTargetMachine result; /* Identifiant à retourner */ + const char *result; /* Identifiant à retourner */ switch (ELF_HDR(format, format->header, e_machine)) { case EM_386: - result = FTM_386; + result = "i386"; break; case EM_MIPS: - result = FTM_MIPS; + result = "mips"; break; case EM_ARM: - result = FTM_ARM; + result = "armv7"; break; case EM_NONE: default: - result = FTM_NONE; + result = NULL; break; } diff --git a/src/format/elf/helper_arm.c b/src/format/elf/helper_arm.c index d5e8af8..7282d23 100644 --- a/src/format/elf/helper_arm.c +++ b/src/format/elf/helper_arm.c @@ -362,7 +362,7 @@ GArchInstruction **decode_elf_relocations(GElfFormat *format, const elf_shdr *pl get_elf_section_content(format, plt, &plt_start, &plt_size, &plt_address); - proc = get_arch_processor_for_type(APT_386); + proc = NULL;//get_arch_processor_for_type(APT_386); for (pos = 0; pos < plt_size; ) { diff --git a/src/format/elf/helper_x86.c b/src/format/elf/helper_x86.c index 708a7e1..742d1c3 100644 --- a/src/format/elf/helper_x86.c +++ b/src/format/elf/helper_x86.c @@ -216,7 +216,7 @@ GArchInstruction **decode_elf_relocations(GElfFormat *format, const elf_shdr *pl get_elf_section_content(format, plt, &plt_start, &plt_size, &plt_address); - proc = get_arch_processor_for_type(APT_386); + proc = NULL;//get_arch_processor_for_type(APT_386); for (pos = 0; pos < plt_size; ) { diff --git a/src/format/elf/symbols.c b/src/format/elf/symbols.c index 2d8057e..31fbabd 100644 --- a/src/format/elf/symbols.c +++ b/src/format/elf/symbols.c @@ -1852,13 +1852,13 @@ static bool load_elf_external_symbols(GElfFormat *format, const elf_shdr *sectio result = find_elf_section_by_index(format, ELF_SHDR(format, dynsym, sh_link), &dynstr); if (result) - switch (g_exe_format_get_target_machine(G_EXE_FORMAT(format))) + switch (ELF_HDR(format, format->header, e_machine)) { - case FTM_ARM: + case EM_ARM: result = load_elf_arm_relocated_symbols(format, &relxxx, &dynsym, &dynstr); break; - case FTM_386: + case EM_386: result = load_elf_x86_relocated_symbols(format, &relxxx, &dynsym, &dynstr); break; diff --git a/src/format/executable-int.h b/src/format/executable-int.h index 119c251..59a513e 100644 --- a/src/format/executable-int.h +++ b/src/format/executable-int.h @@ -33,7 +33,7 @@ /* Indique le type d'architecture visée par le format. */ -typedef FormatTargetMachine (* get_target_machine_fc) (const GExeFormat *); +typedef const char * (* get_target_machine_fc) (const GExeFormat *); /* Etend la définition des portions au sein d'un binaire. */ typedef void (* refine_portions_fc) (const GExeFormat *, GBinPortion *); diff --git a/src/format/executable.c b/src/format/executable.c index c1a0a7c..319d3dd 100644 --- a/src/format/executable.c +++ b/src/format/executable.c @@ -102,7 +102,7 @@ static void g_executable_format_init(GExeFormat *format) * * ******************************************************************************/ -FormatTargetMachine g_exe_format_get_target_machine(const GExeFormat *format) +const char *g_exe_format_get_target_machine(const GExeFormat *format) { return format->get_machine(format); diff --git a/src/format/executable.h b/src/format/executable.h index 4dc2ddd..0607a0e 100644 --- a/src/format/executable.h +++ b/src/format/executable.h @@ -32,22 +32,6 @@ -/* Architectures de destination des formats */ -typedef enum _FormatTargetMachine -{ - FTM_NONE, /* Aucune archi. (reconnue) */ - - FTM_ARM, /* ARM vX */ - FTM_DALVIK, /* Dalvik Virtual Machine */ - FTM_JVM, /* Java Virtual Machine */ - FTM_MIPS, /* Mips 32 ou 64 bits */ - FTM_386, /* Intel 80386 */ - - FTM_COUNT - -} FormatTargetMachine; - - #define G_TYPE_EXE_FORMAT g_executable_format_get_type() #define G_EXE_FORMAT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_executable_format_get_type(), GExeFormat)) #define G_IS_EXE_FORMAT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_executable_format_get_type())) @@ -69,7 +53,7 @@ GType g_executable_format_get_type(void); /* Indique le type d'architecture visée par le format. */ -FormatTargetMachine g_exe_format_get_target_machine(const GExeFormat *); +const char *g_exe_format_get_target_machine(const GExeFormat *); /* Décrit les différentes portions qui composent le binaire. */ GBinPortion *g_exe_format_get_portions(GExeFormat *); diff --git a/src/format/format.c b/src/format/format.c index 73e6794..b44d8ed 100644 --- a/src/format/format.c +++ b/src/format/format.c @@ -182,29 +182,22 @@ const bin_t *g_binary_format_get_content(const GBinFormat *format, off_t *length /****************************************************************************** * * * Paramètres : format = description de l'exécutable à consulter. * +* ctx = contexte de désassemblage à préparer. * * * * Description : Fournit un contexte initialisé pour un désassemblage. * * * -* Retour : Nouveau contexte pour désassemblage prêt à emploi. * +* Retour : - * * * * Remarques : - * * * ******************************************************************************/ -GProcContext *g_binary_format_get_disassembling_context(const GBinFormat *format) +void g_binary_format_setup_disassembling_context(const GBinFormat *format, GProcContext *ctx) { - GProcContext *result; /* Contexte à retourner */ - GArchProcessor *proc; /* Architecture du binaire */ size_t i; /* Boucle de parcours */ - proc = get_arch_processor_from_format(G_EXE_FORMAT(format)); - - result = g_arch_processor_get_context(proc); - for (i = 0; i < format->ep_count; i++) - g_proc_context_push_drop_point(result, format->entry_points[i]); - - return result; + g_proc_context_push_drop_point(ctx, format->entry_points[i]); } diff --git a/src/format/format.h b/src/format/format.h index d2034ef..0ac658b 100644 --- a/src/format/format.h +++ b/src/format/format.h @@ -60,7 +60,7 @@ GType g_binary_format_get_type(void); const bin_t *g_binary_format_get_content(const GBinFormat *, off_t *); /* Fournit un contexte initialisé pour un désassemblage. */ -GProcContext *g_binary_format_get_disassembling_context(const GBinFormat *); +void g_binary_format_setup_disassembling_context(const GBinFormat *, GProcContext *); /* Ajoute un symbole à la collection du format binaire. */ void g_binary_format_add_symbol(GBinFormat *, GBinSymbol *); diff --git a/src/format/java/java.c b/src/format/java/java.c index 16c9fb7..e477b82 100755 --- a/src/format/java/java.c +++ b/src/format/java/java.c @@ -46,7 +46,7 @@ static void g_java_format_class_init(GJavaFormatClass *); static void g_java_format_init(GJavaFormat *); /* Indique le type d'architecture visée par le format. */ -static FormatTargetMachine g_java_format_get_target_machine(const GJavaFormat *); +static const char *g_java_format_get_target_machine(const GJavaFormat *); /* Fournit la position correspondant à une adresse virtuelle. */ static bool g_java_format_translate_address_into_offset(const GJavaFormat *, vmpa_t, off_t *); @@ -181,32 +181,9 @@ GBinFormat *g_java_format_new(const bin_t *content, off_t length) * * ******************************************************************************/ -static FormatTargetMachine g_java_format_get_target_machine(const GJavaFormat *format) +static const char *g_java_format_get_target_machine(const GJavaFormat *format) { - FormatTargetMachine result; /* Identifiant à retourner */ - - result = FTM_386; - - /* - switch (format->header.e_machine) - { - case EM_MIPS: - result = FTM_MIPS; - break; - - case EM_386: - result = FTM_386; - break; - - case EM_NONE: - default: - result = FTM_NONE; - break; - - } - */ - - return result; + return "jvm"; } diff --git a/src/format/pe/pe.c b/src/format/pe/pe.c index 16a9032..88756dd 100644 --- a/src/format/pe/pe.c +++ b/src/format/pe/pe.c @@ -40,7 +40,7 @@ static void g_pe_format_class_init(GPeFormatClass *); static void g_pe_format_init(GPeFormat *); /* Indique le type d'architecture visée par le format. */ -static FormatTargetMachine g_pe_format_get_target_machine(const GPeFormat *); +static const char *g_pe_format_get_target_machine(const GPeFormat *); /* Fournit les références aux zones binaires à analyser. */ //static GBinPart **g_pe_format_get_parts(const GPeFormat *, size_t *); @@ -220,32 +220,9 @@ GBinFormat *g_pe_format_new(const bin_t *content, off_t length) * * ******************************************************************************/ -static FormatTargetMachine g_pe_format_get_target_machine(const GPeFormat *format) +static const char *g_pe_format_get_target_machine(const GPeFormat *format) { - FormatTargetMachine result; /* Identifiant à retourner */ - - result = FTM_386; - - /* - switch (format->header.e_machine) - { - case EM_MIPS: - result = FTM_MIPS; - break; - - case EM_386: - result = FTM_386; - break; - - case EM_NONE: - default: - result = FTM_NONE; - break; - - } - */ - - return result; + return "i386"; } diff --git a/src/gui/panels/bookmarks.c b/src/gui/panels/bookmarks.c index 4b4777e..9239203 100644 --- a/src/gui/panels/bookmarks.c +++ b/src/gui/panels/bookmarks.c @@ -473,7 +473,6 @@ static void reload_bookmarks_into_treeview(GBookmarksPanel *panel, GLoadedBinary { GtkTreeStore *store; /* Modèle de gestion */ GDbCollection *collec; /* Collection à lister ici */ - GExeFormat *format; /* Format du fichier binaire */ GArchProcessor *proc; /* Architecture du binaire */ MemoryDataSize msize; /* Taille par défaut */ GList *items; /* Liste des éléments groupés */ @@ -503,10 +502,9 @@ static void reload_bookmarks_into_treeview(GBookmarksPanel *panel, GLoadedBinary /* Actualisation de l'affichage */ - format = g_loaded_binary_get_format(binary); - proc = get_arch_processor_from_format(format); - + proc = g_loaded_binary_get_processor(binary); msize = g_arch_processor_get_memory_size(proc); + g_object_unref(G_OBJECT(proc)); collec = g_loaded_binary_find_collection(binary, DBF_BOOKMARKS); diff --git a/src/gui/panels/symbols.c b/src/gui/panels/symbols.c index cb10a54..e5fd390 100644 --- a/src/gui/panels/symbols.c +++ b/src/gui/panels/symbols.c @@ -635,9 +635,9 @@ static void change_symbols_panel_current_binary(GSymbolsPanel *panel, GLoadedBin static void reload_symbols_for_new_list_view(GSymbolsPanel *panel) { GExeFormat *format; /* Format associé au binaire */ - GArchProcessor *proc; /* Architecture utilisée */ GBinSymbol **symbols; /* Symboles à représenter */ size_t sym_count; /* Qté de symboles présents */ + GArchProcessor *proc; /* Architecture utilisée */ MemoryDataSize size; /* Taille des localisations */ size_t i; /* Boucle de parcours */ cairo_surface_t *icon; /* Image associée au symbole */ @@ -646,11 +646,12 @@ static void reload_symbols_for_new_list_view(GSymbolsPanel *panel) GtkTreeIter iter; /* Point d'insertion */ format = g_loaded_binary_get_format(panel->binary); - proc = get_arch_processor_from_format(format); symbols = g_binary_format_get_symbols(G_BIN_FORMAT(format), &sym_count); + proc = g_loaded_binary_get_processor(panel->binary); size = g_arch_processor_get_memory_size(proc); + g_object_unref(G_OBJECT(proc)); for (i = 0; i < sym_count; i++) { @@ -801,9 +802,9 @@ static bool find_parent_for_symbol(GtkTreeStore *store, const GBinSymbol *symbol static void reload_symbols_for_new_tree_view(GSymbolsPanel *panel) { GExeFormat *format; /* Format associé au binaire */ - GArchProcessor *proc; /* Architecture utilisée */ GBinSymbol **symbols; /* Symboles à représenter */ size_t sym_count; /* Qté de symboles présents */ + GArchProcessor *proc; /* Architecture utilisée */ MemoryDataSize size; /* Taille des localisations */ size_t i; /* Boucle de parcours */ GtkTreeIter parent; /* Point d'insertion parent */ @@ -813,11 +814,12 @@ static void reload_symbols_for_new_tree_view(GSymbolsPanel *panel) GtkTreeIter iter; /* Point d'insertion */ format = g_loaded_binary_get_format(panel->binary); - proc = get_arch_processor_from_format(format); symbols = g_binary_format_get_symbols(G_BIN_FORMAT(format), &sym_count); + proc = g_loaded_binary_get_processor(panel->binary); size = g_arch_processor_get_memory_size(proc); + g_object_unref(G_OBJECT(proc)); for (i = 0; i < sym_count; i++) { diff --git a/src/gui/status.c b/src/gui/status.c index 3a96ea1..07e8254 100644 --- a/src/gui/status.c +++ b/src/gui/status.c @@ -283,8 +283,10 @@ static void track_caret_address_on_buffer_views(GtkBufferView *view, const vmpa2 item = G_EDITOR_ITEM(info); binary = g_editor_item_get_current_binary(item); - format = g_loaded_binary_get_format(binary); - proc = get_arch_processor_from_format(format); + + proc = g_loaded_binary_get_processor(binary); + msize = g_arch_processor_get_memory_size(proc); + g_object_unref(G_OBJECT(proc)); /* Adresse brute */ @@ -374,8 +376,10 @@ static void focus_address_in_status_info(GStatusInfo *info, GLoadedBinary *binar size_t len; /* Caractère à faire basculer */ format = g_loaded_binary_get_format(binary); - proc = get_arch_processor_from_format(format); + + proc = g_loaded_binary_get_processor(binary); msize = g_arch_processor_get_memory_size(proc); + g_object_unref(G_OBJECT(proc)); msg = strdup(_("Localisation:")); diff --git a/src/main.c b/src/main.c index 724659a..8a31bcb 100644 --- a/src/main.c +++ b/src/main.c @@ -118,6 +118,7 @@ int main(int argc, char **argv) if (!load_extra_gtk_theme()) return EXIT_FAILURE; + /* Initialisation du programme */ if (!load_all_basic_components()) return EXIT_FAILURE; @@ -132,7 +133,6 @@ int main(int argc, char **argv) add_pixmap_directory(PACKAGE_SOURCE_DIR G_DIR_SEPARATOR_S "pixmaps"); /* Initialisation du programme */ - init_all_processors(); init_all_formats(); /* Création de l'interface */ diff --git a/src/panels/breaks.c b/src/panels/breaks.c index 4bdac36..18b5a17 100644 --- a/src/panels/breaks.c +++ b/src/panels/breaks.c @@ -321,6 +321,7 @@ static void add_bp_group_to_breaks_panel(GLoadedBinary *binary, GBreakGroup *gro static void refresh_breaks_panel_on_bp_added(GBreakGroup *group, GBreakPoint *point, GBreaksPanel *panel) { +#if 0 GExeFormat *format; /* Format associé au binaire */ GArchProcessor *proc; /* Architecture utilisée */ char address[VMPA_MAX_SIZE]; /* Conversion de l'adresse */ @@ -342,7 +343,7 @@ static void refresh_breaks_panel_on_bp_added(GBreakGroup *group, GBreakPoint *po /* Pour le reste... */ refresh_breaks_panel_on_bp_changed(group, point, panel); - +#endif } diff --git a/src/plugins/plugin-int.h b/src/plugins/plugin-int.h index de43a5c..5f7eac2 100644 --- a/src/plugins/plugin-int.h +++ b/src/plugins/plugin-int.h @@ -28,6 +28,7 @@ #include +#include "plugin.h" #include "plugin-def.h" #include "../gui/panels/log.h" -- cgit v0.11.2-87-g4458