mirror of https://github.com/pwndbg/pwndbg
Add mocks
This commit is contained in:
parent
8eabec5541
commit
8a417091b5
|
@ -0,0 +1,9 @@
|
|||
import types
|
||||
|
||||
|
||||
class Amd64Arch(types.ModuleType):
|
||||
def __init__(self, module_name):
|
||||
super(Amd64Arch, self).__init__(module_name)
|
||||
|
||||
self.ptrsize = 8
|
||||
self.endian = "little"
|
|
@ -0,0 +1,18 @@
|
|||
import types
|
||||
|
||||
|
||||
class Config(types.ModuleType):
|
||||
def __init__(self, module_name):
|
||||
super(Config, self).__init__(module_name)
|
||||
|
||||
def trigger(self, *args):
|
||||
def wrapper(func):
|
||||
return func
|
||||
|
||||
return wrapper
|
||||
|
||||
def add_param(self, *args):
|
||||
pass
|
||||
|
||||
def init_params(self):
|
||||
pass
|
|
@ -0,0 +1,12 @@
|
|||
import sys
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
module_name = "gdb"
|
||||
module = MagicMock()
|
||||
sys.modules[module_name] = module
|
||||
|
||||
import gdb
|
||||
|
||||
gdb.PARAM_BOOLEAN = 0
|
||||
gdb.PARAM_ZINTEGER = 4
|
||||
gdb.PARAM_STRING = 8
|
|
@ -0,0 +1,36 @@
|
|||
import sys
|
||||
import types
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from mocks.arch import Amd64Arch
|
||||
from mocks.config import Config
|
||||
from mocks.typeinfo import Amd64TypeInfo
|
||||
|
||||
|
||||
class GdbLib(types.ModuleType):
|
||||
def __init__(self, module_name):
|
||||
super().__init__(module_name)
|
||||
|
||||
self.config_mod = Config(module_name + ".config")
|
||||
self.arch = Amd64Arch(module_name + ".arch")
|
||||
self.typeinfo = Amd64TypeInfo(module_name + ".typeinfo")
|
||||
self.regs = MagicMock(__name__=module_name + ".regs")
|
||||
|
||||
self.prompt = MagicMock()
|
||||
|
||||
sys.modules[self.config_mod.__name__] = self.config_mod
|
||||
sys.modules[self.arch.__name__] = self.arch
|
||||
sys.modules[self.typeinfo.__name__] = self.typeinfo
|
||||
sys.modules[self.regs.__name__] = self.regs
|
||||
|
||||
def load_gdblib(self):
|
||||
pass
|
||||
|
||||
|
||||
module_name = "pwndbg.gdblib"
|
||||
module = GdbLib(module_name)
|
||||
sys.modules[module_name] = module
|
||||
|
||||
import pwndbg
|
||||
|
||||
pwndbg.gdblib = sys.modules["pwndbg.gdblib"]
|
|
@ -0,0 +1,7 @@
|
|||
import types
|
||||
|
||||
|
||||
class Amd64TypeInfo(types.ModuleType):
|
||||
def __init__(self, module_name):
|
||||
super(Amd64TypeInfo, self).__init__(module_name)
|
||||
self.ptrsize = 8
|
Loading…
Reference in New Issue