Skip to content

Commit 457ca16

Browse files
committed
Misc insignificant fixes
1 parent 3ef5137 commit 457ca16

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

qiling/core.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
# Cross Platform and Multi Architecture Advanced Binary Emulation Framework
44
#
55

6-
from configparser import ConfigParser
76
import os, pickle
87

98
# See https://stackoverflow.com/questions/39740632/python-type-hinting-without-cyclic-imports
109
from typing import AnyStr, List, Mapping, MutableMapping, Sequence, Union
1110
from typing import TYPE_CHECKING
12-
13-
from unicorn.unicorn import Uc
11+
from configparser import ConfigParser
1412

1513
if TYPE_CHECKING:
14+
from unicorn.unicorn import Uc
1615
from logging import Logger
1716
from .arch.arch import QlArch
1817
from .os.os import QlOs
@@ -142,14 +141,14 @@ def __init__(
142141

143142
# arch should have been determined by now; fail if not
144143
if type(archtype) is not QL_ARCH:
145-
raise QlErrorArch(f'Uknown or unsupported architecture: "{archtype}"')
144+
raise QlErrorArch(f'Unknown or unsupported architecture: "{archtype}"')
146145

147146
# os should have been determined by now; fail if not
148147
if type(ostype) is not QL_OS:
149148
raise QlErrorOsType(f'Unknown or unsupported operating system: "{ostype}"')
150149

151150
# if endianess is still undetermined, set it to little-endian.
152-
# this setting is ignored for architectures with predfined endianess
151+
# this setting is ignored for architectures with predefined endianess
153152
if endian is None:
154153
endian = QL_ENDIAN.EL
155154

@@ -193,7 +192,8 @@ def __init__(
193192

194193
# Run the loader
195194
self.loader.run()
196-
self._init_stop_guard()
195+
196+
self._init_stop_guard()
197197

198198
#####################
199199
# Qiling Components #
@@ -373,8 +373,8 @@ def verbose(self) -> QL_VERBOSE:
373373
Values:
374374
`QL_VERBOSE.DISABLED`: turn off logging
375375
`QL_VERBOSE.OFF` : mask off anything below warnings, errors and critical severity
376-
`QL_VERBOSE.DEFAULT` : info logging level: default verbosity
377-
`QL_VERBOSE.DEBUG` : debug logging level: higher verbosity
376+
`QL_VERBOSE.DEFAULT` : info logging level; default verbosity
377+
`QL_VERBOSE.DEBUG` : debug logging level; higher verbosity
378378
`QL_VERBOSE.DISASM` : debug verbosity along with disassembly trace (slow!)
379379
`QL_VERBOSE.DUMP` : disassembly trace along with cpu context dump
380380
"""
@@ -465,15 +465,15 @@ def filter(self, regex: Optional[str]):
465465
self._log_filter.update_filter(regex)
466466

467467
@property
468-
def uc(self) -> Uc:
468+
def uc(self) -> 'Uc':
469469
""" Raw uc instance.
470470
471-
Type: Ucgit
471+
Type: Uc
472472
"""
473473
return self._uc
474474

475475
@uc.setter
476-
def uc(self, u):
476+
def uc(self, u: 'Uc'):
477477
self._uc = u
478478

479479
@property

qiling/utils.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
T = TypeVar('T')
3131
QlClassInit = Callable[['Qiling'], T]
3232

33-
def catch_KeyboardInterrupt(ql, func):
33+
def catch_KeyboardInterrupt(ql: 'Qiling', func: Callable):
3434
def wrapper(*args, **kw):
3535
try:
3636
return func(*args, **kw)
@@ -84,6 +84,16 @@ def ql_get_module_function(module_name: str, function_name: str):
8484

8585
return module_function
8686

87+
# This function is extracted from os_setup (QlOsPosix) so I put it here.
88+
def ql_syscall_mapping_function(ostype: QL_OS, archtype: QL_ARCH):
89+
qlos_name = ostype.name
90+
qlos_path = f'qiling.os.{qlos_name.lower()}.map_syscall'
91+
qlos_func = 'get_syscall_mapper'
92+
93+
func = ql_get_module_function(qlos_path, qlos_func)
94+
95+
return func(archtype)
96+
8797
def __emu_env_from_pathname(path: str) -> Tuple[Optional[QL_ARCH], Optional[QL_OS], Optional[QL_ENDIAN]]:
8898
if os.path.isdir(path) and path.endswith('.kext'):
8999
return QL_ARCH.X8664, QL_OS.MACOS, QL_ENDIAN.EL
@@ -380,16 +390,6 @@ def select_arch(archtype: QL_ARCH, endian: QL_ENDIAN, thumb: bool) -> QlClassIni
380390

381391
return partial(obj, **kwargs)
382392

383-
# This function is extracted from os_setup (QlOsPosix) so I put it here.
384-
def ql_syscall_mapping_function(ostype: QL_OS, archtype: QL_ARCH):
385-
qlos_name = ostype.name
386-
qlos_path = f'qiling.os.{qlos_name.lower()}.map_syscall'
387-
qlos_func = 'get_syscall_mapper'
388-
389-
func = ql_get_module_function(qlos_path, qlos_func)
390-
391-
return func(archtype)
392-
393393
def select_os(ostype: QL_OS) -> QlClassInit['QlOs']:
394394
qlos_name = ostype.name
395395
qlos_path = f'qiling.os.{qlos_name.lower()}.{qlos_name.lower()}'

0 commit comments

Comments
 (0)