diff options
| author | iximeow <me@iximeow.net> | 2026-05-31 05:51:50 +0000 |
|---|---|---|
| committer | iximeow <me@iximeow.net> | 2026-07-05 00:08:38 +0000 |
| commit | 9b24ada2c3a7afa42448fff7ee441ad983530d88 (patch) | |
| tree | e6a1ed54f5ce4fe5fc1fe5f462c25b4eada678c8 /src/real_mode/display.rs | |
| parent | 9c676ba70cdbf0edfeae7b8a13e881724711383b (diff) | |
add MASM-style formatting support in all modes
this includes a mildly nightmarish bit of test harness to compare
against ml.exe/ml64.exe/dumpbin.exe, which in turn chased out a bunch of
bugs. yay!
Diffstat (limited to 'src/real_mode/display.rs')
| -rw-r--r-- | src/real_mode/display.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/real_mode/display.rs b/src/real_mode/display.rs index b90c305..d4d5944 100644 --- a/src/real_mode/display.rs +++ b/src/real_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 @@ -2136,6 +2138,13 @@ 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. +/// +/// 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)] pub enum DisplayStyle { /// intel-style syntax for instructions, like @@ -2144,6 +2153,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. @@ -2707,6 +2722,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) + } } } } @@ -2990,6 +3008,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()) |
