# Path: voidwalker/framework/interface/command.py
# class PrefixCommand(Command):
#     def execute(self, terminal):
#         terminal.write('%(face-error)sAttempting to invoke an '
#                        'incomplete command!\n')
# 
# Path: voidwalker/framework/interface/command.py
# class StackCommand(Command):
#     __metaclass__ = abc.ABCMeta
# 
#     @abc.abstractmethod
#     def execute(self, config, terminal, thread, platform_factory, argument):
#         raise NotImplementedError
# 
# Path: voidwalker/framework/interface/command.py
# class SupportCommand(Command):
#     __metaclass__ = abc.ABCMeta
# 
#     @abc.abstractmethod
#     def execute(self, terminal, argument):
#         raise NotImplementedError
# 
# Path: voidwalker/framework/interface/command.py
# def register_command(cls):
#     _command_list.append(cls)
#     return cls
# 
# Path: voidwalker/framework/platform/cpu.py
# class Register(object):
#     class StaticRegister(type(register), object):
# class Cpu(object):
# class CpuFactory(object):
# class CpuRepository(object):
#     def __init__(self, name):
#     def name(self):
#     def size(self):
#     def value(self):
#     def str(self):
# def create_static_register(register):
#         def __init__(self, name):
#         def size(self):
#         def value(self):
#     def __init__(self, cpu_factory, registers):
#     def architecture(cls):
#     def register(self, name):
#     def registers(self):
#     def stack_pointer(self):
#     def program_counter(self):
#     def create_cpu(self, architecture):
#     def create_register(self, cpu, register):
#     def __init__(self, cpu_factory):
#     def get_cpu(self, architecture):
# def register_cpu(cls):
# 
# Path: voidwalker/application/commands/voidwalker.py
# class VoidwalkerCommand(PrefixCommand):
#     '''(void)walker is a GDB toolbox for low-level software debugging.
# 
# https://github.com/dholm/voidwalker'''
# 
#     @staticmethod
#     def name():
#         return 'voidwalker'
# 
#     def __init__(self):
#         super(VoidwalkerCommand, self).__init__()


from flowui.widgets import Section
from flowui.widgets.table import Cell
from flowui.widgets.table import Row
from flowui.widgets.table import Table
from ...framework.interface import PrefixCommand
from ...framework.interface import StackCommand
from ...framework.interface import SupportCommand
from ...framework.interface import register_command
from ...framework.platform import Architecture
from ..commands.voidwalker import VoidwalkerCommand
Apply the specified snippet at the specified address. This operation will
overwrite whatever is at that location in memory. The original binary is never
touched by this command.'''

            @staticmethod
            def name():
                return '%s %s' % (SnippetCommand.name(), 'apply')

            def __init__(self):
                super(ApplySnippetCommand, self).__init__()

            def execute(self, config, terminal, thread, platform_factory,
                        argument):
                if len(argument) < 2:
                    terminal.write('%(face-error)s'
                                   'Wrong number of arguments!\n')
                    return

                inferior = thread.get_inferior()
                snippet = snippet_repository.snippet(argument[0])
                if snippet is None:
                    terminal.write(' '.join(['%(face-error)sSnippet',
                                             argument[0],
                                             '%s does not exist!\n']))
                    return

                architecture = inferior.cpu().architecture()
                implementation = None
                if ((architecture == Architecture.X8664 and
                     architecture not in snippet.architectures())):

# Path: voidwalker/framework/interface/command.py
# class PrefixCommand(Command):
#     def execute(self, terminal):
#         terminal.write('%(face-error)sAttempting to invoke an '
#                        'incomplete command!\n')
# 
# Path: voidwalker/framework/interface/command.py
# class StackCommand(Command):
#     __metaclass__ = abc.ABCMeta
# 
#     @abc.abstractmethod
#     def execute(self, config, terminal, thread, platform_factory, argument):
#         raise NotImplementedError
# 
# Path: voidwalker/framework/interface/command.py
# class SupportCommand(Command):
#     __metaclass__ = abc.ABCMeta
# 
#     @abc.abstractmethod
#     def execute(self, terminal, argument):
#         raise NotImplementedError
# 
# Path: voidwalker/framework/interface/command.py
# def register_command(cls):
#     _command_list.append(cls)
#     return cls
# 
# Path: voidwalker/framework/platform/cpu.py
# class Register(object):
#     class StaticRegister(type(register), object):
# class Cpu(object):
# class CpuFactory(object):
# class CpuRepository(object):
#     def __init__(self, name):
#     def name(self):
#     def size(self):
#     def value(self):
#     def str(self):
# def create_static_register(register):
#         def __init__(self, name):
#         def size(self):
#         def value(self):
#     def __init__(self, cpu_factory, registers):
#     def architecture(cls):
#     def register(self, name):
#     def registers(self):
#     def stack_pointer(self):
#     def program_counter(self):
#     def create_cpu(self, architecture):
#     def create_register(self, cpu, register):
#     def __init__(self, cpu_factory):
#     def get_cpu(self, architecture):
# def register_cpu(cls):
# 
# Path: voidwalker/application/commands/voidwalker.py
# class VoidwalkerCommand(PrefixCommand):
#     '''(void)walker is a GDB toolbox for low-level software debugging.
# 
# https://github.com/dholm/voidwalker'''
# 
#     @staticmethod
#     def name():
#         return 'voidwalker'
# 
#     def __init__(self):
#         super(VoidwalkerCommand, self).__init__()


# Path: voidwalker/application/patching/interface.py
from flowui.widgets import Section
from flowui.widgets.table import Cell
from flowui.widgets.table import Row
from flowui.widgets.table import Table
from ...framework.interface import PrefixCommand
from ...framework.interface import StackCommand
from ...framework.interface import SupportCommand
from ...framework.interface import register_command
from ...framework.platform import Architecture
from ..commands.voidwalker import VoidwalkerCommand

Apply the specified snippet at the specified address. This operation will
overwrite whatever is at that location in memory. The original binary is never
touched by this command.'''

            @staticmethod
            def name():
                return '%s %s' % (SnippetCommand.name(), 'apply')

            def __init__(self):
                super(ApplySnippetCommand, self).__init__()

            def execute(self, config, terminal, thread, platform_factory,
                        argument):
                if len(argument) < 2:
                    terminal.write('%(face-error)s'
                                   'Wrong number of arguments!\n')
                    return

                inferior = thread.get_inferior()
                snippet = snippet_repository.snippet(argument[0])
                if snippet is None:
                    terminal.write(' '.join(['%(face-error)sSnippet',
                                             argument[0],
                                             '%s does not exist!\n']))
                    return

                architecture = inferior.cpu().architecture()
                implementation = None
                if ((architecture == Architecture.X8664 and
                     architecture not in snippet.architectures())):

                    assert Architecture.X86 in snippet.architectures()