Skip to content

Commit ac1d970

Browse files
authored
Merge pull request n1nj4sec#2 from AlessandroZ/master
manage groups on regex
2 parents d07fcd4 + f5e05e2 commit ac1d970

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

memorpy/MemWorker.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ def mem_search(self, value, ftype = 'match', protec = PAGE_READWRITE | PAGE_READ
9595
ftype = ftype.lower().strip()
9696
if type(value) is list:
9797
ftype = 'group'
98-
if ftype == 're':
98+
if ftype == 're' or ftype == 'groups':
9999
if type(value) is str:
100100
regex = re.compile(value)
101101
else:
102102
regex = value
103103
if ftype == 'float':
104104
structtype, structlen = utils.type_unpack(ftype)
105-
elif ftype != 'match' and ftype != 'group' and ftype != 're':
105+
elif ftype != 'match' and ftype != 'group' and ftype != 're' and ftype != 'groups':
106106
structtype, structlen = utils.type_unpack(ftype)
107107
value = struct.pack(structtype, value)
108108
for offset, chunk in self.process.iter_region(start_offset=start_offset, end_offset=end_offset, protec=protec):
@@ -158,6 +158,10 @@ def mem_search(self, value, ftype = 'match', protec = PAGE_READWRITE | PAGE_READ
158158
except Exception as e:
159159
pass
160160

161+
elif ftype == 'groups':
162+
for res in regex.findall(b):
163+
yield res
164+
161165
else:
162166
index = b.find(value)
163167
while index != -1:

0 commit comments

Comments
 (0)