Skip to content

Commit b57acc0

Browse files
committed
Replace UcError with IndexError when checking for invalid memory
1 parent 6a75429 commit b57acc0

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/dumpulator/dumpulator.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ def _all_exports(self):
717717
def _parse_module_exports(self, module):
718718
try:
719719
module_data = self.read(module.baseaddress, module.size)
720-
except UcError:
720+
except IndexError:
721721
self.error(f"Failed to read module data")
722722
return []
723723
pe = PE(data=module_data, fast_load=True)
@@ -757,7 +757,7 @@ def _setup_modules(self):
757757
try:
758758
data = self.read(va, size)
759759
mapped_data[rva:size] = data
760-
except UcError:
760+
except IndexError:
761761
self.error(f"Failed to read section {name} from module {path}")
762762
# Load the PE dumped from memory
763763
pe = PE(data=mapped_data, fast_load=True)
@@ -1325,9 +1325,9 @@ def _hook_code(uc: Uc, address, size, dp: Dumpulator):
13251325
instr = next(dp.cs.disasm(code, address, 1))
13261326
except StopIteration:
13271327
instr = None # Unsupported instruction
1328-
except UcError:
1329-
instr = None # Likely invalid memory
1330-
code = []
1328+
except IndexError:
1329+
instr = None # Likely invalid memory
1330+
code = b""
13311331
address_name = dp.exports.get(address, "")
13321332

13331333
module = ""
@@ -1361,13 +1361,13 @@ def _hook_code(uc: Uc, address, size, dp: Dumpulator):
13611361
def _unicode_string_to_string(dp: Dumpulator, arg: P(UNICODE_STRING)):
13621362
try:
13631363
return arg[0].read_str()
1364-
except UcError:
1364+
except IndexError:
13651365
return None
13661366

13671367
def _object_attributes_to_string(dp: Dumpulator, arg: P(OBJECT_ATTRIBUTES)):
13681368
try:
13691369
return arg[0].ObjectName[0].read_str()
1370-
except UcError:
1370+
except IndexError:
13711371
pass
13721372
return None
13731373

@@ -1555,6 +1555,6 @@ def _hook_invalid(uc: Uc, dp: Dumpulator):
15551555
return False # NOTE: returning True would stop emulation
15561556
except StopIteration:
15571557
pass # Unsupported instruction
1558-
except UcError:
1558+
except IndexError:
15591559
pass # Invalid memory access (NOTE: this should not be possible actually)
15601560
raise NotImplementedError("TODO: throw invalid instruction exception")

0 commit comments

Comments
 (0)