diff options
Diffstat (limited to 'src/arch')
-rw-r--r-- | src/arch/Makefile.am | 45 | ||||
-rw-r--r-- | src/arch/instruction-int.h | 4 | ||||
-rw-r--r-- | src/arch/instruction.c | 14 | ||||
-rw-r--r-- | src/arch/instruction.h | 12 | ||||
-rw-r--r-- | src/arch/instructions/Makefile.am | 18 | ||||
-rw-r--r-- | src/arch/instructions/raw.c | 2 | ||||
-rw-r--r-- | src/arch/instructions/undefined-int.h | 4 | ||||
-rw-r--r-- | src/arch/instructions/undefined.c | 2 | ||||
-rw-r--r-- | src/arch/operand-int.c | 308 | ||||
-rw-r--r-- | src/arch/operand-int.h | 59 | ||||
-rw-r--r-- | src/arch/operand.c | 74 | ||||
-rw-r--r-- | src/arch/operand.h | 4 | ||||
-rw-r--r-- | src/arch/operands/Makefile.am | 12 | ||||
-rw-r--r-- | src/arch/operands/immediate-int.h | 4 | ||||
-rw-r--r-- | src/arch/operands/immediate.c | 14 | ||||
-rw-r--r-- | src/arch/operands/known.c | 14 | ||||
-rw-r--r-- | src/arch/operands/proxy.c | 12 | ||||
-rw-r--r-- | src/arch/operands/target-int.h | 4 | ||||
-rw-r--r-- | src/arch/operands/target.c | 14 | ||||
-rw-r--r-- | src/arch/vmpa.h | 56 |
20 files changed, 584 insertions, 92 deletions
diff --git a/src/arch/Makefile.am b/src/arch/Makefile.am index 3ea5713..bdfceb7 100644 --- a/src/arch/Makefile.am +++ b/src/arch/Makefile.am @@ -1,29 +1,29 @@ noinst_LTLIBRARIES = libarch.la -libarch_la_SOURCES = \ - archbase.h archbase.c \ - context-int.h \ - context.h context.c \ - instriter.h instriter.c \ - instruction-int.h \ - instruction.h instruction.c \ - link.h link.c \ - operand-int.h \ - operand.h operand.c \ - post.h post.c \ - processor-int.h \ - processor.h processor.c \ - register-int.h \ - register.h register.c \ - storage.h storage.c \ +libarch_la_SOURCES = \ + archbase.h archbase.c \ + context-int.h \ + context.h context.c \ + instriter.h instriter.c \ + instruction-int.h \ + instruction.h instruction.c \ + link.h link.c \ + operand-int.h operand-int.c \ + operand.h operand.c \ + post.h post.c \ + processor-int.h \ + processor.h processor.c \ + register-int.h \ + register.h register.c \ + storage.h storage.c \ vmpa.h vmpa.c -libarch_la_LIBADD = \ - instructions/libarchinstructions.la \ - operands/libarchoperands.la +libarch_la_CFLAGS = $(TOOLKIT_CFLAGS) $(LIBXML_CFLAGS) -libarch_la_LDFLAGS = +libarch_la_LIBADD = \ + instructions/libarchinstructions.la \ + operands/libarchoperands.la devdir = $(includedir)/chrysalide/$(subdir:src/%=core/%) @@ -31,9 +31,4 @@ devdir = $(includedir)/chrysalide/$(subdir:src/%=core/%) dev_HEADERS = $(libarch_la_SOURCES:%c=) -AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) - -AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) - - SUBDIRS = instructions operands diff --git a/src/arch/instruction-int.h b/src/arch/instruction-int.h index f8998a1..7dbbe27 100644 --- a/src/arch/instruction-int.h +++ b/src/arch/instruction-int.h @@ -90,7 +90,7 @@ struct _GArchInstruction { GObject parent; /* A laisser en premier */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ /** * L'inclusion des informations suivantes dépend de l'architecture. @@ -162,7 +162,7 @@ struct _GArchInstructionClass * Accès aux informations éventuellement déportées. */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ # define GET_ARCH_INSTR_EXTRA(ins) (instr_extra_data_t *)&ins->extra diff --git a/src/arch/instruction.c b/src/arch/instruction.c index 4de16d6..cd1e9c7 100644 --- a/src/arch/instruction.c +++ b/src/arch/instruction.c @@ -35,11 +35,11 @@ #include "instruction-int.h" #include "storage.h" #include "../analysis/storage/serialize-int.h" +#include "../core/columns.h" #include "../core/logs.h" #include "../core/processors.h" #include "../glibext/gbinarycursor.h" #include "../glibext/linegen-int.h" -#include "../gtkext/gtkblockdisplay.h" @@ -81,12 +81,16 @@ bool g_arch_instruction_store_destinations(GArchInstruction *, GObjectStorage *, /* Indique le nombre de ligne prêtes à être générées. */ static size_t g_arch_instruction_count_lines(const GArchInstruction *); +#ifdef INCLUDE_GTK_SUPPORT + /* Retrouve l'emplacement correspondant à une position donnée. */ static void g_arch_instruction_compute_cursor(const GArchInstruction *, gint, size_t, size_t, GLineCursor **); /* Détermine si le conteneur s'inscrit dans une plage donnée. */ static int g_arch_instruction_contain_cursor(const GArchInstruction *, size_t, size_t, const GLineCursor *); +#endif + /* Renseigne sur les propriétés liées à un générateur. */ static BufferLineFlags g_arch_instruction_get_flags2(const GArchInstruction *, size_t, size_t); @@ -195,8 +199,10 @@ static void g_arch_instruction_init(GArchInstruction *instr) static void g_arch_instruction_generator_init(GLineGeneratorInterface *iface) { iface->count = (linegen_count_lines_fc)g_arch_instruction_count_lines; +#ifdef INCLUDE_GTK_SUPPORT iface->compute = (linegen_compute_fc)g_arch_instruction_compute_cursor; iface->contain = (linegen_contain_fc)g_arch_instruction_contain_cursor; +#endif iface->get_flags = (linegen_get_flags_fc)g_arch_instruction_get_flags2; iface->print = (linegen_print_fc)g_arch_instruction_print; @@ -1835,6 +1841,9 @@ static size_t g_arch_instruction_count_lines(const GArchInstruction *instr) } +#ifdef INCLUDE_GTK_SUPPORT + + /****************************************************************************** * * * Paramètres : instr = générateur à consulter. * @@ -1891,6 +1900,9 @@ static int g_arch_instruction_contain_cursor(const GArchInstruction *instr, size } +#endif + + /****************************************************************************** * * * Paramètres : instr = générateur à consulter. * diff --git a/src/arch/instruction.h b/src/arch/instruction.h index 26eadc9..3c9c149 100644 --- a/src/arch/instruction.h +++ b/src/arch/instruction.h @@ -38,12 +38,12 @@ -#define G_TYPE_ARCH_INSTRUCTION g_arch_instruction_get_type() -#define G_ARCH_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_arch_instruction_get_type(), GArchInstruction)) -#define G_IS_ARCH_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_arch_instruction_get_type())) -#define G_ARCH_INSTRUCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARCH_INSTRUCTION, GArchInstructionClass)) -#define G_IS_ARCH_INSTRUCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARCH_INSTRUCTION)) -#define G_ARCH_INSTRUCTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARCH_INSTRUCTION, GArchInstructionClass)) +#define G_TYPE_ARCH_INSTRUCTION g_arch_instruction_get_type() +#define G_ARCH_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_arch_instruction_get_type(), GArchInstruction)) +#define G_IS_ARCH_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_arch_instruction_get_type())) +#define G_ARCH_INSTRUCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARCH_INSTRUCTION, GArchInstructionClass)) +#define G_IS_ARCH_INSTRUCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARCH_INSTRUCTION)) +#define G_ARCH_INSTRUCTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARCH_INSTRUCTION, GArchInstructionClass)) /* Définition générique d'une instruction d'architecture (instance) */ diff --git a/src/arch/instructions/Makefile.am b/src/arch/instructions/Makefile.am index 24d3eb5..28cf90f 100644 --- a/src/arch/instructions/Makefile.am +++ b/src/arch/instructions/Makefile.am @@ -1,24 +1,14 @@ noinst_LTLIBRARIES = libarchinstructions.la -libarchinstructions_la_SOURCES = \ - raw.h raw.c \ - undefined-int.h \ +libarchinstructions_la_SOURCES = \ + raw.h raw.c \ + undefined-int.h \ undefined.h undefined.c -libarchinstructions_la_LIBADD = - -libarchinstructions_la_LDFLAGS = +libarchinstructions_la_CFLAGS = $(TOOLKIT_CFLAGS) $(LIBXML_CFLAGS) devdir = $(includedir)/chrysalide/$(subdir:src/%=core/%) dev_HEADERS = $(libarchinstructions_la_SOURCES:%c=) - - -AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) - -AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) - - -SUBDIRS = diff --git a/src/arch/instructions/raw.c b/src/arch/instructions/raw.c index 6340e46..26282fa 100644 --- a/src/arch/instructions/raw.c +++ b/src/arch/instructions/raw.c @@ -35,7 +35,7 @@ #include "../instruction-int.h" #include "../operands/immediate.h" #include "../operands/target.h" -#include "../../gtkext/gtkblockdisplay.h" +#include "../../core/columns.h" diff --git a/src/arch/instructions/undefined-int.h b/src/arch/instructions/undefined-int.h index 491ec31..a9b7627 100644 --- a/src/arch/instructions/undefined-int.h +++ b/src/arch/instructions/undefined-int.h @@ -73,9 +73,9 @@ struct _GUndefInstructionClass * Accès aux informations éventuellement déportées. */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ -# define GET_UNDEF_INSTR_EXTRA(ins) (undef_extra_data_t *)&ins->extra +# define GET_UNDEF_INSTR_EXTRA(ins) ((undef_extra_data_t *)&((GArchInstruction *)ins)->extra) #else diff --git a/src/arch/instructions/undefined.c b/src/arch/instructions/undefined.c index 7ed5db9..15c63e7 100644 --- a/src/arch/instructions/undefined.c +++ b/src/arch/instructions/undefined.c @@ -31,7 +31,7 @@ #include "undefined-int.h" -#include "../../gtkext/gtkblockdisplay.h" +#include "../../core/columns.h" diff --git a/src/arch/operand-int.c b/src/arch/operand-int.c new file mode 100644 index 0000000..51e8d44 --- /dev/null +++ b/src/arch/operand-int.c @@ -0,0 +1,308 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * operand-int.c - définition générique interne des opérandes + * + * Copyright (C) 2021 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide 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. + * + * Chrysalide 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 Chrysalide. If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "operand-int.h" + + + +/* ---------------------------------------------------------------------------------- */ +/* CONSERVATION ET RECHARGEMENT DES DONNEES */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +* * +* Paramètres : operand = élément GLib à consulter. * +* storage = conservateur de données à manipuler ou NULL. * +* pbuf = zone tampon à consulter. * +* count = quantité d'opérandes à extraire du tampon. * +* * +* Description : Charge une série d'opérandes internes depuis un tampon. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool _g_arch_operand_load_inner_instances(GArchOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf, size_t count) +{ + bool result; /* Bilan à retourner */ + GArchOperand **instances; /* Liste d'opérandes à charger */ + size_t i; /* Boucle de parcours */ + + result = true; + + instances = calloc(count, sizeof(GArchOperand *)); + + for (i = 0; i < count && result; i++) + result = g_object_storage_unpack_object_2(storage, "operands", pbuf, G_TYPE_ARCH_OPERAND, &instances[i]); + + if (result) + g_arch_operand_update_inner_instances(operand, instances, count); + + for (i = 0; i < count; i++) + g_clear_object(&instances[i]); + + free(instances); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = élément GLib à consulter. * +* storage = conservateur de données à manipuler ou NULL. * +* pbuf = zone tampon à consulter. * +* * +* Description : Charge une série d'opérandes internes depuis un tampon. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_arch_operand_load_generic_fixed_1(GArchOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf) +{ + bool result; /* Bilan à retourner */ + GType type; /* Type d'opérande manipulé */ + GArchOperandClass *parent; /* Classe parente à consulter */ + + type = G_TYPE_FROM_INSTANCE(operand); + + parent = g_type_class_peek_parent(g_type_class_peek(type)); + + result = parent->load(G_ARCH_OPERAND(operand), storage, pbuf); + + if (result) + result = _g_arch_operand_load_inner_instances(operand, storage, pbuf, 1); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = élément GLib à consulter. * +* storage = conservateur de données à manipuler ou NULL. * +* pbuf = zone tampon à consulter. * +* * +* Description : Charge une série d'opérandes internes depuis un tampon. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_arch_operand_load_generic_fixed_3(GArchOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf) +{ + bool result; /* Bilan à retourner */ + GType type; /* Type d'opérande manipulé */ + GArchOperandClass *parent; /* Classe parente à consulter */ + + type = G_TYPE_FROM_INSTANCE(operand); + + parent = g_type_class_peek_parent(g_type_class_peek(type)); + + result = parent->load(G_ARCH_OPERAND(operand), storage, pbuf); + + if (result) + result = _g_arch_operand_load_inner_instances(operand, storage, pbuf, 3); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = élément GLib à consulter. * +* storage = conservateur de données à manipuler ou NULL. * +* pbuf = zone tampon à consulter. * +* * +* Description : Charge une série d'opérandes internes depuis un tampon. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_arch_operand_load_generic_variadic(GArchOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf) +{ + bool result; /* Bilan à retourner */ + GType type; /* Type d'opérande manipulé */ + GArchOperandClass *parent; /* Classe parente à consulter */ + uleb128_t value; /* Valeur ULEB128 à charger */ + + type = G_TYPE_FROM_INSTANCE(operand); + + parent = g_type_class_peek_parent(g_type_class_peek(type)); + + result = parent->load(G_ARCH_OPERAND(operand), storage, pbuf); + + if (result) + result = unpack_uleb128(&value, pbuf); + + if (result) + result = _g_arch_operand_load_inner_instances(operand, storage, pbuf, value); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = élément GLib à consulter. * +* storage = conservateur de données à manipuler ou NULL. * +* pbuf = zone tampon à remplir. * +* fixed = précise si le nombre d'opérande est fixe ou non. * +* * +* Description : Sauvegarde une série d'opérandes internes dans un tampon. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool _g_arch_operand_store_inner_instances(GArchOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf, bool fixed) +{ + bool result; /* Bilan à retourner */ + size_t count; /* Nombre d'opérandes listées */ + GArchOperand **instances; /* Liste d'opérandes à traiter */ + size_t i; /* Boucle de parcours */ + GSerializableObject *obj; /* Objet à conserver */ + + result = true; + + instances = g_arch_operand_list_inner_instances(operand, &count); + + if (!fixed) + result = pack_uleb128((uleb128_t []){ count }, pbuf); + + if (instances != NULL) + { + for (i = 0; i < count && result; i++) + { + if (instances[i] == NULL) + result = g_object_storage_pack_object(storage, "operands", NULL, pbuf); + + else + { + obj = G_SERIALIZABLE_OBJECT(instances[i]); + + result = g_object_storage_pack_object(storage, "operands", obj, pbuf); + + g_object_unref(G_OBJECT(instances[i])); + + } + + } + + for (; i < count && result; i++) + g_clear_object(&instances[i]); + + free(instances); + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = élément GLib à consulter. * +* storage = conservateur de données à manipuler ou NULL. * +* pbuf = zone tampon à remplir. * +* fixed = précise si le nombre d'opérande est fixe ou non. * +* * +* Description : Sauvegarde un opérande dans un tampon de façon générique. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_arch_operand_store_generic_fixed(GArchOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf) +{ + bool result; /* Bilan à retourner */ + GType type; /* Type d'opérande manipulé */ + GArchOperandClass *parent; /* Classe parente à consulter */ + + type = G_TYPE_FROM_INSTANCE(operand); + + parent = g_type_class_peek_parent(g_type_class_peek(type)); + + result = parent->store(G_ARCH_OPERAND(operand), storage, pbuf); + + if (result) + result = _g_arch_operand_store_inner_instances(operand, storage, pbuf, true); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = élément GLib à consulter. * +* storage = conservateur de données à manipuler ou NULL. * +* pbuf = zone tampon à remplir. * +* fixed = précise si le nombre d'opérande est fixe ou non. * +* * +* Description : Sauvegarde un opérande dans un tampon de façon générique. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_arch_operand_store_generic_variadic(GArchOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf) +{ + bool result; /* Bilan à retourner */ + GType type; /* Type d'opérande manipulé */ + GArchOperandClass *parent; /* Classe parente à consulter */ + + type = G_TYPE_FROM_INSTANCE(operand); + + parent = g_type_class_peek_parent(g_type_class_peek(type)); + + result = parent->store(G_ARCH_OPERAND(operand), storage, pbuf); + + if (result) + result = _g_arch_operand_store_inner_instances(operand, storage, pbuf, false); + + return result; + +} diff --git a/src/arch/operand-int.h b/src/arch/operand-int.h index d2f43f1..e6c1232 100644 --- a/src/arch/operand-int.h +++ b/src/arch/operand-int.h @@ -26,6 +26,11 @@ #include "operand.h" + + +#include <stdbool.h> + + #include "../analysis/storage/storage.h" #include "../glibext/objhole.h" @@ -43,9 +48,13 @@ typedef GArchOperand * (* get_inner_operand_fc) (const GArchOperand *, const cha /* Traduit un opérande en version humainement lisible. */ typedef void (* operand_print_fc) (const GArchOperand *, GBufferLine *); +#ifdef INCLUDE_GTK_SUPPORT + /* Construit un petit résumé concis de l'opérande. */ typedef char * (* operand_build_tooltip_fc) (const GArchOperand *, const GLoadedBinary *); +#endif + /* Fournit une liste de candidats embarqués par un candidat. */ typedef GArchOperand ** (* operand_list_inners_fc) (const GArchOperand *, size_t *); @@ -83,7 +92,7 @@ struct _GArchOperand { GObject parent; /* A laisser en premier */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ /** * L'inclusion des informations suivantes dépend de l'architecture. @@ -108,7 +117,9 @@ struct _GArchOperandClass get_inner_operand_fc get_inner; /* Récupération d'un opérande */ operand_print_fc print; /* Texte humain équivalent */ +#ifdef INCLUDE_GTK_SUPPORT operand_build_tooltip_fc build_tooltip; /* Construction de description */ +#endif operand_list_inners_fc list_inner; /* Récupération d'internes */ operand_update_inners_fc update_inner; /* Mise à jour des éléments */ @@ -124,7 +135,7 @@ struct _GArchOperandClass * Accès aux informations éventuellement déportées. */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ # define GET_ARCH_OP_EXTRA(op) (operand_extra_data_t *)&op->extra @@ -135,5 +146,49 @@ struct _GArchOperandClass #endif +/* Ajoute une information complémentaire à un opérande. */ +bool _g_arch_operand_set_flag(GArchOperand *, ArchOperandFlag, bool); + +/* Retire une information complémentaire à un opérande. */ +bool _g_arch_operand_unset_flag(GArchOperand *, ArchOperandFlag, bool); + + + +/* ------------------------ CONTROLE DU VOLUME DES INSTANCES ------------------------ */ + + +/* Fournit une liste de candidats embarqués par un candidat. */ +GArchOperand **g_arch_operand_list_inner_instances(const GArchOperand *, size_t *); + +/* Met à jour une liste de candidats embarqués par un candidat. */ +void g_arch_operand_update_inner_instances(GArchOperand *, GArchOperand **, size_t); + + + +/* -------------------- CONSERVATION ET RECHARGEMENT DES DONNEES -------------------- */ + + +/* Charge une série d'opérandes internes depuis un tampon. */ +bool _g_arch_operand_load_inner_instances(GArchOperand *, GObjectStorage *, packed_buffer_t *, size_t); + +/* Charge une série d'opérandes internes depuis un tampon. */ +bool g_arch_operand_load_generic_fixed_1(GArchOperand *, GObjectStorage *, packed_buffer_t *); + +/* Charge une série d'opérandes internes depuis un tampon. */ +bool g_arch_operand_load_generic_fixed_3(GArchOperand *, GObjectStorage *, packed_buffer_t *); + +/* Charge une série d'opérandes internes depuis un tampon. */ +bool g_arch_operand_load_generic_variadic(GArchOperand *, GObjectStorage *, packed_buffer_t *); + +/* Sauvegarde une série d'opérandes internes dans un tampon. */ +bool _g_arch_operand_store_inner_instances(GArchOperand *, GObjectStorage *, packed_buffer_t *, bool); + +/* Sauvegarde un opérande dans un tampon de façon générique. */ +bool g_arch_operand_store_generic_fixed(GArchOperand *, GObjectStorage *, packed_buffer_t *); + +/* Sauvegarde un opérande dans un tampon de façon générique. */ +bool g_arch_operand_store_generic_variadic(GArchOperand *, GObjectStorage *, packed_buffer_t *); + + #endif /* _ARCH_OPERAND_INT_H */ diff --git a/src/arch/operand.c b/src/arch/operand.c index e95f24e..0f5ffd5 100644 --- a/src/arch/operand.c +++ b/src/arch/operand.c @@ -69,10 +69,10 @@ static int _g_arch_operand_compare(const GArchOperand *, const GArchOperand *, b /* Fournit une liste de candidats embarqués par un candidat. */ -static GArchOperand **g_arch_operand_list_inner_instances(const GArchOperand *, size_t *); +GArchOperand **g_arch_operand_list_inner_instances(const GArchOperand *, size_t *); /* Met à jour une liste de candidats embarqués par un candidat. */ -static void g_arch_operand_update_inner_instances(GArchOperand *, GArchOperand **, size_t); +void g_arch_operand_update_inner_instances(GArchOperand *, GArchOperand **, size_t); /* Fournit l'empreinte d'un candidat à une centralisation. */ static guint _g_arch_operand_hash(const GArchOperand *, bool); @@ -408,6 +408,9 @@ void g_arch_operand_print(const GArchOperand *operand, GBufferLine *line) } +#ifdef INCLUDE_GTK_SUPPORT + + /****************************************************************************** * * * Paramètres : operand = opérande à consulter. * @@ -438,10 +441,14 @@ char *g_arch_operand_build_tooltip(const GArchOperand *operand, const GLoadedBin } +#endif + + /****************************************************************************** * * * Paramètres : operand = opérande à venir modifier. * * flag = drapeau d'information complémentaire à planter. * +* lock = indique un besoin de verrouillage des données. * * * * Description : Ajoute une information complémentaire à un opérande. * * * @@ -451,7 +458,7 @@ char *g_arch_operand_build_tooltip(const GArchOperand *operand, const GLoadedBin * * ******************************************************************************/ -bool g_arch_operand_set_flag(GArchOperand *operand, ArchOperandFlag flag) +bool _g_arch_operand_set_flag(GArchOperand *operand, ArchOperandFlag flag, bool lock) { bool result; /* Bilan à retourner */ operand_extra_data_t *extra; /* Données insérées à modifier */ @@ -460,13 +467,39 @@ bool g_arch_operand_set_flag(GArchOperand *operand, ArchOperandFlag flag) extra = GET_ARCH_OP_EXTRA(operand); - LOCK_GOBJECT_EXTRA(extra); + if (lock) + LOCK_GOBJECT_EXTRA(extra); result = !(extra->flags & flag); extra->flags |= flag; - UNLOCK_GOBJECT_EXTRA(extra); + if (lock) + UNLOCK_GOBJECT_EXTRA(extra); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à venir modifier. * +* flag = drapeau d'information complémentaire à planter. * +* * +* Description : Ajoute une information complémentaire à un opérande. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_arch_operand_set_flag(GArchOperand *operand, ArchOperandFlag flag) +{ + bool result; /* Bilan à retourner */ + + result = _g_arch_operand_set_flag(operand, flag, true); return result; @@ -477,6 +510,7 @@ bool g_arch_operand_set_flag(GArchOperand *operand, ArchOperandFlag flag) * * * Paramètres : operand = opérande à venir modifier. * * flag = drapeau d'information complémentaire à planter. * +* lock = indique un besoin de verrouillage des données. * * * * Description : Retire une information complémentaire à un opérande. * * * @@ -486,7 +520,7 @@ bool g_arch_operand_set_flag(GArchOperand *operand, ArchOperandFlag flag) * * ******************************************************************************/ -bool g_arch_operand_unset_flag(GArchOperand *operand, ArchOperandFlag flag) +bool _g_arch_operand_unset_flag(GArchOperand *operand, ArchOperandFlag flag, bool lock) { bool result; /* Bilan à retourner */ operand_extra_data_t *extra; /* Données insérées à modifier */ @@ -510,6 +544,30 @@ bool g_arch_operand_unset_flag(GArchOperand *operand, ArchOperandFlag flag) /****************************************************************************** * * +* Paramètres : operand = opérande à venir modifier. * +* flag = drapeau d'information complémentaire à planter. * +* * +* Description : Retire une information complémentaire à un opérande. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_arch_operand_unset_flag(GArchOperand *operand, ArchOperandFlag flag) +{ + bool result; /* Bilan à retourner */ + + result = _g_arch_operand_unset_flag(operand, flag, true); + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : operand = opérande à venir consulter. * * flag = drapeau d'information à rechercher. * * * @@ -590,7 +648,7 @@ ArchOperandFlag g_arch_operand_get_flags(const GArchOperand *operand) * * ******************************************************************************/ -static GArchOperand **g_arch_operand_list_inner_instances(const GArchOperand *operand, size_t *count) +GArchOperand **g_arch_operand_list_inner_instances(const GArchOperand *operand, size_t *count) { GArchOperand **result; /* Instances à retourner */ GArchOperandClass *class; /* Classe associée à l'objet */ @@ -625,7 +683,7 @@ static GArchOperand **g_arch_operand_list_inner_instances(const GArchOperand *op * * ******************************************************************************/ -static void g_arch_operand_update_inner_instances(GArchOperand *operand, GArchOperand **instances, size_t count) +void g_arch_operand_update_inner_instances(GArchOperand *operand, GArchOperand **instances, size_t count) { GArchOperandClass *class; /* Classe associée à l'objet */ diff --git a/src/arch/operand.h b/src/arch/operand.h index a93e898..234ee64 100644 --- a/src/arch/operand.h +++ b/src/arch/operand.h @@ -88,9 +88,13 @@ GArchOperand *g_arch_operand_get_inner_operand_from_path(const GArchOperand *, c /* Traduit un opérande en version humainement lisible. */ void g_arch_operand_print(const GArchOperand *, GBufferLine *); +#ifdef INCLUDE_GTK_SUPPORT + /* Construit un petit résumé concis de l'opérande. */ char *g_arch_operand_build_tooltip(const GArchOperand *, const GLoadedBinary *); +#endif + /* Ajoute une information complémentaire à un opérande. */ bool g_arch_operand_set_flag(GArchOperand *, ArchOperandFlag); diff --git a/src/arch/operands/Makefile.am b/src/arch/operands/Makefile.am index 4371457..f2a8767 100644 --- a/src/arch/operands/Makefile.am +++ b/src/arch/operands/Makefile.am @@ -18,19 +18,9 @@ libarchoperands_la_SOURCES = \ targetable-int.h \ targetable.h targetable.c -libarchoperands_la_LIBADD = - -libarchoperands_la_LDFLAGS = +libarchoperands_la_CFLAGS = $(TOOLKIT_CFLAGS) $(LIBXML_CFLAGS) devdir = $(includedir)/chrysalide/$(subdir:src/%=core/%) dev_HEADERS = $(libarchoperands_la_SOURCES:%c=) - - -AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) - -AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) - - -SUBDIRS = diff --git a/src/arch/operands/immediate-int.h b/src/arch/operands/immediate-int.h index 46bc3ce..d2313f5 100644 --- a/src/arch/operands/immediate-int.h +++ b/src/arch/operands/immediate-int.h @@ -70,9 +70,9 @@ struct _GImmOperandClass * Accès aux informations éventuellement déportées. */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ -# define GET_IMM_OP_EXTRA(op) (immop_extra_data_t *)&op->extra +# define GET_IMM_OP_EXTRA(op) ((immop_extra_data_t *)&((GArchOperand *)op)->extra) #else diff --git a/src/arch/operands/immediate.c b/src/arch/operands/immediate.c index 0df8bbb..f40c645 100644 --- a/src/arch/operands/immediate.c +++ b/src/arch/operands/immediate.c @@ -43,7 +43,7 @@ #include "../../common/asm.h" #include "../../common/extstr.h" #include "../../common/sort.h" -#include "../../gtkext/gtkblockdisplay.h" +#include "../../core/columns.h" @@ -82,9 +82,13 @@ static void g_imm_operand_print(const GImmOperand *, GBufferLine *); /* Compare un opérande avec un autre. */ static int g_imm_operand_compare(const GImmOperand *, const GImmOperand *, bool); +#ifdef INCLUDE_GTK_SUPPORT + /* Construit un petit résumé concis de l'opérande. */ static char *g_imm_operand_build_tooltip(const GImmOperand *, const GLoadedBinary *); +#endif + /* Fournit l'empreinte d'un candidat à une centralisation. */ static guint g_imm_operand_hash(const GImmOperand *, bool); @@ -148,7 +152,9 @@ static void g_imm_operand_class_init(GImmOperandClass *klass) operand->compare = (operand_compare_fc)g_imm_operand_compare; operand->print = (operand_print_fc)g_imm_operand_print; +#ifdef INCLUDE_GTK_SUPPORT operand->build_tooltip = (operand_build_tooltip_fc)g_imm_operand_build_tooltip; +#endif operand->hash = (operand_hash_fc)g_imm_operand_hash; @@ -1226,6 +1232,9 @@ static int g_imm_operand_compare(const GImmOperand *a, const GImmOperand *b, boo } +#ifdef INCLUDE_GTK_SUPPORT + + /****************************************************************************** * * * Paramètres : operand = opérande à consulter. * @@ -1314,6 +1323,9 @@ static char *g_imm_operand_build_tooltip(const GImmOperand *operand, const GLoad } +#endif + + /****************************************************************************** * * * Paramètres : operand = objet dont l'instance se veut unique. * diff --git a/src/arch/operands/known.c b/src/arch/operands/known.c index a4b3844..5402879 100644 --- a/src/arch/operands/known.c +++ b/src/arch/operands/known.c @@ -32,8 +32,8 @@ #include "immediate-int.h" #include "rename-int.h" #include "../../analysis/db/misc/rlestr.h" +#include "../../core/columns.h" #include "../../core/logs.h" -#include "../../gtkext/gtkblockdisplay.h" @@ -292,12 +292,12 @@ GArchOperand *g_known_imm_operand_new(const GImmOperand *old, const char *alt) static int g_known_imm_operand_compare(const GKnownImmOperand *a, const GKnownImmOperand *b, bool lock) { int result; /* Bilan à retourner */ - lockable_obj_extra_t *ea; /* Données insérées à consulter*/ - lockable_obj_extra_t *eb; /* Données insérées à consulter*/ + immop_extra_data_t *ea; /* Données insérées à consulter*/ + immop_extra_data_t *eb; /* Données insérées à consulter*/ GArchOperandClass *class; /* Classe parente normalisée */ - ea = GET_GOBJECT_EXTRA(G_OBJECT(a), lockable_obj_extra_t); - eb = GET_GOBJECT_EXTRA(G_OBJECT(b), lockable_obj_extra_t); + ea = GET_IMM_OP_EXTRA(G_IMM_OPERAND(a)); + eb = GET_IMM_OP_EXTRA(G_IMM_OPERAND(b)); if (lock) { @@ -364,10 +364,10 @@ static void g_known_imm_operand_print(const GKnownImmOperand *operand, GBufferLi static guint g_known_imm_operand_hash(const GKnownImmOperand *operand, bool lock) { guint result; /* Valeur à retourner */ - lockable_obj_extra_t *extra; /* Données insérées à consulter*/ + immop_extra_data_t *extra; /* Données insérées à consulter*/ GArchOperandClass *class; /* Classe parente normalisée */ - extra = GET_GOBJECT_EXTRA(G_OBJECT(operand), lockable_obj_extra_t); + extra = GET_IMM_OP_EXTRA(G_IMM_OPERAND(operand)); if (lock) LOCK_GOBJECT_EXTRA(extra); diff --git a/src/arch/operands/proxy.c b/src/arch/operands/proxy.c index 91690a7..c71f96f 100644 --- a/src/arch/operands/proxy.c +++ b/src/arch/operands/proxy.c @@ -241,12 +241,12 @@ GProxyFeeder *g_proxy_operand_get_feeder(const GProxyOperand *operand) static int g_proxy_operand_compare(const GProxyOperand *a, const GProxyOperand *b, bool lock) { int result; /* Bilan à retourner */ - lockable_obj_extra_t *ea; /* Données insérées à consulter*/ - lockable_obj_extra_t *eb; /* Données insérées à consulter*/ + operand_extra_data_t *ea; /* Données insérées à consulter*/ + operand_extra_data_t *eb; /* Données insérées à consulter*/ GArchOperandClass *class; /* Classe parente normalisée */ - ea = GET_GOBJECT_EXTRA(G_OBJECT(a), lockable_obj_extra_t); - eb = GET_GOBJECT_EXTRA(G_OBJECT(b), lockable_obj_extra_t); + ea = GET_ARCH_OP_EXTRA(G_ARCH_OPERAND(a)); + eb = GET_ARCH_OP_EXTRA(G_ARCH_OPERAND(b)); if (lock) { @@ -309,10 +309,10 @@ static void g_proxy_operand_print(const GProxyOperand *operand, GBufferLine *lin static guint g_proxy_operand_hash(const GProxyOperand *operand, bool lock) { guint result; /* Valeur à retourner */ - lockable_obj_extra_t *extra; /* Données insérées à consulter*/ + operand_extra_data_t *extra; /* Données insérées à consulter*/ GArchOperandClass *class; /* Classe parente normalisée */ - extra = GET_GOBJECT_EXTRA(G_OBJECT(operand), lockable_obj_extra_t); + extra = GET_ARCH_OP_EXTRA(G_ARCH_OPERAND(operand)); if (lock) LOCK_GOBJECT_EXTRA(extra); diff --git a/src/arch/operands/target-int.h b/src/arch/operands/target-int.h index ac4cdcd..aa48b2b 100644 --- a/src/arch/operands/target-int.h +++ b/src/arch/operands/target-int.h @@ -65,9 +65,9 @@ struct _GTargetOperandClass * Accès aux informations éventuellement déportées. */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ -# define GET_TARGET_OP_EXTRA(op) (tarop_extra_data_t *)&op->extra +# define GET_TARGET_OP_EXTRA(op) ((tarop_extra_data_t *)&((GArchOperand *)op)->extra) #else diff --git a/src/arch/operands/target.c b/src/arch/operands/target.c index 068d060..61f683a 100644 --- a/src/arch/operands/target.c +++ b/src/arch/operands/target.c @@ -41,7 +41,7 @@ #include "../../format/format.h" #include "../../format/strsym.h" #include "../../glibext/gbinarycursor.h" -#include "../../gtkext/gtkblockdisplay.h" +#include "../../core/columns.h" @@ -74,9 +74,13 @@ static int g_target_operand_compare(const GTargetOperand *, const GTargetOperand /* Traduit un opérande en version humainement lisible. */ static void g_target_operand_print(const GTargetOperand *, GBufferLine *); +#ifdef INCLUDE_GTK_SUPPORT + /* Construit un petit résumé concis de l'opérande. */ static char *g_target_operand_build_tooltip(const GTargetOperand *, const GLoadedBinary *); +#endif + /* Fournit l'empreinte d'un candidat à une centralisation. */ static guint g_target_operand_hash(const GTargetOperand *, bool); @@ -132,7 +136,9 @@ static void g_target_operand_class_init(GTargetOperandClass *klass) operand->compare = (operand_compare_fc)g_target_operand_compare; operand->print = (operand_print_fc)g_target_operand_print; +#ifdef INCLUDE_GTK_SUPPORT operand->build_tooltip = (operand_build_tooltip_fc)g_target_operand_build_tooltip; +#endif operand->hash = (operand_hash_fc)g_target_operand_hash; @@ -382,6 +388,9 @@ GArchOperand *g_target_operand_new(MemoryDataSize size, const vmpa2t *addr) } +#ifdef INCLUDE_GTK_SUPPORT + + /****************************************************************************** * * * Paramètres : operand = opérande à consulter. * @@ -462,6 +471,9 @@ static char *g_target_operand_build_tooltip(const GTargetOperand *operand, const } +#endif + + /****************************************************************************** * * * Paramètres : operand = structure dont le contenu est à consulter. * diff --git a/src/arch/vmpa.h b/src/arch/vmpa.h index f353ebd..4f35ebe 100644 --- a/src/arch/vmpa.h +++ b/src/arch/vmpa.h @@ -156,6 +156,62 @@ bool store_vmpa(const vmpa2t *, const char *, bound_value **, size_t *); +/* ------------------------ DEFINITION DE POSITION AVEC BITS ------------------------ */ + + +/* Adresse mémoire ou position physique */ +typedef struct _ext_vmpa_t +{ + vmpa2t base; /* Vision macroscopique */ + + uint8_t consumed_extra_bits; /* Avancée supplémentaire */ + +} ext_vmpa_t; + + +#define init_evmpa_from_vmpa(d, s) \ + do \ + { \ + copy_vmpa(&(d)->base, (s)); \ + (d)->consumed_extra_bits = 0; \ + } \ + while (0) + +#define copy_evmpa(d, s) \ + do \ + { \ + copy_vmpa(&(d)->base, &(s)->base); \ + (d)->consumed_extra_bits = (s)->consumed_extra_bits; \ + } \ + while (0) + +#define advance_evmpa_bits(a, q) \ + do \ + { \ + uint8_t __sum; \ + __sum = (a)->consumed_extra_bits + q; \ + if (__sum > 8) \ + { \ + advance_vmpa(&(a)->base, __sum / 8); \ + (a)->consumed_extra_bits = __sum % 8; \ + } \ + else \ + (a)->consumed_extra_bits = __sum; \ + } \ + while (0) + +#define align_evmpa_on_byte(a) \ + do \ + { \ + if ((a)->consumed_extra_bits > 0) \ + { \ + advance_vmpa(&(a)->base, 1); \ + (a)->consumed_extra_bits = 0; \ + } \ + } \ + while (0); + + /* ------------------------ AIDES FONCTIONNELLES AUXILIAIRES ------------------------ */ |