diff options
Diffstat (limited to 'src/analysis/scan/matches/bytes.c')
-rw-r--r-- | src/analysis/scan/matches/bytes.c | 98 |
1 files changed, 9 insertions, 89 deletions
diff --git a/src/analysis/scan/matches/bytes.c b/src/analysis/scan/matches/bytes.c index c4c43bc..218121d 100644 --- a/src/analysis/scan/matches/bytes.c +++ b/src/analysis/scan/matches/bytes.c @@ -117,11 +117,6 @@ static void g_scan_bytes_matches_class_init(GScanBytesMatchesClass *klass) static void g_scan_bytes_matches_init(GScanBytesMatches *matches) { - matches->context = NULL; - - matches->content_start = VMPA_NO_PHYSICAL; - matches->content_end = VMPA_NO_PHYSICAL; - matches->areas = NULL; matches->count = 0; @@ -142,8 +137,6 @@ static void g_scan_bytes_matches_init(GScanBytesMatches *matches) static void g_scan_bytes_matches_dispose(GScanBytesMatches *matches) { - //g_clear_object(&matches->context); - G_OBJECT_CLASS(g_scan_bytes_matches_parent_class)->dispose(G_OBJECT(matches)); } @@ -170,8 +163,7 @@ static void g_scan_bytes_matches_finalize(GScanBytesMatches *matches) /****************************************************************************** * * -* Paramètres : source = lien vers le motif recherché d'origine. * -* context = contexte associé au scan courant. * +* Paramètres : - * * * * Description : Crée un suivi pour série de correspondances avec des octets. * * * @@ -181,87 +173,12 @@ static void g_scan_bytes_matches_finalize(GScanBytesMatches *matches) * * ******************************************************************************/ -GScanMatches *g_scan_bytes_matches_new(GSearchPattern *source, GScanContext *context) +GScanMatches *g_scan_bytes_matches_new(void) { GScanMatches *result; /* Structure à retourner */ result = g_object_new(G_TYPE_SCAN_BYTES_MATCHES, NULL); - if (!g_scan_bytes_matches_create(G_SCAN_BYTES_MATCHES(result), source, context)) - g_clear_object(&result); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : matches = instance à initialiser pleinement. * -* source = lien vers le motif recherché d'origine. * -* context = contexte associé au scan courant. * -* * -* Description : Met en place une série de correspondances avec des octets. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool g_scan_bytes_matches_create(GScanBytesMatches *matches, GSearchPattern *source, GScanContext *context) -{ - bool result; /* Bilan à retourner */ - GScanMatches *base; /* Lien vers les infos de base */ - GBinContent *content; /* Contenu à manipuler */ - vmpa2t start; /* Point de début du contenu */ - vmpa2t end; /* Point de fin du contenu */ - - result = true; - - base = G_SCAN_MATCHES(matches); - - base->source = source; - g_object_ref(G_OBJECT(source)); - - matches->context = context; - //g_object_ref(G_OBJECT(context)); - - content = g_scan_context_get_content(context); - - g_binary_content_compute_start_pos(content, &start); - g_binary_content_compute_end_pos(content, &end); - - matches->content_start = start.physical; - matches->content_end = end.physical; - - g_object_unref(G_OBJECT(content)); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : matches = informations de correspondances à consulter. * -* * -* Description : Fournit le contexte du scan associé aux correspondances. * -* * -* Retour : Contexte de scan courant. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GScanContext *g_scan_bytes_matches_get_context(const GScanBytesMatches *matches) -{ - GScanContext *result; /* Instance à retourner */ - - result = matches->context; - - g_object_ref(G_OBJECT(result)); - return result; } @@ -433,8 +350,8 @@ char *g_scan_bytes_matches_get_modifier_path(const GScanBytesMatches *matches) static void g_scan_bytes_matches_output_to_text(const GScanBytesMatches *matches, int fd) { - GBinContent *content; /* Contenu binaire analysé */ GScanMatches *base; /* Lien vers les infos de base */ + GBinContent *content; /* Contenu binaire analysé */ const char *name; /* Désignation du motif ciblé */ match_area_t *iter; /* Boucle de parcours #1 */ char value[2 + ULLONG_MAXLEN]; /* Impression de la position */ @@ -444,10 +361,10 @@ static void g_scan_bytes_matches_output_to_text(const GScanBytesMatches *matches const bin_t *data; /* Accès aux données brutes */ phys_t k; /* Boucle de parcours #2 */ - content = g_scan_context_get_content(matches->context); - base = G_SCAN_MATCHES(matches); + content = g_scan_context_get_content(base->context); + name = g_search_pattern_get_name(base->source); for_each_match_area(iter, matches->areas) @@ -547,6 +464,7 @@ static void g_scan_bytes_matches_output_to_json(const GScanBytesMatches *matches unsigned int i; /* Boucle de parcours #1 */ char value[4 + ULLONG_MAXLEN]; /* Impression de la position */ int ret; /* Bilan d'une conversion */ + GScanMatches *base; /* Lien vers les infos de base */ GBinContent *content; /* Contenu binaire analysé */ match_area_t *iter; /* Boucle de parcours #1 */ vmpa2t pos; /* Tête de lecture */ @@ -581,7 +499,9 @@ static void g_scan_bytes_matches_output_to_json(const GScanBytesMatches *matches write(fd, "\"matches\": [\n", 13); - content = g_scan_context_get_content(matches->context); + base = G_SCAN_MATCHES(matches); + + content = g_scan_context_get_content(base->context); for_each_match_area(iter, matches->areas) { |