11#!/usr/bin/env python3
2- #
2+ #
33# Cross Platform and Multi Architecture Advanced Binary Emulation Framework
44#
55
66from enum import Enum , Flag , IntEnum
7- from typing import Mapping , Type , TypeVar
7+ from typing import Final , Mapping , Type , TypeVar
8+
89
910class QL_ENDIAN (IntEnum ):
1011 EL = 1
1112 EB = 2
1213
14+
1315class QL_ARCH (IntEnum ):
1416 X86 = 101
1517 X8664 = 102
@@ -23,6 +25,7 @@ class QL_ARCH(IntEnum):
2325 RISCV64 = 111
2426 PPC = 112
2527
28+
2629class QL_OS (IntEnum ):
2730 LINUX = 201
2831 FREEBSD = 202
@@ -35,44 +38,53 @@ class QL_OS(IntEnum):
3538 MCU = 209
3639 BLOB = 210
3740
41+
3842class QL_VERBOSE (IntEnum ):
39- DISABLED = - 1 # turn off all the output
40- OFF = 0 # output only warnings
41- DEFAULT = 1 # output warnings and Qiling execute process information
42- DEBUG = 4 # output all logs above and debug information, include syscall information
43- DISASM = 10 # output all assembly instructions during Qiling execution
44- DUMP = 20 # output any log Qiling can, include instructions and registers
43+ DISABLED = - 1 # turn off all the output
44+ OFF = 0 # output only warnings
45+ DEFAULT = 1 # output warnings and Qiling execute process information
46+ DEBUG = 4 # output all logs above and debug information, include syscall information
47+ DISASM = 10 # output all assembly instructions during Qiling execution
48+ DUMP = 20 # output any log Qiling can, include instructions and registers
49+
4550
4651class QL_DEBUGGER (IntEnum ):
4752 GDB = 1
4853 IDAPRO = 2
4954 QDB = 3
5055
56+
5157class QL_INTERCEPT (IntEnum ):
5258 CALL = 1
5359 ENTER = 2
5460 EXIT = 3
5561
62+
5663class QL_STOP (Flag ):
5764 NONE = 0
5865 STACK_POINTER = (1 << 0 )
59- EXIT_TRAP = (1 << 1 )
66+ EXIT_TRAP = (1 << 1 )
67+
68+
69+ QL_ARCH_INTERPRETER : Final = (QL_ARCH .EVM ,)
6070
61- QL_ARCH_INTERPRETER = (QL_ARCH .EVM ,)
71+ QL_OS_POSIX : Final = (QL_OS .LINUX , QL_OS .FREEBSD , QL_OS .MACOS , QL_OS .QNX )
72+ QL_OS_BAREMETAL : Final = (QL_OS .MCU ,)
6273
63- QL_OS_POSIX = (QL_OS .LINUX , QL_OS .FREEBSD , QL_OS .MACOS , QL_OS .QNX )
64- QL_OS_BAREMETAL = (QL_OS .MCU ,)
6574
6675QL_HOOK_BLOCK = 0b0001
6776QL_CALL_BLOCK = 0b0010
6877
6978T = TypeVar ('T' , bound = Enum )
79+
80+
7081def __casefold_enum (e : Type [T ]) -> Mapping [str , T ]:
7182 '''Create a casefolded mapping of an enum to allow case-insensitive lookup.
7283 '''
7384
7485 return dict ((k .casefold (), v ) for k , v in e ._member_map_ .items ())
7586
87+
7688debugger_map = __casefold_enum (QL_DEBUGGER )
7789arch_map = __casefold_enum (QL_ARCH )
7890os_map = __casefold_enum (QL_OS )
0 commit comments