diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2015-07-24 21:53:29 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2015-07-24 21:53:29 (GMT) |
commit | 0bd8f885b20c1d660507c62e35410e2e5a958066 (patch) | |
tree | 10c92cdaa52235f9f4ab1b7b4a51b881a7eba800 /src/analysis/db/items/bookmark.c | |
parent | 156d2e2f6beda2302552ac79678494d914fda05b (diff) |
Applied or canceled the effect of collected items on a given binary.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@556 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/analysis/db/items/bookmark.c')
-rw-r--r-- | src/analysis/db/items/bookmark.c | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/src/analysis/db/items/bookmark.c b/src/analysis/db/items/bookmark.c index c9d7b7a..8512406 100644 --- a/src/analysis/db/items/bookmark.c +++ b/src/analysis/db/items/bookmark.c @@ -44,6 +44,8 @@ struct _GDbBookmark vmpa2t addr; /* Adresse du signet */ rle_string comment; /* Eventuel commentaire associé*/ + bool prev_state; /* Drapeau déjà présent avant ?*/ + }; /* Signet à l'intérieur d'une zone de texte (classe) */ @@ -75,6 +77,15 @@ static bool g_db_bookmark_recv_from_fd(GDbBookmark *, int, int); /* Exporte la définition d'un signet dans un flux réseau. */ static bool g_db_bookmark_send_to_fd(const GDbBookmark *, int, int); +/* Exécute un signet sur un tampon de binaire chargé. */ +static bool g_db_bookmark_run(GDbBookmark *, GLoadedBinary *, bool *, bool); + +/* Applique un signet sur un tampon de binaire chargé. */ +static bool g_db_bookmark_apply(GDbBookmark *, GLoadedBinary *); + +/* Annule un signet sur un tampon de binaire chargé. */ +static bool g_db_bookmark_cancel(GDbBookmark *, GLoadedBinary *); + /* Constitue les champs destinés à une insertion / modification. */ static bool g_db_bookmark_prepare_db_statement(const GDbBookmark *, bound_value **, size_t *); @@ -161,6 +172,8 @@ static void g_db_bookmark_class_init(GDbBookmarkClass *klass) item->recv = (recv_db_item_fc)g_db_bookmark_recv_from_fd; item->send = (send_db_item_fc)g_db_bookmark_send_to_fd; + item->apply = (run_item_fc)g_db_bookmark_apply; + item->cancel = (run_item_fc)g_db_bookmark_cancel; item->prepare_stmt = (prepare_db_statement)g_db_bookmark_prepare_db_statement; item->load = (load_db_item_fc)g_db_bookmark_load; @@ -350,6 +363,106 @@ static bool g_db_bookmark_send_to_fd(const GDbBookmark *bookmark, int fd, int fl /****************************************************************************** * * +* Paramètres : bookmark = signet à manipuler. * +* binary = binaire chargé en mémoire à modifier. * +* prev = état précédent de la présence du drapeau. * +* set = précision quant au nouvel état du drapeau. * +* * +* Description : Exécute un signet sur un tampon de binaire chargé. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool g_db_bookmark_run(GDbBookmark *bookmark, GLoadedBinary *binary, bool *prev, bool set) +{ + bool result; /* Bilan à faire remonter */ + GCodeBuffer *buffer; /* Tampon de lignes à traiter */ + GBufferLine *line; /* Ligne de tampon à marquer */ + + result = true; + + buffer = g_loaded_binary_get_disassembled_buffer(binary); + + line = g_code_buffer_find_line_by_addr(buffer, &bookmark->addr, BLF_HAS_CODE, NULL); + if (line == NULL) + { + result = false; + goto exit; + } + + *prev = g_buffer_line_get_flags(line) & BLF_BOOKMARK; + + if (set) + g_buffer_line_add_flag(line, BLF_BOOKMARK); + + else + g_buffer_line_remove_flag(line, BLF_BOOKMARK); + + g_object_unref(G_OBJECT(line)); + + exit: + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : bookmark = signet à manipuler. * +* binary = binaire chargé en mémoire à modifier. * +* * +* Description : Applique un signet sur un tampon de binaire chargé. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool g_db_bookmark_apply(GDbBookmark *bookmark, GLoadedBinary *binary) +{ + bool result; /* Bilan à faire remonter */ + + result = g_db_bookmark_run(bookmark, binary, &bookmark->prev_state, true); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : bookmark = signet à manipuler. * +* binary = binaire chargé en mémoire à modifier. * +* * +* Description : Annule un signet sur un tampon de binaire chargé. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool g_db_bookmark_cancel(GDbBookmark *bookmark, GLoadedBinary *binary) +{ + bool result; /* Bilan à faire remonter */ + + if (!bookmark->prev_state) + result = g_db_bookmark_run(bookmark, binary, (bool []) { 0 }, false); + else + result = true; + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : bookmark = base d'éléments sur laquelle s'appuyer. * * values = couples de champs et de valeurs à lier. [OUT] * * count = nombre de ces couples. [OUT] * |