From 4f3f96c2c98ac507f4aa7c83e2393c5c1fdd3cdd Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Sun, 26 Mar 2017 16:02:38 +0200 Subject: Limited the displayed calls and strings in tooltips using the configuration. --- ChangeLog | 9 +++++++++ src/analysis/routine.c | 27 +++++++++++++++++++++++---- src/core/params.c | 5 ++++- src/core/params.h | 3 ++- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1008968..2c34438 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 17-03-26 Cyrille Bagard + * src/analysis/routine.c: + Limit the displayed calls and strings in tooltips using the configuration. + + * src/core/params.c: + * src/core/params.h: + Update the global default configuration. + +17-03-26 Cyrille Bagard + * src/arch/immediate.c: Fix the conversion of immediate operands to binary strings. diff --git a/src/analysis/routine.c b/src/analysis/routine.c index 9ec17c1..f84a5fd 100644 --- a/src/analysis/routine.c +++ b/src/analysis/routine.c @@ -35,6 +35,7 @@ #include "../arch/raw.h" #include "../common/extstr.h" +#include "../core/params.h" @@ -1156,6 +1157,9 @@ void g_binary_routine_print_code(const GBinRoutine *routine, GLangOutput *lang, char *g_binary_routine_build_tooltip(const GBinRoutine *routine, const GLoadedBinary *binary) { char *result; /* Description à retourner */ + GGenConfig *config; /* Configuration à consulter */ + unsigned int max_calls; /* Quantité d'appels à afficher*/ + unsigned int max_strings; /* Nbre de chaînes à afficher */ unsigned int ins_count; /* Quantité d'instructions */ unsigned int call_count; /* Quantité d'appels */ char *call_info; /* Détails des appels */ @@ -1176,6 +1180,19 @@ char *g_binary_routine_build_tooltip(const GBinRoutine *routine, const GLoadedBi result = NULL; + + config = get_main_configuration(); + + if (!g_generic_config_get_value(config, MPK_TOOLTIP_MAX_CALLS, &max_calls)) + goto gbrbt_bad_config; + + max_calls++; + + if (!g_generic_config_get_value(config, MPK_TOOLTIP_MAX_STRINGS, &max_strings)) + goto gbrbt_bad_config; + + max_strings++; + ins_count = 0; call_count = 0; @@ -1212,10 +1229,10 @@ char *g_binary_routine_build_tooltip(const GBinRoutine *routine, const GLoadedBi call_count++; - if (call_count > 6) + if (call_count > max_calls) continue; - if (call_count == 6) + if (call_count == max_calls) { call_info = stradd(call_info, "\n ..."); continue; @@ -1263,10 +1280,10 @@ char *g_binary_routine_build_tooltip(const GBinRoutine *routine, const GLoadedBi string_count++; - if (string_count > 6) + if (string_count > max_strings) continue; - if (string_count == 6) + if (string_count == max_strings) { string_info = stradd(string_info, "\n ..."); continue; @@ -1379,6 +1396,8 @@ char *g_binary_routine_build_tooltip(const GBinRoutine *routine, const GLoadedBi g_object_unref(G_OBJECT(cache)); g_object_unref(G_OBJECT(proc)); + gbrbt_bad_config: + return result; } diff --git a/src/core/params.c b/src/core/params.c index a82f186..bf662a1 100644 --- a/src/core/params.c +++ b/src/core/params.c @@ -207,7 +207,10 @@ bool load_main_config_parameters(void) param = g_generic_config_create_param(config, MPK_SELECTION_LINE, CPT_BOOLEAN, true); if (param == NULL) return false; - param = g_generic_config_create_param(config, MPK_TOOLTIP_SIZE, CPT_INTEGER, 8); + param = g_generic_config_create_param(config, MPK_TOOLTIP_MAX_CALLS, CPT_INTEGER, 5); + if (param == NULL) return false; + + param = g_generic_config_create_param(config, MPK_TOOLTIP_MAX_STRINGS, CPT_INTEGER, 5); if (param == NULL) return false; param = g_generic_config_create_param(config, MPK_KEYBINDINGS_EDIT, CPT_STRING, "F2"); diff --git a/src/core/params.h b/src/core/params.h index 9bbffc6..ee5583f 100644 --- a/src/core/params.h +++ b/src/core/params.h @@ -63,7 +63,8 @@ #define MPK_WELCOME_STARTUP "gui.editor.panels.welcome.show_at_startup" #define MPK_WELCOME_CHECK "gui.editor.panels.welcome.check_version" #define MPK_SELECTION_LINE "gui.editor.views.selection_line" -#define MPK_TOOLTIP_SIZE "gui.editor.views.tooltip_max_size" +#define MPK_TOOLTIP_MAX_CALLS "gui.editor.views.tooltip_max_calls" +#define MPK_TOOLTIP_MAX_STRINGS "gui.editor.views.tooltip_max_strings" #define MPK_KEYBINDINGS_EDIT "gui.key_bindings.global.edit" #define MPK_AUTO_SAVE "project.autosave" -- cgit v0.11.2-87-g4458