aboutsummaryrefslogtreecommitdiff
path: root/src/protected_mode/display.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/protected_mode/display.rs')
-rw-r--r--src/protected_mode/display.rs23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/protected_mode/display.rs b/src/protected_mode/display.rs
index dc0cb1d..328ee5a 100644
--- a/src/protected_mode/display.rs
+++ b/src/protected_mode/display.rs
@@ -1,3 +1,5 @@
+mod masm;
+
use core::fmt;
// allowing these deprecated items for the time being, not yet breaking yaxpeax-x86 apis
@@ -2134,7 +2136,14 @@ impl<'instr> fmt::Display for InstructionDisplayer<'instr> {
/// enum controlling how `Instruction::display_with` renders instructions. `Intel` is more or less
/// intel syntax, though memory operand sizes are elided if they can be inferred from other
/// operands.
-#[derive(Copy, Clone)]
+///
+/// note that `yaxpeax-x86` does not (and can not!) try to guarantee that formatting through any
+/// `DisplayStyle` round-trips through an assembler to produce the same bytes as were intially
+/// disassembled. opcode choice (for example, `0x31` vs `0x33` encodings of register-register
+/// `xor`) may not be controllable, immediates and displacements may have multiple valid encodings,
+/// and prefix handling in general is very lossy especially in the presence of repeat or
+/// ineffectual prefixes.
+#[derive(Copy, Clone, Debug)]
pub enum DisplayStyle {
/// intel-style syntax for instructions, like
/// `add eax, [edx + ecx * 2 + 0x1234]`
@@ -2142,6 +2151,12 @@ pub enum DisplayStyle {
/// C-style syntax for instructions, like
/// `eax += [edx + ecx * 2 + 0x1234]`
C,
+ /// format instructions in the syntax used by the Microsoft Assembler (MASM), like
+ /// `add eax, dword ptr [edx + ecx * 2 + 1234h]`
+ ///
+ /// some instructions are decoded by `dumpbin.exe` and `yaxpeax-x86` but cannot be assembled by
+ /// `masm.exe` or `ml64.exe`. as one example, `ud0`.
+ Masm,
// one might imagine an ATT style here, which is mostly interesting for reversing operand
// order.
// well.
@@ -2705,6 +2720,9 @@ impl <'instr, T: fmt::Write, Y: YaxColors> ShowContextual<u32, NoContext, T, Y>
DisplayStyle::C => {
contextualize_c(instr, &mut out)
}
+ DisplayStyle::Masm => {
+ masm::contextualize(&instr, &mut out)
+ }
}
}
}
@@ -2988,6 +3006,9 @@ mod buffer_sink {
DisplayStyle::C => {
contextualize_c(&display.instr, &mut handle)?;
}
+ DisplayStyle::Masm => {
+ super::masm::contextualize(&display.instr, &mut handle)?;
+ }
}
Ok(self.text_str())