diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2023-10-11 23:16:21 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2023-10-11 23:16:21 (GMT) |
commit | ab6b87b7309e2d00926615f6557016bee6ab0b71 (patch) | |
tree | bf69b93d2f0548fc845e68ae1e8519bd33d1da24 /src/analysis/scan/matches/bytes.c | |
parent | 404097b7b07b336b427b3682ec2bc48d831cb2e9 (diff) |
Add two new functions to ROST grammar: modpath and maxcommon.
Diffstat (limited to 'src/analysis/scan/matches/bytes.c')
-rw-r--r-- | src/analysis/scan/matches/bytes.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/analysis/scan/matches/bytes.c b/src/analysis/scan/matches/bytes.c index de101c4..f0b97fe 100644 --- a/src/analysis/scan/matches/bytes.c +++ b/src/analysis/scan/matches/bytes.c @@ -30,6 +30,7 @@ #include "bytes-int.h" +#include "../patterns/token.h" #include "../../../common/cpp.h" #include "../../../core/logs.h" @@ -121,6 +122,8 @@ static void g_scan_bytes_match_init(GScanBytesMatch *match) match->start = VMPA_NO_PHYSICAL; match->len = VMPA_NO_PHYSICAL; + match->has_mod_path = false; + } @@ -285,6 +288,59 @@ phys_t g_scan_bytes_match_get_location(const GScanBytesMatch *match, phys_t *sta } +/****************************************************************************** +* * +* Paramètres : match = informations de correspondance à compléter. * +* index = indice de la combinaison de modificateurs ciblée. * +* * +* Description : Mémorise l'origine d'une correspondance à partir d'un indice.* +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_scan_bytes_match_remember_modifier_path(GScanBytesMatch *match, size_t index) +{ + match->mod_path_index = index; + match->has_mod_path = true; + +} + + +/****************************************************************************** +* * +* Paramètres : match = 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_match_get_modifier_path(const GScanBytesMatch *match) +{ + char *result; /* Combinaison à retourner */ + GBytesToken *pattern; /* Autre version du motif */ + + 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 */ /* ---------------------------------------------------------------------------------- */ |