Disassemble::X86::MemRegion - Represent a region of memory
use Disassemble::X86::MemRegion; my $mem = Disassemble::X86::MemRegion->new( mem => $data ); print $mem->get_string($pos), "\n";
Represents a region of memory. Provides methods for extracting parts of the memory. Since this module is designed with the Intel x86 architecture in mind, it uses the little-endian byte ordering wherever appropriate.
$mem = Disassemble::X86::MemRegion->new( mem => $data, start => $addr, );
Create a new memory region object. The mem parameter is a scalar value which gives the contents of the memory region. If the optional start parameter is present, it gives the starting address of the region. Otherwise, 0 is used.
mem
start
$data = $mem->mem();
Returns the contents of the memory region as a single scalar value.
$start = $mem->start();
Returns the starting address of the region.
$end = $mem->end();
Returns the ending address of the region, which is one plus the last valid address.
if ( $mem->contains($addr) ) { ... }
Returns true if the given address is within the memory region.
$val = $mem->get_byte($pos);
Returns a byte from position $pos as an integer value. Returns undef if position is invalid.
$pos
undef
$val = $mem->get_word($pos);
Returns a 2-byte little-endian integer from $pos, or undef if position is invalid.
$val = $mem->get_long($pos);
Returns a 4-byte little-endian integer from $pos, or undef if position is invalid.
$str = $mem->get_string($pos, $maxlen);
Extracts and returns a null-terminated (C style) string from the memory region starting at position $pos. The null terminator is not included in the return value. Returns undef if the starting position is outside the memory region. The $maxlen parameter is optional. If present, it gives the maximum length of the string returned.
$maxlen
$str = $mem->get_string_lenbyte($pos);
Fetches a single byte from memory address $pos. Using that as a length byte, extracts and returns a string containing that many bytes. Returns undef if position is invalid.
$str = $mem->get_string_lenword($pos);
Fetches a two-byte little-endian word starting at $pos. Extracts and returns a string containing that many bytes. Returns undef if position is invalid.
Memory is read-only.
The entire memory region must be present in memory.
Disassemble::X86
Bob Mathews <bobmathews@alumni.calpoly.edu>
Copyright (c) 2002 Bob Mathews. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Disassemble::X86, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Disassemble::X86
CPAN shell
perl -MCPAN -e shell install Disassemble::X86
For more information on module installation, please visit the detailed CPAN module installation guide.