class Cradare2::DSL::Memory

Overview

DSL for memory inspection, reading, writing, and byte pattern searching.

Defined in:

cradare2/dsl/memory.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(client : Client) #

[View source]

Instance Method Detail

def hexdiff(address1 : Address, address2 : Address, size : Int32 = 64) : String #

Compares memory between two addresses and returns diff output.


[View source]
def hexdump(address : Address | Nil = nil, size : Int32 = 64) : String #

Returns formatted hexdump text for human inspection.


[View source]
def read(address : Address, size : Int32) : Bytes #

Reads raw bytes from address as a Crystal Bytes slice.


[View source]
def read_bytes(address : Address, size : Int32) : Bytes #

Alias for #read.


[View source]
def read_cstring(address : Address, max_len : Int32 = 256) : String #

Reads a null-terminated UTF-8 C-string from memory with fallback to byte search.


[View source]
def read_f32(address : Address, format : IO::ByteFormat = IO::ByteFormat::LittleEndian) : Float32 #

Reads floating-point numbers.


[View source]
def read_f32_array(address : Address, count : Int32, format : IO::ByteFormat = IO::ByteFormat::LittleEndian) : Array(Float32) #

Reads an array of 32-bit IEEE 754 floating point numbers.


[View source]
def read_f64(address : Address, format : IO::ByteFormat = IO::ByteFormat::LittleEndian) : Float64 #

[View source]
def read_hex(address : Address, size : Int32) : String #

Reads bytes formatted as a continuous hex string.


[View source]
def read_i128(address : Address, format : IO::ByteFormat = IO::ByteFormat::LittleEndian) : Int128 #

[View source]
def read_i16(address : Address, format : IO::ByteFormat = IO::ByteFormat::LittleEndian) : Int16 #

[View source]
def read_i32(address : Address, format : IO::ByteFormat = IO::ByteFormat::LittleEndian) : Int32 #

[View source]
def read_i64(address : Address, format : IO::ByteFormat = IO::ByteFormat::LittleEndian) : Int64 #

[View source]
def read_i8(address : Address) : Int8 #

Reads signed integers of various bit widths.


[View source]
def read_pointer32_array(address : Address, count : Int32, format : IO::ByteFormat = IO::ByteFormat::LittleEndian) : Array(UInt32) #

Reads an array of 32-bit pointers (ideal for 32-bit targets like PS2 MIPS).


[View source]
def read_pointer_array(address : Address, count : Int32) : Array(UInt64) #

Reads an array of 64-bit pointers (ideal for vtables, dispatch tables, and StringName literals).


[View source]
def read_qword(address : Address, format : IO::ByteFormat = IO::ByteFormat::LittleEndian) : UInt128 #

Alias for read_u128.


[View source]
def read_string(address : Address, max_len : Int32 | Nil = nil) : String #

Reads a null-terminated C string from memory address.


[View source]
def read_u128(address : Address, format : IO::ByteFormat = IO::ByteFormat::LittleEndian) : UInt128 #

Reads a 128-bit unsigned integer (Emotion Engine QWORD).


[View source]
def read_u16(address : Address, format : IO::ByteFormat = IO::ByteFormat::LittleEndian) : UInt16 #

[View source]
def read_u32(address : Address, format : IO::ByteFormat = IO::ByteFormat::LittleEndian) : UInt32 #

[View source]
def read_u32_array(address : Address, count : Int32, format : IO::ByteFormat = IO::ByteFormat::LittleEndian) : Array(UInt32) #

Reads an array of 32-bit unsigned integers.


[View source]
def read_u64(address : Address, format : IO::ByteFormat = IO::ByteFormat::LittleEndian) : UInt64 #

[View source]
def read_u64_array(address : Address, count : Int32, format : IO::ByteFormat = IO::ByteFormat::LittleEndian) : Array(UInt64) #

Reads an array of 64-bit unsigned integers.


[View source]
def read_u8(address : Address) : UInt8 #

Reads unsigned integers of various bit widths.


[View source]
def read_u8_array(address : Address, count : Int32) : Array(UInt8) #

Reads an array of 8-bit unsigned integers.


[View source]
def search_bytes(bytes : Bytes) : Array(UInt64) #

Searches memory for a byte pattern (e.g. Bytes[0x48, 0x89]).


[View source]
def search_hex(hex_pattern : String) : Array(UInt64) #

Searches memory for a hex string pattern, allowing optional spaces (e.g. "48 89 5c 24").


[View source]
def search_string(query : String) : Array(UInt64) #

Searches memory for a string query.


[View source]
def write(address : Address, bytes : Bytes) : self #

Writes a slice of bytes to the given address using wx.


[View source]
def write_hex(address : Address, hex : String) : self #

Writes hex characters directly (e.g. "909090" for NOPs).


[View source]
def write_i128(address : Address, value : Int128, format : IO::ByteFormat = IO::ByteFormat::LittleEndian) : self #

[View source]
def write_i16(address : Address, value : Int16) : self #

[View source]
def write_i32(address : Address, value : Int32) : self #

[View source]
def write_i64(address : Address, value : Int64) : self #

[View source]
def write_i8(address : Address, value : Int8) : self #

[View source]
def write_qword(address : Address, value : UInt128, format : IO::ByteFormat = IO::ByteFormat::LittleEndian) : self #

Alias for write_u128.


[View source]
def write_string(address : Address, string : String) : self #

Writes a string to the given address.


[View source]
def write_u128(address : Address, value : UInt128, format : IO::ByteFormat = IO::ByteFormat::LittleEndian) : self #

Writes a 128-bit unsigned integer (Emotion Engine QWORD).


[View source]
def write_u16(address : Address, value : UInt16) : self #

Writes a 16-bit unsigned integer.


[View source]
def write_u32(address : Address, value : UInt32) : self #

Writes a 32-bit integer.


[View source]
def write_u64(address : Address, value : UInt64) : self #

Writes a 64-bit integer.


[View source]
def write_u8(address : Address, value : UInt8) : self #

Writes an 8-bit unsigned integer.


[View source]