aboutsummaryrefslogtreecommitdiff
path: root/src/long_mode/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/long_mode/mod.rs')
-rw-r--r--src/long_mode/mod.rs26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/long_mode/mod.rs b/src/long_mode/mod.rs
index f2b2b57..4babca3 100644
--- a/src/long_mode/mod.rs
+++ b/src/long_mode/mod.rs
@@ -2757,9 +2757,9 @@ pub struct InstDecoder {
}
impl InstDecoder {
- /// Instantiates an x86_64 decoder that decodes the bare minimum of x86_64.
+ /// instantiates an x86_64 decoder that decodes the bare minimum of x86_64.
///
- /// Pedantic and only decodes what the spec says is well-defined, rejecting undefined sequences
+ /// pedantic and only decodes what the spec says is well-defined, rejecting undefined sequences
/// and any instructions defined by extensions.
pub fn minimal() -> Self {
InstDecoder {
@@ -2767,6 +2767,15 @@ impl InstDecoder {
}
}
+ /// helper to decode an instruction directly from a byte slice.
+ ///
+ /// this lets callers avoid the work of setting up a [`yaxpeax_arch::U8Reader`] for the slice
+ /// to decode.
+ pub fn decode_slice(&self, data: &[u8]) -> Result<Instruction, DecodeError> {
+ let mut reader = yaxpeax_arch::U8Reader::new(data);
+ self.decode(&mut reader)
+ }
+
pub fn sse3(&self) -> bool {
self.flags & (1 << 0) != 0
}
@@ -4194,6 +4203,17 @@ impl Default for Instruction {
}
}
+const MEM_SIZE_STRINGS: [&'static str; 64] = [
+ "byte", "word", "BUG", "dword", "BUG", "BUG", "BUG", "qword",
+ "far", "mword", "BUG", "BUG", "BUG", "BUG", "BUG", "xmmword",
+ "BUG", "BUG", "BUG", "BUG", "BUG", "BUG", "BUG", "BUG",
+ "BUG", "BUG", "BUG", "BUG", "BUG", "BUG", "BUG", "ymmword",
+ "BUG", "BUG", "BUG", "BUG", "BUG", "BUG", "BUG", "BUG",
+ "BUG", "BUG", "BUG", "BUG", "BUG", "BUG", "BUG", "BUG",
+ "BUG", "BUG", "BUG", "BUG", "BUG", "BUG", "BUG", "BUG",
+ "BUG", "BUG", "BUG", "BUG", "BUG", "BUG", "ptr", "zmmword",
+];
+
pub struct MemoryAccessSize {
size: u8,
}
@@ -4207,7 +4227,7 @@ impl MemoryAccessSize {
}
pub fn size_name(&self) -> &'static str {
- "name_strings"
+ MEM_SIZE_STRINGS[self.size as usize - 1]
}
}