class Cradare2::DSL::Types

Overview

DSL for defining, inspecting, and decoding custom binary structures using radare2's pf and type engine.

Defined in:

cradare2/dsl/types.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(client : Client) #

[View source]

Instance Method Detail

def define_format(name : String, format : String, field_names : Array(String) = [] of String) : self #

Registers a custom print format (pf.<name> <format> <fields...>).

Format specifiers:

  • b : uint8, byte
  • w : uint16, word
  • d : uint32, dword
  • q : uint64, qword
  • f : float (32-bit)
  • F : double (64-bit)
  • p : pointer (architecture bits)
  • z : null-terminated string
  • x : hex pairs

[View source]
def define_struct(name : String, fields : Hash(String, String)) : self #

Convenience helper to define a struct using a mapping of Field Name => Format specifier.


[View source]
def define_struct(name : String, fields : Array(Tuple(String, String))) : self #

Convenience helper to define a struct using an array of tuples ({format, field_name} or {field_name, format}).


[View source]
def delete_format(name : String) : self #

Deletes a registered format (pf.-<name>).


[View source]
def format(name : String) : String | Nil #

Returns the registered format definition for a named format, or nil if not defined (pf.<name>).


[View source]
def parse_c_definition(c_code : String) : self #

Defines a C typedef, struct, or union in radare2 (td "<c_code>").


[View source]
def parse_c_header(header_path : String) : self #

Loads C header declarations into radare2 (to <path>).


[View source]
def print_format(name : String, address : Address) : Hash(String, JSON::Any) #

Decodes and prints formatted struct at address into a structured dictionary of Field => JSON::Any (pfj.<name> @ <addr>).


[View source]
def register_godot_formats! : self #

Registers all standard Godot 4.x GDExtension print formats (pf.godot_*).


[View source]