diff --git a/qiling/arch/evm/vm/evm.py b/qiling/arch/evm/vm/evm.py
index 73bd4e63a..8310d493b 100644
--- a/qiling/arch/evm/vm/evm.py
+++ b/qiling/arch/evm/vm/evm.py
@@ -14,20 +14,20 @@
from .utils import bytecode_to_bytes, runtime_code_detector
from ..abi import QlArchEVMABI
-# Code name Release date Release block Opcode supported
+# Code name Release date Release block Opcode supported
-# Frontier 2015-07-30 0 Yes
-# Ice Age 2015-09-08 200,000 -
-# Homestead 2016-03-15 1,150,000 Yes
-# DAO Fork (unplanned) 2016-07-20 1,920,000 -
-# Tangerine Whistle (unplanned) 2016-10-18 2,463,000 Yes
-# Spurious Dragon 2016-11-23 2,675,000 Yes
-# Byzantium 2017-10-16 4,370,000 Yes
-# Constantinople 2019-02-28 7,280,000 Yes
-# Petersburg (unplanned) 2019-02-28 7,280,000 Yes
-# Istanbul 2019-12-08 9,069,000 Yes
-# Muir Glacier 2020-01-01 9,200,000 Yes
-# Berlin TBD TBD Yes
+# Frontier 2015-07-30 0 Yes
+# Ice Age 2015-09-08 200,000 -
+# Homestead 2016-03-15 1,150,000 Yes
+# DAO Fork (unplanned) 2016-07-20 1,920,000 -
+# Tangerine Whistle (unplanned) 2016-10-18 2,463,000 Yes
+# Spurious Dragon 2016-11-23 2,675,000 Yes
+# Byzantium 2017-10-16 4,370,000 Yes
+# Constantinople 2019-02-28 7,280,000 Yes
+# Petersburg (unplanned) 2019-02-28 7,280,000 Yes
+# Istanbul 2019-12-08 9,069,000 Yes
+# Muir Glacier 2020-01-01 9,200,000 Yes
+# Berlin TBD TBD Yes
father_VMs = {
diff --git a/qiling/cc/__init__.py b/qiling/cc/__init__.py
index 5f7216c38..126bf620a 100644
--- a/qiling/cc/__init__.py
+++ b/qiling/cc/__init__.py
@@ -7,171 +7,171 @@
from qiling.arch.arch import QlArch
class QlCC:
- """Calling convention base class.
- """
+ """Calling convention base class.
+ """
- def __init__(self, arch: QlArch) -> None:
- """Initialize a calling convention instance.
+ def __init__(self, arch: QlArch) -> None:
+ """Initialize a calling convention instance.
- Args:
- arch: underlying architecture instance
- """
+ Args:
+ arch: underlying architecture instance
+ """
- self.arch = arch
+ self.arch = arch
- @staticmethod
- def getNumSlots(argbits: int) -> int:
- """Get the number of slots allocated for an argument of width `argbits`.
- """
+ @staticmethod
+ def getNumSlots(argbits: int) -> int:
+ """Get the number of slots allocated for an argument of width `argbits`.
+ """
- raise NotImplementedError
+ raise NotImplementedError
- def getRawParam(self, slot: int, argbits: int = 0) -> int:
- """Read a value of native size from the specified argument slot.
+ def getRawParam(self, slot: int, argbits: int = 0) -> int:
+ """Read a value of native size from the specified argument slot.
- Note that argument slots and argument indexes are not the same. Though they often correlate
- to each other, some implementations might use more than one slot to represent a sigle argument.
+ Note that argument slots and argument indexes are not the same. Though they often correlate
+ to each other, some implementations might use more than one slot to represent a sigle argument.
- Args:
- slot: argument slot to access
- argbits: argument size in bits (default: arch native size)
+ Args:
+ slot: argument slot to access
+ argbits: argument size in bits (default: arch native size)
- Returns: raw value
- """
+ Returns: raw value
+ """
- raise NotImplementedError
+ raise NotImplementedError
- def setRawParam(self, slot: int, value: int, argbits: int = 0) -> None:
- """Replace the value in the specified argument slot.
+ def setRawParam(self, slot: int, value: int, argbits: int = 0) -> None:
+ """Replace the value in the specified argument slot.
- Note that argument slots and argument indexes are not the same. Though they often correlate
- to each other, some implementations might use more than one slot to represent a sigle argument.
+ Note that argument slots and argument indexes are not the same. Though they often correlate
+ to each other, some implementations might use more than one slot to represent a sigle argument.
- Args:
- slot: argument slot to access
- value: new raw value to write
- argbits: argument size in bits (default: arch native size)
- """
+ Args:
+ slot: argument slot to access
+ value: new raw value to write
+ argbits: argument size in bits (default: arch native size)
+ """
- raise NotImplementedError
+ raise NotImplementedError
- def getReturnValue(self) -> int:
- """Get function return value.
- """
+ def getReturnValue(self) -> int:
+ """Get function return value.
+ """
- raise NotImplementedError
+ raise NotImplementedError
- def setReturnValue(self, val: int) -> None:
- """Set function return value.
+ def setReturnValue(self, val: int) -> None:
+ """Set function return value.
- Args:
- val: a value to set
- """
+ Args:
+ val: a value to set
+ """
- raise NotImplementedError
+ raise NotImplementedError
- def setReturnAddress(self, addr: int) -> None:
- """Set function return address.
+ def setReturnAddress(self, addr: int) -> None:
+ """Set function return address.
- Args:
- addr: return address to set
- """
+ Args:
+ addr: return address to set
+ """
- raise NotImplementedError
+ raise NotImplementedError
- def reserve(self, nslots: int) -> None:
- """Reserve slots for function arguments.
+ def reserve(self, nslots: int) -> None:
+ """Reserve slots for function arguments.
- This may be used to stage a new frame before executing a native function.
+ This may be used to stage a new frame before executing a native function.
- Args:
- nslots: number of arg slots to reserve
- """
+ Args:
+ nslots: number of arg slots to reserve
+ """
- raise NotImplementedError
+ raise NotImplementedError
- def unwind(self, nslots: int) -> int:
- """Unwind frame and return from function call.
+ def unwind(self, nslots: int) -> int:
+ """Unwind frame and return from function call.
- Args:
- nslots: number of arg slots used
+ Args:
+ nslots: number of arg slots used
- Returns: return address
- """
+ Returns: return address
+ """
- raise NotImplementedError
+ raise NotImplementedError
class QlCommonBaseCC(QlCC):
- """Calling convention base class that implements parameters access through both
- registers and the stack. The extending class is resopnsible to implement the rest
- of the QlCC interface.
- """
+ """Calling convention base class that implements parameters access through both
+ registers and the stack. The extending class is resopnsible to implement the rest
+ of the QlCC interface.
+ """
- _retreg: int
- _argregs: Sequence
- _shadow = 0
- _retaddr_on_stack = True
+ _retreg: int
+ _argregs: Sequence
+ _shadow = 0
+ _retaddr_on_stack = True
- def __init__(self, arch: QlArch):
- super().__init__(arch)
+ def __init__(self, arch: QlArch):
+ super().__init__(arch)
- # native address size in bytes
- self._asize = self.arch.pointersize
+ # native address size in bytes
+ self._asize = self.arch.pointersize
- def __access_param(self, index: int, stack_access: Callable, reg_access: Callable) -> Tuple[Callable, int]:
- """[private] Generic accessor to function call parameters by their index.
+ def __access_param(self, index: int, stack_access: Callable, reg_access: Callable) -> Tuple[Callable, int]:
+ """[private] Generic accessor to function call parameters by their index.
- This method will determine whether the parameter should be accessed on the stack or in a
- register, and return the appropriate accessor along with the location to access (either a
- register id or stack address)
+ This method will determine whether the parameter should be accessed on the stack or in a
+ register, and return the appropriate accessor along with the location to access (either a
+ register id or stack address)
- Args:
- index: parameter index to access
- stack_access: stack accessor method (either read or write)
- reg_access: regs accessor method (either read or write)
+ Args:
+ index: parameter index to access
+ stack_access: stack accessor method (either read or write)
+ reg_access: regs accessor method (either read or write)
- Returns: a tuple of the accessor method to use and the location to access
- """
+ Returns: a tuple of the accessor method to use and the location to access
+ """
- if index >= len(self._argregs):
- raise IndexError(f'tried to access arg {index}, but only {len(self._argregs) - 1} args are supported')
+ if index >= len(self._argregs):
+ raise IndexError(f'tried to access arg {index}, but only {len(self._argregs) - 1} args are supported')
- reg = self._argregs[index]
+ reg = self._argregs[index]
- # should arg be read from a reg or the stack?
- if reg is None:
- # get matching stack item
- si = index - self._argregs.index(None)
+ # should arg be read from a reg or the stack?
+ if reg is None:
+ # get matching stack item
+ si = index - self._argregs.index(None)
- # skip return address and shadow space
- return stack_access, (self._retaddr_on_stack + self._shadow + si) * self._asize
- else:
- return reg_access, reg
+ # skip return address and shadow space
+ return stack_access, (self._retaddr_on_stack + self._shadow + si) * self._asize
+ else:
+ return reg_access, reg
- def getRawParam(self, index: int, argbits: int = 0) -> int:
- read, loc = self.__access_param(index, self.arch.stack_read, self.arch.regs.read)
+ def getRawParam(self, index: int, argbits: int = 0) -> int:
+ read, loc = self.__access_param(index, self.arch.stack_read, self.arch.regs.read)
- mask = (argbits and (1 << argbits)) - 1
+ mask = (argbits and (1 << argbits)) - 1
- return read(loc) & mask
+ return read(loc) & mask
- def setRawParam(self, index: int, value: int, argbits: int = 0) -> None:
- write, loc = self.__access_param(index, self.arch.stack_write, self.arch.regs.write)
+ def setRawParam(self, index: int, value: int, argbits: int = 0) -> None:
+ write, loc = self.__access_param(index, self.arch.stack_write, self.arch.regs.write)
- mask = (argbits and (1 << argbits)) - 1
+ mask = (argbits and (1 << argbits)) - 1
- write(loc, value & mask)
+ write(loc, value & mask)
- def getReturnValue(self) -> int:
- return self.arch.regs.read(self._retreg)
+ def getReturnValue(self) -> int:
+ return self.arch.regs.read(self._retreg)
- def setReturnValue(self, value: int) -> None:
- self.arch.regs.write(self._retreg, value)
+ def setReturnValue(self, value: int) -> None:
+ self.arch.regs.write(self._retreg, value)
- def reserve(self, nslots: int) -> None:
- assert nslots < len(self._argregs), 'too many slots'
+ def reserve(self, nslots: int) -> None:
+ assert nslots < len(self._argregs), 'too many slots'
- # count how many slots should be reserved on the stack
- si = self._argregs[:nslots].count(None)
+ # count how many slots should be reserved on the stack
+ si = self._argregs[:nslots].count(None)
- self.arch.regs.arch_sp -= (self._shadow + si) * self._asize
+ self.arch.regs.arch_sp -= (self._shadow + si) * self._asize
diff --git a/qiling/cc/intel.py b/qiling/cc/intel.py
index 9c9aded49..b916b659b 100644
--- a/qiling/cc/intel.py
+++ b/qiling/cc/intel.py
@@ -3,104 +3,104 @@
# Cross Platform and Multi Architecture Advanced Binary Emulation Framework
from unicorn.x86_const import (
- UC_X86_REG_EAX, UC_X86_REG_RAX, UC_X86_REG_RCX, UC_X86_REG_RDI,
- UC_X86_REG_RDX, UC_X86_REG_RSI, UC_X86_REG_R8, UC_X86_REG_R9,
- UC_X86_REG_R10
+ UC_X86_REG_EAX, UC_X86_REG_RAX, UC_X86_REG_RCX, UC_X86_REG_RDI,
+ UC_X86_REG_RDX, UC_X86_REG_RSI, UC_X86_REG_R8, UC_X86_REG_R9,
+ UC_X86_REG_R10
)
from qiling.cc import QlCommonBaseCC
class QlIntelBaseCC(QlCommonBaseCC):
- """Calling convention base class for Intel-based systems.
- Supports arguments passing over registers and stack.
- """
+ """Calling convention base class for Intel-based systems.
+ Supports arguments passing over registers and stack.
+ """
- def setReturnAddress(self, addr: int) -> None:
- self.arch.stack_push(addr)
+ def setReturnAddress(self, addr: int) -> None:
+ self.arch.stack_push(addr)
- def unwind(self, nslots: int) -> int:
- # no cleanup; just pop out the return address
- return self.arch.stack_pop()
+ def unwind(self, nslots: int) -> int:
+ # no cleanup; just pop out the return address
+ return self.arch.stack_pop()
class QlIntel64(QlIntelBaseCC):
- """Calling convention base class for Intel-based 64-bit systems.
- """
+ """Calling convention base class for Intel-based 64-bit systems.
+ """
- _retreg = UC_X86_REG_RAX
+ _retreg = UC_X86_REG_RAX
- @staticmethod
- def getNumSlots(argbits: int) -> int:
- return max(argbits, 64) // 64
+ @staticmethod
+ def getNumSlots(argbits: int) -> int:
+ return max(argbits, 64) // 64
class QlIntel32(QlIntelBaseCC):
- """Calling convention base class for Intel-based 32-bit systems.
- """
+ """Calling convention base class for Intel-based 32-bit systems.
+ """
- _retreg = UC_X86_REG_EAX
+ _retreg = UC_X86_REG_EAX
- @staticmethod
- def getNumSlots(argbits: int) -> int:
- return max(argbits, 32) // 32
+ @staticmethod
+ def getNumSlots(argbits: int) -> int:
+ return max(argbits, 32) // 32
- def getRawParam(self, slot: int, nbits: int = 0) -> int:
- __super_getparam = super().getRawParam
+ def getRawParam(self, slot: int, nbits: int = 0) -> int:
+ __super_getparam = super().getRawParam
- if nbits == 64:
- lo = __super_getparam(slot)
- hi = __super_getparam(slot + 1)
+ if nbits == 64:
+ lo = __super_getparam(slot)
+ hi = __super_getparam(slot + 1)
- val = (hi << 32) | lo
- else:
- val = __super_getparam(slot, nbits)
+ val = (hi << 32) | lo
+ else:
+ val = __super_getparam(slot, nbits)
- return val
+ return val
class amd64(QlIntel64):
- """Default calling convention for POSIX (x86-64).
- First 6 arguments are passed in regs, the rest are passed on the stack.
- """
+ """Default calling convention for POSIX (x86-64).
+ First 6 arguments are passed in regs, the rest are passed on the stack.
+ """
- _argregs = (UC_X86_REG_RDI, UC_X86_REG_RSI, UC_X86_REG_RDX, UC_X86_REG_R10, UC_X86_REG_R8, UC_X86_REG_R9) + (None, ) * 10
+ _argregs = (UC_X86_REG_RDI, UC_X86_REG_RSI, UC_X86_REG_RDX, UC_X86_REG_R10, UC_X86_REG_R8, UC_X86_REG_R9) + (None, ) * 10
class ms64(QlIntel64):
- """Default calling convention for Windows and UEFI (x86-64).
- First 4 arguments are passed in regs, the rest are passed on the stack.
+ """Default calling convention for Windows and UEFI (x86-64).
+ First 4 arguments are passed in regs, the rest are passed on the stack.
- Each stack frame starts with a shadow space in size of 4 items, corresponding
- to the first arguments passed in regs.
- """
+ Each stack frame starts with a shadow space in size of 4 items, corresponding
+ to the first arguments passed in regs.
+ """
- _argregs = (UC_X86_REG_RCX, UC_X86_REG_RDX, UC_X86_REG_R8, UC_X86_REG_R9) + (None, ) * 12
- _shadow = 4
+ _argregs = (UC_X86_REG_RCX, UC_X86_REG_RDX, UC_X86_REG_R8, UC_X86_REG_R9) + (None, ) * 12
+ _shadow = 4
class macosx64(QlIntel64):
- """Default calling convention for Mac OS (x86-64).
- First 6 arguments are passed in regs, the rest are passed on the stack.
- """
+ """Default calling convention for Mac OS (x86-64).
+ First 6 arguments are passed in regs, the rest are passed on the stack.
+ """
- _argregs = (UC_X86_REG_RDI, UC_X86_REG_RSI, UC_X86_REG_RDX, UC_X86_REG_RCX, UC_X86_REG_R8, UC_X86_REG_R9) + (None, ) * 10
+ _argregs = (UC_X86_REG_RDI, UC_X86_REG_RSI, UC_X86_REG_RDX, UC_X86_REG_RCX, UC_X86_REG_R8, UC_X86_REG_R9) + (None, ) * 10
class cdecl(QlIntel32):
- """Calling convention used by all operating systems (x86).
- All arguments are passed on the stack.
+ """Calling convention used by all operating systems (x86).
+ All arguments are passed on the stack.
- The caller is resopnsible to unwind the stack.
- """
+ The caller is resopnsible to unwind the stack.
+ """
- _argregs = (None, ) * 16
+ _argregs = (None, ) * 16
class stdcall(QlIntel32):
- """Calling convention used by all operating systems (x86).
- All arguments are passed on the stack.
+ """Calling convention used by all operating systems (x86).
+ All arguments are passed on the stack.
- The callee is resopnsible to unwind the stack.
- """
+ The callee is resopnsible to unwind the stack.
+ """
- _argregs = (None, ) * 16
+ _argregs = (None, ) * 16
- def unwind(self, nslots: int) -> int:
- retaddr = super().unwind(nslots)
+ def unwind(self, nslots: int) -> int:
+ retaddr = super().unwind(nslots)
- self.arch.regs.arch_sp += (nslots * self._asize)
+ self.arch.regs.arch_sp += (nslots * self._asize)
- return retaddr
+ return retaddr
diff --git a/qiling/cc/mips.py b/qiling/cc/mips.py
index c1b3a0897..658b58587 100644
--- a/qiling/cc/mips.py
+++ b/qiling/cc/mips.py
@@ -7,15 +7,15 @@
from qiling.cc import QlCommonBaseCC
class mipso32(QlCommonBaseCC):
- _retreg = UC_MIPS_REG_V0
- _argregs = (UC_MIPS_REG_A0, UC_MIPS_REG_A1, UC_MIPS_REG_A2, UC_MIPS_REG_A3) + (None, ) * 12
- _shadow = 4
- _retaddr_on_stack = False
+ _retreg = UC_MIPS_REG_V0
+ _argregs = (UC_MIPS_REG_A0, UC_MIPS_REG_A1, UC_MIPS_REG_A2, UC_MIPS_REG_A3) + (None, ) * 12
+ _shadow = 4
+ _retaddr_on_stack = False
- @staticmethod
- def getNumSlots(argbits: int):
- return 1
+ @staticmethod
+ def getNumSlots(argbits: int):
+ return 1
- def unwind(self, nslots: int) -> int:
- # TODO: stack frame unwiding?
- return self.arch.regs.ra
+ def unwind(self, nslots: int) -> int:
+ # TODO: stack frame unwiding?
+ return self.arch.regs.ra
diff --git a/qiling/core_struct.py b/qiling/core_struct.py
index 08c325a07..6c0d99cca 100644
--- a/qiling/core_struct.py
+++ b/qiling/core_struct.py
@@ -19,81 +19,81 @@
# Don't assume self is Qiling.
class QlCoreStructs:
- def __init__(self, endian: QL_ENDIAN, bit: int):
- modifier = {
- QL_ENDIAN.EL: '<',
- QL_ENDIAN.EB: '>'
- }[endian]
+ def __init__(self, endian: QL_ENDIAN, bit: int):
+ modifier = {
+ QL_ENDIAN.EL: '<',
+ QL_ENDIAN.EB: '>'
+ }[endian]
- self._fmt8 = f'{modifier}B'
- self._fmt8s = f'{modifier}b'
- self._fmt16 = f'{modifier}H'
- self._fmt16s = f'{modifier}h'
- self._fmt32 = f'{modifier}I'
- self._fmt32s = f'{modifier}i'
- self._fmt64 = f'{modifier}Q'
- self._fmt64s = f'{modifier}q'
+ self._fmt8 = f'{modifier}B'
+ self._fmt8s = f'{modifier}b'
+ self._fmt16 = f'{modifier}H'
+ self._fmt16s = f'{modifier}h'
+ self._fmt32 = f'{modifier}I'
+ self._fmt32s = f'{modifier}i'
+ self._fmt64 = f'{modifier}Q'
+ self._fmt64s = f'{modifier}q'
- handlers = {
- 64 : (self.pack64, self.pack64s, self.unpack64, self.unpack64s),
- 32 : (self.pack32, self.pack32s, self.unpack32, self.unpack32s),
- 16 : (self.pack16, self.pack16s, self.unpack16, self.unpack16s),
- }
+ handlers = {
+ 64 : (self.pack64, self.pack64s, self.unpack64, self.unpack64s),
+ 32 : (self.pack32, self.pack32s, self.unpack32, self.unpack32s),
+ 16 : (self.pack16, self.pack16s, self.unpack16, self.unpack16s),
+ }
- if bit not in handlers:
- raise QlErrorStructConversion("Unsupported Qiling struct conversion")
+ if bit not in handlers:
+ raise QlErrorStructConversion("Unsupported Qiling struct conversion")
- p, ps, up, ups = handlers[bit]
+ p, ps, up, ups = handlers[bit]
- self.pack = p
- self.packs = ps
- self.unpack = up
- self.unpacks = ups
+ self.pack = p
+ self.packs = ps
+ self.unpack = up
+ self.unpacks = ups
- def pack64(self, x: int, /) -> bytes:
- return struct.pack(self._fmt64, x)
+ def pack64(self, x: int, /) -> bytes:
+ return struct.pack(self._fmt64, x)
- def pack64s(self, x: int, /) -> bytes:
- return struct.pack(self._fmt64s, x)
+ def pack64s(self, x: int, /) -> bytes:
+ return struct.pack(self._fmt64s, x)
- def unpack64(self, x: ReadableBuffer, /) -> int:
- return struct.unpack(self._fmt64, x)[0]
+ def unpack64(self, x: ReadableBuffer, /) -> int:
+ return struct.unpack(self._fmt64, x)[0]
- def unpack64s(self, x: ReadableBuffer, /) -> int:
- return struct.unpack(self._fmt64s, x)[0]
+ def unpack64s(self, x: ReadableBuffer, /) -> int:
+ return struct.unpack(self._fmt64s, x)[0]
- def pack32(self, x: int, /) -> bytes:
- return struct.pack(self._fmt32, x)
+ def pack32(self, x: int, /) -> bytes:
+ return struct.pack(self._fmt32, x)
- def pack32s(self, x: int, /) -> bytes:
- return struct.pack(self._fmt32s, x)
+ def pack32s(self, x: int, /) -> bytes:
+ return struct.pack(self._fmt32s, x)
- def unpack32(self, x: ReadableBuffer, /) -> int:
- return struct.unpack(self._fmt32, x)[0]
+ def unpack32(self, x: ReadableBuffer, /) -> int:
+ return struct.unpack(self._fmt32, x)[0]
- def unpack32s(self, x: ReadableBuffer, /) -> int:
- return struct.unpack(self._fmt32s, x)[0]
+ def unpack32s(self, x: ReadableBuffer, /) -> int:
+ return struct.unpack(self._fmt32s, x)[0]
- def pack16(self, x: int, /) -> bytes:
- return struct.pack(self._fmt16, x)
+ def pack16(self, x: int, /) -> bytes:
+ return struct.pack(self._fmt16, x)
- def pack16s(self, x: int, /) -> bytes:
- return struct.pack(self._fmt16s, x)
+ def pack16s(self, x: int, /) -> bytes:
+ return struct.pack(self._fmt16s, x)
- def unpack16(self, x: ReadableBuffer, /) -> int:
- return struct.unpack(self._fmt16, x)[0]
+ def unpack16(self, x: ReadableBuffer, /) -> int:
+ return struct.unpack(self._fmt16, x)[0]
- def unpack16s(self, x: ReadableBuffer, /) -> int:
- return struct.unpack(self._fmt16s, x)[0]
+ def unpack16s(self, x: ReadableBuffer, /) -> int:
+ return struct.unpack(self._fmt16s, x)[0]
- def pack8(self, x: int, /) -> bytes:
- return struct.pack(self._fmt8, x)
+ def pack8(self, x: int, /) -> bytes:
+ return struct.pack(self._fmt8, x)
- def pack8s(self, x: int, /) -> bytes:
- return struct.pack(self._fmt8s, x)
+ def pack8s(self, x: int, /) -> bytes:
+ return struct.pack(self._fmt8s, x)
- def unpack8(self, x: ReadableBuffer, /) -> int:
- return struct.unpack(self._fmt8, x)[0]
+ def unpack8(self, x: ReadableBuffer, /) -> int:
+ return struct.unpack(self._fmt8, x)[0]
- def unpack8s(self, x: ReadableBuffer, /) -> int:
- return struct.unpack(self._fmt8s, x)[0]
+ def unpack8s(self, x: ReadableBuffer, /) -> int:
+ return struct.unpack(self._fmt8s, x)[0]
diff --git a/qiling/extensions/trace.py b/qiling/extensions/trace.py
index ca99ecdb7..32dbb5881 100644
--- a/qiling/extensions/trace.py
+++ b/qiling/extensions/trace.py
@@ -15,216 +15,216 @@
#
def __uc2_workaround() -> Mapping[int, int]:
- """Starting from Unicorn2, Unicorn and Capstone Intel registers definitions are
- no longer aligned and cannot be used interchangebly. This temporary workaround
- maps capstone x86 registers definitions to unicorn x86 registers definitions.
+ """Starting from Unicorn2, Unicorn and Capstone Intel registers definitions are
+ no longer aligned and cannot be used interchangebly. This temporary workaround
+ maps capstone x86 registers definitions to unicorn x86 registers definitions.
- see: https://github.com/unicorn-engine/unicorn/issues/1492
- """
+ see: https://github.com/unicorn-engine/unicorn/issues/1492
+ """
- from capstone import x86_const as cs_x86_const
- from unicorn import x86_const as uc_x86_const
+ from capstone import x86_const as cs_x86_const
+ from unicorn import x86_const as uc_x86_const
- def __canonicalized_mapping(module, prefix: str) -> Mapping[str, int]:
- return dict((k[len(prefix):], getattr(module, k)) for k in dir(module) if k.startswith(prefix))
+ def __canonicalized_mapping(module, prefix: str) -> Mapping[str, int]:
+ return dict((k[len(prefix):], getattr(module, k)) for k in dir(module) if k.startswith(prefix))
- cs_x86_regs = __canonicalized_mapping(cs_x86_const, 'X86_REG')
- uc_x86_regs = __canonicalized_mapping(uc_x86_const, 'UC_X86_REG')
+ cs_x86_regs = __canonicalized_mapping(cs_x86_const, 'X86_REG')
+ uc_x86_regs = __canonicalized_mapping(uc_x86_const, 'UC_X86_REG')
- return dict((cs_x86_regs[k], uc_x86_regs[k]) for k in cs_x86_regs if k in uc_x86_regs)
+ return dict((cs_x86_regs[k], uc_x86_regs[k]) for k in cs_x86_regs if k in uc_x86_regs)
CS_UC_REGS = __uc2_workaround()
#
def __get_trace_records(ql: Qiling, address: int, size: int, md: Cs) -> Iterator[TraceRecord]:
- """[private] Acquire trace info for the current instruction and yield as a trace record.
- A trace record is a parsed instruction paired to a list of registers and their values.
+ """[private] Acquire trace info for the current instruction and yield as a trace record.
+ A trace record is a parsed instruction paired to a list of registers and their values.
- This method might yield more than one record for a single instruction.
- """
+ This method might yield more than one record for a single instruction.
+ """
- # unicorn denotes unsupported instructions by a magic size value. though these instructions
- # are not emulated, capstone can still parse them.
- if size == 0xf1f1f1f1:
- # note that invalid instructions will generate a StopIteration exception here
- yield next(__get_trace_records(ql, address, 16, md))
- return
+ # unicorn denotes unsupported instructions by a magic size value. though these instructions
+ # are not emulated, capstone can still parse them.
+ if size == 0xf1f1f1f1:
+ # note that invalid instructions will generate a StopIteration exception here
+ yield next(__get_trace_records(ql, address, 16, md))
+ return
- # a trace line is generated even for hook addresses that do not contain meaningful opcodes.
- # in that case, make it look like a nop
- if address in ql._addr_hook:
- buf = b'\x90'
- else:
- buf = ql.mem.read(address, size)
+ # a trace line is generated even for hook addresses that do not contain meaningful opcodes.
+ # in that case, make it look like a nop
+ if address in ql._addr_hook:
+ buf = b'\x90'
+ else:
+ buf = ql.mem.read(address, size)
- for insn in md.disasm(buf, address):
- # BUG: insn.regs_read doesn't work well, so we use insn.regs_access()[0]
- state = tuple((reg, ql.arch.regs.read(CS_UC_REGS[reg])) for reg in insn.regs_access()[0])
+ for insn in md.disasm(buf, address):
+ # BUG: insn.regs_read doesn't work well, so we use insn.regs_access()[0]
+ state = tuple((reg, ql.arch.regs.read(CS_UC_REGS[reg])) for reg in insn.regs_access()[0])
- yield (insn, state)
+ yield (insn, state)
def __to_trace_line(record: TraceRecord, symsmap: Mapping[int, str] = {}) -> str:
- """[private] Transform trace info into a formatted trace line.
- """
+ """[private] Transform trace info into a formatted trace line.
+ """
- insn, state = record
+ insn, state = record
- # when the rip register is referenced from within an instruction it is expected to point
- # to the next instruction boundary. since unicorn has not executed the instruction yet
- # is uses the cpu state resulted from the previous instruction - and rip points to the
- # current instruction instead of the next one.
- #
- # here we patch rip value recorded in state to point to the next instruction boundary
- state = tuple((reg, val + insn.size if reg == X86_REG_RIP else val) for reg, val in state)
+ # when the rip register is referenced from within an instruction it is expected to point
+ # to the next instruction boundary. since unicorn has not executed the instruction yet
+ # is uses the cpu state resulted from the previous instruction - and rip points to the
+ # current instruction instead of the next one.
+ #
+ # here we patch rip value recorded in state to point to the next instruction boundary
+ state = tuple((reg, val + insn.size if reg == X86_REG_RIP else val) for reg, val in state)
- def __read_reg(reg: int) -> int:
- """[internal] Read a register value from the recorded state. Only registers that were
- referenced by the current instruction can be read.
- """
+ def __read_reg(reg: int) -> int:
+ """[internal] Read a register value from the recorded state. Only registers that were
+ referenced by the current instruction can be read.
+ """
- return 0 if reg == X86_REG_INVALID else next(v for r, v in state if r == reg)
+ return 0 if reg == X86_REG_INVALID else next(v for r, v in state if r == reg)
- def __resolve(address: int) -> str:
- """[internal] Find the symbol that matches to the specified address (if any).
- """
+ def __resolve(address: int) -> str:
+ """[internal] Find the symbol that matches to the specified address (if any).
+ """
- return symsmap.get(address, '')
+ return symsmap.get(address, '')
- def __parse_op(op: X86Op) -> str:
- """[internal] Parse an operand and return its string representation. Indirect memory
- references will be substitued by the effective address they refer to. If the referenced
- address is associated with a symbol, it will be substitued by that symbol.
- """
+ def __parse_op(op: X86Op) -> str:
+ """[internal] Parse an operand and return its string representation. Indirect memory
+ references will be substitued by the effective address they refer to. If the referenced
+ address is associated with a symbol, it will be substitued by that symbol.
+ """
- if op.type == CS_OP_REG:
- return insn.reg_name(op.value.reg) or '?'
+ if op.type == CS_OP_REG:
+ return insn.reg_name(op.value.reg) or '?'
- elif op.type == CS_OP_IMM:
- imm = op.value.imm
+ elif op.type == CS_OP_IMM:
+ imm = op.value.imm
- return __resolve(imm) or f'{imm:#x}'
+ return __resolve(imm) or f'{imm:#x}'
- elif op.type == CS_OP_MEM:
- mem = op.value.mem
+ elif op.type == CS_OP_MEM:
+ mem = op.value.mem
- base = __read_reg(mem.base)
- index = __read_reg(mem.index)
- scale = mem.scale
- disp = mem.disp
+ base = __read_reg(mem.base)
+ index = __read_reg(mem.index)
+ scale = mem.scale
+ disp = mem.disp
- ea = base + index * scale + disp
- seg = f'{insn.reg_name(mem.segment)}:' if mem.segment else ''
+ ea = base + index * scale + disp
+ seg = f'{insn.reg_name(mem.segment)}:' if mem.segment else ''
- # we construct the string representation for each operand; denote memory
- # dereferenes with the appropriate 'ptr' prefix. the 'lea' instruction is
- # an exception since it does not use that notation.
- if insn.id == X86_INS_LEA:
- qualifier = f''
- else:
- ptr = {
- 1: 'byte',
- 2: 'word',
- 4: 'dword',
- 8: 'qword',
- 10: 'fword',
- 16: 'xmmword'
- }[op.size]
+ # we construct the string representation for each operand; denote memory
+ # dereferenes with the appropriate 'ptr' prefix. the 'lea' instruction is
+ # an exception since it does not use that notation.
+ if insn.id == X86_INS_LEA:
+ qualifier = f''
+ else:
+ ptr = {
+ 1: 'byte',
+ 2: 'word',
+ 4: 'dword',
+ 8: 'qword',
+ 10: 'fword',
+ 16: 'xmmword'
+ }[op.size]
- qualifier = f'{ptr} ptr '
+ qualifier = f'{ptr} ptr '
- return f'{qualifier}{seg}[{__resolve(ea) or f"{ea:#x}"}]'
+ return f'{qualifier}{seg}[{__resolve(ea) or f"{ea:#x}"}]'
- # unexpected op type
- raise RuntimeError
+ # unexpected op type
+ raise RuntimeError
- operands = ', '.join(__parse_op(o) for o in insn.operands)
- reads = ', '.join(f'{insn.reg_name(reg)} = {val:#x}' for reg, val in state)
+ operands = ', '.join(__parse_op(o) for o in insn.operands)
+ reads = ', '.join(f'{insn.reg_name(reg)} = {val:#x}' for reg, val in state)
- return f'{insn.address:08x} | {insn.bytes.hex():24s} {insn.mnemonic:10} {operands:56s} | {reads}'
+ return f'{insn.address:08x} | {insn.bytes.hex():24s} {insn.mnemonic:10} {operands:56s} | {reads}'
def enable_full_trace(ql: Qiling):
- """Enable instruction-level tracing.
+ """Enable instruction-level tracing.
- Trace line will be emitted for each instruction before it gets executed. The info
- includes static data along with the relevant registers state and symbols resolving.
+ Trace line will be emitted for each instruction before it gets executed. The info
+ includes static data along with the relevant registers state and symbols resolving.
- Args:
- ql: qiling instance
- """
+ Args:
+ ql: qiling instance
+ """
- # enable detailed disassembly info
- md = ql.arch.disassembler
- md.detail = True
+ # enable detailed disassembly info
+ md = ql.arch.disassembler
+ md.detail = True
- assert md.arch == CS_ARCH_X86, 'currently available only for intel architecture'
+ assert md.arch == CS_ARCH_X86, 'currently available only for intel architecture'
- # if available, use symbols map to resolve memory accesses
- symsmap = getattr(ql.loader, 'symsmap', {})
+ # if available, use symbols map to resolve memory accesses
+ symsmap = getattr(ql.loader, 'symsmap', {})
- # show trace lines in a darker color so they would be easily distinguished from
- # ordinary log records
- faded_color = "\033[2m"
- reset_color = "\033[0m"
+ # show trace lines in a darker color so they would be easily distinguished from
+ # ordinary log records
+ faded_color = "\033[2m"
+ reset_color = "\033[0m"
- def __trace_hook(ql: Qiling, address: int, size: int):
- """[internal] Trace hook callback.
- """
+ def __trace_hook(ql: Qiling, address: int, size: int):
+ """[internal] Trace hook callback.
+ """
- for record in __get_trace_records(ql, address, size, md):
- line = __to_trace_line(record, symsmap)
+ for record in __get_trace_records(ql, address, size, md):
+ line = __to_trace_line(record, symsmap)
- ql.log.debug(f'{faded_color}{line}{reset_color}')
+ ql.log.debug(f'{faded_color}{line}{reset_color}')
- ql.hook_code(__trace_hook)
+ ql.hook_code(__trace_hook)
def enable_history_trace(ql: Qiling, nrecords: int):
- """Enable instruction-level tracing in history mode.
+ """Enable instruction-level tracing in history mode.
- To allow faster execution, the trace info collected throughout program execution is not
- emitted and undergo as minimal post-processing as possible. When program crahses, the
- last `nrecords` trace lines are shown.
+ To allow faster execution, the trace info collected throughout program execution is not
+ emitted and undergo as minimal post-processing as possible. When program crahses, the
+ last `nrecords` trace lines are shown.
- Args:
- ql: qiling instance
- nrecords: number of last records to show
- """
+ Args:
+ ql: qiling instance
+ nrecords: number of last records to show
+ """
- # enable detailed disassembly info
- md = ql.arch.disassembler
- md.detail = True
+ # enable detailed disassembly info
+ md = ql.arch.disassembler
+ md.detail = True
- assert md.arch == CS_ARCH_X86, 'currently available only for intel architecture'
+ assert md.arch == CS_ARCH_X86, 'currently available only for intel architecture'
- # if available, use symbols map to resolve memory accesses
- symsmap = getattr(ql.loader, 'symsmap', {})
+ # if available, use symbols map to resolve memory accesses
+ symsmap = getattr(ql.loader, 'symsmap', {})
- history: Deque[TraceRecord] = deque(maxlen=nrecords)
+ history: Deque[TraceRecord] = deque(maxlen=nrecords)
- def __trace_hook(ql: Qiling, address: int, size: int):
- """[internal] Trace hook callback.
- """
+ def __trace_hook(ql: Qiling, address: int, size: int):
+ """[internal] Trace hook callback.
+ """
- history.extend(__get_trace_records(ql, address, size, md))
+ history.extend(__get_trace_records(ql, address, size, md))
- ql.hook_code(__trace_hook)
+ ql.hook_code(__trace_hook)
- # replace the emulation error handler with our own so we can emit the trace
- # records when program crashes. before we do that, we save the original one
- # so we can call it.
+ # replace the emulation error handler with our own so we can emit the trace
+ # records when program crashes. before we do that, we save the original one
+ # so we can call it.
- orig_emu_error = ql.os.emu_error
+ orig_emu_error = ql.os.emu_error
- def __emu_error(*args):
- # first run the original emulation error handler
- orig_emu_error(*args)
+ def __emu_error(*args):
+ # first run the original emulation error handler
+ orig_emu_error(*args)
- # then parse and emit the trace info we collected
- ql.log.error(f'History:')
- for record in history:
- line = __to_trace_line(record, symsmap)
+ # then parse and emit the trace info we collected
+ ql.log.error(f'History:')
+ for record in history:
+ line = __to_trace_line(record, symsmap)
- ql.log.error(line)
+ ql.log.error(line)
- ql.log.error(f'')
+ ql.log.error(f'')
- ql.os.emu_error = __emu_error
+ ql.os.emu_error = __emu_error
diff --git a/qiling/extensions/winsdkapi.py b/qiling/extensions/winsdkapi.py
index 2430b5ef7..8daf6c79b 100755
--- a/qiling/extensions/winsdkapi.py
+++ b/qiling/extensions/winsdkapi.py
@@ -25,132 +25,132 @@
FuncDecl = Tuple[FuncType, FuncName, FuncArgs]
def parse_json(jfile: TextIO) -> Sequence[FuncDecl]:
- JObj = Mapping[str, Any]
+ JObj = Mapping[str, Any]
- def __parse_param(arg: JObj) -> Tuple[str, str]:
- ptrlvl = 0
+ def __parse_param(arg: JObj) -> Tuple[str, str]:
+ ptrlvl = 0
- while type(arg['type']) is dict and 'type' in arg['type']:
- arg = arg['type']
- ptrlvl += 1
+ while type(arg['type']) is dict and 'type' in arg['type']:
+ arg = arg['type']
+ ptrlvl += 1
- aname = arg.get('name', '')
- atype = arg['type']
+ aname = arg.get('name', '')
+ atype = arg['type']
- if arg.get('data_type') == 'Ptr':
- ptrlvl += 1
+ if arg.get('data_type') == 'Ptr':
+ ptrlvl += 1
- if type(atype) is dict:
- if atype['data_type'] == 'Struct':
- atype = atype['name']
+ if type(atype) is dict:
+ if atype['data_type'] == 'Struct':
+ atype = atype['name']
- elif atype['data_type'] == 'Enum':
- # BUG: windows_sdk_data repo doesn't specify the name of the enum
- atype = 'enum?'
+ elif atype['data_type'] == 'Enum':
+ # BUG: windows_sdk_data repo doesn't specify the name of the enum
+ atype = 'enum?'
- else:
- raise RuntimeError(f'unexpected data_type (atype = {atype})')
+ else:
+ raise RuntimeError(f'unexpected data_type (atype = {atype})')
- return (aname, atype + '*' * ptrlvl)
+ return (aname, atype + '*' * ptrlvl)
- def __parse_args(args: Sequence[JObj]):
- upidx = 1
+ def __parse_args(args: Sequence[JObj]):
+ upidx = 1
- for a in args:
- aname, atype = __parse_param(a)
+ for a in args:
+ aname, atype = __parse_param(a)
- if not aname:
- if atype == 'void':
- assert len(args) == 1
- continue
+ if not aname:
+ if atype == 'void':
+ assert len(args) == 1
+ continue
- aname = f'unnamedParam{upidx}'
- upidx += 1
+ aname = f'unnamedParam{upidx}'
+ upidx += 1
- yield (aname, atype)
+ yield (aname, atype)
- decls = json.load(jfile)
+ decls = json.load(jfile)
- def __parse_decls(decls: Sequence):
- for decl in decls:
- # pick up only function declarations
- if decl.get('data_type') == 'FuncDecl':
- ftype = decl['type']
- fname = decl['name']
- fargs = decl['arguments']
- # loc = 'api_locations'
+ def __parse_decls(decls: Sequence):
+ for decl in decls:
+ # pick up only function declarations
+ if decl.get('data_type') == 'FuncDecl':
+ ftype = decl['type']
+ fname = decl['name']
+ fargs = decl['arguments']
+ # loc = 'api_locations'
- func_type = __parse_param(ftype)
- func_name = fname
- func_args = tuple(__parse_args(fargs))
+ func_type = __parse_param(ftype)
+ func_name = fname
+ func_args = tuple(__parse_args(fargs))
- assert func_type[0] == fname, 'function name is inconsistent with its return type declaration'
+ assert func_type[0] == fname, 'function name is inconsistent with its return type declaration'
- yield (func_type[1], func_name, func_args)
+ yield (func_type[1], func_name, func_args)
- if type(decls) is not list:
- return tuple()
+ if type(decls) is not list:
+ return tuple()
- return tuple(__parse_decls(decls))
+ return tuple(__parse_decls(decls))
def dump_py(decls: Sequence[FuncDecl], cc: str) -> Iterable[str]:
- print(f'')
- print(f'from qiling import Qiling')
- print(f'from qiling.os.windows.api import *')
- print(f'from qiling.os.windows.fncc import *')
- print(f'')
+ print(f'')
+ print(f'from qiling import Qiling')
+ print(f'from qiling.os.windows.api import *')
+ print(f'from qiling.os.windows.fncc import *')
+ print(f'')
- indent: Final[str] = ' ' * 4
+ indent: Final[str] = ' ' * 4
- def __patch_name(aname: str) -> str:
- # merely a placeholder: nothing here yet
- return aname
+ def __patch_name(aname: str) -> str:
+ # merely a placeholder: nothing here yet
+ return aname
- def __patch_type(atype: str) -> str:
- return 'POINTER' if atype.endswith('*') else atype
+ def __patch_type(atype: str) -> str:
+ return 'POINTER' if atype.endswith('*') else atype
- for ftype, fname, fargs in decls:
- if fargs:
- names = [__patch_name(a[0]) for a in fargs]
- types = [__patch_type(a[1]) for a in fargs]
+ for ftype, fname, fargs in decls:
+ if fargs:
+ names = [__patch_name(a[0]) for a in fargs]
+ types = [__patch_type(a[1]) for a in fargs]
- longest = max(len(n) for n in names)
+ longest = max(len(n) for n in names)
- args = ',\n'.join(f"{indent}'{n}'{' ' * (longest - len(n))} : {t}" for n, t in zip(names, types))
- args = f'\n{args}\n'
- else:
- args = ''
+ args = ',\n'.join(f"{indent}'{n}'{' ' * (longest - len(n))} : {t}" for n, t in zip(names, types))
+ args = f'\n{args}\n'
+ else:
+ args = ''
- decor = f'@winsdkapi(cc={cc}, params={{{args}}})'
- proto = f'def hook_{fname}(ql: Qiling, address: int, params):'
- body = f'{indent}pass'
+ decor = f'@winsdkapi(cc={cc}, params={{{args}}})'
+ proto = f'def hook_{fname}(ql: Qiling, address: int, params):'
+ body = f'{indent}pass'
- # TODO: specify return type (ftype) as a comment, or None for a 'void'
+ # TODO: specify return type (ftype) as a comment, or None for a 'void'
- yield f'{decor}\n{proto}\n{body}\n'
+ yield f'{decor}\n{proto}\n{body}\n'
def dump_c(decls: Sequence[FuncDecl], cc: str) -> Iterable[str]:
- # use a dimmed color for data types
- def __dim(s: str) -> str:
- return f'\x1b[90m{s}\x1b[39m'
+ # use a dimmed color for data types
+ def __dim(s: str) -> str:
+ return f'\x1b[90m{s}\x1b[39m'
- for ftype, fname, fargs in decls:
- yield f'{__dim(ftype)} {fname} ({", ".join(f"{__dim(a[1])} {a[0]}" for a in fargs)});'
+ for ftype, fname, fargs in decls:
+ yield f'{__dim(ftype)} {fname} ({", ".join(f"{__dim(a[1])} {a[0]}" for a in fargs)});'
if __name__ == '__main__':
- parser = argparse.ArgumentParser()
- parser.add_argument('format', choices=('c', 'py-cdecl', 'py-stdcall'), help='Declarations output format')
- parser.add_argument('jfiles', metavar='jsonfile', nargs='+', help='JSON file(s) containing API prototypes')
- args = parser.parse_args()
-
- fmt, _, cc = args.format.partition('-')
-
- handler: Callable = {
- 'c' : dump_c,
- 'py' : dump_py
- }[fmt]
-
- for filename in args.jfiles:
- with open(filename, 'r') as jfile:
- for decl in handler(parse_json(jfile), cc):
- print(decl)
+ parser = argparse.ArgumentParser()
+ parser.add_argument('format', choices=('c', 'py-cdecl', 'py-stdcall'), help='Declarations output format')
+ parser.add_argument('jfiles', metavar='jsonfile', nargs='+', help='JSON file(s) containing API prototypes')
+ args = parser.parse_args()
+
+ fmt, _, cc = args.format.partition('-')
+
+ handler: Callable = {
+ 'c' : dump_c,
+ 'py' : dump_py
+ }[fmt]
+
+ for filename in args.jfiles:
+ with open(filename, 'r') as jfile:
+ for decl in handler(parse_json(jfile), cc):
+ print(decl)
diff --git a/qiling/hw/char/sam3xa_uotghs.py b/qiling/hw/char/sam3xa_uotghs.py
index a97c1fad7..d3f4b210d 100644
--- a/qiling/hw/char/sam3xa_uotghs.py
+++ b/qiling/hw/char/sam3xa_uotghs.py
@@ -106,7 +106,7 @@ def __init__(self, ql, label, intn = None):
self.intn = intn
@QlPeripheral.monitor()
- def read(self, offset: int, size: int) -> int:
+ def read(self, offset: int, size: int) -> int:
buf = ctypes.create_string_buffer(size)
ctypes.memmove(buf, ctypes.addressof(self.instance) + offset, size)
return int.from_bytes(buf.raw, byteorder='little')
diff --git a/qiling/hw/char/stm32f4xx_usart.py b/qiling/hw/char/stm32f4xx_usart.py
index 8351e1afe..3e346158b 100644
--- a/qiling/hw/char/stm32f4xx_usart.py
+++ b/qiling/hw/char/stm32f4xx_usart.py
@@ -12,40 +12,40 @@
class STM32F4xxUsart(QlConnectivityPeripheral):
class Type(ctypes.Structure):
""" the structure available in :
- stm32f413xx.h
- stm32f407xx.h
- stm32f469xx.h
- stm32f446xx.h
- stm32f427xx.h
- stm32f401xc.h
- stm32f415xx.h
- stm32f412cx.h
- stm32f410rx.h
- stm32f410tx.h
- stm32f439xx.h
- stm32f412vx.h
- stm32f417xx.h
- stm32f479xx.h
- stm32f429xx.h
- stm32f412rx.h
- stm32f423xx.h
- stm32f437xx.h
- stm32f412zx.h
- stm32f401xe.h
- stm32f410cx.h
- stm32f405xx.h
- stm32f411xe.h
- """
+ stm32f413xx.h
+ stm32f407xx.h
+ stm32f469xx.h
+ stm32f446xx.h
+ stm32f427xx.h
+ stm32f401xc.h
+ stm32f415xx.h
+ stm32f412cx.h
+ stm32f410rx.h
+ stm32f410tx.h
+ stm32f439xx.h
+ stm32f412vx.h
+ stm32f417xx.h
+ stm32f479xx.h
+ stm32f429xx.h
+ stm32f412rx.h
+ stm32f423xx.h
+ stm32f437xx.h
+ stm32f412zx.h
+ stm32f401xe.h
+ stm32f410cx.h
+ stm32f405xx.h
+ stm32f411xe.h
+ """
_fields_ = [
- ('SR' , ctypes.c_uint32), # USART Status register, Address offset: 0x00
- ('DR' , ctypes.c_uint32), # USART Data register, Address offset: 0x04
- ('BRR' , ctypes.c_uint32), # USART Baud rate register, Address offset: 0x08
- ('CR1' , ctypes.c_uint32), # USART Control register 1, Address offset: 0x0C
- ('CR2' , ctypes.c_uint32), # USART Control register 2, Address offset: 0x10
- ('CR3' , ctypes.c_uint32), # USART Control register 3, Address offset: 0x14
- ('GTPR', ctypes.c_uint32), # USART Guard time and prescaler register, Address offset: 0x18
- ]
+ ('SR' , ctypes.c_uint32), # USART Status register, Address offset: 0x00
+ ('DR' , ctypes.c_uint32), # USART Data register, Address offset: 0x04
+ ('BRR' , ctypes.c_uint32), # USART Baud rate register, Address offset: 0x08
+ ('CR1' , ctypes.c_uint32), # USART Control register 1, Address offset: 0x0C
+ ('CR2' , ctypes.c_uint32), # USART Control register 2, Address offset: 0x10
+ ('CR3' , ctypes.c_uint32), # USART Control register 3, Address offset: 0x14
+ ('GTPR', ctypes.c_uint32), # USART Guard time and prescaler register, Address offset: 0x18
+ ]
def __init__(self, ql, label, intn=None):
diff --git a/qiling/hw/const/stm32f1xx_adc.py b/qiling/hw/const/stm32f1xx_adc.py
index 94bee377f..a16a0713e 100644
--- a/qiling/hw/const/stm32f1xx_adc.py
+++ b/qiling/hw/const/stm32f1xx_adc.py
@@ -7,94 +7,94 @@
class ADC_SR(IntEnum):
- AWD = 1 << 0
- EOS = 1 << 1
- JEOS = 1 << 2
- JSTRT = 1 << 3
- STRT = 1 << 4
+ AWD = 1 << 0
+ EOS = 1 << 1
+ JEOS = 1 << 2
+ JSTRT = 1 << 3
+ STRT = 1 << 4
class ADC_CR1(IntEnum):
- AWDCH = 0x1f << 0
- EOSIE = 1 << 5
- AWDIE = 1 << 6
- JEOSIE = 1 << 7
- SCAN = 1 << 8
- AWDSGL = 1 << 9
- JAUTO = 1 << 10
- DISCEN = 1 << 11
- JDISCEN = 1 << 12
- DISCNUM = 0x7 << 13
- DALMOD = 0xf << 16
- JAWDEN = 1 << 22
- AWDEN = 1 << 23
+ AWDCH = 0x1f << 0
+ EOSIE = 1 << 5
+ AWDIE = 1 << 6
+ JEOSIE = 1 << 7
+ SCAN = 1 << 8
+ AWDSGL = 1 << 9
+ JAUTO = 1 << 10
+ DISCEN = 1 << 11
+ JDISCEN = 1 << 12
+ DISCNUM = 0x7 << 13
+ DALMOD = 0xf << 16
+ JAWDEN = 1 << 22
+ AWDEN = 1 << 23
class ADC_CR2(IntEnum):
- ADON = 1 << 0
- CONT = 1 << 1
- CAL = 1 << 2
- RSTCAL = 1 << 3
- DMA = 1 << 8
- ALIGN = 1 << 11
- JEXTSEL = 0x7 << 12
- JEXTTRIG = 1 << 15
- EXTSEL = 0x7 << 17
- EXTTRIG = 1 << 20
- JSWSTART = 1 << 21
- SWSTART = 1 << 22
- TSVREFE = 1 << 23
+ ADON = 1 << 0
+ CONT = 1 << 1
+ CAL = 1 << 2
+ RSTCAL = 1 << 3
+ DMA = 1 << 8
+ ALIGN = 1 << 11
+ JEXTSEL = 0x7 << 12
+ JEXTTRIG = 1 << 15
+ EXTSEL = 0x7 << 17
+ EXTTRIG = 1 << 20
+ JSWSTART = 1 << 21
+ SWSTART = 1 << 22
+ TSVREFE = 1 << 23
class ADC_SMPR1(IntEnum):
- SMP10 = 0x7 << 0
- SMP11 = 0x7 << 3
- SMP12 = 0x7 << 6
- SMP13 = 0x7 << 9
- SMP14 = 0x7 << 12
- SMP15 = 0x7 << 15
- SMP16 = 0x7 << 18
- SMP17 = 0x7 << 21
+ SMP10 = 0x7 << 0
+ SMP11 = 0x7 << 3
+ SMP12 = 0x7 << 6
+ SMP13 = 0x7 << 9
+ SMP14 = 0x7 << 12
+ SMP15 = 0x7 << 15
+ SMP16 = 0x7 << 18
+ SMP17 = 0x7 << 21
class ADC_SMPR2(IntEnum):
- SMP0 = 0x7 << 0
- SMP1 = 0x7 << 3
- SMP2 = 0x7 << 6
- SMP3 = 0x7 << 9
- SMP4 = 0x7 << 12
- SMP5 = 0x7 << 15
- SMP6 = 0x7 << 18
- SMP7 = 0x7 << 21
- SMP8 = 0x7 << 24
- SMP9 = 0x7 << 27
+ SMP0 = 0x7 << 0
+ SMP1 = 0x7 << 3
+ SMP2 = 0x7 << 6
+ SMP3 = 0x7 << 9
+ SMP4 = 0x7 << 12
+ SMP5 = 0x7 << 15
+ SMP6 = 0x7 << 18
+ SMP7 = 0x7 << 21
+ SMP8 = 0x7 << 24
+ SMP9 = 0x7 << 27
class ADC_SQR1(IntEnum):
- SQ13 = 0x1f << 0
- SQ14 = 0x1f << 5
- SQ15 = 0x1f << 10
- SQ16 = 0x1f << 15
- L = 0xf << 20
+ SQ13 = 0x1f << 0
+ SQ14 = 0x1f << 5
+ SQ15 = 0x1f << 10
+ SQ16 = 0x1f << 15
+ L = 0xf << 20
class ADC_SQR2(IntEnum):
- SQ7 = 0x1f << 0
- SQ8 = 0x1f << 5
- SQ9 = 0x1f << 10
- SQ10 = 0x1f << 15
- SQ11 = 0x1f << 20
- SQ12 = 0x1f << 25
+ SQ7 = 0x1f << 0
+ SQ8 = 0x1f << 5
+ SQ9 = 0x1f << 10
+ SQ10 = 0x1f << 15
+ SQ11 = 0x1f << 20
+ SQ12 = 0x1f << 25
class ADC_SQR3(IntEnum):
- SQ1 = 0x1f << 0
- SQ2 = 0x1f << 5
- SQ3 = 0x1f << 10
- SQ4 = 0x1f << 15
- SQ5 = 0x1f << 20
- SQ6 = 0x1f << 25
+ SQ1 = 0x1f << 0
+ SQ2 = 0x1f << 5
+ SQ3 = 0x1f << 10
+ SQ4 = 0x1f << 15
+ SQ5 = 0x1f << 20
+ SQ6 = 0x1f << 25
class ADC_JSQR(IntEnum):
- JSQ1 = 0x1f << 0
- JSQ2 = 0x1f << 5
- JSQ3 = 0x1f << 10
- JSQ4 = 0x1f << 15
- JL = 0x3 << 20
+ JSQ1 = 0x1f << 0
+ JSQ2 = 0x1f << 5
+ JSQ3 = 0x1f << 10
+ JSQ4 = 0x1f << 15
+ JL = 0x3 << 20
class ADC_DR(IntEnum):
- DATA = 0xffff << 0
- ADC2DATA = 0xffff << 16
+ DATA = 0xffff << 0
+ ADC2DATA = 0xffff << 16
diff --git a/qiling/hw/const/stm32f1xx_dma.py b/qiling/hw/const/stm32f1xx_dma.py
index a848428e8..d0a6690e5 100644
--- a/qiling/hw/const/stm32f1xx_dma.py
+++ b/qiling/hw/const/stm32f1xx_dma.py
@@ -7,64 +7,64 @@
class DMA_ISR(IntEnum):
- GIF1 = 1 << 0
- TCIF1 = 1 << 1
- HTIF1 = 1 << 2
- TEIF1 = 1 << 3
- GIF2 = 1 << 4
- TCIF2 = 1 << 5
- HTIF2 = 1 << 6
- TEIF2 = 1 << 7
- GIF3 = 1 << 8
- TCIF3 = 1 << 9
- HTIF3 = 1 << 10
- TEIF3 = 1 << 11
- GIF4 = 1 << 12
- TCIF4 = 1 << 13
- HTIF4 = 1 << 14
- TEIF4 = 1 << 15
- GIF5 = 1 << 16
- TCIF5 = 1 << 17
- HTIF5 = 1 << 18
- TEIF5 = 1 << 19
- GIF6 = 1 << 20
- TCIF6 = 1 << 21
- HTIF6 = 1 << 22
- TEIF6 = 1 << 23
- GIF7 = 1 << 24
- TCIF7 = 1 << 25
- HTIF7 = 1 << 26
- TEIF7 = 1 << 27
+ GIF1 = 1 << 0
+ TCIF1 = 1 << 1
+ HTIF1 = 1 << 2
+ TEIF1 = 1 << 3
+ GIF2 = 1 << 4
+ TCIF2 = 1 << 5
+ HTIF2 = 1 << 6
+ TEIF2 = 1 << 7
+ GIF3 = 1 << 8
+ TCIF3 = 1 << 9
+ HTIF3 = 1 << 10
+ TEIF3 = 1 << 11
+ GIF4 = 1 << 12
+ TCIF4 = 1 << 13
+ HTIF4 = 1 << 14
+ TEIF4 = 1 << 15
+ GIF5 = 1 << 16
+ TCIF5 = 1 << 17
+ HTIF5 = 1 << 18
+ TEIF5 = 1 << 19
+ GIF6 = 1 << 20
+ TCIF6 = 1 << 21
+ HTIF6 = 1 << 22
+ TEIF6 = 1 << 23
+ GIF7 = 1 << 24
+ TCIF7 = 1 << 25
+ HTIF7 = 1 << 26
+ TEIF7 = 1 << 27
class DMA_IFCR(IntEnum):
- CGIF1 = 1 << 0
- CTCIF1 = 1 << 1
- CHTIF1 = 1 << 2
- CTEIF1 = 1 << 3
- CGIF2 = 1 << 4
- CTCIF2 = 1 << 5
- CHTIF2 = 1 << 6
- CTEIF2 = 1 << 7
- CGIF3 = 1 << 8
- CTCIF3 = 1 << 9
- CHTIF3 = 1 << 10
- CTEIF3 = 1 << 11
- CGIF4 = 1 << 12
- CTCIF4 = 1 << 13
- CHTIF4 = 1 << 14
- CTEIF4 = 1 << 15
- CGIF5 = 1 << 16
- CTCIF5 = 1 << 17
- CHTIF5 = 1 << 18
- CTEIF5 = 1 << 19
- CGIF6 = 1 << 20
- CTCIF6 = 1 << 21
- CHTIF6 = 1 << 22
- CTEIF6 = 1 << 23
- CGIF7 = 1 << 24
- CTCIF7 = 1 << 25
- CHTIF7 = 1 << 26
- CTEIF7 = 1 << 27
+ CGIF1 = 1 << 0
+ CTCIF1 = 1 << 1
+ CHTIF1 = 1 << 2
+ CTEIF1 = 1 << 3
+ CGIF2 = 1 << 4
+ CTCIF2 = 1 << 5
+ CHTIF2 = 1 << 6
+ CTEIF2 = 1 << 7
+ CGIF3 = 1 << 8
+ CTCIF3 = 1 << 9
+ CHTIF3 = 1 << 10
+ CTEIF3 = 1 << 11
+ CGIF4 = 1 << 12
+ CTCIF4 = 1 << 13
+ CHTIF4 = 1 << 14
+ CTEIF4 = 1 << 15
+ CGIF5 = 1 << 16
+ CTCIF5 = 1 << 17
+ CHTIF5 = 1 << 18
+ CTEIF5 = 1 << 19
+ CGIF6 = 1 << 20
+ CTCIF6 = 1 << 21
+ CHTIF6 = 1 << 22
+ CTEIF6 = 1 << 23
+ CGIF7 = 1 << 24
+ CTCIF7 = 1 << 25
+ CHTIF7 = 1 << 26
+ CTEIF7 = 1 << 27
class DMA_CR(IntEnum):
EN = 1 << 0
@@ -85,13 +85,13 @@ class DMA_CR(IntEnum):
MEM2MEM = 1 << 14
class DMA(IntEnum):
- PERIPH_TO_MEMORY = 0
- MEMORY_TO_PERIPH = DMA_CR.DIR
+ PERIPH_TO_MEMORY = 0
+ MEMORY_TO_PERIPH = DMA_CR.DIR
- PDATAALIGN_BYTE = 0
- PDATAALIGN_HALFWORD = DMA_CR.PSIZE_0
- PDATAALIGN_WORD = DMA_CR.PSIZE_1
+ PDATAALIGN_BYTE = 0
+ PDATAALIGN_HALFWORD = DMA_CR.PSIZE_0
+ PDATAALIGN_WORD = DMA_CR.PSIZE_1
- MDATAALIGN_BYTE = 0
- MDATAALIGN_HALFWORD = DMA_CR.MSIZE_0
- MDATAALIGN_WORD = DMA_CR.MSIZE_1
+ MDATAALIGN_BYTE = 0
+ MDATAALIGN_HALFWORD = DMA_CR.MSIZE_0
+ MDATAALIGN_WORD = DMA_CR.MSIZE_1
diff --git a/qiling/hw/const/stm32f4xx_dma.py b/qiling/hw/const/stm32f4xx_dma.py
index e48527012..036726ee1 100644
--- a/qiling/hw/const/stm32f4xx_dma.py
+++ b/qiling/hw/const/stm32f4xx_dma.py
@@ -43,117 +43,117 @@ class DMA_SxCR(IntEnum):
EN = 1 << 0
class DMA_SxFCR(IntEnum):
- FEIE = 1 << 7
- FS = 0x7 << 3
- DMDIS = 1 << 2
- FTH = 0x3 << 0
+ FEIE = 1 << 7
+ FS = 0x7 << 3
+ DMDIS = 1 << 2
+ FTH = 0x3 << 0
class DMA_LISR(IntEnum):
- TCIF3 = 1 << 27
- HTIF3 = 1 << 26
- TEIF3 = 1 << 25
- DMEIF3 = 1 << 24
- FEIF3 = 1 << 22
- TCIF2 = 1 << 21
- HTIF2 = 1 << 20
- TEIF2 = 1 << 19
- DMEIF2 = 1 << 18
- FEIF2 = 1 << 16
- TCIF1 = 1 << 11
- HTIF1 = 1 << 10
- TEIF1 = 1 << 9
- DMEIF1 = 1 << 8
- FEIF1 = 1 << 6
- TCIF0 = 1 << 5
- HTIF0 = 1 << 4
- TEIF0 = 1 << 3
- DMEIF0 = 1 << 2
- FEIF0 = 1 << 0
+ TCIF3 = 1 << 27
+ HTIF3 = 1 << 26
+ TEIF3 = 1 << 25
+ DMEIF3 = 1 << 24
+ FEIF3 = 1 << 22
+ TCIF2 = 1 << 21
+ HTIF2 = 1 << 20
+ TEIF2 = 1 << 19
+ DMEIF2 = 1 << 18
+ FEIF2 = 1 << 16
+ TCIF1 = 1 << 11
+ HTIF1 = 1 << 10
+ TEIF1 = 1 << 9
+ DMEIF1 = 1 << 8
+ FEIF1 = 1 << 6
+ TCIF0 = 1 << 5
+ HTIF0 = 1 << 4
+ TEIF0 = 1 << 3
+ DMEIF0 = 1 << 2
+ FEIF0 = 1 << 0
class DMA_HISR(IntEnum):
- TCIF7 = 1 << 27
- HTIF7 = 1 << 26
- TEIF7 = 1 << 25
- DMEIF7 = 1 << 24
- FEIF7 = 1 << 22
- TCIF6 = 1 << 21
- HTIF6 = 1 << 20
- TEIF6 = 1 << 19
- DMEIF6 = 1 << 18
- FEIF6 = 1 << 16
- TCIF5 = 1 << 11
- HTIF5 = 1 << 10
- TEIF5 = 1 << 9
- DMEIF5 = 1 << 8
- FEIF5 = 1 << 6
- TCIF4 = 1 << 5
- HTIF4 = 1 << 4
- TEIF4 = 1 << 3
- DMEIF4 = 1 << 2
- FEIF4 = 1 << 0
+ TCIF7 = 1 << 27
+ HTIF7 = 1 << 26
+ TEIF7 = 1 << 25
+ DMEIF7 = 1 << 24
+ FEIF7 = 1 << 22
+ TCIF6 = 1 << 21
+ HTIF6 = 1 << 20
+ TEIF6 = 1 << 19
+ DMEIF6 = 1 << 18
+ FEIF6 = 1 << 16
+ TCIF5 = 1 << 11
+ HTIF5 = 1 << 10
+ TEIF5 = 1 << 9
+ DMEIF5 = 1 << 8
+ FEIF5 = 1 << 6
+ TCIF4 = 1 << 5
+ HTIF4 = 1 << 4
+ TEIF4 = 1 << 3
+ DMEIF4 = 1 << 2
+ FEIF4 = 1 << 0
class DMA_LIFCR(IntEnum):
- CTCIF3 = 1 << 27
- CHTIF3 = 1 << 26
- CTEIF3 = 1 << 25
- CDMEIF3 = 1 << 24
- CFEIF3 = 1 << 22
- CTCIF2 = 1 << 21
- CHTIF2 = 1 << 20
- CTEIF2 = 1 << 19
- CDMEIF2 = 1 << 18
- CFEIF2 = 1 << 16
- CTCIF1 = 1 << 11
- CHTIF1 = 1 << 10
- CTEIF1 = 1 << 9
- CDMEIF1 = 1 << 8
- CFEIF1 = 1 << 6
- CTCIF0 = 1 << 5
- CHTIF0 = 1 << 4
- CTEIF0 = 1 << 3
- CDMEIF0 = 1 << 2
- CFEIF0 = 1 << 0
+ CTCIF3 = 1 << 27
+ CHTIF3 = 1 << 26
+ CTEIF3 = 1 << 25
+ CDMEIF3 = 1 << 24
+ CFEIF3 = 1 << 22
+ CTCIF2 = 1 << 21
+ CHTIF2 = 1 << 20
+ CTEIF2 = 1 << 19
+ CDMEIF2 = 1 << 18
+ CFEIF2 = 1 << 16
+ CTCIF1 = 1 << 11
+ CHTIF1 = 1 << 10
+ CTEIF1 = 1 << 9
+ CDMEIF1 = 1 << 8
+ CFEIF1 = 1 << 6
+ CTCIF0 = 1 << 5
+ CHTIF0 = 1 << 4
+ CTEIF0 = 1 << 3
+ CDMEIF0 = 1 << 2
+ CFEIF0 = 1 << 0
class DMA_HIFCR(IntEnum):
- CTCIF7 = 1 << 27
- CHTIF7 = 1 << 26
- CTEIF7 = 1 << 25
- CDMEIF7 = 1 << 24
- CFEIF7 = 1 << 22
- CTCIF6 = 1 << 21
- CHTIF6 = 1 << 20
- CTEIF6 = 1 << 19
- CDMEIF6 = 1 << 18
- CFEIF6 = 1 << 16
- CTCIF5 = 1 << 11
- CHTIF5 = 1 << 10
- CTEIF5 = 1 << 9
- CDMEIF5 = 1 << 8
- CFEIF5 = 1 << 6
- CTCIF4 = 1 << 5
- CHTIF4 = 1 << 4
- CTEIF4 = 1 << 3
- CDMEIF4 = 1 << 2
- CFEIF4 = 1 << 0
+ CTCIF7 = 1 << 27
+ CHTIF7 = 1 << 26
+ CTEIF7 = 1 << 25
+ CDMEIF7 = 1 << 24
+ CFEIF7 = 1 << 22
+ CTCIF6 = 1 << 21
+ CHTIF6 = 1 << 20
+ CTEIF6 = 1 << 19
+ CDMEIF6 = 1 << 18
+ CFEIF6 = 1 << 16
+ CTCIF5 = 1 << 11
+ CHTIF5 = 1 << 10
+ CTEIF5 = 1 << 9
+ CDMEIF5 = 1 << 8
+ CFEIF5 = 1 << 6
+ CTCIF4 = 1 << 5
+ CHTIF4 = 1 << 4
+ CTEIF4 = 1 << 3
+ CDMEIF4 = 1 << 2
+ CFEIF4 = 1 << 0
class DMA_SxPAR(IntEnum):
- PA = 0xffffffff << 0
+ PA = 0xffffffff << 0
class DMA_SxM0AR(IntEnum):
- M0A = 0xffffffff << 0
+ M0A = 0xffffffff << 0
class DMA_SxM1AR(IntEnum):
- M1A = 0xffffffff << 0
+ M1A = 0xffffffff << 0
class DMA(IntEnum):
- PERIPH_TO_MEMORY = 0
- MEMORY_TO_PERIPH = DMA_SxCR.DIR_0
- MEMORY_TO_MEMORY = DMA_SxCR.DIR_1
+ PERIPH_TO_MEMORY = 0
+ MEMORY_TO_PERIPH = DMA_SxCR.DIR_0
+ MEMORY_TO_MEMORY = DMA_SxCR.DIR_1
- PDATAALIGN_BYTE = 0
- PDATAALIGN_HALFWORD = DMA_SxCR.PSIZE_0
- PDATAALIGN_WORD = DMA_SxCR.PSIZE_1
+ PDATAALIGN_BYTE = 0
+ PDATAALIGN_HALFWORD = DMA_SxCR.PSIZE_0
+ PDATAALIGN_WORD = DMA_SxCR.PSIZE_1
- MDATAALIGN_BYTE = 0
- MDATAALIGN_HALFWORD = DMA_SxCR.MSIZE_0
- MDATAALIGN_WORD = DMA_SxCR.MSIZE_1
+ MDATAALIGN_BYTE = 0
+ MDATAALIGN_HALFWORD = DMA_SxCR.MSIZE_0
+ MDATAALIGN_WORD = DMA_SxCR.MSIZE_1
diff --git a/qiling/hw/const/stm32f4xx_eth.py b/qiling/hw/const/stm32f4xx_eth.py
index bbafc2945..4d6d617aa 100644
--- a/qiling/hw/const/stm32f4xx_eth.py
+++ b/qiling/hw/const/stm32f4xx_eth.py
@@ -2,271 +2,271 @@
class ETH_MACCR(IntEnum):
- WD = 1 << 23
- JD = 1 << 22
- IFG = 0x7 << 17
- CSD = 1 << 16
- FES = 1 << 14
- ROD = 1 << 13
- LM = 1 << 12
- DM = 1 << 11
- IPCO = 1 << 10
- RD = 1 << 9
- APCS = 1 << 7
- BL = 0x3 << 5
- DC = 1 << 4
- TE = 1 << 3
- RE = 1 << 2
+ WD = 1 << 23
+ JD = 1 << 22
+ IFG = 0x7 << 17
+ CSD = 1 << 16
+ FES = 1 << 14
+ ROD = 1 << 13
+ LM = 1 << 12
+ DM = 1 << 11
+ IPCO = 1 << 10
+ RD = 1 << 9
+ APCS = 1 << 7
+ BL = 0x3 << 5
+ DC = 1 << 4
+ TE = 1 << 3
+ RE = 1 << 2
class ETH_MACFFR(IntEnum):
- RA = 1 << 31
- HPF = 1 << 10
- SAF = 1 << 9
- SAIF = 1 << 8
- PCF = 0x3 << 6
- PCF_BlockAll = 1 << 6
- PCF_ForwardAll = 1 << 7
- PCF_ForwardPassedAddrFilter = 0x3 << 6
- BFD = 1 << 5
- PAM = 1 << 4
- DAIF = 1 << 3
- HM = 1 << 2
- HU = 1 << 1
- PM = 1 << 0
+ RA = 1 << 31
+ HPF = 1 << 10
+ SAF = 1 << 9
+ SAIF = 1 << 8
+ PCF = 0x3 << 6
+ PCF_BlockAll = 1 << 6
+ PCF_ForwardAll = 1 << 7
+ PCF_ForwardPassedAddrFilter = 0x3 << 6
+ BFD = 1 << 5
+ PAM = 1 << 4
+ DAIF = 1 << 3
+ HM = 1 << 2
+ HU = 1 << 1
+ PM = 1 << 0
class ETH_MACMIIAR(IntEnum):
- PA = 0x1f << 11
- MR = 0x1f << 6
- CR = 0x7 << 2
- CR_Div62 = 1 << 2
- CR_Div16 = 1 << 3
- CR_Div26 = 0x3 << 2
- CR_Div102 = 1 << 4
- MW = 1 << 1
- MB = 1 << 0
+ PA = 0x1f << 11
+ MR = 0x1f << 6
+ CR = 0x7 << 2
+ CR_Div62 = 1 << 2
+ CR_Div16 = 1 << 3
+ CR_Div26 = 0x3 << 2
+ CR_Div102 = 1 << 4
+ MW = 1 << 1
+ MB = 1 << 0
class ETH_MACFCR(IntEnum):
- PT = 0xffff << 16
- ZQPD = 1 << 7
- PLT = 0x3 << 4
- PLT_Minus28 = 1 << 4
- PLT_Minus144 = 1 << 5
- PLT_Minus256 = 0x3 << 4
- UPFD = 1 << 3
- RFCE = 1 << 2
- TFCE = 1 << 1
- FCBBPA = 1 << 0
+ PT = 0xffff << 16
+ ZQPD = 1 << 7
+ PLT = 0x3 << 4
+ PLT_Minus28 = 1 << 4
+ PLT_Minus144 = 1 << 5
+ PLT_Minus256 = 0x3 << 4
+ UPFD = 1 << 3
+ RFCE = 1 << 2
+ TFCE = 1 << 1
+ FCBBPA = 1 << 0
class ETH_MACVLANTR(IntEnum):
- VLANTC = 1 << 16
- VLANTI = 0xffff << 0
+ VLANTC = 1 << 16
+ VLANTI = 0xffff << 0
class ETH_MACPMTCSR(IntEnum):
- WFFRPR = 1 << 31
- GU = 1 << 9
- WFR = 1 << 6
- MPR = 1 << 5
- WFE = 1 << 2
- MPE = 1 << 1
- PD = 1 << 0
+ WFFRPR = 1 << 31
+ GU = 1 << 9
+ WFR = 1 << 6
+ MPR = 1 << 5
+ WFE = 1 << 2
+ MPE = 1 << 1
+ PD = 1 << 0
class ETH_MACDBGR(IntEnum):
- TFF = 1 << 25
- TFNE = 1 << 24
- TFWA = 1 << 22
- TFRS = 0x3 << 20
- TFRS_WRITING = 0x3 << 20
- TFRS_WAITING = 1 << 21
- TFRS_READ = 1 << 20
- MTP = 1 << 19
- MTFCS = 0x3 << 17
- MTFCS_TRANSFERRING = 0x3 << 17
- MTFCS_GENERATINGPCF = 1 << 18
- MTFCS_WAITING = 1 << 17
- MMTEA = 1 << 16
- RFFL = 0x3 << 8
- RFFL_FL = 0x3 << 8
- RFFL_ABOVEFCT = 1 << 9
- RFFL_BELOWFCT = 1 << 8
- RFRCS = 0x3 << 5
- RFRCS_FLUSHING = 0x3 << 5
- RFRCS_STATUSREADING = 1 << 6
- RFRCS_DATAREADING = 1 << 5
- RFWRA = 1 << 4
- MSFRWCS = 0x3 << 1
- MMRPEA = 1 << 0
+ TFF = 1 << 25
+ TFNE = 1 << 24
+ TFWA = 1 << 22
+ TFRS = 0x3 << 20
+ TFRS_WRITING = 0x3 << 20
+ TFRS_WAITING = 1 << 21
+ TFRS_READ = 1 << 20
+ MTP = 1 << 19
+ MTFCS = 0x3 << 17
+ MTFCS_TRANSFERRING = 0x3 << 17
+ MTFCS_GENERATINGPCF = 1 << 18
+ MTFCS_WAITING = 1 << 17
+ MMTEA = 1 << 16
+ RFFL = 0x3 << 8
+ RFFL_FL = 0x3 << 8
+ RFFL_ABOVEFCT = 1 << 9
+ RFFL_BELOWFCT = 1 << 8
+ RFRCS = 0x3 << 5
+ RFRCS_FLUSHING = 0x3 << 5
+ RFRCS_STATUSREADING = 1 << 6
+ RFRCS_DATAREADING = 1 << 5
+ RFWRA = 1 << 4
+ MSFRWCS = 0x3 << 1
+ MMRPEA = 1 << 0
class ETH_MACSR(IntEnum):
- TSTS = 1 << 9
- MMCTS = 1 << 6
- MMMCRS = 1 << 5
- MMCS = 1 << 4
- PMTS = 1 << 3
+ TSTS = 1 << 9
+ MMCTS = 1 << 6
+ MMMCRS = 1 << 5
+ MMCS = 1 << 4
+ PMTS = 1 << 3
class ETH_MACIMR(IntEnum):
- TSTIM = 1 << 9
- PMTIM = 1 << 3
+ TSTIM = 1 << 9
+ PMTIM = 1 << 3
class ETH_MACA1HR(IntEnum):
- AE = 1 << 31
- SA = 1 << 30
- MBC = 0x3f << 24
- MACA1H = 0xffff << 0
+ AE = 1 << 31
+ SA = 1 << 30
+ MBC = 0x3f << 24
+ MACA1H = 0xffff << 0
class ETH_MACA2HR(IntEnum):
- AE = 1 << 31
- SA = 1 << 30
- MBC = 0x3f << 24
- MACA2H = 0xffff << 0
+ AE = 1 << 31
+ SA = 1 << 30
+ MBC = 0x3f << 24
+ MACA2H = 0xffff << 0
class ETH_MACA3HR(IntEnum):
- AE = 1 << 31
- SA = 1 << 30
- MBC = 0x3f << 24
- MACA3H = 0xffff << 0
+ AE = 1 << 31
+ SA = 1 << 30
+ MBC = 0x3f << 24
+ MACA3H = 0xffff << 0
class ETH_MMCCR(IntEnum):
- MCFHP = 1 << 5
- MCP = 1 << 4
- MCF = 1 << 3
- ROR = 1 << 2
- CSR = 1 << 1
- CR = 1 << 0
+ MCFHP = 1 << 5
+ MCP = 1 << 4
+ MCF = 1 << 3
+ ROR = 1 << 2
+ CSR = 1 << 1
+ CR = 1 << 0
class ETH_MMCRIR(IntEnum):
- RGUFS = 1 << 17
- RFAES = 1 << 6
- RFCES = 1 << 5
+ RGUFS = 1 << 17
+ RFAES = 1 << 6
+ RFCES = 1 << 5
class ETH_MMCTIR(IntEnum):
- TGFS = 1 << 21
- TGFMSCS = 1 << 15
- TGFSCS = 1 << 14
+ TGFS = 1 << 21
+ TGFMSCS = 1 << 15
+ TGFSCS = 1 << 14
class ETH_MMCRIMR(IntEnum):
- RGUFM = 1 << 17
- RFAEM = 1 << 6
- RFCEM = 1 << 5
+ RGUFM = 1 << 17
+ RFAEM = 1 << 6
+ RFCEM = 1 << 5
class ETH_MMCTIMR(IntEnum):
- TGFM = 1 << 21
- TGFMSCM = 1 << 15
- TGFSCM = 1 << 14
+ TGFM = 1 << 21
+ TGFMSCM = 1 << 15
+ TGFSCM = 1 << 14
class ETH_PTPTSCR(IntEnum):
- TSCNT = 0x3 << 16
- TSARU = 1 << 5
- TSITE = 1 << 4
- TSSTU = 1 << 3
- TSSTI = 1 << 2
- TSFCU = 1 << 1
- TSE = 1 << 0
+ TSCNT = 0x3 << 16
+ TSARU = 1 << 5
+ TSITE = 1 << 4
+ TSSTU = 1 << 3
+ TSSTI = 1 << 2
+ TSFCU = 1 << 1
+ TSE = 1 << 0
class ETH_PTPTSSR(IntEnum):
- TSSMRME = 1 << 15
- TSSEME = 1 << 14
- TSSIPV4FE = 1 << 13
- TSSIPV6FE = 1 << 12
- TSSPTPOEFE = 1 << 11
- TSPTPPSV2E = 1 << 10
- TSSSR = 1 << 9
- TSSARFE = 1 << 8
- TSTTR = 1 << 5
- TSSO = 1 << 4
+ TSSMRME = 1 << 15
+ TSSEME = 1 << 14
+ TSSIPV4FE = 1 << 13
+ TSSIPV6FE = 1 << 12
+ TSSPTPOEFE = 1 << 11
+ TSPTPPSV2E = 1 << 10
+ TSSSR = 1 << 9
+ TSSARFE = 1 << 8
+ TSTTR = 1 << 5
+ TSSO = 1 << 4
class ETH_PTPSSIR(IntEnum):
- STSSI = 0xff << 0
+ STSSI = 0xff << 0
class ETH_PTPTSLR(IntEnum):
- STPNS = 1 << 31
- STSS = 0x7fffffff << 0
+ STPNS = 1 << 31
+ STSS = 0x7fffffff << 0
class ETH_PTPTSLUR(IntEnum):
- TSUPNS = 1 << 31
- TSUSS = 0x7fffffff << 0
+ TSUPNS = 1 << 31
+ TSUSS = 0x7fffffff << 0
class ETH_DMABMR(IntEnum):
- AAB = 1 << 25
- FPM = 1 << 24
- USP = 1 << 23
- RDP = 0x3f << 17
- FB = 1 << 16
- RTPR = 0x3 << 14
- PBL = 0x3f << 8
- EDE = 1 << 7
- DSL = 0x1f << 2
- DA = 1 << 1
- SR = 1 << 0
+ AAB = 1 << 25
+ FPM = 1 << 24
+ USP = 1 << 23
+ RDP = 0x3f << 17
+ FB = 1 << 16
+ RTPR = 0x3 << 14
+ PBL = 0x3f << 8
+ EDE = 1 << 7
+ DSL = 0x1f << 2
+ DA = 1 << 1
+ SR = 1 << 0
class ETH_DMASR(IntEnum):
- TSTS = 1 << 29
- PMTS = 1 << 28
- MMCS = 1 << 27
- EBS = 0x7 << 23
- EBS_DescAccess = 1 << 25
- EBS_ReadTransf = 1 << 24
- EBS_DataTransfTx = 1 << 23
- TPS = 0x7 << 20
- TPS_Fetching = 1 << 20
- TPS_Waiting = 1 << 21
- TPS_Reading = 0x3 << 20
- TPS_Suspended = 0x3 << 21
- TPS_Closing = 0x7 << 20
- RPS = 0x7 << 17
- RPS_Fetching = 1 << 17
- RPS_Waiting = 0x3 << 17
- RPS_Suspended = 1 << 19
- RPS_Closing = 0x5 << 17
- RPS_Queuing = 0x7 << 17
- NIS = 1 << 16
- AIS = 1 << 15
- ERS = 1 << 14
- FBES = 1 << 13
- ETS = 1 << 10
- RWTS = 1 << 9
- RPSS = 1 << 8
- RBUS = 1 << 7
- RS = 1 << 6
- TUS = 1 << 5
- ROS = 1 << 4
- TJTS = 1 << 3
- TBUS = 1 << 2
- TPSS = 1 << 1
- TS = 1 << 0
+ TSTS = 1 << 29
+ PMTS = 1 << 28
+ MMCS = 1 << 27
+ EBS = 0x7 << 23
+ EBS_DescAccess = 1 << 25
+ EBS_ReadTransf = 1 << 24
+ EBS_DataTransfTx = 1 << 23
+ TPS = 0x7 << 20
+ TPS_Fetching = 1 << 20
+ TPS_Waiting = 1 << 21
+ TPS_Reading = 0x3 << 20
+ TPS_Suspended = 0x3 << 21
+ TPS_Closing = 0x7 << 20
+ RPS = 0x7 << 17
+ RPS_Fetching = 1 << 17
+ RPS_Waiting = 0x3 << 17
+ RPS_Suspended = 1 << 19
+ RPS_Closing = 0x5 << 17
+ RPS_Queuing = 0x7 << 17
+ NIS = 1 << 16
+ AIS = 1 << 15
+ ERS = 1 << 14
+ FBES = 1 << 13
+ ETS = 1 << 10
+ RWTS = 1 << 9
+ RPSS = 1 << 8
+ RBUS = 1 << 7
+ RS = 1 << 6
+ TUS = 1 << 5
+ ROS = 1 << 4
+ TJTS = 1 << 3
+ TBUS = 1 << 2
+ TPSS = 1 << 1
+ TS = 1 << 0
class ETH_DMAOMR(IntEnum):
- DTCEFD = 1 << 26
- RSF = 1 << 25
- DFRF = 1 << 24
- TSF = 1 << 21
- FTF = 1 << 20
- TTC = 0x7 << 14
- ST = 1 << 13
- FEF = 1 << 7
- FGF = 1 << 6
- RTC = 0x3 << 3
- OSF = 1 << 2
- SR = 1 << 1
+ DTCEFD = 1 << 26
+ RSF = 1 << 25
+ DFRF = 1 << 24
+ TSF = 1 << 21
+ FTF = 1 << 20
+ TTC = 0x7 << 14
+ ST = 1 << 13
+ FEF = 1 << 7
+ FGF = 1 << 6
+ RTC = 0x3 << 3
+ OSF = 1 << 2
+ SR = 1 << 1
class ETH_DMAIER(IntEnum):
- NISE = 1 << 16
- AISE = 1 << 15
- ERIE = 1 << 14
- FBEIE = 1 << 13
- ETIE = 1 << 10
- RWTIE = 1 << 9
- RPSIE = 1 << 8
- RBUIE = 1 << 7
- RIE = 1 << 6
- TUIE = 1 << 5
- ROIE = 1 << 4
- TJTIE = 1 << 3
- TBUIE = 1 << 2
- TPSIE = 1 << 1
- TIE = 1 << 0
+ NISE = 1 << 16
+ AISE = 1 << 15
+ ERIE = 1 << 14
+ FBEIE = 1 << 13
+ ETIE = 1 << 10
+ RWTIE = 1 << 9
+ RPSIE = 1 << 8
+ RBUIE = 1 << 7
+ RIE = 1 << 6
+ TUIE = 1 << 5
+ ROIE = 1 << 4
+ TJTIE = 1 << 3
+ TBUIE = 1 << 2
+ TPSIE = 1 << 1
+ TIE = 1 << 0
class ETH_DMAMFBOCR(IntEnum):
- OFOC = 1 << 28
- MFA = 0x7ff << 17
- OMFC = 1 << 16
- MFC = 0xffff << 0
+ OFOC = 1 << 28
+ MFA = 0x7ff << 17
+ OMFC = 1 << 16
+ MFC = 0xffff << 0
diff --git a/qiling/hw/const/stm32f4xx_i2c.py b/qiling/hw/const/stm32f4xx_i2c.py
index e8032597b..3efb1f2b6 100644
--- a/qiling/hw/const/stm32f4xx_i2c.py
+++ b/qiling/hw/const/stm32f4xx_i2c.py
@@ -7,88 +7,88 @@
class I2C_CR1(IntEnum):
- PE = 1 << 0
- SMBUS = 1 << 1
- SMBTYPE = 1 << 3
- ENARP = 1 << 4
- ENPEC = 1 << 5
- ENGC = 1 << 6
- NOSTRETCH = 1 << 7
- START = 1 << 8
- STOP = 1 << 9
- ACK = 1 << 10
- POS = 1 << 11
- PEC = 1 << 12
- ALERT = 1 << 13
- SWRST = 1 << 15
+ PE = 1 << 0
+ SMBUS = 1 << 1
+ SMBTYPE = 1 << 3
+ ENARP = 1 << 4
+ ENPEC = 1 << 5
+ ENGC = 1 << 6
+ NOSTRETCH = 1 << 7
+ START = 1 << 8
+ STOP = 1 << 9
+ ACK = 1 << 10
+ POS = 1 << 11
+ PEC = 1 << 12
+ ALERT = 1 << 13
+ SWRST = 1 << 15
- RW_MASK = PE|SMBUS|SMBTYPE|ENARP|ENPEC|ENGC|NOSTRETCH|START|STOP|ACK|POS|ALERT|SWRST
+ RW_MASK = PE|SMBUS|SMBTYPE|ENARP|ENPEC|ENGC|NOSTRETCH|START|STOP|ACK|POS|ALERT|SWRST
class I2C_CR2(IntEnum):
- FREQ = 0x3f << 0
- ITERREN = 1 << 8
- ITEVTEN = 1 << 9
- ITBUFEN = 1 << 10
- DMAEN = 1 << 11
- LAST = 1 << 12
+ FREQ = 0x3f << 0
+ ITERREN = 1 << 8
+ ITEVTEN = 1 << 9
+ ITBUFEN = 1 << 10
+ DMAEN = 1 << 11
+ LAST = 1 << 12
class I2C_OAR1(IntEnum):
- ADD0 = 1 << 0
- ADD1 = 1 << 1
- ADD2 = 1 << 2
- ADD3 = 1 << 3
- ADD4 = 1 << 4
- ADD5 = 1 << 5
- ADD6 = 1 << 6
- ADD7 = 1 << 7
- ADD8 = 1 << 8
- ADD9 = 1 << 9
- ADDMODE = 1 << 15
+ ADD0 = 1 << 0
+ ADD1 = 1 << 1
+ ADD2 = 1 << 2
+ ADD3 = 1 << 3
+ ADD4 = 1 << 4
+ ADD5 = 1 << 5
+ ADD6 = 1 << 6
+ ADD7 = 1 << 7
+ ADD8 = 1 << 8
+ ADD9 = 1 << 9
+ ADDMODE = 1 << 15
- ADDR1_7B = 0x7f << 1
- ADDR1_10B = 0x3ff
+ ADDR1_7B = 0x7f << 1
+ ADDR1_10B = 0x3ff
class I2C_OAR2(IntEnum):
- ENDUAL = 1 << 0
- ADDR2 = 0x7f << 1
+ ENDUAL = 1 << 0
+ ADDR2 = 0x7f << 1
class I2C_DR(IntEnum):
- DR = 0xff << 0
+ DR = 0xff << 0
class I2C_SR1(IntEnum):
- SB = 1 << 0
- ADDR = 1 << 1
- BTF = 1 << 2
- ADD10 = 1 << 3
- STOPF = 1 << 4
- RXNE = 1 << 6
- TXE = 1 << 7
- BERR = 1 << 8
- ARLO = 1 << 9
- AF = 1 << 10
- OVR = 1 << 11
- PECERR = 1 << 12
- TIMEOUT = 1 << 14
- SMBALERT = 1 << 15
+ SB = 1 << 0
+ ADDR = 1 << 1
+ BTF = 1 << 2
+ ADD10 = 1 << 3
+ STOPF = 1 << 4
+ RXNE = 1 << 6
+ TXE = 1 << 7
+ BERR = 1 << 8
+ ARLO = 1 << 9
+ AF = 1 << 10
+ OVR = 1 << 11
+ PECERR = 1 << 12
+ TIMEOUT = 1 << 14
+ SMBALERT = 1 << 15
class I2C_SR2(IntEnum):
- MSL = 1 << 0
- BSY = 1 << 1
- TRA = 1 << 2
- GENCALL = 1 << 4
- SMBDEFAULT = 1 << 5
- SMBHOST = 1 << 6
- DALF = 1 << 7
- PEC = 0xff << 8
+ MSL = 1 << 0
+ BSY = 1 << 1
+ TRA = 1 << 2
+ GENCALL = 1 << 4
+ SMBDEFAULT = 1 << 5
+ SMBHOST = 1 << 6
+ DALF = 1 << 7
+ PEC = 0xff << 8
class I2C_CCR(IntEnum):
- CCR = 0xfff << 0
- DTY = 1 << 14
- FS = 1 << 15
+ CCR = 0xfff << 0
+ DTY = 1 << 14
+ FS = 1 << 15
class I2C_TRISE(IntEnum):
- TRISE = 0x3f << 0
+ TRISE = 0x3f << 0
class I2C_FLTR(IntEnum):
- DNF = 0xf << 0
- ANOFF = 1 << 4
+ DNF = 0xf << 0
+ ANOFF = 1 << 4
diff --git a/qiling/hw/const/stm32f4xx_pwr.py b/qiling/hw/const/stm32f4xx_pwr.py
index 7e9fe07fb..7ddaeab0d 100644
--- a/qiling/hw/const/stm32f4xx_pwr.py
+++ b/qiling/hw/const/stm32f4xx_pwr.py
@@ -7,30 +7,30 @@
class PWR_CR(IntEnum):
- LPDS = 1 << 0
- PDDS = 1 << 1
- CWUF = 1 << 2
- CSBF = 1 << 3
- PVDE = 1 << 4
- PLS = 0x7 << 5
- DBP = 1 << 8
- FPDS = 1 << 9
- LPLVDS = 1 << 10
- MRLVDS = 1 << 11
- ADCDC1 = 1 << 13
- VOS = 0x3 << 14
- ODEN = 1 << 16
- ODSWEN = 1 << 17
- UDEN = 0x3 << 18
+ LPDS = 1 << 0
+ PDDS = 1 << 1
+ CWUF = 1 << 2
+ CSBF = 1 << 3
+ PVDE = 1 << 4
+ PLS = 0x7 << 5
+ DBP = 1 << 8
+ FPDS = 1 << 9
+ LPLVDS = 1 << 10
+ MRLVDS = 1 << 11
+ ADCDC1 = 1 << 13
+ VOS = 0x3 << 14
+ ODEN = 1 << 16
+ ODSWEN = 1 << 17
+ UDEN = 0x3 << 18
class PWR_CSR(IntEnum):
- WUF = 1 << 0
- SBF = 1 << 1
- PVDO = 1 << 2
- BRR = 1 << 3
- EWUP = 1 << 8
- BRE = 1 << 9
- VOSRDY = 1 << 14
- ODRDY = 1 << 16
- ODSWRDY = 1 << 17
- UDRDY = 0x3 << 18
+ WUF = 1 << 0
+ SBF = 1 << 1
+ PVDO = 1 << 2
+ BRR = 1 << 3
+ EWUP = 1 << 8
+ BRE = 1 << 9
+ VOSRDY = 1 << 14
+ ODRDY = 1 << 16
+ ODSWRDY = 1 << 17
+ UDRDY = 0x3 << 18
diff --git a/qiling/hw/const/stm32f4xx_rtc.py b/qiling/hw/const/stm32f4xx_rtc.py
index d1ca5f81c..ba145d417 100644
--- a/qiling/hw/const/stm32f4xx_rtc.py
+++ b/qiling/hw/const/stm32f4xx_rtc.py
@@ -8,161 +8,161 @@
class RTC_TR(IntEnum):
- PM = 1 << 22
- HT = 0x3 << 20
- HU = 0xf << 16
- MNT = 0x7 << 12
- MNU = 0xf << 8
- ST = 0x7 << 4
- SU = 0xf << 0
+ PM = 1 << 22
+ HT = 0x3 << 20
+ HU = 0xf << 16
+ MNT = 0x7 << 12
+ MNU = 0xf << 8
+ ST = 0x7 << 4
+ SU = 0xf << 0
class RTC_DR(IntEnum):
- YT = 0xf << 20
- YU = 0xf << 16
- WDU = 0x7 << 13
- MT = 1 << 12
- MU = 0xf << 8
- DT = 0x3 << 4
- D = 0xf << 0
+ YT = 0xf << 20
+ YU = 0xf << 16
+ WDU = 0x7 << 13
+ MT = 1 << 12
+ MU = 0xf << 8
+ DT = 0x3 << 4
+ D = 0xf << 0
class RTC_CR(IntEnum):
- COE = 1 << 23
- OSEL = 0x3 << 21
- POL = 1 << 20
- COSEL = 1 << 19
- BKP = 1 << 18
- SUB1H = 1 << 17
- ADD1H = 1 << 16
- TSIE = 1 << 15
- WUTIE = 1 << 14
- ALRBIE = 1 << 13
- ALRAIE = 1 << 12
- TSE = 1 << 11
- WUTE = 1 << 10
- ALRBE = 1 << 9
- ALRAE = 1 << 8
- DCE = 1 << 7
- FMT = 1 << 6
- BYPSHAD = 1 << 5
- REFCKON = 1 << 4
- TSEDGE = 1 << 3
- WUCKSEL = 0x7 << 0
+ COE = 1 << 23
+ OSEL = 0x3 << 21
+ POL = 1 << 20
+ COSEL = 1 << 19
+ BKP = 1 << 18
+ SUB1H = 1 << 17
+ ADD1H = 1 << 16
+ TSIE = 1 << 15
+ WUTIE = 1 << 14
+ ALRBIE = 1 << 13
+ ALRAIE = 1 << 12
+ TSE = 1 << 11
+ WUTE = 1 << 10
+ ALRBE = 1 << 9
+ ALRAE = 1 << 8
+ DCE = 1 << 7
+ FMT = 1 << 6
+ BYPSHAD = 1 << 5
+ REFCKON = 1 << 4
+ TSEDGE = 1 << 3
+ WUCKSEL = 0x7 << 0
class RTC_ISR(IntEnum):
- RECALPF = 1 << 16
- TAMP1F = 1 << 13
- TAMP2F = 1 << 14
- TSOVF = 1 << 12
- TSF = 1 << 11
- WUTF = 1 << 10
- ALRBF = 1 << 9
- ALRAF = 1 << 8
- INIT = 1 << 7
- INITF = 1 << 6
- RSF = 1 << 5
- INITS = 1 << 4
- SHPF = 1 << 3
- WUTWF = 1 << 2
- ALRBWF = 1 << 1
- ALRAWF = 1 << 0
+ RECALPF = 1 << 16
+ TAMP1F = 1 << 13
+ TAMP2F = 1 << 14
+ TSOVF = 1 << 12
+ TSF = 1 << 11
+ WUTF = 1 << 10
+ ALRBF = 1 << 9
+ ALRAF = 1 << 8
+ INIT = 1 << 7
+ INITF = 1 << 6
+ RSF = 1 << 5
+ INITS = 1 << 4
+ SHPF = 1 << 3
+ WUTWF = 1 << 2
+ ALRBWF = 1 << 1
+ ALRAWF = 1 << 0
class RTC_PRER(IntEnum):
- PREDIV_A = 0x7f << 16
- PREDIV_S = 0x7fff << 0
+ PREDIV_A = 0x7f << 16
+ PREDIV_S = 0x7fff << 0
class RTC_WUTR(IntEnum):
- WUT = 0xffff << 0
+ WUT = 0xffff << 0
class RTC_CALIBR(IntEnum):
- DCS = 1 << 7
- DC = 0x1f << 0
+ DCS = 1 << 7
+ DC = 0x1f << 0
class RTC_ALRMAR(IntEnum):
- MSK4 = 1 << 31
- WDSEL = 1 << 30
- DT = 0x3 << 28
- D = 0xf << 24
- MSK3 = 1 << 23
- PM = 1 << 22
- HT = 0x3 << 20
- HU = 0xf << 16
- MSK2 = 1 << 15
- MNT = 0x7 << 12
- MNU = 0xf << 8
- MSK1 = 1 << 7
- ST = 0x7 << 4
- SU = 0xf << 0
+ MSK4 = 1 << 31
+ WDSEL = 1 << 30
+ DT = 0x3 << 28
+ D = 0xf << 24
+ MSK3 = 1 << 23
+ PM = 1 << 22
+ HT = 0x3 << 20
+ HU = 0xf << 16
+ MSK2 = 1 << 15
+ MNT = 0x7 << 12
+ MNU = 0xf << 8
+ MSK1 = 1 << 7
+ ST = 0x7 << 4
+ SU = 0xf << 0
class RTC_ALRMBR(IntEnum):
- MSK4 = 1 << 31
- WDSEL = 1 << 30
- DT = 0x3 << 28
- D = 0xf << 24
- MSK3 = 1 << 23
- PM = 1 << 22
- HT = 0x3 << 20
- HU = 0xf << 16
- MSK2 = 1 << 15
- MNT = 0x7 << 12
- MNU = 0xf << 8
- MSK1 = 1 << 7
- ST = 0x7 << 4
- SU = 0xf << 0
+ MSK4 = 1 << 31
+ WDSEL = 1 << 30
+ DT = 0x3 << 28
+ D = 0xf << 24
+ MSK3 = 1 << 23
+ PM = 1 << 22
+ HT = 0x3 << 20
+ HU = 0xf << 16
+ MSK2 = 1 << 15
+ MNT = 0x7 << 12
+ MNU = 0xf << 8
+ MSK1 = 1 << 7
+ ST = 0x7 << 4
+ SU = 0xf << 0
class RTC_WPR(IntEnum):
- KEY = 0xff << 0
+ KEY = 0xff << 0
class RTC_SSR(IntEnum):
- SS = 0xffff << 0
+ SS = 0xffff << 0
class RTC_SHIFTR(IntEnum):
- SUBFS = 0x7fff << 0
- ADD1S = 1 << 31
+ SUBFS = 0x7fff << 0
+ ADD1S = 1 << 31
class RTC_TSTR(IntEnum):
- PM = 1 << 22
- HT = 0x3 << 20
- HU = 0xf << 16
- MNT = 0x7 << 12
- MNU = 0xf << 8
- ST = 0x7 << 4
- SU = 0xf << 0
+ PM = 1 << 22
+ HT = 0x3 << 20
+ HU = 0xf << 16
+ MNT = 0x7 << 12
+ MNU = 0xf << 8
+ ST = 0x7 << 4
+ SU = 0xf << 0
class RTC_TSDR(IntEnum):
- WDU = 0x7 << 13
- MT = 1 << 12
- MU = 0xf << 8
- DT = 0x3 << 4
- D = 0xf << 0
+ WDU = 0x7 << 13
+ MT = 1 << 12
+ MU = 0xf << 8
+ DT = 0x3 << 4
+ D = 0xf << 0
class RTC_TSSSR(IntEnum):
- SS = 0xffff << 0
+ SS = 0xffff << 0
class RTC_CALR(IntEnum):
- CALP = 1 << 15
- CALW8 = 1 << 14
- CALW16 = 1 << 13
- CALM = 0x1ff << 0
+ CALP = 1 << 15
+ CALW8 = 1 << 14
+ CALW16 = 1 << 13
+ CALM = 0x1ff << 0
class RTC_TAFCR(IntEnum):
- ALARMOUTTYPE = 1 << 18
- TSINSEL = 1 << 17
- TAMP1INSEL = 1 << 16
- TAMPPUDIS = 1 << 15
- TAMPPRCH = 0x3 << 13
- TAMPFLT = 0x3 << 11
- TAMPFREQ = 0x7 << 8
- TAMPTS = 1 << 7
- TAMP2TRG = 1 << 4
- TAMP2E = 1 << 3
- TAMPIE = 1 << 2
- TAMP1TRG = 1 << 1
- TAMP1E = 1 << 0
+ ALARMOUTTYPE = 1 << 18
+ TSINSEL = 1 << 17
+ TAMP1INSEL = 1 << 16
+ TAMPPUDIS = 1 << 15
+ TAMPPRCH = 0x3 << 13
+ TAMPFLT = 0x3 << 11
+ TAMPFREQ = 0x7 << 8
+ TAMPTS = 1 << 7
+ TAMP2TRG = 1 << 4
+ TAMP2E = 1 << 3
+ TAMPIE = 1 << 2
+ TAMP1TRG = 1 << 1
+ TAMP1E = 1 << 0
class RTC_ALRMASSR(IntEnum):
- MASKSS = 0xf << 24
- SS = 0x7fff << 0
+ MASKSS = 0xf << 24
+ SS = 0x7fff << 0
class RTC_ALRMBSSR(IntEnum):
- MASKSS = 0xf << 24
- SS = 0x7fff << 0
+ MASKSS = 0xf << 24
+ SS = 0x7fff << 0
diff --git a/qiling/hw/const/stm32f4xx_sdio.py b/qiling/hw/const/stm32f4xx_sdio.py
index e48821845..84374a772 100644
--- a/qiling/hw/const/stm32f4xx_sdio.py
+++ b/qiling/hw/const/stm32f4xx_sdio.py
@@ -7,99 +7,99 @@
class SDIO_CLKCR(IntEnum):
- CLKDIV = 0xff << 0
- CLKEN = 1 << 8
- PWRSAV = 1 << 9
- BYPASS = 1 << 10
- WIDBUS = 0x3 << 11
- NEGEDGE = 1 << 13
- HWFC_EN = 1 << 14
+ CLKDIV = 0xff << 0
+ CLKEN = 1 << 8
+ PWRSAV = 1 << 9
+ BYPASS = 1 << 10
+ WIDBUS = 0x3 << 11
+ NEGEDGE = 1 << 13
+ HWFC_EN = 1 << 14
class SDIO_CMD(IntEnum):
- CMDINDEX = 0x3f << 0
- WAITRESP = 0x3 << 6
- WAITINT = 1 << 8
- WAITPEND = 1 << 9
- CPSMEN = 1 << 10
- SDIOSUSPEND = 1 << 11
- ENCMDCOMPL = 1 << 12
- NIEN = 1 << 13
- CEATACMD = 1 << 14
+ CMDINDEX = 0x3f << 0
+ WAITRESP = 0x3 << 6
+ WAITINT = 1 << 8
+ WAITPEND = 1 << 9
+ CPSMEN = 1 << 10
+ SDIOSUSPEND = 1 << 11
+ ENCMDCOMPL = 1 << 12
+ NIEN = 1 << 13
+ CEATACMD = 1 << 14
class SDIO_DCTRL(IntEnum):
- DTEN = 1 << 0
- DTDIR = 1 << 1
- DTMODE = 1 << 2
- DMAEN = 1 << 3
- DBLOCKSIZE = 0xf << 4
- RWSTART = 1 << 8
- RWSTOP = 1 << 9
- RWMOD = 1 << 10
- SDIOEN = 1 << 11
+ DTEN = 1 << 0
+ DTDIR = 1 << 1
+ DTMODE = 1 << 2
+ DMAEN = 1 << 3
+ DBLOCKSIZE = 0xf << 4
+ RWSTART = 1 << 8
+ RWSTOP = 1 << 9
+ RWMOD = 1 << 10
+ SDIOEN = 1 << 11
class SDIO_STA(IntEnum):
- CCRCFAIL = 1 << 0
- DCRCFAIL = 1 << 1
- CTIMEOUT = 1 << 2
- DTIMEOUT = 1 << 3
- TXUNDERR = 1 << 4
- RXOVERR = 1 << 5
- CMDREND = 1 << 6
- CMDSENT = 1 << 7
- DATAEND = 1 << 8
- STBITERR = 1 << 9
- DBCKEND = 1 << 10
- CMDACT = 1 << 11
- TXACT = 1 << 12
- RXACT = 1 << 13
- TXFIFOHE = 1 << 14
- RXFIFOHF = 1 << 15
- TXFIFOF = 1 << 16
- RXFIFOF = 1 << 17
- TXFIFOE = 1 << 18
- RXFIFOE = 1 << 19
- TXDAVL = 1 << 20
- RXDAVL = 1 << 21
- SDIOIT = 1 << 22
- CEATAEND = 1 << 23
+ CCRCFAIL = 1 << 0
+ DCRCFAIL = 1 << 1
+ CTIMEOUT = 1 << 2
+ DTIMEOUT = 1 << 3
+ TXUNDERR = 1 << 4
+ RXOVERR = 1 << 5
+ CMDREND = 1 << 6
+ CMDSENT = 1 << 7
+ DATAEND = 1 << 8
+ STBITERR = 1 << 9
+ DBCKEND = 1 << 10
+ CMDACT = 1 << 11
+ TXACT = 1 << 12
+ RXACT = 1 << 13
+ TXFIFOHE = 1 << 14
+ RXFIFOHF = 1 << 15
+ TXFIFOF = 1 << 16
+ RXFIFOF = 1 << 17
+ TXFIFOE = 1 << 18
+ RXFIFOE = 1 << 19
+ TXDAVL = 1 << 20
+ RXDAVL = 1 << 21
+ SDIOIT = 1 << 22
+ CEATAEND = 1 << 23
class SDIO_ICR(IntEnum):
- CCRCFAILC = 1 << 0
- DCRCFAILC = 1 << 1
- CTIMEOUTC = 1 << 2
- DTIMEOUTC = 1 << 3
- TXUNDERRC = 1 << 4
- RXOVERRC = 1 << 5
- CMDRENDC = 1 << 6
- CMDSENTC = 1 << 7
- DATAENDC = 1 << 8
- STBITERRC = 1 << 9
- DBCKENDC = 1 << 10
- SDIOITC = 1 << 22
- CEATAENDC = 1 << 23
+ CCRCFAILC = 1 << 0
+ DCRCFAILC = 1 << 1
+ CTIMEOUTC = 1 << 2
+ DTIMEOUTC = 1 << 3
+ TXUNDERRC = 1 << 4
+ RXOVERRC = 1 << 5
+ CMDRENDC = 1 << 6
+ CMDSENTC = 1 << 7
+ DATAENDC = 1 << 8
+ STBITERRC = 1 << 9
+ DBCKENDC = 1 << 10
+ SDIOITC = 1 << 22
+ CEATAENDC = 1 << 23
class SDIO_MASK(IntEnum):
- CCRCFAILIE = 1 << 0
- DCRCFAILIE = 1 << 1
- CTIMEOUTIE = 1 << 2
- DTIMEOUTIE = 1 << 3
- TXUNDERRIE = 1 << 4
- RXOVERRIE = 1 << 5
- CMDRENDIE = 1 << 6
- CMDSENTIE = 1 << 7
- DATAENDIE = 1 << 8
- STBITERRIE = 1 << 9
- DBCKENDIE = 1 << 10
- CMDACTIE = 1 << 11
- TXACTIE = 1 << 12
- RXACTIE = 1 << 13
- TXFIFOHEIE = 1 << 14
- RXFIFOHFIE = 1 << 15
- TXFIFOFIE = 1 << 16
- RXFIFOFIE = 1 << 17
- TXFIFOEIE = 1 << 18
- RXFIFOEIE = 1 << 19
- TXDAVLIE = 1 << 20
- RXDAVLIE = 1 << 21
- SDIOITIE = 1 << 22
- CEATAENDIE = 1 << 23
+ CCRCFAILIE = 1 << 0
+ DCRCFAILIE = 1 << 1
+ CTIMEOUTIE = 1 << 2
+ DTIMEOUTIE = 1 << 3
+ TXUNDERRIE = 1 << 4
+ RXOVERRIE = 1 << 5
+ CMDRENDIE = 1 << 6
+ CMDSENTIE = 1 << 7
+ DATAENDIE = 1 << 8
+ STBITERRIE = 1 << 9
+ DBCKENDIE = 1 << 10
+ CMDACTIE = 1 << 11
+ TXACTIE = 1 << 12
+ RXACTIE = 1 << 13
+ TXFIFOHEIE = 1 << 14
+ RXFIFOHFIE = 1 << 15
+ TXFIFOFIE = 1 << 16
+ RXFIFOFIE = 1 << 17
+ TXFIFOEIE = 1 << 18
+ RXFIFOEIE = 1 << 19
+ TXDAVLIE = 1 << 20
+ RXDAVLIE = 1 << 21
+ SDIOITIE = 1 << 22
+ CEATAENDIE = 1 << 23
diff --git a/qiling/hw/const/stm32f4xx_spi.py b/qiling/hw/const/stm32f4xx_spi.py
index 203087c17..4eb5bbfa0 100644
--- a/qiling/hw/const/stm32f4xx_spi.py
+++ b/qiling/hw/const/stm32f4xx_spi.py
@@ -7,63 +7,63 @@
class SPI_CR1(IntEnum):
- CPHA = 1 << 0
- CPOL = 1 << 1
- MSTR = 1 << 2
- BR = 0x7 << 3
- SPE = 1 << 6
- LSBFIRST = 1 << 7
- SSI = 1 << 8
- SSM = 1 << 9
- RXONLY = 1 << 10
- DFF = 1 << 11
- CRCNEXT = 1 << 12
- CRCEN = 1 << 13
- BIDIOE = 1 << 14
- BIDIMODE = 1 << 15
+ CPHA = 1 << 0
+ CPOL = 1 << 1
+ MSTR = 1 << 2
+ BR = 0x7 << 3
+ SPE = 1 << 6
+ LSBFIRST = 1 << 7
+ SSI = 1 << 8
+ SSM = 1 << 9
+ RXONLY = 1 << 10
+ DFF = 1 << 11
+ CRCNEXT = 1 << 12
+ CRCEN = 1 << 13
+ BIDIOE = 1 << 14
+ BIDIMODE = 1 << 15
- RW_MASK = 0xffff
+ RW_MASK = 0xffff
class SPI_CR2(IntEnum):
- RXDMAEN = 1 << 0
- TXDMAEN = 1 << 1
- SSOE = 1 << 2
- FRF = 1 << 4
- ERRIE = 1 << 5
- RXNEIE = 1 << 6
- TXEIE = 1 << 7
+ RXDMAEN = 1 << 0
+ TXDMAEN = 1 << 1
+ SSOE = 1 << 2
+ FRF = 1 << 4
+ ERRIE = 1 << 5
+ RXNEIE = 1 << 6
+ TXEIE = 1 << 7
- RW_MASK = RXDMAEN|TXDMAEN|SSOE|FRF|ERRIE|RXNEIE|TXEIE
+ RW_MASK = RXDMAEN|TXDMAEN|SSOE|FRF|ERRIE|RXNEIE|TXEIE
class SPI_SR(IntEnum):
- RXNE = 1 << 0
- TXE = 1 << 1
- CHSIDE = 1 << 2
- UDR = 1 << 3
- CRCERR = 1 << 4
- MODF = 1 << 5
- OVR = 1 << 6
- BSY = 1 << 7
- FRE = 1 << 8
+ RXNE = 1 << 0
+ TXE = 1 << 1
+ CHSIDE = 1 << 2
+ UDR = 1 << 3
+ CRCERR = 1 << 4
+ MODF = 1 << 5
+ OVR = 1 << 6
+ BSY = 1 << 7
+ FRE = 1 << 8
class SPI_CRCPR(IntEnum):
- CRCPOLY = 0xffff
+ CRCPOLY = 0xffff
class SPI_I2SCFGR(IntEnum):
- CHLEN = 1 << 0
- DATLEN = 0x3 << 1
- CKPOL = 1 << 3
- I2SSTD = 0x3 << 4
- PCMSYNC = 1 << 7
- I2SCFG = 0x3 << 8
- I2SE = 1 << 10
- I2SMOD = 1 << 11
+ CHLEN = 1 << 0
+ DATLEN = 0x3 << 1
+ CKPOL = 1 << 3
+ I2SSTD = 0x3 << 4
+ PCMSYNC = 1 << 7
+ I2SCFG = 0x3 << 8
+ I2SE = 1 << 10
+ I2SMOD = 1 << 11
- RW_MASK = CHLEN|DATLEN|CKPOL|I2SSTD|PCMSYNC|I2SCFG|I2SE|I2SMOD
+ RW_MASK = CHLEN|DATLEN|CKPOL|I2SSTD|PCMSYNC|I2SCFG|I2SE|I2SMOD
class SPI_I2SPR(IntEnum):
- I2SDIV = 0xff << 0
- ODD = 1 << 8
- MCKOE = 1 << 9
+ I2SDIV = 0xff << 0
+ ODD = 1 << 8
+ MCKOE = 1 << 9
- RW_MASK = I2SDIV|ODD|MCKOE
+ RW_MASK = I2SDIV|ODD|MCKOE
diff --git a/qiling/hw/const/stm32f4xx_tim.py b/qiling/hw/const/stm32f4xx_tim.py
index 693f75295..5e126e36d 100644
--- a/qiling/hw/const/stm32f4xx_tim.py
+++ b/qiling/hw/const/stm32f4xx_tim.py
@@ -7,170 +7,170 @@
class TIM_CR1(IntEnum):
- CEN = 1 << 0
- UDIS = 1 << 1
- URS = 1 << 2
- OPM = 1 << 3
- DIR = 1 << 4
- CMS = 0x3 << 5
- ARPE = 1 << 7
- CKD = 0x3 << 8
+ CEN = 1 << 0
+ UDIS = 1 << 1
+ URS = 1 << 2
+ OPM = 1 << 3
+ DIR = 1 << 4
+ CMS = 0x3 << 5
+ ARPE = 1 << 7
+ CKD = 0x3 << 8
class TIM_CR2(IntEnum):
- CCPC = 1 << 0
- CCS = 1 << 2
- CCDS = 1 << 3
- MMS = 0x7 << 4
- TI1S = 1 << 7
- OIS1 = 1 << 8
- OIS1N = 1 << 9
- OIS2 = 1 << 10
- OIS2N = 1 << 11
- OIS3 = 1 << 12
- OIS3N = 1 << 13
- OIS4 = 1 << 14
+ CCPC = 1 << 0
+ CCS = 1 << 2
+ CCDS = 1 << 3
+ MMS = 0x7 << 4
+ TI1S = 1 << 7
+ OIS1 = 1 << 8
+ OIS1N = 1 << 9
+ OIS2 = 1 << 10
+ OIS2N = 1 << 11
+ OIS3 = 1 << 12
+ OIS3N = 1 << 13
+ OIS4 = 1 << 14
class TIM_SMCR(IntEnum):
- SMS = 0x7 << 0
- TS = 0x7 << 4
- MSM = 1 << 7
- ETF = 0xf << 8
- ETPS = 0x3 << 12
- ECE = 1 << 14
- ETP = 1 << 15
+ SMS = 0x7 << 0
+ TS = 0x7 << 4
+ MSM = 1 << 7
+ ETF = 0xf << 8
+ ETPS = 0x3 << 12
+ ECE = 1 << 14
+ ETP = 1 << 15
class TIM_DIER(IntEnum):
- UIE = 1 << 0
- CC1IE = 1 << 1
- CC2IE = 1 << 2
- CC3IE = 1 << 3
- CC4IE = 1 << 4
- COMIE = 1 << 5
- TIE = 1 << 6
- BIE = 1 << 7
- UDE = 1 << 8
- CC1DE = 1 << 9
- CC2DE = 1 << 10
- CC3DE = 1 << 11
- CC4DE = 1 << 12
- COMDE = 1 << 13
- TDE = 1 << 14
+ UIE = 1 << 0
+ CC1IE = 1 << 1
+ CC2IE = 1 << 2
+ CC3IE = 1 << 3
+ CC4IE = 1 << 4
+ COMIE = 1 << 5
+ TIE = 1 << 6
+ BIE = 1 << 7
+ UDE = 1 << 8
+ CC1DE = 1 << 9
+ CC2DE = 1 << 10
+ CC3DE = 1 << 11
+ CC4DE = 1 << 12
+ COMDE = 1 << 13
+ TDE = 1 << 14
class TIM_SR(IntEnum):
- UIF = 1 << 0
- CC1IF = 1 << 1
- CC2IF = 1 << 2
- CC3IF = 1 << 3
- CC4IF = 1 << 4
- COMIF = 1 << 5
- TIF = 1 << 6
- BIF = 1 << 7
- CC1OF = 1 << 9
- CC2OF = 1 << 10
- CC3OF = 1 << 11
- CC4OF = 1 << 12
+ UIF = 1 << 0
+ CC1IF = 1 << 1
+ CC2IF = 1 << 2
+ CC3IF = 1 << 3
+ CC4IF = 1 << 4
+ COMIF = 1 << 5
+ TIF = 1 << 6
+ BIF = 1 << 7
+ CC1OF = 1 << 9
+ CC2OF = 1 << 10
+ CC3OF = 1 << 11
+ CC4OF = 1 << 12
class TIM_EGR(IntEnum):
- UG = 1 << 0
- CC1G = 1 << 1
- CC2G = 1 << 2
- CC3G = 1 << 3
- CC4G = 1 << 4
- COMG = 1 << 5
- TG = 1 << 6
- BG = 1 << 7
+ UG = 1 << 0
+ CC1G = 1 << 1
+ CC2G = 1 << 2
+ CC3G = 1 << 3
+ CC4G = 1 << 4
+ COMG = 1 << 5
+ TG = 1 << 6
+ BG = 1 << 7
class TIM_CCMR1(IntEnum):
- CC1S = 0x3 << 0
- OC1FE = 1 << 2
- OC1PE = 1 << 3
- OC1M = 0x7 << 4
- OC1CE = 1 << 7
- CC2S = 0x3 << 8
- OC2FE = 1 << 10
- OC2PE = 1 << 11
- OC2M = 0x7 << 12
- OC2CE = 1 << 15
- IC1PSC = 0x3 << 2
- IC1F = 0xf << 4
- IC2PSC = 0x3 << 10
- IC2F = 0xf << 12
+ CC1S = 0x3 << 0
+ OC1FE = 1 << 2
+ OC1PE = 1 << 3
+ OC1M = 0x7 << 4
+ OC1CE = 1 << 7
+ CC2S = 0x3 << 8
+ OC2FE = 1 << 10
+ OC2PE = 1 << 11
+ OC2M = 0x7 << 12
+ OC2CE = 1 << 15
+ IC1PSC = 0x3 << 2
+ IC1F = 0xf << 4
+ IC2PSC = 0x3 << 10
+ IC2F = 0xf << 12
class TIM_CCMR2(IntEnum):
- CC3S = 0x3 << 0
- OC3FE = 1 << 2
- OC3PE = 1 << 3
- OC3M = 0x7 << 4
- OC3CE = 1 << 7
- CC4S = 0x3 << 8
- OC4FE = 1 << 10
- OC4PE = 1 << 11
- OC4M = 0x7 << 12
- OC4CE = 1 << 15
- IC3PSC = 0x3 << 2
- IC3F = 0xf << 4
- IC4PSC = 0x3 << 10
- IC4F = 0xf << 12
+ CC3S = 0x3 << 0
+ OC3FE = 1 << 2
+ OC3PE = 1 << 3
+ OC3M = 0x7 << 4
+ OC3CE = 1 << 7
+ CC4S = 0x3 << 8
+ OC4FE = 1 << 10
+ OC4PE = 1 << 11
+ OC4M = 0x7 << 12
+ OC4CE = 1 << 15
+ IC3PSC = 0x3 << 2
+ IC3F = 0xf << 4
+ IC4PSC = 0x3 << 10
+ IC4F = 0xf << 12
class TIM_CCER(IntEnum):
- CC1E = 1 << 0
- CC1P = 1 << 1
- CC1NE = 1 << 2
- CC1NP = 1 << 3
- CC2E = 1 << 4
- CC2P = 1 << 5
- CC2NE = 1 << 6
- CC2NP = 1 << 7
- CC3E = 1 << 8
- CC3P = 1 << 9
- CC3NE = 1 << 10
- CC3NP = 1 << 11
- CC4E = 1 << 12
- CC4P = 1 << 13
- CC4NP = 1 << 15
+ CC1E = 1 << 0
+ CC1P = 1 << 1
+ CC1NE = 1 << 2
+ CC1NP = 1 << 3
+ CC2E = 1 << 4
+ CC2P = 1 << 5
+ CC2NE = 1 << 6
+ CC2NP = 1 << 7
+ CC3E = 1 << 8
+ CC3P = 1 << 9
+ CC3NE = 1 << 10
+ CC3NP = 1 << 11
+ CC4E = 1 << 12
+ CC4P = 1 << 13
+ CC4NP = 1 << 15
class TIM_CNT(IntEnum):
- CNT = 0xffffffff << 0
+ CNT = 0xffffffff << 0
class TIM_PSC(IntEnum):
- PSC = 0xffff << 0
+ PSC = 0xffff << 0
class TIM_ARR(IntEnum):
- ARR = 0xffffffff << 0
+ ARR = 0xffffffff << 0
class TIM_RCR(IntEnum):
- REP = 0xff << 0
+ REP = 0xff << 0
class TIM_CCR1(IntEnum):
- CCR1 = 0xffff << 0
+ CCR1 = 0xffff << 0
class TIM_CCR2(IntEnum):
- CCR2 = 0xffff << 0
+ CCR2 = 0xffff << 0
class TIM_CCR3(IntEnum):
- CCR3 = 0xffff << 0
+ CCR3 = 0xffff << 0
class TIM_CCR4(IntEnum):
- CCR4 = 0xffff << 0
+ CCR4 = 0xffff << 0
class TIM_BDTR(IntEnum):
- DTG = 0xff << 0
- LOCK = 0x3 << 8
- OSSI = 1 << 10
- OSSR = 1 << 11
- BKE = 1 << 12
- BKP = 1 << 13
- AOE = 1 << 14
- MOE = 1 << 15
+ DTG = 0xff << 0
+ LOCK = 0x3 << 8
+ OSSI = 1 << 10
+ OSSR = 1 << 11
+ BKE = 1 << 12
+ BKP = 1 << 13
+ AOE = 1 << 14
+ MOE = 1 << 15
class TIM_DCR(IntEnum):
- DBA = 0x1f << 0
- DBL = 0x1f << 8
+ DBA = 0x1f << 0
+ DBL = 0x1f << 8
class TIM_DMAR(IntEnum):
- DMAB = 0xffff << 0
+ DMAB = 0xffff << 0
class TIM_OR(IntEnum):
- TI1_RMP = 0x3 << 0
- TI4_RMP = 0x3 << 6
- ITR1_RMP = 0x3 << 10
+ TI1_RMP = 0x3 << 0
+ TI4_RMP = 0x3 << 6
+ ITR1_RMP = 0x3 << 10
diff --git a/qiling/hw/const/stm32f4xx_usart.py b/qiling/hw/const/stm32f4xx_usart.py
index 669ecd372..9dc8c11f3 100644
--- a/qiling/hw/const/stm32f4xx_usart.py
+++ b/qiling/hw/const/stm32f4xx_usart.py
@@ -20,11 +20,11 @@ class USART_SR(IntEnum):
RESET = TXE | TC
class USART_DR(IntEnum):
- DR = 0x1ff << 0
+ DR = 0x1ff << 0
class USART_BRR(IntEnum):
- DIV_Fraction = 0xf << 0
- DIV_Mantissa = 0xfff << 4
+ DIV_Fraction = 0xf << 0
+ DIV_Mantissa = 0xfff << 4
class USART_CR1(IntEnum):
OVER8 = 1 << 15
@@ -44,30 +44,30 @@ class USART_CR1(IntEnum):
SBK = 1 << 0
class USART_CR2(IntEnum):
- ADD = 0xf << 0
- LBDL = 1 << 5
- LBDIE = 1 << 6
- LBCL = 1 << 8
- CPHA = 1 << 9
- CPOL = 1 << 10
- CLKEN = 1 << 11
- STOP = 0x3 << 12
- LINEN = 1 << 14
+ ADD = 0xf << 0
+ LBDL = 1 << 5
+ LBDIE = 1 << 6
+ LBCL = 1 << 8
+ CPHA = 1 << 9
+ CPOL = 1 << 10
+ CLKEN = 1 << 11
+ STOP = 0x3 << 12
+ LINEN = 1 << 14
class USART_CR3(IntEnum):
- EIE = 1 << 0
- IREN = 1 << 1
- IRLP = 1 << 2
- HDSEL = 1 << 3
- NACK = 1 << 4
- SCEN = 1 << 5
- DMAR = 1 << 6
- DMAT = 1 << 7
- RTSE = 1 << 8
- CTSE = 1 << 9
- CTSIE = 1 << 10
- ONEBIT = 1 << 11
+ EIE = 1 << 0
+ IREN = 1 << 1
+ IRLP = 1 << 2
+ HDSEL = 1 << 3
+ NACK = 1 << 4
+ SCEN = 1 << 5
+ DMAR = 1 << 6
+ DMAT = 1 << 7
+ RTSE = 1 << 8
+ CTSE = 1 << 9
+ CTSIE = 1 << 10
+ ONEBIT = 1 << 11
class USART_GTPR(IntEnum):
- PSC = 0xff << 0
- GT = 0xff << 8
+ PSC = 0xff << 0
+ GT = 0xff << 8
diff --git a/qiling/hw/const/stm32fxxx_rcc.py b/qiling/hw/const/stm32fxxx_rcc.py
index c8ccd0b3e..b1de35ea2 100644
--- a/qiling/hw/const/stm32fxxx_rcc.py
+++ b/qiling/hw/const/stm32fxxx_rcc.py
@@ -27,12 +27,12 @@ class RCC_CR(IntEnum):
class RCC_PLLCFGR(IntEnum):
- PLLM = 0x3f << 0
- PLLN = 0x1ff << 6
- PLLP = 0x3 << 16
- PLLSRC = 1 << 22
- PLLSRC_HSE = 1 << 22
- PLLQ = 0xf << 24
+ PLLM = 0x3f << 0
+ PLLN = 0x1ff << 6
+ PLLP = 0x3 << 16
+ PLLSRC = 1 << 22
+ PLLSRC_HSE = 1 << 22
+ PLLQ = 0xf << 24
class RCC_CFGR(IntEnum):
@@ -56,186 +56,186 @@ class RCC_CFGR(IntEnum):
RW_MASK = SW | HPRE | PPRE1 | PPRE2 | MCO1 | I2SSCR | MCO1PRE | MCO2PRE | MCO2
class RCC_CIR(IntEnum):
- LSIRDYF = 1 << 0
- LSERDYF = 1 << 1
- HSIRDYF = 1 << 2
- HSERDYF = 1 << 3
- PLLRDYF = 1 << 4
- PLLI2SRDYF = 1 << 5
- CSSF = 1 << 7
- LSIRDYIE = 1 << 8
- LSERDYIE = 1 << 9
- HSIRDYIE = 1 << 10
- HSERDYIE = 1 << 11
- PLLRDYIE = 1 << 12
- PLLI2SRDYIE = 1 << 13
- LSIRDYC = 1 << 16
- LSERDYC = 1 << 17
- HSIRDYC = 1 << 18
- HSERDYC = 1 << 19
- PLLRDYC = 1 << 20
- PLLI2SRDYC = 1 << 21
- CSSC = 1 << 23
+ LSIRDYF = 1 << 0
+ LSERDYF = 1 << 1
+ HSIRDYF = 1 << 2
+ HSERDYF = 1 << 3
+ PLLRDYF = 1 << 4
+ PLLI2SRDYF = 1 << 5
+ CSSF = 1 << 7
+ LSIRDYIE = 1 << 8
+ LSERDYIE = 1 << 9
+ HSIRDYIE = 1 << 10
+ HSERDYIE = 1 << 11
+ PLLRDYIE = 1 << 12
+ PLLI2SRDYIE = 1 << 13
+ LSIRDYC = 1 << 16
+ LSERDYC = 1 << 17
+ HSIRDYC = 1 << 18
+ HSERDYC = 1 << 19
+ PLLRDYC = 1 << 20
+ PLLI2SRDYC = 1 << 21
+ CSSC = 1 << 23
class RCC_AHB1RSTR(IntEnum):
- GPIOARST = 1 << 0
- GPIOBRST = 1 << 1
- GPIOCRST = 1 << 2
- GPIODRST = 1 << 3
- GPIOERST = 1 << 4
- GPIOHRST = 1 << 7
- CRCRST = 1 << 12
- DMA1RST = 1 << 21
- DMA2RST = 1 << 22
+ GPIOARST = 1 << 0
+ GPIOBRST = 1 << 1
+ GPIOCRST = 1 << 2
+ GPIODRST = 1 << 3
+ GPIOERST = 1 << 4
+ GPIOHRST = 1 << 7
+ CRCRST = 1 << 12
+ DMA1RST = 1 << 21
+ DMA2RST = 1 << 22
class RCC_AHB2RSTR(IntEnum):
- OTGFSRST = 1 << 7
+ OTGFSRST = 1 << 7
class RCC_APB1RSTR(IntEnum):
- TIM2RST = 1 << 0
- TIM3RST = 1 << 1
- TIM4RST = 1 << 2
- TIM5RST = 1 << 3
- WWDGRST = 1 << 11
- SPI2RST = 1 << 14
- SPI3RST = 1 << 15
- USART2RST = 1 << 17
- I2C1RST = 1 << 21
- I2C2RST = 1 << 22
- I2C3RST = 1 << 23
- PWRRST = 1 << 28
+ TIM2RST = 1 << 0
+ TIM3RST = 1 << 1
+ TIM4RST = 1 << 2
+ TIM5RST = 1 << 3
+ WWDGRST = 1 << 11
+ SPI2RST = 1 << 14
+ SPI3RST = 1 << 15
+ USART2RST = 1 << 17
+ I2C1RST = 1 << 21
+ I2C2RST = 1 << 22
+ I2C3RST = 1 << 23
+ PWRRST = 1 << 28
class RCC_APB2RSTR(IntEnum):
- TIM1RST = 1 << 0
- USART1RST = 1 << 4
- USART6RST = 1 << 5
- ADCRST = 1 << 8
- SDIORST = 1 << 11
- SPI1RST = 1 << 12
- SPI4RST = 1 << 13
- SYSCFGRST = 1 << 14
- TIM9RST = 1 << 16
- TIM10RST = 1 << 17
- TIM11RST = 1 << 18
- SPI5RST = 1 << 20
+ TIM1RST = 1 << 0
+ USART1RST = 1 << 4
+ USART6RST = 1 << 5
+ ADCRST = 1 << 8
+ SDIORST = 1 << 11
+ SPI1RST = 1 << 12
+ SPI4RST = 1 << 13
+ SYSCFGRST = 1 << 14
+ TIM9RST = 1 << 16
+ TIM10RST = 1 << 17
+ TIM11RST = 1 << 18
+ SPI5RST = 1 << 20
class RCC_AHB1ENR(IntEnum):
- GPIOAEN = 1 << 0
- GPIOBEN = 1 << 1
- GPIOCEN = 1 << 2
- GPIODEN = 1 << 3
- GPIOEEN = 1 << 4
- GPIOHEN = 1 << 7
- CRCEN = 1 << 12
- DMA1EN = 1 << 21
- DMA2EN = 1 << 22
+ GPIOAEN = 1 << 0
+ GPIOBEN = 1 << 1
+ GPIOCEN = 1 << 2
+ GPIODEN = 1 << 3
+ GPIOEEN = 1 << 4
+ GPIOHEN = 1 << 7
+ CRCEN = 1 << 12
+ DMA1EN = 1 << 21
+ DMA2EN = 1 << 22
class RCC_AHB2ENR(IntEnum):
- OTGFSEN = 1 << 7
+ OTGFSEN = 1 << 7
class RCC_APB1ENR(IntEnum):
- TIM2EN = 1 << 0
- TIM3EN = 1 << 1
- TIM4EN = 1 << 2
- TIM5EN = 1 << 3
- WWDGEN = 1 << 11
- SPI2EN = 1 << 14
- SPI3EN = 1 << 15
- USART2EN = 1 << 17
- I2C1EN = 1 << 21
- I2C2EN = 1 << 22
- I2C3EN = 1 << 23
- PWREN = 1 << 28
+ TIM2EN = 1 << 0
+ TIM3EN = 1 << 1
+ TIM4EN = 1 << 2
+ TIM5EN = 1 << 3
+ WWDGEN = 1 << 11
+ SPI2EN = 1 << 14
+ SPI3EN = 1 << 15
+ USART2EN = 1 << 17
+ I2C1EN = 1 << 21
+ I2C2EN = 1 << 22
+ I2C3EN = 1 << 23
+ PWREN = 1 << 28
class RCC_APB2ENR(IntEnum):
- TIM1EN = 1 << 0
- USART1EN = 1 << 4
- USART6EN = 1 << 5
- ADC1EN = 1 << 8
- SDIOEN = 1 << 11
- SPI1EN = 1 << 12
- SPI4EN = 1 << 13
- SYSCFGEN = 1 << 14
- TIM9EN = 1 << 16
- TIM10EN = 1 << 17
- TIM11EN = 1 << 18
- SPI5EN = 1 << 20
+ TIM1EN = 1 << 0
+ USART1EN = 1 << 4
+ USART6EN = 1 << 5
+ ADC1EN = 1 << 8
+ SDIOEN = 1 << 11
+ SPI1EN = 1 << 12
+ SPI4EN = 1 << 13
+ SYSCFGEN = 1 << 14
+ TIM9EN = 1 << 16
+ TIM10EN = 1 << 17
+ TIM11EN = 1 << 18
+ SPI5EN = 1 << 20
class RCC_AHB1LPENR(IntEnum):
- GPIOALPEN = 1 << 0
- GPIOBLPEN = 1 << 1
- GPIOCLPEN = 1 << 2
- GPIODLPEN = 1 << 3
- GPIOELPEN = 1 << 4
- GPIOHLPEN = 1 << 7
- CRCLPEN = 1 << 12
- FLITFLPEN = 1 << 15
- SRAM1LPEN = 1 << 16
- DMA1LPEN = 1 << 21
- DMA2LPEN = 1 << 22
+ GPIOALPEN = 1 << 0
+ GPIOBLPEN = 1 << 1
+ GPIOCLPEN = 1 << 2
+ GPIODLPEN = 1 << 3
+ GPIOELPEN = 1 << 4
+ GPIOHLPEN = 1 << 7
+ CRCLPEN = 1 << 12
+ FLITFLPEN = 1 << 15
+ SRAM1LPEN = 1 << 16
+ DMA1LPEN = 1 << 21
+ DMA2LPEN = 1 << 22
class RCC_AHB2LPENR(IntEnum):
- OTGFSLPEN = 1 << 7
+ OTGFSLPEN = 1 << 7
class RCC_APB1LPENR(IntEnum):
- TIM2LPEN = 1 << 0
- TIM3LPEN = 1 << 1
- TIM4LPEN = 1 << 2
- TIM5LPEN = 1 << 3
- WWDGLPEN = 1 << 11
- SPI2LPEN = 1 << 14
- SPI3LPEN = 1 << 15
- USART2LPEN = 1 << 17
- I2C1LPEN = 1 << 21
- I2C2LPEN = 1 << 22
- I2C3LPEN = 1 << 23
- PWRLPEN = 1 << 28
+ TIM2LPEN = 1 << 0
+ TIM3LPEN = 1 << 1
+ TIM4LPEN = 1 << 2
+ TIM5LPEN = 1 << 3
+ WWDGLPEN = 1 << 11
+ SPI2LPEN = 1 << 14
+ SPI3LPEN = 1 << 15
+ USART2LPEN = 1 << 17
+ I2C1LPEN = 1 << 21
+ I2C2LPEN = 1 << 22
+ I2C3LPEN = 1 << 23
+ PWRLPEN = 1 << 28
class RCC_APB2LPENR(IntEnum):
- TIM1LPEN = 1 << 0
- USART1LPEN = 1 << 4
- USART6LPEN = 1 << 5
- ADC1LPEN = 1 << 8
- SDIOLPEN = 1 << 11
- SPI1LPEN = 1 << 12
- SPI4LPEN = 1 << 13
- SYSCFGLPEN = 1 << 14
- TIM9LPEN = 1 << 16
- TIM10LPEN = 1 << 17
- TIM11LPEN = 1 << 18
- SPI5LPEN = 1 << 20
+ TIM1LPEN = 1 << 0
+ USART1LPEN = 1 << 4
+ USART6LPEN = 1 << 5
+ ADC1LPEN = 1 << 8
+ SDIOLPEN = 1 << 11
+ SPI1LPEN = 1 << 12
+ SPI4LPEN = 1 << 13
+ SYSCFGLPEN = 1 << 14
+ TIM9LPEN = 1 << 16
+ TIM10LPEN = 1 << 17
+ TIM11LPEN = 1 << 18
+ SPI5LPEN = 1 << 20
class RCC_BDCR(IntEnum):
- LSEON = 1 << 0
- LSERDY = 1 << 1
- LSEBYP = 1 << 2
- LSEMOD = 1 << 3
- RTCSEL = 0x3 << 8
- RTCEN = 1 << 15
- BDRST = 1 << 16
+ LSEON = 1 << 0
+ LSERDY = 1 << 1
+ LSEBYP = 1 << 2
+ LSEMOD = 1 << 3
+ RTCSEL = 0x3 << 8
+ RTCEN = 1 << 15
+ BDRST = 1 << 16
class RCC_CSR(IntEnum):
- LSION = 1 << 0
- LSIRDY = 1 << 1
- RMVF = 1 << 24
- BORRSTF = 1 << 25
- PINRSTF = 1 << 26
- PORRSTF = 1 << 27
- SFTRSTF = 1 << 28
- IWDGRSTF = 1 << 29
- WWDGRSTF = 1 << 30
- LPWRRSTF = 1 << 31
+ LSION = 1 << 0
+ LSIRDY = 1 << 1
+ RMVF = 1 << 24
+ BORRSTF = 1 << 25
+ PINRSTF = 1 << 26
+ PORRSTF = 1 << 27
+ SFTRSTF = 1 << 28
+ IWDGRSTF = 1 << 29
+ WWDGRSTF = 1 << 30
+ LPWRRSTF = 1 << 31
class RCC_SSCGR(IntEnum):
- MODPER = 0x1fff << 0
- INCSTEP = 0x7fff << 13
- SPREADSEL = 1 << 30
- SSCGEN = 1 << 31
+ MODPER = 0x1fff << 0
+ INCSTEP = 0x7fff << 13
+ SPREADSEL = 1 << 30
+ SSCGEN = 1 << 31
class RCC_PLLI2SCFGR(IntEnum):
- PLLI2SM = 0x3f << 0
- PLLI2SN = 0x1ff << 6
- PLLI2SR = 0x7 << 28
+ PLLI2SM = 0x3f << 0
+ PLLI2SN = 0x1ff << 6
+ PLLI2SR = 0x7 << 28
class RCC_DCKCFGR(IntEnum):
- TIMPRE = 1 << 24
+ TIMPRE = 1 << 24
diff --git a/qiling/hw/dma/stm32f4xx_dma.py b/qiling/hw/dma/stm32f4xx_dma.py
index 32443ee71..e65a7a932 100644
--- a/qiling/hw/dma/stm32f4xx_dma.py
+++ b/qiling/hw/dma/stm32f4xx_dma.py
@@ -69,36 +69,36 @@ def step(self, mem):
class STM32F4xxDma(QlPeripheral):
class Type(ctypes.Structure):
""" the structure available in :
- stm32f413xx.h
- stm32f407xx.h
- stm32f469xx.h
- stm32f446xx.h
- stm32f427xx.h
- stm32f401xc.h
- stm32f415xx.h
- stm32f412cx.h
- stm32f410rx.h
- stm32f410tx.h
- stm32f439xx.h
- stm32f412vx.h
- stm32f417xx.h
- stm32f479xx.h
- stm32f429xx.h
- stm32f412rx.h
- stm32f423xx.h
- stm32f437xx.h
- stm32f412zx.h
- stm32f401xe.h
- stm32f410cx.h
- stm32f405xx.h
- stm32f411xe.h
- """
+ stm32f413xx.h
+ stm32f407xx.h
+ stm32f469xx.h
+ stm32f446xx.h
+ stm32f427xx.h
+ stm32f401xc.h
+ stm32f415xx.h
+ stm32f412cx.h
+ stm32f410rx.h
+ stm32f410tx.h
+ stm32f439xx.h
+ stm32f412vx.h
+ stm32f417xx.h
+ stm32f479xx.h
+ stm32f429xx.h
+ stm32f412rx.h
+ stm32f423xx.h
+ stm32f437xx.h
+ stm32f412zx.h
+ stm32f401xe.h
+ stm32f410cx.h
+ stm32f405xx.h
+ stm32f411xe.h
+ """
_fields_ = [
- ('LISR' , ctypes.c_uint32), # DMA low interrupt status register, Address offset: 0x00
- ('HISR' , ctypes.c_uint32), # DMA high interrupt status register, Address offset: 0x04
- ('LIFCR', ctypes.c_uint32), # DMA low interrupt flag clear register, Address offset: 0x08
- ('HIFCR', ctypes.c_uint32), # DMA high interrupt flag clear register, Address offset: 0x0C
+ ('LISR' , ctypes.c_uint32), # DMA low interrupt status register, Address offset: 0x00
+ ('HISR' , ctypes.c_uint32), # DMA high interrupt status register, Address offset: 0x04
+ ('LIFCR', ctypes.c_uint32), # DMA low interrupt flag clear register, Address offset: 0x08
+ ('HIFCR', ctypes.c_uint32), # DMA high interrupt flag clear register, Address offset: 0x0C
('stream', Stream * 8),
]
diff --git a/qiling/hw/flash/stm32f1xx_flash.py b/qiling/hw/flash/stm32f1xx_flash.py
index fd69cfdb7..20c769fd9 100644
--- a/qiling/hw/flash/stm32f1xx_flash.py
+++ b/qiling/hw/flash/stm32f1xx_flash.py
@@ -43,7 +43,7 @@ def __init__(self, ql: Qiling, label: str, intn: int = None):
self.instance = self.struct()
@QlPeripheral.monitor()
- def read(self, offset: int, size: int) -> int:
+ def read(self, offset: int, size: int) -> int:
buf = ctypes.create_string_buffer(size)
ctypes.memmove(buf, ctypes.addressof(self.instance) + offset, size)
return int.from_bytes(buf.raw, byteorder='little')
diff --git a/qiling/hw/flash/stm32f4xx_flash.py b/qiling/hw/flash/stm32f4xx_flash.py
index 389dd1322..753a9fd4b 100644
--- a/qiling/hw/flash/stm32f4xx_flash.py
+++ b/qiling/hw/flash/stm32f4xx_flash.py
@@ -55,7 +55,7 @@ def __init__(self, ql: Qiling, label: str, intn: int = None):
self.instance = self.struct()
@QlPeripheral.monitor()
- def read(self, offset: int, size: int) -> int:
+ def read(self, offset: int, size: int) -> int:
buf = ctypes.create_string_buffer(size)
ctypes.memmove(buf, ctypes.addressof(self.instance) + offset, size)
return int.from_bytes(buf.raw, byteorder='little')
diff --git a/qiling/hw/gpio/gd32vf1xx_gpio.py b/qiling/hw/gpio/gd32vf1xx_gpio.py
index 40be4c669..087500f10 100644
--- a/qiling/hw/gpio/gd32vf1xx_gpio.py
+++ b/qiling/hw/gpio/gd32vf1xx_gpio.py
@@ -39,7 +39,7 @@ def __init__(self, ql, label):
)
@QlPeripheral.monitor()
- def read(self, offset: int, size: int) -> int:
+ def read(self, offset: int, size: int) -> int:
buf = ctypes.create_string_buffer(size)
ctypes.memmove(buf, ctypes.addressof(self.instance) + offset, size)
return int.from_bytes(buf.raw, byteorder='little')
diff --git a/qiling/hw/gpio/stm32f1xx_afio.py b/qiling/hw/gpio/stm32f1xx_afio.py
index ac2ec27ad..aa6d7fbdc 100644
--- a/qiling/hw/gpio/stm32f1xx_afio.py
+++ b/qiling/hw/gpio/stm32f1xx_afio.py
@@ -38,7 +38,7 @@ def __init__(self, ql, label):
self.instance = self.struct()
@QlPeripheral.monitor()
- def read(self, offset: int, size: int) -> int:
+ def read(self, offset: int, size: int) -> int:
buf = ctypes.create_string_buffer(size)
ctypes.memmove(buf, ctypes.addressof(self.instance) + offset, size)
return int.from_bytes(buf.raw, byteorder='little')
diff --git a/qiling/hw/gpio/stm32f4xx_gpio.py b/qiling/hw/gpio/stm32f4xx_gpio.py
index 69d875265..1df97cebf 100644
--- a/qiling/hw/gpio/stm32f4xx_gpio.py
+++ b/qiling/hw/gpio/stm32f4xx_gpio.py
@@ -36,7 +36,7 @@ class Type(ctypes.Structure):
stm32f410cx.h
stm32f405xx.h
stm32f411xe.h
- """
+ """
_fields_ = [
('MODER' , ctypes.c_uint32), # GPIO port mode register, Address offset: 0x00
diff --git a/qiling/hw/i2c/stm32f4xx_i2c.py b/qiling/hw/i2c/stm32f4xx_i2c.py
index 8d6dbe870..280c20184 100644
--- a/qiling/hw/i2c/stm32f4xx_i2c.py
+++ b/qiling/hw/i2c/stm32f4xx_i2c.py
@@ -13,226 +13,226 @@
class STM32F4xxI2c(QlConnectivityPeripheral):
- class Type(ctypes.Structure):
- """ the structure is available in :
- stm32f423xx.h
- stm32f469xx.h
- stm32f427xx.h
- stm32f479xx.h
- stm32f413xx.h
- stm32f429xx.h
- stm32f439xx.h
- stm32f412cx.h
- stm32f412rx.h
- stm32f410tx.h
- stm32f410cx.h
- stm32f412zx.h
- stm32f446xx.h
- stm32f401xc.h
- stm32f437xx.h
- stm32f401xe.h
- stm32f412vx.h
- stm32f410rx.h
- stm32f411xe.h
- """
-
- _fields_ = [
- ('CR1' , ctypes.c_uint32), # I2C Control register 1, Address offset: 0x00
- ('CR2' , ctypes.c_uint32), # I2C Control register 2, Address offset: 0x04
- ('OAR1' , ctypes.c_uint32), # I2C Own address register 1, Address offset: 0x08
- ('OAR2' , ctypes.c_uint32), # I2C Own address register 2, Address offset: 0x0C
- ('DR' , ctypes.c_uint32), # I2C Data register, Address offset: 0x10
- ('SR1' , ctypes.c_uint32), # I2C Status register 1, Address offset: 0x14
- ('SR2' , ctypes.c_uint32), # I2C Status register 2, Address offset: 0x18
- ('CCR' , ctypes.c_uint32), # I2C Clock control register, Address offset: 0x1C
- ('TRISE', ctypes.c_uint32), # I2C TRISE register, Address offset: 0x20
- ('FLTR' , ctypes.c_uint32), # I2C FLTR register, Address offset: 0x24
- ]
-
- def __init__(self, ql, label, ev_intn=None, er_intn=None):
- super().__init__(ql, label, 2)
-
- self.history = AccessSequence()
-
- self.ev_intn = ev_intn # event interrupt
- self.er_intn = er_intn # error interrupt
-
- self.reset()
-
- def reset(self):
- self.instance = self.struct(
- TRISE = 0x0002
- )
-
- @QlPeripheral.recorder()
- @QlPeripheral.monitor()
- def read(self, offset: int, size: int) -> int:
- buf = ctypes.create_string_buffer(size)
- ctypes.memmove(buf, ctypes.addressof(self.instance) + offset, size)
-
- if self.history.match([
- Access(Action.READ, self.struct.SR1.offset),
- Access(Action.READ, self.struct.SR2.offset)
- ]):
- self.instance.SR1 &= ~I2C_SR1.ADDR
-
- return int.from_bytes(buf.raw, byteorder='little')
-
- @QlPeripheral.recorder()
- @QlPeripheral.monitor()
- def write(self, offset: int, size: int, value: int):
- if offset in [self.struct.SR1.offset, self.struct.SR2.offset]:
- return
-
- if offset == self.struct.CR1.offset:
- self.instance.CR1 = value & I2C_CR1.RW_MASK
-
- if value & I2C_CR1.START:
- self.generate_start()
-
- if value & I2C_CR1.STOP:
- self.generate_stop()
-
- return
-
- if offset == self.struct.DR.offset:
- self.instance.DR = value & I2C_DR.DR
- self.instance.SR1 &= ~I2C_SR1.TXE
-
- if self.is_master_mode():
- if self.is_7bit_mode():
- if self.instance.SR2 & I2C_SR2.TRA:
- self.send_data()
-
- else:
- self.send_address()
-
- # TODO 10-bit mode
-
- return
-
- data = (value).to_bytes(size, 'little')
- ctypes.memmove(ctypes.addressof(self.instance) + offset, data, size)
-
- ## I2C Control register 2 (I2C_CR2)
- def send_event_interrupt(self):
- """
- ITBUFEN: Buffer interrupt enable
- 0: TxE = 1 or RxNE = 1 does not generate any interrupt.
- 1: TxE = 1 or RxNE = 1 generates Event Interrupt (whatever the state of DMAEN)
-
- ITEVTEN: Event interrupt enable
- 0: Event interrupt disabled
- 1: Event interrupt enabled
- This interrupt is generated when:
- - SB = 1 (Master)
- - ADDR = 1 (Master/Slave)
- - ADD10= 1 (Master)
- - STOPF = 1 (Slave)
- - BTF = 1 with no TxE or RxNE event
- - TxE event to 1 if ITBUFEN = 1
- - RxNE event to 1if ITBUFEN = 1
- """
- if self.ev_intn is None:
- return
-
- if not self.instance.CR2 & I2C_CR2.ITEVTEN:
- return
-
- BUF_IT = I2C_SR1.TXE|I2C_SR1.RXNE
- SLAVE_IT = I2C_SR1.STOPF|I2C_SR1.ADDR|I2C_SR1.BTF
- MASTER_IT = I2C_SR1.SB|I2C_SR1.ADDR|I2C_SR1.ADD10|I2C_SR1.BTF
-
- if (self.instance.CR2 & I2C_CR2.ITBUFEN and self.instance.SR1 & BUF_IT) or \
- (self.is_slave_mode() and self.instance.SR1 & SLAVE_IT) or \
- (self.is_master_mode() and self.instance.SR1 & MASTER_IT):
- self.ql.hw.nvic.set_pending(self.ev_intn)
-
- ## I2C Status register 1 (I2C_SR1)
- def generate_start(self):
- """
- SB: Start bit (Master mode)
- 0: No Start condition
- 1: Start condition generated.
- - Set when a Start condition generated.
- - Cleared by software by reading the SR1 register followed by writing the DR register, or by hardware when PE=0
- """
-
- # TODO: generate a start condition
- self.fetch_device_address()
- self.instance.SR1 |= I2C_SR1.SB
- self.instance.CR1 &= ~I2C_CR1.START
-
- self.set_master_mode()
-
- def generate_stop(self):
- # TODO: generate a stop condition
- self.instance.CR1 &= ~I2C_CR1.STOP
-
- self.instance.SR1 |= I2C_SR1.STOPF
- self.instance.SR1 &= ~I2C_SR1.ADDR
-
- self.set_slave_mode()
- self.instance.SR2 &= ~I2C_SR2.TRA
-
- def send_address(self):
- if self.instance.DR == self.instance.OAR1 >> 1:
-
- # TODO: send ACK
- self.instance.SR1 &= ~I2C_SR1.SB
- self.instance.SR1 |= I2C_SR1.ADDR | I2C_SR1.TXE | I2C_SR1.AF
- self.instance.SR2 |= I2C_SR2.TRA
-
- def send_data(self):
- self.instance.SR1 |= I2C_SR1.BTF | I2C_SR1.TXE
-
- self.send_to_user(self.instance.DR)
-
- ## I2C Status register 2 (I2C_SR2)
- def is_master_mode(self):
- """
- I2C Status register 2 (I2C_SR2) MSL bit
- 0: Slave Mode
- 1: Master Mode
- """
- return self.instance.SR2 & I2C_SR2.MSL
-
- def is_slave_mode(self):
- return not self.is_master_mode()
-
- def set_master_mode(self):
- """
- I2C Status register 2 (I2C_SR2) MSL bit
- - Set by hardware as soon as the interface is in Master mode (SB=1)
- """
- self.instance.SR2 |= I2C_SR2.MSL
-
- def set_slave_mode(self):
- """
- I2C Status register 2 (I2C_SR2) MSL bit
- - Cleared by hardware after detecting a Stop condition on the bus
- or a loss of arbitration (ARLO=1), or by hardware when PE=0.
- """
- self.instance.SR2 &= ~I2C_SR2.MSL
-
- ## I2C Own address register 1 (I2C_OAR1)
- def is_7bit_mode(self):
- return self.instance.OAR2 & I2C_OAR2.ENDUAL or not self.instance.OAR1 & I2C_OAR1.ADDMODE
-
- def fetch_device_address(self):
- # dual addressing mode
- if self.instance.OAR2 & I2C_OAR2.ENDUAL:
- self.instance.OAR1 = self.device_list[0].address << 1
- self.instance.OAR2 = I2C_OAR2.ENDUAL | (self.device_list[1].address << 1)
-
- # single device, 10-bit slave address
- elif self.instance.OAR1 & I2C_OAR1.ADDMODE:
- self.instance.OAR1 = I2C_OAR1.ADDMODE | self.device_list[0].address
-
- # single device, 7-bit slave address
- else:
- self.instance.OAR1 = self.device_list[0].address << 1
-
- @QlConnectivityPeripheral.device_handler
- def step(self):
- self.send_event_interrupt()
+ class Type(ctypes.Structure):
+ """ the structure is available in :
+ stm32f423xx.h
+ stm32f469xx.h
+ stm32f427xx.h
+ stm32f479xx.h
+ stm32f413xx.h
+ stm32f429xx.h
+ stm32f439xx.h
+ stm32f412cx.h
+ stm32f412rx.h
+ stm32f410tx.h
+ stm32f410cx.h
+ stm32f412zx.h
+ stm32f446xx.h
+ stm32f401xc.h
+ stm32f437xx.h
+ stm32f401xe.h
+ stm32f412vx.h
+ stm32f410rx.h
+ stm32f411xe.h
+ """
+
+ _fields_ = [
+ ('CR1' , ctypes.c_uint32), # I2C Control register 1, Address offset: 0x00
+ ('CR2' , ctypes.c_uint32), # I2C Control register 2, Address offset: 0x04
+ ('OAR1' , ctypes.c_uint32), # I2C Own address register 1, Address offset: 0x08
+ ('OAR2' , ctypes.c_uint32), # I2C Own address register 2, Address offset: 0x0C
+ ('DR' , ctypes.c_uint32), # I2C Data register, Address offset: 0x10
+ ('SR1' , ctypes.c_uint32), # I2C Status register 1, Address offset: 0x14
+ ('SR2' , ctypes.c_uint32), # I2C Status register 2, Address offset: 0x18
+ ('CCR' , ctypes.c_uint32), # I2C Clock control register, Address offset: 0x1C
+ ('TRISE', ctypes.c_uint32), # I2C TRISE register, Address offset: 0x20
+ ('FLTR' , ctypes.c_uint32), # I2C FLTR register, Address offset: 0x24
+ ]
+
+ def __init__(self, ql, label, ev_intn=None, er_intn=None):
+ super().__init__(ql, label, 2)
+
+ self.history = AccessSequence()
+
+ self.ev_intn = ev_intn # event interrupt
+ self.er_intn = er_intn # error interrupt
+
+ self.reset()
+
+ def reset(self):
+ self.instance = self.struct(
+ TRISE = 0x0002
+ )
+
+ @QlPeripheral.recorder()
+ @QlPeripheral.monitor()
+ def read(self, offset: int, size: int) -> int:
+ buf = ctypes.create_string_buffer(size)
+ ctypes.memmove(buf, ctypes.addressof(self.instance) + offset, size)
+
+ if self.history.match([
+ Access(Action.READ, self.struct.SR1.offset),
+ Access(Action.READ, self.struct.SR2.offset)
+ ]):
+ self.instance.SR1 &= ~I2C_SR1.ADDR
+
+ return int.from_bytes(buf.raw, byteorder='little')
+
+ @QlPeripheral.recorder()
+ @QlPeripheral.monitor()
+ def write(self, offset: int, size: int, value: int):
+ if offset in [self.struct.SR1.offset, self.struct.SR2.offset]:
+ return
+
+ if offset == self.struct.CR1.offset:
+ self.instance.CR1 = value & I2C_CR1.RW_MASK
+
+ if value & I2C_CR1.START:
+ self.generate_start()
+
+ if value & I2C_CR1.STOP:
+ self.generate_stop()
+
+ return
+
+ if offset == self.struct.DR.offset:
+ self.instance.DR = value & I2C_DR.DR
+ self.instance.SR1 &= ~I2C_SR1.TXE
+
+ if self.is_master_mode():
+ if self.is_7bit_mode():
+ if self.instance.SR2 & I2C_SR2.TRA:
+ self.send_data()
+
+ else:
+ self.send_address()
+
+ # TODO 10-bit mode
+
+ return
+
+ data = (value).to_bytes(size, 'little')
+ ctypes.memmove(ctypes.addressof(self.instance) + offset, data, size)
+
+ ## I2C Control register 2 (I2C_CR2)
+ def send_event_interrupt(self):
+ """
+ ITBUFEN: Buffer interrupt enable
+ 0: TxE = 1 or RxNE = 1 does not generate any interrupt.
+ 1: TxE = 1 or RxNE = 1 generates Event Interrupt (whatever the state of DMAEN)
+
+ ITEVTEN: Event interrupt enable
+ 0: Event interrupt disabled
+ 1: Event interrupt enabled
+ This interrupt is generated when:
+ - SB = 1 (Master)
+ - ADDR = 1 (Master/Slave)
+ - ADD10= 1 (Master)
+ - STOPF = 1 (Slave)
+ - BTF = 1 with no TxE or RxNE event
+ - TxE event to 1 if ITBUFEN = 1
+ - RxNE event to 1if ITBUFEN = 1
+ """
+ if self.ev_intn is None:
+ return
+
+ if not self.instance.CR2 & I2C_CR2.ITEVTEN:
+ return
+
+ BUF_IT = I2C_SR1.TXE|I2C_SR1.RXNE
+ SLAVE_IT = I2C_SR1.STOPF|I2C_SR1.ADDR|I2C_SR1.BTF
+ MASTER_IT = I2C_SR1.SB|I2C_SR1.ADDR|I2C_SR1.ADD10|I2C_SR1.BTF
+
+ if (self.instance.CR2 & I2C_CR2.ITBUFEN and self.instance.SR1 & BUF_IT) or \
+ (self.is_slave_mode() and self.instance.SR1 & SLAVE_IT) or \
+ (self.is_master_mode() and self.instance.SR1 & MASTER_IT):
+ self.ql.hw.nvic.set_pending(self.ev_intn)
+
+ ## I2C Status register 1 (I2C_SR1)
+ def generate_start(self):
+ """
+ SB: Start bit (Master mode)
+ 0: No Start condition
+ 1: Start condition generated.
+ - Set when a Start condition generated.
+ - Cleared by software by reading the SR1 register followed by writing the DR register, or by hardware when PE=0
+ """
+
+ # TODO: generate a start condition
+ self.fetch_device_address()
+ self.instance.SR1 |= I2C_SR1.SB
+ self.instance.CR1 &= ~I2C_CR1.START
+
+ self.set_master_mode()
+
+ def generate_stop(self):
+ # TODO: generate a stop condition
+ self.instance.CR1 &= ~I2C_CR1.STOP
+
+ self.instance.SR1 |= I2C_SR1.STOPF
+ self.instance.SR1 &= ~I2C_SR1.ADDR
+
+ self.set_slave_mode()
+ self.instance.SR2 &= ~I2C_SR2.TRA
+
+ def send_address(self):
+ if self.instance.DR == self.instance.OAR1 >> 1:
+
+ # TODO: send ACK
+ self.instance.SR1 &= ~I2C_SR1.SB
+ self.instance.SR1 |= I2C_SR1.ADDR | I2C_SR1.TXE | I2C_SR1.AF
+ self.instance.SR2 |= I2C_SR2.TRA
+
+ def send_data(self):
+ self.instance.SR1 |= I2C_SR1.BTF | I2C_SR1.TXE
+
+ self.send_to_user(self.instance.DR)
+
+ ## I2C Status register 2 (I2C_SR2)
+ def is_master_mode(self):
+ """
+ I2C Status register 2 (I2C_SR2) MSL bit
+ 0: Slave Mode
+ 1: Master Mode
+ """
+ return self.instance.SR2 & I2C_SR2.MSL
+
+ def is_slave_mode(self):
+ return not self.is_master_mode()
+
+ def set_master_mode(self):
+ """
+ I2C Status register 2 (I2C_SR2) MSL bit
+ - Set by hardware as soon as the interface is in Master mode (SB=1)
+ """
+ self.instance.SR2 |= I2C_SR2.MSL
+
+ def set_slave_mode(self):
+ """
+ I2C Status register 2 (I2C_SR2) MSL bit
+ - Cleared by hardware after detecting a Stop condition on the bus
+ or a loss of arbitration (ARLO=1), or by hardware when PE=0.
+ """
+ self.instance.SR2 &= ~I2C_SR2.MSL
+
+ ## I2C Own address register 1 (I2C_OAR1)
+ def is_7bit_mode(self):
+ return self.instance.OAR2 & I2C_OAR2.ENDUAL or not self.instance.OAR1 & I2C_OAR1.ADDMODE
+
+ def fetch_device_address(self):
+ # dual addressing mode
+ if self.instance.OAR2 & I2C_OAR2.ENDUAL:
+ self.instance.OAR1 = self.device_list[0].address << 1
+ self.instance.OAR2 = I2C_OAR2.ENDUAL | (self.device_list[1].address << 1)
+
+ # single device, 10-bit slave address
+ elif self.instance.OAR1 & I2C_OAR1.ADDMODE:
+ self.instance.OAR1 = I2C_OAR1.ADDMODE | self.device_list[0].address
+
+ # single device, 7-bit slave address
+ else:
+ self.instance.OAR1 = self.device_list[0].address << 1
+
+ @QlConnectivityPeripheral.device_handler
+ def step(self):
+ self.send_event_interrupt()
diff --git a/qiling/hw/intc/gd32vf1xx_eclic.py b/qiling/hw/intc/gd32vf1xx_eclic.py
index 2c57383bb..1ac5e084c 100644
--- a/qiling/hw/intc/gd32vf1xx_eclic.py
+++ b/qiling/hw/intc/gd32vf1xx_eclic.py
@@ -725,7 +725,7 @@ def __init__(self, ql, label):
)
@QlPeripheral.monitor()
- def read(self, offset: int, size: int) -> int:
+ def read(self, offset: int, size: int) -> int:
buf = ctypes.create_string_buffer(size)
ctypes.memmove(buf, ctypes.addressof(self.instance) + offset, size)
return int.from_bytes(buf.raw, byteorder='little')
diff --git a/qiling/hw/intc/stm32f1xx_exti.py b/qiling/hw/intc/stm32f1xx_exti.py
index 7dc3e1276..df9e1a92e 100644
--- a/qiling/hw/intc/stm32f1xx_exti.py
+++ b/qiling/hw/intc/stm32f1xx_exti.py
@@ -53,7 +53,7 @@ def __init__(self, ql, label,
]
@QlPeripheral.monitor()
- def read(self, offset: int, size: int) -> int:
+ def read(self, offset: int, size: int) -> int:
buf = ctypes.create_string_buffer(size)
ctypes.memmove(buf, ctypes.addressof(self.instance) + offset, size)
return int.from_bytes(buf.raw, byteorder='little')
diff --git a/qiling/hw/intc/stm32f4xx_exti.py b/qiling/hw/intc/stm32f4xx_exti.py
index b9ad8f93f..8bd5d72ad 100644
--- a/qiling/hw/intc/stm32f4xx_exti.py
+++ b/qiling/hw/intc/stm32f4xx_exti.py
@@ -10,36 +10,36 @@
class STM32F4xxExti(QlPeripheral):
class Type(ctypes.Structure):
""" the structure available in :
- stm32f413xx.h
- stm32f407xx.h
- stm32f469xx.h
- stm32f446xx.h
- stm32f427xx.h
- stm32f401xc.h
- stm32f415xx.h
- stm32f412cx.h
- stm32f410rx.h
- stm32f410tx.h
- stm32f439xx.h
- stm32f412vx.h
- stm32f417xx.h
- stm32f479xx.h
- stm32f429xx.h
- stm32f412rx.h
- stm32f423xx.h
- stm32f437xx.h
- stm32f412zx.h
- stm32f401xe.h
- stm32f410cx.h
- stm32f405xx.h
- stm32f411xe.h
- """
+ stm32f413xx.h
+ stm32f407xx.h
+ stm32f469xx.h
+ stm32f446xx.h
+ stm32f427xx.h
+ stm32f401xc.h
+ stm32f415xx.h
+ stm32f412cx.h
+ stm32f410rx.h
+ stm32f410tx.h
+ stm32f439xx.h
+ stm32f412vx.h
+ stm32f417xx.h
+ stm32f479xx.h
+ stm32f429xx.h
+ stm32f412rx.h
+ stm32f423xx.h
+ stm32f437xx.h
+ stm32f412zx.h
+ stm32f401xe.h
+ stm32f410cx.h
+ stm32f405xx.h
+ stm32f411xe.h
+ """
_fields_ = [
- ('IMR' , ctypes.c_uint32), # EXTI Interrupt mask register, Address offset: 0x00
- ('EMR' , ctypes.c_uint32), # EXTI Event mask register, Address offset: 0x04
- ('RTSR' , ctypes.c_uint32), # EXTI Rising trigger selection register, Address offset: 0x08
- ('FTSR' , ctypes.c_uint32), # EXTI Falling trigger selection register, Address offset: 0x0C
- ('SWIER', ctypes.c_uint32), # EXTI Software interrupt event register, Address offset: 0x10
- ('PR' , ctypes.c_uint32), # EXTI Pending register, Address offset: 0x14
+ ('IMR' , ctypes.c_uint32), # EXTI Interrupt mask register, Address offset: 0x00
+ ('EMR' , ctypes.c_uint32), # EXTI Event mask register, Address offset: 0x04
+ ('RTSR' , ctypes.c_uint32), # EXTI Rising trigger selection register, Address offset: 0x08
+ ('FTSR' , ctypes.c_uint32), # EXTI Falling trigger selection register, Address offset: 0x0C
+ ('SWIER', ctypes.c_uint32), # EXTI Software interrupt event register, Address offset: 0x10
+ ('PR' , ctypes.c_uint32), # EXTI Pending register, Address offset: 0x14
]
diff --git a/qiling/hw/math/stm32f4xx_crc.py b/qiling/hw/math/stm32f4xx_crc.py
index 9d804697b..5699bdc1b 100644
--- a/qiling/hw/math/stm32f4xx_crc.py
+++ b/qiling/hw/math/stm32f4xx_crc.py
@@ -8,68 +8,68 @@
class STM32F4xxCrc(QlPeripheral):
- class Type(ctypes.Structure):
- """ the structure available in :
- stm32f413xx.h
- stm32f407xx.h
- stm32f469xx.h
- stm32f446xx.h
- stm32f427xx.h
- stm32f401xc.h
- stm32f415xx.h
- stm32f412cx.h
- stm32f410rx.h
- stm32f410tx.h
- stm32f439xx.h
- stm32f412vx.h
- stm32f417xx.h
- stm32f479xx.h
- stm32f429xx.h
- stm32f412rx.h
- stm32f423xx.h
- stm32f437xx.h
- stm32f412zx.h
- stm32f401xe.h
- stm32f410cx.h
- stm32f405xx.h
- stm32f411xe.h
- """
+ class Type(ctypes.Structure):
+ """ the structure available in :
+ stm32f413xx.h
+ stm32f407xx.h
+ stm32f469xx.h
+ stm32f446xx.h
+ stm32f427xx.h
+ stm32f401xc.h
+ stm32f415xx.h
+ stm32f412cx.h
+ stm32f410rx.h
+ stm32f410tx.h
+ stm32f439xx.h
+ stm32f412vx.h
+ stm32f417xx.h
+ stm32f479xx.h
+ stm32f429xx.h
+ stm32f412rx.h
+ stm32f423xx.h
+ stm32f437xx.h
+ stm32f412zx.h
+ stm32f401xe.h
+ stm32f410cx.h
+ stm32f405xx.h
+ stm32f411xe.h
+ """
- _fields_ = [
- ('DR' , ctypes.c_uint32), # CRC Data register, Address offset: 0x00
- ('IDR' , ctypes.c_uint8), # CRC Independent data register, Address offset: 0x04
- ('RESERVED0', ctypes.c_uint8), # Reserved, 0x05
- ('RESERVED1', ctypes.c_uint8), # Reserved, 0x06
- ('CR' , ctypes.c_uint32), # CRC Control register, Address offset: 0x08
- ]
+ _fields_ = [
+ ('DR' , ctypes.c_uint32), # CRC Data register, Address offset: 0x00
+ ('IDR' , ctypes.c_uint8), # CRC Independent data register, Address offset: 0x04
+ ('RESERVED0', ctypes.c_uint8), # Reserved, 0x05
+ ('RESERVED1', ctypes.c_uint8), # Reserved, 0x06
+ ('CR' , ctypes.c_uint32), # CRC Control register, Address offset: 0x08
+ ]
- def __init__(self, ql, label):
- super().__init__(ql, label)
+ def __init__(self, ql, label):
+ super().__init__(ql, label)
- self.instance = self.struct(
+ self.instance = self.struct(
DR = 0xffffffff,
)
- @QlPeripheral.monitor()
- def read(self, offset: int, size: int) -> int:
- buf = ctypes.create_string_buffer(size)
- ctypes.memmove(buf, ctypes.addressof(self.instance) + offset, size)
- return int.from_bytes(buf.raw, byteorder='little')
+ @QlPeripheral.monitor()
+ def read(self, offset: int, size: int) -> int:
+ buf = ctypes.create_string_buffer(size)
+ ctypes.memmove(buf, ctypes.addressof(self.instance) + offset, size)
+ return int.from_bytes(buf.raw, byteorder='little')
- @QlPeripheral.monitor()
- def write(self, offset: int, size: int, value: int):
- if offset == self.struct.CR.offset:
- if value & 1: # RESET bit
- self.instance.DR = 0xffffffff
- return
-
- elif offset == self.struct.DR.offset:
- for i in range(31, -1, -1):
- if self.instance.DR & 0x80000000:
- self.instance.DR <<= 1
- self.instance.DR ^= 0x04c11db7
- else:
- self.instance.DR <<= 1
+ @QlPeripheral.monitor()
+ def write(self, offset: int, size: int, value: int):
+ if offset == self.struct.CR.offset:
+ if value & 1: # RESET bit
+ self.instance.DR = 0xffffffff
+ return
+
+ elif offset == self.struct.DR.offset:
+ for i in range(31, -1, -1):
+ if self.instance.DR & 0x80000000:
+ self.instance.DR <<= 1
+ self.instance.DR ^= 0x04c11db7
+ else:
+ self.instance.DR <<= 1
- if value & (1 << i):
- self.instance.DR ^= 0x04c11db7
+ if value & (1 << i):
+ self.instance.DR ^= 0x04c11db7
diff --git a/qiling/hw/misc/gd32vf1xx_rcu.py b/qiling/hw/misc/gd32vf1xx_rcu.py
index 364bf4c5b..2e8fd536b 100644
--- a/qiling/hw/misc/gd32vf1xx_rcu.py
+++ b/qiling/hw/misc/gd32vf1xx_rcu.py
@@ -52,7 +52,7 @@ def __init__(self, ql, label, intn=None):
self.intn = intn
@QlPeripheral.monitor()
- def read(self, offset: int, size: int) -> int:
+ def read(self, offset: int, size: int) -> int:
buf = ctypes.create_string_buffer(size)
ctypes.memmove(buf, ctypes.addressof(self.instance) + offset, size)
return int.from_bytes(buf.raw, byteorder='little')
diff --git a/qiling/hw/misc/stm32f1xx_rcc.py b/qiling/hw/misc/stm32f1xx_rcc.py
index 434d17240..ccc8b308f 100644
--- a/qiling/hw/misc/stm32f1xx_rcc.py
+++ b/qiling/hw/misc/stm32f1xx_rcc.py
@@ -43,25 +43,25 @@ def __init__(self, ql, label, intn=None):
)
self.rdyon = {
- 'CR': [
- (RCC_CR.HSIRDY , RCC_CR.HSION ),
- (RCC_CR.HSERDY , RCC_CR.HSEON ),
- (RCC_CR.PLLRDY , RCC_CR.PLLON ),
- (RCC_CR.PLLI2SRDY, RCC_CR.PLLI2SON),
- ],
- 'CFGR': [
- (RCC_CFGR.SWS_0, RCC_CFGR.SW_0),
- (RCC_CFGR.SWS_1, RCC_CFGR.SW_1),
- ],
- 'CSR': [
- (RCC_CSR.LSIRDY, RCC_CSR.LSION)
- ]
- }
+ 'CR': [
+ (RCC_CR.HSIRDY , RCC_CR.HSION ),
+ (RCC_CR.HSERDY , RCC_CR.HSEON ),
+ (RCC_CR.PLLRDY , RCC_CR.PLLON ),
+ (RCC_CR.PLLI2SRDY, RCC_CR.PLLI2SON),
+ ],
+ 'CFGR': [
+ (RCC_CFGR.SWS_0, RCC_CFGR.SW_0),
+ (RCC_CFGR.SWS_1, RCC_CFGR.SW_1),
+ ],
+ 'CSR': [
+ (RCC_CSR.LSIRDY, RCC_CSR.LSION)
+ ]
+ }
self.intn = intn
@QlPeripheral.monitor()
- def read(self, offset: int, size: int) -> int:
+ def read(self, offset: int, size: int) -> int:
buf = ctypes.create_string_buffer(size)
ctypes.memmove(buf, ctypes.addressof(self.instance) + offset, size)
return int.from_bytes(buf.raw, byteorder='little')
diff --git a/qiling/hw/misc/stm32f4xx_dbg.py b/qiling/hw/misc/stm32f4xx_dbg.py
index 148c375f4..cf3d448e4 100644
--- a/qiling/hw/misc/stm32f4xx_dbg.py
+++ b/qiling/hw/misc/stm32f4xx_dbg.py
@@ -52,7 +52,7 @@ def __init__(self, ql: Qiling, label: str, dev_id: int = 0x400):
)
@QlPeripheral.monitor()
- def read(self, offset: int, size: int) -> int:
+ def read(self, offset: int, size: int) -> int:
buf = ctypes.create_string_buffer(size)
ctypes.memmove(buf, ctypes.addressof(self.instance) + offset, size)
return int.from_bytes(buf.raw, byteorder='little')
diff --git a/qiling/hw/misc/stm32f4xx_rcc.py b/qiling/hw/misc/stm32f4xx_rcc.py
index 8d634cf01..9bdbc96f2 100644
--- a/qiling/hw/misc/stm32f4xx_rcc.py
+++ b/qiling/hw/misc/stm32f4xx_rcc.py
@@ -9,102 +9,102 @@
class STM32F4xxRcc(QlPeripheral):
- class Type(ctypes.Structure):
- """ the structure available in :
- stm32f401xc.h
- stm32f401xe.h
- stm32f411xe.h
- """
+ class Type(ctypes.Structure):
+ """ the structure available in :
+ stm32f401xc.h
+ stm32f401xe.h
+ stm32f411xe.h
+ """
- _fields_ = [
- ('CR' , ctypes.c_uint32), # RCC clock control register, Address offset: 0x00
- ('PLLCFGR' , ctypes.c_uint32), # RCC PLL configuration register, Address offset: 0x04
- ('CFGR' , ctypes.c_uint32), # RCC clock configuration register, Address offset: 0x08
- ('CIR' , ctypes.c_uint32), # RCC clock interrupt register, Address offset: 0x0C
- ('AHB1RSTR' , ctypes.c_uint32), # RCC AHB1 peripheral reset register, Address offset: 0x10
- ('AHB2RSTR' , ctypes.c_uint32), # RCC AHB2 peripheral reset register, Address offset: 0x14
- ('AHB3RSTR' , ctypes.c_uint32), # RCC AHB3 peripheral reset register, Address offset: 0x18
- ('RESERVED0' , ctypes.c_uint32), # Reserved, 0x1C
- ('APB1RSTR' , ctypes.c_uint32), # RCC APB1 peripheral reset register, Address offset: 0x20
- ('APB2RSTR' , ctypes.c_uint32), # RCC APB2 peripheral reset register, Address offset: 0x24
- ('RESERVED1' , ctypes.c_uint32 * 2), # Reserved, 0x28-0x2C
- ('AHB1ENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock register, Address offset: 0x30
- ('AHB2ENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock register, Address offset: 0x34
- ('AHB3ENR' , ctypes.c_uint32), # RCC AHB3 peripheral clock register, Address offset: 0x38
- ('RESERVED2' , ctypes.c_uint32), # Reserved, 0x3C
- ('APB1ENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable register, Address offset: 0x40
- ('APB2ENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable register, Address offset: 0x44
- ('RESERVED3' , ctypes.c_uint32 * 2), # Reserved, 0x48-0x4C
- ('AHB1LPENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock enable in low power mode register, Address offset: 0x50
- ('AHB2LPENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock enable in low power mode register, Address offset: 0x54
- ('AHB3LPENR' , ctypes.c_uint32), # RCC AHB3 peripheral clock enable in low power mode register, Address offset: 0x58
- ('RESERVED4' , ctypes.c_uint32), # Reserved, 0x5C
- ('APB1LPENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable in low power mode register, Address offset: 0x60
- ('APB2LPENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable in low power mode register, Address offset: 0x64
- ('RESERVED5' , ctypes.c_uint32 * 2), # Reserved, 0x68-0x6C
- ('BDCR' , ctypes.c_uint32), # RCC Backup domain control register, Address offset: 0x70
- ('CSR' , ctypes.c_uint32), # RCC clock control & status register, Address offset: 0x74
- ('RESERVED6' , ctypes.c_uint32 * 2), # Reserved, 0x78-0x7C
- ('SSCGR' , ctypes.c_uint32), # RCC spread spectrum clock generation register, Address offset: 0x80
- ('PLLI2SCFGR', ctypes.c_uint32), # RCC PLLI2S configuration register, Address offset: 0x84
- ('RESERVED7' , ctypes.c_uint32), # Reserved, 0x88
- ('DCKCFGR' , ctypes.c_uint32), # RCC Dedicated Clocks configuration register, Address offset: 0x8C
- ]
+ _fields_ = [
+ ('CR' , ctypes.c_uint32), # RCC clock control register, Address offset: 0x00
+ ('PLLCFGR' , ctypes.c_uint32), # RCC PLL configuration register, Address offset: 0x04
+ ('CFGR' , ctypes.c_uint32), # RCC clock configuration register, Address offset: 0x08
+ ('CIR' , ctypes.c_uint32), # RCC clock interrupt register, Address offset: 0x0C
+ ('AHB1RSTR' , ctypes.c_uint32), # RCC AHB1 peripheral reset register, Address offset: 0x10
+ ('AHB2RSTR' , ctypes.c_uint32), # RCC AHB2 peripheral reset register, Address offset: 0x14
+ ('AHB3RSTR' , ctypes.c_uint32), # RCC AHB3 peripheral reset register, Address offset: 0x18
+ ('RESERVED0' , ctypes.c_uint32), # Reserved, 0x1C
+ ('APB1RSTR' , ctypes.c_uint32), # RCC APB1 peripheral reset register, Address offset: 0x20
+ ('APB2RSTR' , ctypes.c_uint32), # RCC APB2 peripheral reset register, Address offset: 0x24
+ ('RESERVED1' , ctypes.c_uint32 * 2), # Reserved, 0x28-0x2C
+ ('AHB1ENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock register, Address offset: 0x30
+ ('AHB2ENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock register, Address offset: 0x34
+ ('AHB3ENR' , ctypes.c_uint32), # RCC AHB3 peripheral clock register, Address offset: 0x38
+ ('RESERVED2' , ctypes.c_uint32), # Reserved, 0x3C
+ ('APB1ENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable register, Address offset: 0x40
+ ('APB2ENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable register, Address offset: 0x44
+ ('RESERVED3' , ctypes.c_uint32 * 2), # Reserved, 0x48-0x4C
+ ('AHB1LPENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock enable in low power mode register, Address offset: 0x50
+ ('AHB2LPENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock enable in low power mode register, Address offset: 0x54
+ ('AHB3LPENR' , ctypes.c_uint32), # RCC AHB3 peripheral clock enable in low power mode register, Address offset: 0x58
+ ('RESERVED4' , ctypes.c_uint32), # Reserved, 0x5C
+ ('APB1LPENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable in low power mode register, Address offset: 0x60
+ ('APB2LPENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable in low power mode register, Address offset: 0x64
+ ('RESERVED5' , ctypes.c_uint32 * 2), # Reserved, 0x68-0x6C
+ ('BDCR' , ctypes.c_uint32), # RCC Backup domain control register, Address offset: 0x70
+ ('CSR' , ctypes.c_uint32), # RCC clock control & status register, Address offset: 0x74
+ ('RESERVED6' , ctypes.c_uint32 * 2), # Reserved, 0x78-0x7C
+ ('SSCGR' , ctypes.c_uint32), # RCC spread spectrum clock generation register, Address offset: 0x80
+ ('PLLI2SCFGR', ctypes.c_uint32), # RCC PLLI2S configuration register, Address offset: 0x84
+ ('RESERVED7' , ctypes.c_uint32), # Reserved, 0x88
+ ('DCKCFGR' , ctypes.c_uint32), # RCC Dedicated Clocks configuration register, Address offset: 0x8C
+ ]
- def __init__(self, ql, label, intn=None):
- super().__init__(ql, label)
+ def __init__(self, ql, label, intn=None):
+ super().__init__(ql, label)
- self.instance = self.struct(
- CR = 0x00000083,
- PLLCFGR = 0x24003010,
- AHB1LPENR = 0x0061900F,
- AHB2LPENR = 0x00000080,
- APB1LPENR = 0x10E2C80F,
- APB2LPENR = 0x00077930,
- CSR = 0x0E000000,
- PLLI2SCFGR = 0x24003000,
- )
+ self.instance = self.struct(
+ CR = 0x00000083,
+ PLLCFGR = 0x24003010,
+ AHB1LPENR = 0x0061900F,
+ AHB2LPENR = 0x00000080,
+ APB1LPENR = 0x10E2C80F,
+ APB2LPENR = 0x00077930,
+ CSR = 0x0E000000,
+ PLLI2SCFGR = 0x24003000,
+ )
- self.rdyon = {
- 'CR': [
- (RCC_CR.HSIRDY , RCC_CR.HSION ),
- (RCC_CR.HSERDY , RCC_CR.HSEON ),
- (RCC_CR.PLLRDY , RCC_CR.PLLON ),
- (RCC_CR.PLLI2SRDY, RCC_CR.PLLI2SON),
- ],
- 'CFGR': [
- (RCC_CFGR.SWS_0, RCC_CFGR.SW_0),
- (RCC_CFGR.SWS_1, RCC_CFGR.SW_1),
- ],
- 'CSR': [
- (RCC_CSR.LSIRDY, RCC_CSR.LSION)
- ]
- }
+ self.rdyon = {
+ 'CR': [
+ (RCC_CR.HSIRDY , RCC_CR.HSION ),
+ (RCC_CR.HSERDY , RCC_CR.HSEON ),
+ (RCC_CR.PLLRDY , RCC_CR.PLLON ),
+ (RCC_CR.PLLI2SRDY, RCC_CR.PLLI2SON),
+ ],
+ 'CFGR': [
+ (RCC_CFGR.SWS_0, RCC_CFGR.SW_0),
+ (RCC_CFGR.SWS_1, RCC_CFGR.SW_1),
+ ],
+ 'CSR': [
+ (RCC_CSR.LSIRDY, RCC_CSR.LSION)
+ ]
+ }
- self.intn = intn
+ self.intn = intn
- @QlPeripheral.monitor()
- def read(self, offset: int, size: int) -> int:
- buf = ctypes.create_string_buffer(size)
- ctypes.memmove(buf, ctypes.addressof(self.instance) + offset, size)
- return int.from_bytes(buf.raw, byteorder='little')
+ @QlPeripheral.monitor()
+ def read(self, offset: int, size: int) -> int:
+ buf = ctypes.create_string_buffer(size)
+ ctypes.memmove(buf, ctypes.addressof(self.instance) + offset, size)
+ return int.from_bytes(buf.raw, byteorder='little')
- @QlPeripheral.monitor()
- def write(self, offset: int, size: int, value: int):
- if offset == self.struct.CR.offset:
- value = (self.instance.CR & RCC_CR.RO_MASK) | (value & RCC_CR.RW_MASK)
- elif offset == self.struct.CFGR.offset:
- value = (self.instance.CFGR & RCC_CFGR.RO_MASK) | (value & RCC_CFGR.RW_MASK)
+ @QlPeripheral.monitor()
+ def write(self, offset: int, size: int, value: int):
+ if offset == self.struct.CR.offset:
+ value = (self.instance.CR & RCC_CR.RO_MASK) | (value & RCC_CR.RW_MASK)
+ elif offset == self.struct.CFGR.offset:
+ value = (self.instance.CFGR & RCC_CFGR.RO_MASK) | (value & RCC_CFGR.RW_MASK)
- data = (value).to_bytes(size, 'little')
- ctypes.memmove(ctypes.addressof(self.instance) + offset, data, size)
+ data = (value).to_bytes(size, 'little')
+ ctypes.memmove(ctypes.addressof(self.instance) + offset, data, size)
- def step(self):
- for reg, rdyon in self.rdyon.items():
- value = getattr(self.instance, reg)
- for rdy, on in rdyon:
- if value & on:
- value |= rdy
- else:
- value &= ~rdy
- setattr(self.instance, reg, value)
+ def step(self):
+ for reg, rdyon in self.rdyon.items():
+ value = getattr(self.instance, reg)
+ for rdy, on in rdyon:
+ if value & on:
+ value |= rdy
+ else:
+ value &= ~rdy
+ setattr(self.instance, reg, value)
diff --git a/qiling/hw/misc/stm32f4xx_rcc_derive.py b/qiling/hw/misc/stm32f4xx_rcc_derive.py
index d4b86f000..63d916106 100644
--- a/qiling/hw/misc/stm32f4xx_rcc_derive.py
+++ b/qiling/hw/misc/stm32f4xx_rcc_derive.py
@@ -10,262 +10,262 @@
class STM32F4xxRccV1(STM32F4xxRcc):
class Type(ctypes.Structure):
""" the structure available in :
- stm32f413xx.h
- stm32f412vx.h
- stm32f412rx.h
- stm32f423xx.h
- stm32f412zx.h
- """
+ stm32f413xx.h
+ stm32f412vx.h
+ stm32f412rx.h
+ stm32f423xx.h
+ stm32f412zx.h
+ """
_fields_ = [
- ('CR' , ctypes.c_uint32), # RCC clock control register, Address offset: 0x00
- ('PLLCFGR' , ctypes.c_uint32), # RCC PLL configuration register, Address offset: 0x04
- ('CFGR' , ctypes.c_uint32), # RCC clock configuration register, Address offset: 0x08
- ('CIR' , ctypes.c_uint32), # RCC clock interrupt register, Address offset: 0x0C
- ('AHB1RSTR' , ctypes.c_uint32), # RCC AHB1 peripheral reset register, Address offset: 0x10
- ('AHB2RSTR' , ctypes.c_uint32), # RCC AHB2 peripheral reset register, Address offset: 0x14
- ('AHB3RSTR' , ctypes.c_uint32), # RCC AHB3 peripheral reset register, Address offset: 0x18
- ('RESERVED0' , ctypes.c_uint32), # Reserved, 0x1C
- ('APB1RSTR' , ctypes.c_uint32), # RCC APB1 peripheral reset register, Address offset: 0x20
- ('APB2RSTR' , ctypes.c_uint32), # RCC APB2 peripheral reset register, Address offset: 0x24
- ('RESERVED1' , ctypes.c_uint32 * 2), # Reserved, 0x28-0x2C
- ('AHB1ENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock register, Address offset: 0x30
- ('AHB2ENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock register, Address offset: 0x34
- ('AHB3ENR' , ctypes.c_uint32), # RCC AHB3 peripheral clock register, Address offset: 0x38
- ('RESERVED2' , ctypes.c_uint32), # Reserved, 0x3C
- ('APB1ENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable register, Address offset: 0x40
- ('APB2ENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable register, Address offset: 0x44
- ('RESERVED3' , ctypes.c_uint32 * 2), # Reserved, 0x48-0x4C
- ('AHB1LPENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock enable in low power mode register, Address offset: 0x50
- ('AHB2LPENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock enable in low power mode register, Address offset: 0x54
- ('AHB3LPENR' , ctypes.c_uint32), # RCC AHB3 peripheral clock enable in low power mode register, Address offset: 0x58
- ('RESERVED4' , ctypes.c_uint32), # Reserved, 0x5C
- ('APB1LPENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable in low power mode register, Address offset: 0x60
- ('APB2LPENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable in low power mode register, Address offset: 0x64
- ('RESERVED5' , ctypes.c_uint32 * 2), # Reserved, 0x68-0x6C
- ('BDCR' , ctypes.c_uint32), # RCC Backup domain control register, Address offset: 0x70
- ('CSR' , ctypes.c_uint32), # RCC clock control & status register, Address offset: 0x74
- ('RESERVED6' , ctypes.c_uint32 * 2), # Reserved, 0x78-0x7C
- ('SSCGR' , ctypes.c_uint32), # RCC spread spectrum clock generation register, Address offset: 0x80
- ('PLLI2SCFGR', ctypes.c_uint32), # RCC PLLI2S configuration register, Address offset: 0x84
- ('RESERVED7' , ctypes.c_uint32), # Reserved, 0x84
- ('DCKCFGR' , ctypes.c_uint32), # RCC Dedicated Clocks configuration register, Address offset: 0x8C
- ('CKGATENR' , ctypes.c_uint32), # RCC Clocks Gated ENable Register, Address offset: 0x90
- ('DCKCFGR2' , ctypes.c_uint32), # RCC Dedicated Clocks configuration register 2, Address offset: 0x94
- ]
+ ('CR' , ctypes.c_uint32), # RCC clock control register, Address offset: 0x00
+ ('PLLCFGR' , ctypes.c_uint32), # RCC PLL configuration register, Address offset: 0x04
+ ('CFGR' , ctypes.c_uint32), # RCC clock configuration register, Address offset: 0x08
+ ('CIR' , ctypes.c_uint32), # RCC clock interrupt register, Address offset: 0x0C
+ ('AHB1RSTR' , ctypes.c_uint32), # RCC AHB1 peripheral reset register, Address offset: 0x10
+ ('AHB2RSTR' , ctypes.c_uint32), # RCC AHB2 peripheral reset register, Address offset: 0x14
+ ('AHB3RSTR' , ctypes.c_uint32), # RCC AHB3 peripheral reset register, Address offset: 0x18
+ ('RESERVED0' , ctypes.c_uint32), # Reserved, 0x1C
+ ('APB1RSTR' , ctypes.c_uint32), # RCC APB1 peripheral reset register, Address offset: 0x20
+ ('APB2RSTR' , ctypes.c_uint32), # RCC APB2 peripheral reset register, Address offset: 0x24
+ ('RESERVED1' , ctypes.c_uint32 * 2), # Reserved, 0x28-0x2C
+ ('AHB1ENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock register, Address offset: 0x30
+ ('AHB2ENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock register, Address offset: 0x34
+ ('AHB3ENR' , ctypes.c_uint32), # RCC AHB3 peripheral clock register, Address offset: 0x38
+ ('RESERVED2' , ctypes.c_uint32), # Reserved, 0x3C
+ ('APB1ENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable register, Address offset: 0x40
+ ('APB2ENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable register, Address offset: 0x44
+ ('RESERVED3' , ctypes.c_uint32 * 2), # Reserved, 0x48-0x4C
+ ('AHB1LPENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock enable in low power mode register, Address offset: 0x50
+ ('AHB2LPENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock enable in low power mode register, Address offset: 0x54
+ ('AHB3LPENR' , ctypes.c_uint32), # RCC AHB3 peripheral clock enable in low power mode register, Address offset: 0x58
+ ('RESERVED4' , ctypes.c_uint32), # Reserved, 0x5C
+ ('APB1LPENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable in low power mode register, Address offset: 0x60
+ ('APB2LPENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable in low power mode register, Address offset: 0x64
+ ('RESERVED5' , ctypes.c_uint32 * 2), # Reserved, 0x68-0x6C
+ ('BDCR' , ctypes.c_uint32), # RCC Backup domain control register, Address offset: 0x70
+ ('CSR' , ctypes.c_uint32), # RCC clock control & status register, Address offset: 0x74
+ ('RESERVED6' , ctypes.c_uint32 * 2), # Reserved, 0x78-0x7C
+ ('SSCGR' , ctypes.c_uint32), # RCC spread spectrum clock generation register, Address offset: 0x80
+ ('PLLI2SCFGR', ctypes.c_uint32), # RCC PLLI2S configuration register, Address offset: 0x84
+ ('RESERVED7' , ctypes.c_uint32), # Reserved, 0x84
+ ('DCKCFGR' , ctypes.c_uint32), # RCC Dedicated Clocks configuration register, Address offset: 0x8C
+ ('CKGATENR' , ctypes.c_uint32), # RCC Clocks Gated ENable Register, Address offset: 0x90
+ ('DCKCFGR2' , ctypes.c_uint32), # RCC Dedicated Clocks configuration register 2, Address offset: 0x94
+ ]
class STM32F4xxRccV2(STM32F4xxRcc):
class Type(ctypes.Structure):
""" the structure available in :
- stm32f407xx.h
- stm32f415xx.h
- stm32f417xx.h
- stm32f405xx.h
- """
+ stm32f407xx.h
+ stm32f415xx.h
+ stm32f417xx.h
+ stm32f405xx.h
+ """
_fields_ = [
- ('CR' , ctypes.c_uint32), # RCC clock control register, Address offset: 0x00
- ('PLLCFGR' , ctypes.c_uint32), # RCC PLL configuration register, Address offset: 0x04
- ('CFGR' , ctypes.c_uint32), # RCC clock configuration register, Address offset: 0x08
- ('CIR' , ctypes.c_uint32), # RCC clock interrupt register, Address offset: 0x0C
- ('AHB1RSTR' , ctypes.c_uint32), # RCC AHB1 peripheral reset register, Address offset: 0x10
- ('AHB2RSTR' , ctypes.c_uint32), # RCC AHB2 peripheral reset register, Address offset: 0x14
- ('AHB3RSTR' , ctypes.c_uint32), # RCC AHB3 peripheral reset register, Address offset: 0x18
- ('RESERVED0' , ctypes.c_uint32), # Reserved, 0x1C
- ('APB1RSTR' , ctypes.c_uint32), # RCC APB1 peripheral reset register, Address offset: 0x20
- ('APB2RSTR' , ctypes.c_uint32), # RCC APB2 peripheral reset register, Address offset: 0x24
- ('RESERVED1' , ctypes.c_uint32 * 2), # Reserved, 0x28-0x2C
- ('AHB1ENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock register, Address offset: 0x30
- ('AHB2ENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock register, Address offset: 0x34
- ('AHB3ENR' , ctypes.c_uint32), # RCC AHB3 peripheral clock register, Address offset: 0x38
- ('RESERVED2' , ctypes.c_uint32), # Reserved, 0x3C
- ('APB1ENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable register, Address offset: 0x40
- ('APB2ENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable register, Address offset: 0x44
- ('RESERVED3' , ctypes.c_uint32 * 2), # Reserved, 0x48-0x4C
- ('AHB1LPENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock enable in low power mode register, Address offset: 0x50
- ('AHB2LPENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock enable in low power mode register, Address offset: 0x54
- ('AHB3LPENR' , ctypes.c_uint32), # RCC AHB3 peripheral clock enable in low power mode register, Address offset: 0x58
- ('RESERVED4' , ctypes.c_uint32), # Reserved, 0x5C
- ('APB1LPENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable in low power mode register, Address offset: 0x60
- ('APB2LPENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable in low power mode register, Address offset: 0x64
- ('RESERVED5' , ctypes.c_uint32 * 2), # Reserved, 0x68-0x6C
- ('BDCR' , ctypes.c_uint32), # RCC Backup domain control register, Address offset: 0x70
- ('CSR' , ctypes.c_uint32), # RCC clock control & status register, Address offset: 0x74
- ('RESERVED6' , ctypes.c_uint32 * 2), # Reserved, 0x78-0x7C
- ('SSCGR' , ctypes.c_uint32), # RCC spread spectrum clock generation register, Address offset: 0x80
- ('PLLI2SCFGR', ctypes.c_uint32), # RCC PLLI2S configuration register, Address offset: 0x84
- ]
+ ('CR' , ctypes.c_uint32), # RCC clock control register, Address offset: 0x00
+ ('PLLCFGR' , ctypes.c_uint32), # RCC PLL configuration register, Address offset: 0x04
+ ('CFGR' , ctypes.c_uint32), # RCC clock configuration register, Address offset: 0x08
+ ('CIR' , ctypes.c_uint32), # RCC clock interrupt register, Address offset: 0x0C
+ ('AHB1RSTR' , ctypes.c_uint32), # RCC AHB1 peripheral reset register, Address offset: 0x10
+ ('AHB2RSTR' , ctypes.c_uint32), # RCC AHB2 peripheral reset register, Address offset: 0x14
+ ('AHB3RSTR' , ctypes.c_uint32), # RCC AHB3 peripheral reset register, Address offset: 0x18
+ ('RESERVED0' , ctypes.c_uint32), # Reserved, 0x1C
+ ('APB1RSTR' , ctypes.c_uint32), # RCC APB1 peripheral reset register, Address offset: 0x20
+ ('APB2RSTR' , ctypes.c_uint32), # RCC APB2 peripheral reset register, Address offset: 0x24
+ ('RESERVED1' , ctypes.c_uint32 * 2), # Reserved, 0x28-0x2C
+ ('AHB1ENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock register, Address offset: 0x30
+ ('AHB2ENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock register, Address offset: 0x34
+ ('AHB3ENR' , ctypes.c_uint32), # RCC AHB3 peripheral clock register, Address offset: 0x38
+ ('RESERVED2' , ctypes.c_uint32), # Reserved, 0x3C
+ ('APB1ENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable register, Address offset: 0x40
+ ('APB2ENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable register, Address offset: 0x44
+ ('RESERVED3' , ctypes.c_uint32 * 2), # Reserved, 0x48-0x4C
+ ('AHB1LPENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock enable in low power mode register, Address offset: 0x50
+ ('AHB2LPENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock enable in low power mode register, Address offset: 0x54
+ ('AHB3LPENR' , ctypes.c_uint32), # RCC AHB3 peripheral clock enable in low power mode register, Address offset: 0x58
+ ('RESERVED4' , ctypes.c_uint32), # Reserved, 0x5C
+ ('APB1LPENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable in low power mode register, Address offset: 0x60
+ ('APB2LPENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable in low power mode register, Address offset: 0x64
+ ('RESERVED5' , ctypes.c_uint32 * 2), # Reserved, 0x68-0x6C
+ ('BDCR' , ctypes.c_uint32), # RCC Backup domain control register, Address offset: 0x70
+ ('CSR' , ctypes.c_uint32), # RCC clock control & status register, Address offset: 0x74
+ ('RESERVED6' , ctypes.c_uint32 * 2), # Reserved, 0x78-0x7C
+ ('SSCGR' , ctypes.c_uint32), # RCC spread spectrum clock generation register, Address offset: 0x80
+ ('PLLI2SCFGR', ctypes.c_uint32), # RCC PLLI2S configuration register, Address offset: 0x84
+ ]
class STM32F4xxRccV3(STM32F4xxRcc):
class Type(ctypes.Structure):
""" the structure available in :
- stm32f469xx.h
- stm32f427xx.h
- stm32f439xx.h
- stm32f479xx.h
- stm32f429xx.h
- stm32f437xx.h
- """
+ stm32f469xx.h
+ stm32f427xx.h
+ stm32f439xx.h
+ stm32f479xx.h
+ stm32f429xx.h
+ stm32f437xx.h
+ """
_fields_ = [
- ('CR' , ctypes.c_uint32), # RCC clock control register, Address offset: 0x00
- ('PLLCFGR' , ctypes.c_uint32), # RCC PLL configuration register, Address offset: 0x04
- ('CFGR' , ctypes.c_uint32), # RCC clock configuration register, Address offset: 0x08
- ('CIR' , ctypes.c_uint32), # RCC clock interrupt register, Address offset: 0x0C
- ('AHB1RSTR' , ctypes.c_uint32), # RCC AHB1 peripheral reset register, Address offset: 0x10
- ('AHB2RSTR' , ctypes.c_uint32), # RCC AHB2 peripheral reset register, Address offset: 0x14
- ('AHB3RSTR' , ctypes.c_uint32), # RCC AHB3 peripheral reset register, Address offset: 0x18
- ('RESERVED0' , ctypes.c_uint32), # Reserved, 0x1C
- ('APB1RSTR' , ctypes.c_uint32), # RCC APB1 peripheral reset register, Address offset: 0x20
- ('APB2RSTR' , ctypes.c_uint32), # RCC APB2 peripheral reset register, Address offset: 0x24
- ('RESERVED1' , ctypes.c_uint32 * 2), # Reserved, 0x28-0x2C
- ('AHB1ENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock register, Address offset: 0x30
- ('AHB2ENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock register, Address offset: 0x34
- ('AHB3ENR' , ctypes.c_uint32), # RCC AHB3 peripheral clock register, Address offset: 0x38
- ('RESERVED2' , ctypes.c_uint32), # Reserved, 0x3C
- ('APB1ENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable register, Address offset: 0x40
- ('APB2ENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable register, Address offset: 0x44
- ('RESERVED3' , ctypes.c_uint32 * 2), # Reserved, 0x48-0x4C
- ('AHB1LPENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock enable in low power mode register, Address offset: 0x50
- ('AHB2LPENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock enable in low power mode register, Address offset: 0x54
- ('AHB3LPENR' , ctypes.c_uint32), # RCC AHB3 peripheral clock enable in low power mode register, Address offset: 0x58
- ('RESERVED4' , ctypes.c_uint32), # Reserved, 0x5C
- ('APB1LPENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable in low power mode register, Address offset: 0x60
- ('APB2LPENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable in low power mode register, Address offset: 0x64
- ('RESERVED5' , ctypes.c_uint32 * 2), # Reserved, 0x68-0x6C
- ('BDCR' , ctypes.c_uint32), # RCC Backup domain control register, Address offset: 0x70
- ('CSR' , ctypes.c_uint32), # RCC clock control & status register, Address offset: 0x74
- ('RESERVED6' , ctypes.c_uint32 * 2), # Reserved, 0x78-0x7C
- ('SSCGR' , ctypes.c_uint32), # RCC spread spectrum clock generation register, Address offset: 0x80
- ('PLLI2SCFGR', ctypes.c_uint32), # RCC PLLI2S configuration register, Address offset: 0x84
- ('PLLSAICFGR', ctypes.c_uint32), # RCC PLLSAI configuration register, Address offset: 0x88
- ('DCKCFGR' , ctypes.c_uint32), # RCC Dedicated Clocks configuration register, Address offset: 0x8C
- ]
+ ('CR' , ctypes.c_uint32), # RCC clock control register, Address offset: 0x00
+ ('PLLCFGR' , ctypes.c_uint32), # RCC PLL configuration register, Address offset: 0x04
+ ('CFGR' , ctypes.c_uint32), # RCC clock configuration register, Address offset: 0x08
+ ('CIR' , ctypes.c_uint32), # RCC clock interrupt register, Address offset: 0x0C
+ ('AHB1RSTR' , ctypes.c_uint32), # RCC AHB1 peripheral reset register, Address offset: 0x10
+ ('AHB2RSTR' , ctypes.c_uint32), # RCC AHB2 peripheral reset register, Address offset: 0x14
+ ('AHB3RSTR' , ctypes.c_uint32), # RCC AHB3 peripheral reset register, Address offset: 0x18
+ ('RESERVED0' , ctypes.c_uint32), # Reserved, 0x1C
+ ('APB1RSTR' , ctypes.c_uint32), # RCC APB1 peripheral reset register, Address offset: 0x20
+ ('APB2RSTR' , ctypes.c_uint32), # RCC APB2 peripheral reset register, Address offset: 0x24
+ ('RESERVED1' , ctypes.c_uint32 * 2), # Reserved, 0x28-0x2C
+ ('AHB1ENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock register, Address offset: 0x30
+ ('AHB2ENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock register, Address offset: 0x34
+ ('AHB3ENR' , ctypes.c_uint32), # RCC AHB3 peripheral clock register, Address offset: 0x38
+ ('RESERVED2' , ctypes.c_uint32), # Reserved, 0x3C
+ ('APB1ENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable register, Address offset: 0x40
+ ('APB2ENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable register, Address offset: 0x44
+ ('RESERVED3' , ctypes.c_uint32 * 2), # Reserved, 0x48-0x4C
+ ('AHB1LPENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock enable in low power mode register, Address offset: 0x50
+ ('AHB2LPENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock enable in low power mode register, Address offset: 0x54
+ ('AHB3LPENR' , ctypes.c_uint32), # RCC AHB3 peripheral clock enable in low power mode register, Address offset: 0x58
+ ('RESERVED4' , ctypes.c_uint32), # Reserved, 0x5C
+ ('APB1LPENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable in low power mode register, Address offset: 0x60
+ ('APB2LPENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable in low power mode register, Address offset: 0x64
+ ('RESERVED5' , ctypes.c_uint32 * 2), # Reserved, 0x68-0x6C
+ ('BDCR' , ctypes.c_uint32), # RCC Backup domain control register, Address offset: 0x70
+ ('CSR' , ctypes.c_uint32), # RCC clock control & status register, Address offset: 0x74
+ ('RESERVED6' , ctypes.c_uint32 * 2), # Reserved, 0x78-0x7C
+ ('SSCGR' , ctypes.c_uint32), # RCC spread spectrum clock generation register, Address offset: 0x80
+ ('PLLI2SCFGR', ctypes.c_uint32), # RCC PLLI2S configuration register, Address offset: 0x84
+ ('PLLSAICFGR', ctypes.c_uint32), # RCC PLLSAI configuration register, Address offset: 0x88
+ ('DCKCFGR' , ctypes.c_uint32), # RCC Dedicated Clocks configuration register, Address offset: 0x8C
+ ]
class STM32F446Rcc(STM32F4xxRcc):
class Type(ctypes.Structure):
""" the structure available in :
- stm32f446xx.h
- """
+ stm32f446xx.h
+ """
_fields_ = [
- ('CR' , ctypes.c_uint32), # RCC clock control register, Address offset: 0x00
- ('PLLCFGR' , ctypes.c_uint32), # RCC PLL configuration register, Address offset: 0x04
- ('CFGR' , ctypes.c_uint32), # RCC clock configuration register, Address offset: 0x08
- ('CIR' , ctypes.c_uint32), # RCC clock interrupt register, Address offset: 0x0C
- ('AHB1RSTR' , ctypes.c_uint32), # RCC AHB1 peripheral reset register, Address offset: 0x10
- ('AHB2RSTR' , ctypes.c_uint32), # RCC AHB2 peripheral reset register, Address offset: 0x14
- ('AHB3RSTR' , ctypes.c_uint32), # RCC AHB3 peripheral reset register, Address offset: 0x18
- ('RESERVED0' , ctypes.c_uint32), # Reserved, 0x1C
- ('APB1RSTR' , ctypes.c_uint32), # RCC APB1 peripheral reset register, Address offset: 0x20
- ('APB2RSTR' , ctypes.c_uint32), # RCC APB2 peripheral reset register, Address offset: 0x24
- ('RESERVED1' , ctypes.c_uint32 * 2), # Reserved, 0x28-0x2C
- ('AHB1ENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock register, Address offset: 0x30
- ('AHB2ENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock register, Address offset: 0x34
- ('AHB3ENR' , ctypes.c_uint32), # RCC AHB3 peripheral clock register, Address offset: 0x38
- ('RESERVED2' , ctypes.c_uint32), # Reserved, 0x3C
- ('APB1ENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable register, Address offset: 0x40
- ('APB2ENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable register, Address offset: 0x44
- ('RESERVED3' , ctypes.c_uint32 * 2), # Reserved, 0x48-0x4C
- ('AHB1LPENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock enable in low power mode register, Address offset: 0x50
- ('AHB2LPENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock enable in low power mode register, Address offset: 0x54
- ('AHB3LPENR' , ctypes.c_uint32), # RCC AHB3 peripheral clock enable in low power mode register, Address offset: 0x58
- ('RESERVED4' , ctypes.c_uint32), # Reserved, 0x5C
- ('APB1LPENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable in low power mode register, Address offset: 0x60
- ('APB2LPENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable in low power mode register, Address offset: 0x64
- ('RESERVED5' , ctypes.c_uint32 * 2), # Reserved, 0x68-0x6C
- ('BDCR' , ctypes.c_uint32), # RCC Backup domain control register, Address offset: 0x70
- ('CSR' , ctypes.c_uint32), # RCC clock control & status register, Address offset: 0x74
- ('RESERVED6' , ctypes.c_uint32 * 2), # Reserved, 0x78-0x7C
- ('SSCGR' , ctypes.c_uint32), # RCC spread spectrum clock generation register, Address offset: 0x80
- ('PLLI2SCFGR', ctypes.c_uint32), # RCC PLLI2S configuration register, Address offset: 0x84
- ('PLLSAICFGR', ctypes.c_uint32), # RCC PLLSAI configuration register, Address offset: 0x88
- ('DCKCFGR' , ctypes.c_uint32), # RCC Dedicated Clocks configuration register, Address offset: 0x8C
- ('CKGATENR' , ctypes.c_uint32), # RCC Clocks Gated ENable Register, Address offset: 0x90
- ('DCKCFGR2' , ctypes.c_uint32), # RCC Dedicated Clocks configuration register 2, Address offset: 0x94
- ]
+ ('CR' , ctypes.c_uint32), # RCC clock control register, Address offset: 0x00
+ ('PLLCFGR' , ctypes.c_uint32), # RCC PLL configuration register, Address offset: 0x04
+ ('CFGR' , ctypes.c_uint32), # RCC clock configuration register, Address offset: 0x08
+ ('CIR' , ctypes.c_uint32), # RCC clock interrupt register, Address offset: 0x0C
+ ('AHB1RSTR' , ctypes.c_uint32), # RCC AHB1 peripheral reset register, Address offset: 0x10
+ ('AHB2RSTR' , ctypes.c_uint32), # RCC AHB2 peripheral reset register, Address offset: 0x14
+ ('AHB3RSTR' , ctypes.c_uint32), # RCC AHB3 peripheral reset register, Address offset: 0x18
+ ('RESERVED0' , ctypes.c_uint32), # Reserved, 0x1C
+ ('APB1RSTR' , ctypes.c_uint32), # RCC APB1 peripheral reset register, Address offset: 0x20
+ ('APB2RSTR' , ctypes.c_uint32), # RCC APB2 peripheral reset register, Address offset: 0x24
+ ('RESERVED1' , ctypes.c_uint32 * 2), # Reserved, 0x28-0x2C
+ ('AHB1ENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock register, Address offset: 0x30
+ ('AHB2ENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock register, Address offset: 0x34
+ ('AHB3ENR' , ctypes.c_uint32), # RCC AHB3 peripheral clock register, Address offset: 0x38
+ ('RESERVED2' , ctypes.c_uint32), # Reserved, 0x3C
+ ('APB1ENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable register, Address offset: 0x40
+ ('APB2ENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable register, Address offset: 0x44
+ ('RESERVED3' , ctypes.c_uint32 * 2), # Reserved, 0x48-0x4C
+ ('AHB1LPENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock enable in low power mode register, Address offset: 0x50
+ ('AHB2LPENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock enable in low power mode register, Address offset: 0x54
+ ('AHB3LPENR' , ctypes.c_uint32), # RCC AHB3 peripheral clock enable in low power mode register, Address offset: 0x58
+ ('RESERVED4' , ctypes.c_uint32), # Reserved, 0x5C
+ ('APB1LPENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable in low power mode register, Address offset: 0x60
+ ('APB2LPENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable in low power mode register, Address offset: 0x64
+ ('RESERVED5' , ctypes.c_uint32 * 2), # Reserved, 0x68-0x6C
+ ('BDCR' , ctypes.c_uint32), # RCC Backup domain control register, Address offset: 0x70
+ ('CSR' , ctypes.c_uint32), # RCC clock control & status register, Address offset: 0x74
+ ('RESERVED6' , ctypes.c_uint32 * 2), # Reserved, 0x78-0x7C
+ ('SSCGR' , ctypes.c_uint32), # RCC spread spectrum clock generation register, Address offset: 0x80
+ ('PLLI2SCFGR', ctypes.c_uint32), # RCC PLLI2S configuration register, Address offset: 0x84
+ ('PLLSAICFGR', ctypes.c_uint32), # RCC PLLSAI configuration register, Address offset: 0x88
+ ('DCKCFGR' , ctypes.c_uint32), # RCC Dedicated Clocks configuration register, Address offset: 0x8C
+ ('CKGATENR' , ctypes.c_uint32), # RCC Clocks Gated ENable Register, Address offset: 0x90
+ ('DCKCFGR2' , ctypes.c_uint32), # RCC Dedicated Clocks configuration register 2, Address offset: 0x94
+ ]
class Type(ctypes.Structure):
""" the structure available in :
- stm32f469xx.h
- stm32f427xx.h
- stm32f439xx.h
- stm32f479xx.h
- stm32f429xx.h
- stm32f437xx.h
- """
+ stm32f469xx.h
+ stm32f427xx.h
+ stm32f439xx.h
+ stm32f479xx.h
+ stm32f429xx.h
+ stm32f437xx.h
+ """
_fields_ = [
- ('CR' , ctypes.c_uint32), # RCC clock control register, Address offset: 0x00
- ('PLLCFGR' , ctypes.c_uint32), # RCC PLL configuration register, Address offset: 0x04
- ('CFGR' , ctypes.c_uint32), # RCC clock configuration register, Address offset: 0x08
- ('CIR' , ctypes.c_uint32), # RCC clock interrupt register, Address offset: 0x0C
- ('AHB1RSTR' , ctypes.c_uint32), # RCC AHB1 peripheral reset register, Address offset: 0x10
- ('AHB2RSTR' , ctypes.c_uint32), # RCC AHB2 peripheral reset register, Address offset: 0x14
- ('AHB3RSTR' , ctypes.c_uint32), # RCC AHB3 peripheral reset register, Address offset: 0x18
- ('RESERVED0' , ctypes.c_uint32), # Reserved, 0x1C
- ('APB1RSTR' , ctypes.c_uint32), # RCC APB1 peripheral reset register, Address offset: 0x20
- ('APB2RSTR' , ctypes.c_uint32), # RCC APB2 peripheral reset register, Address offset: 0x24
- ('RESERVED1' , ctypes.c_uint32 * 2), # Reserved, 0x28-0x2C
- ('AHB1ENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock register, Address offset: 0x30
- ('AHB2ENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock register, Address offset: 0x34
- ('AHB3ENR' , ctypes.c_uint32), # RCC AHB3 peripheral clock register, Address offset: 0x38
- ('RESERVED2' , ctypes.c_uint32), # Reserved, 0x3C
- ('APB1ENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable register, Address offset: 0x40
- ('APB2ENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable register, Address offset: 0x44
- ('RESERVED3' , ctypes.c_uint32 * 2), # Reserved, 0x48-0x4C
- ('AHB1LPENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock enable in low power mode register, Address offset: 0x50
- ('AHB2LPENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock enable in low power mode register, Address offset: 0x54
- ('AHB3LPENR' , ctypes.c_uint32), # RCC AHB3 peripheral clock enable in low power mode register, Address offset: 0x58
- ('RESERVED4' , ctypes.c_uint32), # Reserved, 0x5C
- ('APB1LPENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable in low power mode register, Address offset: 0x60
- ('APB2LPENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable in low power mode register, Address offset: 0x64
- ('RESERVED5' , ctypes.c_uint32 * 2), # Reserved, 0x68-0x6C
- ('BDCR' , ctypes.c_uint32), # RCC Backup domain control register, Address offset: 0x70
- ('CSR' , ctypes.c_uint32), # RCC clock control & status register, Address offset: 0x74
- ('RESERVED6' , ctypes.c_uint32 * 2), # Reserved, 0x78-0x7C
- ('SSCGR' , ctypes.c_uint32), # RCC spread spectrum clock generation register, Address offset: 0x80
- ('PLLI2SCFGR', ctypes.c_uint32), # RCC PLLI2S configuration register, Address offset: 0x84
- ('PLLSAICFGR', ctypes.c_uint32), # RCC PLLSAI configuration register, Address offset: 0x88
- ('DCKCFGR' , ctypes.c_uint32), # RCC Dedicated Clocks configuration register, Address offset: 0x8C
- ]
+ ('CR' , ctypes.c_uint32), # RCC clock control register, Address offset: 0x00
+ ('PLLCFGR' , ctypes.c_uint32), # RCC PLL configuration register, Address offset: 0x04
+ ('CFGR' , ctypes.c_uint32), # RCC clock configuration register, Address offset: 0x08
+ ('CIR' , ctypes.c_uint32), # RCC clock interrupt register, Address offset: 0x0C
+ ('AHB1RSTR' , ctypes.c_uint32), # RCC AHB1 peripheral reset register, Address offset: 0x10
+ ('AHB2RSTR' , ctypes.c_uint32), # RCC AHB2 peripheral reset register, Address offset: 0x14
+ ('AHB3RSTR' , ctypes.c_uint32), # RCC AHB3 peripheral reset register, Address offset: 0x18
+ ('RESERVED0' , ctypes.c_uint32), # Reserved, 0x1C
+ ('APB1RSTR' , ctypes.c_uint32), # RCC APB1 peripheral reset register, Address offset: 0x20
+ ('APB2RSTR' , ctypes.c_uint32), # RCC APB2 peripheral reset register, Address offset: 0x24
+ ('RESERVED1' , ctypes.c_uint32 * 2), # Reserved, 0x28-0x2C
+ ('AHB1ENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock register, Address offset: 0x30
+ ('AHB2ENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock register, Address offset: 0x34
+ ('AHB3ENR' , ctypes.c_uint32), # RCC AHB3 peripheral clock register, Address offset: 0x38
+ ('RESERVED2' , ctypes.c_uint32), # Reserved, 0x3C
+ ('APB1ENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable register, Address offset: 0x40
+ ('APB2ENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable register, Address offset: 0x44
+ ('RESERVED3' , ctypes.c_uint32 * 2), # Reserved, 0x48-0x4C
+ ('AHB1LPENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock enable in low power mode register, Address offset: 0x50
+ ('AHB2LPENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock enable in low power mode register, Address offset: 0x54
+ ('AHB3LPENR' , ctypes.c_uint32), # RCC AHB3 peripheral clock enable in low power mode register, Address offset: 0x58
+ ('RESERVED4' , ctypes.c_uint32), # Reserved, 0x5C
+ ('APB1LPENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable in low power mode register, Address offset: 0x60
+ ('APB2LPENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable in low power mode register, Address offset: 0x64
+ ('RESERVED5' , ctypes.c_uint32 * 2), # Reserved, 0x68-0x6C
+ ('BDCR' , ctypes.c_uint32), # RCC Backup domain control register, Address offset: 0x70
+ ('CSR' , ctypes.c_uint32), # RCC clock control & status register, Address offset: 0x74
+ ('RESERVED6' , ctypes.c_uint32 * 2), # Reserved, 0x78-0x7C
+ ('SSCGR' , ctypes.c_uint32), # RCC spread spectrum clock generation register, Address offset: 0x80
+ ('PLLI2SCFGR', ctypes.c_uint32), # RCC PLLI2S configuration register, Address offset: 0x84
+ ('PLLSAICFGR', ctypes.c_uint32), # RCC PLLSAI configuration register, Address offset: 0x88
+ ('DCKCFGR' , ctypes.c_uint32), # RCC Dedicated Clocks configuration register, Address offset: 0x8C
+ ]
class STM32F412Rcc(STM32F4xxRcc):
class Type(ctypes.Structure):
""" the structure available in :
- stm32f412cx.h
- """
+ stm32f412cx.h
+ """
_fields_ = [
- ('CR' , ctypes.c_uint32), # RCC clock control register, Address offset: 0x00
- ('PLLCFGR' , ctypes.c_uint32), # RCC PLL configuration register, Address offset: 0x04
- ('CFGR' , ctypes.c_uint32), # RCC clock configuration register, Address offset: 0x08
- ('CIR' , ctypes.c_uint32), # RCC clock interrupt register, Address offset: 0x0C
- ('AHB1RSTR' , ctypes.c_uint32), # RCC AHB1 peripheral reset register, Address offset: 0x10
- ('AHB2RSTR' , ctypes.c_uint32), # RCC AHB2 peripheral reset register, Address offset: 0x14
- ('RESERVED0' , ctypes.c_uint32 * 2), # Reserved, 0x18-0x1C
- ('APB1RSTR' , ctypes.c_uint32), # RCC APB1 peripheral reset register, Address offset: 0x20
- ('APB2RSTR' , ctypes.c_uint32), # RCC APB2 peripheral reset register, Address offset: 0x24
- ('RESERVED1' , ctypes.c_uint32 * 2), # Reserved, 0x28-0x2C
- ('AHB1ENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock register, Address offset: 0x30
- ('AHB2ENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock register, Address offset: 0x34
- ('RESERVED2' , ctypes.c_uint32 * 2), # Reserved, 0x38-0x3C
- ('APB1ENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable register, Address offset: 0x40
- ('APB2ENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable register, Address offset: 0x44
- ('RESERVED3' , ctypes.c_uint32 * 2), # Reserved, 0x48-0x4C
- ('AHB1LPENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock enable in low power mode register, Address offset: 0x50
- ('AHB2LPENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock enable in low power mode register, Address offset: 0x54
- ('RESERVED4' , ctypes.c_uint32 * 2), # Reserved, 0x58-0x5C
- ('APB1LPENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable in low power mode register, Address offset: 0x60
- ('APB2LPENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable in low power mode register, Address offset: 0x64
- ('RESERVED5' , ctypes.c_uint32 * 2), # Reserved, 0x68-0x6C
- ('BDCR' , ctypes.c_uint32), # RCC Backup domain control register, Address offset: 0x70
- ('CSR' , ctypes.c_uint32), # RCC clock control & status register, Address offset: 0x74
- ('RESERVED6' , ctypes.c_uint32 * 2), # Reserved, 0x78-0x7C
- ('SSCGR' , ctypes.c_uint32), # RCC spread spectrum clock generation register, Address offset: 0x80
- ('PLLI2SCFGR', ctypes.c_uint32), # RCC PLLI2S configuration register, Address offset: 0x84
- ('RESERVED7' , ctypes.c_uint32), # Reserved, 0x88
- ('DCKCFGR' , ctypes.c_uint32), # RCC Dedicated Clocks configuration register, Address offset: 0x8C
- ('CKGATENR' , ctypes.c_uint32), # RCC Clocks Gated ENable Register, Address offset: 0x90
- ('DCKCFGR2' , ctypes.c_uint32), # RCC Dedicated Clocks configuration register 2, Address offset: 0x94
- ]
+ ('CR' , ctypes.c_uint32), # RCC clock control register, Address offset: 0x00
+ ('PLLCFGR' , ctypes.c_uint32), # RCC PLL configuration register, Address offset: 0x04
+ ('CFGR' , ctypes.c_uint32), # RCC clock configuration register, Address offset: 0x08
+ ('CIR' , ctypes.c_uint32), # RCC clock interrupt register, Address offset: 0x0C
+ ('AHB1RSTR' , ctypes.c_uint32), # RCC AHB1 peripheral reset register, Address offset: 0x10
+ ('AHB2RSTR' , ctypes.c_uint32), # RCC AHB2 peripheral reset register, Address offset: 0x14
+ ('RESERVED0' , ctypes.c_uint32 * 2), # Reserved, 0x18-0x1C
+ ('APB1RSTR' , ctypes.c_uint32), # RCC APB1 peripheral reset register, Address offset: 0x20
+ ('APB2RSTR' , ctypes.c_uint32), # RCC APB2 peripheral reset register, Address offset: 0x24
+ ('RESERVED1' , ctypes.c_uint32 * 2), # Reserved, 0x28-0x2C
+ ('AHB1ENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock register, Address offset: 0x30
+ ('AHB2ENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock register, Address offset: 0x34
+ ('RESERVED2' , ctypes.c_uint32 * 2), # Reserved, 0x38-0x3C
+ ('APB1ENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable register, Address offset: 0x40
+ ('APB2ENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable register, Address offset: 0x44
+ ('RESERVED3' , ctypes.c_uint32 * 2), # Reserved, 0x48-0x4C
+ ('AHB1LPENR' , ctypes.c_uint32), # RCC AHB1 peripheral clock enable in low power mode register, Address offset: 0x50
+ ('AHB2LPENR' , ctypes.c_uint32), # RCC AHB2 peripheral clock enable in low power mode register, Address offset: 0x54
+ ('RESERVED4' , ctypes.c_uint32 * 2), # Reserved, 0x58-0x5C
+ ('APB1LPENR' , ctypes.c_uint32), # RCC APB1 peripheral clock enable in low power mode register, Address offset: 0x60
+ ('APB2LPENR' , ctypes.c_uint32), # RCC APB2 peripheral clock enable in low power mode register, Address offset: 0x64
+ ('RESERVED5' , ctypes.c_uint32 * 2), # Reserved, 0x68-0x6C
+ ('BDCR' , ctypes.c_uint32), # RCC Backup domain control register, Address offset: 0x70
+ ('CSR' , ctypes.c_uint32), # RCC clock control & status register, Address offset: 0x74
+ ('RESERVED6' , ctypes.c_uint32 * 2), # Reserved, 0x78-0x7C
+ ('SSCGR' , ctypes.c_uint32), # RCC spread spectrum clock generation register, Address offset: 0x80
+ ('PLLI2SCFGR', ctypes.c_uint32), # RCC PLLI2S configuration register, Address offset: 0x84
+ ('RESERVED7' , ctypes.c_uint32), # Reserved, 0x88
+ ('DCKCFGR' , ctypes.c_uint32), # RCC Dedicated Clocks configuration register, Address offset: 0x8C
+ ('CKGATENR' , ctypes.c_uint32), # RCC Clocks Gated ENable Register, Address offset: 0x90
+ ('DCKCFGR2' , ctypes.c_uint32), # RCC Dedicated Clocks configuration register 2, Address offset: 0x94
+ ]
diff --git a/qiling/hw/misc/stm32f4xx_syscfg.py b/qiling/hw/misc/stm32f4xx_syscfg.py
index 8a63ab551..4360db2b0 100644
--- a/qiling/hw/misc/stm32f4xx_syscfg.py
+++ b/qiling/hw/misc/stm32f4xx_syscfg.py
@@ -10,25 +10,25 @@
class STM32F4xxSyscfg(QlPeripheral):
class Type(ctypes.Structure):
""" the structure available in :
- stm32f407xx.h
- stm32f469xx.h
- stm32f427xx.h
- stm32f401xc.h
- stm32f415xx.h
- stm32f439xx.h
- stm32f417xx.h
- stm32f479xx.h
- stm32f429xx.h
- stm32f437xx.h
- stm32f401xe.h
- stm32f405xx.h
- stm32f411xe.h
- """
+ stm32f407xx.h
+ stm32f469xx.h
+ stm32f427xx.h
+ stm32f401xc.h
+ stm32f415xx.h
+ stm32f439xx.h
+ stm32f417xx.h
+ stm32f479xx.h
+ stm32f429xx.h
+ stm32f437xx.h
+ stm32f401xe.h
+ stm32f405xx.h
+ stm32f411xe.h
+ """
_fields_ = [
- ('MEMRMP' , ctypes.c_uint32), # SYSCFG memory remap register, Address offset: 0x00
- ('PMC' , ctypes.c_uint32), # SYSCFG peripheral mode configuration register, Address offset: 0x04
- ('EXTICR' , ctypes.c_uint32 * 4), # SYSCFG external interrupt configuration registers, Address offset: 0x08-0x14
- ('RESERVED', ctypes.c_uint32 * 2), # Reserved, 0x18-0x1C
- ('CMPCR' , ctypes.c_uint32), # SYSCFG Compensation cell control register, Address offset: 0x20
- ]
\ No newline at end of file
+ ('MEMRMP' , ctypes.c_uint32), # SYSCFG memory remap register, Address offset: 0x00
+ ('PMC' , ctypes.c_uint32), # SYSCFG peripheral mode configuration register, Address offset: 0x04
+ ('EXTICR' , ctypes.c_uint32 * 4), # SYSCFG external interrupt configuration registers, Address offset: 0x08-0x14
+ ('RESERVED', ctypes.c_uint32 * 2), # Reserved, 0x18-0x1C
+ ('CMPCR' , ctypes.c_uint32), # SYSCFG Compensation cell control register, Address offset: 0x20
+ ]
\ No newline at end of file
diff --git a/qiling/hw/power/sam3xa_pmc.py b/qiling/hw/power/sam3xa_pmc.py
index b9f0d3e7c..b83e0f257 100644
--- a/qiling/hw/power/sam3xa_pmc.py
+++ b/qiling/hw/power/sam3xa_pmc.py
@@ -66,7 +66,7 @@ def __init__(self, ql: Qiling, label: str, intn = None):
self.intn = intn
@QlPeripheral.monitor()
- def read(self, offset: int, size: int) -> int:
+ def read(self, offset: int, size: int) -> int:
buf = ctypes.create_string_buffer(size)
ctypes.memmove(buf, ctypes.addressof(self.instance) + offset, size)
return int.from_bytes(buf.raw, byteorder='little')
diff --git a/qiling/hw/power/stm32f4xx_pwr.py b/qiling/hw/power/stm32f4xx_pwr.py
index c00279b67..916448e03 100644
--- a/qiling/hw/power/stm32f4xx_pwr.py
+++ b/qiling/hw/power/stm32f4xx_pwr.py
@@ -10,49 +10,49 @@
class STM32F4xxPwr(QlPeripheral):
- class Type(ctypes.Structure):
- """ the structure available in :
- stm32f413xx.h
- stm32f407xx.h
- stm32f469xx.h
- stm32f446xx.h
- stm32f427xx.h
- stm32f401xc.h
- stm32f415xx.h
- stm32f412cx.h
- stm32f410rx.h
- stm32f410tx.h
- stm32f439xx.h
- stm32f412vx.h
- stm32f417xx.h
- stm32f479xx.h
- stm32f429xx.h
- stm32f412rx.h
- stm32f423xx.h
- stm32f437xx.h
- stm32f412zx.h
- stm32f401xe.h
- stm32f410cx.h
- stm32f405xx.h
- stm32f411xe.h
- """
-
- _fields_ = [
- ('CR' , ctypes.c_uint32), # PWR power control register, Address offset: 0x00
- ('CSR', ctypes.c_uint32), # PWR power control/status register, Address offset: 0x04
- ]
-
- def __init__(self, ql: Qiling, label: str):
- super().__init__(ql, label)
-
- self.instance = self.struct()
-
- @QlPeripheral.monitor()
- def write(self, offset: int, size: int, value: int):
- if offset == self.struct.CR.offset:
- if value & PWR_CR.ODEN:
- self.instance.CSR |= PWR_CSR.ODRDY
- if value & PWR_CR.ODSWEN:
- self.instance.CSR |= PWR_CSR.ODSWRDY
-
- self.raw_write(offset, size, value)
\ No newline at end of file
+ class Type(ctypes.Structure):
+ """ the structure available in :
+ stm32f413xx.h
+ stm32f407xx.h
+ stm32f469xx.h
+ stm32f446xx.h
+ stm32f427xx.h
+ stm32f401xc.h
+ stm32f415xx.h
+ stm32f412cx.h
+ stm32f410rx.h
+ stm32f410tx.h
+ stm32f439xx.h
+ stm32f412vx.h
+ stm32f417xx.h
+ stm32f479xx.h
+ stm32f429xx.h
+ stm32f412rx.h
+ stm32f423xx.h
+ stm32f437xx.h
+ stm32f412zx.h
+ stm32f401xe.h
+ stm32f410cx.h
+ stm32f405xx.h
+ stm32f411xe.h
+ """
+
+ _fields_ = [
+ ('CR' , ctypes.c_uint32), # PWR power control register, Address offset: 0x00
+ ('CSR', ctypes.c_uint32), # PWR power control/status register, Address offset: 0x04
+ ]
+
+ def __init__(self, ql: Qiling, label: str):
+ super().__init__(ql, label)
+
+ self.instance = self.struct()
+
+ @QlPeripheral.monitor()
+ def write(self, offset: int, size: int, value: int):
+ if offset == self.struct.CR.offset:
+ if value & PWR_CR.ODEN:
+ self.instance.CSR |= PWR_CSR.ODRDY
+ if value & PWR_CR.ODSWEN:
+ self.instance.CSR |= PWR_CSR.ODSWRDY
+
+ self.raw_write(offset, size, value)
\ No newline at end of file
diff --git a/qiling/hw/spi/stm32f4xx_spi.py b/qiling/hw/spi/stm32f4xx_spi.py
index 1d47e2ff7..d2dcabab5 100644
--- a/qiling/hw/spi/stm32f4xx_spi.py
+++ b/qiling/hw/spi/stm32f4xx_spi.py
@@ -90,7 +90,7 @@ def write(self, offset: int, size: int, value: int):
value &= SPI_CR2.RW_MASK
elif offset == self.struct.CRCPR.offset:
- value &= SPI_CRCPR.CRCPOLY
+ value &= SPI_CRCPR.CRCPOLY
elif offset == self.struct.I2SCFGR.offset:
value &= SPI_I2SCFGR.RW_MASK
diff --git a/qiling/hw/timer/stm32f4xx_rtc.py b/qiling/hw/timer/stm32f4xx_rtc.py
index 34cc91768..1c5567120 100644
--- a/qiling/hw/timer/stm32f4xx_rtc.py
+++ b/qiling/hw/timer/stm32f4xx_rtc.py
@@ -13,30 +13,30 @@
class STM32F4xxRtc(QlPeripheral):
class Type(ctypes.Structure):
""" the structure is available in :
- stm32f423xx.h
- stm32f469xx.h
- stm32f427xx.h
- stm32f479xx.h
- stm32f413xx.h
- stm32f429xx.h
- stm32f439xx.h
- stm32f415xx.h
- stm32f412cx.h
- stm32f412rx.h
- stm32f410tx.h
- stm32f410cx.h
- stm32f412zx.h
- stm32f405xx.h
- stm32f407xx.h
- stm32f417xx.h
- stm32f446xx.h
- stm32f401xc.h
- stm32f437xx.h
- stm32f401xe.h
- stm32f412vx.h
- stm32f410rx.h
- stm32f411xe.h
- """
+ stm32f423xx.h
+ stm32f469xx.h
+ stm32f427xx.h
+ stm32f479xx.h
+ stm32f413xx.h
+ stm32f429xx.h
+ stm32f439xx.h
+ stm32f415xx.h
+ stm32f412cx.h
+ stm32f412rx.h
+ stm32f410tx.h
+ stm32f410cx.h
+ stm32f412zx.h
+ stm32f405xx.h
+ stm32f407xx.h
+ stm32f417xx.h
+ stm32f446xx.h
+ stm32f401xc.h
+ stm32f437xx.h
+ stm32f401xe.h
+ stm32f412vx.h
+ stm32f410rx.h
+ stm32f411xe.h
+ """
_fields_ = [
('TR' , ctypes.c_uint32), # RTC time register, Address offset: 0x00
diff --git a/qiling/os/dos/interrupts/__init__.py b/qiling/os/dos/interrupts/__init__.py
index e8e27c198..85a8e6c2a 100644
--- a/qiling/os/dos/interrupts/__init__.py
+++ b/qiling/os/dos/interrupts/__init__.py
@@ -22,14 +22,14 @@
# http://www2.ift.ulaval.ca/~marchand/ift17583/dosints.pdf
handlers: Mapping[int, IntHandler] = {
- 0x10: int10.handler,
- 0x13: int13.handler,
- 0x15: int15.handler,
- 0x16: int16.handler,
- 0x19: int19.handler,
- 0x1a: int1a.handler,
- 0x20: int20.handler,
- 0x21: int21.handler
+ 0x10: int10.handler,
+ 0x13: int13.handler,
+ 0x15: int15.handler,
+ 0x16: int16.handler,
+ 0x19: int19.handler,
+ 0x1a: int1a.handler,
+ 0x20: int20.handler,
+ 0x21: int21.handler
}
__all__ = ['handlers']
diff --git a/qiling/os/dos/interrupts/int10.py b/qiling/os/dos/interrupts/int10.py
index 9b887f0b2..7f2c07055 100644
--- a/qiling/os/dos/interrupts/int10.py
+++ b/qiling/os/dos/interrupts/int10.py
@@ -10,236 +10,236 @@
from qiling import Qiling
COLORS_MAPPING = {
- 0: curses.COLOR_BLACK,
- 1: curses.COLOR_BLUE,
- 2: curses.COLOR_GREEN,
- 3: curses.COLOR_CYAN,
- 4: curses.COLOR_RED,
- 5: curses.COLOR_MAGENTA,
- 6: 9,
- 7: 7,
- 8: 8,
- 9: 6,
- 10: 10,
- 11: 14,
- 12: 9,
- 13: 13,
- 14: curses.COLOR_YELLOW,
- 15: curses.COLOR_WHITE
+ 0: curses.COLOR_BLACK,
+ 1: curses.COLOR_BLUE,
+ 2: curses.COLOR_GREEN,
+ 3: curses.COLOR_CYAN,
+ 4: curses.COLOR_RED,
+ 5: curses.COLOR_MAGENTA,
+ 6: 9,
+ 7: 7,
+ 8: 8,
+ 9: 6,
+ 10: 10,
+ 11: 14,
+ 12: 9,
+ 13: 13,
+ 14: curses.COLOR_YELLOW,
+ 15: curses.COLOR_WHITE
}
REVERSE_COLORS_MAPPING = {v : k for k, v in COLORS_MAPPING.items()}
def get_attr(color_pairs: Mapping[int, Mapping[int, int]], char: int) -> int:
- fg = (char & 0x0f)
- bg = (char & 0xf0) >> 4
+ fg = (char & 0x0f)
+ bg = (char & 0xf0) >> 4
- # For blinking
- attr = color_pairs[fg][bg & 0b0111]
+ # For blinking
+ attr = color_pairs[fg][bg & 0b0111]
- if (bg & 0b1000) != 0:
- attr |= curses.A_BLINK
+ if (bg & 0b1000) != 0:
+ attr |= curses.A_BLINK
- return attr
+ return attr
def get_ch_non_blocking(scr) -> int:
- scr.timeout(0)
- key = scr.getch()
- scr.timeout(-1)
+ scr.timeout(0)
+ key = scr.getch()
+ scr.timeout(-1)
- return key
+ return key
def __leaf_00(ql: Qiling):
- # time to set up curses
- # copied from curses.wrapper
-
- stdscr = curses.initscr()
- curses.noecho()
- curses.cbreak()
- stdscr.keypad(True)
-
- try:
- curses.start_color()
- except:
- pass
-
- al = ql.arch.regs.al
-
- resolution = {
- 0x00 : (25, 40),
- 0x01 : (25, 40),
- 0x02 : (25, 80),
- 0x03 : (25, 80),
- 0x04 : (200, 320),
- 0x05 : (200, 320),
- 0x06 : (200, 640),
- 0x08 : (200, 160),
- 0x09 : (200, 320),
- 0x0a : (200, 640),
- 0x0d : (200, 320),
- 0x0e : (200, 640),
- 0x0f : (350, 640),
- 0x10 : (350, 640),
- 0x11 : (480, 640),
- 0x12 : (480, 640),
- 0x13 : (200, 320)
- }.get(al)
-
- if resolution is None:
- ql.log.exception(f'resolution not implemented (al: {al:#02x})')
- raise NotImplementedError()
-
- curses.resizeterm(*resolution)
-
- # Quoted from https://linux.die.net/man/3/resizeterm
- #
- # If ncurses is configured to supply its own SIGWINCH handler,
- # the resizeterm function ungetch's a KEY_RESIZE which will be
- # read on the next call to getch.
- ch = get_ch_non_blocking(stdscr)
-
- if ch == curses.KEY_RESIZE:
- ql.log.info(f'terminal has been resized')
- elif ch != -1:
- curses.ungetch(ch)
-
- stdscr.scrollok(True)
-
- if not curses.has_colors():
- ql.log.warning(f'your terminal does not support colors, content might not be displayed correctly')
-
- # https://en.wikipedia.org/wiki/BIOS_color_attributes
- # blink support?
- if curses.has_colors():
- for fg in range(16):
- for bg in range(16):
- color_pair_index = 16 * fg + bg + 1
-
- if fg not in ql.os.color_pairs:
- ql.os.color_pairs[fg] = {}
-
- curses.init_pair(color_pair_index, COLORS_MAPPING[fg], COLORS_MAPPING[bg])
- color_pair = curses.color_pair(color_pair_index)
-
- ql.os.color_pairs[fg][bg] = color_pair
- ql.os.revese_color_pairs[color_pair] = (fg, bg)
-
- ql.os.stdscr = stdscr
+ # time to set up curses
+ # copied from curses.wrapper
+
+ stdscr = curses.initscr()
+ curses.noecho()
+ curses.cbreak()
+ stdscr.keypad(True)
+
+ try:
+ curses.start_color()
+ except:
+ pass
+
+ al = ql.arch.regs.al
+
+ resolution = {
+ 0x00 : (25, 40),
+ 0x01 : (25, 40),
+ 0x02 : (25, 80),
+ 0x03 : (25, 80),
+ 0x04 : (200, 320),
+ 0x05 : (200, 320),
+ 0x06 : (200, 640),
+ 0x08 : (200, 160),
+ 0x09 : (200, 320),
+ 0x0a : (200, 640),
+ 0x0d : (200, 320),
+ 0x0e : (200, 640),
+ 0x0f : (350, 640),
+ 0x10 : (350, 640),
+ 0x11 : (480, 640),
+ 0x12 : (480, 640),
+ 0x13 : (200, 320)
+ }.get(al)
+
+ if resolution is None:
+ ql.log.exception(f'resolution not implemented (al: {al:#02x})')
+ raise NotImplementedError()
+
+ curses.resizeterm(*resolution)
+
+ # Quoted from https://linux.die.net/man/3/resizeterm
+ #
+ # If ncurses is configured to supply its own SIGWINCH handler,
+ # the resizeterm function ungetch's a KEY_RESIZE which will be
+ # read on the next call to getch.
+ ch = get_ch_non_blocking(stdscr)
+
+ if ch == curses.KEY_RESIZE:
+ ql.log.info(f'terminal has been resized')
+ elif ch != -1:
+ curses.ungetch(ch)
+
+ stdscr.scrollok(True)
+
+ if not curses.has_colors():
+ ql.log.warning(f'your terminal does not support colors, content might not be displayed correctly')
+
+ # https://en.wikipedia.org/wiki/BIOS_color_attributes
+ # blink support?
+ if curses.has_colors():
+ for fg in range(16):
+ for bg in range(16):
+ color_pair_index = 16 * fg + bg + 1
+
+ if fg not in ql.os.color_pairs:
+ ql.os.color_pairs[fg] = {}
+
+ curses.init_pair(color_pair_index, COLORS_MAPPING[fg], COLORS_MAPPING[bg])
+ color_pair = curses.color_pair(color_pair_index)
+
+ ql.os.color_pairs[fg][bg] = color_pair
+ ql.os.revese_color_pairs[color_pair] = (fg, bg)
+
+ ql.os.stdscr = stdscr
def __leaf_01(ql: Qiling):
- # limited support
- ch = ql.arch.regs.ch
+ # limited support
+ ch = ql.arch.regs.ch
- if (ch & 0x20):
- curses.curs_set(0)
+ if (ch & 0x20):
+ curses.curs_set(0)
def __leaf_02(ql: Qiling):
- # page number ignored
- dh = ql.arch.regs.dh # row
- dl = ql.arch.regs.dl # column
+ # page number ignored
+ dh = ql.arch.regs.dh # row
+ dl = ql.arch.regs.dl # column
- ql.os.stdscr.move(dh, dl)
+ ql.os.stdscr.move(dh, dl)
def __leaf_05(ql: Qiling):
- # No idea how to implement, do nothing here.
- ql.arch.regs.al = 0
+ # No idea how to implement, do nothing here.
+ ql.arch.regs.al = 0
def __leaf_06(ql: Qiling):
- stdscr = ql.os.stdscr
+ stdscr = ql.os.stdscr
- al = ql.arch.regs.al # lines to scroll
- ch = ql.arch.regs.ch # row of upper-left cornner
- cl = ql.arch.regs.cl # column of upper-left corner
- dh = ql.arch.regs.dh # row of lower right corner
- dl = ql.arch.regs.dl # column of lower righ corner
- bh = ql.arch.regs.bh # color
+ al = ql.arch.regs.al # lines to scroll
+ ch = ql.arch.regs.ch # row of upper-left cornner
+ cl = ql.arch.regs.cl # column of upper-left corner
+ dh = ql.arch.regs.dh # row of lower right corner
+ dl = ql.arch.regs.dl # column of lower righ corner
+ bh = ql.arch.regs.bh # color
- y, x = stdscr.getmaxyx()
- cy, cx = stdscr.getyx()
- attr = get_attr(ql.os.color_pairs, bh)
+ y, x = stdscr.getmaxyx()
+ cy, cx = stdscr.getyx()
+ attr = get_attr(ql.os.color_pairs, bh)
- if ch != 0 or cl != 0 or dh != y - 1 or dl != x - 1:
- ql.log.warning(f'Partial scroll is unsupported. Will scroll the whole page.')
- ql.log.warning(f'Resolution: {y}x{x} but asked to scroll [({ch},{cl}), ({dh}, {dl})]')
+ if ch != 0 or cl != 0 or dh != y - 1 or dl != x - 1:
+ ql.log.warning(f'Partial scroll is unsupported. Will scroll the whole page.')
+ ql.log.warning(f'Resolution: {y}x{x} but asked to scroll [({ch},{cl}), ({dh}, {dl})]')
- if al == 0:
- stdscr.clear()
+ if al == 0:
+ stdscr.clear()
- # Alternate way?
- #for ln in range(y):
- # stdscr.addstr(ln, 0, " " * x, attr)
+ # Alternate way?
+ #for ln in range(y):
+ # stdscr.addstr(ln, 0, " " * x, attr)
- stdscr.bkgd(" ", attr)
- stdscr.move(0, 0)
+ stdscr.bkgd(" ", attr)
+ stdscr.move(0, 0)
- else:
- stdscr.scroll(al)
- ny = 0
+ else:
+ stdscr.scroll(al)
+ ny = 0
- if cy - al < 0:
- ny = 0
- else:
- ny = cy - al + 1
+ if cy - al < 0:
+ ny = 0
+ else:
+ ny = cy - al + 1
- if al > y:
- al = y
+ if al > y:
+ al = y
- for ln in range(al):
- stdscr.addstr(ny + ln, 0, " " * x, attr)
+ for ln in range(al):
+ stdscr.addstr(ny + ln, 0, " " * x, attr)
- stdscr.move(cy, cx)
+ stdscr.move(cy, cx)
def __leaf_08(ql: Qiling):
- stdscr = ql.os.stdscr
+ stdscr = ql.os.stdscr
- if stdscr is None:
- ql.arch.regs.ax = 0x0720
- else:
- cy, cx = stdscr.getyx()
- inch = stdscr.inch(cy, cx)
- attr = inch & curses.A_COLOR
- ch = inch & 0xFF
- ql.arch.regs.al = ch
- pair_number = curses.pair_number(attr)
+ if stdscr is None:
+ ql.arch.regs.ax = 0x0720
+ else:
+ cy, cx = stdscr.getyx()
+ inch = stdscr.inch(cy, cx)
+ attr = inch & curses.A_COLOR
+ ch = inch & 0xFF
+ ql.arch.regs.al = ch
+ pair_number = curses.pair_number(attr)
- fg, bg = curses.pair_content(pair_number)
- orig_fg = REVERSE_COLORS_MAPPING[fg]
- orig_bg = REVERSE_COLORS_MAPPING[bg]
+ fg, bg = curses.pair_content(pair_number)
+ orig_fg = REVERSE_COLORS_MAPPING[fg]
+ orig_bg = REVERSE_COLORS_MAPPING[bg]
- if attr & curses.A_BLINK:
- orig_bg |= 0b1000
+ if attr & curses.A_BLINK:
+ orig_bg |= 0b1000
- ql.arch.regs.ah = ((orig_bg << 4) & orig_fg)
+ ql.arch.regs.ah = ((orig_bg << 4) & orig_fg)
def __leaf_0e(ql: Qiling):
- al = ql.arch.regs.al
+ al = ql.arch.regs.al
- ql.log.debug(f'echo: {al:02x} -> {curses.ascii.unctrl(al)}')
+ ql.log.debug(f'echo: {al:02x} -> {curses.ascii.unctrl(al)}')
- stdscr = ql.os.stdscr
- cy, cx = stdscr.getyx()
+ stdscr = ql.os.stdscr
+ cy, cx = stdscr.getyx()
- # https://stackoverflow.com/questions/27674158/how-to-get-color-information-with-mvinch
- # https://linux.die.net/man/3/inch
- # https://github.com/mirror/ncurses/blob/master/include/curses.h.in#L1197
- # wtf curses...
+ # https://stackoverflow.com/questions/27674158/how-to-get-color-information-with-mvinch
+ # https://linux.die.net/man/3/inch
+ # https://github.com/mirror/ncurses/blob/master/include/curses.h.in#L1197
+ # wtf curses...
- if al == 0xa:
- y, x = stdscr.getmaxyx()
+ if al == 0xa:
+ y, x = stdscr.getmaxyx()
- # \n will erase current line with echochar, so we have to handle it carefully.
- ql.log.info(f"Resolution: {x}x{y}, Cursor position: {cx},{cy}, Going to get a new line.")
+ # \n will erase current line with echochar, so we have to handle it carefully.
+ ql.log.info(f"Resolution: {x}x{y}, Cursor position: {cx},{cy}, Going to get a new line.")
- if (y - 1) == cy:
- # scroll doesn't affect our cursor
- stdscr.scroll(1)
- stdscr.move(cy, 0)
- else:
- stdscr.move(cy + 1, 0)
- else:
- attr = stdscr.inch(cy, cx) & curses.A_COLOR
+ if (y - 1) == cy:
+ # scroll doesn't affect our cursor
+ stdscr.scroll(1)
+ stdscr.move(cy, 0)
+ else:
+ stdscr.move(cy + 1, 0)
+ else:
+ attr = stdscr.inch(cy, cx) & curses.A_COLOR
- stdscr.echochar(al, attr)
+ stdscr.echochar(al, attr)
# BIOS video support
@@ -247,23 +247,23 @@ def __leaf_0e(ql: Qiling):
# https://stanislavs.org/helppc/idx_interrupt.html
# implemented by curses
def handler(ql: Qiling):
- ah = ql.arch.regs.ah
-
- leaffunc = {
- 0x00 : __leaf_00,
- 0x01 : __leaf_01,
- 0x02 : __leaf_02,
- 0x05 : __leaf_05,
- 0x06 : __leaf_06,
- 0x08 : __leaf_08,
- 0x0e : __leaf_0e
- }.get(ah)
-
- if leaffunc is None:
- ql.log.exception(f'leaf {ah:02x}h of INT 10h is not implemented')
- raise NotImplementedError()
-
- leaffunc(ql)
-
- if ql.os.stdscr is not None:
- ql.os.stdscr.refresh()
+ ah = ql.arch.regs.ah
+
+ leaffunc = {
+ 0x00 : __leaf_00,
+ 0x01 : __leaf_01,
+ 0x02 : __leaf_02,
+ 0x05 : __leaf_05,
+ 0x06 : __leaf_06,
+ 0x08 : __leaf_08,
+ 0x0e : __leaf_0e
+ }.get(ah)
+
+ if leaffunc is None:
+ ql.log.exception(f'leaf {ah:02x}h of INT 10h is not implemented')
+ raise NotImplementedError()
+
+ leaffunc(ql)
+
+ if ql.os.stdscr is not None:
+ ql.os.stdscr.refresh()
diff --git a/qiling/os/dos/interrupts/int13.py b/qiling/os/dos/interrupts/int13.py
index 1714111ab..142d82650 100644
--- a/qiling/os/dos/interrupts/int13.py
+++ b/qiling/os/dos/interrupts/int13.py
@@ -11,152 +11,152 @@
from .. import utils
class DiskError(IntEnum):
- NoError = 0
- BadCommand = 1
- AddressNotFound = 2
- DiskWriteProtectError = 3
- SectorNotFound = 4
- FixedDiskResetFailed = 5
- DiskChangedOrRemoved = 6
- BadFixedDiskParameterTable = 7
- DMAOverrun = 8
- DMAAcessAcrossBoundary = 9
- BadFixedDiskSectorFlag = 10
- BadFixedDiskCylinder = 11
- UnsupportedTrack = 12
- InvalidNumberofSectors = 13
+ NoError = 0
+ BadCommand = 1
+ AddressNotFound = 2
+ DiskWriteProtectError = 3
+ SectorNotFound = 4
+ FixedDiskResetFailed = 5
+ DiskChangedOrRemoved = 6
+ BadFixedDiskParameterTable = 7
+ DMAOverrun = 8
+ DMAAcessAcrossBoundary = 9
+ BadFixedDiskSectorFlag = 10
+ BadFixedDiskCylinder = 11
+ UnsupportedTrack = 12
+ InvalidNumberofSectors = 13
FixedDiskControlledDataAdressDetected = 14
FixedDiskDMAArbitrationLevelOutofRange = 15
- ECCErrorOnRead = 16
- RecoverableFixedDiskDataError = 17
- ControllerError = 32
- SeekFailure = 64
- Timeout = 128
- FixedDiskDriveNotReady = 170
- FixedDiskUndefinedError = 187
- FixedDiskWriteFault = 204
- FixedDiskStatusError = 224
- SenseOperationFailed = 255
+ ECCErrorOnRead = 16
+ RecoverableFixedDiskDataError = 17
+ ControllerError = 32
+ SeekFailure = 64
+ Timeout = 128
+ FixedDiskDriveNotReady = 170
+ FixedDiskUndefinedError = 187
+ FixedDiskWriteFault = 204
+ FixedDiskStatusError = 224
+ SenseOperationFailed = 255
def parse_dap(dapbs):
- return struct.unpack("> 8) | ((ql.arch.regs.cx & 0xC0) << 2)
- head = ql.arch.regs.dh
- sector = ql.arch.regs.cx & 63
- cnt = ql.arch.regs.al
+ cylinder = ((ql.arch.regs.cx & 0xff00) >> 8) | ((ql.arch.regs.cx & 0xC0) << 2)
+ head = ql.arch.regs.dh
+ sector = ql.arch.regs.cx & 63
+ cnt = ql.arch.regs.al
- disk = ql.os.fs_mapper.open(idx, None)
- content = disk.read_chs(cylinder, head, sector, cnt)
+ disk = ql.os.fs_mapper.open(idx, None)
+ content = disk.read_chs(cylinder, head, sector, cnt)
- ql.mem.write(utils.linaddr(ql.arch.regs.es, ql.arch.regs.bx), content)
- ql.os.clear_cf()
- ql.arch.regs.ah = 0
- ql.arch.regs.al = sector
+ ql.mem.write(utils.linaddr(ql.arch.regs.es, ql.arch.regs.bx), content)
+ ql.os.clear_cf()
+ ql.arch.regs.ah = 0
+ ql.arch.regs.al = sector
# @see: https://stanislavs.org/helppc/int_13-8.html
def __leaf_08(ql: Qiling):
- idx = ql.arch.regs.dl
+ idx = ql.arch.regs.dl
- if not ql.os.fs_mapper.has_mapping(idx):
- ql.log.warning(f'Warning: No such disk: {idx:#x}')
- ql.arch.regs.ah = DiskError.BadCommand.value
- ql.os.set_cf()
- return
+ if not ql.os.fs_mapper.has_mapping(idx):
+ ql.log.warning(f'Warning: No such disk: {idx:#x}')
+ ql.arch.regs.ah = DiskError.BadCommand.value
+ ql.os.set_cf()
+ return
- disk = ql.os.fs_mapper.open(idx, None)
- ql.arch.regs.dl = ql.os.fs_mapper.mapping_count()
- ql.arch.regs.dh = disk.n_heads - 1
- ql.arch.regs.bl = 0x4
- ql.arch.regs.di = 0
- ql.arch.regs.ds = 0
+ disk = ql.os.fs_mapper.open(idx, None)
+ ql.arch.regs.dl = ql.os.fs_mapper.mapping_count()
+ ql.arch.regs.dh = disk.n_heads - 1
+ ql.arch.regs.bl = 0x4
+ ql.arch.regs.di = 0
+ ql.arch.regs.ds = 0
- n_sectors = min(disk.n_sectors, 63)
- n_cylinders = min(disk.n_cylinders, 1023)
+ n_sectors = min(disk.n_sectors, 63)
+ n_cylinders = min(disk.n_cylinders, 1023)
- cx = (n_sectors & 0b111111)
- cx |= ((n_cylinders & 0b11) << 6)
- cx |= (((n_cylinders & 0b1111111100) >> 2) << 8)
+ cx = (n_sectors & 0b111111)
+ cx |= ((n_cylinders & 0b11) << 6)
+ cx |= (((n_cylinders & 0b1111111100) >> 2) << 8)
- ql.arch.regs.cx = cx
- ql.arch.regs.ah = 0
- ql.os.clear_cf()
+ ql.arch.regs.cx = cx
+ ql.arch.regs.ah = 0
+ ql.os.clear_cf()
def __leaf_41(ql: Qiling):
- ql.arch.regs.ah = 0
- # 1 -> Device Access using the packet structure.
- # 2 -> Drive locking and ejecting.
- # 4 -> Enhanced Disk Drive Support.
- ql.arch.regs.bx = 0xaa55
- ql.arch.regs.cx = 7
+ ql.arch.regs.ah = 0
+ # 1 -> Device Access using the packet structure.
+ # 2 -> Drive locking and ejecting.
+ # 4 -> Enhanced Disk Drive Support.
+ ql.arch.regs.bx = 0xaa55
+ ql.arch.regs.cx = 7
def __leaf_42(ql: Qiling):
- idx = ql.arch.regs.dl
+ idx = ql.arch.regs.dl
- if not ql.os.fs_mapper.has_mapping(idx):
- ql.log.warning(f'Warning: No such disk: {idx:#x}')
- ql.arch.regs.ah = DiskError.BadCommand.value
- ql.os.set_cf()
- return
+ if not ql.os.fs_mapper.has_mapping(idx):
+ ql.log.warning(f'Warning: No such disk: {idx:#x}')
+ ql.arch.regs.ah = DiskError.BadCommand.value
+ ql.os.set_cf()
+ return
- dapbs = ql.mem.read(utils.linaddr(ql.arch.regs.ds, ql.arch.regs.si), 16)
- _, _, cnt, offset, segment, lba = parse_dap(dapbs)
- ql.log.info(f'Reading {cnt} sectors from disk {idx:#x} with LBA {lba}')
+ dapbs = ql.mem.read(utils.linaddr(ql.arch.regs.ds, ql.arch.regs.si), 16)
+ _, _, cnt, offset, segment, lba = parse_dap(dapbs)
+ ql.log.info(f'Reading {cnt} sectors from disk {idx:#x} with LBA {lba}')
- disk = ql.os.fs_mapper.open(idx, None)
- content = disk.read_sectors(lba, cnt)
- ql.mem.write(utils.linaddr(segment, offset), content)
+ disk = ql.os.fs_mapper.open(idx, None)
+ content = disk.read_sectors(lba, cnt)
+ ql.mem.write(utils.linaddr(segment, offset), content)
- ql.os.clear_cf()
- ql.arch.regs.ah = 0
+ ql.os.clear_cf()
+ ql.arch.regs.ah = 0
def __leaf_43(ql: Qiling):
- idx = ql.arch.regs.dl
+ idx = ql.arch.regs.dl
- if not ql.os.fs_mapper.has_mapping(idx):
- ql.log.info(f"Warning: No such disk: {hex(idx)}")
- ql.arch.regs.ah = DiskError.BadCommand.value
- ql.os.set_cf()
- return
+ if not ql.os.fs_mapper.has_mapping(idx):
+ ql.log.info(f"Warning: No such disk: {hex(idx)}")
+ ql.arch.regs.ah = DiskError.BadCommand.value
+ ql.os.set_cf()
+ return
- dapbs = ql.mem.read(utils.linaddr(ql.arch.regs.ds, ql.arch.regs.si), 16)
- _, _, cnt, offset, segment, lba = parse_dap(dapbs)
- ql.log.info(f'Writing {cnt} sectors to disk {idx:#x} with LBA {lba}')
+ dapbs = ql.mem.read(utils.linaddr(ql.arch.regs.ds, ql.arch.regs.si), 16)
+ _, _, cnt, offset, segment, lba = parse_dap(dapbs)
+ ql.log.info(f'Writing {cnt} sectors to disk {idx:#x} with LBA {lba}')
- disk = ql.os.fs_mapper.open(idx, None)
- buffer = ql.mem.read(utils.linaddr(segment, offset), cnt * disk.sector_size)
- disk.write_sectors(lba, cnt, buffer)
+ disk = ql.os.fs_mapper.open(idx, None)
+ buffer = ql.mem.read(utils.linaddr(segment, offset), cnt * disk.sector_size)
+ disk.write_sectors(lba, cnt, buffer)
- ql.os.clear_cf()
- ql.arch.regs.ah = 0
+ ql.os.clear_cf()
+ ql.arch.regs.ah = 0
# @see: https://en.wikipedia.org/wiki/INT_13H
def handler(ql: Qiling):
- ah = ql.arch.regs.ah
-
- leaffunc = {
- 0x00 : __leaf_00,
- 0x02 : __leaf_02,
- 0x08 : __leaf_08,
- 0x41 : __leaf_41,
- 0x42 : __leaf_42,
- 0x43 : __leaf_43
- }.get(ah)
-
- if leaffunc is None:
- ql.log.exception(f'leaf {ah:02x}h of INT 13h is not implemented')
- raise NotImplementedError()
-
- leaffunc(ql)
+ ah = ql.arch.regs.ah
+
+ leaffunc = {
+ 0x00 : __leaf_00,
+ 0x02 : __leaf_02,
+ 0x08 : __leaf_08,
+ 0x41 : __leaf_41,
+ 0x42 : __leaf_42,
+ 0x43 : __leaf_43
+ }.get(ah)
+
+ if leaffunc is None:
+ ql.log.exception(f'leaf {ah:02x}h of INT 13h is not implemented')
+ raise NotImplementedError()
+
+ leaffunc(ql)
diff --git a/qiling/os/dos/interrupts/int15.py b/qiling/os/dos/interrupts/int15.py
index 87110d28f..f9917765f 100644
--- a/qiling/os/dos/interrupts/int15.py
+++ b/qiling/os/dos/interrupts/int15.py
@@ -10,51 +10,51 @@
# @see: http://www.oldlinux.org/Linux.old/docs/interrupts/int-html/int-15.htm
def __leaf_00(ql: Qiling):
- pass
+ pass
def __leaf_01(ql: Qiling):
- pass
+ pass
def __leaf_53(ql: Qiling):
- al = ql.arch.regs.al
-
- if al == 0x01:
- ql.os.clear_cf()
- elif al == 0x0e:
- ql.arch.regs.ax = 0x0102
- ql.os.clear_cf()
- elif al == 0x07:
- if (ql.arch.regs.bx == 1) and (ql.arch.regs.cx == 3):
- ql.log.info("Emulation Stop")
- ql.emu_stop()
- else:
- raise NotImplementedError()
+ al = ql.arch.regs.al
+
+ if al == 0x01:
+ ql.os.clear_cf()
+ elif al == 0x0e:
+ ql.arch.regs.ax = 0x0102
+ ql.os.clear_cf()
+ elif al == 0x07:
+ if (ql.arch.regs.bx == 1) and (ql.arch.regs.cx == 3):
+ ql.log.info("Emulation Stop")
+ ql.emu_stop()
+ else:
+ raise NotImplementedError()
def __leaf_86(ql: Qiling):
- dx = ql.arch.regs.dx
- cx = ql.arch.regs.cx
- full_secs = ((cx << 16) + dx) / 1000000
+ dx = ql.arch.regs.dx
+ cx = ql.arch.regs.cx
+ full_secs = ((cx << 16) + dx) / 1000000
- ql.log.info(f"Goint to sleep for {full_secs} seconds")
- time.sleep(full_secs)
+ ql.log.info(f"Goint to sleep for {full_secs} seconds")
+ time.sleep(full_secs)
- # Note: Since we are in a single thread environment, we assume
- # that no one will wait at the same time.
- ql.os.clear_cf()
- ql.arch.regs.ah = 0x80
+ # Note: Since we are in a single thread environment, we assume
+ # that no one will wait at the same time.
+ ql.os.clear_cf()
+ ql.arch.regs.ah = 0x80
def handler(ql: Qiling):
- ah = ql.arch.regs.ah
+ ah = ql.arch.regs.ah
- leaffunc = {
- 0x00 : __leaf_00,
- 0x01 : __leaf_01,
- 0x53 : __leaf_53,
- 0x86 : __leaf_86
- }.get(ah)
+ leaffunc = {
+ 0x00 : __leaf_00,
+ 0x01 : __leaf_01,
+ 0x53 : __leaf_53,
+ 0x86 : __leaf_86
+ }.get(ah)
- if leaffunc is None:
- ql.log.exception(f'leaf {ah:02x}h of INT 15h is not implemented')
- raise NotImplementedError()
+ if leaffunc is None:
+ ql.log.exception(f'leaf {ah:02x}h of INT 15h is not implemented')
+ raise NotImplementedError()
- leaffunc(ql)
+ leaffunc(ql)
diff --git a/qiling/os/dos/interrupts/int16.py b/qiling/os/dos/interrupts/int16.py
index 215d20c2f..293fae37a 100644
--- a/qiling/os/dos/interrupts/int16.py
+++ b/qiling/os/dos/interrupts/int16.py
@@ -119,59 +119,59 @@
}
def parse_key(ky):
- # https://stackoverflow.com/questions/27200597/c-ncurses-key-backspace-not-working
- # https://stackoverflow.com/questions/44943249/detecting-key-backspace-in-ncurses
+ # https://stackoverflow.com/questions/27200597/c-ncurses-key-backspace-not-working
+ # https://stackoverflow.com/questions/44943249/detecting-key-backspace-in-ncurses
- # oh my curses...
- if ky == curses.KEY_BACKSPACE or ky == 127:
- ky = ord(b'\b')
+ # oh my curses...
+ if ky == curses.KEY_BACKSPACE or ky == 127:
+ ky = ord(b'\b')
- return ky
+ return ky
def get_scan_code(ch):
- return SCANCODES.get(ch, 0)
+ return SCANCODES.get(ch, 0)
def __leaf_00(ql: Qiling):
- curses.nonl()
- key = parse_key(ql.os.stdscr.getch())
- ql.log.debug(f"Get key: {hex(key)}")
- if curses.ascii.isascii(key):
- ql.arch.regs.al = key
- else:
- ql.arch.regs.al = 0
- ql.arch.regs.ah = get_scan_code(key)
- curses.nl()
+ curses.nonl()
+ key = parse_key(ql.os.stdscr.getch())
+ ql.log.debug(f"Get key: {hex(key)}")
+ if curses.ascii.isascii(key):
+ ql.arch.regs.al = key
+ else:
+ ql.arch.regs.al = 0
+ ql.arch.regs.ah = get_scan_code(key)
+ curses.nl()
def __leaf_01(ql: Qiling):
- curses.nonl()
- # set non-blocking
- ql.os.stdscr.timeout(0)
- key = parse_key(ql.os.stdscr.getch())
+ curses.nonl()
+ # set non-blocking
+ ql.os.stdscr.timeout(0)
+ key = parse_key(ql.os.stdscr.getch())
- if key == -1:
- ql.os.set_zf()
- ql.arch.regs.ax = 0
- else:
- ql.log.debug(f"Has key: {hex(key)} ({curses.ascii.unctrl(key)})")
- ql.arch.regs.al = key
- ql.arch.regs.ah = get_scan_code(key)
- ql.os.clear_zf()
- # Buffer shouldn't be removed in this interrupt.
- curses.ungetch(key)
+ if key == -1:
+ ql.os.set_zf()
+ ql.arch.regs.ax = 0
+ else:
+ ql.log.debug(f"Has key: {hex(key)} ({curses.ascii.unctrl(key)})")
+ ql.arch.regs.al = key
+ ql.arch.regs.ah = get_scan_code(key)
+ ql.os.clear_zf()
+ # Buffer shouldn't be removed in this interrupt.
+ curses.ungetch(key)
- ql.os.stdscr.timeout(-1)
- curses.nl()
+ ql.os.stdscr.timeout(-1)
+ curses.nl()
def handler(ql: Qiling):
- ah = ql.arch.regs.ah
+ ah = ql.arch.regs.ah
- leaffunc = {
- 0x00 : __leaf_00,
- 0x01 : __leaf_01
- }.get(ah)
+ leaffunc = {
+ 0x00 : __leaf_00,
+ 0x01 : __leaf_01
+ }.get(ah)
- if leaffunc is None:
- ql.log.exception(f'leaf {ah:02x}h of INT 16h is not implemented')
- raise NotImplementedError()
+ if leaffunc is None:
+ ql.log.exception(f'leaf {ah:02x}h of INT 16h is not implemented')
+ raise NotImplementedError()
- leaffunc(ql)
+ leaffunc(ql)
diff --git a/qiling/os/dos/interrupts/int19.py b/qiling/os/dos/interrupts/int19.py
index 4513e0200..c73268c9d 100644
--- a/qiling/os/dos/interrupts/int19.py
+++ b/qiling/os/dos/interrupts/int19.py
@@ -6,18 +6,18 @@
from qiling import Qiling
def handler(ql: Qiling):
- # Note: Memory is not cleaned.
- dl = ql.arch.regs.dl
+ # Note: Memory is not cleaned.
+ dl = ql.arch.regs.dl
- if ql.os.fs_mapper.has_mapping(dl):
- disk = ql.os.fs_mapper.open(dl, None)
- disk.lseek(0, 0)
- mbr = disk.read(512)
- else:
- with open(ql.path, "rb") as f:
- mbr = f.read()
+ if ql.os.fs_mapper.has_mapping(dl):
+ disk = ql.os.fs_mapper.open(dl, None)
+ disk.lseek(0, 0)
+ mbr = disk.read(512)
+ else:
+ with open(ql.path, "rb") as f:
+ mbr = f.read()
- ql.mem.write(0x7C00, mbr)
+ ql.mem.write(0x7C00, mbr)
- ql.arch.regs.cs = 0x07C0
- ql.arch.regs.ip = 0x0000
+ ql.arch.regs.cs = 0x07C0
+ ql.arch.regs.ip = 0x0000
diff --git a/qiling/os/dos/interrupts/int1a.py b/qiling/os/dos/interrupts/int1a.py
index 4f7edc1f9..09af06961 100644
--- a/qiling/os/dos/interrupts/int1a.py
+++ b/qiling/os/dos/interrupts/int1a.py
@@ -10,76 +10,76 @@
from .. import utils
def __set_elapsed_ticks(ql: Qiling):
- now = datetime.now()
- ticks = int((now - ql.os.start_time).total_seconds() * ql.os.ticks_per_second)
+ now = datetime.now()
+ ticks = int((now - ql.os.start_time).total_seconds() * ql.os.ticks_per_second)
- ql.arch.regs.cx = (ticks >> 16) & 0xffff
- ql.arch.regs.dx = (ticks >> 0) & 0xffff
+ ql.arch.regs.cx = (ticks >> 16) & 0xffff
+ ql.arch.regs.dx = (ticks >> 0) & 0xffff
def __leaf_00(ql: Qiling):
- __set_elapsed_ticks(ql)
+ __set_elapsed_ticks(ql)
- ql.arch.regs.al = 0
+ ql.arch.regs.al = 0
def __leaf_01(ql: Qiling):
- __set_elapsed_ticks(ql)
+ __set_elapsed_ticks(ql)
def __leaf_02_03(ql: Qiling):
- now = datetime.now()
+ now = datetime.now()
- ql.arch.regs.ch = utils.BIN2BCD(now.hour)
- ql.arch.regs.cl = utils.BIN2BCD(now.minute)
- ql.arch.regs.dh = utils.BIN2BCD(now.second)
- ql.arch.regs.dl = 0
+ ql.arch.regs.ch = utils.BIN2BCD(now.hour)
+ ql.arch.regs.cl = utils.BIN2BCD(now.minute)
+ ql.arch.regs.dh = utils.BIN2BCD(now.second)
+ ql.arch.regs.dl = 0
- ql.os.clear_cf()
+ ql.os.clear_cf()
def __leaf_04_05(ql: Qiling):
- now = datetime.now()
+ now = datetime.now()
- # See https://sites.google.com/site/liangweiqiang/Home/e5006/e5006classnote/jumptiming/int1ahclockservice
- ql.arch.regs.ch = utils.BIN2BCD((now.year - 1) // 100)
- ql.arch.regs.cl = utils.BIN2BCD(now.year % 100)
- ql.arch.regs.dh = utils.BIN2BCD(now.month)
- ql.arch.regs.dl = utils.BIN2BCD(now.day)
+ # See https://sites.google.com/site/liangweiqiang/Home/e5006/e5006classnote/jumptiming/int1ahclockservice
+ ql.arch.regs.ch = utils.BIN2BCD((now.year - 1) // 100)
+ ql.arch.regs.cl = utils.BIN2BCD(now.year % 100)
+ ql.arch.regs.dh = utils.BIN2BCD(now.month)
+ ql.arch.regs.dl = utils.BIN2BCD(now.day)
- ql.os.clear_cf()
+ ql.os.clear_cf()
def __leaf_06_07_09(ql: Qiling):
- # TODO: Implement clock interrupt.
- ql.os.set_cf()
+ # TODO: Implement clock interrupt.
+ ql.os.set_cf()
def __leaf_08(ql: Qiling):
- pass
+ pass
def __leaf_0a(ql: Qiling):
- now = datetime.now()
+ now = datetime.now()
- ql.arch.regs.cx = (now - datetime(1980, 1, 1)).days
+ ql.arch.regs.cx = (now - datetime(1980, 1, 1)).days
def __leaf_0b(ql: Qiling):
- pass
+ pass
def handler(ql: Qiling):
- ah = ql.arch.regs.ah
-
- leaffunc = {
- 0x00 : __leaf_00,
- 0x01 : __leaf_01,
- 0x02 : __leaf_02_03,
- 0x03 : __leaf_02_03,
- 0x04 : __leaf_04_05,
- 0x05 : __leaf_04_05,
- 0x06 : __leaf_06_07_09,
- 0x07 : __leaf_06_07_09,
- 0x08 : __leaf_08,
- 0x09 : __leaf_06_07_09,
- 0x0a : __leaf_0a,
- 0x0b : __leaf_0b
- }.get(ah)
-
- if leaffunc is None:
- ql.log.exception(f'leaf {ah:02x}h of INT 1Ah is not implemented')
- raise NotImplementedError()
-
- leaffunc(ql)
+ ah = ql.arch.regs.ah
+
+ leaffunc = {
+ 0x00 : __leaf_00,
+ 0x01 : __leaf_01,
+ 0x02 : __leaf_02_03,
+ 0x03 : __leaf_02_03,
+ 0x04 : __leaf_04_05,
+ 0x05 : __leaf_04_05,
+ 0x06 : __leaf_06_07_09,
+ 0x07 : __leaf_06_07_09,
+ 0x08 : __leaf_08,
+ 0x09 : __leaf_06_07_09,
+ 0x0a : __leaf_0a,
+ 0x0b : __leaf_0b
+ }.get(ah)
+
+ if leaffunc is None:
+ ql.log.exception(f'leaf {ah:02x}h of INT 1Ah is not implemented')
+ raise NotImplementedError()
+
+ leaffunc(ql)
diff --git a/qiling/os/dos/interrupts/int20.py b/qiling/os/dos/interrupts/int20.py
index 14bc51fdb..0dd639c21 100644
--- a/qiling/os/dos/interrupts/int20.py
+++ b/qiling/os/dos/interrupts/int20.py
@@ -6,17 +6,17 @@
from qiling import Qiling
def __leaf_13(self):
- pass
+ pass
def handler(ql: Qiling):
- ah = ql.arch.regs.ah
+ ah = ql.arch.regs.ah
- leaffunc = {
- 0x13 : __leaf_13
- }.get(ah)
+ leaffunc = {
+ 0x13 : __leaf_13
+ }.get(ah)
- if leaffunc is None:
- ql.log.exception(f'leaf {ah:02x}h of INT 20h is not implemented')
- raise NotImplementedError()
+ if leaffunc is None:
+ ql.log.exception(f'leaf {ah:02x}h of INT 20h is not implemented')
+ raise NotImplementedError()
- leaffunc(ql)
+ leaffunc(ql)
diff --git a/qiling/os/dos/interrupts/int21.py b/qiling/os/dos/interrupts/int21.py
index a87094941..a360b8a45 100644
--- a/qiling/os/dos/interrupts/int21.py
+++ b/qiling/os/dos/interrupts/int21.py
@@ -11,151 +11,151 @@
# exit
def __leaf_4c(ql: Qiling):
- ql.log.info("Program terminated gracefully")
- ql.emu_stop()
+ ql.log.info("Program terminated gracefully")
+ ql.emu_stop()
# write a character to screen
def __leaf_02(ql: Qiling):
- ch = ql.arch.regs.dl
- ql.arch.regs.al = ch
+ ch = ql.arch.regs.dl
+ ql.arch.regs.al = ch
- print(f'{ch:c}', end='')
+ print(f'{ch:c}', end='')
# write a string to screen
def __leaf_09(ql: Qiling):
- print(utils.read_dos_string_from_ds_dx(ql))
+ print(utils.read_dos_string_from_ds_dx(ql))
# clear input buffer
def __leaf_0c(ql: Qiling):
- pass
+ pass
# set interrupt vector
def __leaf_25(ql: Qiling):
- pass
+ pass
# create psp
def __leaf_26(ql: Qiling):
- pass
+ pass
# get dos version
def __leaf_30(ql: Qiling):
- ql.arch.regs.ax = ql.os.dos_ver
+ ql.arch.regs.ax = ql.os.dos_ver
# get or set ctrl-break
def __leaf_33(ql: Qiling):
- pass
+ pass
# get interrupt vector
def __leaf_35(ql: Qiling):
- pass
+ pass
# open file for write
def __leaf_3c(ql: Qiling):
- # fileattr ignored
- fname = utils.read_dos_string_from_ds_dx(ql)
- fpath = ql.os.path.transform_to_real_path(fname)
+ # fileattr ignored
+ fname = utils.read_dos_string_from_ds_dx(ql)
+ fpath = ql.os.path.transform_to_real_path(fname)
- ql.os.handles[ql.os.handle_next] = open(fpath, "wb")
- ql.arch.regs.ax = ql.os.handle_next
- ql.os.handle_next += 1
- ql.os.clear_cf()
+ ql.os.handles[ql.os.handle_next] = open(fpath, "wb")
+ ql.arch.regs.ax = ql.os.handle_next
+ ql.os.handle_next += 1
+ ql.os.clear_cf()
# open file for read
def __leaf_3d(ql: Qiling):
- fname = utils.read_dos_string_from_ds_dx(ql)
- fpath = ql.os.path.transform_to_real_path(fname)
+ fname = utils.read_dos_string_from_ds_dx(ql)
+ fpath = ql.os.path.transform_to_real_path(fname)
- ql.os.handles[ql.os.handle_next] = open(fpath, "rb")
- ql.arch.regs.ax = ql.os.handle_next
- ql.os.handle_next += 1
- ql.os.clear_cf()
+ ql.os.handles[ql.os.handle_next] = open(fpath, "rb")
+ ql.arch.regs.ax = ql.os.handle_next
+ ql.os.handle_next += 1
+ ql.os.clear_cf()
# close file
def __leaf_3e(ql: Qiling):
- hd = ql.arch.regs.bx
+ hd = ql.arch.regs.bx
- if hd in ql.os.handles:
- f = ql.os.handles.pop(hd)
- f.close()
+ if hd in ql.os.handles:
+ f = ql.os.handles.pop(hd)
+ f.close()
- ql.os.clear_cf()
- else:
- ql.arch.regs.ax = 0x06
- ql.os.set_cf()
+ ql.os.clear_cf()
+ else:
+ ql.arch.regs.ax = 0x06
+ ql.os.set_cf()
# read from file
def __leaf_3f(ql: Qiling):
- hd = ql.arch.regs.bx
-
- if hd in ql.os.handles:
- f = ql.os.handles[hd]
- buffer = utils.linaddr(ql.arch.regs.ds, ql.arch.regs.dx)
- sz = ql.arch.regs.cx
- rd = f.read(sz)
- ql.mem.write(buffer, rd)
- ql.os.clear_cf()
- ql.arch.regs.ax = len(rd)
- else:
- ql.arch.regs.ax = 0x06
- ql.os.set_cf()
+ hd = ql.arch.regs.bx
+
+ if hd in ql.os.handles:
+ f = ql.os.handles[hd]
+ buffer = utils.linaddr(ql.arch.regs.ds, ql.arch.regs.dx)
+ sz = ql.arch.regs.cx
+ rd = f.read(sz)
+ ql.mem.write(buffer, rd)
+ ql.os.clear_cf()
+ ql.arch.regs.ax = len(rd)
+ else:
+ ql.arch.regs.ax = 0x06
+ ql.os.set_cf()
# write to file
def __leaf_40(ql: Qiling):
- hd = ql.arch.regs.bx
-
- if hd in ql.os.handles:
- f = ql.os.handles[hd]
- buffer = utils.linaddr(ql.arch.regs.ds, ql.arch.regs.dx)
- sz = ql.arch.regs.cx
- rd = ql.mem.read(buffer, sz)
- f.write(bytes(rd))
- ql.os.clear_cf()
- ql.arch.regs.ax = len(rd)
- else:
- ql.arch.regs.ax = 0x06
- ql.os.set_cf()
+ hd = ql.arch.regs.bx
+
+ if hd in ql.os.handles:
+ f = ql.os.handles[hd]
+ buffer = utils.linaddr(ql.arch.regs.ds, ql.arch.regs.dx)
+ sz = ql.arch.regs.cx
+ rd = ql.mem.read(buffer, sz)
+ f.write(bytes(rd))
+ ql.os.clear_cf()
+ ql.arch.regs.ax = len(rd)
+ else:
+ ql.arch.regs.ax = 0x06
+ ql.os.set_cf()
# delete file
def __leaf_41(ql: Qiling):
- fname = utils.read_dos_string_from_ds_dx(ql)
- fpath = ql.os.path.transform_to_real_path(fname)
+ fname = utils.read_dos_string_from_ds_dx(ql)
+ fpath = ql.os.path.transform_to_real_path(fname)
- try:
- os.remove(fpath)
- ql.os.clear_cf()
- except OSError:
- ql.arch.regs.ax = 0x05
- ql.os.set_cf()
+ try:
+ os.remove(fpath)
+ ql.os.clear_cf()
+ except OSError:
+ ql.arch.regs.ax = 0x05
+ ql.os.set_cf()
def __leaf_43(ql: Qiling):
- ql.arch.regs.cx = 0xffff
- ql.os.clear_cf()
+ ql.arch.regs.cx = 0xffff
+ ql.os.clear_cf()
def handler(ql: Qiling):
- ah = ql.arch.regs.ah
-
- leaffunc = {
- 0x02 : __leaf_02,
- 0x06 : __leaf_02,
- 0x09 : __leaf_09,
- 0x0c : __leaf_0c,
- 0x25 : __leaf_25,
- 0x26 : __leaf_26,
- 0x30 : __leaf_30,
- 0x33 : __leaf_33,
- 0x35 : __leaf_35,
- 0x3c : __leaf_3c,
- 0x3d : __leaf_3d,
- 0x3e : __leaf_3e,
- 0x3f : __leaf_3f,
- 0x40 : __leaf_40,
- 0x41 : __leaf_41,
- 0x43 : __leaf_43,
- 0x4c : __leaf_4c
- }.get(ah)
-
- if leaffunc is None:
- ql.log.exception(f'leaf {ah:02x}h of INT 21h is not implemented')
- raise NotImplementedError()
-
- leaffunc(ql)
+ ah = ql.arch.regs.ah
+
+ leaffunc = {
+ 0x02 : __leaf_02,
+ 0x06 : __leaf_02,
+ 0x09 : __leaf_09,
+ 0x0c : __leaf_0c,
+ 0x25 : __leaf_25,
+ 0x26 : __leaf_26,
+ 0x30 : __leaf_30,
+ 0x33 : __leaf_33,
+ 0x35 : __leaf_35,
+ 0x3c : __leaf_3c,
+ 0x3d : __leaf_3d,
+ 0x3e : __leaf_3e,
+ 0x3f : __leaf_3f,
+ 0x40 : __leaf_40,
+ 0x41 : __leaf_41,
+ 0x43 : __leaf_43,
+ 0x4c : __leaf_4c
+ }.get(ah)
+
+ if leaffunc is None:
+ ql.log.exception(f'leaf {ah:02x}h of INT 21h is not implemented')
+ raise NotImplementedError()
+
+ leaffunc(ql)
diff --git a/qiling/os/fcall.py b/qiling/os/fcall.py
index 30fff7594..eef3b6207 100644
--- a/qiling/os/fcall.py
+++ b/qiling/os/fcall.py
@@ -19,194 +19,194 @@
TypedArg = Tuple[Any, str, Any]
class QlFunctionCall:
- def __init__(self, ql: Qiling, cc: QlCC, accessors: Mapping[int, Accessor] = {}) -> None:
- """Initialize function call handler.
+ def __init__(self, ql: Qiling, cc: QlCC, accessors: Mapping[int, Accessor] = {}) -> None:
+ """Initialize function call handler.
- Args:
- ql: qiling instance
- cc: calling convention instance to handle the call
- accessors: a mapping of parameter types to methods that read and write their values (optional)
- """
+ Args:
+ ql: qiling instance
+ cc: calling convention instance to handle the call
+ accessors: a mapping of parameter types to methods that read and write their values (optional)
+ """
- self.ql = ql
- self.cc = cc
+ self.ql = ql
+ self.cc = cc
- def __make_accessor(nbits: int) -> Accessor:
- reader = lambda si: cc.getRawParam(si, nbits)
- writer = lambda si, val: cc.setRawParam(si, val, nbits)
- nslots = cc.getNumSlots(nbits)
+ def __make_accessor(nbits: int) -> Accessor:
+ reader = lambda si: cc.getRawParam(si, nbits)
+ writer = lambda si, val: cc.setRawParam(si, val, nbits)
+ nslots = cc.getNumSlots(nbits)
- return (reader, writer, nslots)
+ return (reader, writer, nslots)
- # default parameter accessors: readers, writers and slots count
- self.accessors: MutableMapping[int, Accessor] = {
- PARAM_INT8 : __make_accessor(8),
- PARAM_INT16: __make_accessor(16),
- PARAM_INT32: __make_accessor(32),
- PARAM_INT64: __make_accessor(64),
- PARAM_INTN : __make_accessor(0)
- }
+ # default parameter accessors: readers, writers and slots count
+ self.accessors: MutableMapping[int, Accessor] = {
+ PARAM_INT8 : __make_accessor(8),
+ PARAM_INT16: __make_accessor(16),
+ PARAM_INT32: __make_accessor(32),
+ PARAM_INT64: __make_accessor(64),
+ PARAM_INTN : __make_accessor(0)
+ }
- # let the user override default accessors or add custom ones
- self.accessors.update(accessors)
+ # let the user override default accessors or add custom ones
+ self.accessors.update(accessors)
- def readEllipsis(self, ptypes: Sequence[Any]) -> Iterator[int]:
- """
- """
+ def readEllipsis(self, ptypes: Sequence[Any]) -> Iterator[int]:
+ """
+ """
- default = self.accessors[PARAM_INTN]
+ default = self.accessors[PARAM_INTN]
- # count skipped slots
- si = sum(self.accessors.get(typ, default)[2] for typ in ptypes)
+ # count skipped slots
+ si = sum(self.accessors.get(typ, default)[2] for typ in ptypes)
- while True:
- read, _, nslots = default
+ while True:
+ read, _, nslots = default
- yield read(si)
- si += nslots
+ yield read(si)
+ si += nslots
- def readParams(self, ptypes: Sequence[Any]) -> Sequence[int]:
- """Walk the function parameters list and get their values.
+ def readParams(self, ptypes: Sequence[Any]) -> Sequence[int]:
+ """Walk the function parameters list and get their values.
- Args:
- ptypes: a sequence of parameters types to read
+ Args:
+ ptypes: a sequence of parameters types to read
- Returns: parameters raw values
- """
+ Returns: parameters raw values
+ """
- default = self.accessors[PARAM_INTN]
+ default = self.accessors[PARAM_INTN]
- si = 0
- values = []
+ si = 0
+ values = []
- for typ in ptypes:
- read, _, nslots = self.accessors.get(typ, default)
+ for typ in ptypes:
+ read, _, nslots = self.accessors.get(typ, default)
- val = read(si)
- si += nslots
+ val = read(si)
+ si += nslots
- values.append(val)
+ values.append(val)
- return values
+ return values
- def writeParams(self, params: Sequence[Tuple[Any, int]]) -> None:
- """Walk the function parameters list and set their values.
+ def writeParams(self, params: Sequence[Tuple[Any, int]]) -> None:
+ """Walk the function parameters list and set their values.
- Args:
- params: a sequence of 2-tuples containing parameters types and values
- """
+ Args:
+ params: a sequence of 2-tuples containing parameters types and values
+ """
- default = self.accessors[PARAM_INTN]
+ default = self.accessors[PARAM_INTN]
- si = 0
+ si = 0
- for typ, val in params:
- _, write, nslots = self.accessors.get(typ, default)
+ for typ, val in params:
+ _, write, nslots = self.accessors.get(typ, default)
- write(si, val)
- si += nslots
+ write(si, val)
+ si += nslots
- def __count_slots(self, ptypes: Iterable[Any]) -> int:
- default = self.accessors[PARAM_INTN]
+ def __count_slots(self, ptypes: Iterable[Any]) -> int:
+ default = self.accessors[PARAM_INTN]
- return sum(self.accessors.get(typ, default)[2] for typ in ptypes)
+ return sum(self.accessors.get(typ, default)[2] for typ in ptypes)
- @staticmethod
- def __get_typed_args(proto: Mapping[str, Any], args: Mapping[str, Any]) -> Iterable[TypedArg]:
- types = list(proto.values())
- names = list(args.keys())
- values = list(args.values())
+ @staticmethod
+ def __get_typed_args(proto: Mapping[str, Any], args: Mapping[str, Any]) -> Iterable[TypedArg]:
+ types = list(proto.values())
+ names = list(args.keys())
+ values = list(args.values())
- # variadic functions are invoked with unknown set of arguments which
- # do not explicitly appear in prototype (there is an ellipsis instead).
- #
- # when a hooked variadic function is called, it updates the arguments
- # mapping with the additional arguments it was given. that makes the
- # arguments mapping longer than the prototype mapping; in other words:
- # at this point we may have more values and names than types.
- #
- # here we expand the types list to meet names length, in such a case.
- if len(names) > len(types):
- types.extend([None] * (len(names) - len(types)))
+ # variadic functions are invoked with unknown set of arguments which
+ # do not explicitly appear in prototype (there is an ellipsis instead).
+ #
+ # when a hooked variadic function is called, it updates the arguments
+ # mapping with the additional arguments it was given. that makes the
+ # arguments mapping longer than the prototype mapping; in other words:
+ # at this point we may have more values and names than types.
+ #
+ # here we expand the types list to meet names length, in such a case.
+ if len(names) > len(types):
+ types.extend([None] * (len(names) - len(types)))
- return tuple(zip(types, names, values))
+ return tuple(zip(types, names, values))
- def call(self, func: CallHook, proto: Mapping[str, Any], params: Mapping[str, Any], hook_onenter: Optional[OnEnterHook], hook_onexit: Optional[OnExitHook], passthru: bool) -> Tuple[Iterable[TypedArg], int, int]:
- """Execute a hooked function.
+ def call(self, func: CallHook, proto: Mapping[str, Any], params: Mapping[str, Any], hook_onenter: Optional[OnEnterHook], hook_onexit: Optional[OnExitHook], passthru: bool) -> Tuple[Iterable[TypedArg], int, int]:
+ """Execute a hooked function.
- Args:
- func: function hook
- proto: function's parameters types list
- params: a mapping of parameter names to their values
- hook_onenter: a hook to call before entering function hook
- hook_onexit: a hook to call after returning from function hook
- passthru: whether to skip stack frame unwinding
+ Args:
+ func: function hook
+ proto: function's parameters types list
+ params: a mapping of parameter names to their values
+ hook_onenter: a hook to call before entering function hook
+ hook_onexit: a hook to call after returning from function hook
+ passthru: whether to skip stack frame unwinding
- Returns: resolved params mapping, return value, return address
- """
+ Returns: resolved params mapping, return value, return address
+ """
- ql = self.ql
- pc = ql.arch.regs.arch_pc
+ ql = self.ql
+ pc = ql.arch.regs.arch_pc
- # if set, fire up the on-enter hook and let it override original args set
- if hook_onenter:
- overrides = hook_onenter(ql, pc, params)
+ # if set, fire up the on-enter hook and let it override original args set
+ if hook_onenter:
+ overrides = hook_onenter(ql, pc, params)
- if overrides is not None:
- pc, params = overrides
+ if overrides is not None:
+ pc, params = overrides
- # call function
- retval = func(ql, pc, params)
+ # call function
+ retval = func(ql, pc, params)
- # if set, fire up the on-exit hook and let it override the return value
- if hook_onexit:
- override = hook_onexit(ql, pc, params, retval)
+ # if set, fire up the on-exit hook and let it override the return value
+ if hook_onexit:
+ override = hook_onexit(ql, pc, params, retval)
- if override is not None:
- retval = override
+ if override is not None:
+ retval = override
- # set return value
- if retval is not None:
- self.cc.setReturnValue(retval)
+ # set return value
+ if retval is not None:
+ self.cc.setReturnValue(retval)
- targs = QlFunctionCall.__get_typed_args(proto, params)
+ targs = QlFunctionCall.__get_typed_args(proto, params)
- # TODO: resolve return value
+ # TODO: resolve return value
- # unwind stack frame; note that function prototype sometimes does not
- # reflect the actual number of arguments passed to the function, like
- # in variadic functions (e.g. printf-like functions). in such case the
- # function frame would not be unwinded entirely and cause the program
- # to fail or produce funny results.
- #
- # nevertheless this type of functions never unwind their own frame,
- # exactly for the reason they are not aware of the actual number of
- # arguments they got. since the caller is responsible for unwinding
- # we should be good.
+ # unwind stack frame; note that function prototype sometimes does not
+ # reflect the actual number of arguments passed to the function, like
+ # in variadic functions (e.g. printf-like functions). in such case the
+ # function frame would not be unwinded entirely and cause the program
+ # to fail or produce funny results.
+ #
+ # nevertheless this type of functions never unwind their own frame,
+ # exactly for the reason they are not aware of the actual number of
+ # arguments they got. since the caller is responsible for unwinding
+ # we should be good.
- nslots = self.__count_slots(proto.values())
- retaddr = -1 if passthru else self.cc.unwind(nslots)
+ nslots = self.__count_slots(proto.values())
+ retaddr = -1 if passthru else self.cc.unwind(nslots)
- return targs, retval, retaddr
+ return targs, retval, retaddr
- def call_native(self, addr: int, args: Sequence[Tuple[Any, int]], ret: Optional[int]) -> None:
- """Call a native function after properly staging its arguments and return address.
+ def call_native(self, addr: int, args: Sequence[Tuple[Any, int]], ret: Optional[int]) -> None:
+ """Call a native function after properly staging its arguments and return address.
- Args:
- addr: function entry point
- args: a sequence of 2-tuples containing parameters types and values to pass to the function; may be empty
- ret: return address; may be None
- """
+ Args:
+ addr: function entry point
+ args: a sequence of 2-tuples containing parameters types and values to pass to the function; may be empty
+ ret: return address; may be None
+ """
- # reserve slots for arguments
- nslots = self.__count_slots(atype for atype, _ in args)
- self.cc.reserve(nslots)
+ # reserve slots for arguments
+ nslots = self.__count_slots(atype for atype, _ in args)
+ self.cc.reserve(nslots)
- if ret is not None:
- self.cc.setReturnAddress(ret)
+ if ret is not None:
+ self.cc.setReturnAddress(ret)
- # set arguments values
- self.writeParams(args)
+ # set arguments values
+ self.writeParams(args)
- # call
- self.ql.arch.regs.arch_pc = addr
+ # call
+ self.ql.arch.regs.arch_pc = addr
diff --git a/qiling/os/linux/function_hook.py b/qiling/os/linux/function_hook.py
index 5e7c564d7..d8bbd9415 100644
--- a/qiling/os/linux/function_hook.py
+++ b/qiling/os/linux/function_hook.py
@@ -9,39 +9,39 @@
from qiling.const import *
PT_DYNAMIC = 2
-DT_NULL = 0
-DT_NEEDED = 1
-DT_PLTRELSZ = 2
-DT_PLTGOT = 3
-DT_HASH = 4
-DT_STRTAB = 5
-DT_SYMTAB = 6
-DT_RELA = 7
-DT_RELASZ = 8
-DT_RELAENT = 9
-DT_STRSZ = 10
-DT_SYMENT = 11
-DT_INIT = 12
-DT_FINI = 13
-DT_SONAME = 14
-DT_RPATH = 15
-DT_SYMBOLIC = 16
-DT_REL = 17
-DT_RELSZ = 18
-DT_RELENT = 19
-DT_PLTREL = 20
-DT_DEBUG = 21
-DT_TEXTREL = 22
-DT_JMPREL = 23
-DT_BIND_NOW = 24
-DT_INIT_ARRAY = 25
-DT_FINI_ARRAY = 26
+DT_NULL = 0
+DT_NEEDED = 1
+DT_PLTRELSZ = 2
+DT_PLTGOT = 3
+DT_HASH = 4
+DT_STRTAB = 5
+DT_SYMTAB = 6
+DT_RELA = 7
+DT_RELASZ = 8
+DT_RELAENT = 9
+DT_STRSZ = 10
+DT_SYMENT = 11
+DT_INIT = 12
+DT_FINI = 13
+DT_SONAME = 14
+DT_RPATH = 15
+DT_SYMBOLIC = 16
+DT_REL = 17
+DT_RELSZ = 18
+DT_RELENT = 19
+DT_PLTREL = 20
+DT_DEBUG = 21
+DT_TEXTREL = 22
+DT_JMPREL = 23
+DT_BIND_NOW = 24
+DT_INIT_ARRAY = 25
+DT_FINI_ARRAY = 26
DT_INIT_ARRAYSZ = 27
DT_FINI_ARRAYSZ = 28
-DT_RUNPATH = 29
-DT_FLAGS = 30
-DT_ENCODING = 32
-DT_GNU_HASH = 0x6ffffef5
+DT_RUNPATH = 29
+DT_FLAGS = 30
+DT_ENCODING = 32
+DT_GNU_HASH = 0x6ffffef5
DT_MIPS_LOCAL_GOTNO = 0x7000000a
DT_MIPS_SYMTABNO = 0x70000011
@@ -638,14 +638,14 @@ def __init__(self, ql, phoff, phnum, phentsize, load_base, hook_mem):
def parse_program_header32(self):
# typedef struct elf32_phdr{
- # Elf32_Word p_type;
- # Elf32_Off p_offset;
- # Elf32_Addr p_vaddr;
- # Elf32_Addr p_paddr;
- # Elf32_Word p_filesz;
- # Elf32_Word p_memsz;
- # Elf32_Word p_flags;
- # Elf32_Word p_align;
+ # Elf32_Word p_type;
+ # Elf32_Off p_offset;
+ # Elf32_Addr p_vaddr;
+ # Elf32_Addr p_paddr;
+ # Elf32_Word p_filesz;
+ # Elf32_Word p_memsz;
+ # Elf32_Word p_flags;
+ # Elf32_Word p_align;
# } Elf32_Phdr;
# /* 32-bit ELF base types. */
@@ -669,20 +669,20 @@ def parse_program_header64(self):
# typedef struct elf64_phdr {
# Elf64_Word p_type;
# Elf64_Word p_flags;
- # Elf64_Off p_offset; /* Segment file offset */
- # Elf64_Addr p_vaddr; /* Segment virtual address */
- # Elf64_Addr p_paddr; /* Segment physical address */
- # Elf64_Xword p_filesz; /* Segment size in file */
- # Elf64_Xword p_memsz; /* Segment size in memory */
- # Elf64_Xword p_align; /* Segment alignment, file & memory */
+ # Elf64_Off p_offset; /* Segment file offset */
+ # Elf64_Addr p_vaddr; /* Segment virtual address */
+ # Elf64_Addr p_paddr; /* Segment physical address */
+ # Elf64_Xword p_filesz; /* Segment size in file */
+ # Elf64_Xword p_memsz; /* Segment size in memory */
+ # Elf64_Xword p_align; /* Segment alignment, file & memory */
# } Elf64_Phdr;
# /* 64-bit ELF base types. */
# typedef uint64_t Elf64_Addr;
# typedef uint16_t Elf64_Half;
- # typedef int16_t Elf64_SHalf;
+ # typedef int16_t Elf64_SHalf;
# typedef uint64_t Elf64_Off;
- # typedef int32_t Elf64_Sword;
+ # typedef int32_t Elf64_Sword;
# typedef uint32_t Elf64_Word;
# typedef uint64_t Elf64_Xword;
# typedef int64_t Elf64_Sxword;
@@ -706,20 +706,20 @@ def parse_program_header(self):
def parse_dynamic64(self):
# typedef struct
# {
- # Elf64_Sxword d_tag; /* Dynamic entry type */
+ # Elf64_Sxword d_tag; /* Dynamic entry type */
# union
# {
- # Elf64_Xword d_val; /* Integer value */
- # Elf64_Addr d_ptr; /* Address value */
+ # Elf64_Xword d_val; /* Integer value */
+ # Elf64_Addr d_ptr; /* Address value */
# } d_un;
# } Elf64_Dyn;
# /* 64-bit ELF base types. */
# typedef uint64_t Elf64_Addr;
# typedef uint16_t Elf64_Half;
- # typedef int16_t Elf64_SHalf;
+ # typedef int16_t Elf64_SHalf;
# typedef uint64_t Elf64_Off;
- # typedef int32_t Elf64_Sword;
+ # typedef int32_t Elf64_Sword;
# typedef uint32_t Elf64_Word;
# typedef uint64_t Elf64_Xword;
# typedef int64_t Elf64_Sxword;
@@ -739,11 +739,11 @@ def parse_dynamic64(self):
def parse_dynamic32(self):
# typedef struct
# {
- # Elf32_Sword d_tag; /* Dynamic entry type */
+ # Elf32_Sword d_tag; /* Dynamic entry type */
# union
# {
- # Elf32_Word d_val; /* Integer value */
- # Elf32_Addr d_ptr; /* Address value */
+ # Elf32_Word d_val; /* Integer value */
+ # Elf32_Addr d_ptr; /* Address value */
# } d_un;
# } Elf32_Dyn;
diff --git a/qiling/os/linux/map_syscall.py b/qiling/os/linux/map_syscall.py
index 3d0bcead8..0584d58d2 100644
--- a/qiling/os/linux/map_syscall.py
+++ b/qiling/os/linux/map_syscall.py
@@ -30,2942 +30,2942 @@ def __mapper(syscall_num: int) -> str:
arm_syscall_table = {
0: "restart_syscall",
- 1: "exit",
- 2: "fork",
- 3: "read",
- 4: "write",
- 5: "open",
- 6: "close",
- 8: "creat",
- 9: "link",
- 10: "unlink",
- 11: "execve",
- 12: "chdir",
+ 1: "exit",
+ 2: "fork",
+ 3: "read",
+ 4: "write",
+ 5: "open",
+ 6: "close",
+ 8: "creat",
+ 9: "link",
+ 10: "unlink",
+ 11: "execve",
+ 12: "chdir",
13: "time",
- 14: "mknod",
- 15: "chmod",
- 16: "lchown",
- 19: "lseek",
- 20: "getpid",
- 21: "mount",
- 23: "setuid",
- 24: "getuid",
- 26: "ptrace",
- 29: "pause",
- 33: "access",
- 34: "nice",
- 36: "sync",
- 37: "kill",
- 38: "rename",
- 39: "mkdir",
- 40: "rmdir",
- 41: "dup",
- 42: "pipe",
- 43: "times",
- 45: "brk",
- 46: "setgid",
- 47: "getgid",
- 49: "geteuid",
- 50: "getegid",
- 51: "acct",
- 52: "umount2",
- 54: "ioctl",
- 55: "fcntl",
- 57: "setpgid",
- 60: "umask",
- 61: "chroot",
- 62: "ustat",
- 63: "dup2",
- 64: "getppid",
- 65: "getpgrp",
- 66: "setsid",
- 67: "sigaction",
- 70: "setreuid",
- 71: "setregid",
- 72: "sigsuspend",
- 73: "sigpending",
- 74: "sethostname",
- 75: "setrlimit",
- 77: "getrusage",
- 78: "gettimeofday",
- 79: "settimeofday",
- 80: "getgroups",
- 81: "setgroups",
- 83: "symlink",
- 85: "readlink",
- 86: "uselib",
- 87: "swapon",
- 88: "reboot",
- 91: "munmap",
- 92: "truncate",
- 93: "ftruncate",
- 94: "fchmod",
- 95: "fchown",
- 96: "getpriority",
- 97: "setpriority",
- 99: "statfs",
- 100: "fstatfs",
+ 14: "mknod",
+ 15: "chmod",
+ 16: "lchown",
+ 19: "lseek",
+ 20: "getpid",
+ 21: "mount",
+ 23: "setuid",
+ 24: "getuid",
+ 26: "ptrace",
+ 29: "pause",
+ 33: "access",
+ 34: "nice",
+ 36: "sync",
+ 37: "kill",
+ 38: "rename",
+ 39: "mkdir",
+ 40: "rmdir",
+ 41: "dup",
+ 42: "pipe",
+ 43: "times",
+ 45: "brk",
+ 46: "setgid",
+ 47: "getgid",
+ 49: "geteuid",
+ 50: "getegid",
+ 51: "acct",
+ 52: "umount2",
+ 54: "ioctl",
+ 55: "fcntl",
+ 57: "setpgid",
+ 60: "umask",
+ 61: "chroot",
+ 62: "ustat",
+ 63: "dup2",
+ 64: "getppid",
+ 65: "getpgrp",
+ 66: "setsid",
+ 67: "sigaction",
+ 70: "setreuid",
+ 71: "setregid",
+ 72: "sigsuspend",
+ 73: "sigpending",
+ 74: "sethostname",
+ 75: "setrlimit",
+ 77: "getrusage",
+ 78: "gettimeofday",
+ 79: "settimeofday",
+ 80: "getgroups",
+ 81: "setgroups",
+ 83: "symlink",
+ 85: "readlink",
+ 86: "uselib",
+ 87: "swapon",
+ 88: "reboot",
+ 91: "munmap",
+ 92: "truncate",
+ 93: "ftruncate",
+ 94: "fchmod",
+ 95: "fchown",
+ 96: "getpriority",
+ 97: "setpriority",
+ 99: "statfs",
+ 100: "fstatfs",
102: "socketcall",
- 103: "syslog",
- 104: "setitimer",
- 105: "getitimer",
- 106: "stat",
- 107: "lstat",
- 108: "fstat",
- 111: "vhangup",
+ 103: "syslog",
+ 104: "setitimer",
+ 105: "getitimer",
+ 106: "stat",
+ 107: "lstat",
+ 108: "fstat",
+ 111: "vhangup",
113: "syscall",
- 114: "wait4",
- 115: "swapoff",
- 116: "sysinfo",
- 118: "fsync",
- 119: "sigreturn",
- 120: "clone",
- 121: "setdomainname",
- 122: "uname",
- 124: "adjtimex",
- 125: "mprotect",
- 126: "sigprocmask",
- 128: "init_module",
- 129: "delete_module",
- 131: "quotactl",
- 132: "getpgid",
- 133: "fchdir",
- 134: "bdflush",
- 135: "sysfs",
- 136: "personality",
- 138: "setfsuid",
- 139: "setfsgid",
- 140: "_llseek",
- 141: "getdents",
- 142: "_newselect",
- 143: "flock",
- 144: "msync",
- 145: "readv",
- 146: "writev",
- 147: "getsid",
- 148: "fdatasync",
- 149: "_sysctl",
- 150: "mlock",
- 151: "munlock",
- 152: "mlockall",
- 153: "munlockall",
- 154: "sched_setparam",
- 155: "sched_getparam",
- 156: "sched_setscheduler",
- 157: "sched_getscheduler",
- 158: "sched_yield",
- 159: "sched_get_priority_max",
- 160: "sched_get_priority_min",
- 161: "sched_rr_get_interval",
- 162: "nanosleep",
- 163: "mremap",
- 164: "setresuid",
- 165: "getresuid",
- 168: "poll",
- 169: "nfsservctl",
- 170: "setresgid",
- 171: "getresgid",
- 172: "prctl",
- 173: "rt_sigreturn",
- 174: "rt_sigaction",
- 175: "rt_sigprocmask",
- 176: "rt_sigpending",
- 177: "rt_sigtimedwait",
- 178: "rt_sigqueueinfo",
- 179: "rt_sigsuspend",
- 180: "pread64",
- 181: "pwrite64",
- 182: "chown",
- 183: "getcwd",
- 184: "capget",
- 185: "capset",
- 186: "sigaltstack",
- 187: "sendfile",
- 190: "vfork",
- 191: "ugetrlimit",
- 192: "mmap2",
- 193: "truncate64",
- 194: "ftruncate64",
- 195: "stat64",
- 196: "lstat64",
- 197: "fstat64",
- 198: "lchown32",
- 199: "getuid32",
- 200: "getgid32",
- 201: "geteuid32",
- 202: "getegid32",
- 203: "setreuid32",
- 204: "setregid32",
- 205: "getgroups32",
- 206: "setgroups32",
- 207: "fchown32",
- 208: "setresuid32",
- 209: "getresuid32",
- 210: "setresgid32",
- 211: "getresgid32",
- 212: "chown32",
- 213: "setuid32",
- 214: "setgid32",
- 215: "setfsuid32",
- 216: "setfsgid32",
- 217: "getdents64",
- 218: "pivot_root",
- 219: "mincore",
- 220: "madvise",
- 221: "fcntl64",
- 224: "gettid",
- 225: "readahead",
- 226: "setxattr",
- 227: "lsetxattr",
- 228: "fsetxattr",
- 229: "getxattr",
- 230: "lgetxattr",
- 231: "fgetxattr",
- 232: "listxattr",
- 233: "llistxattr",
- 234: "flistxattr",
- 235: "removexattr",
- 236: "lremovexattr",
- 237: "fremovexattr",
- 238: "tkill",
- 239: "sendfile64",
- 240: "futex",
- 241: "sched_setaffinity",
- 242: "sched_getaffinity",
- 243: "io_setup",
- 244: "io_destroy",
- 245: "io_getevents",
- 246: "io_submit",
- 247: "io_cancel",
- 248: "exit_group",
- 249: "lookup_dcookie",
- 250: "epoll_create",
- 251: "epoll_ctl",
- 252: "epoll_wait",
- 253: "remap_file_pages",
- 256: "set_tid_address",
- 257: "timer_create",
- 258: "timer_settime",
- 259: "timer_gettime",
- 260: "timer_getoverrun",
- 261: "timer_delete",
- 262: "clock_settime",
- 263: "clock_gettime",
- 264: "clock_getres",
- 265: "clock_nanosleep",
- 266: "statfs64",
- 267: "fstatfs64",
- 268: "tgkill",
- 269: "utimes",
- 270: "arm_fadvise64_64",
- 271: "pciconfig_iobase",
- 272: "pciconfig_read",
- 273: "pciconfig_write",
- 274: "mq_open",
- 275: "mq_unlink",
- 276: "mq_timedsend",
- 277: "mq_timedreceive",
- 278: "mq_notify",
- 279: "mq_getsetattr",
- 280: "waitid",
- 281: "socket",
- 282: "bind",
- 283: "connect",
- 284: "listen",
- 285: "accept",
- 286: "getsockname",
- 287: "getpeername",
- 288: "socketpair",
- 289: "send",
- 290: "sendto",
- 291: "recv",
- 292: "recvfrom",
- 293: "shutdown",
- 294: "setsockopt",
- 295: "getsockopt",
- 296: "sendmsg",
- 297: "recvmsg",
- 298: "semop",
- 299: "semget",
- 300: "semctl",
- 301: "msgsnd",
- 302: "msgrcv",
- 303: "msgget",
- 304: "msgctl",
- 305: "shmat",
- 306: "shmdt",
- 307: "shmget",
- 308: "shmctl",
- 309: "add_key",
- 310: "request_key",
- 311: "keyctl",
- 312: "semtimedop",
- 314: "ioprio_set",
- 315: "ioprio_get",
- 316: "inotify_init",
- 317: "inotify_add_watch",
- 318: "inotify_rm_watch",
- 319: "mbind",
- 320: "get_mempolicy",
- 321: "set_mempolicy",
- 322: "openat",
- 323: "mkdirat",
- 324: "mknodat",
- 325: "fchownat",
- 326: "futimesat",
- 327: "fstatat64",
- 328: "unlinkat",
- 329: "renameat",
- 330: "linkat",
- 331: "symlinkat",
- 332: "readlinkat",
- 333: "fchmodat",
- 334: "faccessat",
- 335: "pselect6",
- 336: "ppoll",
- 337: "unshare",
- 338: "set_robust_list",
- 339: "get_robust_list",
- 340: "splice",
- 341: "sync_file_range2",
- 342: "tee",
- 343: "vmsplice",
- 344: "move_pages",
- 345: "getcpu",
- 346: "epoll_pwait",
- 347: "kexec_load",
- 348: "utimensat",
- 349: "signalfd",
- 350: "timerfd_create",
- 351: "eventfd",
- 352: "fallocate",
- 353: "timerfd_settime",
- 354: "timerfd_gettime",
- 355: "signalfd4",
- 356: "eventfd2",
- 357: "epoll_create1",
- 358: "dup3",
- 359: "pipe2",
- 360: "inotify_init1",
- 361: "preadv",
- 362: "pwritev",
- 363: "rt_tgsigqueueinfo",
- 364: "perf_event_open",
- 365: "recvmmsg",
- 366: "accept4",
- 367: "fanotify_init",
- 368: "fanotify_mark",
- 369: "prlimit64",
- 370: "name_to_handle_at",
- 371: "open_by_handle_at",
- 372: "clock_adjtime",
- 373: "syncfs",
- 374: "sendmmsg",
- 375: "setns",
- 376: "process_vm_readv",
- 377: "process_vm_writev",
- 378: "kcmp",
- 379: "finit_module",
- 380: "sched_setattr",
- 381: "sched_getattr",
- 382: "renameat2",
- 383: "seccomp",
- 384: "getrandom",
- 385: "memfd_create",
- 386: "bpf",
- 387: "execveat",
- 388: "userfaultfd",
- 389: "membarrier",
- 390: "mlock2",
- 391: "copy_file_range",
- 392: "preadv2",
- 393: "pwritev2",
- 394: "pkey_mprotect",
- 395: "pkey_alloc",
- 396: "pkey_free",
- 397: "statx",
- 398: "rseq",
- 399: "io_pgetevents",
- 400: "migrate_pages",
- 401: "kexec_file_load",
- 403: "clock_gettime64",
- 404: "clock_settime64",
- 405: "clock_adjtime64",
- 406: "clock_getres_time64",
- 407: "clock_nanosleep_time64",
- 408: "timer_gettime64",
- 409: "timer_settime64",
- 410: "timerfd_gettime64",
- 411: "timerfd_settime64",
- 412: "utimensat_time64",
- 413: "pselect6_time64",
- 414: "ppoll_time64",
- 416: "io_pgetevents_time64",
- 417: "recvmmsg_time64",
- 418: "mq_timedsend_time64",
- 419: "mq_timedreceive_time64",
- 420: "semtimedop_time64",
- 421: "rt_sigtimedwait_time64",
- 422: "futex_time64",
- 423: "sched_rr_get_interval_time64",
- 424: "pidfd_send_signal",
- 425: "io_uring_setup",
- 426: "io_uring_enter",
- 427: "io_uring_register",
- 428: "open_tree",
- 429: "move_mount",
- 430: "fsopen",
- 431: "fsconfig",
- 432: "fsmount",
- 433: "fspick",
- 434: "pidfd_open",
- 435: "clone3",
- 436: "close_range",
- 437: "openat2",
- 438: "pidfd_getfd",
- 439: "faccessat2",
- 440: "process_madvise",
- 441: "epoll_pwait2",
- 442: "mount_setattr",
- 443: "quotactl_fd",
- 444: "landlock_create_ruleset",
- 445: "landlock_add_rule",
- 446: "landlock_restrict_self",
- 448: "process_mrelease",
+ 114: "wait4",
+ 115: "swapoff",
+ 116: "sysinfo",
+ 118: "fsync",
+ 119: "sigreturn",
+ 120: "clone",
+ 121: "setdomainname",
+ 122: "uname",
+ 124: "adjtimex",
+ 125: "mprotect",
+ 126: "sigprocmask",
+ 128: "init_module",
+ 129: "delete_module",
+ 131: "quotactl",
+ 132: "getpgid",
+ 133: "fchdir",
+ 134: "bdflush",
+ 135: "sysfs",
+ 136: "personality",
+ 138: "setfsuid",
+ 139: "setfsgid",
+ 140: "_llseek",
+ 141: "getdents",
+ 142: "_newselect",
+ 143: "flock",
+ 144: "msync",
+ 145: "readv",
+ 146: "writev",
+ 147: "getsid",
+ 148: "fdatasync",
+ 149: "_sysctl",
+ 150: "mlock",
+ 151: "munlock",
+ 152: "mlockall",
+ 153: "munlockall",
+ 154: "sched_setparam",
+ 155: "sched_getparam",
+ 156: "sched_setscheduler",
+ 157: "sched_getscheduler",
+ 158: "sched_yield",
+ 159: "sched_get_priority_max",
+ 160: "sched_get_priority_min",
+ 161: "sched_rr_get_interval",
+ 162: "nanosleep",
+ 163: "mremap",
+ 164: "setresuid",
+ 165: "getresuid",
+ 168: "poll",
+ 169: "nfsservctl",
+ 170: "setresgid",
+ 171: "getresgid",
+ 172: "prctl",
+ 173: "rt_sigreturn",
+ 174: "rt_sigaction",
+ 175: "rt_sigprocmask",
+ 176: "rt_sigpending",
+ 177: "rt_sigtimedwait",
+ 178: "rt_sigqueueinfo",
+ 179: "rt_sigsuspend",
+ 180: "pread64",
+ 181: "pwrite64",
+ 182: "chown",
+ 183: "getcwd",
+ 184: "capget",
+ 185: "capset",
+ 186: "sigaltstack",
+ 187: "sendfile",
+ 190: "vfork",
+ 191: "ugetrlimit",
+ 192: "mmap2",
+ 193: "truncate64",
+ 194: "ftruncate64",
+ 195: "stat64",
+ 196: "lstat64",
+ 197: "fstat64",
+ 198: "lchown32",
+ 199: "getuid32",
+ 200: "getgid32",
+ 201: "geteuid32",
+ 202: "getegid32",
+ 203: "setreuid32",
+ 204: "setregid32",
+ 205: "getgroups32",
+ 206: "setgroups32",
+ 207: "fchown32",
+ 208: "setresuid32",
+ 209: "getresuid32",
+ 210: "setresgid32",
+ 211: "getresgid32",
+ 212: "chown32",
+ 213: "setuid32",
+ 214: "setgid32",
+ 215: "setfsuid32",
+ 216: "setfsgid32",
+ 217: "getdents64",
+ 218: "pivot_root",
+ 219: "mincore",
+ 220: "madvise",
+ 221: "fcntl64",
+ 224: "gettid",
+ 225: "readahead",
+ 226: "setxattr",
+ 227: "lsetxattr",
+ 228: "fsetxattr",
+ 229: "getxattr",
+ 230: "lgetxattr",
+ 231: "fgetxattr",
+ 232: "listxattr",
+ 233: "llistxattr",
+ 234: "flistxattr",
+ 235: "removexattr",
+ 236: "lremovexattr",
+ 237: "fremovexattr",
+ 238: "tkill",
+ 239: "sendfile64",
+ 240: "futex",
+ 241: "sched_setaffinity",
+ 242: "sched_getaffinity",
+ 243: "io_setup",
+ 244: "io_destroy",
+ 245: "io_getevents",
+ 246: "io_submit",
+ 247: "io_cancel",
+ 248: "exit_group",
+ 249: "lookup_dcookie",
+ 250: "epoll_create",
+ 251: "epoll_ctl",
+ 252: "epoll_wait",
+ 253: "remap_file_pages",
+ 256: "set_tid_address",
+ 257: "timer_create",
+ 258: "timer_settime",
+ 259: "timer_gettime",
+ 260: "timer_getoverrun",
+ 261: "timer_delete",
+ 262: "clock_settime",
+ 263: "clock_gettime",
+ 264: "clock_getres",
+ 265: "clock_nanosleep",
+ 266: "statfs64",
+ 267: "fstatfs64",
+ 268: "tgkill",
+ 269: "utimes",
+ 270: "arm_fadvise64_64",
+ 271: "pciconfig_iobase",
+ 272: "pciconfig_read",
+ 273: "pciconfig_write",
+ 274: "mq_open",
+ 275: "mq_unlink",
+ 276: "mq_timedsend",
+ 277: "mq_timedreceive",
+ 278: "mq_notify",
+ 279: "mq_getsetattr",
+ 280: "waitid",
+ 281: "socket",
+ 282: "bind",
+ 283: "connect",
+ 284: "listen",
+ 285: "accept",
+ 286: "getsockname",
+ 287: "getpeername",
+ 288: "socketpair",
+ 289: "send",
+ 290: "sendto",
+ 291: "recv",
+ 292: "recvfrom",
+ 293: "shutdown",
+ 294: "setsockopt",
+ 295: "getsockopt",
+ 296: "sendmsg",
+ 297: "recvmsg",
+ 298: "semop",
+ 299: "semget",
+ 300: "semctl",
+ 301: "msgsnd",
+ 302: "msgrcv",
+ 303: "msgget",
+ 304: "msgctl",
+ 305: "shmat",
+ 306: "shmdt",
+ 307: "shmget",
+ 308: "shmctl",
+ 309: "add_key",
+ 310: "request_key",
+ 311: "keyctl",
+ 312: "semtimedop",
+ 314: "ioprio_set",
+ 315: "ioprio_get",
+ 316: "inotify_init",
+ 317: "inotify_add_watch",
+ 318: "inotify_rm_watch",
+ 319: "mbind",
+ 320: "get_mempolicy",
+ 321: "set_mempolicy",
+ 322: "openat",
+ 323: "mkdirat",
+ 324: "mknodat",
+ 325: "fchownat",
+ 326: "futimesat",
+ 327: "fstatat64",
+ 328: "unlinkat",
+ 329: "renameat",
+ 330: "linkat",
+ 331: "symlinkat",
+ 332: "readlinkat",
+ 333: "fchmodat",
+ 334: "faccessat",
+ 335: "pselect6",
+ 336: "ppoll",
+ 337: "unshare",
+ 338: "set_robust_list",
+ 339: "get_robust_list",
+ 340: "splice",
+ 341: "sync_file_range2",
+ 342: "tee",
+ 343: "vmsplice",
+ 344: "move_pages",
+ 345: "getcpu",
+ 346: "epoll_pwait",
+ 347: "kexec_load",
+ 348: "utimensat",
+ 349: "signalfd",
+ 350: "timerfd_create",
+ 351: "eventfd",
+ 352: "fallocate",
+ 353: "timerfd_settime",
+ 354: "timerfd_gettime",
+ 355: "signalfd4",
+ 356: "eventfd2",
+ 357: "epoll_create1",
+ 358: "dup3",
+ 359: "pipe2",
+ 360: "inotify_init1",
+ 361: "preadv",
+ 362: "pwritev",
+ 363: "rt_tgsigqueueinfo",
+ 364: "perf_event_open",
+ 365: "recvmmsg",
+ 366: "accept4",
+ 367: "fanotify_init",
+ 368: "fanotify_mark",
+ 369: "prlimit64",
+ 370: "name_to_handle_at",
+ 371: "open_by_handle_at",
+ 372: "clock_adjtime",
+ 373: "syncfs",
+ 374: "sendmmsg",
+ 375: "setns",
+ 376: "process_vm_readv",
+ 377: "process_vm_writev",
+ 378: "kcmp",
+ 379: "finit_module",
+ 380: "sched_setattr",
+ 381: "sched_getattr",
+ 382: "renameat2",
+ 383: "seccomp",
+ 384: "getrandom",
+ 385: "memfd_create",
+ 386: "bpf",
+ 387: "execveat",
+ 388: "userfaultfd",
+ 389: "membarrier",
+ 390: "mlock2",
+ 391: "copy_file_range",
+ 392: "preadv2",
+ 393: "pwritev2",
+ 394: "pkey_mprotect",
+ 395: "pkey_alloc",
+ 396: "pkey_free",
+ 397: "statx",
+ 398: "rseq",
+ 399: "io_pgetevents",
+ 400: "migrate_pages",
+ 401: "kexec_file_load",
+ 403: "clock_gettime64",
+ 404: "clock_settime64",
+ 405: "clock_adjtime64",
+ 406: "clock_getres_time64",
+ 407: "clock_nanosleep_time64",
+ 408: "timer_gettime64",
+ 409: "timer_settime64",
+ 410: "timerfd_gettime64",
+ 411: "timerfd_settime64",
+ 412: "utimensat_time64",
+ 413: "pselect6_time64",
+ 414: "ppoll_time64",
+ 416: "io_pgetevents_time64",
+ 417: "recvmmsg_time64",
+ 418: "mq_timedsend_time64",
+ 419: "mq_timedreceive_time64",
+ 420: "semtimedop_time64",
+ 421: "rt_sigtimedwait_time64",
+ 422: "futex_time64",
+ 423: "sched_rr_get_interval_time64",
+ 424: "pidfd_send_signal",
+ 425: "io_uring_setup",
+ 426: "io_uring_enter",
+ 427: "io_uring_register",
+ 428: "open_tree",
+ 429: "move_mount",
+ 430: "fsopen",
+ 431: "fsconfig",
+ 432: "fsmount",
+ 433: "fspick",
+ 434: "pidfd_open",
+ 435: "clone3",
+ 436: "close_range",
+ 437: "openat2",
+ 438: "pidfd_getfd",
+ 439: "faccessat2",
+ 440: "process_madvise",
+ 441: "epoll_pwait2",
+ 442: "mount_setattr",
+ 443: "quotactl_fd",
+ 444: "landlock_create_ruleset",
+ 445: "landlock_add_rule",
+ 446: "landlock_restrict_self",
+ 448: "process_mrelease",
983042: "cacheflush",
983045: "set_tls",
}
arm64_syscall_table = {
0: "io_setup",
- 1: "io_destroy",
- 2: "io_submit",
- 3: "io_cancel",
- 4: "io_getevents",
- 5: "setxattr",
- 6: "lsetxattr",
- 7: "fsetxattr",
- 8: "getxattr",
- 9: "lgetxattr",
- 10: "fgetxattr",
- 11: "listxattr",
- 12: "llistxattr",
- 13: "flistxattr",
- 14: "removexattr",
- 15: "lremovexattr",
- 16: "fremovexattr",
- 17: "getcwd",
- 18: "lookup_dcookie",
- 19: "eventfd2",
- 20: "epoll_create1",
- 21: "epoll_ctl",
- 22: "epoll_pwait",
- 23: "dup",
- 24: "dup3",
- 25: "fcntl",
- 26: "inotify_init1",
- 27: "inotify_add_watch",
- 28: "inotify_rm_watch",
- 29: "ioctl",
- 30: "ioprio_set",
- 31: "ioprio_get",
- 32: "flock",
- 33: "mknodat",
- 34: "mkdirat",
- 35: "unlinkat",
- 36: "symlinkat",
- 37: "linkat",
- 38: "renameat",
- 39: "umount2",
- 40: "mount",
- 41: "pivot_root",
- 42: "nfsservctl",
- 43: "statfs",
- 44: "fstatfs",
- 45: "truncate",
- 46: "ftruncate",
- 47: "fallocate",
- 48: "faccessat",
- 49: "chdir",
- 50: "fchdir",
- 51: "chroot",
- 52: "fchmod",
- 53: "fchmodat",
- 54: "fchownat",
- 55: "fchown",
- 56: "openat",
- 57: "close",
- 58: "vhangup",
- 59: "pipe2",
- 60: "quotactl",
- 61: "getdents64",
- 62: "lseek",
- 63: "read",
- 64: "write",
- 65: "readv",
- 66: "writev",
- 67: "pread64",
- 68: "pwrite64",
- 69: "preadv",
- 70: "pwritev",
- 71: "sendfile",
- 72: "pselect6",
- 73: "ppoll",
- 74: "signalfd4",
- 75: "vmsplice",
- 76: "splice",
- 77: "tee",
- 78: "readlinkat",
- 79: "newfstatat",
- 80: "fstat",
- 81: "sync",
- 82: "fsync",
- 83: "fdatasync",
- 84: "sync_file_range",
- 85: "timerfd_create",
- 86: "timerfd_settime",
- 87: "timerfd_gettime",
- 88: "utimensat",
- 89: "acct",
- 90: "capget",
- 91: "capset",
- 92: "personality",
- 93: "exit",
- 94: "exit_group",
- 95: "waitid",
- 96: "set_tid_address",
- 97: "unshare",
- 98: "futex",
- 99: "set_robust_list",
- 100: "get_robust_list",
- 101: "nanosleep",
- 102: "getitimer",
- 103: "setitimer",
- 104: "kexec_load",
- 105: "init_module",
- 106: "delete_module",
- 107: "timer_create",
- 108: "timer_gettime",
- 109: "timer_getoverrun",
- 110: "timer_settime",
- 111: "timer_delete",
- 112: "clock_settime",
- 113: "clock_gettime",
- 114: "clock_getres",
- 115: "clock_nanosleep",
- 116: "syslog",
- 117: "ptrace",
- 118: "sched_setparam",
- 119: "sched_setscheduler",
- 120: "sched_getscheduler",
- 121: "sched_getparam",
- 122: "sched_setaffinity",
- 123: "sched_getaffinity",
- 124: "sched_yield",
- 125: "sched_get_priority_max",
- 126: "sched_get_priority_min",
- 127: "sched_rr_get_interval",
- 128: "restart_syscall",
- 129: "kill",
- 130: "tkill",
- 131: "tgkill",
- 132: "sigaltstack",
- 133: "rt_sigsuspend",
- 134: "rt_sigaction",
- 135: "rt_sigprocmask",
- 136: "rt_sigpending",
- 137: "rt_sigtimedwait",
- 138: "rt_sigqueueinfo",
- 139: "rt_sigreturn",
- 140: "setpriority",
- 141: "getpriority",
- 142: "reboot",
- 143: "setregid",
- 144: "setgid",
- 145: "setreuid",
- 146: "setuid",
- 147: "setresuid",
- 148: "getresuid",
- 149: "setresgid",
- 150: "getresgid",
- 151: "setfsuid",
- 152: "setfsgid",
- 153: "times",
- 154: "setpgid",
- 155: "getpgid",
- 156: "getsid",
- 157: "setsid",
- 158: "getgroups",
- 159: "setgroups",
- 160: "uname",
- 161: "sethostname",
- 162: "setdomainname",
- 163: "getrlimit",
- 164: "setrlimit",
- 165: "getrusage",
- 166: "umask",
- 167: "prctl",
- 168: "getcpu",
- 169: "gettimeofday",
- 170: "settimeofday",
- 171: "adjtimex",
- 172: "getpid",
- 173: "getppid",
- 174: "getuid",
- 175: "geteuid",
- 176: "getgid",
- 177: "getegid",
- 178: "gettid",
- 179: "sysinfo",
- 180: "mq_open",
- 181: "mq_unlink",
- 182: "mq_timedsend",
- 183: "mq_timedreceive",
- 184: "mq_notify",
- 185: "mq_getsetattr",
- 186: "msgget",
- 187: "msgctl",
- 188: "msgrcv",
- 189: "msgsnd",
- 190: "semget",
- 191: "semctl",
- 192: "semtimedop",
- 193: "semop",
- 194: "shmget",
- 195: "shmctl",
- 196: "shmat",
- 197: "shmdt",
- 198: "socket",
- 199: "socketpair",
- 200: "bind",
- 201: "listen",
- 202: "accept",
- 203: "connect",
- 204: "getsockname",
- 205: "getpeername",
- 206: "sendto",
- 207: "recvfrom",
- 208: "setsockopt",
- 209: "getsockopt",
- 210: "shutdown",
- 211: "sendmsg",
- 212: "recvmsg",
- 213: "readahead",
- 214: "brk",
- 215: "munmap",
- 216: "mremap",
- 217: "add_key",
- 218: "request_key",
- 219: "keyctl",
- 220: "clone",
- 221: "execve",
- 222: "mmap",
- 223: "fadvise64",
- 224: "swapon",
- 225: "swapoff",
- 226: "mprotect",
- 227: "msync",
- 228: "mlock",
- 229: "munlock",
- 230: "mlockall",
- 231: "munlockall",
- 232: "mincore",
- 233: "madvise",
- 234: "remap_file_pages",
- 235: "mbind",
- 236: "get_mempolicy",
- 237: "set_mempolicy",
- 238: "migrate_pages",
- 239: "move_pages",
- 240: "rt_tgsigqueueinfo",
- 241: "perf_event_open",
- 242: "accept4",
- 243: "recvmmsg",
- 260: "wait4",
- 261: "prlimit64",
- 262: "fanotify_init",
- 263: "fanotify_mark",
- 264: "name_to_handle_at",
- 265: "open_by_handle_at",
- 266: "clock_adjtime",
- 267: "syncfs",
- 268: "setns",
- 269: "sendmmsg",
- 270: "process_vm_readv",
- 271: "process_vm_writev",
- 272: "kcmp",
- 273: "finit_module",
- 274: "sched_setattr",
- 275: "sched_getattr",
- 276: "renameat2",
- 277: "seccomp",
- 278: "getrandom",
- 279: "memfd_create",
- 280: "bpf",
- 281: "execveat",
- 282: "userfaultfd",
- 283: "membarrier",
- 284: "mlock2",
- 285: "copy_file_range",
- 286: "preadv2",
- 287: "pwritev2",
- 288: "pkey_mprotect",
- 289: "pkey_alloc",
- 290: "pkey_free",
- 291: "statx",
- 292: "io_pgetevents",
- 293: "rseq",
- 294: "kexec_file_load",
- 424: "pidfd_send_signal",
- 425: "io_uring_setup",
- 426: "io_uring_enter",
- 427: "io_uring_register",
- 428: "open_tree",
- 429: "move_mount",
- 430: "fsopen",
- 431: "fsconfig",
- 432: "fsmount",
- 433: "fspick",
- 434: "pidfd_open",
- 435: "clone3",
- 436: "close_range",
- 437: "openat2",
- 438: "pidfd_getfd",
- 439: "faccessat2",
- 440: "process_madvise",
- 441: "epoll_pwait2",
- 442: "mount_setattr",
- 443: "quotactl_fd",
- 444: "landlock_create_ruleset",
- 445: "landlock_add_rule",
- 446: "landlock_restrict_self",
- 447: "memfd_secret",
- 448: "process_mrelease",
+ 1: "io_destroy",
+ 2: "io_submit",
+ 3: "io_cancel",
+ 4: "io_getevents",
+ 5: "setxattr",
+ 6: "lsetxattr",
+ 7: "fsetxattr",
+ 8: "getxattr",
+ 9: "lgetxattr",
+ 10: "fgetxattr",
+ 11: "listxattr",
+ 12: "llistxattr",
+ 13: "flistxattr",
+ 14: "removexattr",
+ 15: "lremovexattr",
+ 16: "fremovexattr",
+ 17: "getcwd",
+ 18: "lookup_dcookie",
+ 19: "eventfd2",
+ 20: "epoll_create1",
+ 21: "epoll_ctl",
+ 22: "epoll_pwait",
+ 23: "dup",
+ 24: "dup3",
+ 25: "fcntl",
+ 26: "inotify_init1",
+ 27: "inotify_add_watch",
+ 28: "inotify_rm_watch",
+ 29: "ioctl",
+ 30: "ioprio_set",
+ 31: "ioprio_get",
+ 32: "flock",
+ 33: "mknodat",
+ 34: "mkdirat",
+ 35: "unlinkat",
+ 36: "symlinkat",
+ 37: "linkat",
+ 38: "renameat",
+ 39: "umount2",
+ 40: "mount",
+ 41: "pivot_root",
+ 42: "nfsservctl",
+ 43: "statfs",
+ 44: "fstatfs",
+ 45: "truncate",
+ 46: "ftruncate",
+ 47: "fallocate",
+ 48: "faccessat",
+ 49: "chdir",
+ 50: "fchdir",
+ 51: "chroot",
+ 52: "fchmod",
+ 53: "fchmodat",
+ 54: "fchownat",
+ 55: "fchown",
+ 56: "openat",
+ 57: "close",
+ 58: "vhangup",
+ 59: "pipe2",
+ 60: "quotactl",
+ 61: "getdents64",
+ 62: "lseek",
+ 63: "read",
+ 64: "write",
+ 65: "readv",
+ 66: "writev",
+ 67: "pread64",
+ 68: "pwrite64",
+ 69: "preadv",
+ 70: "pwritev",
+ 71: "sendfile",
+ 72: "pselect6",
+ 73: "ppoll",
+ 74: "signalfd4",
+ 75: "vmsplice",
+ 76: "splice",
+ 77: "tee",
+ 78: "readlinkat",
+ 79: "newfstatat",
+ 80: "fstat",
+ 81: "sync",
+ 82: "fsync",
+ 83: "fdatasync",
+ 84: "sync_file_range",
+ 85: "timerfd_create",
+ 86: "timerfd_settime",
+ 87: "timerfd_gettime",
+ 88: "utimensat",
+ 89: "acct",
+ 90: "capget",
+ 91: "capset",
+ 92: "personality",
+ 93: "exit",
+ 94: "exit_group",
+ 95: "waitid",
+ 96: "set_tid_address",
+ 97: "unshare",
+ 98: "futex",
+ 99: "set_robust_list",
+ 100: "get_robust_list",
+ 101: "nanosleep",
+ 102: "getitimer",
+ 103: "setitimer",
+ 104: "kexec_load",
+ 105: "init_module",
+ 106: "delete_module",
+ 107: "timer_create",
+ 108: "timer_gettime",
+ 109: "timer_getoverrun",
+ 110: "timer_settime",
+ 111: "timer_delete",
+ 112: "clock_settime",
+ 113: "clock_gettime",
+ 114: "clock_getres",
+ 115: "clock_nanosleep",
+ 116: "syslog",
+ 117: "ptrace",
+ 118: "sched_setparam",
+ 119: "sched_setscheduler",
+ 120: "sched_getscheduler",
+ 121: "sched_getparam",
+ 122: "sched_setaffinity",
+ 123: "sched_getaffinity",
+ 124: "sched_yield",
+ 125: "sched_get_priority_max",
+ 126: "sched_get_priority_min",
+ 127: "sched_rr_get_interval",
+ 128: "restart_syscall",
+ 129: "kill",
+ 130: "tkill",
+ 131: "tgkill",
+ 132: "sigaltstack",
+ 133: "rt_sigsuspend",
+ 134: "rt_sigaction",
+ 135: "rt_sigprocmask",
+ 136: "rt_sigpending",
+ 137: "rt_sigtimedwait",
+ 138: "rt_sigqueueinfo",
+ 139: "rt_sigreturn",
+ 140: "setpriority",
+ 141: "getpriority",
+ 142: "reboot",
+ 143: "setregid",
+ 144: "setgid",
+ 145: "setreuid",
+ 146: "setuid",
+ 147: "setresuid",
+ 148: "getresuid",
+ 149: "setresgid",
+ 150: "getresgid",
+ 151: "setfsuid",
+ 152: "setfsgid",
+ 153: "times",
+ 154: "setpgid",
+ 155: "getpgid",
+ 156: "getsid",
+ 157: "setsid",
+ 158: "getgroups",
+ 159: "setgroups",
+ 160: "uname",
+ 161: "sethostname",
+ 162: "setdomainname",
+ 163: "getrlimit",
+ 164: "setrlimit",
+ 165: "getrusage",
+ 166: "umask",
+ 167: "prctl",
+ 168: "getcpu",
+ 169: "gettimeofday",
+ 170: "settimeofday",
+ 171: "adjtimex",
+ 172: "getpid",
+ 173: "getppid",
+ 174: "getuid",
+ 175: "geteuid",
+ 176: "getgid",
+ 177: "getegid",
+ 178: "gettid",
+ 179: "sysinfo",
+ 180: "mq_open",
+ 181: "mq_unlink",
+ 182: "mq_timedsend",
+ 183: "mq_timedreceive",
+ 184: "mq_notify",
+ 185: "mq_getsetattr",
+ 186: "msgget",
+ 187: "msgctl",
+ 188: "msgrcv",
+ 189: "msgsnd",
+ 190: "semget",
+ 191: "semctl",
+ 192: "semtimedop",
+ 193: "semop",
+ 194: "shmget",
+ 195: "shmctl",
+ 196: "shmat",
+ 197: "shmdt",
+ 198: "socket",
+ 199: "socketpair",
+ 200: "bind",
+ 201: "listen",
+ 202: "accept",
+ 203: "connect",
+ 204: "getsockname",
+ 205: "getpeername",
+ 206: "sendto",
+ 207: "recvfrom",
+ 208: "setsockopt",
+ 209: "getsockopt",
+ 210: "shutdown",
+ 211: "sendmsg",
+ 212: "recvmsg",
+ 213: "readahead",
+ 214: "brk",
+ 215: "munmap",
+ 216: "mremap",
+ 217: "add_key",
+ 218: "request_key",
+ 219: "keyctl",
+ 220: "clone",
+ 221: "execve",
+ 222: "mmap",
+ 223: "fadvise64",
+ 224: "swapon",
+ 225: "swapoff",
+ 226: "mprotect",
+ 227: "msync",
+ 228: "mlock",
+ 229: "munlock",
+ 230: "mlockall",
+ 231: "munlockall",
+ 232: "mincore",
+ 233: "madvise",
+ 234: "remap_file_pages",
+ 235: "mbind",
+ 236: "get_mempolicy",
+ 237: "set_mempolicy",
+ 238: "migrate_pages",
+ 239: "move_pages",
+ 240: "rt_tgsigqueueinfo",
+ 241: "perf_event_open",
+ 242: "accept4",
+ 243: "recvmmsg",
+ 260: "wait4",
+ 261: "prlimit64",
+ 262: "fanotify_init",
+ 263: "fanotify_mark",
+ 264: "name_to_handle_at",
+ 265: "open_by_handle_at",
+ 266: "clock_adjtime",
+ 267: "syncfs",
+ 268: "setns",
+ 269: "sendmmsg",
+ 270: "process_vm_readv",
+ 271: "process_vm_writev",
+ 272: "kcmp",
+ 273: "finit_module",
+ 274: "sched_setattr",
+ 275: "sched_getattr",
+ 276: "renameat2",
+ 277: "seccomp",
+ 278: "getrandom",
+ 279: "memfd_create",
+ 280: "bpf",
+ 281: "execveat",
+ 282: "userfaultfd",
+ 283: "membarrier",
+ 284: "mlock2",
+ 285: "copy_file_range",
+ 286: "preadv2",
+ 287: "pwritev2",
+ 288: "pkey_mprotect",
+ 289: "pkey_alloc",
+ 290: "pkey_free",
+ 291: "statx",
+ 292: "io_pgetevents",
+ 293: "rseq",
+ 294: "kexec_file_load",
+ 424: "pidfd_send_signal",
+ 425: "io_uring_setup",
+ 426: "io_uring_enter",
+ 427: "io_uring_register",
+ 428: "open_tree",
+ 429: "move_mount",
+ 430: "fsopen",
+ 431: "fsconfig",
+ 432: "fsmount",
+ 433: "fspick",
+ 434: "pidfd_open",
+ 435: "clone3",
+ 436: "close_range",
+ 437: "openat2",
+ 438: "pidfd_getfd",
+ 439: "faccessat2",
+ 440: "process_madvise",
+ 441: "epoll_pwait2",
+ 442: "mount_setattr",
+ 443: "quotactl_fd",
+ 444: "landlock_create_ruleset",
+ 445: "landlock_add_rule",
+ 446: "landlock_restrict_self",
+ 447: "memfd_secret",
+ 448: "process_mrelease",
}
x86_syscall_table = {
0: "restart_syscall",
- 1: "exit",
- 2: "fork",
- 3: "read",
- 4: "write",
- 5: "open",
- 6: "close",
- 7: "waitpid",
- 8: "creat",
- 9: "link",
- 10: "unlink",
- 11: "execve",
- 12: "chdir",
- 13: "time",
- 14: "mknod",
- 15: "chmod",
- 16: "lchown",
- 18: "oldstat",
- 19: "lseek",
- 20: "getpid",
- 21: "mount",
- 22: "umount",
- 23: "setuid",
- 24: "getuid",
- 25: "stime",
- 26: "ptrace",
- 27: "alarm",
- 28: "oldfstat",
- 29: "pause",
- 30: "utime",
- 33: "access",
- 34: "nice",
- 36: "sync",
- 37: "kill",
- 38: "rename",
- 39: "mkdir",
- 40: "rmdir",
- 41: "dup",
- 42: "pipe",
- 43: "times",
- 45: "brk",
- 46: "setgid",
- 47: "getgid",
- 48: "signal",
- 49: "geteuid",
- 50: "getegid",
- 51: "acct",
- 52: "umount2",
- 54: "ioctl",
- 55: "fcntl",
- 57: "setpgid",
- 59: "oldolduname",
- 60: "umask",
- 61: "chroot",
- 62: "ustat",
- 63: "dup2",
- 64: "getppid",
- 65: "getpgrp",
- 66: "setsid",
- 67: "sigaction",
- 68: "sgetmask",
- 69: "ssetmask",
- 70: "setreuid",
- 71: "setregid",
- 72: "sigsuspend",
- 73: "sigpending",
- 74: "sethostname",
- 75: "setrlimit",
- 76: "getrlimit",
- 77: "getrusage",
- 78: "gettimeofday",
- 79: "settimeofday",
- 80: "getgroups",
- 81: "setgroups",
- 82: "select",
- 83: "symlink",
- 84: "oldlstat",
- 85: "readlink",
- 86: "uselib",
- 87: "swapon",
- 88: "reboot",
- 89: "readdir",
- 90: "mmap",
- 91: "munmap",
- 92: "truncate",
- 93: "ftruncate",
- 94: "fchmod",
- 95: "fchown",
- 96: "getpriority",
- 97: "setpriority",
- 99: "statfs",
- 100: "fstatfs",
- 101: "ioperm",
- 102: "socketcall",
- 103: "syslog",
- 104: "setitimer",
- 105: "getitimer",
- 106: "stat",
- 107: "lstat",
- 108: "fstat",
- 109: "olduname",
- 110: "iopl",
- 111: "vhangup",
- 112: "idle",
- 113: "vm86old",
- 114: "wait4",
- 115: "swapoff",
- 116: "sysinfo",
- 117: "ipc",
- 118: "fsync",
- 119: "sigreturn",
- 120: "clone",
- 121: "setdomainname",
- 122: "uname",
- 123: "modify_ldt",
- 124: "adjtimex",
- 125: "mprotect",
- 126: "sigprocmask",
- 127: "create_module",
- 128: "init_module",
- 129: "delete_module",
- 130: "get_kernel_syms",
- 131: "quotactl",
- 132: "getpgid",
- 133: "fchdir",
- 134: "bdflush",
- 135: "sysfs",
- 136: "personality",
- 138: "setfsuid",
- 139: "setfsgid",
- 140: "_llseek",
- 141: "getdents",
- 142: "_newselect",
- 143: "flock",
- 144: "msync",
- 145: "readv",
- 146: "writev",
- 147: "getsid",
- 148: "fdatasync",
- 149: "_sysctl",
- 150: "mlock",
- 151: "munlock",
- 152: "mlockall",
- 153: "munlockall",
- 154: "sched_setparam",
- 155: "sched_getparam",
- 156: "sched_setscheduler",
- 157: "sched_getscheduler",
- 158: "sched_yield",
- 159: "sched_get_priority_max",
- 160: "sched_get_priority_min",
- 161: "sched_rr_get_interval",
- 162: "nanosleep",
- 163: "mremap",
- 164: "setresuid",
- 165: "getresuid",
- 166: "vm86",
- 167: "query_module",
- 168: "poll",
- 169: "nfsservctl",
- 170: "setresgid",
- 171: "getresgid",
- 172: "prctl",
- 173: "rt_sigreturn",
- 174: "rt_sigaction",
- 175: "rt_sigprocmask",
- 176: "rt_sigpending",
- 177: "rt_sigtimedwait",
- 178: "rt_sigqueueinfo",
- 179: "rt_sigsuspend",
- 180: "pread64",
- 181: "pwrite64",
- 182: "chown",
- 183: "getcwd",
- 184: "capget",
- 185: "capset",
- 186: "sigaltstack",
- 187: "sendfile",
- 188: "getpmsg",
- 190: "vfork",
- 191: "ugetrlimit",
- 192: "mmap2",
- 193: "truncate64",
- 194: "ftruncate64",
- 195: "stat64",
- 196: "lstat64",
- 197: "fstat64",
- 198: "lchown32",
- 199: "getuid32",
- 200: "getgid32",
- 201: "geteuid32",
- 202: "getegid32",
- 203: "setreuid32",
- 204: "setregid32",
- 205: "getgroups32",
- 206: "setgroups32",
- 207: "fchown32",
- 208: "setresuid32",
- 209: "getresuid32",
- 210: "setresgid32",
- 211: "getresgid32",
- 212: "chown32",
- 213: "setuid32",
- 214: "setgid32",
- 215: "setfsuid32",
- 216: "setfsgid32",
- 217: "pivot_root",
- 218: "mincore",
- 219: "madvise",
- 220: "getdents64",
- 221: "fcntl64",
- 224: "gettid",
- 225: "readahead",
- 226: "setxattr",
- 227: "lsetxattr",
- 228: "fsetxattr",
- 229: "getxattr",
- 230: "lgetxattr",
- 231: "fgetxattr",
- 232: "listxattr",
- 233: "llistxattr",
- 234: "flistxattr",
- 235: "removexattr",
- 236: "lremovexattr",
- 237: "fremovexattr",
- 238: "tkill",
- 239: "sendfile64",
- 240: "futex",
- 241: "sched_setaffinity",
- 242: "sched_getaffinity",
- 243: "set_thread_area",
- 244: "get_thread_area",
- 245: "io_setup",
- 246: "io_destroy",
- 247: "io_getevents",
- 248: "io_submit",
- 249: "io_cancel",
- 250: "fadvise64",
- 252: "exit_group",
- 253: "lookup_dcookie",
- 254: "epoll_create",
- 255: "epoll_ctl",
- 256: "epoll_wait",
- 257: "remap_file_pages",
- 258: "set_tid_address",
- 259: "timer_create",
- 260: "timer_settime",
- 261: "timer_gettime",
- 262: "timer_getoverrun",
- 263: "timer_delete",
- 264: "clock_settime",
- 265: "clock_gettime",
- 266: "clock_getres",
- 267: "clock_nanosleep",
- 268: "statfs64",
- 269: "fstatfs64",
- 270: "tgkill",
- 271: "utimes",
- 272: "fadvise64_64",
- 274: "mbind",
- 275: "get_mempolicy",
- 276: "set_mempolicy",
- 277: "mq_open",
- 278: "mq_unlink",
- 279: "mq_timedsend",
- 280: "mq_timedreceive",
- 281: "mq_notify",
- 282: "mq_getsetattr",
- 283: "kexec_load",
- 284: "waitid",
- 286: "add_key",
- 287: "request_key",
- 288: "keyctl",
- 289: "ioprio_set",
- 290: "ioprio_get",
- 291: "inotify_init",
- 292: "inotify_add_watch",
- 293: "inotify_rm_watch",
- 294: "migrate_pages",
- 295: "openat",
- 296: "mkdirat",
- 297: "mknodat",
- 298: "fchownat",
- 299: "futimesat",
- 300: "fstatat64",
- 301: "unlinkat",
- 302: "renameat",
- 303: "linkat",
- 304: "symlinkat",
- 305: "readlinkat",
- 306: "fchmodat",
- 307: "faccessat",
- 308: "pselect6",
- 309: "ppoll",
- 310: "unshare",
- 311: "set_robust_list",
- 312: "get_robust_list",
- 313: "splice",
- 314: "sync_file_range",
- 315: "tee",
- 316: "vmsplice",
- 317: "move_pages",
- 318: "getcpu",
- 319: "epoll_pwait",
- 320: "utimensat",
- 321: "signalfd",
- 322: "timerfd_create",
- 323: "eventfd",
- 324: "fallocate",
- 325: "timerfd_settime",
- 326: "timerfd_gettime",
- 327: "signalfd4",
- 328: "eventfd2",
- 329: "epoll_create1",
- 330: "dup3",
- 331: "pipe2",
- 332: "inotify_init1",
- 333: "preadv",
- 334: "pwritev",
- 335: "rt_tgsigqueueinfo",
- 336: "perf_event_open",
- 337: "recvmmsg",
- 338: "fanotify_init",
- 339: "fanotify_mark",
- 340: "prlimit64",
- 341: "name_to_handle_at",
- 342: "open_by_handle_at",
- 343: "clock_adjtime",
- 344: "syncfs",
- 345: "sendmmsg",
- 346: "setns",
- 347: "process_vm_readv",
- 348: "process_vm_writev",
- 349: "kcmp",
- 350: "finit_module",
- 351: "sched_setattr",
- 352: "sched_getattr",
- 353: "renameat2",
- 354: "seccomp",
- 355: "getrandom",
- 356: "memfd_create",
- 357: "bpf",
- 358: "execveat",
- 359: "socket",
- 360: "socketpair",
- 361: "bind",
- 362: "connect",
- 363: "listen",
- 364: "accept4",
- 365: "getsockopt",
- 366: "setsockopt",
- 367: "getsockname",
- 368: "getpeername",
- 369: "sendto",
- 370: "sendmsg",
- 371: "recvfrom",
- 372: "recvmsg",
- 373: "shutdown",
- 374: "userfaultfd",
- 375: "membarrier",
- 376: "mlock2",
- 377: "copy_file_range",
- 378: "preadv2",
- 379: "pwritev2",
- 380: "pkey_mprotect",
- 381: "pkey_alloc",
- 382: "pkey_free",
- 383: "statx",
- 384: "arch_prctl",
- 385: "io_pgetevents",
- 386: "rseq",
- 393: "semget",
- 394: "semctl",
- 395: "shmget",
- 396: "shmctl",
- 397: "shmat",
- 398: "shmdt",
- 399: "msgget",
- 400: "msgsnd",
- 401: "msgrcv",
- 402: "msgctl",
- 403: "clock_gettime64",
- 404: "clock_settime64",
- 405: "clock_adjtime64",
- 406: "clock_getres_time64",
- 407: "clock_nanosleep_time64",
- 408: "timer_gettime64",
- 409: "timer_settime64",
- 410: "timerfd_gettime64",
- 411: "timerfd_settime64",
- 412: "utimensat_time64",
- 413: "pselect6_time64",
- 414: "ppoll_time64",
- 416: "io_pgetevents_time64",
- 417: "recvmmsg_time64",
- 418: "mq_timedsend_time64",
- 419: "mq_timedreceive_time64",
- 420: "semtimedop_time64",
- 421: "rt_sigtimedwait_time64",
- 422: "futex_time64",
- 423: "sched_rr_get_interval_time64",
- 424: "pidfd_send_signal",
- 425: "io_uring_setup",
- 426: "io_uring_enter",
- 427: "io_uring_register",
- 428: "open_tree",
- 429: "move_mount",
- 430: "fsopen",
- 431: "fsconfig",
- 432: "fsmount",
- 433: "fspick",
- 434: "pidfd_open",
- 435: "clone3",
- 436: "close_range",
- 437: "openat2",
- 438: "pidfd_getfd",
- 439: "faccessat2",
- 440: "process_madvise",
- 441: "epoll_pwait2",
- 442: "mount_setattr",
- 443: "quotactl_fd",
- 444: "landlock_create_ruleset",
- 445: "landlock_add_rule",
- 446: "landlock_restrict_self",
- 447: "memfd_secret",
- 448: "process_mrelease",
+ 1: "exit",
+ 2: "fork",
+ 3: "read",
+ 4: "write",
+ 5: "open",
+ 6: "close",
+ 7: "waitpid",
+ 8: "creat",
+ 9: "link",
+ 10: "unlink",
+ 11: "execve",
+ 12: "chdir",
+ 13: "time",
+ 14: "mknod",
+ 15: "chmod",
+ 16: "lchown",
+ 18: "oldstat",
+ 19: "lseek",
+ 20: "getpid",
+ 21: "mount",
+ 22: "umount",
+ 23: "setuid",
+ 24: "getuid",
+ 25: "stime",
+ 26: "ptrace",
+ 27: "alarm",
+ 28: "oldfstat",
+ 29: "pause",
+ 30: "utime",
+ 33: "access",
+ 34: "nice",
+ 36: "sync",
+ 37: "kill",
+ 38: "rename",
+ 39: "mkdir",
+ 40: "rmdir",
+ 41: "dup",
+ 42: "pipe",
+ 43: "times",
+ 45: "brk",
+ 46: "setgid",
+ 47: "getgid",
+ 48: "signal",
+ 49: "geteuid",
+ 50: "getegid",
+ 51: "acct",
+ 52: "umount2",
+ 54: "ioctl",
+ 55: "fcntl",
+ 57: "setpgid",
+ 59: "oldolduname",
+ 60: "umask",
+ 61: "chroot",
+ 62: "ustat",
+ 63: "dup2",
+ 64: "getppid",
+ 65: "getpgrp",
+ 66: "setsid",
+ 67: "sigaction",
+ 68: "sgetmask",
+ 69: "ssetmask",
+ 70: "setreuid",
+ 71: "setregid",
+ 72: "sigsuspend",
+ 73: "sigpending",
+ 74: "sethostname",
+ 75: "setrlimit",
+ 76: "getrlimit",
+ 77: "getrusage",
+ 78: "gettimeofday",
+ 79: "settimeofday",
+ 80: "getgroups",
+ 81: "setgroups",
+ 82: "select",
+ 83: "symlink",
+ 84: "oldlstat",
+ 85: "readlink",
+ 86: "uselib",
+ 87: "swapon",
+ 88: "reboot",
+ 89: "readdir",
+ 90: "mmap",
+ 91: "munmap",
+ 92: "truncate",
+ 93: "ftruncate",
+ 94: "fchmod",
+ 95: "fchown",
+ 96: "getpriority",
+ 97: "setpriority",
+ 99: "statfs",
+ 100: "fstatfs",
+ 101: "ioperm",
+ 102: "socketcall",
+ 103: "syslog",
+ 104: "setitimer",
+ 105: "getitimer",
+ 106: "stat",
+ 107: "lstat",
+ 108: "fstat",
+ 109: "olduname",
+ 110: "iopl",
+ 111: "vhangup",
+ 112: "idle",
+ 113: "vm86old",
+ 114: "wait4",
+ 115: "swapoff",
+ 116: "sysinfo",
+ 117: "ipc",
+ 118: "fsync",
+ 119: "sigreturn",
+ 120: "clone",
+ 121: "setdomainname",
+ 122: "uname",
+ 123: "modify_ldt",
+ 124: "adjtimex",
+ 125: "mprotect",
+ 126: "sigprocmask",
+ 127: "create_module",
+ 128: "init_module",
+ 129: "delete_module",
+ 130: "get_kernel_syms",
+ 131: "quotactl",
+ 132: "getpgid",
+ 133: "fchdir",
+ 134: "bdflush",
+ 135: "sysfs",
+ 136: "personality",
+ 138: "setfsuid",
+ 139: "setfsgid",
+ 140: "_llseek",
+ 141: "getdents",
+ 142: "_newselect",
+ 143: "flock",
+ 144: "msync",
+ 145: "readv",
+ 146: "writev",
+ 147: "getsid",
+ 148: "fdatasync",
+ 149: "_sysctl",
+ 150: "mlock",
+ 151: "munlock",
+ 152: "mlockall",
+ 153: "munlockall",
+ 154: "sched_setparam",
+ 155: "sched_getparam",
+ 156: "sched_setscheduler",
+ 157: "sched_getscheduler",
+ 158: "sched_yield",
+ 159: "sched_get_priority_max",
+ 160: "sched_get_priority_min",
+ 161: "sched_rr_get_interval",
+ 162: "nanosleep",
+ 163: "mremap",
+ 164: "setresuid",
+ 165: "getresuid",
+ 166: "vm86",
+ 167: "query_module",
+ 168: "poll",
+ 169: "nfsservctl",
+ 170: "setresgid",
+ 171: "getresgid",
+ 172: "prctl",
+ 173: "rt_sigreturn",
+ 174: "rt_sigaction",
+ 175: "rt_sigprocmask",
+ 176: "rt_sigpending",
+ 177: "rt_sigtimedwait",
+ 178: "rt_sigqueueinfo",
+ 179: "rt_sigsuspend",
+ 180: "pread64",
+ 181: "pwrite64",
+ 182: "chown",
+ 183: "getcwd",
+ 184: "capget",
+ 185: "capset",
+ 186: "sigaltstack",
+ 187: "sendfile",
+ 188: "getpmsg",
+ 190: "vfork",
+ 191: "ugetrlimit",
+ 192: "mmap2",
+ 193: "truncate64",
+ 194: "ftruncate64",
+ 195: "stat64",
+ 196: "lstat64",
+ 197: "fstat64",
+ 198: "lchown32",
+ 199: "getuid32",
+ 200: "getgid32",
+ 201: "geteuid32",
+ 202: "getegid32",
+ 203: "setreuid32",
+ 204: "setregid32",
+ 205: "getgroups32",
+ 206: "setgroups32",
+ 207: "fchown32",
+ 208: "setresuid32",
+ 209: "getresuid32",
+ 210: "setresgid32",
+ 211: "getresgid32",
+ 212: "chown32",
+ 213: "setuid32",
+ 214: "setgid32",
+ 215: "setfsuid32",
+ 216: "setfsgid32",
+ 217: "pivot_root",
+ 218: "mincore",
+ 219: "madvise",
+ 220: "getdents64",
+ 221: "fcntl64",
+ 224: "gettid",
+ 225: "readahead",
+ 226: "setxattr",
+ 227: "lsetxattr",
+ 228: "fsetxattr",
+ 229: "getxattr",
+ 230: "lgetxattr",
+ 231: "fgetxattr",
+ 232: "listxattr",
+ 233: "llistxattr",
+ 234: "flistxattr",
+ 235: "removexattr",
+ 236: "lremovexattr",
+ 237: "fremovexattr",
+ 238: "tkill",
+ 239: "sendfile64",
+ 240: "futex",
+ 241: "sched_setaffinity",
+ 242: "sched_getaffinity",
+ 243: "set_thread_area",
+ 244: "get_thread_area",
+ 245: "io_setup",
+ 246: "io_destroy",
+ 247: "io_getevents",
+ 248: "io_submit",
+ 249: "io_cancel",
+ 250: "fadvise64",
+ 252: "exit_group",
+ 253: "lookup_dcookie",
+ 254: "epoll_create",
+ 255: "epoll_ctl",
+ 256: "epoll_wait",
+ 257: "remap_file_pages",
+ 258: "set_tid_address",
+ 259: "timer_create",
+ 260: "timer_settime",
+ 261: "timer_gettime",
+ 262: "timer_getoverrun",
+ 263: "timer_delete",
+ 264: "clock_settime",
+ 265: "clock_gettime",
+ 266: "clock_getres",
+ 267: "clock_nanosleep",
+ 268: "statfs64",
+ 269: "fstatfs64",
+ 270: "tgkill",
+ 271: "utimes",
+ 272: "fadvise64_64",
+ 274: "mbind",
+ 275: "get_mempolicy",
+ 276: "set_mempolicy",
+ 277: "mq_open",
+ 278: "mq_unlink",
+ 279: "mq_timedsend",
+ 280: "mq_timedreceive",
+ 281: "mq_notify",
+ 282: "mq_getsetattr",
+ 283: "kexec_load",
+ 284: "waitid",
+ 286: "add_key",
+ 287: "request_key",
+ 288: "keyctl",
+ 289: "ioprio_set",
+ 290: "ioprio_get",
+ 291: "inotify_init",
+ 292: "inotify_add_watch",
+ 293: "inotify_rm_watch",
+ 294: "migrate_pages",
+ 295: "openat",
+ 296: "mkdirat",
+ 297: "mknodat",
+ 298: "fchownat",
+ 299: "futimesat",
+ 300: "fstatat64",
+ 301: "unlinkat",
+ 302: "renameat",
+ 303: "linkat",
+ 304: "symlinkat",
+ 305: "readlinkat",
+ 306: "fchmodat",
+ 307: "faccessat",
+ 308: "pselect6",
+ 309: "ppoll",
+ 310: "unshare",
+ 311: "set_robust_list",
+ 312: "get_robust_list",
+ 313: "splice",
+ 314: "sync_file_range",
+ 315: "tee",
+ 316: "vmsplice",
+ 317: "move_pages",
+ 318: "getcpu",
+ 319: "epoll_pwait",
+ 320: "utimensat",
+ 321: "signalfd",
+ 322: "timerfd_create",
+ 323: "eventfd",
+ 324: "fallocate",
+ 325: "timerfd_settime",
+ 326: "timerfd_gettime",
+ 327: "signalfd4",
+ 328: "eventfd2",
+ 329: "epoll_create1",
+ 330: "dup3",
+ 331: "pipe2",
+ 332: "inotify_init1",
+ 333: "preadv",
+ 334: "pwritev",
+ 335: "rt_tgsigqueueinfo",
+ 336: "perf_event_open",
+ 337: "recvmmsg",
+ 338: "fanotify_init",
+ 339: "fanotify_mark",
+ 340: "prlimit64",
+ 341: "name_to_handle_at",
+ 342: "open_by_handle_at",
+ 343: "clock_adjtime",
+ 344: "syncfs",
+ 345: "sendmmsg",
+ 346: "setns",
+ 347: "process_vm_readv",
+ 348: "process_vm_writev",
+ 349: "kcmp",
+ 350: "finit_module",
+ 351: "sched_setattr",
+ 352: "sched_getattr",
+ 353: "renameat2",
+ 354: "seccomp",
+ 355: "getrandom",
+ 356: "memfd_create",
+ 357: "bpf",
+ 358: "execveat",
+ 359: "socket",
+ 360: "socketpair",
+ 361: "bind",
+ 362: "connect",
+ 363: "listen",
+ 364: "accept4",
+ 365: "getsockopt",
+ 366: "setsockopt",
+ 367: "getsockname",
+ 368: "getpeername",
+ 369: "sendto",
+ 370: "sendmsg",
+ 371: "recvfrom",
+ 372: "recvmsg",
+ 373: "shutdown",
+ 374: "userfaultfd",
+ 375: "membarrier",
+ 376: "mlock2",
+ 377: "copy_file_range",
+ 378: "preadv2",
+ 379: "pwritev2",
+ 380: "pkey_mprotect",
+ 381: "pkey_alloc",
+ 382: "pkey_free",
+ 383: "statx",
+ 384: "arch_prctl",
+ 385: "io_pgetevents",
+ 386: "rseq",
+ 393: "semget",
+ 394: "semctl",
+ 395: "shmget",
+ 396: "shmctl",
+ 397: "shmat",
+ 398: "shmdt",
+ 399: "msgget",
+ 400: "msgsnd",
+ 401: "msgrcv",
+ 402: "msgctl",
+ 403: "clock_gettime64",
+ 404: "clock_settime64",
+ 405: "clock_adjtime64",
+ 406: "clock_getres_time64",
+ 407: "clock_nanosleep_time64",
+ 408: "timer_gettime64",
+ 409: "timer_settime64",
+ 410: "timerfd_gettime64",
+ 411: "timerfd_settime64",
+ 412: "utimensat_time64",
+ 413: "pselect6_time64",
+ 414: "ppoll_time64",
+ 416: "io_pgetevents_time64",
+ 417: "recvmmsg_time64",
+ 418: "mq_timedsend_time64",
+ 419: "mq_timedreceive_time64",
+ 420: "semtimedop_time64",
+ 421: "rt_sigtimedwait_time64",
+ 422: "futex_time64",
+ 423: "sched_rr_get_interval_time64",
+ 424: "pidfd_send_signal",
+ 425: "io_uring_setup",
+ 426: "io_uring_enter",
+ 427: "io_uring_register",
+ 428: "open_tree",
+ 429: "move_mount",
+ 430: "fsopen",
+ 431: "fsconfig",
+ 432: "fsmount",
+ 433: "fspick",
+ 434: "pidfd_open",
+ 435: "clone3",
+ 436: "close_range",
+ 437: "openat2",
+ 438: "pidfd_getfd",
+ 439: "faccessat2",
+ 440: "process_madvise",
+ 441: "epoll_pwait2",
+ 442: "mount_setattr",
+ 443: "quotactl_fd",
+ 444: "landlock_create_ruleset",
+ 445: "landlock_add_rule",
+ 446: "landlock_restrict_self",
+ 447: "memfd_secret",
+ 448: "process_mrelease",
}
x8664_syscall_table = {
0: "read",
- 1: "write",
- 2: "open",
- 3: "close",
- 4: "stat",
- 5: "fstat",
- 6: "lstat",
- 7: "poll",
- 8: "lseek",
- 9: "mmap",
- 10: "mprotect",
- 11: "munmap",
- 12: "brk",
- 13: "rt_sigaction",
- 14: "rt_sigprocmask",
- 15: "rt_sigreturn",
- 16: "ioctl",
- 17: "pread64",
- 18: "pwrite64",
- 19: "readv",
- 20: "writev",
- 21: "access",
- 22: "pipe",
- 23: "select",
- 24: "sched_yield",
- 25: "mremap",
- 26: "msync",
- 27: "mincore",
- 28: "madvise",
- 29: "shmget",
- 30: "shmat",
- 31: "shmctl",
- 32: "dup",
- 33: "dup2",
- 34: "pause",
- 35: "nanosleep",
- 36: "getitimer",
- 37: "alarm",
- 38: "setitimer",
- 39: "getpid",
- 40: "sendfile",
- 41: "socket",
- 42: "connect",
- 43: "accept",
- 44: "sendto",
- 45: "recvfrom",
- 46: "sendmsg",
- 47: "recvmsg",
- 48: "shutdown",
- 49: "bind",
- 50: "listen",
- 51: "getsockname",
- 52: "getpeername",
- 53: "socketpair",
- 54: "setsockopt",
- 55: "getsockopt",
- 56: "clone",
- 57: "fork",
- 58: "vfork",
- 59: "execve",
- 60: "exit",
- 61: "wait4",
- 62: "kill",
- 63: "uname",
- 64: "semget",
- 65: "semop",
- 66: "semctl",
- 67: "shmdt",
- 68: "msgget",
- 69: "msgsnd",
- 70: "msgrcv",
- 71: "msgctl",
- 72: "fcntl",
- 73: "flock",
- 74: "fsync",
- 75: "fdatasync",
- 76: "truncate",
- 77: "ftruncate",
- 78: "getdents",
- 79: "getcwd",
- 80: "chdir",
- 81: "fchdir",
- 82: "rename",
- 83: "mkdir",
- 84: "rmdir",
- 85: "creat",
- 86: "link",
- 87: "unlink",
- 88: "symlink",
- 89: "readlink",
- 90: "chmod",
- 91: "fchmod",
- 92: "chown",
- 93: "fchown",
- 94: "lchown",
- 95: "umask",
- 96: "gettimeofday",
- 97: "getrlimit",
- 98: "getrusage",
- 99: "sysinfo",
- 100: "times",
- 101: "ptrace",
- 102: "getuid",
- 103: "syslog",
- 104: "getgid",
- 105: "setuid",
- 106: "setgid",
- 107: "geteuid",
- 108: "getegid",
- 109: "setpgid",
- 110: "getppid",
- 111: "getpgrp",
- 112: "setsid",
- 113: "setreuid",
- 114: "setregid",
- 115: "getgroups",
- 116: "setgroups",
- 117: "setresuid",
- 118: "getresuid",
- 119: "setresgid",
- 120: "getresgid",
- 121: "getpgid",
- 122: "setfsuid",
- 123: "setfsgid",
- 124: "getsid",
- 125: "capget",
- 126: "capset",
- 127: "rt_sigpending",
- 128: "rt_sigtimedwait",
- 129: "rt_sigqueueinfo",
- 130: "rt_sigsuspend",
- 131: "sigaltstack",
- 132: "utime",
- 133: "mknod",
- 134: "uselib",
- 135: "personality",
- 136: "ustat",
- 137: "statfs",
- 138: "fstatfs",
- 139: "sysfs",
- 140: "getpriority",
- 141: "setpriority",
- 142: "sched_setparam",
- 143: "sched_getparam",
- 144: "sched_setscheduler",
- 145: "sched_getscheduler",
- 146: "sched_get_priority_max",
- 147: "sched_get_priority_min",
- 148: "sched_rr_get_interval",
- 149: "mlock",
- 150: "munlock",
- 151: "mlockall",
- 152: "munlockall",
- 153: "vhangup",
- 154: "modify_ldt",
- 155: "pivot_root",
- 156: "_sysctl",
- 157: "prctl",
- 158: "arch_prctl",
- 159: "adjtimex",
- 160: "setrlimit",
- 161: "chroot",
- 162: "sync",
- 163: "acct",
- 164: "settimeofday",
- 165: "mount",
- 166: "umount2",
- 167: "swapon",
- 168: "swapoff",
- 169: "reboot",
- 170: "sethostname",
- 171: "setdomainname",
- 172: "iopl",
- 173: "ioperm",
- 174: "create_module",
- 175: "init_module",
- 176: "delete_module",
- 177: "get_kernel_syms",
- 178: "query_module",
- 179: "quotactl",
- 180: "nfsservctl",
- 181: "getpmsg",
- 186: "gettid",
- 187: "readahead",
- 188: "setxattr",
- 189: "lsetxattr",
- 190: "fsetxattr",
- 191: "getxattr",
- 192: "lgetxattr",
- 193: "fgetxattr",
- 194: "listxattr",
- 195: "llistxattr",
- 196: "flistxattr",
- 197: "removexattr",
- 198: "lremovexattr",
- 199: "fremovexattr",
- 200: "tkill",
- 201: "time",
- 202: "futex",
- 203: "sched_setaffinity",
- 204: "sched_getaffinity",
- 205: "set_thread_area",
- 206: "io_setup",
- 207: "io_destroy",
- 208: "io_getevents",
- 209: "io_submit",
- 210: "io_cancel",
- 211: "get_thread_area",
- 212: "lookup_dcookie",
- 213: "epoll_create",
- 214: "epoll_ctl_old",
- 215: "epoll_wait_old",
- 216: "remap_file_pages",
- 217: "getdents64",
- 218: "set_tid_address",
- 219: "restart_syscall",
- 220: "semtimedop",
- 221: "fadvise64",
- 222: "timer_create",
- 223: "timer_settime",
- 224: "timer_gettime",
- 225: "timer_getoverrun",
- 226: "timer_delete",
- 227: "clock_settime",
- 228: "clock_gettime",
- 229: "clock_getres",
- 230: "clock_nanosleep",
- 231: "exit_group",
- 232: "epoll_wait",
- 233: "epoll_ctl",
- 234: "tgkill",
- 235: "utimes",
- 237: "mbind",
- 238: "set_mempolicy",
- 239: "get_mempolicy",
- 240: "mq_open",
- 241: "mq_unlink",
- 242: "mq_timedsend",
- 243: "mq_timedreceive",
- 244: "mq_notify",
- 245: "mq_getsetattr",
- 246: "kexec_load",
- 247: "waitid",
- 248: "add_key",
- 249: "request_key",
- 250: "keyctl",
- 251: "ioprio_set",
- 252: "ioprio_get",
- 253: "inotify_init",
- 254: "inotify_add_watch",
- 255: "inotify_rm_watch",
- 256: "migrate_pages",
- 257: "openat",
- 258: "mkdirat",
- 259: "mknodat",
- 260: "fchownat",
- 261: "futimesat",
- 262: "newfstatat",
- 263: "unlinkat",
- 264: "renameat",
- 265: "linkat",
- 266: "symlinkat",
- 267: "readlinkat",
- 268: "fchmodat",
- 269: "faccessat",
- 270: "pselect6",
- 271: "ppoll",
- 272: "unshare",
- 273: "set_robust_list",
- 274: "get_robust_list",
- 275: "splice",
- 276: "tee",
- 277: "sync_file_range",
- 278: "vmsplice",
- 279: "move_pages",
- 280: "utimensat",
- 281: "epoll_pwait",
- 282: "signalfd",
- 283: "timerfd_create",
- 284: "eventfd",
- 285: "fallocate",
- 286: "timerfd_settime",
- 287: "timerfd_gettime",
- 288: "accept4",
- 289: "signalfd4",
- 290: "eventfd2",
- 291: "epoll_create1",
- 292: "dup3",
- 293: "pipe2",
- 294: "inotify_init1",
- 295: "preadv",
- 296: "pwritev",
- 297: "rt_tgsigqueueinfo",
- 298: "perf_event_open",
- 299: "recvmmsg",
- 300: "fanotify_init",
- 301: "fanotify_mark",
- 302: "prlimit64",
- 303: "name_to_handle_at",
- 304: "open_by_handle_at",
- 305: "clock_adjtime",
- 306: "syncfs",
- 307: "sendmmsg",
- 308: "setns",
- 309: "getcpu",
- 310: "process_vm_readv",
- 311: "process_vm_writev",
- 312: "kcmp",
- 313: "finit_module",
- 314: "sched_setattr",
- 315: "sched_getattr",
- 316: "renameat2",
- 317: "seccomp",
- 318: "getrandom",
- 319: "memfd_create",
- 320: "kexec_file_load",
- 321: "bpf",
- 322: "execveat",
- 323: "userfaultfd",
- 324: "membarrier",
- 325: "mlock2",
- 326: "copy_file_range",
- 327: "preadv2",
- 328: "pwritev2",
- 329: "pkey_mprotect",
- 330: "pkey_alloc",
- 331: "pkey_free",
- 332: "statx",
- 333: "io_pgetevents",
- 334: "rseq",
- 424: "pidfd_send_signal",
- 425: "io_uring_setup",
- 426: "io_uring_enter",
- 427: "io_uring_register",
- 428: "open_tree",
- 429: "move_mount",
- 430: "fsopen",
- 431: "fsconfig",
- 432: "fsmount",
- 433: "fspick",
- 434: "pidfd_open",
- 435: "clone3",
- 436: "close_range",
- 437: "openat2",
- 438: "pidfd_getfd",
- 439: "faccessat2",
- 440: "process_madvise",
- 441: "epoll_pwait2",
- 442: "mount_setattr",
- 443: "quotactl_fd",
- 444: "landlock_create_ruleset",
- 445: "landlock_add_rule",
- 446: "landlock_restrict_self",
- 447: "memfd_secret",
- 448: "process_mrelease",
+ 1: "write",
+ 2: "open",
+ 3: "close",
+ 4: "stat",
+ 5: "fstat",
+ 6: "lstat",
+ 7: "poll",
+ 8: "lseek",
+ 9: "mmap",
+ 10: "mprotect",
+ 11: "munmap",
+ 12: "brk",
+ 13: "rt_sigaction",
+ 14: "rt_sigprocmask",
+ 15: "rt_sigreturn",
+ 16: "ioctl",
+ 17: "pread64",
+ 18: "pwrite64",
+ 19: "readv",
+ 20: "writev",
+ 21: "access",
+ 22: "pipe",
+ 23: "select",
+ 24: "sched_yield",
+ 25: "mremap",
+ 26: "msync",
+ 27: "mincore",
+ 28: "madvise",
+ 29: "shmget",
+ 30: "shmat",
+ 31: "shmctl",
+ 32: "dup",
+ 33: "dup2",
+ 34: "pause",
+ 35: "nanosleep",
+ 36: "getitimer",
+ 37: "alarm",
+ 38: "setitimer",
+ 39: "getpid",
+ 40: "sendfile",
+ 41: "socket",
+ 42: "connect",
+ 43: "accept",
+ 44: "sendto",
+ 45: "recvfrom",
+ 46: "sendmsg",
+ 47: "recvmsg",
+ 48: "shutdown",
+ 49: "bind",
+ 50: "listen",
+ 51: "getsockname",
+ 52: "getpeername",
+ 53: "socketpair",
+ 54: "setsockopt",
+ 55: "getsockopt",
+ 56: "clone",
+ 57: "fork",
+ 58: "vfork",
+ 59: "execve",
+ 60: "exit",
+ 61: "wait4",
+ 62: "kill",
+ 63: "uname",
+ 64: "semget",
+ 65: "semop",
+ 66: "semctl",
+ 67: "shmdt",
+ 68: "msgget",
+ 69: "msgsnd",
+ 70: "msgrcv",
+ 71: "msgctl",
+ 72: "fcntl",
+ 73: "flock",
+ 74: "fsync",
+ 75: "fdatasync",
+ 76: "truncate",
+ 77: "ftruncate",
+ 78: "getdents",
+ 79: "getcwd",
+ 80: "chdir",
+ 81: "fchdir",
+ 82: "rename",
+ 83: "mkdir",
+ 84: "rmdir",
+ 85: "creat",
+ 86: "link",
+ 87: "unlink",
+ 88: "symlink",
+ 89: "readlink",
+ 90: "chmod",
+ 91: "fchmod",
+ 92: "chown",
+ 93: "fchown",
+ 94: "lchown",
+ 95: "umask",
+ 96: "gettimeofday",
+ 97: "getrlimit",
+ 98: "getrusage",
+ 99: "sysinfo",
+ 100: "times",
+ 101: "ptrace",
+ 102: "getuid",
+ 103: "syslog",
+ 104: "getgid",
+ 105: "setuid",
+ 106: "setgid",
+ 107: "geteuid",
+ 108: "getegid",
+ 109: "setpgid",
+ 110: "getppid",
+ 111: "getpgrp",
+ 112: "setsid",
+ 113: "setreuid",
+ 114: "setregid",
+ 115: "getgroups",
+ 116: "setgroups",
+ 117: "setresuid",
+ 118: "getresuid",
+ 119: "setresgid",
+ 120: "getresgid",
+ 121: "getpgid",
+ 122: "setfsuid",
+ 123: "setfsgid",
+ 124: "getsid",
+ 125: "capget",
+ 126: "capset",
+ 127: "rt_sigpending",
+ 128: "rt_sigtimedwait",
+ 129: "rt_sigqueueinfo",
+ 130: "rt_sigsuspend",
+ 131: "sigaltstack",
+ 132: "utime",
+ 133: "mknod",
+ 134: "uselib",
+ 135: "personality",
+ 136: "ustat",
+ 137: "statfs",
+ 138: "fstatfs",
+ 139: "sysfs",
+ 140: "getpriority",
+ 141: "setpriority",
+ 142: "sched_setparam",
+ 143: "sched_getparam",
+ 144: "sched_setscheduler",
+ 145: "sched_getscheduler",
+ 146: "sched_get_priority_max",
+ 147: "sched_get_priority_min",
+ 148: "sched_rr_get_interval",
+ 149: "mlock",
+ 150: "munlock",
+ 151: "mlockall",
+ 152: "munlockall",
+ 153: "vhangup",
+ 154: "modify_ldt",
+ 155: "pivot_root",
+ 156: "_sysctl",
+ 157: "prctl",
+ 158: "arch_prctl",
+ 159: "adjtimex",
+ 160: "setrlimit",
+ 161: "chroot",
+ 162: "sync",
+ 163: "acct",
+ 164: "settimeofday",
+ 165: "mount",
+ 166: "umount2",
+ 167: "swapon",
+ 168: "swapoff",
+ 169: "reboot",
+ 170: "sethostname",
+ 171: "setdomainname",
+ 172: "iopl",
+ 173: "ioperm",
+ 174: "create_module",
+ 175: "init_module",
+ 176: "delete_module",
+ 177: "get_kernel_syms",
+ 178: "query_module",
+ 179: "quotactl",
+ 180: "nfsservctl",
+ 181: "getpmsg",
+ 186: "gettid",
+ 187: "readahead",
+ 188: "setxattr",
+ 189: "lsetxattr",
+ 190: "fsetxattr",
+ 191: "getxattr",
+ 192: "lgetxattr",
+ 193: "fgetxattr",
+ 194: "listxattr",
+ 195: "llistxattr",
+ 196: "flistxattr",
+ 197: "removexattr",
+ 198: "lremovexattr",
+ 199: "fremovexattr",
+ 200: "tkill",
+ 201: "time",
+ 202: "futex",
+ 203: "sched_setaffinity",
+ 204: "sched_getaffinity",
+ 205: "set_thread_area",
+ 206: "io_setup",
+ 207: "io_destroy",
+ 208: "io_getevents",
+ 209: "io_submit",
+ 210: "io_cancel",
+ 211: "get_thread_area",
+ 212: "lookup_dcookie",
+ 213: "epoll_create",
+ 214: "epoll_ctl_old",
+ 215: "epoll_wait_old",
+ 216: "remap_file_pages",
+ 217: "getdents64",
+ 218: "set_tid_address",
+ 219: "restart_syscall",
+ 220: "semtimedop",
+ 221: "fadvise64",
+ 222: "timer_create",
+ 223: "timer_settime",
+ 224: "timer_gettime",
+ 225: "timer_getoverrun",
+ 226: "timer_delete",
+ 227: "clock_settime",
+ 228: "clock_gettime",
+ 229: "clock_getres",
+ 230: "clock_nanosleep",
+ 231: "exit_group",
+ 232: "epoll_wait",
+ 233: "epoll_ctl",
+ 234: "tgkill",
+ 235: "utimes",
+ 237: "mbind",
+ 238: "set_mempolicy",
+ 239: "get_mempolicy",
+ 240: "mq_open",
+ 241: "mq_unlink",
+ 242: "mq_timedsend",
+ 243: "mq_timedreceive",
+ 244: "mq_notify",
+ 245: "mq_getsetattr",
+ 246: "kexec_load",
+ 247: "waitid",
+ 248: "add_key",
+ 249: "request_key",
+ 250: "keyctl",
+ 251: "ioprio_set",
+ 252: "ioprio_get",
+ 253: "inotify_init",
+ 254: "inotify_add_watch",
+ 255: "inotify_rm_watch",
+ 256: "migrate_pages",
+ 257: "openat",
+ 258: "mkdirat",
+ 259: "mknodat",
+ 260: "fchownat",
+ 261: "futimesat",
+ 262: "newfstatat",
+ 263: "unlinkat",
+ 264: "renameat",
+ 265: "linkat",
+ 266: "symlinkat",
+ 267: "readlinkat",
+ 268: "fchmodat",
+ 269: "faccessat",
+ 270: "pselect6",
+ 271: "ppoll",
+ 272: "unshare",
+ 273: "set_robust_list",
+ 274: "get_robust_list",
+ 275: "splice",
+ 276: "tee",
+ 277: "sync_file_range",
+ 278: "vmsplice",
+ 279: "move_pages",
+ 280: "utimensat",
+ 281: "epoll_pwait",
+ 282: "signalfd",
+ 283: "timerfd_create",
+ 284: "eventfd",
+ 285: "fallocate",
+ 286: "timerfd_settime",
+ 287: "timerfd_gettime",
+ 288: "accept4",
+ 289: "signalfd4",
+ 290: "eventfd2",
+ 291: "epoll_create1",
+ 292: "dup3",
+ 293: "pipe2",
+ 294: "inotify_init1",
+ 295: "preadv",
+ 296: "pwritev",
+ 297: "rt_tgsigqueueinfo",
+ 298: "perf_event_open",
+ 299: "recvmmsg",
+ 300: "fanotify_init",
+ 301: "fanotify_mark",
+ 302: "prlimit64",
+ 303: "name_to_handle_at",
+ 304: "open_by_handle_at",
+ 305: "clock_adjtime",
+ 306: "syncfs",
+ 307: "sendmmsg",
+ 308: "setns",
+ 309: "getcpu",
+ 310: "process_vm_readv",
+ 311: "process_vm_writev",
+ 312: "kcmp",
+ 313: "finit_module",
+ 314: "sched_setattr",
+ 315: "sched_getattr",
+ 316: "renameat2",
+ 317: "seccomp",
+ 318: "getrandom",
+ 319: "memfd_create",
+ 320: "kexec_file_load",
+ 321: "bpf",
+ 322: "execveat",
+ 323: "userfaultfd",
+ 324: "membarrier",
+ 325: "mlock2",
+ 326: "copy_file_range",
+ 327: "preadv2",
+ 328: "pwritev2",
+ 329: "pkey_mprotect",
+ 330: "pkey_alloc",
+ 331: "pkey_free",
+ 332: "statx",
+ 333: "io_pgetevents",
+ 334: "rseq",
+ 424: "pidfd_send_signal",
+ 425: "io_uring_setup",
+ 426: "io_uring_enter",
+ 427: "io_uring_register",
+ 428: "open_tree",
+ 429: "move_mount",
+ 430: "fsopen",
+ 431: "fsconfig",
+ 432: "fsmount",
+ 433: "fspick",
+ 434: "pidfd_open",
+ 435: "clone3",
+ 436: "close_range",
+ 437: "openat2",
+ 438: "pidfd_getfd",
+ 439: "faccessat2",
+ 440: "process_madvise",
+ 441: "epoll_pwait2",
+ 442: "mount_setattr",
+ 443: "quotactl_fd",
+ 444: "landlock_create_ruleset",
+ 445: "landlock_add_rule",
+ 446: "landlock_restrict_self",
+ 447: "memfd_secret",
+ 448: "process_mrelease",
}
mips_syscall_table = {
4000: "syscall",
- 4001: "exit",
- 4002: "fork",
- 4003: "read",
- 4004: "write",
- 4005: "open",
- 4006: "close",
- 4007: "waitpid",
- 4008: "creat",
- 4009: "link",
- 4010: "unlink",
- 4011: "execve",
- 4012: "chdir",
- 4013: "time",
- 4014: "mknod",
- 4015: "chmod",
- 4016: "lchown",
- 4019: "lseek",
- 4020: "getpid",
- 4021: "mount",
- 4022: "umount",
- 4023: "setuid",
- 4024: "getuid",
- 4025: "stime",
- 4026: "ptrace",
- 4027: "alarm",
- 4029: "pause",
- 4030: "utime",
- 4033: "access",
- 4034: "nice",
- 4036: "sync",
- 4037: "kill",
- 4038: "rename",
- 4039: "mkdir",
- 4040: "rmdir",
- 4041: "dup",
- 4042: "pipe",
- 4043: "times",
- 4045: "brk",
- 4046: "setgid",
- 4047: "getgid",
- 4048: "signal",
- 4049: "geteuid",
- 4050: "getegid",
- 4051: "acct",
- 4052: "umount2",
- 4054: "ioctl",
- 4055: "fcntl",
- 4057: "setpgid",
- 4060: "umask",
- 4061: "chroot",
- 4062: "ustat",
- 4063: "dup2",
- 4064: "getppid",
- 4065: "getpgrp",
- 4066: "setsid",
- 4067: "sigaction",
- 4068: "sgetmask",
- 4069: "ssetmask",
- 4070: "setreuid",
- 4071: "setregid",
- 4072: "sigsuspend",
- 4073: "sigpending",
- 4074: "sethostname",
- 4075: "setrlimit",
- 4076: "getrlimit",
- 4077: "getrusage",
- 4078: "gettimeofday",
- 4079: "settimeofday",
- 4080: "getgroups",
- 4081: "setgroups",
- 4083: "symlink",
- 4085: "readlink",
- 4086: "uselib",
- 4087: "swapon",
- 4088: "reboot",
- 4089: "readdir",
- 4090: "mmap",
- 4091: "munmap",
- 4092: "truncate",
- 4093: "ftruncate",
- 4094: "fchmod",
- 4095: "fchown",
- 4096: "getpriority",
- 4097: "setpriority",
- 4099: "statfs",
- 4100: "fstatfs",
- 4101: "ioperm",
- 4102: "socketcall",
- 4103: "syslog",
- 4104: "setitimer",
- 4105: "getitimer",
- 4106: "stat",
- 4107: "lstat",
- 4108: "fstat",
- 4110: "iopl",
- 4111: "vhangup",
- 4112: "idle",
- 4113: "vm86",
- 4114: "wait4",
- 4115: "swapoff",
- 4116: "sysinfo",
- 4117: "ipc",
- 4118: "fsync",
- 4119: "sigreturn",
- 4120: "clone",
- 4121: "setdomainname",
- 4122: "uname",
- 4123: "modify_ldt",
- 4124: "adjtimex",
- 4125: "mprotect",
- 4126: "sigprocmask",
- 4127: "create_module",
- 4128: "init_module",
- 4129: "delete_module",
- 4130: "get_kernel_syms",
- 4131: "quotactl",
- 4132: "getpgid",
- 4133: "fchdir",
- 4134: "bdflush",
- 4135: "sysfs",
- 4136: "personality",
- 4138: "setfsuid",
- 4139: "setfsgid",
- 4140: "_llseek",
- 4141: "getdents",
- 4142: "_newselect",
- 4143: "flock",
- 4144: "msync",
- 4145: "readv",
- 4146: "writev",
- 4147: "cacheflush",
- 4148: "cachectl",
- 4149: "sysmips",
- 4151: "getsid",
- 4152: "fdatasync",
- 4153: "_sysctl",
- 4154: "mlock",
- 4155: "munlock",
- 4156: "mlockall",
- 4157: "munlockall",
- 4158: "sched_setparam",
- 4159: "sched_getparam",
- 4160: "sched_setscheduler",
- 4161: "sched_getscheduler",
- 4162: "sched_yield",
- 4163: "sched_get_priority_max",
- 4164: "sched_get_priority_min",
- 4165: "sched_rr_get_interval",
- 4166: "nanosleep",
- 4167: "mremap",
- 4168: "accept",
- 4169: "bind",
- 4170: "connect",
- 4171: "getpeername",
- 4172: "getsockname",
- 4173: "getsockopt",
- 4174: "listen",
- 4175: "recv",
- 4176: "recvfrom",
- 4177: "recvmsg",
- 4178: "send",
- 4179: "sendmsg",
- 4180: "sendto",
- 4181: "setsockopt",
- 4182: "shutdown",
- 4183: "socket",
- 4184: "socketpair",
- 4185: "setresuid",
- 4186: "getresuid",
- 4187: "query_module",
- 4188: "poll",
- 4189: "nfsservctl",
- 4190: "setresgid",
- 4191: "getresgid",
- 4192: "prctl",
- 4193: "rt_sigreturn",
- 4194: "rt_sigaction",
- 4195: "rt_sigprocmask",
- 4196: "rt_sigpending",
- 4197: "rt_sigtimedwait",
- 4198: "rt_sigqueueinfo",
- 4199: "rt_sigsuspend",
- 4200: "pread64",
- 4201: "pwrite64",
- 4202: "chown",
- 4203: "getcwd",
- 4204: "capget",
- 4205: "capset",
- 4206: "sigaltstack",
- 4207: "sendfile",
- 4208: "getpmsg",
- 4210: "mmap2",
- 4211: "truncate64",
- 4212: "ftruncate64",
- 4213: "stat64",
- 4214: "lstat64",
- 4215: "fstat64",
- 4216: "pivot_root",
- 4217: "mincore",
- 4218: "madvise",
- 4219: "getdents64",
- 4220: "fcntl64",
- 4222: "gettid",
- 4223: "readahead",
- 4224: "setxattr",
- 4225: "lsetxattr",
- 4226: "fsetxattr",
- 4227: "getxattr",
- 4228: "lgetxattr",
- 4229: "fgetxattr",
- 4230: "listxattr",
- 4231: "llistxattr",
- 4232: "flistxattr",
- 4233: "removexattr",
- 4234: "lremovexattr",
- 4235: "fremovexattr",
- 4236: "tkill",
- 4237: "sendfile64",
- 4238: "futex",
- 4239: "sched_setaffinity",
- 4240: "sched_getaffinity",
- 4241: "io_setup",
- 4242: "io_destroy",
- 4243: "io_getevents",
- 4244: "io_submit",
- 4245: "io_cancel",
- 4246: "exit_group",
- 4247: "lookup_dcookie",
- 4248: "epoll_create",
- 4249: "epoll_ctl",
- 4250: "epoll_wait",
- 4251: "remap_file_pages",
- 4252: "set_tid_address",
- 4253: "restart_syscall",
- 4254: "fadvise64",
- 4255: "statfs64",
- 4256: "fstatfs64",
- 4257: "timer_create",
- 4258: "timer_settime",
- 4259: "timer_gettime",
- 4260: "timer_getoverrun",
- 4261: "timer_delete",
- 4262: "clock_settime",
- 4263: "clock_gettime",
- 4264: "clock_getres",
- 4265: "clock_nanosleep",
- 4266: "tgkill",
- 4267: "utimes",
- 4268: "mbind",
- 4269: "get_mempolicy",
- 4270: "set_mempolicy",
- 4271: "mq_open",
- 4272: "mq_unlink",
- 4273: "mq_timedsend",
- 4274: "mq_timedreceive",
- 4275: "mq_notify",
- 4276: "mq_getsetattr",
- 4278: "waitid",
- 4280: "add_key",
- 4281: "request_key",
- 4282: "keyctl",
- 4283: "set_thread_area",
- 4284: "inotify_init",
- 4285: "inotify_add_watch",
- 4286: "inotify_rm_watch",
- 4287: "migrate_pages",
- 4288: "openat",
- 4289: "mkdirat",
- 4290: "mknodat",
- 4291: "fchownat",
- 4292: "futimesat",
- 4293: "fstatat64",
- 4294: "unlinkat",
- 4295: "renameat",
- 4296: "linkat",
- 4297: "symlinkat",
- 4298: "readlinkat",
- 4299: "fchmodat",
- 4300: "faccessat",
- 4301: "pselect6",
- 4302: "ppoll",
- 4303: "unshare",
- 4304: "splice",
- 4305: "sync_file_range",
- 4306: "tee",
- 4307: "vmsplice",
- 4308: "move_pages",
- 4309: "set_robust_list",
- 4310: "get_robust_list",
- 4311: "kexec_load",
- 4312: "getcpu",
- 4313: "epoll_pwait",
- 4314: "ioprio_set",
- 4315: "ioprio_get",
- 4316: "utimensat",
- 4317: "signalfd",
- 4318: "timerfd",
- 4319: "eventfd",
- 4320: "fallocate",
- 4321: "timerfd_create",
- 4322: "timerfd_gettime",
- 4323: "timerfd_settime",
- 4324: "signalfd4",
- 4325: "eventfd2",
- 4326: "epoll_create1",
- 4327: "dup3",
- 4328: "pipe2",
- 4329: "inotify_init1",
- 4330: "preadv",
- 4331: "pwritev",
- 4332: "rt_tgsigqueueinfo",
- 4333: "perf_event_open",
- 4334: "accept4",
- 4335: "recvmmsg",
- 4336: "fanotify_init",
- 4337: "fanotify_mark",
- 4338: "prlimit64",
- 4339: "name_to_handle_at",
- 4340: "open_by_handle_at",
- 4341: "clock_adjtime",
- 4342: "syncfs",
- 4343: "sendmmsg",
- 4344: "setns",
- 4345: "process_vm_readv",
- 4346: "process_vm_writev",
- 4347: "kcmp",
- 4348: "finit_module",
- 4349: "sched_setattr",
- 4350: "sched_getattr",
- 4351: "renameat2",
- 4352: "seccomp",
- 4353: "getrandom",
- 4354: "memfd_create",
- 4355: "bpf",
- 4356: "execveat",
- 4357: "userfaultfd",
- 4358: "membarrier",
- 4359: "mlock2",
- 4360: "copy_file_range",
- 4361: "preadv2",
- 4362: "pwritev2",
- 4363: "pkey_mprotect",
- 4364: "pkey_alloc",
- 4365: "pkey_free",
- 4366: "statx",
- 4367: "rseq",
- 4368: "io_pgetevents",
- 4393: "semget",
- 4394: "semctl",
- 4395: "shmget",
- 4396: "shmctl",
- 4397: "shmat",
- 4398: "shmdt",
- 4399: "msgget",
- 4400: "msgsnd",
- 4401: "msgrcv",
- 4402: "msgctl",
- 4403: "clock_gettime64",
- 4404: "clock_settime64",
- 4405: "clock_adjtime64",
- 4406: "clock_getres_time64",
- 4407: "clock_nanosleep_time64",
- 4408: "timer_gettime64",
- 4409: "timer_settime64",
- 4410: "timerfd_gettime64",
- 4411: "timerfd_settime64",
- 4412: "utimensat_time64",
- 4413: "pselect6_time64",
- 4414: "ppoll_time64",
- 4416: "io_pgetevents_time64",
- 4417: "recvmmsg_time64",
- 4418: "mq_timedsend_time64",
- 4419: "mq_timedreceive_time64",
- 4420: "semtimedop_time64",
- 4421: "rt_sigtimedwait_time64",
- 4422: "futex_time64",
- 4423: "sched_rr_get_interval_time64",
- 4424: "pidfd_send_signal",
- 4425: "io_uring_setup",
- 4426: "io_uring_enter",
- 4427: "io_uring_register",
- 4428: "open_tree",
- 4429: "move_mount",
- 4430: "fsopen",
- 4431: "fsconfig",
- 4432: "fsmount",
- 4433: "fspick",
- 4434: "pidfd_open",
- 4435: "clone3",
- 4436: "close_range",
- 4437: "openat2",
- 4438: "pidfd_getfd",
- 4439: "faccessat2",
- 4440: "process_madvise",
- 4441: "epoll_pwait2",
- 4442: "mount_setattr",
- 4443: "quotactl_fd",
- 4444: "landlock_create_ruleset",
- 4445: "landlock_add_rule",
- 4446: "landlock_restrict_self",
- 4448: "process_mrelease",
+ 4001: "exit",
+ 4002: "fork",
+ 4003: "read",
+ 4004: "write",
+ 4005: "open",
+ 4006: "close",
+ 4007: "waitpid",
+ 4008: "creat",
+ 4009: "link",
+ 4010: "unlink",
+ 4011: "execve",
+ 4012: "chdir",
+ 4013: "time",
+ 4014: "mknod",
+ 4015: "chmod",
+ 4016: "lchown",
+ 4019: "lseek",
+ 4020: "getpid",
+ 4021: "mount",
+ 4022: "umount",
+ 4023: "setuid",
+ 4024: "getuid",
+ 4025: "stime",
+ 4026: "ptrace",
+ 4027: "alarm",
+ 4029: "pause",
+ 4030: "utime",
+ 4033: "access",
+ 4034: "nice",
+ 4036: "sync",
+ 4037: "kill",
+ 4038: "rename",
+ 4039: "mkdir",
+ 4040: "rmdir",
+ 4041: "dup",
+ 4042: "pipe",
+ 4043: "times",
+ 4045: "brk",
+ 4046: "setgid",
+ 4047: "getgid",
+ 4048: "signal",
+ 4049: "geteuid",
+ 4050: "getegid",
+ 4051: "acct",
+ 4052: "umount2",
+ 4054: "ioctl",
+ 4055: "fcntl",
+ 4057: "setpgid",
+ 4060: "umask",
+ 4061: "chroot",
+ 4062: "ustat",
+ 4063: "dup2",
+ 4064: "getppid",
+ 4065: "getpgrp",
+ 4066: "setsid",
+ 4067: "sigaction",
+ 4068: "sgetmask",
+ 4069: "ssetmask",
+ 4070: "setreuid",
+ 4071: "setregid",
+ 4072: "sigsuspend",
+ 4073: "sigpending",
+ 4074: "sethostname",
+ 4075: "setrlimit",
+ 4076: "getrlimit",
+ 4077: "getrusage",
+ 4078: "gettimeofday",
+ 4079: "settimeofday",
+ 4080: "getgroups",
+ 4081: "setgroups",
+ 4083: "symlink",
+ 4085: "readlink",
+ 4086: "uselib",
+ 4087: "swapon",
+ 4088: "reboot",
+ 4089: "readdir",
+ 4090: "mmap",
+ 4091: "munmap",
+ 4092: "truncate",
+ 4093: "ftruncate",
+ 4094: "fchmod",
+ 4095: "fchown",
+ 4096: "getpriority",
+ 4097: "setpriority",
+ 4099: "statfs",
+ 4100: "fstatfs",
+ 4101: "ioperm",
+ 4102: "socketcall",
+ 4103: "syslog",
+ 4104: "setitimer",
+ 4105: "getitimer",
+ 4106: "stat",
+ 4107: "lstat",
+ 4108: "fstat",
+ 4110: "iopl",
+ 4111: "vhangup",
+ 4112: "idle",
+ 4113: "vm86",
+ 4114: "wait4",
+ 4115: "swapoff",
+ 4116: "sysinfo",
+ 4117: "ipc",
+ 4118: "fsync",
+ 4119: "sigreturn",
+ 4120: "clone",
+ 4121: "setdomainname",
+ 4122: "uname",
+ 4123: "modify_ldt",
+ 4124: "adjtimex",
+ 4125: "mprotect",
+ 4126: "sigprocmask",
+ 4127: "create_module",
+ 4128: "init_module",
+ 4129: "delete_module",
+ 4130: "get_kernel_syms",
+ 4131: "quotactl",
+ 4132: "getpgid",
+ 4133: "fchdir",
+ 4134: "bdflush",
+ 4135: "sysfs",
+ 4136: "personality",
+ 4138: "setfsuid",
+ 4139: "setfsgid",
+ 4140: "_llseek",
+ 4141: "getdents",
+ 4142: "_newselect",
+ 4143: "flock",
+ 4144: "msync",
+ 4145: "readv",
+ 4146: "writev",
+ 4147: "cacheflush",
+ 4148: "cachectl",
+ 4149: "sysmips",
+ 4151: "getsid",
+ 4152: "fdatasync",
+ 4153: "_sysctl",
+ 4154: "mlock",
+ 4155: "munlock",
+ 4156: "mlockall",
+ 4157: "munlockall",
+ 4158: "sched_setparam",
+ 4159: "sched_getparam",
+ 4160: "sched_setscheduler",
+ 4161: "sched_getscheduler",
+ 4162: "sched_yield",
+ 4163: "sched_get_priority_max",
+ 4164: "sched_get_priority_min",
+ 4165: "sched_rr_get_interval",
+ 4166: "nanosleep",
+ 4167: "mremap",
+ 4168: "accept",
+ 4169: "bind",
+ 4170: "connect",
+ 4171: "getpeername",
+ 4172: "getsockname",
+ 4173: "getsockopt",
+ 4174: "listen",
+ 4175: "recv",
+ 4176: "recvfrom",
+ 4177: "recvmsg",
+ 4178: "send",
+ 4179: "sendmsg",
+ 4180: "sendto",
+ 4181: "setsockopt",
+ 4182: "shutdown",
+ 4183: "socket",
+ 4184: "socketpair",
+ 4185: "setresuid",
+ 4186: "getresuid",
+ 4187: "query_module",
+ 4188: "poll",
+ 4189: "nfsservctl",
+ 4190: "setresgid",
+ 4191: "getresgid",
+ 4192: "prctl",
+ 4193: "rt_sigreturn",
+ 4194: "rt_sigaction",
+ 4195: "rt_sigprocmask",
+ 4196: "rt_sigpending",
+ 4197: "rt_sigtimedwait",
+ 4198: "rt_sigqueueinfo",
+ 4199: "rt_sigsuspend",
+ 4200: "pread64",
+ 4201: "pwrite64",
+ 4202: "chown",
+ 4203: "getcwd",
+ 4204: "capget",
+ 4205: "capset",
+ 4206: "sigaltstack",
+ 4207: "sendfile",
+ 4208: "getpmsg",
+ 4210: "mmap2",
+ 4211: "truncate64",
+ 4212: "ftruncate64",
+ 4213: "stat64",
+ 4214: "lstat64",
+ 4215: "fstat64",
+ 4216: "pivot_root",
+ 4217: "mincore",
+ 4218: "madvise",
+ 4219: "getdents64",
+ 4220: "fcntl64",
+ 4222: "gettid",
+ 4223: "readahead",
+ 4224: "setxattr",
+ 4225: "lsetxattr",
+ 4226: "fsetxattr",
+ 4227: "getxattr",
+ 4228: "lgetxattr",
+ 4229: "fgetxattr",
+ 4230: "listxattr",
+ 4231: "llistxattr",
+ 4232: "flistxattr",
+ 4233: "removexattr",
+ 4234: "lremovexattr",
+ 4235: "fremovexattr",
+ 4236: "tkill",
+ 4237: "sendfile64",
+ 4238: "futex",
+ 4239: "sched_setaffinity",
+ 4240: "sched_getaffinity",
+ 4241: "io_setup",
+ 4242: "io_destroy",
+ 4243: "io_getevents",
+ 4244: "io_submit",
+ 4245: "io_cancel",
+ 4246: "exit_group",
+ 4247: "lookup_dcookie",
+ 4248: "epoll_create",
+ 4249: "epoll_ctl",
+ 4250: "epoll_wait",
+ 4251: "remap_file_pages",
+ 4252: "set_tid_address",
+ 4253: "restart_syscall",
+ 4254: "fadvise64",
+ 4255: "statfs64",
+ 4256: "fstatfs64",
+ 4257: "timer_create",
+ 4258: "timer_settime",
+ 4259: "timer_gettime",
+ 4260: "timer_getoverrun",
+ 4261: "timer_delete",
+ 4262: "clock_settime",
+ 4263: "clock_gettime",
+ 4264: "clock_getres",
+ 4265: "clock_nanosleep",
+ 4266: "tgkill",
+ 4267: "utimes",
+ 4268: "mbind",
+ 4269: "get_mempolicy",
+ 4270: "set_mempolicy",
+ 4271: "mq_open",
+ 4272: "mq_unlink",
+ 4273: "mq_timedsend",
+ 4274: "mq_timedreceive",
+ 4275: "mq_notify",
+ 4276: "mq_getsetattr",
+ 4278: "waitid",
+ 4280: "add_key",
+ 4281: "request_key",
+ 4282: "keyctl",
+ 4283: "set_thread_area",
+ 4284: "inotify_init",
+ 4285: "inotify_add_watch",
+ 4286: "inotify_rm_watch",
+ 4287: "migrate_pages",
+ 4288: "openat",
+ 4289: "mkdirat",
+ 4290: "mknodat",
+ 4291: "fchownat",
+ 4292: "futimesat",
+ 4293: "fstatat64",
+ 4294: "unlinkat",
+ 4295: "renameat",
+ 4296: "linkat",
+ 4297: "symlinkat",
+ 4298: "readlinkat",
+ 4299: "fchmodat",
+ 4300: "faccessat",
+ 4301: "pselect6",
+ 4302: "ppoll",
+ 4303: "unshare",
+ 4304: "splice",
+ 4305: "sync_file_range",
+ 4306: "tee",
+ 4307: "vmsplice",
+ 4308: "move_pages",
+ 4309: "set_robust_list",
+ 4310: "get_robust_list",
+ 4311: "kexec_load",
+ 4312: "getcpu",
+ 4313: "epoll_pwait",
+ 4314: "ioprio_set",
+ 4315: "ioprio_get",
+ 4316: "utimensat",
+ 4317: "signalfd",
+ 4318: "timerfd",
+ 4319: "eventfd",
+ 4320: "fallocate",
+ 4321: "timerfd_create",
+ 4322: "timerfd_gettime",
+ 4323: "timerfd_settime",
+ 4324: "signalfd4",
+ 4325: "eventfd2",
+ 4326: "epoll_create1",
+ 4327: "dup3",
+ 4328: "pipe2",
+ 4329: "inotify_init1",
+ 4330: "preadv",
+ 4331: "pwritev",
+ 4332: "rt_tgsigqueueinfo",
+ 4333: "perf_event_open",
+ 4334: "accept4",
+ 4335: "recvmmsg",
+ 4336: "fanotify_init",
+ 4337: "fanotify_mark",
+ 4338: "prlimit64",
+ 4339: "name_to_handle_at",
+ 4340: "open_by_handle_at",
+ 4341: "clock_adjtime",
+ 4342: "syncfs",
+ 4343: "sendmmsg",
+ 4344: "setns",
+ 4345: "process_vm_readv",
+ 4346: "process_vm_writev",
+ 4347: "kcmp",
+ 4348: "finit_module",
+ 4349: "sched_setattr",
+ 4350: "sched_getattr",
+ 4351: "renameat2",
+ 4352: "seccomp",
+ 4353: "getrandom",
+ 4354: "memfd_create",
+ 4355: "bpf",
+ 4356: "execveat",
+ 4357: "userfaultfd",
+ 4358: "membarrier",
+ 4359: "mlock2",
+ 4360: "copy_file_range",
+ 4361: "preadv2",
+ 4362: "pwritev2",
+ 4363: "pkey_mprotect",
+ 4364: "pkey_alloc",
+ 4365: "pkey_free",
+ 4366: "statx",
+ 4367: "rseq",
+ 4368: "io_pgetevents",
+ 4393: "semget",
+ 4394: "semctl",
+ 4395: "shmget",
+ 4396: "shmctl",
+ 4397: "shmat",
+ 4398: "shmdt",
+ 4399: "msgget",
+ 4400: "msgsnd",
+ 4401: "msgrcv",
+ 4402: "msgctl",
+ 4403: "clock_gettime64",
+ 4404: "clock_settime64",
+ 4405: "clock_adjtime64",
+ 4406: "clock_getres_time64",
+ 4407: "clock_nanosleep_time64",
+ 4408: "timer_gettime64",
+ 4409: "timer_settime64",
+ 4410: "timerfd_gettime64",
+ 4411: "timerfd_settime64",
+ 4412: "utimensat_time64",
+ 4413: "pselect6_time64",
+ 4414: "ppoll_time64",
+ 4416: "io_pgetevents_time64",
+ 4417: "recvmmsg_time64",
+ 4418: "mq_timedsend_time64",
+ 4419: "mq_timedreceive_time64",
+ 4420: "semtimedop_time64",
+ 4421: "rt_sigtimedwait_time64",
+ 4422: "futex_time64",
+ 4423: "sched_rr_get_interval_time64",
+ 4424: "pidfd_send_signal",
+ 4425: "io_uring_setup",
+ 4426: "io_uring_enter",
+ 4427: "io_uring_register",
+ 4428: "open_tree",
+ 4429: "move_mount",
+ 4430: "fsopen",
+ 4431: "fsconfig",
+ 4432: "fsmount",
+ 4433: "fspick",
+ 4434: "pidfd_open",
+ 4435: "clone3",
+ 4436: "close_range",
+ 4437: "openat2",
+ 4438: "pidfd_getfd",
+ 4439: "faccessat2",
+ 4440: "process_madvise",
+ 4441: "epoll_pwait2",
+ 4442: "mount_setattr",
+ 4443: "quotactl_fd",
+ 4444: "landlock_create_ruleset",
+ 4445: "landlock_add_rule",
+ 4446: "landlock_restrict_self",
+ 4448: "process_mrelease",
}
riscv32_syscall_table = {
- 0: "io_setup",
- 1: "io_destroy",
- 2: "io_submit",
- 3: "io_cancel",
- 5: "setxattr",
- 6: "lsetxattr",
- 7: "fsetxattr",
- 8: "getxattr",
- 9: "lgetxattr",
- 10: "fgetxattr",
- 11: "listxattr",
- 12: "llistxattr",
- 13: "flistxattr",
- 14: "removexattr",
- 15: "lremovexattr",
- 16: "fremovexattr",
- 17: "getcwd",
- 18: "lookup_dcookie",
- 19: "eventfd2",
- 20: "epoll_create1",
- 21: "epoll_ctl",
- 22: "epoll_pwait",
- 23: "dup",
- 24: "dup3",
- 25: "fcntl",
- 26: "inotify_init1",
- 27: "inotify_add_watch",
- 28: "inotify_rm_watch",
- 29: "ioctl",
- 30: "ioprio_set",
- 31: "ioprio_get",
- 32: "flock",
- 33: "mknodat",
- 34: "mkdirat",
- 35: "unlinkat",
- 36: "symlinkat",
- 37: "linkat",
- 38: "renameat",
- 39: "umount2",
- 40: "mount",
- 41: "pivot_root",
- 42: "nfsservctl",
- 43: "statfs64",
- 44: "fstatfs64",
- 45: "truncate64",
- 46: "ftruncate",
- 47: "fallocate",
- 48: "faccessat",
- 49: "chdir",
- 50: "fchdir",
- 51: "chroot",
- 52: "fchmod",
- 53: "fchmodat",
- 54: "fchownat",
- 55: "fchown",
- 56: "openat",
- 57: "close",
- 58: "vhangup",
- 59: "pipe2",
- 60: "quotactl",
- 61: "getdents",
- 62: "lseek",
- 63: "read",
- 64: "write",
- 65: "readv",
- 66: "writev",
- 67: "pread",
- 68: "pwrite",
- 69: "preadv",
- 70: "pwritev",
- 71: "sendfile64",
- 74: "signalfd4",
- 75: "vmsplice",
- 76: "splice",
- 77: "tee",
- 78: "readlinkat",
- 79: "fstatat",
- 80: "fstat",
- 81: "sync",
- 82: "fsync",
- 83: "fdatasync",
- 84: "sync_file_range",
- 85: "timerfd_create",
- 89: "acct",
- 90: "capget",
- 91: "capset",
- 92: "personality",
- 93: "exit",
- 94: "exit_group",
- 95: "waitid",
- 96: "set_tid_address",
- 97: "unshare",
- 99: "set_robust_list",
- 100: "get_robust_list",
- 102: "getitimer",
- 103: "setitimer",
- 104: "kexec_load",
- 105: "init_module",
- 106: "delete_module",
- 107: "timer_create",
- 109: "timer_getoverrun",
- 111: "timer_delete",
- 113: "clock_gettime",
- 116: "syslog",
- 117: "ptrace",
- 118: "sched_setparam",
- 119: "sched_setscheduler",
- 120: "sched_getscheduler",
- 121: "sched_getparam",
- 122: "sched_setaffinity",
- 123: "sched_getaffinity",
- 124: "sched_yield",
- 125: "sched_get_priority_max",
- 126: "sched_get_priority_min",
- 128: "restart_syscall",
- 129: "kill",
- 130: "tkill",
- 131: "tgkill",
- 132: "sigaltstack",
- 133: "rt_sigsuspend",
- 134: "rt_sigaction",
- 135: "rt_sigprocmask",
- 136: "rt_sigpending",
- 138: "rt_sigqueueinfo",
- 139: "rt_sigreturn",
- 140: "setpriority",
- 141: "getpriority",
- 142: "reboot",
- 143: "setregid",
- 144: "setgid",
- 145: "setreuid",
- 146: "setuid",
- 147: "setresuid",
- 148: "getresuid",
- 149: "setresgid",
- 150: "getresgid",
- 151: "setfsuid",
- 152: "setfsgid",
- 153: "times",
- 154: "setpgid",
- 155: "getpgid",
- 156: "getsid",
- 157: "setsid",
- 158: "getgroups",
- 159: "setgroups",
- 160: "uname",
- 161: "sethostname",
- 162: "setdomainname",
- 163: "getrlimit",
- 164: "setrlimit",
- 165: "getrusage",
- 166: "umask",
- 167: "prctl",
- 168: "getcpu",
- 169: "gettimeofday",
- 172: "getpid",
- 173: "getppid",
- 174: "getuid",
- 175: "geteuid",
- 176: "getgid",
- 177: "getegid",
- 178: "gettid",
- 179: "sysinfo",
- 180: "mq_open",
- 181: "mq_unlink",
- 184: "mq_notify",
- 185: "mq_getsetattr",
- 186: "msgget",
- 187: "msgctl",
- 188: "msgrcv",
- 189: "msgsnd",
- 190: "semget",
- 191: "semctl",
- 193: "semop",
- 194: "shmget",
- 195: "shmctl",
- 196: "shmat",
- 197: "shmdt",
- 198: "socket",
- 199: "socketpair",
- 200: "bind",
- 201: "listen",
- 202: "accept",
- 203: "connect",
- 204: "getsockname",
- 205: "getpeername",
- 206: "sendto",
- 207: "recvfrom",
- 208: "setsockopt",
- 209: "getsockopt",
- 210: "shutdown",
- 211: "sendmsg",
- 212: "recvmsg",
- 213: "readahead",
- 214: "brk",
- 215: "munmap",
- 216: "mremap",
- 217: "add_key",
- 218: "request_key",
- 219: "keyctl",
- 220: "clone",
- 221: "execve",
- 222: "mmap2",
- 223: "fadvise64_64",
- 224: "swapon",
- 225: "swapoff",
- 226: "mprotect",
- 227: "msync",
- 228: "mlock",
- 229: "munlock",
- 230: "mlockall",
- 231: "munlockall",
- 232: "mincore",
- 233: "madvise",
- 234: "remap_file_pages",
- 235: "mbind",
- 236: "get_mempolicy",
- 237: "set_mempolicy",
- 238: "migrate_pages",
- 239: "move_pages",
- 240: "rt_tgsigqueueinfo",
- 241: "perf_event_open",
- 242: "accept4",
- 259: "riscv_flush_icache",
- 261: "prlimit64",
- 262: "fanotify_init",
- 263: "fanotify_mark",
- 264: "name_to_handle_at",
- 265: "open_by_handle_at",
- 267: "syncfs",
- 268: "setns",
- 269: "sendmmsg",
- 270: "process_vm_readv",
- 271: "process_vm_writev",
- 272: "kcmp",
- 273: "finit_module",
- 274: "sched_setattr",
- 275: "sched_getattr",
- 276: "renameat2",
- 277: "seccomp",
- 278: "getrandom",
- 279: "memfd_create",
- 280: "bpf",
- 281: "execveat",
- 282: "userfaultfd",
- 283: "membarrier",
- 284: "mlock2",
- 285: "copy_file_range",
- 286: "preadv2",
- 287: "pwritev2",
- 288: "pkey_mprotect",
- 289: "pkey_alloc",
- 290: "pkey_free",
- 291: "statx",
- 293: "rseq",
- 294: "kexec_file_load",
- 403: "clock_gettime64",
- 404: "clock_settime64",
- 405: "clock_adjtime64",
- 406: "clock_getres_time64",
- 407: "clock_nanosleep_time64",
- 408: "timer_gettime64",
- 409: "timer_settime64",
- 410: "timerfd_gettime64",
- 411: "timerfd_settime64",
- 412: "utimensat_time64",
- 413: "pselect6_time64",
- 414: "ppoll_time64",
- 416: "io_pgetevents_time64",
- 417: "recvmmsg_time64",
- 418: "mq_timedsend_time64",
- 419: "mq_timedreceive_time64",
- 420: "semtimedop_time64",
- 421: "rt_sigtimedwait_time64",
- 422: "futex_time64",
- 423: "sched_rr_get_interval_time64",
- 424: "pidfd_send_signal",
- 425: "io_uring_setup",
- 426: "io_uring_enter",
- 427: "io_uring_register",
- 428: "open_tree",
- 429: "move_mount",
- 430: "fsopen",
- 431: "fsconfig",
- 432: "fsmount",
- 433: "fspick",
- 434: "pidfd_open",
- 436: "close_range",
- 437: "openat2",
- 438: "pidfd_getfd",
- 439: "faccessat2",
- 440: "process_madvise",
- 441: "epoll_pwait2",
- 442: "mount_setattr",
- 443: "quotactl_fd",
- 444: "landlock_create_ruleset",
- 445: "landlock_add_rule",
- 446: "landlock_restrict_self",
- 448: "process_mrelease",
- 1024: "open",
- 1025: "link",
- 1026: "unlink",
- 1030: "mkdir",
- 1033: "access",
- 1038: "stat",
- 1039: "lstat",
- 1062: "time",
- 2011: "getmainvars",
+ 0: "io_setup",
+ 1: "io_destroy",
+ 2: "io_submit",
+ 3: "io_cancel",
+ 5: "setxattr",
+ 6: "lsetxattr",
+ 7: "fsetxattr",
+ 8: "getxattr",
+ 9: "lgetxattr",
+ 10: "fgetxattr",
+ 11: "listxattr",
+ 12: "llistxattr",
+ 13: "flistxattr",
+ 14: "removexattr",
+ 15: "lremovexattr",
+ 16: "fremovexattr",
+ 17: "getcwd",
+ 18: "lookup_dcookie",
+ 19: "eventfd2",
+ 20: "epoll_create1",
+ 21: "epoll_ctl",
+ 22: "epoll_pwait",
+ 23: "dup",
+ 24: "dup3",
+ 25: "fcntl",
+ 26: "inotify_init1",
+ 27: "inotify_add_watch",
+ 28: "inotify_rm_watch",
+ 29: "ioctl",
+ 30: "ioprio_set",
+ 31: "ioprio_get",
+ 32: "flock",
+ 33: "mknodat",
+ 34: "mkdirat",
+ 35: "unlinkat",
+ 36: "symlinkat",
+ 37: "linkat",
+ 38: "renameat",
+ 39: "umount2",
+ 40: "mount",
+ 41: "pivot_root",
+ 42: "nfsservctl",
+ 43: "statfs64",
+ 44: "fstatfs64",
+ 45: "truncate64",
+ 46: "ftruncate",
+ 47: "fallocate",
+ 48: "faccessat",
+ 49: "chdir",
+ 50: "fchdir",
+ 51: "chroot",
+ 52: "fchmod",
+ 53: "fchmodat",
+ 54: "fchownat",
+ 55: "fchown",
+ 56: "openat",
+ 57: "close",
+ 58: "vhangup",
+ 59: "pipe2",
+ 60: "quotactl",
+ 61: "getdents",
+ 62: "lseek",
+ 63: "read",
+ 64: "write",
+ 65: "readv",
+ 66: "writev",
+ 67: "pread",
+ 68: "pwrite",
+ 69: "preadv",
+ 70: "pwritev",
+ 71: "sendfile64",
+ 74: "signalfd4",
+ 75: "vmsplice",
+ 76: "splice",
+ 77: "tee",
+ 78: "readlinkat",
+ 79: "fstatat",
+ 80: "fstat",
+ 81: "sync",
+ 82: "fsync",
+ 83: "fdatasync",
+ 84: "sync_file_range",
+ 85: "timerfd_create",
+ 89: "acct",
+ 90: "capget",
+ 91: "capset",
+ 92: "personality",
+ 93: "exit",
+ 94: "exit_group",
+ 95: "waitid",
+ 96: "set_tid_address",
+ 97: "unshare",
+ 99: "set_robust_list",
+ 100: "get_robust_list",
+ 102: "getitimer",
+ 103: "setitimer",
+ 104: "kexec_load",
+ 105: "init_module",
+ 106: "delete_module",
+ 107: "timer_create",
+ 109: "timer_getoverrun",
+ 111: "timer_delete",
+ 113: "clock_gettime",
+ 116: "syslog",
+ 117: "ptrace",
+ 118: "sched_setparam",
+ 119: "sched_setscheduler",
+ 120: "sched_getscheduler",
+ 121: "sched_getparam",
+ 122: "sched_setaffinity",
+ 123: "sched_getaffinity",
+ 124: "sched_yield",
+ 125: "sched_get_priority_max",
+ 126: "sched_get_priority_min",
+ 128: "restart_syscall",
+ 129: "kill",
+ 130: "tkill",
+ 131: "tgkill",
+ 132: "sigaltstack",
+ 133: "rt_sigsuspend",
+ 134: "rt_sigaction",
+ 135: "rt_sigprocmask",
+ 136: "rt_sigpending",
+ 138: "rt_sigqueueinfo",
+ 139: "rt_sigreturn",
+ 140: "setpriority",
+ 141: "getpriority",
+ 142: "reboot",
+ 143: "setregid",
+ 144: "setgid",
+ 145: "setreuid",
+ 146: "setuid",
+ 147: "setresuid",
+ 148: "getresuid",
+ 149: "setresgid",
+ 150: "getresgid",
+ 151: "setfsuid",
+ 152: "setfsgid",
+ 153: "times",
+ 154: "setpgid",
+ 155: "getpgid",
+ 156: "getsid",
+ 157: "setsid",
+ 158: "getgroups",
+ 159: "setgroups",
+ 160: "uname",
+ 161: "sethostname",
+ 162: "setdomainname",
+ 163: "getrlimit",
+ 164: "setrlimit",
+ 165: "getrusage",
+ 166: "umask",
+ 167: "prctl",
+ 168: "getcpu",
+ 169: "gettimeofday",
+ 172: "getpid",
+ 173: "getppid",
+ 174: "getuid",
+ 175: "geteuid",
+ 176: "getgid",
+ 177: "getegid",
+ 178: "gettid",
+ 179: "sysinfo",
+ 180: "mq_open",
+ 181: "mq_unlink",
+ 184: "mq_notify",
+ 185: "mq_getsetattr",
+ 186: "msgget",
+ 187: "msgctl",
+ 188: "msgrcv",
+ 189: "msgsnd",
+ 190: "semget",
+ 191: "semctl",
+ 193: "semop",
+ 194: "shmget",
+ 195: "shmctl",
+ 196: "shmat",
+ 197: "shmdt",
+ 198: "socket",
+ 199: "socketpair",
+ 200: "bind",
+ 201: "listen",
+ 202: "accept",
+ 203: "connect",
+ 204: "getsockname",
+ 205: "getpeername",
+ 206: "sendto",
+ 207: "recvfrom",
+ 208: "setsockopt",
+ 209: "getsockopt",
+ 210: "shutdown",
+ 211: "sendmsg",
+ 212: "recvmsg",
+ 213: "readahead",
+ 214: "brk",
+ 215: "munmap",
+ 216: "mremap",
+ 217: "add_key",
+ 218: "request_key",
+ 219: "keyctl",
+ 220: "clone",
+ 221: "execve",
+ 222: "mmap2",
+ 223: "fadvise64_64",
+ 224: "swapon",
+ 225: "swapoff",
+ 226: "mprotect",
+ 227: "msync",
+ 228: "mlock",
+ 229: "munlock",
+ 230: "mlockall",
+ 231: "munlockall",
+ 232: "mincore",
+ 233: "madvise",
+ 234: "remap_file_pages",
+ 235: "mbind",
+ 236: "get_mempolicy",
+ 237: "set_mempolicy",
+ 238: "migrate_pages",
+ 239: "move_pages",
+ 240: "rt_tgsigqueueinfo",
+ 241: "perf_event_open",
+ 242: "accept4",
+ 259: "riscv_flush_icache",
+ 261: "prlimit64",
+ 262: "fanotify_init",
+ 263: "fanotify_mark",
+ 264: "name_to_handle_at",
+ 265: "open_by_handle_at",
+ 267: "syncfs",
+ 268: "setns",
+ 269: "sendmmsg",
+ 270: "process_vm_readv",
+ 271: "process_vm_writev",
+ 272: "kcmp",
+ 273: "finit_module",
+ 274: "sched_setattr",
+ 275: "sched_getattr",
+ 276: "renameat2",
+ 277: "seccomp",
+ 278: "getrandom",
+ 279: "memfd_create",
+ 280: "bpf",
+ 281: "execveat",
+ 282: "userfaultfd",
+ 283: "membarrier",
+ 284: "mlock2",
+ 285: "copy_file_range",
+ 286: "preadv2",
+ 287: "pwritev2",
+ 288: "pkey_mprotect",
+ 289: "pkey_alloc",
+ 290: "pkey_free",
+ 291: "statx",
+ 293: "rseq",
+ 294: "kexec_file_load",
+ 403: "clock_gettime64",
+ 404: "clock_settime64",
+ 405: "clock_adjtime64",
+ 406: "clock_getres_time64",
+ 407: "clock_nanosleep_time64",
+ 408: "timer_gettime64",
+ 409: "timer_settime64",
+ 410: "timerfd_gettime64",
+ 411: "timerfd_settime64",
+ 412: "utimensat_time64",
+ 413: "pselect6_time64",
+ 414: "ppoll_time64",
+ 416: "io_pgetevents_time64",
+ 417: "recvmmsg_time64",
+ 418: "mq_timedsend_time64",
+ 419: "mq_timedreceive_time64",
+ 420: "semtimedop_time64",
+ 421: "rt_sigtimedwait_time64",
+ 422: "futex_time64",
+ 423: "sched_rr_get_interval_time64",
+ 424: "pidfd_send_signal",
+ 425: "io_uring_setup",
+ 426: "io_uring_enter",
+ 427: "io_uring_register",
+ 428: "open_tree",
+ 429: "move_mount",
+ 430: "fsopen",
+ 431: "fsconfig",
+ 432: "fsmount",
+ 433: "fspick",
+ 434: "pidfd_open",
+ 436: "close_range",
+ 437: "openat2",
+ 438: "pidfd_getfd",
+ 439: "faccessat2",
+ 440: "process_madvise",
+ 441: "epoll_pwait2",
+ 442: "mount_setattr",
+ 443: "quotactl_fd",
+ 444: "landlock_create_ruleset",
+ 445: "landlock_add_rule",
+ 446: "landlock_restrict_self",
+ 448: "process_mrelease",
+ 1024: "open",
+ 1025: "link",
+ 1026: "unlink",
+ 1030: "mkdir",
+ 1033: "access",
+ 1038: "stat",
+ 1039: "lstat",
+ 1062: "time",
+ 2011: "getmainvars",
}
riscv64_syscall_table = {
- 0: "io_setup",
- 1: "io_destroy",
- 2: "io_submit",
- 3: "io_cancel",
- 4: "io_getevents",
- 5: "setxattr",
- 6: "lsetxattr",
- 7: "fsetxattr",
- 8: "getxattr",
- 9: "lgetxattr",
- 10: "fgetxattr",
- 11: "listxattr",
- 12: "llistxattr",
- 13: "flistxattr",
- 14: "removexattr",
- 15: "lremovexattr",
- 16: "fremovexattr",
- 17: "getcwd",
- 18: "lookup_dcookie",
- 19: "eventfd2",
- 20: "epoll_create1",
- 21: "epoll_ctl",
- 22: "epoll_pwait",
- 23: "dup",
- 24: "dup3",
- 25: "fcntl",
- 26: "inotify_init1",
- 27: "inotify_add_watch",
- 28: "inotify_rm_watch",
- 29: "ioctl",
- 30: "ioprio_set",
- 31: "ioprio_get",
- 32: "flock",
- 33: "mknodat",
- 34: "mkdirat",
- 35: "unlinkat",
- 36: "symlinkat",
- 37: "linkat",
- 39: "umount2",
- 40: "mount",
- 41: "pivot_root",
- 42: "nfsservctl",
- 43: "statfs",
- 44: "fstatfs",
- 45: "truncate",
- 46: "ftruncate",
- 47: "fallocate",
- 48: "faccessat",
- 49: "chdir",
- 50: "fchdir",
- 51: "chroot",
- 52: "fchmod",
- 53: "fchmodat",
- 54: "fchownat",
- 55: "fchown",
- 56: "openat",
- 57: "close",
- 58: "vhangup",
- 59: "pipe2",
- 60: "quotactl",
- 61: "getdents64",
- 62: "lseek",
- 63: "read",
- 64: "write",
- 65: "readv",
- 66: "writev",
- 67: "pread64",
- 68: "pwrite64",
- 69: "preadv",
- 70: "pwritev",
- 71: "sendfile",
- 72: "pselect6",
- 73: "ppoll",
- 74: "signalfd4",
- 75: "vmsplice",
- 76: "splice",
- 77: "tee",
- 78: "readlinkat",
- 79: "newfstatat",
- 80: "fstat",
- 81: "sync",
- 82: "fsync",
- 83: "fdatasync",
- 84: "sync_file_range",
- 85: "timerfd_create",
- 86: "timerfd_settime",
- 87: "timerfd_gettime",
- 88: "utimensat",
- 89: "acct",
- 90: "capget",
- 91: "capset",
- 92: "personality",
- 93: "exit",
- 94: "exit_group",
- 95: "waitid",
- 96: "set_tid_address",
- 97: "unshare",
- 98: "futex",
- 99: "set_robust_list",
- 100: "get_robust_list",
- 101: "nanosleep",
- 102: "getitimer",
- 103: "setitimer",
- 104: "kexec_load",
- 105: "init_module",
- 106: "delete_module",
- 107: "timer_create",
- 108: "timer_gettime",
- 109: "timer_getoverrun",
- 110: "timer_settime",
- 111: "timer_delete",
- 112: "clock_settime",
- 113: "clock_gettime",
- 114: "clock_getres",
- 115: "clock_nanosleep",
- 116: "syslog",
- 117: "ptrace",
- 118: "sched_setparam",
- 119: "sched_setscheduler",
- 120: "sched_getscheduler",
- 121: "sched_getparam",
- 122: "sched_setaffinity",
- 123: "sched_getaffinity",
- 124: "sched_yield",
- 125: "sched_get_priority_max",
- 126: "sched_get_priority_min",
- 127: "sched_rr_get_interval",
- 128: "restart_syscall",
- 129: "kill",
- 130: "tkill",
- 131: "tgkill",
- 132: "sigaltstack",
- 133: "rt_sigsuspend",
- 134: "rt_sigaction",
- 135: "rt_sigprocmask",
- 136: "rt_sigpending",
- 137: "rt_sigtimedwait",
- 138: "rt_sigqueueinfo",
- 139: "rt_sigreturn",
- 140: "setpriority",
- 141: "getpriority",
- 142: "reboot",
- 143: "setregid",
- 144: "setgid",
- 145: "setreuid",
- 146: "setuid",
- 147: "setresuid",
- 148: "getresuid",
- 149: "setresgid",
- 150: "getresgid",
- 151: "setfsuid",
- 152: "setfsgid",
- 153: "times",
- 154: "setpgid",
- 155: "getpgid",
- 156: "getsid",
- 157: "setsid",
- 158: "getgroups",
- 159: "setgroups",
- 160: "uname",
- 161: "sethostname",
- 162: "setdomainname",
- 163: "getrlimit",
- 164: "setrlimit",
- 165: "getrusage",
- 166: "umask",
- 167: "prctl",
- 168: "getcpu",
- 169: "gettimeofday",
- 170: "settimeofday",
- 171: "adjtimex",
- 172: "getpid",
- 173: "getppid",
- 174: "getuid",
- 175: "geteuid",
- 176: "getgid",
- 177: "getegid",
- 178: "gettid",
- 179: "sysinfo",
- 180: "mq_open",
- 181: "mq_unlink",
- 182: "mq_timedsend",
- 183: "mq_timedreceive",
- 184: "mq_notify",
- 185: "mq_getsetattr",
- 186: "msgget",
- 187: "msgctl",
- 188: "msgrcv",
- 189: "msgsnd",
- 190: "semget",
- 191: "semctl",
- 192: "semtimedop",
- 193: "semop",
- 194: "shmget",
- 195: "shmctl",
- 196: "shmat",
- 197: "shmdt",
- 198: "socket",
- 199: "socketpair",
- 200: "bind",
- 201: "listen",
- 202: "accept",
- 203: "connect",
- 204: "getsockname",
- 205: "getpeername",
- 206: "sendto",
- 207: "recvfrom",
- 208: "setsockopt",
- 209: "getsockopt",
- 210: "shutdown",
- 211: "sendmsg",
- 212: "recvmsg",
- 213: "readahead",
- 214: "brk",
- 215: "munmap",
- 216: "mremap",
- 217: "add_key",
- 218: "request_key",
- 219: "keyctl",
- 220: "clone",
- 221: "execve",
- 222: "mmap",
- 223: "fadvise64",
- 224: "swapon",
- 225: "swapoff",
- 226: "mprotect",
- 227: "msync",
- 228: "mlock",
- 229: "munlock",
- 230: "mlockall",
- 231: "munlockall",
- 232: "mincore",
- 233: "madvise",
- 234: "remap_file_pages",
- 235: "mbind",
- 236: "get_mempolicy",
- 237: "set_mempolicy",
- 238: "migrate_pages",
- 239: "move_pages",
- 240: "rt_tgsigqueueinfo",
- 241: "perf_event_open",
- 242: "accept4",
- 243: "recvmmsg",
- 259: "riscv_flush_icache",
- 260: "wait4",
- 261: "prlimit64",
- 262: "fanotify_init",
- 263: "fanotify_mark",
- 264: "name_to_handle_at",
- 265: "open_by_handle_at",
- 266: "clock_adjtime",
- 267: "syncfs",
- 268: "setns",
- 269: "sendmmsg",
- 270: "process_vm_readv",
- 271: "process_vm_writev",
- 272: "kcmp",
- 273: "finit_module",
- 274: "sched_setattr",
- 275: "sched_getattr",
- 276: "renameat2",
- 277: "seccomp",
- 278: "getrandom",
- 279: "memfd_create",
- 280: "bpf",
- 281: "execveat",
- 282: "userfaultfd",
- 283: "membarrier",
- 284: "mlock2",
- 285: "copy_file_range",
- 286: "preadv2",
- 287: "pwritev2",
- 288: "pkey_mprotect",
- 289: "pkey_alloc",
- 290: "pkey_free",
- 291: "statx",
- 292: "io_pgetevents",
- 293: "rseq",
- 294: "kexec_file_load",
- 424: "pidfd_send_signal",
- 425: "io_uring_setup",
- 426: "io_uring_enter",
- 427: "io_uring_register",
- 428: "open_tree",
- 429: "move_mount",
- 430: "fsopen",
- 431: "fsconfig",
- 432: "fsmount",
- 433: "fspick",
- 434: "pidfd_open",
- 435: "clone3",
- 436: "close_range",
- 437: "openat2",
- 438: "pidfd_getfd",
- 439: "faccessat2",
- 440: "process_madvise",
- 441: "epoll_pwait2",
- 442: "mount_setattr",
- 443: "quotactl_fd",
- 444: "landlock_create_ruleset",
- 445: "landlock_add_rule",
- 446: "landlock_restrict_self",
- 448: "process_mrelease",
+ 0: "io_setup",
+ 1: "io_destroy",
+ 2: "io_submit",
+ 3: "io_cancel",
+ 4: "io_getevents",
+ 5: "setxattr",
+ 6: "lsetxattr",
+ 7: "fsetxattr",
+ 8: "getxattr",
+ 9: "lgetxattr",
+ 10: "fgetxattr",
+ 11: "listxattr",
+ 12: "llistxattr",
+ 13: "flistxattr",
+ 14: "removexattr",
+ 15: "lremovexattr",
+ 16: "fremovexattr",
+ 17: "getcwd",
+ 18: "lookup_dcookie",
+ 19: "eventfd2",
+ 20: "epoll_create1",
+ 21: "epoll_ctl",
+ 22: "epoll_pwait",
+ 23: "dup",
+ 24: "dup3",
+ 25: "fcntl",
+ 26: "inotify_init1",
+ 27: "inotify_add_watch",
+ 28: "inotify_rm_watch",
+ 29: "ioctl",
+ 30: "ioprio_set",
+ 31: "ioprio_get",
+ 32: "flock",
+ 33: "mknodat",
+ 34: "mkdirat",
+ 35: "unlinkat",
+ 36: "symlinkat",
+ 37: "linkat",
+ 39: "umount2",
+ 40: "mount",
+ 41: "pivot_root",
+ 42: "nfsservctl",
+ 43: "statfs",
+ 44: "fstatfs",
+ 45: "truncate",
+ 46: "ftruncate",
+ 47: "fallocate",
+ 48: "faccessat",
+ 49: "chdir",
+ 50: "fchdir",
+ 51: "chroot",
+ 52: "fchmod",
+ 53: "fchmodat",
+ 54: "fchownat",
+ 55: "fchown",
+ 56: "openat",
+ 57: "close",
+ 58: "vhangup",
+ 59: "pipe2",
+ 60: "quotactl",
+ 61: "getdents64",
+ 62: "lseek",
+ 63: "read",
+ 64: "write",
+ 65: "readv",
+ 66: "writev",
+ 67: "pread64",
+ 68: "pwrite64",
+ 69: "preadv",
+ 70: "pwritev",
+ 71: "sendfile",
+ 72: "pselect6",
+ 73: "ppoll",
+ 74: "signalfd4",
+ 75: "vmsplice",
+ 76: "splice",
+ 77: "tee",
+ 78: "readlinkat",
+ 79: "newfstatat",
+ 80: "fstat",
+ 81: "sync",
+ 82: "fsync",
+ 83: "fdatasync",
+ 84: "sync_file_range",
+ 85: "timerfd_create",
+ 86: "timerfd_settime",
+ 87: "timerfd_gettime",
+ 88: "utimensat",
+ 89: "acct",
+ 90: "capget",
+ 91: "capset",
+ 92: "personality",
+ 93: "exit",
+ 94: "exit_group",
+ 95: "waitid",
+ 96: "set_tid_address",
+ 97: "unshare",
+ 98: "futex",
+ 99: "set_robust_list",
+ 100: "get_robust_list",
+ 101: "nanosleep",
+ 102: "getitimer",
+ 103: "setitimer",
+ 104: "kexec_load",
+ 105: "init_module",
+ 106: "delete_module",
+ 107: "timer_create",
+ 108: "timer_gettime",
+ 109: "timer_getoverrun",
+ 110: "timer_settime",
+ 111: "timer_delete",
+ 112: "clock_settime",
+ 113: "clock_gettime",
+ 114: "clock_getres",
+ 115: "clock_nanosleep",
+ 116: "syslog",
+ 117: "ptrace",
+ 118: "sched_setparam",
+ 119: "sched_setscheduler",
+ 120: "sched_getscheduler",
+ 121: "sched_getparam",
+ 122: "sched_setaffinity",
+ 123: "sched_getaffinity",
+ 124: "sched_yield",
+ 125: "sched_get_priority_max",
+ 126: "sched_get_priority_min",
+ 127: "sched_rr_get_interval",
+ 128: "restart_syscall",
+ 129: "kill",
+ 130: "tkill",
+ 131: "tgkill",
+ 132: "sigaltstack",
+ 133: "rt_sigsuspend",
+ 134: "rt_sigaction",
+ 135: "rt_sigprocmask",
+ 136: "rt_sigpending",
+ 137: "rt_sigtimedwait",
+ 138: "rt_sigqueueinfo",
+ 139: "rt_sigreturn",
+ 140: "setpriority",
+ 141: "getpriority",
+ 142: "reboot",
+ 143: "setregid",
+ 144: "setgid",
+ 145: "setreuid",
+ 146: "setuid",
+ 147: "setresuid",
+ 148: "getresuid",
+ 149: "setresgid",
+ 150: "getresgid",
+ 151: "setfsuid",
+ 152: "setfsgid",
+ 153: "times",
+ 154: "setpgid",
+ 155: "getpgid",
+ 156: "getsid",
+ 157: "setsid",
+ 158: "getgroups",
+ 159: "setgroups",
+ 160: "uname",
+ 161: "sethostname",
+ 162: "setdomainname",
+ 163: "getrlimit",
+ 164: "setrlimit",
+ 165: "getrusage",
+ 166: "umask",
+ 167: "prctl",
+ 168: "getcpu",
+ 169: "gettimeofday",
+ 170: "settimeofday",
+ 171: "adjtimex",
+ 172: "getpid",
+ 173: "getppid",
+ 174: "getuid",
+ 175: "geteuid",
+ 176: "getgid",
+ 177: "getegid",
+ 178: "gettid",
+ 179: "sysinfo",
+ 180: "mq_open",
+ 181: "mq_unlink",
+ 182: "mq_timedsend",
+ 183: "mq_timedreceive",
+ 184: "mq_notify",
+ 185: "mq_getsetattr",
+ 186: "msgget",
+ 187: "msgctl",
+ 188: "msgrcv",
+ 189: "msgsnd",
+ 190: "semget",
+ 191: "semctl",
+ 192: "semtimedop",
+ 193: "semop",
+ 194: "shmget",
+ 195: "shmctl",
+ 196: "shmat",
+ 197: "shmdt",
+ 198: "socket",
+ 199: "socketpair",
+ 200: "bind",
+ 201: "listen",
+ 202: "accept",
+ 203: "connect",
+ 204: "getsockname",
+ 205: "getpeername",
+ 206: "sendto",
+ 207: "recvfrom",
+ 208: "setsockopt",
+ 209: "getsockopt",
+ 210: "shutdown",
+ 211: "sendmsg",
+ 212: "recvmsg",
+ 213: "readahead",
+ 214: "brk",
+ 215: "munmap",
+ 216: "mremap",
+ 217: "add_key",
+ 218: "request_key",
+ 219: "keyctl",
+ 220: "clone",
+ 221: "execve",
+ 222: "mmap",
+ 223: "fadvise64",
+ 224: "swapon",
+ 225: "swapoff",
+ 226: "mprotect",
+ 227: "msync",
+ 228: "mlock",
+ 229: "munlock",
+ 230: "mlockall",
+ 231: "munlockall",
+ 232: "mincore",
+ 233: "madvise",
+ 234: "remap_file_pages",
+ 235: "mbind",
+ 236: "get_mempolicy",
+ 237: "set_mempolicy",
+ 238: "migrate_pages",
+ 239: "move_pages",
+ 240: "rt_tgsigqueueinfo",
+ 241: "perf_event_open",
+ 242: "accept4",
+ 243: "recvmmsg",
+ 259: "riscv_flush_icache",
+ 260: "wait4",
+ 261: "prlimit64",
+ 262: "fanotify_init",
+ 263: "fanotify_mark",
+ 264: "name_to_handle_at",
+ 265: "open_by_handle_at",
+ 266: "clock_adjtime",
+ 267: "syncfs",
+ 268: "setns",
+ 269: "sendmmsg",
+ 270: "process_vm_readv",
+ 271: "process_vm_writev",
+ 272: "kcmp",
+ 273: "finit_module",
+ 274: "sched_setattr",
+ 275: "sched_getattr",
+ 276: "renameat2",
+ 277: "seccomp",
+ 278: "getrandom",
+ 279: "memfd_create",
+ 280: "bpf",
+ 281: "execveat",
+ 282: "userfaultfd",
+ 283: "membarrier",
+ 284: "mlock2",
+ 285: "copy_file_range",
+ 286: "preadv2",
+ 287: "pwritev2",
+ 288: "pkey_mprotect",
+ 289: "pkey_alloc",
+ 290: "pkey_free",
+ 291: "statx",
+ 292: "io_pgetevents",
+ 293: "rseq",
+ 294: "kexec_file_load",
+ 424: "pidfd_send_signal",
+ 425: "io_uring_setup",
+ 426: "io_uring_enter",
+ 427: "io_uring_register",
+ 428: "open_tree",
+ 429: "move_mount",
+ 430: "fsopen",
+ 431: "fsconfig",
+ 432: "fsmount",
+ 433: "fspick",
+ 434: "pidfd_open",
+ 435: "clone3",
+ 436: "close_range",
+ 437: "openat2",
+ 438: "pidfd_getfd",
+ 439: "faccessat2",
+ 440: "process_madvise",
+ 441: "epoll_pwait2",
+ 442: "mount_setattr",
+ 443: "quotactl_fd",
+ 444: "landlock_create_ruleset",
+ 445: "landlock_add_rule",
+ 446: "landlock_restrict_self",
+ 448: "process_mrelease",
}
ppc_syscall_table = {
- 0: "restart_syscall",
- 1: "exit",
- 2: "fork",
- 3: "read",
- 4: "write",
- 5: "open",
- 6: "close",
- 7: "waitpid",
- 8: "creat",
- 9: "link",
- 10: "unlink",
- 11: "execve",
- 12: "chdir",
- 13: "time",
- 14: "mknod",
- 15: "chmod",
- 16: "lchown",
- 17: "break",
- 18: "oldstat",
- 19: "lseek",
- 20: "getpid",
- 21: "mount",
- 22: "umount",
- 23: "setuid",
- 24: "getuid",
- 25: "stime",
- 26: "ptrace",
- 27: "alarm",
- 28: "oldfstat",
- 29: "pause",
- 30: "utime",
- 31: "stty",
- 32: "gtty",
- 33: "access",
- 34: "nice",
- 35: "ftime",
- 36: "sync",
- 37: "kill",
- 38: "rename",
- 39: "mkdir",
- 40: "rmdir",
- 41: "dup",
- 42: "pipe",
- 43: "times",
- 44: "prof",
- 45: "brk",
- 46: "setgid",
- 47: "getgid",
- 48: "signal",
- 49: "geteuid",
- 50: "getegid",
- 51: "acct",
- 52: "umount2",
- 53: "lock",
- 54: "ioctl",
- 55: "fcntl",
- 56: "mpx",
- 57: "setpgid",
- 58: "ulimit",
- 59: "oldolduname",
- 60: "umask",
- 61: "chroot",
- 62: "ustat",
- 63: "dup2",
- 64: "getppid",
- 65: "getpgrp",
- 66: "setsid",
- 67: "sigaction",
- 68: "sgetmask",
- 69: "ssetmask",
- 70: "setreuid",
- 71: "setregid",
- 72: "sigsuspend",
- 73: "sigpending",
- 74: "sethostname",
- 75: "setrlimit",
- 76: "getrlimit",
- 77: "getrusage",
- 78: "gettimeofday",
- 79: "settimeofday",
- 80: "getgroups",
- 81: "setgroups",
- 82: "select",
- 83: "symlink",
- 84: "oldlstat",
- 85: "readlink",
- 86: "uselib",
- 87: "swapon",
- 88: "reboot",
- 89: "readdir",
- 90: "mmap",
- 91: "munmap",
- 92: "truncate",
- 93: "ftruncate",
- 94: "fchmod",
- 95: "fchown",
- 96: "getpriority",
- 97: "setpriority",
- 98: "profil",
- 99: "statfs",
- 100: "fstatfs",
- 101: "ioperm",
- 102: "socketcall",
- 103: "syslog",
- 104: "setitimer",
- 105: "getitimer",
- 106: "stat",
- 107: "lstat",
- 108: "fstat",
- 109: "olduname",
- 110: "iopl",
- 111: "vhangup",
- 112: "idle",
- 113: "vm86",
- 114: "wait4",
- 115: "swapoff",
- 116: "sysinfo",
- 117: "ipc",
- 118: "fsync",
- 119: "sigreturn",
- 120: "clone",
- 121: "setdomainname",
- 122: "uname",
- 123: "modify_ldt",
- 124: "adjtimex",
- 125: "mprotect",
- 126: "sigprocmask",
- 127: "create_module",
- 128: "init_module",
- 129: "delete_module",
- 130: "get_kernel_syms",
- 131: "quotactl",
- 132: "getpgid",
- 133: "fchdir",
- 134: "bdflush",
- 135: "sysfs",
- 136: "personality",
- 137: "afs_syscall",
- 138: "setfsuid",
- 139: "setfsgid",
- 140: "_llseek",
- 141: "getdents",
- 142: "_newselect",
- 143: "flock",
- 144: "msync",
- 145: "readv",
- 146: "writev",
- 147: "getsid",
- 148: "fdatasync",
- 149: "_sysctl",
- 150: "mlock",
- 151: "munlock",
- 152: "mlockall",
- 153: "munlockall",
- 154: "sched_setparam",
- 155: "sched_getparam",
- 156: "sched_setscheduler",
- 157: "sched_getscheduler",
- 158: "sched_yield",
- 159: "sched_get_priority_max",
- 160: "sched_get_priority_min",
- 161: "sched_rr_get_interval",
- 162: "nanosleep",
- 163: "mremap",
- 164: "setresuid",
- 165: "getresuid",
- 166: "query_module",
- 167: "poll",
- 168: "nfsservctl",
- 169: "setresgid",
- 170: "getresgid",
- 171: "prctl",
- 172: "rt_sigreturn",
- 173: "rt_sigaction",
- 174: "rt_sigprocmask",
- 175: "rt_sigpending",
- 176: "rt_sigtimedwait",
- 177: "rt_sigqueueinfo",
- 178: "rt_sigsuspend",
- 179: "pread64",
- 180: "pwrite64",
- 181: "chown",
- 182: "getcwd",
- 183: "capget",
- 184: "capset",
- 185: "sigaltstack",
- 186: "sendfile",
- 187: "getpmsg",
- 188: "putpmsg",
- 189: "vfork",
- 190: "ugetrlimit",
- 191: "readahead",
- 192: "mmap2",
- 193: "truncate64",
- 194: "ftruncate64",
- 195: "stat64",
- 196: "lstat64",
- 197: "fstat64",
- 198: "pciconfig_read",
- 199: "pciconfig_write",
- 200: "pciconfig_iobase",
- 201: "multiplexer",
- 202: "getdents64",
- 203: "pivot_root",
- 204: "fcntl64",
- 205: "madvise",
- 206: "mincore",
- 207: "gettid",
- 208: "tkill",
- 209: "setxattr",
- 210: "lsetxattr",
- 211: "fsetxattr",
- 212: "getxattr",
- 213: "lgetxattr",
- 214: "fgetxattr",
- 215: "listxattr",
- 216: "llistxattr",
- 217: "flistxattr",
- 218: "removexattr",
- 219: "lremovexattr",
- 220: "fremovexattr",
- 221: "futex",
- 222: "sched_setaffinity",
- 223: "sched_getaffinity",
- 225: "tuxcall",
- 226: "sendfile64",
- 227: "io_setup",
- 228: "io_destroy",
- 229: "io_getevents",
- 230: "io_submit",
- 231: "io_cancel",
- 232: "set_tid_address",
- 233: "fadvise64",
- 234: "exit_group",
- 235: "lookup_dcookie",
- 236: "epoll_create",
- 237: "epoll_ctl",
- 238: "epoll_wait",
- 239: "remap_file_pages",
- 240: "timer_create",
- 241: "timer_settime",
- 242: "timer_gettime",
- 243: "timer_getoverrun",
- 244: "timer_delete",
- 245: "clock_settime",
- 246: "clock_gettime",
- 247: "clock_getres",
- 248: "clock_nanosleep",
- 249: "swapcontext",
- 250: "tgkill",
- 251: "utimes",
- 252: "statfs64",
- 253: "fstatfs64",
- 254: "fadvise64_64",
- 255: "rtas",
- 256: "sys_debug_setcontext",
- 258: "migrate_pages",
- 259: "mbind",
- 260: "get_mempolicy",
- 261: "set_mempolicy",
- 262: "mq_open",
- 263: "mq_unlink",
- 264: "mq_timedsend",
- 265: "mq_timedreceive",
- 266: "mq_notify",
- 267: "mq_getsetattr",
- 268: "kexec_load",
- 269: "add_key",
- 270: "request_key",
- 271: "keyctl",
- 272: "waitid",
- 273: "ioprio_set",
- 274: "ioprio_get",
- 275: "inotify_init",
- 276: "inotify_add_watch",
- 277: "inotify_rm_watch",
- 278: "spu_run",
- 279: "spu_create",
- 280: "pselect6",
- 281: "ppoll",
- 282: "unshare",
- 283: "splice",
- 284: "tee",
- 285: "vmsplice",
- 286: "openat",
- 287: "mkdirat",
- 288: "mknodat",
- 289: "fchownat",
- 290: "futimesat",
- 291: "fstatat64",
- 292: "unlinkat",
- 293: "renameat",
- 294: "linkat",
- 295: "symlinkat",
- 296: "readlinkat",
- 297: "fchmodat",
- 298: "faccessat",
- 299: "get_robust_list",
- 300: "set_robust_list",
- 301: "move_pages",
- 302: "getcpu",
- 303: "epoll_pwait",
- 304: "utimensat",
- 305: "signalfd",
- 306: "timerfd_create",
- 307: "eventfd",
- 308: "sync_file_range2",
- 309: "fallocate",
- 310: "subpage_prot",
- 311: "timerfd_settime",
- 312: "timerfd_gettime",
- 313: "signalfd4",
- 314: "eventfd2",
- 315: "epoll_create1",
- 316: "dup3",
- 317: "pipe2",
- 318: "inotify_init1",
- 319: "perf_event_open",
- 320: "preadv",
- 321: "pwritev",
- 322: "rt_tgsigqueueinfo",
- 323: "fanotify_init",
- 324: "fanotify_mark",
- 325: "prlimit64",
- 326: "socket",
- 327: "bind",
- 328: "connect",
- 329: "listen",
- 330: "accept",
- 331: "getsockname",
- 332: "getpeername",
- 333: "socketpair",
- 334: "send",
- 335: "sendto",
- 336: "recv",
- 337: "recvfrom",
- 338: "shutdown",
- 339: "setsockopt",
- 340: "getsockopt",
- 341: "sendmsg",
- 342: "recvmsg",
- 343: "recvmmsg",
- 344: "accept4",
- 345: "name_to_handle_at",
- 346: "open_by_handle_at",
- 347: "clock_adjtime",
- 348: "syncfs",
- 349: "sendmmsg",
- 350: "setns",
- 351: "process_vm_readv",
- 352: "process_vm_writev",
- 353: "finit_module",
- 354: "kcmp",
- 355: "sched_setattr",
- 356: "sched_getattr",
- 357: "renameat2",
- 358: "seccomp",
- 359: "getrandom",
- 360: "memfd_create",
- 361: "bpf",
- 362: "execveat",
- 363: "switch_endian",
- 364: "userfaultfd",
- 365: "membarrier",
- 378: "mlock2",
- 379: "copy_file_range",
- 380: "preadv2",
- 381: "pwritev2",
- 382: "kexec_file_load",
- 383: "statx",
- 384: "pkey_alloc",
- 385: "pkey_free",
- 386: "pkey_mprotect",
- 387: "rseq",
- 388: "io_pgetevents",
- 393: "semget",
- 394: "semctl",
- 395: "shmget",
- 396: "shmctl",
- 397: "shmat",
- 398: "shmdt",
- 399: "msgget",
- 400: "msgsnd",
- 401: "msgrcv",
- 402: "msgctl",
- 403: "clock_gettime64",
- 404: "clock_settime64",
- 405: "clock_adjtime64",
- 406: "clock_getres_time64",
- 407: "clock_nanosleep_time64",
- 408: "timer_gettime64",
- 409: "timer_settime64",
- 410: "timerfd_gettime64",
- 411: "timerfd_settime64",
- 412: "utimensat_time64",
- 413: "pselect6_time64",
- 414: "ppoll_time64",
- 416: "io_pgetevents_time64",
- 417: "recvmmsg_time64",
- 418: "mq_timedsend_time64",
- 419: "mq_timedreceive_time64",
- 420: "semtimedop_time64",
- 421: "rt_sigtimedwait_time64",
- 422: "futex_time64",
- 423: "sched_rr_get_interval_time64",
- 424: "pidfd_send_signal",
- 425: "io_uring_setup",
- 426: "io_uring_enter",
- 427: "io_uring_register",
- 428: "open_tree",
- 429: "move_mount",
- 430: "fsopen",
- 431: "fsconfig",
- 432: "fsmount",
- 433: "fspick",
+ 0: "restart_syscall",
+ 1: "exit",
+ 2: "fork",
+ 3: "read",
+ 4: "write",
+ 5: "open",
+ 6: "close",
+ 7: "waitpid",
+ 8: "creat",
+ 9: "link",
+ 10: "unlink",
+ 11: "execve",
+ 12: "chdir",
+ 13: "time",
+ 14: "mknod",
+ 15: "chmod",
+ 16: "lchown",
+ 17: "break",
+ 18: "oldstat",
+ 19: "lseek",
+ 20: "getpid",
+ 21: "mount",
+ 22: "umount",
+ 23: "setuid",
+ 24: "getuid",
+ 25: "stime",
+ 26: "ptrace",
+ 27: "alarm",
+ 28: "oldfstat",
+ 29: "pause",
+ 30: "utime",
+ 31: "stty",
+ 32: "gtty",
+ 33: "access",
+ 34: "nice",
+ 35: "ftime",
+ 36: "sync",
+ 37: "kill",
+ 38: "rename",
+ 39: "mkdir",
+ 40: "rmdir",
+ 41: "dup",
+ 42: "pipe",
+ 43: "times",
+ 44: "prof",
+ 45: "brk",
+ 46: "setgid",
+ 47: "getgid",
+ 48: "signal",
+ 49: "geteuid",
+ 50: "getegid",
+ 51: "acct",
+ 52: "umount2",
+ 53: "lock",
+ 54: "ioctl",
+ 55: "fcntl",
+ 56: "mpx",
+ 57: "setpgid",
+ 58: "ulimit",
+ 59: "oldolduname",
+ 60: "umask",
+ 61: "chroot",
+ 62: "ustat",
+ 63: "dup2",
+ 64: "getppid",
+ 65: "getpgrp",
+ 66: "setsid",
+ 67: "sigaction",
+ 68: "sgetmask",
+ 69: "ssetmask",
+ 70: "setreuid",
+ 71: "setregid",
+ 72: "sigsuspend",
+ 73: "sigpending",
+ 74: "sethostname",
+ 75: "setrlimit",
+ 76: "getrlimit",
+ 77: "getrusage",
+ 78: "gettimeofday",
+ 79: "settimeofday",
+ 80: "getgroups",
+ 81: "setgroups",
+ 82: "select",
+ 83: "symlink",
+ 84: "oldlstat",
+ 85: "readlink",
+ 86: "uselib",
+ 87: "swapon",
+ 88: "reboot",
+ 89: "readdir",
+ 90: "mmap",
+ 91: "munmap",
+ 92: "truncate",
+ 93: "ftruncate",
+ 94: "fchmod",
+ 95: "fchown",
+ 96: "getpriority",
+ 97: "setpriority",
+ 98: "profil",
+ 99: "statfs",
+ 100: "fstatfs",
+ 101: "ioperm",
+ 102: "socketcall",
+ 103: "syslog",
+ 104: "setitimer",
+ 105: "getitimer",
+ 106: "stat",
+ 107: "lstat",
+ 108: "fstat",
+ 109: "olduname",
+ 110: "iopl",
+ 111: "vhangup",
+ 112: "idle",
+ 113: "vm86",
+ 114: "wait4",
+ 115: "swapoff",
+ 116: "sysinfo",
+ 117: "ipc",
+ 118: "fsync",
+ 119: "sigreturn",
+ 120: "clone",
+ 121: "setdomainname",
+ 122: "uname",
+ 123: "modify_ldt",
+ 124: "adjtimex",
+ 125: "mprotect",
+ 126: "sigprocmask",
+ 127: "create_module",
+ 128: "init_module",
+ 129: "delete_module",
+ 130: "get_kernel_syms",
+ 131: "quotactl",
+ 132: "getpgid",
+ 133: "fchdir",
+ 134: "bdflush",
+ 135: "sysfs",
+ 136: "personality",
+ 137: "afs_syscall",
+ 138: "setfsuid",
+ 139: "setfsgid",
+ 140: "_llseek",
+ 141: "getdents",
+ 142: "_newselect",
+ 143: "flock",
+ 144: "msync",
+ 145: "readv",
+ 146: "writev",
+ 147: "getsid",
+ 148: "fdatasync",
+ 149: "_sysctl",
+ 150: "mlock",
+ 151: "munlock",
+ 152: "mlockall",
+ 153: "munlockall",
+ 154: "sched_setparam",
+ 155: "sched_getparam",
+ 156: "sched_setscheduler",
+ 157: "sched_getscheduler",
+ 158: "sched_yield",
+ 159: "sched_get_priority_max",
+ 160: "sched_get_priority_min",
+ 161: "sched_rr_get_interval",
+ 162: "nanosleep",
+ 163: "mremap",
+ 164: "setresuid",
+ 165: "getresuid",
+ 166: "query_module",
+ 167: "poll",
+ 168: "nfsservctl",
+ 169: "setresgid",
+ 170: "getresgid",
+ 171: "prctl",
+ 172: "rt_sigreturn",
+ 173: "rt_sigaction",
+ 174: "rt_sigprocmask",
+ 175: "rt_sigpending",
+ 176: "rt_sigtimedwait",
+ 177: "rt_sigqueueinfo",
+ 178: "rt_sigsuspend",
+ 179: "pread64",
+ 180: "pwrite64",
+ 181: "chown",
+ 182: "getcwd",
+ 183: "capget",
+ 184: "capset",
+ 185: "sigaltstack",
+ 186: "sendfile",
+ 187: "getpmsg",
+ 188: "putpmsg",
+ 189: "vfork",
+ 190: "ugetrlimit",
+ 191: "readahead",
+ 192: "mmap2",
+ 193: "truncate64",
+ 194: "ftruncate64",
+ 195: "stat64",
+ 196: "lstat64",
+ 197: "fstat64",
+ 198: "pciconfig_read",
+ 199: "pciconfig_write",
+ 200: "pciconfig_iobase",
+ 201: "multiplexer",
+ 202: "getdents64",
+ 203: "pivot_root",
+ 204: "fcntl64",
+ 205: "madvise",
+ 206: "mincore",
+ 207: "gettid",
+ 208: "tkill",
+ 209: "setxattr",
+ 210: "lsetxattr",
+ 211: "fsetxattr",
+ 212: "getxattr",
+ 213: "lgetxattr",
+ 214: "fgetxattr",
+ 215: "listxattr",
+ 216: "llistxattr",
+ 217: "flistxattr",
+ 218: "removexattr",
+ 219: "lremovexattr",
+ 220: "fremovexattr",
+ 221: "futex",
+ 222: "sched_setaffinity",
+ 223: "sched_getaffinity",
+ 225: "tuxcall",
+ 226: "sendfile64",
+ 227: "io_setup",
+ 228: "io_destroy",
+ 229: "io_getevents",
+ 230: "io_submit",
+ 231: "io_cancel",
+ 232: "set_tid_address",
+ 233: "fadvise64",
+ 234: "exit_group",
+ 235: "lookup_dcookie",
+ 236: "epoll_create",
+ 237: "epoll_ctl",
+ 238: "epoll_wait",
+ 239: "remap_file_pages",
+ 240: "timer_create",
+ 241: "timer_settime",
+ 242: "timer_gettime",
+ 243: "timer_getoverrun",
+ 244: "timer_delete",
+ 245: "clock_settime",
+ 246: "clock_gettime",
+ 247: "clock_getres",
+ 248: "clock_nanosleep",
+ 249: "swapcontext",
+ 250: "tgkill",
+ 251: "utimes",
+ 252: "statfs64",
+ 253: "fstatfs64",
+ 254: "fadvise64_64",
+ 255: "rtas",
+ 256: "sys_debug_setcontext",
+ 258: "migrate_pages",
+ 259: "mbind",
+ 260: "get_mempolicy",
+ 261: "set_mempolicy",
+ 262: "mq_open",
+ 263: "mq_unlink",
+ 264: "mq_timedsend",
+ 265: "mq_timedreceive",
+ 266: "mq_notify",
+ 267: "mq_getsetattr",
+ 268: "kexec_load",
+ 269: "add_key",
+ 270: "request_key",
+ 271: "keyctl",
+ 272: "waitid",
+ 273: "ioprio_set",
+ 274: "ioprio_get",
+ 275: "inotify_init",
+ 276: "inotify_add_watch",
+ 277: "inotify_rm_watch",
+ 278: "spu_run",
+ 279: "spu_create",
+ 280: "pselect6",
+ 281: "ppoll",
+ 282: "unshare",
+ 283: "splice",
+ 284: "tee",
+ 285: "vmsplice",
+ 286: "openat",
+ 287: "mkdirat",
+ 288: "mknodat",
+ 289: "fchownat",
+ 290: "futimesat",
+ 291: "fstatat64",
+ 292: "unlinkat",
+ 293: "renameat",
+ 294: "linkat",
+ 295: "symlinkat",
+ 296: "readlinkat",
+ 297: "fchmodat",
+ 298: "faccessat",
+ 299: "get_robust_list",
+ 300: "set_robust_list",
+ 301: "move_pages",
+ 302: "getcpu",
+ 303: "epoll_pwait",
+ 304: "utimensat",
+ 305: "signalfd",
+ 306: "timerfd_create",
+ 307: "eventfd",
+ 308: "sync_file_range2",
+ 309: "fallocate",
+ 310: "subpage_prot",
+ 311: "timerfd_settime",
+ 312: "timerfd_gettime",
+ 313: "signalfd4",
+ 314: "eventfd2",
+ 315: "epoll_create1",
+ 316: "dup3",
+ 317: "pipe2",
+ 318: "inotify_init1",
+ 319: "perf_event_open",
+ 320: "preadv",
+ 321: "pwritev",
+ 322: "rt_tgsigqueueinfo",
+ 323: "fanotify_init",
+ 324: "fanotify_mark",
+ 325: "prlimit64",
+ 326: "socket",
+ 327: "bind",
+ 328: "connect",
+ 329: "listen",
+ 330: "accept",
+ 331: "getsockname",
+ 332: "getpeername",
+ 333: "socketpair",
+ 334: "send",
+ 335: "sendto",
+ 336: "recv",
+ 337: "recvfrom",
+ 338: "shutdown",
+ 339: "setsockopt",
+ 340: "getsockopt",
+ 341: "sendmsg",
+ 342: "recvmsg",
+ 343: "recvmmsg",
+ 344: "accept4",
+ 345: "name_to_handle_at",
+ 346: "open_by_handle_at",
+ 347: "clock_adjtime",
+ 348: "syncfs",
+ 349: "sendmmsg",
+ 350: "setns",
+ 351: "process_vm_readv",
+ 352: "process_vm_writev",
+ 353: "finit_module",
+ 354: "kcmp",
+ 355: "sched_setattr",
+ 356: "sched_getattr",
+ 357: "renameat2",
+ 358: "seccomp",
+ 359: "getrandom",
+ 360: "memfd_create",
+ 361: "bpf",
+ 362: "execveat",
+ 363: "switch_endian",
+ 364: "userfaultfd",
+ 365: "membarrier",
+ 378: "mlock2",
+ 379: "copy_file_range",
+ 380: "preadv2",
+ 381: "pwritev2",
+ 382: "kexec_file_load",
+ 383: "statx",
+ 384: "pkey_alloc",
+ 385: "pkey_free",
+ 386: "pkey_mprotect",
+ 387: "rseq",
+ 388: "io_pgetevents",
+ 393: "semget",
+ 394: "semctl",
+ 395: "shmget",
+ 396: "shmctl",
+ 397: "shmat",
+ 398: "shmdt",
+ 399: "msgget",
+ 400: "msgsnd",
+ 401: "msgrcv",
+ 402: "msgctl",
+ 403: "clock_gettime64",
+ 404: "clock_settime64",
+ 405: "clock_adjtime64",
+ 406: "clock_getres_time64",
+ 407: "clock_nanosleep_time64",
+ 408: "timer_gettime64",
+ 409: "timer_settime64",
+ 410: "timerfd_gettime64",
+ 411: "timerfd_settime64",
+ 412: "utimensat_time64",
+ 413: "pselect6_time64",
+ 414: "ppoll_time64",
+ 416: "io_pgetevents_time64",
+ 417: "recvmmsg_time64",
+ 418: "mq_timedsend_time64",
+ 419: "mq_timedreceive_time64",
+ 420: "semtimedop_time64",
+ 421: "rt_sigtimedwait_time64",
+ 422: "futex_time64",
+ 423: "sched_rr_get_interval_time64",
+ 424: "pidfd_send_signal",
+ 425: "io_uring_setup",
+ 426: "io_uring_enter",
+ 427: "io_uring_register",
+ 428: "open_tree",
+ 429: "move_mount",
+ 430: "fsopen",
+ 431: "fsconfig",
+ 432: "fsmount",
+ 433: "fspick",
}
diff --git a/qiling/os/linux/syscall_nums.py b/qiling/os/linux/syscall_nums.py
index a5672e523..fc7037a6a 100644
--- a/qiling/os/linux/syscall_nums.py
+++ b/qiling/os/linux/syscall_nums.py
@@ -7,336 +7,336 @@
# Linux syscall numbers
class SYSCALL_NR(IntEnum):
- read = 0
- write = 1
- open = 2
- close = 3
- stat = 4
- fstat = 5
- lstat = 6
- poll = 7
- lseek = 8
- mmap = 9
- mprotect = 10
- munmap = 11
- brk = 12
- rt_sigaction = 13
- rt_sigprocmask = 14
- rt_sigreturn = 15
- ioctl = 16
- pread64 = 17
- pwrite64 = 18
- readv = 19
- writev = 20
- access = 21
- pipe = 22
- select = 23
- sched_yield = 24
- mremap = 25
- msync = 26
- mincore = 27
- madvise = 28
- shmget = 29
- shmat = 30
- shmctl = 31
- dup = 32
- dup2 = 33
- pause = 34
- nanosleep = 35
- getitimer = 36
- alarm = 37
- setitimer = 38
- getpid = 39
- sendfile = 40
- socket = 41
- connect = 42
- accept = 43
- sendto = 44
- recvfrom = 45
- sendmsg = 46
- recvmsg = 47
- shutdown = 48
- bind = 49
- listen = 50
- getsockname = 51
- getpeername = 52
- socketpair = 53
- setsockopt = 54
- getsockopt = 55
- clone = 56
- fork = 57
- vfork = 58
- execve = 59
- exit = 60
- wait4 = 61
- kill = 62
- uname = 63
- semget = 64
- semop = 65
- semctl = 66
- shmdt = 67
- msgget = 68
- msgsnd = 69
- msgrcv = 70
- msgctl = 71
- fcntl = 72
- flock = 73
- fsync = 74
- fdatasync = 75
- truncate = 76
- ftruncate = 77
- getdents = 78
- getcwd = 79
- chdir = 80
- fchdir = 81
- rename = 82
- mkdir = 83
- rmdir = 84
- creat = 85
- link = 86
- unlink = 87
- symlink = 88
- readlink = 89
- chmod = 90
- fchmod = 91
- chown = 92
- fchown = 93
- lchown = 94
- umask = 95
- gettimeofday = 96
- getrlimit = 97
- getrusage = 98
- sysinfo = 99
- times = 100
- ptrace = 101
- getuid = 102
- syslog = 103
- getgid = 104
- setuid = 105
- setgid = 106
- geteuid = 107
- getegid = 108
- setpgid = 109
- getppid = 110
- getpgrp = 111
- setsid = 112
- setreuid = 113
- setregid = 114
- getgroups = 115
- setgroups = 116
- setresuid = 117
- getresuid = 118
- setresgid = 119
- getresgid = 120
- getpgid = 121
- setfsuid = 122
- setfsgid = 123
- getsid = 124
- capget = 125
- capset = 126
- rt_sigpending = 127
- rt_sigtimedwait = 128
- rt_sigqueueinfo = 129
- rt_sigsuspend = 130
- sigaltstack = 131
- utime = 132
- mknod = 133
- uselib = 134
- personality = 135
- ustat = 136
- statfs = 137
- fstatfs = 138
- sysfs = 139
- getpriority = 140
- setpriority = 141
- sched_setparam = 142
- sched_getparam = 143
- sched_setscheduler = 144
- sched_getscheduler = 145
- sched_get_priority_max = 146
- sched_get_priority_min = 147
- sched_rr_get_interval = 148
- mlock = 149
- munlock = 150
- mlockall = 151
- munlockall = 152
- vhangup = 153
- modify_ldt = 154
- pivot_root = 155
- _sysctl = 156
- prctl = 157
- arch_prctl = 158
- adjtimex = 159
- setrlimit = 160
- chroot = 161
- sync = 162
- acct = 163
- settimeofday = 164
- mount = 165
- umount2 = 166
- swapon = 167
- swapoff = 168
- reboot = 169
- sethostname = 170
- setdomainname = 171
- iopl = 172
- ioperm = 173
- create_module = 174
- init_module = 175
- delete_module = 176
- get_kernel_syms = 177
- query_module = 178
- quotactl = 179
- nfsservctl = 180
- getpmsg = 181
- putpmsg = 182
- afs_syscall = 183
- tuxcall = 184
- security = 185
- gettid = 186
- readahead = 187
- setxattr = 188
- lsetxattr = 189
- fsetxattr = 190
- getxattr = 191
- lgetxattr = 192
- fgetxattr = 193
- listxattr = 194
- llistxattr = 195
- flistxattr = 196
- removexattr = 197
- lremovexattr = 198
- fremovexattr = 199
- tkill = 200
- time = 201
- futex = 202
- sched_setaffinity = 203
- sched_getaffinity = 204
- set_thread_area = 205
- io_setup = 206
- io_destroy = 207
- io_getevents = 208
- io_submit = 209
- io_cancel = 210
- get_thread_area = 211
- lookup_dcookie = 212
- epoll_create = 213
- epoll_ctl_old = 214
- epoll_wait_old = 215
- remap_file_pages = 216
- getdents64 = 217
- set_tid_address = 218
- restart_syscall = 219
- semtimedop = 220
- fadvise64 = 221
- timer_create = 222
- timer_settime = 223
- timer_gettime = 224
- timer_getoverrun = 225
- timer_delete = 226
- clock_settime = 227
- clock_gettime = 228
- clock_getres = 229
- clock_nanosleep = 230
- exit_group = 231
- epoll_wait = 232
- epoll_ctl = 233
- tgkill = 234
- utimes = 235
- vserver = 236
- mbind = 237
- set_mempolicy = 238
- get_mempolicy = 239
- mq_open = 240
- mq_unlink = 241
- mq_timedsend = 242
- mq_timedreceive = 243
- mq_notify = 244
- mq_getsetattr = 245
- kexec_load = 246
- waitid = 247
- add_key = 248
- request_key = 249
- keyctl = 250
- ioprio_set = 251
- ioprio_get = 252
- inotify_init = 253
- inotify_add_watch = 254
- inotify_rm_watch = 255
- migrate_pages = 256
- openat = 257
- mkdirat = 258
- mknodat = 259
- fchownat = 260
- futimesat = 261
- newfstatat = 262
- unlinkat = 263
- renameat = 264
- linkat = 265
- symlinkat = 266
- readlinkat = 267
- fchmodat = 268
- faccessat = 269
- pselect6 = 270
- ppoll = 271
- unshare = 272
- set_robust_list = 273
- get_robust_list = 274
- splice = 275
- tee = 276
- sync_file_range = 277
- vmsplice = 278
- move_pages = 279
- utimensat = 280
- epoll_pwait = 281
- signalfd = 282
- timerfd_create = 283
- eventfd = 284
- fallocate = 285
- timerfd_settime = 286
- timerfd_gettime = 287
- accept4 = 288
- signalfd4 = 289
- eventfd2 = 290
- epoll_create1 = 291
- dup3 = 292
- pipe2 = 293
- inotify_init1 = 294
- preadv = 295
- pwritev = 296
- rt_tgsigqueueinfo = 297
- perf_event_open = 298
- recvmmsg = 299
- fanotify_init = 300
- fanotify_mark = 301
- prlimit64 = 302
- name_to_handle_at = 303
- open_by_handle_at = 304
- clock_adjtime = 305
- syncfs = 306
- sendmmsg = 307
- setns = 308
- getcpu = 309
- process_vm_readv = 310
- process_vm_writev = 311
- kcmp = 312
- finit_module = 313
- sched_setattr = 314
- sched_getattr = 315
- renameat2 = 316
- seccomp = 317
- getrandom = 318
- memfd_create = 319
- kexec_file_load = 320
- bpf = 321
- execveat = 322
- userfaultfd = 323
- membarrier = 324
- mlock2 = 325
- copy_file_range = 326
- preadv2 = 327
- pwritev2 = 328
- pkey_mprotect = 329
- pkey_alloc = 330
- pkey_free = 331
- statx = 332
+ read = 0
+ write = 1
+ open = 2
+ close = 3
+ stat = 4
+ fstat = 5
+ lstat = 6
+ poll = 7
+ lseek = 8
+ mmap = 9
+ mprotect = 10
+ munmap = 11
+ brk = 12
+ rt_sigaction = 13
+ rt_sigprocmask = 14
+ rt_sigreturn = 15
+ ioctl = 16
+ pread64 = 17
+ pwrite64 = 18
+ readv = 19
+ writev = 20
+ access = 21
+ pipe = 22
+ select = 23
+ sched_yield = 24
+ mremap = 25
+ msync = 26
+ mincore = 27
+ madvise = 28
+ shmget = 29
+ shmat = 30
+ shmctl = 31
+ dup = 32
+ dup2 = 33
+ pause = 34
+ nanosleep = 35
+ getitimer = 36
+ alarm = 37
+ setitimer = 38
+ getpid = 39
+ sendfile = 40
+ socket = 41
+ connect = 42
+ accept = 43
+ sendto = 44
+ recvfrom = 45
+ sendmsg = 46
+ recvmsg = 47
+ shutdown = 48
+ bind = 49
+ listen = 50
+ getsockname = 51
+ getpeername = 52
+ socketpair = 53
+ setsockopt = 54
+ getsockopt = 55
+ clone = 56
+ fork = 57
+ vfork = 58
+ execve = 59
+ exit = 60
+ wait4 = 61
+ kill = 62
+ uname = 63
+ semget = 64
+ semop = 65
+ semctl = 66
+ shmdt = 67
+ msgget = 68
+ msgsnd = 69
+ msgrcv = 70
+ msgctl = 71
+ fcntl = 72
+ flock = 73
+ fsync = 74
+ fdatasync = 75
+ truncate = 76
+ ftruncate = 77
+ getdents = 78
+ getcwd = 79
+ chdir = 80
+ fchdir = 81
+ rename = 82
+ mkdir = 83
+ rmdir = 84
+ creat = 85
+ link = 86
+ unlink = 87
+ symlink = 88
+ readlink = 89
+ chmod = 90
+ fchmod = 91
+ chown = 92
+ fchown = 93
+ lchown = 94
+ umask = 95
+ gettimeofday = 96
+ getrlimit = 97
+ getrusage = 98
+ sysinfo = 99
+ times = 100
+ ptrace = 101
+ getuid = 102
+ syslog = 103
+ getgid = 104
+ setuid = 105
+ setgid = 106
+ geteuid = 107
+ getegid = 108
+ setpgid = 109
+ getppid = 110
+ getpgrp = 111
+ setsid = 112
+ setreuid = 113
+ setregid = 114
+ getgroups = 115
+ setgroups = 116
+ setresuid = 117
+ getresuid = 118
+ setresgid = 119
+ getresgid = 120
+ getpgid = 121
+ setfsuid = 122
+ setfsgid = 123
+ getsid = 124
+ capget = 125
+ capset = 126
+ rt_sigpending = 127
+ rt_sigtimedwait = 128
+ rt_sigqueueinfo = 129
+ rt_sigsuspend = 130
+ sigaltstack = 131
+ utime = 132
+ mknod = 133
+ uselib = 134
+ personality = 135
+ ustat = 136
+ statfs = 137
+ fstatfs = 138
+ sysfs = 139
+ getpriority = 140
+ setpriority = 141
+ sched_setparam = 142
+ sched_getparam = 143
+ sched_setscheduler = 144
+ sched_getscheduler = 145
+ sched_get_priority_max = 146
+ sched_get_priority_min = 147
+ sched_rr_get_interval = 148
+ mlock = 149
+ munlock = 150
+ mlockall = 151
+ munlockall = 152
+ vhangup = 153
+ modify_ldt = 154
+ pivot_root = 155
+ _sysctl = 156
+ prctl = 157
+ arch_prctl = 158
+ adjtimex = 159
+ setrlimit = 160
+ chroot = 161
+ sync = 162
+ acct = 163
+ settimeofday = 164
+ mount = 165
+ umount2 = 166
+ swapon = 167
+ swapoff = 168
+ reboot = 169
+ sethostname = 170
+ setdomainname = 171
+ iopl = 172
+ ioperm = 173
+ create_module = 174
+ init_module = 175
+ delete_module = 176
+ get_kernel_syms = 177
+ query_module = 178
+ quotactl = 179
+ nfsservctl = 180
+ getpmsg = 181
+ putpmsg = 182
+ afs_syscall = 183
+ tuxcall = 184
+ security = 185
+ gettid = 186
+ readahead = 187
+ setxattr = 188
+ lsetxattr = 189
+ fsetxattr = 190
+ getxattr = 191
+ lgetxattr = 192
+ fgetxattr = 193
+ listxattr = 194
+ llistxattr = 195
+ flistxattr = 196
+ removexattr = 197
+ lremovexattr = 198
+ fremovexattr = 199
+ tkill = 200
+ time = 201
+ futex = 202
+ sched_setaffinity = 203
+ sched_getaffinity = 204
+ set_thread_area = 205
+ io_setup = 206
+ io_destroy = 207
+ io_getevents = 208
+ io_submit = 209
+ io_cancel = 210
+ get_thread_area = 211
+ lookup_dcookie = 212
+ epoll_create = 213
+ epoll_ctl_old = 214
+ epoll_wait_old = 215
+ remap_file_pages = 216
+ getdents64 = 217
+ set_tid_address = 218
+ restart_syscall = 219
+ semtimedop = 220
+ fadvise64 = 221
+ timer_create = 222
+ timer_settime = 223
+ timer_gettime = 224
+ timer_getoverrun = 225
+ timer_delete = 226
+ clock_settime = 227
+ clock_gettime = 228
+ clock_getres = 229
+ clock_nanosleep = 230
+ exit_group = 231
+ epoll_wait = 232
+ epoll_ctl = 233
+ tgkill = 234
+ utimes = 235
+ vserver = 236
+ mbind = 237
+ set_mempolicy = 238
+ get_mempolicy = 239
+ mq_open = 240
+ mq_unlink = 241
+ mq_timedsend = 242
+ mq_timedreceive = 243
+ mq_notify = 244
+ mq_getsetattr = 245
+ kexec_load = 246
+ waitid = 247
+ add_key = 248
+ request_key = 249
+ keyctl = 250
+ ioprio_set = 251
+ ioprio_get = 252
+ inotify_init = 253
+ inotify_add_watch = 254
+ inotify_rm_watch = 255
+ migrate_pages = 256
+ openat = 257
+ mkdirat = 258
+ mknodat = 259
+ fchownat = 260
+ futimesat = 261
+ newfstatat = 262
+ unlinkat = 263
+ renameat = 264
+ linkat = 265
+ symlinkat = 266
+ readlinkat = 267
+ fchmodat = 268
+ faccessat = 269
+ pselect6 = 270
+ ppoll = 271
+ unshare = 272
+ set_robust_list = 273
+ get_robust_list = 274
+ splice = 275
+ tee = 276
+ sync_file_range = 277
+ vmsplice = 278
+ move_pages = 279
+ utimensat = 280
+ epoll_pwait = 281
+ signalfd = 282
+ timerfd_create = 283
+ eventfd = 284
+ fallocate = 285
+ timerfd_settime = 286
+ timerfd_gettime = 287
+ accept4 = 288
+ signalfd4 = 289
+ eventfd2 = 290
+ epoll_create1 = 291
+ dup3 = 292
+ pipe2 = 293
+ inotify_init1 = 294
+ preadv = 295
+ pwritev = 296
+ rt_tgsigqueueinfo = 297
+ perf_event_open = 298
+ recvmmsg = 299
+ fanotify_init = 300
+ fanotify_mark = 301
+ prlimit64 = 302
+ name_to_handle_at = 303
+ open_by_handle_at = 304
+ clock_adjtime = 305
+ syncfs = 306
+ sendmmsg = 307
+ setns = 308
+ getcpu = 309
+ process_vm_readv = 310
+ process_vm_writev = 311
+ kcmp = 312
+ finit_module = 313
+ sched_setattr = 314
+ sched_getattr = 315
+ renameat2 = 316
+ seccomp = 317
+ getrandom = 318
+ memfd_create = 319
+ kexec_file_load = 320
+ bpf = 321
+ execveat = 322
+ userfaultfd = 323
+ membarrier = 324
+ mlock2 = 325
+ copy_file_range = 326
+ preadv2 = 327
+ pwritev2 = 328
+ pkey_mprotect = 329
+ pkey_alloc = 330
+ pkey_free = 331
+ statx = 332
diff --git a/qiling/os/macos/const.py b/qiling/os/macos/const.py
index 46c5b9a40..e3799f014 100644
--- a/qiling/os/macos/const.py
+++ b/qiling/os/macos/const.py
@@ -6,7 +6,7 @@
# basic values
PAGE_SIZE = 0x1000
VMMAP_PAGE_SIZE = 0x100000
-MAX_FD_SIZE = 0xFF
+MAX_FD_SIZE = 0xFF
MAX_PATH_SIZE = 0x800
# GS
@@ -76,61 +76,61 @@
# mach mag flags
MACH_MSG_SUCCESS = 0x00000000
-MACH_MSG_MASK = 0x00003e00
-MACH_MSG_IPC_SPACE = 0x00002000
-MACH_MSG_VM_SPACE = 0x00001000
-MACH_MSG_IPC_KERNEL = 0x00000800
-MACH_MSG_VM_KERNEL = 0x00000400
-MACH_SEND_IN_PROGRESS = 0x10000001
-MACH_SEND_INVALID_DATA = 0x10000002
-MACH_SEND_INVALID_DEST = 0x10000003
-MACH_SEND_TIMED_OUT = 0x10000004
-MACH_SEND_INVALID_VOUCHER = 0x10000005
-MACH_SEND_INTERRUPTED = 0x10000007
-MACH_SEND_MSG_TOO_SMALL = 0x10000008
-MACH_SEND_INVALID_REPLY = 0x10000009
-MACH_SEND_INVALID_RIGHT = 0x1000000a
-MACH_SEND_INVALID_NOTIFY = 0x1000000b
-MACH_SEND_INVALID_MEMORY = 0x1000000c
-MACH_SEND_NO_BUFFER = 0x1000000d
-MACH_SEND_TOO_LARGE = 0x1000000e
-MACH_SEND_INVALID_TYPE = 0x1000000f
-MACH_SEND_INVALID_HEADER = 0x10000010
-MACH_SEND_INVALID_TRAILER = 0x10000011
-MACH_SEND_INVALID_RT_OOL_SIZE = 0x10000015
-MACH_RCV_IN_PROGRESS = 0x10004001
-MACH_RCV_INVALID_NAME = 0x10004002
-MACH_RCV_TIMED_OUT = 0x10004003
-MACH_RCV_TOO_LARGE = 0x10004004
-MACH_RCV_INTERRUPTED = 0x10004005
-MACH_RCV_PORT_CHANGED = 0x10004006
-MACH_RCV_INVALID_NOTIFY = 0x10004007
-MACH_RCV_INVALID_DATA = 0x10004008
-MACH_RCV_PORT_DIED = 0x10004009
-MACH_RCV_IN_SET = 0x1000400a
-MACH_RCV_HEADER_ERROR = 0x1000400b
-MACH_RCV_BODY_ERROR = 0x1000400c
-MACH_RCV_INVALID_TYPE = 0x1000400d
-MACH_RCV_SCATTER_SMALL = 0x1000400e
-MACH_RCV_INVALID_TRAILER = 0x1000400f
+MACH_MSG_MASK = 0x00003e00
+MACH_MSG_IPC_SPACE = 0x00002000
+MACH_MSG_VM_SPACE = 0x00001000
+MACH_MSG_IPC_KERNEL = 0x00000800
+MACH_MSG_VM_KERNEL = 0x00000400
+MACH_SEND_IN_PROGRESS = 0x10000001
+MACH_SEND_INVALID_DATA = 0x10000002
+MACH_SEND_INVALID_DEST = 0x10000003
+MACH_SEND_TIMED_OUT = 0x10000004
+MACH_SEND_INVALID_VOUCHER = 0x10000005
+MACH_SEND_INTERRUPTED = 0x10000007
+MACH_SEND_MSG_TOO_SMALL = 0x10000008
+MACH_SEND_INVALID_REPLY = 0x10000009
+MACH_SEND_INVALID_RIGHT = 0x1000000a
+MACH_SEND_INVALID_NOTIFY = 0x1000000b
+MACH_SEND_INVALID_MEMORY = 0x1000000c
+MACH_SEND_NO_BUFFER = 0x1000000d
+MACH_SEND_TOO_LARGE = 0x1000000e
+MACH_SEND_INVALID_TYPE = 0x1000000f
+MACH_SEND_INVALID_HEADER = 0x10000010
+MACH_SEND_INVALID_TRAILER = 0x10000011
+MACH_SEND_INVALID_RT_OOL_SIZE = 0x10000015
+MACH_RCV_IN_PROGRESS = 0x10004001
+MACH_RCV_INVALID_NAME = 0x10004002
+MACH_RCV_TIMED_OUT = 0x10004003
+MACH_RCV_TOO_LARGE = 0x10004004
+MACH_RCV_INTERRUPTED = 0x10004005
+MACH_RCV_PORT_CHANGED = 0x10004006
+MACH_RCV_INVALID_NOTIFY = 0x10004007
+MACH_RCV_INVALID_DATA = 0x10004008
+MACH_RCV_PORT_DIED = 0x10004009
+MACH_RCV_IN_SET = 0x1000400a
+MACH_RCV_HEADER_ERROR = 0x1000400b
+MACH_RCV_BODY_ERROR = 0x1000400c
+MACH_RCV_INVALID_TYPE = 0x1000400d
+MACH_RCV_SCATTER_SMALL = 0x1000400e
+MACH_RCV_INVALID_TRAILER = 0x1000400f
MACH_RCV_IN_PROGRESS_TIMED = 0x10004011
# CS opetions
-CS_OPS_STATUS = 0
-CS_OPS_MARKINVALID = 1
-CS_OPS_MARKHARD = 2
-CS_OPS_MARKKILL = 3
-CS_OPS_CDHASH = 5
-CS_OPS_PIDOFFSET = 6
+CS_OPS_STATUS = 0
+CS_OPS_MARKINVALID = 1
+CS_OPS_MARKHARD = 2
+CS_OPS_MARKKILL = 3
+CS_OPS_CDHASH = 5
+CS_OPS_PIDOFFSET = 6
CS_OPS_ENTITLEMENTS_BLOB = 7
-CS_OPS_MARKRESTRICT = 8
-CS_OPS_SET_STATUS = 9
-CS_OPS_BLOB = 10
-CS_OPS_IDENTITY = 11
-CS_OPS_CLEARINSTALLER = 12
+CS_OPS_MARKRESTRICT = 8
+CS_OPS_SET_STATUS = 9
+CS_OPS_BLOB = 10
+CS_OPS_IDENTITY = 11
+CS_OPS_CLEARINSTALLER = 12
CS_OPS_CLEARPLATFORM = 13
CS_OPS_TEAMID = 14
-CS_MAX_TEAMID_LEN = 64
+CS_MAX_TEAMID_LEN = 64
# code signing attributes of a proc
CS_VALID = 0x00000001
@@ -164,7 +164,7 @@
CS_ENTITLEMENT_FLAGS = (CS_GET_TASK_ALLOW | CS_INSTALLER | CS_DATAVAULT_CONTROLLER | CS_NVRAM_UNRESTRICTED)
# executeable segment flags
-CS_EXECSEG_MAIN_BINARY = 0x1
+CS_EXECSEG_MAIN_BINARY = 0x1
CS_EXECSEG_ALLOW_UNSIGNED =0x10
CS_EXECSEG_DEBUGGER = 0x20
CS_EXECSEG_JIT = 0x40
@@ -189,7 +189,7 @@
MACH_SEND_IMPORTANCE = 0x00080000
MACH_SEND_SYNC_OVERRIDE = 0x00100000
MACH_SEND_PROPAGATE_QOS = 0x00200000
-MACH_SEND_SYNC_USE_THRPRI = MACH_SEND_PROPAGATE_QOS
+MACH_SEND_SYNC_USE_THRPRI = MACH_SEND_PROPAGATE_QOS
MACH_SEND_KERNEL = 0x00400000
MACH_RCV_TIMEOUT = 0x00000100
MACH_RCV_NOTIFY = 0x00000200
@@ -325,10 +325,10 @@
# shared region
-SHARED_REGION_BASE_I386 = 0x90000000
+SHARED_REGION_BASE_I386 = 0x90000000
SHARED_REGION_SIZE_I386 = 0x20000000
-SHARED_REGION_NESTING_BASE_I386 = 0x90000000
-SHARED_REGION_NESTING_SIZE_I386 = 0x20000000
+SHARED_REGION_NESTING_BASE_I386 = 0x90000000
+SHARED_REGION_NESTING_SIZE_I386 = 0x20000000
SHARED_REGION_NESTING_MIN_I386 = 0x00200000
SHARED_REGION_NESTING_MAX_I386 = 0xFFE00000
SHARED_REGION_BASE_X86_64 = 0x00007FFF00000000
@@ -503,9 +503,9 @@
COMM_PAGE_UNUSED0 = 0x024 # 2 unused bytes, previouly reserved for expansion of cpu_capabilities */
COMM_PAGE_CACHE_LINESIZE = 0x026 # uint16_t cache line size */
-COMM_PAGE_SCHED_GEN = 0x028 # uint32_t scheduler generation number (count of pre-emptions) */
+COMM_PAGE_SCHED_GEN = 0x028 # uint32_t scheduler generation number (count of pre-emptions) */
COMM_PAGE_MEMORY_PRESSURE = 0x02c # uint32_t copy of vm_memory_pressure */
-COMM_PAGE_SPIN_COUNT = 0x030 # uint32_t max spin count for mutex's */
+COMM_PAGE_SPIN_COUNT = 0x030 # uint32_t max spin count for mutex's */
COMM_PAGE_ACTIVE_CPUS = 0x034 # uint8_t number of active CPUs (hw.activecpu) */
COMM_PAGE_PHYSICAL_CPUS = 0x035 # uint8_t number of physical CPUs (hw.physicalcpu_max) */
diff --git a/qiling/os/macos/events/macos.py b/qiling/os/macos/events/macos.py
index 83145f6c0..da863eaa9 100644
--- a/qiling/os/macos/events/macos.py
+++ b/qiling/os/macos/events/macos.py
@@ -582,30 +582,30 @@ def kauth_vnode(self, action, parent_dir):
# arguments passed to KAUTH_FILEOP_OPEN listeners
# arg0 is pointer to vnode (vnode *) for given user path.
-# arg1 is pointer to path (char *) passed in to open.
+# arg1 is pointer to path (char *) passed in to open.
# arguments passed to KAUTH_FILEOP_CLOSE listeners
# arg0 is pointer to vnode (vnode *) for file to be closed.
-# arg1 is pointer to path (char *) of file to be closed.
-# arg2 is close flags.
+# arg1 is pointer to path (char *) of file to be closed.
+# arg2 is close flags.
# arguments passed to KAUTH_FILEOP_WILL_RENAME listeners
-# arg0 is pointer to vnode (vnode *) of the file being renamed
-# arg1 is pointer to the "from" path (char *)
-# arg2 is pointer to the "to" path (char *)
+# arg0 is pointer to vnode (vnode *) of the file being renamed
+# arg1 is pointer to the "from" path (char *)
+# arg2 is pointer to the "to" path (char *)
# arguments passed to KAUTH_FILEOP_RENAME listeners
-# arg0 is pointer to "from" path (char *).
-# arg1 is pointer to "to" path (char *).
+# arg0 is pointer to "from" path (char *).
+# arg1 is pointer to "to" path (char *).
# arguments passed to KAUTH_FILEOP_EXCHANGE listeners
-# arg0 is pointer to file 1 path (char *).
-# arg1 is pointer to file 2 path (char *).
+# arg0 is pointer to file 1 path (char *).
+# arg1 is pointer to file 2 path (char *).
# arguments passed to KAUTH_FILEOP_LINK listeners
-# arg0 is pointer to path to file we are linking to (char *).
-# arg1 is pointer to path to the new link file (char *).
+# arg0 is pointer to path to file we are linking to (char *).
+# arg1 is pointer to path to the new link file (char *).
# arguments passed to KAUTH_FILEOP_EXEC listeners
-# arg0 is pointer to vnode (vnode *) for executable.
-# arg1 is pointer to path (char *) to executable.
+# arg0 is pointer to vnode (vnode *) for executable.
+# arg1 is pointer to path (char *) to executable.
# arguments passed to KAUTH_FILEOP_DELETE listeners
-# arg0 is pointer to vnode (vnode *) of file/dir that was deleted.
-# arg1 is pointer to path (char *) of file/dir that was deleted.
+# arg0 is pointer to vnode (vnode *) of file/dir that was deleted.
+# arg1 is pointer to path (char *) of file/dir that was deleted.
@init_ev_ctx
def kauth_fileop(self, action, params={}):
path = self.ql.os.heap.alloc(len(self.current_proc) + 1)
diff --git a/qiling/os/macos/events/macos_structs.py b/qiling/os/macos/events/macos_structs.py
index 77d7f529f..c56cbbbcb 100644
--- a/qiling/os/macos/events/macos_structs.py
+++ b/qiling/os/macos/events/macos_structs.py
@@ -62,16 +62,16 @@ class MacOSEventType(AutoNumberNormalEvent):
EV_IPF_DETACH = ()
# enum {
-# sock_evt_connecting = 1,
-# sock_evt_connected = 2,
-# sock_evt_disconnecting = 3,
-# sock_evt_disconnected = 4,
-# sock_evt_flush_read = 5,
-# sock_evt_shutdown = 6, /* param points to an integer specifying how (read, write, or both) see man 2 shutdown */
-# sock_evt_cantrecvmore = 7,
-# sock_evt_cantsendmore = 8,
-# sock_evt_closing = 9,
-# sock_evt_bound = 10
+# sock_evt_connecting = 1,
+# sock_evt_connected = 2,
+# sock_evt_disconnecting = 3,
+# sock_evt_disconnected = 4,
+# sock_evt_flush_read = 5,
+# sock_evt_shutdown = 6, /* param points to an integer specifying how (read, write, or both) see man 2 shutdown */
+# sock_evt_cantrecvmore = 7,
+# sock_evt_cantsendmore = 8,
+# sock_evt_closing = 9,
+# sock_evt_bound = 10
# };
base_event_socket = 0x1000
@@ -131,7 +131,7 @@ class NetworkProtocol(enum.Enum):
IPPROTO_IL = 40
IPPROTO_IPV6 = 41
IPPROTO_SDRP = 42
- IPPROTO_ROUTING = 43
+ IPPROTO_ROUTING = 43
IPPROTO_FRAGMENT = 44
IPPROTO_IDRP = 45
IPPROTO_RSVP = 46
@@ -214,18 +214,18 @@ class Kauth(enum.Enum):
KAUTH_FILEOP_WILL_RENAME = 8
# struct sysctl_oid {
-# struct sysctl_oid_list *oid_parent;
-# SLIST_ENTRY(sysctl_oid) oid_link;
-# int oid_number;
-# int oid_kind;
-# void *oid_arg1;
-# int oid_arg2;
-# const char *oid_name;
-# int (*oid_handler) SYSCTL_HANDLER_ARGS;
-# const char *oid_fmt;
-# const char *oid_descr; /* offsetof() field / long description */
-# int oid_version;
-# int oid_refcnt;
+# struct sysctl_oid_list *oid_parent;
+# SLIST_ENTRY(sysctl_oid) oid_link;
+# int oid_number;
+# int oid_kind;
+# void *oid_arg1;
+# int oid_arg2;
+# const char *oid_name;
+# int (*oid_handler) SYSCTL_HANDLER_ARGS;
+# const char *oid_fmt;
+# const char *oid_descr; /* offsetof() field / long description */
+# int oid_version;
+# int oid_refcnt;
# };
class sysctl_oid_t(ctypes.Structure):
@@ -274,11 +274,11 @@ def dump(self):
class sysctl_args_t(ctypes.Structure):
_fields_ = (
("name", ctypes.c_int32 * 2),
- ("namelen", ctypes.c_uint32),
- ("old", POINTER64),
- ("oldlenp", POINTER64),
- ("new", POINTER64),
- ("newlen", ctypes.c_uint64),
+ ("namelen", ctypes.c_uint32),
+ ("old", POINTER64),
+ ("oldlenp", POINTER64),
+ ("new", POINTER64),
+ ("newlen", ctypes.c_uint64),
)
def __init__(self, ql, base):
@@ -296,12 +296,12 @@ def loadFromMem(self):
return newObj
# struct sysctlbyname_args {
-# const char * name
-# size_t namelen
-# void * old
-# size_t * oldlenp
-# void * new
-# size_t newlen
+# const char * name
+# size_t namelen
+# void * old
+# size_t * oldlenp
+# void * new
+# size_t newlen
# }
class sysctlbyname_args_t(ctypes.Structure):
@@ -329,16 +329,16 @@ def loadFromMem(self):
return newObj
# struct sysctl_req {
-# struct proc *p;
-# int lock;
-# user_addr_t oldptr; /* pointer to user supplied buffer */
-# size_t oldlen; /* user buffer length (also returned) */
-# size_t oldidx; /* total data iteratively copied out */
-# int (*oldfunc)(struct sysctl_req *, const void *, size_t);
-# user_addr_t newptr; /* buffer containing new value */
-# size_t newlen; /* length of new value */
-# size_t newidx; /* total data iteratively copied in */
-# int (*newfunc)(struct sysctl_req *, void *, size_t);
+# struct proc *p;
+# int lock;
+# user_addr_t oldptr; /* pointer to user supplied buffer */
+# size_t oldlen; /* user buffer length (also returned) */
+# size_t oldidx; /* total data iteratively copied out */
+# int (*oldfunc)(struct sysctl_req *, const void *, size_t);
+# user_addr_t newptr; /* buffer containing new value */
+# size_t newlen; /* length of new value */
+# size_t newidx; /* total data iteratively copied in */
+# int (*newfunc)(struct sysctl_req *, void *, size_t);
# };
class sysctl_req_t(ctypes.Structure):
@@ -371,26 +371,26 @@ def loadFromMem(self):
# struct kern_ctl_reg
# {
-# /* control information */
-# char ctl_name[MAX_KCTL_NAME];
-# u_int32_t ctl_id;
-# u_int32_t ctl_unit;
+# /* control information */
+# char ctl_name[MAX_KCTL_NAME];
+# u_int32_t ctl_id;
+# u_int32_t ctl_unit;
#
# /* control settings */
-# u_int32_t ctl_flags;
-# u_int32_t ctl_sendsize;
-# u_int32_t ctl_recvsize;
+# u_int32_t ctl_flags;
+# u_int32_t ctl_sendsize;
+# u_int32_t ctl_recvsize;
#
# /* Dispatch functions */
-# ctl_connect_func ctl_connect;
-# ctl_disconnect_func ctl_disconnect;
-# ctl_send_func ctl_send;
-# ctl_setopt_func ctl_setopt;
-# ctl_getopt_func ctl_getopt;
+# ctl_connect_func ctl_connect;
+# ctl_disconnect_func ctl_disconnect;
+# ctl_send_func ctl_send;
+# ctl_setopt_func ctl_setopt;
+# ctl_getopt_func ctl_getopt;
# #ifdef KERNEL_PRIVATE
-# ctl_rcvd_func ctl_rcvd; /* Only valid if CTL_FLAG_REG_EXTENDED is set */
-# ctl_send_list_func ctl_send_list; /* Only valid if CTL_FLAG_REG_EXTENDED is set */
-# ctl_bind_func ctl_bind;
+# ctl_rcvd_func ctl_rcvd; /* Only valid if CTL_FLAG_REG_EXTENDED is set */
+# ctl_send_list_func ctl_send_list; /* Only valid if CTL_FLAG_REG_EXTENDED is set */
+# ctl_bind_func ctl_bind;
# #endif /* KERNEL_PRIVATE */
# };
@@ -437,12 +437,12 @@ def dump(self):
# struct sockaddr_ctl {
-# u_char sc_len; /* depends on size of bundle ID string */
-# u_char sc_family; /* AF_SYSTEM */
-# u_int16_t ss_sysaddr; /* AF_SYS_KERNCONTROL */
-# u_int32_t sc_id; /* Controller unique identifier */
-# u_int32_t sc_unit; /* Developer private unit number */
-# u_int32_t sc_reserved[5];
+# u_char sc_len; /* depends on size of bundle ID string */
+# u_char sc_family; /* AF_SYSTEM */
+# u_int16_t ss_sysaddr; /* AF_SYS_KERNCONTROL */
+# u_int32_t sc_id; /* Controller unique identifier */
+# u_int32_t sc_unit; /* Developer private unit number */
+# u_int32_t sc_reserved[5];
# };
class sockaddr_ctl_t(ctypes.Structure):
@@ -470,12 +470,12 @@ def loadFromMem(self):
return newObj
# struct m_hdr {
-# struct mbuf *mh_next; /* next buffer in chain */
-# struct mbuf *mh_nextpkt; /* next chain in queue/record */
-# caddr_t mh_data; /* location of data */
-# int32_t mh_len; /* amount of data in this mbuf */
-# u_int16_t mh_type; /* type of data in this mbuf */
-# u_int16_t mh_flags; /* flags; see below */
+# struct mbuf *mh_next; /* next buffer in chain */
+# struct mbuf *mh_nextpkt; /* next chain in queue/record */
+# caddr_t mh_data; /* location of data */
+# int32_t mh_len; /* amount of data in this mbuf */
+# u_int16_t mh_type; /* type of data in this mbuf */
+# u_int16_t mh_flags; /* flags; see below */
# }
class m_hdr_t(ctypes.Structure):
@@ -496,18 +496,18 @@ class tag_t(ctypes.Structure):
# struct tcp_pktinfo {
# union {
# struct {
-# u_int32_t segsz; /* segment size (actual MSS) */
-# u_int32_t start_seq; /* start seq of this packet */
+# u_int32_t segsz; /* segment size (actual MSS) */
+# u_int32_t start_seq; /* start seq of this packet */
# } __tx;
# struct {
-# u_int16_t lro_pktlen; /* max seg size encountered */
-# u_int8_t lro_npkts; /* # of coalesced TCP pkts */
-# u_int8_t lro_timediff; /* time spent in LRO */
+# u_int16_t lro_pktlen; /* max seg size encountered */
+# u_int8_t lro_npkts; /* # of coalesced TCP pkts */
+# u_int8_t lro_timediff; /* time spent in LRO */
# } __rx;
# } __offload;
# union {
-# u_int32_t pri; /* send msg priority */
-# u_int32_t seq; /* recv msg sequence # */
+# u_int32_t pri; /* send msg priority */
+# u_int32_t seq; /* recv msg sequence # */
# } __msgattr;
# };
class tcp_pktinfo_t(ctypes.Structure):
@@ -538,10 +538,10 @@ class __msgattr_u(ctypes.Union):
)
# struct mptcp_pktinfo {
-# u_int64_t mtpi_dsn; /* MPTCP Data Sequence Number */
-# u_int32_t mtpi_rel_seq; /* Relative Seq Number */
-# u_int16_t mtpi_length; /* Length of mapping */
-# u_int16_t mtpi_csum;
+# u_int64_t mtpi_dsn; /* MPTCP Data Sequence Number */
+# u_int32_t mtpi_rel_seq; /* Relative Seq Number */
+# u_int16_t mtpi_length; /* Length of mapping */
+# u_int16_t mtpi_csum;
# };
class mptcp_pktinfo_t(ctypes.Structure):
_fields_ = (
@@ -553,8 +553,8 @@ class mptcp_pktinfo_t(ctypes.Structure):
# struct tcp_mtag {
# union {
-# struct tcp_pktinfo tm_tcp; /* TCP and below */
-# struct mptcp_pktinfo tm_mptcp; /* MPTCP-TCP only */
+# struct tcp_pktinfo tm_tcp; /* TCP and below */
+# struct mptcp_pktinfo tm_mptcp; /* MPTCP-TCP only */
# };
# };
class tcp_mtag_t(ctypes.Structure):
@@ -570,7 +570,7 @@ class pktinfo_u(ctypes.Union):
# struct proto_mtag_ {
# union {
-# struct tcp_mtag tcp; /* TCP specific */
+# struct tcp_mtag tcp; /* TCP specific */
# } __pr_u;
# };
class proto_mtag__t(ctypes.Structure):
@@ -583,12 +583,12 @@ class __pr_u_u(ctypes.Union):
)
# struct pf_mtag {
-# u_int16_t pftag_flags; /* PF_TAG flags */
-# u_int16_t pftag_rtableid; /* alternate routing table id */
-# u_int16_t pftag_tag;
-# u_int16_t pftag_routed;
+# u_int16_t pftag_flags; /* PF_TAG flags */
+# u_int16_t pftag_rtableid; /* alternate routing table id */
+# u_int16_t pftag_tag;
+# u_int16_t pftag_routed;
# #if PF_ECN
-# void *pftag_hdr; /* saved hdr pos in mbuf, for ECN */
+# void *pftag_hdr; /* saved hdr pos in mbuf, for ECN */
# #endif /* PF_ECN */
# };
class pf_mtag_t(ctypes.Structure):
@@ -600,10 +600,10 @@ class pf_mtag_t(ctypes.Structure):
)
# struct necp_mtag_ {
-# u_int32_t necp_policy_id;
-# u_int32_t necp_last_interface_index;
-# u_int32_t necp_route_rule_id;
-# u_int32_t necp_app_id;
+# u_int32_t necp_policy_id;
+# u_int32_t necp_last_interface_index;
+# u_int32_t necp_route_rule_id;
+# u_int32_t necp_app_id;
# };
class necp_mtag__t(ctypes.Structure):
_fields_ = (
@@ -617,16 +617,16 @@ class necp_mtag__t(ctypes.Structure):
# struct {
# union {
-# u_int8_t __mpriv8[16];
-# u_int16_t __mpriv16[8];
+# u_int8_t __mpriv8[16];
+# u_int16_t __mpriv16[8];
# struct {
# union {
-# u_int8_t __val8[4];
-# u_int16_t __val16[2];
-# u_int32_t __val32;
+# u_int8_t __val8[4];
+# u_int16_t __val16[2];
+# u_int32_t __val32;
# } __mpriv32_u;
# } __mpriv32[4];
-# u_int64_t __mpriv64[2];
+# u_int64_t __mpriv64[2];
# } __mpriv_u;
# } pkt_mpriv __attribute__((aligned(4)));
class pkt_mpriv_t(ctypes.Structure):
@@ -650,63 +650,63 @@ class __mpriv32_u_u(ctypes.Union):
)
# struct pkthdr {
-# struct ifnet *rcvif; /* rcv interface */
-# void *pkt_hdr; /* pointer to packet header */
-# int32_t len; /* total packet length */
-# u_int32_t csum_flags; /* flags regarding checksum */
-# union {
-# struct {
-# u_int16_t val; /* checksum value */
-# u_int16_t start; /* checksum start offset */
-# } _csum_rx;
-# struct {
-# u_int16_t start; /* checksum start offset */
-# u_int16_t stuff; /* checksum stuff offset */
-# } _csum_tx;
-# u_int32_t csum_data; /* data field used by csum routines */
-# };
-# u_int16_t vlan_tag; /* VLAN tag, host byte order */
-# u_int8_t pkt_proto; /* IPPROTO value */
-# u_int8_t pkt_flowsrc; /* FLOWSRC values */
-# u_int32_t pkt_flowid; /* flow ID */
-# u_int32_t pkt_flags; /* PKTF flags (see below) */
-# u_int32_t pkt_svc; /* MBUF_SVC value */
+# struct ifnet *rcvif; /* rcv interface */
+# void *pkt_hdr; /* pointer to packet header */
+# int32_t len; /* total packet length */
+# u_int32_t csum_flags; /* flags regarding checksum */
+# union {
+# struct {
+# u_int16_t val; /* checksum value */
+# u_int16_t start; /* checksum start offset */
+# } _csum_rx;
+# struct {
+# u_int16_t start; /* checksum start offset */
+# u_int16_t stuff; /* checksum stuff offset */
+# } _csum_tx;
+# u_int32_t csum_data; /* data field used by csum routines */
+# };
+# u_int16_t vlan_tag; /* VLAN tag, host byte order */
+# u_int8_t pkt_proto; /* IPPROTO value */
+# u_int8_t pkt_flowsrc; /* FLOWSRC values */
+# u_int32_t pkt_flowid; /* flow ID */
+# u_int32_t pkt_flags; /* PKTF flags (see below) */
+# u_int32_t pkt_svc; /* MBUF_SVC value */
#
-# u_int32_t pkt_compl_context; /* Packet completion context */
+# u_int32_t pkt_compl_context; /* Packet completion context */
#
-# union {
-# struct {
-# u_int16_t src; /* ifindex of src addr i/f */
-# u_int16_t src_flags; /* src PKT_IFAIFF flags */
-# u_int16_t dst; /* ifindex of dst addr i/f */
-# u_int16_t dst_flags; /* dst PKT_IFAIFF flags */
-# } _pkt_iaif;
-# u_int64_t pkt_ifainfo; /* data field used by ifainfo */
-# struct {
-# u_int32_t if_data; /* bytes in interface queue */
-# u_int32_t sndbuf_data; /* bytes in socket buffer */
-# } _pkt_bsr; /* Buffer status report used by cellular interface */
-# };
-# u_int64_t pkt_timestamp; /* enqueue time */
+# union {
+# struct {
+# u_int16_t src; /* ifindex of src addr i/f */
+# u_int16_t src_flags; /* src PKT_IFAIFF flags */
+# u_int16_t dst; /* ifindex of dst addr i/f */
+# u_int16_t dst_flags; /* dst PKT_IFAIFF flags */
+# } _pkt_iaif;
+# u_int64_t pkt_ifainfo; /* data field used by ifainfo */
+# struct {
+# u_int32_t if_data; /* bytes in interface queue */
+# u_int32_t sndbuf_data; /* bytes in socket buffer */
+# } _pkt_bsr; /* Buffer status report used by cellular interface */
+# };
+# u_int64_t pkt_timestamp; /* enqueue time */
#
-# SLIST_HEAD(packet_tags, m_tag) tags; /* list of external tags */
-# union builtin_mtag builtin_mtag;
-# struct {
-# union {
-# u_int8_t __mpriv8[16];
-# u_int16_t __mpriv16[8];
-# struct {
-# union {
-# u_int8_t __val8[4];
-# u_int16_t __val16[2];
-# u_int32_t __val32;
-# } __mpriv32_u;
-# } __mpriv32[4];
-# u_int64_t __mpriv64[2];
-# } __mpriv_u;
-# } pkt_mpriv __attribute__((aligned(4)));
-# u_int32_t redzone; /* red zone */
-# u_int32_t pkt_compl_callbacks; /* Packet completion callbacks */
+# SLIST_HEAD(packet_tags, m_tag) tags; /* list of external tags */
+# union builtin_mtag builtin_mtag;
+# struct {
+# union {
+# u_int8_t __mpriv8[16];
+# u_int16_t __mpriv16[8];
+# struct {
+# union {
+# u_int8_t __val8[4];
+# u_int16_t __val16[2];
+# u_int32_t __val32;
+# } __mpriv32_u;
+# } __mpriv32[4];
+# u_int64_t __mpriv64[2];
+# } __mpriv_u;
+# } pkt_mpriv __attribute__((aligned(4)));
+# u_int32_t redzone; /* red zone */
+# u_int32_t pkt_compl_callbacks; /* Packet completion callbacks */
# };
class pkthdr_t(ctypes.Structure):
@@ -747,19 +747,19 @@ class _pkt_bsr_t(ctypes.Structure):
)
# union builtin_mtag {
-# struct {
-# struct proto_mtag_ _proto_mtag; /* built-in protocol-specific tag */
-# struct pf_mtag _pf_mtag; /* built-in PF tag */
-# struct necp_mtag_ _necp_mtag; /* built-in NECP tag */
-# } _net_mtag;
-# struct driver_mtag_ _drv_mtag;
+# struct {
+# struct proto_mtag_ _proto_mtag; /* built-in protocol-specific tag */
+# struct pf_mtag _pf_mtag; /* built-in PF tag */
+# struct necp_mtag_ _necp_mtag; /* built-in NECP tag */
+# } _net_mtag;
+# struct driver_mtag_ _drv_mtag;
# }
class builtin_mtag_u(ctypes.Union):
# struct driver_mtag_ {
-# uintptr_t _drv_tx_compl_arg;
-# uintptr_t _drv_tx_compl_data;
-# kern_return_t _drv_tx_status;
-# uint16_t _drv_flowid;
+# uintptr_t _drv_tx_compl_arg;
+# uintptr_t _drv_tx_compl_data;
+# kern_return_t _drv_tx_status;
+# uint16_t _drv_flowid;
# };
class driver_mtag__t(ctypes.Structure):
_fields_ = (
@@ -803,19 +803,19 @@ class _net_mtag_t(ctypes.Structure):
)
# struct m_ext {
-# caddr_t ext_buf; /* start of buffer */
-# m_ext_free_func_t ext_free; /* free routine if not the usual */
-# u_int ext_size; /* size of buffer, for ext_free */
-# caddr_t ext_arg; /* additional ext_free argument */
-# struct ext_ref {
-# struct mbuf *paired;
-# u_int16_t minref;
-# u_int16_t refcnt;
-# u_int16_t prefcnt;
-# u_int16_t flags;
-# u_int32_t priv;
-# uintptr_t ext_token;
-# } *ext_refflags;
+# caddr_t ext_buf; /* start of buffer */
+# m_ext_free_func_t ext_free; /* free routine if not the usual */
+# u_int ext_size; /* size of buffer, for ext_free */
+# caddr_t ext_arg; /* additional ext_free argument */
+# struct ext_ref {
+# struct mbuf *paired;
+# u_int16_t minref;
+# u_int16_t refcnt;
+# u_int16_t prefcnt;
+# u_int16_t flags;
+# u_int32_t priv;
+# uintptr_t ext_token;
+# } *ext_refflags;
# };
class ext_ref(ctypes.Structure):
_fields_ = (
@@ -837,23 +837,23 @@ class m_ext_t(ctypes.Structure):
)
# struct mbuf {
-# struct m_hdr m_hdr;
-# union {
-# struct {
-# struct pkthdr MH_pkthdr; /* M_PKTHDR set */
-# union {
-# struct m_ext MH_ext; /* M_EXT set */
-# char MH_databuf[_MHLEN];
-# } MH_dat;
-# } MH;
-# char M_databuf[_MLEN]; /* !M_PKTHDR, !M_EXT */
-# } M_dat;
+# struct m_hdr m_hdr;
+# union {
+# struct {
+# struct pkthdr MH_pkthdr; /* M_PKTHDR set */
+# union {
+# struct m_ext MH_ext; /* M_EXT set */
+# char MH_databuf[_MHLEN];
+# } MH_dat;
+# } MH;
+# char M_databuf[_MLEN]; /* !M_PKTHDR, !M_EXT */
+# } M_dat;
# };
-#define MSIZESHIFT 8 /* 256 */
-#define MSIZE (1 << MSIZESHIFT) /* size of an mbuf */
-#define _MLEN (MSIZE - sizeof(struct m_hdr)) /* normal data len */
-#define _MHLEN (_MLEN - sizeof(struct pkthdr)) /* data len w/pkthdr */
+#define MSIZESHIFT 8 /* 256 */
+#define MSIZE (1 << MSIZESHIFT) /* size of an mbuf */
+#define _MLEN (MSIZE - sizeof(struct m_hdr)) /* normal data len */
+#define _MHLEN (_MLEN - sizeof(struct pkthdr)) /* data len w/pkthdr */
MSIZESHIFT = 8
MSIZE = (1 << MSIZESHIFT)
@@ -897,12 +897,12 @@ def loadFromMem(self):
# enum sopt_dir { SOPT_GET, SOPT_SET };
# struct sockopt {
-# enum sopt_dir sopt_dir; /* is this a get or a set? */
-# int sopt_level; /* second arg of [gs]etsockopt */
-# int sopt_name; /* third arg of [gs]etsockopt */
-# void* sopt_val; /* fourth arg of [gs]etsockopt */
-# size_t sopt_valsize; /* (almost) fifth arg of [gs]etsockopt */
-# void *sopt_p; /* calling process or null if kernel */
+# enum sopt_dir sopt_dir; /* is this a get or a set? */
+# int sopt_level; /* second arg of [gs]etsockopt */
+# int sopt_name; /* third arg of [gs]etsockopt */
+# void* sopt_val; /* fourth arg of [gs]etsockopt */
+# size_t sopt_valsize; /* (almost) fifth arg of [gs]etsockopt */
+# void *sopt_p; /* calling process or null if kernel */
# };
class sockopt_t(ctypes.Structure):
@@ -930,36 +930,36 @@ def loadFromMem(self):
return newObj
# struct sflt_filter {
-# sflt_handle sf_handle;
-# int sf_flags;
-# char *sf_name;
+# sflt_handle sf_handle;
+# int sf_flags;
+# char *sf_name;
#
-# sf_unregistered_func sf_unregistered;
-# sf_attach_func sf_attach;
-# sf_detach_func sf_detach;
+# sf_unregistered_func sf_unregistered;
+# sf_attach_func sf_attach;
+# sf_detach_func sf_detach;
#
-# sf_notify_func sf_notify;
-# sf_getpeername_func sf_getpeername;
-# sf_getsockname_func sf_getsockname;
-# sf_data_in_func sf_data_in;
-# sf_data_out_func sf_data_out;
-# sf_connect_in_func sf_connect_in;
-# sf_connect_out_func sf_connect_out;
-# sf_bind_func sf_bind;
-# sf_setoption_func sf_setoption;
-# sf_getoption_func sf_getoption;
-# sf_listen_func sf_listen;
-# sf_ioctl_func sf_ioctl;
-# /*
-# * The following are valid only if SFLT_EXTENDED flag is set.
-# * Initialize sf_ext_len to sizeof sflt_filter_ext structure.
-# * Filters must also initialize reserved fields with zeroes.
-# */
-# struct sflt_filter_ext {
-# unsigned int sf_ext_len;
-# sf_accept_func sf_ext_accept;
-# void *sf_ext_rsvd[5]; /* Reserved */
-# } sf_ext;
+# sf_notify_func sf_notify;
+# sf_getpeername_func sf_getpeername;
+# sf_getsockname_func sf_getsockname;
+# sf_data_in_func sf_data_in;
+# sf_data_out_func sf_data_out;
+# sf_connect_in_func sf_connect_in;
+# sf_connect_out_func sf_connect_out;
+# sf_bind_func sf_bind;
+# sf_setoption_func sf_setoption;
+# sf_getoption_func sf_getoption;
+# sf_listen_func sf_listen;
+# sf_ioctl_func sf_ioctl;
+# /*
+# * The following are valid only if SFLT_EXTENDED flag is set.
+# * Initialize sf_ext_len to sizeof sflt_filter_ext structure.
+# * Filters must also initialize reserved fields with zeroes.
+# */
+# struct sflt_filter_ext {
+# unsigned int sf_ext_len;
+# sf_accept_func sf_ext_accept;
+# void *sf_ext_rsvd[5]; /* Reserved */
+# } sf_ext;
# };
class sflt_filter_t(ctypes.Structure):
@@ -1017,16 +1017,16 @@ def dump(self):
self.ql.log.info("%s: %s" % (field[0], getattr(self, field[0]).decode()))
# struct sockaddr_in {
-# __uint8_t sin_len;
-# sa_family_t sin_family;
-# in_port_t sin_port;
-# struct in_addr sin_addr;
-# char sin_zero[8];
+# __uint8_t sin_len;
+# sa_family_t sin_family;
+# in_port_t sin_port;
+# struct in_addr sin_addr;
+# char sin_zero[8];
# };
class sockaddr_in_t(ctypes.Structure):
# struct in_addr {
-# in_addr_t s_addr;
+# in_addr_t s_addr;
# };
class in_addr_t(ctypes.Structure):
_fields_ = (
@@ -1056,9 +1056,9 @@ def loadFromMem(self):
# #define ETHER_ADDR_LEN 6
# typedef struct ether_header {
-# u_char ether_dhost[ETHER_ADDR_LEN];
-# u_char ether_shost[ETHER_ADDR_LEN];
-# u_short ether_type;
+# u_char ether_dhost[ETHER_ADDR_LEN];
+# u_char ether_shost[ETHER_ADDR_LEN];
+# u_short ether_type;
# } ether_header_t;
class ether_header_t(ctypes.Structure):
_fields_ = (
@@ -1131,22 +1131,22 @@ def dump(self):
self.ql.log.info("%s: %s" % (field[0], getattr(self, field[0]).decode()))
# struct ucred {
-# TAILQ_ENTRY(ucred) cr_link; /* never modify this without KAUTH_CRED_HASH_LOCK */
-# u_long cr_ref; /* reference count */
-#
+# TAILQ_ENTRY(ucred) cr_link; /* never modify this without KAUTH_CRED_HASH_LOCK */
+# u_long cr_ref; /* reference count */
+#
# struct posix_cred {
-# uid_t cr_uid; /* effective user id */
-# uid_t cr_ruid; /* real user id */
-# uid_t cr_svuid; /* saved user id */
-# short cr_ngroups; /* number of groups in advisory list */
-# gid_t cr_groups[NGROUPS]; /* advisory group list */
-# gid_t cr_rgid; /* real group id */
-# gid_t cr_svgid; /* saved group id */
-# uid_t cr_gmuid; /* UID for group membership purposes */
-# int cr_flags; /* flags on credential */
+# uid_t cr_uid; /* effective user id */
+# uid_t cr_ruid; /* real user id */
+# uid_t cr_svuid; /* saved user id */
+# short cr_ngroups; /* number of groups in advisory list */
+# gid_t cr_groups[NGROUPS]; /* advisory group list */
+# gid_t cr_rgid; /* real group id */
+# gid_t cr_svgid; /* saved group id */
+# uid_t cr_gmuid; /* UID for group membership purposes */
+# int cr_flags; /* flags on credential */
# } cr_posix;
-# struct label *cr_label; /* MAC label */
-# struct au_session cr_audit; /* user auditing data */
+# struct label *cr_label; /* MAC label */
+# struct au_session cr_audit; /* user auditing data */
# };
class ucred_t(ctypes.Structure):
@@ -1195,11 +1195,11 @@ def loadFromMem(self):
return newObj
# struct label {
-# int l_flags;
+# int l_flags;
# union {
-# void *l_ptr;
-# long l_long;
-# } l_perpolicy[MAC_MAX_SLOTS];
+# void *l_ptr;
+# long l_long;
+# } l_perpolicy[MAC_MAX_SLOTS];
# };
class label_t(ctypes.Structure):
@@ -1228,48 +1228,48 @@ def loadFromMem(self):
return newObj
# struct vnode {
-# lck_mtx_t v_lock; /* vnode mutex */
-# TAILQ_ENTRY(vnode) v_freelist; /* vnode freelist */
-# TAILQ_ENTRY(vnode) v_mntvnodes; /* vnodes for mount point */
-# TAILQ_HEAD(, namecache) v_ncchildren; /* name cache entries that regard us as their parent */
-# LIST_HEAD(, namecache) v_nclinks; /* name cache entries that name this vnode */
-# vnode_t v_defer_reclaimlist; /* in case we have to defer the reclaim to avoid recursion */
-# uint32_t v_listflag; /* flags protected by the vnode_list_lock (see below) */
-# uint32_t v_flag; /* vnode flags (see below) */
-# uint16_t v_lflag; /* vnode local and named ref flags */
-# uint8_t v_iterblkflags; /* buf iterator flags */
-# uint8_t v_references; /* number of times io_count has been granted */
-# int32_t v_kusecount; /* count of in-kernel refs */
-# int32_t v_usecount; /* reference count of users */
-# int32_t v_iocount; /* iocounters */
-# void * v_owner; /* act that owns the vnode */
-# uint16_t v_type; /* vnode type */
-# uint16_t v_tag; /* type of underlying data */
-# uint32_t v_id; /* identity of vnode contents */
-# union {
-# struct mount *vu_mountedhere;/* ptr to mounted vfs (VDIR) */
-# struct socket *vu_socket; /* unix ipc (VSOCK) */
-# struct specinfo *vu_specinfo; /* device (VCHR, VBLK) */
-# struct fifoinfo *vu_fifoinfo; /* fifo (VFIFO) */
-# struct ubc_info *vu_ubcinfo; /* valid for (VREG) */
-# } v_un;
-# struct buflists v_cleanblkhd; /* clean blocklist head */
-# struct buflists v_dirtyblkhd; /* dirty blocklist head */
-# struct klist v_knotes; /* knotes attached to this vnode */
-# kauth_cred_t v_cred; /* last authorized credential */
-# kauth_action_t v_authorized_actions; /* current authorized actions for v_cred */
-# int v_cred_timestamp; /* determine if entry is stale for MNTK_AUTH_OPAQUE */
-# int v_nc_generation; /* changes when nodes are removed from the name cache */
-# int32_t v_numoutput; /* num of writes in progress */
-# int32_t v_writecount; /* reference count of writers */
-# const char *v_name; /* name component of the vnode */
-# vnode_t v_parent; /* pointer to parent vnode */
-# struct lockf *v_lockf; /* advisory lock list head */
-# int (**v_op)(void *); /* vnode operations vector */
-# mount_t v_mount; /* ptr to vfs we are in */
-# void * v_data; /* private data for fs */
-# struct label *v_label; /* MAC security label */
-# vnode_resolve_t v_resolve; /* trigger vnode resolve info (VDIR only) */
+# lck_mtx_t v_lock; /* vnode mutex */
+# TAILQ_ENTRY(vnode) v_freelist; /* vnode freelist */
+# TAILQ_ENTRY(vnode) v_mntvnodes; /* vnodes for mount point */
+# TAILQ_HEAD(, namecache) v_ncchildren; /* name cache entries that regard us as their parent */
+# LIST_HEAD(, namecache) v_nclinks; /* name cache entries that name this vnode */
+# vnode_t v_defer_reclaimlist; /* in case we have to defer the reclaim to avoid recursion */
+# uint32_t v_listflag; /* flags protected by the vnode_list_lock (see below) */
+# uint32_t v_flag; /* vnode flags (see below) */
+# uint16_t v_lflag; /* vnode local and named ref flags */
+# uint8_t v_iterblkflags; /* buf iterator flags */
+# uint8_t v_references; /* number of times io_count has been granted */
+# int32_t v_kusecount; /* count of in-kernel refs */
+# int32_t v_usecount; /* reference count of users */
+# int32_t v_iocount; /* iocounters */
+# void * v_owner; /* act that owns the vnode */
+# uint16_t v_type; /* vnode type */
+# uint16_t v_tag; /* type of underlying data */
+# uint32_t v_id; /* identity of vnode contents */
+# union {
+# struct mount *vu_mountedhere;/* ptr to mounted vfs (VDIR) */
+# struct socket *vu_socket; /* unix ipc (VSOCK) */
+# struct specinfo *vu_specinfo; /* device (VCHR, VBLK) */
+# struct fifoinfo *vu_fifoinfo; /* fifo (VFIFO) */
+# struct ubc_info *vu_ubcinfo; /* valid for (VREG) */
+# } v_un;
+# struct buflists v_cleanblkhd; /* clean blocklist head */
+# struct buflists v_dirtyblkhd; /* dirty blocklist head */
+# struct klist v_knotes; /* knotes attached to this vnode */
+# kauth_cred_t v_cred; /* last authorized credential */
+# kauth_action_t v_authorized_actions; /* current authorized actions for v_cred */
+# int v_cred_timestamp; /* determine if entry is stale for MNTK_AUTH_OPAQUE */
+# int v_nc_generation; /* changes when nodes are removed from the name cache */
+# int32_t v_numoutput; /* num of writes in progress */
+# int32_t v_writecount; /* reference count of writers */
+# const char *v_name; /* name component of the vnode */
+# vnode_t v_parent; /* pointer to parent vnode */
+# struct lockf *v_lockf; /* advisory lock list head */
+# int (**v_op)(void *); /* vnode operations vector */
+# mount_t v_mount; /* ptr to vfs we are in */
+# void * v_data; /* private data for fs */
+# struct label *v_label; /* MAC security label */
+# vnode_resolve_t v_resolve; /* trigger vnode resolve info (VDIR only) */
# };
class vnode_t(ctypes.Structure):
class tailq_entry(ctypes.Structure):
@@ -1352,32 +1352,32 @@ def loadFromMem(self):
return newObj
# struct fileglob {
-# LIST_ENTRY(fileglob) f_msglist;/* list of active files */
-# int32_t fg_flag; /* see fcntl.h */
-# int32_t fg_count; /* reference count */
-# int32_t fg_msgcount; /* references from message queue */
-# int32_t fg_lflags; /* file global flags */
-# kauth_cred_t fg_cred; /* credentials associated with descriptor */
-# const struct fileops {
-# file_type_t fo_type; /* descriptor type */
-# int (*fo_read) (struct fileproc *fp, struct uio *uio,
-# int flags, vfs_context_t ctx);
-# int (*fo_write) (struct fileproc *fp, struct uio *uio,
-# int flags, vfs_context_t ctx);
-# int (*fo_ioctl) (struct fileproc *fp, u_long com,
-# caddr_t data, vfs_context_t ctx);
-# int (*fo_select) (struct fileproc *fp, int which,
-# void *wql, vfs_context_t ctx);
-# int (*fo_close) (struct fileglob *fg, vfs_context_t ctx);
-# int (*fo_kqfilter) (struct fileproc *fp, struct knote *kn,
-# struct kevent_internal_s *kev, vfs_context_t ctx);
-# int (*fo_drain) (struct fileproc *fp, vfs_context_t ctx);
-# } *fg_ops;
-# off_t fg_offset;
-# void *fg_data; /* vnode or socket or SHM or semaphore */
-# void *fg_vn_data; /* Per fd vnode data, used for directories */
-# lck_mtx_t fg_lock;
-# struct label *fg_label; /* JMM - use the one in the cred? */
+# LIST_ENTRY(fileglob) f_msglist;/* list of active files */
+# int32_t fg_flag; /* see fcntl.h */
+# int32_t fg_count; /* reference count */
+# int32_t fg_msgcount; /* references from message queue */
+# int32_t fg_lflags; /* file global flags */
+# kauth_cred_t fg_cred; /* credentials associated with descriptor */
+# const struct fileops {
+# file_type_t fo_type; /* descriptor type */
+# int (*fo_read) (struct fileproc *fp, struct uio *uio,
+# int flags, vfs_context_t ctx);
+# int (*fo_write) (struct fileproc *fp, struct uio *uio,
+# int flags, vfs_context_t ctx);
+# int (*fo_ioctl) (struct fileproc *fp, u_long com,
+# caddr_t data, vfs_context_t ctx);
+# int (*fo_select) (struct fileproc *fp, int which,
+# void *wql, vfs_context_t ctx);
+# int (*fo_close) (struct fileglob *fg, vfs_context_t ctx);
+# int (*fo_kqfilter) (struct fileproc *fp, struct knote *kn,
+# struct kevent_internal_s *kev, vfs_context_t ctx);
+# int (*fo_drain) (struct fileproc *fp, vfs_context_t ctx);
+# } *fg_ops;
+# off_t fg_offset;
+# void *fg_data; /* vnode or socket or SHM or semaphore */
+# void *fg_vn_data; /* Per fd vnode data, used for directories */
+# lck_mtx_t fg_lock;
+# struct label *fg_label; /* JMM - use the one in the cred? */
# };
class fileglob_t(ctypes.Structure):
@@ -1459,11 +1459,11 @@ def loadFromMem(self):
return newObj
# struct ipf_filter {
-# void *cookie;
-# const char *name;
-# ipf_input_func ipf_input;
-# ipf_output_func ipf_output;
-# ipf_detach_func ipf_detach;
+# void *cookie;
+# const char *name;
+# ipf_input_func ipf_input;
+# ipf_output_func ipf_output;
+# ipf_detach_func ipf_detach;
# };
class ipf_filter_t(ctypes.Structure):
_fields_ = (
diff --git a/qiling/os/macos/mach_port.py b/qiling/os/macos/mach_port.py
index ac4dc9886..75790e238 100644
--- a/qiling/os/macos/mach_port.py
+++ b/qiling/os/macos/mach_port.py
@@ -11,12 +11,12 @@
# define in kernel osfmk/mach/message.h
# mach_msg_header_t:
-# mach_msg_bits_t msgh_bits; unsigned int
-# mach_msg_size_t msgh_size; 4 bytes
-# mach_port_t msgh_remote_port; 4 bytes
-# mach_port_t msgh_local_port; 4 bytes
-# mach_port_name_t msgh_voucher_port; 4 bytes
-# mach_msg_id_t msgh_id; 4 bytes
+# mach_msg_bits_t msgh_bits; unsigned int
+# mach_msg_size_t msgh_size; 4 bytes
+# mach_port_t msgh_remote_port; 4 bytes
+# mach_port_t msgh_local_port; 4 bytes
+# mach_port_name_t msgh_voucher_port; 4 bytes
+# mach_msg_id_t msgh_id; 4 bytes
class MachMsgHeader():
def __init__(self, ql):
@@ -136,13 +136,13 @@ def get_thread_port(self, MachoThread):
# XNU define struct :
# struct mach_msg_overwrite_trap_args {
-# PAD_ARG_(user_addr_t, msg); addr length
-# PAD_ARG_(mach_msg_option_t, option); int
-# PAD_ARG_(mach_msg_size_t, send_size); unsigned int
-# PAD_ARG_(mach_msg_size_t, rcv_size); unsigned int
-# PAD_ARG_(mach_port_name_t, rcv_name); unsigned int
-# PAD_ARG_(mach_msg_timeout_t, timeout); unsigned int
-# PAD_ARG_(mach_msg_priority_t, override); unsigned int
-# PAD_ARG_8
-# PAD_ARG_(user_addr_t, rcv_msg); /* Unused on mach_msg_trap */ addr length
+# PAD_ARG_(user_addr_t, msg); addr length
+# PAD_ARG_(mach_msg_option_t, option); int
+# PAD_ARG_(mach_msg_size_t, send_size); unsigned int
+# PAD_ARG_(mach_msg_size_t, rcv_size); unsigned int
+# PAD_ARG_(mach_port_name_t, rcv_name); unsigned int
+# PAD_ARG_(mach_msg_timeout_t, timeout); unsigned int
+# PAD_ARG_(mach_msg_priority_t, override); unsigned int
+# PAD_ARG_8
+# PAD_ARG_(user_addr_t, rcv_msg); /* Unused on mach_msg_trap */ addr length
# };
diff --git a/qiling/os/macos/syscall.py b/qiling/os/macos/syscall.py
index 96cc099f6..8e3c720d6 100644
--- a/qiling/os/macos/syscall.py
+++ b/qiling/os/macos/syscall.py
@@ -263,8 +263,8 @@ def ql_syscall_getattrlist(ql, path, alist, attributeBuffer, bufferSize, options
# 0xc2
# struct rlimit {
-# rlim_t rlim_cur; /* current (soft) limit */ uint64
-# rlim_t rlim_max; /* maximum value for rlim_cur */ uint64
+# rlim_t rlim_cur; /* current (soft) limit */ uint64
+# rlim_t rlim_max; /* maximum value for rlim_cur */ uint64
# };
def ql_syscall_getrlimit(ql, which, rlp, *args, **kw):
ql.log.debug("getrlimit(which:0x%x, rlp:0x%x)" % (which, rlp))
diff --git a/qiling/os/posix/const.py b/qiling/os/posix/const.py
index 49aa56cd5..632a95ffa 100644
--- a/qiling/os/posix/const.py
+++ b/qiling/os/posix/const.py
@@ -111,42 +111,42 @@
# https://github.com/torvalds/linux/blob/master/include/uapi/linux/tcp.h
linux_socket_tcp_options = {
- "TCP_NODELAY" : 0x1,
- "TCP_MAXSEG" : 0x2,
- "TCP_CORK" : 0x3,
- "TCP_KEEPIDLE" : 0x4,
- "TCP_KEEPINTVL" : 0x5,
- "TCP_KEEPCNT" : 0x6,
- "TCP_SYNCNT" : 0x7,
- "TCP_LINGER2" : 0x8,
- "TCP_DEFER_ACCEPT" : 0x9,
- "TCP_WINDOW_CLAMP" : 0xa,
- "TCP_INFO" : 0xb,
- "TCP_QUICKACK" : 0xc,
- "TCP_CONGESTION" : 0xd,
- "TCP_MD5SIG" : 0xe,
- "TCP_THIN_LINEAR_TIMEOUTS" : 0x10,
- "TCP_THIN_DUPACK" : 0x11,
- "TCP_USER_TIMEOUT" : 0x12,
- "TCP_REPAIR" : 0x13,
- "TCP_REPAIR_QUEUE" : 0x14,
- "TCP_QUEUE_SEQ" : 0x15,
- "TCP_REPAIR_OPTIONS" : 0x16,
- "TCP_FASTOPEN" : 0x17,
- "TCP_TIMESTAMP" : 0x18,
- "TCP_NOTSENT_LOWAT" : 0x19,
- "TCP_CC_INFO" : 0x1a,
- "TCP_SAVE_SYN" : 0x1b,
- "TCP_SAVED_SYN" : 0x1c,
- "TCP_REPAIR_WINDOW" : 0x1d,
- "TCP_FASTOPEN_CONNECT" : 0x1e,
- "TCP_ULP" : 0x1f,
- "TCP_MD5SIG_EXT" : 0x20,
- "TCP_FASTOPEN_KEY" : 0x21,
- "TCP_FASTOPEN_NO_COOKIE" : 0x22,
- "TCP_ZEROCOPY_RECEIVE" : 0x23,
- "TCP_INQ" : 0x24,
- "TCP_TX_DELAY" : 0x25,
+ "TCP_NODELAY" : 0x1,
+ "TCP_MAXSEG" : 0x2,
+ "TCP_CORK" : 0x3,
+ "TCP_KEEPIDLE" : 0x4,
+ "TCP_KEEPINTVL" : 0x5,
+ "TCP_KEEPCNT" : 0x6,
+ "TCP_SYNCNT" : 0x7,
+ "TCP_LINGER2" : 0x8,
+ "TCP_DEFER_ACCEPT" : 0x9,
+ "TCP_WINDOW_CLAMP" : 0xa,
+ "TCP_INFO" : 0xb,
+ "TCP_QUICKACK" : 0xc,
+ "TCP_CONGESTION" : 0xd,
+ "TCP_MD5SIG" : 0xe,
+ "TCP_THIN_LINEAR_TIMEOUTS" : 0x10,
+ "TCP_THIN_DUPACK" : 0x11,
+ "TCP_USER_TIMEOUT" : 0x12,
+ "TCP_REPAIR" : 0x13,
+ "TCP_REPAIR_QUEUE" : 0x14,
+ "TCP_QUEUE_SEQ" : 0x15,
+ "TCP_REPAIR_OPTIONS" : 0x16,
+ "TCP_FASTOPEN" : 0x17,
+ "TCP_TIMESTAMP" : 0x18,
+ "TCP_NOTSENT_LOWAT" : 0x19,
+ "TCP_CC_INFO" : 0x1a,
+ "TCP_SAVE_SYN" : 0x1b,
+ "TCP_SAVED_SYN" : 0x1c,
+ "TCP_REPAIR_WINDOW" : 0x1d,
+ "TCP_FASTOPEN_CONNECT" : 0x1e,
+ "TCP_ULP" : 0x1f,
+ "TCP_MD5SIG_EXT" : 0x20,
+ "TCP_FASTOPEN_KEY" : 0x21,
+ "TCP_FASTOPEN_NO_COOKIE" : 0x22,
+ "TCP_ZEROCOPY_RECEIVE" : 0x23,
+ "TCP_INQ" : 0x24,
+ "TCP_TX_DELAY" : 0x25,
}
macos_socket_ip_options = {
@@ -723,14 +723,14 @@ class qnx_mmap_flags(Flag):
MAP_UNINITIALIZED = MAP_NOINIT
# fcntl flags
-F_DUPFD = 0
-F_GETFD = 1
-F_SETFD = 2
-F_GETFL = 3
-F_SETFL = 4
-F_GETLK = 5
-F_SETLK = 6
-F_SETLKW = 7
+F_DUPFD = 0
+F_GETFD = 1
+F_SETFD = 2
+F_GETFL = 3
+F_SETFL = 4
+F_GETLK = 5
+F_SETLK = 6
+F_SETLKW = 7
FD_CLOEXEC = 1
diff --git a/qiling/os/posix/posix.py b/qiling/os/posix/posix.py
index b67e409fe..a4f88f052 100644
--- a/qiling/os/posix/posix.py
+++ b/qiling/os/posix/posix.py
@@ -269,14 +269,14 @@ def __get_os_module(osname: str):
params = [self.__syscall_cc.getRawParam(i) for i in range(len(param_names))]
try:
- # if set, fire up the on-enter hook and let it override original args set
+ # if set, fire up the on-enter hook and let it override original args set
if onenter_hook:
overrides = onenter_hook(self.ql, *params)
if overrides is not None:
_, params = overrides
- # perform syscall
+ # perform syscall
retval = syscall_hook(self.ql, *params)
# if set, fire up the on-exit hook and let it override the return value
diff --git a/qiling/os/posix/syscall/ioctl.py b/qiling/os/posix/syscall/ioctl.py
index 4b1b988da..d87a8e2fd 100644
--- a/qiling/os/posix/syscall/ioctl.py
+++ b/qiling/os/posix/syscall/ioctl.py
@@ -61,10 +61,10 @@ def ioctl(_fd: int, _cmd: int, _arg: int):
elif _cmd == TIOCGWINSZ:
# struct winsize
# {
- # unsigned short ws_row; /* rows, in characters */
- # unsigned short ws_col; /* columns, in characters */
- # unsigned short ws_xpixel; /* horizontal size, pixels */
- # unsigned short ws_ypixel; /* vertical size, pixels */
+ # unsigned short ws_row; /* rows, in characters */
+ # unsigned short ws_col; /* columns, in characters */
+ # unsigned short ws_xpixel; /* horizontal size, pixels */
+ # unsigned short ws_ypixel; /* vertical size, pixels */
# };
return 1000, 360, 1000, 1000
diff --git a/qiling/os/posix/syscall/stat.py b/qiling/os/posix/syscall/stat.py
index efc809119..0a6da9e4f 100644
--- a/qiling/os/posix/syscall/stat.py
+++ b/qiling/os/posix/syscall/stat.py
@@ -17,42 +17,42 @@
# /sys/sys/stat.h
# struct stat {
-# dev_t st_dev; /* inode's device */ uint64_t
-# ino_t st_ino; /* inode's number */ uint64_t
-# nlink_t st_nlink; /* number of hard links */ uint64_t
-# mode_t st_mode; /* inode protection mode */ uint16_t
-# __int16_t st_padding0; int16_t
-# uid_t st_uid; /* user ID of the file's owner */ uint32_t
-# gid_t st_gid; /* group ID of the file's group */ uint32_t
-# __int32_t st_padding1; int32_t
-# dev_t st_rdev; /* device type */ uint64_t
-# #ifdef __STAT_TIME_T_EXT
-# __int32_t st_atim_ext;
+# dev_t st_dev; /* inode's device */ uint64_t
+# ino_t st_ino; /* inode's number */ uint64_t
+# nlink_t st_nlink; /* number of hard links */ uint64_t
+# mode_t st_mode; /* inode protection mode */ uint16_t
+# __int16_t st_padding0; int16_t
+# uid_t st_uid; /* user ID of the file's owner */ uint32_t
+# gid_t st_gid; /* group ID of the file's group */ uint32_t
+# __int32_t st_padding1; int32_t
+# dev_t st_rdev; /* device type */ uint64_t
+# #ifdef __STAT_TIME_T_EXT
+# __int32_t st_atim_ext;
# #endif
-# struct timespec st_atim; /* time of last access */ uint64_t * 2
-# #ifdef __STAT_TIME_T_EXT
-# __int32_t st_mtim_ext;
+# struct timespec st_atim; /* time of last access */ uint64_t * 2
+# #ifdef __STAT_TIME_T_EXT
+# __int32_t st_mtim_ext;
# #endif
-# struct timespec st_mtim; /* time of last data modification */ uint64_t * 2
-# #ifdef __STAT_TIME_T_EXT
-# __int32_t st_ctim_ext;
+# struct timespec st_mtim; /* time of last data modification */ uint64_t * 2
+# #ifdef __STAT_TIME_T_EXT
+# __int32_t st_ctim_ext;
# #endif
-# struct timespec st_ctim; /* time of last file status change */ uint64_t * 2
-# #ifdef __STAT_TIME_T_EXT
-# __int32_t st_btim_ext;
+# struct timespec st_ctim; /* time of last file status change */ uint64_t * 2
+# #ifdef __STAT_TIME_T_EXT
+# __int32_t st_btim_ext;
# #endif
-# struct timespec st_birthtim; /* time of file creation */ uint64_t * 2
-# off_t st_size; /* file size, in bytes */ int64_t
-# blkcnt_t st_blocks; /* blocks allocated for file */ int64_t
-# blksize_t st_blksize; /* optimal blocksize for I/O */ int32_t
-# fflags_t st_flags; /* user defined flags for file */ uint32_t
-# __uint64_t st_gen; /* file generation number */ uint64_t
-# __uint64_t st_spare[10]; uint64_t * 10
+# struct timespec st_birthtim; /* time of file creation */ uint64_t * 2
+# off_t st_size; /* file size, in bytes */ int64_t
+# blkcnt_t st_blocks; /* blocks allocated for file */ int64_t
+# blksize_t st_blksize; /* optimal blocksize for I/O */ int32_t
+# fflags_t st_flags; /* user defined flags for file */ uint32_t
+# __uint64_t st_gen; /* file generation number */ uint64_t
+# __uint64_t st_spare[10]; uint64_t * 10
# };
#
# struct timespec {
-# time_t tv_sec; /* seconds */ uint64_t
-# long tv_nsec; /* and nanoseconds */ uint64_t (LP64 data model)
+# time_t tv_sec; /* seconds */ uint64_t
+# long tv_nsec; /* and nanoseconds */ uint64_t (LP64 data model)
# };
#
#
@@ -130,21 +130,21 @@ class FreeBSDX8664Stat(ctypes.Structure):
# struct timespec st_birthtimespec; /* time of file creation(birth) */
#
# #define __DARWIN_STRUCT_STAT64 { \
-# dev_t st_dev; /* [XSI] ID of device containing file */ \ int32_t
-# mode_t st_mode; /* [XSI] Mode of file (see below) */ \ uint16_t
-# nlink_t st_nlink; /* [XSI] Number of hard links */ \ uint16_t
-# __darwin_ino64_t st_ino; /* [XSI] File serial number */ \ uint64_t
-# uid_t st_uid; /* [XSI] User ID of the file */ \ uint32_t
-# gid_t st_gid; /* [XSI] Group ID of the file */ \ uint32_t
-# dev_t st_rdev; /* [XSI] Device ID */ \ int32_t
-# __DARWIN_STRUCT_STAT64_TIMES \ uint64_t (long) * 8
-# off_t st_size; /* [XSI] file size, in bytes */ \ int64_t
-# blkcnt_t st_blocks; /* [XSI] blocks allocated for file */ \ int64_t
-# blksize_t st_blksize; /* [XSI] optimal blocksize for I/O */ \ int32_t
-# __uint32_t st_flags; /* user defined flags for file */ \ uint32_t
-# __uint32_t st_gen; /* file generation number */ \ uint32_t
-# __int32_t st_lspare; /* RESERVED: DO NOT USE! */ \ int32_t
-# __int64_t st_qspare[2]; /* RESERVED: DO NOT USE! */ \ int64_t * 2
+# dev_t st_dev; /* [XSI] ID of device containing file */ \ int32_t
+# mode_t st_mode; /* [XSI] Mode of file (see below) */ \ uint16_t
+# nlink_t st_nlink; /* [XSI] Number of hard links */ \ uint16_t
+# __darwin_ino64_t st_ino; /* [XSI] File serial number */ \ uint64_t
+# uid_t st_uid; /* [XSI] User ID of the file */ \ uint32_t
+# gid_t st_gid; /* [XSI] Group ID of the file */ \ uint32_t
+# dev_t st_rdev; /* [XSI] Device ID */ \ int32_t
+# __DARWIN_STRUCT_STAT64_TIMES \ uint64_t (long) * 8
+# off_t st_size; /* [XSI] file size, in bytes */ \ int64_t
+# blkcnt_t st_blocks; /* [XSI] blocks allocated for file */ \ int64_t
+# blksize_t st_blksize; /* [XSI] optimal blocksize for I/O */ \ int32_t
+# __uint32_t st_flags; /* user defined flags for file */ \ uint32_t
+# __uint32_t st_gen; /* file generation number */ \ uint32_t
+# __int32_t st_lspare; /* RESERVED: DO NOT USE! */ \ int32_t
+# __int64_t st_qspare[2]; /* RESERVED: DO NOT USE! */ \ int64_t * 2
# }
# /*
# * [XSI] This structure is used as the second parameter to the fstat(),
@@ -188,84 +188,84 @@ class MacOSStat(ctypes.Structure):
#
# #if (_MIPS_SIM == _MIPS_SIM_ABI32) || (_MIPS_SIM == _MIPS_SIM_NABI32)
# struct stat {
-# unsigned st_dev; uint32_t
-# long st_pad1[3]; /* Reserved for network id */ int32_t
-# ino_t st_ino; uint32_t (unsinged long)
-# mode_t st_mode; uint32_t (unsinged int)
-# __u32 st_nlink; uint32_t
-# uid_t st_uid; uint32_t (unsigned int)
-# gid_t st_gid; uint32_t (unsigned int)
-# unsigned st_rdev; uint32_t
-# long st_pad2[2]; uint32_t * 2
-# long st_size; uint32_t
-# long st_pad3; uint32_t
-# /*
-# * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
-# * but we don't have it under Linux.
-# */
-# long st_atime; uint32_t
-# long st_atime_nsec; uint32_t
-# long st_mtime; uint32_t
-# long st_mtime_nsec; uint32_t
-# long st_ctime; uint32_t
-# long st_ctime_nsec; uint32_t
-# long st_blksize; uint32_t
-# long st_blocks; uint32_t
-# long st_pad4[14]; uint32_t * 4
+# unsigned st_dev; uint32_t
+# long st_pad1[3]; /* Reserved for network id */ int32_t
+# ino_t st_ino; uint32_t (unsinged long)
+# mode_t st_mode; uint32_t (unsinged int)
+# __u32 st_nlink; uint32_t
+# uid_t st_uid; uint32_t (unsigned int)
+# gid_t st_gid; uint32_t (unsigned int)
+# unsigned st_rdev; uint32_t
+# long st_pad2[2]; uint32_t * 2
+# long st_size; uint32_t
+# long st_pad3; uint32_t
+# /*
+# * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
+# * but we don't have it under Linux.
+# */
+# long st_atime; uint32_t
+# long st_atime_nsec; uint32_t
+# long st_mtime; uint32_t
+# long st_mtime_nsec; uint32_t
+# long st_ctime; uint32_t
+# long st_ctime_nsec; uint32_t
+# long st_blksize; uint32_t
+# long st_blocks; uint32_t
+# long st_pad4[14]; uint32_t * 4
# };
#
# struct stat64 {
-# unsigned long st_dev; uint32_t
-# unsigned long st_pad0[3]; /* Reserved for st_dev expansion */ uint32_t * 3
-# unsigned long long st_ino; uint64_t
-# mode_t st_mode; uint32_t
-# __u32 st_nlink; uint32_t
-# uid_t st_uid; uint32_t
-# gid_t st_gid; uint32_t
-# unsigned long st_rdev; uint32_t
-# unsigned long st_pad1[3]; /* Reserved for st_rdev expansion */ uint32_t * 3
-# long long st_size; uint64_t
-# /*
-# * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
-# * but we don't have it under Linux.
-# */
-# long st_atime; int32_t
-# unsigned long st_atime_nsec; /* Reserved for st_atime expansion */ uint32_t
-# long st_mtime; int32_t
-# unsigned long st_mtime_nsec; /* Reserved for st_mtime expansion */ uint32_t
-# long st_ctime; int32_t
-# unsigned long st_ctime_nsec; /* Reserved for st_ctime expansion */ uint32_t
-# unsigned long st_blksize; uint32_t
-# unsigned long st_pad2; uint32_t
-# long long st_blocks; int64_t
+# unsigned long st_dev; uint32_t
+# unsigned long st_pad0[3]; /* Reserved for st_dev expansion */ uint32_t * 3
+# unsigned long long st_ino; uint64_t
+# mode_t st_mode; uint32_t
+# __u32 st_nlink; uint32_t
+# uid_t st_uid; uint32_t
+# gid_t st_gid; uint32_t
+# unsigned long st_rdev; uint32_t
+# unsigned long st_pad1[3]; /* Reserved for st_rdev expansion */ uint32_t * 3
+# long long st_size; uint64_t
+# /*
+# * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
+# * but we don't have it under Linux.
+# */
+# long st_atime; int32_t
+# unsigned long st_atime_nsec; /* Reserved for st_atime expansion */ uint32_t
+# long st_mtime; int32_t
+# unsigned long st_mtime_nsec; /* Reserved for st_mtime expansion */ uint32_t
+# long st_ctime; int32_t
+# unsigned long st_ctime_nsec; /* Reserved for st_ctime expansion */ uint32_t
+# unsigned long st_blksize; uint32_t
+# unsigned long st_pad2; uint32_t
+# long long st_blocks; int64_t
# };
# #endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
# #if _MIPS_SIM == _MIPS_SIM_ABI64
# /* The memory layout is the same as of struct stat64 of the 32-bit kernel. */
# struct stat {
-# unsigned int st_dev; uint32_t
-# unsigned int st_pad0[3]; /* Reserved for st_dev expansion */ uint32_t * 3
-# unsigned long st_ino; uint64_t
-# mode_t st_mode; uint32_t
-# __u32 st_nlink; uint32_t
-# uid_t st_uid; uint32_t
-# gid_t st_gid; uint32_t
-# unsigned int st_rdev; uint32_t
-# unsigned int st_pad1[3]; /* Reserved for st_rdev expansion */ uint32_t * 3
-# long st_size; uint64_t
-# /*
-# * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
-# * but we don't have it under Linux.
-# */
-# unsigned int st_atime; uint32_t
-# unsigned int st_atime_nsec; uint32_t
-# unsigned int st_mtime; uint32_t
-# unsigned int st_mtime_nsec; uint32_t
-# unsigned int st_ctime; uint32_t
-# unsigned int st_ctime_nsec; uint32_t
-# unsigned int st_blksize; uint32_t
-# unsigned int st_pad2; uint32_t
-# unsigned long st_blocks; uint64_t
+# unsigned int st_dev; uint32_t
+# unsigned int st_pad0[3]; /* Reserved for st_dev expansion */ uint32_t * 3
+# unsigned long st_ino; uint64_t
+# mode_t st_mode; uint32_t
+# __u32 st_nlink; uint32_t
+# uid_t st_uid; uint32_t
+# gid_t st_gid; uint32_t
+# unsigned int st_rdev; uint32_t
+# unsigned int st_pad1[3]; /* Reserved for st_rdev expansion */ uint32_t * 3
+# long st_size; uint64_t
+# /*
+# * Actually this should be timestruc_t st_atime, st_mtime and st_ctime
+# * but we don't have it under Linux.
+# */
+# unsigned int st_atime; uint32_t
+# unsigned int st_atime_nsec; uint32_t
+# unsigned int st_mtime; uint32_t
+# unsigned int st_mtime_nsec; uint32_t
+# unsigned int st_ctime; uint32_t
+# unsigned int st_ctime_nsec; uint32_t
+# unsigned int st_blksize; uint32_t
+# unsigned int st_pad2; uint32_t
+# unsigned long st_blocks; uint64_t
# };
class LinuxMips32Stat(ctypes.Structure):
@@ -399,67 +399,67 @@ class LinuxMips32Stat64(ctypes.Structure):
#
# #ifdef __i386__
# struct stat {
-# unsigned long st_dev; uint32_t
-# unsigned long st_ino; uint32_t
-# unsigned short st_mode; uint16_t
-# unsigned short st_nlink; uint16_t
-# unsigned short st_uid; uint16_t
-# unsigned short st_gid; uint16_t
-# unsigned long st_rdev; uint32_t
-# unsigned long st_size; uint32_t
-# unsigned long st_blksize; uint32_t
-# unsigned long st_blocks; uint32_t
-# unsigned long st_atime; uint32_t
-# unsigned long st_atime_nsec; uint32_t
-# unsigned long st_mtime; uint32_t
-# unsigned long st_mtime_nsec; uint32_t
-# unsigned long st_ctime; uint32_t
-# unsigned long st_ctime_nsec; uint32_t
-# unsigned long __unused4; uint32_t
-# unsigned long __unused5; uint32_t
+# unsigned long st_dev; uint32_t
+# unsigned long st_ino; uint32_t
+# unsigned short st_mode; uint16_t
+# unsigned short st_nlink; uint16_t
+# unsigned short st_uid; uint16_t
+# unsigned short st_gid; uint16_t
+# unsigned long st_rdev; uint32_t
+# unsigned long st_size; uint32_t
+# unsigned long st_blksize; uint32_t
+# unsigned long st_blocks; uint32_t
+# unsigned long st_atime; uint32_t
+# unsigned long st_atime_nsec; uint32_t
+# unsigned long st_mtime; uint32_t
+# unsigned long st_mtime_nsec; uint32_t
+# unsigned long st_ctime; uint32_t
+# unsigned long st_ctime_nsec; uint32_t
+# unsigned long __unused4; uint32_t
+# unsigned long __unused5; uint32_t
# };
# struct stat64 {
-# unsigned long long st_dev; uint64_t
-# unsigned char __pad0[4]; uint8_t * 4
-# unsigned long __st_ino; uint32_t
-# unsigned int st_mode; uint32_t
-# unsigned int st_nlink; uint32_t
-# unsigned long st_uid; uint32_t
-# unsigned long st_gid; uint32_t
-# unsigned long long st_rdev; uint64_t
-# unsigned char __pad3[4]; uint8_t * 4
-# long long st_size; int64_t
-# unsigned long st_blksize; uint32_t
-# /* Number 512-byte blocks allocated. */
-# unsigned long long st_blocks; uint64_t
-# unsigned long st_atime; uint32_t
-# unsigned long st_atime_nsec; uint32_t
-# unsigned long st_mtime; uint32_t
-# unsigned int st_mtime_nsec; uint32_t
-# unsigned long st_ctime; uint32_t
-# unsigned long st_ctime_nsec; uint32_t
-# unsigned long long st_ino; uint64_t
+# unsigned long long st_dev; uint64_t
+# unsigned char __pad0[4]; uint8_t * 4
+# unsigned long __st_ino; uint32_t
+# unsigned int st_mode; uint32_t
+# unsigned int st_nlink; uint32_t
+# unsigned long st_uid; uint32_t
+# unsigned long st_gid; uint32_t
+# unsigned long long st_rdev; uint64_t
+# unsigned char __pad3[4]; uint8_t * 4
+# long long st_size; int64_t
+# unsigned long st_blksize; uint32_t
+# /* Number 512-byte blocks allocated. */
+# unsigned long long st_blocks; uint64_t
+# unsigned long st_atime; uint32_t
+# unsigned long st_atime_nsec; uint32_t
+# unsigned long st_mtime; uint32_t
+# unsigned int st_mtime_nsec; uint32_t
+# unsigned long st_ctime; uint32_t
+# unsigned long st_ctime_nsec; uint32_t
+# unsigned long long st_ino; uint64_t
# };
# #else /* __i386__ */
# struct stat {
-# __kernel_ulong_t st_dev; uint64_t
-# __kernel_ulong_t st_ino; uint64_t
-# __kernel_ulong_t st_nlink; uint64_t
-# unsigned int st_mode; uint32_t
-# unsigned int st_uid; uint32_t
-# unsigned int st_gid; uint32_t
-# unsigned int __pad0; uint32_t
-# __kernel_ulong_t st_rdev; uint64_t
-# __kernel_long_t st_size; int64_t
-# __kernel_long_t st_blksize; int64_t
-# __kernel_long_t st_blocks; /* Number 512-byte blocks allocated. */ int64_t
-# __kernel_ulong_t st_atime; uint64_t
-# __kernel_ulong_t st_atime_nsec; uint64_t
-# __kernel_ulong_t st_mtime; uint64_t
-# __kernel_ulong_t st_mtime_nsec; uint64_t
-# __kernel_ulong_t st_ctime; uint64_t
-# __kernel_ulong_t st_ctime_nsec; uint64_t
-# __kernel_long_t __unused[3]; int64_t
+# __kernel_ulong_t st_dev; uint64_t
+# __kernel_ulong_t st_ino; uint64_t
+# __kernel_ulong_t st_nlink; uint64_t
+# unsigned int st_mode; uint32_t
+# unsigned int st_uid; uint32_t
+# unsigned int st_gid; uint32_t
+# unsigned int __pad0; uint32_t
+# __kernel_ulong_t st_rdev; uint64_t
+# __kernel_long_t st_size; int64_t
+# __kernel_long_t st_blksize; int64_t
+# __kernel_long_t st_blocks; /* Number 512-byte blocks allocated. */ int64_t
+# __kernel_ulong_t st_atime; uint64_t
+# __kernel_ulong_t st_atime_nsec; uint64_t
+# __kernel_ulong_t st_mtime; uint64_t
+# __kernel_ulong_t st_mtime_nsec; uint64_t
+# __kernel_ulong_t st_ctime; uint64_t
+# __kernel_ulong_t st_ctime_nsec; uint64_t
+# __kernel_long_t __unused[3]; int64_t
# };
# #endif
@@ -540,82 +540,82 @@ class LinuxX86Stat64(ctypes.Structure):
#
# struct stat {
# #if defined(__ARMEB__)
-# unsigned short st_dev; uint16_t
-# unsigned short __pad1; uint16_t
+# unsigned short st_dev; uint16_t
+# unsigned short __pad1; uint16_t
# #else
-# unsigned long st_dev; uint32_t
+# unsigned long st_dev; uint32_t
# #endif
-# unsigned long st_ino; uint32_t
-# unsigned short st_mode; uint16_t
-# unsigned short st_nlink; uint16_t
-# unsigned short st_uid; uint16_t
-# unsigned short st_gid; uint16_t
+# unsigned long st_ino; uint32_t
+# unsigned short st_mode; uint16_t
+# unsigned short st_nlink; uint16_t
+# unsigned short st_uid; uint16_t
+# unsigned short st_gid; uint16_t
# #if defined(__ARMEB__)
-# unsigned short st_rdev; uint16_t
-# unsigned short __pad2; uint16_t
+# unsigned short st_rdev; uint16_t
+# unsigned short __pad2; uint16_t
# #else
-# unsigned long st_rdev; uint32_t
+# unsigned long st_rdev; uint32_t
# #endif
-# unsigned long st_size; uint32_t
-# unsigned long st_blksize; uint32_t
-# unsigned long st_blocks; uint32_t
-# unsigned long st_atime; uint32_t
-# unsigned long st_atime_nsec; uint32_t
-# unsigned long st_mtime; uint32_t
-# unsigned long st_mtime_nsec; uint32_t
-# unsigned long st_ctime; uint32_t
-# unsigned long st_ctime_nsec; uint32_t
-# unsigned long __unused4; uint32_t
-# unsigned long __unused5; uint32_t
+# unsigned long st_size; uint32_t
+# unsigned long st_blksize; uint32_t
+# unsigned long st_blocks; uint32_t
+# unsigned long st_atime; uint32_t
+# unsigned long st_atime_nsec; uint32_t
+# unsigned long st_mtime; uint32_t
+# unsigned long st_mtime_nsec; uint32_t
+# unsigned long st_ctime; uint32_t
+# unsigned long st_ctime_nsec; uint32_t
+# unsigned long __unused4; uint32_t
+# unsigned long __unused5; uint32_t
# };
# struct stat64 {
-# unsigned long long st_dev; uint64_t
-# unsigned char __pad0[4]; uint8_t * 4
-# #define STAT64_HAS_BROKEN_ST_INO 1
-# unsigned long __st_ino; uint32_t
-# unsigned int st_mode; uint32_t
-# unsigned int st_nlink; uint32_t
-# unsigned long st_uid; uint32_t
-# unsigned long st_gid; uint32_t
-# unsigned long long st_rdev; uint64_t
-# unsigned char __pad3[4]; uint8_t * 4
-# long long st_size; int64_t
-# unsigned long st_blksize; uint32_t
-# unsigned long long st_blocks; /* Number 512-byte blocks allocated. */ uint64_t
-# unsigned long st_atime; uint32_t
-# unsigned long st_atime_nsec; uint32_t
-# unsigned long st_mtime; uint32_t
-# unsigned long st_mtime_nsec; uint32_t
-# unsigned long st_ctime; uint32_t
-# unsigned long st_ctime_nsec; uint32_t
-# unsigned long long st_ino; uint64_t
+# unsigned long long st_dev; uint64_t
+# unsigned char __pad0[4]; uint8_t * 4
+# #define STAT64_HAS_BROKEN_ST_INO 1
+# unsigned long __st_ino; uint32_t
+# unsigned int st_mode; uint32_t
+# unsigned int st_nlink; uint32_t
+# unsigned long st_uid; uint32_t
+# unsigned long st_gid; uint32_t
+# unsigned long long st_rdev; uint64_t
+# unsigned char __pad3[4]; uint8_t * 4
+# long long st_size; int64_t
+# unsigned long st_blksize; uint32_t
+# unsigned long long st_blocks; /* Number 512-byte blocks allocated. */ uint64_t
+# unsigned long st_atime; uint32_t
+# unsigned long st_atime_nsec; uint32_t
+# unsigned long st_mtime; uint32_t
+# unsigned long st_mtime_nsec; uint32_t
+# unsigned long st_ctime; uint32_t
+# unsigned long st_ctime_nsec; uint32_t
+# unsigned long long st_ino; uint64_t
# };
# ARM64 stat is different!
# https://elixir.bootlin.com/linux/v4.20.17/source/arch/arm64/include/asm/stat.h
# The stat.h above includes https://elixir.bootlin.com/linux/v4.20.17/source/arch/arm64/include/uapi/asm/stat.h
# struct stat {
-# unsigned long st_dev; /* Device. */ uint64_t
-# unsigned long st_ino; /* File serial number. */ uint64_t
-# unsigned int st_mode; /* File mode. */ uint32_t
-# unsigned int st_nlink; /* Link count. */ uint32_t
-# unsigned int st_uid; /* User ID of the file's owner. */ uint32_t
-# unsigned int st_gid; /* Group ID of the file's group. */ uint32_t
-# unsigned long st_rdev; /* Device number, if device. */ uint64_t
-# unsigned long __pad1; uint64_t
-# long st_size; /* Size of file, in bytes. */ int64_t
-# int st_blksize; /* Optimal block size for I/O. */ int32_t
-# int __pad2; int32_t
-# long st_blocks; /* Number 512-byte blocks allocated. */ int64_t
-# long st_atime; /* Time of last access. */ int64_t
-# unsigned long st_atime_nsec; uint64_t
-# long st_mtime; /* Time of last modification. */ int64_t
-# unsigned long st_mtime_nsec; uint64_t
-# long st_ctime; /* Time of last status change. */ int64_t
-# unsigned long st_ctime_nsec; uint64_t
-# unsigned int __unused4; uint32_t
-# unsigned int __unused5; uint32_t
+# unsigned long st_dev; /* Device. */ uint64_t
+# unsigned long st_ino; /* File serial number. */ uint64_t
+# unsigned int st_mode; /* File mode. */ uint32_t
+# unsigned int st_nlink; /* Link count. */ uint32_t
+# unsigned int st_uid; /* User ID of the file's owner. */ uint32_t
+# unsigned int st_gid; /* Group ID of the file's group. */ uint32_t
+# unsigned long st_rdev; /* Device number, if device. */ uint64_t
+# unsigned long __pad1; uint64_t
+# long st_size; /* Size of file, in bytes. */ int64_t
+# int st_blksize; /* Optimal block size for I/O. */ int32_t
+# int __pad2; int32_t
+# long st_blocks; /* Number 512-byte blocks allocated. */ int64_t
+# long st_atime; /* Time of last access. */ int64_t
+# unsigned long st_atime_nsec; uint64_t
+# long st_mtime; /* Time of last modification. */ int64_t
+# unsigned long st_mtime_nsec; uint64_t
+# long st_ctime; /* Time of last status change. */ int64_t
+# unsigned long st_ctime_nsec; uint64_t
+# unsigned int __unused4; uint32_t
+# unsigned int __unused5; uint32_t
# };
class LinuxARMStat(ctypes.Structure):
@@ -771,26 +771,26 @@ class LinuxARM64EBStat(ctypes.BigEndianStructure):
# Srouce: https://github.com/riscv-collab/riscv-gnu-toolchain/blob/master/linux-headers/include/asm-generic/stat.h
# struct stat {
-# unsigned long st_dev; /* Device. */
-# unsigned long st_ino; /* File serial number. */
-# unsigned int st_mode; /* File mode. */
-# unsigned int st_nlink; /* Link count. */
-# unsigned int st_uid; /* User ID of the file's owner. */
-# unsigned int st_gid; /* Group ID of the file's group. */
-# unsigned long st_rdev; /* Device number, if device. */
-# unsigned long __pad1;
-# long st_size; /* Size of file, in bytes. */
-# int st_blksize; /* Optimal block size for I/O. */
-# int __pad2;
-# long st_blocks; /* Number 512-byte blocks allocated. */
-# long st_atime; /* Time of last access. */
-# unsigned long st_atime_nsec;
-# long st_mtime; /* Time of last modification. */
-# unsigned long st_mtime_nsec;
-# long st_ctime; /* Time of last status change. */
-# unsigned long st_ctime_nsec;
-# unsigned int __unused4;
-# unsigned int __unused5;
+# unsigned long st_dev; /* Device. */
+# unsigned long st_ino; /* File serial number. */
+# unsigned int st_mode; /* File mode. */
+# unsigned int st_nlink; /* Link count. */
+# unsigned int st_uid; /* User ID of the file's owner. */
+# unsigned int st_gid; /* Group ID of the file's group. */
+# unsigned long st_rdev; /* Device number, if device. */
+# unsigned long __pad1;
+# long st_size; /* Size of file, in bytes. */
+# int st_blksize; /* Optimal block size for I/O. */
+# int __pad2;
+# long st_blocks; /* Number 512-byte blocks allocated. */
+# long st_atime; /* Time of last access. */
+# unsigned long st_atime_nsec;
+# long st_mtime; /* Time of last modification. */
+# unsigned long st_mtime_nsec;
+# long st_ctime; /* Time of last status change. */
+# unsigned long st_ctime_nsec;
+# unsigned int __unused4;
+# unsigned int __unused5;
# };
class LinuxRISCVStat(ctypes.Structure):
@@ -821,31 +821,31 @@ class LinuxRISCVStat(ctypes.Structure):
# Srouce: https://elixir.bootlin.com/linux/latest/source/arch/powerpc/include/uapi/asm/stat.h#L30
# struct stat {
-# unsigned long st_dev;
-# ino_t st_ino;
+# unsigned long st_dev;
+# ino_t st_ino;
# #ifdef __powerpc64__
-# unsigned long st_nlink;
-# mode_t st_mode;
+# unsigned long st_nlink;
+# mode_t st_mode;
# #else
-# mode_t st_mode;
-# unsigned short st_nlink;
+# mode_t st_mode;
+# unsigned short st_nlink;
# #endif
-# uid_t st_uid;
-# gid_t st_gid;
-# unsigned long st_rdev;
-# long st_size;
-# unsigned long st_blksize;
-# unsigned long st_blocks;
-# unsigned long st_atime;
-# unsigned long st_atime_nsec;
-# unsigned long st_mtime;
-# unsigned long st_mtime_nsec;
-# unsigned long st_ctime;
-# unsigned long st_ctime_nsec;
-# unsigned long __unused4;
-# unsigned long __unused5;
+# uid_t st_uid;
+# gid_t st_gid;
+# unsigned long st_rdev;
+# long st_size;
+# unsigned long st_blksize;
+# unsigned long st_blocks;
+# unsigned long st_atime;
+# unsigned long st_atime_nsec;
+# unsigned long st_mtime;
+# unsigned long st_mtime_nsec;
+# unsigned long st_ctime;
+# unsigned long st_ctime_nsec;
+# unsigned long __unused4;
+# unsigned long __unused5;
# #ifdef __powerpc64__
-# unsigned long __unused6;
+# unsigned long __unused6;
# #endif
# };
@@ -875,25 +875,25 @@ class LinuxPPCStat(ctypes.BigEndianStructure):
# Srouce: https://elixir.bootlin.com/linux/latest/source/arch/powerpc/include/uapi/asm/stat.h#L60
# struct stat64 {
-# unsigned long long st_dev; /* Device. */
-# unsigned long long st_ino; /* File serial number. */
-# unsigned int st_mode; /* File mode. */
-# unsigned int st_nlink; /* Link count. */
-# unsigned int st_uid; /* User ID of the file's owner. */
-# unsigned int st_gid; /* Group ID of the file's group. */
-# unsigned long long st_rdev; /* Device number, if device. */
-# unsigned short __pad2;
-# long long st_size; /* Size of file, in bytes. */
-# int st_blksize; /* Optimal block size for I/O. */
-# long long st_blocks; /* Number 512-byte blocks allocated. */
-# int st_atime; /* Time of last access. */
-# unsigned int st_atime_nsec;
-# int st_mtime; /* Time of last modification. */
-# unsigned int st_mtime_nsec;
-# int st_ctime; /* Time of last status change. */
-# unsigned int st_ctime_nsec;
-# unsigned int __unused4;
-# unsigned int __unused5;
+# unsigned long long st_dev; /* Device. */
+# unsigned long long st_ino; /* File serial number. */
+# unsigned int st_mode; /* File mode. */
+# unsigned int st_nlink; /* Link count. */
+# unsigned int st_uid; /* User ID of the file's owner. */
+# unsigned int st_gid; /* Group ID of the file's group. */
+# unsigned long long st_rdev; /* Device number, if device. */
+# unsigned short __pad2;
+# long long st_size; /* Size of file, in bytes. */
+# int st_blksize; /* Optimal block size for I/O. */
+# long long st_blocks; /* Number 512-byte blocks allocated. */
+# int st_atime; /* Time of last access. */
+# unsigned int st_atime_nsec;
+# int st_mtime; /* Time of last modification. */
+# unsigned int st_mtime_nsec;
+# int st_ctime; /* Time of last status change. */
+# unsigned int st_ctime_nsec;
+# unsigned int __unused4;
+# unsigned int __unused5;
# };
class LinuxPPCStat64(ctypes.BigEndianStructure):
@@ -925,46 +925,46 @@ class LinuxPPCStat64(ctypes.BigEndianStructure):
#
# struct stat {
# #if _FILE_OFFSET_BITS - 0 == 64
-# ino_t st_ino; /* File serial number. */
-# off_t st_size;
+# ino_t st_ino; /* File serial number. */
+# off_t st_size;
# #elif !defined(_FILE_OFFSET_BITS) || _FILE_OFFSET_BITS == 32
# #if defined(__LITTLEENDIAN__)
-# ino_t st_ino; /* File serial number. */
-# ino_t st_ino_hi;
-# off_t st_size;
-# off_t st_size_hi;
+# ino_t st_ino; /* File serial number. */
+# ino_t st_ino_hi;
+# off_t st_size;
+# off_t st_size_hi;
# #elif defined(__BIGENDIAN__)
-# ino_t st_ino_hi;
-# ino_t st_ino; /* File serial number. */
-# off_t st_size_hi;
-# off_t st_size;
+# ino_t st_ino_hi;
+# ino_t st_ino; /* File serial number. */
+# off_t st_size_hi;
+# off_t st_size;
# #else
# #error endian not configured for system
# #endif
# #else
# #error _FILE_OFFSET_BITS value is unsupported
# #endif
-# _CSTD dev_t st_dev; /* ID of device containing file. */
-# _CSTD dev_t st_rdev; /* Device ID, for inode that is device */
-# uid_t st_uid;
-# gid_t st_gid;
-# _CSTD time_t st_mtime; /* Time of last data modification */
-# _CSTD time_t st_atime; /* Time last accessed */
-# _CSTD time_t st_ctime; /* Time of last status change */
-# _CSTD mode_t st_mode; /* see below */
-# nlink_t st_nlink;
-# blksize_t st_blocksize; /* Size of a block used by st_nblocks */
-# _Int32t st_nblocks; /* Number of blocks st_blocksize blocks */
-# blksize_t st_blksize; /* Prefered I/O block size for object */
+# _CSTD dev_t st_dev; /* ID of device containing file. */
+# _CSTD dev_t st_rdev; /* Device ID, for inode that is device */
+# uid_t st_uid;
+# gid_t st_gid;
+# _CSTD time_t st_mtime; /* Time of last data modification */
+# _CSTD time_t st_atime; /* Time last accessed */
+# _CSTD time_t st_ctime; /* Time of last status change */
+# _CSTD mode_t st_mode; /* see below */
+# nlink_t st_nlink;
+# blksize_t st_blocksize; /* Size of a block used by st_nblocks */
+# _Int32t st_nblocks; /* Number of blocks st_blocksize blocks */
+# blksize_t st_blksize; /* Prefered I/O block size for object */
# #if _FILE_OFFSET_BITS - 0 == 64
-# blkcnt_t st_blocks; /* Number of 512 byte blocks */
+# blkcnt_t st_blocks; /* Number of 512 byte blocks */
# #elif !defined(_FILE_OFFSET_BITS) || _FILE_OFFSET_BITS == 32
# #if defined(__LITTLEENDIAN__)
-# blkcnt_t st_blocks;
-# blkcnt_t st_blocks_hi;
+# blkcnt_t st_blocks;
+# blkcnt_t st_blocks_hi;
# #elif defined(__BIGENDIAN__)
-# blkcnt_t st_blocks_hi;
-# blkcnt_t st_blocks;
+# blkcnt_t st_blocks_hi;
+# blkcnt_t st_blocks;
# #else
# #error endian not configured for system
# #endif
@@ -974,21 +974,21 @@ class LinuxPPCStat64(ctypes.BigEndianStructure):
# };
# struct stat64 {
-# ino64_t st_ino; /* File serial number. */
-# off64_t st_size;
-# _CSTD dev_t st_dev; /* ID of device containing file. */
-# _CSTD dev_t st_rdev; /* Device ID, for inode that is device */
-# uid_t st_uid;
-# gid_t st_gid;
-# _CSTD time_t st_mtime; /* Time of last data modification */
-# _CSTD time_t st_atime; /* Time last accessed */
-# _CSTD time_t st_ctime; /* Time of last status change */
-# _CSTD mode_t st_mode; /* see below */
-# nlink_t st_nlink;
-# blksize_t st_blocksize; /* Size of a block used by st_nblocks */
-# _Int32t st_nblocks; /* Number of blocks st_blocksize blocks */
-# blksize_t st_blksize; /* Prefered I/O block size for object */
-# blkcnt64_t st_blocks; /* Number of 512 byte blocks */
+# ino64_t st_ino; /* File serial number. */
+# off64_t st_size;
+# _CSTD dev_t st_dev; /* ID of device containing file. */
+# _CSTD dev_t st_rdev; /* Device ID, for inode that is device */
+# uid_t st_uid;
+# gid_t st_gid;
+# _CSTD time_t st_mtime; /* Time of last data modification */
+# _CSTD time_t st_atime; /* Time last accessed */
+# _CSTD time_t st_ctime; /* Time of last status change */
+# _CSTD mode_t st_mode; /* see below */
+# nlink_t st_nlink;
+# blksize_t st_blocksize; /* Size of a block used by st_nblocks */
+# _Int32t st_nblocks; /* Number of blocks st_blocksize blocks */
+# blksize_t st_blksize; /* Prefered I/O block size for object */
+# blkcnt64_t st_blocks; /* Number of 512 byte blocks */
# };
class QNXARMStat(ctypes.Structure):
diff --git a/qiling/os/qnx/types.py b/qiling/os/qnx/types.py
index bb8a5980d..af0c56c01 100644
--- a/qiling/os/qnx/types.py
+++ b/qiling/os/qnx/types.py
@@ -5,232 +5,232 @@
# lib/c/public/confname.h
sysconf_names = {
- 1 : '_CS_PATH', # default path to find system utilities
- 2 : '_CS_HOSTNAME', # Name of this node within the communications network
- 3 : '_CS_RELEASE', # Current release level of this implementation
- 4 : '_CS_VERSION', # Current version of this release
- 5 : '_CS_MACHINE', # Name of the hardware type on which the system is running
- 6 : '__CS_ARCHITECTURE', # Name of the instructions set architechure
- 7 : '_CS_HW_SERIAL', # A serial number assiciated with the hardware
- 8 : '_CS_HW_PROVIDER', # The name of the hardware manufacturers
- 9 : '_CS_SRPC_DOMAIN', # The secure RPC domain
- 11 : '_CS_SYSNAME', # Name of this implementation of the operating system
- 200 : '_CS_LIBPATH', # default path for runtime to find standard shared objects
- 201 : '_CS_DOMAIN', # Domain of this node within the communications network
- 202 : '_CS_RESOLVE', # In memory /etc/resolve.conf
- 203 : '_CS_TIMEZONE', # timezone string (TZ style)
- 204 : '_CS_LOCALE' # locale string
+ 1 : '_CS_PATH', # default path to find system utilities
+ 2 : '_CS_HOSTNAME', # Name of this node within the communications network
+ 3 : '_CS_RELEASE', # Current release level of this implementation
+ 4 : '_CS_VERSION', # Current version of this release
+ 5 : '_CS_MACHINE', # Name of the hardware type on which the system is running
+ 6 : '__CS_ARCHITECTURE', # Name of the instructions set architechure
+ 7 : '_CS_HW_SERIAL', # A serial number assiciated with the hardware
+ 8 : '_CS_HW_PROVIDER', # The name of the hardware manufacturers
+ 9 : '_CS_SRPC_DOMAIN', # The secure RPC domain
+ 11 : '_CS_SYSNAME', # Name of this implementation of the operating system
+ 200 : '_CS_LIBPATH', # default path for runtime to find standard shared objects
+ 201 : '_CS_DOMAIN', # Domain of this node within the communications network
+ 202 : '_CS_RESOLVE', # In memory /etc/resolve.conf
+ 203 : '_CS_TIMEZONE', # timezone string (TZ style)
+ 204 : '_CS_LOCALE' # locale string
}
# lib/c/public/confname.h
sysconf_consts = {
- 1 : '_SC_ARG_MAX',
- 2 : '_SC_CHILD_MAX',
- 3 : '_SC_CLK_TCK',
- 4 : '_SC_NGROUPS_MAX',
- 5 : '_SC_OPEN_MAX',
- 6 : '_SC_JOB_CONTROL',
- 7 : '_SC_SAVED_IDS',
- 8 : '_SC_VERSION',
- 9 : '_SC_PASS_MAX',
- 10 : '_SC_LOGNAME_MAX',
- 11 : '_SC_PAGESIZE',
- 12 : '_SC_XOPEN_VERSION',
- 13 : '_SC_STREAM_MAX',
- 14 : '_SC_TZNAME_MAX'
- # TODO: add 15 - 173
+ 1 : '_SC_ARG_MAX',
+ 2 : '_SC_CHILD_MAX',
+ 3 : '_SC_CLK_TCK',
+ 4 : '_SC_NGROUPS_MAX',
+ 5 : '_SC_OPEN_MAX',
+ 6 : '_SC_JOB_CONTROL',
+ 7 : '_SC_SAVED_IDS',
+ 8 : '_SC_VERSION',
+ 9 : '_SC_PASS_MAX',
+ 10 : '_SC_LOGNAME_MAX',
+ 11 : '_SC_PAGESIZE',
+ 12 : '_SC_XOPEN_VERSION',
+ 13 : '_SC_STREAM_MAX',
+ 14 : '_SC_TZNAME_MAX'
+ # TODO: add 15 - 173
}
# lib/c/public/confname.h
pathconf_names = {
- 1 : '_PC_LINK_MAX',
- 2 : '_PC_MAX_CANON',
- 3 : '_PC_MAX_INPUT',
- 4 : '_PC_NAME_MAX',
- 5 : '_PC_PATH_MAX',
- 6 : '_PC_PIPE_BUF',
- 7 : '_PC_NO_TRUNC',
- 8 : '_PC_VDISABLE',
- 9 : '_PC_CHOWN_RESTRICTED'
+ 1 : '_PC_LINK_MAX',
+ 2 : '_PC_MAX_CANON',
+ 3 : '_PC_MAX_INPUT',
+ 4 : '_PC_NAME_MAX',
+ 5 : '_PC_PATH_MAX',
+ 6 : '_PC_PIPE_BUF',
+ 7 : '_PC_NO_TRUNC',
+ 8 : '_PC_VDISABLE',
+ 9 : '_PC_CHOWN_RESTRICTED'
}
# lib/c/public/fcntl.h
file_open_flags = {
- 'O_RDONLY' : 0o0000000, # read-only
- 'O_WRONLY' : 0o0000001, # write-only
- 'O_RDWR' : 0o0000002, # read-write
- 'O_APPEND' : 0o0000010, # append
- 'O_DSYNC' : 0o0000020, # data integrity sync
- 'O_SYNC' : 0o0000040, # file integrity sync
- 'O_RSYNC' : 0o0000100, # data integrity sync
- 'O_NONBLOCK' : 0o0000200, # non-blocking
- 'O_CREAT' : 0o0000400, # file create
- 'O_TRUNC' : 0o0001000, # truncation
- 'O_EXCL' : 0o0002000, # exclusive
- 'O_NOCTTY' : 0o0004000, # no controlling terminal
- 'O_CLOEXEC' : 0o0020000, # close-on-exec
- 'O_REALIDS' : 0o0040000, # use real uid/gid instead of effectice uid/gid
- 'O_LARGEFILE' : 0o0100000, # off_t can be 64 bit
- 'O_ASYNC' : 0o0200000 # async
+ 'O_RDONLY' : 0o0000000, # read-only
+ 'O_WRONLY' : 0o0000001, # write-only
+ 'O_RDWR' : 0o0000002, # read-write
+ 'O_APPEND' : 0o0000010, # append
+ 'O_DSYNC' : 0o0000020, # data integrity sync
+ 'O_SYNC' : 0o0000040, # file integrity sync
+ 'O_RSYNC' : 0o0000100, # data integrity sync
+ 'O_NONBLOCK' : 0o0000200, # non-blocking
+ 'O_CREAT' : 0o0000400, # file create
+ 'O_TRUNC' : 0o0001000, # truncation
+ 'O_EXCL' : 0o0002000, # exclusive
+ 'O_NOCTTY' : 0o0004000, # no controlling terminal
+ 'O_CLOEXEC' : 0o0020000, # close-on-exec
+ 'O_REALIDS' : 0o0040000, # use real uid/gid instead of effectice uid/gid
+ 'O_LARGEFILE' : 0o0100000, # off_t can be 64 bit
+ 'O_ASYNC' : 0o0200000 # async
}
# lib/c/public/share.h
file_sharing_modes = {
- 0x00 : 'SH_COMPAT', # compatibility
- 0x10 : 'SH_DENYRW', # deny read/write
- 0x20 : 'SH_DENYWR', # deny write
- 0x30 : 'SH_DENYRD', # deny read
- 0x40 : 'SH_DENYNO' # no deny
+ 0x00 : 'SH_COMPAT', # compatibility
+ 0x10 : 'SH_DENYRW', # deny read/write
+ 0x20 : 'SH_DENYWR', # deny write
+ 0x30 : 'SH_DENYRD', # deny read
+ 0x40 : 'SH_DENYNO' # no deny
}
# lib/c/public/time.h
clock_types = {
- 0 : "CLOCK_REALTIME",
- 1 : "CLOCK_SOFTTIME",
- 2 : "CLOCK_MONOTONIC",
- 3 : "CLOCK_PROCESS_CPUTIME_ID",
- 4 : "CLOCK_THREAD_CPUTIME_ID"
+ 0 : "CLOCK_REALTIME",
+ 1 : "CLOCK_SOFTTIME",
+ 2 : "CLOCK_MONOTONIC",
+ 3 : "CLOCK_PROCESS_CPUTIME_ID",
+ 4 : "CLOCK_THREAD_CPUTIME_ID"
}
# lib/c/public/unistd.h
lseek_whence = {
- 0 : "SEEK_SET", # relative to start of file
- 1 : "SEEK_CUR", # relative to current position
- 2 : "SEEK_END" # relative to end of file
+ 0 : "SEEK_SET", # relative to start of file
+ 1 : "SEEK_CUR", # relative to current position
+ 2 : "SEEK_END" # relative to end of file
}
# lib/c/public/sys/conf.h
sysconf_conditions = {
- 1 << 20 : "_CONF_STR", # checking for string
- 2 << 20 : "_CONF_NUM" # checking for number
+ 1 << 20 : "_CONF_STR", # checking for string
+ 2 << 20 : "_CONF_NUM" # checking for number
}
# lib/c/public/sys/ftype.h
file_types = {
- 0 : "_FTYPE_ANY",
- 1 : "_FTYPE_FILE",
- 2 : "_FTYPE_LINK",
- 3 : "_FTYPE_SYMLINK",
- 4 : "_FTYPE_PIPE",
- 5 : "_FTYPE_SHMEM",
- 6 : "_FTYPE_MQUEUE",
- 7 : "_FTYPE_SOCKET",
- 8 : "_FTYPE_SEM",
- 9 : "_FTYPE_PHOTON",
- 10 : "_FTYPE_DUMPER",
- 11 : "_FTYPE_MOUNT",
- 12 : "_FTYPE_NAME",
- 13 : "_FTYPE_TYMEM"
+ 0 : "_FTYPE_ANY",
+ 1 : "_FTYPE_FILE",
+ 2 : "_FTYPE_LINK",
+ 3 : "_FTYPE_SYMLINK",
+ 4 : "_FTYPE_PIPE",
+ 5 : "_FTYPE_SHMEM",
+ 6 : "_FTYPE_MQUEUE",
+ 7 : "_FTYPE_SOCKET",
+ 8 : "_FTYPE_SEM",
+ 9 : "_FTYPE_PHOTON",
+ 10 : "_FTYPE_DUMPER",
+ 11 : "_FTYPE_MOUNT",
+ 12 : "_FTYPE_NAME",
+ 13 : "_FTYPE_TYMEM"
}
# lib/c/public/sys/iomsg.h
io_connect_subtypes = {
- 0 : "_IO_CONNECT_COMBINE", # more than two iov_t
- 1 : "_IO_CONNECT_COMBINE_CLOSE", # _IO_CONNECT_COMBINE with close-on-exec
- 2 : "_IO_CONNECT_OPEN",
- 3 : "_IO_CONNECT_UNLINK",
- 4 : "_IO_CONNECT_RENAME",
- 5 : "_IO_CONNECT_MKNOD",
- 6 : "_IO_CONNECT_READLINK",
- 7 : "_IO_CONNECT_LINK",
- 8 : "_IO_CONNECT_RSVD_UNBLOCK",
- 9 : "_IO_CONNECT_MOUNT"
+ 0 : "_IO_CONNECT_COMBINE", # more than two iov_t
+ 1 : "_IO_CONNECT_COMBINE_CLOSE", # _IO_CONNECT_COMBINE with close-on-exec
+ 2 : "_IO_CONNECT_OPEN",
+ 3 : "_IO_CONNECT_UNLINK",
+ 4 : "_IO_CONNECT_RENAME",
+ 5 : "_IO_CONNECT_MKNOD",
+ 6 : "_IO_CONNECT_READLINK",
+ 7 : "_IO_CONNECT_LINK",
+ 8 : "_IO_CONNECT_RSVD_UNBLOCK",
+ 9 : "_IO_CONNECT_MOUNT"
}
# lib/c/public/sys/iomsg.h
io_connect_ioflag = {
- '_IO_FLAG_RD' : 0x01,
- '_IO_FLAG_WR' : 0x02
+ '_IO_FLAG_RD' : 0x01,
+ '_IO_FLAG_WR' : 0x02
}
# lib/c/public/sys/iomsg.h
io_connect_eflag = {
- '_IO_CONNECT_EFLAG_DIR' : 0x01, # path is a directory
- '_IO_CONNECT_EFLAG_DOT' : 0x02, # last component of path is . or ..
- '_IO_CONNECT_EFLAG_DOTDOT' : 0x04 # last component is ..
+ '_IO_CONNECT_EFLAG_DIR' : 0x01, # path is a directory
+ '_IO_CONNECT_EFLAG_DOT' : 0x02, # last component of path is . or ..
+ '_IO_CONNECT_EFLAG_DOTDOT' : 0x04 # last component is ..
}
# lib/c/public/sys/mman.h
mmap_flags = {
- 'MAP_SHARED' : 0x00000001,
- 'MAP_PRIVATE' : 0x00000002,
- 'MAP_FIXED' : 0x00000010,
- 'MAP_ELF' : 0x00000020,
- 'MAP_NOSYNCFILE' : 0x00000040,
- 'MAP_LAZY' : 0x00000080,
- 'MAP_STACK' : 0x00001000,
- 'MAP_BELOW' : 0x00002000,
- 'MAP_NOINIT' : 0x00004000,
- 'MAP_PHYS' : 0x00010000,
- 'MAP_NOX64K' : 0x00020000,
- 'MAP_BELOW16M' : 0x00040000,
- 'MAP_ANON' : 0x00080000,
- 'MAP_ANONYMOUS' : 0x00080000,
- 'MAP_SYSRAM' : 0x01000000,
+ 'MAP_SHARED' : 0x00000001,
+ 'MAP_PRIVATE' : 0x00000002,
+ 'MAP_FIXED' : 0x00000010,
+ 'MAP_ELF' : 0x00000020,
+ 'MAP_NOSYNCFILE' : 0x00000040,
+ 'MAP_LAZY' : 0x00000080,
+ 'MAP_STACK' : 0x00001000,
+ 'MAP_BELOW' : 0x00002000,
+ 'MAP_NOINIT' : 0x00004000,
+ 'MAP_PHYS' : 0x00010000,
+ 'MAP_NOX64K' : 0x00020000,
+ 'MAP_BELOW16M' : 0x00040000,
+ 'MAP_ANON' : 0x00080000,
+ 'MAP_ANONYMOUS' : 0x00080000,
+ 'MAP_SYSRAM' : 0x01000000,
}
# lib/c/public/sys/neutrino.h for syscall ChannelCreate(unsigned flags)
channel_create_flags = {
- '_NTO_CHF_FIXED_PRIORITY' : 0x0001,
- '_NTO_CHF_UNBLOCK' : 0x0002,
- '_NTO_CHF_THREAD_DEATH' : 0x0004,
- '_NTO_CHF_DISCONNECT' : 0x0008,
- '_NTO_CHF_NET_MSG' : 0x0010,
- '_NTO_CHF_SENDER_LEN' : 0x0020,
- '_NTO_CHF_COID_DISCONNECT' : 0x0040,
- '_NTO_CHF_REPLY_LEN' : 0x0080,
- '_NTO_CHF_STICKY' : 0x0100,
- '_NTO_CHF_ASYNC_NONBLOCK' : 0x0200,
- '_NTO_CHF_ASYNC' : 0x0400,
- '_NTO_CHF_GLOBAL' : 0x0800
+ '_NTO_CHF_FIXED_PRIORITY' : 0x0001,
+ '_NTO_CHF_UNBLOCK' : 0x0002,
+ '_NTO_CHF_THREAD_DEATH' : 0x0004,
+ '_NTO_CHF_DISCONNECT' : 0x0008,
+ '_NTO_CHF_NET_MSG' : 0x0010,
+ '_NTO_CHF_SENDER_LEN' : 0x0020,
+ '_NTO_CHF_COID_DISCONNECT' : 0x0040,
+ '_NTO_CHF_REPLY_LEN' : 0x0080,
+ '_NTO_CHF_STICKY' : 0x0100,
+ '_NTO_CHF_ASYNC_NONBLOCK' : 0x0200,
+ '_NTO_CHF_ASYNC' : 0x0400,
+ '_NTO_CHF_GLOBAL' : 0x0800
}
# lib/c/public/sys/neutrino.h for syscall ConnectAttach(..., int flags)
connect_attach_flags = {
- '_NTO_COF_CLOEXEC' : 0x0001, # close on exec
- '_NTO_COF_DEAD' : 0x0002,
- '_NTO_COF_NOSHARE' : 0x0040,
- '_NTO_COF_NETCON' : 0x0080,
- '_NTO_COF_NONBLOCK' : 0x0100,
- '_NTO_COF_ASYNC' : 0x0200,
- '_NTO_COF_GLOBAL' : 0x0400
+ '_NTO_COF_CLOEXEC' : 0x0001, # close on exec
+ '_NTO_COF_DEAD' : 0x0002,
+ '_NTO_COF_NOSHARE' : 0x0040,
+ '_NTO_COF_NETCON' : 0x0080,
+ '_NTO_COF_NONBLOCK' : 0x0100,
+ '_NTO_COF_ASYNC' : 0x0200,
+ '_NTO_COF_GLOBAL' : 0x0400
}
# lib/c/public/sys/stat.h
file_access = {
- 0o00001 : '_S_INSEM', # semaphore
- 0o00002 : '_S_INSHD', # shared data
- 0o00003 : '_S_INMQ', # message queue
- 0o00004 : '_S_INTMO', # typed memory
- 0o40000 : '_S_QNX_SPECIAL'
+ 0o00001 : '_S_INSEM', # semaphore
+ 0o00002 : '_S_INSHD', # shared data
+ 0o00003 : '_S_INMQ', # message queue
+ 0o00004 : '_S_INTMO', # typed memory
+ 0o40000 : '_S_QNX_SPECIAL'
}
# lib/c/public/sys/stat.h
file_stats = {
- '_S_IFIFO' : 0x1000, # FIFO
- '_S_IFCHR' : 0x2000, # Character special
- '_S_IFDIR' : 0x4000, # Directory
- '_S_IFNAM' : 0x5000, # Named file
- '_S_IFBLK' : 0x6000, # Block special
- '_S_IFREG' : 0x8000, # Regular
- '_S_IFLNK' : 0xa000, # Symlink
- '_S_IFSOCK' : 0xc000 # Socket
+ '_S_IFIFO' : 0x1000, # FIFO
+ '_S_IFCHR' : 0x2000, # Character special
+ '_S_IFDIR' : 0x4000, # Directory
+ '_S_IFNAM' : 0x5000, # Named file
+ '_S_IFBLK' : 0x6000, # Block special
+ '_S_IFREG' : 0x8000, # Regular
+ '_S_IFLNK' : 0xa000, # Symlink
+ '_S_IFSOCK' : 0xc000 # Socket
}
# services/system/public/sys/memmsg.h
mem_ctrl_subtypes = {
- 0 : "MEM_CTRL_UNMAP",
- 1 : "MEM_CTRL_PROTECT",
- 2 : "MEM_CTRL_SYNC",
- 3 : "MEM_CTRL_LOCKALL",
- 4 : "MEM_CTRL_UNLOCKALL",
- 5 : "MEM_CTRL_LOCK",
- 6 : "MEM_CTRL_UNLOCK",
- 7 : "MEM_CTRL_ADVISE"
+ 0 : "MEM_CTRL_UNMAP",
+ 1 : "MEM_CTRL_PROTECT",
+ 2 : "MEM_CTRL_SYNC",
+ 3 : "MEM_CTRL_LOCKALL",
+ 4 : "MEM_CTRL_UNLOCKALL",
+ 5 : "MEM_CTRL_LOCK",
+ 6 : "MEM_CTRL_UNLOCK",
+ 7 : "MEM_CTRL_ADVISE"
}
# services/system/public/sys/sysmsg.h
sysconf_subtypes = {
- 0 : "_SYS_SUB_GET",
- 1 : "_SYS_SUB_SET"
+ 0 : "_SYS_SUB_GET",
+ 1 : "_SYS_SUB_SET"
}
diff --git a/qiling/os/uefi/PiMultiPhase.py b/qiling/os/uefi/PiMultiPhase.py
index 798705a78..ba9906f96 100644
--- a/qiling/os/uefi/PiMultiPhase.py
+++ b/qiling/os/uefi/PiMultiPhase.py
@@ -6,29 +6,29 @@
from .UefiBaseType import *
from .ProcessorBind import *
-EFI_SMRAM_OPEN = 0x00000001
-EFI_SMRAM_CLOSED = 0x00000002
-EFI_SMRAM_LOCKED = 0x00000004
-EFI_CACHEABLE = 0x00000008
-EFI_ALLOCATED = 0x00000010
-EFI_NEEDS_TESTING = 0x00000020
-EFI_NEEDS_ECC_INITIALIZATION = 0x00000040
+EFI_SMRAM_OPEN = 0x00000001
+EFI_SMRAM_CLOSED = 0x00000002
+EFI_SMRAM_LOCKED = 0x00000004
+EFI_CACHEABLE = 0x00000008
+EFI_ALLOCATED = 0x00000010
+EFI_NEEDS_TESTING = 0x00000020
+EFI_NEEDS_ECC_INITIALIZATION = 0x00000040
class EFI_SMRAM_DESCRIPTOR(STRUCT):
- _fields_ = [
- ('PhysicalStart', EFI_PHYSICAL_ADDRESS),
- ('CpuStart', EFI_PHYSICAL_ADDRESS),
- ('PhysicalSize', UINT64),
- ('RegionState', UINT64)
- ]
+ _fields_ = [
+ ('PhysicalStart', EFI_PHYSICAL_ADDRESS),
+ ('CpuStart', EFI_PHYSICAL_ADDRESS),
+ ('PhysicalSize', UINT64),
+ ('RegionState', UINT64)
+ ]
__all__ = [
- 'EFI_SMRAM_DESCRIPTOR',
- 'EFI_SMRAM_OPEN',
- 'EFI_SMRAM_CLOSED',
- 'EFI_SMRAM_LOCKED',
- 'EFI_CACHEABLE',
- 'EFI_ALLOCATED',
- 'EFI_NEEDS_TESTING',
- 'EFI_NEEDS_ECC_INITIALIZATION'
+ 'EFI_SMRAM_DESCRIPTOR',
+ 'EFI_SMRAM_OPEN',
+ 'EFI_SMRAM_CLOSED',
+ 'EFI_SMRAM_LOCKED',
+ 'EFI_CACHEABLE',
+ 'EFI_ALLOCATED',
+ 'EFI_NEEDS_TESTING',
+ 'EFI_NEEDS_ECC_INITIALIZATION'
]
diff --git a/qiling/os/uefi/ProcessorBind.py b/qiling/os/uefi/ProcessorBind.py
index 817be539f..73a6e7bf1 100644
--- a/qiling/os/uefi/ProcessorBind.py
+++ b/qiling/os/uefi/ProcessorBind.py
@@ -13,19 +13,19 @@
psize = bits // 8
dummy_ptr_type = {
- 32 : ctypes.c_uint32,
- 64 : ctypes.c_uint64
+ 32 : ctypes.c_uint32,
+ 64 : ctypes.c_uint64
}[bits]
_pointer_type_cache: MutableMapping[str, type] = {}
def PTR(ptype: Optional[type]) -> type:
- pname = 'c_void' if ptype is None else ptype.__name__
+ pname = 'c_void' if ptype is None else ptype.__name__
- if pname not in _pointer_type_cache:
- _pointer_type_cache[pname] = type(f'LP_{psize}_{pname}', (dummy_ptr_type,), {})
+ if pname not in _pointer_type_cache:
+ _pointer_type_cache[pname] = type(f'LP_{psize}_{pname}', (dummy_ptr_type,), {})
- return _pointer_type_cache[pname]
+ return _pointer_type_cache[pname]
VOID = None
INT8 = ctypes.c_int8
@@ -51,111 +51,111 @@ def PTR(ptype: Optional[type]) -> type:
PAGE_SIZE = 0x1000
class STRUCT(ctypes.LittleEndianStructure):
- """An abstract class for C structures.
- """
+ """An abstract class for C structures.
+ """
- # Structures are packed by default; when needed, padding should be added
- # manually through placeholder fields
- _pack_ = 1
+ # Structures are packed by default; when needed, padding should be added
+ # manually through placeholder fields
+ _pack_ = 1
- def __init__(self):
- pass
+ def __init__(self):
+ pass
- def saveTo(self, ql: Qiling, address: int) -> None:
- """Store self contents to a specified memory address.
- """
+ def saveTo(self, ql: Qiling, address: int) -> None:
+ """Store self contents to a specified memory address.
+ """
- data = bytes(self)
+ data = bytes(self)
- ql.mem.write(address, data)
+ ql.mem.write(address, data)
- @classmethod
- def loadFrom(cls, ql: Qiling, address: int) -> 'STRUCT':
- """Construct an instance of the structure from saved contents.
- """
+ @classmethod
+ def loadFrom(cls, ql: Qiling, address: int) -> 'STRUCT':
+ """Construct an instance of the structure from saved contents.
+ """
- data = bytes(ql.mem.read(address, cls.sizeof()))
+ data = bytes(ql.mem.read(address, cls.sizeof()))
- return cls.from_buffer_copy(data)
+ return cls.from_buffer_copy(data)
- @classmethod
- @contextmanager
- def bindTo(cls, ql: Qiling, address: int):
- instance = cls.loadFrom(ql, address)
+ @classmethod
+ @contextmanager
+ def bindTo(cls, ql: Qiling, address: int):
+ instance = cls.loadFrom(ql, address)
- try:
- yield instance
- finally:
- instance.saveTo(ql, address)
+ try:
+ yield instance
+ finally:
+ instance.saveTo(ql, address)
- @classmethod
- def sizeof(cls) -> int:
- """Get the C structure size in bytes.
- """
+ @classmethod
+ def sizeof(cls) -> int:
+ """Get the C structure size in bytes.
+ """
- return ctypes.sizeof(cls)
+ return ctypes.sizeof(cls)
- @classmethod
- def offsetof(cls, fname: str) -> int:
- """Get the offset of a field in the C structure.
- """
+ @classmethod
+ def offsetof(cls, fname: str) -> int:
+ """Get the offset of a field in the C structure.
+ """
- return getattr(cls, fname).offset
+ return getattr(cls, fname).offset
- @classmethod
- def memberat(cls, offset: int) -> Optional[str]:
- """Get the member name at a given offset.
- """
+ @classmethod
+ def memberat(cls, offset: int) -> Optional[str]:
+ """Get the member name at a given offset.
+ """
- return next((fname for fname, *_ in cls._fields_ if cls.offsetof(fname) == offset), None)
+ return next((fname for fname, *_ in cls._fields_ if cls.offsetof(fname) == offset), None)
class EnumMeta(type(ctypes.c_int)):
- def __getattr__(self, key):
- return self._members_.index(key)
+ def __getattr__(self, key):
+ return self._members_.index(key)
class ENUM(ctypes.c_int, metaclass=EnumMeta):
- """An abstract class for continuous C enums.
- """
+ """An abstract class for continuous C enums.
+ """
- # a list or tuple of names (strings)
- # names will be enumerate by their corresponding index in the list
- _members_: Sequence[str] = []
+ # a list or tuple of names (strings)
+ # names will be enumerate by their corresponding index in the list
+ _members_: Sequence[str] = []
class EnumUCMeta(type(ctypes.c_int)):
- def __getattr__(self, key):
- return self._members_[key]
+ def __getattr__(self, key):
+ return self._members_[key]
class ENUM_UC(ctypes.c_int, metaclass=EnumUCMeta):
- """An abstract class for uncontinuous C enums.
- """
+ """An abstract class for uncontinuous C enums.
+ """
- # a dictionary of (names : str, value : int) tuples
- # names will be enumerate by their paired value
- _members_: Mapping[str, int] = {}
+ # a dictionary of (names : str, value : int) tuples
+ # names will be enumerate by their paired value
+ _members_: Mapping[str, int] = {}
__all__ = [
- 'VOID',
- 'INT8',
- 'INT16',
- 'INT32',
- 'INT64',
- 'INTN',
- 'UINT8',
- 'UINT16',
- 'UINT32',
- 'UINT64',
- 'UINTN',
- 'BOOLEAN',
- 'CHAR8',
- 'CHAR16',
-
- 'PTR',
- 'FUNCPTR',
- 'STRUCT',
- 'UNION',
- 'ENUM',
- 'ENUM_UC',
-
- 'CPU_STACK_ALIGNMENT',
- 'PAGE_SIZE'
+ 'VOID',
+ 'INT8',
+ 'INT16',
+ 'INT32',
+ 'INT64',
+ 'INTN',
+ 'UINT8',
+ 'UINT16',
+ 'UINT32',
+ 'UINT64',
+ 'UINTN',
+ 'BOOLEAN',
+ 'CHAR8',
+ 'CHAR16',
+
+ 'PTR',
+ 'FUNCPTR',
+ 'STRUCT',
+ 'UNION',
+ 'ENUM',
+ 'ENUM_UC',
+
+ 'CPU_STACK_ALIGNMENT',
+ 'PAGE_SIZE'
]
\ No newline at end of file
diff --git a/qiling/os/uefi/UefiBaseType.py b/qiling/os/uefi/UefiBaseType.py
index 65380bd1c..5f9d87fbe 100644
--- a/qiling/os/uefi/UefiBaseType.py
+++ b/qiling/os/uefi/UefiBaseType.py
@@ -6,12 +6,12 @@
from qiling.os.uefi.ProcessorBind import *
class EFI_GUID(STRUCT):
- _fields_ = [
- ('Data1', UINT32),
- ('Data2', UINT16),
- ('Data3', UINT16),
- ('Data4', UINT8 * 8)
- ]
+ _fields_ = [
+ ('Data1', UINT32),
+ ('Data2', UINT16),
+ ('Data3', UINT16),
+ ('Data4', UINT8 * 8)
+ ]
EFI_STATUS = UINTN
EFI_HANDLE = PTR(VOID)
@@ -22,28 +22,28 @@ class EFI_GUID(STRUCT):
EFI_VIRTUAL_ADDRESS = UINT64
class EFI_TIME(STRUCT):
- _fields_ = [
- ('Year', UINT16),
- ('Month', UINT8),
- ('Day', UINT8),
- ('Hour', UINT8),
- ('Minute', UINT8),
- ('Second', UINT8),
- ('Pad1', UINT8),
- ('Nanosecond', UINT32),
- ('TimeZone', UINT16),
- ('Daylight', UINT8),
- ('Pad2', UINT8)
- ]
+ _fields_ = [
+ ('Year', UINT16),
+ ('Month', UINT8),
+ ('Day', UINT8),
+ ('Hour', UINT8),
+ ('Minute', UINT8),
+ ('Second', UINT8),
+ ('Pad1', UINT8),
+ ('Nanosecond', UINT32),
+ ('TimeZone', UINT16),
+ ('Daylight', UINT8),
+ ('Pad2', UINT8)
+ ]
__all__ = [
- 'EFI_GUID',
- 'EFI_STATUS',
- 'EFI_HANDLE',
- 'EFI_EVENT',
- 'EFI_TPL',
- 'EFI_LBA',
- 'EFI_PHYSICAL_ADDRESS',
- 'EFI_VIRTUAL_ADDRESS',
- 'EFI_TIME'
+ 'EFI_GUID',
+ 'EFI_STATUS',
+ 'EFI_HANDLE',
+ 'EFI_EVENT',
+ 'EFI_TPL',
+ 'EFI_LBA',
+ 'EFI_PHYSICAL_ADDRESS',
+ 'EFI_VIRTUAL_ADDRESS',
+ 'EFI_TIME'
]
diff --git a/qiling/os/uefi/UefiMultiPhase.py b/qiling/os/uefi/UefiMultiPhase.py
index 01bd0e8ad..7e44b1d92 100644
--- a/qiling/os/uefi/UefiMultiPhase.py
+++ b/qiling/os/uefi/UefiMultiPhase.py
@@ -7,44 +7,44 @@
# @see: MdePkg\Include\Uefi\UefiMultiPhase.h
class EFI_TABLE_HEADER(STRUCT):
- _fields_ = [
- ('Signature', UINT64),
- ('Revision', UINT32),
- ('HeaderSize', UINT32),
- ('CRC32', UINT32),
- ('Reserved', UINT32)
- ]
+ _fields_ = [
+ ('Signature', UINT64),
+ ('Revision', UINT32),
+ ('HeaderSize', UINT32),
+ ('CRC32', UINT32),
+ ('Reserved', UINT32)
+ ]
class EFI_RESET_TYPE(ENUM):
- _members_ = [
- 'EfiResetCold',
- 'EfiResetWarm'
- 'EfiResetShutdown',
- 'EfiResetPlatformSpecific',
- ]
+ _members_ = [
+ 'EfiResetCold',
+ 'EfiResetWarm'
+ 'EfiResetShutdown',
+ 'EfiResetPlatformSpecific',
+ ]
class EFI_MEMORY_TYPE(ENUM):
- _members_ = [
- 'EfiReservedMemoryType',
- 'EfiLoaderCode',
- 'EfiLoaderData',
- 'EfiBootServicesCode',
- 'EfiBootServicesData',
- 'EfiRuntimeServicesCode',
- 'EfiRuntimeServicesData',
- 'EfiConventionalMemory',
- 'EfiUnusableMemory',
- 'EfiACPIReclaimMemory',
- 'EfiACPIMemoryNVS',
- 'EfiMemoryMappedIO',
- 'EfiMemoryMappedIOPortSpace',
- 'EfiPalCode',
- 'EfiPersistentMemory',
- 'EfiMaxMemoryType'
- ]
+ _members_ = [
+ 'EfiReservedMemoryType',
+ 'EfiLoaderCode',
+ 'EfiLoaderData',
+ 'EfiBootServicesCode',
+ 'EfiBootServicesData',
+ 'EfiRuntimeServicesCode',
+ 'EfiRuntimeServicesData',
+ 'EfiConventionalMemory',
+ 'EfiUnusableMemory',
+ 'EfiACPIReclaimMemory',
+ 'EfiACPIMemoryNVS',
+ 'EfiMemoryMappedIO',
+ 'EfiMemoryMappedIOPortSpace',
+ 'EfiPalCode',
+ 'EfiPersistentMemory',
+ 'EfiMaxMemoryType'
+ ]
__all__ = [
- 'EFI_TABLE_HEADER',
- 'EFI_RESET_TYPE',
- 'EFI_MEMORY_TYPE'
+ 'EFI_TABLE_HEADER',
+ 'EFI_RESET_TYPE',
+ 'EFI_MEMORY_TYPE'
]
\ No newline at end of file
diff --git a/qiling/os/uefi/UefiSpec.py b/qiling/os/uefi/UefiSpec.py
index 6e9e85e66..7c236d0ab 100644
--- a/qiling/os/uefi/UefiSpec.py
+++ b/qiling/os/uefi/UefiSpec.py
@@ -12,216 +12,216 @@
# definitions for EFI_TIME.Daylight
EFI_TIME_ADJUST_DAYLIGHT = (1 << 1)
-EFI_TIME_IN_DAYLIGHT = (1 << 2)
+EFI_TIME_IN_DAYLIGHT = (1 << 2)
# definition for EFI_TIME.TimeZone
EFI_UNSPECIFIED_TIMEZONE = 0x07ff
class EFI_ALLOCATE_TYPE(ENUM):
- _members_ = [
- 'AllocateAnyPages',
- 'AllocateMaxAddress',
- 'AllocateAddress',
- 'MaxAllocateType'
- ]
+ _members_ = [
+ 'AllocateAnyPages',
+ 'AllocateMaxAddress',
+ 'AllocateAddress',
+ 'MaxAllocateType'
+ ]
class EFI_TIMER_DELAY(ENUM):
- _members_ = [
- 'TimerCancel',
- 'TimerPeriodic',
- 'TimerRelative'
- ]
+ _members_ = [
+ 'TimerCancel',
+ 'TimerPeriodic',
+ 'TimerRelative'
+ ]
class EFI_INTERFACE_TYPE(ENUM):
- _members_ = [
- 'EFI_NATIVE_INTERFACE'
- ]
+ _members_ = [
+ 'EFI_NATIVE_INTERFACE'
+ ]
class EFI_LOCATE_SEARCH_TYPE(ENUM):
- _members_ = [
- 'AllHandles',
- 'ByRegisterNotify',
- 'ByProtocol'
+ _members_ = [
+ 'AllHandles',
+ 'ByRegisterNotify',
+ 'ByProtocol'
]
class EFI_TIME_CAPABILITIES(STRUCT):
- _pack_ = 8
+ _pack_ = 8
- _fields_ = [
- ('Resolution', UINT32),
- ('Accuracy', UINT32),
- ('SetsToZero', BOOLEAN),
- ]
+ _fields_ = [
+ ('Resolution', UINT32),
+ ('Accuracy', UINT32),
+ ('SetsToZero', BOOLEAN),
+ ]
class EFI_MEMORY_DESCRIPTOR(STRUCT):
- _pack_ = 8
+ _pack_ = 8
- _fields_ = [
- ('Type', UINT32),
- ('PhysicalStart', EFI_PHYSICAL_ADDRESS),
- ('VirtualStart', EFI_VIRTUAL_ADDRESS),
- ('NumberOfPages', UINT64),
- ('Attribute', UINT64)
- ]
+ _fields_ = [
+ ('Type', UINT32),
+ ('PhysicalStart', EFI_PHYSICAL_ADDRESS),
+ ('VirtualStart', EFI_VIRTUAL_ADDRESS),
+ ('NumberOfPages', UINT64),
+ ('Attribute', UINT64)
+ ]
class EFI_CAPSULE_HEADER(STRUCT):
- _fields_ = [
- ('CapsuleGuid', EFI_GUID),
- ('HeaderSize', UINT32),
- ('Flags', UINT32),
- ('CapsuleImageSize', UINT32)
- ]
+ _fields_ = [
+ ('CapsuleGuid', EFI_GUID),
+ ('HeaderSize', UINT32),
+ ('Flags', UINT32),
+ ('CapsuleImageSize', UINT32)
+ ]
-EFI_GET_TIME = FUNCPTR(EFI_STATUS, PTR(EFI_TIME), PTR(EFI_TIME_CAPABILITIES))
-EFI_SET_TIME = FUNCPTR(EFI_STATUS, PTR(EFI_TIME))
-EFI_GET_WAKEUP_TIME = FUNCPTR(EFI_STATUS, PTR(BOOLEAN), PTR(BOOLEAN), PTR(EFI_TIME))
-EFI_SET_WAKEUP_TIME = FUNCPTR(EFI_STATUS, BOOLEAN, PTR(EFI_TIME))
-EFI_SET_VIRTUAL_ADDRESS_MAP = FUNCPTR(EFI_STATUS, UINTN, UINTN, UINT32, PTR(EFI_MEMORY_DESCRIPTOR))
-EFI_CONVERT_POINTER = FUNCPTR(EFI_STATUS, UINTN, PTR(PTR(VOID)))
-EFI_GET_VARIABLE = FUNCPTR(EFI_STATUS, PTR(CHAR16), PTR(EFI_GUID), PTR(UINT32), PTR(UINTN), PTR(VOID))
-EFI_GET_NEXT_VARIABLE_NAME = FUNCPTR(EFI_STATUS, PTR(UINTN), PTR(CHAR16), PTR(EFI_GUID))
-EFI_SET_VARIABLE = FUNCPTR(EFI_STATUS, PTR(CHAR16), PTR(EFI_GUID), UINT32, UINTN, PTR(VOID))
-EFI_GET_NEXT_HIGH_MONO_COUNT = FUNCPTR(EFI_STATUS, PTR(UINT32))
-EFI_RESET_SYSTEM = FUNCPTR(VOID, EFI_RESET_TYPE, EFI_STATUS, UINTN, PTR(VOID))
-EFI_UPDATE_CAPSULE = FUNCPTR(EFI_STATUS, PTR(PTR(EFI_CAPSULE_HEADER)), UINTN, EFI_PHYSICAL_ADDRESS)
-EFI_QUERY_CAPSULE_CAPABILITIES = FUNCPTR(EFI_STATUS, PTR(PTR(EFI_CAPSULE_HEADER)), UINTN, PTR(UINT64), PTR(EFI_RESET_TYPE))
-EFI_QUERY_VARIABLE_INFO = FUNCPTR(EFI_STATUS, UINT32, PTR(UINT64), PTR(UINT64), PTR(UINT64))
+EFI_GET_TIME = FUNCPTR(EFI_STATUS, PTR(EFI_TIME), PTR(EFI_TIME_CAPABILITIES))
+EFI_SET_TIME = FUNCPTR(EFI_STATUS, PTR(EFI_TIME))
+EFI_GET_WAKEUP_TIME = FUNCPTR(EFI_STATUS, PTR(BOOLEAN), PTR(BOOLEAN), PTR(EFI_TIME))
+EFI_SET_WAKEUP_TIME = FUNCPTR(EFI_STATUS, BOOLEAN, PTR(EFI_TIME))
+EFI_SET_VIRTUAL_ADDRESS_MAP = FUNCPTR(EFI_STATUS, UINTN, UINTN, UINT32, PTR(EFI_MEMORY_DESCRIPTOR))
+EFI_CONVERT_POINTER = FUNCPTR(EFI_STATUS, UINTN, PTR(PTR(VOID)))
+EFI_GET_VARIABLE = FUNCPTR(EFI_STATUS, PTR(CHAR16), PTR(EFI_GUID), PTR(UINT32), PTR(UINTN), PTR(VOID))
+EFI_GET_NEXT_VARIABLE_NAME = FUNCPTR(EFI_STATUS, PTR(UINTN), PTR(CHAR16), PTR(EFI_GUID))
+EFI_SET_VARIABLE = FUNCPTR(EFI_STATUS, PTR(CHAR16), PTR(EFI_GUID), UINT32, UINTN, PTR(VOID))
+EFI_GET_NEXT_HIGH_MONO_COUNT = FUNCPTR(EFI_STATUS, PTR(UINT32))
+EFI_RESET_SYSTEM = FUNCPTR(VOID, EFI_RESET_TYPE, EFI_STATUS, UINTN, PTR(VOID))
+EFI_UPDATE_CAPSULE = FUNCPTR(EFI_STATUS, PTR(PTR(EFI_CAPSULE_HEADER)), UINTN, EFI_PHYSICAL_ADDRESS)
+EFI_QUERY_CAPSULE_CAPABILITIES = FUNCPTR(EFI_STATUS, PTR(PTR(EFI_CAPSULE_HEADER)), UINTN, PTR(UINT64), PTR(EFI_RESET_TYPE))
+EFI_QUERY_VARIABLE_INFO = FUNCPTR(EFI_STATUS, UINT32, PTR(UINT64), PTR(UINT64), PTR(UINT64))
class EFI_RUNTIME_SERVICES(STRUCT):
- _fields_ = [
- ('Hdr', EFI_TABLE_HEADER),
- ('GetTime', EFI_GET_TIME),
- ('SetTime', EFI_SET_TIME),
- ('GetWakeupTime', EFI_GET_WAKEUP_TIME),
- ('SetWakeupTime', EFI_SET_WAKEUP_TIME),
- ('SetVirtualAddressMap', EFI_SET_VIRTUAL_ADDRESS_MAP),
- ('ConvertPointer', EFI_CONVERT_POINTER),
- ('GetVariable', EFI_GET_VARIABLE),
- ('GetNextVariableName', EFI_GET_NEXT_VARIABLE_NAME),
- ('SetVariable', EFI_SET_VARIABLE),
- ('GetNextHighMonotonicCount', EFI_GET_NEXT_HIGH_MONO_COUNT),
- ('ResetSystem', EFI_RESET_SYSTEM),
- ('UpdateCapsule', EFI_UPDATE_CAPSULE),
- ('QueryCapsuleCapabilities', EFI_QUERY_CAPSULE_CAPABILITIES),
- ('QueryVariableInfo', EFI_QUERY_VARIABLE_INFO)
- ]
+ _fields_ = [
+ ('Hdr', EFI_TABLE_HEADER),
+ ('GetTime', EFI_GET_TIME),
+ ('SetTime', EFI_SET_TIME),
+ ('GetWakeupTime', EFI_GET_WAKEUP_TIME),
+ ('SetWakeupTime', EFI_SET_WAKEUP_TIME),
+ ('SetVirtualAddressMap', EFI_SET_VIRTUAL_ADDRESS_MAP),
+ ('ConvertPointer', EFI_CONVERT_POINTER),
+ ('GetVariable', EFI_GET_VARIABLE),
+ ('GetNextVariableName', EFI_GET_NEXT_VARIABLE_NAME),
+ ('SetVariable', EFI_SET_VARIABLE),
+ ('GetNextHighMonotonicCount', EFI_GET_NEXT_HIGH_MONO_COUNT),
+ ('ResetSystem', EFI_RESET_SYSTEM),
+ ('UpdateCapsule', EFI_UPDATE_CAPSULE),
+ ('QueryCapsuleCapabilities', EFI_QUERY_CAPSULE_CAPABILITIES),
+ ('QueryVariableInfo', EFI_QUERY_VARIABLE_INFO)
+ ]
EFI_EVENT_NOTIFY = FUNCPTR(VOID, EFI_EVENT, PTR(VOID))
# this one belongs to another header, actually
class EFI_DEVICE_PATH_PROTOCOL(STRUCT):
- _fields_ = [
- ('Type', UINT8),
- ('SubType', UINT8),
- ('Length', UINT8 * 2)
- ]
+ _fields_ = [
+ ('Type', UINT8),
+ ('SubType', UINT8),
+ ('Length', UINT8 * 2)
+ ]
class EFI_OPEN_PROTOCOL_INFORMATION_ENTRY(STRUCT):
- _fields_ = [
- ('AgentHandle', EFI_HANDLE),
- ('ControllerHandle',EFI_HANDLE),
- ('Attributes', UINT32),
- ('OpenCount', UINT32)
- ]
+ _fields_ = [
+ ('AgentHandle', EFI_HANDLE),
+ ('ControllerHandle',EFI_HANDLE),
+ ('Attributes', UINT32),
+ ('OpenCount', UINT32)
+ ]
-EFI_RAISE_TPL = FUNCPTR(EFI_TPL, EFI_TPL)
-EFI_RESTORE_TPL = FUNCPTR(VOID, EFI_TPL)
-EFI_ALLOCATE_PAGES = FUNCPTR(EFI_STATUS, EFI_ALLOCATE_TYPE, EFI_MEMORY_TYPE, UINTN, PTR(EFI_PHYSICAL_ADDRESS))
-EFI_FREE_PAGES = FUNCPTR(EFI_STATUS, EFI_PHYSICAL_ADDRESS, UINTN)
-EFI_GET_MEMORY_MAP = FUNCPTR(EFI_STATUS, PTR(UINTN), PTR(EFI_MEMORY_DESCRIPTOR), PTR(UINTN), PTR(UINTN), PTR(UINT32))
-EFI_ALLOCATE_POOL = FUNCPTR(EFI_STATUS, EFI_MEMORY_TYPE, UINTN, PTR(PTR(VOID)))
-EFI_FREE_POOL = FUNCPTR(EFI_STATUS, PTR(VOID))
-EFI_CREATE_EVENT = FUNCPTR(EFI_STATUS, UINT32, EFI_TPL, EFI_EVENT_NOTIFY, PTR(VOID), PTR(EFI_EVENT))
-EFI_SET_TIMER = FUNCPTR(EFI_STATUS, EFI_EVENT, EFI_TIMER_DELAY, UINT64)
-EFI_WAIT_FOR_EVENT = FUNCPTR(EFI_STATUS, UINTN, PTR(EFI_EVENT), PTR(UINTN))
-EFI_SIGNAL_EVENT = FUNCPTR(EFI_STATUS, EFI_EVENT)
-EFI_CLOSE_EVENT = FUNCPTR(EFI_STATUS, EFI_EVENT)
-EFI_CHECK_EVENT = FUNCPTR(EFI_STATUS, EFI_EVENT)
-EFI_INSTALL_PROTOCOL_INTERFACE = FUNCPTR(EFI_STATUS, PTR(EFI_HANDLE), PTR(EFI_GUID), EFI_INTERFACE_TYPE, PTR(VOID))
-EFI_REINSTALL_PROTOCOL_INTERFACE = FUNCPTR(EFI_STATUS, EFI_HANDLE, PTR(EFI_GUID), PTR(VOID), PTR(VOID))
-EFI_UNINSTALL_PROTOCOL_INTERFACE = FUNCPTR(EFI_STATUS, EFI_HANDLE, PTR(EFI_GUID), PTR(VOID))
-EFI_HANDLE_PROTOCOL = FUNCPTR(EFI_STATUS, EFI_HANDLE, PTR(EFI_GUID), PTR(PTR(VOID)))
-EFI_REGISTER_PROTOCOL_NOTIFY = FUNCPTR(EFI_STATUS, PTR(EFI_GUID), EFI_EVENT, PTR(PTR(VOID)))
-EFI_LOCATE_HANDLE = FUNCPTR(EFI_STATUS, EFI_LOCATE_SEARCH_TYPE, PTR(EFI_GUID), PTR(VOID), PTR(UINTN), PTR(EFI_HANDLE))
-EFI_LOCATE_DEVICE_PATH = FUNCPTR(EFI_STATUS, PTR(EFI_GUID), PTR(PTR(EFI_DEVICE_PATH_PROTOCOL)), PTR(EFI_HANDLE))
-EFI_INSTALL_CONFIGURATION_TABLE = FUNCPTR(EFI_STATUS, PTR(EFI_GUID), PTR(VOID))
-EFI_IMAGE_LOAD = FUNCPTR(EFI_STATUS, BOOLEAN, EFI_HANDLE, PTR(EFI_DEVICE_PATH_PROTOCOL), PTR(VOID) , UINTN, PTR(EFI_HANDLE))
-EFI_IMAGE_START = FUNCPTR(EFI_STATUS, EFI_HANDLE, PTR(UINTN), PTR(PTR(CHAR16)))
-EFI_EXIT = FUNCPTR(EFI_STATUS, EFI_HANDLE, EFI_STATUS, UINTN, PTR(CHAR16))
-EFI_IMAGE_UNLOAD = FUNCPTR(EFI_STATUS, EFI_HANDLE)
-EFI_EXIT_BOOT_SERVICES = FUNCPTR(EFI_STATUS, EFI_HANDLE, UINTN)
-EFI_GET_NEXT_MONOTONIC_COUNT = FUNCPTR(EFI_STATUS, PTR(UINT64))
-EFI_STALL = FUNCPTR(EFI_STATUS, UINTN)
-EFI_SET_WATCHDOG_TIMER = FUNCPTR(EFI_STATUS, UINTN, UINT64, UINTN, PTR(CHAR16))
-EFI_CONNECT_CONTROLLER = FUNCPTR(EFI_STATUS, EFI_HANDLE, PTR(EFI_HANDLE), PTR(EFI_DEVICE_PATH_PROTOCOL), BOOLEAN)
-EFI_DISCONNECT_CONTROLLER = FUNCPTR(EFI_STATUS, EFI_HANDLE, EFI_HANDLE, EFI_HANDLE)
-EFI_OPEN_PROTOCOL = FUNCPTR(EFI_STATUS, EFI_HANDLE, PTR(EFI_GUID), PTR(PTR(VOID)), EFI_HANDLE, EFI_HANDLE, UINT32)
-EFI_CLOSE_PROTOCOL = FUNCPTR(EFI_STATUS, EFI_HANDLE, PTR(EFI_GUID), EFI_HANDLE, EFI_HANDLE)
-EFI_OPEN_PROTOCOL_INFORMATION = FUNCPTR(EFI_STATUS, EFI_HANDLE, PTR(EFI_GUID), PTR(PTR(EFI_OPEN_PROTOCOL_INFORMATION_ENTRY)), PTR(UINTN))
-EFI_PROTOCOLS_PER_HANDLE = FUNCPTR(EFI_STATUS, EFI_HANDLE, PTR(PTR(PTR(EFI_GUID))), PTR(UINTN))
-EFI_LOCATE_HANDLE_BUFFER = FUNCPTR(EFI_STATUS, EFI_LOCATE_SEARCH_TYPE, PTR(EFI_GUID), PTR(VOID), PTR(UINTN), PTR(PTR(EFI_HANDLE)))
-EFI_LOCATE_PROTOCOL = FUNCPTR(EFI_STATUS, PTR(EFI_GUID), PTR(VOID), PTR(PTR(VOID)))
-EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES = FUNCPTR(EFI_STATUS, PTR(EFI_HANDLE)) # ...
-EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES = FUNCPTR(EFI_STATUS, EFI_HANDLE) # ...
-EFI_CALCULATE_CRC32 = FUNCPTR(EFI_STATUS, PTR(VOID), UINTN, PTR(UINT32))
-EFI_COPY_MEM = FUNCPTR(VOID, PTR(VOID), PTR(VOID), UINTN)
-EFI_SET_MEM = FUNCPTR(VOID, PTR(VOID), UINTN, UINT8)
-EFI_CREATE_EVENT_EX = FUNCPTR(EFI_STATUS, UINT32, EFI_TPL, EFI_EVENT_NOTIFY, PTR(VOID), PTR(EFI_GUID), PTR(EFI_EVENT))
+EFI_RAISE_TPL = FUNCPTR(EFI_TPL, EFI_TPL)
+EFI_RESTORE_TPL = FUNCPTR(VOID, EFI_TPL)
+EFI_ALLOCATE_PAGES = FUNCPTR(EFI_STATUS, EFI_ALLOCATE_TYPE, EFI_MEMORY_TYPE, UINTN, PTR(EFI_PHYSICAL_ADDRESS))
+EFI_FREE_PAGES = FUNCPTR(EFI_STATUS, EFI_PHYSICAL_ADDRESS, UINTN)
+EFI_GET_MEMORY_MAP = FUNCPTR(EFI_STATUS, PTR(UINTN), PTR(EFI_MEMORY_DESCRIPTOR), PTR(UINTN), PTR(UINTN), PTR(UINT32))
+EFI_ALLOCATE_POOL = FUNCPTR(EFI_STATUS, EFI_MEMORY_TYPE, UINTN, PTR(PTR(VOID)))
+EFI_FREE_POOL = FUNCPTR(EFI_STATUS, PTR(VOID))
+EFI_CREATE_EVENT = FUNCPTR(EFI_STATUS, UINT32, EFI_TPL, EFI_EVENT_NOTIFY, PTR(VOID), PTR(EFI_EVENT))
+EFI_SET_TIMER = FUNCPTR(EFI_STATUS, EFI_EVENT, EFI_TIMER_DELAY, UINT64)
+EFI_WAIT_FOR_EVENT = FUNCPTR(EFI_STATUS, UINTN, PTR(EFI_EVENT), PTR(UINTN))
+EFI_SIGNAL_EVENT = FUNCPTR(EFI_STATUS, EFI_EVENT)
+EFI_CLOSE_EVENT = FUNCPTR(EFI_STATUS, EFI_EVENT)
+EFI_CHECK_EVENT = FUNCPTR(EFI_STATUS, EFI_EVENT)
+EFI_INSTALL_PROTOCOL_INTERFACE = FUNCPTR(EFI_STATUS, PTR(EFI_HANDLE), PTR(EFI_GUID), EFI_INTERFACE_TYPE, PTR(VOID))
+EFI_REINSTALL_PROTOCOL_INTERFACE = FUNCPTR(EFI_STATUS, EFI_HANDLE, PTR(EFI_GUID), PTR(VOID), PTR(VOID))
+EFI_UNINSTALL_PROTOCOL_INTERFACE = FUNCPTR(EFI_STATUS, EFI_HANDLE, PTR(EFI_GUID), PTR(VOID))
+EFI_HANDLE_PROTOCOL = FUNCPTR(EFI_STATUS, EFI_HANDLE, PTR(EFI_GUID), PTR(PTR(VOID)))
+EFI_REGISTER_PROTOCOL_NOTIFY = FUNCPTR(EFI_STATUS, PTR(EFI_GUID), EFI_EVENT, PTR(PTR(VOID)))
+EFI_LOCATE_HANDLE = FUNCPTR(EFI_STATUS, EFI_LOCATE_SEARCH_TYPE, PTR(EFI_GUID), PTR(VOID), PTR(UINTN), PTR(EFI_HANDLE))
+EFI_LOCATE_DEVICE_PATH = FUNCPTR(EFI_STATUS, PTR(EFI_GUID), PTR(PTR(EFI_DEVICE_PATH_PROTOCOL)), PTR(EFI_HANDLE))
+EFI_INSTALL_CONFIGURATION_TABLE = FUNCPTR(EFI_STATUS, PTR(EFI_GUID), PTR(VOID))
+EFI_IMAGE_LOAD = FUNCPTR(EFI_STATUS, BOOLEAN, EFI_HANDLE, PTR(EFI_DEVICE_PATH_PROTOCOL), PTR(VOID) , UINTN, PTR(EFI_HANDLE))
+EFI_IMAGE_START = FUNCPTR(EFI_STATUS, EFI_HANDLE, PTR(UINTN), PTR(PTR(CHAR16)))
+EFI_EXIT = FUNCPTR(EFI_STATUS, EFI_HANDLE, EFI_STATUS, UINTN, PTR(CHAR16))
+EFI_IMAGE_UNLOAD = FUNCPTR(EFI_STATUS, EFI_HANDLE)
+EFI_EXIT_BOOT_SERVICES = FUNCPTR(EFI_STATUS, EFI_HANDLE, UINTN)
+EFI_GET_NEXT_MONOTONIC_COUNT = FUNCPTR(EFI_STATUS, PTR(UINT64))
+EFI_STALL = FUNCPTR(EFI_STATUS, UINTN)
+EFI_SET_WATCHDOG_TIMER = FUNCPTR(EFI_STATUS, UINTN, UINT64, UINTN, PTR(CHAR16))
+EFI_CONNECT_CONTROLLER = FUNCPTR(EFI_STATUS, EFI_HANDLE, PTR(EFI_HANDLE), PTR(EFI_DEVICE_PATH_PROTOCOL), BOOLEAN)
+EFI_DISCONNECT_CONTROLLER = FUNCPTR(EFI_STATUS, EFI_HANDLE, EFI_HANDLE, EFI_HANDLE)
+EFI_OPEN_PROTOCOL = FUNCPTR(EFI_STATUS, EFI_HANDLE, PTR(EFI_GUID), PTR(PTR(VOID)), EFI_HANDLE, EFI_HANDLE, UINT32)
+EFI_CLOSE_PROTOCOL = FUNCPTR(EFI_STATUS, EFI_HANDLE, PTR(EFI_GUID), EFI_HANDLE, EFI_HANDLE)
+EFI_OPEN_PROTOCOL_INFORMATION = FUNCPTR(EFI_STATUS, EFI_HANDLE, PTR(EFI_GUID), PTR(PTR(EFI_OPEN_PROTOCOL_INFORMATION_ENTRY)), PTR(UINTN))
+EFI_PROTOCOLS_PER_HANDLE = FUNCPTR(EFI_STATUS, EFI_HANDLE, PTR(PTR(PTR(EFI_GUID))), PTR(UINTN))
+EFI_LOCATE_HANDLE_BUFFER = FUNCPTR(EFI_STATUS, EFI_LOCATE_SEARCH_TYPE, PTR(EFI_GUID), PTR(VOID), PTR(UINTN), PTR(PTR(EFI_HANDLE)))
+EFI_LOCATE_PROTOCOL = FUNCPTR(EFI_STATUS, PTR(EFI_GUID), PTR(VOID), PTR(PTR(VOID)))
+EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES = FUNCPTR(EFI_STATUS, PTR(EFI_HANDLE)) # ...
+EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES = FUNCPTR(EFI_STATUS, EFI_HANDLE) # ...
+EFI_CALCULATE_CRC32 = FUNCPTR(EFI_STATUS, PTR(VOID), UINTN, PTR(UINT32))
+EFI_COPY_MEM = FUNCPTR(VOID, PTR(VOID), PTR(VOID), UINTN)
+EFI_SET_MEM = FUNCPTR(VOID, PTR(VOID), UINTN, UINT8)
+EFI_CREATE_EVENT_EX = FUNCPTR(EFI_STATUS, UINT32, EFI_TPL, EFI_EVENT_NOTIFY, PTR(VOID), PTR(EFI_GUID), PTR(EFI_EVENT))
class EFI_BOOT_SERVICES(STRUCT):
- _fields_ = [
- ('Hdr', EFI_TABLE_HEADER),
- ('RaiseTPL', EFI_RAISE_TPL),
- ('RestoreTPL', EFI_RESTORE_TPL),
- ('AllocatePages', EFI_ALLOCATE_PAGES),
- ('FreePages', EFI_FREE_PAGES),
- ('GetMemoryMap', EFI_GET_MEMORY_MAP),
- ('AllocatePool', EFI_ALLOCATE_POOL),
- ('FreePool', EFI_FREE_POOL),
- ('CreateEvent', EFI_CREATE_EVENT),
- ('SetTimer', EFI_SET_TIMER),
- ('WaitForEvent', EFI_WAIT_FOR_EVENT),
- ('SignalEvent', EFI_SIGNAL_EVENT),
- ('CloseEvent', EFI_CLOSE_EVENT),
- ('CheckEvent', EFI_CHECK_EVENT),
- ('InstallProtocolInterface', EFI_INSTALL_PROTOCOL_INTERFACE),
- ('ReinstallProtocolInterface', EFI_REINSTALL_PROTOCOL_INTERFACE),
- ('UninstallProtocolInterface', EFI_UNINSTALL_PROTOCOL_INTERFACE),
- ('HandleProtocol', EFI_HANDLE_PROTOCOL),
- ('Reserved', PTR(VOID)),
- ('RegisterProtocolNotify', EFI_REGISTER_PROTOCOL_NOTIFY),
- ('LocateHandle', EFI_LOCATE_HANDLE),
- ('LocateDevicePath', EFI_LOCATE_DEVICE_PATH),
- ('InstallConfigurationTable', EFI_INSTALL_CONFIGURATION_TABLE),
- ('LoadImage', EFI_IMAGE_LOAD),
- ('StartImage', EFI_IMAGE_START),
- ('Exit', EFI_EXIT),
- ('UnloadImage', EFI_IMAGE_UNLOAD),
- ('ExitBootServices', EFI_EXIT_BOOT_SERVICES),
- ('GetNextMonotonicCount', EFI_GET_NEXT_MONOTONIC_COUNT),
- ('Stall', EFI_STALL),
- ('SetWatchdogTimer', EFI_SET_WATCHDOG_TIMER),
- ('ConnectController', EFI_CONNECT_CONTROLLER),
- ('DisconnectController', EFI_DISCONNECT_CONTROLLER),
- ('OpenProtocol', EFI_OPEN_PROTOCOL),
- ('CloseProtocol', EFI_CLOSE_PROTOCOL),
- ('OpenProtocolInformation', EFI_OPEN_PROTOCOL_INFORMATION),
- ('ProtocolsPerHandle', EFI_PROTOCOLS_PER_HANDLE),
- ('LocateHandleBuffer', EFI_LOCATE_HANDLE_BUFFER),
- ('LocateProtocol', EFI_LOCATE_PROTOCOL),
- ('InstallMultipleProtocolInterfaces', EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES),
- ('UninstallMultipleProtocolInterfaces', EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES),
- ('CalculateCrc32', EFI_CALCULATE_CRC32),
- ('CopyMem', EFI_COPY_MEM),
- ('SetMem', EFI_SET_MEM),
- ('CreateEventEx', EFI_CREATE_EVENT_EX)
- ]
+ _fields_ = [
+ ('Hdr', EFI_TABLE_HEADER),
+ ('RaiseTPL', EFI_RAISE_TPL),
+ ('RestoreTPL', EFI_RESTORE_TPL),
+ ('AllocatePages', EFI_ALLOCATE_PAGES),
+ ('FreePages', EFI_FREE_PAGES),
+ ('GetMemoryMap', EFI_GET_MEMORY_MAP),
+ ('AllocatePool', EFI_ALLOCATE_POOL),
+ ('FreePool', EFI_FREE_POOL),
+ ('CreateEvent', EFI_CREATE_EVENT),
+ ('SetTimer', EFI_SET_TIMER),
+ ('WaitForEvent', EFI_WAIT_FOR_EVENT),
+ ('SignalEvent', EFI_SIGNAL_EVENT),
+ ('CloseEvent', EFI_CLOSE_EVENT),
+ ('CheckEvent', EFI_CHECK_EVENT),
+ ('InstallProtocolInterface', EFI_INSTALL_PROTOCOL_INTERFACE),
+ ('ReinstallProtocolInterface', EFI_REINSTALL_PROTOCOL_INTERFACE),
+ ('UninstallProtocolInterface', EFI_UNINSTALL_PROTOCOL_INTERFACE),
+ ('HandleProtocol', EFI_HANDLE_PROTOCOL),
+ ('Reserved', PTR(VOID)),
+ ('RegisterProtocolNotify', EFI_REGISTER_PROTOCOL_NOTIFY),
+ ('LocateHandle', EFI_LOCATE_HANDLE),
+ ('LocateDevicePath', EFI_LOCATE_DEVICE_PATH),
+ ('InstallConfigurationTable', EFI_INSTALL_CONFIGURATION_TABLE),
+ ('LoadImage', EFI_IMAGE_LOAD),
+ ('StartImage', EFI_IMAGE_START),
+ ('Exit', EFI_EXIT),
+ ('UnloadImage', EFI_IMAGE_UNLOAD),
+ ('ExitBootServices', EFI_EXIT_BOOT_SERVICES),
+ ('GetNextMonotonicCount', EFI_GET_NEXT_MONOTONIC_COUNT),
+ ('Stall', EFI_STALL),
+ ('SetWatchdogTimer', EFI_SET_WATCHDOG_TIMER),
+ ('ConnectController', EFI_CONNECT_CONTROLLER),
+ ('DisconnectController', EFI_DISCONNECT_CONTROLLER),
+ ('OpenProtocol', EFI_OPEN_PROTOCOL),
+ ('CloseProtocol', EFI_CLOSE_PROTOCOL),
+ ('OpenProtocolInformation', EFI_OPEN_PROTOCOL_INFORMATION),
+ ('ProtocolsPerHandle', EFI_PROTOCOLS_PER_HANDLE),
+ ('LocateHandleBuffer', EFI_LOCATE_HANDLE_BUFFER),
+ ('LocateProtocol', EFI_LOCATE_PROTOCOL),
+ ('InstallMultipleProtocolInterfaces', EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES),
+ ('UninstallMultipleProtocolInterfaces', EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES),
+ ('CalculateCrc32', EFI_CALCULATE_CRC32),
+ ('CopyMem', EFI_COPY_MEM),
+ ('SetMem', EFI_SET_MEM),
+ ('CreateEventEx', EFI_CREATE_EVENT_EX)
+ ]
class EFI_CONFIGURATION_TABLE(STRUCT):
- _fields_ = [
- ('VendorGuid', EFI_GUID),
- ('VendorTable', PTR(VOID)),
- ]
+ _fields_ = [
+ ('VendorGuid', EFI_GUID),
+ ('VendorTable', PTR(VOID)),
+ ]
# TODO: to be implemented
# @see: MdePkg\Include\Protocol\SimpleTextIn.h
@@ -232,36 +232,36 @@ class EFI_CONFIGURATION_TABLE(STRUCT):
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL = STRUCT
class EFI_SYSTEM_TABLE(STRUCT):
- _pack_ = 8
+ _pack_ = 8
- _fields_ = [
- ('Hdr', EFI_TABLE_HEADER),
- ('FirmwareVendor', PTR(CHAR16)),
- ('FirmwareRevision', UINT32),
- ('ConsoleInHandle', EFI_HANDLE),
- ('ConIn', PTR(EFI_SIMPLE_TEXT_INPUT_PROTOCOL)),
- ('ConsoleOutHandle', EFI_HANDLE),
- ('ConOut', PTR(EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL)),
- ('StandardErrorHandle', EFI_HANDLE),
- ('StdErr', PTR(EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL)),
- ('RuntimeServices', PTR(EFI_RUNTIME_SERVICES)),
- ('BootServices', PTR(EFI_BOOT_SERVICES)),
- ('NumberOfTableEntries', UINTN),
- ('ConfigurationTable', PTR(EFI_CONFIGURATION_TABLE))
- ]
+ _fields_ = [
+ ('Hdr', EFI_TABLE_HEADER),
+ ('FirmwareVendor', PTR(CHAR16)),
+ ('FirmwareRevision', UINT32),
+ ('ConsoleInHandle', EFI_HANDLE),
+ ('ConIn', PTR(EFI_SIMPLE_TEXT_INPUT_PROTOCOL)),
+ ('ConsoleOutHandle', EFI_HANDLE),
+ ('ConOut', PTR(EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL)),
+ ('StandardErrorHandle', EFI_HANDLE),
+ ('StdErr', PTR(EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL)),
+ ('RuntimeServices', PTR(EFI_RUNTIME_SERVICES)),
+ ('BootServices', PTR(EFI_BOOT_SERVICES)),
+ ('NumberOfTableEntries', UINTN),
+ ('ConfigurationTable', PTR(EFI_CONFIGURATION_TABLE))
+ ]
__all__ = [
- 'EFI_TIME_ADJUST_DAYLIGHT',
- 'EFI_TIME_IN_DAYLIGHT',
- 'EFI_UNSPECIFIED_TIMEZONE',
- 'EFI_RUNTIME_SERVICES',
- 'EFI_BOOT_SERVICES',
- 'EFI_CONFIGURATION_TABLE',
- 'EFI_SYSTEM_TABLE',
- 'EFI_ALLOCATE_TYPE',
- 'EFI_INTERFACE_TYPE',
- 'EFI_LOCATE_SEARCH_TYPE',
- 'EFI_DEVICE_PATH_PROTOCOL',
- 'EFI_OPEN_PROTOCOL_INFORMATION_ENTRY',
- 'EFI_IMAGE_UNLOAD'
+ 'EFI_TIME_ADJUST_DAYLIGHT',
+ 'EFI_TIME_IN_DAYLIGHT',
+ 'EFI_UNSPECIFIED_TIMEZONE',
+ 'EFI_RUNTIME_SERVICES',
+ 'EFI_BOOT_SERVICES',
+ 'EFI_CONFIGURATION_TABLE',
+ 'EFI_SYSTEM_TABLE',
+ 'EFI_ALLOCATE_TYPE',
+ 'EFI_INTERFACE_TYPE',
+ 'EFI_LOCATE_SEARCH_TYPE',
+ 'EFI_DEVICE_PATH_PROTOCOL',
+ 'EFI_OPEN_PROTOCOL_INFORMATION_ENTRY',
+ 'EFI_IMAGE_UNLOAD'
]
\ No newline at end of file
diff --git a/qiling/os/uefi/bs.py b/qiling/os/uefi/bs.py
index 3532a159c..91e139254 100644
--- a/qiling/os/uefi/bs.py
+++ b/qiling/os/uefi/bs.py
@@ -16,581 +16,581 @@
from qiling.os.uefi.protocols import common
@dxeapi(params = {
- "NewTpl" : ULONGLONG # EFI_TPL
+ "NewTpl" : ULONGLONG # EFI_TPL
})
def hook_RaiseTPL(ql: Qiling, address: int, params):
- prev_tpl = ql.loader.tpl
- ql.loader.tpl = params["NewTpl"]
+ prev_tpl = ql.loader.tpl
+ ql.loader.tpl = params["NewTpl"]
- return prev_tpl
+ return prev_tpl
@dxeapi(params = {
- "OldTpl": ULONGLONG # EFI_TPL
+ "OldTpl": ULONGLONG # EFI_TPL
})
def hook_RestoreTPL(ql: Qiling, address: int, params):
- ql.loader.tpl = params["OldTpl"]
+ ql.loader.tpl = params["OldTpl"]
@dxeapi(params = {
- "type" : INT, # EFI_ALLOCATE_TYPE
- "MemoryType": INT, # EFI_MEMORY_TYPE
- "Pages" : ULONGLONG, # UINTN
- "Memory" : POINTER # PTR(EFI_PHYSICAL_ADDRESS)
+ "type" : INT, # EFI_ALLOCATE_TYPE
+ "MemoryType": INT, # EFI_MEMORY_TYPE
+ "Pages" : ULONGLONG, # UINTN
+ "Memory" : POINTER # PTR(EFI_PHYSICAL_ADDRESS)
})
def hook_AllocatePages(ql: Qiling, address: int, params):
- alloc_size = params["Pages"] * PAGE_SIZE
+ alloc_size = params["Pages"] * PAGE_SIZE
- if params['type'] == EFI_ALLOCATE_TYPE.AllocateAddress:
- address = read_int64(ql, params["Memory"])
+ if params['type'] == EFI_ALLOCATE_TYPE.AllocateAddress:
+ address = read_int64(ql, params["Memory"])
- # TODO: check the range [address, address + alloc_size] is available first
- ql.mem.map(address, alloc_size)
- else:
- # TODO: allocate memory according to 'MemoryType'
- address = ql.loader.dxe_context.heap.alloc(alloc_size)
+ # TODO: check the range [address, address + alloc_size] is available first
+ ql.mem.map(address, alloc_size)
+ else:
+ # TODO: allocate memory according to 'MemoryType'
+ address = ql.loader.dxe_context.heap.alloc(alloc_size)
- if address == 0:
- return EFI_OUT_OF_RESOURCES
+ if address == 0:
+ return EFI_OUT_OF_RESOURCES
- write_int64(ql, params["Memory"], address)
+ write_int64(ql, params["Memory"], address)
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "Memory" : ULONGLONG, # EFI_PHYSICAL_ADDRESS
- "Pages" : ULONGLONG # UINTN
+ "Memory" : ULONGLONG, # EFI_PHYSICAL_ADDRESS
+ "Pages" : ULONGLONG # UINTN
})
def hook_FreePages(ql: Qiling, address: int, params):
- address = params["Memory"]
+ address = params["Memory"]
- ret = ql.loader.dxe_context.heap.free(address)
+ ret = ql.loader.dxe_context.heap.free(address)
- return EFI_SUCCESS if ret else EFI_INVALID_PARAMETER
+ return EFI_SUCCESS if ret else EFI_INVALID_PARAMETER
@dxeapi(params = {
- "MemoryMapSize" : POINTER, # PTR(UINTN)
- "MemoryMap" : POINTER, # PTR(EFI_MEMORY_DESCRIPTOR)
- "MapKey" : POINTER, # PTR(UINTN)
- "DescriptorSize" : POINTER, # PTR(UINTN)
- "DescriptorVersion" : POINTER # PTR(UINT32)
+ "MemoryMapSize" : POINTER, # PTR(UINTN)
+ "MemoryMap" : POINTER, # PTR(EFI_MEMORY_DESCRIPTOR)
+ "MapKey" : POINTER, # PTR(UINTN)
+ "DescriptorSize" : POINTER, # PTR(UINTN)
+ "DescriptorVersion" : POINTER # PTR(UINT32)
})
def hook_GetMemoryMap(ql: Qiling, address: int, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "PoolType" : INT, # EFI_MEMORY_TYPE
- "Size" : INT, # UINTN
- "Buffer" : POINTER # PTR(PTR(VOID))
+ "PoolType" : INT, # EFI_MEMORY_TYPE
+ "Size" : INT, # UINTN
+ "Buffer" : POINTER # PTR(PTR(VOID))
})
def hook_AllocatePool(ql: Qiling, address: int, params):
- # TODO: allocate memory acording to "PoolType"
- Size = params["Size"]
- Buffer = params["Buffer"]
+ # TODO: allocate memory acording to "PoolType"
+ Size = params["Size"]
+ Buffer = params["Buffer"]
- address = ql.loader.dxe_context.heap.alloc(Size)
- write_int64(ql, Buffer, address)
+ address = ql.loader.dxe_context.heap.alloc(Size)
+ write_int64(ql, Buffer, address)
- return EFI_SUCCESS if address else EFI_OUT_OF_RESOURCES
+ return EFI_SUCCESS if address else EFI_OUT_OF_RESOURCES
@dxeapi(params = {
- "Buffer": POINTER # PTR(VOID)
+ "Buffer": POINTER # PTR(VOID)
})
def hook_FreePool(ql: Qiling, address: int, params):
- Buffer = params["Buffer"]
+ Buffer = params["Buffer"]
- ret = ql.loader.dxe_context.heap.free(Buffer)
+ ret = ql.loader.dxe_context.heap.free(Buffer)
- return EFI_SUCCESS if ret else EFI_INVALID_PARAMETER
+ return EFI_SUCCESS if ret else EFI_INVALID_PARAMETER
@dxeapi(params = {
- "Type" : UINT, # UINT32
- "NotifyTpl" : UINT, # EFI_TPL
- "NotifyFunction": POINTER, # EFI_EVENT_NOTIFY
- "NotifyContext" : POINTER, # PTR(VOID)
- "Event" : POINTER # PTR(EFI_EVENT)
+ "Type" : UINT, # UINT32
+ "NotifyTpl" : UINT, # EFI_TPL
+ "NotifyFunction": POINTER, # EFI_EVENT_NOTIFY
+ "NotifyContext" : POINTER, # PTR(VOID)
+ "Event" : POINTER # PTR(EFI_EVENT)
})
def hook_CreateEvent(ql: Qiling, address: int, params):
- return CreateEvent(ql, params)
+ return CreateEvent(ql, params)
@dxeapi(params = {
- "Event" : POINTER, # EFI_EVENT
- "Type" : ULONGLONG, # EFI_TIMER_DELAY
- "TriggerTime" : ULONGLONG # UINT64
+ "Event" : POINTER, # EFI_EVENT
+ "Type" : ULONGLONG, # EFI_TIMER_DELAY
+ "TriggerTime" : ULONGLONG # UINT64
})
def hook_SetTimer(ql: Qiling, address: int, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "NumberOfEvents": ULONGLONG, # UINTN
- "Event" : POINTER, # PTR(EFI_EVENT)
- "Index" : POINTER, # PTR(UINTN)
+ "NumberOfEvents": ULONGLONG, # UINTN
+ "Event" : POINTER, # PTR(EFI_EVENT)
+ "Index" : POINTER, # PTR(UINTN)
})
def hook_WaitForEvent(ql: Qiling, address: int, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "Event": POINTER # EFI_EVENT
+ "Event": POINTER # EFI_EVENT
})
def hook_SignalEvent(ql: Qiling, address: int, params):
- event_id = params["Event"]
+ event_id = params["Event"]
- if event_id not in ql.loader.events:
- return EFI_INVALID_PARAMETER
+ if event_id not in ql.loader.events:
+ return EFI_INVALID_PARAMETER
- signal_event(ql, event_id)
+ signal_event(ql, event_id)
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "Event": POINTER # EFI_EVENT
+ "Event": POINTER # EFI_EVENT
})
def hook_CloseEvent(ql: Qiling, address: int, params):
- event_id = params["Event"]
+ event_id = params["Event"]
- if event_id not in ql.loader.events:
- return EFI_INVALID_PARAMETER
+ if event_id not in ql.loader.events:
+ return EFI_INVALID_PARAMETER
- del ql.loader.events[event_id]
+ del ql.loader.events[event_id]
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "Event": POINTER # EFI_EVENT
+ "Event": POINTER # EFI_EVENT
})
def hook_CheckEvent(ql: Qiling, address: int, params):
- event_id = params["Event"]
+ event_id = params["Event"]
- return EFI_SUCCESS if ql.loader.events[event_id]["Set"] else EFI_NOT_READY
+ return EFI_SUCCESS if ql.loader.events[event_id]["Set"] else EFI_NOT_READY
@dxeapi(params = {
- "Handle" : POINTER, # PTR(EFI_HANDLE)
- "Protocol" : GUID, # PTR(EFI_GUID)
- "InterfaceType" : ULONGLONG, # EFI_INTERFACE_TYPE
- "Interface" : POINTER, # PTR(VOID)
+ "Handle" : POINTER, # PTR(EFI_HANDLE)
+ "Protocol" : GUID, # PTR(EFI_GUID)
+ "InterfaceType" : ULONGLONG, # EFI_INTERFACE_TYPE
+ "Interface" : POINTER, # PTR(VOID)
})
def hook_InstallProtocolInterface(ql: Qiling, address: int, params):
- return common.InstallProtocolInterface(ql.loader.dxe_context, params)
+ return common.InstallProtocolInterface(ql.loader.dxe_context, params)
@dxeapi(params = {
- "Handle" : POINTER, # EFI_HANDLE
- "Protocol" : GUID, # PTR(EFI_GUID)
- "OldInterface" : POINTER, # PTR(VOID)
- "NewInterface" : POINTER # PTR(VOID)
+ "Handle" : POINTER, # EFI_HANDLE
+ "Protocol" : GUID, # PTR(EFI_GUID)
+ "OldInterface" : POINTER, # PTR(VOID)
+ "NewInterface" : POINTER # PTR(VOID)
})
def hook_ReinstallProtocolInterface(ql: Qiling, address: int, params):
- handle = params["Handle"]
+ handle = params["Handle"]
- if handle not in ql.loader.dxe_context.protocols:
- return EFI_NOT_FOUND
+ if handle not in ql.loader.dxe_context.protocols:
+ return EFI_NOT_FOUND
- dic = ql.loader.dxe_context.protocols[handle]
- protocol = params["Protocol"]
+ dic = ql.loader.dxe_context.protocols[handle]
+ protocol = params["Protocol"]
- if protocol not in dic:
- return EFI_NOT_FOUND
+ if protocol not in dic:
+ return EFI_NOT_FOUND
- dic[protocol] = params["NewInterface"]
+ dic[protocol] = params["NewInterface"]
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "Handle" : POINTER, # EFI_HANDLE
- "Protocol" : GUID, # PTR(EFI_GUID)
- "Interface" : POINTER # PTR(VOID)
+ "Handle" : POINTER, # EFI_HANDLE
+ "Protocol" : GUID, # PTR(EFI_GUID)
+ "Interface" : POINTER # PTR(VOID)
})
def hook_UninstallProtocolInterface(ql: Qiling, address: int, params):
- return common.UninstallProtocolInterface(ql.loader.dxe_context, params)
+ return common.UninstallProtocolInterface(ql.loader.dxe_context, params)
@dxeapi(params = {
- "Handle" : POINTER, # EFI_HANDLE
- "Protocol" : GUID, # PTR(EFI_GUID)
- "Interface" : POINTER # PTR(PTR(VOID))
+ "Handle" : POINTER, # EFI_HANDLE
+ "Protocol" : GUID, # PTR(EFI_GUID)
+ "Interface" : POINTER # PTR(PTR(VOID))
})
def hook_HandleProtocol(ql: Qiling, address: int, params):
- return common.HandleProtocol(ql.loader.dxe_context, params)
+ return common.HandleProtocol(ql.loader.dxe_context, params)
@dxeapi(params = {
- "Protocol" : GUID, # PTR(EFI_GUID)
- "Event" : POINTER, # EFI_EVENT
- "Registration" : POINTER # PTR(PTR(VOID))
+ "Protocol" : GUID, # PTR(EFI_GUID)
+ "Event" : POINTER, # EFI_EVENT
+ "Registration" : POINTER # PTR(PTR(VOID))
})
def hook_RegisterProtocolNotify(ql: Qiling, address: int, params):
- event = params['Event']
- proto = params["Protocol"]
+ event = params['Event']
+ proto = params["Protocol"]
- if event in ql.loader.events:
- ql.loader.events[event]['Guid'] = proto
+ if event in ql.loader.events:
+ ql.loader.events[event]['Guid'] = proto
- return EFI_SUCCESS
+ return EFI_SUCCESS
- return EFI_INVALID_PARAMETER
+ return EFI_INVALID_PARAMETER
@dxeapi(params = {
- "SearchType": INT, # EFI_LOCATE_SEARCH_TYPE
- "Protocol" : GUID, # PTR(EFI_GUID)
- "SearchKey" : POINTER, # PTR(VOID)
- "BufferSize": POINTER, # PTR(UINTN)
- "Buffer" : POINTER # PTR(EFI_HANDLE)
+ "SearchType": INT, # EFI_LOCATE_SEARCH_TYPE
+ "Protocol" : GUID, # PTR(EFI_GUID)
+ "SearchKey" : POINTER, # PTR(VOID)
+ "BufferSize": POINTER, # PTR(UINTN)
+ "Buffer" : POINTER # PTR(EFI_HANDLE)
})
def hook_LocateHandle(ql: Qiling, address: int, params):
- return common.LocateHandle(ql.loader.dxe_context, params)
+ return common.LocateHandle(ql.loader.dxe_context, params)
@dxeapi(params = {
- "Protocol" : GUID, # PTR(EFI_GUID)
- "DevicePath": POINTER, # PTR(PTR(EFI_DEVICE_PATH_PROTOCOL))
- "Device" : POINTER # PTR(EFI_HANDLE)
+ "Protocol" : GUID, # PTR(EFI_GUID)
+ "DevicePath": POINTER, # PTR(PTR(EFI_DEVICE_PATH_PROTOCOL))
+ "Device" : POINTER # PTR(EFI_HANDLE)
})
def hook_LocateDevicePath(ql: Qiling, address: int, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "Guid" : GUID, # PTR(EFI_GUID)
- "Table" : POINTER # PTR(VOID)
+ "Guid" : GUID, # PTR(EFI_GUID)
+ "Table" : POINTER # PTR(VOID)
})
def hook_InstallConfigurationTable(ql: Qiling, address: int, params):
- return common.InstallConfigurationTable(ql.loader.dxe_context, params)
+ return common.InstallConfigurationTable(ql.loader.dxe_context, params)
@dxeapi(params = {
- "BootPolicy" : BOOL, # BOOLEAN
- "ParentImageHandle" : POINTER, # EFI_HANDLE
- "DevicePath" : POINTER, # PTR(EFI_DEVICE_PATH_PROTOCOL)
- "SourceBuffer" : POINTER, # PTR(VOID)
- "SourceSize" : ULONGLONG, # UINTN
- "ImageHandle" : POINTER # PTR(EFI_HANDLE)
+ "BootPolicy" : BOOL, # BOOLEAN
+ "ParentImageHandle" : POINTER, # EFI_HANDLE
+ "DevicePath" : POINTER, # PTR(EFI_DEVICE_PATH_PROTOCOL)
+ "SourceBuffer" : POINTER, # PTR(VOID)
+ "SourceSize" : ULONGLONG, # UINTN
+ "ImageHandle" : POINTER # PTR(EFI_HANDLE)
})
def hook_LoadImage(ql: Qiling, address: int, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "ImageHandle" : POINTER, # EFI_HANDLE
- "ExitDataSize" : POINTER, # PTR(UINTN)
- "ExitData" : POINTER # PTR(PTR(CHAR16))
+ "ImageHandle" : POINTER, # EFI_HANDLE
+ "ExitDataSize" : POINTER, # PTR(UINTN)
+ "ExitData" : POINTER # PTR(PTR(CHAR16))
})
def hook_StartImage(ql: Qiling, address: int, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "ImageHandle" : POINTER, # EFI_HANDLE
- "ExitStatus" : ULONGLONG, # EFI_STATUS
- "ExitDataSize" : ULONGLONG, # UINTN
- "ExitData" : POINTER # PTR(CHAR16)
+ "ImageHandle" : POINTER, # EFI_HANDLE
+ "ExitStatus" : ULONGLONG, # EFI_STATUS
+ "ExitDataSize" : ULONGLONG, # UINTN
+ "ExitData" : POINTER # PTR(CHAR16)
})
def hook_Exit(ql: Qiling, address: int, params):
- ql.emu_stop()
+ ql.emu_stop()
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "ImageHandle" : POINTER # EFI_HANDLE
+ "ImageHandle" : POINTER # EFI_HANDLE
})
def hook_UnloadImage(ql: Qiling, address: int, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "ImageHandle" : POINTER, # EFI_HANDLE
- "MapKey" : ULONGLONG # UINTN
+ "ImageHandle" : POINTER, # EFI_HANDLE
+ "MapKey" : ULONGLONG # UINTN
})
def hook_ExitBootServices(ql: Qiling, address: int, params):
- ql.emu_stop()
+ ql.emu_stop()
- # TODO: cleanup BS tableas and data, and notify signal list gEfiEventExitBootServicesGuid
- # @see: MdeModulePkg\Core\Dxe\DxeMain\DxeMain.c, CoreExitBootServices
+ # TODO: cleanup BS tableas and data, and notify signal list gEfiEventExitBootServicesGuid
+ # @see: MdeModulePkg\Core\Dxe\DxeMain\DxeMain.c, CoreExitBootServices
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "Count": POINTER # PTR(UINT64)
+ "Count": POINTER # PTR(UINT64)
})
def hook_GetNextMonotonicCount(ql: Qiling, address: int, params):
- out = params["Count"]
+ out = params["Count"]
- ql.os.monotonic_count += 1
- write_int64(ql, out, ql.os.monotonic_count)
+ ql.os.monotonic_count += 1
+ write_int64(ql, out, ql.os.monotonic_count)
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "Microseconds": ULONGLONG # UINTN
+ "Microseconds": ULONGLONG # UINTN
})
def hook_Stall(ql: Qiling, address: int, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "Timeout" : ULONGLONG, # UINTN
- "WatchdogCode" : ULONGLONG, # UINT64
- "DataSize" : ULONGLONG, # UINTN
- "WatchdogData" : POINTER # PTR(CHAR16)
+ "Timeout" : ULONGLONG, # UINTN
+ "WatchdogCode" : ULONGLONG, # UINT64
+ "DataSize" : ULONGLONG, # UINTN
+ "WatchdogData" : POINTER # PTR(CHAR16)
})
def hook_SetWatchdogTimer(ql: Qiling, address: int, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "ControllerHandle" : POINTER, # EFI_HANDLE
- "DriverImageHandle" : POINTER, #PTR(EFI_HANDLE)
- "RemainingDevicePath" : POINTER, # PTR(EFI_DEVICE_PATH_PROTOCOL)
- "Recursive" : BOOL # BOOLEAN
+ "ControllerHandle" : POINTER, # EFI_HANDLE
+ "DriverImageHandle" : POINTER, #PTR(EFI_HANDLE)
+ "RemainingDevicePath" : POINTER, # PTR(EFI_DEVICE_PATH_PROTOCOL)
+ "Recursive" : BOOL # BOOLEAN
})
def hook_ConnectController(ql: Qiling, address: int, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "ControllerHandle" : POINTER, # EFI_HANDLE
- "DriverImageHandle" : POINTER, # EFI_HANDLE
- "ChildHandle" : POINTER # EFI_HANDLE
+ "ControllerHandle" : POINTER, # EFI_HANDLE
+ "DriverImageHandle" : POINTER, # EFI_HANDLE
+ "ChildHandle" : POINTER # EFI_HANDLE
})
def hook_DisconnectController(ql: Qiling, address: int, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "Handle" : POINTER, # EFI_HANDLE
- "Protocol" : GUID, # PTR(EFI_GUID)
- "Interface" : POINTER, # PTR(PTR(VOID))
- "AgentHandle" : POINTER, # EFI_HANDLE
- "ControllerHandle" : POINTER, # EFI_HANDLE
- "Attributes" : UINT # UINT32
+ "Handle" : POINTER, # EFI_HANDLE
+ "Protocol" : GUID, # PTR(EFI_GUID)
+ "Interface" : POINTER, # PTR(PTR(VOID))
+ "AgentHandle" : POINTER, # EFI_HANDLE
+ "ControllerHandle" : POINTER, # EFI_HANDLE
+ "Attributes" : UINT # UINT32
})
def hook_OpenProtocol(ql: Qiling, address: int, params):
- return common.LocateProtocol(ql.loader.dxe_context, params)
+ return common.LocateProtocol(ql.loader.dxe_context, params)
@dxeapi(params = {
- "Handle" : POINTER, # EFI_HANDLE
- "Protocol" : GUID, # PTR(EFI_GUID)
- "AgentHandle" : POINTER, # EFI_HANDLE
- "ControllerHandle" : POINTER # EFI_HANDLE
+ "Handle" : POINTER, # EFI_HANDLE
+ "Protocol" : GUID, # PTR(EFI_GUID)
+ "AgentHandle" : POINTER, # EFI_HANDLE
+ "ControllerHandle" : POINTER # EFI_HANDLE
})
def hook_CloseProtocol(ql: Qiling, address: int, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "Handle" : POINTER, # EFI_HANDLE
- "Protocol" : GUID, # PTR(EFI_GUID)
- "EntryBuffer" : POINTER, # PTR(PTR(EFI_OPEN_PROTOCOL_INFORMATION_ENTRY))
- "EntryCount" : POINTER # PTR(UINTN)
+ "Handle" : POINTER, # EFI_HANDLE
+ "Protocol" : GUID, # PTR(EFI_GUID)
+ "EntryBuffer" : POINTER, # PTR(PTR(EFI_OPEN_PROTOCOL_INFORMATION_ENTRY))
+ "EntryCount" : POINTER # PTR(UINTN)
})
def hook_OpenProtocolInformation(ql: Qiling, address: int, params):
- return EFI_NOT_FOUND
+ return EFI_NOT_FOUND
@dxeapi(params = {
- "Handle" : POINTER, # EFI_HANDLE
- "ProtocolBuffer" : POINTER, # PTR(PTR(PTR(EFI_GUID)))
- "ProtocolBufferCount" : POINTER # PTR(UINTN)
+ "Handle" : POINTER, # EFI_HANDLE
+ "ProtocolBuffer" : POINTER, # PTR(PTR(PTR(EFI_GUID)))
+ "ProtocolBufferCount" : POINTER # PTR(UINTN)
})
def hook_ProtocolsPerHandle(ql: Qiling, address: int, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "SearchType": INT, # EFI_LOCATE_SEARCH_TYPE
- "Protocol" : GUID, # PTR(EFI_GUID)
- "SearchKey" : POINTER, # PTR(VOID)
- "NoHandles" : POINTER, # PTR(UINTN)
- "Buffer" : POINTER # PTR(PTR(EFI_HANDLE))
+ "SearchType": INT, # EFI_LOCATE_SEARCH_TYPE
+ "Protocol" : GUID, # PTR(EFI_GUID)
+ "SearchKey" : POINTER, # PTR(VOID)
+ "NoHandles" : POINTER, # PTR(UINTN)
+ "Buffer" : POINTER # PTR(PTR(EFI_HANDLE))
})
def hook_LocateHandleBuffer(ql: Qiling, address: int, params):
- buffer_size, handles = common.LocateHandles(ql.loader.dxe_context, params)
- write_int64(ql, params["NoHandles"], len(handles))
+ buffer_size, handles = common.LocateHandles(ql.loader.dxe_context, params)
+ write_int64(ql, params["NoHandles"], len(handles))
- if len(handles) == 0:
- return EFI_NOT_FOUND
+ if len(handles) == 0:
+ return EFI_NOT_FOUND
- address = ql.loader.dxe_context.heap.alloc(buffer_size)
- write_int64(ql, params["Buffer"], address)
+ address = ql.loader.dxe_context.heap.alloc(buffer_size)
+ write_int64(ql, params["Buffer"], address)
- if address == 0:
- return EFI_OUT_OF_RESOURCES
+ if address == 0:
+ return EFI_OUT_OF_RESOURCES
- for handle in handles:
- write_int64(ql, address, handle)
- address += ql.arch.pointersize
+ for handle in handles:
+ write_int64(ql, address, handle)
+ address += ql.arch.pointersize
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "Protocol" : GUID, # PTR(EFI_GUID)
- "Registration" : POINTER, # PTR(VOID)
- "Interface" : POINTER # PTR(PTR(VOID))
+ "Protocol" : GUID, # PTR(EFI_GUID)
+ "Registration" : POINTER, # PTR(VOID)
+ "Interface" : POINTER # PTR(PTR(VOID))
})
def hook_LocateProtocol(ql: Qiling, address: int, params):
- return common.LocateProtocol(ql.loader.dxe_context, params)
+ return common.LocateProtocol(ql.loader.dxe_context, params)
@dxeapi(params = {
- "Handle" : POINTER # PTR(EFI_HANDLE)
- # ...
+ "Handle" : POINTER # PTR(EFI_HANDLE)
+ # ...
})
def hook_InstallMultipleProtocolInterfaces(ql: Qiling, address: int, params):
- handle = read_int64(ql, params["Handle"])
+ handle = read_int64(ql, params["Handle"])
- if handle == 0:
- handle = ql.loader.dxe_context.heap.alloc(ql.arch.pointersize)
+ if handle == 0:
+ handle = ql.loader.dxe_context.heap.alloc(ql.arch.pointersize)
- dic = ql.loader.dxe_context.protocols.get(handle, {})
+ dic = ql.loader.dxe_context.protocols.get(handle, {})
- # process elipsiss arguments
- index = 1
- while ql.os.fcall.cc.getRawParam(index) != 0:
- GUID_ptr = ql.os.fcall.cc.getRawParam(index)
- protocol_ptr = ql.os.fcall.cc.getRawParam(index + 1)
+ # process elipsiss arguments
+ index = 1
+ while ql.os.fcall.cc.getRawParam(index) != 0:
+ GUID_ptr = ql.os.fcall.cc.getRawParam(index)
+ protocol_ptr = ql.os.fcall.cc.getRawParam(index + 1)
- GUID = str(ql.os.utils.read_guid(GUID_ptr))
- dic[GUID] = protocol_ptr
+ GUID = str(ql.os.utils.read_guid(GUID_ptr))
+ dic[GUID] = protocol_ptr
- ql.log.info(f'Installing protocol interface {guids_db.get(GUID.upper(), GUID)} to {protocol_ptr:#x}')
- index += 2
+ ql.log.info(f'Installing protocol interface {guids_db.get(GUID.upper(), GUID)} to {protocol_ptr:#x}')
+ index += 2
- ql.loader.dxe_context.protocols[handle] = dic
- execute_protocol_notifications(ql, True)
- write_int64(ql, params["Handle"], handle)
+ ql.loader.dxe_context.protocols[handle] = dic
+ execute_protocol_notifications(ql, True)
+ write_int64(ql, params["Handle"], handle)
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "Handle" : POINTER # EFI_HANDLE
- # ...
+ "Handle" : POINTER # EFI_HANDLE
+ # ...
})
def hook_UninstallMultipleProtocolInterfaces(ql: Qiling, address: int, params):
- handle = params["Handle"]
+ handle = params["Handle"]
- if handle not in ql.loader.dxe_context.protocols:
- return EFI_NOT_FOUND
+ if handle not in ql.loader.dxe_context.protocols:
+ return EFI_NOT_FOUND
- dic = ql.loader.dxe_context.protocols[handle]
+ dic = ql.loader.dxe_context.protocols[handle]
- # process elipsiss arguments
- index = 1
- while ql.os.fcall.cc.getRawParam(index) != 0:
- GUID_ptr = ql.os.fcall.cc.getRawParam(index)
- protocol_ptr = ql.os.fcall.cc.getRawParam(index + 1)
+ # process elipsiss arguments
+ index = 1
+ while ql.os.fcall.cc.getRawParam(index) != 0:
+ GUID_ptr = ql.os.fcall.cc.getRawParam(index)
+ protocol_ptr = ql.os.fcall.cc.getRawParam(index + 1)
- GUID = str(ql.os.utils.read_guid(GUID_ptr))
+ GUID = str(ql.os.utils.read_guid(GUID_ptr))
- if GUID not in dic:
- return EFI_INVALID_PARAMETER
+ if GUID not in dic:
+ return EFI_INVALID_PARAMETER
- del dic[GUID]
+ del dic[GUID]
- ql.log.info(f'Uninstalling protocol interface {guids_db.get(GUID.upper(), GUID)} from {protocol_ptr:#x}')
- index += 2
+ ql.log.info(f'Uninstalling protocol interface {guids_db.get(GUID.upper(), GUID)} from {protocol_ptr:#x}')
+ index += 2
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "Data" : POINTER, # PTR(VOID)
- "DataSize" : ULONGLONG, # UINTN
- "Crc32" : POINTER # PTR(UINT32)
+ "Data" : POINTER, # PTR(VOID)
+ "DataSize" : ULONGLONG, # UINTN
+ "Crc32" : POINTER # PTR(UINT32)
})
def hook_CalculateCrc32(ql: Qiling, address: int, params):
- data = bytes(ql.mem.read(params['Data'], params['DataSize']))
- write_int32(ql, params['Crc32'], crc32(data))
+ data = bytes(ql.mem.read(params['Data'], params['DataSize']))
+ write_int32(ql, params['Crc32'], crc32(data))
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "Destination" : POINTER, # PTR(VOID)
- "Source" : POINTER, # PTR(VOID)
- "Length" : SIZE_T # UINTN
+ "Destination" : POINTER, # PTR(VOID)
+ "Source" : POINTER, # PTR(VOID)
+ "Length" : SIZE_T # UINTN
})
def hook_CopyMem(ql: Qiling, address: int, params):
- dst = params["Destination"]
- src = params["Source"]
- length = params["Length"]
+ dst = params["Destination"]
+ src = params["Source"]
+ length = params["Length"]
- ql.mem.write(dst, bytes(ql.mem.read(src, length)))
+ ql.mem.write(dst, bytes(ql.mem.read(src, length)))
@dxeapi(params = {
- "Buffer": POINTER, # PTR(VOID)
- "Size" : SIZE_T, # UINTN
- "Value" : BYTE # UINT8
+ "Buffer": POINTER, # PTR(VOID)
+ "Size" : SIZE_T, # UINTN
+ "Value" : BYTE # UINT8
})
def hook_SetMem(ql: Qiling, address: int, params):
- buffer = params["Buffer"]
- value: int = params["Value"] & 0xff
- size = params["Size"]
+ buffer = params["Buffer"]
+ value: int = params["Value"] & 0xff
+ size = params["Size"]
- ql.mem.write(buffer, bytes([value]) * size)
+ ql.mem.write(buffer, bytes([value]) * size)
@dxeapi(params = {
- "Type" : UINT, # UINT32
- "NotifyTpl" : ULONGLONG,# EFI_TPL
- "NotifyFunction": POINTER, # EFI_EVENT_NOTIFY
- "NotifyContext" : POINTER, # PTR(VOID)
- "EventGroup" : GUID, # PTR(EFI_GUID)
- "Event" : POINTER # PTR(EFI_EVENT)
+ "Type" : UINT, # UINT32
+ "NotifyTpl" : ULONGLONG,# EFI_TPL
+ "NotifyFunction": POINTER, # EFI_EVENT_NOTIFY
+ "NotifyContext" : POINTER, # PTR(VOID)
+ "EventGroup" : GUID, # PTR(EFI_GUID)
+ "Event" : POINTER # PTR(EFI_EVENT)
})
def hook_CreateEventEx(ql: Qiling, address: int, params):
- return CreateEvent(ql, params)
+ return CreateEvent(ql, params)
def CreateEvent(ql: Qiling, params):
- event_id = len(ql.loader.events)
- event_dic = {
- "NotifyFunction": params["NotifyFunction"],
- "CallbackArgs" : [event_id, params["NotifyContext"]],
- "Guid" : "",
- "Set" : False
- }
+ event_id = len(ql.loader.events)
+ event_dic = {
+ "NotifyFunction": params["NotifyFunction"],
+ "CallbackArgs" : [event_id, params["NotifyContext"]],
+ "Guid" : "",
+ "Set" : False
+ }
- if "EventGroup" in params:
- event_dic["EventGroup"] = params["EventGroup"]
+ if "EventGroup" in params:
+ event_dic["EventGroup"] = params["EventGroup"]
- ql.loader.events[event_id] = event_dic
- write_int64(ql, params["Event"], event_id)
+ ql.loader.events[event_id] = event_dic
+ write_int64(ql, params["Event"], event_id)
- return EFI_SUCCESS
+ return EFI_SUCCESS
def initialize(ql: Qiling, gBS: int):
- descriptor = {
- 'struct' : EFI_BOOT_SERVICES,
- 'fields' : (
- ('Hdr', None),
- ('RaiseTPL', hook_RaiseTPL),
- ('RestoreTPL', hook_RestoreTPL),
- ('AllocatePages', hook_AllocatePages),
- ('FreePages', hook_FreePages),
- ('GetMemoryMap', hook_GetMemoryMap),
- ('AllocatePool', hook_AllocatePool),
- ('FreePool', hook_FreePool),
- ('CreateEvent', hook_CreateEvent),
- ('SetTimer', hook_SetTimer),
- ('WaitForEvent', hook_WaitForEvent),
- ('SignalEvent', hook_SignalEvent),
- ('CloseEvent', hook_CloseEvent),
- ('CheckEvent', hook_CheckEvent),
- ('InstallProtocolInterface', hook_InstallProtocolInterface),
- ('ReinstallProtocolInterface', hook_ReinstallProtocolInterface),
- ('UninstallProtocolInterface', hook_UninstallProtocolInterface),
- ('HandleProtocol', hook_HandleProtocol),
- ('Reserved', None),
- ('RegisterProtocolNotify', hook_RegisterProtocolNotify),
- ('LocateHandle', hook_LocateHandle),
- ('LocateDevicePath', hook_LocateDevicePath),
- ('InstallConfigurationTable', hook_InstallConfigurationTable),
- ('LoadImage', hook_LoadImage),
- ('StartImage', hook_StartImage),
- ('Exit', hook_Exit),
- ('UnloadImage', hook_UnloadImage),
- ('ExitBootServices', hook_ExitBootServices),
- ('GetNextMonotonicCount', hook_GetNextMonotonicCount),
- ('Stall', hook_Stall),
- ('SetWatchdogTimer', hook_SetWatchdogTimer),
- ('ConnectController', hook_ConnectController),
- ('DisconnectController', hook_DisconnectController),
- ('OpenProtocol', hook_OpenProtocol),
- ('CloseProtocol', hook_CloseProtocol),
- ('OpenProtocolInformation', hook_OpenProtocolInformation),
- ('ProtocolsPerHandle', hook_ProtocolsPerHandle),
- ('LocateHandleBuffer', hook_LocateHandleBuffer),
- ('LocateProtocol', hook_LocateProtocol),
- ('InstallMultipleProtocolInterfaces', hook_InstallMultipleProtocolInterfaces),
- ('UninstallMultipleProtocolInterfaces', hook_UninstallMultipleProtocolInterfaces),
- ('CalculateCrc32', hook_CalculateCrc32),
- ('CopyMem', hook_CopyMem),
- ('SetMem', hook_SetMem),
- ('CreateEventEx', hook_CreateEventEx)
- )
- }
-
- ql.os.monotonic_count = 0
-
- instance = init_struct(ql, gBS, descriptor)
- instance.saveTo(ql, gBS)
+ descriptor = {
+ 'struct' : EFI_BOOT_SERVICES,
+ 'fields' : (
+ ('Hdr', None),
+ ('RaiseTPL', hook_RaiseTPL),
+ ('RestoreTPL', hook_RestoreTPL),
+ ('AllocatePages', hook_AllocatePages),
+ ('FreePages', hook_FreePages),
+ ('GetMemoryMap', hook_GetMemoryMap),
+ ('AllocatePool', hook_AllocatePool),
+ ('FreePool', hook_FreePool),
+ ('CreateEvent', hook_CreateEvent),
+ ('SetTimer', hook_SetTimer),
+ ('WaitForEvent', hook_WaitForEvent),
+ ('SignalEvent', hook_SignalEvent),
+ ('CloseEvent', hook_CloseEvent),
+ ('CheckEvent', hook_CheckEvent),
+ ('InstallProtocolInterface', hook_InstallProtocolInterface),
+ ('ReinstallProtocolInterface', hook_ReinstallProtocolInterface),
+ ('UninstallProtocolInterface', hook_UninstallProtocolInterface),
+ ('HandleProtocol', hook_HandleProtocol),
+ ('Reserved', None),
+ ('RegisterProtocolNotify', hook_RegisterProtocolNotify),
+ ('LocateHandle', hook_LocateHandle),
+ ('LocateDevicePath', hook_LocateDevicePath),
+ ('InstallConfigurationTable', hook_InstallConfigurationTable),
+ ('LoadImage', hook_LoadImage),
+ ('StartImage', hook_StartImage),
+ ('Exit', hook_Exit),
+ ('UnloadImage', hook_UnloadImage),
+ ('ExitBootServices', hook_ExitBootServices),
+ ('GetNextMonotonicCount', hook_GetNextMonotonicCount),
+ ('Stall', hook_Stall),
+ ('SetWatchdogTimer', hook_SetWatchdogTimer),
+ ('ConnectController', hook_ConnectController),
+ ('DisconnectController', hook_DisconnectController),
+ ('OpenProtocol', hook_OpenProtocol),
+ ('CloseProtocol', hook_CloseProtocol),
+ ('OpenProtocolInformation', hook_OpenProtocolInformation),
+ ('ProtocolsPerHandle', hook_ProtocolsPerHandle),
+ ('LocateHandleBuffer', hook_LocateHandleBuffer),
+ ('LocateProtocol', hook_LocateProtocol),
+ ('InstallMultipleProtocolInterfaces', hook_InstallMultipleProtocolInterfaces),
+ ('UninstallMultipleProtocolInterfaces', hook_UninstallMultipleProtocolInterfaces),
+ ('CalculateCrc32', hook_CalculateCrc32),
+ ('CopyMem', hook_CopyMem),
+ ('SetMem', hook_SetMem),
+ ('CreateEventEx', hook_CreateEventEx)
+ )
+ }
+
+ ql.os.monotonic_count = 0
+
+ instance = init_struct(ql, gBS, descriptor)
+ instance.saveTo(ql, gBS)
__all__ = [
- 'initialize'
+ 'initialize'
]
\ No newline at end of file
diff --git a/qiling/os/uefi/const.py b/qiling/os/uefi/const.py
index d96972489..b4d0704a3 100644
--- a/qiling/os/uefi/const.py
+++ b/qiling/os/uefi/const.py
@@ -6,41 +6,41 @@
EFI_MAX_BIT = (1 << 63)
EFI_SUCCESS = 0
-EFI_LOAD_ERROR = EFI_MAX_BIT | 1
-EFI_INVALID_PARAMETER = EFI_MAX_BIT | 2
-EFI_UNSUPPORTED = EFI_MAX_BIT | 3
-EFI_BAD_BUFFER_SIZE = EFI_MAX_BIT | 4
-EFI_BUFFER_TOO_SMALL = EFI_MAX_BIT | 5
-EFI_NOT_READY = EFI_MAX_BIT | 6
-EFI_DEVICE_ERROR = EFI_MAX_BIT | 7
-EFI_WRITE_PROTECTED = EFI_MAX_BIT | 8
-EFI_OUT_OF_RESOURCES = EFI_MAX_BIT | 9
-EFI_VOLUME_CORRUPTED = EFI_MAX_BIT | 10
-EFI_VOLUME_FULL = EFI_MAX_BIT | 11
-EFI_NO_MEDIA = EFI_MAX_BIT | 12
-EFI_MEDIA_CHANGED = EFI_MAX_BIT | 13
-EFI_NOT_FOUND = EFI_MAX_BIT | 14
-EFI_ACCESS_DENIED = EFI_MAX_BIT | 15
-EFI_NO_RESPONSE = EFI_MAX_BIT | 16
-EFI_NO_MAPPING = EFI_MAX_BIT | 17
-EFI_TIMEOUT = EFI_MAX_BIT | 18
-EFI_NOT_STARTED = EFI_MAX_BIT | 19
-EFI_ALREADY_STARTED = EFI_MAX_BIT | 20
-EFI_ABORTED = EFI_MAX_BIT | 21
-EFI_ICMP_ERROR = EFI_MAX_BIT | 22
-EFI_TFTP_ERROR = EFI_MAX_BIT | 23
-EFI_PROTOCOL_ERROR = EFI_MAX_BIT | 24
-EFI_INCOMPATIBLE_VERSION = EFI_MAX_BIT | 25
-EFI_SECURITY_VIOLATION = EFI_MAX_BIT | 26
-EFI_CRC_ERROR = EFI_MAX_BIT | 27
-EFI_END_OF_MEDIA = EFI_MAX_BIT | 28
-EFI_END_OF_FILE = EFI_MAX_BIT | 31
-EFI_INVALID_LANGUAGE = EFI_MAX_BIT | 32
+EFI_LOAD_ERROR = EFI_MAX_BIT | 1
+EFI_INVALID_PARAMETER = EFI_MAX_BIT | 2
+EFI_UNSUPPORTED = EFI_MAX_BIT | 3
+EFI_BAD_BUFFER_SIZE = EFI_MAX_BIT | 4
+EFI_BUFFER_TOO_SMALL = EFI_MAX_BIT | 5
+EFI_NOT_READY = EFI_MAX_BIT | 6
+EFI_DEVICE_ERROR = EFI_MAX_BIT | 7
+EFI_WRITE_PROTECTED = EFI_MAX_BIT | 8
+EFI_OUT_OF_RESOURCES = EFI_MAX_BIT | 9
+EFI_VOLUME_CORRUPTED = EFI_MAX_BIT | 10
+EFI_VOLUME_FULL = EFI_MAX_BIT | 11
+EFI_NO_MEDIA = EFI_MAX_BIT | 12
+EFI_MEDIA_CHANGED = EFI_MAX_BIT | 13
+EFI_NOT_FOUND = EFI_MAX_BIT | 14
+EFI_ACCESS_DENIED = EFI_MAX_BIT | 15
+EFI_NO_RESPONSE = EFI_MAX_BIT | 16
+EFI_NO_MAPPING = EFI_MAX_BIT | 17
+EFI_TIMEOUT = EFI_MAX_BIT | 18
+EFI_NOT_STARTED = EFI_MAX_BIT | 19
+EFI_ALREADY_STARTED = EFI_MAX_BIT | 20
+EFI_ABORTED = EFI_MAX_BIT | 21
+EFI_ICMP_ERROR = EFI_MAX_BIT | 22
+EFI_TFTP_ERROR = EFI_MAX_BIT | 23
+EFI_PROTOCOL_ERROR = EFI_MAX_BIT | 24
+EFI_INCOMPATIBLE_VERSION = EFI_MAX_BIT | 25
+EFI_SECURITY_VIOLATION = EFI_MAX_BIT | 26
+EFI_CRC_ERROR = EFI_MAX_BIT | 27
+EFI_END_OF_MEDIA = EFI_MAX_BIT | 28
+EFI_END_OF_FILE = EFI_MAX_BIT | 31
+EFI_INVALID_LANGUAGE = EFI_MAX_BIT | 32
-EFI_WARN_UNKNOWN_GLYPH = EFI_MAX_BIT | 1
-EFI_WARN_DELETE_FAILURE = EFI_MAX_BIT | 2
-EFI_WARN_WRITE_FAILURE = EFI_MAX_BIT | 3
-EFI_WARN_BUFFER_TOO_SMALL = EFI_MAX_BIT | 4
+EFI_WARN_UNKNOWN_GLYPH = EFI_MAX_BIT | 1
+EFI_WARN_DELETE_FAILURE = EFI_MAX_BIT | 2
+EFI_WARN_WRITE_FAILURE = EFI_MAX_BIT | 3
+EFI_WARN_BUFFER_TOO_SMALL = EFI_MAX_BIT | 4
# @see: MdePkg\Include\Base.h
EFI_ERROR = lambda status: (status & EFI_MAX_BIT) != 0
diff --git a/qiling/os/uefi/context.py b/qiling/os/uefi/context.py
index 4975d1370..830995080 100644
--- a/qiling/os/uefi/context.py
+++ b/qiling/os/uefi/context.py
@@ -9,186 +9,186 @@
from qiling.os.uefi import utils
class UefiContext(ABC):
- def __init__(self, ql: Qiling):
- self.ql = ql
- self.heap: QlMemoryHeap
- self.top_of_stack: int
- self.protocols = {}
- self.loaded_image_protocol_modules: MutableSequence[int] = []
- self.next_image_base: int
+ def __init__(self, ql: Qiling):
+ self.ql = ql
+ self.heap: QlMemoryHeap
+ self.top_of_stack: int
+ self.protocols = {}
+ self.loaded_image_protocol_modules: MutableSequence[int] = []
+ self.next_image_base: int
- # These members must be initialized before attempting to install a configuration table.
- self.conf_table_data_ptr = 0
- self.conf_table_data_next_ptr = 0
+ # These members must be initialized before attempting to install a configuration table.
+ self.conf_table_data_ptr = 0
+ self.conf_table_data_next_ptr = 0
- self.conftable: UefiConfTable
- self.end_of_execution_ptr: int
+ self.conftable: UefiConfTable
+ self.end_of_execution_ptr: int
- # TODO: implement save state
- def save(self) -> Mapping[str, Any]:
- return {}
+ # TODO: implement save state
+ def save(self) -> Mapping[str, Any]:
+ return {}
- # TODO: implement restore state
- def restore(self, saved_state: Mapping[str, Any]):
- pass
+ # TODO: implement restore state
+ def restore(self, saved_state: Mapping[str, Any]):
+ pass
- def init_heap(self, base: int, size: int):
- self.heap = QlMemoryHeap(self.ql, base, base + size)
+ def init_heap(self, base: int, size: int):
+ self.heap = QlMemoryHeap(self.ql, base, base + size)
- def init_stack(self, base: int, size: int):
- self.ql.mem.map(base, size, info='[stack]')
- self.top_of_stack = (base + size - 1) & ~(CPU_STACK_ALIGNMENT - 1)
+ def init_stack(self, base: int, size: int):
+ self.ql.mem.map(base, size, info='[stack]')
+ self.top_of_stack = (base + size - 1) & ~(CPU_STACK_ALIGNMENT - 1)
- def install_protocol(self, proto_desc: Mapping, handle: int, address: int = None, from_hook: bool = False):
- guid = proto_desc['guid']
+ def install_protocol(self, proto_desc: Mapping, handle: int, address: int = None, from_hook: bool = False):
+ guid = proto_desc['guid']
- if handle not in self.protocols:
- self.protocols[handle] = {}
+ if handle not in self.protocols:
+ self.protocols[handle] = {}
- if guid in self.protocols[handle]:
- self.ql.log.warning(f'a protocol with guid {guid} is already installed')
+ if guid in self.protocols[handle]:
+ self.ql.log.warning(f'a protocol with guid {guid} is already installed')
- if address is None:
- struct_class = proto_desc['struct']
- address = self.heap.alloc(struct_class.sizeof())
+ if address is None:
+ struct_class = proto_desc['struct']
+ address = self.heap.alloc(struct_class.sizeof())
- instance = utils.init_struct(self.ql, address, proto_desc)
- instance.saveTo(self.ql, address)
+ instance = utils.init_struct(self.ql, address, proto_desc)
+ instance.saveTo(self.ql, address)
- self.protocols[handle][guid] = address
- return self.notify_protocol(handle, guid, address, from_hook)
+ self.protocols[handle][guid] = address
+ return self.notify_protocol(handle, guid, address, from_hook)
- def notify_protocol(self, handle: int, protocol: str, interface: int, from_hook: bool):
- for (event_id, event_dic) in self.ql.loader.events.items():
- if event_dic['Guid'] == protocol:
- if event_dic['CallbackArgs'] == None:
- # To support smm notification, we use None for CallbackArgs on SmmRegisterProtocolNotify
- # and updare it here.
- guid = utils.str_to_guid(protocol)
- guid_ptr = self.heap.alloc(guid.sizeof())
- guid.saveTo(self.ql, guid_ptr)
+ def notify_protocol(self, handle: int, protocol: str, interface: int, from_hook: bool):
+ for (event_id, event_dic) in self.ql.loader.events.items():
+ if event_dic['Guid'] == protocol:
+ if event_dic['CallbackArgs'] == None:
+ # To support smm notification, we use None for CallbackArgs on SmmRegisterProtocolNotify
+ # and updare it here.
+ guid = utils.str_to_guid(protocol)
+ guid_ptr = self.heap.alloc(guid.sizeof())
+ guid.saveTo(self.ql, guid_ptr)
- event_dic['CallbackArgs'] = [guid_ptr, interface, handle]
+ event_dic['CallbackArgs'] = [guid_ptr, interface, handle]
- # The event was previously registered by 'RegisterProtocolNotify'.
- utils.signal_event(self.ql, event_id)
+ # The event was previously registered by 'RegisterProtocolNotify'.
+ utils.signal_event(self.ql, event_id)
- return utils.execute_protocol_notifications(self.ql, from_hook)
+ return utils.execute_protocol_notifications(self.ql, from_hook)
class DxeContext(UefiContext):
- def __init__(self, ql: Qiling):
- super().__init__(ql)
+ def __init__(self, ql: Qiling):
+ super().__init__(ql)
- self.conftable = DxeConfTable(ql)
+ self.conftable = DxeConfTable(ql)
class SmmContext(UefiContext):
- def __init__(self, ql: Qiling):
- super().__init__(ql)
+ def __init__(self, ql: Qiling):
+ super().__init__(ql)
- self.conftable = SmmConfTable(ql)
+ self.conftable = SmmConfTable(ql)
- self.smram_base: int
- self.smram_size: int
+ self.smram_base: int
+ self.smram_size: int
- # assume tseg is inaccessible to non-smm
- self.tseg_open = False
+ # assume tseg is inaccessible to non-smm
+ self.tseg_open = False
- # assume tseg is locked
- self.tseg_locked = True
+ # assume tseg is locked
+ self.tseg_locked = True
- # registered sw smi handlers
- self.swsmi_handlers: Mapping[int, Tuple[int, Mapping]] = {}
+ # registered sw smi handlers
+ self.swsmi_handlers: Mapping[int, Tuple[int, Mapping]] = {}
class UefiConfTable:
- _struct_systbl: STRUCT
- _fname_arrptr: str
- _fname_nitems: str
+ _struct_systbl: STRUCT
+ _fname_arrptr: str
+ _fname_nitems: str
- def __init__(self, ql: Qiling):
- self.ql = ql
+ def __init__(self, ql: Qiling):
+ self.ql = ql
- self.__arrptr_off = self._struct_systbl.offsetof(self._fname_arrptr)
- self.__nitems_off = self._struct_systbl.offsetof(self._fname_nitems)
+ self.__arrptr_off = self._struct_systbl.offsetof(self._fname_arrptr)
+ self.__nitems_off = self._struct_systbl.offsetof(self._fname_nitems)
- @property
- @abstractmethod
- def system_table(self) -> int:
- pass
+ @property
+ @abstractmethod
+ def system_table(self) -> int:
+ pass
- @property
- def baseptr(self) -> int:
- addr = self.system_table + self.__arrptr_off
+ @property
+ def baseptr(self) -> int:
+ addr = self.system_table + self.__arrptr_off
- return utils.read_int64(self.ql, addr)
+ return utils.read_int64(self.ql, addr)
- @property
- def nitems(self) -> int:
- addr = self.system_table + self.__nitems_off
+ @property
+ def nitems(self) -> int:
+ addr = self.system_table + self.__nitems_off
- return utils.read_int64(self.ql, addr) # UINTN
+ return utils.read_int64(self.ql, addr) # UINTN
- @nitems.setter
- def nitems(self, value: int):
- addr = self.system_table + self.__nitems_off
+ @nitems.setter
+ def nitems(self, value: int):
+ addr = self.system_table + self.__nitems_off
- utils.write_int64(self.ql, addr, value)
+ utils.write_int64(self.ql, addr, value)
- def install(self, guid: str, table: int):
- ptr = self.find(guid)
- append = ptr is None
+ def install(self, guid: str, table: int):
+ ptr = self.find(guid)
+ append = ptr is None
- if append:
- ptr = self.baseptr + self.nitems * EFI_CONFIGURATION_TABLE.sizeof()
- append = True
+ if append:
+ ptr = self.baseptr + self.nitems * EFI_CONFIGURATION_TABLE.sizeof()
+ append = True
- instance = EFI_CONFIGURATION_TABLE()
- instance.VendorGuid = utils.str_to_guid(guid)
- instance.VendorTable = table
- instance.saveTo(self.ql, ptr)
+ instance = EFI_CONFIGURATION_TABLE()
+ instance.VendorGuid = utils.str_to_guid(guid)
+ instance.VendorTable = table
+ instance.saveTo(self.ql, ptr)
- if append:
- self.nitems += 1
+ if append:
+ self.nitems += 1
- def find(self, guid: str) -> Optional[int]:
- ptr = self.baseptr
- nitems = self.nitems
- efi_guid = utils.str_to_guid(guid)
+ def find(self, guid: str) -> Optional[int]:
+ ptr = self.baseptr
+ nitems = self.nitems
+ efi_guid = utils.str_to_guid(guid)
- for _ in range(nitems):
- entry = EFI_CONFIGURATION_TABLE.loadFrom(self.ql, ptr)
+ for _ in range(nitems):
+ entry = EFI_CONFIGURATION_TABLE.loadFrom(self.ql, ptr)
- if utils.CompareGuid(entry.VendorGuid, efi_guid):
- return ptr
+ if utils.CompareGuid(entry.VendorGuid, efi_guid):
+ return ptr
- ptr += EFI_CONFIGURATION_TABLE.sizeof()
+ ptr += EFI_CONFIGURATION_TABLE.sizeof()
- return None
+ return None
- def get_vendor_table(self, guid: str) -> Optional[int]:
- ptr = self.find(guid)
+ def get_vendor_table(self, guid: str) -> Optional[int]:
+ ptr = self.find(guid)
- if ptr is not None:
- entry = EFI_CONFIGURATION_TABLE.loadFrom(self.ql, ptr)
+ if ptr is not None:
+ entry = EFI_CONFIGURATION_TABLE.loadFrom(self.ql, ptr)
- return entry.VendorTable.value
+ return entry.VendorTable.value
- # not found
- return None
+ # not found
+ return None
class DxeConfTable(UefiConfTable):
- _struct_systbl = EFI_SYSTEM_TABLE
- _fname_arrptr = 'ConfigurationTable'
- _fname_nitems = 'NumberOfTableEntries'
+ _struct_systbl = EFI_SYSTEM_TABLE
+ _fname_arrptr = 'ConfigurationTable'
+ _fname_nitems = 'NumberOfTableEntries'
- @property
- def system_table(self) -> int:
- return self.ql.loader.gST
+ @property
+ def system_table(self) -> int:
+ return self.ql.loader.gST
class SmmConfTable(UefiConfTable):
- _struct_systbl = EFI_SMM_SYSTEM_TABLE2
- _fname_arrptr = 'SmmConfigurationTable'
- _fname_nitems = 'NumberOfTableEntries'
+ _struct_systbl = EFI_SMM_SYSTEM_TABLE2
+ _fname_arrptr = 'SmmConfigurationTable'
+ _fname_nitems = 'NumberOfTableEntries'
- @property
- def system_table(self) -> int:
- return self.ql.loader.gSmst
+ @property
+ def system_table(self) -> int:
+ return self.ql.loader.gSmst
diff --git a/qiling/os/uefi/ds.py b/qiling/os/uefi/ds.py
index df76615cc..ada10b1d7 100644
--- a/qiling/os/uefi/ds.py
+++ b/qiling/os/uefi/ds.py
@@ -13,271 +13,271 @@
from .UefiMultiPhase import *
class EFI_GCD_MEMORY_TYPE(ENUM):
- _members_ = [
- 'EfiGcdMemoryTypeNonExistent',
- 'EfiGcdMemoryTypeReserved',
- 'EfiGcdMemoryTypeSystemMemory',
- 'EfiGcdMemoryTypeMemoryMappedIo',
- 'EfiGcdMemoryTypePersistent',
- 'EfiGcdMemoryTypePersistentMemory',
- 'EfiGcdMemoryTypeMoreReliable',
- 'EfiGcdMemoryTypeMaximum'
- ]
+ _members_ = [
+ 'EfiGcdMemoryTypeNonExistent',
+ 'EfiGcdMemoryTypeReserved',
+ 'EfiGcdMemoryTypeSystemMemory',
+ 'EfiGcdMemoryTypeMemoryMappedIo',
+ 'EfiGcdMemoryTypePersistent',
+ 'EfiGcdMemoryTypePersistentMemory',
+ 'EfiGcdMemoryTypeMoreReliable',
+ 'EfiGcdMemoryTypeMaximum'
+ ]
class EFI_GCD_MEMORY_SPACE_DESCRIPTOR(STRUCT):
- _pack_ = 8
+ _pack_ = 8
- _fields_ = [
- ('BaseAddress', EFI_PHYSICAL_ADDRESS),
- ('Length', UINT64),
- ('Capabilities', UINT64),
- ('Attributes', UINT64),
- ('GcdMemoryType', EFI_GCD_MEMORY_TYPE),
- ('ImageHandle', EFI_HANDLE),
- ('DeviceHandle', EFI_HANDLE)
- ]
+ _fields_ = [
+ ('BaseAddress', EFI_PHYSICAL_ADDRESS),
+ ('Length', UINT64),
+ ('Capabilities', UINT64),
+ ('Attributes', UINT64),
+ ('GcdMemoryType', EFI_GCD_MEMORY_TYPE),
+ ('ImageHandle', EFI_HANDLE),
+ ('DeviceHandle', EFI_HANDLE)
+ ]
class EFI_GCD_IO_TYPE(ENUM):
- _members_ = [
- 'EfiGcdIoTypeNonExistent',
- 'EfiGcdIoTypeReserved',
- 'EfiGcdIoTypeIo',
- 'EfiGcdIoTypeMaximum'
- ]
+ _members_ = [
+ 'EfiGcdIoTypeNonExistent',
+ 'EfiGcdIoTypeReserved',
+ 'EfiGcdIoTypeIo',
+ 'EfiGcdIoTypeMaximum'
+ ]
class EFI_GCD_IO_SPACE_DESCRIPTOR(STRUCT):
- _pack_ = 8
+ _pack_ = 8
- _fields_ = [
- ('BaseAddress', EFI_PHYSICAL_ADDRESS),
- ('Length', UINT64),
- ('GcdIoType', EFI_GCD_IO_TYPE),
- ('ImageHandle', EFI_HANDLE),
- ('DeviceHandle', EFI_HANDLE)
- ]
+ _fields_ = [
+ ('BaseAddress', EFI_PHYSICAL_ADDRESS),
+ ('Length', UINT64),
+ ('GcdIoType', EFI_GCD_IO_TYPE),
+ ('ImageHandle', EFI_HANDLE),
+ ('DeviceHandle', EFI_HANDLE)
+ ]
class EFI_GCD_ALLOCATE_TYPE(ENUM):
- _members_ = [
- 'EfiGcdAllocateAnySearchBottomUp',
- 'EfiGcdAllocateMaxAddressSearchBottomUp',
- 'EfiGcdAllocateAddress',
- 'EfiGcdAllocateAnySearchTopDown',
- 'EfiGcdAllocateMaxAddressSearchTopDown',
- 'EfiGcdMaxAllocateType'
- ]
+ _members_ = [
+ 'EfiGcdAllocateAnySearchBottomUp',
+ 'EfiGcdAllocateMaxAddressSearchBottomUp',
+ 'EfiGcdAllocateAddress',
+ 'EfiGcdAllocateAnySearchTopDown',
+ 'EfiGcdAllocateMaxAddressSearchTopDown',
+ 'EfiGcdMaxAllocateType'
+ ]
-EFI_ADD_MEMORY_SPACE = FUNCPTR(EFI_STATUS, EFI_GCD_MEMORY_TYPE, EFI_PHYSICAL_ADDRESS, UINT64, UINT64)
-EFI_ALLOCATE_MEMORY_SPACE = FUNCPTR(EFI_STATUS, EFI_GCD_ALLOCATE_TYPE, EFI_GCD_MEMORY_TYPE, UINTN, UINT64, PTR(EFI_PHYSICAL_ADDRESS), EFI_HANDLE, EFI_HANDLE)
-EFI_FREE_MEMORY_SPACE = FUNCPTR(EFI_STATUS, EFI_PHYSICAL_ADDRESS, UINT64)
-EFI_REMOVE_MEMORY_SPACE = FUNCPTR(EFI_STATUS, EFI_PHYSICAL_ADDRESS, UINT64)
-EFI_GET_MEMORY_SPACE_DESCRIPTOR = FUNCPTR(EFI_STATUS, EFI_PHYSICAL_ADDRESS, PTR(EFI_GCD_MEMORY_SPACE_DESCRIPTOR))
-EFI_SET_MEMORY_SPACE_ATTRIBUTES = FUNCPTR(EFI_STATUS, EFI_PHYSICAL_ADDRESS, UINT64, UINT64)
-EFI_GET_MEMORY_SPACE_MAP = FUNCPTR(EFI_STATUS, PTR(UINTN), PTR(PTR(EFI_GCD_MEMORY_SPACE_DESCRIPTOR)))
-EFI_ADD_IO_SPACE = FUNCPTR(EFI_STATUS, EFI_GCD_IO_TYPE, EFI_PHYSICAL_ADDRESS, UINT64)
-EFI_ALLOCATE_IO_SPACE = FUNCPTR(EFI_STATUS, EFI_GCD_ALLOCATE_TYPE, EFI_GCD_IO_TYPE, UINTN, UINT64, PTR(EFI_PHYSICAL_ADDRESS), EFI_HANDLE, EFI_HANDLE)
-EFI_FREE_IO_SPACE = FUNCPTR(EFI_STATUS, EFI_PHYSICAL_ADDRESS, UINT64)
-EFI_REMOVE_IO_SPACE = FUNCPTR(EFI_STATUS, EFI_PHYSICAL_ADDRESS, UINT64)
-EFI_GET_IO_SPACE_DESCRIPTOR = FUNCPTR(EFI_STATUS, EFI_PHYSICAL_ADDRESS, PTR(EFI_GCD_IO_SPACE_DESCRIPTOR))
-EFI_GET_IO_SPACE_MAP = FUNCPTR(EFI_STATUS, PTR(UINTN), PTR(PTR(EFI_GCD_IO_SPACE_DESCRIPTOR)))
-EFI_DISPATCH = FUNCPTR(EFI_STATUS)
-EFI_SCHEDULE = FUNCPTR(EFI_STATUS, EFI_HANDLE, PTR(EFI_GUID))
-EFI_TRUST = FUNCPTR(EFI_STATUS, EFI_HANDLE, PTR(EFI_GUID))
-EFI_PROCESS_FIRMWARE_VOLUME = FUNCPTR(EFI_STATUS, PTR(VOID), UINTN, PTR(EFI_HANDLE))
-EFI_SET_MEMORY_SPACE_CAPABILITIES = FUNCPTR(EFI_STATUS, EFI_PHYSICAL_ADDRESS, UINT64, UINT64)
+EFI_ADD_MEMORY_SPACE = FUNCPTR(EFI_STATUS, EFI_GCD_MEMORY_TYPE, EFI_PHYSICAL_ADDRESS, UINT64, UINT64)
+EFI_ALLOCATE_MEMORY_SPACE = FUNCPTR(EFI_STATUS, EFI_GCD_ALLOCATE_TYPE, EFI_GCD_MEMORY_TYPE, UINTN, UINT64, PTR(EFI_PHYSICAL_ADDRESS), EFI_HANDLE, EFI_HANDLE)
+EFI_FREE_MEMORY_SPACE = FUNCPTR(EFI_STATUS, EFI_PHYSICAL_ADDRESS, UINT64)
+EFI_REMOVE_MEMORY_SPACE = FUNCPTR(EFI_STATUS, EFI_PHYSICAL_ADDRESS, UINT64)
+EFI_GET_MEMORY_SPACE_DESCRIPTOR = FUNCPTR(EFI_STATUS, EFI_PHYSICAL_ADDRESS, PTR(EFI_GCD_MEMORY_SPACE_DESCRIPTOR))
+EFI_SET_MEMORY_SPACE_ATTRIBUTES = FUNCPTR(EFI_STATUS, EFI_PHYSICAL_ADDRESS, UINT64, UINT64)
+EFI_GET_MEMORY_SPACE_MAP = FUNCPTR(EFI_STATUS, PTR(UINTN), PTR(PTR(EFI_GCD_MEMORY_SPACE_DESCRIPTOR)))
+EFI_ADD_IO_SPACE = FUNCPTR(EFI_STATUS, EFI_GCD_IO_TYPE, EFI_PHYSICAL_ADDRESS, UINT64)
+EFI_ALLOCATE_IO_SPACE = FUNCPTR(EFI_STATUS, EFI_GCD_ALLOCATE_TYPE, EFI_GCD_IO_TYPE, UINTN, UINT64, PTR(EFI_PHYSICAL_ADDRESS), EFI_HANDLE, EFI_HANDLE)
+EFI_FREE_IO_SPACE = FUNCPTR(EFI_STATUS, EFI_PHYSICAL_ADDRESS, UINT64)
+EFI_REMOVE_IO_SPACE = FUNCPTR(EFI_STATUS, EFI_PHYSICAL_ADDRESS, UINT64)
+EFI_GET_IO_SPACE_DESCRIPTOR = FUNCPTR(EFI_STATUS, EFI_PHYSICAL_ADDRESS, PTR(EFI_GCD_IO_SPACE_DESCRIPTOR))
+EFI_GET_IO_SPACE_MAP = FUNCPTR(EFI_STATUS, PTR(UINTN), PTR(PTR(EFI_GCD_IO_SPACE_DESCRIPTOR)))
+EFI_DISPATCH = FUNCPTR(EFI_STATUS)
+EFI_SCHEDULE = FUNCPTR(EFI_STATUS, EFI_HANDLE, PTR(EFI_GUID))
+EFI_TRUST = FUNCPTR(EFI_STATUS, EFI_HANDLE, PTR(EFI_GUID))
+EFI_PROCESS_FIRMWARE_VOLUME = FUNCPTR(EFI_STATUS, PTR(VOID), UINTN, PTR(EFI_HANDLE))
+EFI_SET_MEMORY_SPACE_CAPABILITIES = FUNCPTR(EFI_STATUS, EFI_PHYSICAL_ADDRESS, UINT64, UINT64)
class EFI_DXE_SERVICES(STRUCT):
- _fields_ = [
- ('Hdr', EFI_TABLE_HEADER),
- ('AddMemorySpace', EFI_ADD_MEMORY_SPACE),
- ('AllocateMemorySpace', EFI_ALLOCATE_MEMORY_SPACE),
- ('FreeMemorySpace', EFI_FREE_MEMORY_SPACE),
- ('RemoveMemorySpace', EFI_REMOVE_MEMORY_SPACE),
- ('GetMemorySpaceDescriptor', EFI_GET_MEMORY_SPACE_DESCRIPTOR),
- ('SetMemorySpaceAttributes', EFI_SET_MEMORY_SPACE_ATTRIBUTES),
- ('GetMemorySpaceMap', EFI_GET_MEMORY_SPACE_MAP),
- ('AddIoSpace', EFI_ADD_IO_SPACE),
- ('AllocateIoSpace', EFI_ALLOCATE_IO_SPACE),
- ('FreeIoSpace', EFI_FREE_IO_SPACE),
- ('RemoveIoSpace', EFI_REMOVE_IO_SPACE),
- ('GetIoSpaceDescriptor', EFI_GET_IO_SPACE_DESCRIPTOR),
- ('GetIoSpaceMap', EFI_GET_IO_SPACE_MAP),
- ('Dispatch', EFI_DISPATCH),
- ('Schedule', EFI_SCHEDULE),
- ('Trust', EFI_TRUST),
- ('ProcessFirmwareVolume', EFI_PROCESS_FIRMWARE_VOLUME),
- ('SetMemorySpaceCapabilities', EFI_SET_MEMORY_SPACE_CAPABILITIES)
- ]
+ _fields_ = [
+ ('Hdr', EFI_TABLE_HEADER),
+ ('AddMemorySpace', EFI_ADD_MEMORY_SPACE),
+ ('AllocateMemorySpace', EFI_ALLOCATE_MEMORY_SPACE),
+ ('FreeMemorySpace', EFI_FREE_MEMORY_SPACE),
+ ('RemoveMemorySpace', EFI_REMOVE_MEMORY_SPACE),
+ ('GetMemorySpaceDescriptor', EFI_GET_MEMORY_SPACE_DESCRIPTOR),
+ ('SetMemorySpaceAttributes', EFI_SET_MEMORY_SPACE_ATTRIBUTES),
+ ('GetMemorySpaceMap', EFI_GET_MEMORY_SPACE_MAP),
+ ('AddIoSpace', EFI_ADD_IO_SPACE),
+ ('AllocateIoSpace', EFI_ALLOCATE_IO_SPACE),
+ ('FreeIoSpace', EFI_FREE_IO_SPACE),
+ ('RemoveIoSpace', EFI_REMOVE_IO_SPACE),
+ ('GetIoSpaceDescriptor', EFI_GET_IO_SPACE_DESCRIPTOR),
+ ('GetIoSpaceMap', EFI_GET_IO_SPACE_MAP),
+ ('Dispatch', EFI_DISPATCH),
+ ('Schedule', EFI_SCHEDULE),
+ ('Trust', EFI_TRUST),
+ ('ProcessFirmwareVolume', EFI_PROCESS_FIRMWARE_VOLUME),
+ ('SetMemorySpaceCapabilities', EFI_SET_MEMORY_SPACE_CAPABILITIES)
+ ]
@dxeapi(params={
- "a0": ULONGLONG,
- "a1": ULONGLONG,
- "a2": ULONGLONG,
- "a3": ULONGLONG,
+ "a0": ULONGLONG,
+ "a1": ULONGLONG,
+ "a2": ULONGLONG,
+ "a3": ULONGLONG,
})
def hook_AddMemorySpace(ctx, address, params):
- return EFI_OUT_OF_RESOURCES
+ return EFI_OUT_OF_RESOURCES
@dxeapi(params={
- "a0": ULONGLONG,
- "a1": ULONGLONG,
- "a2": ULONGLONG,
- "a3": ULONGLONG,
- "a4": POINTER, #POINTER_T(ctypes.c_uint64)
- "a5": POINTER, #POINTER_T(None)
- "a6": POINTER, #POINTER_T(None)
+ "a0": ULONGLONG,
+ "a1": ULONGLONG,
+ "a2": ULONGLONG,
+ "a3": ULONGLONG,
+ "a4": POINTER, #POINTER_T(ctypes.c_uint64)
+ "a5": POINTER, #POINTER_T(None)
+ "a6": POINTER, #POINTER_T(None)
})
def hook_AllocateMemorySpace(ctx, address, params):
- return EFI_OUT_OF_RESOURCES
+ return EFI_OUT_OF_RESOURCES
@dxeapi(params={
- "a0": ULONGLONG,
- "a1": ULONGLONG,
+ "a0": ULONGLONG,
+ "a1": ULONGLONG,
})
def hook_FreeMemorySpace(ctx, address, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params={
- "a0": ULONGLONG,
- "a1": ULONGLONG,
+ "a0": ULONGLONG,
+ "a1": ULONGLONG,
})
def hook_RemoveMemorySpace(ctx, address, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params={
- "a0": ULONGLONG,
- "a1": POINTER, #POINTER_T(struct_EFI_GCD_MEMORY_SPACE_DESCRIPTOR)
+ "a0": ULONGLONG,
+ "a1": POINTER, #POINTER_T(struct_EFI_GCD_MEMORY_SPACE_DESCRIPTOR)
})
def hook_GetMemorySpaceDescriptor(ctx, address, params):
- return EFI_UNSUPPORTED
+ return EFI_UNSUPPORTED
@dxeapi(params={
- "a0": ULONGLONG,
- "a1": ULONGLONG,
- "a2": ULONGLONG,
+ "a0": ULONGLONG,
+ "a1": ULONGLONG,
+ "a2": ULONGLONG,
})
def hook_SetMemorySpaceAttributes(ctx, address, params):
- return EFI_UNSUPPORTED
+ return EFI_UNSUPPORTED
@dxeapi(params={
- "a0": POINTER, #POINTER_T(ctypes.c_uint64)
- "a1": POINTER, #POINTER_T(POINTER_T(struct_EFI_GCD_MEMORY_SPACE_DESCRIPTOR))
+ "a0": POINTER, #POINTER_T(ctypes.c_uint64)
+ "a1": POINTER, #POINTER_T(POINTER_T(struct_EFI_GCD_MEMORY_SPACE_DESCRIPTOR))
})
def hook_GetMemorySpaceMap(ctx, address, params):
- return EFI_UNSUPPORTED
+ return EFI_UNSUPPORTED
@dxeapi(params={
- "a0": ULONGLONG,
- "a1": ULONGLONG,
- "a2": ULONGLONG,
+ "a0": ULONGLONG,
+ "a1": ULONGLONG,
+ "a2": ULONGLONG,
})
def hook_AddIoSpace(ctx, address, params):
- return EFI_OUT_OF_RESOURCES
+ return EFI_OUT_OF_RESOURCES
@dxeapi(params={
- "a0": ULONGLONG,
- "a1": ULONGLONG,
- "a2": ULONGLONG,
- "a3": ULONGLONG,
- "a4": POINTER, #POINTER_T(ctypes.c_uint64)
- "a5": POINTER, #POINTER_T(None)
- "a6": POINTER, #POINTER_T(None)
+ "a0": ULONGLONG,
+ "a1": ULONGLONG,
+ "a2": ULONGLONG,
+ "a3": ULONGLONG,
+ "a4": POINTER, #POINTER_T(ctypes.c_uint64)
+ "a5": POINTER, #POINTER_T(None)
+ "a6": POINTER, #POINTER_T(None)
})
def hook_AllocateIoSpace(ctx, address, params):
- return EFI_OUT_OF_RESOURCES
+ return EFI_OUT_OF_RESOURCES
@dxeapi(params={
- "a0": ULONGLONG,
- "a1": ULONGLONG,
+ "a0": ULONGLONG,
+ "a1": ULONGLONG,
})
def hook_FreeIoSpace(ctx, address, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params={
- "a0": ULONGLONG,
- "a1": ULONGLONG,
+ "a0": ULONGLONG,
+ "a1": ULONGLONG,
})
def hook_RemoveIoSpace(ctx, address, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params={
- "a0": ULONGLONG,
- "a1": POINTER, #POINTER_T(struct_EFI_GCD_IO_SPACE_DESCRIPTOR)
+ "a0": ULONGLONG,
+ "a1": POINTER, #POINTER_T(struct_EFI_GCD_IO_SPACE_DESCRIPTOR)
})
def hook_GetIoSpaceDescriptor(ctx, address, params):
- return EFI_NOT_FOUND
+ return EFI_NOT_FOUND
@dxeapi(params={
- "a0": POINTER, #POINTER_T(ctypes.c_uint64)
- "a1": POINTER, #POINTER_T(POINTER_T(struct_EFI_GCD_IO_SPACE_DESCRIPTOR))
+ "a0": POINTER, #POINTER_T(ctypes.c_uint64)
+ "a1": POINTER, #POINTER_T(POINTER_T(struct_EFI_GCD_IO_SPACE_DESCRIPTOR))
})
def hook_GetIoSpaceMap(ctx, address, params):
- return EFI_OUT_OF_RESOURCES
+ return EFI_OUT_OF_RESOURCES
@dxeapi(params={
})
def hook_Dispatch(ctx, address, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params={
- "a0": POINTER, #POINTER_T(None)
- "a1": GUID,
+ "a0": POINTER, #POINTER_T(None)
+ "a1": GUID,
})
def hook_Schedule(ctx, address, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params={
- "a0": POINTER, #POINTER_T(None)
- "a1": GUID,
+ "a0": POINTER, #POINTER_T(None)
+ "a1": GUID,
})
def hook_Trust(ctx, address, params):
- return EFI_NOT_FOUND
+ return EFI_NOT_FOUND
@dxeapi(params={
- "a0": POINTER, #POINTER_T(None)
- "a1": ULONGLONG,
- "a2": POINTER, #POINTER_T(POINTER_T(None))
+ "a0": POINTER, #POINTER_T(None)
+ "a1": ULONGLONG,
+ "a2": POINTER, #POINTER_T(POINTER_T(None))
})
def hook_ProcessFirmwareVolume(ctx, address, params):
- return EFI_OUT_OF_RESOURCES
+ return EFI_OUT_OF_RESOURCES
@dxeapi(params={
- "a0": ULONGLONG,
- "a1": ULONGLONG,
- "a2": ULONGLONG,
+ "a0": ULONGLONG,
+ "a1": ULONGLONG,
+ "a2": ULONGLONG,
})
def hook_SetMemorySpaceCapabilities(ctx, address, params):
- return EFI_UNSUPPORTED
+ return EFI_UNSUPPORTED
def initialize(ql: Qiling, gDS: int):
- descriptor = {
- 'struct' : EFI_DXE_SERVICES,
- 'fields' : (
- ('Hdr', None),
- ('AddMemorySpace', hook_AddMemorySpace),
- ('AllocateMemorySpace', hook_AllocateMemorySpace),
- ('FreeMemorySpace', hook_FreeMemorySpace),
- ('RemoveMemorySpace', hook_RemoveMemorySpace),
- ('GetMemorySpaceDescriptor', hook_GetMemorySpaceDescriptor),
- ('SetMemorySpaceAttributes', hook_SetMemorySpaceAttributes),
- ('GetMemorySpaceMap', hook_GetMemorySpaceMap),
- ('AddIoSpace', hook_AddIoSpace),
- ('AllocateIoSpace', hook_AllocateIoSpace),
- ('FreeIoSpace', hook_FreeIoSpace),
- ('RemoveIoSpace', hook_RemoveIoSpace),
- ('GetIoSpaceDescriptor', hook_GetIoSpaceDescriptor),
- ('GetIoSpaceMap', hook_GetIoSpaceMap),
- ('Dispatch', hook_Dispatch),
- ('Schedule', hook_Schedule),
- ('Trust', hook_Trust),
- ('ProcessFirmwareVolume', hook_ProcessFirmwareVolume),
- ('SetMemorySpaceCapabilities', hook_SetMemorySpaceCapabilities)
- )
- }
+ descriptor = {
+ 'struct' : EFI_DXE_SERVICES,
+ 'fields' : (
+ ('Hdr', None),
+ ('AddMemorySpace', hook_AddMemorySpace),
+ ('AllocateMemorySpace', hook_AllocateMemorySpace),
+ ('FreeMemorySpace', hook_FreeMemorySpace),
+ ('RemoveMemorySpace', hook_RemoveMemorySpace),
+ ('GetMemorySpaceDescriptor', hook_GetMemorySpaceDescriptor),
+ ('SetMemorySpaceAttributes', hook_SetMemorySpaceAttributes),
+ ('GetMemorySpaceMap', hook_GetMemorySpaceMap),
+ ('AddIoSpace', hook_AddIoSpace),
+ ('AllocateIoSpace', hook_AllocateIoSpace),
+ ('FreeIoSpace', hook_FreeIoSpace),
+ ('RemoveIoSpace', hook_RemoveIoSpace),
+ ('GetIoSpaceDescriptor', hook_GetIoSpaceDescriptor),
+ ('GetIoSpaceMap', hook_GetIoSpaceMap),
+ ('Dispatch', hook_Dispatch),
+ ('Schedule', hook_Schedule),
+ ('Trust', hook_Trust),
+ ('ProcessFirmwareVolume', hook_ProcessFirmwareVolume),
+ ('SetMemorySpaceCapabilities', hook_SetMemorySpaceCapabilities)
+ )
+ }
- instance = init_struct(ql, gDS, descriptor)
- instance.saveTo(ql, gDS)
+ instance = init_struct(ql, gDS, descriptor)
+ instance.saveTo(ql, gDS)
__all__ = [
- 'EFI_DXE_SERVICES',
- 'initialize'
+ 'EFI_DXE_SERVICES',
+ 'initialize'
]
diff --git a/qiling/os/uefi/hob.py b/qiling/os/uefi/hob.py
index a698be34f..a1a07f0f9 100644
--- a/qiling/os/uefi/hob.py
+++ b/qiling/os/uefi/hob.py
@@ -8,98 +8,98 @@
from qiling.os.uefi.utils import GetEfiConfigurationTable, CompareGuid, str_to_guid
from qiling.os.uefi.UefiBaseType import STRUCT, EFI_GUID, UINT32, UINT16
-EFI_HOB_TYPE_HANDOFF = 0x0001
-EFI_HOB_TYPE_GUID_EXTENSION = 0x0004
+EFI_HOB_TYPE_HANDOFF = 0x0001
+EFI_HOB_TYPE_GUID_EXTENSION = 0x0004
EFI_HOB_TYPE_END_OF_HOB_LIST = 0xffff
class EFI_HOB_GENERIC_HEADER(STRUCT):
- _fields_ = [
- ('HobType', UINT16),
- ('HobLength', UINT16),
- ('Reserved', UINT32)
- ]
+ _fields_ = [
+ ('HobType', UINT16),
+ ('HobLength', UINT16),
+ ('Reserved', UINT32)
+ ]
class EFI_HOB_GUID_TYPE(STRUCT):
- _fields_ = [
- ('Header', EFI_HOB_GENERIC_HEADER),
- ('Name', EFI_GUID)
- ]
+ _fields_ = [
+ ('Header', EFI_HOB_GENERIC_HEADER),
+ ('Name', EFI_GUID)
+ ]
def GetHobList(ql: Qiling, context: UefiContext) -> int:
- """Get HOB list location in memory (ostensibly set by PEI).
- """
+ """Get HOB list location in memory (ostensibly set by PEI).
+ """
- hoblist_guid = ql.os.profile['HOB_LIST']['Guid']
- hoblist_vend = GetEfiConfigurationTable(context, hoblist_guid)
+ hoblist_guid = ql.os.profile['HOB_LIST']['Guid']
+ hoblist_vend = GetEfiConfigurationTable(context, hoblist_guid)
- assert hoblist_vend is not None, 'hob list guid not found'
+ assert hoblist_vend is not None, 'hob list guid not found'
- return hoblist_vend
+ return hoblist_vend
def CreateHob(ql: Qiling, context: UefiContext, hob) -> int:
- """Add a HOB to the end of the HOB list.
- """
+ """Add a HOB to the end of the HOB list.
+ """
- hoblist = GetHobList(ql, context)
+ hoblist = GetHobList(ql, context)
- # look for the list end marker; uefi codebase assumes there is
- # always one
- hoblist = GetNextHob(ql, EFI_HOB_TYPE_END_OF_HOB_LIST, hoblist)
+ # look for the list end marker; uefi codebase assumes there is
+ # always one
+ hoblist = GetNextHob(ql, EFI_HOB_TYPE_END_OF_HOB_LIST, hoblist)
- # overwrite end marker with the hob
- pHob = hoblist
- hob.saveTo(ql, pHob)
- hoblist += hob.sizeof()
+ # overwrite end marker with the hob
+ pHob = hoblist
+ hob.saveTo(ql, pHob)
+ hoblist += hob.sizeof()
- # create a new end marker istead, following the hob
- marker = EFI_HOB_GENERIC_HEADER()
- marker.HobType = EFI_HOB_TYPE_END_OF_HOB_LIST
- marker.HobLength = 0x0000
- marker.Reserved = 0x00000000
- marker.saveTo(ql, hoblist)
+ # create a new end marker istead, following the hob
+ marker = EFI_HOB_GENERIC_HEADER()
+ marker.HobType = EFI_HOB_TYPE_END_OF_HOB_LIST
+ marker.HobLength = 0x0000
+ marker.Reserved = 0x00000000
+ marker.saveTo(ql, hoblist)
- # return the address the hob was written to; it might be useful
- return pHob
+ # return the address the hob was written to; it might be useful
+ return pHob
def GetNextHob(ql: Qiling, hobtype: int, hoblist: int) -> int:
- """Get next HOB on the list.
- """
+ """Get next HOB on the list.
+ """
- hobaddr = hoblist
+ hobaddr = hoblist
- while True:
- header = EFI_HOB_GENERIC_HEADER.loadFrom(ql, hobaddr)
+ while True:
+ header = EFI_HOB_GENERIC_HEADER.loadFrom(ql, hobaddr)
- # found the hob?
- if header.HobType == hobtype:
- break
+ # found the hob?
+ if header.HobType == hobtype:
+ break
- # reached end of hob list?
- if header.HobType == EFI_HOB_TYPE_END_OF_HOB_LIST:
- return 0
+ # reached end of hob list?
+ if header.HobType == EFI_HOB_TYPE_END_OF_HOB_LIST:
+ return 0
- hobaddr += header.HobLength
+ hobaddr += header.HobLength
- return hobaddr
+ return hobaddr
def GetNextGuidHob(ql: Qiling, guid: str, hoblist: int) -> int:
- """Find next HOB with the specified GUID.
- """
+ """Find next HOB with the specified GUID.
+ """
- hobguid = str_to_guid(guid)
- hobaddr = hoblist
+ hobguid = str_to_guid(guid)
+ hobaddr = hoblist
- while True:
- hobaddr = GetNextHob(ql, EFI_HOB_TYPE_GUID_EXTENSION, hobaddr)
+ while True:
+ hobaddr = GetNextHob(ql, EFI_HOB_TYPE_GUID_EXTENSION, hobaddr)
- if not hobaddr:
- return 0
+ if not hobaddr:
+ return 0
- hob = EFI_HOB_GUID_TYPE.loadFrom(ql, hobaddr)
+ hob = EFI_HOB_GUID_TYPE.loadFrom(ql, hobaddr)
- if CompareGuid(hob.Name, hobguid):
- break
+ if CompareGuid(hob.Name, hobguid):
+ break
- hobaddr += hob.Header.HobLength
+ hobaddr += hob.Header.HobLength
- return hobaddr
+ return hobaddr
diff --git a/qiling/os/uefi/protocols/EfiLoadedImageProtocol.py b/qiling/os/uefi/protocols/EfiLoadedImageProtocol.py
index fb450c35a..f422cdf5a 100644
--- a/qiling/os/uefi/protocols/EfiLoadedImageProtocol.py
+++ b/qiling/os/uefi/protocols/EfiLoadedImageProtocol.py
@@ -9,47 +9,47 @@
from ..UefiMultiPhase import EFI_MEMORY_TYPE
class EFI_LOADED_IMAGE_PROTOCOL(STRUCT):
- _pack_ = 8
+ _pack_ = 8
- _fields_ = [
- ('Revision', UINT32),
- ('ParentHandle', EFI_HANDLE),
- ('SystemTable', PTR(EFI_SYSTEM_TABLE)),
- ('DeviceHandle', EFI_HANDLE),
- ('FilePath', PTR(EFI_DEVICE_PATH_PROTOCOL)),
- ('Reserved', PTR(VOID)),
- ('LoadOptionsSize', UINT32),
- ('LoadOptions', PTR(VOID)),
- ('ImageBase', PTR(VOID)),
- ('ImageSize', UINT64),
- ('ImageCodeType', EFI_MEMORY_TYPE),
- ('ImageDataType', EFI_MEMORY_TYPE),
- ('Unload', EFI_IMAGE_UNLOAD)
- ]
+ _fields_ = [
+ ('Revision', UINT32),
+ ('ParentHandle', EFI_HANDLE),
+ ('SystemTable', PTR(EFI_SYSTEM_TABLE)),
+ ('DeviceHandle', EFI_HANDLE),
+ ('FilePath', PTR(EFI_DEVICE_PATH_PROTOCOL)),
+ ('Reserved', PTR(VOID)),
+ ('LoadOptionsSize', UINT32),
+ ('LoadOptions', PTR(VOID)),
+ ('ImageBase', PTR(VOID)),
+ ('ImageSize', UINT64),
+ ('ImageCodeType', EFI_MEMORY_TYPE),
+ ('ImageDataType', EFI_MEMORY_TYPE),
+ ('Unload', EFI_IMAGE_UNLOAD)
+ ]
def make_descriptor(fields):
- descriptor = {
- "guid" : "5b1b31a1-9562-11d2-8e3f-00a0c969723b",
- "struct" : EFI_LOADED_IMAGE_PROTOCOL,
- "fields" : (
- ('Revision', 0x1000),
- ('ParentHandle', 0),
- ('SystemTable', fields['gST']),
- ('DeviceHandle', fields['image_base']),
- ('FilePath', 0), # This is a handle to a complex path object, skip it for now.
- ('LoadOptionsSize', 0),
- ('LoadOptions', 0),
- ('ImageBase', fields['image_base']),
- ('ImageSize', fields['image_size']),
- ('ImageCodeType', EFI_MEMORY_TYPE.EfiLoaderCode),
- ('ImageDataType', EFI_MEMORY_TYPE.EfiLoaderData),
- ('Unload', 0)
- )
- }
+ descriptor = {
+ "guid" : "5b1b31a1-9562-11d2-8e3f-00a0c969723b",
+ "struct" : EFI_LOADED_IMAGE_PROTOCOL,
+ "fields" : (
+ ('Revision', 0x1000),
+ ('ParentHandle', 0),
+ ('SystemTable', fields['gST']),
+ ('DeviceHandle', fields['image_base']),
+ ('FilePath', 0), # This is a handle to a complex path object, skip it for now.
+ ('LoadOptionsSize', 0),
+ ('LoadOptions', 0),
+ ('ImageBase', fields['image_base']),
+ ('ImageSize', fields['image_size']),
+ ('ImageCodeType', EFI_MEMORY_TYPE.EfiLoaderCode),
+ ('ImageDataType', EFI_MEMORY_TYPE.EfiLoaderData),
+ ('Unload', 0)
+ )
+ }
- return descriptor
+ return descriptor
__all__ = [
- 'EFI_LOADED_IMAGE_PROTOCOL',
- 'make_descriptor'
+ 'EFI_LOADED_IMAGE_PROTOCOL',
+ 'make_descriptor'
]
\ No newline at end of file
diff --git a/qiling/os/uefi/protocols/EfiSmmAccess2Protocol.py b/qiling/os/uefi/protocols/EfiSmmAccess2Protocol.py
index 405d26a05..186f4803b 100644
--- a/qiling/os/uefi/protocols/EfiSmmAccess2Protocol.py
+++ b/qiling/os/uefi/protocols/EfiSmmAccess2Protocol.py
@@ -14,143 +14,143 @@
# @see: MdePkg\Include\Pi\PiMultiPhase.h
class EFI_MMRAM_DESCRIPTOR(STRUCT):
- _fields_ = [
- ('PhysicalStart', EFI_PHYSICAL_ADDRESS),
- ('CpuStart', EFI_PHYSICAL_ADDRESS),
- ('PhysicalSize', UINT64),
- ('RegionState', UINT64)
- ]
+ _fields_ = [
+ ('PhysicalStart', EFI_PHYSICAL_ADDRESS),
+ ('CpuStart', EFI_PHYSICAL_ADDRESS),
+ ('PhysicalSize', UINT64),
+ ('RegionState', UINT64)
+ ]
# @see: MdePkg\Include\Protocol\MmAccess.h
class EFI_SMM_ACCESS2_PROTOCOL(STRUCT):
- EFI_SMM_ACCESS2_PROTOCOL = STRUCT
- _pack_ = 8
-
- _fields_ = [
- ('Open', FUNCPTR(EFI_STATUS, PTR(EFI_SMM_ACCESS2_PROTOCOL))),
- ('Close', FUNCPTR(EFI_STATUS, PTR(EFI_SMM_ACCESS2_PROTOCOL))),
- ('Lock', FUNCPTR(EFI_STATUS, PTR(EFI_SMM_ACCESS2_PROTOCOL))),
- ('GetCapabilities', FUNCPTR(EFI_STATUS, PTR(EFI_SMM_ACCESS2_PROTOCOL), PTR(UINTN), PTR(EFI_MMRAM_DESCRIPTOR))),
- ('LockState', BOOLEAN),
- ('OpenState', BOOLEAN)
- ]
+ EFI_SMM_ACCESS2_PROTOCOL = STRUCT
+ _pack_ = 8
+
+ _fields_ = [
+ ('Open', FUNCPTR(EFI_STATUS, PTR(EFI_SMM_ACCESS2_PROTOCOL))),
+ ('Close', FUNCPTR(EFI_STATUS, PTR(EFI_SMM_ACCESS2_PROTOCOL))),
+ ('Lock', FUNCPTR(EFI_STATUS, PTR(EFI_SMM_ACCESS2_PROTOCOL))),
+ ('GetCapabilities', FUNCPTR(EFI_STATUS, PTR(EFI_SMM_ACCESS2_PROTOCOL), PTR(UINTN), PTR(EFI_MMRAM_DESCRIPTOR))),
+ ('LockState', BOOLEAN),
+ ('OpenState', BOOLEAN)
+ ]
@dxeapi(params = {
- "This" : POINTER
+ "This" : POINTER
})
def hook_Open(ql: Qiling, address: int, params):
- ql.loader.smm_context.tseg_open = True
+ ql.loader.smm_context.tseg_open = True
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "This" : POINTER
+ "This" : POINTER
})
def hook_Close(ql: Qiling, address: int, params):
- ql.loader.smm_context.tseg_open = False
+ ql.loader.smm_context.tseg_open = False
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "This" : POINTER
+ "This" : POINTER
})
def hook_Lock(ql: Qiling, address: int, params):
- ql.loader.smm_context.tseg_locked = True
+ ql.loader.smm_context.tseg_locked = True
- return EFI_SUCCESS
+ return EFI_SUCCESS
def _coalesce(seq):
- """Coalesce adjacent ranges on list, as long as they share the
- same attributes.
- """
+ """Coalesce adjacent ranges on list, as long as they share the
+ same attributes.
+ """
- res = []
- curr = seq[0]
+ res = []
+ curr = seq[0]
- for item in seq[1:]:
- start, end, attr = item
+ for item in seq[1:]:
+ start, end, attr = item
- if start == curr[1] and attr == curr[2]:
- curr[1] = end
- else:
- res.append(curr)
- curr = item
+ if start == curr[1] and attr == curr[2]:
+ curr[1] = end
+ else:
+ res.append(curr)
+ curr = item
- res.append(curr)
+ res.append(curr)
- return res
+ return res
@dxeapi(params = {
- "This" : POINTER, # PTR(EFI_SMM_ACCESS2_PROTOCOL)
- "MmramMapSize" : POINTER, # IN OUT PTR(UINTN)
- "MmramMap" : POINTER # OUT PTR(EFI_MMRAM_DESCRIPTOR)
+ "This" : POINTER, # PTR(EFI_SMM_ACCESS2_PROTOCOL)
+ "MmramMapSize" : POINTER, # IN OUT PTR(UINTN)
+ "MmramMap" : POINTER # OUT PTR(EFI_MMRAM_DESCRIPTOR)
})
def hook_GetCapabilities(ql: Qiling, address: int, params):
- heap = ql.loader.smm_context.heap
+ heap = ql.loader.smm_context.heap
- # get a copy of smm heap chunks list sorted by starting address
- chunks = sorted(heap.chunks, key=lambda c: c.address)
+ # get a copy of smm heap chunks list sorted by starting address
+ chunks = sorted(heap.chunks, key=lambda c: c.address)
- # turn chunks objects into 3-item entries: [start, end, inuse]
- chunks = [[ch.address, ch.address + ch.size, ch.inuse] for ch in chunks]
+ # turn chunks objects into 3-item entries: [start, end, inuse]
+ chunks = [[ch.address, ch.address + ch.size, ch.inuse] for ch in chunks]
- # if first chunk does not start at heap start, add a dummy free chunk there
- if chunks[0][0] != heap.start_address:
- chunks.insert(0, [heap.start_address, chunks[0].address, False])
+ # if first chunk does not start at heap start, add a dummy free chunk there
+ if chunks[0][0] != heap.start_address:
+ chunks.insert(0, [heap.start_address, chunks[0].address, False])
- # if last chunk does not end at heap end, add a dummy free chunk there
- if (chunks[-1][1]) != heap.end_address:
- chunks.append([chunks[-1][1], heap.end_address, False])
+ # if last chunk does not end at heap end, add a dummy free chunk there
+ if (chunks[-1][1]) != heap.end_address:
+ chunks.append([chunks[-1][1], heap.end_address, False])
- # coalesce adjacent free / used chunks on the list
- chunks = _coalesce(chunks)
+ # coalesce adjacent free / used chunks on the list
+ chunks = _coalesce(chunks)
- size = len(chunks) * EFI_SMRAM_DESCRIPTOR.sizeof()
- MmramMapSize = params["MmramMapSize"]
+ size = len(chunks) * EFI_SMRAM_DESCRIPTOR.sizeof()
+ MmramMapSize = params["MmramMapSize"]
- if utils.read_int64(ql, MmramMapSize) < size:
- # since the caller cannot predict how much memory would be required for storing
- # the memory map, this method is normally called twice. the first one passes a
- # zero size only to determine the expected size, then the caller allocates the
- # required amount of memory and call it again.
- #
- # our memory map is managed differently from the real one, and memory allocations
- # are likely to generate an additional "map block" (or two, if allocated somewhere
- # in the last free heap chunk). because the caller allocates a new memory chunk
- # between the two calls, that would cause the second call to always complain the
- # buffer is too small.
- #
- # to work around that, we have the first call return a larger number than it should
- # have, to compensate on the coming allocation.
- extra = 2 * EFI_SMRAM_DESCRIPTOR.sizeof()
+ if utils.read_int64(ql, MmramMapSize) < size:
+ # since the caller cannot predict how much memory would be required for storing
+ # the memory map, this method is normally called twice. the first one passes a
+ # zero size only to determine the expected size, then the caller allocates the
+ # required amount of memory and call it again.
+ #
+ # our memory map is managed differently from the real one, and memory allocations
+ # are likely to generate an additional "map block" (or two, if allocated somewhere
+ # in the last free heap chunk). because the caller allocates a new memory chunk
+ # between the two calls, that would cause the second call to always complain the
+ # buffer is too small.
+ #
+ # to work around that, we have the first call return a larger number than it should
+ # have, to compensate on the coming allocation.
+ extra = 2 * EFI_SMRAM_DESCRIPTOR.sizeof()
- utils.write_int64(ql, MmramMapSize, size + extra)
- return EFI_BUFFER_TOO_SMALL
+ utils.write_int64(ql, MmramMapSize, size + extra)
+ return EFI_BUFFER_TOO_SMALL
- MmramMap = params["MmramMap"]
+ MmramMap = params["MmramMap"]
- state = EFI_CACHEABLE
- state |= EFI_SMRAM_OPEN if ql.loader.smm_context.tseg_open else EFI_SMRAM_CLOSED
- state |= EFI_SMRAM_LOCKED if ql.loader.smm_context.tseg_locked else 0
+ state = EFI_CACHEABLE
+ state |= EFI_SMRAM_OPEN if ql.loader.smm_context.tseg_open else EFI_SMRAM_CLOSED
+ state |= EFI_SMRAM_LOCKED if ql.loader.smm_context.tseg_locked else 0
- for i, ch in enumerate(chunks):
- desc = EFI_SMRAM_DESCRIPTOR()
- desc.PhysicalStart = ch[0]
- desc.CpuStart = ch[0]
- desc.PhysicalSize = ch[1] - ch[0]
- desc.RegionState = state | (EFI_ALLOCATED if ch[2] else 0)
+ for i, ch in enumerate(chunks):
+ desc = EFI_SMRAM_DESCRIPTOR()
+ desc.PhysicalStart = ch[0]
+ desc.CpuStart = ch[0]
+ desc.PhysicalSize = ch[1] - ch[0]
+ desc.RegionState = state | (EFI_ALLOCATED if ch[2] else 0)
- desc.saveTo(ql, MmramMap + (i * desc.sizeof()))
+ desc.saveTo(ql, MmramMap + (i * desc.sizeof()))
- return EFI_SUCCESS
+ return EFI_SUCCESS
descriptor = {
- "guid" : "c2702b74-800c-4131-8746-8fb5b89ce4ac",
- "struct" : EFI_SMM_ACCESS2_PROTOCOL,
- "fields" : (
- ("Open", hook_Open),
- ("Close", hook_Close),
- ("Lock", hook_Lock),
- ("GetCapabilities", hook_GetCapabilities)
- )
+ "guid" : "c2702b74-800c-4131-8746-8fb5b89ce4ac",
+ "struct" : EFI_SMM_ACCESS2_PROTOCOL,
+ "fields" : (
+ ("Open", hook_Open),
+ ("Close", hook_Close),
+ ("Lock", hook_Lock),
+ ("GetCapabilities", hook_GetCapabilities)
+ )
}
diff --git a/qiling/os/uefi/protocols/EfiSmmBase2Protocol.py b/qiling/os/uefi/protocols/EfiSmmBase2Protocol.py
index 671e9a81c..1817862a7 100644
--- a/qiling/os/uefi/protocols/EfiSmmBase2Protocol.py
+++ b/qiling/os/uefi/protocols/EfiSmmBase2Protocol.py
@@ -15,43 +15,43 @@
# @see: MdePkg\Include\Protocol\SmmBase2.h
class EFI_SMM_BASE2_PROTOCOL(STRUCT):
- EFI_SMM_BASE2_PROTOCOL = STRUCT
+ EFI_SMM_BASE2_PROTOCOL = STRUCT
- _fields_ = [
- ('InSmm', FUNCPTR(EFI_STATUS, PTR(EFI_SMM_BASE2_PROTOCOL), PTR(BOOLEAN))),
- ('GetSmstLocation', FUNCPTR(EFI_STATUS, PTR(EFI_SMM_BASE2_PROTOCOL), PTR(PTR(EFI_SMM_SYSTEM_TABLE2)))),
- ]
+ _fields_ = [
+ ('InSmm', FUNCPTR(EFI_STATUS, PTR(EFI_SMM_BASE2_PROTOCOL), PTR(BOOLEAN))),
+ ('GetSmstLocation', FUNCPTR(EFI_STATUS, PTR(EFI_SMM_BASE2_PROTOCOL), PTR(PTR(EFI_SMM_SYSTEM_TABLE2)))),
+ ]
@dxeapi(params = {
- "This" : POINTER,
- "InSmram" : POINTER
+ "This" : POINTER,
+ "InSmram" : POINTER
})
def hook_InSmm(ql: Qiling, address: int, params):
- ql.log.debug(f'InSmram = {ql.os.smm.active}')
+ ql.log.debug(f'InSmram = {ql.os.smm.active}')
- write_int8(ql, params["InSmram"], int(ql.os.smm.active))
+ write_int8(ql, params["InSmram"], int(ql.os.smm.active))
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "This" : POINTER,
- "Smst" : POINTER
+ "This" : POINTER,
+ "Smst" : POINTER
})
def hook_GetSmstLocation(ql: Qiling, address: int, params):
- Smst = params["Smst"]
+ Smst = params["Smst"]
- if Smst == 0:
- return EFI_INVALID_PARAMETER
+ if Smst == 0:
+ return EFI_INVALID_PARAMETER
- write_int64(ql, Smst, ql.loader.gSmst)
+ write_int64(ql, Smst, ql.loader.gSmst)
- return EFI_SUCCESS
+ return EFI_SUCCESS
descriptor = {
- "guid" : "f4ccbfb7-f6e0-47fd-9dd4-10a8f150c191",
- "struct" : EFI_SMM_BASE2_PROTOCOL,
- "fields" : (
- ("InSmm", hook_InSmm),
- ("GetSmstLocation", hook_GetSmstLocation)
- )
+ "guid" : "f4ccbfb7-f6e0-47fd-9dd4-10a8f150c191",
+ "struct" : EFI_SMM_BASE2_PROTOCOL,
+ "fields" : (
+ ("InSmm", hook_InSmm),
+ ("GetSmstLocation", hook_GetSmstLocation)
+ )
}
diff --git a/qiling/os/uefi/protocols/EfiSmmCpuProtocol.py b/qiling/os/uefi/protocols/EfiSmmCpuProtocol.py
index eaa6ec681..3b24ea8ec 100644
--- a/qiling/os/uefi/protocols/EfiSmmCpuProtocol.py
+++ b/qiling/os/uefi/protocols/EfiSmmCpuProtocol.py
@@ -11,148 +11,148 @@
# @see: MdePkg/Include/Protocol/MmCpu.h
class EFI_SMM_SAVE_STATE_REGISTER(ENUM_UC):
- _members_ = {
- # note: members names were shorten from 'EFI_SMM_SAVE_STATE_REGISTER_regname' to just 'regname'
- 'GDTBASE' : 4,
- 'IDTBASE' : 5,
- 'LDTBASE' : 6,
- 'GDTLIMIT' : 7,
- 'IDTLIMIT' : 8,
- 'LDTLIMIT' : 9,
- 'LDTINFO' : 10,
-
- 'ES' : 20,
- 'CS' : 21,
- 'SS' : 22,
- 'DS' : 23,
- 'FS' : 24,
- 'GS' : 25,
- 'LDTR_SEL' : 26,
- 'TR_SEL' : 27,
- 'DR7' : 28,
- 'DR6' : 29,
- 'R8' : 30,
- 'R9' : 31,
- 'R10' : 32,
- 'R11' : 33,
- 'R12' : 34,
- 'R13' : 35,
- 'R14' : 36,
- 'R15' : 37,
- 'RAX' : 38,
- 'RBX' : 39,
- 'RCX' : 40,
- 'RDX' : 41,
- 'RSP' : 42,
- 'RBP' : 43,
- 'RSI' : 44,
- 'RDI' : 45,
- 'RIP' : 46,
-
- 'RFLAGS' : 51,
- 'CR0' : 52,
- 'CR3' : 53,
- 'CR4' : 54,
-
- 'FCW' : 256,
- 'FSW' : 257,
- 'FTW' : 258,
- 'OPCODE' : 259,
- 'FP_EIP' : 260,
- 'FP_CS' : 261,
- 'DATAOFFSET': 262,
- 'FP_DS' : 263,
- 'MM0' : 264,
- 'MM1' : 265,
- 'MM2' : 266,
- 'MM3' : 267,
- 'MM4' : 268,
- 'MM5' : 269,
- 'MM6' : 270,
- 'MM7' : 271,
- 'XMM0' : 272,
- 'XMM1' : 273,
- 'XMM2' : 274,
- 'XMM3' : 275,
- 'XMM4' : 276,
- 'XMM5' : 277,
- 'XMM6' : 278,
- 'XMM7' : 279,
- 'XMM8' : 280,
- 'XMM9' : 281,
- 'XMM10' : 282,
- 'XMM11' : 283,
- 'XMM12' : 284,
- 'XMM13' : 285,
- 'XMM14' : 286,
- 'XMM15' : 287,
-
- 'IO' : 512,
- 'LMA' : 513,
- 'PROCESSOR_ID' : 514
- }
-
-# EFI_SUCCESS The register was written from Save State
-# EFI_NOT_FOUND The register is not defined for the Save State of Processor
-# EFI_INVALID_PARAMETER ProcessorIndex or Width is not correct
+ _members_ = {
+ # note: members names were shorten from 'EFI_SMM_SAVE_STATE_REGISTER_regname' to just 'regname'
+ 'GDTBASE' : 4,
+ 'IDTBASE' : 5,
+ 'LDTBASE' : 6,
+ 'GDTLIMIT' : 7,
+ 'IDTLIMIT' : 8,
+ 'LDTLIMIT' : 9,
+ 'LDTINFO' : 10,
+
+ 'ES' : 20,
+ 'CS' : 21,
+ 'SS' : 22,
+ 'DS' : 23,
+ 'FS' : 24,
+ 'GS' : 25,
+ 'LDTR_SEL' : 26,
+ 'TR_SEL' : 27,
+ 'DR7' : 28,
+ 'DR6' : 29,
+ 'R8' : 30,
+ 'R9' : 31,
+ 'R10' : 32,
+ 'R11' : 33,
+ 'R12' : 34,
+ 'R13' : 35,
+ 'R14' : 36,
+ 'R15' : 37,
+ 'RAX' : 38,
+ 'RBX' : 39,
+ 'RCX' : 40,
+ 'RDX' : 41,
+ 'RSP' : 42,
+ 'RBP' : 43,
+ 'RSI' : 44,
+ 'RDI' : 45,
+ 'RIP' : 46,
+
+ 'RFLAGS' : 51,
+ 'CR0' : 52,
+ 'CR3' : 53,
+ 'CR4' : 54,
+
+ 'FCW' : 256,
+ 'FSW' : 257,
+ 'FTW' : 258,
+ 'OPCODE' : 259,
+ 'FP_EIP' : 260,
+ 'FP_CS' : 261,
+ 'DATAOFFSET': 262,
+ 'FP_DS' : 263,
+ 'MM0' : 264,
+ 'MM1' : 265,
+ 'MM2' : 266,
+ 'MM3' : 267,
+ 'MM4' : 268,
+ 'MM5' : 269,
+ 'MM6' : 270,
+ 'MM7' : 271,
+ 'XMM0' : 272,
+ 'XMM1' : 273,
+ 'XMM2' : 274,
+ 'XMM3' : 275,
+ 'XMM4' : 276,
+ 'XMM5' : 277,
+ 'XMM6' : 278,
+ 'XMM7' : 279,
+ 'XMM8' : 280,
+ 'XMM9' : 281,
+ 'XMM10' : 282,
+ 'XMM11' : 283,
+ 'XMM12' : 284,
+ 'XMM13' : 285,
+ 'XMM14' : 286,
+ 'XMM15' : 287,
+
+ 'IO' : 512,
+ 'LMA' : 513,
+ 'PROCESSOR_ID' : 514
+ }
+
+# EFI_SUCCESS The register was written from Save State
+# EFI_NOT_FOUND The register is not defined for the Save State of Processor
+# EFI_INVALID_PARAMETER ProcessorIndex or Width is not correct
@dxeapi(params = {
- "This" : POINTER, # EFI_SMM_CPU_PROTOCOL
- "Width" : ULONGLONG,# UINTN
- "Register" : INT, # EFI_SMM_SAVE_STATE_REGISTER
- "CpuIndex" : ULONGLONG,# UINTN
- "Buffer" : POINTER # PTR(VOID)
+ "This" : POINTER, # EFI_SMM_CPU_PROTOCOL
+ "Width" : ULONGLONG,# UINTN
+ "Register" : INT, # EFI_SMM_SAVE_STATE_REGISTER
+ "CpuIndex" : ULONGLONG,# UINTN
+ "Buffer" : POINTER # PTR(VOID)
})
def hook_SmmReadSaveState(ql: Qiling, address: int, params):
- Width = params['Width']
- Register = params['Register']
- CpuIndex = params['CpuIndex']
- Buffer = params['Buffer']
+ Width = params['Width']
+ Register = params['Register']
+ CpuIndex = params['CpuIndex']
+ Buffer = params['Buffer']
- # currently supporting only one cpu
- if CpuIndex > 0:
- return EFI_INVALID_PARAMETER
+ # currently supporting only one cpu
+ if CpuIndex > 0:
+ return EFI_INVALID_PARAMETER
- data = ql.os.smm.ssa.read(Register, Width)
- ql.mem.write(Buffer, bytes(data))
+ data = ql.os.smm.ssa.read(Register, Width)
+ ql.mem.write(Buffer, bytes(data))
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "This" : POINTER, # EFI_SMM_CPU_PROTOCOL
- "Width" : ULONGLONG,# UINTN
- "Register" : INT, # EFI_SMM_SAVE_STATE_REGISTER
- "CpuIndex" : ULONGLONG,# UINTN
- "Buffer" : POINTER # PTR(VOID)
+ "This" : POINTER, # EFI_SMM_CPU_PROTOCOL
+ "Width" : ULONGLONG,# UINTN
+ "Register" : INT, # EFI_SMM_SAVE_STATE_REGISTER
+ "CpuIndex" : ULONGLONG,# UINTN
+ "Buffer" : POINTER # PTR(VOID)
})
def hook_SmmWriteSaveState(ql: Qiling, address: int, params):
- Width = params['Width']
- Register = params['Register']
- CpuIndex = params['CpuIndex']
- Buffer = params['Buffer']
+ Width = params['Width']
+ Register = params['Register']
+ CpuIndex = params['CpuIndex']
+ Buffer = params['Buffer']
- # currently supporting only one cpu
- if CpuIndex > 0:
- return EFI_INVALID_PARAMETER
+ # currently supporting only one cpu
+ if CpuIndex > 0:
+ return EFI_INVALID_PARAMETER
- data = ql.mem.read(Buffer, Width)
- ql.os.smm.ssa.write(Register, bytes(data))
+ data = ql.mem.read(Buffer, Width)
+ ql.os.smm.ssa.write(Register, bytes(data))
- return EFI_SUCCESS
+ return EFI_SUCCESS
class EFI_SMM_CPU_PROTOCOL(STRUCT):
- EFI_SMM_CPU_PROTOCOL = STRUCT
+ EFI_SMM_CPU_PROTOCOL = STRUCT
- _fields_ = [
- ('SmmReadSaveState', FUNCPTR(PTR(EFI_SMM_CPU_PROTOCOL), UINTN, EFI_SMM_SAVE_STATE_REGISTER, UINTN, PTR(VOID))),
- ('SmmWriteSaveState', FUNCPTR(PTR(EFI_SMM_CPU_PROTOCOL), UINTN, EFI_SMM_SAVE_STATE_REGISTER, UINTN, PTR(VOID)))
- ]
+ _fields_ = [
+ ('SmmReadSaveState', FUNCPTR(PTR(EFI_SMM_CPU_PROTOCOL), UINTN, EFI_SMM_SAVE_STATE_REGISTER, UINTN, PTR(VOID))),
+ ('SmmWriteSaveState', FUNCPTR(PTR(EFI_SMM_CPU_PROTOCOL), UINTN, EFI_SMM_SAVE_STATE_REGISTER, UINTN, PTR(VOID)))
+ ]
descriptor = {
- "guid" : "eb346b97-975f-4a9f-8b22-f8e92bb3d569",
- "struct" : EFI_SMM_CPU_PROTOCOL,
- "fields" : (
- ("SmmReadSaveState", hook_SmmReadSaveState),
- ("SmmWriteSaveState", hook_SmmWriteSaveState)
- )
+ "guid" : "eb346b97-975f-4a9f-8b22-f8e92bb3d569",
+ "struct" : EFI_SMM_CPU_PROTOCOL,
+ "fields" : (
+ ("SmmReadSaveState", hook_SmmReadSaveState),
+ ("SmmWriteSaveState", hook_SmmWriteSaveState)
+ )
}
diff --git a/qiling/os/uefi/protocols/EfiSmmSwDispatch2Protocol.py b/qiling/os/uefi/protocols/EfiSmmSwDispatch2Protocol.py
index 22f92537d..d26b66b9d 100644
--- a/qiling/os/uefi/protocols/EfiSmmSwDispatch2Protocol.py
+++ b/qiling/os/uefi/protocols/EfiSmmSwDispatch2Protocol.py
@@ -14,110 +14,110 @@
MAXIMUM_SWI_VALUE = 0xff
class EFI_SMM_SW_CONTEXT(STRUCT):
- _pack_ = 8
+ _pack_ = 8
- _fields_ = [
- ('SwSmiCpuIndex', UINTN), # index of the cpu which generated the swsmi
- ('CommandPort', UINT8), # port number used to trigger the swsmi
- ('DataPort', UINT8) # irrelevant
- ]
+ _fields_ = [
+ ('SwSmiCpuIndex', UINTN), # index of the cpu which generated the swsmi
+ ('CommandPort', UINT8), # port number used to trigger the swsmi
+ ('DataPort', UINT8) # irrelevant
+ ]
# @file: MdePkg\Include\Protocol\SmmSwDispatch2.h
class EFI_SMM_SW_REGISTER_CONTEXT(STRUCT):
- _fields_ = [
- ('SwSmiInputValue', UINTN)
- ]
+ _fields_ = [
+ ('SwSmiInputValue', UINTN)
+ ]
# @ file: MdePkg\Include\Pi\PiMmCis.h
EFI_SMM_HANDLER_ENTRY_POINT2 = FUNCPTR(EFI_STATUS, EFI_HANDLE, PTR(VOID), PTR(VOID), PTR(UINTN))
class EFI_SMM_SW_DISPATCH2_PROTOCOL(STRUCT):
- EFI_SMM_SW_DISPATCH2_PROTOCOL = STRUCT
+ EFI_SMM_SW_DISPATCH2_PROTOCOL = STRUCT
- _fields_ = [
- ('Register', FUNCPTR(EFI_STATUS, PTR(EFI_SMM_SW_DISPATCH2_PROTOCOL), EFI_SMM_HANDLER_ENTRY_POINT2, PTR(EFI_SMM_SW_REGISTER_CONTEXT), PTR(EFI_HANDLE))),
- ('UnRegister', FUNCPTR(EFI_STATUS, PTR(EFI_SMM_SW_DISPATCH2_PROTOCOL), EFI_HANDLE)),
- ('MaximumSwiValue', UINTN)
- ]
+ _fields_ = [
+ ('Register', FUNCPTR(EFI_STATUS, PTR(EFI_SMM_SW_DISPATCH2_PROTOCOL), EFI_SMM_HANDLER_ENTRY_POINT2, PTR(EFI_SMM_SW_REGISTER_CONTEXT), PTR(EFI_HANDLE))),
+ ('UnRegister', FUNCPTR(EFI_STATUS, PTR(EFI_SMM_SW_DISPATCH2_PROTOCOL), EFI_HANDLE)),
+ ('MaximumSwiValue', UINTN)
+ ]
@dxeapi(params = {
- "This" : POINTER, # PTR(EFI_SMM_SW_DISPATCH2_PROTOCOL)
- "DispatchFunction" : POINTER, # EFI_SMM_HANDLER_ENTRY_POINT2
- "RegisterContext" : POINTER, # PTR(EFI_SMM_SW_REGISTER_CONTEXT)
- "DispatchHandle" : POINTER # PTR(EFI_HANDLE)
+ "This" : POINTER, # PTR(EFI_SMM_SW_DISPATCH2_PROTOCOL)
+ "DispatchFunction" : POINTER, # EFI_SMM_HANDLER_ENTRY_POINT2
+ "RegisterContext" : POINTER, # PTR(EFI_SMM_SW_REGISTER_CONTEXT)
+ "DispatchHandle" : POINTER # PTR(EFI_HANDLE)
})
def hook_Register(ql: Qiling, address: int, params):
- DispatchFunction: int = params['DispatchFunction']
- RegisterContext: int = params['RegisterContext']
- DispatchHandle: int = params['DispatchHandle']
+ DispatchFunction: int = params['DispatchFunction']
+ RegisterContext: int = params['RegisterContext']
+ DispatchHandle: int = params['DispatchHandle']
- if DispatchFunction == 0 or DispatchHandle == 0:
- return EFI_INVALID_PARAMETER
+ if DispatchFunction == 0 or DispatchHandle == 0:
+ return EFI_INVALID_PARAMETER
- handlers = ql.loader.smm_context.swsmi_handlers
+ handlers = ql.loader.smm_context.swsmi_handlers
- SwRegisterContext = EFI_SMM_SW_REGISTER_CONTEXT.loadFrom(ql, RegisterContext)
- idx = SwRegisterContext.SwSmiInputValue
+ SwRegisterContext = EFI_SMM_SW_REGISTER_CONTEXT.loadFrom(ql, RegisterContext)
+ idx = SwRegisterContext.SwSmiInputValue
- # a value of -1 indicates that the swsmi index for this handler is flexible and
- # should be assigned by the protocol
- if idx == ((1 << ql.arch.bits) - 1):
- idx = next((i for i in range(1, MAXIMUM_SWI_VALUE) if i not in handlers), None)
+ # a value of -1 indicates that the swsmi index for this handler is flexible and
+ # should be assigned by the protocol
+ if idx == ((1 << ql.arch.bits) - 1):
+ idx = next((i for i in range(1, MAXIMUM_SWI_VALUE) if i not in handlers), None)
- if idx is None:
- return EFI_OUT_OF_RESOURCES
+ if idx is None:
+ return EFI_OUT_OF_RESOURCES
- SwRegisterContext.SwSmiInputValue = idx
- SwRegisterContext.saveTo(ql, RegisterContext)
+ SwRegisterContext.SwSmiInputValue = idx
+ SwRegisterContext.saveTo(ql, RegisterContext)
- else:
- This = EFI_SMM_SW_DISPATCH2_PROTOCOL.loadFrom(ql, params['This'])
+ else:
+ This = EFI_SMM_SW_DISPATCH2_PROTOCOL.loadFrom(ql, params['This'])
- if idx in handlers:
- return EFI_INVALID_PARAMETER
+ if idx in handlers:
+ return EFI_INVALID_PARAMETER
- if idx > This.MaximumSwiValue:
- return EFI_INVALID_PARAMETER
+ if idx > This.MaximumSwiValue:
+ return EFI_INVALID_PARAMETER
- # allocate handle and return it through out parameter
- Handle = ql.loader.smm_context.heap.alloc(ql.arch.pointersize)
- utils.write_int64(ql, DispatchHandle, Handle)
+ # allocate handle and return it through out parameter
+ Handle = ql.loader.smm_context.heap.alloc(ql.arch.pointersize)
+ utils.write_int64(ql, DispatchHandle, Handle)
- args = {
- 'DispatchHandle' : Handle,
- 'RegisterContext' : SwRegisterContext
- }
+ args = {
+ 'DispatchHandle' : Handle,
+ 'RegisterContext' : SwRegisterContext
+ }
- handlers[idx] = (DispatchFunction, args)
+ handlers[idx] = (DispatchFunction, args)
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "This" : POINTER,
- "DispatchHandle" : POINTER
+ "This" : POINTER,
+ "DispatchHandle" : POINTER
})
def hook_UnRegister(ql: Qiling, address: int, params):
- DispatchHandle: int = params['DispatchHandle']
+ DispatchHandle: int = params['DispatchHandle']
- handlers = ql.loader.smm_context.swsmi_handlers
- heap = ql.loader.smm_context.heap
+ handlers = ql.loader.smm_context.swsmi_handlers
+ heap = ql.loader.smm_context.heap
- idx = next((idx for idx, (_, args) in handlers.items() if args['DispatchHandle'] == DispatchHandle), None)
+ idx = next((idx for idx, (_, args) in handlers.items() if args['DispatchHandle'] == DispatchHandle), None)
- if idx is None:
- return EFI_INVALID_PARAMETER
+ if idx is None:
+ return EFI_INVALID_PARAMETER
- heap.free(DispatchHandle)
- del handlers[idx]
+ heap.free(DispatchHandle)
+ del handlers[idx]
- return EFI_SUCCESS
+ return EFI_SUCCESS
descriptor = {
- "guid" : "18a3c6dc-5eea-48c8-a1c1-b53389f98999",
- "struct" : EFI_SMM_SW_DISPATCH2_PROTOCOL,
- "fields" : (
- ("Register", hook_Register),
- ("UnRegister", hook_UnRegister),
- ('MaximumSwiValue', MAXIMUM_SWI_VALUE)
- )
+ "guid" : "18a3c6dc-5eea-48c8-a1c1-b53389f98999",
+ "struct" : EFI_SMM_SW_DISPATCH2_PROTOCOL,
+ "fields" : (
+ ("Register", hook_Register),
+ ("UnRegister", hook_UnRegister),
+ ('MaximumSwiValue', MAXIMUM_SWI_VALUE)
+ )
}
diff --git a/qiling/os/uefi/protocols/PcdProtocol.py b/qiling/os/uefi/protocols/PcdProtocol.py
index f4237b11a..e1eaafab9 100644
--- a/qiling/os/uefi/protocols/PcdProtocol.py
+++ b/qiling/os/uefi/protocols/PcdProtocol.py
@@ -10,325 +10,325 @@
PCD_PROTOCOL_CALLBACK = FUNCPTR(VOID, PTR(EFI_GUID), UINTN, PTR(VOID), UINTN)
-PCD_PROTOCOL_SET_SKU = FUNCPTR(VOID, UINTN)
-PCD_PROTOCOL_GET8 = FUNCPTR(UINT8, UINTN)
-PCD_PROTOCOL_GET16 = FUNCPTR(UINT16, UINTN)
-PCD_PROTOCOL_GET32 = FUNCPTR(UINT32, UINTN)
-PCD_PROTOCOL_GET64 = FUNCPTR(UINT64, UINTN)
-PCD_PROTOCOL_GET_POINTER = FUNCPTR(PTR(VOID), UINTN)
-PCD_PROTOCOL_GET_BOOLEAN = FUNCPTR(BOOLEAN, UINTN)
-PCD_PROTOCOL_GET_SIZE = FUNCPTR(UINTN, UINTN)
-PCD_PROTOCOL_GET_EX_8 = FUNCPTR(UINT8, PTR(EFI_GUID), UINTN)
-PCD_PROTOCOL_GET_EX_16 = FUNCPTR(UINT16, PTR(EFI_GUID), UINTN)
-PCD_PROTOCOL_GET_EX_32 = FUNCPTR(UINT32, PTR(EFI_GUID), UINTN)
-PCD_PROTOCOL_GET_EX_64 = FUNCPTR(UINT64, PTR(EFI_GUID), UINTN)
-PCD_PROTOCOL_GET_EX_POINTER = FUNCPTR(PTR(VOID), PTR(EFI_GUID), UINTN)
-PCD_PROTOCOL_GET_EX_BOOLEAN = FUNCPTR(BOOLEAN, PTR(EFI_GUID), UINTN)
-PCD_PROTOCOL_GET_EX_SIZE = FUNCPTR(UINTN, PTR(EFI_GUID), UINTN)
-PCD_PROTOCOL_SET8 = FUNCPTR(EFI_STATUS, UINTN, UINT8)
-PCD_PROTOCOL_SET16 = FUNCPTR(EFI_STATUS, UINTN, UINT16)
-PCD_PROTOCOL_SET32 = FUNCPTR(EFI_STATUS, UINTN, UINT32)
-PCD_PROTOCOL_SET64 = FUNCPTR(EFI_STATUS, UINTN, UINT64)
-PCD_PROTOCOL_SET_POINTER = FUNCPTR(EFI_STATUS, UINTN, PTR(UINTN), PTR(VOID))
-PCD_PROTOCOL_SET_BOOLEAN = FUNCPTR(EFI_STATUS, UINTN, BOOLEAN)
-PCD_PROTOCOL_SET_EX_8 = FUNCPTR(EFI_STATUS, PTR(EFI_GUID), UINTN, UINT8)
-PCD_PROTOCOL_SET_EX_16 = FUNCPTR(EFI_STATUS, PTR(EFI_GUID), UINTN, UINT16)
-PCD_PROTOCOL_SET_EX_32 = FUNCPTR(EFI_STATUS, PTR(EFI_GUID), UINTN, UINT32)
-PCD_PROTOCOL_SET_EX_64 = FUNCPTR(EFI_STATUS, PTR(EFI_GUID), UINTN, UINT64)
-PCD_PROTOCOL_SET_EX_POINTER = FUNCPTR(EFI_STATUS, PTR(EFI_GUID), UINTN, PTR(UINTN), PTR(VOID))
-PCD_PROTOCOL_SET_EX_BOOLEAN = FUNCPTR(EFI_STATUS, PTR(EFI_GUID), UINTN, BOOLEAN)
-PCD_PROTOCOL_CALLBACK_ONSET = FUNCPTR(EFI_STATUS, PTR(EFI_GUID), UINTN, PCD_PROTOCOL_CALLBACK)
+PCD_PROTOCOL_SET_SKU = FUNCPTR(VOID, UINTN)
+PCD_PROTOCOL_GET8 = FUNCPTR(UINT8, UINTN)
+PCD_PROTOCOL_GET16 = FUNCPTR(UINT16, UINTN)
+PCD_PROTOCOL_GET32 = FUNCPTR(UINT32, UINTN)
+PCD_PROTOCOL_GET64 = FUNCPTR(UINT64, UINTN)
+PCD_PROTOCOL_GET_POINTER = FUNCPTR(PTR(VOID), UINTN)
+PCD_PROTOCOL_GET_BOOLEAN = FUNCPTR(BOOLEAN, UINTN)
+PCD_PROTOCOL_GET_SIZE = FUNCPTR(UINTN, UINTN)
+PCD_PROTOCOL_GET_EX_8 = FUNCPTR(UINT8, PTR(EFI_GUID), UINTN)
+PCD_PROTOCOL_GET_EX_16 = FUNCPTR(UINT16, PTR(EFI_GUID), UINTN)
+PCD_PROTOCOL_GET_EX_32 = FUNCPTR(UINT32, PTR(EFI_GUID), UINTN)
+PCD_PROTOCOL_GET_EX_64 = FUNCPTR(UINT64, PTR(EFI_GUID), UINTN)
+PCD_PROTOCOL_GET_EX_POINTER = FUNCPTR(PTR(VOID), PTR(EFI_GUID), UINTN)
+PCD_PROTOCOL_GET_EX_BOOLEAN = FUNCPTR(BOOLEAN, PTR(EFI_GUID), UINTN)
+PCD_PROTOCOL_GET_EX_SIZE = FUNCPTR(UINTN, PTR(EFI_GUID), UINTN)
+PCD_PROTOCOL_SET8 = FUNCPTR(EFI_STATUS, UINTN, UINT8)
+PCD_PROTOCOL_SET16 = FUNCPTR(EFI_STATUS, UINTN, UINT16)
+PCD_PROTOCOL_SET32 = FUNCPTR(EFI_STATUS, UINTN, UINT32)
+PCD_PROTOCOL_SET64 = FUNCPTR(EFI_STATUS, UINTN, UINT64)
+PCD_PROTOCOL_SET_POINTER = FUNCPTR(EFI_STATUS, UINTN, PTR(UINTN), PTR(VOID))
+PCD_PROTOCOL_SET_BOOLEAN = FUNCPTR(EFI_STATUS, UINTN, BOOLEAN)
+PCD_PROTOCOL_SET_EX_8 = FUNCPTR(EFI_STATUS, PTR(EFI_GUID), UINTN, UINT8)
+PCD_PROTOCOL_SET_EX_16 = FUNCPTR(EFI_STATUS, PTR(EFI_GUID), UINTN, UINT16)
+PCD_PROTOCOL_SET_EX_32 = FUNCPTR(EFI_STATUS, PTR(EFI_GUID), UINTN, UINT32)
+PCD_PROTOCOL_SET_EX_64 = FUNCPTR(EFI_STATUS, PTR(EFI_GUID), UINTN, UINT64)
+PCD_PROTOCOL_SET_EX_POINTER = FUNCPTR(EFI_STATUS, PTR(EFI_GUID), UINTN, PTR(UINTN), PTR(VOID))
+PCD_PROTOCOL_SET_EX_BOOLEAN = FUNCPTR(EFI_STATUS, PTR(EFI_GUID), UINTN, BOOLEAN)
+PCD_PROTOCOL_CALLBACK_ONSET = FUNCPTR(EFI_STATUS, PTR(EFI_GUID), UINTN, PCD_PROTOCOL_CALLBACK)
PCD_PROTOCOL_CANCEL_CALLBACK= FUNCPTR(EFI_STATUS, PTR(EFI_GUID), UINTN, PCD_PROTOCOL_CALLBACK)
-PCD_PROTOCOL_GET_NEXT_TOKEN = FUNCPTR(EFI_STATUS, PTR(EFI_GUID), PTR(UINTN))
+PCD_PROTOCOL_GET_NEXT_TOKEN = FUNCPTR(EFI_STATUS, PTR(EFI_GUID), PTR(UINTN))
PCD_PROTOCOL_GET_NEXT_TOKENSPACE = FUNCPTR(EFI_STATUS, PTR(PTR(EFI_GUID)))
class PCD_PROTOCOL(STRUCT):
- _fields_ = [
- ('SetSku', PCD_PROTOCOL_SET_SKU),
- ('Get8', PCD_PROTOCOL_GET8),
- ('Get16', PCD_PROTOCOL_GET16),
- ('Get32', PCD_PROTOCOL_GET32),
- ('Get64', PCD_PROTOCOL_GET64),
- ('GetPtr', PCD_PROTOCOL_GET_POINTER),
- ('GetBool', PCD_PROTOCOL_GET_BOOLEAN),
- ('GetSize', PCD_PROTOCOL_GET_SIZE),
- ('Get8Ex', PCD_PROTOCOL_GET_EX_8),
- ('Get16Ex', PCD_PROTOCOL_GET_EX_16),
- ('Get32Ex', PCD_PROTOCOL_GET_EX_32),
- ('Get64Ex', PCD_PROTOCOL_GET_EX_64),
- ('GetPtrEx', PCD_PROTOCOL_GET_EX_POINTER),
- ('GetBoolEx', PCD_PROTOCOL_GET_EX_BOOLEAN),
- ('GetSizeEx', PCD_PROTOCOL_GET_EX_SIZE),
- ('Set8', PCD_PROTOCOL_SET8),
- ('Set16', PCD_PROTOCOL_SET16),
- ('Set32', PCD_PROTOCOL_SET32),
- ('Set64', PCD_PROTOCOL_SET64),
- ('SetPtr', PCD_PROTOCOL_SET_POINTER),
- ('SetBool', PCD_PROTOCOL_SET_BOOLEAN),
- ('Set8Ex', PCD_PROTOCOL_SET_EX_8),
- ('Set16Ex', PCD_PROTOCOL_SET_EX_16),
- ('Set32Ex', PCD_PROTOCOL_SET_EX_32),
- ('Set64Ex', PCD_PROTOCOL_SET_EX_64),
- ('SetPtrEx', PCD_PROTOCOL_SET_EX_POINTER),
- ('SetBoolEx', PCD_PROTOCOL_SET_EX_BOOLEAN),
- ('CallbackOnSet', PCD_PROTOCOL_CALLBACK_ONSET),
- ('CancelCallback', PCD_PROTOCOL_CANCEL_CALLBACK),
- ('GetNextToken', PCD_PROTOCOL_GET_NEXT_TOKEN),
- ('GetNextTokenSpace', PCD_PROTOCOL_GET_NEXT_TOKENSPACE)
- ]
+ _fields_ = [
+ ('SetSku', PCD_PROTOCOL_SET_SKU),
+ ('Get8', PCD_PROTOCOL_GET8),
+ ('Get16', PCD_PROTOCOL_GET16),
+ ('Get32', PCD_PROTOCOL_GET32),
+ ('Get64', PCD_PROTOCOL_GET64),
+ ('GetPtr', PCD_PROTOCOL_GET_POINTER),
+ ('GetBool', PCD_PROTOCOL_GET_BOOLEAN),
+ ('GetSize', PCD_PROTOCOL_GET_SIZE),
+ ('Get8Ex', PCD_PROTOCOL_GET_EX_8),
+ ('Get16Ex', PCD_PROTOCOL_GET_EX_16),
+ ('Get32Ex', PCD_PROTOCOL_GET_EX_32),
+ ('Get64Ex', PCD_PROTOCOL_GET_EX_64),
+ ('GetPtrEx', PCD_PROTOCOL_GET_EX_POINTER),
+ ('GetBoolEx', PCD_PROTOCOL_GET_EX_BOOLEAN),
+ ('GetSizeEx', PCD_PROTOCOL_GET_EX_SIZE),
+ ('Set8', PCD_PROTOCOL_SET8),
+ ('Set16', PCD_PROTOCOL_SET16),
+ ('Set32', PCD_PROTOCOL_SET32),
+ ('Set64', PCD_PROTOCOL_SET64),
+ ('SetPtr', PCD_PROTOCOL_SET_POINTER),
+ ('SetBool', PCD_PROTOCOL_SET_BOOLEAN),
+ ('Set8Ex', PCD_PROTOCOL_SET_EX_8),
+ ('Set16Ex', PCD_PROTOCOL_SET_EX_16),
+ ('Set32Ex', PCD_PROTOCOL_SET_EX_32),
+ ('Set64Ex', PCD_PROTOCOL_SET_EX_64),
+ ('SetPtrEx', PCD_PROTOCOL_SET_EX_POINTER),
+ ('SetBoolEx', PCD_PROTOCOL_SET_EX_BOOLEAN),
+ ('CallbackOnSet', PCD_PROTOCOL_CALLBACK_ONSET),
+ ('CancelCallback', PCD_PROTOCOL_CANCEL_CALLBACK),
+ ('GetNextToken', PCD_PROTOCOL_GET_NEXT_TOKEN),
+ ('GetNextTokenSpace', PCD_PROTOCOL_GET_NEXT_TOKENSPACE)
+ ]
@dxeapi(params = {
- "SkuId" : UINT
+ "SkuId" : UINT
})
def hook_SetSku(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "TokenNumber" : UINT
+ "TokenNumber" : UINT
})
def hook_Get8(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "TokenNumber" : UINT
+ "TokenNumber" : UINT
})
def hook_Get16(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "TokenNumber" : UINT
+ "TokenNumber" : UINT
})
def hook_Get32(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "TokenNumber" : UINT
+ "TokenNumber" : UINT
})
def hook_Get64(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "TokenNumber" : UINT
+ "TokenNumber" : UINT
})
def hook_GetPtr(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "TokenNumber" : UINT
+ "TokenNumber" : UINT
})
def hook_GetBool(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "TokenNumber" : UINT
+ "TokenNumber" : UINT
})
def hook_GetSize(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "Guid" : GUID,
- "TokenNumber" : UINT
+ "Guid" : GUID,
+ "TokenNumber" : UINT
})
def hook_Get8Ex(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "Guid" : GUID,
- "TokenNumber" : UINT
+ "Guid" : GUID,
+ "TokenNumber" : UINT
})
def hook_Get16Ex(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "Guid" : GUID,
- "TokenNumber" : UINT
+ "Guid" : GUID,
+ "TokenNumber" : UINT
})
def hook_Get32Ex(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "Guid" : GUID,
- "TokenNumber" : UINT
+ "Guid" : GUID,
+ "TokenNumber" : UINT
})
def hook_Get64Ex(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "Guid" : GUID,
- "TokenNumber" : UINT
+ "Guid" : GUID,
+ "TokenNumber" : UINT
})
def hook_GetPtrEx(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "Guid" : GUID,
- "TokenNumber" : UINT
+ "Guid" : GUID,
+ "TokenNumber" : UINT
})
def hook_GetBoolEx(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "Guid" : GUID,
- "TokenNumber" : UINT
+ "Guid" : GUID,
+ "TokenNumber" : UINT
})
def hook_GetSizeEx(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "TokenNumber" : UINT,
- "Value" : INT
+ "TokenNumber" : UINT,
+ "Value" : INT
})
def hook_Set8(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "TokenNumber" : UINT,
- "Value" : INT
+ "TokenNumber" : UINT,
+ "Value" : INT
})
def hook_Set16(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "TokenNumber" : UINT,
- "Value" : INT
+ "TokenNumber" : UINT,
+ "Value" : INT
})
def hook_Set32(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "TokenNumber" : UINT,
- "Value" : INT
+ "TokenNumber" : UINT,
+ "Value" : INT
})
def hook_Set64(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "TokenNumber" : UINT,
- "SizeOfValue" : POINTER,
- "Buffer" : POINTER
+ "TokenNumber" : UINT,
+ "SizeOfValue" : POINTER,
+ "Buffer" : POINTER
})
def hook_SetPtr(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "TokenNumber" : UINT,
- "Value" : INT
+ "TokenNumber" : UINT,
+ "Value" : INT
})
def hook_SetBool(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "Guid" : GUID,
- "TokenNumber" : UINT,
- "Value" : INT
+ "Guid" : GUID,
+ "TokenNumber" : UINT,
+ "Value" : INT
})
def hook_Set8Ex(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "Guid" : GUID,
- "TokenNumber" : UINT,
- "Value" : INT
+ "Guid" : GUID,
+ "TokenNumber" : UINT,
+ "Value" : INT
})
def hook_Set16Ex(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "Guid" : GUID,
- "TokenNumber" : UINT,
- "Value" : INT
+ "Guid" : GUID,
+ "TokenNumber" : UINT,
+ "Value" : INT
})
def hook_Set32Ex(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "Guid" : GUID,
- "TokenNumber" : UINT,
- "Value" : INT
+ "Guid" : GUID,
+ "TokenNumber" : UINT,
+ "Value" : INT
})
def hook_Set64Ex(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "Guid" : GUID,
- "TokenNumber" : UINT,
- "SizeOfValue" : POINTER,
- "Buffer" : POINTER
+ "Guid" : GUID,
+ "TokenNumber" : UINT,
+ "SizeOfValue" : POINTER,
+ "Buffer" : POINTER
})
def hook_SetPtrEx(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "Guid" : GUID,
- "TokenNumber" : UINT,
- "Value" : INT
+ "Guid" : GUID,
+ "TokenNumber" : UINT,
+ "Value" : INT
})
def hook_SetBoolEx(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "Guid" : GUID,
- "TokenNumber" : UINT,
- "CallBackFunction" : POINTER
+ "Guid" : GUID,
+ "TokenNumber" : UINT,
+ "CallBackFunction" : POINTER
})
def hook_CallbackOnSet(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "Guid" : GUID,
- "TokenNumber" : UINT,
- "CallBackFunction" : POINTER
+ "Guid" : GUID,
+ "TokenNumber" : UINT,
+ "CallBackFunction" : POINTER
})
def hook_CancelCallback(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "Guid" : GUID,
- "TokenNumber" : POINTER
+ "Guid" : GUID,
+ "TokenNumber" : POINTER
})
def hook_GetNextToken(ql, address, params):
- pass
+ pass
@dxeapi(params = {
- "Guid" : POINTER
+ "Guid" : POINTER
})
def hook_GetNextTokenSpace(ql, address, params):
- pass
+ pass
descriptor = {
- "guid" : "11b34006-d85b-4d0a-a290-d5a571310ef7",
- "struct" : PCD_PROTOCOL,
- "fields" : (
- ('SetSku', hook_SetSku),
- ('Get8', hook_Get8),
- ('Get16', hook_Get16),
- ('Get32', hook_Get32),
- ('Get64', hook_Get64),
- ('GetPtr', hook_GetPtr),
- ('GetBool', hook_GetBool),
- ('GetSize', hook_GetSize),
- ('Get8Ex', hook_Get8Ex),
- ('Get16Ex', hook_Get16Ex),
- ('Get32Ex', hook_Get32Ex),
- ('Get64Ex', hook_Get64Ex),
- ('GetPtrEx', hook_GetPtrEx),
- ('GetBoolEx', hook_GetBoolEx),
- ('GetSizeEx', hook_GetSizeEx),
- ('Set8', hook_Set8),
- ('Set16', hook_Set16),
- ('Set32', hook_Set32),
- ('Set64', hook_Set64),
- ('SetPtr', hook_SetPtr),
- ('SetBool', hook_SetBool),
- ('Set8Ex', hook_Set8Ex),
- ('Set16Ex', hook_Set16Ex),
- ('Set32Ex', hook_Set32Ex),
- ('Set64Ex', hook_Set64Ex),
- ('SetPtrEx', hook_SetPtrEx),
- ('SetBoolEx', hook_SetBoolEx),
- ('CallbackOnSet', hook_CallbackOnSet),
- ('CancelCallback', hook_CancelCallback),
- ('GetNextToken', hook_GetNextToken),
- ('GetNextTokenSpace', hook_GetNextTokenSpace)
- )
+ "guid" : "11b34006-d85b-4d0a-a290-d5a571310ef7",
+ "struct" : PCD_PROTOCOL,
+ "fields" : (
+ ('SetSku', hook_SetSku),
+ ('Get8', hook_Get8),
+ ('Get16', hook_Get16),
+ ('Get32', hook_Get32),
+ ('Get64', hook_Get64),
+ ('GetPtr', hook_GetPtr),
+ ('GetBool', hook_GetBool),
+ ('GetSize', hook_GetSize),
+ ('Get8Ex', hook_Get8Ex),
+ ('Get16Ex', hook_Get16Ex),
+ ('Get32Ex', hook_Get32Ex),
+ ('Get64Ex', hook_Get64Ex),
+ ('GetPtrEx', hook_GetPtrEx),
+ ('GetBoolEx', hook_GetBoolEx),
+ ('GetSizeEx', hook_GetSizeEx),
+ ('Set8', hook_Set8),
+ ('Set16', hook_Set16),
+ ('Set32', hook_Set32),
+ ('Set64', hook_Set64),
+ ('SetPtr', hook_SetPtr),
+ ('SetBool', hook_SetBool),
+ ('Set8Ex', hook_Set8Ex),
+ ('Set16Ex', hook_Set16Ex),
+ ('Set32Ex', hook_Set32Ex),
+ ('Set64Ex', hook_Set64Ex),
+ ('SetPtrEx', hook_SetPtrEx),
+ ('SetBoolEx', hook_SetBoolEx),
+ ('CallbackOnSet', hook_CallbackOnSet),
+ ('CancelCallback', hook_CancelCallback),
+ ('GetNextToken', hook_GetNextToken),
+ ('GetNextTokenSpace', hook_GetNextTokenSpace)
+ )
}
diff --git a/qiling/os/uefi/protocols/common.py b/qiling/os/uefi/protocols/common.py
index a729f5f4c..60cb013dd 100644
--- a/qiling/os/uefi/protocols/common.py
+++ b/qiling/os/uefi/protocols/common.py
@@ -8,127 +8,127 @@
from qiling.os.uefi.UefiSpec import EFI_LOCATE_SEARCH_TYPE
def LocateHandles(context, params):
- SearchType = params["SearchType"]
- Protocol = params["Protocol"]
+ SearchType = params["SearchType"]
+ Protocol = params["Protocol"]
- # get all handles
- if SearchType == EFI_LOCATE_SEARCH_TYPE.AllHandles:
- handles = context.protocols.keys()
+ # get all handles
+ if SearchType == EFI_LOCATE_SEARCH_TYPE.AllHandles:
+ handles = context.protocols.keys()
- # get all handles that support the specified protocol
- elif SearchType == EFI_LOCATE_SEARCH_TYPE.ByProtocol:
- handles = [handle for handle, guid_dic in context.protocols.items() if Protocol in guid_dic]
+ # get all handles that support the specified protocol
+ elif SearchType == EFI_LOCATE_SEARCH_TYPE.ByProtocol:
+ handles = [handle for handle, guid_dic in context.protocols.items() if Protocol in guid_dic]
- else:
- handles = []
+ else:
+ handles = []
- return len(handles) * context.ql.arch.pointersize, handles
+ return len(handles) * context.ql.arch.pointersize, handles
def InstallProtocolInterface(context, params):
- handle = read_int64(context.ql, params["Handle"])
+ handle = read_int64(context.ql, params["Handle"])
- if handle == 0:
- handle = context.heap.alloc(1)
+ if handle == 0:
+ handle = context.heap.alloc(1)
- dic = context.protocols.get(handle, {})
+ dic = context.protocols.get(handle, {})
- dic[params["Protocol"]] = params["Interface"]
- context.protocols[handle] = dic
+ dic[params["Protocol"]] = params["Interface"]
+ context.protocols[handle] = dic
- write_int64(context.ql, params["Handle"], handle)
- context.notify_protocol(params['Handle'], params['Protocol'], params['Interface'], True)
+ write_int64(context.ql, params["Handle"], handle)
+ context.notify_protocol(params['Handle'], params['Protocol'], params['Interface'], True)
- return EFI_SUCCESS
+ return EFI_SUCCESS
def ReinstallProtocolInterface(context, params):
- handle = params["Handle"]
+ handle = params["Handle"]
- if handle not in context.protocols:
- return EFI_NOT_FOUND
+ if handle not in context.protocols:
+ return EFI_NOT_FOUND
- dic = context.protocols[handle]
- protocol = params["Protocol"]
+ dic = context.protocols[handle]
+ protocol = params["Protocol"]
- if protocol not in dic:
- return EFI_NOT_FOUND
+ if protocol not in dic:
+ return EFI_NOT_FOUND
- dic[protocol] = params["NewInterface"]
+ dic[protocol] = params["NewInterface"]
- return EFI_SUCCESS
+ return EFI_SUCCESS
def UninstallProtocolInterface(context, params):
- handle = params["Handle"]
+ handle = params["Handle"]
- if handle not in context.protocols:
- return EFI_NOT_FOUND
+ if handle not in context.protocols:
+ return EFI_NOT_FOUND
- dic = context.protocols[handle]
- protocol = params["Protocol"]
+ dic = context.protocols[handle]
+ protocol = params["Protocol"]
- if protocol not in dic:
- return EFI_NOT_FOUND
+ if protocol not in dic:
+ return EFI_NOT_FOUND
- del dic[protocol]
+ del dic[protocol]
- return EFI_SUCCESS
+ return EFI_SUCCESS
def HandleProtocol(context, params):
- handle = params["Handle"]
- protocol = params["Protocol"]
- interface = params['Interface']
+ handle = params["Handle"]
+ protocol = params["Protocol"]
+ interface = params['Interface']
- if handle in context.protocols:
- supported = context.protocols[handle]
+ if handle in context.protocols:
+ supported = context.protocols[handle]
- if protocol in supported:
- write_int64(context.ql, interface, supported[protocol])
+ if protocol in supported:
+ write_int64(context.ql, interface, supported[protocol])
- return EFI_SUCCESS
+ return EFI_SUCCESS
- return EFI_UNSUPPORTED
+ return EFI_UNSUPPORTED
def LocateHandle(context, params):
- buffer_size, handles = LocateHandles(context, params)
+ buffer_size, handles = LocateHandles(context, params)
- if len(handles) == 0:
- return EFI_NOT_FOUND
+ if len(handles) == 0:
+ return EFI_NOT_FOUND
- ret = EFI_BUFFER_TOO_SMALL
+ ret = EFI_BUFFER_TOO_SMALL
- if read_int64(context.ql, params["BufferSize"]) >= buffer_size:
- ptr = params["Buffer"]
+ if read_int64(context.ql, params["BufferSize"]) >= buffer_size:
+ ptr = params["Buffer"]
- for handle in handles:
- write_int64(context.ql, ptr, handle)
- ptr += context.ql.arch.pointersize
+ for handle in handles:
+ write_int64(context.ql, ptr, handle)
+ ptr += context.ql.arch.pointersize
- ret = EFI_SUCCESS
+ ret = EFI_SUCCESS
- write_int64(context.ql, params["BufferSize"], buffer_size)
+ write_int64(context.ql, params["BufferSize"], buffer_size)
- return ret
+ return ret
def LocateProtocol(context, params):
- protocol = params['Protocol']
+ protocol = params['Protocol']
- for handle, guid_dic in context.protocols.items():
- if "Handle" in params and params["Handle"] != handle:
- continue
+ for handle, guid_dic in context.protocols.items():
+ if "Handle" in params and params["Handle"] != handle:
+ continue
- if protocol in guid_dic:
- # write protocol address to out variable Interface
- write_int64(context.ql, params['Interface'], guid_dic[protocol])
- return EFI_SUCCESS
+ if protocol in guid_dic:
+ # write protocol address to out variable Interface
+ write_int64(context.ql, params['Interface'], guid_dic[protocol])
+ return EFI_SUCCESS
- return EFI_NOT_FOUND
+ return EFI_NOT_FOUND
def InstallConfigurationTable(context, params):
- guid = params["Guid"]
- table = params["Table"]
+ guid = params["Guid"]
+ table = params["Table"]
- if not guid:
- return EFI_INVALID_PARAMETER
+ if not guid:
+ return EFI_INVALID_PARAMETER
- context.conftable.install(guid, table)
+ context.conftable.install(guid, table)
- return EFI_SUCCESS
+ return EFI_SUCCESS
diff --git a/qiling/os/uefi/rt.py b/qiling/os/uefi/rt.py
index 1e108ebe4..67d95f5d0 100644
--- a/qiling/os/uefi/rt.py
+++ b/qiling/os/uefi/rt.py
@@ -15,226 +15,226 @@
from .UefiSpec import *
@dxeapi(params={
- "Time" : POINTER, # OUT PTR(EFI_TIME)
- "Capabilities" : POINTER # OUT PTR(EFI_TIME_CAPABILITIES)
+ "Time" : POINTER, # OUT PTR(EFI_TIME)
+ "Capabilities" : POINTER # OUT PTR(EFI_TIME_CAPABILITIES)
})
def hook_GetTime(ql: Qiling, address: int, params):
- Time = params['Time']
+ Time = params['Time']
- if not Time:
- return EFI_INVALID_PARAMETER
+ if not Time:
+ return EFI_INVALID_PARAMETER
- localtime = time.localtime()
+ localtime = time.localtime()
- efitime = EFI_TIME()
- efitime.Year = localtime.tm_year
- efitime.Month = localtime.tm_mon
- efitime.Day = localtime.tm_mday
- efitime.Hour = localtime.tm_hour
- efitime.Minute = localtime.tm_min
- efitime.Second = localtime.tm_sec
- efitime.Nanosecond = 0
+ efitime = EFI_TIME()
+ efitime.Year = localtime.tm_year
+ efitime.Month = localtime.tm_mon
+ efitime.Day = localtime.tm_mday
+ efitime.Hour = localtime.tm_hour
+ efitime.Minute = localtime.tm_min
+ efitime.Second = localtime.tm_sec
+ efitime.Nanosecond = 0
- # tz and dst settings are stored in the "RtcTimeSettings" nvram variable.
- # we just use the default settings instead
- efitime.TimeZone = EFI_UNSPECIFIED_TIMEZONE
- efitime.Daylight = 0
+ # tz and dst settings are stored in the "RtcTimeSettings" nvram variable.
+ # we just use the default settings instead
+ efitime.TimeZone = EFI_UNSPECIFIED_TIMEZONE
+ efitime.Daylight = 0
- efitime.saveTo(ql, Time)
+ efitime.saveTo(ql, Time)
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params={
- "Time": POINTER # IN PTR(EFI_TIME)
+ "Time": POINTER # IN PTR(EFI_TIME)
})
def hook_SetTime(ql: Qiling, address: int, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params={
- "Enabled" : POINTER, # OUT PTR(BOOLEAN)
- "Pending" : POINTER, # OUT PTR(BOOLEAN)
- "Time" : POINTER # OUT PTR(EFI_TIME)
+ "Enabled" : POINTER, # OUT PTR(BOOLEAN)
+ "Pending" : POINTER, # OUT PTR(BOOLEAN)
+ "Time" : POINTER # OUT PTR(EFI_TIME)
})
def hook_GetWakeupTime(ql: Qiling, address: int, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params={
- "Enable": BOOL, # BOOLEAN
- "Time" : POINTER # PTR(EFI_TIME)
+ "Enable": BOOL, # BOOLEAN
+ "Time" : POINTER # PTR(EFI_TIME)
})
def hook_SetWakeupTime(ql: Qiling, address: int, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params={
- "MemoryMapSize" : UINT, # UINTN
- "DescriptorSize" : UINT, # UINTN
- "DescriptorVersion" : UINT, # UINT32
- "VirtualMap" : POINTER # PTR(EFI_MEMORY_DESCRIPTOR)
+ "MemoryMapSize" : UINT, # UINTN
+ "DescriptorSize" : UINT, # UINTN
+ "DescriptorVersion" : UINT, # UINT32
+ "VirtualMap" : POINTER # PTR(EFI_MEMORY_DESCRIPTOR)
})
def hook_SetVirtualAddressMap(ql: Qiling, address: int, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params={
- "DebugDisposition" : UINT, # UINTN
- "Address" : POINTER # OUT PTR(PTR(VOID))
+ "DebugDisposition" : UINT, # UINTN
+ "Address" : POINTER # OUT PTR(PTR(VOID))
})
def hook_ConvertPointer(ql: Qiling, address: int, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params={
- "VariableName" : WSTRING, # PTR(CHAR16)
- "VendorGuid" : GUID, # PTR(EFI_GUID)
- "Attributes" : POINTER, # OUT PTR(UINT32)
- "DataSize" : POINTER, # IN OUT PTR(UINTN)
- "Data" : POINTER # OUT PTR(VOID)
+ "VariableName" : WSTRING, # PTR(CHAR16)
+ "VendorGuid" : GUID, # PTR(EFI_GUID)
+ "Attributes" : POINTER, # OUT PTR(UINT32)
+ "DataSize" : POINTER, # IN OUT PTR(UINTN)
+ "Data" : POINTER # OUT PTR(VOID)
})
def hook_GetVariable(ql: Qiling, address: int, params):
- name = params['VariableName']
+ name = params['VariableName']
- if name in ql.env:
- var = ql.env[name]
- read_len = read_int64(ql, params['DataSize'])
+ if name in ql.env:
+ var = ql.env[name]
+ read_len = read_int64(ql, params['DataSize'])
- if params['Attributes'] != 0:
- write_int64(ql, params['Attributes'], 0)
+ if params['Attributes'] != 0:
+ write_int64(ql, params['Attributes'], 0)
- write_int64(ql, params['DataSize'], len(var))
+ write_int64(ql, params['DataSize'], len(var))
- if read_len < len(var):
- return EFI_BUFFER_TOO_SMALL
+ if read_len < len(var):
+ return EFI_BUFFER_TOO_SMALL
- if params['Data'] != 0:
- ql.mem.write(params['Data'], var)
+ if params['Data'] != 0:
+ ql.mem.write(params['Data'], var)
- return EFI_SUCCESS
+ return EFI_SUCCESS
- ql.log.warning(f'variable with name {name} not found')
+ ql.log.warning(f'variable with name {name} not found')
- return EFI_NOT_FOUND
+ return EFI_NOT_FOUND
@dxeapi(params={
- "VariableNameSize" : POINTER, # IN OUT PTR(UINTN)
- "VariableName" : POINTER, # IN OUT PTR(CHAR16)
- "VendorGuid" : GUID # IN OUT PTR(EFI_GUID)
+ "VariableNameSize" : POINTER, # IN OUT PTR(UINTN)
+ "VariableName" : POINTER, # IN OUT PTR(CHAR16)
+ "VendorGuid" : GUID # IN OUT PTR(EFI_GUID)
})
def hook_GetNextVariableName(ql: Qiling, address: int, params):
- var_name_size = params["VariableNameSize"]
- var_name = params["VariableName"]
+ var_name_size = params["VariableNameSize"]
+ var_name = params["VariableName"]
- if (var_name_size == 0) or (var_name == 0):
- return EFI_INVALID_PARAMETER
+ if (var_name_size == 0) or (var_name == 0):
+ return EFI_INVALID_PARAMETER
- name_size = read_int64(ql, var_name_size)
- last_name = ql.os.utils.read_wstring(var_name)
+ name_size = read_int64(ql, var_name_size)
+ last_name = ql.os.utils.read_wstring(var_name)
- vars = ql.env['Names'] # This is a list of variable names in correct order.
+ vars = ql.env['Names'] # This is a list of variable names in correct order.
- if last_name not in vars:
- return EFI_NOT_FOUND
+ if last_name not in vars:
+ return EFI_NOT_FOUND
- idx = vars.index(last_name)
+ idx = vars.index(last_name)
- # make sure it is not the last one (i.e. we have a next one to pull)
- if idx == len(vars) - 1:
- return EFI_NOT_FOUND
+ # make sure it is not the last one (i.e. we have a next one to pull)
+ if idx == len(vars) - 1:
+ return EFI_NOT_FOUND
- # get next var name, and add null terminator
- new_name = vars[idx + 1] + '\x00'
+ # get next var name, and add null terminator
+ new_name = vars[idx + 1] + '\x00'
- # turn it into a wide string
- new_name = ''.join(f'{c}\x00' for c in new_name)
+ # turn it into a wide string
+ new_name = ''.join(f'{c}\x00' for c in new_name)
- if len(new_name) > name_size:
- write_int64(ql, var_name_size, len(new_name))
- return EFI_BUFFER_TOO_SMALL
+ if len(new_name) > name_size:
+ write_int64(ql, var_name_size, len(new_name))
+ return EFI_BUFFER_TOO_SMALL
- ql.mem.write(var_name, new_name.encode('ascii'))
+ ql.mem.write(var_name, new_name.encode('ascii'))
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params={
- "VariableName" : WSTRING, # PTR(CHAR16)
- "VendorGuid" : GUID, # PTR(EFI_GUID)
- "Attributes" : UINT, # UINT32
- "DataSize" : UINT, # UINTN
- "Data" : POINTER # PTR(VOID)
+ "VariableName" : WSTRING, # PTR(CHAR16)
+ "VendorGuid" : GUID, # PTR(EFI_GUID)
+ "Attributes" : UINT, # UINT32
+ "DataSize" : UINT, # UINTN
+ "Data" : POINTER # PTR(VOID)
})
def hook_SetVariable(ql: Qiling, address: int, params):
- ql.env[params['VariableName']] = bytes(ql.mem.read(params['Data'], params['DataSize']))
- return EFI_SUCCESS
+ ql.env[params['VariableName']] = bytes(ql.mem.read(params['Data'], params['DataSize']))
+ return EFI_SUCCESS
@dxeapi(params={
- "HighCount": POINTER # OUT PTR(UINT32)
+ "HighCount": POINTER # OUT PTR(UINT32)
})
def hook_GetNextHighMonotonicCount(ql: Qiling, address: int, params):
- ql.os.monotonic_count += 0x0000000100000000
- hmc = ql.os.monotonic_count
- hmc = (hmc >> 32) & 0xffffffff
- write_int32(ql, params["HighCount"], hmc)
- return EFI_SUCCESS
+ ql.os.monotonic_count += 0x0000000100000000
+ hmc = ql.os.monotonic_count
+ hmc = (hmc >> 32) & 0xffffffff
+ write_int32(ql, params["HighCount"], hmc)
+ return EFI_SUCCESS
@dxeapi(params={
- "ResetType" : INT, # EFI_RESET_TYPE
- "ResetStatus" : INT, # EFI_STATUS
- "DataSize" : UINT, # UINTN
- "ResetData" : POINTER # PTR(VOID)
+ "ResetType" : INT, # EFI_RESET_TYPE
+ "ResetStatus" : INT, # EFI_STATUS
+ "DataSize" : UINT, # UINTN
+ "ResetData" : POINTER # PTR(VOID)
})
def hook_ResetSystem(ql: Qiling, address: int, params):
- ql.emu_stop()
+ ql.emu_stop()
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params={
- "CapsuleHeaderArray": POINTER, # PTR(PTR(EFI_CAPSULE_HEADER))
- "CapsuleCount" : UINT, # UINTN
- "ScatterGatherList" : ULONGLONG # EFI_PHYSICAL_ADDRESS
+ "CapsuleHeaderArray": POINTER, # PTR(PTR(EFI_CAPSULE_HEADER))
+ "CapsuleCount" : UINT, # UINTN
+ "ScatterGatherList" : ULONGLONG # EFI_PHYSICAL_ADDRESS
})
def hook_UpdateCapsule(ql: Qiling, address: int, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params={
- "CapsuleHeaderArray": POINTER, # PTR(PTR(EFI_CAPSULE_HEADER))
- "CapsuleCount" : UINT, # UINTN
- "MaximumCapsuleSize": POINTER, # OUT PTR(UINT64)
- "ResetType" : POINTER # OUT PTR(EFI_RESET_TYPE)
+ "CapsuleHeaderArray": POINTER, # PTR(PTR(EFI_CAPSULE_HEADER))
+ "CapsuleCount" : UINT, # UINTN
+ "MaximumCapsuleSize": POINTER, # OUT PTR(UINT64)
+ "ResetType" : POINTER # OUT PTR(EFI_RESET_TYPE)
})
def hook_QueryCapsuleCapabilities(ql: Qiling, address: int, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params={
- "Attributes" : UINT, # UINT32
- "MaximumVariableStorageSize" : POINTER, # OUT PTR(UINT64)
- "RemainingVariableStorageSize" : POINTER, # OUT PTR(UINT64)
- "MaximumVariableSize" : POINTER # OUT PTR(UINT64)
+ "Attributes" : UINT, # UINT32
+ "MaximumVariableStorageSize" : POINTER, # OUT PTR(UINT64)
+ "RemainingVariableStorageSize" : POINTER, # OUT PTR(UINT64)
+ "MaximumVariableSize" : POINTER # OUT PTR(UINT64)
})
def hook_QueryVariableInfo(ql: Qiling, address: int, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
def initialize(ql: Qiling, gRT: int):
- descriptor = {
- 'struct' : EFI_RUNTIME_SERVICES,
- 'fields' : (
- ('Hdr', None),
- ('GetTime', hook_GetTime),
- ('SetTime', hook_SetTime),
- ('GetWakeupTime', hook_GetWakeupTime),
- ('SetWakeupTime', hook_SetWakeupTime),
- ('SetVirtualAddressMap', hook_SetVirtualAddressMap),
- ('ConvertPointer', hook_ConvertPointer),
- ('GetVariable', hook_GetVariable),
- ('GetNextVariableName', hook_GetNextVariableName),
- ('SetVariable', hook_SetVariable),
- ('GetNextHighMonotonicCount', hook_GetNextHighMonotonicCount),
- ('ResetSystem', hook_ResetSystem),
- ('UpdateCapsule', hook_UpdateCapsule),
- ('QueryCapsuleCapabilities', hook_QueryCapsuleCapabilities),
- ('QueryVariableInfo', hook_QueryVariableInfo)
- )
- }
-
- instance = init_struct(ql, gRT, descriptor)
- instance.saveTo(ql, gRT)
+ descriptor = {
+ 'struct' : EFI_RUNTIME_SERVICES,
+ 'fields' : (
+ ('Hdr', None),
+ ('GetTime', hook_GetTime),
+ ('SetTime', hook_SetTime),
+ ('GetWakeupTime', hook_GetWakeupTime),
+ ('SetWakeupTime', hook_SetWakeupTime),
+ ('SetVirtualAddressMap', hook_SetVirtualAddressMap),
+ ('ConvertPointer', hook_ConvertPointer),
+ ('GetVariable', hook_GetVariable),
+ ('GetNextVariableName', hook_GetNextVariableName),
+ ('SetVariable', hook_SetVariable),
+ ('GetNextHighMonotonicCount', hook_GetNextHighMonotonicCount),
+ ('ResetSystem', hook_ResetSystem),
+ ('UpdateCapsule', hook_UpdateCapsule),
+ ('QueryCapsuleCapabilities', hook_QueryCapsuleCapabilities),
+ ('QueryVariableInfo', hook_QueryVariableInfo)
+ )
+ }
+
+ instance = init_struct(ql, gRT, descriptor)
+ instance.saveTo(ql, gRT)
__all__ = [
- 'initialize'
+ 'initialize'
]
\ No newline at end of file
diff --git a/qiling/os/uefi/smm.py b/qiling/os/uefi/smm.py
index 15e80e485..2e0ff61a2 100644
--- a/qiling/os/uefi/smm.py
+++ b/qiling/os/uefi/smm.py
@@ -14,257 +14,257 @@
from qiling.os.uefi.protocols.EfiSmmSwDispatch2Protocol import EFI_SMM_SW_REGISTER_CONTEXT, EFI_SMM_SW_CONTEXT
class SaveStateArea:
- # SSA map for x64; note that it does not include all register enumerated in
- # EFI_SMM_SAVE_STATE_REGISTER, but only the most commonly used ones
- #
- # see: Intel SDM vol. 3 chapter 30.4.1.1
- offsets = {
- EFI_SMM_SAVE_STATE_REGISTER.GDTBASE : 0x7E8C,
- EFI_SMM_SAVE_STATE_REGISTER.IDTBASE : 0x7E94,
- EFI_SMM_SAVE_STATE_REGISTER.LDTBASE : 0x7E9C,
- EFI_SMM_SAVE_STATE_REGISTER.GDTLIMIT: 0x7DD0,
- EFI_SMM_SAVE_STATE_REGISTER.IDTLIMIT: 0x7DD8,
- EFI_SMM_SAVE_STATE_REGISTER.LDTLIMIT: 0x7DD4,
- # EFI_SMM_SAVE_STATE_REGISTER.LDTINFO : ?,
-
- EFI_SMM_SAVE_STATE_REGISTER.ES : 0x7FA8,
- EFI_SMM_SAVE_STATE_REGISTER.CS : 0x7FAC,
- EFI_SMM_SAVE_STATE_REGISTER.SS : 0x7FB0,
- EFI_SMM_SAVE_STATE_REGISTER.DS : 0x7FB4,
- EFI_SMM_SAVE_STATE_REGISTER.FS : 0x7FB8,
- EFI_SMM_SAVE_STATE_REGISTER.GS : 0x7FBC,
- EFI_SMM_SAVE_STATE_REGISTER.LDTR_SEL: 0x7FC0,
- EFI_SMM_SAVE_STATE_REGISTER.TR_SEL : 0x7FC4,
- EFI_SMM_SAVE_STATE_REGISTER.DR7 : 0x7FC8,
- EFI_SMM_SAVE_STATE_REGISTER.DR6 : 0x7FD0,
- EFI_SMM_SAVE_STATE_REGISTER.R8 : 0x7F54,
- EFI_SMM_SAVE_STATE_REGISTER.R9 : 0x7F4C,
- EFI_SMM_SAVE_STATE_REGISTER.R10 : 0x7F44,
- EFI_SMM_SAVE_STATE_REGISTER.R11 : 0x7F3C,
- EFI_SMM_SAVE_STATE_REGISTER.R12 : 0x7F34,
- EFI_SMM_SAVE_STATE_REGISTER.R13 : 0x7F2C,
- EFI_SMM_SAVE_STATE_REGISTER.R14 : 0x7F24,
- EFI_SMM_SAVE_STATE_REGISTER.R15 : 0x7F1C,
- EFI_SMM_SAVE_STATE_REGISTER.RAX : 0x7F5C,
- EFI_SMM_SAVE_STATE_REGISTER.RBX : 0x7F74,
- EFI_SMM_SAVE_STATE_REGISTER.RCX : 0x7F64,
- EFI_SMM_SAVE_STATE_REGISTER.RDX : 0x7F6C,
- EFI_SMM_SAVE_STATE_REGISTER.RSP : 0x7F7C,
- EFI_SMM_SAVE_STATE_REGISTER.RBP : 0x7F84,
- EFI_SMM_SAVE_STATE_REGISTER.RSI : 0x7F8C,
- EFI_SMM_SAVE_STATE_REGISTER.RDI : 0x7F94,
- EFI_SMM_SAVE_STATE_REGISTER.RIP : 0x7FD8,
-
- EFI_SMM_SAVE_STATE_REGISTER.RFLAGS : 0x7FE8,
- EFI_SMM_SAVE_STATE_REGISTER.CR0 : 0x7FF8,
- EFI_SMM_SAVE_STATE_REGISTER.CR3 : 0x7FF0,
- EFI_SMM_SAVE_STATE_REGISTER.CR4 : 0x7E40
- }
-
- def __init__(self, ql: Qiling):
- self.ql = ql
-
- self.ssa_base = ql.loader.smm_context.smram_base + 0x8000
- self.ssa_size = 0x8000
-
- # map smram save state area, but do not make it available just yet
- if ql.mem.is_available(self.ssa_base, self.ssa_size):
- ql.mem.map(self.ssa_base, self.ssa_size, UC_PROT_NONE, '[SMRAM SSA]')
-
- def read(self, regidx: EFI_SMM_SAVE_STATE_REGISTER, width: int) -> bytes:
- """Retrieve a register value from SMM save state area.
- """
-
- reg = self.ssa_base + SaveStateArea.offsets[regidx]
-
- return self.ql.mem.read(reg, width)
-
- def write(self, regidx: EFI_SMM_SAVE_STATE_REGISTER, data: bytes) -> None:
- """Replace a register value in SMM save state area.
- """
-
- reg = self.ssa_base + SaveStateArea.offsets[regidx]
-
- self.ql.mem.write(reg, data)
+ # SSA map for x64; note that it does not include all register enumerated in
+ # EFI_SMM_SAVE_STATE_REGISTER, but only the most commonly used ones
+ #
+ # see: Intel SDM vol. 3 chapter 30.4.1.1
+ offsets = {
+ EFI_SMM_SAVE_STATE_REGISTER.GDTBASE : 0x7E8C,
+ EFI_SMM_SAVE_STATE_REGISTER.IDTBASE : 0x7E94,
+ EFI_SMM_SAVE_STATE_REGISTER.LDTBASE : 0x7E9C,
+ EFI_SMM_SAVE_STATE_REGISTER.GDTLIMIT: 0x7DD0,
+ EFI_SMM_SAVE_STATE_REGISTER.IDTLIMIT: 0x7DD8,
+ EFI_SMM_SAVE_STATE_REGISTER.LDTLIMIT: 0x7DD4,
+ # EFI_SMM_SAVE_STATE_REGISTER.LDTINFO : ?,
+
+ EFI_SMM_SAVE_STATE_REGISTER.ES : 0x7FA8,
+ EFI_SMM_SAVE_STATE_REGISTER.CS : 0x7FAC,
+ EFI_SMM_SAVE_STATE_REGISTER.SS : 0x7FB0,
+ EFI_SMM_SAVE_STATE_REGISTER.DS : 0x7FB4,
+ EFI_SMM_SAVE_STATE_REGISTER.FS : 0x7FB8,
+ EFI_SMM_SAVE_STATE_REGISTER.GS : 0x7FBC,
+ EFI_SMM_SAVE_STATE_REGISTER.LDTR_SEL: 0x7FC0,
+ EFI_SMM_SAVE_STATE_REGISTER.TR_SEL : 0x7FC4,
+ EFI_SMM_SAVE_STATE_REGISTER.DR7 : 0x7FC8,
+ EFI_SMM_SAVE_STATE_REGISTER.DR6 : 0x7FD0,
+ EFI_SMM_SAVE_STATE_REGISTER.R8 : 0x7F54,
+ EFI_SMM_SAVE_STATE_REGISTER.R9 : 0x7F4C,
+ EFI_SMM_SAVE_STATE_REGISTER.R10 : 0x7F44,
+ EFI_SMM_SAVE_STATE_REGISTER.R11 : 0x7F3C,
+ EFI_SMM_SAVE_STATE_REGISTER.R12 : 0x7F34,
+ EFI_SMM_SAVE_STATE_REGISTER.R13 : 0x7F2C,
+ EFI_SMM_SAVE_STATE_REGISTER.R14 : 0x7F24,
+ EFI_SMM_SAVE_STATE_REGISTER.R15 : 0x7F1C,
+ EFI_SMM_SAVE_STATE_REGISTER.RAX : 0x7F5C,
+ EFI_SMM_SAVE_STATE_REGISTER.RBX : 0x7F74,
+ EFI_SMM_SAVE_STATE_REGISTER.RCX : 0x7F64,
+ EFI_SMM_SAVE_STATE_REGISTER.RDX : 0x7F6C,
+ EFI_SMM_SAVE_STATE_REGISTER.RSP : 0x7F7C,
+ EFI_SMM_SAVE_STATE_REGISTER.RBP : 0x7F84,
+ EFI_SMM_SAVE_STATE_REGISTER.RSI : 0x7F8C,
+ EFI_SMM_SAVE_STATE_REGISTER.RDI : 0x7F94,
+ EFI_SMM_SAVE_STATE_REGISTER.RIP : 0x7FD8,
+
+ EFI_SMM_SAVE_STATE_REGISTER.RFLAGS : 0x7FE8,
+ EFI_SMM_SAVE_STATE_REGISTER.CR0 : 0x7FF8,
+ EFI_SMM_SAVE_STATE_REGISTER.CR3 : 0x7FF0,
+ EFI_SMM_SAVE_STATE_REGISTER.CR4 : 0x7E40
+ }
+
+ def __init__(self, ql: Qiling):
+ self.ql = ql
+
+ self.ssa_base = ql.loader.smm_context.smram_base + 0x8000
+ self.ssa_size = 0x8000
+
+ # map smram save state area, but do not make it available just yet
+ if ql.mem.is_available(self.ssa_base, self.ssa_size):
+ ql.mem.map(self.ssa_base, self.ssa_size, UC_PROT_NONE, '[SMRAM SSA]')
+
+ def read(self, regidx: EFI_SMM_SAVE_STATE_REGISTER, width: int) -> bytes:
+ """Retrieve a register value from SMM save state area.
+ """
+
+ reg = self.ssa_base + SaveStateArea.offsets[regidx]
+
+ return self.ql.mem.read(reg, width)
+
+ def write(self, regidx: EFI_SMM_SAVE_STATE_REGISTER, data: bytes) -> None:
+ """Replace a register value in SMM save state area.
+ """
+
+ reg = self.ssa_base + SaveStateArea.offsets[regidx]
+
+ self.ql.mem.write(reg, data)
class SmmEnv:
- SSA_REG_MAP = {
- UC_X86_REG_ES : (4, EFI_SMM_SAVE_STATE_REGISTER.ES),
- UC_X86_REG_CS : (4, EFI_SMM_SAVE_STATE_REGISTER.CS),
- UC_X86_REG_SS : (4, EFI_SMM_SAVE_STATE_REGISTER.SS),
- UC_X86_REG_DS : (4, EFI_SMM_SAVE_STATE_REGISTER.DS),
- UC_X86_REG_FS : (4, EFI_SMM_SAVE_STATE_REGISTER.FS),
- UC_X86_REG_GS : (4, EFI_SMM_SAVE_STATE_REGISTER.GS),
- UC_X86_REG_R8 : (8, EFI_SMM_SAVE_STATE_REGISTER.R8),
- UC_X86_REG_R9 : (8, EFI_SMM_SAVE_STATE_REGISTER.R9),
- UC_X86_REG_R10 : (8, EFI_SMM_SAVE_STATE_REGISTER.R10),
- UC_X86_REG_R11 : (8, EFI_SMM_SAVE_STATE_REGISTER.R11),
- UC_X86_REG_R12 : (8, EFI_SMM_SAVE_STATE_REGISTER.R12),
- UC_X86_REG_R13 : (8, EFI_SMM_SAVE_STATE_REGISTER.R13),
- UC_X86_REG_R14 : (8, EFI_SMM_SAVE_STATE_REGISTER.R14),
- UC_X86_REG_R15 : (8, EFI_SMM_SAVE_STATE_REGISTER.R15),
- UC_X86_REG_RAX : (8, EFI_SMM_SAVE_STATE_REGISTER.RAX),
- UC_X86_REG_RBX : (8, EFI_SMM_SAVE_STATE_REGISTER.RBX),
- UC_X86_REG_RCX : (8, EFI_SMM_SAVE_STATE_REGISTER.RCX),
- UC_X86_REG_RDX : (8, EFI_SMM_SAVE_STATE_REGISTER.RDX),
- UC_X86_REG_RSP : (8, EFI_SMM_SAVE_STATE_REGISTER.RSP),
- UC_X86_REG_RBP : (8, EFI_SMM_SAVE_STATE_REGISTER.RBP),
- UC_X86_REG_RSI : (8, EFI_SMM_SAVE_STATE_REGISTER.RSI),
- UC_X86_REG_RDI : (8, EFI_SMM_SAVE_STATE_REGISTER.RDI),
- UC_X86_REG_RIP : (8, EFI_SMM_SAVE_STATE_REGISTER.RIP),
- UC_X86_REG_EFLAGS : (8, EFI_SMM_SAVE_STATE_REGISTER.RFLAGS),
- UC_X86_REG_CR0 : (8, EFI_SMM_SAVE_STATE_REGISTER.CR0),
- UC_X86_REG_CR3 : (8, EFI_SMM_SAVE_STATE_REGISTER.CR3),
- UC_X86_REG_CR4 : (8, EFI_SMM_SAVE_STATE_REGISTER.CR4)
- }
-
- def __init__(self, ql: Qiling):
- self.ql = ql
- self.ssa = SaveStateArea(ql)
-
- # by default the system is out of smm
- self.active = False
-
- def __mapped_smram_ranges(self) -> Iterator[Tuple[int, int]]:
- """Iterate through all mapped ranges enclosed within SMRAM.
- """
-
- context: SmmContext = self.ql.loader.smm_context
-
- smram_lbound = context.smram_base
- smram_ubound = smram_lbound + context.smram_size
-
- for lbound, ubound, *_ in self.ql.mem.get_mapinfo():
- if (smram_lbound <= lbound) and (ubound <= smram_ubound):
- yield lbound, ubound
-
- def enter(self) -> None:
- """Enter SMM.
-
- Save CPU state and unlock SMM resources.
- """
-
- self.ql.log.info(f'Entering SMM')
-
- assert not self.active, 'SMM is not reentrant'
-
- # unlock smram ranges for access
- for lbound, ubound in self.__mapped_smram_ranges():
- self.ql.mem.protect(lbound, ubound - lbound, UC_PROT_ALL)
-
- # write cpu state to ssa (partially)
- # that can take place only after smram ranges have been unlocked
- for ucreg, (width, regidx) in SmmEnv.SSA_REG_MAP.items():
- val = self.ql.arch.regs.read(ucreg)
-
- pack = {
- 8 : self.ql.pack64,
- 4 : self.ql.pack32,
- 2 : self.ql.pack16,
- 1 : self.ql.pack8
- }[width]
-
- self.ssa.write(regidx, pack(val))
-
- # let os know that the code is now executing in smm
- self.active = True
-
- def leave(self) -> None:
- """Leave SMM.
-
- Restore CPU state and lock SMM resources.
- """
-
- self.ql.log.info(f'Leaving SMM')
-
- # restore cpu state from ssa (partially)
- # that can take place only before smram ranges have been locked
- for ucreg, (width, regidx) in SmmEnv.SSA_REG_MAP.items():
- data = self.ssa.read(regidx, width)
-
- unpack = {
- 8 : self.ql.unpack64,
- 4 : self.ql.unpack32,
- 2 : self.ql.unpack16,
- 1 : self.ql.unpack8
- }[width]
-
- self.ql.arch.regs.write(ucreg, unpack(data))
-
- # lock smram ranges for access
- for lbound, ubound in self.__mapped_smram_ranges():
- self.ql.mem.protect(lbound, ubound - lbound, UC_PROT_NONE)
-
- # let os know that the code is no longer executing in smm
- self.active = False
-
- def invoke_swsmi(self, cpu: int, idx: int, entry: int, args: Mapping[str, Any], *, onexit: Callable[[Qiling], None] = None) -> None:
- """Invoke a native SWSMI handler.
-
- Args:
- cpu: initiating logical processor index
- idx: swsmi index
- entry: swsmi handler entry point
- args: data arguments collected on handler registration
- onexit: optionally specify a method to call on handler exit
- """
+ SSA_REG_MAP = {
+ UC_X86_REG_ES : (4, EFI_SMM_SAVE_STATE_REGISTER.ES),
+ UC_X86_REG_CS : (4, EFI_SMM_SAVE_STATE_REGISTER.CS),
+ UC_X86_REG_SS : (4, EFI_SMM_SAVE_STATE_REGISTER.SS),
+ UC_X86_REG_DS : (4, EFI_SMM_SAVE_STATE_REGISTER.DS),
+ UC_X86_REG_FS : (4, EFI_SMM_SAVE_STATE_REGISTER.FS),
+ UC_X86_REG_GS : (4, EFI_SMM_SAVE_STATE_REGISTER.GS),
+ UC_X86_REG_R8 : (8, EFI_SMM_SAVE_STATE_REGISTER.R8),
+ UC_X86_REG_R9 : (8, EFI_SMM_SAVE_STATE_REGISTER.R9),
+ UC_X86_REG_R10 : (8, EFI_SMM_SAVE_STATE_REGISTER.R10),
+ UC_X86_REG_R11 : (8, EFI_SMM_SAVE_STATE_REGISTER.R11),
+ UC_X86_REG_R12 : (8, EFI_SMM_SAVE_STATE_REGISTER.R12),
+ UC_X86_REG_R13 : (8, EFI_SMM_SAVE_STATE_REGISTER.R13),
+ UC_X86_REG_R14 : (8, EFI_SMM_SAVE_STATE_REGISTER.R14),
+ UC_X86_REG_R15 : (8, EFI_SMM_SAVE_STATE_REGISTER.R15),
+ UC_X86_REG_RAX : (8, EFI_SMM_SAVE_STATE_REGISTER.RAX),
+ UC_X86_REG_RBX : (8, EFI_SMM_SAVE_STATE_REGISTER.RBX),
+ UC_X86_REG_RCX : (8, EFI_SMM_SAVE_STATE_REGISTER.RCX),
+ UC_X86_REG_RDX : (8, EFI_SMM_SAVE_STATE_REGISTER.RDX),
+ UC_X86_REG_RSP : (8, EFI_SMM_SAVE_STATE_REGISTER.RSP),
+ UC_X86_REG_RBP : (8, EFI_SMM_SAVE_STATE_REGISTER.RBP),
+ UC_X86_REG_RSI : (8, EFI_SMM_SAVE_STATE_REGISTER.RSI),
+ UC_X86_REG_RDI : (8, EFI_SMM_SAVE_STATE_REGISTER.RDI),
+ UC_X86_REG_RIP : (8, EFI_SMM_SAVE_STATE_REGISTER.RIP),
+ UC_X86_REG_EFLAGS : (8, EFI_SMM_SAVE_STATE_REGISTER.RFLAGS),
+ UC_X86_REG_CR0 : (8, EFI_SMM_SAVE_STATE_REGISTER.CR0),
+ UC_X86_REG_CR3 : (8, EFI_SMM_SAVE_STATE_REGISTER.CR3),
+ UC_X86_REG_CR4 : (8, EFI_SMM_SAVE_STATE_REGISTER.CR4)
+ }
+
+ def __init__(self, ql: Qiling):
+ self.ql = ql
+ self.ssa = SaveStateArea(ql)
+
+ # by default the system is out of smm
+ self.active = False
+
+ def __mapped_smram_ranges(self) -> Iterator[Tuple[int, int]]:
+ """Iterate through all mapped ranges enclosed within SMRAM.
+ """
+
+ context: SmmContext = self.ql.loader.smm_context
+
+ smram_lbound = context.smram_base
+ smram_ubound = smram_lbound + context.smram_size
+
+ for lbound, ubound, *_ in self.ql.mem.get_mapinfo():
+ if (smram_lbound <= lbound) and (ubound <= smram_ubound):
+ yield lbound, ubound
+
+ def enter(self) -> None:
+ """Enter SMM.
+
+ Save CPU state and unlock SMM resources.
+ """
+
+ self.ql.log.info(f'Entering SMM')
+
+ assert not self.active, 'SMM is not reentrant'
+
+ # unlock smram ranges for access
+ for lbound, ubound in self.__mapped_smram_ranges():
+ self.ql.mem.protect(lbound, ubound - lbound, UC_PROT_ALL)
+
+ # write cpu state to ssa (partially)
+ # that can take place only after smram ranges have been unlocked
+ for ucreg, (width, regidx) in SmmEnv.SSA_REG_MAP.items():
+ val = self.ql.arch.regs.read(ucreg)
+
+ pack = {
+ 8 : self.ql.pack64,
+ 4 : self.ql.pack32,
+ 2 : self.ql.pack16,
+ 1 : self.ql.pack8
+ }[width]
+
+ self.ssa.write(regidx, pack(val))
+
+ # let os know that the code is now executing in smm
+ self.active = True
+
+ def leave(self) -> None:
+ """Leave SMM.
+
+ Restore CPU state and lock SMM resources.
+ """
+
+ self.ql.log.info(f'Leaving SMM')
+
+ # restore cpu state from ssa (partially)
+ # that can take place only before smram ranges have been locked
+ for ucreg, (width, regidx) in SmmEnv.SSA_REG_MAP.items():
+ data = self.ssa.read(regidx, width)
+
+ unpack = {
+ 8 : self.ql.unpack64,
+ 4 : self.ql.unpack32,
+ 2 : self.ql.unpack16,
+ 1 : self.ql.unpack8
+ }[width]
+
+ self.ql.arch.regs.write(ucreg, unpack(data))
+
+ # lock smram ranges for access
+ for lbound, ubound in self.__mapped_smram_ranges():
+ self.ql.mem.protect(lbound, ubound - lbound, UC_PROT_NONE)
+
+ # let os know that the code is no longer executing in smm
+ self.active = False
+
+ def invoke_swsmi(self, cpu: int, idx: int, entry: int, args: Mapping[str, Any], *, onexit: Callable[[Qiling], None] = None) -> None:
+ """Invoke a native SWSMI handler.
+
+ Args:
+ cpu: initiating logical processor index
+ idx: swsmi index
+ entry: swsmi handler entry point
+ args: data arguments collected on handler registration
+ onexit: optionally specify a method to call on handler exit
+ """
- ql = self.ql
- heap: QlMemoryHeap = self.ql.loader.smm_context.heap
+ ql = self.ql
+ heap: QlMemoryHeap = self.ql.loader.smm_context.heap
- self.enter()
+ self.enter()
- DispatchHandle = args['DispatchHandle']
- Context = heap.alloc(EFI_SMM_SW_REGISTER_CONTEXT.sizeof())
- CommBuffer = heap.alloc(EFI_SMM_SW_CONTEXT.sizeof())
- CommBufferSize = heap.alloc(ql.arch.pointersize)
+ DispatchHandle = args['DispatchHandle']
+ Context = heap.alloc(EFI_SMM_SW_REGISTER_CONTEXT.sizeof())
+ CommBuffer = heap.alloc(EFI_SMM_SW_CONTEXT.sizeof())
+ CommBufferSize = heap.alloc(ql.arch.pointersize)
- # setup Context
- args['RegisterContext'].saveTo(ql, Context)
+ # setup Context
+ args['RegisterContext'].saveTo(ql, Context)
- # setup CommBuffer
- SmmSwContext = EFI_SMM_SW_CONTEXT()
- SmmSwContext.SwSmiCpuIndex = cpu
- SmmSwContext.CommandPort = idx
- SmmSwContext.DataPort = 0
- SmmSwContext.saveTo(ql, CommBuffer)
+ # setup CommBuffer
+ SmmSwContext = EFI_SMM_SW_CONTEXT()
+ SmmSwContext.SwSmiCpuIndex = cpu
+ SmmSwContext.CommandPort = idx
+ SmmSwContext.DataPort = 0
+ SmmSwContext.saveTo(ql, CommBuffer)
- # setup CommBufferSize
- utils.ptr_write64(ql, CommBufferSize, SmmSwContext.sizeof())
+ # setup CommBufferSize
+ utils.ptr_write64(ql, CommBufferSize, SmmSwContext.sizeof())
- # clean up handler resources
- def __cleanup(ql: Qiling):
- ql.log.info(f'Leaving SWSMI handler {idx:#04x}')
+ # clean up handler resources
+ def __cleanup(ql: Qiling):
+ ql.log.info(f'Leaving SWSMI handler {idx:#04x}')
- # unwind ms64 shadow space
- ql.arch.regs.arch_sp += (4 * ql.arch.pointersize)
+ # unwind ms64 shadow space
+ ql.arch.regs.arch_sp += (4 * ql.arch.pointersize)
- # release handler resources
- heap.free(DispatchHandle)
- heap.free(Context)
- heap.free(CommBuffer)
- heap.free(CommBufferSize)
+ # release handler resources
+ heap.free(DispatchHandle)
+ heap.free(Context)
+ heap.free(CommBuffer)
+ heap.free(CommBufferSize)
- # release hook
- heap.free(cleanup_trap)
- hret.remove()
-
- self.leave()
+ # release hook
+ heap.free(cleanup_trap)
+ hret.remove()
+
+ self.leave()
- # if specified, call on-exit callback
- if onexit:
- onexit(ql)
+ # if specified, call on-exit callback
+ if onexit:
+ onexit(ql)
- # hook returning from swsmi handler
- cleanup_trap = heap.alloc(ql.arch.pointersize)
- hret = ql.hook_address(__cleanup, cleanup_trap)
+ # hook returning from swsmi handler
+ cleanup_trap = heap.alloc(ql.arch.pointersize)
+ hret = ql.hook_address(__cleanup, cleanup_trap)
- ql.log.info(f'Entering SWSMI handler {idx:#04x}')
+ ql.log.info(f'Entering SWSMI handler {idx:#04x}')
- # invoke the swsmi handler
- ql.os.fcall.call_native(entry, (
- (POINTER, DispatchHandle),
- (POINTER, Context),
- (POINTER, CommBuffer),
- (POINTER, CommBufferSize)
- ), cleanup_trap)
+ # invoke the swsmi handler
+ ql.os.fcall.call_native(entry, (
+ (POINTER, DispatchHandle),
+ (POINTER, Context),
+ (POINTER, CommBuffer),
+ (POINTER, CommBufferSize)
+ ), cleanup_trap)
diff --git a/qiling/os/uefi/smst.py b/qiling/os/uefi/smst.py
index bdd40c0c1..ec78727a7 100644
--- a/qiling/os/uefi/smst.py
+++ b/qiling/os/uefi/smst.py
@@ -19,263 +19,263 @@
# @see: MdePkg\Include\Pi\PiSmmCis.h
class EFI_MM_IO_WIDTH(ENUM):
- _members_ = [
- 'MM_IO_UINT8',
- 'MM_IO_UINT16',
- 'MM_IO_UINT32',
- 'MM_IO_UINT64'
- ]
+ _members_ = [
+ 'MM_IO_UINT8',
+ 'MM_IO_UINT16',
+ 'MM_IO_UINT32',
+ 'MM_IO_UINT64'
+ ]
EFI_MM_HANDLER_ENTRY_POINT = FUNCPTR(EFI_STATUS, EFI_HANDLE, PTR(VOID), PTR(VOID), PTR(UINTN))
EFI_MM_NOTIFY_FN = FUNCPTR(EFI_STATUS, PTR(EFI_GUID), PTR(VOID), EFI_HANDLE)
class EFI_MM_IO_ACCESS(STRUCT):
- EFI_SMM_CPU_IO2_PROTOCOL = STRUCT
+ EFI_SMM_CPU_IO2_PROTOCOL = STRUCT
- _fields_ = [
- ('Read', FUNCPTR(EFI_STATUS, PTR(EFI_SMM_CPU_IO2_PROTOCOL), EFI_MM_IO_WIDTH, UINT64, UINTN, PTR(VOID))),
- ('Write', FUNCPTR(EFI_STATUS, PTR(EFI_SMM_CPU_IO2_PROTOCOL), EFI_MM_IO_WIDTH, UINT64, UINTN, PTR(VOID))),
- ]
+ _fields_ = [
+ ('Read', FUNCPTR(EFI_STATUS, PTR(EFI_SMM_CPU_IO2_PROTOCOL), EFI_MM_IO_WIDTH, UINT64, UINTN, PTR(VOID))),
+ ('Write', FUNCPTR(EFI_STATUS, PTR(EFI_SMM_CPU_IO2_PROTOCOL), EFI_MM_IO_WIDTH, UINT64, UINTN, PTR(VOID))),
+ ]
class EFI_SMM_CPU_IO2_PROTOCOL(STRUCT):
- _fields_ = [
- ('Mem', EFI_MM_IO_ACCESS),
- ('Io', EFI_MM_IO_ACCESS)
- ]
+ _fields_ = [
+ ('Mem', EFI_MM_IO_ACCESS),
+ ('Io', EFI_MM_IO_ACCESS)
+ ]
class EFI_SMM_SYSTEM_TABLE2(STRUCT):
- EFI_SMM_SYSTEM_TABLE2 = STRUCT
- _pack_ = 8
-
- _fields_ = [
- ('Hdr', EFI_TABLE_HEADER),
- ('SmmFirmwareVendor', PTR(CHAR16)),
- ('SmmFirmwareRevision', UINT32),
- ('SmmInstallConfigurationTable', FUNCPTR(EFI_STATUS, PTR(EFI_SMM_SYSTEM_TABLE2), PTR(EFI_GUID), PTR(VOID), UINTN)),
- ('SmmIo', EFI_SMM_CPU_IO2_PROTOCOL),
- ('SmmAllocatePool', FUNCPTR(EFI_STATUS, EFI_MEMORY_TYPE, UINTN, PTR(PTR(VOID)))),
- ('SmmFreePool', FUNCPTR(EFI_STATUS, PTR(VOID))),
- ('SmmAllocatePages', FUNCPTR(EFI_STATUS, EFI_ALLOCATE_TYPE, EFI_MEMORY_TYPE, UINTN, PTR(EFI_PHYSICAL_ADDRESS))),
- ('SmmFreePages', FUNCPTR(EFI_STATUS, EFI_PHYSICAL_ADDRESS, UINTN)),
- ('SmmStartupThisAp', FUNCPTR(EFI_STATUS, FUNCPTR(VOID, PTR(VOID)), UINTN, PTR(VOID))),
- ('CurrentlyExecutingCpu', UINTN),
- ('NumberOfCpus', UINTN),
- ('CpuSaveStateSize', PTR(UINTN)),
- ('CpuSaveState', PTR(PTR(VOID))),
- ('NumberOfTableEntries', UINTN),
- ('SmmConfigurationTable', PTR(EFI_CONFIGURATION_TABLE)),
- ('SmmInstallProtocolInterface', FUNCPTR(EFI_STATUS, PTR(EFI_HANDLE), PTR(EFI_GUID), EFI_INTERFACE_TYPE, PTR(VOID))),
- ('SmmUninstallProtocolInterface', FUNCPTR(EFI_STATUS, PTR(VOID), PTR(EFI_GUID), PTR(VOID))),
- ('SmmHandleProtocol', FUNCPTR(EFI_STATUS, PTR(VOID), PTR(EFI_GUID), PTR(PTR(VOID)))),
- ('SmmRegisterProtocolNotify', FUNCPTR(EFI_STATUS, PTR(EFI_GUID), EFI_MM_NOTIFY_FN, PTR(PTR(VOID)))),
- ('SmmLocateHandle', FUNCPTR(EFI_STATUS, EFI_LOCATE_SEARCH_TYPE, PTR(EFI_GUID), PTR(VOID), PTR(UINTN), PTR(EFI_HANDLE))),
- ('SmmLocateProtocol', FUNCPTR(EFI_STATUS, PTR(EFI_GUID), PTR(VOID), PTR(PTR(VOID)))),
- ('SmiManage', FUNCPTR(EFI_STATUS, PTR(EFI_GUID), PTR(VOID), PTR(VOID), PTR(UINTN))),
- ('SmiHandlerRegister', FUNCPTR(EFI_STATUS, EFI_MM_HANDLER_ENTRY_POINT, PTR(EFI_GUID), PTR(EFI_HANDLE))),
- ('SmiHandlerUnRegister', FUNCPTR(EFI_STATUS, EFI_HANDLE)),
- ]
+ EFI_SMM_SYSTEM_TABLE2 = STRUCT
+ _pack_ = 8
+
+ _fields_ = [
+ ('Hdr', EFI_TABLE_HEADER),
+ ('SmmFirmwareVendor', PTR(CHAR16)),
+ ('SmmFirmwareRevision', UINT32),
+ ('SmmInstallConfigurationTable', FUNCPTR(EFI_STATUS, PTR(EFI_SMM_SYSTEM_TABLE2), PTR(EFI_GUID), PTR(VOID), UINTN)),
+ ('SmmIo', EFI_SMM_CPU_IO2_PROTOCOL),
+ ('SmmAllocatePool', FUNCPTR(EFI_STATUS, EFI_MEMORY_TYPE, UINTN, PTR(PTR(VOID)))),
+ ('SmmFreePool', FUNCPTR(EFI_STATUS, PTR(VOID))),
+ ('SmmAllocatePages', FUNCPTR(EFI_STATUS, EFI_ALLOCATE_TYPE, EFI_MEMORY_TYPE, UINTN, PTR(EFI_PHYSICAL_ADDRESS))),
+ ('SmmFreePages', FUNCPTR(EFI_STATUS, EFI_PHYSICAL_ADDRESS, UINTN)),
+ ('SmmStartupThisAp', FUNCPTR(EFI_STATUS, FUNCPTR(VOID, PTR(VOID)), UINTN, PTR(VOID))),
+ ('CurrentlyExecutingCpu', UINTN),
+ ('NumberOfCpus', UINTN),
+ ('CpuSaveStateSize', PTR(UINTN)),
+ ('CpuSaveState', PTR(PTR(VOID))),
+ ('NumberOfTableEntries', UINTN),
+ ('SmmConfigurationTable', PTR(EFI_CONFIGURATION_TABLE)),
+ ('SmmInstallProtocolInterface', FUNCPTR(EFI_STATUS, PTR(EFI_HANDLE), PTR(EFI_GUID), EFI_INTERFACE_TYPE, PTR(VOID))),
+ ('SmmUninstallProtocolInterface', FUNCPTR(EFI_STATUS, PTR(VOID), PTR(EFI_GUID), PTR(VOID))),
+ ('SmmHandleProtocol', FUNCPTR(EFI_STATUS, PTR(VOID), PTR(EFI_GUID), PTR(PTR(VOID)))),
+ ('SmmRegisterProtocolNotify', FUNCPTR(EFI_STATUS, PTR(EFI_GUID), EFI_MM_NOTIFY_FN, PTR(PTR(VOID)))),
+ ('SmmLocateHandle', FUNCPTR(EFI_STATUS, EFI_LOCATE_SEARCH_TYPE, PTR(EFI_GUID), PTR(VOID), PTR(UINTN), PTR(EFI_HANDLE))),
+ ('SmmLocateProtocol', FUNCPTR(EFI_STATUS, PTR(EFI_GUID), PTR(VOID), PTR(PTR(VOID)))),
+ ('SmiManage', FUNCPTR(EFI_STATUS, PTR(EFI_GUID), PTR(VOID), PTR(VOID), PTR(UINTN))),
+ ('SmiHandlerRegister', FUNCPTR(EFI_STATUS, EFI_MM_HANDLER_ENTRY_POINT, PTR(EFI_GUID), PTR(EFI_HANDLE))),
+ ('SmiHandlerUnRegister', FUNCPTR(EFI_STATUS, EFI_HANDLE)),
+ ]
@dxeapi(params = {
- "Guid" : GUID, # PTR(EFI_GUID)
- "Table" : POINTER # PTR(VOID)
+ "Guid" : GUID, # PTR(EFI_GUID)
+ "Table" : POINTER # PTR(VOID)
})
def hook_SmmInstallConfigurationTable(ql: Qiling, address: int, params):
- return common.InstallConfigurationTable(ql.loader.smm_context, params)
+ return common.InstallConfigurationTable(ql.loader.smm_context, params)
@dxeapi(params = {
- "type" : INT, # EFI_ALLOCATE_TYPE
- "MemoryType": INT, # EFI_MEMORY_TYPE
- "Pages" : ULONGLONG, # UINTN
- "Memory" : POINTER # PTR(EFI_PHYSICAL_ADDRESS)
+ "type" : INT, # EFI_ALLOCATE_TYPE
+ "MemoryType": INT, # EFI_MEMORY_TYPE
+ "Pages" : ULONGLONG, # UINTN
+ "Memory" : POINTER # PTR(EFI_PHYSICAL_ADDRESS)
})
def hook_SmmAllocatePages(ql: Qiling, address: int, params):
- alloc_size = params["Pages"] * PAGE_SIZE
+ alloc_size = params["Pages"] * PAGE_SIZE
- if params['type'] == EFI_ALLOCATE_TYPE.AllocateAddress:
- address = read_int64(ql, params["Memory"])
+ if params['type'] == EFI_ALLOCATE_TYPE.AllocateAddress:
+ address = read_int64(ql, params["Memory"])
- # TODO: check the range [address, address + alloc_size] is available first
- ql.mem.map(address, alloc_size)
- else:
- # TODO: allocate memory according to 'MemoryType'
- address = ql.loader.smm_context.heap.alloc(alloc_size)
+ # TODO: check the range [address, address + alloc_size] is available first
+ ql.mem.map(address, alloc_size)
+ else:
+ # TODO: allocate memory according to 'MemoryType'
+ address = ql.loader.smm_context.heap.alloc(alloc_size)
- if address == 0:
- return EFI_OUT_OF_RESOURCES
+ if address == 0:
+ return EFI_OUT_OF_RESOURCES
- write_int64(ql, params["Memory"], address)
+ write_int64(ql, params["Memory"], address)
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "Memory" : ULONGLONG, # EFI_PHYSICAL_ADDRESS
- "Pages" : ULONGLONG # UINTN
+ "Memory" : ULONGLONG, # EFI_PHYSICAL_ADDRESS
+ "Pages" : ULONGLONG # UINTN
})
def hook_SmmFreePages(ql: Qiling, address: int, params):
- address = params["Memory"]
+ address = params["Memory"]
- ret = ql.loader.smm_context.heap.free(address)
+ ret = ql.loader.smm_context.heap.free(address)
- return EFI_SUCCESS if ret else EFI_INVALID_PARAMETER
+ return EFI_SUCCESS if ret else EFI_INVALID_PARAMETER
@dxeapi(params = {
- "PoolType" : INT, # EFI_MEMORY_TYPE
- "Size" : INT, # UINTN
- "Buffer" : POINTER # PTR(PTR(VOID))
+ "PoolType" : INT, # EFI_MEMORY_TYPE
+ "Size" : INT, # UINTN
+ "Buffer" : POINTER # PTR(PTR(VOID))
})
def hook_SmmAllocatePool(ql: Qiling, address: int, params):
- # TODO: allocate memory acording to "PoolType"
- address = ql.loader.smm_context.heap.alloc(params["Size"])
- write_int64(ql, params["Buffer"], address)
+ # TODO: allocate memory acording to "PoolType"
+ address = ql.loader.smm_context.heap.alloc(params["Size"])
+ write_int64(ql, params["Buffer"], address)
- return EFI_SUCCESS if address else EFI_OUT_OF_RESOURCES
+ return EFI_SUCCESS if address else EFI_OUT_OF_RESOURCES
@dxeapi(params = {
- "Buffer": POINTER # PTR(VOID)
+ "Buffer": POINTER # PTR(VOID)
})
def hook_SmmFreePool(ql: Qiling, address: int, params):
- address = params["Buffer"]
- ret = ql.loader.smm_context.heap.free(address)
+ address = params["Buffer"]
+ ret = ql.loader.smm_context.heap.free(address)
- return EFI_SUCCESS if ret else EFI_INVALID_PARAMETER
+ return EFI_SUCCESS if ret else EFI_INVALID_PARAMETER
@dxeapi(params = {
- "Procedure" : POINTER,
- "CpuNumber" : INT,
- "ProcArguments" : POINTER
+ "Procedure" : POINTER,
+ "CpuNumber" : INT,
+ "ProcArguments" : POINTER
})
def hook_SmmStartupThisAp(ql: Qiling, address: int, params):
- return EFI_INVALID_PARAMETER
+ return EFI_INVALID_PARAMETER
@dxeapi(params = {
- "Handle" : POINTER, # PTR(EFI_HANDLE)
- "Protocol" : GUID, # PTR(EFI_GUID)
- "InterfaceType" : ULONGLONG, # EFI_INTERFACE_TYPE
- "Interface" : POINTER, # PTR(VOID)
+ "Handle" : POINTER, # PTR(EFI_HANDLE)
+ "Protocol" : GUID, # PTR(EFI_GUID)
+ "InterfaceType" : ULONGLONG, # EFI_INTERFACE_TYPE
+ "Interface" : POINTER, # PTR(VOID)
})
def hook_SmmInstallProtocolInterface(ql: Qiling, address: int, params):
- return common.InstallProtocolInterface(ql.loader.smm_context, params)
+ return common.InstallProtocolInterface(ql.loader.smm_context, params)
@dxeapi(params = {
- "Handle" : POINTER, # EFI_HANDLE
- "Protocol" : GUID, # PTR(EFI_GUID)
- "Interface" : POINTER # PTR(VOID)
+ "Handle" : POINTER, # EFI_HANDLE
+ "Protocol" : GUID, # PTR(EFI_GUID)
+ "Interface" : POINTER # PTR(VOID)
})
def hook_SmmUninstallProtocolInterface(ql: Qiling, address: int, params):
- return common.UninstallProtocolInterface(ql.loader.smm_context, params)
+ return common.UninstallProtocolInterface(ql.loader.smm_context, params)
@dxeapi(params = {
- "Handle" : POINTER, # EFI_HANDLE
- "Protocol" : GUID, # PTR(EFI_GUID)
- "Interface" : POINTER # PTR(PTR(VOID))
+ "Handle" : POINTER, # EFI_HANDLE
+ "Protocol" : GUID, # PTR(EFI_GUID)
+ "Interface" : POINTER # PTR(PTR(VOID))
})
def hook_SmmHandleProtocol(ql: Qiling, address: int, params):
- return common.HandleProtocol(ql.loader.smm_context, params)
+ return common.HandleProtocol(ql.loader.smm_context, params)
@dxeapi(params = {
- "Protocol" : GUID, # PTR(EFI_GUID)
- "Function" : POINTER, # EFI_MM_NOTIFY_FN
- "Registration" : POINTER # PTR(PTR(VOID))
+ "Protocol" : GUID, # PTR(EFI_GUID)
+ "Function" : POINTER, # EFI_MM_NOTIFY_FN
+ "Registration" : POINTER # PTR(PTR(VOID))
})
def hook_SmmRegisterProtocolNotify(ql: Qiling, address: int, params):
- event_id = len(ql.loader.events)
- event_dic = {
- "NotifyFunction": params["Function"],
- "CallbackArgs" : None,
- "Guid" : params["Protocol"],
- "Set" : False
- }
- ql.loader.events[event_id] = event_dic
- ptr_write64(ql, params["Registration"], event_id)
- return EFI_SUCCESS
+ event_id = len(ql.loader.events)
+ event_dic = {
+ "NotifyFunction": params["Function"],
+ "CallbackArgs" : None,
+ "Guid" : params["Protocol"],
+ "Set" : False
+ }
+ ql.loader.events[event_id] = event_dic
+ ptr_write64(ql, params["Registration"], event_id)
+ return EFI_SUCCESS
@dxeapi(params = {
- "SearchType": INT, # EFI_LOCATE_SEARCH_TYPE
- "Protocol" : GUID, # PTR(EFI_GUID)
- "SearchKey" : POINTER, # PTR(VOID)
- "BufferSize": POINTER, # PTR(UINTN)
- "Buffer" : POINTER # PTR(EFI_HANDLE)
+ "SearchType": INT, # EFI_LOCATE_SEARCH_TYPE
+ "Protocol" : GUID, # PTR(EFI_GUID)
+ "SearchKey" : POINTER, # PTR(VOID)
+ "BufferSize": POINTER, # PTR(UINTN)
+ "Buffer" : POINTER # PTR(EFI_HANDLE)
})
def hook_SmmLocateHandle(ql: Qiling, address: int, params):
- return common.LocateHandle(ql.loader.smm_context, params)
+ return common.LocateHandle(ql.loader.smm_context, params)
@dxeapi(params = {
- "Protocol" : GUID, # PTR(EFI_GUID)
- "Registration" : POINTER, # PTR(VOID)
- "Interface" : POINTER # PTR(PTR(VOID))
+ "Protocol" : GUID, # PTR(EFI_GUID)
+ "Registration" : POINTER, # PTR(VOID)
+ "Interface" : POINTER # PTR(PTR(VOID))
})
def hook_SmmLocateProtocol(ql: Qiling, address: int, params):
- return common.LocateProtocol(ql.loader.smm_context, params)
+ return common.LocateProtocol(ql.loader.smm_context, params)
@dxeapi(params = {
- "HandlerType" : GUID,
- "Context" : POINTER,
- "CommBuffer" : POINTER,
- "CommBufferSize": POINTER
+ "HandlerType" : GUID,
+ "Context" : POINTER,
+ "CommBuffer" : POINTER,
+ "CommBufferSize": POINTER
})
def hook_SmiManage(ql: Qiling, address: int, params):
- return EFI_NOT_FOUND
+ return EFI_NOT_FOUND
@dxeapi(params = {
- "Handler" : POINTER,
- "HandlerType" : GUID,
- "DispatchHandle": POINTER
+ "Handler" : POINTER,
+ "HandlerType" : GUID,
+ "DispatchHandle": POINTER
})
def hook_SmiHandlerRegister(ql: Qiling, address: int, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
@dxeapi(params = {
- "DispatchHandle": POINTER
+ "DispatchHandle": POINTER
})
def hook_SmiHandlerUnRegister(ql: Qiling, address: int, params):
- return EFI_SUCCESS
+ return EFI_SUCCESS
def initialize(ql: Qiling, context, gSmst: int):
- ql.loader.gSmst = gSmst
-
- gSmmRT = gSmst + EFI_SMM_SYSTEM_TABLE2.sizeof() # smm runtime services
- cfg = gSmmRT + EFI_RUNTIME_SERVICES.sizeof() # configuration tables array
-
- rt.initialize(ql, gSmmRT)
-
- descriptor = {
- 'struct' : EFI_SMM_SYSTEM_TABLE2,
- 'fields' : (
- ('Hdr', None),
- ('SmmFirmwareVendor', None),
- ('SmmFirmwareRevision', None),
- ('SmmInstallConfigurationTable', hook_SmmInstallConfigurationTable),
- ('SmmIo', None),
- ('SmmAllocatePool', hook_SmmAllocatePool),
- ('SmmFreePool', hook_SmmFreePool),
- ('SmmAllocatePages', hook_SmmAllocatePages),
- ('SmmFreePages', hook_SmmFreePages),
- ('SmmStartupThisAp', hook_SmmStartupThisAp),
- ('CurrentlyExecutingCpu', None),
- ('NumberOfCpus', None),
- ('CpuSaveStateSize', None),
- ('CpuSaveState', None),
- ('NumberOfTableEntries', 0),
- ('SmmConfigurationTable', cfg),
- ('SmmInstallProtocolInterface', hook_SmmInstallProtocolInterface),
- ('SmmUninstallProtocolInterface', hook_SmmUninstallProtocolInterface),
- ('SmmHandleProtocol', hook_SmmHandleProtocol),
- ('SmmRegisterProtocolNotify', hook_SmmRegisterProtocolNotify),
- ('SmmLocateHandle', hook_SmmLocateHandle),
- ('SmmLocateProtocol', hook_SmmLocateProtocol),
- ('SmiManage', hook_SmiManage),
- ('SmiHandlerRegister', hook_SmiHandlerRegister),
- ('SmiHandlerUnRegister', hook_SmiHandlerUnRegister),
- )
- }
-
- instance = init_struct(ql, gSmst, descriptor)
- instance.saveTo(ql, gSmst)
-
- install_configuration_table(context, "HOB_LIST", None)
- install_configuration_table(context, "SMM_RUNTIME_SERVICES_TABLE", gSmmRT)
+ ql.loader.gSmst = gSmst
+
+ gSmmRT = gSmst + EFI_SMM_SYSTEM_TABLE2.sizeof() # smm runtime services
+ cfg = gSmmRT + EFI_RUNTIME_SERVICES.sizeof() # configuration tables array
+
+ rt.initialize(ql, gSmmRT)
+
+ descriptor = {
+ 'struct' : EFI_SMM_SYSTEM_TABLE2,
+ 'fields' : (
+ ('Hdr', None),
+ ('SmmFirmwareVendor', None),
+ ('SmmFirmwareRevision', None),
+ ('SmmInstallConfigurationTable', hook_SmmInstallConfigurationTable),
+ ('SmmIo', None),
+ ('SmmAllocatePool', hook_SmmAllocatePool),
+ ('SmmFreePool', hook_SmmFreePool),
+ ('SmmAllocatePages', hook_SmmAllocatePages),
+ ('SmmFreePages', hook_SmmFreePages),
+ ('SmmStartupThisAp', hook_SmmStartupThisAp),
+ ('CurrentlyExecutingCpu', None),
+ ('NumberOfCpus', None),
+ ('CpuSaveStateSize', None),
+ ('CpuSaveState', None),
+ ('NumberOfTableEntries', 0),
+ ('SmmConfigurationTable', cfg),
+ ('SmmInstallProtocolInterface', hook_SmmInstallProtocolInterface),
+ ('SmmUninstallProtocolInterface', hook_SmmUninstallProtocolInterface),
+ ('SmmHandleProtocol', hook_SmmHandleProtocol),
+ ('SmmRegisterProtocolNotify', hook_SmmRegisterProtocolNotify),
+ ('SmmLocateHandle', hook_SmmLocateHandle),
+ ('SmmLocateProtocol', hook_SmmLocateProtocol),
+ ('SmiManage', hook_SmiManage),
+ ('SmiHandlerRegister', hook_SmiHandlerRegister),
+ ('SmiHandlerUnRegister', hook_SmiHandlerUnRegister),
+ )
+ }
+
+ instance = init_struct(ql, gSmst, descriptor)
+ instance.saveTo(ql, gSmst)
+
+ install_configuration_table(context, "HOB_LIST", None)
+ install_configuration_table(context, "SMM_RUNTIME_SERVICES_TABLE", gSmmRT)
__all__ = [
- 'EFI_SMM_SYSTEM_TABLE2',
- 'initialize'
+ 'EFI_SMM_SYSTEM_TABLE2',
+ 'initialize'
]
diff --git a/qiling/os/uefi/st.py b/qiling/os/uefi/st.py
index c88c22b64..5e0199ddb 100644
--- a/qiling/os/uefi/st.py
+++ b/qiling/os/uefi/st.py
@@ -11,73 +11,73 @@
# static mem layout:
#
-# +-- EFI_SYSTEM_TABLE ---------+
-# | |
-# | ... |
-# | RuntimeServices* -> (1) |
-# | BootServices* -> (2) |
-# | NumberOfTableEntries |
-# | ConfigurationTable* -> (4) |
-# +-----------------------------+
-# (1) +-- EFI_RUNTIME_SERVICES -----+
-# | |
-# | ... |
-# +-----------------------------+
-# (2) +-- EFI_BOOT_SERVICES --------+
-# | |
-# | ... |
-# +-----------------------------+
-# (3) +-- EFI_DXE_SERVICES ---------+
-# | |
-# | ... |
-# +-----------------------------+
-# (4) +-- EFI_CONFIGURATION_TABLE --+ of HOB_LIST
-# | VendorGuid |
-# | VendorTable* -> (5) |
-# +-----------------------------+
-# +-- EFI_CONFIGURATION_TABLE --+ of DXE_SERVICE_TABLE
-# | VendorGuid |
-# | VendorTable* -> (3) |
-# +-----------------------------+
+# +-- EFI_SYSTEM_TABLE ---------+
+# | |
+# | ... |
+# | RuntimeServices* -> (1) |
+# | BootServices* -> (2) |
+# | NumberOfTableEntries |
+# | ConfigurationTable* -> (4) |
+# +-----------------------------+
+# (1) +-- EFI_RUNTIME_SERVICES -----+
+# | |
+# | ... |
+# +-----------------------------+
+# (2) +-- EFI_BOOT_SERVICES --------+
+# | |
+# | ... |
+# +-----------------------------+
+# (3) +-- EFI_DXE_SERVICES ---------+
+# | |
+# | ... |
+# +-----------------------------+
+# (4) +-- EFI_CONFIGURATION_TABLE --+ of HOB_LIST
+# | VendorGuid |
+# | VendorTable* -> (5) |
+# +-----------------------------+
+# +-- EFI_CONFIGURATION_TABLE --+ of DXE_SERVICE_TABLE
+# | VendorGuid |
+# | VendorTable* -> (3) |
+# +-----------------------------+
#
-# ... the remainder of the chunk may be used for additional EFI_CONFIGURATION_TABLE entries
+# ... the remainder of the chunk may be used for additional EFI_CONFIGURATION_TABLE entries
# dynamically allocated (context.conf_table_data_ptr):
#
-# (5) +-- VOID* --------------------+
-# | ... |
-# +-----------------------------+
+# (5) +-- VOID* --------------------+
+# | ... |
+# +-----------------------------+
def initialize(ql: Qiling, context: UefiContext, gST: int):
- ql.loader.gST = gST
+ ql.loader.gST = gST
- gBS = gST + EFI_SYSTEM_TABLE.sizeof() # boot services
- gRT = gBS + EFI_BOOT_SERVICES.sizeof() # runtime services
- gDS = gRT + EFI_RUNTIME_SERVICES.sizeof() # dxe services
- cfg = gDS + ds.EFI_DXE_SERVICES.sizeof() # configuration tables array
+ gBS = gST + EFI_SYSTEM_TABLE.sizeof() # boot services
+ gRT = gBS + EFI_BOOT_SERVICES.sizeof() # runtime services
+ gDS = gRT + EFI_RUNTIME_SERVICES.sizeof() # dxe services
+ cfg = gDS + ds.EFI_DXE_SERVICES.sizeof() # configuration tables array
- ql.log.info(f'Global tables:')
- ql.log.info(f' | gST {gST:#010x}')
- ql.log.info(f' | gBS {gBS:#010x}')
- ql.log.info(f' | gRT {gRT:#010x}')
- ql.log.info(f' | gDS {gDS:#010x}')
- ql.log.info(f'')
+ ql.log.info(f'Global tables:')
+ ql.log.info(f' | gST {gST:#010x}')
+ ql.log.info(f' | gBS {gBS:#010x}')
+ ql.log.info(f' | gRT {gRT:#010x}')
+ ql.log.info(f' | gDS {gDS:#010x}')
+ ql.log.info(f'')
- bs.initialize(ql, gBS)
- rt.initialize(ql, gRT)
- ds.initialize(ql, gDS)
+ bs.initialize(ql, gBS)
+ rt.initialize(ql, gRT)
+ ds.initialize(ql, gDS)
- instance = EFI_SYSTEM_TABLE()
- instance.RuntimeServices = gRT
- instance.BootServices = gBS
- instance.NumberOfTableEntries = 0
- instance.ConfigurationTable = cfg
+ instance = EFI_SYSTEM_TABLE()
+ instance.RuntimeServices = gRT
+ instance.BootServices = gBS
+ instance.NumberOfTableEntries = 0
+ instance.ConfigurationTable = cfg
- instance.saveTo(ql, gST)
+ instance.saveTo(ql, gST)
- install_configuration_table(context, "HOB_LIST", None)
- install_configuration_table(context, "DXE_SERVICE_TABLE", gDS)
+ install_configuration_table(context, "HOB_LIST", None)
+ install_configuration_table(context, "DXE_SERVICE_TABLE", gDS)
__all__ = [
- 'initialize'
+ 'initialize'
]
\ No newline at end of file
diff --git a/qiling/os/uefi/uefi.py b/qiling/os/uefi/uefi.py
index a3f481cf0..c44d032ad 100644
--- a/qiling/os/uefi/uefi.py
+++ b/qiling/os/uefi/uefi.py
@@ -19,214 +19,214 @@
from qiling.os.uefi.smm import SmmEnv
class QlOsUefi(QlOs):
- type = QL_OS.UEFI
+ type = QL_OS.UEFI
- def __init__(self, ql: Qiling):
- super().__init__(ql)
+ def __init__(self, ql: Qiling):
+ super().__init__(ql)
- self.entry_point = 0
- self.running_module: str
- self.smm: SmmEnv
- self.PE_RUN: bool
- self.heap: QlMemoryHeap # Will be initialized by the loader.
+ self.entry_point = 0
+ self.running_module: str
+ self.smm: SmmEnv
+ self.PE_RUN: bool
+ self.heap: QlMemoryHeap # Will be initialized by the loader.
- self.on_module_enter: MutableSequence[Callable[[str], bool]] = []
- self.on_module_exit: MutableSequence[Callable[[int], bool]] = []
+ self.on_module_enter: MutableSequence[Callable[[str], bool]] = []
+ self.on_module_exit: MutableSequence[Callable[[int], bool]] = []
- cc: QlCC = {
- 32: intel.cdecl,
- 64: intel.ms64
- }[ql.arch.bits](ql.arch)
+ cc: QlCC = {
+ 32: intel.cdecl,
+ 64: intel.ms64
+ }[ql.arch.bits](ql.arch)
- self.fcall = QlFunctionCall(ql, cc)
+ self.fcall = QlFunctionCall(ql, cc)
- def save(self):
- saved_state = super(QlOsUefi, self).save()
- saved_state['entry_point'] = self.entry_point
- return saved_state
+ def save(self):
+ saved_state = super(QlOsUefi, self).save()
+ saved_state['entry_point'] = self.entry_point
+ return saved_state
- def restore(self, saved_state):
- super(QlOsUefi, self).restore(saved_state)
- self.entry_point = saved_state['entry_point']
+ def restore(self, saved_state):
+ super(QlOsUefi, self).restore(saved_state)
+ self.entry_point = saved_state['entry_point']
- def process_fcall_params(self, targs: Iterable[TypedArg]) -> Sequence[Tuple[str, str]]:
- '''[override] Post-process function call arguments values to
- determine how to display them.
+ def process_fcall_params(self, targs: Iterable[TypedArg]) -> Sequence[Tuple[str, str]]:
+ '''[override] Post-process function call arguments values to
+ determine how to display them.
- Args:
- targs: an iterable of typed args (3-tuples: type, name, value)
+ Args:
+ targs: an iterable of typed args (3-tuples: type, name, value)
- Returns: a sequence of arguments (2-tuples: name, string representation of arg value)
- '''
+ Returns: a sequence of arguments (2-tuples: name, string representation of arg value)
+ '''
- def fallback(v):
- '''Use original processing method for other types.
- '''
+ def fallback(v):
+ '''Use original processing method for other types.
+ '''
- # the original method accepts a list and returns a list, so here we
- # craft a list containing one 3-tuple, and extracting the single element
- # the result list contains. that element is a 2-tuple, from which we
- # only need the value
- return super(QlOsUefi, self).process_fcall_params([(None, '', v)])[0][1]
+ # the original method accepts a list and returns a list, so here we
+ # craft a list containing one 3-tuple, and extracting the single element
+ # the result list contains. that element is a 2-tuple, from which we
+ # only need the value
+ return super(QlOsUefi, self).process_fcall_params([(None, '', v)])[0][1]
- ahandlers: Mapping[Any, Callable[[Any], str]] = {
- POINTER : lambda v: f'{v:#010x}' if v else 'NULL',
- STRING : lambda v: QlOsUtils.stringify(v),
- WSTRING : lambda v: f'L{QlOsUtils.stringify(v)}',
- GUID : lambda v: guids_db.get(v.upper(), v) if v else 'NULL'
- }
+ ahandlers: Mapping[Any, Callable[[Any], str]] = {
+ POINTER : lambda v: f'{v:#010x}' if v else 'NULL',
+ STRING : lambda v: QlOsUtils.stringify(v),
+ WSTRING : lambda v: f'L{QlOsUtils.stringify(v)}',
+ GUID : lambda v: guids_db.get(v.upper(), v) if v else 'NULL'
+ }
- return tuple((aname, ahandlers.get(atype, fallback)(avalue)) for atype, aname, avalue in targs)
+ return tuple((aname, ahandlers.get(atype, fallback)(avalue)) for atype, aname, avalue in targs)
- def notify_after_module_execution(self, nmodules: int) -> bool:
- """Callback fired after a module has finished executing successfully.
+ def notify_after_module_execution(self, nmodules: int) -> bool:
+ """Callback fired after a module has finished executing successfully.
- Args:
- nmodules: number of remaining modules to execute
+ Args:
+ nmodules: number of remaining modules to execute
- Returns: `True` if subsequent modules execution should be thwarted, `False` otherwise
- """
+ Returns: `True` if subsequent modules execution should be thwarted, `False` otherwise
+ """
- return bool(sum(callback(nmodules) for callback in self.on_module_exit))
+ return bool(sum(callback(nmodules) for callback in self.on_module_exit))
- def notify_before_module_execution(self, module: str) -> bool:
- """Callback fired before a module is about to start executing.
+ def notify_before_module_execution(self, module: str) -> bool:
+ """Callback fired before a module is about to start executing.
- Args:
- module: path of module to execute
+ Args:
+ module: path of module to execute
- Returns: `True` if module execution should be thwarted, `False` otherwise
- """
+ Returns: `True` if module execution should be thwarted, `False` otherwise
+ """
- return bool(sum(callback(module) for callback in self.on_module_enter))
+ return bool(sum(callback(module) for callback in self.on_module_enter))
- def emit_context(self):
- rgroups = (
- ((8, 'rax'), (8, 'r8'), (4, 'cs')),
- ((8, 'rbx'), (8, 'r9'), (4, 'ds')),
- ((8, 'rcx'), (8, 'r10'), (4, 'es')),
- ((8, 'rdx'), (8, 'r11'), (4, 'fs')),
- ((8, 'rsi'), (8, 'r12'), (4, 'gs')),
- ((8, 'rdi'), (8, 'r13'), (4, 'ss')),
- ((8, 'rsp'), (8, 'r14')),
- ((8, 'rbp'), (8, 'r15')),
- ((8, 'rip'), )
- )
+ def emit_context(self):
+ rgroups = (
+ ((8, 'rax'), (8, 'r8'), (4, 'cs')),
+ ((8, 'rbx'), (8, 'r9'), (4, 'ds')),
+ ((8, 'rcx'), (8, 'r10'), (4, 'es')),
+ ((8, 'rdx'), (8, 'r11'), (4, 'fs')),
+ ((8, 'rsi'), (8, 'r12'), (4, 'gs')),
+ ((8, 'rdi'), (8, 'r13'), (4, 'ss')),
+ ((8, 'rsp'), (8, 'r14')),
+ ((8, 'rbp'), (8, 'r15')),
+ ((8, 'rip'), )
+ )
- p = re.compile(r'^((?:00)+)')
+ p = re.compile(r'^((?:00)+)')
- def __emit_reg(size: int, reg: str):
- val = f'{self.ql.arch.regs.read(reg):0{size * 2}x}'
- padded = p.sub("\x1b[90m\\1\x1b[39m", val, 1)
+ def __emit_reg(size: int, reg: str):
+ val = f'{self.ql.arch.regs.read(reg):0{size * 2}x}'
+ padded = p.sub("\x1b[90m\\1\x1b[39m", val, 1)
- return f'{reg:3s} = {padded}'
+ return f'{reg:3s} = {padded}'
- self.ql.log.error(f'CPU Context:')
+ self.ql.log.error(f'CPU Context:')
- for regs in rgroups:
- self.ql.log.error(f'{" | ".join(__emit_reg(size, reg) for size, reg in regs)}')
+ for regs in rgroups:
+ self.ql.log.error(f'{" | ".join(__emit_reg(size, reg) for size, reg in regs)}')
- self.ql.log.error(f'')
+ self.ql.log.error(f'')
- def emit_hexdump(self, address: int, data: bytearray, num_cols: int = 16):
- self.ql.log.error('Hexdump:')
+ def emit_hexdump(self, address: int, data: bytearray, num_cols: int = 16):
+ self.ql.log.error('Hexdump:')
- # align hexdump to numbers of columns
- pre_padding = [None] * (address % num_cols)
- post_padding = [None] * (num_cols - len(pre_padding))
- chars = pre_padding + list(data) + post_padding
- address = address & ~(num_cols - 1)
+ # align hexdump to numbers of columns
+ pre_padding = [None] * (address % num_cols)
+ post_padding = [None] * (num_cols - len(pre_padding))
+ chars = pre_padding + list(data) + post_padding
+ address = address & ~(num_cols - 1)
- for i in range(0, len(chars), num_cols):
- hexdump = ' '.join(f' ' if ch is None else f'{ch:02x}' for ch in chars[i: i + num_cols])
- self.ql.log.error(f'{address + i:08x} : {hexdump}')
+ for i in range(0, len(chars), num_cols):
+ hexdump = ' '.join(f' ' if ch is None else f'{ch:02x}' for ch in chars[i: i + num_cols])
+ self.ql.log.error(f'{address + i:08x} : {hexdump}')
- self.ql.log.error(f'')
+ self.ql.log.error(f'')
- def emit_disasm(self, address: int, data: bytearray, num_insns: int = 8):
- md = self.ql.arch.disassembler
+ def emit_disasm(self, address: int, data: bytearray, num_insns: int = 8):
+ md = self.ql.arch.disassembler
- self.ql.log.error('Disassembly:')
+ self.ql.log.error('Disassembly:')
- for insn in tuple(md.disasm(data, address))[:num_insns]:
- self.ql.log.error(f'{insn.address:08x} : {insn.bytes.hex():28s} {insn.mnemonic:10s} {insn.op_str:s}')
+ for insn in tuple(md.disasm(data, address))[:num_insns]:
+ self.ql.log.error(f'{insn.address:08x} : {insn.bytes.hex():28s} {insn.mnemonic:10s} {insn.op_str:s}')
- self.ql.log.error(f'')
+ self.ql.log.error(f'')
- def emit_stack(self, nitems: int = 4):
- self.ql.log.error('Stack:')
+ def emit_stack(self, nitems: int = 4):
+ self.ql.log.error('Stack:')
- for i in range(-nitems, nitems + 1):
- offset = i * self.ql.arch.pointersize
+ for i in range(-nitems, nitems + 1):
+ offset = i * self.ql.arch.pointersize
- try:
- item = self.ql.arch.stack_read(offset)
- except UcError:
- data = '(unavailable)'
- else:
- data = f'{item:0{self.ql.arch.pointersize * 2}x}'
+ try:
+ item = self.ql.arch.stack_read(offset)
+ except UcError:
+ data = '(unavailable)'
+ else:
+ data = f'{item:0{self.ql.arch.pointersize * 2}x}'
- self.ql.log.error(f'{self.ql.arch.regs.arch_sp + offset:08x} : {data}{" <=" if i == 0 else ""}')
+ self.ql.log.error(f'{self.ql.arch.regs.arch_sp + offset:08x} : {data}{" <=" if i == 0 else ""}')
- self.ql.log.error('')
+ self.ql.log.error('')
- def emu_error(self):
- pc = self.ql.arch.regs.arch_pc
+ def emu_error(self):
+ pc = self.ql.arch.regs.arch_pc
- try:
- data = self.ql.mem.read(pc, size=64)
- except UcError:
- pc_info = ' (unreachable)'
- else:
- self.emit_context()
- self.emit_hexdump(pc, data)
- self.emit_disasm(pc, data)
+ try:
+ data = self.ql.mem.read(pc, size=64)
+ except UcError:
+ pc_info = ' (unreachable)'
+ else:
+ self.emit_context()
+ self.emit_hexdump(pc, data)
+ self.emit_disasm(pc, data)
- containing_image = self.ql.loader.find_containing_image(pc)
- pc_info = f' ({containing_image.path} + {pc - containing_image.base:#x})' if containing_image else ''
- finally:
- self.ql.log.error(f'PC = {pc:#010x}{pc_info}')
- self.ql.log.error(f'')
+ containing_image = self.ql.loader.find_containing_image(pc)
+ pc_info = f' ({containing_image.path} + {pc - containing_image.base:#x})' if containing_image else ''
+ finally:
+ self.ql.log.error(f'PC = {pc:#010x}{pc_info}')
+ self.ql.log.error(f'')
- self.emit_stack()
+ self.emit_stack()
- self.ql.log.error(f'Memory map:')
- for info_line in self.ql.mem.get_formatted_mapinfo():
- self.ql.log.error(info_line)
+ self.ql.log.error(f'Memory map:')
+ for info_line in self.ql.mem.get_formatted_mapinfo():
+ self.ql.log.error(info_line)
- def set_api(self, target: str, handler: Callable, intercept: QL_INTERCEPT = QL_INTERCEPT.CALL):
- super().set_api(f'hook_{target}', handler, intercept)
+ def set_api(self, target: str, handler: Callable, intercept: QL_INTERCEPT = QL_INTERCEPT.CALL):
+ super().set_api(f'hook_{target}', handler, intercept)
- def run(self):
- # TODO: this is not the right place for this
- self.smm = SmmEnv(self.ql)
+ def run(self):
+ # TODO: this is not the right place for this
+ self.smm = SmmEnv(self.ql)
- self.notify_before_module_execution(self.running_module)
+ self.notify_before_module_execution(self.running_module)
- if self.ql.entry_point is not None:
- self.ql.loader.entry_point = self.ql.entry_point
+ if self.ql.entry_point is not None:
+ self.ql.loader.entry_point = self.ql.entry_point
- if self.ql.exit_point is not None:
- self.exit_point = self.ql.exit_point
+ if self.ql.exit_point is not None:
+ self.exit_point = self.ql.exit_point
- try:
- self.PE_RUN = True
+ try:
+ self.PE_RUN = True
- self.ql.emu_start(self.ql.loader.entry_point, self.exit_point, self.ql.timeout, self.ql.count)
- except KeyboardInterrupt:
- self.ql.log.critical(f'Execution interrupted by user')
+ self.ql.emu_start(self.ql.loader.entry_point, self.exit_point, self.ql.timeout, self.ql.count)
+ except KeyboardInterrupt:
+ self.ql.log.critical(f'Execution interrupted by user')
- except UcError:
- self.emu_error()
- raise
+ except UcError:
+ self.emu_error()
+ raise
- def stop(self) -> None:
- self.ql.emu_stop()
- self.PE_RUN = False
+ def stop(self) -> None:
+ self.ql.emu_stop()
+ self.PE_RUN = False
diff --git a/qiling/os/uefi/utils.py b/qiling/os/uefi/utils.py
index fe3576749..3c02e7499 100644
--- a/qiling/os/uefi/utils.py
+++ b/qiling/os/uefi/utils.py
@@ -13,103 +13,103 @@
from qiling.os.uefi.UefiBaseType import EFI_GUID
def signal_event(ql: Qiling, event_id: int) -> None:
- event = ql.loader.events[event_id]
+ event = ql.loader.events[event_id]
- if not event["Set"]:
- event["Set"] = True
- notify_func = event["NotifyFunction"]
- callback_args = event["CallbackArgs"]
+ if not event["Set"]:
+ event["Set"] = True
+ notify_func = event["NotifyFunction"]
+ callback_args = event["CallbackArgs"]
- ql.loader.notify_list.append((event_id, notify_func, callback_args))
+ ql.loader.notify_list.append((event_id, notify_func, callback_args))
def execute_protocol_notifications(ql: Qiling, from_hook: bool = False) -> bool:
- if not ql.loader.notify_list:
- return False
+ if not ql.loader.notify_list:
+ return False
- next_hook = ql.loader.context.heap.alloc(ql.arch.pointersize)
+ next_hook = ql.loader.context.heap.alloc(ql.arch.pointersize)
- def __notify_next(ql: Qiling):
- # discard previous callback's shadow space
- ql.arch.regs.arch_sp += (4 * ql.arch.pointersize)
+ def __notify_next(ql: Qiling):
+ # discard previous callback's shadow space
+ ql.arch.regs.arch_sp += (4 * ql.arch.pointersize)
- if ql.loader.notify_list:
- event_id, notify_func, callback_args = ql.loader.notify_list.pop(0)
- ql.log.info(f'Notify event: id = {event_id}, (*{notify_func:#x})({", ".join(f"{a:#x}" for a in callback_args)})')
+ if ql.loader.notify_list:
+ event_id, notify_func, callback_args = ql.loader.notify_list.pop(0)
+ ql.log.info(f'Notify event: id = {event_id}, (*{notify_func:#x})({", ".join(f"{a:#x}" for a in callback_args)})')
- ql.loader.call_function(notify_func, callback_args, next_hook)
- else:
- ql.log.info(f'Notify event: done')
+ ql.loader.call_function(notify_func, callback_args, next_hook)
+ else:
+ ql.log.info(f'Notify event: done')
- # the last item on the list has been notified; tear down this hook
- ql.loader.context.heap.free(next_hook)
- hret.remove()
+ # the last item on the list has been notified; tear down this hook
+ ql.loader.context.heap.free(next_hook)
+ hret.remove()
- ql.arch.regs.rax = EFI_SUCCESS
- ql.arch.regs.arch_pc = ql.stack_pop()
+ ql.arch.regs.rax = EFI_SUCCESS
+ ql.arch.regs.arch_pc = ql.stack_pop()
- hret = ql.hook_address(__notify_next, next_hook)
+ hret = ql.hook_address(__notify_next, next_hook)
- # __notify_next unwinds the previous callback shadow space allocated by call_function. however, on its first invocation
- # there is no such shadow space. to maintain stack consistency we set here a bogus shadow space that may be discarded
- # safely
- ql.arch.regs.arch_sp -= (4 * ql.arch.pointersize)
+ # __notify_next unwinds the previous callback shadow space allocated by call_function. however, on its first invocation
+ # there is no such shadow space. to maintain stack consistency we set here a bogus shadow space that may be discarded
+ # safely
+ ql.arch.regs.arch_sp -= (4 * ql.arch.pointersize)
- # To avoid having two versions of the code the first notify function will also be called from the __notify_next hook.
- if from_hook:
- ql.stack_push(next_hook)
- else:
- ql.stack_push(ql.loader.context.end_of_execution_ptr)
- ql.arch.regs.arch_pc = next_hook
+ # To avoid having two versions of the code the first notify function will also be called from the __notify_next hook.
+ if from_hook:
+ ql.stack_push(next_hook)
+ else:
+ ql.stack_push(ql.loader.context.end_of_execution_ptr)
+ ql.arch.regs.arch_pc = next_hook
- return True
+ return True
def ptr_read8(ql: Qiling, addr: int) -> int:
- """Read BYTE data from a pointer
- """
+ """Read BYTE data from a pointer
+ """
- return ql.mem.read_ptr(addr, 1)
+ return ql.mem.read_ptr(addr, 1)
def ptr_write8(ql: Qiling, addr: int, val: int) -> None:
- """Write BYTE data to a pointer
- """
+ """Write BYTE data to a pointer
+ """
- ql.mem.write_ptr(addr, val, 1)
+ ql.mem.write_ptr(addr, val, 1)
def ptr_read16(ql: Qiling, addr: int) -> int:
- """Read WORD data from a pointer
- """
+ """Read WORD data from a pointer
+ """
- return ql.mem.read_ptr(addr, 2)
+ return ql.mem.read_ptr(addr, 2)
def ptr_write16(ql: Qiling, addr: int, val: int) -> None:
- """Write WORD data to a pointer
- """
+ """Write WORD data to a pointer
+ """
- ql.mem.write_ptr(addr, val, 2)
+ ql.mem.write_ptr(addr, val, 2)
def ptr_read32(ql: Qiling, addr: int) -> int:
- """Read DWORD data from a pointer
- """
+ """Read DWORD data from a pointer
+ """
- return ql.mem.read_ptr(addr, 4)
+ return ql.mem.read_ptr(addr, 4)
def ptr_write32(ql: Qiling, addr: int, val: int) -> None:
- """Write DWORD data to a pointer
- """
+ """Write DWORD data to a pointer
+ """
- ql.mem.write_ptr(addr, val, 4)
+ ql.mem.write_ptr(addr, val, 4)
def ptr_read64(ql: Qiling, addr: int) -> int:
- """Read QWORD data from a pointer
- """
+ """Read QWORD data from a pointer
+ """
- return ql.mem.read_ptr(addr, 8)
+ return ql.mem.read_ptr(addr, 8)
def ptr_write64(ql: Qiling, addr: int, val: int) -> None:
- """Write QWORD data to a pointer
- """
+ """Write QWORD data to a pointer
+ """
- ql.mem.write_ptr(addr, val, 8)
+ ql.mem.write_ptr(addr, val, 8)
# backward comptability
read_int8 = ptr_read8
@@ -122,68 +122,68 @@ def ptr_write64(ql: Qiling, addr: int, val: int) -> None:
write_int64 = ptr_write64
def init_struct(ql: Qiling, base: int, descriptor: Mapping):
- struct_class = descriptor['struct']
- struct_fields = descriptor.get('fields', [])
+ struct_class = descriptor['struct']
+ struct_fields = descriptor.get('fields', [])
- isntance = struct_class()
- ql.log.info(f'Initializing {struct_class.__name__}')
+ isntance = struct_class()
+ ql.log.info(f'Initializing {struct_class.__name__}')
- for name, value in struct_fields:
- if value is not None:
- # a method: hook this field
- if callable(value):
- p = base + struct_class.offsetof(name)
+ for name, value in struct_fields:
+ if value is not None:
+ # a method: hook this field
+ if callable(value):
+ p = base + struct_class.offsetof(name)
- setattr(isntance, name, p)
- ql.hook_address(value, p)
+ setattr(isntance, name, p)
+ ql.hook_address(value, p)
- ql.log.info(f' | {name:36s} {p:#010x}')
+ ql.log.info(f' | {name:36s} {p:#010x}')
- # a value: set it
- else:
- setattr(isntance, name, value)
+ # a value: set it
+ else:
+ setattr(isntance, name, value)
- ql.log.info(f'')
+ ql.log.info(f'')
- return isntance
+ return isntance
def str_to_guid(guid: str) -> EFI_GUID:
- """Construct an EFI_GUID structure out of a plain GUID string.
- """
+ """Construct an EFI_GUID structure out of a plain GUID string.
+ """
- buff = UUID(hex=guid).bytes_le
+ buff = UUID(hex=guid).bytes_le
- return EFI_GUID.from_buffer_copy(buff)
+ return EFI_GUID.from_buffer_copy(buff)
def CompareGuid(guid1: EFI_GUID, guid2: EFI_GUID) -> bool:
- return bytes(guid1) == bytes(guid2)
+ return bytes(guid1) == bytes(guid2)
def install_configuration_table(context, key: str, table: Optional[int]):
- """Create a new Configuration Table entry and add it to the list.
+ """Create a new Configuration Table entry and add it to the list.
- Args:
- ql : Qiling instance
- key : profile section name that holds the entry data
- table : address of configuration table data; if None, data will be read
- from profile section into memory
- """
+ Args:
+ ql : Qiling instance
+ key : profile section name that holds the entry data
+ table : address of configuration table data; if None, data will be read
+ from profile section into memory
+ """
- cfgtable = context.ql.os.profile[key]
- guid = cfgtable['Guid']
+ cfgtable = context.ql.os.profile[key]
+ guid = cfgtable['Guid']
- # if pointer to table data was not specified, load table data
- # from profile and have table pointing to it
- if table is None:
- data = binascii.unhexlify(cfgtable['TableData'])
- table = context.conf_table_data_next_ptr
+ # if pointer to table data was not specified, load table data
+ # from profile and have table pointing to it
+ if table is None:
+ data = binascii.unhexlify(cfgtable['TableData'])
+ table = context.conf_table_data_next_ptr
- context.ql.mem.write(table, data)
- context.conf_table_data_next_ptr += len(data)
+ context.ql.mem.write(table, data)
+ context.conf_table_data_next_ptr += len(data)
- context.conftable.install(guid, table)
+ context.conftable.install(guid, table)
def GetEfiConfigurationTable(context, guid: str) -> Optional[int]:
- """Find a configuration table by its GUID.
- """
+ """Find a configuration table by its GUID.
+ """
- return context.conftable.get_vendor_table(guid)
\ No newline at end of file
+ return context.conftable.get_vendor_table(guid)
\ No newline at end of file
diff --git a/qiling/os/windows/dlls/kernel32/timezoneapi.py b/qiling/os/windows/dlls/kernel32/timezoneapi.py
index b5af67ded..1fcf6835b 100644
--- a/qiling/os/windows/dlls/kernel32/timezoneapi.py
+++ b/qiling/os/windows/dlls/kernel32/timezoneapi.py
@@ -12,8 +12,8 @@
# [out] LPTIME_ZONE_INFORMATION lpTimeZoneInformation
# );
@winsdkapi(cc=STDCALL, params={
- 'lpTimeZoneInformation' : LPTIME_ZONE_INFORMATION
+ 'lpTimeZoneInformation' : LPTIME_ZONE_INFORMATION
})
def hook_GetTimeZoneInformation(ql: Qiling, address: int, params):
# TODO: implement this later. fail for now
- return TIME_ZONE_ID_INVALID
+ return TIME_ZONE_ID_INVALID
diff --git a/qiling/os/windows/dlls/user32.py b/qiling/os/windows/dlls/user32.py
index 3c816646e..0e0e04039 100644
--- a/qiling/os/windows/dlls/user32.py
+++ b/qiling/os/windows/dlls/user32.py
@@ -96,10 +96,10 @@ def hook_DialogBoxParamA(ql: Qiling, address: int, params):
return 0
# UINT GetDlgItemTextA(
-# HWND hDlg,
-# int nIDDlgItem,
-# LPSTR lpString,
-# int cchMax
+# HWND hDlg,
+# int nIDDlgItem,
+# LPSTR lpString,
+# int cchMax
# );
@winsdkapi(cc=STDCALL, params={
'hDlg' : HWND,
diff --git a/qiling/os/windows/structs.py b/qiling/os/windows/structs.py
index 170f534bc..71aed2d74 100644
--- a/qiling/os/windows/structs.py
+++ b/qiling/os/windows/structs.py
@@ -983,7 +983,7 @@ class LdrDataTableEntry(Struct):
('LoadReason', ctypes.c_uint32),
('ImplicitPathOptions', native_type),
('ReferenceCount', native_type),
- # 1607+
+ # 1607+
('DependentLoadFlags', native_type),
# 1703+
('SigningLevel', ctypes.c_uint8)
diff --git a/qiling/utils.py b/qiling/utils.py
index b3b048019..14528b689 100644
--- a/qiling/utils.py
+++ b/qiling/utils.py
@@ -449,14 +449,14 @@ def verify_ret(ql: 'Qiling', err):
if ql.arch.type == QL_ARCH.X8664: # Win64
if ql.os.init_sp == ql.arch.regs.arch_sp or ql.os.init_sp + 8 == ql.arch.regs.arch_sp or ql.os.init_sp + 0x10 == ql.arch.regs.arch_sp: # FIXME
- # 0x11626 c3 ret
+ # 0x11626 c3 ret
# print("OK, stack balanced!")
pass
else:
raise
else: # Win32
if ql.os.init_sp + 12 == ql.arch.regs.arch_sp: # 12 = 8 + 4
- # 0x114dd c2 08 00 ret 8
+ # 0x114dd c2 08 00 ret 8
pass
else:
raise
diff --git a/tests/test_qltool.py b/tests/test_qltool.py
index 8b85c9dc4..0640336b5 100644
--- a/tests/test_qltool.py
+++ b/tests/test_qltool.py
@@ -17,9 +17,9 @@ def test_qltool_exec_args(self):
p = subprocess.Popen(create, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in iter(p.stdout.readline, b''):
self.stdout = line
-
+
self.assertEqual(b'arg 2 test3\n', self.stdout)
-
+
def test_qltool_shellcode(self):
create = [sys.executable, '../qltool', 'code', '--os','linux','--arch', 'x86', '--format', 'asm', '-f', '../examples/shellcodes/lin32_execve.asm']