# Path: lib/Logging.py
# def get_log():
#     global logEng
#     if not logEng:
#         logEng = LoggingEngine()
# 
#     return logEng
# 
# Path: ui/AboutWindow.py
# class AboutWindow(QtWidgets.QDialog):
#     def __init__(self, *args, **kwargs):
#         super(AboutWindow, self).__init__(*args, **kwargs)
#         self.setFixedSize(600, 250)
#         self.setWindowTitle("About ...")
#         self.title = "VMAttack IDA PRO Plugin"
#         self.subtitle = "IDA Pro Plugin for static and dynamic virtualization-obfuscation analysis and deobfuscation"
#         self.author = u"Anatoli Kalysch and Tobias Krauß"
#         self.thanks = u"Special thanks to Johannes Götzfried for conceptual help along the way!"
#         self.version = "Version 0.2"
#         self.address = "Friedrich-Alexander University Erlangen-Nuremberg\n i1 Software Security Research Group \n"
# 
#         try:
#             title = self.config_label(self.title, 16, True)
#             subtitle = self.config_label(self.subtitle, 14)
#             subtitle.move(0, title.height() + title.y() + 10)
#             version = self.config_label(self.version, 12)
#             version.move(0, subtitle.height() + subtitle.y() + 30)
#             author = self.config_label(self.author, 12)
#             author.move(0, version.height() + version.y())
#             thanks = self.config_label(self.thanks, 12)
#             thanks.move(0, author.height() + author.y())
#         except Exception, e:
#             print e.message
# 
#         self.show()
# 
#     def config_label(self, name, size, bold=False, alignment="center"):
#         label = QtWidgets.QLabel(name, self)
#         label.setWordWrap(True)
#         font = label.font()
#         font.setPointSize(size)
#         font.setBold(bold)
#         label.setFont(font)
#         if alignment == "center":
#             label.setAlignment(QtCore.Qt.AlignCenter)
#         elif alignment == "right":
#             label.setAlignment(QtCore.Qt.AlignRight)
#         elif alignment == "left":
#             label.setAlignment(QtCore.Qt.AlignLeft)
#         label.setFixedWidth(600)
# 
#         return label
# 
# Path: ui/UIManager.py
# class UIManager(object):
#     def __init__(self):
# 
#         self.window = None
#         self.widget = None
#         self.menu = None
#         self.menu_dict = {}
#         self.get_init_menu()
# 
#     # initial menu grab
#     def get_init_menu(self):
#         try:
#             self.widget = form_to_widget(idaapi.get_current_tform())
#             if self.widget is None:
#                 raise Exception()
#         except:
#             self.widget = form_to_widget(idaapi.find_tform('Output window'))
#         self.window = self.widget.window()
#         self.menu = self.window.findChild(QtWidgets.QMenuBar)
# 
#     # add top level menu
#     def add_menu(self, name):
#         if name in self.menu_dict:
#             raise Exception("Menu name %s already exists." % name)
#         menu = self.menu.addMenu(name)
#         self.menu_dict[name] = menu
#     # remove top level menu
#     def remove_menu(self, name):
#         if name not in self.menu_dict:
#             raise Exception("Menu %s was not found. It might be deleted, or belong to another menu manager." % name)
# 
#         self.menu.removeAction(self.menu_dict[name].menuAction())
#         del self.menu_dict[name]
# 
#     # remove all menus currently in dict
#     def clear(self):
#         for menu in self.menu_dict.itervalues():
#             self.menu.removeAction(menu.menuAction())
#         self.menu_dict = {}
# 
#     def add_view(self, view):
#         pass


from lib.Logging import get_log
from dynamic.dynamic_deobfuscate import *
from lib.VMRepresentation import *
from static.static_deobfuscate import *
from ui.AboutWindow import AboutWindow
from ui.UIManager import UIManager
import ui.SettingsWindow as SettingsWindow
    def init(self):
        self.vma_mgr = None
        try:
            self.vma_mgr = get_mgr()
            self.vma_mgr.extend_menu()
            #self.vma_mgr.welcome()
            msg('[*] Starting VMAttack plugin...\n')
            get_log().log('[VMA] Starting VMAttack and initiating variables ...\n')
            return PLUGIN_KEEP

        except Exception, e:
            msg("[*] Failed to initialize VMAttack.\n %s\n" % e.message)
            if self.vma_mgr is not None:
                self.vma_mgr.revert_menu()
                del self.vma_mgr
            return PLUGIN_SKIP

    def run(self, arg):
        try:
            self.vma_mgr = get_mgr()
            self.vma_mgr.extend_menu()
            #self.vma_mgr.welcome()
            msg('[*] Reloading VMAttack plugin...\n')
            add_menu_item('Edit/Plugins/', 'Load VMAttack', None, 0, self.vma_mgr.extend_menu, ())
        except Exception,e:
            msg("[*] Failed to initialize VMAttack.\n %s\n" % e.message)
            msg(e.args)

    def term(self):
        if self.vma_mgr is not None:

# Path: lib/Logging.py
# def get_log():
#     global logEng
#     if not logEng:
#         logEng = LoggingEngine()
# 
#     return logEng
# 
# Path: ui/AboutWindow.py
# class AboutWindow(QtWidgets.QDialog):
#     def __init__(self, *args, **kwargs):
#         super(AboutWindow, self).__init__(*args, **kwargs)
#         self.setFixedSize(600, 250)
#         self.setWindowTitle("About ...")
#         self.title = "VMAttack IDA PRO Plugin"
#         self.subtitle = "IDA Pro Plugin for static and dynamic virtualization-obfuscation analysis and deobfuscation"
#         self.author = u"Anatoli Kalysch and Tobias Krauß"
#         self.thanks = u"Special thanks to Johannes Götzfried for conceptual help along the way!"
#         self.version = "Version 0.2"
#         self.address = "Friedrich-Alexander University Erlangen-Nuremberg\n i1 Software Security Research Group \n"
# 
#         try:
#             title = self.config_label(self.title, 16, True)
#             subtitle = self.config_label(self.subtitle, 14)
#             subtitle.move(0, title.height() + title.y() + 10)
#             version = self.config_label(self.version, 12)
#             version.move(0, subtitle.height() + subtitle.y() + 30)
#             author = self.config_label(self.author, 12)
#             author.move(0, version.height() + version.y())
#             thanks = self.config_label(self.thanks, 12)
#             thanks.move(0, author.height() + author.y())
#         except Exception, e:
#             print e.message
# 
#         self.show()
# 
#     def config_label(self, name, size, bold=False, alignment="center"):
#         label = QtWidgets.QLabel(name, self)
#         label.setWordWrap(True)
#         font = label.font()
#         font.setPointSize(size)
#         font.setBold(bold)
#         label.setFont(font)
#         if alignment == "center":
#             label.setAlignment(QtCore.Qt.AlignCenter)
#         elif alignment == "right":
#             label.setAlignment(QtCore.Qt.AlignRight)
#         elif alignment == "left":
#             label.setAlignment(QtCore.Qt.AlignLeft)
#         label.setFixedWidth(600)
# 
#         return label
# 
# Path: ui/UIManager.py
# class UIManager(object):
#     def __init__(self):
# 
#         self.window = None
#         self.widget = None
#         self.menu = None
#         self.menu_dict = {}
#         self.get_init_menu()
# 
#     # initial menu grab
#     def get_init_menu(self):
#         try:
#             self.widget = form_to_widget(idaapi.get_current_tform())
#             if self.widget is None:
#                 raise Exception()
#         except:
#             self.widget = form_to_widget(idaapi.find_tform('Output window'))
#         self.window = self.widget.window()
#         self.menu = self.window.findChild(QtWidgets.QMenuBar)
# 
#     # add top level menu
#     def add_menu(self, name):
#         if name in self.menu_dict:
#             raise Exception("Menu name %s already exists." % name)
#         menu = self.menu.addMenu(name)
#         self.menu_dict[name] = menu
#     # remove top level menu
#     def remove_menu(self, name):
#         if name not in self.menu_dict:
#             raise Exception("Menu %s was not found. It might be deleted, or belong to another menu manager." % name)
# 
#         self.menu.removeAction(self.menu_dict[name].menuAction())
#         del self.menu_dict[name]
# 
#     # remove all menus currently in dict
#     def clear(self):
#         for menu in self.menu_dict.itervalues():
#             self.menu.removeAction(menu.menuAction())
#         self.menu_dict = {}
# 
#     def add_view(self, view):
#         pass


# Path: VMAttack.py
from lib.Logging import get_log
from dynamic.dynamic_deobfuscate import *
from lib.VMRepresentation import *
from static.static_deobfuscate import *
from ui.AboutWindow import AboutWindow
from ui.UIManager import UIManager
import ui.SettingsWindow as SettingsWindow

    def init(self):
        self.vma_mgr = None
        try:
            self.vma_mgr = get_mgr()
            self.vma_mgr.extend_menu()
            #self.vma_mgr.welcome()
            msg('[*] Starting VMAttack plugin...\n')
            get_log().log('[VMA] Starting VMAttack and initiating variables ...\n')
            return PLUGIN_KEEP

        except Exception, e:
            msg("[*] Failed to initialize VMAttack.\n %s\n" % e.message)
            if self.vma_mgr is not None:
                self.vma_mgr.revert_menu()
                del self.vma_mgr
            return PLUGIN_SKIP

    def run(self, arg):
        try:
            self.vma_mgr = get_mgr()
            self.vma_mgr.extend_menu()
            #self.vma_mgr.welcome()
            msg('[*] Reloading VMAttack plugin...\n')
            add_menu_item('Edit/Plugins/', 'Load VMAttack', None, 0, self.vma_mgr.extend_menu, ())
        except Exception,e:
            msg("[*] Failed to initialize VMAttack.\n %s\n" % e.message)
            msg(e.args)

    def term(self):
        if self.vma_mgr is not None:

            get_log().finalize()