about summary refs log tree commit diff stats
path: root/miasm2/core
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--miasm2/core/asmblock.py14
-rw-r--r--miasm2/core/locationdb.py12
2 files changed, 26 insertions, 0 deletions
diff --git a/miasm2/core/asmblock.py b/miasm2/core/asmblock.py
index 2f16543f..c00b4c5c 100644
--- a/miasm2/core/asmblock.py
+++ b/miasm2/core/asmblock.py
@@ -1596,3 +1596,17 @@ class disasmEngine(object):
         warnings.warn('DEPRECATION WARNING: use "dis_multiblock" instead of "dis_multibloc"')
         return self.dis_multiblock(offset, blocs)
 
+    def dis_instr(self, offset):
+        """Disassemble one instruction at offset @offset and return the
+        corresponding instruction instance
+        @offset: targeted offset to disassemble
+        """
+        old_lineswd = self.lines_wd
+        self.lines_wd = 1
+        try:
+            block = self.dis_block(offset)
+        finally:
+            self.lines_wd = old_lineswd
+
+        instr = block.lines[0]
+        return instr
diff --git a/miasm2/core/locationdb.py b/miasm2/core/locationdb.py
index 39c1c99a..21e2d713 100644
--- a/miasm2/core/locationdb.py
+++ b/miasm2/core/locationdb.py
@@ -39,6 +39,8 @@ class LocationDB(object):
     None
     >>> loc_db.get_location_offset(loc_key2)
     0x1234
+    >>> loc_db.get_location_offset("first_name")
+    0x5678
 
     # Display a location
     >>> loc_db.pretty_str(loc_key1)
@@ -112,6 +114,16 @@ class LocationDB(object):
             return loc_key
         return self.add_location(offset=offset)
 
+    def get_name_offset(self, name):
+        """
+        Return the offset of @name if any, None otherwise.
+        @name: target name
+        """
+        loc_key = self.get_name_location(name)
+        if loc_key is None:
+            return None
+        return self.get_location_offset(loc_key)
+
     def add_location_name(self, loc_key, name):
         """Associate a name @name to a given @loc_key
         @name: str instance