aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SystemCalls.py34
1 files changed, 19 insertions, 15 deletions
diff --git a/SystemCalls.py b/SystemCalls.py
index c564029..f47caf0 100644
--- a/SystemCalls.py
+++ b/SystemCalls.py
@@ -9,10 +9,13 @@
by n0p
"""
-from miasm2.core.bin_stream_ida import bin_stream_ida
-from miasm2.analysis.depgraph import DependencyGraph
+try:
+ from miasm2.core.bin_stream_ida import bin_stream_ida
+ from miasm2.analysis.depgraph import DependencyGraph
-from utils import guess_machine
+ from utils import guess_machine
+except:
+ guess_machine = None
from idaapi import *
import idc
@@ -182,19 +185,20 @@ class SystemCall():
def __init__(self):
# Init miasm stuff.
- self.machine = guess_machine()
- self.mn, self.dis_engine, self.ira = self.machine.mn, self.machine.dis_engine, self.machine.ira
+ if guess_machine != None:
+ self.machine = guess_machine()
+ self.mn, self.dis_engine, self.ira = self.machine.mn, self.machine.dis_engine, self.machine.ira
- self.mdis = self.dis_engine(bin_stream_ida(), dont_dis_nulstart_bloc=True)
- self.ir_arch = self.ira(self.mdis.symbol_pool)
+ self.mdis = self.dis_engine(bin_stream_ida(), dont_dis_nulstart_bloc=True)
+ self.ir_arch = self.ira(self.mdis.symbol_pool)
- # Populate symbols with ida names
- for ad, name in Names():
- if name is None:
- continue
- self.mdis.symbol_pool.add_label(name, ad)
+ # Populate symbols with ida names
+ for ad, name in Names():
+ if name is None:
+ continue
+ self.mdis.symbol_pool.add_label(name, ad)
- self.elements = set([self.mn.regs.RAX])
+ self.elements = set([self.mn.regs.RAX])
self.x86 = dict()
self.x86_64 = dict()
@@ -229,8 +233,8 @@ class SystemCall():
func.calls -= calls
- # Just proceed with depgraph if IDA detected a function.
- if not func.f:
+ # Just proceed with depgraph if IDA detected a function and miasm had been imported.
+ if not func.f or guess_machine == None:
for call in func.calls:
sol.append([call.addr, call.sctype, ''])
return sol