chore: fix panic
ModRM parsing still used old parsing style.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
//! The main dissembling logic.
|
||||
|
||||
use env_logger::Target;
|
||||
|
||||
use crate::aout::Aout;
|
||||
use crate::operands::{
|
||||
Byte, DWord, Displacement, IByte, IWord, MemoryIndex, ModRmTarget, Operand, Pointer, Word,
|
||||
@@ -200,9 +202,7 @@ impl Disassembler {
|
||||
&mut self,
|
||||
register_width: Operand,
|
||||
) -> Result<(ModRmTarget, RegisterId), DisasmError> {
|
||||
// advance to operand
|
||||
self.offset += 1;
|
||||
let modrm = self.text[self.offset];
|
||||
let modrm = self.parse_byte()?;
|
||||
self.instruction.raw.push(modrm);
|
||||
|
||||
let (mode, reg, rm) = Self::deconstruct_modrm_byte(modrm);
|
||||
@@ -219,8 +219,9 @@ impl Disassembler {
|
||||
match mode {
|
||||
0b00 => {
|
||||
if rm == 0b110 {
|
||||
displacement = Some(Displacement::IWord(self.parse_word()? as IWord));
|
||||
log::debug!("ModRM direct memory read at {displacement:?}");
|
||||
let word = Displacement::IWord(self.parse_word()? as IWord);
|
||||
log::debug!("ModRM direct memory read at {word:?}");
|
||||
displacement = Some(word);
|
||||
return Ok((
|
||||
ModRmTarget::Memory(MemoryIndex {
|
||||
base: None,
|
||||
@@ -421,6 +422,7 @@ impl Disassembler {
|
||||
|
||||
let mut instructions = Vec::new();
|
||||
|
||||
log::debug!("Starting to decode text of length {}", self.text.len());
|
||||
while self.offset < self.text.len() {
|
||||
self.instruction.start = self.offset;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user