# Path: ui/UIManager.py
# class UIManager(object):
#     def __init__(self):
#     def get_init_menu(self):
#     def add_menu(self, name):
#     def remove_menu(self, name):
#     def clear(self):
#     def add_view(self, view):
# 
# Path: ui/UIManager.py
# class UIManager(object):
#     def __init__(self):
#     def get_init_menu(self):
#     def add_menu(self, name):
#     def remove_menu(self, name):
#     def clear(self):
#     def add_view(self, view):
# 
# Path: ui/UIManager.py
# class UIManager(object):
#     def __init__(self):
#     def get_init_menu(self):
#     def add_menu(self, name):
#     def remove_menu(self, name):
#     def clear(self):
#     def add_view(self, view):
# 
# Path: ui/UIManager.py
# class UIManager(object):
#     def __init__(self):
#     def get_init_menu(self):
#     def add_menu(self, name):
#     def remove_menu(self, name):
#     def clear(self):
#     def add_view(self, view):
# 
# Path: lib/VMRepresentation.py
# def get_vmr():
#     """
#     Get the VMR instance.
#     :return: vmr
#     """
#     global vmr
#     if vmr is None:
#         vmr = VMRepresentation()
#     return vmr
# 
# Path: ui/NotifyProgress.py
# class NotifyProgress(QtWidgets.QWidget):
#     def __init__(self, name='current', *args, **kwargs):
#         super(NotifyProgress, self).__init__(*args, **kwargs)
#         self.analysis = name
#         self.pbar = QtWidgets.QProgressBar(self)
#         self.pbar.setGeometry(30, 40, 370, 25)
#         self.value = 0
#         self.setFixedSize(400, 100)
#         self.setWindowTitle('Running %s Analysis...' % self.analysis)
# 
#     def pbar_update(self, value):
#         self.value += value
#         if self.value > 100:
#             self.value = 100
#             self.close()
#         self.pbar.setValue(self.value)
# 
#     def pbar_set(self, value):
#         self.pbar.setValue(value)
# 
# Path: ui/UIManager.py
# class UIManager(object):
#     def __init__(self):
#     def get_init_menu(self):
#     def add_menu(self, name):
#     def remove_menu(self, name):
#     def clear(self):
#     def add_view(self, view):


from threading import Thread
from ui.UIManager import GradingViewer
from ui.UIManager import OptimizationViewer
from ui.UIManager import StackChangeViewer
from ui.UIManager import VMInputOuputViewer
from DebuggerHandler import load, save, get_dh
from lib.TraceAnalysis import *
from lib.VMRepresentation import get_vmr
from ui.NotifyProgress import NotifyProgress
from ui.UIManager import ClusterViewer
    from IDADebugger import IDADebugger
    from OllyDebugger import OllyDebugger
    from IDADebugger import IDADebugger
    from IDADebugger import IDADebugger
    from IDADebugger import IDADebugger
    """
    Grading System initialization. This function is part of the automaton grading system.
    High grade equals importance. The higher the better. This is the initialization routine for the grading automaton. It assigns the initial grade according to the uniqueness of a line.
    :param trace: instruction trace
    """
    addr_count = address_count(deepcopy(trace))
    grade = len(set(i[1] for i in addr_count))
    addr_count.reverse()  # now the addrs with single occurence are at the beginning of the list
    ctr = 1
    for tupel in addr_count:  # tupel[0] == address, tupel[1] == address occurence
        if ctr != tupel[1]:
            ctr = tupel[1]
            grade -= 1

        for line in trace:
            if line.addr == tupel[0]:
                line.grade = grade
    return trace


def grading_automaton(visualization=0):
    """
    Grading System Analysis computes a grade for every trace line. It is basically a combination of all available analysis capabilities and runs them one after another, increases the grade
    for those trace lines which are in the analysis result and then runs the next trace analysis. In between the analysis runs a pattern matching run is started, to increase / decrease cer-
    tain trace lines grades based on known patterns. The patterns are modelled after known short comings of the analysis capabilities.
    :param trace: instruction trace
    :return: graded instruction trace
    """
    vmr = get_vmr()


# Path: ui/UIManager.py
# class UIManager(object):
#     def __init__(self):
#     def get_init_menu(self):
#     def add_menu(self, name):
#     def remove_menu(self, name):
#     def clear(self):
#     def add_view(self, view):
# 
# Path: ui/UIManager.py
# class UIManager(object):
#     def __init__(self):
#     def get_init_menu(self):
#     def add_menu(self, name):
#     def remove_menu(self, name):
#     def clear(self):
#     def add_view(self, view):
# 
# Path: ui/UIManager.py
# class UIManager(object):
#     def __init__(self):
#     def get_init_menu(self):
#     def add_menu(self, name):
#     def remove_menu(self, name):
#     def clear(self):
#     def add_view(self, view):
# 
# Path: ui/UIManager.py
# class UIManager(object):
#     def __init__(self):
#     def get_init_menu(self):
#     def add_menu(self, name):
#     def remove_menu(self, name):
#     def clear(self):
#     def add_view(self, view):
# 
# Path: lib/VMRepresentation.py
# def get_vmr():
#     """
#     Get the VMR instance.
#     :return: vmr
#     """
#     global vmr
#     if vmr is None:
#         vmr = VMRepresentation()
#     return vmr
# 
# Path: ui/NotifyProgress.py
# class NotifyProgress(QtWidgets.QWidget):
#     def __init__(self, name='current', *args, **kwargs):
#         super(NotifyProgress, self).__init__(*args, **kwargs)
#         self.analysis = name
#         self.pbar = QtWidgets.QProgressBar(self)
#         self.pbar.setGeometry(30, 40, 370, 25)
#         self.value = 0
#         self.setFixedSize(400, 100)
#         self.setWindowTitle('Running %s Analysis...' % self.analysis)
# 
#     def pbar_update(self, value):
#         self.value += value
#         if self.value > 100:
#             self.value = 100
#             self.close()
#         self.pbar.setValue(self.value)
# 
#     def pbar_set(self, value):
#         self.pbar.setValue(value)
# 
# Path: ui/UIManager.py
# class UIManager(object):
#     def __init__(self):
#     def get_init_menu(self):
#     def add_menu(self, name):
#     def remove_menu(self, name):
#     def clear(self):
#     def add_view(self, view):


# Path: dynamic/dynamic_deobfuscate.py
from threading import Thread
from ui.UIManager import GradingViewer
from ui.UIManager import OptimizationViewer
from ui.UIManager import StackChangeViewer
from ui.UIManager import VMInputOuputViewer
from DebuggerHandler import load, save, get_dh
from lib.TraceAnalysis import *
from lib.VMRepresentation import get_vmr
from ui.NotifyProgress import NotifyProgress
from ui.UIManager import ClusterViewer
    from IDADebugger import IDADebugger
    from OllyDebugger import OllyDebugger
    from IDADebugger import IDADebugger
    from IDADebugger import IDADebugger
    from IDADebugger import IDADebugger

    """
    Grading System initialization. This function is part of the automaton grading system.
    High grade equals importance. The higher the better. This is the initialization routine for the grading automaton. It assigns the initial grade according to the uniqueness of a line.
    :param trace: instruction trace
    """
    addr_count = address_count(deepcopy(trace))
    grade = len(set(i[1] for i in addr_count))
    addr_count.reverse()  # now the addrs with single occurence are at the beginning of the list
    ctr = 1
    for tupel in addr_count:  # tupel[0] == address, tupel[1] == address occurence
        if ctr != tupel[1]:
            ctr = tupel[1]
            grade -= 1

        for line in trace:
            if line.addr == tupel[0]:
                line.grade = grade
    return trace


def grading_automaton(visualization=0):
    """
    Grading System Analysis computes a grade for every trace line. It is basically a combination of all available analysis capabilities and runs them one after another, increases the grade
    for those trace lines which are in the analysis result and then runs the next trace analysis. In between the analysis runs a pattern matching run is started, to increase / decrease cer-
    tain trace lines grades based on known patterns. The patterns are modelled after known short comings of the analysis capabilities.
    :param trace: instruction trace
    :return: graded instruction trace
    """
    vmr = get_vmr()


    w = NotifyProgress('Grading')