Skip to content

Commit 3e2509b

Browse files
committed
Future-proof support for unaligned memory violations
1 parent 19853bd commit 3e2509b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/dumpulator/dumpulator.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ class MemoryViolation(Enum):
4747
ReadProtect = 4
4848
WriteProtect = 5
4949
ExecuteProtect = 6
50+
ReadUnaligned = 7
51+
WriteUnaligned = 8
52+
ExecuteUnaligned = 9
5053

5154
@dataclass
5255
class ExceptionInfo:
@@ -991,7 +994,8 @@ def handle_exception(self):
991994
context_ex.XState.Offset = 0xF0 if self._x64 else 0x20
992995
context_ex.XState.Length = 0x160 if self._x64 else 0x140
993996
record = record_type()
994-
if self._exception.type == ExceptionType.Memory:
997+
alignment_violations = [MemoryViolation.ReadUnaligned, MemoryViolation.WriteUnaligned, MemoryViolation.ExecuteUnaligned]
998+
if self._exception.type == ExceptionType.Memory and self._exception.memory_violation not in alignment_violations:
995999
record.ExceptionCode = STATUS_ACCESS_VIOLATION
9961000
record.ExceptionFlags = 0
9971001
record.ExceptionAddress = self.regs.cip
@@ -1004,7 +1008,7 @@ def handle_exception(self):
10041008
MemoryViolation.WriteProtect: EXCEPTION_WRITE_FAULT,
10051009
MemoryViolation.ExecuteProtect: EXCEPTION_EXECUTE_FAULT,
10061010
}
1007-
record.ExceptionInformation[0] = types.get(self._exception.memory_violation, EXCEPTION_READ_FAULT)
1011+
record.ExceptionInformation[0] = types[self._exception.memory_violation]
10081012
record.ExceptionInformation[1] = self._exception.memory_address
10091013
elif self._exception.type == ExceptionType.Interrupt and self._exception.interrupt_number == 3:
10101014
if self._x64:

0 commit comments

Comments
 (0)