aboutsummaryrefslogtreecommitdiff
path: root/test/protected_mode
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2020-11-19 18:13:24 -0800
committeriximeow <me@iximeow.net>2020-11-19 18:13:24 -0800
commit81e9b93aab9217cf7cb508f64b19fc1c0df024b5 (patch)
tree4a17eed4bd3191d3f02417d6c7d63420a474fb95 /test/protected_mode
parente3a400b7a96284d1394cd710ea3bcee01dbfe95f (diff)
fix decoding of rex-prefixed modrm+sib operands selecting index 0b100 and base 0b1010.1.4
for memory operands with a base, index, and displacement either the wrong base would be selected (register number ignored, so only `*ax` or `r8*` would be reported), or yaxpeax-x86 would report a base register is present when it is not (`RegIndexBaseScaleDisp` when the operand is actually `RegScaleDisp`) thank you to Evan Johnson for catching and reporting this bug! also bump crate version to 0.1.4 as this will be immediately tagged and released.
Diffstat (limited to 'test/protected_mode')
-rw-r--r--test/protected_mode/mod.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/protected_mode/mod.rs b/test/protected_mode/mod.rs
index 84448ef..dd0a51f 100644
--- a/test/protected_mode/mod.rs
+++ b/test/protected_mode/mod.rs
@@ -50,6 +50,40 @@ fn test_display_under(decoder: &InstDecoder, data: &[u8], expected: &'static str
}
#[test]
+fn test_modrm_decode() {
+ // just modrm
+ test_display(&[0x33, 0x08], "xor ecx, [eax]");
+ test_display(&[0x33, 0x20], "xor esp, [eax]");
+ test_display(&[0x33, 0x05, 0x78, 0x56, 0x34, 0x12], "xor eax, [0x12345678]");
+ test_display(&[0x33, 0x41, 0x23], "xor eax, [ecx + 0x23]");
+ test_display(&[0x33, 0x81, 0x23, 0x01, 0x65, 0x43], "xor eax, [ecx + 0x43650123]");
+ test_display(&[0x33, 0xc1], "xor eax, ecx");
+
+ // sib
+ test_display(&[0x33, 0x04, 0x0a], "xor eax, [edx + ecx * 1]");
+ test_display(&[0x33, 0x04, 0x4a], "xor eax, [edx + ecx * 2]");
+ test_display(&[0x33, 0x04, 0x8a], "xor eax, [edx + ecx * 4]");
+ test_display(&[0x33, 0x04, 0xca], "xor eax, [edx + ecx * 8]");
+ test_display(&[0x33, 0x04, 0x20], "xor eax, [eax]");
+ test_display(&[0x33, 0x04, 0x60], "xor eax, [eax]");
+ test_display(&[0x33, 0x04, 0xa0], "xor eax, [eax]");
+ test_display(&[0x33, 0x04, 0xe0], "xor eax, [eax]");
+ test_display(&[0x33, 0x04, 0x25, 0x11, 0x22, 0x33, 0x44], "xor eax, [0x44332211]");
+
+ test_display(&[0x33, 0x44, 0x65, 0x11], "xor eax, [ebp + 0x11]");
+ test_display(&[0x33, 0x84, 0xa5, 0x11, 0x22, 0x33, 0x44], "xor eax, [ebp + 0x44332211]");
+ test_display(&[0x33, 0x04, 0xe5, 0x11, 0x22, 0x33, 0x44], "xor eax, [0x44332211]");
+
+ // specifically sib with base == 0b101
+ // mod bits 00
+ test_display(&[0x33, 0x34, 0x25, 0x20, 0x30, 0x40, 0x50], "xor esi, [0x50403020]");
+ // mod bits 01
+ test_display(&[0x33, 0x74, 0x25, 0x20], "xor esi, [ebp + 0x20]");
+ // mod bits 10
+ test_display(&[0x33, 0xb4, 0x25, 0x20, 0x30, 0x40, 0x50], "xor esi, [ebp + 0x50403020]");
+}
+
+#[test]
fn test_mmx() {
test_display(&[0x0f, 0xf7, 0xc1], "maskmovq mm0, mm1");
test_invalid(&[0x0f, 0xf7, 0x01]);