Skip to content

Commit 8ea5ca8

Browse files
committed
Remove duplicate pattern, reuse lower_case_string pattern for simplify_string and lower_case_string
1 parent f6fd319 commit 8ea5ca8

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

fn_byte_patterns.ffsess

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ Tab addst_flag
1212
RuleBytePattern True False 48 89 5c 24 ?? 55 56 57 48 83 ec ?? 48 8b 05 ?? ?? ?? ?? 48 33 c4 48 89 44 24 ?? 49 63 d9 48 8b f9 48 83 7a ?? ?? 0f 84 ?? ?? ?? ?? 48 8d 4c 24 ?? e8 ?? ?? ?? ?? 90 48 8b 4c 24 ?? 85 db 74 ?? 48 3b cb 76 ?? 8b d3 48 8d 4c 24 ?? e8 ?? ?? ?? ?? 48 8b 4c 24 ?? 33 ed 8b dd 48 85 c9 74 ?? 8b b4 24 ?? ?? ?? ?? 66 66 0f 1f 84 00
1313
Tab standardstringentry
1414
RuleBytePattern True False 40 53 56 57 41 56 48 83 ec ?? 80 3d ?? ?? ?? ?? ?? 49 8b d9 41 8b f0 48 63 fa 4c 8b f1 75 ?? ff 15 ?? ?? ?? ?? c6 05 ?? ?? ?? ?? ?? 4c 8b 13 4d 8b da 49 8b 42 ?? 44 0f b6 48 ?? 45 84 c9 75 ?? 48 8b c8 81 79 ?? ?? ?? ?? ?? 7d ?? 48 8b 49 ?? eb ??
15-
Tab simplify_string
16-
RuleBytePattern True False 45 33 d2 4c 39 51 ?? 0f 86 ?? ?? ?? ?? 45 8b c2 4c 8d 1d ?? ?? ?? ?? 66 0f 1f 84 00 ?? ?? ?? ?? 48 8b 41 ?? 48 8b d1 48 83 f8 ?? 76 ?? 48 8b 11 41 80 3c 10 ?? 7c ?? 48 8b d1 48 83 f8 ?? 76 ?? 48 8b 11 41 80 3c 10 ?? 7f ?? 48 8b d1 48 83 f8 ?? 76 ?? 48 8b 11 41 80 04 10 ?? 48 8b c1 48 83 79 ?? ?? 76 ?? 48 8b 01 41 80 04 00 ?? 4c 8b 49 ?? 48 8b c1 49 83 f9 ?? 76 ?? 48 8b 01 41 0f be 04 00 83 e8 ?? 83 f8 ??
1715
Tab upper_case_string
1816
RuleBytePattern True False 45 33 d2 4c 39 51 ?? 0f 86 ?? ?? ?? ?? 45 8b c2 4c 8d 1d ?? ?? ?? ?? 66 0f 1f 84 00 ?? ?? ?? ?? 48 8b 41 ?? 48 8b d1 48 83 f8 ?? 76 ?? 48 8b 11 41 80 3c 10 ?? 7c ?? 48 8b d1 48 83 f8 ?? 76 ?? 48 8b 11 41 80 3c 10 ?? 7f ?? 48 8b d1 48 83 f8 ?? 76 ?? 48 8b 11 41 80 04 10 ?? 48 8b c1 48 83 79 ?? ?? 76 ?? 48 8b 01 41 80 04 00 ?? 4c 8b 49 ?? 48 8b c1 49 83 f9 ?? 76 ?? 48 8b 01 41 0f be 04 00 83 c0 ?? 83 f8 ??
1917
Tab lower_case_string

search_offsets/search.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,9 @@ def process_offsets(
5555
yield pattern_name, None
5656
continue
5757

58-
for i, offset in enumerate(found[pattern_name], -1):
59-
suffix = "" if i < 0 else f"_{i}"
58+
for i, offset in enumerate(found[pattern_name]):
59+
suffix = "" if i <= 0 else f"_{i}"
6060
name = pattern_name + suffix
61-
if name == "addchar_0":
62-
name = "addchar_top"
63-
6461
rva = pe.offset_to_virtual_address(offset)
6562
if isinstance(rva, lief.lief_errors):
6663
msg = f"Error ocurred during getting of virtual address: {rva!r}"
@@ -103,7 +100,10 @@ def validate_offset(name: str, found_offsets: Mapping[str, list[int]], count: in
103100
def validate_offsets(found: Mapping[str, list[int]]) -> None:
104101
"""Check found offsets."""
105102
for key in found:
106-
validate_offset(key, found, 1)
103+
count = 1
104+
if key == "lower_case_string":
105+
count = 2 # the same pattern for simplify_string and lower_case_string
106+
validate_offset(key, found, count)
107107

108108

109109
@dataclass

search_offsets/templates/windows_offsets.toml.jinja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ addst = {{ addst | hex }}
1111
addst_top = {{ addst_top | hex }}
1212
addst_flag = {{ addst_flag | hex }}
1313
standardstringentry = {{ standardstringentry | hex }}
14-
simplify_string = {{ simplify_string | hex }}
14+
simplify_string = {{ lower_case_string | hex }}
1515
upper_case_string = {{ upper_case_string | hex }}
16-
lower_case_string = {{ lower_case_string_0 | hex }}
16+
lower_case_string = {{ lower_case_string_1 | hex }}
1717
capitalize_string_words = {{ capitalize_string_words | hex }}
1818
capitalize_string_first_word = {{ capitalize_string_first_word | hex }}

0 commit comments

Comments
 (0)