Mercurial > repos > blastem
diff gen_x86.c @ 692:e11e68918691
Fix bug in map_native_address that was breaking some self-modifying code in Gunstar Heroes
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 28 Apr 2015 19:04:36 -0700 |
parents | 74d636e85bf8 |
children | cb1c005880e7 |
line wrap: on
line diff
--- a/gen_x86.c Sat Mar 14 12:05:03 2015 -0700 +++ b/gen_x86.c Tue Apr 28 19:04:36 2015 -0700 @@ -2135,9 +2135,15 @@ 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 { }