NAME
Disassemble::X86::MemRegion - Represent a region of memory
SYNOPSIS
my
$mem
= Disassemble::X86::MemRegion->new(
mem
=>
$data
);
$mem
->get_string(
$pos
),
"\n"
;
DESCRIPTION
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.
METHODS
new
$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
$data
=
$mem
->mem();
Returns the contents of the memory region as a single scalar value.
start
$start
=
$mem
->start();
Returns the starting address of the region.
end
$end
=
$mem
->end();
Returns the ending address of the region, which is one plus the last valid address.
contains
if
(
$mem
->contains(
$addr
) ) {
...
}
Returns true if the given address is within the memory region.
get_byte
$val
=
$mem
->get_byte(
$pos
);
Returns a byte from position $pos
as an integer value. Returns undef
if position is invalid.
get_word
$val
=
$mem
->get_word(
$pos
);
Returns a 2-byte little-endian integer from $pos
, or undef
if position is invalid.
get_long
$val
=
$mem
->get_long(
$pos
);
Returns a 4-byte little-endian integer from $pos
, or undef
if position is invalid.
get_string
$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.
get_string_lenbyte
$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.
get_string_lenword
$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.
LIMITATIONS
Memory is read-only.
The entire memory region must be present in memory.
SEE ALSO
AUTHOR
Bob Mathews <bobmathews@alumni.calpoly.edu>
COPYRIGHT
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.