Package IDAscope :: Package idascope :: Package core :: Module IdaProxy
[hide private]
[frames] | no frames]

Source Code for Module IDAscope.idascope.core.IdaProxy

  1  #!/usr/bin/python 
  2  ######################################################################## 
  3  # Copyright (c) 2012 
  4  # Daniel Plohmann <daniel.plohmann<at>gmail<dot>com> 
  5  # Alexander Hanel <alexander.hanel<at>gmail<dot>com> 
  6  # All rights reserved. 
  7  ######################################################################## 
  8  # 
  9  #  This file is part of IDAscope 
 10  # 
 11  #  IDAscope is free software: you can redistribute it and/or modify it 
 12  #  under the terms of the GNU General Public License as published by 
 13  #  the Free Software Foundation, either version 3 of the License, or 
 14  #  (at your option) any later version. 
 15  # 
 16  #  This program is distributed in the hope that it will be useful, but 
 17  #  WITHOUT ANY WARRANTY; without even the implied warranty of 
 18  #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
 19  #  General Public License for more details. 
 20  # 
 21  #  You should have received a copy of the GNU General Public License 
 22  #  along with this program.  If not, see 
 23  #  <http://www.gnu.org/licenses/>. 
 24  # 
 25  ######################################################################## 
 26   
 27  import idaapi 
 28  import idautils 
 29  import idc 
 30   
 31   
32 -class IdaProxy():
33 """ 34 This class serves as a generic proxy to the IDA Pro Python API. This is neccessary because while running the 35 plugin, dynamic references to the loaded Python modules get lost when inside functions called by Qt. 36 As a side effect, we can also do central error handling in this proxy class. 37 """ 38
39 - def __init__(self):
40 self.idc = idc 41 self.idaapi = idaapi 42 self.idautils = idautils 43 # constants 44 self.SN_NOWARN = self.idc.SN_NOWARN 45 self.SN_NOCHECK = self.idc.SN_NOCHECK 46 self.CIC_ITEM = self.idc.CIC_ITEM 47 self.BAD_ADDR = 0xffffffff 48 self.FF_LABL = self.idc.FF_LABL 49 self.SEARCH_DOWN = 1 50 self.FUNCATTR_END = self.idc.FUNCATTR_END 51 self.FUNC_LIB = self.idaapi.FUNC_LIB 52 self.INF_SHORT_DN = self.idc.INF_SHORT_DN
53
54 - def minEA(self):
55 return self.idaapi.cvar.inf.minEA
56
57 - def find_not_func(self, *args):
58 return self.idaapi.find_not_func(*args)
59
60 - def MakeFunction(self, instruction):
61 return self.idc.MakeFunction(instruction)
62
63 - def GetFunctionName(self, address):
64 return self.idc.GetFunctionName(address)
65
66 - def Jump(self, address):
67 return self.idc.Jump(address)
68
70 return self.idaapi.get_highlighted_identifier()
71
72 - def FlowChart(self, function_address):
73 function_chart = [] 74 try: 75 function_chart = self.idaapi.FlowChart(function_address) 76 except: 77 if function_address is not None: 78 print ("Trying to resolve an API address in non-function code at location: 0x%x, continuing analysis" \ 79 + "...") % function_address 80 else: 81 print ("IdaProxy.FlowChart: Tried to create a FlowChart on None object, skipping function.") 82 return function_chart
83
84 - def CompileLine(self, line):
85 return self.idaapi.CompileLine(line)
86
87 - def AddHotkey(self, hotkey, function):
88 return self.idc.AddHotkey(hotkey, function)
89
90 - def get_func(self, function_address):
91 return self.idaapi.get_func(function_address)
92
93 - def LocByName(self, name):
94 return self.idc.LocByName(name)
95
96 - def CodeRefsTo(self, destination, flow):
97 return self.idautils.CodeRefsTo(destination, flow)
98
99 - def CodeRefsFrom(self, source, flow):
100 return self.idautils.CodeRefsFrom(source, flow)
101
102 - def DataRefsTo(self, destination):
103 return self.idautils.DataRefsTo(destination)
104
105 - def SegStart(self, address):
106 return self.idc.SegStart(address)
107
108 - def SegEnd(self, address):
109 return self.idc.SegEnd(address)
110
111 - def SegName(self, address):
112 return self.idc.SegName(address)
113
114 - def MakeNameEx(self, address, name, warning_level):
115 return self.idc.MakeNameEx(address, name, warning_level)
116
117 - def Name(self, address):
118 return self.idc.Name(address)
119
120 - def GetMnem(self, address):
121 return self.idc.GetMnem(address)
122
123 - def GetType(self, address):
124 type_at_address = self.idc.GetType(address) 125 if type_at_address is not None: 126 return type_at_address 127 else: 128 print ("IdaProxy.FlowChart: No type information for 0x%x available, returning \"\".") % address 129 return ""
130
131 - def GetOpType(self, address, index):
132 return self.idc.GetOpType(address, index)
133
134 - def GetOperandValue(self, address, index):
135 return self.idc.GetOperandValue(address, index)
136
137 - def get_byte(self, address):
138 return self.idaapi.get_byte(address)
139
140 - def Segments(self):
141 return self.idautils.Segments()
142
143 - def Functions(self, start_address=None, end_address=None):
144 return self.idautils.Functions(start_address, end_address)
145
146 - def Heads(self, start_address=None, end_address=None):
147 return self.idautils.Heads(start_address, end_address)
148
149 - def XrefsTo(self, ea, flag=0):
150 return self.idautils.XrefsTo(ea, flag)
151
152 - def PrevHead(self, ea, minea=0):
153 return self.idc.PrevHead(ea, minea)
154
155 - def refresh_idaview_anyway(self):
156 return self.idaapi.refresh_idaview_anyway()
157
158 - def SetColor(self, address, location_type, color):
159 return self.idc.SetColor(address, location_type, color)
160
161 - def isCode(self, flags):
162 return self.idc.isCode(flags)
163
164 - def GetFlags(self, address):
165 return self.idc.GetFlags(address)
166
167 - def GetFunctionFlags(self, address):
168 return self.idc.GetFunctionFlags(address)
169
170 - def GetDisasm(self, address):
171 return self.idc.GetDisasm(address)
172
173 - def GetFunctionAttr(self, ea, attr):
174 return self.idc.GetFunctionAttr(ea, attr)
175
176 - def FuncItems(self, function_address):
177 return self.idautils.FuncItems(function_address)
178
179 - def Demangle(self, name, disable_mask):
180 return self.idc.Demangle(name, disable_mask)
181
182 - def GetLongPrm(self, offset):
183 return self.idc.GetLongPrm(offset)
184