summaryrefslogtreecommitdiff
path: root/src/analysis/scan/matches
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/scan/matches')
-rw-r--r--src/analysis/scan/matches/Makefile.am4
-rw-r--r--src/analysis/scan/matches/area.c57
-rw-r--r--src/analysis/scan/matches/area.h85
-rw-r--r--src/analysis/scan/matches/bytes-int.h26
-rw-r--r--src/analysis/scan/matches/bytes.c577
-rw-r--r--src/analysis/scan/matches/bytes.h50
-rw-r--r--src/analysis/scan/matches/pending.c147
-rw-r--r--src/analysis/scan/matches/pending.h17
8 files changed, 684 insertions, 279 deletions
diff --git a/src/analysis/scan/matches/Makefile.am b/src/analysis/scan/matches/Makefile.am
index d6b51c6..f1a69c3 100644
--- a/src/analysis/scan/matches/Makefile.am
+++ b/src/analysis/scan/matches/Makefile.am
@@ -3,9 +3,9 @@ noinst_LTLIBRARIES = libanalysisscanmatches.la
libanalysisscanmatches_la_SOURCES = \
+ area.h area.c \
bytes-int.h \
- bytes.h bytes.c \
- pending.h pending.c
+ bytes.h bytes.c
libanalysisscanmatches_la_CFLAGS = $(LIBGOBJ_CFLAGS)
diff --git a/src/analysis/scan/matches/area.c b/src/analysis/scan/matches/area.c
new file mode 100644
index 0000000..3f512b0
--- /dev/null
+++ b/src/analysis/scan/matches/area.c
@@ -0,0 +1,57 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * area.c - conservation des localisations de correspondances
+ *
+ * Copyright (C) 2023 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "area.h"
+
+
+
+/******************************************************************************
+* *
+* Paramètres : a = première zone de correspondance à comparer. *
+* b = seconde zone de correspondance à comparer. *
+* *
+* Description : Etablit une comparaison entre deux zones de correspondance. *
+* *
+* Retour : Bilan de la comparaison. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+int compare_match_area_as_dl_item(const dl_list_item *a, const dl_list_item *b)
+{
+ int result; /* Bilan à retourner */
+ match_area_t *area_a; /* Première zone à traiter */
+ match_area_t *area_b; /* Seconde zone à traiter */
+
+ area_a = match_area_from_item(a);
+ area_b = match_area_from_item(b);
+
+ result = sort_uint64_t(area_a->start, area_b->start);
+
+ if (result == 0)
+ result = sort_uint64_t(area_a->end, area_b->end);
+
+ return result;
+
+}
diff --git a/src/analysis/scan/matches/area.h b/src/analysis/scan/matches/area.h
new file mode 100644
index 0000000..b059b35
--- /dev/null
+++ b/src/analysis/scan/matches/area.h
@@ -0,0 +1,85 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * area.h - prototypes pour la conservation des localisations de correspondances
+ *
+ * Copyright (C) 2023 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _ANALYSIS_SCAN_MATCHES_AREA_H
+#define _ANALYSIS_SCAN_MATCHES_AREA_H
+
+
+#include <assert.h>
+
+
+#include "../../../arch/vmpa.h"
+#include "../../../common/dllist.h"
+
+
+
+/* Couverture d'une correspondance */
+typedef struct _match_area_t
+{
+ phys_t start; /* Point de départ */
+ phys_t end; /* Point d'arrivée (exclus) */
+
+ DL_LIST_ITEM(link); /* Lien vers les maillons */
+
+ size_t mod_path_index; /* Indice de construction */
+ bool has_mod_path; /* Validité du champ précédent */
+
+} match_area_t;
+
+
+#define match_area_from_item(item) \
+ (match_area_t *)container_of(item, match_area_t, link)
+
+#define add_tail_match_area(new, head) \
+ dl_list_add_tail(new, head, match_area_t, link)
+
+#define del_match_area(item, head) \
+ dl_list_del(item, head, match_area_t, link)
+
+#define for_each_match_area(pos, head) \
+ dl_list_for_each(pos, head, match_area_t, link)
+
+#define for_each_match_area_safe(pos, head, next) \
+ dl_list_for_each_safe(pos, head, next, match_area_t, link)
+
+#define is_last_match_area(item, head) \
+ dl_list_is_last(item, head, link)
+
+#define merge_match_areas(head1, head2) \
+ dl_list_merge(head1, head2, match_area_t, link)
+
+#define sort_match_areas_no_dup(head, len, cmp, dup) \
+ ({ \
+ assert(!dl_list_empty(*(head))); \
+ dl_list_item *hmbr = &(*head)->link; \
+ sort_dl_list_no_dup(&hmbr, len, cmp, dup); \
+ match_area_from_item(hmbr); \
+ })
+
+
+/* Etablit une comparaison entre deux zones de correspondance. */
+int compare_match_area_as_dl_item(const dl_list_item *, const dl_list_item *);
+
+
+
+#endif /* _ANALYSIS_SCAN_MATCHES_AREA_H */
diff --git a/src/analysis/scan/matches/bytes-int.h b/src/analysis/scan/matches/bytes-int.h
index 6f7e60b..f6239e3 100644
--- a/src/analysis/scan/matches/bytes-int.h
+++ b/src/analysis/scan/matches/bytes-int.h
@@ -1,6 +1,6 @@
/* Chrysalide - Outil d'analyse de fichiers binaires
- * bytes-int.h - prototypes internes pour la sauvegarde d'une correspondance identifiée de suite d'octets
+ * bytes-int.h - prototypes internes pour la sauvegarde de correspondances avec des suites d'octets identifiées
*
* Copyright (C) 2022 Cyrille Bagard
*
@@ -28,33 +28,27 @@
#include "bytes.h"
-#include "../match-int.h"
+#include "../matches-int.h"
-/* Correspondance trouvée avec une chaîne (instance) */
-struct _GScanBytesMatch
+/* Correspondances trouvées avec des suite d'octets (instance) */
+struct _GScanBytesMatches
{
- GScanMatch parent; /* A laisser en premier */
+ GScanMatches parent; /* A laisser en premier */
- GBinContent *content; /* Contenu binaire de référence*/
-
- phys_t start; /* Début du motif représenté */
- phys_t len; /* Taille du motif représenté */
+ match_area_t *areas; /* Zones couvertes */
+ size_t count; /* Nombre de zones */
};
-/* Correspondance trouvée avec une chaîne (classe) */
-struct _GScanBytesMatchClass
+/* Correspondances trouvées avec des suite d'octets (classe) */
+struct _GScanBytesMatchesClass
{
- GScanMatchClass parent; /* A laisser en premier */
+ GScanMatchesClass parent; /* A laisser en premier */
};
-/* Met en place une correspondance trouvée avec un motif. */
-bool g_scan_bytes_match_create(GScanBytesMatch *, GSearchPattern *, GBinContent *, phys_t, phys_t);
-
-
#endif /* _ANALYSIS_SCAN_MATCHES_BYTES_INT_H */
diff --git a/src/analysis/scan/matches/bytes.c b/src/analysis/scan/matches/bytes.c
index de101c4..a23188b 100644
--- a/src/analysis/scan/matches/bytes.c
+++ b/src/analysis/scan/matches/bytes.c
@@ -30,53 +30,57 @@
#include "bytes-int.h"
+#include "../patterns/token.h"
#include "../../../common/cpp.h"
#include "../../../core/logs.h"
-/* --------------------- CORRESPONDANCE AVEC UNE SUITE D'OCTETS --------------------- */
+/* -------------------- CONSERVATION DE CORRESPONDANCES ETABLIES -------------------- */
-/* Initialise la classe des correspondances de chaînes. */
-static void g_scan_bytes_match_class_init(GScanBytesMatchClass *);
+/* Initialise la classe des séries de correspondances d'octets. */
+static void g_scan_bytes_matches_class_init(GScanBytesMatchesClass *);
-/* Initialise une instance de correspondance de chaîne trouvée. */
-static void g_scan_bytes_match_init(GScanBytesMatch *);
+/* Initialise une instance de série de correspondances trouvées. */
+static void g_scan_bytes_matches_init(GScanBytesMatches *);
/* Supprime toutes les références externes. */
-static void g_scan_bytes_match_dispose(GScanBytesMatch *);
+static void g_scan_bytes_matches_dispose(GScanBytesMatches *);
/* Procède à la libération totale de la mémoire. */
-static void g_scan_bytes_match_finalize(GScanBytesMatch *);
+static void g_scan_bytes_matches_finalize(GScanBytesMatches *);
/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */
+/* Dénombre les correspondances enregistrées pour un motif. */
+static size_t g_scan_bytes_matches_count(const GScanBytesMatches *);
+
/* Affiche une correspondance au format texte. */
-static void g_scan_bytes_match_output_to_text(const GScanBytesMatch *, int);
+static void g_scan_bytes_matches_output_to_text(const GScanBytesMatches *, int);
/* Affiche une correspondance au format JSON. */
-static void g_scan_bytes_match_output_to_json(const GScanBytesMatch *, const sized_string_t *, unsigned int, int);
+static void g_scan_bytes_matches_output_to_json(const GScanBytesMatches *, const sized_string_t *, unsigned int, int);
/* ---------------------------------------------------------------------------------- */
-/* CORRESPONDANCE AVEC UNE SUITE D'OCTETS */
+/* CONSERVATION DE CORRESPONDANCES ETABLIES */
/* ---------------------------------------------------------------------------------- */
-/* Indique le type défini pour un correspondance de chaîne identifiée. */
-G_DEFINE_TYPE(GScanBytesMatch, g_scan_bytes_match, G_TYPE_SCAN_MATCH);
+/* Indique le type défini pour une série de correspondances d'octets identifiées. */
+G_DEFINE_TYPE(GScanBytesMatches, g_scan_bytes_matches, G_TYPE_SCAN_MATCHES);
/******************************************************************************
* *
* Paramètres : klass = classe à initialiser. *
* *
-* Description : Initialise la classe des correspondances de chaînes. *
+* Description : Initialise la classe des séries de correspondances d'octets. *
* *
* Retour : - *
* *
@@ -84,29 +88,31 @@ G_DEFINE_TYPE(GScanBytesMatch, g_scan_bytes_match, G_TYPE_SCAN_MATCH);
* *
******************************************************************************/
-static void g_scan_bytes_match_class_init(GScanBytesMatchClass *klass)
+static void g_scan_bytes_matches_class_init(GScanBytesMatchesClass *klass)
{
GObjectClass *object; /* Autre version de la classe */
- GScanMatchClass *match; /* Version parente de la classe*/
+ GScanMatchesClass *matches; /* Version parente de la classe*/
object = G_OBJECT_CLASS(klass);
- object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_bytes_match_dispose;
- object->finalize = (GObjectFinalizeFunc)g_scan_bytes_match_finalize;
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_bytes_matches_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_scan_bytes_matches_finalize;
+
+ matches = G_SCAN_MATCHES_CLASS(klass);
- match = G_SCAN_MATCH_CLASS(klass);
+ matches->count = (count_scan_matches_fc)g_scan_bytes_matches_count;
- match->to_text = (output_scan_match_to_text_fc)g_scan_bytes_match_output_to_text;
- match->to_json = (output_scan_match_to_json_fc)g_scan_bytes_match_output_to_json;
+ matches->to_text = (output_scan_matches_to_text_fc)g_scan_bytes_matches_output_to_text;
+ matches->to_json = (output_scan_matches_to_json_fc)g_scan_bytes_matches_output_to_json;
}
/******************************************************************************
* *
-* Paramètres : match = instance à initialiser. *
+* Paramètres : matches = instance à initialiser. *
* *
-* Description : Initialise une instance de correspondance de chaîne trouvée. *
+* Description : Initialise une instance de série de correspondances trouvées.*
* *
* Retour : - *
* *
@@ -114,19 +120,17 @@ static void g_scan_bytes_match_class_init(GScanBytesMatchClass *klass)
* *
******************************************************************************/
-static void g_scan_bytes_match_init(GScanBytesMatch *match)
+static void g_scan_bytes_matches_init(GScanBytesMatches *matches)
{
- match->content = NULL;
-
- match->start = VMPA_NO_PHYSICAL;
- match->len = VMPA_NO_PHYSICAL;
+ matches->areas = NULL;
+ matches->count = 0;
}
/******************************************************************************
* *
-* Paramètres : match = instance d'objet GLib à traiter. *
+* Paramètres : matches = instance d'objet GLib à traiter. *
* *
* Description : Supprime toutes les références externes. *
* *
@@ -136,18 +140,16 @@ static void g_scan_bytes_match_init(GScanBytesMatch *match)
* *
******************************************************************************/
-static void g_scan_bytes_match_dispose(GScanBytesMatch *match)
+static void g_scan_bytes_matches_dispose(GScanBytesMatches *matches)
{
- g_clear_object(&match->content);
-
- G_OBJECT_CLASS(g_scan_bytes_match_parent_class)->dispose(G_OBJECT(match));
+ G_OBJECT_CLASS(g_scan_bytes_matches_parent_class)->dispose(G_OBJECT(matches));
}
/******************************************************************************
* *
-* Paramètres : match = instance d'objet GLib à traiter. *
+* Paramètres : matches = instance d'objet GLib à traiter. *
* *
* Description : Procède à la libération totale de la mémoire. *
* *
@@ -157,21 +159,18 @@ static void g_scan_bytes_match_dispose(GScanBytesMatch *match)
* *
******************************************************************************/
-static void g_scan_bytes_match_finalize(GScanBytesMatch *match)
+static void g_scan_bytes_matches_finalize(GScanBytesMatches *matches)
{
- G_OBJECT_CLASS(g_scan_bytes_match_parent_class)->finalize(G_OBJECT(match));
+ G_OBJECT_CLASS(g_scan_bytes_matches_parent_class)->finalize(G_OBJECT(matches));
}
/******************************************************************************
* *
-* Paramètres : source = lien vers le motif recherché d'origine. *
-* content = contenu binaire présentant un motif reconnu. *
-* start = position de départ d'un motif détecté. *
-* len = taille du motif repéré. *
+* Paramètres : - *
* *
-* Description : Prend note d'une correspondance trouvée avec un motif. *
+* Description : Crée un suivi pour série de correspondances avec des octets. *
* *
* Retour : Correspondance mise en place. *
* *
@@ -179,14 +178,11 @@ static void g_scan_bytes_match_finalize(GScanBytesMatch *match)
* *
******************************************************************************/
-GScanMatch *g_scan_bytes_match_new(GSearchPattern *source, GBinContent *content, phys_t start, phys_t len)
+GScanMatches *g_scan_bytes_matches_new(void)
{
- GScanMatch *result; /* Structure à retourner */
-
- result = g_object_new(G_TYPE_SCAN_BYTES_MATCH, NULL);
+ GScanMatches *result; /* Structure à retourner */
- if (!g_scan_bytes_match_create(G_SCAN_BYTES_MATCH(result), source, content, start, len))
- g_clear_object(&result);
+ result = g_object_new(G_TYPE_SCAN_BYTES_MATCHES, NULL);
return result;
@@ -195,62 +191,51 @@ GScanMatch *g_scan_bytes_match_new(GSearchPattern *source, GBinContent *content,
/******************************************************************************
* *
-* Paramètres : match = instance à initialiser pleinement. *
-* source = lien vers le motif recherché d'origine. *
-* content = contenu binaire présentant un motif reconnu. *
-* start = position de départ d'un motif détecté. *
-* len = taille du motif repéré. *
+* Paramètres : matches = suivi de correspondances à manipuler. *
+* list = correspondances établies à mémoriser. *
+* count = taille de cette liste. *
* *
-* Description : Met en place une correspondance trouvée avec un motif. *
+* Description : Intègre une liste de correspondances vérifiées. *
* *
-* Retour : Bilan de l'opération. *
+* Retour : - *
* *
* Remarques : - *
* *
******************************************************************************/
-bool g_scan_bytes_match_create(GScanBytesMatch *match, GSearchPattern *source, GBinContent *content, phys_t start, phys_t len)
+void g_scan_bytes_matches_set_list(GScanBytesMatches *matches, match_area_t *list, size_t count)
{
- bool result; /* Bilan à retourner */
- GScanMatch *base; /* Lien vers les infos de base */
-
- result = true;
-
- base = G_SCAN_MATCH(match);
-
- base->source = source;
- g_object_ref(G_OBJECT(source));
-
- match->content = content;
- g_object_ref(G_OBJECT(content));
+ matches->areas = list;
- match->start = start;
- match->len = len;
-
- return result;
+ matches->count = count;
}
/******************************************************************************
* *
-* Paramètres : match = informations de correspondance à consulter. *
+* Paramètres : matches = suivi de correspondances à consulter. *
+* index = indice de la correspondance recherchée. *
* *
-* Description : Fournit une référence au contenu lié à la correspondance. *
+* Description : Fournit les informations relatives à une correspondance. *
* *
-* Retour : Content binaire associé au context. *
+* Retour : Propritétés de la correspondance visée ou NULL pour un échec.*
* *
* Remarques : - *
* *
******************************************************************************/
-GBinContent *g_scan_bytes_match_get_content(const GScanBytesMatch *match)
+const match_area_t *g_scan_bytes_matches_get(const GScanBytesMatches *matches, size_t index)
{
- GBinContent *result; /* Instance à retourner */
+ const match_area_t *result; /* Pointeur à retourner */
- result = match->content;
+ for_each_match_area(result, matches->areas)
+ {
+ if (index == 0)
+ break;
+ }
- g_object_ref(G_OBJECT(result));
+ assert(index == 0);
return result;
@@ -259,9 +244,10 @@ GBinContent *g_scan_bytes_match_get_content(const GScanBytesMatch *match)
/******************************************************************************
* *
-* Paramètres : match = informations de correspondance à consulter. *
-* start = position de départ d'un motif détecté. [OUT] *
-* end = position d'arrivée d'un motif détecté. [OUT] *
+* Paramètres : matches = informations de correspondance à consulter. *
+* index = indice de la correspondance visée. *
+* start = position de départ d'un motif détecté. [OUT] *
+* end = position d'arrivée d'un motif détecté. [OUT] *
* *
* Description : Indique la localisation d'une correspondance établie. *
* *
@@ -271,20 +257,61 @@ GBinContent *g_scan_bytes_match_get_content(const GScanBytesMatch *match)
* *
******************************************************************************/
-phys_t g_scan_bytes_match_get_location(const GScanBytesMatch *match, phys_t *start, phys_t *end)
+phys_t g_scan_bytes_matches_get_location(const GScanBytesMatches *matches, size_t index, phys_t *start, phys_t *end)
{
phys_t result; /* Taille à retourner */
+ result = 0;
+
+ /*
result = match->len;
*start = match->start;
*end = match->start + result;
+ */
return result;
}
+/******************************************************************************
+* *
+* Paramètres : matches = informations de correspondance à consulter. *
+* *
+* Description : Retrouve l'origine d'une correspondance à partir d'un indice.*
+* *
+* Retour : Version humainement lisible de la combinaison gagnante. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+char *g_scan_bytes_matches_get_modifier_path(const GScanBytesMatches *matches)
+{
+ char *result; /* Combinaison à retourner */
+ GBytesToken *pattern; /* Autre version du motif */
+
+ result = NULL;
+
+ /*
+
+ if (match->has_mod_path)
+ {
+ pattern = G_BYTES_TOKEN(G_SCAN_MATCH(match)->source);
+ result = g_bytes_token_get_modifier_path(pattern, match->mod_path_index);
+ }
+
+ else
+ result = NULL;
+ */
+
+ return result;
+
+}
+
+
+
/* ---------------------------------------------------------------------------------- */
/* IMPLEMENTATION DES FONCTIONS DE CLASSE */
/* ---------------------------------------------------------------------------------- */
@@ -292,8 +319,31 @@ phys_t g_scan_bytes_match_get_location(const GScanBytesMatch *match, phys_t *sta
/******************************************************************************
* *
-* Paramètres : match = définition de correspondance à manipuler. *
-* fd = canal d'écriture. *
+* Paramètres : matches = suivi de correspondances à consulter. *
+* *
+* Description : Dénombre les correspondances enregistrées pour un motif. *
+* *
+* Retour : Quantité de correspondances établies. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static size_t g_scan_bytes_matches_count(const GScanBytesMatches *matches)
+{
+ size_t result; /* Quantité à retourner */
+
+ result = matches->count;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : matches = définition de correspondance à manipuler. *
+* fd = canal d'écriture. *
* *
* Description : Affiche une correspondance au format texte. *
* *
@@ -303,91 +353,105 @@ phys_t g_scan_bytes_match_get_location(const GScanBytesMatch *match, phys_t *sta
* *
******************************************************************************/
-static void g_scan_bytes_match_output_to_text(const GScanBytesMatch *match, int fd)
+static void g_scan_bytes_matches_output_to_text(const GScanBytesMatches *matches, int fd)
{
+ 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 */
int ret; /* Bilan d'une conversion */
- GScanMatch *base; /* Lien vers les infos de base */
- const char *name; /* Désignation du motif ciblé */
vmpa2t pos; /* Tête de lecture */
+ phys_t len; /* Taille d'une correspondance */
const bin_t *data; /* Accès aux données brutes */
phys_t k; /* Boucle de parcours #2 */
- /* Position dans le binaire (hexadécimal) */
+ base = G_SCAN_MATCHES(matches);
- ret = snprintf(value, ULLONG_MAXLEN, "0x%llx", (unsigned long long)match->start);
+ content = g_scan_context_get_content(base->context);
- if (ret > 0)
- write(fd, value, ret);
+ name = g_search_pattern_get_name(base->source);
- else
+ for_each_match_area(iter, matches->areas)
{
- log_simple_message(LMT_EXT_ERROR, "Error while converting offset to hex!");
- write(fd, "\"<error>\"", 9);
- }
+ /* Position dans le binaire (hexadécimal) */
- write(fd, ":", 1);
+ ret = snprintf(value, ULLONG_MAXLEN, "0x%llx", (unsigned long long)iter->start);
- /* Affichage de la désignation */
+ if (ret > 0)
+ write(fd, value, ret);
- write(fd, "$", 1);
+ else
+ {
+ log_simple_message(LMT_EXT_ERROR, "Error while converting offset to hex!");
+ write(fd, "\"<error>\"", 9);
+ }
- base = G_SCAN_MATCH(match);
+ write(fd, ":", 1);
- name = g_search_pattern_get_name(base->source);
+ /* Affichage de la désignation */
- /**
- * Les fonctionnalités Yara d'origine autorisent les variables anonymes '$'.
- *
- * Cette absence de nom est supportée ici.
- */
+ write(fd, "$", 1);
- if (name != NULL)
- write(fd, name, strlen(name));
+ /**
+ * Les fonctionnalités Yara d'origine autorisent les variables anonymes '$'.
+ *
+ * Cette absence de nom est supportée ici.
+ */
- write(fd, ": ", 2);
+ if (name != NULL)
+ write(fd, name, strlen(name));
- /* Affichage du contenu */
+ write(fd, ": ", 2);
- init_vmpa(&pos, match->start, VMPA_NO_VIRTUAL);
+ /* Affichage du contenu */
- data = g_binary_content_get_raw_access(match->content, &pos, match->len);
+ init_vmpa(&pos, iter->start, VMPA_NO_VIRTUAL);
- for (k = 0; k < match->len; k++)
- {
- if (isprint(data[k]))
- write(fd, &data[k], 1);
+ len = iter->end - iter->start;
- else
- {
- write(fd, "\\x", 2);
-
- ret = snprintf(value, ULLONG_MAXLEN, "%02hhx", data[k]);
+ data = g_binary_content_get_raw_access(content, &pos, len);
+ assert(data != NULL);
- if (ret > 0)
- {
- assert(ret == 2);
- write(fd, value, ret);
- }
+ for (k = 0; k < len; k++)
+ {
+ if (isprint(data[k]))
+ write(fd, &data[k], 1);
else
{
- log_simple_message(LMT_EXT_ERROR, "Error while converting data!");
- write(fd, "??", 2);
+ write(fd, "\\x", 2);
+
+ ret = snprintf(value, ULLONG_MAXLEN, "%02hhx", data[k]);
+
+ if (ret > 0)
+ {
+ assert(ret == 2);
+ write(fd, value, ret);
+ }
+
+ else
+ {
+ log_simple_message(LMT_EXT_ERROR, "Error while converting data!");
+ write(fd, "??", 2);
+ }
+
}
}
+ write(fd, "\n", 1);
+
}
- write(fd, "\n", 1);
+ g_object_unref(G_OBJECT(content));
}
/******************************************************************************
* *
-* Paramètres : match = définition de correspondance à manipuler. *
+* Paramètres : matches = définition de correspondance à manipuler. *
* padding = éventuel bourrage initial à placer ou NULL. *
* level = profondeur actuelle. *
* fd = canal d'écriture. *
@@ -400,188 +464,249 @@ static void g_scan_bytes_match_output_to_text(const GScanBytesMatch *match, int
* *
******************************************************************************/
-static void g_scan_bytes_match_output_to_json(const GScanBytesMatch *match, const sized_string_t *padding, unsigned int level, int fd)
+static void g_scan_bytes_matches_output_to_json(const GScanBytesMatches *matches, const sized_string_t *padding, unsigned int level, int fd)
{
unsigned int i; /* Boucle de parcours #1 */
- vmpa2t pos; /* Tête de lecture */
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 */
+ phys_t len; /* Taille d'une correspondance */
const bin_t *data; /* Accès aux données brutes */
phys_t k; /* Boucle de parcours #2 */
- /* Position dans le binaire (décimal) */
+ /* Nombre de correspondances */
for (i = 0; i < level; i++)
write(fd, padding->data, padding->len);
- write(fd, "\"offset\": ", 10);
+ write(fd, "\"match_count\": ", 15);
- ret = snprintf(value, ULLONG_MAXLEN, "%llu", (unsigned long long)match->start);
+ ret = snprintf(value, ULLONG_MAXLEN, "%zu", matches->count);
if (ret > 0)
write(fd, value, ret);
else
{
- log_simple_message(LMT_EXT_ERROR, "Error while converting offset!");
+ log_simple_message(LMT_EXT_ERROR, "Error while converting value!");
write(fd, "null", 4);
}
write(fd, ",\n", 2);
- /* Position dans le binaire (hexadécimal) */
+ /* Détail des correspondances */
for (i = 0; i < level; i++)
write(fd, padding->data, padding->len);
- write(fd, "\"offset_hex\": ", 14);
+ write(fd, "\"matches\": [\n", 13);
- ret = snprintf(value, ULLONG_MAXLEN, "\"0x%llx\"", (unsigned long long)match->start);
+ base = G_SCAN_MATCHES(matches);
- if (ret > 0)
- write(fd, value, ret);
+ content = g_scan_context_get_content(base->context);
- else
+ for_each_match_area(iter, matches->areas)
{
- log_simple_message(LMT_EXT_ERROR, "Error while converting offset to hex!");
- write(fd, "null", 4);
- }
-
- write(fd, ",\n", 2);
+ /* Marqueur de début */
- /* Affichage du contenu brut */
+ for (i = 0; i < (level + 1); i++)
+ write(fd, padding->data, padding->len);
- for (i = 0; i < level; i++)
- write(fd, padding->data, padding->len);
+ write(fd, "{\n", 2);
- write(fd, "\"content\": \"", 12);
+ /* Position dans le binaire (décimal) */
- init_vmpa(&pos, match->start, VMPA_NO_VIRTUAL);
+ for (i = 0; i < (level + 2); i++)
+ write(fd, padding->data, padding->len);
- data = g_binary_content_get_raw_access(match->content, &pos, match->len);
- assert(data != NULL);
+ write(fd, "\"offset\": ", 10);
- for (k = 0; k < match->len; k++)
- {
- if (data[k] == '\\')
- write(fd, "\\\\", 2);
+ ret = snprintf(value, ULLONG_MAXLEN, "%llu", (unsigned long long)iter->start);
- else if (isprint(data[k]))
- write(fd, &data[k], 1);
+ if (ret > 0)
+ write(fd, value, ret);
else
{
- write(fd, "\\u", 2);
+ log_simple_message(LMT_EXT_ERROR, "Error while converting offset!");
+ write(fd, "null", 4);
+ }
- /**
- * Cf. https://datatracker.ietf.org/doc/html/rfc8259#section-7
- */
- ret = snprintf(value, ULLONG_MAXLEN, "%04hhx", data[k]);
+ write(fd, ",\n", 2);
- if (ret > 0)
- {
- assert(ret == 4);
- write(fd, value, ret);
- }
+ /* Position dans le binaire (hexadécimal) */
- else
- {
- log_simple_message(LMT_EXT_ERROR, "Error while converting data!");
- write(fd, "??", 2);
- }
+ for (i = 0; i < (level + 2); i++)
+ write(fd, padding->data, padding->len);
- }
+ write(fd, "\"offset_hex\": ", 14);
- }
+ ret = snprintf(value, ULLONG_MAXLEN, "\"0x%llx\"", (unsigned long long)iter->start);
+
+ if (ret > 0)
+ write(fd, value, ret);
- write(fd, "\",\n", 3);
+ else
+ {
+ log_simple_message(LMT_EXT_ERROR, "Error while converting offset to hex!");
+ write(fd, "null", 4);
+ }
- /* Affichage du contenu en version humainement lisible */
+ write(fd, ",\n", 2);
- for (i = 0; i < level; i++)
- write(fd, padding->data, padding->len);
+ /* Affichage du contenu brut */
- write(fd, "\"content_str\": \"", 16);
+ for (i = 0; i < (level + 2); i++)
+ write(fd, padding->data, padding->len);
- init_vmpa(&pos, match->start, VMPA_NO_VIRTUAL);
+ write(fd, "\"content\": \"", 12);
- data = g_binary_content_get_raw_access(match->content, &pos, match->len);
- assert(data != NULL);
+ init_vmpa(&pos, iter->start, VMPA_NO_VIRTUAL);
- for (k = 0; k < match->len; k++)
- {
- if (data[k] == '\\')
- write(fd, "\\\\", 2);
+ len = iter->end - iter->start;
- else if (isprint(data[k]))
- write(fd, &data[k], 1);
+ data = g_binary_content_get_raw_access(content, &pos, len);
+ assert(data != NULL);
- else
+ for (k = 0; k < len; k++)
{
- write(fd, "\\\\x", 3);
+ if (data[k] == '\\')
+ write(fd, "\\\\", 2);
- ret = snprintf(value, ULLONG_MAXLEN, "%02hhx", data[k]);
+ else if (isprint(data[k]))
+ write(fd, &data[k], 1);
- if (ret > 0)
+ else
{
- assert(ret == 2);
- write(fd, value, ret);
+ write(fd, "\\u", 2);
+
+ /**
+ * Cf. https://datatracker.ietf.org/doc/html/rfc8259#section-7
+ */
+ ret = snprintf(value, ULLONG_MAXLEN, "%04hhx", data[k]);
+
+ if (ret > 0)
+ {
+ assert(ret == 4);
+ write(fd, value, ret);
+ }
+
+ else
+ {
+ log_simple_message(LMT_EXT_ERROR, "Error while converting data!");
+ write(fd, "??", 2);
+ }
+
}
+ }
+
+ write(fd, "\",\n", 3);
+
+ /* Affichage du contenu en version humainement lisible */
+
+ for (i = 0; i < (level + 2); i++)
+ write(fd, padding->data, padding->len);
+
+ write(fd, "\"content_str\": \"", 16);
+
+ init_vmpa(&pos, iter->start, VMPA_NO_VIRTUAL);
+
+ data = g_binary_content_get_raw_access(content, &pos, len);
+ assert(data != NULL);
+
+ for (k = 0; k < len; k++)
+ {
+ if (data[k] == '\\')
+ write(fd, "\\\\", 2);
+
+ else if (isprint(data[k]))
+ write(fd, &data[k], 1);
+
else
{
- log_simple_message(LMT_EXT_ERROR, "Error while converting data!");
- write(fd, "??", 2);
+ write(fd, "\\\\x", 3);
+
+ ret = snprintf(value, ULLONG_MAXLEN, "%02hhx", data[k]);
+
+ if (ret > 0)
+ {
+ assert(ret == 2);
+ write(fd, value, ret);
+ }
+
+ else
+ {
+ log_simple_message(LMT_EXT_ERROR, "Error while converting data!");
+ write(fd, "??", 2);
+ }
+
}
}
- }
+ write(fd, "\",\n", 3);
- write(fd, "\",\n", 3);
+ /* Affichage du contenu brut */
- /* Affichage du contenu brut */
+ for (i = 0; i < (level + 2); i++)
+ write(fd, padding->data, padding->len);
- for (i = 0; i < level; i++)
- write(fd, padding->data, padding->len);
+ write(fd, "\"length\": ", 10);
- write(fd, "\"length\": ", 10);
+ ret = snprintf(value, ULLONG_MAXLEN, "%llu", (unsigned long long)len);
- init_vmpa(&pos, match->start, VMPA_NO_VIRTUAL);
+ if (ret > 0)
+ write(fd, value, ret);
- ret = snprintf(value, ULLONG_MAXLEN, "%llu", (unsigned long long)match->len);
+ else
+ {
+ log_simple_message(LMT_EXT_ERROR, "Error while converting data!");
+ write(fd, "-1", 2);
+ }
- if (ret > 0)
- write(fd, value, ret);
+ write(fd, ",\n", 2);
- else
- {
- log_simple_message(LMT_EXT_ERROR, "Error while converting data!");
- write(fd, "-1", 2);
- }
+ /* Affichage du contenu brut (hexadécimal) */
- write(fd, ",\n", 2);
+ for (i = 0; i < (level + 2); i++)
+ write(fd, padding->data, padding->len);
- /* Affichage du contenu brut (hexadécimal) */
+ write(fd, "\"length_hex\": ", 14);
- for (i = 0; i < level; i++)
- write(fd, padding->data, padding->len);
+ ret = snprintf(value, ULLONG_MAXLEN, "\"0x%llx\"", (unsigned long long)len);
- write(fd, "\"length_hex\": ", 14);
+ if (ret > 0)
+ write(fd, value, ret);
- init_vmpa(&pos, match->start, VMPA_NO_VIRTUAL);
+ else
+ {
+ log_simple_message(LMT_EXT_ERROR, "Error while converting data!");
+ write(fd, "\"0xffffffffffffffff\"", 20);
+ }
- ret = snprintf(value, ULLONG_MAXLEN, "\"0x%llx\"", (unsigned long long)match->len);
+ write(fd, "\n", 1);
- if (ret > 0)
- write(fd, value, ret);
+ /* Marqueur de fin */
+
+ for (i = 0; i < (level + 1); i++)
+ write(fd, padding->data, padding->len);
+
+ if (is_last_match_area(iter, matches->areas))
+ write(fd, "}\n", 2);
+ else
+ write(fd, "},\n", 3);
- else
- {
- log_simple_message(LMT_EXT_ERROR, "Error while converting data!");
- write(fd, "\"0xffffffffffffffff\"", 20);
}
- write(fd, "\n", 1);
+ g_object_unref(G_OBJECT(content));
+
+ for (i = 0; i < level; i++)
+ write(fd, padding->data, padding->len);
+
+ write(fd, "]\n", 2);
}
diff --git a/src/analysis/scan/matches/bytes.h b/src/analysis/scan/matches/bytes.h
index e599ee4..90d6062 100644
--- a/src/analysis/scan/matches/bytes.h
+++ b/src/analysis/scan/matches/bytes.h
@@ -1,6 +1,6 @@
/* Chrysalide - Outil d'analyse de fichiers binaires
- * bytes.h - prototypes pour la sauvegarde d'une correspondance identifiée de suite d'octets
+ * bytes.h - prototypes pour la sauvegarde de correspondances avec des suites d'octets identifiées
*
* Copyright (C) 2022 Cyrille Bagard
*
@@ -28,37 +28,47 @@
#include <glib-object.h>
-#include "../match.h"
-#include "../../content.h"
+#include "area.h"
+#include "../context.h"
+#include "../matches.h"
-#define G_TYPE_SCAN_BYTES_MATCH g_scan_bytes_match_get_type()
-#define G_SCAN_BYTES_MATCH(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_SCAN_BYTES_MATCH, GScanBytesMatch))
-#define G_IS_SCAN_BYTES_MATCH(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_SCAN_BYTES_MATCH))
-#define G_SCAN_BYTES_MATCH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_SCAN_BYTES_MATCH, GScanBytesMatchClass))
-#define G_IS_SCAN_BYTES_MATCH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_SCAN_BYTES_MATCH))
-#define G_SCAN_BYTES_MATCH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_SCAN_BYTES_MATCH, GScanBytesMatchClass))
+/* -------------------- CONSERVATION DE CORRESPONDANCES ETABLIES -------------------- */
-/* Correspondance trouvée avec une chaîne (instance) */
-typedef struct _GScanBytesMatch GScanBytesMatch;
+#define G_TYPE_SCAN_BYTES_MATCHES g_scan_bytes_matches_get_type()
+#define G_SCAN_BYTES_MATCHES(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_SCAN_BYTES_MATCHES, GScanBytesMatches))
+#define G_IS_SCAN_BYTES_MATCHES(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_SCAN_BYTES_MATCHES))
+#define G_SCAN_BYTES_MATCHES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_SCAN_BYTES_MATCHES, GScanBytesMatchesClass))
+#define G_IS_SCAN_BYTES_MATCHES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_SCAN_BYTES_MATCHES))
+#define G_SCAN_BYTES_MATCHES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_SCAN_BYTES_MATCHES, GScanBytesMatchesClass))
-/* Correspondance trouvée avec une chaîne (classe) */
-typedef struct _GScanBytesMatchClass GScanBytesMatchClass;
+/* Correspondances trouvées avec des suite d'octets (instance) */
+typedef struct _GScanBytesMatches GScanBytesMatches;
-/* Indique le type défini pour un correspondance de chaîne identifiée. */
-GType g_scan_bytes_match_get_type(void);
+/* Correspondances trouvées avec des suite d'octets (classe) */
+typedef struct _GScanBytesMatchesClass GScanBytesMatchesClass;
-/* Prend note d'une correspondance trouvée avec un motif. */
-GScanMatch *g_scan_bytes_match_new(GSearchPattern *, GBinContent *, phys_t, phys_t);
-/* Fournit une référence au contenu lié à la correspondance. */
-GBinContent *g_scan_bytes_match_get_content(const GScanBytesMatch *);
+/* Indique le type défini pour une série de correspondances d'octets identifiées. */
+GType g_scan_bytes_matches_get_type(void);
+
+/* Crée un suivi pour série de correspondances avec des octets. */
+GScanMatches *g_scan_bytes_matches_new(void);
+
+/* Intègre une liste de correspondances vérifiées. */
+void g_scan_bytes_matches_set_list(GScanBytesMatches *, match_area_t *, size_t);
+
+/* Fournit les informations relatives à une correspondance. */
+const match_area_t *g_scan_bytes_matches_get(const GScanBytesMatches *, size_t);
/* Indique la localisation d'une correspondance établie. */
-phys_t g_scan_bytes_match_get_location(const GScanBytesMatch *, phys_t *, phys_t *);
+phys_t g_scan_bytes_matches_get_location(const GScanBytesMatches *, size_t, phys_t *, phys_t *);
+
+/* Retrouve l'origine d'une correspondance à partir d'un indice. */
+char *g_scan_bytes_matches_get_modifier_path(const GScanBytesMatches *);
diff --git a/src/analysis/scan/matches/pending.c b/src/analysis/scan/matches/pending.c
index 9ed4de3..c653257 100644
--- a/src/analysis/scan/matches/pending.c
+++ b/src/analysis/scan/matches/pending.c
@@ -33,6 +33,8 @@
+
+
/* ------------------------- MEMORISATION D'UNE ZONE BORNEE ------------------------- */
@@ -50,8 +52,6 @@ static int compare_match_area(const match_area_t *, const match_area_t *);
-
-
/* ---------------------------------------------------------------------------------- */
/* MEMORISATION D'UNE ZONE BORNEE */
/* ---------------------------------------------------------------------------------- */
@@ -59,6 +59,104 @@ static int compare_match_area(const match_area_t *, const match_area_t *);
/******************************************************************************
* *
+* Paramètres : allocator = allocateur dédié à l'ensemble de zones. *
+* start = point de départ d'une nouvelle correspondance. *
+* length = taille de la zone couverte. *
+* *
+* Description : Crée une nouvelle structure de suivi de correspondance. *
+* *
+* Retour : Structure initialisée mise en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static match_area_t *create_match_area(GUMemCache *allocator, phys_t start, phys_t length)
+{
+ match_area_t *result; /* Zone à retourner */
+
+ result = g_umem_cache_alloc(allocator);
+
+ DL_LIST_ITEM_INIT(&result->link);
+
+ result->start = start;
+ result->end = start + length;
+
+ assert(matches->content_start <= result->start);
+ assert(result->end <= matches->content_end);
+
+ result->ttl = 1;
+
+ result->has_mod_path = false;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : allocator = allocateur dédié à l'ensemble de zones. *
+* start = point de départ d'une nouvelle correspondance. *
+* length = taille de la zone couverte. *
+* index = indice de construction pour le motif concerné. *
+* *
+* Description : Crée une nouvelle structure de suivi de correspondance. *
+* *
+* Retour : Structure initialisée mise en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static match_area_t *create_match_area_with_path(GUMemCache *allocator, phys_t start, phys_t length, size_t index)
+{
+ match_area_t *result; /* Zone à retourner */
+
+ result = g_umem_cache_alloc(allocator);
+
+ DL_LIST_ITEM_INIT(&result->link);
+
+ result->start = start;
+ result->end = start + length;
+
+ assert(matches->content_start <= result->start);
+ assert(result->end <= matches->content_end);
+
+ result->ttl = 1;
+
+ result->mod_path_index = index;
+ result->has_mod_path = true;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : area = zone de suivi à supprimer. *
+* allocator = allocateur dédié à l'ensemble de zones. *
+* *
+* Description : Supprime une structure de suivi de correspondance. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void delete_match_area(match_area_t *area, GUMemCache *allocator)
+{
+ // TODO : assert(alone)
+
+ g_umem_cache_free(allocator, area);
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : a = pointeur vers la première zone à analyser. *
* b = pointeur vers la seconde zone à analyser. *
* *
@@ -82,6 +180,12 @@ static int compare_match_area(const match_area_t *a, const match_area_t *b)
if (result == 0)
result = sort_unsigned_long_long(a->ttl, b->ttl);
+ if (result == 0)
+ result = sort_unsigned_long_long(a->has_mod_path, b->has_mod_path);
+
+ if (result == 0)
+ result = sort_unsigned_long_long(a->mod_path_index, b->mod_path_index);
+
return result;
}
@@ -112,6 +216,7 @@ void init_pending_matches(pending_matches_t *matches, const phys_t *start, const
matches->content_start = *start;
matches->content_end = *end;
+ matches->allocator = NULL;
matches->areas = NULL;
matches->allocated = 0;
matches->used = 0;
@@ -273,25 +378,39 @@ match_area_t * const *get_all_pending_matches(const pending_matches_t *matches,
void add_pending_match(pending_matches_t *matches, phys_t start, phys_t length)
{
- match_area_t *area; /* Zone à initialiser */
+ match_area_t *area; /* Nouvelle zone à intégrer */
- if (matches->used == matches->allocated)
- {
- matches->allocated += PENDING_ALLOC_SIZE;
+ area = create_match_area(matches->allocator, start, length);
- matches->areas = realloc(matches->areas, matches->allocated * sizeof(match_area_t));
+ dl_list_add_tail(area, &matches->areas, match_area_t, link);
+ matches->used++;
- }
+}
- area = &matches->areas[matches->used++];
- area->start = start;
- area->end = start + length;
+/******************************************************************************
+* *
+* Paramètres : matches = suivi de correspondances à compléter. *
+* start = point de départ d'une nouvelle correspondance. *
+* length = taille de la zone couverte. *
+* index = indice de construction pour le motif concerné. *
+* *
+* Description : Ajoute au suivi la définition d'une nouvelle correspondance. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void add_pending_match_with_path(pending_matches_t *matches, phys_t start, phys_t length, size_t index)
+{
+ match_area_t *area; /* Nouvelle zone à intégrer */
- assert(matches->content_start <= area->start);
- assert(area->end <= matches->content_end);
+ area = create_match_area_with_path(matches->allocator, start, length, index);
- area->ttl = 1;
+ dl_list_add_tail(area, &matches->areas, match_area_t, link);
+ matches->used++;
}
diff --git a/src/analysis/scan/matches/pending.h b/src/analysis/scan/matches/pending.h
index 6df01c9..e430ca1 100644
--- a/src/analysis/scan/matches/pending.h
+++ b/src/analysis/scan/matches/pending.h
@@ -21,7 +21,7 @@
*/
-#ifndef _ANALYSIS_SCAN_MATCHES_PENDING_H
+#if 0 //ndef _ANALYSIS_SCAN_MATCHES_PENDING_H
#define _ANALYSIS_SCAN_MATCHES_PENDING_H
@@ -30,17 +30,28 @@
#include "../../content.h"
+#include "../../../common/dllist.h"
+
+
+
+// TODO : move vers ByteMatch
+typedef int GUMemCache;
/* Couverture d'une correspondance */
typedef struct _match_area_t
{
+ DL_LIST_ITEM(link); /* Lien vers les maillons */
+
phys_t start; /* Point de départ */
phys_t end; /* Point d'arrivée (exclus) */
unsigned long ttl; /* Durée de vie pour analyse */
+ size_t mod_path_index; /* Indice de construction */
+ bool has_mod_path; /* Validité du champ précédent */
+
} match_area_t;
/* Suivi de correspondances */
@@ -49,6 +60,7 @@ typedef struct _pending_matches_t
phys_t content_start; /* Point de début du contenu */
phys_t content_end; /* Point de fin du contenu */
+ GUMemCache *allocator; /* Allocateur pour zones */
match_area_t *areas; /* Zones couvertes */
size_t allocated; /* Nombre d'allocations */
size_t used; /* Nombre de zones */
@@ -86,6 +98,9 @@ match_area_t * const *get_all_pending_matches(const pending_matches_t *, size_t
/* Ajoute au suivi la définition d'une nouvelle correspondance. */
void add_pending_match(pending_matches_t *, phys_t, phys_t);
+/* Ajoute au suivi la définition d'une nouvelle correspondance. */
+void add_pending_match_with_path(pending_matches_t *, phys_t, phys_t, size_t);
+
/* Etend une zone couverte dans le suivi des correspondances. */
void extend_pending_match_beginning(pending_matches_t *, size_t, phys_t);