Reduce namespace clutter

This commit is contained in:
elicn
2024-09-19 16:58:03 +03:00
parent 379791ad56
commit 7deb613a3c
7 changed files with 41 additions and 27 deletions

View File

@@ -1,8 +1,14 @@
import sys
import sys as _sys
if sys.version_info[0] == 2:
from .unicorn_const import (
UC_VERSION_MAJOR as __MAJOR,
UC_VERSION_MINOR as __MINOR,
UC_VERSION_PATCH as __PATCH
)
__version__ = "%u.%u.%u" % (__MAJOR, __MINOR, __PATCH)
if _sys.version_info.major == 2:
from .unicorn_py2 import *
else:
from .unicorn_py3 import *
__version__ = "%u.%u.%u" % (uc.UC_VERSION_MAJOR, uc.UC_VERSION_MINOR, uc.UC_VERSION_PATCH)

View File

@@ -1,4 +0,0 @@
# from .arm import UcRegCP
# from .arm64 import UcRegCP64
# from .intel import UcRegFPR, UcRegMMR, UcRegMSR
# from .types import UcReg128, UcReg256, UcReg512, UcReg, UcLargeReg, UcTupledReg

View File

@@ -6,9 +6,11 @@ from typing import Any, Tuple
import ctypes
from .. import Uc
from .. import arm_const as const
# traditional unicorn imports
from unicorn import arm_const as const
# newly introduced unicorn imports
from ..unicorn import Uc
from .types import UcTupledReg, UcReg128
ARMCPReg = Tuple[int, int, int, int, int, int, int, int]
@@ -83,3 +85,5 @@ class UcAArch32(Uc):
else:
self._reg_write(reg_id, reg_cls, value)
__all__ = ['UcRegCP', 'UcAArch32']

View File

@@ -6,11 +6,12 @@ from typing import Any, Callable, NamedTuple, Tuple
import ctypes
from .. import Uc, UcError
from .. import arm64_const as const
# traditional unicorn imports
from unicorn import arm64_const as const
from unicorn.unicorn_const import UC_ERR_ARG, UC_HOOK_INSN
from ..unicorn import uccallback
from unicorn import UC_ERR_ARG, UC_HOOK_INSN
# newly introduced unicorn imports
from ..unicorn import Uc, UcError, uccallback
from .types import uc_engine, UcTupledReg, UcReg128
ARM64CPReg = Tuple[int, int, int, int, int, int]
@@ -124,3 +125,5 @@ class UcAArch64(Uc):
else:
self._reg_write(reg_id, reg_cls, value)
__all__ = ['UcRegCP64', 'UcAArch64']

View File

@@ -2,15 +2,16 @@
#
# @author elicn
from typing import Any, Callable, Tuple
from typing import Any, Callable, Sequence, Tuple
import ctypes
from .. import Uc, UcError
from .. import x86_const as const
from unicorn.unicorn_py3 import uccallback
# traditional unicorn imports
from unicorn import x86_const as const
from unicorn.unicorn_const import UC_ERR_ARG, UC_HOOK_INSN
# newly introduced unicorn imports
from ..unicorn import Uc, UcError, uccallback
from .types import uc_engine, UcTupledReg, UcReg128, UcReg256, UcReg512
X86MMRReg = Tuple[int, int, int, int]
@@ -176,3 +177,6 @@ class UcIntel(Uc):
def msr_write(self, msr_id: int, value: int) -> None:
self._reg_write(const.UC_X86_REG_MSR, UcRegMSR, (msr_id, value))
__all__ = ['UcRegMMR', 'UcRegMSR', 'UcRegFPR', 'UcIntel']

View File

@@ -94,3 +94,6 @@ class UcReg256(UcLargeReg):
class UcReg512(UcLargeReg):
_fields_ = [('qwords', ctypes.c_uint64 * 8)]
__all__ = ['uc_err', 'uc_engine', 'uc_context', 'uc_hook_h', 'UcReg', 'UcTupledReg', 'UcLargeReg', 'UcReg128', 'UcReg256', 'UcReg512']

View File

@@ -5,10 +5,10 @@ import ctypes
import functools
import weakref
from unicorn import x86_const, arm_const, arm64_const, unicorn_const as uc
from .arch.types import *
from unicorn import unicorn_const as uc
from .arch.types import uc_err, uc_engine, uc_context, uc_hook_h, UcReg
__version__ = f'{uc.UC_VERSION_MAJOR}.{uc.UC_VERSION_MINOR}.{uc.UC_VERSION_PATCH}'
# __version__ = f'{uc.UC_VERSION_MAJOR}.{uc.UC_VERSION_MINOR}.{uc.UC_VERSION_PATCH}'
def _structure_repr(self):
return "%s(%s)" % (self.__class__.__name__, ", ".join("%s=%s" % (k, getattr(self, k)) for (k, _) in self._fields_))
@@ -457,7 +457,7 @@ class Uc(RegStateManager):
"""
def __wrapped() -> Type[Uc]:
archmod = importlib.import_module(f'.arch.{pkgname}', f'unicorn.unicorn_py3')
archmod = importlib.import_module(f'.arch.{pkgname}', 'unicorn.unicorn_py3')
return getattr(archmod, clsname)
@@ -1163,8 +1163,6 @@ UC_MMIO_READ_TYPE = Callable[[Uc, int, int, Any], int]
UC_MMIO_WRITE_TYPE = Callable[[Uc, int, int, int, Any], None]
__all__ = ['Uc', 'UcContext', 'ucsubclass', 'UcError', 'uc_version', 'version_bind', 'uc_arch_supported', 'debug']
__all__ = [
'Uc', 'UcContext', 'ucsubclass', 'uc_version', 'uc_arch_supported', 'version_bind', 'UcError', 'uc', 'debug', 'uccallback',
'x86_const', 'arm_const', 'arm64_const'
]