diff options
Diffstat (limited to 'plugins/elf/loading.c')
-rw-r--r-- | plugins/elf/loading.c | 150 |
1 files changed, 150 insertions, 0 deletions
diff --git a/plugins/elf/loading.c b/plugins/elf/loading.c index 0bb6f2b..eb992b9 100644 --- a/plugins/elf/loading.c +++ b/plugins/elf/loading.c @@ -49,6 +49,10 @@ struct _GElfLoading phys_t str_start; /* Chaînes à disposition */ + /** + * Gestion des informations de contexte. + */ + union { struct @@ -73,9 +77,23 @@ struct _GElfLoading }; + struct + { + phys_t global_start; /* Départ global dans la zone */ + phys_t global_end; /* Fin globale dans la zone */ + virt_t global_addr; /* Adresse virtuelle initiale */ + + GBinContent *content; /* Contenu binaire à lire */ + const bin_t *data; /* Contenu complet et original */ + + }; }; + /** + * Gestion du mode de parcours. + */ + union { struct @@ -195,6 +213,9 @@ static void g_elf_loading_init(GElfLoading *loading) static void g_elf_loading_dispose(GElfLoading *loading) { + if (loading->kind == 2) + g_object_unref(G_OBJECT(loading->content)); + G_OBJECT_CLASS(g_elf_loading_parent_class)->dispose(G_OBJECT(loading)); } @@ -361,6 +382,64 @@ GElfLoading *g_elf_loading_new_for_applying(GElfFormat *format, sym_iter_t *iter /****************************************************************************** * * +* Paramètres : format = ensemble d'instructions désassemblées. * +* begin = point de départ de la zone à traiter. * +* end = point d'arrivée exclu du parcours. * +* gb_start = position de départ pour l'ensemble des données. * +* gb_end = position finale dans l'ensemble des données. * +* addr = adresse virtuelle de la position initiale. * +* id = identifiant du message affiché à l'utilisateur. * +* callback = routine de traitements particuliers. * +* * +* Description : Crée une tâche de chargement de chaînes pour ELF différée. * +* * +* Retour : Tâche créée. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GElfLoading *g_elf_loading_new_for_strings(GElfFormat *format, phys_t begin, phys_t end, phys_t gb_start, phys_t gb_end, virt_t addr, activity_id_t id, elf_loading_cb callback) +{ + GElfLoading *result; /* Tâche à retourner */ + vmpa2t pos; /* Tête de lecture */ + + result = g_object_new(G_TYPE_ELF_LOADING, NULL); + + result->format = format; + + result->global_start = gb_start; + result->global_end = gb_end; + result->global_addr = addr; + + result->content = g_binary_format_get_content(G_BIN_FORMAT(format)); + + init_vmpa(&pos, gb_start, addr); + + result->data = g_binary_content_get_raw_access(result->content, &pos, gb_end - gb_start); + if (result->data == NULL) goto no_data; + + result->begin = begin; + result->end = end; + result->callback_0 = callback; + + result->kind = 2; + + result->id = id; + + return result; + + no_data: + + g_object_unref(G_OBJECT(result)); + + return NULL; + +} + + +/****************************************************************************** +* * * Paramètres : loading = traitements différés à mener. * * status = barre de statut à tenir informée. * * * @@ -435,6 +514,24 @@ static void g_elf_loading_process(GElfLoading *loading, GtkStatusStack *status) loading->status = (processed == loading->rel_count); break; + case 2: + + for (iter = loading->begin; iter < loading->end; ) + { + old = iter; + + loading->status |= loading->callback_0(loading, format, &iter); + + gtk_status_stack_update_activity_value(status, loading->id, iter - old); + + } + + break; + + default: + assert(false); + break; + } } @@ -656,3 +753,56 @@ char *g_elf_loading_build_plt_name(const GElfLoading *loading, uint64_t index) return result; } + + +/****************************************************************************** +* * +* Paramètres : loading = chargement pour ELF à mener. * +* content = gestionnaire de contenu utilisé. [OUT] * +* first = première position traitée par la tâche. [OUT] * +* offset = décalage pour les données. [OUT] * +* final = première position dans les données à exclure. [OUT]* +* * +* Description : Donne les informations utiles à la recherche de chaînes. * +* * +* Retour : Données brutes à analyser. * +* * +* Remarques : - * +* * +******************************************************************************/ + +const bin_t *g_elf_loading_get_info_for_strings(const GElfLoading *loading, GBinContent **content, phys_t *first, phys_t *offset, phys_t *final) +{ + const bin_t *result; /* Données à communiquer */ + + result = loading->data; + + *content = loading->content; + *first = loading->begin; + *offset = loading->global_start; + *final = loading->global_end; + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : loading = chargement pour ELF à poursuivre. * +* iter = point de départ dans la zone de données traitée. * +* pos = emplacement construit à la demande. [OUT] * +* * +* Description : Détermine l'adresse de départ d'une chaîne avec une position.* +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_elf_loading_compute_string_address(const GElfLoading *loading, const phys_t *iter, vmpa2t *pos) +{ + init_vmpa(pos, *iter, loading->global_addr + (*iter - loading->global_start)); + +} |