summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-02-24 20:50:41 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-02-24 20:50:41 (GMT)
commit9ff8702e5c51c7916e239caee13b974dccff6413 (patch)
treed754055630699d221e00b2ceb66c358742b0650e
parenta5cd2e6519456f49a0f0d9d76dfac0ff89d8bbb1 (diff)
Shown a loaded view at its entry point at the beginning.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@479 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
-rw-r--r--ChangeLog12
-rw-r--r--src/format/format.c44
-rw-r--r--src/format/format.h3
-rw-r--r--src/format/symbol.c1
-rw-r--r--src/project.c13
5 files changed, 73 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 2560d6c..8eb28e5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+15-02-24 Cyrille Bagard <nocbos@gmail.com>
+
+ * src/format/format.c:
+ * src/format/format.h:
+ Provide a way to find a symbol by its label.
+
+ * src/format/symbol.c:
+ Add a debug comment.
+
+ * src/project.c:
+ Show a loaded view at its entry point at the beginning.
+
15-02-23 Cyrille Bagard <nocbos@gmail.com>
* src/analysis/binary.c:
diff --git a/src/format/format.c b/src/format/format.c
index 29c151d..6b63556 100644
--- a/src/format/format.c
+++ b/src/format/format.c
@@ -25,6 +25,7 @@
#include <malloc.h>
+#include <string.h>
#include "format-int.h"
@@ -223,6 +224,49 @@ GBinSymbol **g_binary_format_get_symbols(const GBinFormat *format, size_t *count
/******************************************************************************
* *
* Paramètres : format = informations chargées à consulter. *
+* label = étiquette à retrouver lors des recherches. *
+* symbol = éventuel symbole trouvé à déréfenrencer. [OUT] *
+* *
+* Description : Recherche le symbole correspondant à une étiquette. *
+* *
+* Retour : true si l'opération a été un succès, false sinon. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_binary_format_find_symbol_by_label(const GBinFormat *format, const char *label, GBinSymbol **symbol)
+{
+ bool result; /* Bilan à retourner */
+ size_t i; /* Boucle de parcours */
+ const char *cur_lbl; /* Etiquette courante */
+
+ result = false;
+
+ for (i = 0; i < format->symbols_count && !result; i++)
+ {
+ cur_lbl = g_binary_symbol_get_label(format->symbols[i]);
+ if (cur_lbl == NULL) continue;
+
+ if (strcmp(label, cur_lbl) == 0)
+ {
+ *symbol = format->symbols[i];
+ g_object_ref(G_OBJECT(*symbol));
+
+ result = true;
+
+ }
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = informations chargées à consulter. *
* addr = adresse à cibler lors des recherches. *
* symbol = éventuel symbole trouvé à déréfenrencer. [OUT] *
* *
diff --git a/src/format/format.h b/src/format/format.h
index ebad980..e23b4bd 100644
--- a/src/format/format.h
+++ b/src/format/format.h
@@ -70,6 +70,9 @@ void g_binary_format_add_symbol(GBinFormat *, GBinSymbol *);
/* Fournit la liste de tous les symboles détectés. */
GBinSymbol **g_binary_format_get_symbols(const GBinFormat *, size_t *);
+/* Recherche le symbole correspondant à une étiquette. */
+bool g_binary_format_find_symbol_by_label(const GBinFormat *, const char *, GBinSymbol **);
+
/* Recherche le symbole correspondant à une adresse. */
bool g_binary_format_find_symbol_at(const GBinFormat *, const vmpa2t *, GBinSymbol **);
diff --git a/src/format/symbol.c b/src/format/symbol.c
index ce5c837..7817d5f 100644
--- a/src/format/symbol.c
+++ b/src/format/symbol.c
@@ -379,6 +379,7 @@ const mrange_t *g_binary_symbol_get_range(const GBinSymbol *symbol)
break;
default:
+ /* FIXME : assert(0); */
result = NULL;
break;
diff --git a/src/project.c b/src/project.c
index 7c98d96..f3a2702 100644
--- a/src/project.c
+++ b/src/project.c
@@ -324,11 +324,24 @@ const char *g_study_project_get_filename(const GStudyProject *project)
void g_study_project_add_loaded_binary(GLoadedBinary *binary, GStudyProject *project)
{
size_t index; /* Indice du nouveau binaire */
+ GBinFormat *format; /* Format associé au binaire */
+ GBinSymbol *symbol; /* Point d'entrée trouvé */
+ const mrange_t *range; /* Emplacement de ce point */
index = g_study_project_attach_binary(project, binary);
g_panel_item_dock(G_PANEL_ITEM(project->binaries[index]->item));
+ format = G_BIN_FORMAT(g_loaded_binary_get_format(binary));
+
+ if (g_binary_format_find_symbol_by_label(format, "entry_point", &symbol))
+ {
+ range = g_binary_symbol_get_range(symbol);
+
+ gtk_view_panel_scroll_to_address(project->binaries[index]->views[BVW_BLOCK], get_mrange_addr(range));
+
+ }
+
}