From 44045b51af019b89392c1813690dc301a8afa2d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Wed, 18 Sep 2024 14:31:32 +0200 Subject: [PATCH 1/6] submodules: Bump releng --- releng | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releng b/releng index d1e77f19c..f1f6586b6 160000 --- a/releng +++ b/releng @@ -1 +1 @@ -Subproject commit d1e77f19c6d21e647f3f57b4701256f8306c670d +Subproject commit f1f6586b6ad23cee85500c91219d71f347617612 From 6e8f73b3bee6971e5c7b007410083e932043ead8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Sat, 5 Oct 2024 16:12:43 +0200 Subject: [PATCH 2/6] submodules: Bump releng --- releng | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releng b/releng index f1f6586b6..186220b71 160000 --- a/releng +++ b/releng @@ -1 +1 @@ -Subproject commit f1f6586b6ad23cee85500c91219d71f347617612 +Subproject commit 186220b71c7570c5b3faa80020cf133c5652094a From 15468812b86b6062ab9d1602463956e58503a9a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Sat, 5 Oct 2024 16:14:39 +0200 Subject: [PATCH 3/6] submodules: Bump releng --- releng | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releng b/releng index 186220b71..896b2a010 160000 --- a/releng +++ b/releng @@ -1 +1 @@ -Subproject commit 186220b71c7570c5b3faa80020cf133c5652094a +Subproject commit 896b2a0108fe9dcb0bf12edb9e2e70fd91e9b0a0 From 76093fffac4d466fd8ffca06c871ae589577962e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Sat, 5 Oct 2024 17:24:51 +0200 Subject: [PATCH 4/6] submodules: Bump releng --- releng | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releng b/releng index 896b2a010..317861f87 160000 --- a/releng +++ b/releng @@ -1 +1 @@ -Subproject commit 896b2a0108fe9dcb0bf12edb9e2e70fd91e9b0a0 +Subproject commit 317861f870e3903645755547e972d01e16ed103d From e4c1125756df51394e34a105868965a2c4460cb1 Mon Sep 17 00:00:00 2001 From: Francesco Tamagni Date: Thu, 10 Oct 2024 20:05:59 +0200 Subject: [PATCH 5/6] memory: Make regex patterns raw (#971) According to the docs of `g_regex_new`: "Usually strings must be valid UTF-8 strings, using this flag they are considered as a raw sequence of bytes." The "strings" this refers to are the haystacks we then pass to `g_regex_match_full` when searching. Without the flag, memory search with regex patterns can get interrupted before the range is over, when "invalid" bytes are encountered, resulting in false negatives. --- gum/gummemory.c | 4 ++-- tests/gumjs/script.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/gum/gummemory.c b/gum/gummemory.c index 26c800dd5..871c82181 100644 --- a/gum/gummemory.c +++ b/gum/gummemory.c @@ -576,8 +576,8 @@ gum_match_pattern_new_from_regex (const gchar * regex_str) GumMatchPattern * pattern; GRegex * regex; - regex = g_regex_new (regex_str, G_REGEX_OPTIMIZE, G_REGEX_MATCH_NOTEMPTY, - NULL); + regex = g_regex_new (regex_str, G_REGEX_OPTIMIZE | G_REGEX_RAW, + G_REGEX_MATCH_NOTEMPTY, NULL); if (regex == NULL) return NULL; diff --git a/tests/gumjs/script.c b/tests/gumjs/script.c index d05f16de1..bb1854043 100644 --- a/tests/gumjs/script.c +++ b/tests/gumjs/script.c @@ -8137,6 +8137,22 @@ TESTCASE (memory_can_be_scanned_with_match_pattern_object) EXPECT_SEND_MESSAGE_WITH ("\"onMatch offset=0 size=11\""); EXPECT_SEND_MESSAGE_WITH ("\"onMatch offset=13 size=11\""); EXPECT_SEND_MESSAGE_WITH ("\"onComplete\""); + + haystack2[7] = 0xd1; + + COMPILE_AND_LOAD_SCRIPT ( + "const pattern = new MatchPattern(/Hello/.toString());" + "Memory.scan(" GUM_PTR_CONST ", 33, pattern, {" + "onMatch(address, size) {" + " send('onMatch offset=' + address.sub(" GUM_PTR_CONST + ").toInt32() + ' size=' + size);" + "}," + "onComplete() {" + " send('onComplete');" + "}" + "});", haystack2, haystack2); + EXPECT_SEND_MESSAGE_WITH ("\"onMatch offset=0 size=5\""); + EXPECT_SEND_MESSAGE_WITH ("\"onComplete\""); } TESTCASE (memory_can_be_scanned_synchronously) From 0afeb85fcdeae1d995a55bc07f0fe57b197aecae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Thu, 10 Oct 2024 20:08:47 +0200 Subject: [PATCH 6/6] submodules: Bump releng --- releng | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releng b/releng index 317861f87..4622f5c4c 160000 --- a/releng +++ b/releng @@ -1 +1 @@ -Subproject commit 317861f870e3903645755547e972d01e16ed103d +Subproject commit 4622f5c4c432d94c1c625e598b120425a68a8414