angr.analyses.decompiler.known_patterns.context

PatternContext: the architecture / platform / language facts a KnownPattern template needs to instantiate itself for a given binary.

A pattern is defined once as a KnownPatternTemplate whose build(ctx) computes concrete field offsets, load sizes, and return types from a PatternContext, so a single definition covers 32- and 64-bit, libstdc++ and MSVC, etc.

angr.analyses.decompiler.known_patterns.context.size_t_typename(bits)

The C spelling of size_t for a given word width.

Return type:

str

Parameters:

bits (int)

angr.analyses.decompiler.known_patterns.context.detect_linux_kernel_object(project)

Whether the main object is a Linux kernel module or the kernel image.

Sections are checked first because they are the cheap and decisive signal: modpost emits .modinfo and .gnu.linkonce.this_module into every .ko, and they survive stripping. The __ksymtab/__kcrctab symbol scan additionally catches a vmlinux and modules whose section names were renamed.

Return type:

bool

Parameters:

project (Project)

angr.analyses.decompiler.known_patterns.context.detect_windows_kernel_driver(project)

Whether the main object is a Windows kernel-mode driver, i.e. imports the kernel executive / HAL / a kernel-mode port or class library instead of the user-mode Win32 DLLs.

Return type:

bool

Parameters:

project (Project)

angr.analyses.decompiler.known_patterns.context.detect_cxx_runtime(project)

Identify the C++ standard-library runtime: "msvc", "libstdcxx", or None. Mirrors the old is_cpp_binary / is_msvc_cpp_binary heuristics: dependency names first, then mangled-symbol evidence (mingw PEs link libstdc++ and use its layouts even though they are PEs), then, for statically linked, stripped binaries that carry neither, RTTI type descriptors embedded in data sections.

Return type:

str | None

Parameters:

project (Project)

class angr.analyses.decompiler.known_patterns.context.PatternContext

Bases: object

Target facts used to instantiate pattern templates.

The last two fields are binary evidence: facts about what kind of program this is, used by gating to switch whole pattern families on for targets where the idioms are certain to appear and off everywhere else.

arch_name: str
bits: int
ptr_size: int
platform: str | None
cxx_runtime: str | None
is_cpp: bool
is_linux_kernel_object: bool = False
is_windows_kernel_driver: bool = False
classmethod from_project(project)
Return type:

PatternContext

Parameters:

project (Project)

word(n)

Byte offset of the n-th pointer-word field.

Return type:

int

Parameters:

n (int)

property word_size: int

Load size (bytes) of a pointer / size_t field.

property language: str
__init__(arch_name, bits, ptr_size, platform, cxx_runtime, is_cpp, is_linux_kernel_object=False, is_windows_kernel_driver=False)
Parameters:
  • arch_name (str)

  • bits (int)

  • ptr_size (int)

  • platform (str | None)

  • cxx_runtime (str | None)

  • is_cpp (bool)

  • is_linux_kernel_object (bool)

  • is_windows_kernel_driver (bool)

Return type:

None