# 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

            v0 = ClusterViewer(cluster, create_bb_diff, trace.ctx_reg_size, save_func=save)
            w.pbar_update(24)
            v0.Show()

            prev_ctx = defaultdict(lambda: 0)
            stack_changes = defaultdict(lambda: 0)
            for line in cluster:
                if isinstance(line, Traceline):
                    prev_ctx = line.ctx
                else:
                    stack_changes = create_cluster_gist(line, trace.ctx_reg_size, prev_ctx, stack_changes)
                    prev_ctx = line[-1].ctx
            # sort the stack_changes by address
            sorted_result = sorted(stack_changes.keys())
            sorted_result.reverse()
            w.close()
            v1 = StackChangeViewer(vr, sorted_result, stack_changes)
            v1.Show()
        else:
            w.close()
            visualize_cli(cluster)
    except:
        w.close()

def optimization_analysis():
    """
    Opens the Optimization Viewer to let the user dynamically interact with the trace.
    """
    trace = prepare_trace()

# 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


            v0 = ClusterViewer(cluster, create_bb_diff, trace.ctx_reg_size, save_func=save)
            w.pbar_update(24)
            v0.Show()

            prev_ctx = defaultdict(lambda: 0)
            stack_changes = defaultdict(lambda: 0)
            for line in cluster:
                if isinstance(line, Traceline):
                    prev_ctx = line.ctx
                else:
                    stack_changes = create_cluster_gist(line, trace.ctx_reg_size, prev_ctx, stack_changes)
                    prev_ctx = line[-1].ctx
            # sort the stack_changes by address
            sorted_result = sorted(stack_changes.keys())
            sorted_result.reverse()
            w.close()
            v1 = StackChangeViewer(vr, sorted_result, stack_changes)
            v1.Show()
        else:
            w.close()
            visualize_cli(cluster)
    except:
        w.close()

def optimization_analysis():
    """
    Opens the Optimization Viewer to let the user dynamically interact with the trace.
    """
    trace = prepare_trace()

    v = OptimizationViewer(trace, save=save)