Skip to content

Commit

Permalink
updates to get plugin working in IDA 7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
demonduck committed Sep 19, 2017
1 parent 41cd8c3 commit dd67089
Showing 1 changed file with 39 additions and 17 deletions.
56 changes: 39 additions & 17 deletions first_plugin_ida/first.py
Expand Up @@ -62,6 +62,7 @@
import threading
import collections
import ConfigParser
from pprint import pprint
from os.path import exists
from hashlib import sha256, md5, sha1
from base64 import b64encode, b64decode
Expand All @@ -82,9 +83,19 @@ class IDAWrapper(object):
'''
Class to wrap functions that are not thread safe
'''
mapping = {
'get_tform_type' : 'get_widget_type',

}
def __init__(self):
self.version = idaapi.IDA_SDK_VERSION

def __getattribute__(self, name):
default = '[1st] default'

if (idaapi.IDA_SDK_VERSION >= 700) and (name in IDAWrapper.mapping):
name = IDAWrapper.mapping[name]

val = getattr(idaapi, name, default)
if val == default:
val = getattr(idc, name, default)
Expand Down Expand Up @@ -220,19 +231,22 @@ def view_created(self):

# Add chunks to the list at a time receieved
self.__received_data = False
idaapi.show_wait_box('Querying FIRST for metadata you\'ve created')
server_thread = FIRST.server.created(self.__data_callback, self.__complete_callback)
# Spawn thread to get chunks of data back from server
self.thread_stop = False
if FIRST.server:
# Spawn thread to get chunks of data back from server
self.thread_stop = False
idaapi.show_wait_box('Querying FIRST for metadata you\'ve created')
server_thread = FIRST.server.created(self.__data_callback,
self.__complete_callback)

# wait several seconds
for i in xrange(2):
time.sleep(1)
if idaapi.wasBreak():
self.thread_stop = True
FIRST.server.stop_operation(server_thread)

# wait several seconds
for i in xrange(2):
time.sleep(1)
if idaapi.wasBreak():
self.thread_stop = True
FIRST.server.stop_operation(server_thread)
idaapi.hide_wait_box()

idaapi.hide_wait_box()

self.history_dialogs = []
tree_view.setContextMenuPolicy(Qt.ActionsContextMenu)
Expand Down Expand Up @@ -826,10 +840,13 @@ def get_functions_with_applied_metadata():
list: Empty list or list of `MetadataShim` objects
'''
applied_metadata = []
for segment in FIRST.Metadata.get_segments_with_functions():
for function in FIRST.Metadata.get_segment_functions(segment):
if function.id:
applied_metadata.append(function)
segments = FIRST.Metadata.get_segments_with_functions()
if segments:
for segment in segments:
functions = FIRST.Metadata.get_segment_functions(segment)
for function in functions:
if function.id:
applied_metadata.append(function)

return applied_metadata

Expand Down Expand Up @@ -3355,7 +3372,10 @@ class IDP(idaapi.IDP_Hooks):
def __init__(self):
super(FIRST.Hook.IDP, self).__init__()

def auto_queue_empty(self, arg):
def ev_auto_queue_empty(self, arg):
self.auto_queue_empty(arg, before7=False)

def auto_queue_empty(self, arg, before7=True):
'''Called function for signaling queue status changes.
The function will populate FIRST's in memory function list, get
Expand Down Expand Up @@ -3394,7 +3414,9 @@ def auto_queue_empty(self, arg):

FIRST.plugin_enabled = True

return super(self.__class__, self).auto_queue_empty(arg)
if before7:
return super(self.__class__, self).auto_queue_empty(arg)
return super(self.__class__, self).ev_auto_queue_empty(arg)


class UI(idaapi.UI_Hooks):
Expand Down

0 comments on commit dd67089

Please sign in to comment.