Skip to content

Commit

Permalink
Error when trying to use 64-bit registers in 32-bit mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexodia committed Jun 20, 2022
1 parent 4893c1a commit b230656
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,4 @@ What sets dumpulator apart from sandboxes like speakeasy and qiling is that the

- [herrcore](https://twitter.com/herrcore) for inspiring me to make this
- [secret club](https://secret.club)
- [JetBrains](https://www.jetbrains.com/opensource/) for free PyCharm license!
12 changes: 10 additions & 2 deletions src/dumpulator/dumpulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,22 @@ def __init__(self, uc: Uc, x64):
"cip": UC_X86_REG_EIP,
})

def _resolve_reg(self, regname):
uc_reg = self._regmap.get(regname, None)
if uc_reg is None:
raise Exception(f"Unknown register '{regname}'")
if not self._x64 and regname.startswith("r"):
raise Exception(f"Register {regname} is not available in 32-bit mode")
return uc_reg

def __getattr__(self, name: str):
return self._uc.reg_read(self._regmap[name])
return self._uc.reg_read(self._resolve_reg(name))

def __setattr__(self, name: str, value):
if name.startswith("_"):
object.__setattr__(self, name, value)
else:
self._uc.reg_write(self._regmap[name], value)
self._uc.reg_write(self._resolve_reg(name), value)

# value = dp.regs[myname]
def __getitem__(self, name: str):
Expand Down

0 comments on commit b230656

Please sign in to comment.