From a5cd2e6519456f49a0f0d9d76dfac0ff89d8bbb1 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Mon, 23 Feb 2015 22:56:59 +0000 Subject: Fixed a bug: do not close the connection after the initial handshake. git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@478 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a --- ChangeLog | 23 +++++++++++++ src/analysis/binary.c | 77 ++++++++++++++++++++++++++++++++++++++++++- src/analysis/binary.h | 1 - src/analysis/db/misc/rlestr.c | 2 +- src/analysis/db/server.c | 2 +- src/glibext/gbufferline.c | 33 ++++++++++++++++--- src/gui/menus/project.c | 1 - src/gui/panels/bookmarks.c | 2 +- 8 files changed, 131 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 40f1ba1..2560d6c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +15-02-23 Cyrille Bagard + + * src/analysis/binary.c: + Track updates inside the bookmarks collection. + + * src/analysis/binary.h: + Typo. + + * src/analysis/db/misc/rlestr.c: + Optimize the network pressure while sending strings. + + * src/analysis/db/server.c: + Fix a bug: do not close the connection after the initial handshake. + + * src/glibext/gbufferline.c: + Create a signal used when changing line flags. + + * src/gui/menus/project.c: + Connect to the server only once disassbling is done. + + * src/gui/panels/bookmarks.c: + Typo. + 15-02-22 Cyrille Bagard * src/gui/panels/bookmarks.c: diff --git a/src/analysis/binary.c b/src/analysis/binary.c index b94071c..cf01e16 100644 --- a/src/analysis/binary.c +++ b/src/analysis/binary.c @@ -36,6 +36,7 @@ #include "binary-int.h" #include "routine.h" #include "binaries/file.h" +#include "db/items/bookmark.h" #include "decomp/decompiler.h" #include "disass/disassembler.h" #include "../common/extstr.h" @@ -78,6 +79,15 @@ static bool g_loaded_binary_save_storage(const GLoadedBinary *, xmlDocPtr, xmlXP +/* -------------------------- MANIPULATION DES COLLECTIONS -------------------------- */ + + +/* Actualise suite à un changement affectant les signets. */ +static void on_binary_bookmarks_change(GDbCollection *, DBAction, GDbBookmark *, GLoadedBinary *); + + + + /* Indique le type défini pour une description de fichier binaire. */ @@ -138,6 +148,8 @@ static void g_loaded_binary_class_init(GLoadedBinaryClass *klass) static void g_loaded_binary_init(GLoadedBinary *binary) { + GDbCollection *collec; /* Collection à lister ici */ + binary->username = strdup("default"); binary->remote_host = strdup("localhost"); @@ -150,6 +162,9 @@ static void g_loaded_binary_init(GLoadedBinary *binary) binary->collections = create_collections_list(); + collec = g_loaded_binary_find_collection(binary, DBF_BOOKMARKS); + g_signal_connect(collec, "content-changed", G_CALLBACK(on_binary_bookmarks_change), binary); + binary->col_display[BVW_BLOCK][BLC_PHYSICAL] = true; binary->col_display[BVW_BLOCK][BLC_VIRTUAL] = true; binary->col_display[BVW_BLOCK][BLC_BINARY] = true; @@ -811,6 +826,61 @@ bool _g_loaded_binary_add_to_collection(GLoadedBinary *binary, DBFeatures featur + + +/****************************************************************************** +* * +* Paramètres : collec = collection dont le contenu vient de changer. * +* action = type de modification notifiée par la collection. * +* bookmark = élément en cause dans le changement survenu. * +* binary = structure contenant les informations maîtresses. * +* * +* Description : Actualise suite à un changement affectant les signets. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void on_binary_bookmarks_change(GDbCollection *collec, DBAction action, GDbBookmark *bookmark, GLoadedBinary *binary) +{ + const vmpa2t *addr; /* Adressse associée au signet */ + GBufferLine *line; /* Ligne de tampon à marquer */ + + addr = g_db_bookmark_get_address(bookmark); + + line = g_code_buffer_find_line_by_addr(binary->disass_buffer, addr); + + if (line != NULL) + { + if (action == DBA_ADD_ITEM) + g_buffer_line_add_flag(line, BLF_BOOKMARK); + + else /*if (action == DBA_REM_ITEM)*/ + g_buffer_line_remove_flag(line, BLF_BOOKMARK); + + g_object_unref(G_OBJECT(line)); + + } + +} + + + + + + + + + + + + + + + + /****************************************************************************** * * * Paramètres : binary = élément binaire à traiter. * @@ -832,11 +902,13 @@ void g_loaded_binary_analyse(GLoadedBinary *binary) /* Contacts avec les serveurs */ - + // Déconnexion... disassemble_binary(binary, &binary->instrs, &binary->disass_buffer, ack_completed_disassembly); + + /* TODO : remme ! */ //ack_completed_disassembly(NULL, binary); @@ -1096,6 +1168,9 @@ void ack_completed_disassembly(GDelayedDisassembly *disass, GLoadedBinary *binar g_object_unref(G_OBJECT(disass)); + g_loaded_binary_connect(binary); + + /* Décompilation... */ diff --git a/src/analysis/binary.h b/src/analysis/binary.h index b0fb369..6878fe4 100644 --- a/src/analysis/binary.h +++ b/src/analysis/binary.h @@ -112,7 +112,6 @@ bool g_loaded_binary_connect(GLoadedBinary *); -/* ------------------------- INFORMATIONS D'ENREGISTREMENTS ------------------------- */ /* -------------------------- MANIPULATION DES COLLECTIONS -------------------------- */ diff --git a/src/analysis/db/misc/rlestr.c b/src/analysis/db/misc/rlestr.c index d75e7ab..631b1e9 100644 --- a/src/analysis/db/misc/rlestr.c +++ b/src/analysis/db/misc/rlestr.c @@ -331,7 +331,7 @@ bool send_rle_string(const rle_string *str, int fd, int flags) { bool status; /* Bilan d'une opération */ - status = safe_send(fd, (uint32_t []) { htobe32(str->length) }, sizeof(uint32_t), flags); + status = safe_send(fd, (uint32_t []) { htobe32(str->length) }, sizeof(uint32_t), MSG_MORE | flags); if (!status) return false; if (str->length > 0) diff --git a/src/analysis/db/server.c b/src/analysis/db/server.c index 04b0dc4..c51c21e 100644 --- a/src/analysis/db/server.c +++ b/src/analysis/db/server.c @@ -390,7 +390,7 @@ static void *g_db_server_listener(GDbServer *server) if (archive != NULL) error = g_cdb_archive_add_client(archive, fd, &user); - + continue; gdsl_error: diff --git a/src/glibext/gbufferline.c b/src/glibext/gbufferline.c index ff64604..ac838b8 100644 --- a/src/glibext/gbufferline.c +++ b/src/glibext/gbufferline.c @@ -29,6 +29,7 @@ #include /* Récupération du langage par défaut ; FIXME ? */ +#include "chrysamarshal.h" #include "../common/extstr.h" #include "../gtkext/support.h" @@ -108,6 +109,10 @@ struct _GBufferLineClass cairo_surface_t *entrypoint_img; /* Image pour les entrées */ cairo_surface_t *bookmark_img; /* Image pour les signets */ + /* Signaux */ + + void (* flip_flag) (GBufferLine *, BufferLineFlags, BufferLineFlags); + }; @@ -445,19 +450,27 @@ static void g_buffer_line_class_init(GBufferLineClass *class) gchar *filename; /* Chemin d'accès à utiliser */ filename = find_pixmap_file("entrypoint.png"); - /* assert(filename != NULL); */ + assert(filename != NULL); class->entrypoint_img = cairo_image_surface_create_from_png(filename); g_free(filename); filename = find_pixmap_file("bookmark.png"); - /* assert(filename != NULL); */ + assert(filename != NULL); class->bookmark_img = cairo_image_surface_create_from_png(filename); g_free(filename); + g_signal_new("flip-flag", + G_TYPE_BUFFER_LINE, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(GBufferLineClass, flip_flag), + NULL, NULL, + g_cclosure_user_marshal_VOID__ENUM_ENUM, + G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); + } @@ -1172,7 +1185,13 @@ void g_buffer_line_start_merge_at(GBufferLine *line, BufferLineColumn start) void g_buffer_line_add_flag(GBufferLine *line, BufferLineFlags flag) { - line->flags |= flag; + if ((line->flags & flag) == 0) + { + g_signal_emit_by_name(line, "flip-flag", line->flags, flag); + + line->flags |= flag; + + } } @@ -1211,7 +1230,13 @@ BufferLineFlags g_buffer_line_get_flags(const GBufferLine *line) void g_buffer_line_remove_flag(GBufferLine *line, BufferLineFlags flag) { - line->flags &= ~flag; + if ((line->flags & flag) != 0) + { + g_signal_emit_by_name(line, "flip-flag", line->flags, flag); + + line->flags &= ~flag; + + } } diff --git a/src/gui/menus/project.c b/src/gui/menus/project.c index 5e86c0f..caf3f64 100644 --- a/src/gui/menus/project.c +++ b/src/gui/menus/project.c @@ -306,7 +306,6 @@ static void mcb_project_add_binary_file(GtkMenuItem *menuitem, GMenuBar *bar) g_signal_connect(binary, "disassembly-done", G_CALLBACK(g_study_project_add_loaded_binary), get_current_project()); g_loaded_binary_analyse(binary); - g_loaded_binary_connect(binary); } g_free(filename); diff --git a/src/gui/panels/bookmarks.c b/src/gui/panels/bookmarks.c index 99c1673..052bf5a 100644 --- a/src/gui/panels/bookmarks.c +++ b/src/gui/panels/bookmarks.c @@ -554,7 +554,7 @@ static void reload_bookmarks_into_treeview(GBookmarksPanel *panel, GLoadedBinary * Paramètres : collec = collection dont le contenu vient de changer. * * action = type de modification notifiée par la collection. * * bookmark = élément en cause dans le changement survenu. * -* pane = structure contenant les informations maîtresses. * +* panel = structure contenant les informations maîtresses. * * * * Description : Met à jour une collection suite à une modification. * * * -- cgit v0.11.2-87-g4458