diff options
author | Michael Pavone <pavone@retrodev.com> | 2015-04-28 19:04:36 -0700 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2015-04-28 19:04:36 -0700 |
commit | 46b4c104c2447d9081122696a43094d0cb987de3 (patch) | |
tree | b8cc21080d6f91124ba48478f1cb1f09c52faaac /gen_x86.c | |
parent | 543e7e93904092da8c12149c83304c0d64a5e789 (diff) |
Fix bug in map_native_address that was breaking some self-modifying code in Gunstar Heroes
Diffstat (limited to 'gen_x86.c')
-rw-r--r-- | gen_x86.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -2135,9 +2135,15 @@ uint32_t x86_inst_size(code_ptr start) if (has_modrm(prefix, main_op)) { uint8_t mod_rm = *(code++); if (has_sib(mod_rm)) { - uint8_t sib = *(code++); - } else { - + //sib takes up a byte, but can't add any additional ones beyond that + code++; + } + uint8_t mode = mod_rm & 0xC0; + uint8_t rm = mod_rm & 3; + if (mode == MODE_REG_DISPLACE8) { + code++; + } else if (mode == MODE_REG_DISPLACE32 || (mode == MODE_REG_INDIRECT && rm == RBP)) { + code += 4; } } else { } |